Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
7bd80be97a13987fcc25427e0c4ed4c5834a0264
[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         wxString ContactLine;
99         wxString PropertyLine;
100         wxString PropertySeg1;
101         wxString PropertySeg2;
102         wxString PropertyNextLine;
103         wxString Property;
104         
105         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
106          iter != ContactFileLines.end(); ++iter){
108                 ExtraLineSeek = TRUE;
109                 QuoteMode = FALSE;
110                 PropertyFind = TRUE;
111                 ContactLineLen = 0;
112                 QuoteBreakPoint = 0;
113                 ContactLine.Clear();
114                 PropertyLine.Clear();
115                 PropertySeg1.Clear();
116                 PropertySeg2.Clear();
117                 Property.Clear();
118          
119                 ContactLine = iter->second;
120                 
121                 while (ExtraLineSeek == TRUE){
122                 
123                         // Check if there is extra data on the next line 
124                         // (indicated by space or tab at the start) and add data.
125                 
126                         iter++;
127                         
128                         if (iter == ContactFileLines.end()){
129                         
130                                 iter--;
131                                 break;
132                         
133                         }                       
134                 
135                         PropertyNextLine = iter->second;
136                 
137                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
138                 
139                                 PropertyNextLine.Remove(0, 1);
140                                 ContactLine.Append(PropertyNextLine);
141                 
142                         } else {
143                         
144                                 iter--;
145                                 ExtraLineSeek = FALSE;
146                         
147                         }
148                 
149                 }
151                 ContactLineLen = ContactLine.Len();
152                 
153                 // Make sure we are not in quotation mode.
154                 // Make sure colon does not have \ or \\ before it.
155                 
156                 for (int i = 0; i <= ContactLineLen; i++){
157                 
158                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
159                         
160                                 PropertyFind = FALSE;
161                         
162                         } else if (PropertyFind == TRUE){
163                         
164                                 Property.Append(ContactLine.Mid(i, 1));
165                         
166                         }               
167                 
168                         if (ContactLine.Mid(i, 1) == wxT("\"")){
169                         
170                                 if (QuoteMode == TRUE){
171                                 
172                                         QuoteMode = FALSE;
173                                 
174                                 } else {
175                         
176                                         QuoteMode = TRUE;
177                                         
178                                 }
179                         
180                         }
181                         
182                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
183                         
184                                 QuoteBreakPoint = i;
185                                 break;
186                         
187                         }
188                 
189                 }
190                 
191                 // Split that line at the point into two variables (ignore the colon).
192                 
193                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
194                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
195                 
196                  if (Property == wxT("KIND") && KindProcessed == FALSE){
197                                 
198                         ProcessKind(PropertySeg2);
199                 
200                 } else if (Property == wxT("MEMBER")){
202                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
203                         GroupCount++;   
204                 
205                 } else if (Property == wxT("FN")){
206                 
207                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
208                         FNCount++;
209                 
210                 } else if (Property == wxT("N") && NameProcessed == FALSE){
211                 
212                         ProcessN(PropertySeg1, PropertySeg2);
213                         NameProcessed = TRUE;
214                 
215                 } else if (Property == wxT("NICKNAME")){
216                                                 
217                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
218                         NicknameCount++;
219                         
220                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
221                 
222                         ProcessGender(PropertySeg1, PropertySeg2);
223                         GenderProcessed = TRUE;
224                 
225                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
226                 
227                         ProcessBirthday(PropertySeg1, PropertySeg2);
228                         BirthdayProcessed = TRUE;
229                 
230                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
231                 
232                         ProcessAnniversary(PropertySeg1, PropertySeg2);
233                         AnniversaryProcessed = TRUE;
234                 
235                 } else if (Property == wxT("TZ")){
236                 
237                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
238                         TimeZoneCount++;
239                 
240                 } else if (Property == wxT("ADR")){
241                 
242                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
243                         AddressCount++;
244                 
245                 } else if (Property == wxT("EMAIL")){
246                                         
247                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
248                         EmailCount++;
249                 
250                 } else if (Property == wxT("IMPP")){
251                 
252                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
253                         IMCount++;
254                         
255                 } else if (Property == wxT("TEL")){
256                                 
257                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
258                         TelephoneCount++;
259                 
260                 } else if (Property == wxT("LANG")){
261                 
262                         // See frmContactEditor-LoadLanguage.cpp
263                         
264                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
265                         LanguageCount++;
266                 
267                 } else if (Property == wxT("GEO")){
268                 
269                         // See frmContactEditor-LoadGeo.cpp
270                         
271                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
272                         GeographicCount++;
273                 
274                 } else if (Property == wxT("RELATED")){
275                         
276                         // See fromContactEditor-LoadRelated.cpp
277                         
278                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
279                         RelatedCount++;
280                         
281                 } else if (Property == wxT("URL")){
283                         // See frmContactEditor-LoadURL.cpp
284                 
285                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
286                         URLCount++;
287                 
288                 } else if (Property == wxT("TITLE")) {
289                 
290                         // See frmContactEditor-LoadTitle.cpp
291                         
292                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
293                         TitleCount++;
294                         
295                 } else if (Property == wxT("ROLE")) {
296                 
297                         // See frmContactEditor-LoadTitle.cpp
298                         
299                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
300                         RoleCount++;
301                         
302                 } else if (Property == wxT("ORG")) {
303                 
304                         // See frmContactEditor-LoadOrg.cpp
305                         
306                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
307                         OrganisationCount++;
308                         
309                 }
310                 
311         }
312         
313         return CONTACTLOAD_OK;
317 void ContactDataObject::ProcessKind(wxString KindType){
319         if (KindType == wxT("individual")){
320                         
321                 ContactKind = CONTACTKIND_INDIVIDUAL;
322                         
323         } else if (KindType == wxT("group")){
324                         
325                 ContactKind = CONTACTKIND_GROUP;
326                         
327         } else if (KindType == wxT("org")){
328                         
329                 ContactKind = CONTACTKIND_ORGANISATION;
330                         
331         } else if (KindType == wxT("location")){
332                         
333                 ContactKind = CONTACTKIND_LOCATION;
334                         
335         } else {
336                         
337                 ContactKind = CONTACTKIND_NONE;                 
338         }
342 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
344         std::map<int, int> SplitPoints;
345         std::map<int, int> SplitLength;
347         int intPrevValue = 8;
348         int intPref = 0;                        
349         int intType = 0;
350         
351         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
353         intPrevValue = 7;
354         
355         wxString PropertyName;
356         wxString PropertyValue;
357         wxString PropertyData;
358         wxString PropertyTokens;
359         std::map<int,int>::iterator SLiter;
360         bool FirstToken = TRUE;
361         
362         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
363         intiter != SplitPoints.end(); ++intiter){
364         
365                 SLiter = SplitLength.find(intiter->first);
366         
367                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
368                 
369                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
370                 PropertyName = PropertyElement.GetNextToken();                          
371                 PropertyValue = PropertyElement.GetNextToken();
372                 
373                 intPrevValue = intiter->second;
374                 
375                 CaptureString(&PropertyValue, FALSE);
376         
377                 if (PropertyName == wxT("ALTID")){
379                         GroupsListAltID.erase(*GroupCount);
380                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
381                 
382                 } else if (PropertyName == wxT("PID")){
384                         GroupsListPID.erase(*GroupCount);
385                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
386                 
387                 } else if (PropertyName == wxT("PREF")){
389                         int PriorityNumber = 0;
390                         bool ValidNumber = TRUE;
391                         
392                         try{
393                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
394                         }
395                         
396                         catch(std::invalid_argument &e){
397                                 ValidNumber = FALSE;
398                         }
400                         if (ValidNumber == TRUE){
402                                 GroupsListPref.erase(*GroupCount);
403                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
404                 
405                         }
406                 
407                 } else if (PropertyName == wxT("MEDIATYPE")){
409                         GroupsListMediaType.erase(*GroupCount);
410                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
411                 
412                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
413                         
414                         if (FirstToken == TRUE){
415                                 
416                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
417                                 FirstToken = FALSE;
418                                 
419                         } else {
420                         
421                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
422                                 
423                         }
424                         
425                 }
426                 
427         }
429         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
431         if (!PropertyTokens.IsEmpty()){
432         
433                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
434         
435         }
440 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
442         std::map<int, int> SplitPoints;
443         std::map<int, int> SplitLength;
445         int intPrevValue = 4;
446         int intPref = 0;                        
447         int intType = 0;
448         
449         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
451         intPrevValue = 3;
452         
453         wxString PropertyName;
454         wxString PropertyValue;
455         wxString PropertyData;
456         wxString PropertyTokens;
457         std::map<int,int>::iterator SLiter;
458         bool FirstToken = TRUE;
459         
460         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
461         intiter != SplitPoints.end(); ++intiter){
462         
463                 SLiter = SplitLength.find(intiter->first);
464         
465                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
466                 
467                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
468                 PropertyName = PropertyElement.GetNextToken();                          
469                 PropertyValue = PropertyElement.GetNextToken();
470                 
471                 intPrevValue = intiter->second;
472                 
473                 CaptureString(&PropertyValue, FALSE);
474                 
475                 if (PropertyName == wxT("TYPE")){
477                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
478                                 PropertyValue == wxT("work") ){
480                                 FullNamesListType.erase(*FNCount);
481                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
482                 
483                         }
484                 
485                 } else if (PropertyName == wxT("LANGUAGE")){
487                         FullNamesListLanguage.erase(*FNCount);
488                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
489                 
490                 } else if (PropertyName == wxT("ALTID")){
491                 
492                         FullNamesListAltID.erase(*FNCount);
493                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
494                 
495                 } else if (PropertyName == wxT("PID")){
497                         FullNamesListPID.erase(*FNCount);
498                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
499                 
500                 } else if (PropertyName == wxT("PREF")){
502                         int PriorityNumber = 0;
503                         bool ValidNumber = TRUE;
504                         
505                         try{
506                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
507                         }
508                         
509                         catch(std::invalid_argument &e){
510                                 ValidNumber = FALSE;
511                         }
513                         if (ValidNumber == TRUE){
515                                 FullNamesListPref.erase(*FNCount);
516                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
518                         }
519                 
520                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
521                         
522                         if (FirstToken == TRUE){
523                                 
524                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
525                                 FirstToken = FALSE;
526                                 
527                         } else {
528                         
529                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
530                                 
531                         }
532                         
533                 } 
534         
535         }
537         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
539         if (!PropertyTokens.IsEmpty()){
540         
541                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
542         
543         }
547 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
549         std::map<int, int> SplitPoints;
550         std::map<int, int> SplitLength;
552         int intPrevValue = 3;
553         int intPref = 0;                        
554         int intType = 0;
555         
556         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
557         
558         intPrevValue = 2;
559         
560         wxString PropertyName;
561         wxString PropertyValue;
562         wxString PropertyData;
563         wxString PropertyTokens;
564         std::map<int,int>::iterator SLiter;
565         bool FirstToken = TRUE;
566         
567         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
568         intiter != SplitPoints.end(); ++intiter){
569         
570                 SLiter = SplitLength.find(intiter->first);
571         
572                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
573                 
574                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
575                 PropertyName = PropertyElement.GetNextToken();                          
576                 PropertyValue = PropertyElement.GetNextToken();
577                 
578                 intPrevValue = intiter->second;
579                 
580                 CaptureString(&PropertyValue, FALSE);
581                 
582                 if (PropertyName == wxT("ALTID")){
584                         NameAltID = PropertyValue;
585                 
586                 } else if (PropertyName == wxT("LANGUAGE")){
587                 
588                         NameLanguage = PropertyValue;
589                 
590                 } else if (PropertyName == wxT("SORT-AS")){
591                 
592                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
593                                 PropertyValue.Len() >= 3){
594                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
595                         }
596                 
597                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
598                         
599                         if (FirstToken == TRUE){
600                                 
601                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
602                                 FirstToken = FALSE;
603                                 
604                         } else {
605                         
606                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
607                                 
608                         }
609                         
610                 }
611         
612         }
613         
614         // Split the name data.
615         
616         int intSplitSeek = 0;           
617         int intSplitsFound = 0;
618         int intSplitSize = 0;
619         int intPropertyLen = PropertySeg2.Len();
620         
621         std::map<int,wxString> NameValues;
622         intPrevValue = 0;                                       
623         
624         for (int i = 0; i <= intPropertyLen; i++){
625         
626                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
627                         
628                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
629                         
630                         intSplitSeek = i;
631                         intSplitSeek++;
632                         
633                         if (intSplitsFound == 4){
634                         
635                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
636                                 break;
637                         
638                         }
639                         
640                         intSplitSize = 0;
641                         continue;
642         
643                 }
644                 
645                 intSplitSize++;
647         }
648         
649         // Split the data into several parts.
650                         
651         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
652         iter != NameValues.end(); ++iter){
653         
654                 if (iter->first == 1){
655                 
656                         // Deal with family name.
657                         
658                         NameSurname = iter->second;
659                 
660                 } else if (iter->first == 2){
661                 
662                         // Deal with given names.
663                         
664                         NameForename = iter->second;
665                 
666                 } else if (iter->first == 3){
667                 
668                         // Deal with additional names.
669                         
670                         NameOtherNames = iter->second;
671                 
672                 } else if (iter->first == 4){
673                 
674                         // Deal with honorifix prefixes and suffixes.
676                         NameTitle = iter->second;
677                 
678                         iter++;
679                         
680                         if (iter == NameValues.end()){
681                         
682                                 break;
683                         
684                         }
685                 
686                         NameSuffix = iter->second;
687                 
688                 }
689         
690         }
691         
692         // Add the name token data.
693         
694         if (!PropertyTokens.IsEmpty()){
695         
696                 NameTokens = PropertyTokens;
697         
698         }
702 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
704         std::map<int, int> SplitPoints;
705         std::map<int, int> SplitLength;
707         int intPrevValue = 10;
708         int intPref = 0;                        
709         
710         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
711         
712         intPrevValue = 9;
713         
714         PropertyType PropType = PROPERTY_NONE;
715         
716         // Look for type before continuing.
717         
718         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
719         
720         intPrevValue = 9;
721         
722         std::map<int, wxString> *NicknamesList = NULL;
723         std::map<int, wxString> *NicknamesListType = NULL;
724         std::map<int, wxString> *NicknamesListLanguage = NULL;
725         std::map<int, wxString> *NicknamesListAltID = NULL;
726         std::map<int, wxString> *NicknamesListPID = NULL;
727         std::map<int, wxString> *NicknamesListTokens = NULL;            
728         std::map<int, int> *NicknamesListPref = NULL;
729         
730         switch(PropType){
731                 case PROPERTY_NONE:
732                         NicknamesList = &GeneralNicknamesList;
733                         NicknamesListType = &GeneralNicknamesListType;
734                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
735                         NicknamesListAltID = &GeneralNicknamesListAltID;
736                         NicknamesListPID = &GeneralNicknamesListPID;
737                         NicknamesListTokens = &GeneralNicknamesListTokens;
738                         NicknamesListPref = &GeneralNicknamesListPref;
739                         break;
740                 case PROPERTY_HOME:
741                         NicknamesList = &HomeNicknamesList;
742                         NicknamesListType = &HomeNicknamesListType;
743                         NicknamesListLanguage = &HomeNicknamesListLanguage;
744                         NicknamesListAltID = &HomeNicknamesListAltID;
745                         NicknamesListPID = &HomeNicknamesListPID;
746                         NicknamesListTokens = &HomeNicknamesListTokens;
747                         NicknamesListPref = &HomeNicknamesListPref;
748                         break;
749                 case PROPERTY_WORK:
750                         NicknamesList = &BusinessNicknamesList;
751                         NicknamesListType = &BusinessNicknamesListType;
752                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
753                         NicknamesListAltID = &BusinessNicknamesListAltID;
754                         NicknamesListPID = &BusinessNicknamesListPID;
755                         NicknamesListTokens = &BusinessNicknamesListTokens;
756                         NicknamesListPref = &BusinessNicknamesListPref;
757                         break;
758         }
759         
760         std::map<int, int>::iterator SLiter;    
761         wxString PropertyData;
762         wxString PropertyName;
763         wxString PropertyValue;
764         wxString PropertyTokens;
765         bool FirstToken = TRUE;
766         
767         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
768         intiter != SplitPoints.end(); ++intiter){
769         
770                 SLiter = SplitLength.find(intiter->first);
771         
772                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
773                 
774                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
775                 PropertyName = PropertyElement.GetNextToken();                          
776                 PropertyValue = PropertyElement.GetNextToken();
777                 
778                 intPrevValue = intiter->second;
779                 
780                 CaptureString(&PropertyValue, FALSE);
781                 
782                 if (PropertyName == wxT("ALTID")){
784                         NicknamesListAltID->erase(*NicknameCount);
785                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
786                 
787                 } else if (PropertyName == wxT("PID")){
789                         NicknamesListPID->erase(*NicknameCount);
790                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
792                 } else if (PropertyName == wxT("PREF")){
794                         int PriorityNumber = 0;
795                         bool ValidNumber = TRUE;
796                         
797                         try{
798                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
799                         }
800                         
801                         catch(std::invalid_argument &e){
802                                 ValidNumber = FALSE;
803                         }
805                         if (ValidNumber == TRUE){
807                                 NicknamesListPref->erase(*NicknameCount);
808                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
810                         }
811                 
812                 } else if (PropertyName == wxT("LANGUAGE")){
814                         NicknamesListLanguage->erase(*NicknameCount);
815                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
817                 } else {
818                 
819                         // Something else we don't know about so append
820                         // to the tokens variable.
821                 
822                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
823                 
824                                 if (FirstToken == TRUE){
825                         
826                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
827                                         FirstToken = FALSE;
828                         
829                                 } else {
830                         
831                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
832                         
833                                 }
834                 
835                         }
836                 
837                 }
838                 
839         }
840         
841         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
842         
843         // Add the name token data.
844         
845         if (!PropertyTokens.IsEmpty()){
846         
847                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
848         
849         }
853 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
855         std::map<int, int> SplitPoints;
856         std::map<int, int> SplitLength;
857         std::map<int, int>::iterator SLiter;                    
858         wxString PropertyData;
859         wxString PropertyName;
860         wxString PropertyValue;
861         wxString PropertyTokens;
862         bool FirstToken = TRUE;
863         int intPrevValue = 8;
865         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
867         intPrevValue = 7;                       
868         
869         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
870         intiter != SplitPoints.end(); ++intiter){
871         
872                 SLiter = SplitLength.find(intiter->first);
873         
874                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
875                 
876                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
877                 PropertyName = PropertyElement.GetNextToken();                          
878                 PropertyValue = PropertyElement.GetNextToken();
879                 
880                 intPrevValue = intiter->second;
881                 
882                 // Process properties.
883                 
884                 size_t intPropertyValueLen = PropertyValue.Len();
885                 
886                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
887                         
888                         PropertyValue.Trim();
889                         PropertyValue.RemoveLast();
890                         
891                 }                               
892                 
893                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
894                         
895                         PropertyValue.Remove(0, 1);
896                         
897                 }                               
898                 
899                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
901                         if (FirstToken == TRUE){
902         
903                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
904                                 FirstToken = FALSE;
905         
906                         } else {
907         
908                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
909         
910                         }
912                 }
913         
914         }       
916         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
917         
918         wxString GenderComponent;
919         
920         if (GenderData.CountTokens() >= 2){
921         
922                 Gender = GenderData.GetNextToken();
923                 GenderDetails = GenderData.GetString();
924         
925                 CaptureString(&GenderDetails, FALSE);
926                                                 
927         } else {
928         
929                 Gender = GenderData.GetNextToken();
930         
931         }
932         
933         if (!PropertyTokens.IsEmpty()){
934         
935                 GenderTokens = PropertyTokens;
936         
937         }
941 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
943         // Process date. Preserve the remainder in the string.
945         std::map<int, int> SplitPoints;
946         std::map<int, int> SplitLength;
947         std::map<int, int>::iterator SLiter;                    
948         wxString PropertyData;
949         wxString PropertyName;
950         wxString PropertyValue;
951         wxString PropertyTokens;
952         bool BirthdayText = FALSE;
953         int intPrevValue = 6;
955         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
957         intPrevValue = 5;
959         // Look for type before continuing.
961         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
962         intiter != SplitPoints.end(); ++intiter){
964                 SLiter = SplitLength.find(intiter->first);
966                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
967         
968                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
969                 PropertyName = PropertyElement.GetNextToken();                          
970                 PropertyValue = PropertyElement.GetNextToken();
971         
972                 intPrevValue = intiter->second;
973         
974                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
975         
976                         CaptureString(&PropertySeg2, FALSE);
977                         Birthday = PropertySeg2;
978                         BirthdayText = TRUE;
979         
980                 }
982         }
984         // Setup blank lines for later on.
985         
986         intPrevValue = 5;
987         bool FirstToken = TRUE;
989         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
990         intiter != SplitPoints.end(); ++intiter){
992                 SLiter = SplitLength.find(intiter->first);
994                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
995         
996                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
997                 PropertyName = PropertyElement.GetNextToken();                          
998                 PropertyValue = PropertyElement.GetNextToken();
999         
1000                 intPrevValue = intiter->second;
1001         
1002                 // Process properties.
1003         
1004                 CaptureString(&PropertyValue, FALSE);
1005         
1006                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1007                 
1008                         PropertyValue.Trim();
1009                         PropertyValue.RemoveLast();
1010                 
1011                 }                               
1012         
1013                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1014                 
1015                         PropertyValue.Remove(0, 1);
1016                 
1017                 }                               
1018         
1019                 if (PropertyName == wxT("ALTID")){
1021                         BirthdayAltID = PropertyValue;
1022         
1023                 } else if (PropertyName == wxT("CALSCALE")){
1024         
1025                         BirthdayCalScale = PropertyValue;
1026         
1027                 } else if (PropertyName != wxT("VALUE")) {
1028         
1029                         // Something else we don't know about so append
1030                         // to the tokens variable.
1031                 
1032                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1033                 
1034                                 if (FirstToken == TRUE){
1035         
1036                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1037                                         FirstToken = FALSE;
1038         
1039                                 } else {
1040         
1041                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1042         
1043                                 }
1044                                 
1045                         }
1046                         
1047                 }
1049         }       
1051         // Add the data to the variables and form.
1052         
1053         if (BirthdayText == FALSE){
1054         
1055                 Birthday = PropertySeg2;
1057         }
1058         
1059         if (!PropertyTokens.IsEmpty()){
1060         
1061                 BirthdayTokens = PropertyTokens;
1063         }
1067 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1069         // Process date. Preserve the remainder in the string.
1071         std::map<int, int> SplitPoints;
1072         std::map<int, int> SplitLength;
1073         std::map<int, int>::iterator SLiter;                    
1074         wxString PropertyData;
1075         wxString PropertyName;
1076         wxString PropertyValue;
1077         wxString PropertyTokens;
1078         bool AnniversaryText = FALSE;
1079         int intPrevValue = 13;
1081         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1083         intPrevValue = 12;
1085         // Look for type before continuing.
1087         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1088         intiter != SplitPoints.end(); ++intiter){
1090                 SLiter = SplitLength.find(intiter->first);
1092                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1093         
1094                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1095                 PropertyName = PropertyElement.GetNextToken();                          
1096                 PropertyValue = PropertyElement.GetNextToken();
1097         
1098                 intPrevValue = intiter->second;
1099         
1100                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1101         
1102                         CaptureString(&PropertySeg2, FALSE);
1103                         Anniversary = PropertySeg2;
1104                         AnniversaryText = TRUE;
1105         
1106                 }
1108         }
1110         // Setup blank lines for later on.
1111         
1112         intPrevValue = 12;
1113         bool FirstToken = TRUE;
1115         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1116         intiter != SplitPoints.end(); ++intiter){
1118                 SLiter = SplitLength.find(intiter->first);
1120                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1121         
1122                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1123                 PropertyName = PropertyElement.GetNextToken();                          
1124                 PropertyValue = PropertyElement.GetNextToken();
1125         
1126                 intPrevValue = intiter->second;
1127         
1128                 // Process properties.
1129         
1130                 CaptureString(&PropertyValue, FALSE);
1131         
1132                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1133                 
1134                         PropertyValue.Trim();
1135                         PropertyValue.RemoveLast();
1136                 
1137                 }                               
1138         
1139                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1140                 
1141                         PropertyValue.Remove(0, 1);
1142                 
1143                 }                               
1144         
1145                 if (PropertyName == wxT("ALTID")){
1147                         AnniversaryAltID = PropertyValue;
1148         
1149                 } else if (PropertyName == wxT("CALSCALE")){
1150         
1151                         AnniversaryCalScale = PropertyValue;
1152         
1153                 } else if (PropertyName != wxT("VALUE")) {
1154         
1155                         // Something else we don't know about so append
1156                         // to the tokens variable.
1157                 
1158                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1159                 
1160                                 if (FirstToken == TRUE){
1161         
1162                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1163                                         FirstToken = FALSE;
1164         
1165                                 } else {
1166         
1167                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1168         
1169                                 }
1170                                 
1171                         }
1172                         
1173                 }
1175         }       
1177         // Add the data to the variables and form.
1178         
1179         if (AnniversaryText == FALSE){
1180         
1181                 Anniversary = PropertySeg2;
1183         }
1184         
1185         if (!PropertyTokens.IsEmpty()){
1186         
1187                 AnniversaryTokens = PropertyTokens;
1189         }
1193 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1195         std::map<int, int> SplitPoints;
1196         std::map<int, int> SplitLength;
1198         int intPrevValue = 4;
1199         int intPref = 0;                        
1200         
1201         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1202         
1203         intPrevValue = 3;
1204         
1205         PropertyType PropType = PROPERTY_NONE;
1206         
1207         // Look for type before continuing.
1208         
1209         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1210         
1211         intPrevValue = 3;
1212         
1213         std::map<int, wxString> *TZList = NULL;
1214         std::map<int, wxString> *TZListType = NULL;
1215         std::map<int, wxString> *TZListMediatype = NULL;
1216         std::map<int, wxString> *TZListAltID = NULL;
1217         std::map<int, wxString> *TZListPID = NULL;
1218         std::map<int, wxString> *TZListTokens = NULL;           
1219         std::map<int, int> *TZListPref = NULL;
1220         
1221         switch(PropType){
1222                 case PROPERTY_NONE:
1223                         TZList = &GeneralTZList;
1224                         TZListType = &GeneralTZListType;
1225                         TZListMediatype = &GeneralTZListMediatype;
1226                         TZListAltID = &GeneralTZListAltID;
1227                         TZListPID = &GeneralTZListPID;
1228                         TZListTokens = &GeneralTZListTokens;
1229                         TZListPref = &GeneralTZListPref;
1230                         break;
1231                 case PROPERTY_HOME:
1232                         TZList = &HomeTZList;
1233                         TZListType = &HomeTZListType;
1234                         TZListMediatype = &HomeTZListMediatype;
1235                         TZListAltID = &HomeTZListAltID;
1236                         TZListPID = &HomeTZListPID;
1237                         TZListTokens = &HomeTZListTokens;
1238                         TZListPref = &HomeTZListPref;
1239                         break;
1240                 case PROPERTY_WORK:
1241                         TZList = &BusinessTZList;
1242                         TZListType = &BusinessTZListType;
1243                         TZListMediatype = &BusinessTZListMediatype;
1244                         TZListAltID = &BusinessTZListAltID;
1245                         TZListPID = &BusinessTZListPID;
1246                         TZListTokens = &BusinessTZListTokens;
1247                         TZListPref = &BusinessTZListPref;
1248                         break;
1249         }
1250         
1251         std::map<int, int>::iterator SLiter;    
1252         wxString PropertyData;
1253         wxString PropertyName;
1254         wxString PropertyValue;
1255         wxString PropertyTokens;
1256         bool FirstToken = TRUE;
1257         
1258         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1259         intiter != SplitPoints.end(); ++intiter){
1260         
1261                 SLiter = SplitLength.find(intiter->first);
1262         
1263                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1264                 
1265                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1266                 PropertyName = PropertyElement.GetNextToken();                          
1267                 PropertyValue = PropertyElement.GetNextToken();
1268                 
1269                 intPrevValue = intiter->second;
1270                 
1271                 CaptureString(&PropertyValue, FALSE);
1273                 if (PropertyName == wxT("ALTID")){
1275                         TZListAltID->erase(*TimeZoneCount);
1276                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1277                 
1278                 } else if (PropertyName == wxT("PID")){
1280                         TZListPID->erase(*TimeZoneCount);
1281                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1283                 } else if (PropertyName == wxT("PREF")){
1285                         int PriorityNumber = 0;
1286                         bool ValidNumber = TRUE;
1287                         
1288                         try{
1289                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1290                         }
1291                         
1292                         catch(std::invalid_argument &e){
1293                                 ValidNumber = FALSE;
1294                         }
1296                         if (ValidNumber == TRUE){
1298                                 TZListPref->erase(*TimeZoneCount);
1299                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1301                         }
1302                 
1303                 } else if (PropertyName == wxT("MEDIATYPE")){
1305                         TZListMediatype->erase(*TimeZoneCount);
1306                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1308                 } else {
1309                 
1310                         // Something else we don't know about so append
1311                         // to the tokens variable.
1312                 
1313                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1314                 
1315                                 if (FirstToken == TRUE){
1316                         
1317                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1318                                         FirstToken = FALSE;
1319                         
1320                                 } else {
1321                         
1322                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1323                         
1324                                 }
1325                 
1326                         }
1327                 
1328                 }
1329                 
1330         }
1331         
1332         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1333         
1334         // Add the name token data.
1335         
1336         if (!PropertyTokens.IsEmpty()){
1337         
1338                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1339         
1340         }
1345 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1347         size_t intPropertyLen = PropertySeg1.Len();
1348         std::map<int, int> SplitPoints;
1349         std::map<int, int> SplitLength;
1350         std::map<int, int>::iterator SLiter;                    
1351         wxString PropertyData;
1352         wxString PropertyName;
1353         wxString PropertyValue;
1354         wxString PropertyTokens;
1355         wxString AddressLabel;
1356         wxString AddressLang;
1357         wxString AddressAltID;
1358         wxString AddressPID;
1359         wxString AddressTokens;
1360         wxString AddressGeo;
1361         wxString AddressTimezone;
1362         wxString AddressType;
1363         wxString AddressMediatype;
1364         wxString AddressPOBox;
1365         wxString AddressExtended;
1366         wxString AddressStreet;
1367         wxString AddressLocality;
1368         wxString AddressCity;
1369         wxString AddressRegion;
1370         wxString AddressPostalCode;
1371         wxString AddressCountry;
1372         bool FirstToken = TRUE;                 
1373         int intSplitsFound = 0;
1374         int intSplitSize = 0;
1375         int intPrevValue = 5;
1376         int intPref = 0;                        
1377         int intType = 0;
1378         long ListCtrlIndex;
1379         
1380         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1381         
1382         intPrevValue = 4;
1383         
1384         PropertyType PropType = PROPERTY_NONE;
1385                 
1386         // Look for type before continuing.
1387         
1388         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1389         
1390         intPrevValue = 4;
1391         
1392         std::map<int, wxString> *AddressList = NULL;
1393         std::map<int, wxString> *AddressListTown = NULL;
1394         std::map<int, wxString> *AddressListCounty = NULL;
1395         std::map<int, wxString> *AddressListPostCode = NULL;
1396         std::map<int, wxString> *AddressListCountry = NULL;
1397         std::map<int, wxString> *AddressListLabel = NULL;
1398         std::map<int, wxString> *AddressListLang = NULL;                
1399         std::map<int, wxString> *AddressListAltID = NULL;
1400         std::map<int, wxString> *AddressListPID = NULL;
1401         std::map<int, wxString> *AddressListTokens = NULL;
1402         std::map<int, wxString> *AddressListGeo = NULL;
1403         std::map<int, wxString> *AddressListTimezone = NULL;            
1404         std::map<int, wxString> *AddressListType = NULL;
1405         std::map<int, wxString> *AddressListMediatype = NULL;
1406         std::map<int, int> *AddressListPref = NULL;
1408         switch(PropType){
1409                 case PROPERTY_NONE:
1410                         AddressList = &GeneralAddressList;
1411                         AddressListTown = &GeneralAddressListTown;
1412                         AddressListCounty = &GeneralAddressListCounty;
1413                         AddressListPostCode = &GeneralAddressListPostCode;
1414                         AddressListCountry = &GeneralAddressListCountry;
1415                         AddressListLabel = &GeneralAddressListLabel;
1416                         AddressListLang = &GeneralAddressListLang;              
1417                         AddressListAltID = &GeneralAddressListAltID;
1418                         AddressListPID = &GeneralAddressListPID;
1419                         AddressListTokens = &GeneralAddressListTokens;
1420                         AddressListGeo = &GeneralAddressListGeo;
1421                         AddressListTimezone = &GeneralAddressListTimezone;
1422                         AddressListType = &GeneralAddressListType;
1423                         AddressListMediatype = &GeneralAddressListMediatype;
1424                         AddressListPref = &GeneralAddressListPref;              
1425                         break;
1426                 case PROPERTY_HOME:
1427                         AddressList = &HomeAddressList;
1428                         AddressListTown = &HomeAddressListTown;
1429                         AddressListCounty = &HomeAddressListCounty;
1430                         AddressListPostCode = &HomeAddressListPostCode;
1431                         AddressListCountry = &HomeAddressListCountry;
1432                         AddressListLabel = &HomeAddressListLabel;
1433                         AddressListLang = &HomeAddressListLang;         
1434                         AddressListAltID = &HomeAddressListAltID;
1435                         AddressListPID = &HomeAddressListPID;
1436                         AddressListTokens = &HomeAddressListTokens;
1437                         AddressListGeo = &HomeAddressListGeo;
1438                         AddressListTimezone = &HomeAddressListTimezone;
1439                         AddressListType = &HomeAddressListType;
1440                         AddressListMediatype = &HomeAddressListMediatype;
1441                         AddressListPref = &HomeAddressListPref;
1442                         break;
1443                 case PROPERTY_WORK:
1444                         AddressList = &BusinessAddressList;
1445                         AddressListTown = &BusinessAddressListTown;
1446                         AddressListCounty = &BusinessAddressListCounty;
1447                         AddressListPostCode = &BusinessAddressListPostCode;
1448                         AddressListCountry = &BusinessAddressListCountry;
1449                         AddressListLabel = &BusinessAddressListLabel;
1450                         AddressListLang = &BusinessAddressListLang;             
1451                         AddressListAltID = &BusinessAddressListAltID;
1452                         AddressListPID = &BusinessAddressListPID;
1453                         AddressListTokens = &BusinessAddressListTokens;
1454                         AddressListGeo = &BusinessAddressListGeo;
1455                         AddressListTimezone = &BusinessAddressListTimezone;
1456                         AddressListType = &BusinessAddressListType;
1457                         AddressListMediatype = &BusinessAddressListMediatype;
1458                         AddressListPref = &BusinessAddressListPref;
1459                         break;
1460         }
1461         
1462         intPrevValue = 4;
1463         
1464         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1465         intiter != SplitPoints.end(); ++intiter){
1466         
1467                 SLiter = SplitLength.find(intiter->first);
1468         
1469                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1470                 
1471                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1472                 PropertyName = PropertyElement.GetNextToken();                          
1473                 PropertyValue = PropertyElement.GetNextToken();
1474                 
1475                 intPrevValue = intiter->second;
1476                 
1477                 CaptureString(&PropertyValue, FALSE);
1478                 
1479                 // Process properties.
1480                 
1481                 if (PropertyName == wxT("LABEL")){
1482                 
1483                         AddressListLabel->erase(*AddressCount);
1484                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1485                                 
1486                 } else if (PropertyName == wxT("LANGUAGE")){
1487                 
1488                         AddressListLang->erase(*AddressCount);
1489                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1490                 
1491                 } else if (PropertyName == wxT("ALTID")){
1493                         AddressListAltID->erase(*AddressCount);
1494                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1495                 
1496                 } else if (PropertyName == wxT("PID")){
1498                         AddressListPID->erase(*AddressCount);
1499                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1500                 
1501                 } else if (PropertyName == wxT("GEO")){
1502                 
1503                         AddressListGeo->erase(*AddressCount);
1504                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1505                 
1506                 } else if (PropertyName == wxT("TZ")){
1508                         AddressListTimezone->erase(*AddressCount);
1509                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1510                 
1511                 } else if (PropertyName == wxT("MEDIATYPE")){
1513                         AddressListMediatype->erase(*AddressCount);
1514                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1515                 
1516                 } else if (PropertyName == wxT("PREF")){
1517                         
1518                         int PriorityNumber = 0;
1519                         bool ValidNumber = TRUE;
1520                         
1521                         try{
1522                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1523                         }
1524                         
1525                         catch(std::invalid_argument &e){
1526                                 ValidNumber = FALSE;
1527                         }
1529                         if (ValidNumber == TRUE){
1531                                 AddressListPref->erase(*AddressCount);
1532                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1534                         }
1535                 
1536                 } else {
1537                 
1538                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1539                         
1540                                 if (FirstToken == TRUE){
1541                                 
1542                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1543                                         FirstToken = FALSE;
1544                                 
1545                                 } else {
1546                                 
1547                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1548                                 
1549                                 }
1550                         
1551                         }
1552                 
1553                 }
1554         
1555         }                       
1556         
1557         // Split the address. 
1559         //std::map<int, int>::iterator SLiter;
1560         intPropertyLen = PropertySeg2.Len();
1561         SplitPoints.clear();
1562         SplitLength.clear();
1563         intSplitsFound = 0;
1564         intSplitSize = 0;
1565         intPrevValue = 0;
1566         
1567         for (int i = 0; i <= intPropertyLen; i++){
1569                 intSplitSize++;
1570         
1571                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1572         
1573                         intSplitsFound++;
1574                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1575                         
1576                         if (intSplitsFound == 6){ 
1577                         
1578                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1579                                 break; 
1580                                 
1581                         } else {
1582                         
1583                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1584                         
1585                         }
1586                         
1587                         intSplitSize = 0;                                       
1588         
1589                 }
1591         }
1592         
1593         // Split the data into several parts.                   
1594         
1595         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1596         intiter != SplitPoints.end(); ++intiter){
1597                         
1598                 if (intiter->first == 1){
1599                 
1600                         // Deal with PO Box.
1601                         
1602                         SLiter = SplitLength.find(1);
1603                                                                 
1604                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1605                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1606                         intPrevValue = intiter->second;
1607                 
1608                 } else if (intiter->first == 2){
1609                 
1610                         // Deal with extended address.
1611                         
1612                         SLiter = SplitLength.find(2);
1613                         
1614                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1615                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1616                         intPrevValue = intiter->second;
1617                 
1618                 } else if (intiter->first == 3){
1619                 
1620                         // Deal with street address.
1621                         
1622                         SLiter = SplitLength.find(3);
1623                                                                 
1624                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1625                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1626                         intPrevValue = intiter->second;
1627                 
1628                 } else if (intiter->first == 4){
1629                 
1630                         // Deal with locality
1632                         SLiter = SplitLength.find(4);
1633                         
1634                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1635                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1636                         intPrevValue = intiter->second;
1637                         
1638                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1639                 
1640                 } else if (intiter->first == 5){
1641                 
1642                         // Deal with region.
1644                         SLiter = SplitLength.find(5);
1645                         
1646                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1647                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1648                         intPrevValue = intiter->second;
1649                         
1650                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1651                 
1652                 } else if (intiter->first == 6){
1653                 
1654                         // Deal with post code.
1656                         SLiter = SplitLength.find(6);
1657                         
1658                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1659                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1660                         intPrevValue = intiter->second;
1661                         
1662                         // Deal with country.
1663                                                 
1664                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1665                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1666                         
1667                         break;
1668                 
1669                 }
1670         
1671         }       
1672         
1673         // Add the data to the General/Home/Work address variables.
1674         
1675         CaptureString(&AddressStreet, FALSE); 
1676         CaptureString(&AddressLocality, FALSE);
1677         CaptureString(&AddressRegion, FALSE);
1678         CaptureString(&AddressPostalCode, FALSE);
1679         CaptureString(&AddressCountry, FALSE);
1680                 
1681         if (!PropertyTokens.IsEmpty()){
1682         
1683                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1684         
1685         }
1687         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1688         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1689         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1690         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1691         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1693         switch(PropType){
1694                 case PROPERTY_NONE:
1695                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1696                         break;
1697                 case PROPERTY_HOME:
1698                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1699                         break;
1700                 case PROPERTY_WORK:
1701                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1702                         break;
1703         }
1704         
1705         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1709 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1711         std::map<int, int> SplitPoints;
1712         std::map<int, int> SplitLength;
1714         int intPrevValue = 7;
1715         int intPref = 0;                        
1716         
1717         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1718         
1719         intPrevValue = 6;
1720         
1721         PropertyType PropType = PROPERTY_NONE;
1722                 
1723         // Look for type before continuing.
1724         
1725         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1726         
1727         std::map<int, wxString> *EmailList = NULL;
1728         std::map<int, wxString> *EmailListType = NULL;
1729         std::map<int, wxString> *EmailListAltID = NULL;
1730         std::map<int, wxString> *EmailListPID = NULL;
1731         std::map<int, wxString> *EmailListTokens = NULL;                
1732         std::map<int, int> *EmailListPref = NULL;
1734         switch(PropType){
1735                 case PROPERTY_NONE:
1736                         EmailList = &GeneralEmailList;
1737                         EmailListType = &GeneralEmailListType;
1738                         EmailListAltID = &GeneralEmailListAltID;
1739                         EmailListPID = &GeneralEmailListPID;
1740                         EmailListTokens = &GeneralEmailListTokens;              
1741                         EmailListPref = &GeneralEmailListPref;  
1742                         break;
1743                 case PROPERTY_HOME:
1744                         EmailList = &HomeEmailList;
1745                         EmailListType = &HomeEmailListType;
1746                         EmailListAltID = &HomeEmailListAltID;
1747                         EmailListPID = &HomeEmailListPID;
1748                         EmailListTokens = &HomeEmailListTokens;         
1749                         EmailListPref = &HomeEmailListPref;     
1750                         break;
1751                 case PROPERTY_WORK:
1752                         EmailList = &BusinessEmailList;
1753                         EmailListType = &BusinessEmailListType;
1754                         EmailListAltID = &BusinessEmailListAltID;
1755                         EmailListPID = &BusinessEmailListPID;
1756                         EmailListTokens = &BusinessEmailListTokens;             
1757                         EmailListPref = &BusinessEmailListPref; 
1758                         break;
1759         }
1760         
1761         intPrevValue = 6;
1762         
1763         std::map<int,int>::iterator SLiter;
1764         wxString PropertyData;
1765         wxString PropertyName;
1766         wxString PropertyValue;
1767         wxString PropertyTokens;
1768         bool FirstToken = TRUE;
1769         
1770         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1771         intiter != SplitPoints.end(); ++intiter){
1772         
1773                 SLiter = SplitLength.find(intiter->first);
1774         
1775                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1776                 
1777                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1778                 PropertyName = PropertyElement.GetNextToken();                          
1779                 PropertyValue = PropertyElement.GetNextToken();
1780                 
1781                 intPrevValue = intiter->second;
1782                 
1783                 CaptureString(&PropertyValue, FALSE);
1784                 
1785                 // Process properties.
1786                 
1787                 if (PropertyName == wxT("ALTID")){
1789                         EmailListAltID->erase(*EmailCount);
1790                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1791                 
1792                 } else if (PropertyName == wxT("PID")){
1794                         EmailListPID->erase(*EmailCount);
1795                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1796                 
1797                 } else if (PropertyName == wxT("PREF")){
1798                         
1799                         int PriorityNumber = 0;
1800                         bool ValidNumber = TRUE;
1801                         
1802                         try{
1803                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1804                         }
1805                         
1806                         catch(std::invalid_argument &e){
1807                                 ValidNumber = FALSE;
1808                         }
1810                         if (ValidNumber == TRUE){
1812                                 EmailListPref->erase(*EmailCount);
1813                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1815                         }
1816                 
1817                 } else {
1818                 
1819                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1820                         
1821                                 if (FirstToken == TRUE){
1822                                 
1823                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1824                                         FirstToken = FALSE;
1825                                 
1826                                 } else {
1827                                 
1828                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1829                                 
1830                                 }
1831                         
1832                         }
1833                 
1834                 }
1835         
1836         }
1837         
1838         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1839         
1840         // Add the name token data.
1841         
1842         if (!PropertyTokens.IsEmpty()){
1843         
1844                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1845         
1846         }       
1851 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1853         std::map<int, int> SplitPoints;
1854         std::map<int, int> SplitLength;
1856         int intPrevValue = 6;
1857         int intPref = 0;                        
1858         
1859         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1860         
1861         intPrevValue = 5;
1862         
1863         PropertyType PropType = PROPERTY_NONE;
1864                 
1865         // Look for type before continuing.
1866         
1867         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1868         
1869         std::map<int, wxString> *IMList = NULL;
1870         std::map<int, wxString> *IMListType = NULL;
1871         std::map<int, wxString> *IMListAltID = NULL;
1872         std::map<int, wxString> *IMListPID = NULL;
1873         std::map<int, wxString> *IMListTokens = NULL;
1874         std::map<int, wxString> *IMListMediatype = NULL;        
1875         std::map<int, int> *IMListPref = NULL;
1877         switch(PropType){
1878                 case PROPERTY_NONE:
1879                         IMList = &GeneralIMList;
1880                         IMListType = &GeneralIMListType;
1881                         IMListAltID = &GeneralIMListAltID;
1882                         IMListPID = &GeneralIMListPID;
1883                         IMListTokens = &GeneralIMListTokens;
1884                         IMListMediatype = &GeneralIMListMediatype;
1885                         IMListPref = &GeneralIMListPref;        
1886                         break;
1887                 case PROPERTY_HOME:
1888                         IMList = &HomeIMList;
1889                         IMListType = &HomeIMListType;
1890                         IMListAltID = &HomeIMListAltID;
1891                         IMListPID = &HomeIMListPID;
1892                         IMListTokens = &HomeIMListTokens;
1893                         IMListMediatype = &HomeIMListMediatype;         
1894                         IMListPref = &HomeIMListPref;   
1895                         break;
1896                 case PROPERTY_WORK:
1897                         IMList = &BusinessIMList;
1898                         IMListType = &BusinessIMListType;
1899                         IMListAltID = &BusinessIMListAltID;
1900                         IMListPID = &BusinessIMListPID;
1901                         IMListTokens = &BusinessIMListTokens;   
1902                         IMListMediatype = &BusinessIMListMediatype;     
1903                         IMListPref = &BusinessIMListPref;       
1904                         break;
1905         }
1906         
1907         intPrevValue = 5;
1908         
1909         std::map<int,int>::iterator SLiter;
1910         wxString PropertyData;
1911         wxString PropertyName;
1912         wxString PropertyValue;
1913         wxString PropertyTokens;
1914         bool FirstToken = TRUE;
1915         
1916         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1917         intiter != SplitPoints.end(); ++intiter){
1918         
1919                 SLiter = SplitLength.find(intiter->first);
1920         
1921                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1922                 
1923                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1924                 PropertyName = PropertyElement.GetNextToken();                          
1925                 PropertyValue = PropertyElement.GetNextToken();
1926                 
1927                 intPrevValue = intiter->second;
1928                 
1929                 CaptureString(&PropertyValue, FALSE);
1930                 
1931                 // Process properties.
1932                 
1933                 if (PropertyName == wxT("ALTID")){
1935                         IMListAltID->erase(*IMCount);
1936                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1937                 
1938                 } else if (PropertyName == wxT("PID")){
1940                         IMListPID->erase(*IMCount);
1941                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1942                 
1943                 } else if (PropertyName == wxT("MEDIATYPE")){
1945                         IMListMediatype->erase(*IMCount);
1946                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1947                 
1948                 } else if (PropertyName == wxT("PREF")){
1949                         
1950                         int PriorityNumber = 0;
1951                         bool ValidNumber = TRUE;
1952                         
1953                         try{
1954                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1955                         }
1956                         
1957                         catch(std::invalid_argument &e){
1958                                 ValidNumber = FALSE;
1959                         }
1961                         if (ValidNumber == TRUE){
1963                                 IMListPref->erase(*IMCount);
1964                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1966                         }
1967                 
1968                 } else {
1969                 
1970                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1971                         
1972                                 if (FirstToken == TRUE){
1973                                 
1974                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1975                                         FirstToken = FALSE;
1976                                 
1977                                 } else {
1978                                 
1979                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1980                                 
1981                                 }
1982                         
1983                         }
1984                 
1985                 }
1986         
1987         }
1988                 
1989         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1990         
1991         // Add the name token data.
1992         
1993         if (!PropertyTokens.IsEmpty()){
1994         
1995                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1996         
1997         }
2001 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2003         std::map<int, int> SplitPoints;
2004         std::map<int, int> SplitLength;
2005         std::map<int, int>::iterator SLiter;
2006         
2007         int intPref = 0;
2008         
2009         PropertyType PropType = PROPERTY_NONE;
2010                 
2011         // Look for type before continuing.
2012         
2013         wxString TelTypeUI;
2014         wxString TelTypeDetail;
2015         wxString PropertyData;
2016         wxString PropertyName;
2017         wxString PropertyValue;
2018         wxString PropertyTokens;
2019         
2020         std::map<int,int> TypeSplitPoints;
2021         std::map<int,int> TypeSplitLength;
2022         std::map<int,int>::iterator TSLiter;
2023         
2024         int intSplitSize = 0;
2025         int intSplitsFound = 0;
2026         int intSplitPoint = 0;
2027         int intType = 0;
2028         int intPrevValue = 5;
2029                 
2030         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2031         
2032         intPrevValue = 4;
2033         
2034         // Look for type before continuing.
2035         
2036         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2037         intiter != SplitPoints.end(); ++intiter){
2038         
2039                 SLiter = SplitLength.find(intiter->first);
2040         
2041                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2042                 
2043                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2044                 PropertyName = PropertyElement.GetNextToken();                          
2045                 PropertyValue = PropertyElement.GetNextToken();
2046                 
2047                 intPrevValue = intiter->second;
2049                 if (PropertyName == wxT("TYPE")){
2050                 
2051                         // Process each value in type and translate each
2052                         // part.
2053                 
2054                         // Strip out the quotes if they are there.
2055                 
2056                         size_t intPropertyValueLen = PropertyValue.Len();
2057                 
2058                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2059                         
2060                                 PropertyValue.Trim();
2061                                 PropertyValue.RemoveLast();
2062                         
2063                         }                               
2064                 
2065                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2066                         
2067                                 PropertyValue.Remove(0, 1);
2068                         
2069                         }
2070                         
2071                         TelTypeDetail = PropertyValue;
2072                         
2073                         intSplitSize = 0;
2074                         intSplitsFound = 0;
2075                         intSplitPoint = 0;
2076                         
2077                         for (int i = 0; i <= intPropertyValueLen; i++){
2078         
2079                                 intSplitSize++;
2080         
2081                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2082         
2083                                         if (intSplitsFound == 0){
2085                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2086                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2087                         
2088                                         } else {
2089                         
2090                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2091                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2092                         
2093                                         }                       
2095                                         intSplitsFound++;
2096                                         i++;
2097                                         intSplitPoint = i;
2098                                         intSplitSize = 0;
2099         
2100                                 }
2101         
2102                         }
2103                         
2104                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2105                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2106                 
2107                         int intTypeSeek = 0;
2108                 
2109                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2110                         typeiter != TypeSplitPoints.end(); ++typeiter){
2111                         
2112                                 wxString TypePropertyName;
2113                                 
2114                                 TSLiter = TypeSplitLength.find(typeiter->first);
2115                                 
2116                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2117                                 
2118                                 if (intTypeSeek == 0){
2119                                 
2120                                 
2121                                 } else {
2122                                                                                 
2123                                         TelTypeUI.Append(wxT(","));                                                     
2124                                 
2125                                 }
2126                         
2127                                 if (TypePropertyName == wxT("home")){
2128                                 
2129                                         PropType = PROPERTY_HOME;
2130                                 
2131                                 } else if (TypePropertyName == wxT("work")){
2132                                 
2133                                         PropType = PROPERTY_WORK;
2134                                                                         
2135                                 }
2136                                 
2137                                 
2138                                 if (TypePropertyName == wxT("text")){
2139                                 
2140                                         TelTypeUI.Append(_("text"));
2141                                         intTypeSeek++;
2142                                 
2143                                 } else if (TypePropertyName == wxT("voice")){
2144                                 
2145                                         TelTypeUI.Append(_("voice"));
2146                                         intTypeSeek++;
2147                                 
2148                                 } else if (TypePropertyName == wxT("fax")){
2149                                 
2150                                         TelTypeUI.Append(_("fax"));
2151                                         intTypeSeek++;
2152                                 
2153                                 } else if (TypePropertyName == wxT("cell")){
2154                                 
2155                                         TelTypeUI.Append(_("mobile"));
2156                                         intTypeSeek++;
2157                                 
2158                                 } else if (TypePropertyName == wxT("video")){
2159                                 
2160                                         TelTypeUI.Append(_("video"));
2161                                         intTypeSeek++;
2162                                 
2163                                 } else if (TypePropertyName == wxT("pager")){
2164                                 
2165                                         TelTypeUI.Append(_("pager"));
2166                                         intTypeSeek++;
2167                                 
2168                                 } else if (TypePropertyName == wxT("textphone")){
2169                                 
2170                                         TelTypeUI.Append(_("textphone"));
2171                                         intTypeSeek++;
2172                                 
2173                                 }
2174                         
2175                         }
2176                 
2177                 }
2178                 
2179         }
2180         
2181         std::map<int, wxString> *TelephoneList = NULL;
2182         std::map<int, wxString> *TelephoneListType = NULL;
2183         std::map<int, wxString> *TelephoneListAltID = NULL;
2184         std::map<int, wxString> *TelephoneListPID = NULL;
2185         std::map<int, wxString> *TelephoneListTokens = NULL;
2186         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2187         std::map<int, int> *TelephoneListPref = NULL;
2189         switch(PropType){
2190                 case PROPERTY_NONE:
2191                         TelephoneList = &GeneralTelephoneList;
2192                         TelephoneListType = &GeneralTelephoneListType;
2193                         TelephoneListAltID = &GeneralTelephoneListAltID;
2194                         TelephoneListPID = &GeneralTelephoneListPID;
2195                         TelephoneListTokens = &GeneralTelephoneListTokens;
2196                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2197                         TelephoneListPref = &GeneralTelephoneListPref;  
2198                         break;
2199                 case PROPERTY_HOME:
2200                         TelephoneList = &HomeTelephoneList;
2201                         TelephoneListType = &HomeTelephoneListType;
2202                         TelephoneListAltID = &HomeTelephoneListAltID;
2203                         TelephoneListPID = &HomeTelephoneListPID;
2204                         TelephoneListTokens = &HomeTelephoneListTokens;
2205                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2206                         TelephoneListPref = &HomeTelephoneListPref;     
2207                         break;
2208                 case PROPERTY_WORK:
2209                         TelephoneList = &BusinessTelephoneList;
2210                         TelephoneListType = &BusinessTelephoneListType;
2211                         TelephoneListAltID = &BusinessTelephoneListAltID;
2212                         TelephoneListPID = &BusinessTelephoneListPID;
2213                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2214                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2215                         TelephoneListPref = &BusinessTelephoneListPref; 
2216                         break;
2217         }
2218                 
2219         // Process the properties.
2220         
2221         bool FirstToken = TRUE;
2222         
2223         intPrevValue = 5;
2224         SplitPoints.clear();
2225         SplitLength.clear();
2227         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2229         intPrevValue = 4;
2230         
2231         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2232         intiter != SplitPoints.end(); ++intiter){
2233         
2234                 SLiter = SplitLength.find(intiter->first);
2235         
2236                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2237                 
2238                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2239                 PropertyName = PropertyElement.GetNextToken();                          
2240                 PropertyValue = PropertyElement.GetNextToken();
2241                 
2242                 intPrevValue = intiter->second;
2243                 
2244                 CaptureString(&PropertyValue, FALSE);
2245                 
2246                 // Process properties.
2247                 
2248                 if (PropertyName == wxT("ALTID")){
2250                         TelephoneListAltID->erase(*TelephoneCount);
2251                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2252                 
2253                 } else if (PropertyName == wxT("PID")){
2255                         TelephoneListPID->erase(*TelephoneCount);
2256                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2257                 
2258                 } else if (PropertyName == wxT("PREF")){
2259                         
2260                         int PriorityNumber = 0;
2261                         bool ValidNumber = TRUE;
2262                         
2263                         try{
2264                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2265                         }
2266                         
2267                         catch(std::invalid_argument &e){
2268                                 ValidNumber = FALSE;
2269                         }
2271                         if (ValidNumber == TRUE){
2273                                 TelephoneListPref->erase(*TelephoneCount);
2274                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2276                         }
2277                 
2278                 } else {
2279                 
2280                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2281                         
2282                                 if (FirstToken == TRUE){
2283                                 
2284                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2285                                         FirstToken = FALSE;
2286                                 
2287                                 } else {
2288                                 
2289                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2290                                 
2291                                 }
2292                         
2293                         }
2294                 
2295                 }
2296         
2297         }
2298                 
2299         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2300         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2301         
2302         // Add the name token data.
2303         
2304         if (!PropertyTokens.IsEmpty()){
2305         
2306                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2307         
2308         }
2312 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2314         std::map<int, int> SplitPoints;
2315         std::map<int, int> SplitLength;
2317         int intPrevValue = 6;
2318         int intPref = 0;                        
2319         
2320         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2321         
2322         intPrevValue = 5;
2323         
2324         PropertyType PropType = PROPERTY_NONE;
2325                 
2326         // Look for type before continuing.
2327         
2328         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2329         
2330         std::map<int, wxString> *LanguageList = NULL;
2331         std::map<int, wxString> *LanguageListType = NULL;
2332         std::map<int, wxString> *LanguageListAltID = NULL;
2333         std::map<int, wxString> *LanguageListPID = NULL;
2334         std::map<int, wxString> *LanguageListTokens = NULL;
2335         std::map<int, int> *LanguageListPref = NULL;
2337         switch(PropType){
2338                 case PROPERTY_NONE:
2339                         LanguageList = &GeneralLanguageList;
2340                         LanguageListType = &GeneralLanguageListType;
2341                         LanguageListAltID = &GeneralLanguageListAltID;
2342                         LanguageListPID = &GeneralLanguageListPID;
2343                         LanguageListTokens = &GeneralLanguageListTokens;
2344                         LanguageListPref = &GeneralLanguageListPref;    
2345                         break;
2346                 case PROPERTY_HOME:
2347                         LanguageList = &HomeLanguageList;
2348                         LanguageListType = &HomeLanguageListType;
2349                         LanguageListAltID = &HomeLanguageListAltID;
2350                         LanguageListPID = &HomeLanguageListPID;
2351                         LanguageListTokens = &HomeLanguageListTokens;   
2352                         LanguageListPref = &HomeLanguageListPref;       
2353                         break;
2354                 case PROPERTY_WORK:
2355                         LanguageList = &BusinessLanguageList;
2356                         LanguageListType = &BusinessLanguageListType;
2357                         LanguageListAltID = &BusinessLanguageListAltID;
2358                         LanguageListPID = &BusinessLanguageListPID;
2359                         LanguageListTokens = &BusinessLanguageListTokens;       
2360                         LanguageListPref = &BusinessLanguageListPref;
2361                         break;
2362         }
2363         
2364         intPrevValue = 5;
2365         
2366         std::map<int,int>::iterator SLiter;
2367         wxString PropertyData;
2368         wxString PropertyName;
2369         wxString PropertyValue;
2370         wxString PropertyTokens;
2371         bool FirstToken = TRUE;
2372         
2373         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2374         intiter != SplitPoints.end(); ++intiter){
2375         
2376                 SLiter = SplitLength.find(intiter->first);
2377         
2378                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2379                 
2380                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2381                 PropertyName = PropertyElement.GetNextToken();                          
2382                 PropertyValue = PropertyElement.GetNextToken();
2383                 
2384                 intPrevValue = intiter->second;
2385                 
2386                 CaptureString(&PropertyValue, FALSE);
2387                 
2388                 // Process properties.
2389                 
2390                 if (PropertyName == wxT("ALTID")){
2392                         LanguageListAltID->erase(*LanguageCount);
2393                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2394                 
2395                 } else if (PropertyName == wxT("PID")){
2397                         LanguageListPID->erase(*LanguageCount);
2398                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2399                 
2400                 } else if (PropertyName == wxT("PREF")){
2401                         
2402                         int PriorityNumber = 0;
2403                         bool ValidNumber = TRUE;
2404                         
2405                         try{
2406                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2407                         }
2408                         
2409                         catch(std::invalid_argument &e){
2410                                 ValidNumber = FALSE;
2411                         }
2413                         if (ValidNumber == TRUE){
2415                                 LanguageListPref->erase(*LanguageCount);
2416                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2418                         }
2419                 
2420                 } else {
2421                 
2422                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2423                         
2424                                 if (FirstToken == TRUE){
2425                                 
2426                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2427                                         FirstToken = FALSE;
2428                                 
2429                                 } else {
2430                                 
2431                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2432                                 
2433                                 }
2434                         
2435                         }
2436                 
2437                 }
2438         
2439         }
2440                 
2441         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2442         
2443         // Add the name token data.
2444         
2445         if (!PropertyTokens.IsEmpty()){
2446         
2447                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2448         
2449         }
2453 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2455         std::map<int, int> SplitPoints;
2456         std::map<int, int> SplitLength;
2458         int intPrevValue = 5;
2459         int intPref = 0;                        
2460         
2461         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2462         
2463         intPrevValue = 4;
2464         
2465         PropertyType PropType = PROPERTY_NONE;
2466                 
2467         // Look for type before continuing.
2468         
2469         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2470         
2471         std::map<int, wxString> *GeopositionList = NULL;
2472         std::map<int, wxString> *GeopositionListType = NULL;
2473         std::map<int, wxString> *GeopositionListAltID = NULL;
2474         std::map<int, wxString> *GeopositionListPID = NULL;
2475         std::map<int, wxString> *GeopositionListTokens = NULL;
2476         std::map<int, wxString> *GeopositionListMediatype = NULL;
2477         std::map<int, int> *GeopositionListPref = NULL;
2479         switch(PropType){
2480                 case PROPERTY_NONE:
2481                         GeopositionList = &GeneralGeographyList;
2482                         GeopositionListType = &GeneralGeographyListType;
2483                         GeopositionListAltID = &GeneralGeographyListAltID;
2484                         GeopositionListPID = &GeneralGeographyListPID;
2485                         GeopositionListTokens = &GeneralGeographyListTokens;
2486                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2487                         GeopositionListPref = &GeneralGeographyListPref;        
2488                         break;
2489                 case PROPERTY_HOME:
2490                         GeopositionList = &HomeGeographyList;
2491                         GeopositionListType = &HomeGeographyListType;
2492                         GeopositionListAltID = &HomeGeographyListAltID;
2493                         GeopositionListPID = &HomeGeographyListPID;
2494                         GeopositionListTokens = &HomeGeographyListTokens;
2495                         GeopositionListMediatype = &HomeGeographyListMediatype;
2496                         GeopositionListPref = &HomeGeographyListPref;   
2497                         break;
2498                 case PROPERTY_WORK:
2499                         GeopositionList = &BusinessGeographyList;
2500                         GeopositionListType = &BusinessGeographyListType;
2501                         GeopositionListAltID = &BusinessGeographyListAltID;
2502                         GeopositionListPID = &BusinessGeographyListPID;
2503                         GeopositionListTokens = &BusinessGeographyListTokens;
2504                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2505                         GeopositionListPref = &BusinessGeographyListPref;
2506                         break;
2507         }
2508         
2509         intPrevValue = 4;
2510         
2511         std::map<int,int>::iterator SLiter;
2512         wxString PropertyData;
2513         wxString PropertyName;
2514         wxString PropertyValue;
2515         wxString PropertyTokens;
2516         bool FirstToken = TRUE;
2517         
2518         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2519         intiter != SplitPoints.end(); ++intiter){
2520         
2521                 SLiter = SplitLength.find(intiter->first);
2522         
2523                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2524                 
2525                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2526                 PropertyName = PropertyElement.GetNextToken();                          
2527                 PropertyValue = PropertyElement.GetNextToken();
2528                 
2529                 intPrevValue = intiter->second;
2530                 
2531                 CaptureString(&PropertyValue, FALSE);
2532                 
2533                 // Process properties.
2534                 
2535                 if (PropertyName == wxT("ALTID")){
2537                         GeopositionListAltID->erase(*GeographicCount);
2538                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2539                 
2540                 } else if (PropertyName == wxT("PID")){
2542                         GeopositionListPID->erase(*GeographicCount);
2543                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2544                 
2545                 } else if (PropertyName == wxT("MEDIATYPE")){
2547                         GeopositionListMediatype->erase(*GeographicCount);
2548                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2549                 
2550                 } else if (PropertyName == wxT("PREF")){
2551                         
2552                         int PriorityNumber = 0;
2553                         bool ValidNumber = TRUE;
2554                         
2555                         try{
2556                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2557                         }
2558                         
2559                         catch(std::invalid_argument &e){
2560                                 ValidNumber = FALSE;
2561                         }
2563                         if (ValidNumber == TRUE){
2565                                 GeopositionListPref->erase(*GeographicCount);
2566                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2568                         }
2569                 
2570                 } else {
2571                 
2572                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2573                         
2574                                 if (FirstToken == TRUE){
2575                                 
2576                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2577                                         FirstToken = FALSE;
2578                                 
2579                                 } else {
2580                                 
2581                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2582                                 
2583                                 }
2584                         
2585                         }
2586                 
2587                 }
2588         
2589         }
2590                 
2591         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2592         
2593         // Add the name token data.
2594         
2595         if (!PropertyTokens.IsEmpty()){
2596         
2597                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2598         
2599         }
2603 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2605         size_t intPropertyLen = PropertySeg1.Len();
2606         std::map<int, int> SplitPoints;
2607         std::map<int, int> SplitLength;
2608         std::map<int, int>::iterator SLiter;                    
2609         wxString PropertyData;
2610         wxString PropertyName;
2611         wxString PropertyValue;
2612         wxString PropertyTokens;
2613         wxString RelatedType;
2614         wxString RelatedTypeOriginal;                   
2615         wxString RelatedName;
2616         bool FirstToken = TRUE;                 
2617         int intSplitsFound = 0;
2618         int intSplitSize = 0;
2619         int intPrevValue = 9;
2620         int intPref = 0;
2621         long ListCtrlIndex;
2622         
2623         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2624         
2625         intPrevValue = 8;
2626         
2627         // Look for type before continuing.
2628         
2629         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2630         intiter != SplitPoints.end(); ++intiter){
2631         
2632                 SLiter = SplitLength.find(intiter->first);
2633         
2634                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2635                 
2636                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2637                 PropertyName = PropertyElement.GetNextToken();                          
2638                 PropertyValue = PropertyElement.GetNextToken();
2639                 
2640                 intPrevValue = intiter->second;
2641                 
2642                 // Process these.
2643                 
2644                 RelatedTypeOriginal = PropertyValue;
2645                 
2646                 if (PropertyName == wxT("TYPE")){
2647                 
2648                         if (PropertyValue == wxT("contact")){
2650                                 RelatedType = _("Contact");
2652                         } else if (PropertyValue == wxT("acquaintance")){
2654                                 RelatedType = _("Acquaintance");
2656                         } else if (PropertyValue == wxT("friend")){
2658                                 RelatedType = _("Friend");
2660                         } else if (PropertyValue == wxT("met")){
2662                                 RelatedType = _("Met");
2664                         } else if (PropertyValue == wxT("co-worker")){
2666                                 RelatedType = _("Co-worker");
2668                         } else if (PropertyValue == wxT("colleague")){
2670                                 RelatedType = _("Colleague");
2672                         } else if (PropertyValue == wxT("co-resident")){
2674                                 RelatedType = _("Co-resident");
2676                         } else if (PropertyValue == wxT("neighbor")){
2678                                 RelatedType = _("Neighbour");
2680                         } else if (PropertyValue == wxT("child")){
2682                                 RelatedType = _("Child");
2684                         } else if (PropertyValue == wxT("parent")){
2686                                 RelatedType = _("Parent");
2688                         } else if (PropertyValue == wxT("sibling")){
2690                                 RelatedType = _("Sibling");
2692                         } else if (PropertyValue == wxT("spouse")){
2694                                 RelatedType = _("Spouse");
2696                         } else if (PropertyValue == wxT("kin")){
2698                                 RelatedType = _("Kin");
2700                         } else if (PropertyValue == wxT("muse")){
2702                                 RelatedType = _("Muse");
2704                         } else if (PropertyValue == wxT("crush")){
2706                                 RelatedType = _("Crush");
2708                         } else if (PropertyValue == wxT("date")){
2710                                 RelatedType = _("Date");
2712                         } else if (PropertyValue == wxT("sweetheart")){
2714                                 RelatedType = _("Sweetheart");
2716                         } else if (PropertyValue == wxT("me")){
2718                                 RelatedType = _("Me");
2720                         } else if (PropertyValue == wxT("agent")){
2722                                 RelatedType = _("Agent");
2724                         } else if (PropertyValue == wxT("emergency")){
2726                                 RelatedType = _("Emergency");
2728                         } else {
2730                                 RelatedType = PropertyValue;
2732                         }
2733                 
2734                 }
2735         
2736         }
2737         
2738         intPrevValue = 8;                       
2739         
2740         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2741         intiter != SplitPoints.end(); ++intiter){
2742         
2743                 SLiter = SplitLength.find(intiter->first);
2744         
2745                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2746                 
2747                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2748                 PropertyName = PropertyElement.GetNextToken();                          
2749                 PropertyValue = PropertyElement.GetNextToken();
2750                 
2751                 intPrevValue = intiter->second;
2752                 
2753                 // Process properties.
2754                 
2755                 size_t intPropertyValueLen = PropertyValue.Len();
2756                 
2757                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2758                         
2759                         PropertyValue.Trim();
2760                         PropertyValue.RemoveLast();
2761                         
2762                 }                               
2763                 
2764                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2765                         
2766                         PropertyValue.Remove(0, 1);
2767                         
2768                 }
2769                 
2770                 CaptureString(&PropertyValue, FALSE);
2771                         
2772                 if (PropertyName == wxT("ALTID")){
2774                         GeneralRelatedListAltID.erase(*RelatedCount);
2775                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2776                 
2777                 } else if (PropertyName == wxT("PID")){
2779                         GeneralRelatedListPID.erase(*RelatedCount);
2780                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2781                 
2782                 } else if (PropertyName == wxT("PREF")){
2783                         
2784                         int PriorityNumber = 0;
2785                         bool ValidNumber = TRUE;
2786                         
2787                         try{
2788                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2789                         }
2790                         
2791                         catch(std::invalid_argument &e){
2792                                 ValidNumber = FALSE;
2793                         }
2795                         if (ValidNumber == TRUE){
2797                                 GeneralRelatedListPref.erase(*RelatedCount);
2798                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2800                         }
2801                 
2802                 } else if (PropertyName == wxT("LANGUAGE")){
2803                 
2804                         GeneralRelatedListLanguage.erase(*RelatedCount);
2805                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2806                 
2807                 } else if (PropertyName != wxT("TYPE")) {
2808                 
2809                         // Something else we don't know about so append
2810                         // to the tokens variable.
2811                 
2812                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2813                 
2814                                 if (FirstToken == TRUE){
2815                         
2816                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2817                                         FirstToken = FALSE;
2818                         
2819                                 } else {
2820                         
2821                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2822                         
2823                                 }
2824                 
2825                         }
2826                 
2827                 }
2828         
2829         }                                       
2830         
2831         // Add the data to the General/Home/Work address variables.
2832                                 
2833         GeneralRelatedList.erase(*RelatedCount);
2834         GeneralRelatedListRelType.erase(*RelatedCount);
2835         GeneralRelatedListType.erase(*RelatedCount);
2836         GeneralRelatedListTokens.erase(*RelatedCount);
2837         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2838         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2839         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2840         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2844 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2846         std::map<int, int> SplitPoints;
2847         std::map<int, int> SplitLength;
2848         std::map<int, int>::iterator SLiter;                    
2849         wxString PropertyData;
2850         wxString PropertyName;
2851         wxString PropertyValue;
2852         wxString PropertyTokens;
2853         bool FirstToken = TRUE;
2854         int intPrevValue = 5;
2855         int intPref = 0;                        
2856         int intType = 0;
2857         long ListCtrlIndex;
2858         
2859         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2860         
2861         intPrevValue = 4;
2862         
2863         PropertyType PropType = PROPERTY_NONE;
2864                 
2865         // Look for type before continuing.
2866         
2867         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2868         
2869         // Setup the pointers.
2870         
2871         std::map<int, wxString> *WebsiteList = NULL;
2872         std::map<int, wxString> *WebsiteListAltID = NULL;
2873         std::map<int, wxString> *WebsiteListPID = NULL;
2874         std::map<int, wxString> *WebsiteListType = NULL;
2875         std::map<int, wxString> *WebsiteListTokens = NULL;
2876         std::map<int, wxString> *WebsiteListMediatype = NULL;
2877         std::map<int, int> *WebsiteListPref = NULL;
2878         
2879         // Setup blank lines for later on.
2880         
2881         switch(PropType){
2882                 case PROPERTY_NONE:
2883                         WebsiteList = &GeneralWebsiteList;
2884                         WebsiteListType = &GeneralWebsiteListType;
2885                         WebsiteListAltID = &GeneralWebsiteListAltID;
2886                         WebsiteListPID = &GeneralWebsiteListPID;
2887                         WebsiteListTokens = &GeneralWebsiteListTokens;
2888                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2889                         WebsiteListPref = &GeneralWebsiteListPref;      
2890                         break;
2891                 case PROPERTY_HOME:
2892                         WebsiteList = &HomeWebsiteList;
2893                         WebsiteListType = &HomeWebsiteListType;
2894                         WebsiteListAltID = &HomeWebsiteListAltID;
2895                         WebsiteListPID = &HomeWebsiteListPID;
2896                         WebsiteListTokens = &HomeWebsiteListTokens;
2897                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2898                         WebsiteListPref = &HomeWebsiteListPref; 
2899                         break;
2900                 case PROPERTY_WORK:
2901                         WebsiteList = &BusinessWebsiteList;
2902                         WebsiteListType = &BusinessWebsiteListType;
2903                         WebsiteListAltID = &BusinessWebsiteListAltID;
2904                         WebsiteListPID = &BusinessWebsiteListPID;
2905                         WebsiteListTokens = &BusinessWebsiteListTokens;
2906                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2907                         WebsiteListPref = &BusinessWebsiteListPref;
2908                         break;
2909         }
2910         
2911         intPrevValue = 4;
2912         
2913         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2914         intiter != SplitPoints.end(); ++intiter){
2915         
2916                 SLiter = SplitLength.find(intiter->first);
2917         
2918                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2919                 
2920                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2921                 PropertyName = PropertyElement.GetNextToken();                          
2922                 PropertyValue = PropertyElement.GetNextToken();
2923                 
2924                 intPrevValue = intiter->second;
2925                 
2926                 // Process properties.
2927                 
2928                 size_t intPropertyValueLen = PropertyValue.Len();
2929                 
2930                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2931                         
2932                         PropertyValue.Trim();
2933                         PropertyValue.RemoveLast();
2934                         
2935                 }                               
2936                 
2937                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2938                         
2939                         PropertyValue.Remove(0, 1);
2940                         
2941                 }
2942                 
2943                 CaptureString(&PropertyValue, FALSE);
2944                 
2945                 if (PropertyName == wxT("ALTID")){
2947                         WebsiteListAltID->erase(*URLCount);
2948                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2949                 
2950                 } else if (PropertyName == wxT("PID")){
2952                         WebsiteListPID->erase(*URLCount);
2953                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2954                         
2955                 } else if (PropertyName == wxT("PREF")){
2956                         
2957                         int PriorityNumber = 0;
2958                         bool ValidNumber = TRUE;
2959                         
2960                         try{
2961                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2962                         }
2963                         
2964                         catch(std::invalid_argument &e){
2965                                 ValidNumber = FALSE;
2966                         }
2968                         if (ValidNumber == TRUE){
2970                                 WebsiteListPref->erase(*URLCount);
2971                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2973                         }
2974                                         
2975                 } else if (PropertyName == wxT("MEDIATYPE")){
2976                 
2977                         WebsiteListMediatype->erase(*URLCount);
2978                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2979                 
2980                 } else {
2981                 
2982                         // Something else we don't know about so append
2983                         // to the tokens variable.
2984                 
2985                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2986                 
2987                                 if (FirstToken == TRUE){
2988                         
2989                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2990                                         FirstToken = FALSE;
2991                         
2992                                 } else {
2993                         
2994                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2995                         
2996                                 }
2997                 
2998                         }
2999                 
3000                 }
3001         
3002         }
3003         
3004         // Add the data to the General/Home/Work address variables.
3005         
3006         CaptureString(&PropertySeg2, FALSE);
3007                         
3008         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3009         
3010         if (!PropertyTokens.IsEmpty()){
3011         
3012                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3013                         
3014         }
3015         
3018 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3020         std::map<int, int> SplitPoints;
3021         std::map<int, int> SplitLength;
3022         std::map<int, int>::iterator SLiter;                    
3023         wxString PropertyData;
3024         wxString PropertyName;
3025         wxString PropertyValue;
3026         wxString PropertyTokens;
3027         bool FirstToken = TRUE;
3028         int intPrevValue = 7;
3029         int intPref = 0;                        
3030         int intType = 0;
3031         long ListCtrlIndex;
3032         
3033         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3034         
3035         intPrevValue = 6;
3036         
3037         PropertyType PropType = PROPERTY_NONE;
3038                 
3039         // Look for type before continuing.
3040         
3041         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3042         
3043         // Setup the pointers.
3044         
3045         std::map<int, wxString> *TitleList = NULL;
3046         std::map<int, wxString> *TitleListAltID = NULL;
3047         std::map<int, wxString> *TitleListPID = NULL;
3048         std::map<int, wxString> *TitleListType = NULL;
3049         std::map<int, wxString> *TitleListTokens = NULL;
3050         std::map<int, wxString> *TitleListLanguage = NULL;
3051         std::map<int, int> *TitleListPref = NULL;
3052         
3053         // Setup blank lines for later on.
3054         
3055         switch(PropType){
3056                 case PROPERTY_NONE:
3057                         TitleList = &GeneralTitleList;
3058                         TitleListType = &GeneralTitleListType;
3059                         TitleListAltID = &GeneralTitleListAltID;
3060                         TitleListPID = &GeneralTitleListPID;
3061                         TitleListTokens = &GeneralTitleListTokens;
3062                         TitleListLanguage = &GeneralTitleListLanguage;
3063                         TitleListPref = &GeneralTitleListPref;  
3064                         break;
3065                 case PROPERTY_HOME:
3066                         TitleList = &HomeTitleList;
3067                         TitleListType = &HomeTitleListType;
3068                         TitleListAltID = &HomeTitleListAltID;
3069                         TitleListPID = &HomeTitleListPID;
3070                         TitleListTokens = &HomeTitleListTokens;
3071                         TitleListLanguage = &HomeTitleListLanguage;
3072                         TitleListPref = &HomeTitleListPref;     
3073                         break;
3074                 case PROPERTY_WORK:
3075                         TitleList = &BusinessTitleList;
3076                         TitleListType = &BusinessTitleListType;
3077                         TitleListAltID = &BusinessTitleListAltID;
3078                         TitleListPID = &BusinessTitleListPID;
3079                         TitleListTokens = &BusinessTitleListTokens;
3080                         TitleListLanguage = &BusinessTitleListLanguage; 
3081                         TitleListPref = &BusinessTitleListPref;
3082                         break;
3083         }
3085         intPrevValue = 6;
3086                 
3087         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3088         intiter != SplitPoints.end(); ++intiter){
3089         
3090                 SLiter = SplitLength.find(intiter->first);
3091         
3092                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3093                 
3094                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3095                 PropertyName = PropertyElement.GetNextToken();                          
3096                 PropertyValue = PropertyElement.GetNextToken();
3097                 
3098                 intPrevValue = intiter->second;
3099                 
3100                 // Process properties.
3101                 
3102                 size_t intPropertyValueLen = PropertyValue.Len();
3103                 
3104                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3105                         
3106                         PropertyValue.Trim();
3107                         PropertyValue.RemoveLast();
3108                         
3109                 }                               
3110                 
3111                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3112                         
3113                         PropertyValue.Remove(0, 1);
3114                         
3115                 }                               
3116                 
3117                 CaptureString(&PropertyValue, FALSE);
3118                 
3119                 if (PropertyName == wxT("ALTID")){
3120                 
3121                         TitleListAltID->erase(*TitleCount);
3122                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3123                 
3124                 } else if (PropertyName == wxT("PID")){
3126                         TitleListPID->erase(*TitleCount);
3127                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3128                 
3129                 } else if (PropertyName == wxT("PREF")){
3130                                 
3131                         int PriorityNumber = 0;
3132                         bool ValidNumber = TRUE;
3133                         
3134                         try{
3135                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3136                         }
3137                         
3138                         catch(std::invalid_argument &e){
3139                                 ValidNumber = FALSE;
3140                         }
3142                         if (ValidNumber == TRUE){
3144                                 TitleListPref->erase(*TitleCount);
3145                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3147                         }
3148                                         
3149                 } else if (PropertyName == wxT("LANGUAGE")){
3150                 
3151                         TitleListLanguage->erase(*TitleCount);
3152                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3153                 
3154                 } else {
3155                 
3156                         // Something else we don't know about so append
3157                         // to the tokens variable.
3158                 
3159                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3160                 
3161                                 if (FirstToken == TRUE){
3162                         
3163                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3164                                         FirstToken = FALSE;
3165                         
3166                                 } else {
3167                         
3168                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3169                         
3170                                 }
3171                 
3172                         }
3173                 
3174                 }
3175         
3176         }
3177         
3178         // Add the data to the General/Home/Work address variables.
3179         
3180         CaptureString(&PropertySeg2, FALSE);
3182         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3183         
3184         if (!PropertyTokens.IsEmpty()){
3185         
3186                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3187                         
3188         }
3192 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3194         std::map<int, int> SplitPoints;
3195         std::map<int, int> SplitLength;
3196         std::map<int, int>::iterator SLiter;                    
3197         wxString PropertyData;
3198         wxString PropertyName;
3199         wxString PropertyValue;
3200         wxString PropertyTokens;
3201         bool FirstToken = TRUE;
3202         int intPrevValue = 6;
3203         int intPref = 0;                        
3204         int intType = 0;
3205         long ListCtrlIndex;
3206         
3207         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3208         
3209         intPrevValue = 5;
3210         
3211         PropertyType PropType = PROPERTY_NONE;
3212                 
3213         // Look for type before continuing.
3214         
3215         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3216         
3217         // Setup the pointers.
3218         
3219         std::map<int, wxString> *RoleList = NULL;
3220         std::map<int, wxString> *RoleListAltID = NULL;
3221         std::map<int, wxString> *RoleListPID = NULL;
3222         std::map<int, wxString> *RoleListType = NULL;
3223         std::map<int, wxString> *RoleListTokens = NULL;
3224         std::map<int, wxString> *RoleListLanguage = NULL;
3225         std::map<int, int> *RoleListPref = NULL;
3226         
3227         // Setup blank lines for later on.
3228         
3229         switch(PropType){
3230                 case PROPERTY_NONE:
3231                         RoleList = &GeneralRoleList;
3232                         RoleListType = &GeneralRoleListType;
3233                         RoleListAltID = &GeneralRoleListAltID;
3234                         RoleListPID = &GeneralRoleListPID;
3235                         RoleListTokens = &GeneralRoleListTokens;
3236                         RoleListLanguage = &GeneralRoleListLanguage;
3237                         RoleListPref = &GeneralRoleListPref;    
3238                         break;
3239                 case PROPERTY_HOME:
3240                         RoleList = &HomeRoleList;
3241                         RoleListType = &HomeRoleListType;
3242                         RoleListAltID = &HomeRoleListAltID;
3243                         RoleListPID = &HomeRoleListPID;
3244                         RoleListTokens = &HomeRoleListTokens;
3245                         RoleListLanguage = &HomeRoleListLanguage;
3246                         RoleListPref = &HomeRoleListPref;       
3247                         break;
3248                 case PROPERTY_WORK:
3249                         RoleList = &BusinessRoleList;
3250                         RoleListType = &BusinessRoleListType;
3251                         RoleListAltID = &BusinessRoleListAltID;
3252                         RoleListPID = &BusinessRoleListPID;
3253                         RoleListTokens = &BusinessRoleListTokens;
3254                         RoleListLanguage = &BusinessRoleListLanguage;   
3255                         RoleListPref = &BusinessRoleListPref;
3256                         break;
3257         }
3259         intPrevValue = 5;
3260                 
3261         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3262         intiter != SplitPoints.end(); ++intiter){
3263         
3264                 SLiter = SplitLength.find(intiter->first);
3265         
3266                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3267                 
3268                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3269                 PropertyName = PropertyElement.GetNextToken();                          
3270                 PropertyValue = PropertyElement.GetNextToken();
3271                 
3272                 intPrevValue = intiter->second;
3273                 
3274                 // Process properties.
3275                 
3276                 size_t intPropertyValueLen = PropertyValue.Len();
3277                 
3278                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3279                         
3280                         PropertyValue.Trim();
3281                         PropertyValue.RemoveLast();
3282                         
3283                 }                               
3284                 
3285                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3286                         
3287                         PropertyValue.Remove(0, 1);
3288                         
3289                 }                               
3290                 
3291                 CaptureString(&PropertyValue, FALSE);
3292                 
3293                 if (PropertyName == wxT("ALTID")){
3294                 
3295                         RoleListAltID->erase(*RoleCount);
3296                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3297                 
3298                 } else if (PropertyName == wxT("PID")){
3300                         RoleListPID->erase(*RoleCount);
3301                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3302                 
3303                 } else if (PropertyName == wxT("PREF")){
3304                                 
3305                         int PriorityNumber = 0;
3306                         bool ValidNumber = TRUE;
3307                         
3308                         try{
3309                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3310                         }
3311                         
3312                         catch(std::invalid_argument &e){
3313                                 ValidNumber = FALSE;
3314                         }
3316                         if (ValidNumber == TRUE){
3318                                 RoleListPref->erase(*RoleCount);
3319                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3321                         }
3322                                         
3323                 } else if (PropertyName == wxT("LANGUAGE")){
3324                 
3325                         RoleListLanguage->erase(*RoleCount);
3326                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3327                 
3328                 } else {
3329                 
3330                         // Something else we don't know about so append
3331                         // to the tokens variable.
3332                 
3333                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3334                 
3335                                 if (FirstToken == TRUE){
3336                         
3337                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3338                                         FirstToken = FALSE;
3339                         
3340                                 } else {
3341                         
3342                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3343                         
3344                                 }
3345                 
3346                         }
3347                 
3348                 }
3349         
3350         }
3351         
3352         // Add the data to the General/Home/Work address variables.
3353         
3354         CaptureString(&PropertySeg2, FALSE);
3356         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3357         
3358         if (!PropertyTokens.IsEmpty()){
3359         
3360                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3361                         
3362         }
3366 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3368         std::map<int, int> SplitPoints;
3369         std::map<int, int> SplitLength;
3370         std::map<int, int>::iterator SLiter;                    
3371         wxString PropertyData;
3372         wxString PropertyName;
3373         wxString PropertyValue;
3374         wxString PropertyTokens;
3375         bool FirstToken = TRUE;
3376         int intPrevValue = 5;
3377         int intPref = 0;                        
3378         int intType = 0;
3379         long ListCtrlIndex;
3380         
3381         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3382         
3383         intPrevValue = 4;
3384         
3385         PropertyType PropType = PROPERTY_NONE;
3386                 
3387         // Look for type before continuing.
3388         
3389         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3390         
3391         // Setup the pointers.
3392         
3393         std::map<int, wxString> *OrganisationsList = NULL;
3394         std::map<int, wxString> *OrganisationsListAltID = NULL;
3395         std::map<int, wxString> *OrganisationsListPID = NULL;
3396         std::map<int, wxString> *OrganisationsListType = NULL;
3397         std::map<int, wxString> *OrganisationsListTokens = NULL;
3398         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3399         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3400         std::map<int, int> *OrganisationsListPref = NULL;
3401         
3402         // Setup blank lines for later on.
3403         
3404         switch(PropType){
3405                 case PROPERTY_NONE:
3406                         OrganisationsList = &GeneralOrganisationsList;
3407                         OrganisationsListType = &GeneralOrganisationsListType;
3408                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3409                         OrganisationsListPID = &GeneralOrganisationsListPID;
3410                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3411                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3412                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3413                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3414                         break;
3415                 case PROPERTY_HOME:
3416                         OrganisationsList = &HomeOrganisationsList;
3417                         OrganisationsListType = &HomeOrganisationsListType;
3418                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3419                         OrganisationsListPID = &HomeOrganisationsListPID;
3420                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3421                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3422                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3423                         OrganisationsListPref = &HomeOrganisationsListPref;     
3424                         break;
3425                 case PROPERTY_WORK:
3426                         OrganisationsList = &BusinessOrganisationsList;
3427                         OrganisationsListType = &BusinessOrganisationsListType;
3428                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3429                         OrganisationsListPID = &BusinessOrganisationsListPID;
3430                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3431                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3432                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3433                         OrganisationsListPref = &BusinessOrganisationsListPref;
3434                         break;
3435         }
3437         intPrevValue = 4;
3438                 
3439         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3440         intiter != SplitPoints.end(); ++intiter){
3441         
3442                 SLiter = SplitLength.find(intiter->first);
3443         
3444                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3445                 
3446                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3447                 PropertyName = PropertyElement.GetNextToken();                          
3448                 PropertyValue = PropertyElement.GetNextToken();
3449                 
3450                 intPrevValue = intiter->second;
3451                 
3452                 // Process properties.
3453                 
3454                 size_t intPropertyValueLen = PropertyValue.Len();
3455                 
3456                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3457                         
3458                         PropertyValue.Trim();
3459                         PropertyValue.RemoveLast();
3460                         
3461                 }                               
3462                 
3463                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3464                         
3465                         PropertyValue.Remove(0, 1);
3466                         
3467                 }                               
3468                 
3469                 CaptureString(&PropertyValue, FALSE);
3470                 
3471                 if (PropertyName == wxT("ALTID")){
3472                 
3473                         OrganisationsListAltID->erase(*OrganisationCount);
3474                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3475                 
3476                 } else if (PropertyName == wxT("PID")){
3478                         OrganisationsListPID->erase(*OrganisationCount);
3479                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3480                 
3481                 } else if (PropertyName == wxT("SORT-AS")){
3483                         OrganisationsListSortAs->erase(*OrganisationCount);
3484                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3485                 
3486                 } else if (PropertyName == wxT("PREF")){
3487                                 
3488                         int PriorityNumber = 0;
3489                         bool ValidNumber = TRUE;
3490                         
3491                         try{
3492                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3493                         }
3494                         
3495                         catch(std::invalid_argument &e){
3496                                 ValidNumber = FALSE;
3497                         }
3499                         if (ValidNumber == TRUE){
3501                                 OrganisationsListPref->erase(*OrganisationCount);
3502                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3504                         }
3505                                         
3506                 } else if (PropertyName == wxT("LANGUAGE")){
3507                 
3508                         OrganisationsListLanguage->erase(*OrganisationCount);
3509                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3510                 
3511                 } else {
3512                 
3513                         // Something else we don't know about so append
3514                         // to the tokens variable.
3515                 
3516                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3517                 
3518                                 if (FirstToken == TRUE){
3519                         
3520                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3521                                         FirstToken = FALSE;
3522                         
3523                                 } else {
3524                         
3525                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3526                         
3527                                 }
3528                 
3529                         }
3530                 
3531                 }
3532         
3533         }
3534         
3535         // Add the data to the General/Home/Work address variables.
3536         
3537         CaptureString(&PropertySeg2, FALSE);
3539         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3540         
3541         if (!PropertyTokens.IsEmpty()){
3542         
3543                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3544                         
3545         }
3549 void SplitValues(wxString *PropertyLine, 
3550         std::map<int,int> *SplitPoints, 
3551         std::map<int,int> *SplitLength, 
3552         int intSize){
3553         
3554         size_t intPropertyLen = PropertyLine->Len();
3555         int intSplitsFound = 0;
3556         int intSplitSize = 0;
3557         int intSplitSeek = 0;
3558         
3559         for (int i = intSize; i <= intPropertyLen; i++){
3561                 intSplitSize++;
3562         
3563                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
3564                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
3565            
3566                     if (intSplitsFound == 0){
3567             
3568                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
3569           
3570                     } else {
3571            
3572                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3573             
3574                     }
3575             
3576                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
3577             
3578                     intSplitsFound++;
3579                     intSplitSeek = i;
3580                     intSplitSize = 0;
3581             
3582                 }
3584         }
3586         if (intSplitsFound == 0){
3588                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
3589                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3591         } else {
3593                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3594                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3596         }
3600 void CheckType(wxString *PropertySeg1, 
3601         std::map<int,int> *SplitPoints, 
3602         std::map<int,int> *SplitLength, 
3603         int *intPrevValue, 
3604         PropertyType *PropType){
3605         
3606         wxString PropertyData;
3607         wxString PropertyName;
3608         wxString PropertyValue;
3609         std::map<int,int>::iterator SLiter;
3610         
3611         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
3612         intiter != SplitPoints->end(); ++intiter){
3613         
3614                 SLiter = SplitLength->find(intiter->first);
3615         
3616                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
3617                 
3618                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3619                 PropertyName = PropertyElement.GetNextToken();                          
3620                 PropertyValue = PropertyElement.GetNextToken();
3621                 
3622                 *intPrevValue = intiter->second;
3623                 
3624                 if (PropertyName == wxT("TYPE")){
3625                                 
3626                         if (PropertyValue == wxT("work")){
3627                         
3628                                 *PropType = PROPERTY_WORK;
3629                                                         
3630                         } else if (PropertyValue == wxT("home")){
3632                                 *PropType = PROPERTY_HOME;
3633                                                         
3634                         } else {
3635                         
3636                                 *PropType = PROPERTY_NONE;
3637                         
3638                         }
3639                 
3640                         return;
3641                 
3642                 }
3643         
3644         }
3645         
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