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