Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
d14043c53e13f4c90089380beae9aaac78e04d88
[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         int SoundCount = 0;
103         int CalendarCount = 0;
104         int CalendarAddressCount = 0;
105         wxString ContactLine;
106         wxString PropertyLine;
107         wxString PropertySeg1;
108         wxString PropertySeg2;
109         wxString PropertyNextLine;
110         wxString Property;
111         
112         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
113          iter != ContactFileLines.end(); ++iter){
115                 ExtraLineSeek = TRUE;
116                 QuoteMode = FALSE;
117                 PropertyFind = TRUE;
118                 ContactLineLen = 0;
119                 QuoteBreakPoint = 0;
120                 ContactLine.Clear();
121                 PropertyLine.Clear();
122                 PropertySeg1.Clear();
123                 PropertySeg2.Clear();
124                 Property.Clear();
125          
126                 ContactLine = iter->second;
127                 
128                 while (ExtraLineSeek == TRUE){
129                 
130                         // Check if there is extra data on the next line 
131                         // (indicated by space or tab at the start) and add data.
132                 
133                         iter++;
134                         
135                         if (iter == ContactFileLines.end()){
136                         
137                                 iter--;
138                                 break;
139                         
140                         }                       
141                 
142                         PropertyNextLine = iter->second;
143                 
144                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
145                 
146                                 PropertyNextLine.Remove(0, 1);
147                                 ContactLine.Append(PropertyNextLine);
148                 
149                         } else {
150                         
151                                 iter--;
152                                 ExtraLineSeek = FALSE;
153                         
154                         }
155                 
156                 }
158                 ContactLineLen = ContactLine.Len();
159                 
160                 // Make sure we are not in quotation mode.
161                 // Make sure colon does not have \ or \\ before it.
162                 
163                 for (int i = 0; i <= ContactLineLen; i++){
164                 
165                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
166                         
167                                 PropertyFind = FALSE;
168                         
169                         } else if (PropertyFind == TRUE){
170                         
171                                 Property.Append(ContactLine.Mid(i, 1));
172                         
173                         }               
174                 
175                         if (ContactLine.Mid(i, 1) == wxT("\"")){
176                         
177                                 if (QuoteMode == TRUE){
178                                 
179                                         QuoteMode = FALSE;
180                                 
181                                 } else {
182                         
183                                         QuoteMode = TRUE;
184                                         
185                                 }
186                         
187                         }
188                         
189                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
190                         
191                                 QuoteBreakPoint = i;
192                                 break;
193                         
194                         }
195                 
196                 }
197                 
198                 // Split that line at the point into two variables (ignore the colon).
199                 
200                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
201                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
202                 
203                  if (Property == wxT("KIND") && KindProcessed == FALSE){
204                                 
205                         ProcessKind(PropertySeg2);
206                 
207                 } else if (Property == wxT("MEMBER")){
209                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
210                         GroupCount++;   
211                 
212                 } else if (Property == wxT("FN")){
213                 
214                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
215                         FNCount++;
216                 
217                 } else if (Property == wxT("N") && NameProcessed == FALSE){
218                 
219                         ProcessN(PropertySeg1, PropertySeg2);
220                         NameProcessed = TRUE;
221                 
222                 } else if (Property == wxT("NICKNAME")){
223                                                 
224                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
225                         NicknameCount++;
226                         
227                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
228                 
229                         ProcessGender(PropertySeg1, PropertySeg2);
230                         GenderProcessed = TRUE;
231                 
232                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
233                 
234                         ProcessBirthday(PropertySeg1, PropertySeg2);
235                         BirthdayProcessed = TRUE;
236                 
237                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
238                 
239                         ProcessAnniversary(PropertySeg1, PropertySeg2);
240                         AnniversaryProcessed = TRUE;
241                 
242                 } else if (Property == wxT("TZ")){
243                 
244                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
245                         TimeZoneCount++;
246                 
247                 } else if (Property == wxT("ADR")){
248                 
249                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
250                         AddressCount++;
251                 
252                 } else if (Property == wxT("EMAIL")){
253                                         
254                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
255                         EmailCount++;
256                 
257                 } else if (Property == wxT("IMPP")){
258                 
259                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
260                         IMCount++;
261                         
262                 } else if (Property == wxT("TEL")){
263                                 
264                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
265                         TelephoneCount++;
266                 
267                 } else if (Property == wxT("LANG")){
268                 
269                         // See frmContactEditor-LoadLanguage.cpp
270                         
271                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
272                         LanguageCount++;
273                 
274                 } else if (Property == wxT("GEO")){
275                 
276                         // See frmContactEditor-LoadGeo.cpp
277                         
278                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
279                         GeographicCount++;
280                 
281                 } else if (Property == wxT("RELATED")){
282                         
283                         // See fromContactEditor-LoadRelated.cpp
284                         
285                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
286                         RelatedCount++;
287                         
288                 } else if (Property == wxT("URL")){
290                         // See frmContactEditor-LoadURL.cpp
291                 
292                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
293                         URLCount++;
294                 
295                 } else if (Property == wxT("TITLE")) {
296                 
297                         // See frmContactEditor-LoadTitle.cpp
298                         
299                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
300                         TitleCount++;
301                         
302                 } else if (Property == wxT("ROLE")) {
303                 
304                         // See frmContactEditor-LoadTitle.cpp
305                         
306                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
307                         RoleCount++;
308                         
309                 } else if (Property == wxT("ORG")) {
310                 
311                         // See frmContactEditor-LoadOrg.cpp
312                         
313                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
314                         OrganisationCount++;
315                         
316                 } else if (Property == wxT("NOTE")) {
318                         // See frmContactEditor-LoadNote.cpp
320                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
321                         NoteCount++;    
322                         
323                 } else if (Property == wxT("CATEGORIES")) {
324                 
325                         // See frmContactEditor-LoadCategory.cpp
326                 
327                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
328                         CategoryCount++;
329                         
330                 } else if (Property == wxT("PHOTO")) {
331                 
332                         // See frmContactEditor-LoadPhoto.cpp
333                         
334                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
335                         PhotoCount++;
337                 } else if (Property == wxT("LOGO")) {
338                 
339                         // See frmContactEditor-LoadPhoto.cpp
340                         
341                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
342                         LogoCount++;
344                 } else if (Property == wxT("LOGO")) {
345                 
346                         // See frmContactEditor-LoadPhoto.cpp
347                         
348                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
349                         LogoCount++;
351                 } else if (Property == wxT("SOUND")) {
352                 
353                         // See frmContactEditor-LoadSound.cpp
354                         
355                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
356                         SoundCount++;
357                         
358                 } else if (Property == wxT("CALURI")){
360                         // See frmContactEditor-LoadCalendar.cpp
361                         
362                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
363                         CalendarCount++;
364                 
365                 } else if (Property == wxT("CALADRURI")){
366                 
367                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
368                         CalendarAddressCount++;
369                 
370                 }
371                 
372         }
373         
374         return CONTACTLOAD_OK;
378 void ContactDataObject::ProcessKind(wxString KindType){
380         if (KindType == wxT("individual")){
381                         
382                 ContactKind = CONTACTKIND_INDIVIDUAL;
383                         
384         } else if (KindType == wxT("group")){
385                         
386                 ContactKind = CONTACTKIND_GROUP;
387                         
388         } else if (KindType == wxT("org")){
389                         
390                 ContactKind = CONTACTKIND_ORGANISATION;
391                         
392         } else if (KindType == wxT("location")){
393                         
394                 ContactKind = CONTACTKIND_LOCATION;
395                         
396         } else {
397                         
398                 ContactKind = CONTACTKIND_NONE;                 
399         }
403 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
405         std::map<int, int> SplitPoints;
406         std::map<int, int> SplitLength;
408         int intPrevValue = 8;
409         int intPref = 0;                        
410         int intType = 0;
411         
412         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
414         intPrevValue = 7;
415         
416         wxString PropertyName;
417         wxString PropertyValue;
418         wxString PropertyData;
419         wxString PropertyTokens;
420         std::map<int,int>::iterator SLiter;
421         bool FirstToken = TRUE;
422         
423         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
424         intiter != SplitPoints.end(); ++intiter){
425         
426                 SLiter = SplitLength.find(intiter->first);
427         
428                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
429                 
430                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
431                 PropertyName = PropertyElement.GetNextToken();                          
432                 PropertyValue = PropertyElement.GetNextToken();
433                 
434                 intPrevValue = intiter->second;
435                 
436                 CaptureString(&PropertyValue, FALSE);
437         
438                 if (PropertyName == wxT("ALTID")){
440                         GroupsListAltID.erase(*GroupCount);
441                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
442                 
443                 } else if (PropertyName == wxT("PID")){
445                         GroupsListPID.erase(*GroupCount);
446                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
447                 
448                 } else if (PropertyName == wxT("PREF")){
450                         int PriorityNumber = 0;
451                         bool ValidNumber = TRUE;
452                         
453                         try{
454                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
455                         }
456                         
457                         catch(std::invalid_argument &e){
458                                 ValidNumber = FALSE;
459                         }
461                         if (ValidNumber == TRUE){
463                                 GroupsListPref.erase(*GroupCount);
464                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
465                 
466                         }
467                 
468                 } else if (PropertyName == wxT("MEDIATYPE")){
470                         GroupsListMediaType.erase(*GroupCount);
471                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
472                 
473                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
474                         
475                         if (FirstToken == TRUE){
476                                 
477                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
478                                 FirstToken = FALSE;
479                                 
480                         } else {
481                         
482                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
483                                 
484                         }
485                         
486                 }
487                 
488         }
490         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
492         if (!PropertyTokens.IsEmpty()){
493         
494                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
495         
496         }
501 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
503         std::map<int, int> SplitPoints;
504         std::map<int, int> SplitLength;
506         int intPrevValue = 4;
507         int intPref = 0;                        
508         int intType = 0;
509         
510         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
512         intPrevValue = 3;
513         
514         wxString PropertyName;
515         wxString PropertyValue;
516         wxString PropertyData;
517         wxString PropertyTokens;
518         std::map<int,int>::iterator SLiter;
519         bool FirstToken = TRUE;
520         
521         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
522         intiter != SplitPoints.end(); ++intiter){
523         
524                 SLiter = SplitLength.find(intiter->first);
525         
526                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
527                 
528                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
529                 PropertyName = PropertyElement.GetNextToken();                          
530                 PropertyValue = PropertyElement.GetNextToken();
531                 
532                 intPrevValue = intiter->second;
533                 
534                 CaptureString(&PropertyValue, FALSE);
535                 
536                 if (PropertyName == wxT("TYPE")){
538                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
539                                 PropertyValue == wxT("work") ){
541                                 FullNamesListType.erase(*FNCount);
542                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
543                 
544                         }
545                 
546                 } else if (PropertyName == wxT("LANGUAGE")){
548                         FullNamesListLanguage.erase(*FNCount);
549                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
550                 
551                 } else if (PropertyName == wxT("ALTID")){
552                 
553                         FullNamesListAltID.erase(*FNCount);
554                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
555                 
556                 } else if (PropertyName == wxT("PID")){
558                         FullNamesListPID.erase(*FNCount);
559                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
560                 
561                 } else if (PropertyName == wxT("PREF")){
563                         int PriorityNumber = 0;
564                         bool ValidNumber = TRUE;
565                         
566                         try{
567                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
568                         }
569                         
570                         catch(std::invalid_argument &e){
571                                 ValidNumber = FALSE;
572                         }
574                         if (ValidNumber == TRUE){
576                                 FullNamesListPref.erase(*FNCount);
577                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
579                         }
580                 
581                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
582                         
583                         if (FirstToken == TRUE){
584                                 
585                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
586                                 FirstToken = FALSE;
587                                 
588                         } else {
589                         
590                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
591                                 
592                         }
593                         
594                 } 
595         
596         }
598         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
600         if (!PropertyTokens.IsEmpty()){
601         
602                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
603         
604         }
608 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
610         std::map<int, int> SplitPoints;
611         std::map<int, int> SplitLength;
613         int intPrevValue = 3;
614         int intPref = 0;                        
615         int intType = 0;
616         
617         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
618         
619         intPrevValue = 2;
620         
621         wxString PropertyName;
622         wxString PropertyValue;
623         wxString PropertyData;
624         wxString PropertyTokens;
625         std::map<int,int>::iterator SLiter;
626         bool FirstToken = TRUE;
627         
628         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
629         intiter != SplitPoints.end(); ++intiter){
630         
631                 SLiter = SplitLength.find(intiter->first);
632         
633                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
634                 
635                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
636                 PropertyName = PropertyElement.GetNextToken();                          
637                 PropertyValue = PropertyElement.GetNextToken();
638                 
639                 intPrevValue = intiter->second;
640                 
641                 CaptureString(&PropertyValue, FALSE);
642                 
643                 if (PropertyName == wxT("ALTID")){
645                         NameAltID = PropertyValue;
646                 
647                 } else if (PropertyName == wxT("LANGUAGE")){
648                 
649                         NameLanguage = PropertyValue;
650                 
651                 } else if (PropertyName == wxT("SORT-AS")){
652                 
653                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
654                                 PropertyValue.Len() >= 3){
655                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
656                         }
657                 
658                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
659                         
660                         if (FirstToken == TRUE){
661                                 
662                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
663                                 FirstToken = FALSE;
664                                 
665                         } else {
666                         
667                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
668                                 
669                         }
670                         
671                 }
672         
673         }
674         
675         // Split the name data.
676         
677         int intSplitSeek = 0;           
678         int intSplitsFound = 0;
679         int intSplitSize = 0;
680         int intPropertyLen = PropertySeg2.Len();
681         
682         std::map<int,wxString> NameValues;
683         intPrevValue = 0;                                       
684         
685         for (int i = 0; i <= intPropertyLen; i++){
686         
687                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
688                         
689                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
690                         
691                         intSplitSeek = i;
692                         intSplitSeek++;
693                         
694                         if (intSplitsFound == 4){
695                         
696                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
697                                 break;
698                         
699                         }
700                         
701                         intSplitSize = 0;
702                         continue;
703         
704                 }
705                 
706                 intSplitSize++;
708         }
709         
710         // Split the data into several parts.
711                         
712         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
713         iter != NameValues.end(); ++iter){
714         
715                 if (iter->first == 1){
716                 
717                         // Deal with family name.
718                         
719                         NameSurname = iter->second;
720                 
721                 } else if (iter->first == 2){
722                 
723                         // Deal with given names.
724                         
725                         NameForename = iter->second;
726                 
727                 } else if (iter->first == 3){
728                 
729                         // Deal with additional names.
730                         
731                         NameOtherNames = iter->second;
732                 
733                 } else if (iter->first == 4){
734                 
735                         // Deal with honorifix prefixes and suffixes.
737                         NameTitle = iter->second;
738                 
739                         iter++;
740                         
741                         if (iter == NameValues.end()){
742                         
743                                 break;
744                         
745                         }
746                 
747                         NameSuffix = iter->second;
748                 
749                 }
750         
751         }
752         
753         // Add the name token data.
754         
755         if (!PropertyTokens.IsEmpty()){
756         
757                 NameTokens = PropertyTokens;
758         
759         }
763 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
765         std::map<int, int> SplitPoints;
766         std::map<int, int> SplitLength;
768         int intPrevValue = 10;
769         int intPref = 0;                        
770         
771         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
772         
773         intPrevValue = 9;
774         
775         PropertyType PropType = PROPERTY_NONE;
776         
777         // Look for type before continuing.
778         
779         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
780         
781         intPrevValue = 9;
782         
783         std::map<int, wxString> *NicknamesList = NULL;
784         std::map<int, wxString> *NicknamesListType = NULL;
785         std::map<int, wxString> *NicknamesListLanguage = NULL;
786         std::map<int, wxString> *NicknamesListAltID = NULL;
787         std::map<int, wxString> *NicknamesListPID = NULL;
788         std::map<int, wxString> *NicknamesListTokens = NULL;            
789         std::map<int, int> *NicknamesListPref = NULL;
790         
791         switch(PropType){
792                 case PROPERTY_NONE:
793                         NicknamesList = &GeneralNicknamesList;
794                         NicknamesListType = &GeneralNicknamesListType;
795                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
796                         NicknamesListAltID = &GeneralNicknamesListAltID;
797                         NicknamesListPID = &GeneralNicknamesListPID;
798                         NicknamesListTokens = &GeneralNicknamesListTokens;
799                         NicknamesListPref = &GeneralNicknamesListPref;
800                         break;
801                 case PROPERTY_HOME:
802                         NicknamesList = &HomeNicknamesList;
803                         NicknamesListType = &HomeNicknamesListType;
804                         NicknamesListLanguage = &HomeNicknamesListLanguage;
805                         NicknamesListAltID = &HomeNicknamesListAltID;
806                         NicknamesListPID = &HomeNicknamesListPID;
807                         NicknamesListTokens = &HomeNicknamesListTokens;
808                         NicknamesListPref = &HomeNicknamesListPref;
809                         break;
810                 case PROPERTY_WORK:
811                         NicknamesList = &BusinessNicknamesList;
812                         NicknamesListType = &BusinessNicknamesListType;
813                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
814                         NicknamesListAltID = &BusinessNicknamesListAltID;
815                         NicknamesListPID = &BusinessNicknamesListPID;
816                         NicknamesListTokens = &BusinessNicknamesListTokens;
817                         NicknamesListPref = &BusinessNicknamesListPref;
818                         break;
819         }
820         
821         std::map<int, int>::iterator SLiter;    
822         wxString PropertyData;
823         wxString PropertyName;
824         wxString PropertyValue;
825         wxString PropertyTokens;
826         bool FirstToken = TRUE;
827         
828         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
829         intiter != SplitPoints.end(); ++intiter){
830         
831                 SLiter = SplitLength.find(intiter->first);
832         
833                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
834                 
835                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
836                 PropertyName = PropertyElement.GetNextToken();                          
837                 PropertyValue = PropertyElement.GetNextToken();
838                 
839                 intPrevValue = intiter->second;
840                 
841                 CaptureString(&PropertyValue, FALSE);
842                 
843                 if (PropertyName == wxT("ALTID")){
845                         NicknamesListAltID->erase(*NicknameCount);
846                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
847                 
848                 } else if (PropertyName == wxT("PID")){
850                         NicknamesListPID->erase(*NicknameCount);
851                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
853                 } else if (PropertyName == wxT("PREF")){
855                         int PriorityNumber = 0;
856                         bool ValidNumber = TRUE;
857                         
858                         try{
859                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
860                         }
861                         
862                         catch(std::invalid_argument &e){
863                                 ValidNumber = FALSE;
864                         }
866                         if (ValidNumber == TRUE){
868                                 NicknamesListPref->erase(*NicknameCount);
869                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
871                         }
872                 
873                 } else if (PropertyName == wxT("LANGUAGE")){
875                         NicknamesListLanguage->erase(*NicknameCount);
876                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
878                 } else {
879                 
880                         // Something else we don't know about so append
881                         // to the tokens variable.
882                 
883                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
884                 
885                                 if (FirstToken == TRUE){
886                         
887                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
888                                         FirstToken = FALSE;
889                         
890                                 } else {
891                         
892                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
893                         
894                                 }
895                 
896                         }
897                 
898                 }
899                 
900         }
901         
902         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
903         
904         // Add the name token data.
905         
906         if (!PropertyTokens.IsEmpty()){
907         
908                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
909         
910         }
914 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
916         std::map<int, int> SplitPoints;
917         std::map<int, int> SplitLength;
918         std::map<int, int>::iterator SLiter;                    
919         wxString PropertyData;
920         wxString PropertyName;
921         wxString PropertyValue;
922         wxString PropertyTokens;
923         bool FirstToken = TRUE;
924         int intPrevValue = 8;
926         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
928         intPrevValue = 7;                       
929         
930         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
931         intiter != SplitPoints.end(); ++intiter){
932         
933                 SLiter = SplitLength.find(intiter->first);
934         
935                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
936                 
937                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
938                 PropertyName = PropertyElement.GetNextToken();                          
939                 PropertyValue = PropertyElement.GetNextToken();
940                 
941                 intPrevValue = intiter->second;
942                 
943                 // Process properties.
944                 
945                 size_t intPropertyValueLen = PropertyValue.Len();
946                 
947                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
948                         
949                         PropertyValue.Trim();
950                         PropertyValue.RemoveLast();
951                         
952                 }                               
953                 
954                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
955                         
956                         PropertyValue.Remove(0, 1);
957                         
958                 }                               
959                 
960                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
962                         if (FirstToken == TRUE){
963         
964                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
965                                 FirstToken = FALSE;
966         
967                         } else {
968         
969                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
970         
971                         }
973                 }
974         
975         }       
977         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
978         
979         wxString GenderComponent;
980         
981         if (GenderData.CountTokens() >= 2){
982         
983                 Gender = GenderData.GetNextToken();
984                 GenderDetails = GenderData.GetString();
985         
986                 CaptureString(&GenderDetails, FALSE);
987                                                 
988         } else {
989         
990                 Gender = GenderData.GetNextToken();
991         
992         }
993         
994         if (!PropertyTokens.IsEmpty()){
995         
996                 GenderTokens = PropertyTokens;
997         
998         }
1002 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1004         // Process date. Preserve the remainder in the string.
1006         std::map<int, int> SplitPoints;
1007         std::map<int, int> SplitLength;
1008         std::map<int, int>::iterator SLiter;                    
1009         wxString PropertyData;
1010         wxString PropertyName;
1011         wxString PropertyValue;
1012         wxString PropertyTokens;
1013         bool BirthdayText = FALSE;
1014         int intPrevValue = 6;
1016         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1018         intPrevValue = 5;
1020         // Look for type before continuing.
1022         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1023         intiter != SplitPoints.end(); ++intiter){
1025                 SLiter = SplitLength.find(intiter->first);
1027                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1028         
1029                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1030                 PropertyName = PropertyElement.GetNextToken();                          
1031                 PropertyValue = PropertyElement.GetNextToken();
1032         
1033                 intPrevValue = intiter->second;
1034         
1035                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1036         
1037                         CaptureString(&PropertySeg2, FALSE);
1038                         Birthday = PropertySeg2;
1039                         BirthdayText = TRUE;
1040         
1041                 }
1043         }
1045         // Setup blank lines for later on.
1046         
1047         intPrevValue = 5;
1048         bool FirstToken = TRUE;
1050         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1051         intiter != SplitPoints.end(); ++intiter){
1053                 SLiter = SplitLength.find(intiter->first);
1055                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1056         
1057                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1058                 PropertyName = PropertyElement.GetNextToken();                          
1059                 PropertyValue = PropertyElement.GetNextToken();
1060         
1061                 intPrevValue = intiter->second;
1062         
1063                 // Process properties.
1064         
1065                 CaptureString(&PropertyValue, FALSE);
1066         
1067                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1068                 
1069                         PropertyValue.Trim();
1070                         PropertyValue.RemoveLast();
1071                 
1072                 }                               
1073         
1074                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1075                 
1076                         PropertyValue.Remove(0, 1);
1077                 
1078                 }                               
1079         
1080                 if (PropertyName == wxT("ALTID")){
1082                         BirthdayAltID = PropertyValue;
1083         
1084                 } else if (PropertyName == wxT("CALSCALE")){
1085         
1086                         BirthdayCalScale = PropertyValue;
1087         
1088                 } else if (PropertyName != wxT("VALUE")) {
1089         
1090                         // Something else we don't know about so append
1091                         // to the tokens variable.
1092                 
1093                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1094                 
1095                                 if (FirstToken == TRUE){
1096         
1097                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1098                                         FirstToken = FALSE;
1099         
1100                                 } else {
1101         
1102                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1103         
1104                                 }
1105                                 
1106                         }
1107                         
1108                 }
1110         }       
1112         // Add the data to the variables and form.
1113         
1114         if (BirthdayText == FALSE){
1115         
1116                 Birthday = PropertySeg2;
1118         }
1119         
1120         if (!PropertyTokens.IsEmpty()){
1121         
1122                 BirthdayTokens = PropertyTokens;
1124         }
1128 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1130         // Process date. Preserve the remainder in the string.
1132         std::map<int, int> SplitPoints;
1133         std::map<int, int> SplitLength;
1134         std::map<int, int>::iterator SLiter;                    
1135         wxString PropertyData;
1136         wxString PropertyName;
1137         wxString PropertyValue;
1138         wxString PropertyTokens;
1139         bool AnniversaryText = FALSE;
1140         int intPrevValue = 13;
1142         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1144         intPrevValue = 12;
1146         // Look for type before continuing.
1148         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1149         intiter != SplitPoints.end(); ++intiter){
1151                 SLiter = SplitLength.find(intiter->first);
1153                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1154         
1155                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1156                 PropertyName = PropertyElement.GetNextToken();                          
1157                 PropertyValue = PropertyElement.GetNextToken();
1158         
1159                 intPrevValue = intiter->second;
1160         
1161                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1162         
1163                         CaptureString(&PropertySeg2, FALSE);
1164                         Anniversary = PropertySeg2;
1165                         AnniversaryText = TRUE;
1166         
1167                 }
1169         }
1171         // Setup blank lines for later on.
1172         
1173         intPrevValue = 12;
1174         bool FirstToken = TRUE;
1176         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1177         intiter != SplitPoints.end(); ++intiter){
1179                 SLiter = SplitLength.find(intiter->first);
1181                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1182         
1183                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1184                 PropertyName = PropertyElement.GetNextToken();                          
1185                 PropertyValue = PropertyElement.GetNextToken();
1186         
1187                 intPrevValue = intiter->second;
1188         
1189                 // Process properties.
1190         
1191                 CaptureString(&PropertyValue, FALSE);
1192         
1193                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1194                 
1195                         PropertyValue.Trim();
1196                         PropertyValue.RemoveLast();
1197                 
1198                 }                               
1199         
1200                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1201                 
1202                         PropertyValue.Remove(0, 1);
1203                 
1204                 }                               
1205         
1206                 if (PropertyName == wxT("ALTID")){
1208                         AnniversaryAltID = PropertyValue;
1209         
1210                 } else if (PropertyName == wxT("CALSCALE")){
1211         
1212                         AnniversaryCalScale = PropertyValue;
1213         
1214                 } else if (PropertyName != wxT("VALUE")) {
1215         
1216                         // Something else we don't know about so append
1217                         // to the tokens variable.
1218                 
1219                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1220                 
1221                                 if (FirstToken == TRUE){
1222         
1223                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1224                                         FirstToken = FALSE;
1225         
1226                                 } else {
1227         
1228                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1229         
1230                                 }
1231                                 
1232                         }
1233                         
1234                 }
1236         }       
1238         // Add the data to the variables and form.
1239         
1240         if (AnniversaryText == FALSE){
1241         
1242                 Anniversary = PropertySeg2;
1244         }
1245         
1246         if (!PropertyTokens.IsEmpty()){
1247         
1248                 AnniversaryTokens = PropertyTokens;
1250         }
1254 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1256         std::map<int, int> SplitPoints;
1257         std::map<int, int> SplitLength;
1259         int intPrevValue = 4;
1260         int intPref = 0;                        
1261         
1262         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1263         
1264         intPrevValue = 3;
1265         
1266         PropertyType PropType = PROPERTY_NONE;
1267         
1268         // Look for type before continuing.
1269         
1270         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1271         
1272         intPrevValue = 3;
1273         
1274         std::map<int, wxString> *TZList = NULL;
1275         std::map<int, wxString> *TZListType = NULL;
1276         std::map<int, wxString> *TZListMediatype = NULL;
1277         std::map<int, wxString> *TZListAltID = NULL;
1278         std::map<int, wxString> *TZListPID = NULL;
1279         std::map<int, wxString> *TZListTokens = NULL;           
1280         std::map<int, int> *TZListPref = NULL;
1281         
1282         switch(PropType){
1283                 case PROPERTY_NONE:
1284                         TZList = &GeneralTZList;
1285                         TZListType = &GeneralTZListType;
1286                         TZListMediatype = &GeneralTZListMediatype;
1287                         TZListAltID = &GeneralTZListAltID;
1288                         TZListPID = &GeneralTZListPID;
1289                         TZListTokens = &GeneralTZListTokens;
1290                         TZListPref = &GeneralTZListPref;
1291                         break;
1292                 case PROPERTY_HOME:
1293                         TZList = &HomeTZList;
1294                         TZListType = &HomeTZListType;
1295                         TZListMediatype = &HomeTZListMediatype;
1296                         TZListAltID = &HomeTZListAltID;
1297                         TZListPID = &HomeTZListPID;
1298                         TZListTokens = &HomeTZListTokens;
1299                         TZListPref = &HomeTZListPref;
1300                         break;
1301                 case PROPERTY_WORK:
1302                         TZList = &BusinessTZList;
1303                         TZListType = &BusinessTZListType;
1304                         TZListMediatype = &BusinessTZListMediatype;
1305                         TZListAltID = &BusinessTZListAltID;
1306                         TZListPID = &BusinessTZListPID;
1307                         TZListTokens = &BusinessTZListTokens;
1308                         TZListPref = &BusinessTZListPref;
1309                         break;
1310         }
1311         
1312         std::map<int, int>::iterator SLiter;    
1313         wxString PropertyData;
1314         wxString PropertyName;
1315         wxString PropertyValue;
1316         wxString PropertyTokens;
1317         bool FirstToken = TRUE;
1318         
1319         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1320         intiter != SplitPoints.end(); ++intiter){
1321         
1322                 SLiter = SplitLength.find(intiter->first);
1323         
1324                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1325                 
1326                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1327                 PropertyName = PropertyElement.GetNextToken();                          
1328                 PropertyValue = PropertyElement.GetNextToken();
1329                 
1330                 intPrevValue = intiter->second;
1331                 
1332                 CaptureString(&PropertyValue, FALSE);
1334                 if (PropertyName == wxT("ALTID")){
1336                         TZListAltID->erase(*TimeZoneCount);
1337                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1338                 
1339                 } else if (PropertyName == wxT("PID")){
1341                         TZListPID->erase(*TimeZoneCount);
1342                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1344                 } else if (PropertyName == wxT("PREF")){
1346                         int PriorityNumber = 0;
1347                         bool ValidNumber = TRUE;
1348                         
1349                         try{
1350                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1351                         }
1352                         
1353                         catch(std::invalid_argument &e){
1354                                 ValidNumber = FALSE;
1355                         }
1357                         if (ValidNumber == TRUE){
1359                                 TZListPref->erase(*TimeZoneCount);
1360                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1362                         }
1363                 
1364                 } else if (PropertyName == wxT("MEDIATYPE")){
1366                         TZListMediatype->erase(*TimeZoneCount);
1367                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1369                 } else {
1370                 
1371                         // Something else we don't know about so append
1372                         // to the tokens variable.
1373                 
1374                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1375                 
1376                                 if (FirstToken == TRUE){
1377                         
1378                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1379                                         FirstToken = FALSE;
1380                         
1381                                 } else {
1382                         
1383                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1384                         
1385                                 }
1386                 
1387                         }
1388                 
1389                 }
1390                 
1391         }
1392         
1393         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1394         
1395         // Add the name token data.
1396         
1397         if (!PropertyTokens.IsEmpty()){
1398         
1399                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1400         
1401         }
1406 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1408         size_t intPropertyLen = PropertySeg1.Len();
1409         std::map<int, int> SplitPoints;
1410         std::map<int, int> SplitLength;
1411         std::map<int, int>::iterator SLiter;                    
1412         wxString PropertyData;
1413         wxString PropertyName;
1414         wxString PropertyValue;
1415         wxString PropertyTokens;
1416         wxString AddressLabel;
1417         wxString AddressLang;
1418         wxString AddressAltID;
1419         wxString AddressPID;
1420         wxString AddressTokens;
1421         wxString AddressGeo;
1422         wxString AddressTimezone;
1423         wxString AddressType;
1424         wxString AddressMediatype;
1425         wxString AddressPOBox;
1426         wxString AddressExtended;
1427         wxString AddressStreet;
1428         wxString AddressLocality;
1429         wxString AddressCity;
1430         wxString AddressRegion;
1431         wxString AddressPostalCode;
1432         wxString AddressCountry;
1433         bool FirstToken = TRUE;                 
1434         int intSplitsFound = 0;
1435         int intSplitSize = 0;
1436         int intPrevValue = 5;
1437         int intPref = 0;                        
1438         int intType = 0;
1439         long ListCtrlIndex;
1440         
1441         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1442         
1443         intPrevValue = 4;
1444         
1445         PropertyType PropType = PROPERTY_NONE;
1446                 
1447         // Look for type before continuing.
1448         
1449         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1450         
1451         intPrevValue = 4;
1452         
1453         std::map<int, wxString> *AddressList = NULL;
1454         std::map<int, wxString> *AddressListTown = NULL;
1455         std::map<int, wxString> *AddressListCounty = NULL;
1456         std::map<int, wxString> *AddressListPostCode = NULL;
1457         std::map<int, wxString> *AddressListCountry = NULL;
1458         std::map<int, wxString> *AddressListLabel = NULL;
1459         std::map<int, wxString> *AddressListLang = NULL;                
1460         std::map<int, wxString> *AddressListAltID = NULL;
1461         std::map<int, wxString> *AddressListPID = NULL;
1462         std::map<int, wxString> *AddressListTokens = NULL;
1463         std::map<int, wxString> *AddressListGeo = NULL;
1464         std::map<int, wxString> *AddressListTimezone = NULL;            
1465         std::map<int, wxString> *AddressListType = NULL;
1466         std::map<int, wxString> *AddressListMediatype = NULL;
1467         std::map<int, int> *AddressListPref = NULL;
1469         switch(PropType){
1470                 case PROPERTY_NONE:
1471                         AddressList = &GeneralAddressList;
1472                         AddressListTown = &GeneralAddressListTown;
1473                         AddressListCounty = &GeneralAddressListCounty;
1474                         AddressListPostCode = &GeneralAddressListPostCode;
1475                         AddressListCountry = &GeneralAddressListCountry;
1476                         AddressListLabel = &GeneralAddressListLabel;
1477                         AddressListLang = &GeneralAddressListLang;              
1478                         AddressListAltID = &GeneralAddressListAltID;
1479                         AddressListPID = &GeneralAddressListPID;
1480                         AddressListTokens = &GeneralAddressListTokens;
1481                         AddressListGeo = &GeneralAddressListGeo;
1482                         AddressListTimezone = &GeneralAddressListTimezone;
1483                         AddressListType = &GeneralAddressListType;
1484                         AddressListMediatype = &GeneralAddressListMediatype;
1485                         AddressListPref = &GeneralAddressListPref;              
1486                         break;
1487                 case PROPERTY_HOME:
1488                         AddressList = &HomeAddressList;
1489                         AddressListTown = &HomeAddressListTown;
1490                         AddressListCounty = &HomeAddressListCounty;
1491                         AddressListPostCode = &HomeAddressListPostCode;
1492                         AddressListCountry = &HomeAddressListCountry;
1493                         AddressListLabel = &HomeAddressListLabel;
1494                         AddressListLang = &HomeAddressListLang;         
1495                         AddressListAltID = &HomeAddressListAltID;
1496                         AddressListPID = &HomeAddressListPID;
1497                         AddressListTokens = &HomeAddressListTokens;
1498                         AddressListGeo = &HomeAddressListGeo;
1499                         AddressListTimezone = &HomeAddressListTimezone;
1500                         AddressListType = &HomeAddressListType;
1501                         AddressListMediatype = &HomeAddressListMediatype;
1502                         AddressListPref = &HomeAddressListPref;
1503                         break;
1504                 case PROPERTY_WORK:
1505                         AddressList = &BusinessAddressList;
1506                         AddressListTown = &BusinessAddressListTown;
1507                         AddressListCounty = &BusinessAddressListCounty;
1508                         AddressListPostCode = &BusinessAddressListPostCode;
1509                         AddressListCountry = &BusinessAddressListCountry;
1510                         AddressListLabel = &BusinessAddressListLabel;
1511                         AddressListLang = &BusinessAddressListLang;             
1512                         AddressListAltID = &BusinessAddressListAltID;
1513                         AddressListPID = &BusinessAddressListPID;
1514                         AddressListTokens = &BusinessAddressListTokens;
1515                         AddressListGeo = &BusinessAddressListGeo;
1516                         AddressListTimezone = &BusinessAddressListTimezone;
1517                         AddressListType = &BusinessAddressListType;
1518                         AddressListMediatype = &BusinessAddressListMediatype;
1519                         AddressListPref = &BusinessAddressListPref;
1520                         break;
1521         }
1522         
1523         intPrevValue = 4;
1524         
1525         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1526         intiter != SplitPoints.end(); ++intiter){
1527         
1528                 SLiter = SplitLength.find(intiter->first);
1529         
1530                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1531                 
1532                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1533                 PropertyName = PropertyElement.GetNextToken();                          
1534                 PropertyValue = PropertyElement.GetNextToken();
1535                 
1536                 intPrevValue = intiter->second;
1537                 
1538                 CaptureString(&PropertyValue, FALSE);
1539                 
1540                 // Process properties.
1541                 
1542                 if (PropertyName == wxT("LABEL")){
1543                 
1544                         AddressListLabel->erase(*AddressCount);
1545                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1546                                 
1547                 } else if (PropertyName == wxT("LANGUAGE")){
1548                 
1549                         AddressListLang->erase(*AddressCount);
1550                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1551                 
1552                 } else if (PropertyName == wxT("ALTID")){
1554                         AddressListAltID->erase(*AddressCount);
1555                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1556                 
1557                 } else if (PropertyName == wxT("PID")){
1559                         AddressListPID->erase(*AddressCount);
1560                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1561                 
1562                 } else if (PropertyName == wxT("GEO")){
1563                 
1564                         AddressListGeo->erase(*AddressCount);
1565                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1566                 
1567                 } else if (PropertyName == wxT("TZ")){
1569                         AddressListTimezone->erase(*AddressCount);
1570                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1571                 
1572                 } else if (PropertyName == wxT("MEDIATYPE")){
1574                         AddressListMediatype->erase(*AddressCount);
1575                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1576                 
1577                 } else if (PropertyName == wxT("PREF")){
1578                         
1579                         int PriorityNumber = 0;
1580                         bool ValidNumber = TRUE;
1581                         
1582                         try{
1583                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1584                         }
1585                         
1586                         catch(std::invalid_argument &e){
1587                                 ValidNumber = FALSE;
1588                         }
1590                         if (ValidNumber == TRUE){
1592                                 AddressListPref->erase(*AddressCount);
1593                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1595                         }
1596                 
1597                 } else {
1598                 
1599                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1600                         
1601                                 if (FirstToken == TRUE){
1602                                 
1603                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1604                                         FirstToken = FALSE;
1605                                 
1606                                 } else {
1607                                 
1608                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1609                                 
1610                                 }
1611                         
1612                         }
1613                 
1614                 }
1615         
1616         }                       
1617         
1618         // Split the address. 
1620         //std::map<int, int>::iterator SLiter;
1621         intPropertyLen = PropertySeg2.Len();
1622         SplitPoints.clear();
1623         SplitLength.clear();
1624         intSplitsFound = 0;
1625         intSplitSize = 0;
1626         intPrevValue = 0;
1627         
1628         for (int i = 0; i <= intPropertyLen; i++){
1630                 intSplitSize++;
1631         
1632                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1633         
1634                         intSplitsFound++;
1635                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1636                         
1637                         if (intSplitsFound == 6){ 
1638                         
1639                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1640                                 break; 
1641                                 
1642                         } else {
1643                         
1644                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1645                         
1646                         }
1647                         
1648                         intSplitSize = 0;                                       
1649         
1650                 }
1652         }
1653         
1654         // Split the data into several parts.                   
1655         
1656         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1657         intiter != SplitPoints.end(); ++intiter){
1658                         
1659                 if (intiter->first == 1){
1660                 
1661                         // Deal with PO Box.
1662                         
1663                         SLiter = SplitLength.find(1);
1664                                                                 
1665                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1666                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1667                         intPrevValue = intiter->second;
1668                 
1669                 } else if (intiter->first == 2){
1670                 
1671                         // Deal with extended address.
1672                         
1673                         SLiter = SplitLength.find(2);
1674                         
1675                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1676                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1677                         intPrevValue = intiter->second;
1678                 
1679                 } else if (intiter->first == 3){
1680                 
1681                         // Deal with street address.
1682                         
1683                         SLiter = SplitLength.find(3);
1684                                                                 
1685                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1686                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1687                         intPrevValue = intiter->second;
1688                 
1689                 } else if (intiter->first == 4){
1690                 
1691                         // Deal with locality
1693                         SLiter = SplitLength.find(4);
1694                         
1695                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1696                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1697                         intPrevValue = intiter->second;
1698                         
1699                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1700                 
1701                 } else if (intiter->first == 5){
1702                 
1703                         // Deal with region.
1705                         SLiter = SplitLength.find(5);
1706                         
1707                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1708                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1709                         intPrevValue = intiter->second;
1710                         
1711                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1712                 
1713                 } else if (intiter->first == 6){
1714                 
1715                         // Deal with post code.
1717                         SLiter = SplitLength.find(6);
1718                         
1719                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1720                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1721                         intPrevValue = intiter->second;
1722                         
1723                         // Deal with country.
1724                                                 
1725                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1726                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1727                         
1728                         break;
1729                 
1730                 }
1731         
1732         }       
1733         
1734         // Add the data to the General/Home/Work address variables.
1735         
1736         CaptureString(&AddressStreet, FALSE); 
1737         CaptureString(&AddressLocality, FALSE);
1738         CaptureString(&AddressRegion, FALSE);
1739         CaptureString(&AddressPostalCode, FALSE);
1740         CaptureString(&AddressCountry, FALSE);
1741                 
1742         if (!PropertyTokens.IsEmpty()){
1743         
1744                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1745         
1746         }
1748         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1749         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1750         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1751         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1752         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1754         switch(PropType){
1755                 case PROPERTY_NONE:
1756                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1757                         break;
1758                 case PROPERTY_HOME:
1759                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1760                         break;
1761                 case PROPERTY_WORK:
1762                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1763                         break;
1764         }
1765         
1766         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1770 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1772         std::map<int, int> SplitPoints;
1773         std::map<int, int> SplitLength;
1775         int intPrevValue = 7;
1776         int intPref = 0;                        
1777         
1778         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1779         
1780         intPrevValue = 6;
1781         
1782         PropertyType PropType = PROPERTY_NONE;
1783                 
1784         // Look for type before continuing.
1785         
1786         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1787         
1788         std::map<int, wxString> *EmailList = NULL;
1789         std::map<int, wxString> *EmailListType = NULL;
1790         std::map<int, wxString> *EmailListAltID = NULL;
1791         std::map<int, wxString> *EmailListPID = NULL;
1792         std::map<int, wxString> *EmailListTokens = NULL;                
1793         std::map<int, int> *EmailListPref = NULL;
1795         switch(PropType){
1796                 case PROPERTY_NONE:
1797                         EmailList = &GeneralEmailList;
1798                         EmailListType = &GeneralEmailListType;
1799                         EmailListAltID = &GeneralEmailListAltID;
1800                         EmailListPID = &GeneralEmailListPID;
1801                         EmailListTokens = &GeneralEmailListTokens;              
1802                         EmailListPref = &GeneralEmailListPref;  
1803                         break;
1804                 case PROPERTY_HOME:
1805                         EmailList = &HomeEmailList;
1806                         EmailListType = &HomeEmailListType;
1807                         EmailListAltID = &HomeEmailListAltID;
1808                         EmailListPID = &HomeEmailListPID;
1809                         EmailListTokens = &HomeEmailListTokens;         
1810                         EmailListPref = &HomeEmailListPref;     
1811                         break;
1812                 case PROPERTY_WORK:
1813                         EmailList = &BusinessEmailList;
1814                         EmailListType = &BusinessEmailListType;
1815                         EmailListAltID = &BusinessEmailListAltID;
1816                         EmailListPID = &BusinessEmailListPID;
1817                         EmailListTokens = &BusinessEmailListTokens;             
1818                         EmailListPref = &BusinessEmailListPref; 
1819                         break;
1820         }
1821         
1822         intPrevValue = 6;
1823         
1824         std::map<int,int>::iterator SLiter;
1825         wxString PropertyData;
1826         wxString PropertyName;
1827         wxString PropertyValue;
1828         wxString PropertyTokens;
1829         bool FirstToken = TRUE;
1830         
1831         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1832         intiter != SplitPoints.end(); ++intiter){
1833         
1834                 SLiter = SplitLength.find(intiter->first);
1835         
1836                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1837                 
1838                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1839                 PropertyName = PropertyElement.GetNextToken();                          
1840                 PropertyValue = PropertyElement.GetNextToken();
1841                 
1842                 intPrevValue = intiter->second;
1843                 
1844                 CaptureString(&PropertyValue, FALSE);
1845                 
1846                 // Process properties.
1847                 
1848                 if (PropertyName == wxT("ALTID")){
1850                         EmailListAltID->erase(*EmailCount);
1851                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1852                 
1853                 } else if (PropertyName == wxT("PID")){
1855                         EmailListPID->erase(*EmailCount);
1856                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1857                 
1858                 } else if (PropertyName == wxT("PREF")){
1859                         
1860                         int PriorityNumber = 0;
1861                         bool ValidNumber = TRUE;
1862                         
1863                         try{
1864                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1865                         }
1866                         
1867                         catch(std::invalid_argument &e){
1868                                 ValidNumber = FALSE;
1869                         }
1871                         if (ValidNumber == TRUE){
1873                                 EmailListPref->erase(*EmailCount);
1874                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1876                         }
1877                 
1878                 } else {
1879                 
1880                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1881                         
1882                                 if (FirstToken == TRUE){
1883                                 
1884                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1885                                         FirstToken = FALSE;
1886                                 
1887                                 } else {
1888                                 
1889                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1890                                 
1891                                 }
1892                         
1893                         }
1894                 
1895                 }
1896         
1897         }
1898         
1899         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1900         
1901         // Add the name token data.
1902         
1903         if (!PropertyTokens.IsEmpty()){
1904         
1905                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1906         
1907         }       
1912 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1914         std::map<int, int> SplitPoints;
1915         std::map<int, int> SplitLength;
1917         int intPrevValue = 6;
1918         int intPref = 0;                        
1919         
1920         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1921         
1922         intPrevValue = 5;
1923         
1924         PropertyType PropType = PROPERTY_NONE;
1925                 
1926         // Look for type before continuing.
1927         
1928         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1929         
1930         std::map<int, wxString> *IMList = NULL;
1931         std::map<int, wxString> *IMListType = NULL;
1932         std::map<int, wxString> *IMListAltID = NULL;
1933         std::map<int, wxString> *IMListPID = NULL;
1934         std::map<int, wxString> *IMListTokens = NULL;
1935         std::map<int, wxString> *IMListMediatype = NULL;        
1936         std::map<int, int> *IMListPref = NULL;
1938         switch(PropType){
1939                 case PROPERTY_NONE:
1940                         IMList = &GeneralIMList;
1941                         IMListType = &GeneralIMListType;
1942                         IMListAltID = &GeneralIMListAltID;
1943                         IMListPID = &GeneralIMListPID;
1944                         IMListTokens = &GeneralIMListTokens;
1945                         IMListMediatype = &GeneralIMListMediatype;
1946                         IMListPref = &GeneralIMListPref;        
1947                         break;
1948                 case PROPERTY_HOME:
1949                         IMList = &HomeIMList;
1950                         IMListType = &HomeIMListType;
1951                         IMListAltID = &HomeIMListAltID;
1952                         IMListPID = &HomeIMListPID;
1953                         IMListTokens = &HomeIMListTokens;
1954                         IMListMediatype = &HomeIMListMediatype;         
1955                         IMListPref = &HomeIMListPref;   
1956                         break;
1957                 case PROPERTY_WORK:
1958                         IMList = &BusinessIMList;
1959                         IMListType = &BusinessIMListType;
1960                         IMListAltID = &BusinessIMListAltID;
1961                         IMListPID = &BusinessIMListPID;
1962                         IMListTokens = &BusinessIMListTokens;   
1963                         IMListMediatype = &BusinessIMListMediatype;     
1964                         IMListPref = &BusinessIMListPref;       
1965                         break;
1966         }
1967         
1968         intPrevValue = 5;
1969         
1970         std::map<int,int>::iterator SLiter;
1971         wxString PropertyData;
1972         wxString PropertyName;
1973         wxString PropertyValue;
1974         wxString PropertyTokens;
1975         bool FirstToken = TRUE;
1976         
1977         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1978         intiter != SplitPoints.end(); ++intiter){
1979         
1980                 SLiter = SplitLength.find(intiter->first);
1981         
1982                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1983                 
1984                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1985                 PropertyName = PropertyElement.GetNextToken();                          
1986                 PropertyValue = PropertyElement.GetNextToken();
1987                 
1988                 intPrevValue = intiter->second;
1989                 
1990                 CaptureString(&PropertyValue, FALSE);
1991                 
1992                 // Process properties.
1993                 
1994                 if (PropertyName == wxT("ALTID")){
1996                         IMListAltID->erase(*IMCount);
1997                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1998                 
1999                 } else if (PropertyName == wxT("PID")){
2001                         IMListPID->erase(*IMCount);
2002                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2003                 
2004                 } else if (PropertyName == wxT("MEDIATYPE")){
2006                         IMListMediatype->erase(*IMCount);
2007                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2008                 
2009                 } else if (PropertyName == wxT("PREF")){
2010                         
2011                         int PriorityNumber = 0;
2012                         bool ValidNumber = TRUE;
2013                         
2014                         try{
2015                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2016                         }
2017                         
2018                         catch(std::invalid_argument &e){
2019                                 ValidNumber = FALSE;
2020                         }
2022                         if (ValidNumber == TRUE){
2024                                 IMListPref->erase(*IMCount);
2025                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2027                         }
2028                 
2029                 } else {
2030                 
2031                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2032                         
2033                                 if (FirstToken == TRUE){
2034                                 
2035                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2036                                         FirstToken = FALSE;
2037                                 
2038                                 } else {
2039                                 
2040                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2041                                 
2042                                 }
2043                         
2044                         }
2045                 
2046                 }
2047         
2048         }
2049                 
2050         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2051         
2052         // Add the name token data.
2053         
2054         if (!PropertyTokens.IsEmpty()){
2055         
2056                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2057         
2058         }
2062 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2064         std::map<int, int> SplitPoints;
2065         std::map<int, int> SplitLength;
2066         std::map<int, int>::iterator SLiter;
2067         
2068         int intPref = 0;
2069         
2070         PropertyType PropType = PROPERTY_NONE;
2071                 
2072         // Look for type before continuing.
2073         
2074         wxString TelTypeUI;
2075         wxString TelTypeDetail;
2076         wxString PropertyData;
2077         wxString PropertyName;
2078         wxString PropertyValue;
2079         wxString PropertyTokens;
2080         
2081         std::map<int,int> TypeSplitPoints;
2082         std::map<int,int> TypeSplitLength;
2083         std::map<int,int>::iterator TSLiter;
2084         
2085         int intSplitSize = 0;
2086         int intSplitsFound = 0;
2087         int intSplitPoint = 0;
2088         int intType = 0;
2089         int intPrevValue = 5;
2090                 
2091         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2092         
2093         intPrevValue = 4;
2094         
2095         // Look for type before continuing.
2096         
2097         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2098         intiter != SplitPoints.end(); ++intiter){
2099         
2100                 SLiter = SplitLength.find(intiter->first);
2101         
2102                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2103                 
2104                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2105                 PropertyName = PropertyElement.GetNextToken();                          
2106                 PropertyValue = PropertyElement.GetNextToken();
2107                 
2108                 intPrevValue = intiter->second;
2110                 if (PropertyName == wxT("TYPE")){
2111                 
2112                         // Process each value in type and translate each
2113                         // part.
2114                 
2115                         // Strip out the quotes if they are there.
2116                 
2117                         size_t intPropertyValueLen = PropertyValue.Len();
2118                 
2119                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2120                         
2121                                 PropertyValue.Trim();
2122                                 PropertyValue.RemoveLast();
2123                         
2124                         }                               
2125                 
2126                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2127                         
2128                                 PropertyValue.Remove(0, 1);
2129                         
2130                         }
2131                         
2132                         TelTypeDetail = PropertyValue;
2133                         
2134                         intSplitSize = 0;
2135                         intSplitsFound = 0;
2136                         intSplitPoint = 0;
2137                         
2138                         for (int i = 0; i <= intPropertyValueLen; i++){
2139         
2140                                 intSplitSize++;
2141         
2142                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2143         
2144                                         if (intSplitsFound == 0){
2146                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2147                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2148                         
2149                                         } else {
2150                         
2151                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2152                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2153                         
2154                                         }                       
2156                                         intSplitsFound++;
2157                                         i++;
2158                                         intSplitPoint = i;
2159                                         intSplitSize = 0;
2160         
2161                                 }
2162         
2163                         }
2164                         
2165                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2166                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2167                 
2168                         int intTypeSeek = 0;
2169                 
2170                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2171                         typeiter != TypeSplitPoints.end(); ++typeiter){
2172                         
2173                                 wxString TypePropertyName;
2174                                 
2175                                 TSLiter = TypeSplitLength.find(typeiter->first);
2176                                 
2177                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2178                                 
2179                                 if (intTypeSeek == 0){
2180                                 
2181                                 
2182                                 } else {
2183                                                                                 
2184                                         TelTypeUI.Append(wxT(","));                                                     
2185                                 
2186                                 }
2187                         
2188                                 if (TypePropertyName == wxT("home")){
2189                                 
2190                                         PropType = PROPERTY_HOME;
2191                                 
2192                                 } else if (TypePropertyName == wxT("work")){
2193                                 
2194                                         PropType = PROPERTY_WORK;
2195                                                                         
2196                                 }
2197                                 
2198                                 
2199                                 if (TypePropertyName == wxT("text")){
2200                                 
2201                                         TelTypeUI.Append(_("text"));
2202                                         intTypeSeek++;
2203                                 
2204                                 } else if (TypePropertyName == wxT("voice")){
2205                                 
2206                                         TelTypeUI.Append(_("voice"));
2207                                         intTypeSeek++;
2208                                 
2209                                 } else if (TypePropertyName == wxT("fax")){
2210                                 
2211                                         TelTypeUI.Append(_("fax"));
2212                                         intTypeSeek++;
2213                                 
2214                                 } else if (TypePropertyName == wxT("cell")){
2215                                 
2216                                         TelTypeUI.Append(_("mobile"));
2217                                         intTypeSeek++;
2218                                 
2219                                 } else if (TypePropertyName == wxT("video")){
2220                                 
2221                                         TelTypeUI.Append(_("video"));
2222                                         intTypeSeek++;
2223                                 
2224                                 } else if (TypePropertyName == wxT("pager")){
2225                                 
2226                                         TelTypeUI.Append(_("pager"));
2227                                         intTypeSeek++;
2228                                 
2229                                 } else if (TypePropertyName == wxT("textphone")){
2230                                 
2231                                         TelTypeUI.Append(_("textphone"));
2232                                         intTypeSeek++;
2233                                 
2234                                 }
2235                         
2236                         }
2237                 
2238                 }
2239                 
2240         }
2241         
2242         std::map<int, wxString> *TelephoneList = NULL;
2243         std::map<int, wxString> *TelephoneListType = NULL;
2244         std::map<int, wxString> *TelephoneListAltID = NULL;
2245         std::map<int, wxString> *TelephoneListPID = NULL;
2246         std::map<int, wxString> *TelephoneListTokens = NULL;
2247         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2248         std::map<int, int> *TelephoneListPref = NULL;
2250         switch(PropType){
2251                 case PROPERTY_NONE:
2252                         TelephoneList = &GeneralTelephoneList;
2253                         TelephoneListType = &GeneralTelephoneListType;
2254                         TelephoneListAltID = &GeneralTelephoneListAltID;
2255                         TelephoneListPID = &GeneralTelephoneListPID;
2256                         TelephoneListTokens = &GeneralTelephoneListTokens;
2257                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2258                         TelephoneListPref = &GeneralTelephoneListPref;  
2259                         break;
2260                 case PROPERTY_HOME:
2261                         TelephoneList = &HomeTelephoneList;
2262                         TelephoneListType = &HomeTelephoneListType;
2263                         TelephoneListAltID = &HomeTelephoneListAltID;
2264                         TelephoneListPID = &HomeTelephoneListPID;
2265                         TelephoneListTokens = &HomeTelephoneListTokens;
2266                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2267                         TelephoneListPref = &HomeTelephoneListPref;     
2268                         break;
2269                 case PROPERTY_WORK:
2270                         TelephoneList = &BusinessTelephoneList;
2271                         TelephoneListType = &BusinessTelephoneListType;
2272                         TelephoneListAltID = &BusinessTelephoneListAltID;
2273                         TelephoneListPID = &BusinessTelephoneListPID;
2274                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2275                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2276                         TelephoneListPref = &BusinessTelephoneListPref; 
2277                         break;
2278         }
2279                 
2280         // Process the properties.
2281         
2282         bool FirstToken = TRUE;
2283         
2284         intPrevValue = 5;
2285         SplitPoints.clear();
2286         SplitLength.clear();
2288         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2290         intPrevValue = 4;
2291         
2292         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2293         intiter != SplitPoints.end(); ++intiter){
2294         
2295                 SLiter = SplitLength.find(intiter->first);
2296         
2297                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2298                 
2299                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2300                 PropertyName = PropertyElement.GetNextToken();                          
2301                 PropertyValue = PropertyElement.GetNextToken();
2302                 
2303                 intPrevValue = intiter->second;
2304                 
2305                 CaptureString(&PropertyValue, FALSE);
2306                 
2307                 // Process properties.
2308                 
2309                 if (PropertyName == wxT("ALTID")){
2311                         TelephoneListAltID->erase(*TelephoneCount);
2312                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2313                 
2314                 } else if (PropertyName == wxT("PID")){
2316                         TelephoneListPID->erase(*TelephoneCount);
2317                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2318                 
2319                 } else if (PropertyName == wxT("PREF")){
2320                         
2321                         int PriorityNumber = 0;
2322                         bool ValidNumber = TRUE;
2323                         
2324                         try{
2325                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2326                         }
2327                         
2328                         catch(std::invalid_argument &e){
2329                                 ValidNumber = FALSE;
2330                         }
2332                         if (ValidNumber == TRUE){
2334                                 TelephoneListPref->erase(*TelephoneCount);
2335                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2337                         }
2338                 
2339                 } else {
2340                 
2341                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2342                         
2343                                 if (FirstToken == TRUE){
2344                                 
2345                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2346                                         FirstToken = FALSE;
2347                                 
2348                                 } else {
2349                                 
2350                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2351                                 
2352                                 }
2353                         
2354                         }
2355                 
2356                 }
2357         
2358         }
2359                 
2360         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2361         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2362         
2363         // Add the name token data.
2364         
2365         if (!PropertyTokens.IsEmpty()){
2366         
2367                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2368         
2369         }
2373 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2375         std::map<int, int> SplitPoints;
2376         std::map<int, int> SplitLength;
2378         int intPrevValue = 6;
2379         int intPref = 0;                        
2380         
2381         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2382         
2383         intPrevValue = 5;
2384         
2385         PropertyType PropType = PROPERTY_NONE;
2386                 
2387         // Look for type before continuing.
2388         
2389         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2390         
2391         std::map<int, wxString> *LanguageList = NULL;
2392         std::map<int, wxString> *LanguageListType = NULL;
2393         std::map<int, wxString> *LanguageListAltID = NULL;
2394         std::map<int, wxString> *LanguageListPID = NULL;
2395         std::map<int, wxString> *LanguageListTokens = NULL;
2396         std::map<int, int> *LanguageListPref = NULL;
2398         switch(PropType){
2399                 case PROPERTY_NONE:
2400                         LanguageList = &GeneralLanguageList;
2401                         LanguageListType = &GeneralLanguageListType;
2402                         LanguageListAltID = &GeneralLanguageListAltID;
2403                         LanguageListPID = &GeneralLanguageListPID;
2404                         LanguageListTokens = &GeneralLanguageListTokens;
2405                         LanguageListPref = &GeneralLanguageListPref;    
2406                         break;
2407                 case PROPERTY_HOME:
2408                         LanguageList = &HomeLanguageList;
2409                         LanguageListType = &HomeLanguageListType;
2410                         LanguageListAltID = &HomeLanguageListAltID;
2411                         LanguageListPID = &HomeLanguageListPID;
2412                         LanguageListTokens = &HomeLanguageListTokens;   
2413                         LanguageListPref = &HomeLanguageListPref;       
2414                         break;
2415                 case PROPERTY_WORK:
2416                         LanguageList = &BusinessLanguageList;
2417                         LanguageListType = &BusinessLanguageListType;
2418                         LanguageListAltID = &BusinessLanguageListAltID;
2419                         LanguageListPID = &BusinessLanguageListPID;
2420                         LanguageListTokens = &BusinessLanguageListTokens;       
2421                         LanguageListPref = &BusinessLanguageListPref;
2422                         break;
2423         }
2424         
2425         intPrevValue = 5;
2426         
2427         std::map<int,int>::iterator SLiter;
2428         wxString PropertyData;
2429         wxString PropertyName;
2430         wxString PropertyValue;
2431         wxString PropertyTokens;
2432         bool FirstToken = TRUE;
2433         
2434         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2435         intiter != SplitPoints.end(); ++intiter){
2436         
2437                 SLiter = SplitLength.find(intiter->first);
2438         
2439                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2440                 
2441                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2442                 PropertyName = PropertyElement.GetNextToken();                          
2443                 PropertyValue = PropertyElement.GetNextToken();
2444                 
2445                 intPrevValue = intiter->second;
2446                 
2447                 CaptureString(&PropertyValue, FALSE);
2448                 
2449                 // Process properties.
2450                 
2451                 if (PropertyName == wxT("ALTID")){
2453                         LanguageListAltID->erase(*LanguageCount);
2454                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2455                 
2456                 } else if (PropertyName == wxT("PID")){
2458                         LanguageListPID->erase(*LanguageCount);
2459                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2460                 
2461                 } else if (PropertyName == wxT("PREF")){
2462                         
2463                         int PriorityNumber = 0;
2464                         bool ValidNumber = TRUE;
2465                         
2466                         try{
2467                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2468                         }
2469                         
2470                         catch(std::invalid_argument &e){
2471                                 ValidNumber = FALSE;
2472                         }
2474                         if (ValidNumber == TRUE){
2476                                 LanguageListPref->erase(*LanguageCount);
2477                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2479                         }
2480                 
2481                 } else {
2482                 
2483                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2484                         
2485                                 if (FirstToken == TRUE){
2486                                 
2487                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2488                                         FirstToken = FALSE;
2489                                 
2490                                 } else {
2491                                 
2492                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2493                                 
2494                                 }
2495                         
2496                         }
2497                 
2498                 }
2499         
2500         }
2501                 
2502         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2503         
2504         // Add the name token data.
2505         
2506         if (!PropertyTokens.IsEmpty()){
2507         
2508                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2509         
2510         }
2514 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2516         std::map<int, int> SplitPoints;
2517         std::map<int, int> SplitLength;
2519         int intPrevValue = 5;
2520         int intPref = 0;                        
2521         
2522         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2523         
2524         intPrevValue = 4;
2525         
2526         PropertyType PropType = PROPERTY_NONE;
2527                 
2528         // Look for type before continuing.
2529         
2530         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2531         
2532         std::map<int, wxString> *GeopositionList = NULL;
2533         std::map<int, wxString> *GeopositionListType = NULL;
2534         std::map<int, wxString> *GeopositionListAltID = NULL;
2535         std::map<int, wxString> *GeopositionListPID = NULL;
2536         std::map<int, wxString> *GeopositionListTokens = NULL;
2537         std::map<int, wxString> *GeopositionListMediatype = NULL;
2538         std::map<int, int> *GeopositionListPref = NULL;
2540         switch(PropType){
2541                 case PROPERTY_NONE:
2542                         GeopositionList = &GeneralGeographyList;
2543                         GeopositionListType = &GeneralGeographyListType;
2544                         GeopositionListAltID = &GeneralGeographyListAltID;
2545                         GeopositionListPID = &GeneralGeographyListPID;
2546                         GeopositionListTokens = &GeneralGeographyListTokens;
2547                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2548                         GeopositionListPref = &GeneralGeographyListPref;        
2549                         break;
2550                 case PROPERTY_HOME:
2551                         GeopositionList = &HomeGeographyList;
2552                         GeopositionListType = &HomeGeographyListType;
2553                         GeopositionListAltID = &HomeGeographyListAltID;
2554                         GeopositionListPID = &HomeGeographyListPID;
2555                         GeopositionListTokens = &HomeGeographyListTokens;
2556                         GeopositionListMediatype = &HomeGeographyListMediatype;
2557                         GeopositionListPref = &HomeGeographyListPref;   
2558                         break;
2559                 case PROPERTY_WORK:
2560                         GeopositionList = &BusinessGeographyList;
2561                         GeopositionListType = &BusinessGeographyListType;
2562                         GeopositionListAltID = &BusinessGeographyListAltID;
2563                         GeopositionListPID = &BusinessGeographyListPID;
2564                         GeopositionListTokens = &BusinessGeographyListTokens;
2565                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2566                         GeopositionListPref = &BusinessGeographyListPref;
2567                         break;
2568         }
2569         
2570         intPrevValue = 4;
2571         
2572         std::map<int,int>::iterator SLiter;
2573         wxString PropertyData;
2574         wxString PropertyName;
2575         wxString PropertyValue;
2576         wxString PropertyTokens;
2577         bool FirstToken = TRUE;
2578         
2579         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2580         intiter != SplitPoints.end(); ++intiter){
2581         
2582                 SLiter = SplitLength.find(intiter->first);
2583         
2584                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2585                 
2586                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2587                 PropertyName = PropertyElement.GetNextToken();                          
2588                 PropertyValue = PropertyElement.GetNextToken();
2589                 
2590                 intPrevValue = intiter->second;
2591                 
2592                 CaptureString(&PropertyValue, FALSE);
2593                 
2594                 // Process properties.
2595                 
2596                 if (PropertyName == wxT("ALTID")){
2598                         GeopositionListAltID->erase(*GeographicCount);
2599                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2600                 
2601                 } else if (PropertyName == wxT("PID")){
2603                         GeopositionListPID->erase(*GeographicCount);
2604                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2605                 
2606                 } else if (PropertyName == wxT("MEDIATYPE")){
2608                         GeopositionListMediatype->erase(*GeographicCount);
2609                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2610                 
2611                 } else if (PropertyName == wxT("PREF")){
2612                         
2613                         int PriorityNumber = 0;
2614                         bool ValidNumber = TRUE;
2615                         
2616                         try{
2617                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2618                         }
2619                         
2620                         catch(std::invalid_argument &e){
2621                                 ValidNumber = FALSE;
2622                         }
2624                         if (ValidNumber == TRUE){
2626                                 GeopositionListPref->erase(*GeographicCount);
2627                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2629                         }
2630                 
2631                 } else {
2632                 
2633                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2634                         
2635                                 if (FirstToken == TRUE){
2636                                 
2637                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2638                                         FirstToken = FALSE;
2639                                 
2640                                 } else {
2641                                 
2642                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2643                                 
2644                                 }
2645                         
2646                         }
2647                 
2648                 }
2649         
2650         }
2651                 
2652         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2653         
2654         // Add the name token data.
2655         
2656         if (!PropertyTokens.IsEmpty()){
2657         
2658                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2659         
2660         }
2664 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2666         size_t intPropertyLen = PropertySeg1.Len();
2667         std::map<int, int> SplitPoints;
2668         std::map<int, int> SplitLength;
2669         std::map<int, int>::iterator SLiter;                    
2670         wxString PropertyData;
2671         wxString PropertyName;
2672         wxString PropertyValue;
2673         wxString PropertyTokens;
2674         wxString RelatedType;
2675         wxString RelatedTypeOriginal;                   
2676         wxString RelatedName;
2677         bool FirstToken = TRUE;                 
2678         int intSplitsFound = 0;
2679         int intSplitSize = 0;
2680         int intPrevValue = 9;
2681         int intPref = 0;
2682         long ListCtrlIndex;
2683         
2684         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2685         
2686         intPrevValue = 8;
2687         
2688         // Look for type before continuing.
2689         
2690         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2691         intiter != SplitPoints.end(); ++intiter){
2692         
2693                 SLiter = SplitLength.find(intiter->first);
2694         
2695                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2696                 
2697                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2698                 PropertyName = PropertyElement.GetNextToken();                          
2699                 PropertyValue = PropertyElement.GetNextToken();
2700                 
2701                 intPrevValue = intiter->second;
2702                 
2703                 // Process these.
2704                 
2705                 RelatedTypeOriginal = PropertyValue;
2706                 
2707                 if (PropertyName == wxT("TYPE")){
2708                 
2709                         if (PropertyValue == wxT("contact")){
2711                                 RelatedType = _("Contact");
2713                         } else if (PropertyValue == wxT("acquaintance")){
2715                                 RelatedType = _("Acquaintance");
2717                         } else if (PropertyValue == wxT("friend")){
2719                                 RelatedType = _("Friend");
2721                         } else if (PropertyValue == wxT("met")){
2723                                 RelatedType = _("Met");
2725                         } else if (PropertyValue == wxT("co-worker")){
2727                                 RelatedType = _("Co-worker");
2729                         } else if (PropertyValue == wxT("colleague")){
2731                                 RelatedType = _("Colleague");
2733                         } else if (PropertyValue == wxT("co-resident")){
2735                                 RelatedType = _("Co-resident");
2737                         } else if (PropertyValue == wxT("neighbor")){
2739                                 RelatedType = _("Neighbour");
2741                         } else if (PropertyValue == wxT("child")){
2743                                 RelatedType = _("Child");
2745                         } else if (PropertyValue == wxT("parent")){
2747                                 RelatedType = _("Parent");
2749                         } else if (PropertyValue == wxT("sibling")){
2751                                 RelatedType = _("Sibling");
2753                         } else if (PropertyValue == wxT("spouse")){
2755                                 RelatedType = _("Spouse");
2757                         } else if (PropertyValue == wxT("kin")){
2759                                 RelatedType = _("Kin");
2761                         } else if (PropertyValue == wxT("muse")){
2763                                 RelatedType = _("Muse");
2765                         } else if (PropertyValue == wxT("crush")){
2767                                 RelatedType = _("Crush");
2769                         } else if (PropertyValue == wxT("date")){
2771                                 RelatedType = _("Date");
2773                         } else if (PropertyValue == wxT("sweetheart")){
2775                                 RelatedType = _("Sweetheart");
2777                         } else if (PropertyValue == wxT("me")){
2779                                 RelatedType = _("Me");
2781                         } else if (PropertyValue == wxT("agent")){
2783                                 RelatedType = _("Agent");
2785                         } else if (PropertyValue == wxT("emergency")){
2787                                 RelatedType = _("Emergency");
2789                         } else {
2791                                 RelatedType = PropertyValue;
2793                         }
2794                 
2795                 }
2796         
2797         }
2798         
2799         intPrevValue = 8;                       
2800         
2801         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2802         intiter != SplitPoints.end(); ++intiter){
2803         
2804                 SLiter = SplitLength.find(intiter->first);
2805         
2806                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2807                 
2808                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2809                 PropertyName = PropertyElement.GetNextToken();                          
2810                 PropertyValue = PropertyElement.GetNextToken();
2811                 
2812                 intPrevValue = intiter->second;
2813                 
2814                 // Process properties.
2815                 
2816                 size_t intPropertyValueLen = PropertyValue.Len();
2817                 
2818                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2819                         
2820                         PropertyValue.Trim();
2821                         PropertyValue.RemoveLast();
2822                         
2823                 }                               
2824                 
2825                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2826                         
2827                         PropertyValue.Remove(0, 1);
2828                         
2829                 }
2830                 
2831                 CaptureString(&PropertyValue, FALSE);
2832                         
2833                 if (PropertyName == wxT("ALTID")){
2835                         GeneralRelatedListAltID.erase(*RelatedCount);
2836                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2837                 
2838                 } else if (PropertyName == wxT("PID")){
2840                         GeneralRelatedListPID.erase(*RelatedCount);
2841                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2842                 
2843                 } else if (PropertyName == wxT("PREF")){
2844                         
2845                         int PriorityNumber = 0;
2846                         bool ValidNumber = TRUE;
2847                         
2848                         try{
2849                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2850                         }
2851                         
2852                         catch(std::invalid_argument &e){
2853                                 ValidNumber = FALSE;
2854                         }
2856                         if (ValidNumber == TRUE){
2858                                 GeneralRelatedListPref.erase(*RelatedCount);
2859                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2861                         }
2862                 
2863                 } else if (PropertyName == wxT("LANGUAGE")){
2864                 
2865                         GeneralRelatedListLanguage.erase(*RelatedCount);
2866                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2867                 
2868                 } else if (PropertyName != wxT("TYPE")) {
2869                 
2870                         // Something else we don't know about so append
2871                         // to the tokens variable.
2872                 
2873                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2874                 
2875                                 if (FirstToken == TRUE){
2876                         
2877                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2878                                         FirstToken = FALSE;
2879                         
2880                                 } else {
2881                         
2882                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2883                         
2884                                 }
2885                 
2886                         }
2887                 
2888                 }
2889         
2890         }                                       
2891         
2892         // Add the data to the General/Home/Work address variables.
2893                                 
2894         GeneralRelatedList.erase(*RelatedCount);
2895         GeneralRelatedListRelType.erase(*RelatedCount);
2896         GeneralRelatedListType.erase(*RelatedCount);
2897         GeneralRelatedListTokens.erase(*RelatedCount);
2898         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2899         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2900         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2901         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2905 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2907         std::map<int, int> SplitPoints;
2908         std::map<int, int> SplitLength;
2909         std::map<int, int>::iterator SLiter;                    
2910         wxString PropertyData;
2911         wxString PropertyName;
2912         wxString PropertyValue;
2913         wxString PropertyTokens;
2914         bool FirstToken = TRUE;
2915         int intPrevValue = 5;
2916         int intPref = 0;                        
2917         int intType = 0;
2918         long ListCtrlIndex;
2919         
2920         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2921         
2922         intPrevValue = 4;
2923         
2924         PropertyType PropType = PROPERTY_NONE;
2925                 
2926         // Look for type before continuing.
2927         
2928         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2929         
2930         // Setup the pointers.
2931         
2932         std::map<int, wxString> *WebsiteList = NULL;
2933         std::map<int, wxString> *WebsiteListAltID = NULL;
2934         std::map<int, wxString> *WebsiteListPID = NULL;
2935         std::map<int, wxString> *WebsiteListType = NULL;
2936         std::map<int, wxString> *WebsiteListTokens = NULL;
2937         std::map<int, wxString> *WebsiteListMediatype = NULL;
2938         std::map<int, int> *WebsiteListPref = NULL;
2939         
2940         // Setup blank lines for later on.
2941         
2942         switch(PropType){
2943                 case PROPERTY_NONE:
2944                         WebsiteList = &GeneralWebsiteList;
2945                         WebsiteListType = &GeneralWebsiteListType;
2946                         WebsiteListAltID = &GeneralWebsiteListAltID;
2947                         WebsiteListPID = &GeneralWebsiteListPID;
2948                         WebsiteListTokens = &GeneralWebsiteListTokens;
2949                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2950                         WebsiteListPref = &GeneralWebsiteListPref;      
2951                         break;
2952                 case PROPERTY_HOME:
2953                         WebsiteList = &HomeWebsiteList;
2954                         WebsiteListType = &HomeWebsiteListType;
2955                         WebsiteListAltID = &HomeWebsiteListAltID;
2956                         WebsiteListPID = &HomeWebsiteListPID;
2957                         WebsiteListTokens = &HomeWebsiteListTokens;
2958                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2959                         WebsiteListPref = &HomeWebsiteListPref; 
2960                         break;
2961                 case PROPERTY_WORK:
2962                         WebsiteList = &BusinessWebsiteList;
2963                         WebsiteListType = &BusinessWebsiteListType;
2964                         WebsiteListAltID = &BusinessWebsiteListAltID;
2965                         WebsiteListPID = &BusinessWebsiteListPID;
2966                         WebsiteListTokens = &BusinessWebsiteListTokens;
2967                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2968                         WebsiteListPref = &BusinessWebsiteListPref;
2969                         break;
2970         }
2971         
2972         intPrevValue = 4;
2973         
2974         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2975         intiter != SplitPoints.end(); ++intiter){
2976         
2977                 SLiter = SplitLength.find(intiter->first);
2978         
2979                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2980                 
2981                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2982                 PropertyName = PropertyElement.GetNextToken();                          
2983                 PropertyValue = PropertyElement.GetNextToken();
2984                 
2985                 intPrevValue = intiter->second;
2986                 
2987                 // Process properties.
2988                 
2989                 size_t intPropertyValueLen = PropertyValue.Len();
2990                 
2991                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2992                         
2993                         PropertyValue.Trim();
2994                         PropertyValue.RemoveLast();
2995                         
2996                 }                               
2997                 
2998                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2999                         
3000                         PropertyValue.Remove(0, 1);
3001                         
3002                 }
3003                 
3004                 CaptureString(&PropertyValue, FALSE);
3005                 
3006                 if (PropertyName == wxT("ALTID")){
3008                         WebsiteListAltID->erase(*URLCount);
3009                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3010                 
3011                 } else if (PropertyName == wxT("PID")){
3013                         WebsiteListPID->erase(*URLCount);
3014                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3015                         
3016                 } else if (PropertyName == wxT("PREF")){
3017                         
3018                         int PriorityNumber = 0;
3019                         bool ValidNumber = TRUE;
3020                         
3021                         try{
3022                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3023                         }
3024                         
3025                         catch(std::invalid_argument &e){
3026                                 ValidNumber = FALSE;
3027                         }
3029                         if (ValidNumber == TRUE){
3031                                 WebsiteListPref->erase(*URLCount);
3032                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3034                         }
3035                                         
3036                 } else if (PropertyName == wxT("MEDIATYPE")){
3037                 
3038                         WebsiteListMediatype->erase(*URLCount);
3039                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3040                 
3041                 } else {
3042                 
3043                         // Something else we don't know about so append
3044                         // to the tokens variable.
3045                 
3046                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3047                 
3048                                 if (FirstToken == TRUE){
3049                         
3050                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3051                                         FirstToken = FALSE;
3052                         
3053                                 } else {
3054                         
3055                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3056                         
3057                                 }
3058                 
3059                         }
3060                 
3061                 }
3062         
3063         }
3064         
3065         // Add the data to the General/Home/Work address variables.
3066         
3067         CaptureString(&PropertySeg2, FALSE);
3068                         
3069         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3070         
3071         if (!PropertyTokens.IsEmpty()){
3072         
3073                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3074                         
3075         }
3076         
3079 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3081         std::map<int, int> SplitPoints;
3082         std::map<int, int> SplitLength;
3083         std::map<int, int>::iterator SLiter;                    
3084         wxString PropertyData;
3085         wxString PropertyName;
3086         wxString PropertyValue;
3087         wxString PropertyTokens;
3088         bool FirstToken = TRUE;
3089         int intPrevValue = 7;
3090         int intPref = 0;                        
3091         int intType = 0;
3092         long ListCtrlIndex;
3093         
3094         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3095         
3096         intPrevValue = 6;
3097         
3098         PropertyType PropType = PROPERTY_NONE;
3099                 
3100         // Look for type before continuing.
3101         
3102         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3103         
3104         // Setup the pointers.
3105         
3106         std::map<int, wxString> *TitleList = NULL;
3107         std::map<int, wxString> *TitleListAltID = NULL;
3108         std::map<int, wxString> *TitleListPID = NULL;
3109         std::map<int, wxString> *TitleListType = NULL;
3110         std::map<int, wxString> *TitleListTokens = NULL;
3111         std::map<int, wxString> *TitleListLanguage = NULL;
3112         std::map<int, int> *TitleListPref = NULL;
3113         
3114         // Setup blank lines for later on.
3115         
3116         switch(PropType){
3117                 case PROPERTY_NONE:
3118                         TitleList = &GeneralTitleList;
3119                         TitleListType = &GeneralTitleListType;
3120                         TitleListAltID = &GeneralTitleListAltID;
3121                         TitleListPID = &GeneralTitleListPID;
3122                         TitleListTokens = &GeneralTitleListTokens;
3123                         TitleListLanguage = &GeneralTitleListLanguage;
3124                         TitleListPref = &GeneralTitleListPref;  
3125                         break;
3126                 case PROPERTY_HOME:
3127                         TitleList = &HomeTitleList;
3128                         TitleListType = &HomeTitleListType;
3129                         TitleListAltID = &HomeTitleListAltID;
3130                         TitleListPID = &HomeTitleListPID;
3131                         TitleListTokens = &HomeTitleListTokens;
3132                         TitleListLanguage = &HomeTitleListLanguage;
3133                         TitleListPref = &HomeTitleListPref;     
3134                         break;
3135                 case PROPERTY_WORK:
3136                         TitleList = &BusinessTitleList;
3137                         TitleListType = &BusinessTitleListType;
3138                         TitleListAltID = &BusinessTitleListAltID;
3139                         TitleListPID = &BusinessTitleListPID;
3140                         TitleListTokens = &BusinessTitleListTokens;
3141                         TitleListLanguage = &BusinessTitleListLanguage; 
3142                         TitleListPref = &BusinessTitleListPref;
3143                         break;
3144         }
3146         intPrevValue = 6;
3147                 
3148         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3149         intiter != SplitPoints.end(); ++intiter){
3150         
3151                 SLiter = SplitLength.find(intiter->first);
3152         
3153                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3154                 
3155                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3156                 PropertyName = PropertyElement.GetNextToken();                          
3157                 PropertyValue = PropertyElement.GetNextToken();
3158                 
3159                 intPrevValue = intiter->second;
3160                 
3161                 // Process properties.
3162                 
3163                 size_t intPropertyValueLen = PropertyValue.Len();
3164                 
3165                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3166                         
3167                         PropertyValue.Trim();
3168                         PropertyValue.RemoveLast();
3169                         
3170                 }                               
3171                 
3172                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3173                         
3174                         PropertyValue.Remove(0, 1);
3175                         
3176                 }                               
3177                 
3178                 CaptureString(&PropertyValue, FALSE);
3179                 
3180                 if (PropertyName == wxT("ALTID")){
3181                 
3182                         TitleListAltID->erase(*TitleCount);
3183                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3184                 
3185                 } else if (PropertyName == wxT("PID")){
3187                         TitleListPID->erase(*TitleCount);
3188                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3189                 
3190                 } else if (PropertyName == wxT("PREF")){
3191                                 
3192                         int PriorityNumber = 0;
3193                         bool ValidNumber = TRUE;
3194                         
3195                         try{
3196                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3197                         }
3198                         
3199                         catch(std::invalid_argument &e){
3200                                 ValidNumber = FALSE;
3201                         }
3203                         if (ValidNumber == TRUE){
3205                                 TitleListPref->erase(*TitleCount);
3206                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3208                         }
3209                                         
3210                 } else if (PropertyName == wxT("LANGUAGE")){
3211                 
3212                         TitleListLanguage->erase(*TitleCount);
3213                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3214                 
3215                 } else {
3216                 
3217                         // Something else we don't know about so append
3218                         // to the tokens variable.
3219                 
3220                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3221                 
3222                                 if (FirstToken == TRUE){
3223                         
3224                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3225                                         FirstToken = FALSE;
3226                         
3227                                 } else {
3228                         
3229                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3230                         
3231                                 }
3232                 
3233                         }
3234                 
3235                 }
3236         
3237         }
3238         
3239         // Add the data to the General/Home/Work address variables.
3240         
3241         CaptureString(&PropertySeg2, FALSE);
3243         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3244         
3245         if (!PropertyTokens.IsEmpty()){
3246         
3247                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3248                         
3249         }
3253 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3255         std::map<int, int> SplitPoints;
3256         std::map<int, int> SplitLength;
3257         std::map<int, int>::iterator SLiter;                    
3258         wxString PropertyData;
3259         wxString PropertyName;
3260         wxString PropertyValue;
3261         wxString PropertyTokens;
3262         bool FirstToken = TRUE;
3263         int intPrevValue = 6;
3264         int intPref = 0;                        
3265         int intType = 0;
3266         long ListCtrlIndex;
3267         
3268         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3269         
3270         intPrevValue = 5;
3271         
3272         PropertyType PropType = PROPERTY_NONE;
3273                 
3274         // Look for type before continuing.
3275         
3276         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3277         
3278         // Setup the pointers.
3279         
3280         std::map<int, wxString> *RoleList = NULL;
3281         std::map<int, wxString> *RoleListAltID = NULL;
3282         std::map<int, wxString> *RoleListPID = NULL;
3283         std::map<int, wxString> *RoleListType = NULL;
3284         std::map<int, wxString> *RoleListTokens = NULL;
3285         std::map<int, wxString> *RoleListLanguage = NULL;
3286         std::map<int, int> *RoleListPref = NULL;
3287         
3288         // Setup blank lines for later on.
3289         
3290         switch(PropType){
3291                 case PROPERTY_NONE:
3292                         RoleList = &GeneralRoleList;
3293                         RoleListType = &GeneralRoleListType;
3294                         RoleListAltID = &GeneralRoleListAltID;
3295                         RoleListPID = &GeneralRoleListPID;
3296                         RoleListTokens = &GeneralRoleListTokens;
3297                         RoleListLanguage = &GeneralRoleListLanguage;
3298                         RoleListPref = &GeneralRoleListPref;    
3299                         break;
3300                 case PROPERTY_HOME:
3301                         RoleList = &HomeRoleList;
3302                         RoleListType = &HomeRoleListType;
3303                         RoleListAltID = &HomeRoleListAltID;
3304                         RoleListPID = &HomeRoleListPID;
3305                         RoleListTokens = &HomeRoleListTokens;
3306                         RoleListLanguage = &HomeRoleListLanguage;
3307                         RoleListPref = &HomeRoleListPref;       
3308                         break;
3309                 case PROPERTY_WORK:
3310                         RoleList = &BusinessRoleList;
3311                         RoleListType = &BusinessRoleListType;
3312                         RoleListAltID = &BusinessRoleListAltID;
3313                         RoleListPID = &BusinessRoleListPID;
3314                         RoleListTokens = &BusinessRoleListTokens;
3315                         RoleListLanguage = &BusinessRoleListLanguage;   
3316                         RoleListPref = &BusinessRoleListPref;
3317                         break;
3318         }
3320         intPrevValue = 5;
3321                 
3322         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3323         intiter != SplitPoints.end(); ++intiter){
3324         
3325                 SLiter = SplitLength.find(intiter->first);
3326         
3327                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3328                 
3329                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3330                 PropertyName = PropertyElement.GetNextToken();                          
3331                 PropertyValue = PropertyElement.GetNextToken();
3332                 
3333                 intPrevValue = intiter->second;
3334                 
3335                 // Process properties.
3336                 
3337                 size_t intPropertyValueLen = PropertyValue.Len();
3338                 
3339                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3340                         
3341                         PropertyValue.Trim();
3342                         PropertyValue.RemoveLast();
3343                         
3344                 }                               
3345                 
3346                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3347                         
3348                         PropertyValue.Remove(0, 1);
3349                         
3350                 }                               
3351                 
3352                 CaptureString(&PropertyValue, FALSE);
3353                 
3354                 if (PropertyName == wxT("ALTID")){
3355                 
3356                         RoleListAltID->erase(*RoleCount);
3357                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3358                 
3359                 } else if (PropertyName == wxT("PID")){
3361                         RoleListPID->erase(*RoleCount);
3362                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3363                 
3364                 } else if (PropertyName == wxT("PREF")){
3365                                 
3366                         int PriorityNumber = 0;
3367                         bool ValidNumber = TRUE;
3368                         
3369                         try{
3370                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3371                         }
3372                         
3373                         catch(std::invalid_argument &e){
3374                                 ValidNumber = FALSE;
3375                         }
3377                         if (ValidNumber == TRUE){
3379                                 RoleListPref->erase(*RoleCount);
3380                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3382                         }
3383                                         
3384                 } else if (PropertyName == wxT("LANGUAGE")){
3385                 
3386                         RoleListLanguage->erase(*RoleCount);
3387                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3388                 
3389                 } else {
3390                 
3391                         // Something else we don't know about so append
3392                         // to the tokens variable.
3393                 
3394                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3395                 
3396                                 if (FirstToken == TRUE){
3397                         
3398                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3399                                         FirstToken = FALSE;
3400                         
3401                                 } else {
3402                         
3403                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3404                         
3405                                 }
3406                 
3407                         }
3408                 
3409                 }
3410         
3411         }
3412         
3413         // Add the data to the General/Home/Work address variables.
3414         
3415         CaptureString(&PropertySeg2, FALSE);
3417         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3418         
3419         if (!PropertyTokens.IsEmpty()){
3420         
3421                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3422                         
3423         }
3427 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3429         std::map<int, int> SplitPoints;
3430         std::map<int, int> SplitLength;
3431         std::map<int, int>::iterator SLiter;                    
3432         wxString PropertyData;
3433         wxString PropertyName;
3434         wxString PropertyValue;
3435         wxString PropertyTokens;
3436         bool FirstToken = TRUE;
3437         int intPrevValue = 5;
3438         int intPref = 0;                        
3439         int intType = 0;
3440         long ListCtrlIndex;
3441         
3442         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3443         
3444         intPrevValue = 4;
3445         
3446         PropertyType PropType = PROPERTY_NONE;
3447                 
3448         // Look for type before continuing.
3449         
3450         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3451         
3452         // Setup the pointers.
3453         
3454         std::map<int, wxString> *OrganisationsList = NULL;
3455         std::map<int, wxString> *OrganisationsListAltID = NULL;
3456         std::map<int, wxString> *OrganisationsListPID = NULL;
3457         std::map<int, wxString> *OrganisationsListType = NULL;
3458         std::map<int, wxString> *OrganisationsListTokens = NULL;
3459         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3460         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3461         std::map<int, int> *OrganisationsListPref = NULL;
3462         
3463         // Setup blank lines for later on.
3464         
3465         switch(PropType){
3466                 case PROPERTY_NONE:
3467                         OrganisationsList = &GeneralOrganisationsList;
3468                         OrganisationsListType = &GeneralOrganisationsListType;
3469                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3470                         OrganisationsListPID = &GeneralOrganisationsListPID;
3471                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3472                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3473                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3474                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3475                         break;
3476                 case PROPERTY_HOME:
3477                         OrganisationsList = &HomeOrganisationsList;
3478                         OrganisationsListType = &HomeOrganisationsListType;
3479                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3480                         OrganisationsListPID = &HomeOrganisationsListPID;
3481                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3482                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3483                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3484                         OrganisationsListPref = &HomeOrganisationsListPref;     
3485                         break;
3486                 case PROPERTY_WORK:
3487                         OrganisationsList = &BusinessOrganisationsList;
3488                         OrganisationsListType = &BusinessOrganisationsListType;
3489                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3490                         OrganisationsListPID = &BusinessOrganisationsListPID;
3491                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3492                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3493                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3494                         OrganisationsListPref = &BusinessOrganisationsListPref;
3495                         break;
3496         }
3498         intPrevValue = 4;
3499                 
3500         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3501         intiter != SplitPoints.end(); ++intiter){
3502         
3503                 SLiter = SplitLength.find(intiter->first);
3504         
3505                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3506                 
3507                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3508                 PropertyName = PropertyElement.GetNextToken();                          
3509                 PropertyValue = PropertyElement.GetNextToken();
3510                 
3511                 intPrevValue = intiter->second;
3512                 
3513                 // Process properties.
3514                 
3515                 size_t intPropertyValueLen = PropertyValue.Len();
3516                 
3517                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3518                         
3519                         PropertyValue.Trim();
3520                         PropertyValue.RemoveLast();
3521                         
3522                 }                               
3523                 
3524                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3525                         
3526                         PropertyValue.Remove(0, 1);
3527                         
3528                 }                               
3529                 
3530                 CaptureString(&PropertyValue, FALSE);
3531                 
3532                 if (PropertyName == wxT("ALTID")){
3533                 
3534                         OrganisationsListAltID->erase(*OrganisationCount);
3535                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3536                 
3537                 } else if (PropertyName == wxT("PID")){
3539                         OrganisationsListPID->erase(*OrganisationCount);
3540                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3541                 
3542                 } else if (PropertyName == wxT("SORT-AS")){
3544                         OrganisationsListSortAs->erase(*OrganisationCount);
3545                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3546                 
3547                 } else if (PropertyName == wxT("PREF")){
3548                                 
3549                         int PriorityNumber = 0;
3550                         bool ValidNumber = TRUE;
3551                         
3552                         try{
3553                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3554                         }
3555                         
3556                         catch(std::invalid_argument &e){
3557                                 ValidNumber = FALSE;
3558                         }
3560                         if (ValidNumber == TRUE){
3562                                 OrganisationsListPref->erase(*OrganisationCount);
3563                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3565                         }
3566                                         
3567                 } else if (PropertyName == wxT("LANGUAGE")){
3568                 
3569                         OrganisationsListLanguage->erase(*OrganisationCount);
3570                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3571                 
3572                 } else {
3573                 
3574                         // Something else we don't know about so append
3575                         // to the tokens variable.
3576                 
3577                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3578                 
3579                                 if (FirstToken == TRUE){
3580                         
3581                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3582                                         FirstToken = FALSE;
3583                         
3584                                 } else {
3585                         
3586                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3587                         
3588                                 }
3589                 
3590                         }
3591                 
3592                 }
3593         
3594         }
3595         
3596         // Add the data to the General/Home/Work address variables.
3597         
3598         CaptureString(&PropertySeg2, FALSE);
3600         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3601         
3602         if (!PropertyTokens.IsEmpty()){
3603         
3604                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3605                         
3606         }
3610 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3612         std::map<int, int> SplitPoints;
3613         std::map<int, int> SplitLength;
3614         std::map<int, int>::iterator SLiter;                    
3615         wxString PropertyData;
3616         wxString PropertyName;
3617         wxString PropertyValue;
3618         wxString PropertyTokens;
3619         bool FirstToken = TRUE;
3620         int intPrevValue = 6;
3621         int intPref = 0;                        
3622         int intType = 0;
3623         long ListCtrlIndex;
3624         
3625         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3626         
3627         intPrevValue = 5;
3628         
3629         PropertyType PropType = PROPERTY_NONE;
3630                 
3631         // Look for type before continuing.
3632         
3633         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3634         
3635         // Setup the pointers.
3636         
3637         std::map<int, wxString> *NoteList = NULL;
3638         std::map<int, wxString> *NoteListAltID = NULL;
3639         std::map<int, wxString> *NoteListPID = NULL;
3640         std::map<int, wxString> *NoteListType = NULL;
3641         std::map<int, wxString> *NoteListTokens = NULL;
3642         std::map<int, wxString> *NoteListLanguage = NULL;
3643         std::map<int, int> *NoteListPref = NULL;
3644         
3645         // Setup blank lines for later on.
3646         
3647         switch(PropType){
3648                 case PROPERTY_NONE:
3649                         NoteList = &GeneralNoteList;
3650                         NoteListType = &GeneralNoteListType;
3651                         NoteListAltID = &GeneralNoteListAltID;
3652                         NoteListPID = &GeneralNoteListPID;
3653                         NoteListTokens = &GeneralNoteListTokens;
3654                         NoteListLanguage = &GeneralNoteListLanguage;
3655                         NoteListPref = &GeneralNoteListPref;    
3656                         break;
3657                 case PROPERTY_HOME:
3658                         NoteList = &HomeNoteList;
3659                         NoteListType = &HomeNoteListType;
3660                         NoteListAltID = &HomeNoteListAltID;
3661                         NoteListPID = &HomeNoteListPID;
3662                         NoteListTokens = &HomeNoteListTokens;
3663                         NoteListLanguage = &HomeNoteListLanguage;
3664                         NoteListPref = &HomeNoteListPref;       
3665                         break;
3666                 case PROPERTY_WORK:
3667                         NoteList = &BusinessNoteList;
3668                         NoteListType = &BusinessNoteListType;
3669                         NoteListAltID = &BusinessNoteListAltID;
3670                         NoteListPID = &BusinessNoteListPID;
3671                         NoteListTokens = &BusinessNoteListTokens;
3672                         NoteListLanguage = &BusinessNoteListLanguage;   
3673                         NoteListPref = &BusinessNoteListPref;
3674                         break;
3675         }
3677         intPrevValue = 5;
3678                 
3679         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3680         intiter != SplitPoints.end(); ++intiter){
3681         
3682                 SLiter = SplitLength.find(intiter->first);
3683         
3684                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3685                 
3686                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3687                 PropertyName = PropertyElement.GetNextToken();                          
3688                 PropertyValue = PropertyElement.GetNextToken();
3689                 
3690                 intPrevValue = intiter->second;
3691                 
3692                 // Process properties.
3693                 
3694                 size_t intPropertyValueLen = PropertyValue.Len();
3695                 
3696                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3697                         
3698                         PropertyValue.Trim();
3699                         PropertyValue.RemoveLast();
3700                         
3701                 }                               
3702                 
3703                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3704                         
3705                         PropertyValue.Remove(0, 1);
3706                         
3707                 }                               
3708                 
3709                 CaptureString(&PropertyValue, FALSE);
3710                 
3711                 if (PropertyName == wxT("ALTID")){
3712                 
3713                         NoteListAltID->erase(*NoteCount);
3714                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3715                 
3716                 } else if (PropertyName == wxT("PID")){
3718                         NoteListPID->erase(*NoteCount);
3719                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3720                 
3721                 } else if (PropertyName == wxT("PREF")){
3722                                 
3723                         int PriorityNumber = 0;
3724                         bool ValidNumber = TRUE;
3725                         
3726                         try{
3727                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3728                         }
3729                         
3730                         catch(std::invalid_argument &e){
3731                                 ValidNumber = FALSE;
3732                         }
3734                         if (ValidNumber == TRUE){
3736                                 NoteListPref->erase(*NoteCount);
3737                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3739                         }
3740                                         
3741                 } else if (PropertyName == wxT("LANGUAGE")){
3742                 
3743                         NoteListLanguage->erase(*NoteCount);
3744                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3745                 
3746                 } else {
3747                 
3748                         // Something else we don't know about so append
3749                         // to the tokens variable.
3750                 
3751                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3752                 
3753                                 if (FirstToken == TRUE){
3754                         
3755                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3756                                         FirstToken = FALSE;
3757                         
3758                                 } else {
3759                         
3760                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3761                         
3762                                 }
3763                 
3764                         }
3765                 
3766                 }
3767         
3768         }
3769         
3770         // Add the data to the General/Home/Work address variables.
3771         
3772         CaptureString(&PropertySeg2, FALSE);
3774         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3775         
3776         if (!PropertyTokens.IsEmpty()){
3777         
3778                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3779                         
3780         }
3784 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3786         std::map<int, int> SplitPoints;
3787         std::map<int, int> SplitLength;
3788         std::map<int, int>::iterator SLiter;                    
3789         wxString PropertyData;
3790         wxString PropertyName;
3791         wxString PropertyValue;
3792         wxString PropertyTokens;
3793         bool FirstToken = TRUE;
3794         int intPrevValue = 12;
3795         int intPref = 0;                        
3796         int intType = 0;
3797         long ListCtrlIndex;
3798         
3799         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3800         
3801         intPrevValue = 11;
3802         
3803         PropertyType PropType = PROPERTY_NONE;
3804                 
3805         // Look for type before continuing.
3806         
3807         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3808         
3809         // Setup blank lines for later on.
3810         
3811         switch(PropType){
3812                 case PROPERTY_NONE:
3813                         break;
3814                 case PROPERTY_HOME:
3815                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3816                         break;
3817                 case PROPERTY_WORK:
3818                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3819                         break;
3820         }
3822         intPrevValue = 11;
3823                 
3824         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3825         intiter != SplitPoints.end(); ++intiter){
3826         
3827                 SLiter = SplitLength.find(intiter->first);
3828         
3829                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3830                 
3831                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3832                 PropertyName = PropertyElement.GetNextToken();                          
3833                 PropertyValue = PropertyElement.GetNextToken();
3834                 
3835                 intPrevValue = intiter->second;
3836                 
3837                 // Process properties.
3838                 
3839                 size_t intPropertyValueLen = PropertyValue.Len();
3840                 
3841                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3842                         
3843                         PropertyValue.Trim();
3844                         PropertyValue.RemoveLast();
3845                         
3846                 }                               
3847                 
3848                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3849                         
3850                         PropertyValue.Remove(0, 1);
3851                         
3852                 }                               
3853                 
3854                 CaptureString(&PropertyValue, FALSE);
3855                 
3856                 if (PropertyName == wxT("ALTID")){
3857                 
3858                         CategoriesListAltID.erase(*CategoryCount);
3859                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3860                 
3861                 } else if (PropertyName == wxT("PID")){
3863                         CategoriesListPID.erase(*CategoryCount);
3864                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3865                 
3866                 } else if (PropertyName == wxT("PREF")){
3867                                 
3868                         int PriorityNumber = 0;
3869                         bool ValidNumber = TRUE;
3870                         
3871                         try{
3872                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3873                         }
3874                         
3875                         catch(std::invalid_argument &e){
3876                                 ValidNumber = FALSE;
3877                         }
3879                         if (ValidNumber == TRUE){
3881                                 CategoriesListPref.erase(*CategoryCount);
3882                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3884                         }
3885                                         
3886                 } else if (PropertyName == wxT("LANGUAGE")){
3887                 
3888                         CategoriesListLanguage.erase(*CategoryCount);
3889                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3890                 
3891                 } else {
3892                 
3893                         // Something else we don't know about so append
3894                         // to the tokens variable.
3895                 
3896                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3897                 
3898                                 if (FirstToken == TRUE){
3899                         
3900                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3901                                         FirstToken = FALSE;
3902                         
3903                                 } else {
3904                         
3905                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3906                         
3907                                 }
3908                 
3909                         }
3910                 
3911                 }
3912         
3913         }
3914         
3915         // Deal with multiple categories.
3916         
3917         int intOrigCatCount = *CategoryCount;
3918         bool FirstCategoryProcessed = TRUE;
3919         bool AfterFirstToken = FALSE;
3920         int intSplitSize = 0;
3921         int intSplitsFound = 0;
3922         int intSplitSeek = 0;
3923         int intPropertyLen = PropertySeg2.Len();
3924         
3925         SplitPoints.clear();
3926         SplitLength.clear();
3927         intPrevValue = 0;
3928         
3929         for (int i = 0; i <= intPropertyLen; i++){
3930         
3931                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3932         
3933                         continue;
3934                 
3935                 }
3936         
3937                 intSplitSize++;
3938         
3939                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3940         
3941                         if (AfterFirstToken == TRUE){
3942                 
3943                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3944                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3945                         
3946                         } else {
3947                         
3948                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3949                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3950                                 AfterFirstToken = TRUE;
3952                         }
3954                         intSplitsFound++;
3955                         intSplitSeek = i;
3956                         intSplitSize = 0;                               
3957         
3958                 }                       
3959         
3960         }
3961         
3962         if (SplitPoints.size() > 0){
3963         
3964                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3965                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3966         
3967         }
3968         
3969         if (SplitPoints.size() == 0){
3970         
3971                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3972         
3973                 if (!PropertyTokens.IsEmpty()){
3974                 
3975                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3976                 
3977                 }
3978         
3979         }
3980         
3981         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3982         intiter != SplitPoints.end(); ++intiter){
3983         
3984                 SLiter = SplitLength.find(intiter->first);
3985         
3986                 intPrevValue = intiter->second;
3987         
3988                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3989                 
3990                 // Add the data to the General/Home/Work address variables.
3991         
3992                 // Trim any whitespace from the start and end.
3993         
3994                 PropertyData = PropertyData.Trim(FALSE);
3995                 PropertyData = PropertyData.Trim(TRUE); 
3996         
3997                 CaptureString(&PropertyData, FALSE);
3998                 
3999                 if (FirstCategoryProcessed == TRUE){
4000                 
4001                         FirstCategoryProcessed = FALSE;
4002                         
4003                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4004         
4005                         if (!PropertyTokens.IsEmpty()){
4006                 
4007                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4008                 
4009                         }
4010                         
4011                         continue;
4012                 
4013                 } else {
4015                         (*CategoryCount)++;
4016                         
4017                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4018                 
4019                         if (!PropertyTokens.IsEmpty()){
4020                 
4021                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4022                 
4023                         }
4024                 
4025                 }
4026                 
4027                 // Copy the properties to each of the categories (if it exists).
4028                 
4029                 if (!PropertyTokens.IsEmpty()){
4030                 
4031                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4032                 
4033                 }
4034                 
4035                 // Check if ALTID was used.
4036                 
4037                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4038                 
4039                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4040                 
4041                 }
4042                 
4043                 // Check if PID was used.
4044                 
4045                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4046                 
4047                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4048                 
4049                 }
4050         
4051                 // Check if PREF was used.
4052         
4053                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4054                 
4055                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4056                 
4057                 }
4058                 
4059                 // Check if LANGUAGE was used.
4060                 
4061                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4062                 
4063                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4064                 
4065                 }
4066                 
4067                 // Check if TYPE was used.
4068                 
4069                 switch(PropType){
4070                         case PROPERTY_NONE:
4071                                 break;
4072                         case PROPERTY_HOME:
4073                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4074                                 break;
4075                         case PROPERTY_WORK:
4076                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4077                                 break;
4078                 }
4079         
4080         }
4084 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4086         size_t intPropertyLen = PropertySeg1.Len();
4087         std::map<int, int> SplitPoints;
4088         std::map<int, int> SplitLength;
4089         std::map<int, int>::iterator SLiter;                    
4090         wxString PropertyData;
4091         wxString PropertyName;
4092         wxString PropertyValue;
4093         wxString PropertyTokens;
4094         bool FirstToken = TRUE;
4095         int intSplitsFound = 0;
4096         int intSplitSize = 0;
4097         int intPrevValue = 7;
4098         int intPref = 0;                        
4099         int intType = 0;
4100         
4101         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4102         
4103         intPrevValue = 6;
4104         
4105         PropertyType PropType = PROPERTY_NONE;
4106                 
4107         // Look for type before continuing.
4108         
4109         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4111         intPrevValue = 6;
4113         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4114         intiter != SplitPoints.end(); ++intiter){
4115         
4116                 SLiter = SplitLength.find(intiter->first);
4117         
4118                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4119                 
4120                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4121                 PropertyName = PropertyElement.GetNextToken();                          
4122                 PropertyValue = PropertyElement.GetNextToken();
4123                 
4124                 intPrevValue = intiter->second;
4125                 
4126                 // Process properties.
4127                 
4128                 size_t intPropertyValueLen = PropertyValue.Len();
4129                 
4130                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4131                         
4132                         PropertyValue.Trim();
4133                         PropertyValue.RemoveLast();
4134                         
4135                 }                               
4136                 
4137                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4138                         
4139                         PropertyValue.Remove(0, 1);
4140                         
4141                 }
4142                 
4143                 CaptureString(&PropertyValue, FALSE);
4144                 
4145                 if (PropertyName == wxT("ALTID")){
4147                         PicturesListAltID.erase(*PhotoCount);
4148                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4149                 
4150                 } else if (PropertyName == wxT("PID")){
4152                         PicturesListPID.erase(*PhotoCount);
4153                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4154                 
4155                 } else if (PropertyName == wxT("PREF")){
4156                         
4157                         int PriorityNumber = 0;
4158                         bool ValidNumber = TRUE;
4159                         
4160                         try{
4161                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4162                         }
4163                         
4164                         catch(std::invalid_argument &e){
4165                                 ValidNumber = FALSE;
4166                         }
4168                         if (ValidNumber == TRUE){
4170                                 PicturesListPref.erase(*PhotoCount);
4171                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4173                         }
4174                 
4175                 } else if (PropertyName == wxT("MEDIATYPE")){
4176                 
4177                         PicturesListMediatype.erase(*PhotoCount);
4178                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4179                                         
4180                 } else {
4181                 
4182                         // Something else we don't know about so append
4183                         // to the tokens variable.
4184                         
4185                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4186                         
4187                                 if (FirstToken == TRUE){
4188                                 
4189                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4190                                         FirstToken = FALSE;
4191                                 
4192                                 } else {
4193                                 
4194                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4195                                 
4196                                 }
4197                         
4198                         }
4199                 
4200                 }
4201         
4202         }       
4203         
4204         intPropertyLen = PropertySeg2.Len();
4205         SplitPoints.clear();
4206         SplitLength.clear();
4207         intSplitsFound = 0;
4208         intSplitSize = 0;
4209         intPrevValue = 0;                       
4210         
4211         CaptureString(&PropertySeg2, FALSE);
4212         
4213         for (int i = 0; i <= intPropertyLen; i++){
4215                 intSplitSize++;
4216         
4217                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4218         
4219                         intSplitsFound++;
4220                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4221                         
4222                         if (intSplitsFound == 6){ 
4223                         
4224                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4225                                 break; 
4226                                 
4227                         } else {
4228                         
4229                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4230                         
4231                         }
4232                         
4233                         intSplitSize = 0;                                       
4234         
4235                 }
4237         }
4238         
4239         wxString wxSPhotoURI;
4240         wxString wxSPhotoMIME;
4241         wxString wxSPhotoEncoding;
4242         wxString wxSPhotoData;
4243         std::string base64enc;
4244         
4245         if (intSplitsFound == 0){
4246         
4247         } else {
4248         
4249                 std::map<int, int>::iterator striter;
4250         
4251                 striter = SplitLength.find(1);
4252         
4253                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4254         
4255                 while (wSTDataType.HasMoreTokens() == TRUE){
4256                 
4257                         wxSPhotoURI = wSTDataType.GetNextToken();
4258                         wxSPhotoMIME = wSTDataType.GetNextToken();
4259                         break;
4260                 
4261                 }                       
4262         
4263                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4264         
4265                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4266                 
4267                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4268                         wxSPhotoData = wSTDataInfo.GetNextToken();
4269                         base64enc = wxSPhotoData.mb_str();
4270                         break;
4271                 
4272                 }
4273         
4274         }
4275         
4276         // Add the data to the General/Home/Work address variables.
4277         
4278         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4279         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4280         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4281         
4282         switch(PropType){
4283                 case PROPERTY_NONE:
4284                         break;
4285                 case PROPERTY_HOME:
4286                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4287                         break;
4288                 case PROPERTY_WORK:
4289                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4290                         break;
4291         }
4292         
4293         if (!PropertyTokens.IsEmpty()){
4295                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4296         
4297         }
4301 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4303         size_t intPropertyLen = PropertySeg1.Len();
4304         std::map<int, int> SplitPoints;
4305         std::map<int, int> SplitLength;
4306         std::map<int, int>::iterator SLiter;                    
4307         wxString PropertyData;
4308         wxString PropertyName;
4309         wxString PropertyValue;
4310         wxString PropertyTokens;
4311         bool FirstToken = TRUE;
4312         int intSplitsFound = 0;
4313         int intSplitSize = 0;
4314         int intPrevValue = 6;
4315         int intPref = 0;                        
4316         int intType = 0;
4317         
4318         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4319         
4320         intPrevValue = 5;
4321         
4322         PropertyType PropType = PROPERTY_NONE;
4323                 
4324         // Look for type before continuing.
4325         
4326         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4328         intPrevValue = 5;
4330         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4331         intiter != SplitPoints.end(); ++intiter){
4332         
4333                 SLiter = SplitLength.find(intiter->first);
4334         
4335                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4336                 
4337                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4338                 PropertyName = PropertyElement.GetNextToken();                          
4339                 PropertyValue = PropertyElement.GetNextToken();
4340                 
4341                 intPrevValue = intiter->second;
4342                 
4343                 // Process properties.
4344                 
4345                 size_t intPropertyValueLen = PropertyValue.Len();
4346                 
4347                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4348                         
4349                         PropertyValue.Trim();
4350                         PropertyValue.RemoveLast();
4351                         
4352                 }                               
4353                 
4354                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4355                         
4356                         PropertyValue.Remove(0, 1);
4357                         
4358                 }
4359                 
4360                 CaptureString(&PropertyValue, FALSE);
4361                 
4362                 if (PropertyName == wxT("ALTID")){
4364                         LogosListAltID.erase(*LogoCount);
4365                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4366                 
4367                 } else if (PropertyName == wxT("PID")){
4369                         LogosListPID.erase(*LogoCount);
4370                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4371                 
4372                 } else if (PropertyName == wxT("PREF")){
4373                         
4374                         int PriorityNumber = 0;
4375                         bool ValidNumber = TRUE;
4376                         
4377                         try{
4378                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4379                         }
4380                         
4381                         catch(std::invalid_argument &e){
4382                                 ValidNumber = FALSE;
4383                         }
4385                         if (ValidNumber == TRUE){
4387                                 LogosListPref.erase(*LogoCount);
4388                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4390                         }
4391                 
4392                 } else if (PropertyName == wxT("MEDIATYPE")){
4393                 
4394                         LogosListMediatype.erase(*LogoCount);
4395                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4396                                         
4397                 } else {
4398                 
4399                         // Something else we don't know about so append
4400                         // to the tokens variable.
4401                         
4402                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4403                         
4404                                 if (FirstToken == TRUE){
4405                                 
4406                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4407                                         FirstToken = FALSE;
4408                                 
4409                                 } else {
4410                                 
4411                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4412                                 
4413                                 }
4414                         
4415                         }
4416                 
4417                 }
4418         
4419         }       
4420         
4421         intPropertyLen = PropertySeg2.Len();
4422         SplitPoints.clear();
4423         SplitLength.clear();
4424         intSplitsFound = 0;
4425         intSplitSize = 0;
4426         intPrevValue = 0;                       
4427         
4428         CaptureString(&PropertySeg2, FALSE);
4429         
4430         for (int i = 0; i <= intPropertyLen; i++){
4432                 intSplitSize++;
4433         
4434                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4435         
4436                         intSplitsFound++;
4437                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4438                         
4439                         if (intSplitsFound == 6){ 
4440                         
4441                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4442                                 break; 
4443                                 
4444                         } else {
4445                         
4446                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4447                         
4448                         }
4449                         
4450                         intSplitSize = 0;                                       
4451         
4452                 }
4454         }
4455         
4456         wxString wxSPhotoURI;
4457         wxString wxSPhotoMIME;
4458         wxString wxSPhotoEncoding;
4459         wxString wxSPhotoData;
4460         std::string base64enc;
4461         
4462         if (intSplitsFound == 0){
4463         
4464         } else {
4465         
4466                 std::map<int, int>::iterator striter;
4467         
4468                 striter = SplitLength.find(1);
4469         
4470                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4471         
4472                 while (wSTDataType.HasMoreTokens() == TRUE){
4473                 
4474                         wxSPhotoURI = wSTDataType.GetNextToken();
4475                         wxSPhotoMIME = wSTDataType.GetNextToken();
4476                         break;
4477                 
4478                 }                       
4479         
4480                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4481         
4482                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4483                 
4484                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4485                         wxSPhotoData = wSTDataInfo.GetNextToken();
4486                         base64enc = wxSPhotoData.mb_str();
4487                         break;
4488                 
4489                 }
4490         
4491         }
4492         
4493         // Add the data to the General/Home/Work address variables.
4494         
4495         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4496         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4497         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4498         
4499         switch(PropType){
4500                 case PROPERTY_NONE:
4501                         break;
4502                 case PROPERTY_HOME:
4503                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4504                         break;
4505                 case PROPERTY_WORK:
4506                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4507                         break;
4508         }
4509         
4510         if (!PropertyTokens.IsEmpty()){
4512                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4513         
4514         }
4518 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4520         size_t intPropertyLen = PropertySeg1.Len();
4521         std::map<int, int> SplitPoints;
4522         std::map<int, int> SplitLength;
4523         std::map<int, int>::iterator SLiter;                    
4524         wxString PropertyData;
4525         wxString PropertyName;
4526         wxString PropertyValue;
4527         wxString PropertyTokens;
4528         bool FirstToken = TRUE;
4529         int intSplitsFound = 0;
4530         int intSplitSize = 0;
4531         int intPrevValue = 7;
4532         int intPref = 0;                        
4533         int intType = 0;
4534         
4535         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4536         
4537         intPrevValue = 6;
4538         
4539         PropertyType PropType = PROPERTY_NONE;
4540         
4541         // Look for type before continuing.                     
4543         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4545         intPrevValue = 6;
4547         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4548         intiter != SplitPoints.end(); ++intiter){
4549         
4550                 SLiter = SplitLength.find(intiter->first);
4551         
4552                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4553                 
4554                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4555                 PropertyName = PropertyElement.GetNextToken();                          
4556                 PropertyValue = PropertyElement.GetNextToken();
4557                 
4558                 intPrevValue = intiter->second;
4559                 
4560                 // Process properties.
4561                 
4562                 size_t intPropertyValueLen = PropertyValue.Len();
4563                 
4564                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4565                         
4566                         PropertyValue.Trim();
4567                         PropertyValue.RemoveLast();
4568                         
4569                 }                               
4570                 
4571                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4572                         
4573                         PropertyValue.Remove(0, 1);
4574                         
4575                 }                       
4576                 
4577                 CaptureString(&PropertyValue, FALSE);
4578                 
4579                 if (PropertyName == wxT("ALTID")){
4581                         SoundsListAltID.erase(*SoundCount);
4582                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4583                 
4584                 } else if (PropertyName == wxT("PID")){
4586                         SoundsListPID.erase(*SoundCount);
4587                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4588                 
4589                 } else if (PropertyName == wxT("PREF")){
4590                         
4591                         int PriorityNumber = 0;
4592                         bool ValidNumber = TRUE;
4593                         
4594                         try{
4595                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4596                         }
4597                         
4598                         catch(std::invalid_argument &e){
4599                                 ValidNumber = FALSE;
4600                         }
4602                         if (ValidNumber == TRUE){
4604                                 SoundsListPref.erase(*SoundCount);
4605                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4607                         }
4608                 
4609                 } else if (PropertyName == wxT("MEDIATYPE")){
4610                 
4611                         SoundsListMediatype.erase(*SoundCount);
4612                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4614                 } else if (PropertyName == wxT("LANGUAGE")){
4615                 
4616                         SoundsListLanguage.erase(*SoundCount);
4617                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4619                 } else {
4620                 
4621                         // Something else we don't know about so append
4622                         // to the tokens variable.
4623                         
4624                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4625                         
4626                                 if (FirstToken == TRUE){
4627                                 
4628                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4629                                         FirstToken = FALSE;
4630                                 
4631                                 } else {
4632                                 
4633                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4634                                 
4635                                 }
4636                         
4637                         }
4638                 
4639                 }
4640         
4641         }       
4642         
4643         intPropertyLen = PropertySeg2.Len();
4644         SplitPoints.clear();
4645         SplitLength.clear();
4646         intSplitsFound = 0;
4647         intSplitSize = 0;
4648         intPrevValue = 0;
4649         
4650         CaptureString(&PropertySeg2, FALSE);
4651         
4652         for (int i = 0; i <= intPropertyLen; i++){
4654                 intSplitSize++;
4655         
4656                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4657         
4658                         intSplitsFound++;
4659                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4660                         
4661                         if (intSplitsFound == 6){ 
4662                         
4663                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4664                                 break; 
4665                                 
4666                         } else {
4667                         
4668                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4669                         
4670                         }
4671                         
4672                         intSplitSize = 0;                                       
4673         
4674                 }
4676         }
4677         
4678         wxString wxSSoundURI;
4679         wxString wxSSoundMIME;
4680         wxString wxSSoundEncoding;
4681         wxString wxSSoundData;
4682         std::string base64enc;
4683         
4684         if (intSplitsFound == 0){
4685         
4686         } else {
4687         
4688                 std::map<int, int>::iterator striter;
4689         
4690                 striter = SplitLength.find(1);
4691         
4692                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4693         
4694                 while (wSTDataType.HasMoreTokens() == TRUE){
4695                 
4696                         wxSSoundURI = wSTDataType.GetNextToken();
4697                         wxSSoundMIME = wSTDataType.GetNextToken();
4698                         break;
4699                 
4700                 }                       
4701         
4702                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4703         
4704                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4705                 
4706                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4707                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4708                         base64enc = wxSSoundData.mb_str();
4709                         break;
4710                 
4711                 }
4712         
4713         }
4714         
4715         // Add the data to the General/Home/Work address variables.
4716                 
4717         switch(PropType){
4718                 case PROPERTY_NONE:
4719                         break;
4720                 case PROPERTY_HOME:
4721                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4722                         break;
4723                 case PROPERTY_WORK:
4724                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4725                         break;
4726         }
4727         
4728         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4729         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4730         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4731         
4732         if (!PropertyTokens.IsEmpty()){
4733         
4734                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4735         
4736         }
4737         
4740 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4742         size_t intPropertyLen = PropertySeg1.Len();
4743         std::map<int, int> SplitPoints;
4744         std::map<int, int> SplitLength;
4745         std::map<int, int>::iterator SLiter;                    
4746         wxString PropertyData;
4747         wxString PropertyName;
4748         wxString PropertyValue;
4749         wxString PropertyTokens;
4750         bool FirstToken = TRUE;
4751         int intSplitsFound = 0;
4752         int intSplitSize = 0;
4753         int intPrevValue = 8;
4754         int intPref = 0;                        
4755         int intType = 0;
4756         
4757         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4758         
4759         intPrevValue = 7;
4760         
4761         PropertyType PropType = PROPERTY_NONE;
4762         
4763         // Look for type before continuing.                     
4765         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4767         intPrevValue = 7;
4769         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4770         intiter != SplitPoints.end(); ++intiter){
4771         
4772                 SLiter = SplitLength.find(intiter->first);
4773         
4774                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4775                 
4776                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4777                 PropertyName = PropertyElement.GetNextToken();                          
4778                 PropertyValue = PropertyElement.GetNextToken();
4779                 
4780                 intPrevValue = intiter->second;
4781                 
4782                 // Process properties.
4783                 
4784                 size_t intPropertyValueLen = PropertyValue.Len();
4785                 
4786                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4787                         
4788                         PropertyValue.Trim();
4789                         PropertyValue.RemoveLast();
4790                         
4791                 }                               
4792                 
4793                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4794                         
4795                         PropertyValue.Remove(0, 1);
4796                         
4797                 }                       
4798                 
4799                 CaptureString(&PropertyValue, FALSE);
4800                 
4801                 if (PropertyName == wxT("ALTID")){
4803                         CalendarListAltID.erase(*CalURICount);
4804                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4805                 
4806                 } else if (PropertyName == wxT("PID")){
4808                         CalendarListPID.erase(*CalURICount);
4809                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4810                 
4811                 } else if (PropertyName == wxT("PREF")){
4812                         
4813                         int PriorityNumber = 0;
4814                         bool ValidNumber = TRUE;
4815                         
4816                         try{
4817                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4818                         }
4819                         
4820                         catch(std::invalid_argument &e){
4821                                 ValidNumber = FALSE;
4822                         }
4824                         if (ValidNumber == TRUE){
4826                                 CalendarListPref.erase(*CalURICount);
4827                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
4829                         }
4830                 
4831                 } else if (PropertyName == wxT("MEDIATYPE")){
4832                 
4833                         CalendarListMediatype.erase(*CalURICount);
4834                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4836                 } else {
4837                 
4838                         // Something else we don't know about so append
4839                         // to the tokens variable.
4840                         
4841                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4842                         
4843                                 if (FirstToken == TRUE){
4844                                 
4845                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4846                                         FirstToken = FALSE;
4847                                 
4848                                 } else {
4849                                 
4850                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4851                                 
4852                                 }
4853                         
4854                         }
4855                 
4856                 }
4857         
4858         }       
4859         
4860         intPropertyLen = PropertySeg2.Len();
4861         SplitPoints.clear();
4862         SplitLength.clear();
4863         intSplitsFound = 0;
4864         intSplitSize = 0;
4865         intPrevValue = 0;
4866         
4867         CaptureString(&PropertySeg2, FALSE);
4868         
4869         // Add the data to the General/Home/Work address variables.
4870                 
4871         switch(PropType){
4872                 case PROPERTY_NONE:
4873                         break;
4874                 case PROPERTY_HOME:
4875                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4876                         break;
4877                 case PROPERTY_WORK:
4878                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4879                         break;
4880         }
4881         
4882         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4883         
4884         if (!PropertyTokens.IsEmpty()){
4885         
4886                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4887         
4888         }
4892 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4894         size_t intPropertyLen = PropertySeg1.Len();
4895         std::map<int, int> SplitPoints;
4896         std::map<int, int> SplitLength;
4897         std::map<int, int>::iterator SLiter;                    
4898         wxString PropertyData;
4899         wxString PropertyName;
4900         wxString PropertyValue;
4901         wxString PropertyTokens;
4902         bool FirstToken = TRUE;
4903         int intSplitsFound = 0;
4904         int intSplitSize = 0;
4905         int intPrevValue = 8;
4906         int intPref = 0;                        
4907         int intType = 0;
4908         
4909         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4910         
4911         intPrevValue = 7;
4912         
4913         PropertyType PropType = PROPERTY_NONE;
4914         
4915         // Look for type before continuing.                     
4917         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4919         intPrevValue = 7;
4921         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4922         intiter != SplitPoints.end(); ++intiter){
4923         
4924                 SLiter = SplitLength.find(intiter->first);
4925         
4926                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4927                 
4928                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4929                 PropertyName = PropertyElement.GetNextToken();                          
4930                 PropertyValue = PropertyElement.GetNextToken();
4931                 
4932                 intPrevValue = intiter->second;
4933                 
4934                 // Process properties.
4935                 
4936                 size_t intPropertyValueLen = PropertyValue.Len();
4937                 
4938                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4939                         
4940                         PropertyValue.Trim();
4941                         PropertyValue.RemoveLast();
4942                         
4943                 }                               
4944                 
4945                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4946                         
4947                         PropertyValue.Remove(0, 1);
4948                         
4949                 }                       
4950                 
4951                 CaptureString(&PropertyValue, FALSE);
4952                 
4953                 if (PropertyName == wxT("ALTID")){
4955                         CalendarRequestListAltID.erase(*CalAdrURICount);
4956                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4957                 
4958                 } else if (PropertyName == wxT("PID")){
4960                         CalendarRequestListPID.erase(*CalAdrURICount);
4961                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4962                 
4963                 } else if (PropertyName == wxT("PREF")){
4964                         
4965                         int PriorityNumber = 0;
4966                         bool ValidNumber = TRUE;
4967                         
4968                         try{
4969                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4970                         }
4971                         
4972                         catch(std::invalid_argument &e){
4973                                 ValidNumber = FALSE;
4974                         }
4976                         if (ValidNumber == TRUE){
4978                                 CalendarRequestListPref.erase(*CalAdrURICount);
4979                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
4981                         }
4982                 
4983                 } else if (PropertyName == wxT("MEDIATYPE")){
4984                 
4985                         CalendarRequestListMediatype.erase(*CalAdrURICount);
4986                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4988                 } else {
4989                 
4990                         // Something else we don't know about so append
4991                         // to the tokens variable.
4992                         
4993                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4994                         
4995                                 if (FirstToken == TRUE){
4996                                 
4997                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4998                                         FirstToken = FALSE;
4999                                 
5000                                 } else {
5001                                 
5002                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5003                                 
5004                                 }
5005                         
5006                         }
5007                 
5008                 }
5009         
5010         }       
5011         
5012         intPropertyLen = PropertySeg2.Len();
5013         SplitPoints.clear();
5014         SplitLength.clear();
5015         intSplitsFound = 0;
5016         intSplitSize = 0;
5017         intPrevValue = 0;
5018         
5019         CaptureString(&PropertySeg2, FALSE);
5020         
5021         // Add the data to the General/Home/Work address variables.
5022                 
5023         switch(PropType){
5024                 case PROPERTY_NONE:
5025                         break;
5026                 case PROPERTY_HOME:
5027                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5028                         break;
5029                 case PROPERTY_WORK:
5030                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5031                         break;
5032         }
5033         
5034         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5035         
5036         if (!PropertyTokens.IsEmpty()){
5037         
5038                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5039         
5040         }       
5041         
5044 void SplitValues(wxString *PropertyLine, 
5045         std::map<int,int> *SplitPoints, 
5046         std::map<int,int> *SplitLength, 
5047         int intSize){
5048         
5049         size_t intPropertyLen = PropertyLine->Len();
5050         int intSplitsFound = 0;
5051         int intSplitSize = 0;
5052         int intSplitSeek = 0;
5053         
5054         for (int i = intSize; i <= intPropertyLen; i++){
5056                 intSplitSize++;
5057         
5058                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5059                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5060            
5061                     if (intSplitsFound == 0){
5062             
5063                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5064           
5065                     } else {
5066            
5067                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5068             
5069                     }
5070             
5071                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5072             
5073                     intSplitsFound++;
5074                     intSplitSeek = i;
5075                     intSplitSize = 0;
5076             
5077                 }
5079         }
5081         if (intSplitsFound == 0){
5083                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5084                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5086         } else {
5088                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5089                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5091         }
5095 void CheckType(wxString *PropertySeg1, 
5096         std::map<int,int> *SplitPoints, 
5097         std::map<int,int> *SplitLength, 
5098         int *intPrevValue, 
5099         PropertyType *PropType){
5100         
5101         wxString PropertyData;
5102         wxString PropertyName;
5103         wxString PropertyValue;
5104         std::map<int,int>::iterator SLiter;
5105         
5106         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5107         intiter != SplitPoints->end(); ++intiter){
5108         
5109                 SLiter = SplitLength->find(intiter->first);
5110         
5111                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5112                 
5113                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5114                 PropertyName = PropertyElement.GetNextToken();                          
5115                 PropertyValue = PropertyElement.GetNextToken();
5116                 
5117                 *intPrevValue = intiter->second;
5118                 
5119                 if (PropertyName == wxT("TYPE")){
5120                                 
5121                         if (PropertyValue == wxT("work")){
5122                         
5123                                 *PropType = PROPERTY_WORK;
5124                                                         
5125                         } else if (PropertyValue == wxT("home")){
5127                                 *PropType = PROPERTY_HOME;
5128                                                         
5129                         } else {
5130                         
5131                                 *PropType = PROPERTY_NONE;
5132                         
5133                         }
5134                 
5135                         return;
5136                 
5137                 }
5138         
5139         }
5140         
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