Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit tests for the REV vCard Property for ContactDataO...
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         if (!wxFileExists(Filename)){
24         
25                 return CONTACTLOAD_FILEMISSING;
26         
27         }
28         
29         wxFile ContactFile;
30         
31         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
32         
33                 return CONTACTLOAD_FILEERROR;
34         
35         }
36         
37         // Check that the vCard is a valid vCard 4.0 file.
39         vCard vCard4FormatCheck;
40         
41         vCard4FormatCheck.LoadFile(Filename);
42         
43         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
44         
45                 return CONTACTLOAD_FILEINVALIDFORMAT;
46         
47         }
49         // Check that the vCard meets the base specification.
50         
51         if (!vCard4FormatCheck.MeetBaseSpecification()){
52         
53                 return CONTACTLOAD_FILEBASESPECFAIL;
54         
55         }
56         
57         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
58         
59         std::map<int, wxString> ContactFileLines;
61         int ContactLineSeek = 0;
63         while (wSTContactFileLines.HasMoreTokens() == TRUE){
65                 wxString ContactLine = wSTContactFileLines.GetNextToken();
66                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
67                 ContactLineSeek++;              
68         
69         }
70         
71         wxString wxSPropertyNextLine;
72         
73         bool ExtraLineSeek = TRUE;
74         bool QuoteMode = FALSE;
75         bool PropertyFind = TRUE;
76         bool KindProcessed = FALSE;
77         bool NameProcessed = FALSE;
78         bool GenderProcessed = FALSE;
79         bool BirthdayProcessed = FALSE;
80         bool AnniversaryProcessed = FALSE;
81         bool UIDProcessed = FALSE;
82         bool RevisionProcessed = FALSE;
83         int ContactLineLen = 0;
84         int QuoteBreakPoint = 0;
85         int SourceCount = 0;
86         int GroupCount = 0;
87         int FNCount = 0;
88         int NicknameCount = 0;
89         int TimeZoneCount = 0;
90         int AddressCount = 0;
91         int EmailCount = 0;
92         int IMCount = 0;
93         int TelephoneCount = 0;
94         int LanguageCount = 0;
95         int GeographicCount = 0;
96         int RelatedCount = 0;
97         int URLCount = 0;
98         int TitleCount = 0;
99         int RoleCount = 0;
100         int OrganisationCount = 0;
101         int NoteCount = 0;
102         int CategoryCount = 0;
103         int PhotoCount = 0;
104         int LogoCount = 0;
105         int SoundCount = 0;
106         int CalendarCount = 0;
107         int CalendarAddressCount = 0;
108         int FreeBusyAddressCount = 0;
109         int KeyCount = 0;
110         int VendorCount = 0;
111         int XTokenCount = 0;
112         int XMLCount = 0;
113         wxString ContactLine;
114         wxString PropertyLine;
115         wxString PropertySeg1;
116         wxString PropertySeg2;
117         wxString PropertyNextLine;
118         wxString Property;
119         
120         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
121          iter != ContactFileLines.end(); ++iter){
123                 ExtraLineSeek = TRUE;
124                 QuoteMode = FALSE;
125                 PropertyFind = TRUE;
126                 ContactLineLen = 0;
127                 QuoteBreakPoint = 0;
128                 ContactLine.Clear();
129                 PropertyLine.Clear();
130                 PropertySeg1.Clear();
131                 PropertySeg2.Clear();
132                 Property.Clear();
133          
134                 ContactLine = iter->second;
135                 
136                 while (ExtraLineSeek == TRUE){
137                 
138                         // Check if there is extra data on the next line 
139                         // (indicated by space or tab at the start) and add data.
140                 
141                         iter++;
142                         
143                         if (iter == ContactFileLines.end()){
144                         
145                                 iter--;
146                                 break;
147                         
148                         }                       
149                 
150                         PropertyNextLine = iter->second;
151                 
152                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
153                 
154                                 PropertyNextLine.Remove(0, 1);
155                                 ContactLine.Append(PropertyNextLine);
156                 
157                         } else {
158                         
159                                 iter--;
160                                 ExtraLineSeek = FALSE;
161                         
162                         }
163                 
164                 }
166                 ContactLineLen = ContactLine.Len();
167                 
168                 // Make sure we are not in quotation mode.
169                 // Make sure colon does not have \ or \\ before it.
170                 
171                 for (int i = 0; i <= ContactLineLen; i++){
172                 
173                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
174                         
175                                 PropertyFind = FALSE;
176                         
177                         } else if (PropertyFind == TRUE){
178                         
179                                 Property.Append(ContactLine.Mid(i, 1));
180                         
181                         }               
182                 
183                         if (ContactLine.Mid(i, 1) == wxT("\"")){
184                         
185                                 if (QuoteMode == TRUE){
186                                 
187                                         QuoteMode = FALSE;
188                                 
189                                 } else {
190                         
191                                         QuoteMode = TRUE;
192                                         
193                                 }
194                         
195                         }
196                         
197                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
198                         
199                                 QuoteBreakPoint = i;
200                                 break;
201                         
202                         }
203                 
204                 }
205                 
206                 // Split that line at the point into two variables (ignore the colon).
207                 
208                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
209                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
210                 
211                  if (Property == wxT("KIND") && KindProcessed == FALSE){
212                                 
213                         ProcessKind(PropertySeg2);
214                 
215                 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
216                 
217                         UIDToken = PropertySeg2;
218                         UIDProcessed = TRUE;
219                 
220                 } else if (Property == wxT("SOURCE")){
221                 
222                         ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
223                         SourceCount++;
224                 
225                 } else if (Property == wxT("XML")){
226                 
227                         ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
228                         XMLCount++;
229                 
230                 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
231                 
232                         ProcessRevision(PropertySeg1, PropertySeg2);
233                         RevisionProcessed = TRUE;
234                 
235                 } else if (Property == wxT("MEMBER")){
237                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
238                         GroupCount++;   
239                 
240                 } else if (Property == wxT("FN")){
241                 
242                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
243                         FNCount++;
244                 
245                 } else if (Property == wxT("N") && NameProcessed == FALSE){
246                 
247                         ProcessN(PropertySeg1, PropertySeg2);
248                         NameProcessed = TRUE;
249                 
250                 } else if (Property == wxT("NICKNAME")){
251                                                 
252                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
253                         NicknameCount++;
254                         
255                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
256                 
257                         ProcessGender(PropertySeg1, PropertySeg2);
258                         GenderProcessed = TRUE;
259                 
260                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
261                 
262                         ProcessBirthday(PropertySeg1, PropertySeg2);
263                         BirthdayProcessed = TRUE;
264                 
265                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
266                 
267                         ProcessAnniversary(PropertySeg1, PropertySeg2);
268                         AnniversaryProcessed = TRUE;
269                 
270                 } else if (Property == wxT("TZ")){
271                 
272                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
273                         TimeZoneCount++;
274                 
275                 } else if (Property == wxT("ADR")){
276                 
277                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
278                         AddressCount++;
279                 
280                 } else if (Property == wxT("EMAIL")){
281                                         
282                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
283                         EmailCount++;
284                 
285                 } else if (Property == wxT("IMPP")){
286                 
287                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
288                         IMCount++;
289                         
290                 } else if (Property == wxT("TEL")){
291                                 
292                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
293                         TelephoneCount++;
294                 
295                 } else if (Property == wxT("LANG")){
296                 
297                         // See frmContactEditor-LoadLanguage.cpp
298                         
299                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
300                         LanguageCount++;
301                 
302                 } else if (Property == wxT("GEO")){
303                 
304                         // See frmContactEditor-LoadGeo.cpp
305                         
306                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
307                         GeographicCount++;
308                 
309                 } else if (Property == wxT("RELATED")){
310                         
311                         // See fromContactEditor-LoadRelated.cpp
312                         
313                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
314                         RelatedCount++;
315                         
316                 } else if (Property == wxT("URL")){
318                         // See frmContactEditor-LoadURL.cpp
319                 
320                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
321                         URLCount++;
322                 
323                 } else if (Property == wxT("TITLE")) {
324                 
325                         // See frmContactEditor-LoadTitle.cpp
326                         
327                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
328                         TitleCount++;
329                         
330                 } else if (Property == wxT("ROLE")) {
331                 
332                         // See frmContactEditor-LoadTitle.cpp
333                         
334                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
335                         RoleCount++;
336                         
337                 } else if (Property == wxT("ORG")) {
338                 
339                         // See frmContactEditor-LoadOrg.cpp
340                         
341                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
342                         OrganisationCount++;
343                         
344                 } else if (Property == wxT("NOTE")) {
346                         // See frmContactEditor-LoadNote.cpp
348                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
349                         NoteCount++;    
350                         
351                 } else if (Property == wxT("CATEGORIES")) {
352                 
353                         // See frmContactEditor-LoadCategory.cpp
354                 
355                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
356                         CategoryCount++;
357                         
358                 } else if (Property == wxT("PHOTO")) {
359                 
360                         // See frmContactEditor-LoadPhoto.cpp
361                         
362                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
363                         PhotoCount++;
365                 } else if (Property == wxT("LOGO")) {
366                 
367                         // See frmContactEditor-LoadPhoto.cpp
368                         
369                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
370                         LogoCount++;
372                 } else if (Property == wxT("LOGO")) {
373                 
374                         // See frmContactEditor-LoadPhoto.cpp
375                         
376                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
377                         LogoCount++;
379                 } else if (Property == wxT("SOUND")) {
380                 
381                         // See frmContactEditor-LoadSound.cpp
382                         
383                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
384                         SoundCount++;
385                         
386                 } else if (Property == wxT("CALURI")){
388                         // See frmContactEditor-LoadCalendar.cpp
389                         
390                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
391                         CalendarCount++;
392                 
393                 } else if (Property == wxT("CALADRURI")){
394                 
395                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
396                         CalendarAddressCount++;
397                 
398                 } else if (Property == wxT("FBURL")){
400                         // See frmContactEditor-LoadCalendar.cpp
402                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
403                         FreeBusyAddressCount++;
405                 } else if (Property == wxT("KEY")){
406                 
407                         // See frmContactEditor-LoadKey.cpp
408                         
409                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
410                         KeyCount++;
411                 
412                 } else if (Property.Mid(0, 3) == wxT("VND")){
413                 
414                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
415                         VendorCount++;
416                 
417                 } else if (Property.Mid(0, 2) == wxT("X-")){
418                         
419                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
420                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
421                         XTokenCount++;
422                 
423                 }
424                 
425         }
426         
427         return CONTACTLOAD_OK;
431 void ContactDataObject::ProcessKind(wxString KindType){
433         if (KindType == wxT("individual")){
434                         
435                 ContactKind = CONTACTKIND_INDIVIDUAL;
436                         
437         } else if (KindType == wxT("group")){
438                         
439                 ContactKind = CONTACTKIND_GROUP;
440                         
441         } else if (KindType == wxT("org")){
442                         
443                 ContactKind = CONTACTKIND_ORGANISATION;
444                         
445         } else if (KindType == wxT("location")){
446                         
447                 ContactKind = CONTACTKIND_LOCATION;
448                         
449         } else {
450                         
451                 ContactKind = CONTACTKIND_NONE;                 
452         }
456 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
458         size_t intPropertyLen = PropertySeg1.Len();
459         std::map<int, int> SplitPoints;
460         std::map<int, int> SplitLength;
461         std::map<int, int>::iterator SLiter;                    
462         wxString PropertyData;
463         wxString PropertyName;
464         wxString PropertyValue;
465         wxString PropertyTokens;
466         bool FirstToken = TRUE;
467         int intSplitsFound = 0;
468         int intSplitSize = 0;
469         int intPrevValue = 5;
470         int intPref = 0;                        
471         int intType = 0;
472         
473         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
474         
475         intPrevValue = 4;
477         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
478         intiter != SplitPoints.end(); ++intiter){
479         
480                 SLiter = SplitLength.find(intiter->first);
481         
482                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
483                 
484                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
485                 PropertyName = PropertyElement.GetNextToken();                          
486                 PropertyValue = PropertyElement.GetNextToken();
487                 
488                 intPrevValue = intiter->second;
489                 
490                 // Process properties.
491                 
492                 size_t intPropertyValueLen = PropertyValue.Len();
493                 
494                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
495                         
496                         PropertyValue.Trim();
497                         PropertyValue.RemoveLast();
498                         
499                 }                               
500                 
501                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
502                         
503                         PropertyValue.Remove(0, 1);
504                         
505                 }                       
506                 
507                 CaptureString(&PropertyValue, FALSE);
508                                                                 
509                 if (FirstToken == TRUE){
510                                 
511                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
512                         FirstToken = FALSE;
513                                 
514                 } else {
515                                 
516                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
517                                 
518                 }
519         
520         }       
521         
522         CaptureString(&PropertySeg2, FALSE);
523         
524         Revision = PropertySeg2;
525         
526         if (!PropertyTokens.IsEmpty()){
527         
528                 RevisionTokens = PropertyTokens;
529         
530         }
535 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
537         size_t intPropertyLen = PropertySeg1.Len();
538         std::map<int, int> SplitPoints;
539         std::map<int, int> SplitLength;
540         std::map<int, int>::iterator SLiter;                    
541         wxString PropertyData;
542         wxString PropertyName;
543         wxString PropertyValue;
544         wxString PropertyTokens;
545         bool FirstToken = TRUE;
546         int intSplitsFound = 0;
547         int intSplitSize = 0;
548         int intPrevValue = 8;
549         int intPref = 0;                        
550         int intType = 0;
551         
552         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
553         
554         intPrevValue = 7;
555         
556         PropertyType PropType = PROPERTY_NONE;
557         
558         // Look for type before continuing.                     
560         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
562         intPrevValue = 7;
564         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
565         intiter != SplitPoints.end(); ++intiter){
566         
567                 SLiter = SplitLength.find(intiter->first);
568         
569                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
570                 
571                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
572                 PropertyName = PropertyElement.GetNextToken();                          
573                 PropertyValue = PropertyElement.GetNextToken();
574                 
575                 intPrevValue = intiter->second;
576                 
577                 // Process properties.
578                 
579                 size_t intPropertyValueLen = PropertyValue.Len();
580                 
581                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
582                         
583                         PropertyValue.Trim();
584                         PropertyValue.RemoveLast();
585                         
586                 }                               
587                 
588                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
589                         
590                         PropertyValue.Remove(0, 1);
591                         
592                 }                       
593                 
594                 CaptureString(&PropertyValue, FALSE);
595                 
596                 if (PropertyName == wxT("ALTID")){
598                         SourceListAltID.erase(*SourceCount);
599                         SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
600                 
601                 } else if (PropertyName == wxT("PID")){
603                         SourceListPID.erase(*SourceCount);
604                         SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
605                 
606                 } else if (PropertyName == wxT("PREF")){
607                         
608                         int PriorityNumber = 0;
609                         bool ValidNumber = TRUE;
610                         
611                         try{
612                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
613                         }
614                         
615                         catch(std::invalid_argument &e){
616                                 ValidNumber = FALSE;
617                         }
619                         if (ValidNumber == TRUE){
621                                 SourceListPref.erase(*SourceCount);
622                                 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
624                         }
625                 
626                 } else if (PropertyName == wxT("MEDIATYPE")){
627                 
628                         SourceListMediatype.erase(*SourceCount);
629                         SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
631                 } else {
632                 
633                         // Something else we don't know about so append
634                         // to the tokens variable.
635                         
636                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
637                         
638                                 if (FirstToken == TRUE){
639                                 
640                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
641                                         FirstToken = FALSE;
642                                 
643                                 } else {
644                                 
645                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
646                                 
647                                 }
648                         
649                         }
650                 
651                 }
652         
653         }       
654         
655         intPropertyLen = PropertySeg2.Len();
656         SplitPoints.clear();
657         SplitLength.clear();
658         intSplitsFound = 0;
659         intSplitSize = 0;
660         intPrevValue = 0;
661         
662         CaptureString(&PropertySeg2, FALSE);
663         
664         // Add the data to the General/Home/Work address variables.
665                 
666         switch(PropType){
667                 case PROPERTY_NONE:
668                         break;
669                 case PROPERTY_HOME:
670                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
671                         break;
672                 case PROPERTY_WORK:
673                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
674                         break;
675         }
676         
677         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
678         
679         if (!PropertyTokens.IsEmpty()){
680         
681                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
682         
683         }
687 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
689         std::map<int, int> SplitPoints;
690         std::map<int, int> SplitLength;
692         int intPrevValue = 5;
693         int intPref = 0;                        
694         int intType = 0;
695         
696         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
698         intPrevValue = 4;
699         
700         wxString PropertyName;
701         wxString PropertyValue;
702         wxString PropertyData;
703         wxString PropertyTokens;
704         std::map<int,int>::iterator SLiter;
705         bool FirstToken = TRUE;
706         
707         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
708         intiter != SplitPoints.end(); ++intiter){
709         
710                 SLiter = SplitLength.find(intiter->first);
711         
712                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
713                 
714                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
715                 PropertyName = PropertyElement.GetNextToken();                          
716                 PropertyValue = PropertyElement.GetNextToken();
717                 
718                 intPrevValue = intiter->second;
719                 
720                 CaptureString(&PropertyValue, FALSE);
721         
722                 if (PropertyName == wxT("ALTID")){
724                         XMLListAltID.erase(*XMLCount);
725                         XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
726                 
727                 }
728                 
729         }
731         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
735 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
737         std::map<int, int> SplitPoints;
738         std::map<int, int> SplitLength;
740         int intPrevValue = 8;
741         int intPref = 0;                        
742         int intType = 0;
743         
744         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
746         intPrevValue = 7;
747         
748         wxString PropertyName;
749         wxString PropertyValue;
750         wxString PropertyData;
751         wxString PropertyTokens;
752         std::map<int,int>::iterator SLiter;
753         bool FirstToken = TRUE;
754         
755         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
756         intiter != SplitPoints.end(); ++intiter){
757         
758                 SLiter = SplitLength.find(intiter->first);
759         
760                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
761                 
762                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
763                 PropertyName = PropertyElement.GetNextToken();                          
764                 PropertyValue = PropertyElement.GetNextToken();
765                 
766                 intPrevValue = intiter->second;
767                 
768                 CaptureString(&PropertyValue, FALSE);
769         
770                 if (PropertyName == wxT("ALTID")){
772                         GroupsListAltID.erase(*GroupCount);
773                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
774                 
775                 } else if (PropertyName == wxT("PID")){
777                         GroupsListPID.erase(*GroupCount);
778                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
779                 
780                 } else if (PropertyName == wxT("PREF")){
782                         int PriorityNumber = 0;
783                         bool ValidNumber = TRUE;
784                         
785                         try{
786                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
787                         }
788                         
789                         catch(std::invalid_argument &e){
790                                 ValidNumber = FALSE;
791                         }
793                         if (ValidNumber == TRUE){
795                                 GroupsListPref.erase(*GroupCount);
796                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
797                 
798                         }
799                 
800                 } else if (PropertyName == wxT("MEDIATYPE")){
802                         GroupsListMediaType.erase(*GroupCount);
803                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
804                 
805                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
806                         
807                         if (FirstToken == TRUE){
808                                 
809                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
810                                 FirstToken = FALSE;
811                                 
812                         } else {
813                         
814                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
815                                 
816                         }
817                         
818                 }
819                 
820         }
822         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
824         if (!PropertyTokens.IsEmpty()){
825         
826                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
827         
828         }
833 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
835         std::map<int, int> SplitPoints;
836         std::map<int, int> SplitLength;
838         int intPrevValue = 4;
839         int intPref = 0;                        
840         int intType = 0;
841         
842         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
844         intPrevValue = 3;
845         
846         wxString PropertyName;
847         wxString PropertyValue;
848         wxString PropertyData;
849         wxString PropertyTokens;
850         std::map<int,int>::iterator SLiter;
851         bool FirstToken = TRUE;
852         
853         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
854         intiter != SplitPoints.end(); ++intiter){
855         
856                 SLiter = SplitLength.find(intiter->first);
857         
858                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
859                 
860                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
861                 PropertyName = PropertyElement.GetNextToken();                          
862                 PropertyValue = PropertyElement.GetNextToken();
863                 
864                 intPrevValue = intiter->second;
865                 
866                 CaptureString(&PropertyValue, FALSE);
867                 
868                 if (PropertyName == wxT("TYPE")){
870                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
871                                 PropertyValue == wxT("work") ){
873                                 FullNamesListType.erase(*FNCount);
874                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
875                 
876                         }
877                 
878                 } else if (PropertyName == wxT("LANGUAGE")){
880                         FullNamesListLanguage.erase(*FNCount);
881                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
882                 
883                 } else if (PropertyName == wxT("ALTID")){
884                 
885                         FullNamesListAltID.erase(*FNCount);
886                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
887                 
888                 } else if (PropertyName == wxT("PID")){
890                         FullNamesListPID.erase(*FNCount);
891                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
892                 
893                 } else if (PropertyName == wxT("PREF")){
895                         int PriorityNumber = 0;
896                         bool ValidNumber = TRUE;
897                         
898                         try{
899                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
900                         }
901                         
902                         catch(std::invalid_argument &e){
903                                 ValidNumber = FALSE;
904                         }
906                         if (ValidNumber == TRUE){
908                                 FullNamesListPref.erase(*FNCount);
909                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
911                         }
912                 
913                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
914                         
915                         if (FirstToken == TRUE){
916                                 
917                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
918                                 FirstToken = FALSE;
919                                 
920                         } else {
921                         
922                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
923                                 
924                         }
925                         
926                 } 
927         
928         }
930         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
932         if (!PropertyTokens.IsEmpty()){
933         
934                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
935         
936         }
940 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
942         std::map<int, int> SplitPoints;
943         std::map<int, int> SplitLength;
945         int intPrevValue = 3;
946         int intPref = 0;                        
947         int intType = 0;
948         
949         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
950         
951         intPrevValue = 2;
952         
953         wxString PropertyName;
954         wxString PropertyValue;
955         wxString PropertyData;
956         wxString PropertyTokens;
957         std::map<int,int>::iterator SLiter;
958         bool FirstToken = TRUE;
959         
960         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
961         intiter != SplitPoints.end(); ++intiter){
962         
963                 SLiter = SplitLength.find(intiter->first);
964         
965                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
966                 
967                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
968                 PropertyName = PropertyElement.GetNextToken();                          
969                 PropertyValue = PropertyElement.GetNextToken();
970                 
971                 intPrevValue = intiter->second;
972                 
973                 CaptureString(&PropertyValue, FALSE);
974                 
975                 if (PropertyName == wxT("ALTID")){
977                         NameAltID = PropertyValue;
978                 
979                 } else if (PropertyName == wxT("LANGUAGE")){
980                 
981                         NameLanguage = PropertyValue;
982                 
983                 } else if (PropertyName == wxT("SORT-AS")){
984                 
985                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
986                                 PropertyValue.Len() >= 3){
987                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
988                         }
989                 
990                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
991                         
992                         if (FirstToken == TRUE){
993                                 
994                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
995                                 FirstToken = FALSE;
996                                 
997                         } else {
998                         
999                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1000                                 
1001                         }
1002                         
1003                 }
1004         
1005         }
1006         
1007         // Split the name data.
1008         
1009         int intSplitSeek = 0;           
1010         int intSplitsFound = 0;
1011         int intSplitSize = 0;
1012         int intPropertyLen = PropertySeg2.Len();
1013         
1014         std::map<int,wxString> NameValues;
1015         intPrevValue = 0;                                       
1016         
1017         for (int i = 0; i <= intPropertyLen; i++){
1018         
1019                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1020                         
1021                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
1022                         
1023                         intSplitSeek = i;
1024                         intSplitSeek++;
1025                         
1026                         if (intSplitsFound == 4){
1027                         
1028                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1029                                 break;
1030                         
1031                         }
1032                         
1033                         intSplitSize = 0;
1034                         continue;
1035         
1036                 }
1037                 
1038                 intSplitSize++;
1040         }
1041         
1042         // Split the data into several parts.
1043                         
1044         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
1045         iter != NameValues.end(); ++iter){
1046         
1047                 if (iter->first == 1){
1048                 
1049                         // Deal with family name.
1050                         
1051                         NameSurname = iter->second;
1052                 
1053                 } else if (iter->first == 2){
1054                 
1055                         // Deal with given names.
1056                         
1057                         NameForename = iter->second;
1058                 
1059                 } else if (iter->first == 3){
1060                 
1061                         // Deal with additional names.
1062                         
1063                         NameOtherNames = iter->second;
1064                 
1065                 } else if (iter->first == 4){
1066                 
1067                         // Deal with honorifix prefixes and suffixes.
1069                         NameTitle = iter->second;
1070                 
1071                         iter++;
1072                         
1073                         if (iter == NameValues.end()){
1074                         
1075                                 break;
1076                         
1077                         }
1078                 
1079                         NameSuffix = iter->second;
1080                 
1081                 }
1082         
1083         }
1084         
1085         // Add the name token data.
1086         
1087         if (!PropertyTokens.IsEmpty()){
1088         
1089                 NameTokens = PropertyTokens;
1090         
1091         }
1095 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1097         std::map<int, int> SplitPoints;
1098         std::map<int, int> SplitLength;
1100         int intPrevValue = 10;
1101         int intPref = 0;                        
1102         
1103         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1104         
1105         intPrevValue = 9;
1106         
1107         PropertyType PropType = PROPERTY_NONE;
1108         
1109         // Look for type before continuing.
1110         
1111         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1112         
1113         intPrevValue = 9;
1114         
1115         std::map<int, wxString> *NicknamesList = NULL;
1116         std::map<int, wxString> *NicknamesListType = NULL;
1117         std::map<int, wxString> *NicknamesListLanguage = NULL;
1118         std::map<int, wxString> *NicknamesListAltID = NULL;
1119         std::map<int, wxString> *NicknamesListPID = NULL;
1120         std::map<int, wxString> *NicknamesListTokens = NULL;            
1121         std::map<int, int> *NicknamesListPref = NULL;
1122         
1123         switch(PropType){
1124                 case PROPERTY_NONE:
1125                         NicknamesList = &GeneralNicknamesList;
1126                         NicknamesListType = &GeneralNicknamesListType;
1127                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1128                         NicknamesListAltID = &GeneralNicknamesListAltID;
1129                         NicknamesListPID = &GeneralNicknamesListPID;
1130                         NicknamesListTokens = &GeneralNicknamesListTokens;
1131                         NicknamesListPref = &GeneralNicknamesListPref;
1132                         break;
1133                 case PROPERTY_HOME:
1134                         NicknamesList = &HomeNicknamesList;
1135                         NicknamesListType = &HomeNicknamesListType;
1136                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1137                         NicknamesListAltID = &HomeNicknamesListAltID;
1138                         NicknamesListPID = &HomeNicknamesListPID;
1139                         NicknamesListTokens = &HomeNicknamesListTokens;
1140                         NicknamesListPref = &HomeNicknamesListPref;
1141                         break;
1142                 case PROPERTY_WORK:
1143                         NicknamesList = &BusinessNicknamesList;
1144                         NicknamesListType = &BusinessNicknamesListType;
1145                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1146                         NicknamesListAltID = &BusinessNicknamesListAltID;
1147                         NicknamesListPID = &BusinessNicknamesListPID;
1148                         NicknamesListTokens = &BusinessNicknamesListTokens;
1149                         NicknamesListPref = &BusinessNicknamesListPref;
1150                         break;
1151         }
1152         
1153         std::map<int, int>::iterator SLiter;    
1154         wxString PropertyData;
1155         wxString PropertyName;
1156         wxString PropertyValue;
1157         wxString PropertyTokens;
1158         bool FirstToken = TRUE;
1159         
1160         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1161         intiter != SplitPoints.end(); ++intiter){
1162         
1163                 SLiter = SplitLength.find(intiter->first);
1164         
1165                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1166                 
1167                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1168                 PropertyName = PropertyElement.GetNextToken();                          
1169                 PropertyValue = PropertyElement.GetNextToken();
1170                 
1171                 intPrevValue = intiter->second;
1172                 
1173                 CaptureString(&PropertyValue, FALSE);
1174                 
1175                 if (PropertyName == wxT("ALTID")){
1177                         NicknamesListAltID->erase(*NicknameCount);
1178                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1179                 
1180                 } else if (PropertyName == wxT("PID")){
1182                         NicknamesListPID->erase(*NicknameCount);
1183                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
1185                 } else if (PropertyName == wxT("PREF")){
1187                         int PriorityNumber = 0;
1188                         bool ValidNumber = TRUE;
1189                         
1190                         try{
1191                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1192                         }
1193                         
1194                         catch(std::invalid_argument &e){
1195                                 ValidNumber = FALSE;
1196                         }
1198                         if (ValidNumber == TRUE){
1200                                 NicknamesListPref->erase(*NicknameCount);
1201                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1203                         }
1204                 
1205                 } else if (PropertyName == wxT("LANGUAGE")){
1207                         NicknamesListLanguage->erase(*NicknameCount);
1208                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
1210                 } else {
1211                 
1212                         // Something else we don't know about so append
1213                         // to the tokens variable.
1214                 
1215                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1216                 
1217                                 if (FirstToken == TRUE){
1218                         
1219                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1220                                         FirstToken = FALSE;
1221                         
1222                                 } else {
1223                         
1224                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1225                         
1226                                 }
1227                 
1228                         }
1229                 
1230                 }
1231                 
1232         }
1233         
1234         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1235         
1236         // Add the name token data.
1237         
1238         if (!PropertyTokens.IsEmpty()){
1239         
1240                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1241         
1242         }
1246 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1248         std::map<int, int> SplitPoints;
1249         std::map<int, int> SplitLength;
1250         std::map<int, int>::iterator SLiter;                    
1251         wxString PropertyData;
1252         wxString PropertyName;
1253         wxString PropertyValue;
1254         wxString PropertyTokens;
1255         bool FirstToken = TRUE;
1256         int intPrevValue = 8;
1258         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1260         intPrevValue = 7;                       
1261         
1262         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1263         intiter != SplitPoints.end(); ++intiter){
1264         
1265                 SLiter = SplitLength.find(intiter->first);
1266         
1267                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1268                 
1269                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1270                 PropertyName = PropertyElement.GetNextToken();                          
1271                 PropertyValue = PropertyElement.GetNextToken();
1272                 
1273                 intPrevValue = intiter->second;
1274                 
1275                 // Process properties.
1276                 
1277                 size_t intPropertyValueLen = PropertyValue.Len();
1278                 
1279                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1280                         
1281                         PropertyValue.Trim();
1282                         PropertyValue.RemoveLast();
1283                         
1284                 }                               
1285                 
1286                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1287                         
1288                         PropertyValue.Remove(0, 1);
1289                         
1290                 }                               
1291                 
1292                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1294                         if (FirstToken == TRUE){
1295         
1296                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1297                                 FirstToken = FALSE;
1298         
1299                         } else {
1300         
1301                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1302         
1303                         }
1305                 }
1306         
1307         }       
1309         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1310         
1311         wxString GenderComponent;
1312         
1313         if (GenderData.CountTokens() >= 2){
1314         
1315                 Gender = GenderData.GetNextToken();
1316                 GenderDetails = GenderData.GetString();
1317         
1318                 CaptureString(&GenderDetails, FALSE);
1319                                                 
1320         } else {
1321         
1322                 Gender = GenderData.GetNextToken();
1323         
1324         }
1325         
1326         if (!PropertyTokens.IsEmpty()){
1327         
1328                 GenderTokens = PropertyTokens;
1329         
1330         }
1334 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1336         // Process date. Preserve the remainder in the string.
1338         std::map<int, int> SplitPoints;
1339         std::map<int, int> SplitLength;
1340         std::map<int, int>::iterator SLiter;                    
1341         wxString PropertyData;
1342         wxString PropertyName;
1343         wxString PropertyValue;
1344         wxString PropertyTokens;
1345         bool BirthdayText = FALSE;
1346         int intPrevValue = 6;
1348         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1350         intPrevValue = 5;
1352         // Look for type before continuing.
1354         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1355         intiter != SplitPoints.end(); ++intiter){
1357                 SLiter = SplitLength.find(intiter->first);
1359                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1360         
1361                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1362                 PropertyName = PropertyElement.GetNextToken();                          
1363                 PropertyValue = PropertyElement.GetNextToken();
1364         
1365                 intPrevValue = intiter->second;
1366         
1367                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1368         
1369                         CaptureString(&PropertySeg2, FALSE);
1370                         Birthday = PropertySeg2;
1371                         BirthdayText = TRUE;
1372         
1373                 }
1375         }
1377         // Setup blank lines for later on.
1378         
1379         intPrevValue = 5;
1380         bool FirstToken = TRUE;
1382         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1383         intiter != SplitPoints.end(); ++intiter){
1385                 SLiter = SplitLength.find(intiter->first);
1387                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1388         
1389                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1390                 PropertyName = PropertyElement.GetNextToken();                          
1391                 PropertyValue = PropertyElement.GetNextToken();
1392         
1393                 intPrevValue = intiter->second;
1394         
1395                 // Process properties.
1396         
1397                 CaptureString(&PropertyValue, FALSE);
1398         
1399                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1400                 
1401                         PropertyValue.Trim();
1402                         PropertyValue.RemoveLast();
1403                 
1404                 }                               
1405         
1406                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1407                 
1408                         PropertyValue.Remove(0, 1);
1409                 
1410                 }                               
1411         
1412                 if (PropertyName == wxT("ALTID")){
1414                         BirthdayAltID = PropertyValue;
1415         
1416                 } else if (PropertyName == wxT("CALSCALE")){
1417         
1418                         BirthdayCalScale = PropertyValue;
1419         
1420                 } else if (PropertyName != wxT("VALUE")) {
1421         
1422                         // Something else we don't know about so append
1423                         // to the tokens variable.
1424                 
1425                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1426                 
1427                                 if (FirstToken == TRUE){
1428         
1429                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1430                                         FirstToken = FALSE;
1431         
1432                                 } else {
1433         
1434                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1435         
1436                                 }
1437                                 
1438                         }
1439                         
1440                 }
1442         }       
1444         // Add the data to the variables and form.
1445         
1446         if (BirthdayText == FALSE){
1447         
1448                 Birthday = PropertySeg2;
1450         }
1451         
1452         if (!PropertyTokens.IsEmpty()){
1453         
1454                 BirthdayTokens = PropertyTokens;
1456         }
1460 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1462         // Process date. Preserve the remainder in the string.
1464         std::map<int, int> SplitPoints;
1465         std::map<int, int> SplitLength;
1466         std::map<int, int>::iterator SLiter;                    
1467         wxString PropertyData;
1468         wxString PropertyName;
1469         wxString PropertyValue;
1470         wxString PropertyTokens;
1471         bool AnniversaryText = FALSE;
1472         int intPrevValue = 13;
1474         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1476         intPrevValue = 12;
1478         // Look for type before continuing.
1480         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1481         intiter != SplitPoints.end(); ++intiter){
1483                 SLiter = SplitLength.find(intiter->first);
1485                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1486         
1487                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1488                 PropertyName = PropertyElement.GetNextToken();                          
1489                 PropertyValue = PropertyElement.GetNextToken();
1490         
1491                 intPrevValue = intiter->second;
1492         
1493                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1494         
1495                         CaptureString(&PropertySeg2, FALSE);
1496                         Anniversary = PropertySeg2;
1497                         AnniversaryText = TRUE;
1498         
1499                 }
1501         }
1503         // Setup blank lines for later on.
1504         
1505         intPrevValue = 12;
1506         bool FirstToken = TRUE;
1508         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1509         intiter != SplitPoints.end(); ++intiter){
1511                 SLiter = SplitLength.find(intiter->first);
1513                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1514         
1515                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1516                 PropertyName = PropertyElement.GetNextToken();                          
1517                 PropertyValue = PropertyElement.GetNextToken();
1518         
1519                 intPrevValue = intiter->second;
1520         
1521                 // Process properties.
1522         
1523                 CaptureString(&PropertyValue, FALSE);
1524         
1525                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1526                 
1527                         PropertyValue.Trim();
1528                         PropertyValue.RemoveLast();
1529                 
1530                 }                               
1531         
1532                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1533                 
1534                         PropertyValue.Remove(0, 1);
1535                 
1536                 }                               
1537         
1538                 if (PropertyName == wxT("ALTID")){
1540                         AnniversaryAltID = PropertyValue;
1541         
1542                 } else if (PropertyName == wxT("CALSCALE")){
1543         
1544                         AnniversaryCalScale = PropertyValue;
1545         
1546                 } else if (PropertyName != wxT("VALUE")) {
1547         
1548                         // Something else we don't know about so append
1549                         // to the tokens variable.
1550                 
1551                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1552                 
1553                                 if (FirstToken == TRUE){
1554         
1555                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1556                                         FirstToken = FALSE;
1557         
1558                                 } else {
1559         
1560                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1561         
1562                                 }
1563                                 
1564                         }
1565                         
1566                 }
1568         }       
1570         // Add the data to the variables and form.
1571         
1572         if (AnniversaryText == FALSE){
1573         
1574                 Anniversary = PropertySeg2;
1576         }
1577         
1578         if (!PropertyTokens.IsEmpty()){
1579         
1580                 AnniversaryTokens = PropertyTokens;
1582         }
1586 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1588         std::map<int, int> SplitPoints;
1589         std::map<int, int> SplitLength;
1591         int intPrevValue = 4;
1592         int intPref = 0;                        
1593         
1594         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1595         
1596         intPrevValue = 3;
1597         
1598         PropertyType PropType = PROPERTY_NONE;
1599         
1600         // Look for type before continuing.
1601         
1602         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1603         
1604         intPrevValue = 3;
1605         
1606         std::map<int, wxString> *TZList = NULL;
1607         std::map<int, wxString> *TZListType = NULL;
1608         std::map<int, wxString> *TZListMediatype = NULL;
1609         std::map<int, wxString> *TZListAltID = NULL;
1610         std::map<int, wxString> *TZListPID = NULL;
1611         std::map<int, wxString> *TZListTokens = NULL;           
1612         std::map<int, int> *TZListPref = NULL;
1613         
1614         switch(PropType){
1615                 case PROPERTY_NONE:
1616                         TZList = &GeneralTZList;
1617                         TZListType = &GeneralTZListType;
1618                         TZListMediatype = &GeneralTZListMediatype;
1619                         TZListAltID = &GeneralTZListAltID;
1620                         TZListPID = &GeneralTZListPID;
1621                         TZListTokens = &GeneralTZListTokens;
1622                         TZListPref = &GeneralTZListPref;
1623                         break;
1624                 case PROPERTY_HOME:
1625                         TZList = &HomeTZList;
1626                         TZListType = &HomeTZListType;
1627                         TZListMediatype = &HomeTZListMediatype;
1628                         TZListAltID = &HomeTZListAltID;
1629                         TZListPID = &HomeTZListPID;
1630                         TZListTokens = &HomeTZListTokens;
1631                         TZListPref = &HomeTZListPref;
1632                         break;
1633                 case PROPERTY_WORK:
1634                         TZList = &BusinessTZList;
1635                         TZListType = &BusinessTZListType;
1636                         TZListMediatype = &BusinessTZListMediatype;
1637                         TZListAltID = &BusinessTZListAltID;
1638                         TZListPID = &BusinessTZListPID;
1639                         TZListTokens = &BusinessTZListTokens;
1640                         TZListPref = &BusinessTZListPref;
1641                         break;
1642         }
1643         
1644         std::map<int, int>::iterator SLiter;    
1645         wxString PropertyData;
1646         wxString PropertyName;
1647         wxString PropertyValue;
1648         wxString PropertyTokens;
1649         bool FirstToken = TRUE;
1650         
1651         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1652         intiter != SplitPoints.end(); ++intiter){
1653         
1654                 SLiter = SplitLength.find(intiter->first);
1655         
1656                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1657                 
1658                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1659                 PropertyName = PropertyElement.GetNextToken();                          
1660                 PropertyValue = PropertyElement.GetNextToken();
1661                 
1662                 intPrevValue = intiter->second;
1663                 
1664                 CaptureString(&PropertyValue, FALSE);
1666                 if (PropertyName == wxT("ALTID")){
1668                         TZListAltID->erase(*TimeZoneCount);
1669                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1670                 
1671                 } else if (PropertyName == wxT("PID")){
1673                         TZListPID->erase(*TimeZoneCount);
1674                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1676                 } else if (PropertyName == wxT("PREF")){
1678                         int PriorityNumber = 0;
1679                         bool ValidNumber = TRUE;
1680                         
1681                         try{
1682                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1683                         }
1684                         
1685                         catch(std::invalid_argument &e){
1686                                 ValidNumber = FALSE;
1687                         }
1689                         if (ValidNumber == TRUE){
1691                                 TZListPref->erase(*TimeZoneCount);
1692                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1694                         }
1695                 
1696                 } else if (PropertyName == wxT("MEDIATYPE")){
1698                         TZListMediatype->erase(*TimeZoneCount);
1699                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1701                 } else {
1702                 
1703                         // Something else we don't know about so append
1704                         // to the tokens variable.
1705                 
1706                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1707                 
1708                                 if (FirstToken == TRUE){
1709                         
1710                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1711                                         FirstToken = FALSE;
1712                         
1713                                 } else {
1714                         
1715                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1716                         
1717                                 }
1718                 
1719                         }
1720                 
1721                 }
1722                 
1723         }
1724         
1725         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1726         
1727         // Add the name token data.
1728         
1729         if (!PropertyTokens.IsEmpty()){
1730         
1731                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1732         
1733         }
1738 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1740         size_t intPropertyLen = PropertySeg1.Len();
1741         std::map<int, int> SplitPoints;
1742         std::map<int, int> SplitLength;
1743         std::map<int, int>::iterator SLiter;                    
1744         wxString PropertyData;
1745         wxString PropertyName;
1746         wxString PropertyValue;
1747         wxString PropertyTokens;
1748         wxString AddressLabel;
1749         wxString AddressLang;
1750         wxString AddressAltID;
1751         wxString AddressPID;
1752         wxString AddressTokens;
1753         wxString AddressGeo;
1754         wxString AddressTimezone;
1755         wxString AddressType;
1756         wxString AddressMediatype;
1757         wxString AddressPOBox;
1758         wxString AddressExtended;
1759         wxString AddressStreet;
1760         wxString AddressLocality;
1761         wxString AddressCity;
1762         wxString AddressRegion;
1763         wxString AddressPostalCode;
1764         wxString AddressCountry;
1765         bool FirstToken = TRUE;                 
1766         int intSplitsFound = 0;
1767         int intSplitSize = 0;
1768         int intPrevValue = 5;
1769         int intPref = 0;                        
1770         int intType = 0;
1771         long ListCtrlIndex;
1772         
1773         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1774         
1775         intPrevValue = 4;
1776         
1777         PropertyType PropType = PROPERTY_NONE;
1778                 
1779         // Look for type before continuing.
1780         
1781         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1782         
1783         intPrevValue = 4;
1784         
1785         std::map<int, wxString> *AddressList = NULL;
1786         std::map<int, wxString> *AddressListTown = NULL;
1787         std::map<int, wxString> *AddressListCounty = NULL;
1788         std::map<int, wxString> *AddressListPostCode = NULL;
1789         std::map<int, wxString> *AddressListCountry = NULL;
1790         std::map<int, wxString> *AddressListLabel = NULL;
1791         std::map<int, wxString> *AddressListLang = NULL;                
1792         std::map<int, wxString> *AddressListAltID = NULL;
1793         std::map<int, wxString> *AddressListPID = NULL;
1794         std::map<int, wxString> *AddressListTokens = NULL;
1795         std::map<int, wxString> *AddressListGeo = NULL;
1796         std::map<int, wxString> *AddressListTimezone = NULL;            
1797         std::map<int, wxString> *AddressListType = NULL;
1798         std::map<int, wxString> *AddressListMediatype = NULL;
1799         std::map<int, int> *AddressListPref = NULL;
1801         switch(PropType){
1802                 case PROPERTY_NONE:
1803                         AddressList = &GeneralAddressList;
1804                         AddressListTown = &GeneralAddressListTown;
1805                         AddressListCounty = &GeneralAddressListCounty;
1806                         AddressListPostCode = &GeneralAddressListPostCode;
1807                         AddressListCountry = &GeneralAddressListCountry;
1808                         AddressListLabel = &GeneralAddressListLabel;
1809                         AddressListLang = &GeneralAddressListLang;              
1810                         AddressListAltID = &GeneralAddressListAltID;
1811                         AddressListPID = &GeneralAddressListPID;
1812                         AddressListTokens = &GeneralAddressListTokens;
1813                         AddressListGeo = &GeneralAddressListGeo;
1814                         AddressListTimezone = &GeneralAddressListTimezone;
1815                         AddressListType = &GeneralAddressListType;
1816                         AddressListMediatype = &GeneralAddressListMediatype;
1817                         AddressListPref = &GeneralAddressListPref;              
1818                         break;
1819                 case PROPERTY_HOME:
1820                         AddressList = &HomeAddressList;
1821                         AddressListTown = &HomeAddressListTown;
1822                         AddressListCounty = &HomeAddressListCounty;
1823                         AddressListPostCode = &HomeAddressListPostCode;
1824                         AddressListCountry = &HomeAddressListCountry;
1825                         AddressListLabel = &HomeAddressListLabel;
1826                         AddressListLang = &HomeAddressListLang;         
1827                         AddressListAltID = &HomeAddressListAltID;
1828                         AddressListPID = &HomeAddressListPID;
1829                         AddressListTokens = &HomeAddressListTokens;
1830                         AddressListGeo = &HomeAddressListGeo;
1831                         AddressListTimezone = &HomeAddressListTimezone;
1832                         AddressListType = &HomeAddressListType;
1833                         AddressListMediatype = &HomeAddressListMediatype;
1834                         AddressListPref = &HomeAddressListPref;
1835                         break;
1836                 case PROPERTY_WORK:
1837                         AddressList = &BusinessAddressList;
1838                         AddressListTown = &BusinessAddressListTown;
1839                         AddressListCounty = &BusinessAddressListCounty;
1840                         AddressListPostCode = &BusinessAddressListPostCode;
1841                         AddressListCountry = &BusinessAddressListCountry;
1842                         AddressListLabel = &BusinessAddressListLabel;
1843                         AddressListLang = &BusinessAddressListLang;             
1844                         AddressListAltID = &BusinessAddressListAltID;
1845                         AddressListPID = &BusinessAddressListPID;
1846                         AddressListTokens = &BusinessAddressListTokens;
1847                         AddressListGeo = &BusinessAddressListGeo;
1848                         AddressListTimezone = &BusinessAddressListTimezone;
1849                         AddressListType = &BusinessAddressListType;
1850                         AddressListMediatype = &BusinessAddressListMediatype;
1851                         AddressListPref = &BusinessAddressListPref;
1852                         break;
1853         }
1854         
1855         intPrevValue = 4;
1856         
1857         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1858         intiter != SplitPoints.end(); ++intiter){
1859         
1860                 SLiter = SplitLength.find(intiter->first);
1861         
1862                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1863                 
1864                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1865                 PropertyName = PropertyElement.GetNextToken();                          
1866                 PropertyValue = PropertyElement.GetNextToken();
1867                 
1868                 intPrevValue = intiter->second;
1869                 
1870                 CaptureString(&PropertyValue, FALSE);
1871                 
1872                 // Process properties.
1873                 
1874                 if (PropertyName == wxT("LABEL")){
1875                 
1876                         AddressListLabel->erase(*AddressCount);
1877                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1878                                 
1879                 } else if (PropertyName == wxT("LANGUAGE")){
1880                 
1881                         AddressListLang->erase(*AddressCount);
1882                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1883                 
1884                 } else if (PropertyName == wxT("ALTID")){
1886                         AddressListAltID->erase(*AddressCount);
1887                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1888                 
1889                 } else if (PropertyName == wxT("PID")){
1891                         AddressListPID->erase(*AddressCount);
1892                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1893                 
1894                 } else if (PropertyName == wxT("GEO")){
1895                 
1896                         AddressListGeo->erase(*AddressCount);
1897                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1898                 
1899                 } else if (PropertyName == wxT("TZ")){
1901                         AddressListTimezone->erase(*AddressCount);
1902                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1903                 
1904                 } else if (PropertyName == wxT("MEDIATYPE")){
1906                         AddressListMediatype->erase(*AddressCount);
1907                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1908                 
1909                 } else if (PropertyName == wxT("PREF")){
1910                         
1911                         int PriorityNumber = 0;
1912                         bool ValidNumber = TRUE;
1913                         
1914                         try{
1915                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1916                         }
1917                         
1918                         catch(std::invalid_argument &e){
1919                                 ValidNumber = FALSE;
1920                         }
1922                         if (ValidNumber == TRUE){
1924                                 AddressListPref->erase(*AddressCount);
1925                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1927                         }
1928                 
1929                 } else {
1930                 
1931                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1932                         
1933                                 if (FirstToken == TRUE){
1934                                 
1935                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1936                                         FirstToken = FALSE;
1937                                 
1938                                 } else {
1939                                 
1940                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1941                                 
1942                                 }
1943                         
1944                         }
1945                 
1946                 }
1947         
1948         }                       
1949         
1950         // Split the address. 
1952         //std::map<int, int>::iterator SLiter;
1953         intPropertyLen = PropertySeg2.Len();
1954         SplitPoints.clear();
1955         SplitLength.clear();
1956         intSplitsFound = 0;
1957         intSplitSize = 0;
1958         intPrevValue = 0;
1959         
1960         for (int i = 0; i <= intPropertyLen; i++){
1962                 intSplitSize++;
1963         
1964                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1965         
1966                         intSplitsFound++;
1967                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1968                         
1969                         if (intSplitsFound == 6){ 
1970                         
1971                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1972                                 break; 
1973                                 
1974                         } else {
1975                         
1976                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1977                         
1978                         }
1979                         
1980                         intSplitSize = 0;                                       
1981         
1982                 }
1984         }
1985         
1986         // Split the data into several parts.                   
1987         
1988         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1989         intiter != SplitPoints.end(); ++intiter){
1990                         
1991                 if (intiter->first == 1){
1992                 
1993                         // Deal with PO Box.
1994                         
1995                         SLiter = SplitLength.find(1);
1996                                                                 
1997                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1998                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1999                         intPrevValue = intiter->second;
2000                 
2001                 } else if (intiter->first == 2){
2002                 
2003                         // Deal with extended address.
2004                         
2005                         SLiter = SplitLength.find(2);
2006                         
2007                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2008                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2009                         intPrevValue = intiter->second;
2010                 
2011                 } else if (intiter->first == 3){
2012                 
2013                         // Deal with street address.
2014                         
2015                         SLiter = SplitLength.find(3);
2016                                                                 
2017                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2018                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2019                         intPrevValue = intiter->second;
2020                 
2021                 } else if (intiter->first == 4){
2022                 
2023                         // Deal with locality
2025                         SLiter = SplitLength.find(4);
2026                         
2027                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2028                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2029                         intPrevValue = intiter->second;
2030                         
2031                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2032                 
2033                 } else if (intiter->first == 5){
2034                 
2035                         // Deal with region.
2037                         SLiter = SplitLength.find(5);
2038                         
2039                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2040                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2041                         intPrevValue = intiter->second;
2042                         
2043                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2044                 
2045                 } else if (intiter->first == 6){
2046                 
2047                         // Deal with post code.
2049                         SLiter = SplitLength.find(6);
2050                         
2051                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2052                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2053                         intPrevValue = intiter->second;
2054                         
2055                         // Deal with country.
2056                                                 
2057                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2058                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2059                         
2060                         break;
2061                 
2062                 }
2063         
2064         }       
2065         
2066         // Add the data to the General/Home/Work address variables.
2067         
2068         CaptureString(&AddressStreet, FALSE); 
2069         CaptureString(&AddressLocality, FALSE);
2070         CaptureString(&AddressRegion, FALSE);
2071         CaptureString(&AddressPostalCode, FALSE);
2072         CaptureString(&AddressCountry, FALSE);
2073                 
2074         if (!PropertyTokens.IsEmpty()){
2075         
2076                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2077         
2078         }
2080         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2081         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2082         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2083         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2084         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2086         switch(PropType){
2087                 case PROPERTY_NONE:
2088                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2089                         break;
2090                 case PROPERTY_HOME:
2091                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2092                         break;
2093                 case PROPERTY_WORK:
2094                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2095                         break;
2096         }
2097         
2098         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2102 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2104         std::map<int, int> SplitPoints;
2105         std::map<int, int> SplitLength;
2107         int intPrevValue = 7;
2108         int intPref = 0;                        
2109         
2110         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2111         
2112         intPrevValue = 6;
2113         
2114         PropertyType PropType = PROPERTY_NONE;
2115                 
2116         // Look for type before continuing.
2117         
2118         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2119         
2120         std::map<int, wxString> *EmailList = NULL;
2121         std::map<int, wxString> *EmailListType = NULL;
2122         std::map<int, wxString> *EmailListAltID = NULL;
2123         std::map<int, wxString> *EmailListPID = NULL;
2124         std::map<int, wxString> *EmailListTokens = NULL;                
2125         std::map<int, int> *EmailListPref = NULL;
2127         switch(PropType){
2128                 case PROPERTY_NONE:
2129                         EmailList = &GeneralEmailList;
2130                         EmailListType = &GeneralEmailListType;
2131                         EmailListAltID = &GeneralEmailListAltID;
2132                         EmailListPID = &GeneralEmailListPID;
2133                         EmailListTokens = &GeneralEmailListTokens;              
2134                         EmailListPref = &GeneralEmailListPref;  
2135                         break;
2136                 case PROPERTY_HOME:
2137                         EmailList = &HomeEmailList;
2138                         EmailListType = &HomeEmailListType;
2139                         EmailListAltID = &HomeEmailListAltID;
2140                         EmailListPID = &HomeEmailListPID;
2141                         EmailListTokens = &HomeEmailListTokens;         
2142                         EmailListPref = &HomeEmailListPref;     
2143                         break;
2144                 case PROPERTY_WORK:
2145                         EmailList = &BusinessEmailList;
2146                         EmailListType = &BusinessEmailListType;
2147                         EmailListAltID = &BusinessEmailListAltID;
2148                         EmailListPID = &BusinessEmailListPID;
2149                         EmailListTokens = &BusinessEmailListTokens;             
2150                         EmailListPref = &BusinessEmailListPref; 
2151                         break;
2152         }
2153         
2154         intPrevValue = 6;
2155         
2156         std::map<int,int>::iterator SLiter;
2157         wxString PropertyData;
2158         wxString PropertyName;
2159         wxString PropertyValue;
2160         wxString PropertyTokens;
2161         bool FirstToken = TRUE;
2162         
2163         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2164         intiter != SplitPoints.end(); ++intiter){
2165         
2166                 SLiter = SplitLength.find(intiter->first);
2167         
2168                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2169                 
2170                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2171                 PropertyName = PropertyElement.GetNextToken();                          
2172                 PropertyValue = PropertyElement.GetNextToken();
2173                 
2174                 intPrevValue = intiter->second;
2175                 
2176                 CaptureString(&PropertyValue, FALSE);
2177                 
2178                 // Process properties.
2179                 
2180                 if (PropertyName == wxT("ALTID")){
2182                         EmailListAltID->erase(*EmailCount);
2183                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2184                 
2185                 } else if (PropertyName == wxT("PID")){
2187                         EmailListPID->erase(*EmailCount);
2188                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2189                 
2190                 } else if (PropertyName == wxT("PREF")){
2191                         
2192                         int PriorityNumber = 0;
2193                         bool ValidNumber = TRUE;
2194                         
2195                         try{
2196                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2197                         }
2198                         
2199                         catch(std::invalid_argument &e){
2200                                 ValidNumber = FALSE;
2201                         }
2203                         if (ValidNumber == TRUE){
2205                                 EmailListPref->erase(*EmailCount);
2206                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2208                         }
2209                 
2210                 } else {
2211                 
2212                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2213                         
2214                                 if (FirstToken == TRUE){
2215                                 
2216                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2217                                         FirstToken = FALSE;
2218                                 
2219                                 } else {
2220                                 
2221                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2222                                 
2223                                 }
2224                         
2225                         }
2226                 
2227                 }
2228         
2229         }
2230         
2231         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2232         
2233         // Add the name token data.
2234         
2235         if (!PropertyTokens.IsEmpty()){
2236         
2237                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2238         
2239         }       
2244 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2246         std::map<int, int> SplitPoints;
2247         std::map<int, int> SplitLength;
2249         int intPrevValue = 6;
2250         int intPref = 0;                        
2251         
2252         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2253         
2254         intPrevValue = 5;
2255         
2256         PropertyType PropType = PROPERTY_NONE;
2257                 
2258         // Look for type before continuing.
2259         
2260         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2261         
2262         std::map<int, wxString> *IMList = NULL;
2263         std::map<int, wxString> *IMListType = NULL;
2264         std::map<int, wxString> *IMListAltID = NULL;
2265         std::map<int, wxString> *IMListPID = NULL;
2266         std::map<int, wxString> *IMListTokens = NULL;
2267         std::map<int, wxString> *IMListMediatype = NULL;        
2268         std::map<int, int> *IMListPref = NULL;
2270         switch(PropType){
2271                 case PROPERTY_NONE:
2272                         IMList = &GeneralIMList;
2273                         IMListType = &GeneralIMListType;
2274                         IMListAltID = &GeneralIMListAltID;
2275                         IMListPID = &GeneralIMListPID;
2276                         IMListTokens = &GeneralIMListTokens;
2277                         IMListMediatype = &GeneralIMListMediatype;
2278                         IMListPref = &GeneralIMListPref;        
2279                         break;
2280                 case PROPERTY_HOME:
2281                         IMList = &HomeIMList;
2282                         IMListType = &HomeIMListType;
2283                         IMListAltID = &HomeIMListAltID;
2284                         IMListPID = &HomeIMListPID;
2285                         IMListTokens = &HomeIMListTokens;
2286                         IMListMediatype = &HomeIMListMediatype;         
2287                         IMListPref = &HomeIMListPref;   
2288                         break;
2289                 case PROPERTY_WORK:
2290                         IMList = &BusinessIMList;
2291                         IMListType = &BusinessIMListType;
2292                         IMListAltID = &BusinessIMListAltID;
2293                         IMListPID = &BusinessIMListPID;
2294                         IMListTokens = &BusinessIMListTokens;   
2295                         IMListMediatype = &BusinessIMListMediatype;     
2296                         IMListPref = &BusinessIMListPref;       
2297                         break;
2298         }
2299         
2300         intPrevValue = 5;
2301         
2302         std::map<int,int>::iterator SLiter;
2303         wxString PropertyData;
2304         wxString PropertyName;
2305         wxString PropertyValue;
2306         wxString PropertyTokens;
2307         bool FirstToken = TRUE;
2308         
2309         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2310         intiter != SplitPoints.end(); ++intiter){
2311         
2312                 SLiter = SplitLength.find(intiter->first);
2313         
2314                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2315                 
2316                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2317                 PropertyName = PropertyElement.GetNextToken();                          
2318                 PropertyValue = PropertyElement.GetNextToken();
2319                 
2320                 intPrevValue = intiter->second;
2321                 
2322                 CaptureString(&PropertyValue, FALSE);
2323                 
2324                 // Process properties.
2325                 
2326                 if (PropertyName == wxT("ALTID")){
2328                         IMListAltID->erase(*IMCount);
2329                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2330                 
2331                 } else if (PropertyName == wxT("PID")){
2333                         IMListPID->erase(*IMCount);
2334                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2335                 
2336                 } else if (PropertyName == wxT("MEDIATYPE")){
2338                         IMListMediatype->erase(*IMCount);
2339                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2340                 
2341                 } else if (PropertyName == wxT("PREF")){
2342                         
2343                         int PriorityNumber = 0;
2344                         bool ValidNumber = TRUE;
2345                         
2346                         try{
2347                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2348                         }
2349                         
2350                         catch(std::invalid_argument &e){
2351                                 ValidNumber = FALSE;
2352                         }
2354                         if (ValidNumber == TRUE){
2356                                 IMListPref->erase(*IMCount);
2357                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2359                         }
2360                 
2361                 } else {
2362                 
2363                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2364                         
2365                                 if (FirstToken == TRUE){
2366                                 
2367                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2368                                         FirstToken = FALSE;
2369                                 
2370                                 } else {
2371                                 
2372                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2373                                 
2374                                 }
2375                         
2376                         }
2377                 
2378                 }
2379         
2380         }
2381                 
2382         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2383         
2384         // Add the name token data.
2385         
2386         if (!PropertyTokens.IsEmpty()){
2387         
2388                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2389         
2390         }
2394 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2396         std::map<int, int> SplitPoints;
2397         std::map<int, int> SplitLength;
2398         std::map<int, int>::iterator SLiter;
2399         
2400         int intPref = 0;
2401         
2402         PropertyType PropType = PROPERTY_NONE;
2403                 
2404         // Look for type before continuing.
2405         
2406         wxString TelTypeUI;
2407         wxString TelTypeDetail;
2408         wxString PropertyData;
2409         wxString PropertyName;
2410         wxString PropertyValue;
2411         wxString PropertyTokens;
2412         
2413         std::map<int,int> TypeSplitPoints;
2414         std::map<int,int> TypeSplitLength;
2415         std::map<int,int>::iterator TSLiter;
2416         
2417         int intSplitSize = 0;
2418         int intSplitsFound = 0;
2419         int intSplitPoint = 0;
2420         int intType = 0;
2421         int intPrevValue = 5;
2422                 
2423         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2424         
2425         intPrevValue = 4;
2426         
2427         // Look for type before continuing.
2428         
2429         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2430         intiter != SplitPoints.end(); ++intiter){
2431         
2432                 SLiter = SplitLength.find(intiter->first);
2433         
2434                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2435                 
2436                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2437                 PropertyName = PropertyElement.GetNextToken();                          
2438                 PropertyValue = PropertyElement.GetNextToken();
2439                 
2440                 intPrevValue = intiter->second;
2442                 if (PropertyName == wxT("TYPE")){
2443                 
2444                         // Process each value in type and translate each
2445                         // part.
2446                 
2447                         // Strip out the quotes if they are there.
2448                 
2449                         size_t intPropertyValueLen = PropertyValue.Len();
2450                 
2451                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2452                         
2453                                 PropertyValue.Trim();
2454                                 PropertyValue.RemoveLast();
2455                         
2456                         }                               
2457                 
2458                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2459                         
2460                                 PropertyValue.Remove(0, 1);
2461                         
2462                         }
2463                         
2464                         TelTypeDetail = PropertyValue;
2465                         
2466                         intSplitSize = 0;
2467                         intSplitsFound = 0;
2468                         intSplitPoint = 0;
2469                         
2470                         for (int i = 0; i <= intPropertyValueLen; i++){
2471         
2472                                 intSplitSize++;
2473         
2474                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2475         
2476                                         if (intSplitsFound == 0){
2478                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2479                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2480                         
2481                                         } else {
2482                         
2483                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2484                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2485                         
2486                                         }                       
2488                                         intSplitsFound++;
2489                                         i++;
2490                                         intSplitPoint = i;
2491                                         intSplitSize = 0;
2492         
2493                                 }
2494         
2495                         }
2496                         
2497                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2498                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2499                 
2500                         int intTypeSeek = 0;
2501                 
2502                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2503                         typeiter != TypeSplitPoints.end(); ++typeiter){
2504                         
2505                                 wxString TypePropertyName;
2506                                 
2507                                 TSLiter = TypeSplitLength.find(typeiter->first);
2508                                 
2509                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2510                                 
2511                                 if (intTypeSeek == 0){
2512                                 
2513                                 
2514                                 } else {
2515                                                                                 
2516                                         TelTypeUI.Append(wxT(","));                                                     
2517                                 
2518                                 }
2519                         
2520                                 if (TypePropertyName == wxT("home")){
2521                                 
2522                                         PropType = PROPERTY_HOME;
2523                                 
2524                                 } else if (TypePropertyName == wxT("work")){
2525                                 
2526                                         PropType = PROPERTY_WORK;
2527                                                                         
2528                                 }
2529                                 
2530                                 
2531                                 if (TypePropertyName == wxT("text")){
2532                                 
2533                                         TelTypeUI.Append(_("text"));
2534                                         intTypeSeek++;
2535                                 
2536                                 } else if (TypePropertyName == wxT("voice")){
2537                                 
2538                                         TelTypeUI.Append(_("voice"));
2539                                         intTypeSeek++;
2540                                 
2541                                 } else if (TypePropertyName == wxT("fax")){
2542                                 
2543                                         TelTypeUI.Append(_("fax"));
2544                                         intTypeSeek++;
2545                                 
2546                                 } else if (TypePropertyName == wxT("cell")){
2547                                 
2548                                         TelTypeUI.Append(_("mobile"));
2549                                         intTypeSeek++;
2550                                 
2551                                 } else if (TypePropertyName == wxT("video")){
2552                                 
2553                                         TelTypeUI.Append(_("video"));
2554                                         intTypeSeek++;
2555                                 
2556                                 } else if (TypePropertyName == wxT("pager")){
2557                                 
2558                                         TelTypeUI.Append(_("pager"));
2559                                         intTypeSeek++;
2560                                 
2561                                 } else if (TypePropertyName == wxT("textphone")){
2562                                 
2563                                         TelTypeUI.Append(_("textphone"));
2564                                         intTypeSeek++;
2565                                 
2566                                 }
2567                         
2568                         }
2569                 
2570                 }
2571                 
2572         }
2573         
2574         std::map<int, wxString> *TelephoneList = NULL;
2575         std::map<int, wxString> *TelephoneListType = NULL;
2576         std::map<int, wxString> *TelephoneListAltID = NULL;
2577         std::map<int, wxString> *TelephoneListPID = NULL;
2578         std::map<int, wxString> *TelephoneListTokens = NULL;
2579         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2580         std::map<int, int> *TelephoneListPref = NULL;
2582         switch(PropType){
2583                 case PROPERTY_NONE:
2584                         TelephoneList = &GeneralTelephoneList;
2585                         TelephoneListType = &GeneralTelephoneListType;
2586                         TelephoneListAltID = &GeneralTelephoneListAltID;
2587                         TelephoneListPID = &GeneralTelephoneListPID;
2588                         TelephoneListTokens = &GeneralTelephoneListTokens;
2589                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2590                         TelephoneListPref = &GeneralTelephoneListPref;  
2591                         break;
2592                 case PROPERTY_HOME:
2593                         TelephoneList = &HomeTelephoneList;
2594                         TelephoneListType = &HomeTelephoneListType;
2595                         TelephoneListAltID = &HomeTelephoneListAltID;
2596                         TelephoneListPID = &HomeTelephoneListPID;
2597                         TelephoneListTokens = &HomeTelephoneListTokens;
2598                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2599                         TelephoneListPref = &HomeTelephoneListPref;     
2600                         break;
2601                 case PROPERTY_WORK:
2602                         TelephoneList = &BusinessTelephoneList;
2603                         TelephoneListType = &BusinessTelephoneListType;
2604                         TelephoneListAltID = &BusinessTelephoneListAltID;
2605                         TelephoneListPID = &BusinessTelephoneListPID;
2606                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2607                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2608                         TelephoneListPref = &BusinessTelephoneListPref; 
2609                         break;
2610         }
2611                 
2612         // Process the properties.
2613         
2614         bool FirstToken = TRUE;
2615         
2616         intPrevValue = 5;
2617         SplitPoints.clear();
2618         SplitLength.clear();
2620         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2622         intPrevValue = 4;
2623         
2624         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2625         intiter != SplitPoints.end(); ++intiter){
2626         
2627                 SLiter = SplitLength.find(intiter->first);
2628         
2629                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2630                 
2631                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2632                 PropertyName = PropertyElement.GetNextToken();                          
2633                 PropertyValue = PropertyElement.GetNextToken();
2634                 
2635                 intPrevValue = intiter->second;
2636                 
2637                 CaptureString(&PropertyValue, FALSE);
2638                 
2639                 // Process properties.
2640                 
2641                 if (PropertyName == wxT("ALTID")){
2643                         TelephoneListAltID->erase(*TelephoneCount);
2644                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2645                 
2646                 } else if (PropertyName == wxT("PID")){
2648                         TelephoneListPID->erase(*TelephoneCount);
2649                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2650                 
2651                 } else if (PropertyName == wxT("PREF")){
2652                         
2653                         int PriorityNumber = 0;
2654                         bool ValidNumber = TRUE;
2655                         
2656                         try{
2657                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2658                         }
2659                         
2660                         catch(std::invalid_argument &e){
2661                                 ValidNumber = FALSE;
2662                         }
2664                         if (ValidNumber == TRUE){
2666                                 TelephoneListPref->erase(*TelephoneCount);
2667                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2669                         }
2670                 
2671                 } else {
2672                 
2673                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2674                         
2675                                 if (FirstToken == TRUE){
2676                                 
2677                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2678                                         FirstToken = FALSE;
2679                                 
2680                                 } else {
2681                                 
2682                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2683                                 
2684                                 }
2685                         
2686                         }
2687                 
2688                 }
2689         
2690         }
2691                 
2692         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2693         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2694         
2695         // Add the name token data.
2696         
2697         if (!PropertyTokens.IsEmpty()){
2698         
2699                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2700         
2701         }
2705 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2707         std::map<int, int> SplitPoints;
2708         std::map<int, int> SplitLength;
2710         int intPrevValue = 6;
2711         int intPref = 0;                        
2712         
2713         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2714         
2715         intPrevValue = 5;
2716         
2717         PropertyType PropType = PROPERTY_NONE;
2718                 
2719         // Look for type before continuing.
2720         
2721         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2722         
2723         std::map<int, wxString> *LanguageList = NULL;
2724         std::map<int, wxString> *LanguageListType = NULL;
2725         std::map<int, wxString> *LanguageListAltID = NULL;
2726         std::map<int, wxString> *LanguageListPID = NULL;
2727         std::map<int, wxString> *LanguageListTokens = NULL;
2728         std::map<int, int> *LanguageListPref = NULL;
2730         switch(PropType){
2731                 case PROPERTY_NONE:
2732                         LanguageList = &GeneralLanguageList;
2733                         LanguageListType = &GeneralLanguageListType;
2734                         LanguageListAltID = &GeneralLanguageListAltID;
2735                         LanguageListPID = &GeneralLanguageListPID;
2736                         LanguageListTokens = &GeneralLanguageListTokens;
2737                         LanguageListPref = &GeneralLanguageListPref;    
2738                         break;
2739                 case PROPERTY_HOME:
2740                         LanguageList = &HomeLanguageList;
2741                         LanguageListType = &HomeLanguageListType;
2742                         LanguageListAltID = &HomeLanguageListAltID;
2743                         LanguageListPID = &HomeLanguageListPID;
2744                         LanguageListTokens = &HomeLanguageListTokens;   
2745                         LanguageListPref = &HomeLanguageListPref;       
2746                         break;
2747                 case PROPERTY_WORK:
2748                         LanguageList = &BusinessLanguageList;
2749                         LanguageListType = &BusinessLanguageListType;
2750                         LanguageListAltID = &BusinessLanguageListAltID;
2751                         LanguageListPID = &BusinessLanguageListPID;
2752                         LanguageListTokens = &BusinessLanguageListTokens;       
2753                         LanguageListPref = &BusinessLanguageListPref;
2754                         break;
2755         }
2756         
2757         intPrevValue = 5;
2758         
2759         std::map<int,int>::iterator SLiter;
2760         wxString PropertyData;
2761         wxString PropertyName;
2762         wxString PropertyValue;
2763         wxString PropertyTokens;
2764         bool FirstToken = TRUE;
2765         
2766         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2767         intiter != SplitPoints.end(); ++intiter){
2768         
2769                 SLiter = SplitLength.find(intiter->first);
2770         
2771                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2772                 
2773                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2774                 PropertyName = PropertyElement.GetNextToken();                          
2775                 PropertyValue = PropertyElement.GetNextToken();
2776                 
2777                 intPrevValue = intiter->second;
2778                 
2779                 CaptureString(&PropertyValue, FALSE);
2780                 
2781                 // Process properties.
2782                 
2783                 if (PropertyName == wxT("ALTID")){
2785                         LanguageListAltID->erase(*LanguageCount);
2786                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2787                 
2788                 } else if (PropertyName == wxT("PID")){
2790                         LanguageListPID->erase(*LanguageCount);
2791                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2792                 
2793                 } else if (PropertyName == wxT("PREF")){
2794                         
2795                         int PriorityNumber = 0;
2796                         bool ValidNumber = TRUE;
2797                         
2798                         try{
2799                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2800                         }
2801                         
2802                         catch(std::invalid_argument &e){
2803                                 ValidNumber = FALSE;
2804                         }
2806                         if (ValidNumber == TRUE){
2808                                 LanguageListPref->erase(*LanguageCount);
2809                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2811                         }
2812                 
2813                 } else {
2814                 
2815                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2816                         
2817                                 if (FirstToken == TRUE){
2818                                 
2819                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2820                                         FirstToken = FALSE;
2821                                 
2822                                 } else {
2823                                 
2824                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2825                                 
2826                                 }
2827                         
2828                         }
2829                 
2830                 }
2831         
2832         }
2833                 
2834         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2835         
2836         // Add the name token data.
2837         
2838         if (!PropertyTokens.IsEmpty()){
2839         
2840                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2841         
2842         }
2846 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2848         std::map<int, int> SplitPoints;
2849         std::map<int, int> SplitLength;
2851         int intPrevValue = 5;
2852         int intPref = 0;                        
2853         
2854         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2855         
2856         intPrevValue = 4;
2857         
2858         PropertyType PropType = PROPERTY_NONE;
2859                 
2860         // Look for type before continuing.
2861         
2862         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2863         
2864         std::map<int, wxString> *GeopositionList = NULL;
2865         std::map<int, wxString> *GeopositionListType = NULL;
2866         std::map<int, wxString> *GeopositionListAltID = NULL;
2867         std::map<int, wxString> *GeopositionListPID = NULL;
2868         std::map<int, wxString> *GeopositionListTokens = NULL;
2869         std::map<int, wxString> *GeopositionListMediatype = NULL;
2870         std::map<int, int> *GeopositionListPref = NULL;
2872         switch(PropType){
2873                 case PROPERTY_NONE:
2874                         GeopositionList = &GeneralGeographyList;
2875                         GeopositionListType = &GeneralGeographyListType;
2876                         GeopositionListAltID = &GeneralGeographyListAltID;
2877                         GeopositionListPID = &GeneralGeographyListPID;
2878                         GeopositionListTokens = &GeneralGeographyListTokens;
2879                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2880                         GeopositionListPref = &GeneralGeographyListPref;        
2881                         break;
2882                 case PROPERTY_HOME:
2883                         GeopositionList = &HomeGeographyList;
2884                         GeopositionListType = &HomeGeographyListType;
2885                         GeopositionListAltID = &HomeGeographyListAltID;
2886                         GeopositionListPID = &HomeGeographyListPID;
2887                         GeopositionListTokens = &HomeGeographyListTokens;
2888                         GeopositionListMediatype = &HomeGeographyListMediatype;
2889                         GeopositionListPref = &HomeGeographyListPref;   
2890                         break;
2891                 case PROPERTY_WORK:
2892                         GeopositionList = &BusinessGeographyList;
2893                         GeopositionListType = &BusinessGeographyListType;
2894                         GeopositionListAltID = &BusinessGeographyListAltID;
2895                         GeopositionListPID = &BusinessGeographyListPID;
2896                         GeopositionListTokens = &BusinessGeographyListTokens;
2897                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2898                         GeopositionListPref = &BusinessGeographyListPref;
2899                         break;
2900         }
2901         
2902         intPrevValue = 4;
2903         
2904         std::map<int,int>::iterator SLiter;
2905         wxString PropertyData;
2906         wxString PropertyName;
2907         wxString PropertyValue;
2908         wxString PropertyTokens;
2909         bool FirstToken = TRUE;
2910         
2911         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2912         intiter != SplitPoints.end(); ++intiter){
2913         
2914                 SLiter = SplitLength.find(intiter->first);
2915         
2916                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2917                 
2918                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2919                 PropertyName = PropertyElement.GetNextToken();                          
2920                 PropertyValue = PropertyElement.GetNextToken();
2921                 
2922                 intPrevValue = intiter->second;
2923                 
2924                 CaptureString(&PropertyValue, FALSE);
2925                 
2926                 // Process properties.
2927                 
2928                 if (PropertyName == wxT("ALTID")){
2930                         GeopositionListAltID->erase(*GeographicCount);
2931                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2932                 
2933                 } else if (PropertyName == wxT("PID")){
2935                         GeopositionListPID->erase(*GeographicCount);
2936                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2937                 
2938                 } else if (PropertyName == wxT("MEDIATYPE")){
2940                         GeopositionListMediatype->erase(*GeographicCount);
2941                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2942                 
2943                 } else if (PropertyName == wxT("PREF")){
2944                         
2945                         int PriorityNumber = 0;
2946                         bool ValidNumber = TRUE;
2947                         
2948                         try{
2949                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2950                         }
2951                         
2952                         catch(std::invalid_argument &e){
2953                                 ValidNumber = FALSE;
2954                         }
2956                         if (ValidNumber == TRUE){
2958                                 GeopositionListPref->erase(*GeographicCount);
2959                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2961                         }
2962                 
2963                 } else {
2964                 
2965                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2966                         
2967                                 if (FirstToken == TRUE){
2968                                 
2969                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2970                                         FirstToken = FALSE;
2971                                 
2972                                 } else {
2973                                 
2974                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2975                                 
2976                                 }
2977                         
2978                         }
2979                 
2980                 }
2981         
2982         }
2983                 
2984         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2985         
2986         // Add the name token data.
2987         
2988         if (!PropertyTokens.IsEmpty()){
2989         
2990                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2991         
2992         }
2996 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2998         size_t intPropertyLen = PropertySeg1.Len();
2999         std::map<int, int> SplitPoints;
3000         std::map<int, int> SplitLength;
3001         std::map<int, int>::iterator SLiter;                    
3002         wxString PropertyData;
3003         wxString PropertyName;
3004         wxString PropertyValue;
3005         wxString PropertyTokens;
3006         wxString RelatedType;
3007         wxString RelatedTypeOriginal;                   
3008         wxString RelatedName;
3009         bool FirstToken = TRUE;                 
3010         int intSplitsFound = 0;
3011         int intSplitSize = 0;
3012         int intPrevValue = 9;
3013         int intPref = 0;
3014         long ListCtrlIndex;
3015         
3016         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3017         
3018         intPrevValue = 8;
3019         
3020         // Look for type before continuing.
3021         
3022         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3023         intiter != SplitPoints.end(); ++intiter){
3024         
3025                 SLiter = SplitLength.find(intiter->first);
3026         
3027                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3028                 
3029                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3030                 PropertyName = PropertyElement.GetNextToken();                          
3031                 PropertyValue = PropertyElement.GetNextToken();
3032                 
3033                 intPrevValue = intiter->second;
3034                 
3035                 // Process these.
3036                 
3037                 RelatedTypeOriginal = PropertyValue;
3038                 
3039                 if (PropertyName == wxT("TYPE")){
3040                 
3041                         if (PropertyValue == wxT("contact")){
3043                                 RelatedType = _("Contact");
3045                         } else if (PropertyValue == wxT("acquaintance")){
3047                                 RelatedType = _("Acquaintance");
3049                         } else if (PropertyValue == wxT("friend")){
3051                                 RelatedType = _("Friend");
3053                         } else if (PropertyValue == wxT("met")){
3055                                 RelatedType = _("Met");
3057                         } else if (PropertyValue == wxT("co-worker")){
3059                                 RelatedType = _("Co-worker");
3061                         } else if (PropertyValue == wxT("colleague")){
3063                                 RelatedType = _("Colleague");
3065                         } else if (PropertyValue == wxT("co-resident")){
3067                                 RelatedType = _("Co-resident");
3069                         } else if (PropertyValue == wxT("neighbor")){
3071                                 RelatedType = _("Neighbour");
3073                         } else if (PropertyValue == wxT("child")){
3075                                 RelatedType = _("Child");
3077                         } else if (PropertyValue == wxT("parent")){
3079                                 RelatedType = _("Parent");
3081                         } else if (PropertyValue == wxT("sibling")){
3083                                 RelatedType = _("Sibling");
3085                         } else if (PropertyValue == wxT("spouse")){
3087                                 RelatedType = _("Spouse");
3089                         } else if (PropertyValue == wxT("kin")){
3091                                 RelatedType = _("Kin");
3093                         } else if (PropertyValue == wxT("muse")){
3095                                 RelatedType = _("Muse");
3097                         } else if (PropertyValue == wxT("crush")){
3099                                 RelatedType = _("Crush");
3101                         } else if (PropertyValue == wxT("date")){
3103                                 RelatedType = _("Date");
3105                         } else if (PropertyValue == wxT("sweetheart")){
3107                                 RelatedType = _("Sweetheart");
3109                         } else if (PropertyValue == wxT("me")){
3111                                 RelatedType = _("Me");
3113                         } else if (PropertyValue == wxT("agent")){
3115                                 RelatedType = _("Agent");
3117                         } else if (PropertyValue == wxT("emergency")){
3119                                 RelatedType = _("Emergency");
3121                         } else {
3123                                 RelatedType = PropertyValue;
3125                         }
3126                 
3127                 }
3128         
3129         }
3130         
3131         intPrevValue = 8;                       
3132         
3133         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3134         intiter != SplitPoints.end(); ++intiter){
3135         
3136                 SLiter = SplitLength.find(intiter->first);
3137         
3138                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3139                 
3140                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3141                 PropertyName = PropertyElement.GetNextToken();                          
3142                 PropertyValue = PropertyElement.GetNextToken();
3143                 
3144                 intPrevValue = intiter->second;
3145                 
3146                 // Process properties.
3147                 
3148                 size_t intPropertyValueLen = PropertyValue.Len();
3149                 
3150                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3151                         
3152                         PropertyValue.Trim();
3153                         PropertyValue.RemoveLast();
3154                         
3155                 }                               
3156                 
3157                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3158                         
3159                         PropertyValue.Remove(0, 1);
3160                         
3161                 }
3162                 
3163                 CaptureString(&PropertyValue, FALSE);
3164                         
3165                 if (PropertyName == wxT("ALTID")){
3167                         GeneralRelatedListAltID.erase(*RelatedCount);
3168                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3169                 
3170                 } else if (PropertyName == wxT("PID")){
3172                         GeneralRelatedListPID.erase(*RelatedCount);
3173                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3174                 
3175                 } else if (PropertyName == wxT("PREF")){
3176                         
3177                         int PriorityNumber = 0;
3178                         bool ValidNumber = TRUE;
3179                         
3180                         try{
3181                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3182                         }
3183                         
3184                         catch(std::invalid_argument &e){
3185                                 ValidNumber = FALSE;
3186                         }
3188                         if (ValidNumber == TRUE){
3190                                 GeneralRelatedListPref.erase(*RelatedCount);
3191                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3193                         }
3194                 
3195                 } else if (PropertyName == wxT("LANGUAGE")){
3196                 
3197                         GeneralRelatedListLanguage.erase(*RelatedCount);
3198                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3199                 
3200                 } else if (PropertyName != wxT("TYPE")) {
3201                 
3202                         // Something else we don't know about so append
3203                         // to the tokens variable.
3204                 
3205                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3206                 
3207                                 if (FirstToken == TRUE){
3208                         
3209                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3210                                         FirstToken = FALSE;
3211                         
3212                                 } else {
3213                         
3214                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3215                         
3216                                 }
3217                 
3218                         }
3219                 
3220                 }
3221         
3222         }                                       
3223         
3224         // Add the data to the General/Home/Work address variables.
3225                                 
3226         GeneralRelatedList.erase(*RelatedCount);
3227         GeneralRelatedListRelType.erase(*RelatedCount);
3228         GeneralRelatedListType.erase(*RelatedCount);
3229         GeneralRelatedListTokens.erase(*RelatedCount);
3230         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3231         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3232         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3233         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3237 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3239         std::map<int, int> SplitPoints;
3240         std::map<int, int> SplitLength;
3241         std::map<int, int>::iterator SLiter;                    
3242         wxString PropertyData;
3243         wxString PropertyName;
3244         wxString PropertyValue;
3245         wxString PropertyTokens;
3246         bool FirstToken = TRUE;
3247         int intPrevValue = 5;
3248         int intPref = 0;                        
3249         int intType = 0;
3250         long ListCtrlIndex;
3251         
3252         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3253         
3254         intPrevValue = 4;
3255         
3256         PropertyType PropType = PROPERTY_NONE;
3257                 
3258         // Look for type before continuing.
3259         
3260         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3261         
3262         // Setup the pointers.
3263         
3264         std::map<int, wxString> *WebsiteList = NULL;
3265         std::map<int, wxString> *WebsiteListAltID = NULL;
3266         std::map<int, wxString> *WebsiteListPID = NULL;
3267         std::map<int, wxString> *WebsiteListType = NULL;
3268         std::map<int, wxString> *WebsiteListTokens = NULL;
3269         std::map<int, wxString> *WebsiteListMediatype = NULL;
3270         std::map<int, int> *WebsiteListPref = NULL;
3271         
3272         // Setup blank lines for later on.
3273         
3274         switch(PropType){
3275                 case PROPERTY_NONE:
3276                         WebsiteList = &GeneralWebsiteList;
3277                         WebsiteListType = &GeneralWebsiteListType;
3278                         WebsiteListAltID = &GeneralWebsiteListAltID;
3279                         WebsiteListPID = &GeneralWebsiteListPID;
3280                         WebsiteListTokens = &GeneralWebsiteListTokens;
3281                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3282                         WebsiteListPref = &GeneralWebsiteListPref;      
3283                         break;
3284                 case PROPERTY_HOME:
3285                         WebsiteList = &HomeWebsiteList;
3286                         WebsiteListType = &HomeWebsiteListType;
3287                         WebsiteListAltID = &HomeWebsiteListAltID;
3288                         WebsiteListPID = &HomeWebsiteListPID;
3289                         WebsiteListTokens = &HomeWebsiteListTokens;
3290                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3291                         WebsiteListPref = &HomeWebsiteListPref; 
3292                         break;
3293                 case PROPERTY_WORK:
3294                         WebsiteList = &BusinessWebsiteList;
3295                         WebsiteListType = &BusinessWebsiteListType;
3296                         WebsiteListAltID = &BusinessWebsiteListAltID;
3297                         WebsiteListPID = &BusinessWebsiteListPID;
3298                         WebsiteListTokens = &BusinessWebsiteListTokens;
3299                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3300                         WebsiteListPref = &BusinessWebsiteListPref;
3301                         break;
3302         }
3303         
3304         intPrevValue = 4;
3305         
3306         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3307         intiter != SplitPoints.end(); ++intiter){
3308         
3309                 SLiter = SplitLength.find(intiter->first);
3310         
3311                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3312                 
3313                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3314                 PropertyName = PropertyElement.GetNextToken();                          
3315                 PropertyValue = PropertyElement.GetNextToken();
3316                 
3317                 intPrevValue = intiter->second;
3318                 
3319                 // Process properties.
3320                 
3321                 size_t intPropertyValueLen = PropertyValue.Len();
3322                 
3323                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3324                         
3325                         PropertyValue.Trim();
3326                         PropertyValue.RemoveLast();
3327                         
3328                 }                               
3329                 
3330                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3331                         
3332                         PropertyValue.Remove(0, 1);
3333                         
3334                 }
3335                 
3336                 CaptureString(&PropertyValue, FALSE);
3337                 
3338                 if (PropertyName == wxT("ALTID")){
3340                         WebsiteListAltID->erase(*URLCount);
3341                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3342                 
3343                 } else if (PropertyName == wxT("PID")){
3345                         WebsiteListPID->erase(*URLCount);
3346                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3347                         
3348                 } else if (PropertyName == wxT("PREF")){
3349                         
3350                         int PriorityNumber = 0;
3351                         bool ValidNumber = TRUE;
3352                         
3353                         try{
3354                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3355                         }
3356                         
3357                         catch(std::invalid_argument &e){
3358                                 ValidNumber = FALSE;
3359                         }
3361                         if (ValidNumber == TRUE){
3363                                 WebsiteListPref->erase(*URLCount);
3364                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3366                         }
3367                                         
3368                 } else if (PropertyName == wxT("MEDIATYPE")){
3369                 
3370                         WebsiteListMediatype->erase(*URLCount);
3371                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3372                 
3373                 } else {
3374                 
3375                         // Something else we don't know about so append
3376                         // to the tokens variable.
3377                 
3378                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3379                 
3380                                 if (FirstToken == TRUE){
3381                         
3382                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3383                                         FirstToken = FALSE;
3384                         
3385                                 } else {
3386                         
3387                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3388                         
3389                                 }
3390                 
3391                         }
3392                 
3393                 }
3394         
3395         }
3396         
3397         // Add the data to the General/Home/Work address variables.
3398         
3399         CaptureString(&PropertySeg2, FALSE);
3400                         
3401         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3402         
3403         if (!PropertyTokens.IsEmpty()){
3404         
3405                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3406                         
3407         }
3408         
3411 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3413         std::map<int, int> SplitPoints;
3414         std::map<int, int> SplitLength;
3415         std::map<int, int>::iterator SLiter;                    
3416         wxString PropertyData;
3417         wxString PropertyName;
3418         wxString PropertyValue;
3419         wxString PropertyTokens;
3420         bool FirstToken = TRUE;
3421         int intPrevValue = 7;
3422         int intPref = 0;                        
3423         int intType = 0;
3424         long ListCtrlIndex;
3425         
3426         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3427         
3428         intPrevValue = 6;
3429         
3430         PropertyType PropType = PROPERTY_NONE;
3431                 
3432         // Look for type before continuing.
3433         
3434         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3435         
3436         // Setup the pointers.
3437         
3438         std::map<int, wxString> *TitleList = NULL;
3439         std::map<int, wxString> *TitleListAltID = NULL;
3440         std::map<int, wxString> *TitleListPID = NULL;
3441         std::map<int, wxString> *TitleListType = NULL;
3442         std::map<int, wxString> *TitleListTokens = NULL;
3443         std::map<int, wxString> *TitleListLanguage = NULL;
3444         std::map<int, int> *TitleListPref = NULL;
3445         
3446         // Setup blank lines for later on.
3447         
3448         switch(PropType){
3449                 case PROPERTY_NONE:
3450                         TitleList = &GeneralTitleList;
3451                         TitleListType = &GeneralTitleListType;
3452                         TitleListAltID = &GeneralTitleListAltID;
3453                         TitleListPID = &GeneralTitleListPID;
3454                         TitleListTokens = &GeneralTitleListTokens;
3455                         TitleListLanguage = &GeneralTitleListLanguage;
3456                         TitleListPref = &GeneralTitleListPref;  
3457                         break;
3458                 case PROPERTY_HOME:
3459                         TitleList = &HomeTitleList;
3460                         TitleListType = &HomeTitleListType;
3461                         TitleListAltID = &HomeTitleListAltID;
3462                         TitleListPID = &HomeTitleListPID;
3463                         TitleListTokens = &HomeTitleListTokens;
3464                         TitleListLanguage = &HomeTitleListLanguage;
3465                         TitleListPref = &HomeTitleListPref;     
3466                         break;
3467                 case PROPERTY_WORK:
3468                         TitleList = &BusinessTitleList;
3469                         TitleListType = &BusinessTitleListType;
3470                         TitleListAltID = &BusinessTitleListAltID;
3471                         TitleListPID = &BusinessTitleListPID;
3472                         TitleListTokens = &BusinessTitleListTokens;
3473                         TitleListLanguage = &BusinessTitleListLanguage; 
3474                         TitleListPref = &BusinessTitleListPref;
3475                         break;
3476         }
3478         intPrevValue = 6;
3479                 
3480         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3481         intiter != SplitPoints.end(); ++intiter){
3482         
3483                 SLiter = SplitLength.find(intiter->first);
3484         
3485                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3486                 
3487                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3488                 PropertyName = PropertyElement.GetNextToken();                          
3489                 PropertyValue = PropertyElement.GetNextToken();
3490                 
3491                 intPrevValue = intiter->second;
3492                 
3493                 // Process properties.
3494                 
3495                 size_t intPropertyValueLen = PropertyValue.Len();
3496                 
3497                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3498                         
3499                         PropertyValue.Trim();
3500                         PropertyValue.RemoveLast();
3501                         
3502                 }                               
3503                 
3504                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3505                         
3506                         PropertyValue.Remove(0, 1);
3507                         
3508                 }                               
3509                 
3510                 CaptureString(&PropertyValue, FALSE);
3511                 
3512                 if (PropertyName == wxT("ALTID")){
3513                 
3514                         TitleListAltID->erase(*TitleCount);
3515                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3516                 
3517                 } else if (PropertyName == wxT("PID")){
3519                         TitleListPID->erase(*TitleCount);
3520                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3521                 
3522                 } else if (PropertyName == wxT("PREF")){
3523                                 
3524                         int PriorityNumber = 0;
3525                         bool ValidNumber = TRUE;
3526                         
3527                         try{
3528                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3529                         }
3530                         
3531                         catch(std::invalid_argument &e){
3532                                 ValidNumber = FALSE;
3533                         }
3535                         if (ValidNumber == TRUE){
3537                                 TitleListPref->erase(*TitleCount);
3538                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3540                         }
3541                                         
3542                 } else if (PropertyName == wxT("LANGUAGE")){
3543                 
3544                         TitleListLanguage->erase(*TitleCount);
3545                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3546                 
3547                 } else {
3548                 
3549                         // Something else we don't know about so append
3550                         // to the tokens variable.
3551                 
3552                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3553                 
3554                                 if (FirstToken == TRUE){
3555                         
3556                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3557                                         FirstToken = FALSE;
3558                         
3559                                 } else {
3560                         
3561                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3562                         
3563                                 }
3564                 
3565                         }
3566                 
3567                 }
3568         
3569         }
3570         
3571         // Add the data to the General/Home/Work address variables.
3572         
3573         CaptureString(&PropertySeg2, FALSE);
3575         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3576         
3577         if (!PropertyTokens.IsEmpty()){
3578         
3579                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3580                         
3581         }
3585 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3587         std::map<int, int> SplitPoints;
3588         std::map<int, int> SplitLength;
3589         std::map<int, int>::iterator SLiter;                    
3590         wxString PropertyData;
3591         wxString PropertyName;
3592         wxString PropertyValue;
3593         wxString PropertyTokens;
3594         bool FirstToken = TRUE;
3595         int intPrevValue = 6;
3596         int intPref = 0;                        
3597         int intType = 0;
3598         long ListCtrlIndex;
3599         
3600         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3601         
3602         intPrevValue = 5;
3603         
3604         PropertyType PropType = PROPERTY_NONE;
3605                 
3606         // Look for type before continuing.
3607         
3608         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3609         
3610         // Setup the pointers.
3611         
3612         std::map<int, wxString> *RoleList = NULL;
3613         std::map<int, wxString> *RoleListAltID = NULL;
3614         std::map<int, wxString> *RoleListPID = NULL;
3615         std::map<int, wxString> *RoleListType = NULL;
3616         std::map<int, wxString> *RoleListTokens = NULL;
3617         std::map<int, wxString> *RoleListLanguage = NULL;
3618         std::map<int, int> *RoleListPref = NULL;
3619         
3620         // Setup blank lines for later on.
3621         
3622         switch(PropType){
3623                 case PROPERTY_NONE:
3624                         RoleList = &GeneralRoleList;
3625                         RoleListType = &GeneralRoleListType;
3626                         RoleListAltID = &GeneralRoleListAltID;
3627                         RoleListPID = &GeneralRoleListPID;
3628                         RoleListTokens = &GeneralRoleListTokens;
3629                         RoleListLanguage = &GeneralRoleListLanguage;
3630                         RoleListPref = &GeneralRoleListPref;    
3631                         break;
3632                 case PROPERTY_HOME:
3633                         RoleList = &HomeRoleList;
3634                         RoleListType = &HomeRoleListType;
3635                         RoleListAltID = &HomeRoleListAltID;
3636                         RoleListPID = &HomeRoleListPID;
3637                         RoleListTokens = &HomeRoleListTokens;
3638                         RoleListLanguage = &HomeRoleListLanguage;
3639                         RoleListPref = &HomeRoleListPref;       
3640                         break;
3641                 case PROPERTY_WORK:
3642                         RoleList = &BusinessRoleList;
3643                         RoleListType = &BusinessRoleListType;
3644                         RoleListAltID = &BusinessRoleListAltID;
3645                         RoleListPID = &BusinessRoleListPID;
3646                         RoleListTokens = &BusinessRoleListTokens;
3647                         RoleListLanguage = &BusinessRoleListLanguage;   
3648                         RoleListPref = &BusinessRoleListPref;
3649                         break;
3650         }
3652         intPrevValue = 5;
3653                 
3654         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3655         intiter != SplitPoints.end(); ++intiter){
3656         
3657                 SLiter = SplitLength.find(intiter->first);
3658         
3659                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3660                 
3661                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3662                 PropertyName = PropertyElement.GetNextToken();                          
3663                 PropertyValue = PropertyElement.GetNextToken();
3664                 
3665                 intPrevValue = intiter->second;
3666                 
3667                 // Process properties.
3668                 
3669                 size_t intPropertyValueLen = PropertyValue.Len();
3670                 
3671                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3672                         
3673                         PropertyValue.Trim();
3674                         PropertyValue.RemoveLast();
3675                         
3676                 }                               
3677                 
3678                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3679                         
3680                         PropertyValue.Remove(0, 1);
3681                         
3682                 }                               
3683                 
3684                 CaptureString(&PropertyValue, FALSE);
3685                 
3686                 if (PropertyName == wxT("ALTID")){
3687                 
3688                         RoleListAltID->erase(*RoleCount);
3689                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3690                 
3691                 } else if (PropertyName == wxT("PID")){
3693                         RoleListPID->erase(*RoleCount);
3694                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3695                 
3696                 } else if (PropertyName == wxT("PREF")){
3697                                 
3698                         int PriorityNumber = 0;
3699                         bool ValidNumber = TRUE;
3700                         
3701                         try{
3702                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3703                         }
3704                         
3705                         catch(std::invalid_argument &e){
3706                                 ValidNumber = FALSE;
3707                         }
3709                         if (ValidNumber == TRUE){
3711                                 RoleListPref->erase(*RoleCount);
3712                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3714                         }
3715                                         
3716                 } else if (PropertyName == wxT("LANGUAGE")){
3717                 
3718                         RoleListLanguage->erase(*RoleCount);
3719                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3720                 
3721                 } else {
3722                 
3723                         // Something else we don't know about so append
3724                         // to the tokens variable.
3725                 
3726                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3727                 
3728                                 if (FirstToken == TRUE){
3729                         
3730                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3731                                         FirstToken = FALSE;
3732                         
3733                                 } else {
3734                         
3735                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3736                         
3737                                 }
3738                 
3739                         }
3740                 
3741                 }
3742         
3743         }
3744         
3745         // Add the data to the General/Home/Work address variables.
3746         
3747         CaptureString(&PropertySeg2, FALSE);
3749         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3750         
3751         if (!PropertyTokens.IsEmpty()){
3752         
3753                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3754                         
3755         }
3759 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3761         std::map<int, int> SplitPoints;
3762         std::map<int, int> SplitLength;
3763         std::map<int, int>::iterator SLiter;                    
3764         wxString PropertyData;
3765         wxString PropertyName;
3766         wxString PropertyValue;
3767         wxString PropertyTokens;
3768         bool FirstToken = TRUE;
3769         int intPrevValue = 5;
3770         int intPref = 0;                        
3771         int intType = 0;
3772         long ListCtrlIndex;
3773         
3774         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3775         
3776         intPrevValue = 4;
3777         
3778         PropertyType PropType = PROPERTY_NONE;
3779                 
3780         // Look for type before continuing.
3781         
3782         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3783         
3784         // Setup the pointers.
3785         
3786         std::map<int, wxString> *OrganisationsList = NULL;
3787         std::map<int, wxString> *OrganisationsListAltID = NULL;
3788         std::map<int, wxString> *OrganisationsListPID = NULL;
3789         std::map<int, wxString> *OrganisationsListType = NULL;
3790         std::map<int, wxString> *OrganisationsListTokens = NULL;
3791         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3792         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3793         std::map<int, int> *OrganisationsListPref = NULL;
3794         
3795         // Setup blank lines for later on.
3796         
3797         switch(PropType){
3798                 case PROPERTY_NONE:
3799                         OrganisationsList = &GeneralOrganisationsList;
3800                         OrganisationsListType = &GeneralOrganisationsListType;
3801                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3802                         OrganisationsListPID = &GeneralOrganisationsListPID;
3803                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3804                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3805                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3806                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3807                         break;
3808                 case PROPERTY_HOME:
3809                         OrganisationsList = &HomeOrganisationsList;
3810                         OrganisationsListType = &HomeOrganisationsListType;
3811                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3812                         OrganisationsListPID = &HomeOrganisationsListPID;
3813                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3814                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3815                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3816                         OrganisationsListPref = &HomeOrganisationsListPref;     
3817                         break;
3818                 case PROPERTY_WORK:
3819                         OrganisationsList = &BusinessOrganisationsList;
3820                         OrganisationsListType = &BusinessOrganisationsListType;
3821                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3822                         OrganisationsListPID = &BusinessOrganisationsListPID;
3823                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3824                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3825                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3826                         OrganisationsListPref = &BusinessOrganisationsListPref;
3827                         break;
3828         }
3830         intPrevValue = 4;
3831                 
3832         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3833         intiter != SplitPoints.end(); ++intiter){
3834         
3835                 SLiter = SplitLength.find(intiter->first);
3836         
3837                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3838                 
3839                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3840                 PropertyName = PropertyElement.GetNextToken();                          
3841                 PropertyValue = PropertyElement.GetNextToken();
3842                 
3843                 intPrevValue = intiter->second;
3844                 
3845                 // Process properties.
3846                 
3847                 size_t intPropertyValueLen = PropertyValue.Len();
3848                 
3849                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3850                         
3851                         PropertyValue.Trim();
3852                         PropertyValue.RemoveLast();
3853                         
3854                 }                               
3855                 
3856                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3857                         
3858                         PropertyValue.Remove(0, 1);
3859                         
3860                 }                               
3861                 
3862                 CaptureString(&PropertyValue, FALSE);
3863                 
3864                 if (PropertyName == wxT("ALTID")){
3865                 
3866                         OrganisationsListAltID->erase(*OrganisationCount);
3867                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3868                 
3869                 } else if (PropertyName == wxT("PID")){
3871                         OrganisationsListPID->erase(*OrganisationCount);
3872                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3873                 
3874                 } else if (PropertyName == wxT("SORT-AS")){
3876                         OrganisationsListSortAs->erase(*OrganisationCount);
3877                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3878                 
3879                 } else if (PropertyName == wxT("PREF")){
3880                                 
3881                         int PriorityNumber = 0;
3882                         bool ValidNumber = TRUE;
3883                         
3884                         try{
3885                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3886                         }
3887                         
3888                         catch(std::invalid_argument &e){
3889                                 ValidNumber = FALSE;
3890                         }
3892                         if (ValidNumber == TRUE){
3894                                 OrganisationsListPref->erase(*OrganisationCount);
3895                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3897                         }
3898                                         
3899                 } else if (PropertyName == wxT("LANGUAGE")){
3900                 
3901                         OrganisationsListLanguage->erase(*OrganisationCount);
3902                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3903                 
3904                 } else {
3905                 
3906                         // Something else we don't know about so append
3907                         // to the tokens variable.
3908                 
3909                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3910                 
3911                                 if (FirstToken == TRUE){
3912                         
3913                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3914                                         FirstToken = FALSE;
3915                         
3916                                 } else {
3917                         
3918                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3919                         
3920                                 }
3921                 
3922                         }
3923                 
3924                 }
3925         
3926         }
3927         
3928         // Add the data to the General/Home/Work address variables.
3929         
3930         CaptureString(&PropertySeg2, FALSE);
3932         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3933         
3934         if (!PropertyTokens.IsEmpty()){
3935         
3936                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3937                         
3938         }
3942 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3944         std::map<int, int> SplitPoints;
3945         std::map<int, int> SplitLength;
3946         std::map<int, int>::iterator SLiter;                    
3947         wxString PropertyData;
3948         wxString PropertyName;
3949         wxString PropertyValue;
3950         wxString PropertyTokens;
3951         bool FirstToken = TRUE;
3952         int intPrevValue = 6;
3953         int intPref = 0;                        
3954         int intType = 0;
3955         long ListCtrlIndex;
3956         
3957         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3958         
3959         intPrevValue = 5;
3960         
3961         PropertyType PropType = PROPERTY_NONE;
3962                 
3963         // Look for type before continuing.
3964         
3965         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3966         
3967         // Setup the pointers.
3968         
3969         std::map<int, wxString> *NoteList = NULL;
3970         std::map<int, wxString> *NoteListAltID = NULL;
3971         std::map<int, wxString> *NoteListPID = NULL;
3972         std::map<int, wxString> *NoteListType = NULL;
3973         std::map<int, wxString> *NoteListTokens = NULL;
3974         std::map<int, wxString> *NoteListLanguage = NULL;
3975         std::map<int, int> *NoteListPref = NULL;
3976         
3977         // Setup blank lines for later on.
3978         
3979         switch(PropType){
3980                 case PROPERTY_NONE:
3981                         NoteList = &GeneralNoteList;
3982                         NoteListType = &GeneralNoteListType;
3983                         NoteListAltID = &GeneralNoteListAltID;
3984                         NoteListPID = &GeneralNoteListPID;
3985                         NoteListTokens = &GeneralNoteListTokens;
3986                         NoteListLanguage = &GeneralNoteListLanguage;
3987                         NoteListPref = &GeneralNoteListPref;    
3988                         break;
3989                 case PROPERTY_HOME:
3990                         NoteList = &HomeNoteList;
3991                         NoteListType = &HomeNoteListType;
3992                         NoteListAltID = &HomeNoteListAltID;
3993                         NoteListPID = &HomeNoteListPID;
3994                         NoteListTokens = &HomeNoteListTokens;
3995                         NoteListLanguage = &HomeNoteListLanguage;
3996                         NoteListPref = &HomeNoteListPref;       
3997                         break;
3998                 case PROPERTY_WORK:
3999                         NoteList = &BusinessNoteList;
4000                         NoteListType = &BusinessNoteListType;
4001                         NoteListAltID = &BusinessNoteListAltID;
4002                         NoteListPID = &BusinessNoteListPID;
4003                         NoteListTokens = &BusinessNoteListTokens;
4004                         NoteListLanguage = &BusinessNoteListLanguage;   
4005                         NoteListPref = &BusinessNoteListPref;
4006                         break;
4007         }
4009         intPrevValue = 5;
4010                 
4011         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4012         intiter != SplitPoints.end(); ++intiter){
4013         
4014                 SLiter = SplitLength.find(intiter->first);
4015         
4016                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4017                 
4018                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4019                 PropertyName = PropertyElement.GetNextToken();                          
4020                 PropertyValue = PropertyElement.GetNextToken();
4021                 
4022                 intPrevValue = intiter->second;
4023                 
4024                 // Process properties.
4025                 
4026                 size_t intPropertyValueLen = PropertyValue.Len();
4027                 
4028                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4029                         
4030                         PropertyValue.Trim();
4031                         PropertyValue.RemoveLast();
4032                         
4033                 }                               
4034                 
4035                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4036                         
4037                         PropertyValue.Remove(0, 1);
4038                         
4039                 }                               
4040                 
4041                 CaptureString(&PropertyValue, FALSE);
4042                 
4043                 if (PropertyName == wxT("ALTID")){
4044                 
4045                         NoteListAltID->erase(*NoteCount);
4046                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4047                 
4048                 } else if (PropertyName == wxT("PID")){
4050                         NoteListPID->erase(*NoteCount);
4051                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4052                 
4053                 } else if (PropertyName == wxT("PREF")){
4054                                 
4055                         int PriorityNumber = 0;
4056                         bool ValidNumber = TRUE;
4057                         
4058                         try{
4059                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4060                         }
4061                         
4062                         catch(std::invalid_argument &e){
4063                                 ValidNumber = FALSE;
4064                         }
4066                         if (ValidNumber == TRUE){
4068                                 NoteListPref->erase(*NoteCount);
4069                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4071                         }
4072                                         
4073                 } else if (PropertyName == wxT("LANGUAGE")){
4074                 
4075                         NoteListLanguage->erase(*NoteCount);
4076                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4077                 
4078                 } else {
4079                 
4080                         // Something else we don't know about so append
4081                         // to the tokens variable.
4082                 
4083                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4084                 
4085                                 if (FirstToken == TRUE){
4086                         
4087                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4088                                         FirstToken = FALSE;
4089                         
4090                                 } else {
4091                         
4092                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4093                         
4094                                 }
4095                 
4096                         }
4097                 
4098                 }
4099         
4100         }
4101         
4102         // Add the data to the General/Home/Work address variables.
4103         
4104         CaptureString(&PropertySeg2, FALSE);
4106         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4107         
4108         if (!PropertyTokens.IsEmpty()){
4109         
4110                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4111                         
4112         }
4116 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4118         std::map<int, int> SplitPoints;
4119         std::map<int, int> SplitLength;
4120         std::map<int, int>::iterator SLiter;                    
4121         wxString PropertyData;
4122         wxString PropertyName;
4123         wxString PropertyValue;
4124         wxString PropertyTokens;
4125         bool FirstToken = TRUE;
4126         int intPrevValue = 12;
4127         int intPref = 0;                        
4128         int intType = 0;
4129         long ListCtrlIndex;
4130         
4131         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4132         
4133         intPrevValue = 11;
4134         
4135         PropertyType PropType = PROPERTY_NONE;
4136                 
4137         // Look for type before continuing.
4138         
4139         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4140         
4141         // Setup blank lines for later on.
4142         
4143         switch(PropType){
4144                 case PROPERTY_NONE:
4145                         break;
4146                 case PROPERTY_HOME:
4147                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4148                         break;
4149                 case PROPERTY_WORK:
4150                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4151                         break;
4152         }
4154         intPrevValue = 11;
4155                 
4156         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4157         intiter != SplitPoints.end(); ++intiter){
4158         
4159                 SLiter = SplitLength.find(intiter->first);
4160         
4161                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4162                 
4163                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4164                 PropertyName = PropertyElement.GetNextToken();                          
4165                 PropertyValue = PropertyElement.GetNextToken();
4166                 
4167                 intPrevValue = intiter->second;
4168                 
4169                 // Process properties.
4170                 
4171                 size_t intPropertyValueLen = PropertyValue.Len();
4172                 
4173                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4174                         
4175                         PropertyValue.Trim();
4176                         PropertyValue.RemoveLast();
4177                         
4178                 }                               
4179                 
4180                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4181                         
4182                         PropertyValue.Remove(0, 1);
4183                         
4184                 }                               
4185                 
4186                 CaptureString(&PropertyValue, FALSE);
4187                 
4188                 if (PropertyName == wxT("ALTID")){
4189                 
4190                         CategoriesListAltID.erase(*CategoryCount);
4191                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4192                 
4193                 } else if (PropertyName == wxT("PID")){
4195                         CategoriesListPID.erase(*CategoryCount);
4196                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4197                 
4198                 } else if (PropertyName == wxT("PREF")){
4199                                 
4200                         int PriorityNumber = 0;
4201                         bool ValidNumber = TRUE;
4202                         
4203                         try{
4204                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4205                         }
4206                         
4207                         catch(std::invalid_argument &e){
4208                                 ValidNumber = FALSE;
4209                         }
4211                         if (ValidNumber == TRUE){
4213                                 CategoriesListPref.erase(*CategoryCount);
4214                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4216                         }
4217                                         
4218                 } else if (PropertyName == wxT("LANGUAGE")){
4219                 
4220                         CategoriesListLanguage.erase(*CategoryCount);
4221                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4222                 
4223                 } else {
4224                 
4225                         // Something else we don't know about so append
4226                         // to the tokens variable.
4227                 
4228                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4229                 
4230                                 if (FirstToken == TRUE){
4231                         
4232                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4233                                         FirstToken = FALSE;
4234                         
4235                                 } else {
4236                         
4237                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4238                         
4239                                 }
4240                 
4241                         }
4242                 
4243                 }
4244         
4245         }
4246         
4247         // Deal with multiple categories.
4248         
4249         int intOrigCatCount = *CategoryCount;
4250         bool FirstCategoryProcessed = TRUE;
4251         bool AfterFirstToken = FALSE;
4252         int intSplitSize = 0;
4253         int intSplitsFound = 0;
4254         int intSplitSeek = 0;
4255         int intPropertyLen = PropertySeg2.Len();
4256         
4257         SplitPoints.clear();
4258         SplitLength.clear();
4259         intPrevValue = 0;
4260         
4261         for (int i = 0; i <= intPropertyLen; i++){
4262         
4263                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4264         
4265                         continue;
4266                 
4267                 }
4268         
4269                 intSplitSize++;
4270         
4271                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4272         
4273                         if (AfterFirstToken == TRUE){
4274                 
4275                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4276                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4277                         
4278                         } else {
4279                         
4280                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4281                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4282                                 AfterFirstToken = TRUE;
4284                         }
4286                         intSplitsFound++;
4287                         intSplitSeek = i;
4288                         intSplitSize = 0;                               
4289         
4290                 }                       
4291         
4292         }
4293         
4294         if (SplitPoints.size() > 0){
4295         
4296                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4297                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4298         
4299         }
4300         
4301         if (SplitPoints.size() == 0){
4302         
4303                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4304         
4305                 if (!PropertyTokens.IsEmpty()){
4306                 
4307                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4308                 
4309                 }
4310         
4311         }
4312         
4313         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4314         intiter != SplitPoints.end(); ++intiter){
4315         
4316                 SLiter = SplitLength.find(intiter->first);
4317         
4318                 intPrevValue = intiter->second;
4319         
4320                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4321                 
4322                 // Add the data to the General/Home/Work address variables.
4323         
4324                 // Trim any whitespace from the start and end.
4325         
4326                 PropertyData = PropertyData.Trim(FALSE);
4327                 PropertyData = PropertyData.Trim(TRUE); 
4328         
4329                 CaptureString(&PropertyData, FALSE);
4330                 
4331                 if (FirstCategoryProcessed == TRUE){
4332                 
4333                         FirstCategoryProcessed = FALSE;
4334                         
4335                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4336         
4337                         if (!PropertyTokens.IsEmpty()){
4338                 
4339                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4340                 
4341                         }
4342                         
4343                         continue;
4344                 
4345                 } else {
4347                         (*CategoryCount)++;
4348                         
4349                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4350                 
4351                         if (!PropertyTokens.IsEmpty()){
4352                 
4353                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4354                 
4355                         }
4356                 
4357                 }
4358                 
4359                 // Copy the properties to each of the categories (if it exists).
4360                 
4361                 if (!PropertyTokens.IsEmpty()){
4362                 
4363                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4364                 
4365                 }
4366                 
4367                 // Check if ALTID was used.
4368                 
4369                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4370                 
4371                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4372                 
4373                 }
4374                 
4375                 // Check if PID was used.
4376                 
4377                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4378                 
4379                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4380                 
4381                 }
4382         
4383                 // Check if PREF was used.
4384         
4385                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4386                 
4387                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4388                 
4389                 }
4390                 
4391                 // Check if LANGUAGE was used.
4392                 
4393                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4394                 
4395                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4396                 
4397                 }
4398                 
4399                 // Check if TYPE was used.
4400                 
4401                 switch(PropType){
4402                         case PROPERTY_NONE:
4403                                 break;
4404                         case PROPERTY_HOME:
4405                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4406                                 break;
4407                         case PROPERTY_WORK:
4408                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4409                                 break;
4410                 }
4411         
4412         }
4416 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4418         size_t intPropertyLen = PropertySeg1.Len();
4419         std::map<int, int> SplitPoints;
4420         std::map<int, int> SplitLength;
4421         std::map<int, int>::iterator SLiter;                    
4422         wxString PropertyData;
4423         wxString PropertyName;
4424         wxString PropertyValue;
4425         wxString PropertyTokens;
4426         bool FirstToken = TRUE;
4427         int intSplitsFound = 0;
4428         int intSplitSize = 0;
4429         int intPrevValue = 7;
4430         int intPref = 0;                        
4431         int intType = 0;
4432         
4433         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4434         
4435         intPrevValue = 6;
4436         
4437         PropertyType PropType = PROPERTY_NONE;
4438                 
4439         // Look for type before continuing.
4440         
4441         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4443         intPrevValue = 6;
4445         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4446         intiter != SplitPoints.end(); ++intiter){
4447         
4448                 SLiter = SplitLength.find(intiter->first);
4449         
4450                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4451                 
4452                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4453                 PropertyName = PropertyElement.GetNextToken();                          
4454                 PropertyValue = PropertyElement.GetNextToken();
4455                 
4456                 intPrevValue = intiter->second;
4457                 
4458                 // Process properties.
4459                 
4460                 size_t intPropertyValueLen = PropertyValue.Len();
4461                 
4462                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4463                         
4464                         PropertyValue.Trim();
4465                         PropertyValue.RemoveLast();
4466                         
4467                 }                               
4468                 
4469                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4470                         
4471                         PropertyValue.Remove(0, 1);
4472                         
4473                 }
4474                 
4475                 CaptureString(&PropertyValue, FALSE);
4476                 
4477                 if (PropertyName == wxT("ALTID")){
4479                         PicturesListAltID.erase(*PhotoCount);
4480                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4481                 
4482                 } else if (PropertyName == wxT("PID")){
4484                         PicturesListPID.erase(*PhotoCount);
4485                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4486                 
4487                 } else if (PropertyName == wxT("PREF")){
4488                         
4489                         int PriorityNumber = 0;
4490                         bool ValidNumber = TRUE;
4491                         
4492                         try{
4493                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4494                         }
4495                         
4496                         catch(std::invalid_argument &e){
4497                                 ValidNumber = FALSE;
4498                         }
4500                         if (ValidNumber == TRUE){
4502                                 PicturesListPref.erase(*PhotoCount);
4503                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4505                         }
4506                 
4507                 } else if (PropertyName == wxT("MEDIATYPE")){
4508                 
4509                         PicturesListMediatype.erase(*PhotoCount);
4510                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4511                                         
4512                 } else {
4513                 
4514                         // Something else we don't know about so append
4515                         // to the tokens variable.
4516                         
4517                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4518                         
4519                                 if (FirstToken == TRUE){
4520                                 
4521                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4522                                         FirstToken = FALSE;
4523                                 
4524                                 } else {
4525                                 
4526                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4527                                 
4528                                 }
4529                         
4530                         }
4531                 
4532                 }
4533         
4534         }       
4535         
4536         intPropertyLen = PropertySeg2.Len();
4537         SplitPoints.clear();
4538         SplitLength.clear();
4539         intSplitsFound = 0;
4540         intSplitSize = 0;
4541         intPrevValue = 0;                       
4542         
4543         CaptureString(&PropertySeg2, FALSE);
4544         
4545         for (int i = 0; i <= intPropertyLen; i++){
4547                 intSplitSize++;
4548         
4549                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4550         
4551                         intSplitsFound++;
4552                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4553                         
4554                         if (intSplitsFound == 6){ 
4555                         
4556                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4557                                 break; 
4558                                 
4559                         } else {
4560                         
4561                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4562                         
4563                         }
4564                         
4565                         intSplitSize = 0;                                       
4566         
4567                 }
4569         }
4570         
4571         wxString wxSPhotoURI;
4572         wxString wxSPhotoMIME;
4573         wxString wxSPhotoEncoding;
4574         wxString wxSPhotoData;
4575         std::string base64enc;
4576         
4577         if (intSplitsFound == 0){
4578         
4579         } else {
4580         
4581                 std::map<int, int>::iterator striter;
4582         
4583                 striter = SplitLength.find(1);
4584         
4585                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4586         
4587                 while (wSTDataType.HasMoreTokens() == TRUE){
4588                 
4589                         wxSPhotoURI = wSTDataType.GetNextToken();
4590                         wxSPhotoMIME = wSTDataType.GetNextToken();
4591                         break;
4592                 
4593                 }                       
4594         
4595                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4596         
4597                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4598                 
4599                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4600                         wxSPhotoData = wSTDataInfo.GetNextToken();
4601                         base64enc = wxSPhotoData.mb_str();
4602                         break;
4603                 
4604                 }
4605         
4606         }
4607         
4608         // Add the data to the General/Home/Work address variables.
4609         
4610         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4611         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4612         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4613         
4614         switch(PropType){
4615                 case PROPERTY_NONE:
4616                         break;
4617                 case PROPERTY_HOME:
4618                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4619                         break;
4620                 case PROPERTY_WORK:
4621                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4622                         break;
4623         }
4624         
4625         if (!PropertyTokens.IsEmpty()){
4627                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4628         
4629         }
4633 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4635         size_t intPropertyLen = PropertySeg1.Len();
4636         std::map<int, int> SplitPoints;
4637         std::map<int, int> SplitLength;
4638         std::map<int, int>::iterator SLiter;                    
4639         wxString PropertyData;
4640         wxString PropertyName;
4641         wxString PropertyValue;
4642         wxString PropertyTokens;
4643         bool FirstToken = TRUE;
4644         int intSplitsFound = 0;
4645         int intSplitSize = 0;
4646         int intPrevValue = 6;
4647         int intPref = 0;                        
4648         int intType = 0;
4649         
4650         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4651         
4652         intPrevValue = 5;
4653         
4654         PropertyType PropType = PROPERTY_NONE;
4655                 
4656         // Look for type before continuing.
4657         
4658         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4660         intPrevValue = 5;
4662         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4663         intiter != SplitPoints.end(); ++intiter){
4664         
4665                 SLiter = SplitLength.find(intiter->first);
4666         
4667                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4668                 
4669                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4670                 PropertyName = PropertyElement.GetNextToken();                          
4671                 PropertyValue = PropertyElement.GetNextToken();
4672                 
4673                 intPrevValue = intiter->second;
4674                 
4675                 // Process properties.
4676                 
4677                 size_t intPropertyValueLen = PropertyValue.Len();
4678                 
4679                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4680                         
4681                         PropertyValue.Trim();
4682                         PropertyValue.RemoveLast();
4683                         
4684                 }                               
4685                 
4686                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4687                         
4688                         PropertyValue.Remove(0, 1);
4689                         
4690                 }
4691                 
4692                 CaptureString(&PropertyValue, FALSE);
4693                 
4694                 if (PropertyName == wxT("ALTID")){
4696                         LogosListAltID.erase(*LogoCount);
4697                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4698                 
4699                 } else if (PropertyName == wxT("PID")){
4701                         LogosListPID.erase(*LogoCount);
4702                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4703                 
4704                 } else if (PropertyName == wxT("PREF")){
4705                         
4706                         int PriorityNumber = 0;
4707                         bool ValidNumber = TRUE;
4708                         
4709                         try{
4710                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4711                         }
4712                         
4713                         catch(std::invalid_argument &e){
4714                                 ValidNumber = FALSE;
4715                         }
4717                         if (ValidNumber == TRUE){
4719                                 LogosListPref.erase(*LogoCount);
4720                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4722                         }
4723                 
4724                 } else if (PropertyName == wxT("MEDIATYPE")){
4725                 
4726                         LogosListMediatype.erase(*LogoCount);
4727                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4728                                         
4729                 } else {
4730                 
4731                         // Something else we don't know about so append
4732                         // to the tokens variable.
4733                         
4734                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4735                         
4736                                 if (FirstToken == TRUE){
4737                                 
4738                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4739                                         FirstToken = FALSE;
4740                                 
4741                                 } else {
4742                                 
4743                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4744                                 
4745                                 }
4746                         
4747                         }
4748                 
4749                 }
4750         
4751         }       
4752         
4753         intPropertyLen = PropertySeg2.Len();
4754         SplitPoints.clear();
4755         SplitLength.clear();
4756         intSplitsFound = 0;
4757         intSplitSize = 0;
4758         intPrevValue = 0;                       
4759         
4760         CaptureString(&PropertySeg2, FALSE);
4761         
4762         for (int i = 0; i <= intPropertyLen; i++){
4764                 intSplitSize++;
4765         
4766                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4767         
4768                         intSplitsFound++;
4769                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4770                         
4771                         if (intSplitsFound == 6){ 
4772                         
4773                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4774                                 break; 
4775                                 
4776                         } else {
4777                         
4778                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4779                         
4780                         }
4781                         
4782                         intSplitSize = 0;                                       
4783         
4784                 }
4786         }
4787         
4788         wxString wxSPhotoURI;
4789         wxString wxSPhotoMIME;
4790         wxString wxSPhotoEncoding;
4791         wxString wxSPhotoData;
4792         std::string base64enc;
4793         
4794         if (intSplitsFound == 0){
4795         
4796         } else {
4797         
4798                 std::map<int, int>::iterator striter;
4799         
4800                 striter = SplitLength.find(1);
4801         
4802                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4803         
4804                 while (wSTDataType.HasMoreTokens() == TRUE){
4805                 
4806                         wxSPhotoURI = wSTDataType.GetNextToken();
4807                         wxSPhotoMIME = wSTDataType.GetNextToken();
4808                         break;
4809                 
4810                 }                       
4811         
4812                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4813         
4814                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4815                 
4816                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4817                         wxSPhotoData = wSTDataInfo.GetNextToken();
4818                         base64enc = wxSPhotoData.mb_str();
4819                         break;
4820                 
4821                 }
4822         
4823         }
4824         
4825         // Add the data to the General/Home/Work address variables.
4826         
4827         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4828         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4829         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4830         
4831         switch(PropType){
4832                 case PROPERTY_NONE:
4833                         break;
4834                 case PROPERTY_HOME:
4835                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4836                         break;
4837                 case PROPERTY_WORK:
4838                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4839                         break;
4840         }
4841         
4842         if (!PropertyTokens.IsEmpty()){
4844                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4845         
4846         }
4850 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4852         size_t intPropertyLen = PropertySeg1.Len();
4853         std::map<int, int> SplitPoints;
4854         std::map<int, int> SplitLength;
4855         std::map<int, int>::iterator SLiter;                    
4856         wxString PropertyData;
4857         wxString PropertyName;
4858         wxString PropertyValue;
4859         wxString PropertyTokens;
4860         bool FirstToken = TRUE;
4861         int intSplitsFound = 0;
4862         int intSplitSize = 0;
4863         int intPrevValue = 7;
4864         int intPref = 0;                        
4865         int intType = 0;
4866         
4867         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4868         
4869         intPrevValue = 6;
4870         
4871         PropertyType PropType = PROPERTY_NONE;
4872         
4873         // Look for type before continuing.                     
4875         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4877         intPrevValue = 6;
4879         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4880         intiter != SplitPoints.end(); ++intiter){
4881         
4882                 SLiter = SplitLength.find(intiter->first);
4883         
4884                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4885                 
4886                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4887                 PropertyName = PropertyElement.GetNextToken();                          
4888                 PropertyValue = PropertyElement.GetNextToken();
4889                 
4890                 intPrevValue = intiter->second;
4891                 
4892                 // Process properties.
4893                 
4894                 size_t intPropertyValueLen = PropertyValue.Len();
4895                 
4896                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4897                         
4898                         PropertyValue.Trim();
4899                         PropertyValue.RemoveLast();
4900                         
4901                 }                               
4902                 
4903                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4904                         
4905                         PropertyValue.Remove(0, 1);
4906                         
4907                 }                       
4908                 
4909                 CaptureString(&PropertyValue, FALSE);
4910                 
4911                 if (PropertyName == wxT("ALTID")){
4913                         SoundsListAltID.erase(*SoundCount);
4914                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4915                 
4916                 } else if (PropertyName == wxT("PID")){
4918                         SoundsListPID.erase(*SoundCount);
4919                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4920                 
4921                 } else if (PropertyName == wxT("PREF")){
4922                         
4923                         int PriorityNumber = 0;
4924                         bool ValidNumber = TRUE;
4925                         
4926                         try{
4927                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4928                         }
4929                         
4930                         catch(std::invalid_argument &e){
4931                                 ValidNumber = FALSE;
4932                         }
4934                         if (ValidNumber == TRUE){
4936                                 SoundsListPref.erase(*SoundCount);
4937                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4939                         }
4940                 
4941                 } else if (PropertyName == wxT("MEDIATYPE")){
4942                 
4943                         SoundsListMediatype.erase(*SoundCount);
4944                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4946                 } else if (PropertyName == wxT("LANGUAGE")){
4947                 
4948                         SoundsListLanguage.erase(*SoundCount);
4949                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4951                 } else {
4952                 
4953                         // Something else we don't know about so append
4954                         // to the tokens variable.
4955                         
4956                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4957                         
4958                                 if (FirstToken == TRUE){
4959                                 
4960                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4961                                         FirstToken = FALSE;
4962                                 
4963                                 } else {
4964                                 
4965                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4966                                 
4967                                 }
4968                         
4969                         }
4970                 
4971                 }
4972         
4973         }       
4974         
4975         intPropertyLen = PropertySeg2.Len();
4976         SplitPoints.clear();
4977         SplitLength.clear();
4978         intSplitsFound = 0;
4979         intSplitSize = 0;
4980         intPrevValue = 0;
4981         
4982         CaptureString(&PropertySeg2, FALSE);
4983         
4984         for (int i = 0; i <= intPropertyLen; i++){
4986                 intSplitSize++;
4987         
4988                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4989         
4990                         intSplitsFound++;
4991                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4992                         
4993                         if (intSplitsFound == 6){ 
4994                         
4995                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4996                                 break; 
4997                                 
4998                         } else {
4999                         
5000                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5001                         
5002                         }
5003                         
5004                         intSplitSize = 0;                                       
5005         
5006                 }
5008         }
5009         
5010         wxString wxSSoundURI;
5011         wxString wxSSoundMIME;
5012         wxString wxSSoundEncoding;
5013         wxString wxSSoundData;
5014         std::string base64enc;
5015         
5016         if (intSplitsFound == 0){
5017         
5018         } else {
5019         
5020                 std::map<int, int>::iterator striter;
5021         
5022                 striter = SplitLength.find(1);
5023         
5024                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5025         
5026                 while (wSTDataType.HasMoreTokens() == TRUE){
5027                 
5028                         wxSSoundURI = wSTDataType.GetNextToken();
5029                         wxSSoundMIME = wSTDataType.GetNextToken();
5030                         break;
5031                 
5032                 }                       
5033         
5034                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5035         
5036                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5037                 
5038                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
5039                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
5040                         base64enc = wxSSoundData.mb_str();
5041                         break;
5042                 
5043                 }
5044         
5045         }
5046         
5047         // Add the data to the General/Home/Work address variables.
5048                 
5049         switch(PropType){
5050                 case PROPERTY_NONE:
5051                         break;
5052                 case PROPERTY_HOME:
5053                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5054                         break;
5055                 case PROPERTY_WORK:
5056                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5057                         break;
5058         }
5059         
5060         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5061         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5062         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5063         
5064         if (!PropertyTokens.IsEmpty()){
5065         
5066                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5067         
5068         }
5069         
5072 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5074         size_t intPropertyLen = PropertySeg1.Len();
5075         std::map<int, int> SplitPoints;
5076         std::map<int, int> SplitLength;
5077         std::map<int, int>::iterator SLiter;                    
5078         wxString PropertyData;
5079         wxString PropertyName;
5080         wxString PropertyValue;
5081         wxString PropertyTokens;
5082         bool FirstToken = TRUE;
5083         int intSplitsFound = 0;
5084         int intSplitSize = 0;
5085         int intPrevValue = 8;
5086         int intPref = 0;                        
5087         int intType = 0;
5088         
5089         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5090         
5091         intPrevValue = 7;
5092         
5093         PropertyType PropType = PROPERTY_NONE;
5094         
5095         // Look for type before continuing.                     
5097         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5099         intPrevValue = 7;
5101         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5102         intiter != SplitPoints.end(); ++intiter){
5103         
5104                 SLiter = SplitLength.find(intiter->first);
5105         
5106                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5107                 
5108                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5109                 PropertyName = PropertyElement.GetNextToken();                          
5110                 PropertyValue = PropertyElement.GetNextToken();
5111                 
5112                 intPrevValue = intiter->second;
5113                 
5114                 // Process properties.
5115                 
5116                 size_t intPropertyValueLen = PropertyValue.Len();
5117                 
5118                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5119                         
5120                         PropertyValue.Trim();
5121                         PropertyValue.RemoveLast();
5122                         
5123                 }                               
5124                 
5125                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5126                         
5127                         PropertyValue.Remove(0, 1);
5128                         
5129                 }                       
5130                 
5131                 CaptureString(&PropertyValue, FALSE);
5132                 
5133                 if (PropertyName == wxT("ALTID")){
5135                         CalendarListAltID.erase(*CalURICount);
5136                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5137                 
5138                 } else if (PropertyName == wxT("PID")){
5140                         CalendarListPID.erase(*CalURICount);
5141                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5142                 
5143                 } else if (PropertyName == wxT("PREF")){
5144                         
5145                         int PriorityNumber = 0;
5146                         bool ValidNumber = TRUE;
5147                         
5148                         try{
5149                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5150                         }
5151                         
5152                         catch(std::invalid_argument &e){
5153                                 ValidNumber = FALSE;
5154                         }
5156                         if (ValidNumber == TRUE){
5158                                 CalendarListPref.erase(*CalURICount);
5159                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5161                         }
5162                 
5163                 } else if (PropertyName == wxT("MEDIATYPE")){
5164                 
5165                         CalendarListMediatype.erase(*CalURICount);
5166                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5168                 } else {
5169                 
5170                         // Something else we don't know about so append
5171                         // to the tokens variable.
5172                         
5173                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5174                         
5175                                 if (FirstToken == TRUE){
5176                                 
5177                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5178                                         FirstToken = FALSE;
5179                                 
5180                                 } else {
5181                                 
5182                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5183                                 
5184                                 }
5185                         
5186                         }
5187                 
5188                 }
5189         
5190         }       
5191         
5192         intPropertyLen = PropertySeg2.Len();
5193         SplitPoints.clear();
5194         SplitLength.clear();
5195         intSplitsFound = 0;
5196         intSplitSize = 0;
5197         intPrevValue = 0;
5198         
5199         CaptureString(&PropertySeg2, FALSE);
5200         
5201         // Add the data to the General/Home/Work address variables.
5202                 
5203         switch(PropType){
5204                 case PROPERTY_NONE:
5205                         break;
5206                 case PROPERTY_HOME:
5207                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5208                         break;
5209                 case PROPERTY_WORK:
5210                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5211                         break;
5212         }
5213         
5214         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5215         
5216         if (!PropertyTokens.IsEmpty()){
5217         
5218                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5219         
5220         }
5224 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5226         size_t intPropertyLen = PropertySeg1.Len();
5227         std::map<int, int> SplitPoints;
5228         std::map<int, int> SplitLength;
5229         std::map<int, int>::iterator SLiter;                    
5230         wxString PropertyData;
5231         wxString PropertyName;
5232         wxString PropertyValue;
5233         wxString PropertyTokens;
5234         bool FirstToken = TRUE;
5235         int intSplitsFound = 0;
5236         int intSplitSize = 0;
5237         int intPrevValue = 8;
5238         int intPref = 0;                        
5239         int intType = 0;
5240         
5241         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5242         
5243         intPrevValue = 7;
5244         
5245         PropertyType PropType = PROPERTY_NONE;
5246         
5247         // Look for type before continuing.                     
5249         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5251         intPrevValue = 7;
5253         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5254         intiter != SplitPoints.end(); ++intiter){
5255         
5256                 SLiter = SplitLength.find(intiter->first);
5257         
5258                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5259                 
5260                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5261                 PropertyName = PropertyElement.GetNextToken();                          
5262                 PropertyValue = PropertyElement.GetNextToken();
5263                 
5264                 intPrevValue = intiter->second;
5265                 
5266                 // Process properties.
5267                 
5268                 size_t intPropertyValueLen = PropertyValue.Len();
5269                 
5270                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5271                         
5272                         PropertyValue.Trim();
5273                         PropertyValue.RemoveLast();
5274                         
5275                 }                               
5276                 
5277                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5278                         
5279                         PropertyValue.Remove(0, 1);
5280                         
5281                 }                       
5282                 
5283                 CaptureString(&PropertyValue, FALSE);
5284                 
5285                 if (PropertyName == wxT("ALTID")){
5287                         CalendarRequestListAltID.erase(*CalAdrURICount);
5288                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5289                 
5290                 } else if (PropertyName == wxT("PID")){
5292                         CalendarRequestListPID.erase(*CalAdrURICount);
5293                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5294                 
5295                 } else if (PropertyName == wxT("PREF")){
5296                         
5297                         int PriorityNumber = 0;
5298                         bool ValidNumber = TRUE;
5299                         
5300                         try{
5301                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5302                         }
5303                         
5304                         catch(std::invalid_argument &e){
5305                                 ValidNumber = FALSE;
5306                         }
5308                         if (ValidNumber == TRUE){
5310                                 CalendarRequestListPref.erase(*CalAdrURICount);
5311                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5313                         }
5314                 
5315                 } else if (PropertyName == wxT("MEDIATYPE")){
5316                 
5317                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5318                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5320                 } else {
5321                 
5322                         // Something else we don't know about so append
5323                         // to the tokens variable.
5324                         
5325                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5326                         
5327                                 if (FirstToken == TRUE){
5328                                 
5329                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5330                                         FirstToken = FALSE;
5331                                 
5332                                 } else {
5333                                 
5334                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5335                                 
5336                                 }
5337                         
5338                         }
5339                 
5340                 }
5341         
5342         }       
5343         
5344         intPropertyLen = PropertySeg2.Len();
5345         SplitPoints.clear();
5346         SplitLength.clear();
5347         intSplitsFound = 0;
5348         intSplitSize = 0;
5349         intPrevValue = 0;
5350         
5351         CaptureString(&PropertySeg2, FALSE);
5352         
5353         // Add the data to the General/Home/Work address variables.
5354                 
5355         switch(PropType){
5356                 case PROPERTY_NONE:
5357                         break;
5358                 case PROPERTY_HOME:
5359                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5360                         break;
5361                 case PROPERTY_WORK:
5362                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5363                         break;
5364         }
5365         
5366         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5367         
5368         if (!PropertyTokens.IsEmpty()){
5369         
5370                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5371         
5372         }       
5373         
5376 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5378         size_t intPropertyLen = PropertySeg1.Len();
5379         std::map<int, int> SplitPoints;
5380         std::map<int, int> SplitLength;
5381         std::map<int, int>::iterator SLiter;                    
5382         wxString PropertyData;
5383         wxString PropertyName;
5384         wxString PropertyValue;
5385         wxString PropertyTokens;
5386         bool FirstToken = TRUE;
5387         int intSplitsFound = 0;
5388         int intSplitSize = 0;
5389         int intPrevValue = 7;
5390         int intPref = 0;                        
5391         int intType = 0;
5392         
5393         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5394         
5395         intPrevValue = 6;
5396         
5397         PropertyType PropType = PROPERTY_NONE;
5398         
5399         // Look for type before continuing.                     
5401         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5403         intPrevValue = 6;
5405         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5406         intiter != SplitPoints.end(); ++intiter){
5407         
5408                 SLiter = SplitLength.find(intiter->first);
5409         
5410                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5411                 
5412                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5413                 PropertyName = PropertyElement.GetNextToken();                          
5414                 PropertyValue = PropertyElement.GetNextToken();
5415                 
5416                 intPrevValue = intiter->second;
5417                 
5418                 // Process properties.
5419                 
5420                 size_t intPropertyValueLen = PropertyValue.Len();
5421                 
5422                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5423                         
5424                         PropertyValue.Trim();
5425                         PropertyValue.RemoveLast();
5426                         
5427                 }                               
5428                 
5429                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5430                         
5431                         PropertyValue.Remove(0, 1);
5432                         
5433                 }                       
5434                 
5435                 CaptureString(&PropertyValue, FALSE);
5436                 
5437                 if (PropertyName == wxT("ALTID")){
5439                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5440                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5441                 
5442                 } else if (PropertyName == wxT("PID")){
5444                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5445                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5446                 
5447                 } else if (PropertyName == wxT("PREF")){
5448                         
5449                         int PriorityNumber = 0;
5450                         bool ValidNumber = TRUE;
5451                         
5452                         try{
5453                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5454                         }
5455                         
5456                         catch(std::invalid_argument &e){
5457                                 ValidNumber = FALSE;
5458                         }
5460                         if (ValidNumber == TRUE){
5462                                 FreeBusyListPref.erase(*FreeBusyAddressCount);
5463                                 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5465                         }
5466                 
5467                 } else if (PropertyName == wxT("MEDIATYPE")){
5468                 
5469                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5470                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5472                 } else {
5473                 
5474                         // Something else we don't know about so append
5475                         // to the tokens variable.
5476                         
5477                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5478                         
5479                                 if (FirstToken == TRUE){
5480                                 
5481                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5482                                         FirstToken = FALSE;
5483                                 
5484                                 } else {
5485                                 
5486                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5487                                 
5488                                 }
5489                         
5490                         }
5491                 
5492                 }
5493         
5494         }       
5495         
5496         intPropertyLen = PropertySeg2.Len();
5497         SplitPoints.clear();
5498         SplitLength.clear();
5499         intSplitsFound = 0;
5500         intSplitSize = 0;
5501         intPrevValue = 0;
5502         
5503         CaptureString(&PropertySeg2, FALSE);
5504         
5505         // Add the data to the General/Home/Work address variables.
5506                 
5507         switch(PropType){
5508                 case PROPERTY_NONE:
5509                         break;
5510                 case PROPERTY_HOME:
5511                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5512                         break;
5513                 case PROPERTY_WORK:
5514                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5515                         break;
5516         }
5517         
5518         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5519         
5520         if (!PropertyTokens.IsEmpty()){
5521         
5522                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5523         
5524         }
5528 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5530         size_t intPropertyLen = PropertySeg1.Len();
5531         std::map<int, int> SplitPoints;
5532         std::map<int, int> SplitLength;
5533         std::map<int, int>::iterator SLiter;                    
5534         wxString PropertyData;
5535         wxString PropertyName;
5536         wxString PropertyValue;
5537         wxString PropertyTokens;
5538         bool FirstToken = TRUE;
5539         int intSplitsFound = 0;
5540         int intSplitSize = 0;
5541         int intPrevValue = 5;
5542         int intPref = 0;                        
5543         int intType = 0;
5544         long ListCtrlIndex;
5545         
5546         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5547         
5548         intPrevValue = 4;
5549         
5550         PropertyType PropType = PROPERTY_NONE;
5551         
5552         // Look for type before continuing.
5554         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5556         intPrevValue = 4;
5558         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5559         intiter != SplitPoints.end(); ++intiter){
5560         
5561                 SLiter = SplitLength.find(intiter->first);
5562         
5563                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5564                 
5565                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5566                 PropertyName = PropertyElement.GetNextToken();                          
5567                 PropertyValue = PropertyElement.GetNextToken();
5568                 
5569                 intPrevValue = intiter->second;
5570                 
5571                 // Process properties.
5572                 
5573                 size_t intPropertyValueLen = PropertyValue.Len();
5574                 
5575                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5576                         
5577                         PropertyValue.Trim();
5578                         PropertyValue.RemoveLast();
5579                         
5580                 }                               
5581                 
5582                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5583                         
5584                         PropertyValue.Remove(0, 1);
5585                         
5586                 }                               
5587                 
5588                 if (PropertyName == wxT("ALTID")){
5590                         KeyListAltID.erase(*KeyCount);
5591                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5592                 
5593                 } else if (PropertyName == wxT("PID")){
5595                         KeyListPID.erase(*KeyCount);
5596                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5597                 
5598                 } else if (PropertyName == wxT("PREF")){
5599                         
5600                         int PriorityNumber = 0;
5601                         bool ValidNumber = TRUE;
5602                         
5603                         try{
5604                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5605                         }
5606                         
5607                         catch(std::invalid_argument &e){
5608                                 ValidNumber = FALSE;
5609                         }
5611                         if (ValidNumber == TRUE){
5613                                 KeyListPref.erase(*KeyCount);
5614                                 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5616                         }
5617                 
5618                 } else {
5619                 
5620                         // Something else we don't know about so append
5621                         // to the tokens variable.
5622                         
5623                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5624                         
5625                                 if (FirstToken == TRUE){
5626                                 
5627                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5628                                         FirstToken = FALSE;
5629                                 
5630                                 } else {
5631                                 
5632                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5633                                 
5634                                 }
5635                         
5636                         }
5637                 
5638                 }
5639         
5640         }                               
5641         
5642         intPropertyLen = PropertySeg2.Len();
5643         SplitPoints.clear();
5644         SplitLength.clear();
5645         intSplitsFound = 0;
5646         intSplitSize = 0;
5647         intPrevValue = 0;                       
5648         
5649         for (int i = 0; i <= intPropertyLen; i++){
5651                 intSplitSize++;
5652         
5653                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5654         
5655                         intSplitsFound++;
5656                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5657                         
5658                         if (intSplitsFound == 6){ 
5659                         
5660                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5661                                 break; 
5662                                 
5663                         } else {
5664                         
5665                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5666                         
5667                         }
5668                         
5669                         intSplitSize = 0;                                       
5670         
5671                 }
5673         }
5674         
5675         wxString wxSKeyURI;
5676         wxString wxSKeyMIME;
5677         wxString wxSKeyEncoding;
5678         wxString wxSKeyData;
5679         std::string base64enc;
5680         
5681         if (intSplitsFound == 0){
5682         
5683         } else {
5684         
5685                 std::map<int, int>::iterator striter;
5686         
5687                 striter = SplitLength.find(1);
5688         
5689                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5690         
5691                 while (wSTDataType.HasMoreTokens() == TRUE){
5692                 
5693                         wxSKeyURI = wSTDataType.GetNextToken();
5694                         wxSKeyMIME = wSTDataType.GetNextToken();
5695                         break;
5696                 
5697                 }                       
5698         
5699                 if (wxSKeyURI == wxT("data")){
5700                 
5701                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5702         
5703                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5704                 
5705                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5706                                 wxSKeyData = wSTDataInfo.GetNextToken();
5707                                 break;
5708                 
5709                         }
5710                 
5711                 }
5712         
5713         }
5714         
5715         // Add the data to the General/Home/Work address variables.
5716         
5717         if (wxSKeyURI == wxT("data")){
5718                 
5719                 KeyListDataEncType.erase(*KeyCount);
5720                 KeyListKeyType.erase(*KeyCount);
5721                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5722                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5723                 
5724                 KeyList.erase(*KeyCount);
5725                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5726         
5727         } else {
5728                 
5729                 KeyList.erase(*KeyCount);
5730                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5731         
5732         }
5733         
5734         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5735                 
5736         switch (PropType){
5737                 case PROPERTY_NONE:
5738                         break;
5739                 case PROPERTY_HOME: 
5740                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5741                         break;
5742                 case PROPERTY_WORK: 
5743                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5744                         break;
5745         }
5747         if (!PropertyTokens.IsEmpty()){
5749                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5751         }
5755 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5757         // Split the Vendor three ways.
5758         
5759         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5760         
5761         wxString wxSVNDID;
5762         wxString wxSVNDPropName;
5763         long ListCtrlIndex;                     
5765         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5766         
5767                 wSTVendorDetails.GetNextToken();
5768                 wxSVNDID = wSTVendorDetails.GetNextToken();
5769                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5770                 break;
5771         
5772         }
5773         
5774         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5775         
5776                 // Add the data to the vendor variables.
5777         
5778                 VendorList.erase(*VendorCount);
5779                 VendorListPEN.erase(*VendorCount);
5780                 VendorListElement.erase(*VendorCount);
5781         
5782                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5783                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5784                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5785         
5786         }
5790 void SplitValues(wxString *PropertyLine, 
5791         std::map<int,int> *SplitPoints, 
5792         std::map<int,int> *SplitLength, 
5793         int intSize){
5794         
5795         size_t intPropertyLen = PropertyLine->Len();
5796         int intSplitsFound = 0;
5797         int intSplitSize = 0;
5798         int intSplitSeek = 0;
5799         
5800         for (int i = intSize; i <= intPropertyLen; i++){
5802                 intSplitSize++;
5803         
5804                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5805                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5806            
5807                     if (intSplitsFound == 0){
5808             
5809                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5810           
5811                     } else {
5812            
5813                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5814             
5815                     }
5816             
5817                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5818             
5819                     intSplitsFound++;
5820                     intSplitSeek = i;
5821                     intSplitSize = 0;
5822             
5823                 }
5825         }
5827         if (intSplitsFound == 0){
5829                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5830                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5832         } else {
5834                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5835                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5837         }
5841 void CheckType(wxString *PropertySeg1, 
5842         std::map<int,int> *SplitPoints, 
5843         std::map<int,int> *SplitLength, 
5844         int *intPrevValue, 
5845         PropertyType *PropType){
5846         
5847         wxString PropertyData;
5848         wxString PropertyName;
5849         wxString PropertyValue;
5850         std::map<int,int>::iterator SLiter;
5851         
5852         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5853         intiter != SplitPoints->end(); ++intiter){
5854         
5855                 SLiter = SplitLength->find(intiter->first);
5856         
5857                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5858                 
5859                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5860                 PropertyName = PropertyElement.GetNextToken();                          
5861                 PropertyValue = PropertyElement.GetNextToken();
5862                 
5863                 *intPrevValue = intiter->second;
5864                 
5865                 if (PropertyName == wxT("TYPE")){
5866                                 
5867                         if (PropertyValue == wxT("work")){
5868                         
5869                                 *PropType = PROPERTY_WORK;
5870                                                         
5871                         } else if (PropertyValue == wxT("home")){
5873                                 *PropType = PROPERTY_HOME;
5874                                                         
5875                         } else {
5876                         
5877                                 *PropType = PROPERTY_NONE;
5878                         
5879                         }
5880                 
5881                         return;
5882                 
5883                 }
5884         
5885         }
5886         
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy