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