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