Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added extra unit tests for CATEGORIES and begun work on the PHOTO vCard property.
[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         int ContactLineLen = 0;
82         int QuoteBreakPoint = 0;
83         int GroupCount = 0;
84         int FNCount = 0;
85         int NicknameCount = 0;
86         int TimeZoneCount = 0;
87         int AddressCount = 0;
88         int EmailCount = 0;
89         int IMCount = 0;
90         int TelephoneCount = 0;
91         int LanguageCount = 0;
92         int GeographicCount = 0;
93         int RelatedCount = 0;
94         int URLCount = 0;
95         int TitleCount = 0;
96         int RoleCount = 0;
97         int OrganisationCount = 0;
98         int NoteCount = 0;
99         int CategoryCount = 0;
100         int PhotoCount = 0;
101         wxString ContactLine;
102         wxString PropertyLine;
103         wxString PropertySeg1;
104         wxString PropertySeg2;
105         wxString PropertyNextLine;
106         wxString Property;
107         
108         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
109          iter != ContactFileLines.end(); ++iter){
111                 ExtraLineSeek = TRUE;
112                 QuoteMode = FALSE;
113                 PropertyFind = TRUE;
114                 ContactLineLen = 0;
115                 QuoteBreakPoint = 0;
116                 ContactLine.Clear();
117                 PropertyLine.Clear();
118                 PropertySeg1.Clear();
119                 PropertySeg2.Clear();
120                 Property.Clear();
121          
122                 ContactLine = iter->second;
123                 
124                 while (ExtraLineSeek == TRUE){
125                 
126                         // Check if there is extra data on the next line 
127                         // (indicated by space or tab at the start) and add data.
128                 
129                         iter++;
130                         
131                         if (iter == ContactFileLines.end()){
132                         
133                                 iter--;
134                                 break;
135                         
136                         }                       
137                 
138                         PropertyNextLine = iter->second;
139                 
140                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
141                 
142                                 PropertyNextLine.Remove(0, 1);
143                                 ContactLine.Append(PropertyNextLine);
144                 
145                         } else {
146                         
147                                 iter--;
148                                 ExtraLineSeek = FALSE;
149                         
150                         }
151                 
152                 }
154                 ContactLineLen = ContactLine.Len();
155                 
156                 // Make sure we are not in quotation mode.
157                 // Make sure colon does not have \ or \\ before it.
158                 
159                 for (int i = 0; i <= ContactLineLen; i++){
160                 
161                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
162                         
163                                 PropertyFind = FALSE;
164                         
165                         } else if (PropertyFind == TRUE){
166                         
167                                 Property.Append(ContactLine.Mid(i, 1));
168                         
169                         }               
170                 
171                         if (ContactLine.Mid(i, 1) == wxT("\"")){
172                         
173                                 if (QuoteMode == TRUE){
174                                 
175                                         QuoteMode = FALSE;
176                                 
177                                 } else {
178                         
179                                         QuoteMode = TRUE;
180                                         
181                                 }
182                         
183                         }
184                         
185                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
186                         
187                                 QuoteBreakPoint = i;
188                                 break;
189                         
190                         }
191                 
192                 }
193                 
194                 // Split that line at the point into two variables (ignore the colon).
195                 
196                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
197                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
198                 
199                  if (Property == wxT("KIND") && KindProcessed == FALSE){
200                                 
201                         ProcessKind(PropertySeg2);
202                 
203                 } else if (Property == wxT("MEMBER")){
205                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
206                         GroupCount++;   
207                 
208                 } else if (Property == wxT("FN")){
209                 
210                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
211                         FNCount++;
212                 
213                 } else if (Property == wxT("N") && NameProcessed == FALSE){
214                 
215                         ProcessN(PropertySeg1, PropertySeg2);
216                         NameProcessed = TRUE;
217                 
218                 } else if (Property == wxT("NICKNAME")){
219                                                 
220                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
221                         NicknameCount++;
222                         
223                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
224                 
225                         ProcessGender(PropertySeg1, PropertySeg2);
226                         GenderProcessed = TRUE;
227                 
228                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
229                 
230                         ProcessBirthday(PropertySeg1, PropertySeg2);
231                         BirthdayProcessed = TRUE;
232                 
233                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
234                 
235                         ProcessAnniversary(PropertySeg1, PropertySeg2);
236                         AnniversaryProcessed = TRUE;
237                 
238                 } else if (Property == wxT("TZ")){
239                 
240                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
241                         TimeZoneCount++;
242                 
243                 } else if (Property == wxT("ADR")){
244                 
245                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
246                         AddressCount++;
247                 
248                 } else if (Property == wxT("EMAIL")){
249                                         
250                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
251                         EmailCount++;
252                 
253                 } else if (Property == wxT("IMPP")){
254                 
255                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
256                         IMCount++;
257                         
258                 } else if (Property == wxT("TEL")){
259                                 
260                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
261                         TelephoneCount++;
262                 
263                 } else if (Property == wxT("LANG")){
264                 
265                         // See frmContactEditor-LoadLanguage.cpp
266                         
267                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
268                         LanguageCount++;
269                 
270                 } else if (Property == wxT("GEO")){
271                 
272                         // See frmContactEditor-LoadGeo.cpp
273                         
274                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
275                         GeographicCount++;
276                 
277                 } else if (Property == wxT("RELATED")){
278                         
279                         // See fromContactEditor-LoadRelated.cpp
280                         
281                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
282                         RelatedCount++;
283                         
284                 } else if (Property == wxT("URL")){
286                         // See frmContactEditor-LoadURL.cpp
287                 
288                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
289                         URLCount++;
290                 
291                 } else if (Property == wxT("TITLE")) {
292                 
293                         // See frmContactEditor-LoadTitle.cpp
294                         
295                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
296                         TitleCount++;
297                         
298                 } else if (Property == wxT("ROLE")) {
299                 
300                         // See frmContactEditor-LoadTitle.cpp
301                         
302                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
303                         RoleCount++;
304                         
305                 } else if (Property == wxT("ORG")) {
306                 
307                         // See frmContactEditor-LoadOrg.cpp
308                         
309                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
310                         OrganisationCount++;
311                         
312                 } else if (Property == wxT("NOTE")) {
314                         // See frmContactEditor-LoadNote.cpp
316                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
317                         NoteCount++;    
318                         
319                 } else if (Property == wxT("CATEGORIES")) {
320                 
321                         // See frmContactEditor-LoadCategory.cpp
322                 
323                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
324                         CategoryCount++;
325                         
326                 } else if (Property == wxT("PHOTO")) {
327                 
328                         // See frmContactEditor-LoadPhoto.cpp
329                         
330                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
331                         PhotoCount++;
333                 }
334                 
335         }
336         
337         return CONTACTLOAD_OK;
341 void ContactDataObject::ProcessKind(wxString KindType){
343         if (KindType == wxT("individual")){
344                         
345                 ContactKind = CONTACTKIND_INDIVIDUAL;
346                         
347         } else if (KindType == wxT("group")){
348                         
349                 ContactKind = CONTACTKIND_GROUP;
350                         
351         } else if (KindType == wxT("org")){
352                         
353                 ContactKind = CONTACTKIND_ORGANISATION;
354                         
355         } else if (KindType == wxT("location")){
356                         
357                 ContactKind = CONTACTKIND_LOCATION;
358                         
359         } else {
360                         
361                 ContactKind = CONTACTKIND_NONE;                 
362         }
366 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
368         std::map<int, int> SplitPoints;
369         std::map<int, int> SplitLength;
371         int intPrevValue = 8;
372         int intPref = 0;                        
373         int intType = 0;
374         
375         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
377         intPrevValue = 7;
378         
379         wxString PropertyName;
380         wxString PropertyValue;
381         wxString PropertyData;
382         wxString PropertyTokens;
383         std::map<int,int>::iterator SLiter;
384         bool FirstToken = TRUE;
385         
386         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
387         intiter != SplitPoints.end(); ++intiter){
388         
389                 SLiter = SplitLength.find(intiter->first);
390         
391                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
392                 
393                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
394                 PropertyName = PropertyElement.GetNextToken();                          
395                 PropertyValue = PropertyElement.GetNextToken();
396                 
397                 intPrevValue = intiter->second;
398                 
399                 CaptureString(&PropertyValue, FALSE);
400         
401                 if (PropertyName == wxT("ALTID")){
403                         GroupsListAltID.erase(*GroupCount);
404                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
405                 
406                 } else if (PropertyName == wxT("PID")){
408                         GroupsListPID.erase(*GroupCount);
409                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
410                 
411                 } else if (PropertyName == wxT("PREF")){
413                         int PriorityNumber = 0;
414                         bool ValidNumber = TRUE;
415                         
416                         try{
417                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
418                         }
419                         
420                         catch(std::invalid_argument &e){
421                                 ValidNumber = FALSE;
422                         }
424                         if (ValidNumber == TRUE){
426                                 GroupsListPref.erase(*GroupCount);
427                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
428                 
429                         }
430                 
431                 } else if (PropertyName == wxT("MEDIATYPE")){
433                         GroupsListMediaType.erase(*GroupCount);
434                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
435                 
436                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
437                         
438                         if (FirstToken == TRUE){
439                                 
440                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
441                                 FirstToken = FALSE;
442                                 
443                         } else {
444                         
445                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
446                                 
447                         }
448                         
449                 }
450                 
451         }
453         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
455         if (!PropertyTokens.IsEmpty()){
456         
457                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
458         
459         }
464 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
466         std::map<int, int> SplitPoints;
467         std::map<int, int> SplitLength;
469         int intPrevValue = 4;
470         int intPref = 0;                        
471         int intType = 0;
472         
473         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
475         intPrevValue = 3;
476         
477         wxString PropertyName;
478         wxString PropertyValue;
479         wxString PropertyData;
480         wxString PropertyTokens;
481         std::map<int,int>::iterator SLiter;
482         bool FirstToken = TRUE;
483         
484         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
485         intiter != SplitPoints.end(); ++intiter){
486         
487                 SLiter = SplitLength.find(intiter->first);
488         
489                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
490                 
491                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
492                 PropertyName = PropertyElement.GetNextToken();                          
493                 PropertyValue = PropertyElement.GetNextToken();
494                 
495                 intPrevValue = intiter->second;
496                 
497                 CaptureString(&PropertyValue, FALSE);
498                 
499                 if (PropertyName == wxT("TYPE")){
501                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
502                                 PropertyValue == wxT("work") ){
504                                 FullNamesListType.erase(*FNCount);
505                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
506                 
507                         }
508                 
509                 } else if (PropertyName == wxT("LANGUAGE")){
511                         FullNamesListLanguage.erase(*FNCount);
512                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
513                 
514                 } else if (PropertyName == wxT("ALTID")){
515                 
516                         FullNamesListAltID.erase(*FNCount);
517                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
518                 
519                 } else if (PropertyName == wxT("PID")){
521                         FullNamesListPID.erase(*FNCount);
522                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
523                 
524                 } else if (PropertyName == wxT("PREF")){
526                         int PriorityNumber = 0;
527                         bool ValidNumber = TRUE;
528                         
529                         try{
530                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
531                         }
532                         
533                         catch(std::invalid_argument &e){
534                                 ValidNumber = FALSE;
535                         }
537                         if (ValidNumber == TRUE){
539                                 FullNamesListPref.erase(*FNCount);
540                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
542                         }
543                 
544                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
545                         
546                         if (FirstToken == TRUE){
547                                 
548                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
549                                 FirstToken = FALSE;
550                                 
551                         } else {
552                         
553                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
554                                 
555                         }
556                         
557                 } 
558         
559         }
561         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
563         if (!PropertyTokens.IsEmpty()){
564         
565                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
566         
567         }
571 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
573         std::map<int, int> SplitPoints;
574         std::map<int, int> SplitLength;
576         int intPrevValue = 3;
577         int intPref = 0;                        
578         int intType = 0;
579         
580         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
581         
582         intPrevValue = 2;
583         
584         wxString PropertyName;
585         wxString PropertyValue;
586         wxString PropertyData;
587         wxString PropertyTokens;
588         std::map<int,int>::iterator SLiter;
589         bool FirstToken = TRUE;
590         
591         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
592         intiter != SplitPoints.end(); ++intiter){
593         
594                 SLiter = SplitLength.find(intiter->first);
595         
596                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
597                 
598                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
599                 PropertyName = PropertyElement.GetNextToken();                          
600                 PropertyValue = PropertyElement.GetNextToken();
601                 
602                 intPrevValue = intiter->second;
603                 
604                 CaptureString(&PropertyValue, FALSE);
605                 
606                 if (PropertyName == wxT("ALTID")){
608                         NameAltID = PropertyValue;
609                 
610                 } else if (PropertyName == wxT("LANGUAGE")){
611                 
612                         NameLanguage = PropertyValue;
613                 
614                 } else if (PropertyName == wxT("SORT-AS")){
615                 
616                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
617                                 PropertyValue.Len() >= 3){
618                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
619                         }
620                 
621                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
622                         
623                         if (FirstToken == TRUE){
624                                 
625                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
626                                 FirstToken = FALSE;
627                                 
628                         } else {
629                         
630                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
631                                 
632                         }
633                         
634                 }
635         
636         }
637         
638         // Split the name data.
639         
640         int intSplitSeek = 0;           
641         int intSplitsFound = 0;
642         int intSplitSize = 0;
643         int intPropertyLen = PropertySeg2.Len();
644         
645         std::map<int,wxString> NameValues;
646         intPrevValue = 0;                                       
647         
648         for (int i = 0; i <= intPropertyLen; i++){
649         
650                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
651                         
652                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
653                         
654                         intSplitSeek = i;
655                         intSplitSeek++;
656                         
657                         if (intSplitsFound == 4){
658                         
659                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
660                                 break;
661                         
662                         }
663                         
664                         intSplitSize = 0;
665                         continue;
666         
667                 }
668                 
669                 intSplitSize++;
671         }
672         
673         // Split the data into several parts.
674                         
675         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
676         iter != NameValues.end(); ++iter){
677         
678                 if (iter->first == 1){
679                 
680                         // Deal with family name.
681                         
682                         NameSurname = iter->second;
683                 
684                 } else if (iter->first == 2){
685                 
686                         // Deal with given names.
687                         
688                         NameForename = iter->second;
689                 
690                 } else if (iter->first == 3){
691                 
692                         // Deal with additional names.
693                         
694                         NameOtherNames = iter->second;
695                 
696                 } else if (iter->first == 4){
697                 
698                         // Deal with honorifix prefixes and suffixes.
700                         NameTitle = iter->second;
701                 
702                         iter++;
703                         
704                         if (iter == NameValues.end()){
705                         
706                                 break;
707                         
708                         }
709                 
710                         NameSuffix = iter->second;
711                 
712                 }
713         
714         }
715         
716         // Add the name token data.
717         
718         if (!PropertyTokens.IsEmpty()){
719         
720                 NameTokens = PropertyTokens;
721         
722         }
726 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
728         std::map<int, int> SplitPoints;
729         std::map<int, int> SplitLength;
731         int intPrevValue = 10;
732         int intPref = 0;                        
733         
734         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
735         
736         intPrevValue = 9;
737         
738         PropertyType PropType = PROPERTY_NONE;
739         
740         // Look for type before continuing.
741         
742         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
743         
744         intPrevValue = 9;
745         
746         std::map<int, wxString> *NicknamesList = NULL;
747         std::map<int, wxString> *NicknamesListType = NULL;
748         std::map<int, wxString> *NicknamesListLanguage = NULL;
749         std::map<int, wxString> *NicknamesListAltID = NULL;
750         std::map<int, wxString> *NicknamesListPID = NULL;
751         std::map<int, wxString> *NicknamesListTokens = NULL;            
752         std::map<int, int> *NicknamesListPref = NULL;
753         
754         switch(PropType){
755                 case PROPERTY_NONE:
756                         NicknamesList = &GeneralNicknamesList;
757                         NicknamesListType = &GeneralNicknamesListType;
758                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
759                         NicknamesListAltID = &GeneralNicknamesListAltID;
760                         NicknamesListPID = &GeneralNicknamesListPID;
761                         NicknamesListTokens = &GeneralNicknamesListTokens;
762                         NicknamesListPref = &GeneralNicknamesListPref;
763                         break;
764                 case PROPERTY_HOME:
765                         NicknamesList = &HomeNicknamesList;
766                         NicknamesListType = &HomeNicknamesListType;
767                         NicknamesListLanguage = &HomeNicknamesListLanguage;
768                         NicknamesListAltID = &HomeNicknamesListAltID;
769                         NicknamesListPID = &HomeNicknamesListPID;
770                         NicknamesListTokens = &HomeNicknamesListTokens;
771                         NicknamesListPref = &HomeNicknamesListPref;
772                         break;
773                 case PROPERTY_WORK:
774                         NicknamesList = &BusinessNicknamesList;
775                         NicknamesListType = &BusinessNicknamesListType;
776                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
777                         NicknamesListAltID = &BusinessNicknamesListAltID;
778                         NicknamesListPID = &BusinessNicknamesListPID;
779                         NicknamesListTokens = &BusinessNicknamesListTokens;
780                         NicknamesListPref = &BusinessNicknamesListPref;
781                         break;
782         }
783         
784         std::map<int, int>::iterator SLiter;    
785         wxString PropertyData;
786         wxString PropertyName;
787         wxString PropertyValue;
788         wxString PropertyTokens;
789         bool FirstToken = TRUE;
790         
791         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
792         intiter != SplitPoints.end(); ++intiter){
793         
794                 SLiter = SplitLength.find(intiter->first);
795         
796                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
797                 
798                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
799                 PropertyName = PropertyElement.GetNextToken();                          
800                 PropertyValue = PropertyElement.GetNextToken();
801                 
802                 intPrevValue = intiter->second;
803                 
804                 CaptureString(&PropertyValue, FALSE);
805                 
806                 if (PropertyName == wxT("ALTID")){
808                         NicknamesListAltID->erase(*NicknameCount);
809                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
810                 
811                 } else if (PropertyName == wxT("PID")){
813                         NicknamesListPID->erase(*NicknameCount);
814                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
816                 } else if (PropertyName == wxT("PREF")){
818                         int PriorityNumber = 0;
819                         bool ValidNumber = TRUE;
820                         
821                         try{
822                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
823                         }
824                         
825                         catch(std::invalid_argument &e){
826                                 ValidNumber = FALSE;
827                         }
829                         if (ValidNumber == TRUE){
831                                 NicknamesListPref->erase(*NicknameCount);
832                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
834                         }
835                 
836                 } else if (PropertyName == wxT("LANGUAGE")){
838                         NicknamesListLanguage->erase(*NicknameCount);
839                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
841                 } else {
842                 
843                         // Something else we don't know about so append
844                         // to the tokens variable.
845                 
846                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
847                 
848                                 if (FirstToken == TRUE){
849                         
850                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
851                                         FirstToken = FALSE;
852                         
853                                 } else {
854                         
855                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
856                         
857                                 }
858                 
859                         }
860                 
861                 }
862                 
863         }
864         
865         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
866         
867         // Add the name token data.
868         
869         if (!PropertyTokens.IsEmpty()){
870         
871                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
872         
873         }
877 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
879         std::map<int, int> SplitPoints;
880         std::map<int, int> SplitLength;
881         std::map<int, int>::iterator SLiter;                    
882         wxString PropertyData;
883         wxString PropertyName;
884         wxString PropertyValue;
885         wxString PropertyTokens;
886         bool FirstToken = TRUE;
887         int intPrevValue = 8;
889         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
891         intPrevValue = 7;                       
892         
893         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
894         intiter != SplitPoints.end(); ++intiter){
895         
896                 SLiter = SplitLength.find(intiter->first);
897         
898                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
899                 
900                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
901                 PropertyName = PropertyElement.GetNextToken();                          
902                 PropertyValue = PropertyElement.GetNextToken();
903                 
904                 intPrevValue = intiter->second;
905                 
906                 // Process properties.
907                 
908                 size_t intPropertyValueLen = PropertyValue.Len();
909                 
910                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
911                         
912                         PropertyValue.Trim();
913                         PropertyValue.RemoveLast();
914                         
915                 }                               
916                 
917                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
918                         
919                         PropertyValue.Remove(0, 1);
920                         
921                 }                               
922                 
923                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
925                         if (FirstToken == TRUE){
926         
927                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
928                                 FirstToken = FALSE;
929         
930                         } else {
931         
932                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
933         
934                         }
936                 }
937         
938         }       
940         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
941         
942         wxString GenderComponent;
943         
944         if (GenderData.CountTokens() >= 2){
945         
946                 Gender = GenderData.GetNextToken();
947                 GenderDetails = GenderData.GetString();
948         
949                 CaptureString(&GenderDetails, FALSE);
950                                                 
951         } else {
952         
953                 Gender = GenderData.GetNextToken();
954         
955         }
956         
957         if (!PropertyTokens.IsEmpty()){
958         
959                 GenderTokens = PropertyTokens;
960         
961         }
965 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
967         // Process date. Preserve the remainder in the string.
969         std::map<int, int> SplitPoints;
970         std::map<int, int> SplitLength;
971         std::map<int, int>::iterator SLiter;                    
972         wxString PropertyData;
973         wxString PropertyName;
974         wxString PropertyValue;
975         wxString PropertyTokens;
976         bool BirthdayText = FALSE;
977         int intPrevValue = 6;
979         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
981         intPrevValue = 5;
983         // Look for type before continuing.
985         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
986         intiter != SplitPoints.end(); ++intiter){
988                 SLiter = SplitLength.find(intiter->first);
990                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
991         
992                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
993                 PropertyName = PropertyElement.GetNextToken();                          
994                 PropertyValue = PropertyElement.GetNextToken();
995         
996                 intPrevValue = intiter->second;
997         
998                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
999         
1000                         CaptureString(&PropertySeg2, FALSE);
1001                         Birthday = PropertySeg2;
1002                         BirthdayText = TRUE;
1003         
1004                 }
1006         }
1008         // Setup blank lines for later on.
1009         
1010         intPrevValue = 5;
1011         bool FirstToken = TRUE;
1013         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1014         intiter != SplitPoints.end(); ++intiter){
1016                 SLiter = SplitLength.find(intiter->first);
1018                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1019         
1020                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1021                 PropertyName = PropertyElement.GetNextToken();                          
1022                 PropertyValue = PropertyElement.GetNextToken();
1023         
1024                 intPrevValue = intiter->second;
1025         
1026                 // Process properties.
1027         
1028                 CaptureString(&PropertyValue, FALSE);
1029         
1030                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1031                 
1032                         PropertyValue.Trim();
1033                         PropertyValue.RemoveLast();
1034                 
1035                 }                               
1036         
1037                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1038                 
1039                         PropertyValue.Remove(0, 1);
1040                 
1041                 }                               
1042         
1043                 if (PropertyName == wxT("ALTID")){
1045                         BirthdayAltID = PropertyValue;
1046         
1047                 } else if (PropertyName == wxT("CALSCALE")){
1048         
1049                         BirthdayCalScale = PropertyValue;
1050         
1051                 } else if (PropertyName != wxT("VALUE")) {
1052         
1053                         // Something else we don't know about so append
1054                         // to the tokens variable.
1055                 
1056                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1057                 
1058                                 if (FirstToken == TRUE){
1059         
1060                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1061                                         FirstToken = FALSE;
1062         
1063                                 } else {
1064         
1065                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1066         
1067                                 }
1068                                 
1069                         }
1070                         
1071                 }
1073         }       
1075         // Add the data to the variables and form.
1076         
1077         if (BirthdayText == FALSE){
1078         
1079                 Birthday = PropertySeg2;
1081         }
1082         
1083         if (!PropertyTokens.IsEmpty()){
1084         
1085                 BirthdayTokens = PropertyTokens;
1087         }
1091 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1093         // Process date. Preserve the remainder in the string.
1095         std::map<int, int> SplitPoints;
1096         std::map<int, int> SplitLength;
1097         std::map<int, int>::iterator SLiter;                    
1098         wxString PropertyData;
1099         wxString PropertyName;
1100         wxString PropertyValue;
1101         wxString PropertyTokens;
1102         bool AnniversaryText = FALSE;
1103         int intPrevValue = 13;
1105         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1107         intPrevValue = 12;
1109         // Look for type before continuing.
1111         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1112         intiter != SplitPoints.end(); ++intiter){
1114                 SLiter = SplitLength.find(intiter->first);
1116                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1117         
1118                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1119                 PropertyName = PropertyElement.GetNextToken();                          
1120                 PropertyValue = PropertyElement.GetNextToken();
1121         
1122                 intPrevValue = intiter->second;
1123         
1124                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1125         
1126                         CaptureString(&PropertySeg2, FALSE);
1127                         Anniversary = PropertySeg2;
1128                         AnniversaryText = TRUE;
1129         
1130                 }
1132         }
1134         // Setup blank lines for later on.
1135         
1136         intPrevValue = 12;
1137         bool FirstToken = TRUE;
1139         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1140         intiter != SplitPoints.end(); ++intiter){
1142                 SLiter = SplitLength.find(intiter->first);
1144                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1145         
1146                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1147                 PropertyName = PropertyElement.GetNextToken();                          
1148                 PropertyValue = PropertyElement.GetNextToken();
1149         
1150                 intPrevValue = intiter->second;
1151         
1152                 // Process properties.
1153         
1154                 CaptureString(&PropertyValue, FALSE);
1155         
1156                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1157                 
1158                         PropertyValue.Trim();
1159                         PropertyValue.RemoveLast();
1160                 
1161                 }                               
1162         
1163                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1164                 
1165                         PropertyValue.Remove(0, 1);
1166                 
1167                 }                               
1168         
1169                 if (PropertyName == wxT("ALTID")){
1171                         AnniversaryAltID = PropertyValue;
1172         
1173                 } else if (PropertyName == wxT("CALSCALE")){
1174         
1175                         AnniversaryCalScale = PropertyValue;
1176         
1177                 } else if (PropertyName != wxT("VALUE")) {
1178         
1179                         // Something else we don't know about so append
1180                         // to the tokens variable.
1181                 
1182                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1183                 
1184                                 if (FirstToken == TRUE){
1185         
1186                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1187                                         FirstToken = FALSE;
1188         
1189                                 } else {
1190         
1191                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1192         
1193                                 }
1194                                 
1195                         }
1196                         
1197                 }
1199         }       
1201         // Add the data to the variables and form.
1202         
1203         if (AnniversaryText == FALSE){
1204         
1205                 Anniversary = PropertySeg2;
1207         }
1208         
1209         if (!PropertyTokens.IsEmpty()){
1210         
1211                 AnniversaryTokens = PropertyTokens;
1213         }
1217 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1219         std::map<int, int> SplitPoints;
1220         std::map<int, int> SplitLength;
1222         int intPrevValue = 4;
1223         int intPref = 0;                        
1224         
1225         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1226         
1227         intPrevValue = 3;
1228         
1229         PropertyType PropType = PROPERTY_NONE;
1230         
1231         // Look for type before continuing.
1232         
1233         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1234         
1235         intPrevValue = 3;
1236         
1237         std::map<int, wxString> *TZList = NULL;
1238         std::map<int, wxString> *TZListType = NULL;
1239         std::map<int, wxString> *TZListMediatype = NULL;
1240         std::map<int, wxString> *TZListAltID = NULL;
1241         std::map<int, wxString> *TZListPID = NULL;
1242         std::map<int, wxString> *TZListTokens = NULL;           
1243         std::map<int, int> *TZListPref = NULL;
1244         
1245         switch(PropType){
1246                 case PROPERTY_NONE:
1247                         TZList = &GeneralTZList;
1248                         TZListType = &GeneralTZListType;
1249                         TZListMediatype = &GeneralTZListMediatype;
1250                         TZListAltID = &GeneralTZListAltID;
1251                         TZListPID = &GeneralTZListPID;
1252                         TZListTokens = &GeneralTZListTokens;
1253                         TZListPref = &GeneralTZListPref;
1254                         break;
1255                 case PROPERTY_HOME:
1256                         TZList = &HomeTZList;
1257                         TZListType = &HomeTZListType;
1258                         TZListMediatype = &HomeTZListMediatype;
1259                         TZListAltID = &HomeTZListAltID;
1260                         TZListPID = &HomeTZListPID;
1261                         TZListTokens = &HomeTZListTokens;
1262                         TZListPref = &HomeTZListPref;
1263                         break;
1264                 case PROPERTY_WORK:
1265                         TZList = &BusinessTZList;
1266                         TZListType = &BusinessTZListType;
1267                         TZListMediatype = &BusinessTZListMediatype;
1268                         TZListAltID = &BusinessTZListAltID;
1269                         TZListPID = &BusinessTZListPID;
1270                         TZListTokens = &BusinessTZListTokens;
1271                         TZListPref = &BusinessTZListPref;
1272                         break;
1273         }
1274         
1275         std::map<int, int>::iterator SLiter;    
1276         wxString PropertyData;
1277         wxString PropertyName;
1278         wxString PropertyValue;
1279         wxString PropertyTokens;
1280         bool FirstToken = TRUE;
1281         
1282         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1283         intiter != SplitPoints.end(); ++intiter){
1284         
1285                 SLiter = SplitLength.find(intiter->first);
1286         
1287                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1288                 
1289                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1290                 PropertyName = PropertyElement.GetNextToken();                          
1291                 PropertyValue = PropertyElement.GetNextToken();
1292                 
1293                 intPrevValue = intiter->second;
1294                 
1295                 CaptureString(&PropertyValue, FALSE);
1297                 if (PropertyName == wxT("ALTID")){
1299                         TZListAltID->erase(*TimeZoneCount);
1300                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1301                 
1302                 } else if (PropertyName == wxT("PID")){
1304                         TZListPID->erase(*TimeZoneCount);
1305                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1307                 } else if (PropertyName == wxT("PREF")){
1309                         int PriorityNumber = 0;
1310                         bool ValidNumber = TRUE;
1311                         
1312                         try{
1313                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1314                         }
1315                         
1316                         catch(std::invalid_argument &e){
1317                                 ValidNumber = FALSE;
1318                         }
1320                         if (ValidNumber == TRUE){
1322                                 TZListPref->erase(*TimeZoneCount);
1323                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1325                         }
1326                 
1327                 } else if (PropertyName == wxT("MEDIATYPE")){
1329                         TZListMediatype->erase(*TimeZoneCount);
1330                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1332                 } else {
1333                 
1334                         // Something else we don't know about so append
1335                         // to the tokens variable.
1336                 
1337                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1338                 
1339                                 if (FirstToken == TRUE){
1340                         
1341                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1342                                         FirstToken = FALSE;
1343                         
1344                                 } else {
1345                         
1346                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1347                         
1348                                 }
1349                 
1350                         }
1351                 
1352                 }
1353                 
1354         }
1355         
1356         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1357         
1358         // Add the name token data.
1359         
1360         if (!PropertyTokens.IsEmpty()){
1361         
1362                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1363         
1364         }
1369 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1371         size_t intPropertyLen = PropertySeg1.Len();
1372         std::map<int, int> SplitPoints;
1373         std::map<int, int> SplitLength;
1374         std::map<int, int>::iterator SLiter;                    
1375         wxString PropertyData;
1376         wxString PropertyName;
1377         wxString PropertyValue;
1378         wxString PropertyTokens;
1379         wxString AddressLabel;
1380         wxString AddressLang;
1381         wxString AddressAltID;
1382         wxString AddressPID;
1383         wxString AddressTokens;
1384         wxString AddressGeo;
1385         wxString AddressTimezone;
1386         wxString AddressType;
1387         wxString AddressMediatype;
1388         wxString AddressPOBox;
1389         wxString AddressExtended;
1390         wxString AddressStreet;
1391         wxString AddressLocality;
1392         wxString AddressCity;
1393         wxString AddressRegion;
1394         wxString AddressPostalCode;
1395         wxString AddressCountry;
1396         bool FirstToken = TRUE;                 
1397         int intSplitsFound = 0;
1398         int intSplitSize = 0;
1399         int intPrevValue = 5;
1400         int intPref = 0;                        
1401         int intType = 0;
1402         long ListCtrlIndex;
1403         
1404         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1405         
1406         intPrevValue = 4;
1407         
1408         PropertyType PropType = PROPERTY_NONE;
1409                 
1410         // Look for type before continuing.
1411         
1412         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1413         
1414         intPrevValue = 4;
1415         
1416         std::map<int, wxString> *AddressList = NULL;
1417         std::map<int, wxString> *AddressListTown = NULL;
1418         std::map<int, wxString> *AddressListCounty = NULL;
1419         std::map<int, wxString> *AddressListPostCode = NULL;
1420         std::map<int, wxString> *AddressListCountry = NULL;
1421         std::map<int, wxString> *AddressListLabel = NULL;
1422         std::map<int, wxString> *AddressListLang = NULL;                
1423         std::map<int, wxString> *AddressListAltID = NULL;
1424         std::map<int, wxString> *AddressListPID = NULL;
1425         std::map<int, wxString> *AddressListTokens = NULL;
1426         std::map<int, wxString> *AddressListGeo = NULL;
1427         std::map<int, wxString> *AddressListTimezone = NULL;            
1428         std::map<int, wxString> *AddressListType = NULL;
1429         std::map<int, wxString> *AddressListMediatype = NULL;
1430         std::map<int, int> *AddressListPref = NULL;
1432         switch(PropType){
1433                 case PROPERTY_NONE:
1434                         AddressList = &GeneralAddressList;
1435                         AddressListTown = &GeneralAddressListTown;
1436                         AddressListCounty = &GeneralAddressListCounty;
1437                         AddressListPostCode = &GeneralAddressListPostCode;
1438                         AddressListCountry = &GeneralAddressListCountry;
1439                         AddressListLabel = &GeneralAddressListLabel;
1440                         AddressListLang = &GeneralAddressListLang;              
1441                         AddressListAltID = &GeneralAddressListAltID;
1442                         AddressListPID = &GeneralAddressListPID;
1443                         AddressListTokens = &GeneralAddressListTokens;
1444                         AddressListGeo = &GeneralAddressListGeo;
1445                         AddressListTimezone = &GeneralAddressListTimezone;
1446                         AddressListType = &GeneralAddressListType;
1447                         AddressListMediatype = &GeneralAddressListMediatype;
1448                         AddressListPref = &GeneralAddressListPref;              
1449                         break;
1450                 case PROPERTY_HOME:
1451                         AddressList = &HomeAddressList;
1452                         AddressListTown = &HomeAddressListTown;
1453                         AddressListCounty = &HomeAddressListCounty;
1454                         AddressListPostCode = &HomeAddressListPostCode;
1455                         AddressListCountry = &HomeAddressListCountry;
1456                         AddressListLabel = &HomeAddressListLabel;
1457                         AddressListLang = &HomeAddressListLang;         
1458                         AddressListAltID = &HomeAddressListAltID;
1459                         AddressListPID = &HomeAddressListPID;
1460                         AddressListTokens = &HomeAddressListTokens;
1461                         AddressListGeo = &HomeAddressListGeo;
1462                         AddressListTimezone = &HomeAddressListTimezone;
1463                         AddressListType = &HomeAddressListType;
1464                         AddressListMediatype = &HomeAddressListMediatype;
1465                         AddressListPref = &HomeAddressListPref;
1466                         break;
1467                 case PROPERTY_WORK:
1468                         AddressList = &BusinessAddressList;
1469                         AddressListTown = &BusinessAddressListTown;
1470                         AddressListCounty = &BusinessAddressListCounty;
1471                         AddressListPostCode = &BusinessAddressListPostCode;
1472                         AddressListCountry = &BusinessAddressListCountry;
1473                         AddressListLabel = &BusinessAddressListLabel;
1474                         AddressListLang = &BusinessAddressListLang;             
1475                         AddressListAltID = &BusinessAddressListAltID;
1476                         AddressListPID = &BusinessAddressListPID;
1477                         AddressListTokens = &BusinessAddressListTokens;
1478                         AddressListGeo = &BusinessAddressListGeo;
1479                         AddressListTimezone = &BusinessAddressListTimezone;
1480                         AddressListType = &BusinessAddressListType;
1481                         AddressListMediatype = &BusinessAddressListMediatype;
1482                         AddressListPref = &BusinessAddressListPref;
1483                         break;
1484         }
1485         
1486         intPrevValue = 4;
1487         
1488         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1489         intiter != SplitPoints.end(); ++intiter){
1490         
1491                 SLiter = SplitLength.find(intiter->first);
1492         
1493                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1494                 
1495                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1496                 PropertyName = PropertyElement.GetNextToken();                          
1497                 PropertyValue = PropertyElement.GetNextToken();
1498                 
1499                 intPrevValue = intiter->second;
1500                 
1501                 CaptureString(&PropertyValue, FALSE);
1502                 
1503                 // Process properties.
1504                 
1505                 if (PropertyName == wxT("LABEL")){
1506                 
1507                         AddressListLabel->erase(*AddressCount);
1508                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1509                                 
1510                 } else if (PropertyName == wxT("LANGUAGE")){
1511                 
1512                         AddressListLang->erase(*AddressCount);
1513                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1514                 
1515                 } else if (PropertyName == wxT("ALTID")){
1517                         AddressListAltID->erase(*AddressCount);
1518                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1519                 
1520                 } else if (PropertyName == wxT("PID")){
1522                         AddressListPID->erase(*AddressCount);
1523                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1524                 
1525                 } else if (PropertyName == wxT("GEO")){
1526                 
1527                         AddressListGeo->erase(*AddressCount);
1528                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1529                 
1530                 } else if (PropertyName == wxT("TZ")){
1532                         AddressListTimezone->erase(*AddressCount);
1533                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1534                 
1535                 } else if (PropertyName == wxT("MEDIATYPE")){
1537                         AddressListMediatype->erase(*AddressCount);
1538                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1539                 
1540                 } else if (PropertyName == wxT("PREF")){
1541                         
1542                         int PriorityNumber = 0;
1543                         bool ValidNumber = TRUE;
1544                         
1545                         try{
1546                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1547                         }
1548                         
1549                         catch(std::invalid_argument &e){
1550                                 ValidNumber = FALSE;
1551                         }
1553                         if (ValidNumber == TRUE){
1555                                 AddressListPref->erase(*AddressCount);
1556                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1558                         }
1559                 
1560                 } else {
1561                 
1562                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1563                         
1564                                 if (FirstToken == TRUE){
1565                                 
1566                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1567                                         FirstToken = FALSE;
1568                                 
1569                                 } else {
1570                                 
1571                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1572                                 
1573                                 }
1574                         
1575                         }
1576                 
1577                 }
1578         
1579         }                       
1580         
1581         // Split the address. 
1583         //std::map<int, int>::iterator SLiter;
1584         intPropertyLen = PropertySeg2.Len();
1585         SplitPoints.clear();
1586         SplitLength.clear();
1587         intSplitsFound = 0;
1588         intSplitSize = 0;
1589         intPrevValue = 0;
1590         
1591         for (int i = 0; i <= intPropertyLen; i++){
1593                 intSplitSize++;
1594         
1595                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1596         
1597                         intSplitsFound++;
1598                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1599                         
1600                         if (intSplitsFound == 6){ 
1601                         
1602                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1603                                 break; 
1604                                 
1605                         } else {
1606                         
1607                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1608                         
1609                         }
1610                         
1611                         intSplitSize = 0;                                       
1612         
1613                 }
1615         }
1616         
1617         // Split the data into several parts.                   
1618         
1619         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1620         intiter != SplitPoints.end(); ++intiter){
1621                         
1622                 if (intiter->first == 1){
1623                 
1624                         // Deal with PO Box.
1625                         
1626                         SLiter = SplitLength.find(1);
1627                                                                 
1628                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1629                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1630                         intPrevValue = intiter->second;
1631                 
1632                 } else if (intiter->first == 2){
1633                 
1634                         // Deal with extended address.
1635                         
1636                         SLiter = SplitLength.find(2);
1637                         
1638                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1639                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1640                         intPrevValue = intiter->second;
1641                 
1642                 } else if (intiter->first == 3){
1643                 
1644                         // Deal with street address.
1645                         
1646                         SLiter = SplitLength.find(3);
1647                                                                 
1648                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1649                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1650                         intPrevValue = intiter->second;
1651                 
1652                 } else if (intiter->first == 4){
1653                 
1654                         // Deal with locality
1656                         SLiter = SplitLength.find(4);
1657                         
1658                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1659                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1660                         intPrevValue = intiter->second;
1661                         
1662                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1663                 
1664                 } else if (intiter->first == 5){
1665                 
1666                         // Deal with region.
1668                         SLiter = SplitLength.find(5);
1669                         
1670                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1671                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1672                         intPrevValue = intiter->second;
1673                         
1674                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1675                 
1676                 } else if (intiter->first == 6){
1677                 
1678                         // Deal with post code.
1680                         SLiter = SplitLength.find(6);
1681                         
1682                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1683                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1684                         intPrevValue = intiter->second;
1685                         
1686                         // Deal with country.
1687                                                 
1688                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1689                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1690                         
1691                         break;
1692                 
1693                 }
1694         
1695         }       
1696         
1697         // Add the data to the General/Home/Work address variables.
1698         
1699         CaptureString(&AddressStreet, FALSE); 
1700         CaptureString(&AddressLocality, FALSE);
1701         CaptureString(&AddressRegion, FALSE);
1702         CaptureString(&AddressPostalCode, FALSE);
1703         CaptureString(&AddressCountry, FALSE);
1704                 
1705         if (!PropertyTokens.IsEmpty()){
1706         
1707                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1708         
1709         }
1711         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1712         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1713         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1714         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1715         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1717         switch(PropType){
1718                 case PROPERTY_NONE:
1719                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1720                         break;
1721                 case PROPERTY_HOME:
1722                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1723                         break;
1724                 case PROPERTY_WORK:
1725                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1726                         break;
1727         }
1728         
1729         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1733 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1735         std::map<int, int> SplitPoints;
1736         std::map<int, int> SplitLength;
1738         int intPrevValue = 7;
1739         int intPref = 0;                        
1740         
1741         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1742         
1743         intPrevValue = 6;
1744         
1745         PropertyType PropType = PROPERTY_NONE;
1746                 
1747         // Look for type before continuing.
1748         
1749         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1750         
1751         std::map<int, wxString> *EmailList = NULL;
1752         std::map<int, wxString> *EmailListType = NULL;
1753         std::map<int, wxString> *EmailListAltID = NULL;
1754         std::map<int, wxString> *EmailListPID = NULL;
1755         std::map<int, wxString> *EmailListTokens = NULL;                
1756         std::map<int, int> *EmailListPref = NULL;
1758         switch(PropType){
1759                 case PROPERTY_NONE:
1760                         EmailList = &GeneralEmailList;
1761                         EmailListType = &GeneralEmailListType;
1762                         EmailListAltID = &GeneralEmailListAltID;
1763                         EmailListPID = &GeneralEmailListPID;
1764                         EmailListTokens = &GeneralEmailListTokens;              
1765                         EmailListPref = &GeneralEmailListPref;  
1766                         break;
1767                 case PROPERTY_HOME:
1768                         EmailList = &HomeEmailList;
1769                         EmailListType = &HomeEmailListType;
1770                         EmailListAltID = &HomeEmailListAltID;
1771                         EmailListPID = &HomeEmailListPID;
1772                         EmailListTokens = &HomeEmailListTokens;         
1773                         EmailListPref = &HomeEmailListPref;     
1774                         break;
1775                 case PROPERTY_WORK:
1776                         EmailList = &BusinessEmailList;
1777                         EmailListType = &BusinessEmailListType;
1778                         EmailListAltID = &BusinessEmailListAltID;
1779                         EmailListPID = &BusinessEmailListPID;
1780                         EmailListTokens = &BusinessEmailListTokens;             
1781                         EmailListPref = &BusinessEmailListPref; 
1782                         break;
1783         }
1784         
1785         intPrevValue = 6;
1786         
1787         std::map<int,int>::iterator SLiter;
1788         wxString PropertyData;
1789         wxString PropertyName;
1790         wxString PropertyValue;
1791         wxString PropertyTokens;
1792         bool FirstToken = TRUE;
1793         
1794         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1795         intiter != SplitPoints.end(); ++intiter){
1796         
1797                 SLiter = SplitLength.find(intiter->first);
1798         
1799                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1800                 
1801                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1802                 PropertyName = PropertyElement.GetNextToken();                          
1803                 PropertyValue = PropertyElement.GetNextToken();
1804                 
1805                 intPrevValue = intiter->second;
1806                 
1807                 CaptureString(&PropertyValue, FALSE);
1808                 
1809                 // Process properties.
1810                 
1811                 if (PropertyName == wxT("ALTID")){
1813                         EmailListAltID->erase(*EmailCount);
1814                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1815                 
1816                 } else if (PropertyName == wxT("PID")){
1818                         EmailListPID->erase(*EmailCount);
1819                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1820                 
1821                 } else if (PropertyName == wxT("PREF")){
1822                         
1823                         int PriorityNumber = 0;
1824                         bool ValidNumber = TRUE;
1825                         
1826                         try{
1827                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1828                         }
1829                         
1830                         catch(std::invalid_argument &e){
1831                                 ValidNumber = FALSE;
1832                         }
1834                         if (ValidNumber == TRUE){
1836                                 EmailListPref->erase(*EmailCount);
1837                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1839                         }
1840                 
1841                 } else {
1842                 
1843                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1844                         
1845                                 if (FirstToken == TRUE){
1846                                 
1847                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1848                                         FirstToken = FALSE;
1849                                 
1850                                 } else {
1851                                 
1852                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1853                                 
1854                                 }
1855                         
1856                         }
1857                 
1858                 }
1859         
1860         }
1861         
1862         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1863         
1864         // Add the name token data.
1865         
1866         if (!PropertyTokens.IsEmpty()){
1867         
1868                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1869         
1870         }       
1875 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1877         std::map<int, int> SplitPoints;
1878         std::map<int, int> SplitLength;
1880         int intPrevValue = 6;
1881         int intPref = 0;                        
1882         
1883         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1884         
1885         intPrevValue = 5;
1886         
1887         PropertyType PropType = PROPERTY_NONE;
1888                 
1889         // Look for type before continuing.
1890         
1891         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1892         
1893         std::map<int, wxString> *IMList = NULL;
1894         std::map<int, wxString> *IMListType = NULL;
1895         std::map<int, wxString> *IMListAltID = NULL;
1896         std::map<int, wxString> *IMListPID = NULL;
1897         std::map<int, wxString> *IMListTokens = NULL;
1898         std::map<int, wxString> *IMListMediatype = NULL;        
1899         std::map<int, int> *IMListPref = NULL;
1901         switch(PropType){
1902                 case PROPERTY_NONE:
1903                         IMList = &GeneralIMList;
1904                         IMListType = &GeneralIMListType;
1905                         IMListAltID = &GeneralIMListAltID;
1906                         IMListPID = &GeneralIMListPID;
1907                         IMListTokens = &GeneralIMListTokens;
1908                         IMListMediatype = &GeneralIMListMediatype;
1909                         IMListPref = &GeneralIMListPref;        
1910                         break;
1911                 case PROPERTY_HOME:
1912                         IMList = &HomeIMList;
1913                         IMListType = &HomeIMListType;
1914                         IMListAltID = &HomeIMListAltID;
1915                         IMListPID = &HomeIMListPID;
1916                         IMListTokens = &HomeIMListTokens;
1917                         IMListMediatype = &HomeIMListMediatype;         
1918                         IMListPref = &HomeIMListPref;   
1919                         break;
1920                 case PROPERTY_WORK:
1921                         IMList = &BusinessIMList;
1922                         IMListType = &BusinessIMListType;
1923                         IMListAltID = &BusinessIMListAltID;
1924                         IMListPID = &BusinessIMListPID;
1925                         IMListTokens = &BusinessIMListTokens;   
1926                         IMListMediatype = &BusinessIMListMediatype;     
1927                         IMListPref = &BusinessIMListPref;       
1928                         break;
1929         }
1930         
1931         intPrevValue = 5;
1932         
1933         std::map<int,int>::iterator SLiter;
1934         wxString PropertyData;
1935         wxString PropertyName;
1936         wxString PropertyValue;
1937         wxString PropertyTokens;
1938         bool FirstToken = TRUE;
1939         
1940         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1941         intiter != SplitPoints.end(); ++intiter){
1942         
1943                 SLiter = SplitLength.find(intiter->first);
1944         
1945                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1946                 
1947                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1948                 PropertyName = PropertyElement.GetNextToken();                          
1949                 PropertyValue = PropertyElement.GetNextToken();
1950                 
1951                 intPrevValue = intiter->second;
1952                 
1953                 CaptureString(&PropertyValue, FALSE);
1954                 
1955                 // Process properties.
1956                 
1957                 if (PropertyName == wxT("ALTID")){
1959                         IMListAltID->erase(*IMCount);
1960                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1961                 
1962                 } else if (PropertyName == wxT("PID")){
1964                         IMListPID->erase(*IMCount);
1965                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1966                 
1967                 } else if (PropertyName == wxT("MEDIATYPE")){
1969                         IMListMediatype->erase(*IMCount);
1970                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1971                 
1972                 } else if (PropertyName == wxT("PREF")){
1973                         
1974                         int PriorityNumber = 0;
1975                         bool ValidNumber = TRUE;
1976                         
1977                         try{
1978                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1979                         }
1980                         
1981                         catch(std::invalid_argument &e){
1982                                 ValidNumber = FALSE;
1983                         }
1985                         if (ValidNumber == TRUE){
1987                                 IMListPref->erase(*IMCount);
1988                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1990                         }
1991                 
1992                 } else {
1993                 
1994                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1995                         
1996                                 if (FirstToken == TRUE){
1997                                 
1998                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1999                                         FirstToken = FALSE;
2000                                 
2001                                 } else {
2002                                 
2003                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2004                                 
2005                                 }
2006                         
2007                         }
2008                 
2009                 }
2010         
2011         }
2012                 
2013         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2014         
2015         // Add the name token data.
2016         
2017         if (!PropertyTokens.IsEmpty()){
2018         
2019                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2020         
2021         }
2025 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2027         std::map<int, int> SplitPoints;
2028         std::map<int, int> SplitLength;
2029         std::map<int, int>::iterator SLiter;
2030         
2031         int intPref = 0;
2032         
2033         PropertyType PropType = PROPERTY_NONE;
2034                 
2035         // Look for type before continuing.
2036         
2037         wxString TelTypeUI;
2038         wxString TelTypeDetail;
2039         wxString PropertyData;
2040         wxString PropertyName;
2041         wxString PropertyValue;
2042         wxString PropertyTokens;
2043         
2044         std::map<int,int> TypeSplitPoints;
2045         std::map<int,int> TypeSplitLength;
2046         std::map<int,int>::iterator TSLiter;
2047         
2048         int intSplitSize = 0;
2049         int intSplitsFound = 0;
2050         int intSplitPoint = 0;
2051         int intType = 0;
2052         int intPrevValue = 5;
2053                 
2054         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2055         
2056         intPrevValue = 4;
2057         
2058         // Look for type before continuing.
2059         
2060         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2061         intiter != SplitPoints.end(); ++intiter){
2062         
2063                 SLiter = SplitLength.find(intiter->first);
2064         
2065                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2066                 
2067                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2068                 PropertyName = PropertyElement.GetNextToken();                          
2069                 PropertyValue = PropertyElement.GetNextToken();
2070                 
2071                 intPrevValue = intiter->second;
2073                 if (PropertyName == wxT("TYPE")){
2074                 
2075                         // Process each value in type and translate each
2076                         // part.
2077                 
2078                         // Strip out the quotes if they are there.
2079                 
2080                         size_t intPropertyValueLen = PropertyValue.Len();
2081                 
2082                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2083                         
2084                                 PropertyValue.Trim();
2085                                 PropertyValue.RemoveLast();
2086                         
2087                         }                               
2088                 
2089                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2090                         
2091                                 PropertyValue.Remove(0, 1);
2092                         
2093                         }
2094                         
2095                         TelTypeDetail = PropertyValue;
2096                         
2097                         intSplitSize = 0;
2098                         intSplitsFound = 0;
2099                         intSplitPoint = 0;
2100                         
2101                         for (int i = 0; i <= intPropertyValueLen; i++){
2102         
2103                                 intSplitSize++;
2104         
2105                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2106         
2107                                         if (intSplitsFound == 0){
2109                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2110                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2111                         
2112                                         } else {
2113                         
2114                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2115                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2116                         
2117                                         }                       
2119                                         intSplitsFound++;
2120                                         i++;
2121                                         intSplitPoint = i;
2122                                         intSplitSize = 0;
2123         
2124                                 }
2125         
2126                         }
2127                         
2128                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2129                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2130                 
2131                         int intTypeSeek = 0;
2132                 
2133                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2134                         typeiter != TypeSplitPoints.end(); ++typeiter){
2135                         
2136                                 wxString TypePropertyName;
2137                                 
2138                                 TSLiter = TypeSplitLength.find(typeiter->first);
2139                                 
2140                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2141                                 
2142                                 if (intTypeSeek == 0){
2143                                 
2144                                 
2145                                 } else {
2146                                                                                 
2147                                         TelTypeUI.Append(wxT(","));                                                     
2148                                 
2149                                 }
2150                         
2151                                 if (TypePropertyName == wxT("home")){
2152                                 
2153                                         PropType = PROPERTY_HOME;
2154                                 
2155                                 } else if (TypePropertyName == wxT("work")){
2156                                 
2157                                         PropType = PROPERTY_WORK;
2158                                                                         
2159                                 }
2160                                 
2161                                 
2162                                 if (TypePropertyName == wxT("text")){
2163                                 
2164                                         TelTypeUI.Append(_("text"));
2165                                         intTypeSeek++;
2166                                 
2167                                 } else if (TypePropertyName == wxT("voice")){
2168                                 
2169                                         TelTypeUI.Append(_("voice"));
2170                                         intTypeSeek++;
2171                                 
2172                                 } else if (TypePropertyName == wxT("fax")){
2173                                 
2174                                         TelTypeUI.Append(_("fax"));
2175                                         intTypeSeek++;
2176                                 
2177                                 } else if (TypePropertyName == wxT("cell")){
2178                                 
2179                                         TelTypeUI.Append(_("mobile"));
2180                                         intTypeSeek++;
2181                                 
2182                                 } else if (TypePropertyName == wxT("video")){
2183                                 
2184                                         TelTypeUI.Append(_("video"));
2185                                         intTypeSeek++;
2186                                 
2187                                 } else if (TypePropertyName == wxT("pager")){
2188                                 
2189                                         TelTypeUI.Append(_("pager"));
2190                                         intTypeSeek++;
2191                                 
2192                                 } else if (TypePropertyName == wxT("textphone")){
2193                                 
2194                                         TelTypeUI.Append(_("textphone"));
2195                                         intTypeSeek++;
2196                                 
2197                                 }
2198                         
2199                         }
2200                 
2201                 }
2202                 
2203         }
2204         
2205         std::map<int, wxString> *TelephoneList = NULL;
2206         std::map<int, wxString> *TelephoneListType = NULL;
2207         std::map<int, wxString> *TelephoneListAltID = NULL;
2208         std::map<int, wxString> *TelephoneListPID = NULL;
2209         std::map<int, wxString> *TelephoneListTokens = NULL;
2210         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2211         std::map<int, int> *TelephoneListPref = NULL;
2213         switch(PropType){
2214                 case PROPERTY_NONE:
2215                         TelephoneList = &GeneralTelephoneList;
2216                         TelephoneListType = &GeneralTelephoneListType;
2217                         TelephoneListAltID = &GeneralTelephoneListAltID;
2218                         TelephoneListPID = &GeneralTelephoneListPID;
2219                         TelephoneListTokens = &GeneralTelephoneListTokens;
2220                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2221                         TelephoneListPref = &GeneralTelephoneListPref;  
2222                         break;
2223                 case PROPERTY_HOME:
2224                         TelephoneList = &HomeTelephoneList;
2225                         TelephoneListType = &HomeTelephoneListType;
2226                         TelephoneListAltID = &HomeTelephoneListAltID;
2227                         TelephoneListPID = &HomeTelephoneListPID;
2228                         TelephoneListTokens = &HomeTelephoneListTokens;
2229                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2230                         TelephoneListPref = &HomeTelephoneListPref;     
2231                         break;
2232                 case PROPERTY_WORK:
2233                         TelephoneList = &BusinessTelephoneList;
2234                         TelephoneListType = &BusinessTelephoneListType;
2235                         TelephoneListAltID = &BusinessTelephoneListAltID;
2236                         TelephoneListPID = &BusinessTelephoneListPID;
2237                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2238                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2239                         TelephoneListPref = &BusinessTelephoneListPref; 
2240                         break;
2241         }
2242                 
2243         // Process the properties.
2244         
2245         bool FirstToken = TRUE;
2246         
2247         intPrevValue = 5;
2248         SplitPoints.clear();
2249         SplitLength.clear();
2251         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2253         intPrevValue = 4;
2254         
2255         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2256         intiter != SplitPoints.end(); ++intiter){
2257         
2258                 SLiter = SplitLength.find(intiter->first);
2259         
2260                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2261                 
2262                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2263                 PropertyName = PropertyElement.GetNextToken();                          
2264                 PropertyValue = PropertyElement.GetNextToken();
2265                 
2266                 intPrevValue = intiter->second;
2267                 
2268                 CaptureString(&PropertyValue, FALSE);
2269                 
2270                 // Process properties.
2271                 
2272                 if (PropertyName == wxT("ALTID")){
2274                         TelephoneListAltID->erase(*TelephoneCount);
2275                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2276                 
2277                 } else if (PropertyName == wxT("PID")){
2279                         TelephoneListPID->erase(*TelephoneCount);
2280                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2281                 
2282                 } else if (PropertyName == wxT("PREF")){
2283                         
2284                         int PriorityNumber = 0;
2285                         bool ValidNumber = TRUE;
2286                         
2287                         try{
2288                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2289                         }
2290                         
2291                         catch(std::invalid_argument &e){
2292                                 ValidNumber = FALSE;
2293                         }
2295                         if (ValidNumber == TRUE){
2297                                 TelephoneListPref->erase(*TelephoneCount);
2298                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2300                         }
2301                 
2302                 } else {
2303                 
2304                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2305                         
2306                                 if (FirstToken == TRUE){
2307                                 
2308                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2309                                         FirstToken = FALSE;
2310                                 
2311                                 } else {
2312                                 
2313                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2314                                 
2315                                 }
2316                         
2317                         }
2318                 
2319                 }
2320         
2321         }
2322                 
2323         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2324         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2325         
2326         // Add the name token data.
2327         
2328         if (!PropertyTokens.IsEmpty()){
2329         
2330                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2331         
2332         }
2336 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2338         std::map<int, int> SplitPoints;
2339         std::map<int, int> SplitLength;
2341         int intPrevValue = 6;
2342         int intPref = 0;                        
2343         
2344         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2345         
2346         intPrevValue = 5;
2347         
2348         PropertyType PropType = PROPERTY_NONE;
2349                 
2350         // Look for type before continuing.
2351         
2352         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2353         
2354         std::map<int, wxString> *LanguageList = NULL;
2355         std::map<int, wxString> *LanguageListType = NULL;
2356         std::map<int, wxString> *LanguageListAltID = NULL;
2357         std::map<int, wxString> *LanguageListPID = NULL;
2358         std::map<int, wxString> *LanguageListTokens = NULL;
2359         std::map<int, int> *LanguageListPref = NULL;
2361         switch(PropType){
2362                 case PROPERTY_NONE:
2363                         LanguageList = &GeneralLanguageList;
2364                         LanguageListType = &GeneralLanguageListType;
2365                         LanguageListAltID = &GeneralLanguageListAltID;
2366                         LanguageListPID = &GeneralLanguageListPID;
2367                         LanguageListTokens = &GeneralLanguageListTokens;
2368                         LanguageListPref = &GeneralLanguageListPref;    
2369                         break;
2370                 case PROPERTY_HOME:
2371                         LanguageList = &HomeLanguageList;
2372                         LanguageListType = &HomeLanguageListType;
2373                         LanguageListAltID = &HomeLanguageListAltID;
2374                         LanguageListPID = &HomeLanguageListPID;
2375                         LanguageListTokens = &HomeLanguageListTokens;   
2376                         LanguageListPref = &HomeLanguageListPref;       
2377                         break;
2378                 case PROPERTY_WORK:
2379                         LanguageList = &BusinessLanguageList;
2380                         LanguageListType = &BusinessLanguageListType;
2381                         LanguageListAltID = &BusinessLanguageListAltID;
2382                         LanguageListPID = &BusinessLanguageListPID;
2383                         LanguageListTokens = &BusinessLanguageListTokens;       
2384                         LanguageListPref = &BusinessLanguageListPref;
2385                         break;
2386         }
2387         
2388         intPrevValue = 5;
2389         
2390         std::map<int,int>::iterator SLiter;
2391         wxString PropertyData;
2392         wxString PropertyName;
2393         wxString PropertyValue;
2394         wxString PropertyTokens;
2395         bool FirstToken = TRUE;
2396         
2397         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2398         intiter != SplitPoints.end(); ++intiter){
2399         
2400                 SLiter = SplitLength.find(intiter->first);
2401         
2402                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2403                 
2404                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2405                 PropertyName = PropertyElement.GetNextToken();                          
2406                 PropertyValue = PropertyElement.GetNextToken();
2407                 
2408                 intPrevValue = intiter->second;
2409                 
2410                 CaptureString(&PropertyValue, FALSE);
2411                 
2412                 // Process properties.
2413                 
2414                 if (PropertyName == wxT("ALTID")){
2416                         LanguageListAltID->erase(*LanguageCount);
2417                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2418                 
2419                 } else if (PropertyName == wxT("PID")){
2421                         LanguageListPID->erase(*LanguageCount);
2422                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2423                 
2424                 } else if (PropertyName == wxT("PREF")){
2425                         
2426                         int PriorityNumber = 0;
2427                         bool ValidNumber = TRUE;
2428                         
2429                         try{
2430                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2431                         }
2432                         
2433                         catch(std::invalid_argument &e){
2434                                 ValidNumber = FALSE;
2435                         }
2437                         if (ValidNumber == TRUE){
2439                                 LanguageListPref->erase(*LanguageCount);
2440                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2442                         }
2443                 
2444                 } else {
2445                 
2446                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2447                         
2448                                 if (FirstToken == TRUE){
2449                                 
2450                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2451                                         FirstToken = FALSE;
2452                                 
2453                                 } else {
2454                                 
2455                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2456                                 
2457                                 }
2458                         
2459                         }
2460                 
2461                 }
2462         
2463         }
2464                 
2465         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2466         
2467         // Add the name token data.
2468         
2469         if (!PropertyTokens.IsEmpty()){
2470         
2471                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2472         
2473         }
2477 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2479         std::map<int, int> SplitPoints;
2480         std::map<int, int> SplitLength;
2482         int intPrevValue = 5;
2483         int intPref = 0;                        
2484         
2485         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2486         
2487         intPrevValue = 4;
2488         
2489         PropertyType PropType = PROPERTY_NONE;
2490                 
2491         // Look for type before continuing.
2492         
2493         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2494         
2495         std::map<int, wxString> *GeopositionList = NULL;
2496         std::map<int, wxString> *GeopositionListType = NULL;
2497         std::map<int, wxString> *GeopositionListAltID = NULL;
2498         std::map<int, wxString> *GeopositionListPID = NULL;
2499         std::map<int, wxString> *GeopositionListTokens = NULL;
2500         std::map<int, wxString> *GeopositionListMediatype = NULL;
2501         std::map<int, int> *GeopositionListPref = NULL;
2503         switch(PropType){
2504                 case PROPERTY_NONE:
2505                         GeopositionList = &GeneralGeographyList;
2506                         GeopositionListType = &GeneralGeographyListType;
2507                         GeopositionListAltID = &GeneralGeographyListAltID;
2508                         GeopositionListPID = &GeneralGeographyListPID;
2509                         GeopositionListTokens = &GeneralGeographyListTokens;
2510                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2511                         GeopositionListPref = &GeneralGeographyListPref;        
2512                         break;
2513                 case PROPERTY_HOME:
2514                         GeopositionList = &HomeGeographyList;
2515                         GeopositionListType = &HomeGeographyListType;
2516                         GeopositionListAltID = &HomeGeographyListAltID;
2517                         GeopositionListPID = &HomeGeographyListPID;
2518                         GeopositionListTokens = &HomeGeographyListTokens;
2519                         GeopositionListMediatype = &HomeGeographyListMediatype;
2520                         GeopositionListPref = &HomeGeographyListPref;   
2521                         break;
2522                 case PROPERTY_WORK:
2523                         GeopositionList = &BusinessGeographyList;
2524                         GeopositionListType = &BusinessGeographyListType;
2525                         GeopositionListAltID = &BusinessGeographyListAltID;
2526                         GeopositionListPID = &BusinessGeographyListPID;
2527                         GeopositionListTokens = &BusinessGeographyListTokens;
2528                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2529                         GeopositionListPref = &BusinessGeographyListPref;
2530                         break;
2531         }
2532         
2533         intPrevValue = 4;
2534         
2535         std::map<int,int>::iterator SLiter;
2536         wxString PropertyData;
2537         wxString PropertyName;
2538         wxString PropertyValue;
2539         wxString PropertyTokens;
2540         bool FirstToken = TRUE;
2541         
2542         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2543         intiter != SplitPoints.end(); ++intiter){
2544         
2545                 SLiter = SplitLength.find(intiter->first);
2546         
2547                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2548                 
2549                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2550                 PropertyName = PropertyElement.GetNextToken();                          
2551                 PropertyValue = PropertyElement.GetNextToken();
2552                 
2553                 intPrevValue = intiter->second;
2554                 
2555                 CaptureString(&PropertyValue, FALSE);
2556                 
2557                 // Process properties.
2558                 
2559                 if (PropertyName == wxT("ALTID")){
2561                         GeopositionListAltID->erase(*GeographicCount);
2562                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2563                 
2564                 } else if (PropertyName == wxT("PID")){
2566                         GeopositionListPID->erase(*GeographicCount);
2567                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2568                 
2569                 } else if (PropertyName == wxT("MEDIATYPE")){
2571                         GeopositionListMediatype->erase(*GeographicCount);
2572                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2573                 
2574                 } else if (PropertyName == wxT("PREF")){
2575                         
2576                         int PriorityNumber = 0;
2577                         bool ValidNumber = TRUE;
2578                         
2579                         try{
2580                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2581                         }
2582                         
2583                         catch(std::invalid_argument &e){
2584                                 ValidNumber = FALSE;
2585                         }
2587                         if (ValidNumber == TRUE){
2589                                 GeopositionListPref->erase(*GeographicCount);
2590                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2592                         }
2593                 
2594                 } else {
2595                 
2596                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2597                         
2598                                 if (FirstToken == TRUE){
2599                                 
2600                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2601                                         FirstToken = FALSE;
2602                                 
2603                                 } else {
2604                                 
2605                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2606                                 
2607                                 }
2608                         
2609                         }
2610                 
2611                 }
2612         
2613         }
2614                 
2615         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2616         
2617         // Add the name token data.
2618         
2619         if (!PropertyTokens.IsEmpty()){
2620         
2621                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2622         
2623         }
2627 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2629         size_t intPropertyLen = PropertySeg1.Len();
2630         std::map<int, int> SplitPoints;
2631         std::map<int, int> SplitLength;
2632         std::map<int, int>::iterator SLiter;                    
2633         wxString PropertyData;
2634         wxString PropertyName;
2635         wxString PropertyValue;
2636         wxString PropertyTokens;
2637         wxString RelatedType;
2638         wxString RelatedTypeOriginal;                   
2639         wxString RelatedName;
2640         bool FirstToken = TRUE;                 
2641         int intSplitsFound = 0;
2642         int intSplitSize = 0;
2643         int intPrevValue = 9;
2644         int intPref = 0;
2645         long ListCtrlIndex;
2646         
2647         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2648         
2649         intPrevValue = 8;
2650         
2651         // Look for type before continuing.
2652         
2653         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2654         intiter != SplitPoints.end(); ++intiter){
2655         
2656                 SLiter = SplitLength.find(intiter->first);
2657         
2658                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2659                 
2660                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2661                 PropertyName = PropertyElement.GetNextToken();                          
2662                 PropertyValue = PropertyElement.GetNextToken();
2663                 
2664                 intPrevValue = intiter->second;
2665                 
2666                 // Process these.
2667                 
2668                 RelatedTypeOriginal = PropertyValue;
2669                 
2670                 if (PropertyName == wxT("TYPE")){
2671                 
2672                         if (PropertyValue == wxT("contact")){
2674                                 RelatedType = _("Contact");
2676                         } else if (PropertyValue == wxT("acquaintance")){
2678                                 RelatedType = _("Acquaintance");
2680                         } else if (PropertyValue == wxT("friend")){
2682                                 RelatedType = _("Friend");
2684                         } else if (PropertyValue == wxT("met")){
2686                                 RelatedType = _("Met");
2688                         } else if (PropertyValue == wxT("co-worker")){
2690                                 RelatedType = _("Co-worker");
2692                         } else if (PropertyValue == wxT("colleague")){
2694                                 RelatedType = _("Colleague");
2696                         } else if (PropertyValue == wxT("co-resident")){
2698                                 RelatedType = _("Co-resident");
2700                         } else if (PropertyValue == wxT("neighbor")){
2702                                 RelatedType = _("Neighbour");
2704                         } else if (PropertyValue == wxT("child")){
2706                                 RelatedType = _("Child");
2708                         } else if (PropertyValue == wxT("parent")){
2710                                 RelatedType = _("Parent");
2712                         } else if (PropertyValue == wxT("sibling")){
2714                                 RelatedType = _("Sibling");
2716                         } else if (PropertyValue == wxT("spouse")){
2718                                 RelatedType = _("Spouse");
2720                         } else if (PropertyValue == wxT("kin")){
2722                                 RelatedType = _("Kin");
2724                         } else if (PropertyValue == wxT("muse")){
2726                                 RelatedType = _("Muse");
2728                         } else if (PropertyValue == wxT("crush")){
2730                                 RelatedType = _("Crush");
2732                         } else if (PropertyValue == wxT("date")){
2734                                 RelatedType = _("Date");
2736                         } else if (PropertyValue == wxT("sweetheart")){
2738                                 RelatedType = _("Sweetheart");
2740                         } else if (PropertyValue == wxT("me")){
2742                                 RelatedType = _("Me");
2744                         } else if (PropertyValue == wxT("agent")){
2746                                 RelatedType = _("Agent");
2748                         } else if (PropertyValue == wxT("emergency")){
2750                                 RelatedType = _("Emergency");
2752                         } else {
2754                                 RelatedType = PropertyValue;
2756                         }
2757                 
2758                 }
2759         
2760         }
2761         
2762         intPrevValue = 8;                       
2763         
2764         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2765         intiter != SplitPoints.end(); ++intiter){
2766         
2767                 SLiter = SplitLength.find(intiter->first);
2768         
2769                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2770                 
2771                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2772                 PropertyName = PropertyElement.GetNextToken();                          
2773                 PropertyValue = PropertyElement.GetNextToken();
2774                 
2775                 intPrevValue = intiter->second;
2776                 
2777                 // Process properties.
2778                 
2779                 size_t intPropertyValueLen = PropertyValue.Len();
2780                 
2781                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2782                         
2783                         PropertyValue.Trim();
2784                         PropertyValue.RemoveLast();
2785                         
2786                 }                               
2787                 
2788                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2789                         
2790                         PropertyValue.Remove(0, 1);
2791                         
2792                 }
2793                 
2794                 CaptureString(&PropertyValue, FALSE);
2795                         
2796                 if (PropertyName == wxT("ALTID")){
2798                         GeneralRelatedListAltID.erase(*RelatedCount);
2799                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2800                 
2801                 } else if (PropertyName == wxT("PID")){
2803                         GeneralRelatedListPID.erase(*RelatedCount);
2804                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2805                 
2806                 } else if (PropertyName == wxT("PREF")){
2807                         
2808                         int PriorityNumber = 0;
2809                         bool ValidNumber = TRUE;
2810                         
2811                         try{
2812                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2813                         }
2814                         
2815                         catch(std::invalid_argument &e){
2816                                 ValidNumber = FALSE;
2817                         }
2819                         if (ValidNumber == TRUE){
2821                                 GeneralRelatedListPref.erase(*RelatedCount);
2822                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2824                         }
2825                 
2826                 } else if (PropertyName == wxT("LANGUAGE")){
2827                 
2828                         GeneralRelatedListLanguage.erase(*RelatedCount);
2829                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2830                 
2831                 } else if (PropertyName != wxT("TYPE")) {
2832                 
2833                         // Something else we don't know about so append
2834                         // to the tokens variable.
2835                 
2836                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2837                 
2838                                 if (FirstToken == TRUE){
2839                         
2840                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2841                                         FirstToken = FALSE;
2842                         
2843                                 } else {
2844                         
2845                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2846                         
2847                                 }
2848                 
2849                         }
2850                 
2851                 }
2852         
2853         }                                       
2854         
2855         // Add the data to the General/Home/Work address variables.
2856                                 
2857         GeneralRelatedList.erase(*RelatedCount);
2858         GeneralRelatedListRelType.erase(*RelatedCount);
2859         GeneralRelatedListType.erase(*RelatedCount);
2860         GeneralRelatedListTokens.erase(*RelatedCount);
2861         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2862         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2863         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2864         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2868 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2870         std::map<int, int> SplitPoints;
2871         std::map<int, int> SplitLength;
2872         std::map<int, int>::iterator SLiter;                    
2873         wxString PropertyData;
2874         wxString PropertyName;
2875         wxString PropertyValue;
2876         wxString PropertyTokens;
2877         bool FirstToken = TRUE;
2878         int intPrevValue = 5;
2879         int intPref = 0;                        
2880         int intType = 0;
2881         long ListCtrlIndex;
2882         
2883         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2884         
2885         intPrevValue = 4;
2886         
2887         PropertyType PropType = PROPERTY_NONE;
2888                 
2889         // Look for type before continuing.
2890         
2891         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2892         
2893         // Setup the pointers.
2894         
2895         std::map<int, wxString> *WebsiteList = NULL;
2896         std::map<int, wxString> *WebsiteListAltID = NULL;
2897         std::map<int, wxString> *WebsiteListPID = NULL;
2898         std::map<int, wxString> *WebsiteListType = NULL;
2899         std::map<int, wxString> *WebsiteListTokens = NULL;
2900         std::map<int, wxString> *WebsiteListMediatype = NULL;
2901         std::map<int, int> *WebsiteListPref = NULL;
2902         
2903         // Setup blank lines for later on.
2904         
2905         switch(PropType){
2906                 case PROPERTY_NONE:
2907                         WebsiteList = &GeneralWebsiteList;
2908                         WebsiteListType = &GeneralWebsiteListType;
2909                         WebsiteListAltID = &GeneralWebsiteListAltID;
2910                         WebsiteListPID = &GeneralWebsiteListPID;
2911                         WebsiteListTokens = &GeneralWebsiteListTokens;
2912                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2913                         WebsiteListPref = &GeneralWebsiteListPref;      
2914                         break;
2915                 case PROPERTY_HOME:
2916                         WebsiteList = &HomeWebsiteList;
2917                         WebsiteListType = &HomeWebsiteListType;
2918                         WebsiteListAltID = &HomeWebsiteListAltID;
2919                         WebsiteListPID = &HomeWebsiteListPID;
2920                         WebsiteListTokens = &HomeWebsiteListTokens;
2921                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2922                         WebsiteListPref = &HomeWebsiteListPref; 
2923                         break;
2924                 case PROPERTY_WORK:
2925                         WebsiteList = &BusinessWebsiteList;
2926                         WebsiteListType = &BusinessWebsiteListType;
2927                         WebsiteListAltID = &BusinessWebsiteListAltID;
2928                         WebsiteListPID = &BusinessWebsiteListPID;
2929                         WebsiteListTokens = &BusinessWebsiteListTokens;
2930                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2931                         WebsiteListPref = &BusinessWebsiteListPref;
2932                         break;
2933         }
2934         
2935         intPrevValue = 4;
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 properties.
2951                 
2952                 size_t intPropertyValueLen = PropertyValue.Len();
2953                 
2954                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2955                         
2956                         PropertyValue.Trim();
2957                         PropertyValue.RemoveLast();
2958                         
2959                 }                               
2960                 
2961                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2962                         
2963                         PropertyValue.Remove(0, 1);
2964                         
2965                 }
2966                 
2967                 CaptureString(&PropertyValue, FALSE);
2968                 
2969                 if (PropertyName == wxT("ALTID")){
2971                         WebsiteListAltID->erase(*URLCount);
2972                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2973                 
2974                 } else if (PropertyName == wxT("PID")){
2976                         WebsiteListPID->erase(*URLCount);
2977                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2978                         
2979                 } else if (PropertyName == wxT("PREF")){
2980                         
2981                         int PriorityNumber = 0;
2982                         bool ValidNumber = TRUE;
2983                         
2984                         try{
2985                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2986                         }
2987                         
2988                         catch(std::invalid_argument &e){
2989                                 ValidNumber = FALSE;
2990                         }
2992                         if (ValidNumber == TRUE){
2994                                 WebsiteListPref->erase(*URLCount);
2995                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2997                         }
2998                                         
2999                 } else if (PropertyName == wxT("MEDIATYPE")){
3000                 
3001                         WebsiteListMediatype->erase(*URLCount);
3002                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3003                 
3004                 } else {
3005                 
3006                         // Something else we don't know about so append
3007                         // to the tokens variable.
3008                 
3009                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3010                 
3011                                 if (FirstToken == TRUE){
3012                         
3013                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3014                                         FirstToken = FALSE;
3015                         
3016                                 } else {
3017                         
3018                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3019                         
3020                                 }
3021                 
3022                         }
3023                 
3024                 }
3025         
3026         }
3027         
3028         // Add the data to the General/Home/Work address variables.
3029         
3030         CaptureString(&PropertySeg2, FALSE);
3031                         
3032         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3033         
3034         if (!PropertyTokens.IsEmpty()){
3035         
3036                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3037                         
3038         }
3039         
3042 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3044         std::map<int, int> SplitPoints;
3045         std::map<int, int> SplitLength;
3046         std::map<int, int>::iterator SLiter;                    
3047         wxString PropertyData;
3048         wxString PropertyName;
3049         wxString PropertyValue;
3050         wxString PropertyTokens;
3051         bool FirstToken = TRUE;
3052         int intPrevValue = 7;
3053         int intPref = 0;                        
3054         int intType = 0;
3055         long ListCtrlIndex;
3056         
3057         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3058         
3059         intPrevValue = 6;
3060         
3061         PropertyType PropType = PROPERTY_NONE;
3062                 
3063         // Look for type before continuing.
3064         
3065         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3066         
3067         // Setup the pointers.
3068         
3069         std::map<int, wxString> *TitleList = NULL;
3070         std::map<int, wxString> *TitleListAltID = NULL;
3071         std::map<int, wxString> *TitleListPID = NULL;
3072         std::map<int, wxString> *TitleListType = NULL;
3073         std::map<int, wxString> *TitleListTokens = NULL;
3074         std::map<int, wxString> *TitleListLanguage = NULL;
3075         std::map<int, int> *TitleListPref = NULL;
3076         
3077         // Setup blank lines for later on.
3078         
3079         switch(PropType){
3080                 case PROPERTY_NONE:
3081                         TitleList = &GeneralTitleList;
3082                         TitleListType = &GeneralTitleListType;
3083                         TitleListAltID = &GeneralTitleListAltID;
3084                         TitleListPID = &GeneralTitleListPID;
3085                         TitleListTokens = &GeneralTitleListTokens;
3086                         TitleListLanguage = &GeneralTitleListLanguage;
3087                         TitleListPref = &GeneralTitleListPref;  
3088                         break;
3089                 case PROPERTY_HOME:
3090                         TitleList = &HomeTitleList;
3091                         TitleListType = &HomeTitleListType;
3092                         TitleListAltID = &HomeTitleListAltID;
3093                         TitleListPID = &HomeTitleListPID;
3094                         TitleListTokens = &HomeTitleListTokens;
3095                         TitleListLanguage = &HomeTitleListLanguage;
3096                         TitleListPref = &HomeTitleListPref;     
3097                         break;
3098                 case PROPERTY_WORK:
3099                         TitleList = &BusinessTitleList;
3100                         TitleListType = &BusinessTitleListType;
3101                         TitleListAltID = &BusinessTitleListAltID;
3102                         TitleListPID = &BusinessTitleListPID;
3103                         TitleListTokens = &BusinessTitleListTokens;
3104                         TitleListLanguage = &BusinessTitleListLanguage; 
3105                         TitleListPref = &BusinessTitleListPref;
3106                         break;
3107         }
3109         intPrevValue = 6;
3110                 
3111         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3112         intiter != SplitPoints.end(); ++intiter){
3113         
3114                 SLiter = SplitLength.find(intiter->first);
3115         
3116                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3117                 
3118                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3119                 PropertyName = PropertyElement.GetNextToken();                          
3120                 PropertyValue = PropertyElement.GetNextToken();
3121                 
3122                 intPrevValue = intiter->second;
3123                 
3124                 // Process properties.
3125                 
3126                 size_t intPropertyValueLen = PropertyValue.Len();
3127                 
3128                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3129                         
3130                         PropertyValue.Trim();
3131                         PropertyValue.RemoveLast();
3132                         
3133                 }                               
3134                 
3135                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3136                         
3137                         PropertyValue.Remove(0, 1);
3138                         
3139                 }                               
3140                 
3141                 CaptureString(&PropertyValue, FALSE);
3142                 
3143                 if (PropertyName == wxT("ALTID")){
3144                 
3145                         TitleListAltID->erase(*TitleCount);
3146                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3147                 
3148                 } else if (PropertyName == wxT("PID")){
3150                         TitleListPID->erase(*TitleCount);
3151                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3152                 
3153                 } else if (PropertyName == wxT("PREF")){
3154                                 
3155                         int PriorityNumber = 0;
3156                         bool ValidNumber = TRUE;
3157                         
3158                         try{
3159                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3160                         }
3161                         
3162                         catch(std::invalid_argument &e){
3163                                 ValidNumber = FALSE;
3164                         }
3166                         if (ValidNumber == TRUE){
3168                                 TitleListPref->erase(*TitleCount);
3169                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3171                         }
3172                                         
3173                 } else if (PropertyName == wxT("LANGUAGE")){
3174                 
3175                         TitleListLanguage->erase(*TitleCount);
3176                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3177                 
3178                 } else {
3179                 
3180                         // Something else we don't know about so append
3181                         // to the tokens variable.
3182                 
3183                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3184                 
3185                                 if (FirstToken == TRUE){
3186                         
3187                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3188                                         FirstToken = FALSE;
3189                         
3190                                 } else {
3191                         
3192                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3193                         
3194                                 }
3195                 
3196                         }
3197                 
3198                 }
3199         
3200         }
3201         
3202         // Add the data to the General/Home/Work address variables.
3203         
3204         CaptureString(&PropertySeg2, FALSE);
3206         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3207         
3208         if (!PropertyTokens.IsEmpty()){
3209         
3210                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3211                         
3212         }
3216 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3218         std::map<int, int> SplitPoints;
3219         std::map<int, int> SplitLength;
3220         std::map<int, int>::iterator SLiter;                    
3221         wxString PropertyData;
3222         wxString PropertyName;
3223         wxString PropertyValue;
3224         wxString PropertyTokens;
3225         bool FirstToken = TRUE;
3226         int intPrevValue = 6;
3227         int intPref = 0;                        
3228         int intType = 0;
3229         long ListCtrlIndex;
3230         
3231         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3232         
3233         intPrevValue = 5;
3234         
3235         PropertyType PropType = PROPERTY_NONE;
3236                 
3237         // Look for type before continuing.
3238         
3239         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3240         
3241         // Setup the pointers.
3242         
3243         std::map<int, wxString> *RoleList = NULL;
3244         std::map<int, wxString> *RoleListAltID = NULL;
3245         std::map<int, wxString> *RoleListPID = NULL;
3246         std::map<int, wxString> *RoleListType = NULL;
3247         std::map<int, wxString> *RoleListTokens = NULL;
3248         std::map<int, wxString> *RoleListLanguage = NULL;
3249         std::map<int, int> *RoleListPref = NULL;
3250         
3251         // Setup blank lines for later on.
3252         
3253         switch(PropType){
3254                 case PROPERTY_NONE:
3255                         RoleList = &GeneralRoleList;
3256                         RoleListType = &GeneralRoleListType;
3257                         RoleListAltID = &GeneralRoleListAltID;
3258                         RoleListPID = &GeneralRoleListPID;
3259                         RoleListTokens = &GeneralRoleListTokens;
3260                         RoleListLanguage = &GeneralRoleListLanguage;
3261                         RoleListPref = &GeneralRoleListPref;    
3262                         break;
3263                 case PROPERTY_HOME:
3264                         RoleList = &HomeRoleList;
3265                         RoleListType = &HomeRoleListType;
3266                         RoleListAltID = &HomeRoleListAltID;
3267                         RoleListPID = &HomeRoleListPID;
3268                         RoleListTokens = &HomeRoleListTokens;
3269                         RoleListLanguage = &HomeRoleListLanguage;
3270                         RoleListPref = &HomeRoleListPref;       
3271                         break;
3272                 case PROPERTY_WORK:
3273                         RoleList = &BusinessRoleList;
3274                         RoleListType = &BusinessRoleListType;
3275                         RoleListAltID = &BusinessRoleListAltID;
3276                         RoleListPID = &BusinessRoleListPID;
3277                         RoleListTokens = &BusinessRoleListTokens;
3278                         RoleListLanguage = &BusinessRoleListLanguage;   
3279                         RoleListPref = &BusinessRoleListPref;
3280                         break;
3281         }
3283         intPrevValue = 5;
3284                 
3285         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3286         intiter != SplitPoints.end(); ++intiter){
3287         
3288                 SLiter = SplitLength.find(intiter->first);
3289         
3290                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3291                 
3292                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3293                 PropertyName = PropertyElement.GetNextToken();                          
3294                 PropertyValue = PropertyElement.GetNextToken();
3295                 
3296                 intPrevValue = intiter->second;
3297                 
3298                 // Process properties.
3299                 
3300                 size_t intPropertyValueLen = PropertyValue.Len();
3301                 
3302                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3303                         
3304                         PropertyValue.Trim();
3305                         PropertyValue.RemoveLast();
3306                         
3307                 }                               
3308                 
3309                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3310                         
3311                         PropertyValue.Remove(0, 1);
3312                         
3313                 }                               
3314                 
3315                 CaptureString(&PropertyValue, FALSE);
3316                 
3317                 if (PropertyName == wxT("ALTID")){
3318                 
3319                         RoleListAltID->erase(*RoleCount);
3320                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3321                 
3322                 } else if (PropertyName == wxT("PID")){
3324                         RoleListPID->erase(*RoleCount);
3325                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3326                 
3327                 } else if (PropertyName == wxT("PREF")){
3328                                 
3329                         int PriorityNumber = 0;
3330                         bool ValidNumber = TRUE;
3331                         
3332                         try{
3333                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3334                         }
3335                         
3336                         catch(std::invalid_argument &e){
3337                                 ValidNumber = FALSE;
3338                         }
3340                         if (ValidNumber == TRUE){
3342                                 RoleListPref->erase(*RoleCount);
3343                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3345                         }
3346                                         
3347                 } else if (PropertyName == wxT("LANGUAGE")){
3348                 
3349                         RoleListLanguage->erase(*RoleCount);
3350                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3351                 
3352                 } else {
3353                 
3354                         // Something else we don't know about so append
3355                         // to the tokens variable.
3356                 
3357                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3358                 
3359                                 if (FirstToken == TRUE){
3360                         
3361                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3362                                         FirstToken = FALSE;
3363                         
3364                                 } else {
3365                         
3366                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3367                         
3368                                 }
3369                 
3370                         }
3371                 
3372                 }
3373         
3374         }
3375         
3376         // Add the data to the General/Home/Work address variables.
3377         
3378         CaptureString(&PropertySeg2, FALSE);
3380         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3381         
3382         if (!PropertyTokens.IsEmpty()){
3383         
3384                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3385                         
3386         }
3390 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3392         std::map<int, int> SplitPoints;
3393         std::map<int, int> SplitLength;
3394         std::map<int, int>::iterator SLiter;                    
3395         wxString PropertyData;
3396         wxString PropertyName;
3397         wxString PropertyValue;
3398         wxString PropertyTokens;
3399         bool FirstToken = TRUE;
3400         int intPrevValue = 5;
3401         int intPref = 0;                        
3402         int intType = 0;
3403         long ListCtrlIndex;
3404         
3405         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3406         
3407         intPrevValue = 4;
3408         
3409         PropertyType PropType = PROPERTY_NONE;
3410                 
3411         // Look for type before continuing.
3412         
3413         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3414         
3415         // Setup the pointers.
3416         
3417         std::map<int, wxString> *OrganisationsList = NULL;
3418         std::map<int, wxString> *OrganisationsListAltID = NULL;
3419         std::map<int, wxString> *OrganisationsListPID = NULL;
3420         std::map<int, wxString> *OrganisationsListType = NULL;
3421         std::map<int, wxString> *OrganisationsListTokens = NULL;
3422         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3423         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3424         std::map<int, int> *OrganisationsListPref = NULL;
3425         
3426         // Setup blank lines for later on.
3427         
3428         switch(PropType){
3429                 case PROPERTY_NONE:
3430                         OrganisationsList = &GeneralOrganisationsList;
3431                         OrganisationsListType = &GeneralOrganisationsListType;
3432                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3433                         OrganisationsListPID = &GeneralOrganisationsListPID;
3434                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3435                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3436                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3437                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3438                         break;
3439                 case PROPERTY_HOME:
3440                         OrganisationsList = &HomeOrganisationsList;
3441                         OrganisationsListType = &HomeOrganisationsListType;
3442                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3443                         OrganisationsListPID = &HomeOrganisationsListPID;
3444                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3445                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3446                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3447                         OrganisationsListPref = &HomeOrganisationsListPref;     
3448                         break;
3449                 case PROPERTY_WORK:
3450                         OrganisationsList = &BusinessOrganisationsList;
3451                         OrganisationsListType = &BusinessOrganisationsListType;
3452                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3453                         OrganisationsListPID = &BusinessOrganisationsListPID;
3454                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3455                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3456                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3457                         OrganisationsListPref = &BusinessOrganisationsListPref;
3458                         break;
3459         }
3461         intPrevValue = 4;
3462                 
3463         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3464         intiter != SplitPoints.end(); ++intiter){
3465         
3466                 SLiter = SplitLength.find(intiter->first);
3467         
3468                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3469                 
3470                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3471                 PropertyName = PropertyElement.GetNextToken();                          
3472                 PropertyValue = PropertyElement.GetNextToken();
3473                 
3474                 intPrevValue = intiter->second;
3475                 
3476                 // Process properties.
3477                 
3478                 size_t intPropertyValueLen = PropertyValue.Len();
3479                 
3480                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3481                         
3482                         PropertyValue.Trim();
3483                         PropertyValue.RemoveLast();
3484                         
3485                 }                               
3486                 
3487                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3488                         
3489                         PropertyValue.Remove(0, 1);
3490                         
3491                 }                               
3492                 
3493                 CaptureString(&PropertyValue, FALSE);
3494                 
3495                 if (PropertyName == wxT("ALTID")){
3496                 
3497                         OrganisationsListAltID->erase(*OrganisationCount);
3498                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3499                 
3500                 } else if (PropertyName == wxT("PID")){
3502                         OrganisationsListPID->erase(*OrganisationCount);
3503                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3504                 
3505                 } else if (PropertyName == wxT("SORT-AS")){
3507                         OrganisationsListSortAs->erase(*OrganisationCount);
3508                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3509                 
3510                 } else if (PropertyName == wxT("PREF")){
3511                                 
3512                         int PriorityNumber = 0;
3513                         bool ValidNumber = TRUE;
3514                         
3515                         try{
3516                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3517                         }
3518                         
3519                         catch(std::invalid_argument &e){
3520                                 ValidNumber = FALSE;
3521                         }
3523                         if (ValidNumber == TRUE){
3525                                 OrganisationsListPref->erase(*OrganisationCount);
3526                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3528                         }
3529                                         
3530                 } else if (PropertyName == wxT("LANGUAGE")){
3531                 
3532                         OrganisationsListLanguage->erase(*OrganisationCount);
3533                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3534                 
3535                 } else {
3536                 
3537                         // Something else we don't know about so append
3538                         // to the tokens variable.
3539                 
3540                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3541                 
3542                                 if (FirstToken == TRUE){
3543                         
3544                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3545                                         FirstToken = FALSE;
3546                         
3547                                 } else {
3548                         
3549                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3550                         
3551                                 }
3552                 
3553                         }
3554                 
3555                 }
3556         
3557         }
3558         
3559         // Add the data to the General/Home/Work address variables.
3560         
3561         CaptureString(&PropertySeg2, FALSE);
3563         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3564         
3565         if (!PropertyTokens.IsEmpty()){
3566         
3567                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3568                         
3569         }
3573 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3575         std::map<int, int> SplitPoints;
3576         std::map<int, int> SplitLength;
3577         std::map<int, int>::iterator SLiter;                    
3578         wxString PropertyData;
3579         wxString PropertyName;
3580         wxString PropertyValue;
3581         wxString PropertyTokens;
3582         bool FirstToken = TRUE;
3583         int intPrevValue = 6;
3584         int intPref = 0;                        
3585         int intType = 0;
3586         long ListCtrlIndex;
3587         
3588         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3589         
3590         intPrevValue = 5;
3591         
3592         PropertyType PropType = PROPERTY_NONE;
3593                 
3594         // Look for type before continuing.
3595         
3596         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3597         
3598         // Setup the pointers.
3599         
3600         std::map<int, wxString> *NoteList = NULL;
3601         std::map<int, wxString> *NoteListAltID = NULL;
3602         std::map<int, wxString> *NoteListPID = NULL;
3603         std::map<int, wxString> *NoteListType = NULL;
3604         std::map<int, wxString> *NoteListTokens = NULL;
3605         std::map<int, wxString> *NoteListLanguage = NULL;
3606         std::map<int, int> *NoteListPref = NULL;
3607         
3608         // Setup blank lines for later on.
3609         
3610         switch(PropType){
3611                 case PROPERTY_NONE:
3612                         NoteList = &GeneralNoteList;
3613                         NoteListType = &GeneralNoteListType;
3614                         NoteListAltID = &GeneralNoteListAltID;
3615                         NoteListPID = &GeneralNoteListPID;
3616                         NoteListTokens = &GeneralNoteListTokens;
3617                         NoteListLanguage = &GeneralNoteListLanguage;
3618                         NoteListPref = &GeneralNoteListPref;    
3619                         break;
3620                 case PROPERTY_HOME:
3621                         NoteList = &HomeNoteList;
3622                         NoteListType = &HomeNoteListType;
3623                         NoteListAltID = &HomeNoteListAltID;
3624                         NoteListPID = &HomeNoteListPID;
3625                         NoteListTokens = &HomeNoteListTokens;
3626                         NoteListLanguage = &HomeNoteListLanguage;
3627                         NoteListPref = &HomeNoteListPref;       
3628                         break;
3629                 case PROPERTY_WORK:
3630                         NoteList = &BusinessNoteList;
3631                         NoteListType = &BusinessNoteListType;
3632                         NoteListAltID = &BusinessNoteListAltID;
3633                         NoteListPID = &BusinessNoteListPID;
3634                         NoteListTokens = &BusinessNoteListTokens;
3635                         NoteListLanguage = &BusinessNoteListLanguage;   
3636                         NoteListPref = &BusinessNoteListPref;
3637                         break;
3638         }
3640         intPrevValue = 5;
3641                 
3642         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3643         intiter != SplitPoints.end(); ++intiter){
3644         
3645                 SLiter = SplitLength.find(intiter->first);
3646         
3647                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3648                 
3649                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3650                 PropertyName = PropertyElement.GetNextToken();                          
3651                 PropertyValue = PropertyElement.GetNextToken();
3652                 
3653                 intPrevValue = intiter->second;
3654                 
3655                 // Process properties.
3656                 
3657                 size_t intPropertyValueLen = PropertyValue.Len();
3658                 
3659                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3660                         
3661                         PropertyValue.Trim();
3662                         PropertyValue.RemoveLast();
3663                         
3664                 }                               
3665                 
3666                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3667                         
3668                         PropertyValue.Remove(0, 1);
3669                         
3670                 }                               
3671                 
3672                 CaptureString(&PropertyValue, FALSE);
3673                 
3674                 if (PropertyName == wxT("ALTID")){
3675                 
3676                         NoteListAltID->erase(*NoteCount);
3677                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3678                 
3679                 } else if (PropertyName == wxT("PID")){
3681                         NoteListPID->erase(*NoteCount);
3682                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3683                 
3684                 } else if (PropertyName == wxT("PREF")){
3685                                 
3686                         int PriorityNumber = 0;
3687                         bool ValidNumber = TRUE;
3688                         
3689                         try{
3690                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3691                         }
3692                         
3693                         catch(std::invalid_argument &e){
3694                                 ValidNumber = FALSE;
3695                         }
3697                         if (ValidNumber == TRUE){
3699                                 NoteListPref->erase(*NoteCount);
3700                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3702                         }
3703                                         
3704                 } else if (PropertyName == wxT("LANGUAGE")){
3705                 
3706                         NoteListLanguage->erase(*NoteCount);
3707                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3708                 
3709                 } else {
3710                 
3711                         // Something else we don't know about so append
3712                         // to the tokens variable.
3713                 
3714                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3715                 
3716                                 if (FirstToken == TRUE){
3717                         
3718                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3719                                         FirstToken = FALSE;
3720                         
3721                                 } else {
3722                         
3723                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3724                         
3725                                 }
3726                 
3727                         }
3728                 
3729                 }
3730         
3731         }
3732         
3733         // Add the data to the General/Home/Work address variables.
3734         
3735         CaptureString(&PropertySeg2, FALSE);
3737         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3738         
3739         if (!PropertyTokens.IsEmpty()){
3740         
3741                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3742                         
3743         }
3747 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3749         std::map<int, int> SplitPoints;
3750         std::map<int, int> SplitLength;
3751         std::map<int, int>::iterator SLiter;                    
3752         wxString PropertyData;
3753         wxString PropertyName;
3754         wxString PropertyValue;
3755         wxString PropertyTokens;
3756         bool FirstToken = TRUE;
3757         int intPrevValue = 12;
3758         int intPref = 0;                        
3759         int intType = 0;
3760         long ListCtrlIndex;
3761         
3762         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3763         
3764         intPrevValue = 11;
3765         
3766         PropertyType PropType = PROPERTY_NONE;
3767                 
3768         // Look for type before continuing.
3769         
3770         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3771         
3772         // Setup blank lines for later on.
3773         
3774         switch(PropType){
3775                 case PROPERTY_NONE:
3776                         break;
3777                 case PROPERTY_HOME:
3778                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3779                         break;
3780                 case PROPERTY_WORK:
3781                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3782                         break;
3783         }
3785         intPrevValue = 11;
3786                 
3787         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3788         intiter != SplitPoints.end(); ++intiter){
3789         
3790                 SLiter = SplitLength.find(intiter->first);
3791         
3792                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3793                 
3794                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3795                 PropertyName = PropertyElement.GetNextToken();                          
3796                 PropertyValue = PropertyElement.GetNextToken();
3797                 
3798                 intPrevValue = intiter->second;
3799                 
3800                 // Process properties.
3801                 
3802                 size_t intPropertyValueLen = PropertyValue.Len();
3803                 
3804                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3805                         
3806                         PropertyValue.Trim();
3807                         PropertyValue.RemoveLast();
3808                         
3809                 }                               
3810                 
3811                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3812                         
3813                         PropertyValue.Remove(0, 1);
3814                         
3815                 }                               
3816                 
3817                 CaptureString(&PropertyValue, FALSE);
3818                 
3819                 if (PropertyName == wxT("ALTID")){
3820                 
3821                         CategoriesListAltID.erase(*CategoryCount);
3822                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3823                 
3824                 } else if (PropertyName == wxT("PID")){
3826                         CategoriesListPID.erase(*CategoryCount);
3827                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3828                 
3829                 } else if (PropertyName == wxT("PREF")){
3830                                 
3831                         int PriorityNumber = 0;
3832                         bool ValidNumber = TRUE;
3833                         
3834                         try{
3835                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3836                         }
3837                         
3838                         catch(std::invalid_argument &e){
3839                                 ValidNumber = FALSE;
3840                         }
3842                         if (ValidNumber == TRUE){
3844                                 CategoriesListPref.erase(*CategoryCount);
3845                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3847                         }
3848                                         
3849                 } else if (PropertyName == wxT("LANGUAGE")){
3850                 
3851                         CategoriesListLanguage.erase(*CategoryCount);
3852                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3853                 
3854                 } else {
3855                 
3856                         // Something else we don't know about so append
3857                         // to the tokens variable.
3858                 
3859                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3860                 
3861                                 if (FirstToken == TRUE){
3862                         
3863                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3864                                         FirstToken = FALSE;
3865                         
3866                                 } else {
3867                         
3868                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3869                         
3870                                 }
3871                 
3872                         }
3873                 
3874                 }
3875         
3876         }
3877         
3878         // Deal with multiple categories.
3879         
3880         int intOrigCatCount = *CategoryCount;
3881         bool FirstCategoryProcessed = TRUE;
3882         bool AfterFirstToken = FALSE;
3883         int intSplitSize = 0;
3884         int intSplitsFound = 0;
3885         int intSplitSeek = 0;
3886         int intPropertyLen = PropertySeg2.Len();
3887         
3888         SplitPoints.clear();
3889         SplitLength.clear();
3890         intPrevValue = 0;
3891         
3892         for (int i = 0; i <= intPropertyLen; i++){
3893         
3894                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3895         
3896                         continue;
3897                 
3898                 }
3899         
3900                 intSplitSize++;
3901         
3902                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3903         
3904                         if (AfterFirstToken == TRUE){
3905                 
3906                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3907                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3908                         
3909                         } else {
3910                         
3911                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3912                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3913                                 AfterFirstToken = TRUE;
3915                         }
3917                         intSplitsFound++;
3918                         intSplitSeek = i;
3919                         intSplitSize = 0;                               
3920         
3921                 }                       
3922         
3923         }
3924         
3925         if (SplitPoints.size() > 0){
3926         
3927                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3928                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3929         
3930         }
3931         
3932         if (SplitPoints.size() == 0){
3933         
3934                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3935         
3936                 if (!PropertyTokens.IsEmpty()){
3937                 
3938                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3939                 
3940                 }
3941         
3942         }
3943         
3944         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3945         intiter != SplitPoints.end(); ++intiter){
3946         
3947                 SLiter = SplitLength.find(intiter->first);
3948         
3949                 intPrevValue = intiter->second;
3950         
3951                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3952                 
3953                 // Add the data to the General/Home/Work address variables.
3954         
3955                 // Trim any whitespace from the start and end.
3956         
3957                 PropertyData = PropertyData.Trim(FALSE);
3958                 PropertyData = PropertyData.Trim(TRUE); 
3959         
3960                 CaptureString(&PropertyData, FALSE);
3961                 
3962                 if (FirstCategoryProcessed == TRUE){
3963                 
3964                         FirstCategoryProcessed = FALSE;
3965                         
3966                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3967         
3968                         if (!PropertyTokens.IsEmpty()){
3969                 
3970                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3971                 
3972                         }
3973                         
3974                         continue;
3975                 
3976                 } else {
3978                         (*CategoryCount)++;
3979                         
3980                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3981                 
3982                         if (!PropertyTokens.IsEmpty()){
3983                 
3984                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3985                 
3986                         }
3987                 
3988                 }
3989                 
3990                 // Copy the properties to each of the categories (if it exists).
3991                 
3992                 if (!PropertyTokens.IsEmpty()){
3993                 
3994                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3995                 
3996                 }
3997                 
3998                 // Check if ALTID was used.
3999                 
4000                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4001                 
4002                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4003                 
4004                 }
4005                 
4006                 // Check if PID was used.
4007                 
4008                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4009                 
4010                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4011                 
4012                 }
4013         
4014                 // Check if PREF was used.
4015         
4016                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4017                 
4018                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4019                 
4020                 }
4021                 
4022                 // Check if LANGUAGE was used.
4023                 
4024                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4025                 
4026                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4027                 
4028                 }
4029                 
4030                 // Check if TYPE was used.
4031                 
4032                 switch(PropType){
4033                         case PROPERTY_NONE:
4034                                 break;
4035                         case PROPERTY_HOME:
4036                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4037                                 break;
4038                         case PROPERTY_WORK:
4039                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4040                                 break;
4041                 }
4042         
4043         }
4047 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4049         size_t intPropertyLen = PropertySeg1.Len();
4050         std::map<int, int> SplitPoints;
4051         std::map<int, int> SplitLength;
4052         std::map<int, int>::iterator SLiter;                    
4053         wxString PropertyData;
4054         wxString PropertyName;
4055         wxString PropertyValue;
4056         wxString PropertyTokens;
4057         bool FirstToken = TRUE;
4058         int intSplitsFound = 0;
4059         int intSplitSize = 0;
4060         int intPrevValue = 7;
4061         int intPref = 0;                        
4062         int intType = 0;
4063         long ListCtrlIndex;
4064         
4065         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4066         
4067         intPrevValue = 6;
4068         
4069         PropertyType PropType = PROPERTY_NONE;
4070                 
4071         // Look for type before continuing.
4072         
4073         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4075         intPrevValue = 6;
4077         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4078         intiter != SplitPoints.end(); ++intiter){
4079         
4080                 SLiter = SplitLength.find(intiter->first);
4081         
4082                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4083                 
4084                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4085                 PropertyName = PropertyElement.GetNextToken();                          
4086                 PropertyValue = PropertyElement.GetNextToken();
4087                 
4088                 intPrevValue = intiter->second;
4089                 
4090                 // Process properties.
4091                 
4092                 size_t intPropertyValueLen = PropertyValue.Len();
4093                 
4094                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4095                         
4096                         PropertyValue.Trim();
4097                         PropertyValue.RemoveLast();
4098                         
4099                 }                               
4100                 
4101                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4102                         
4103                         PropertyValue.Remove(0, 1);
4104                         
4105                 }
4106                 
4107                 CaptureString(&PropertyValue, FALSE);
4108                 
4109                 if (PropertyName == wxT("ALTID")){
4111                         PicturesListAltID.erase(*PhotoCount);
4112                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4113                 
4114                 } else if (PropertyName == wxT("PID")){
4116                         PicturesListPID.erase(*PhotoCount);
4117                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4118                 
4119                 } else if (PropertyName == wxT("PREF")){
4120                         
4121                         int PriorityNumber = 0;
4122                         bool ValidNumber = TRUE;
4123                         
4124                         try{
4125                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4126                         }
4127                         
4128                         catch(std::invalid_argument &e){
4129                                 ValidNumber = FALSE;
4130                         }
4132                         if (ValidNumber == TRUE){
4134                                 PicturesListPref.erase(*PhotoCount);
4135                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4137                         }
4138                 
4139                 } else if (PropertyName == wxT("MEDIATYPE")){
4140                 
4141                         PicturesListMediatype.erase(*PhotoCount);
4142                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4143                                         
4144                 } else {
4145                 
4146                         // Something else we don't know about so append
4147                         // to the tokens variable.
4148                         
4149                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4150                         
4151                                 if (FirstToken == TRUE){
4152                                 
4153                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4154                                         FirstToken = FALSE;
4155                                 
4156                                 } else {
4157                                 
4158                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4159                                 
4160                                 }
4161                         
4162                         }
4163                 
4164                 }
4165         
4166         }       
4167         
4168         intPropertyLen = PropertySeg2.Len();
4169         SplitPoints.clear();
4170         SplitLength.clear();
4171         intSplitsFound = 0;
4172         intSplitSize = 0;
4173         intPrevValue = 0;                       
4174         
4175         CaptureString(&PropertySeg2, FALSE);
4176         
4177         for (int i = 0; i <= intPropertyLen; i++){
4179                 intSplitSize++;
4180         
4181                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4182         
4183                         intSplitsFound++;
4184                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4185                         
4186                         if (intSplitsFound == 6){ 
4187                         
4188                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4189                                 break; 
4190                                 
4191                         } else {
4192                         
4193                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4194                         
4195                         }
4196                         
4197                         intSplitSize = 0;                                       
4198         
4199                 }
4201         }
4202         
4203         wxString wxSPhotoURI;
4204         wxString wxSPhotoMIME;
4205         wxString wxSPhotoEncoding;
4206         wxString wxSPhotoData;
4207         std::string base64enc;
4208         
4209         if (intSplitsFound == 0){
4210         
4211         } else {
4212         
4213                 std::map<int, int>::iterator striter;
4214         
4215                 striter = SplitLength.find(1);
4216         
4217                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4218         
4219                 while (wSTDataType.HasMoreTokens() == TRUE){
4220                 
4221                         wxSPhotoURI = wSTDataType.GetNextToken();
4222                         wxSPhotoMIME = wSTDataType.GetNextToken();
4223                         break;
4224                 
4225                 }                       
4226         
4227                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4228         
4229                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4230                 
4231                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4232                         wxSPhotoData = wSTDataInfo.GetNextToken();                                      
4233                         base64enc = wxSPhotoData.mb_str();
4234                         break;
4235                 
4236                 }
4237         
4238         }
4239         
4240         // Add the data to the General/Home/Work address variables.
4241         
4242         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4243         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4244         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4245         
4246         switch(PropType){
4247                 case PROPERTY_NONE:
4248                         break;
4249                 case PROPERTY_HOME:
4250                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4251                         break;
4252                 case PROPERTY_WORK:
4253                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4254                         break;
4255         }
4256         
4257         if (!PropertyTokens.IsEmpty()){
4259                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4260         
4261         }
4262         
4263         
4264         PhotoCount++;
4268 void SplitValues(wxString *PropertyLine, 
4269         std::map<int,int> *SplitPoints, 
4270         std::map<int,int> *SplitLength, 
4271         int intSize){
4272         
4273         size_t intPropertyLen = PropertyLine->Len();
4274         int intSplitsFound = 0;
4275         int intSplitSize = 0;
4276         int intSplitSeek = 0;
4277         
4278         for (int i = intSize; i <= intPropertyLen; i++){
4280                 intSplitSize++;
4281         
4282                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4283                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4284            
4285                     if (intSplitsFound == 0){
4286             
4287                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4288           
4289                     } else {
4290            
4291                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4292             
4293                     }
4294             
4295                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4296             
4297                     intSplitsFound++;
4298                     intSplitSeek = i;
4299                     intSplitSize = 0;
4300             
4301                 }
4303         }
4305         if (intSplitsFound == 0){
4307                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4308                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4310         } else {
4312                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4313                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4315         }
4319 void CheckType(wxString *PropertySeg1, 
4320         std::map<int,int> *SplitPoints, 
4321         std::map<int,int> *SplitLength, 
4322         int *intPrevValue, 
4323         PropertyType *PropType){
4324         
4325         wxString PropertyData;
4326         wxString PropertyName;
4327         wxString PropertyValue;
4328         std::map<int,int>::iterator SLiter;
4329         
4330         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
4331         intiter != SplitPoints->end(); ++intiter){
4332         
4333                 SLiter = SplitLength->find(intiter->first);
4334         
4335                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4336                 
4337                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4338                 PropertyName = PropertyElement.GetNextToken();                          
4339                 PropertyValue = PropertyElement.GetNextToken();
4340                 
4341                 *intPrevValue = intiter->second;
4342                 
4343                 if (PropertyName == wxT("TYPE")){
4344                                 
4345                         if (PropertyValue == wxT("work")){
4346                         
4347                                 *PropType = PROPERTY_WORK;
4348                                                         
4349                         } else if (PropertyValue == wxT("home")){
4351                                 *PropType = PROPERTY_HOME;
4352                                                         
4353                         } else {
4354                         
4355                                 *PropType = PROPERTY_NONE;
4356                         
4357                         }
4358                 
4359                         return;
4360                 
4361                 }
4362         
4363         }
4364         
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