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