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