Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
e6c82a1382c0c5b76bcdece7458488cc11fa13fa
[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         wxString ContactLine;
101         wxString PropertyLine;
102         wxString PropertySeg1;
103         wxString PropertySeg2;
104         wxString PropertyNextLine;
105         wxString Property;
106         
107         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
108          iter != ContactFileLines.end(); ++iter){
110                 ExtraLineSeek = TRUE;
111                 QuoteMode = FALSE;
112                 PropertyFind = TRUE;
113                 ContactLineLen = 0;
114                 QuoteBreakPoint = 0;
115                 ContactLine.Clear();
116                 PropertyLine.Clear();
117                 PropertySeg1.Clear();
118                 PropertySeg2.Clear();
119                 Property.Clear();
120          
121                 ContactLine = iter->second;
122                 
123                 while (ExtraLineSeek == TRUE){
124                 
125                         // Check if there is extra data on the next line 
126                         // (indicated by space or tab at the start) and add data.
127                 
128                         iter++;
129                         
130                         if (iter == ContactFileLines.end()){
131                         
132                                 iter--;
133                                 break;
134                         
135                         }                       
136                 
137                         PropertyNextLine = iter->second;
138                 
139                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
140                 
141                                 PropertyNextLine.Remove(0, 1);
142                                 ContactLine.Append(PropertyNextLine);
143                 
144                         } else {
145                         
146                                 iter--;
147                                 ExtraLineSeek = FALSE;
148                         
149                         }
150                 
151                 }
153                 ContactLineLen = ContactLine.Len();
154                 
155                 // Make sure we are not in quotation mode.
156                 // Make sure colon does not have \ or \\ before it.
157                 
158                 for (int i = 0; i <= ContactLineLen; i++){
159                 
160                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
161                         
162                                 PropertyFind = FALSE;
163                         
164                         } else if (PropertyFind == TRUE){
165                         
166                                 Property.Append(ContactLine.Mid(i, 1));
167                         
168                         }               
169                 
170                         if (ContactLine.Mid(i, 1) == wxT("\"")){
171                         
172                                 if (QuoteMode == TRUE){
173                                 
174                                         QuoteMode = FALSE;
175                                 
176                                 } else {
177                         
178                                         QuoteMode = TRUE;
179                                         
180                                 }
181                         
182                         }
183                         
184                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
185                         
186                                 QuoteBreakPoint = i;
187                                 break;
188                         
189                         }
190                 
191                 }
192                 
193                 // Split that line at the point into two variables (ignore the colon).
194                 
195                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
196                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
197                 
198                  if (Property == wxT("KIND") && KindProcessed == FALSE){
199                                 
200                         ProcessKind(PropertySeg2);
201                 
202                 } else if (Property == wxT("MEMBER")){
204                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
205                         GroupCount++;   
206                 
207                 } else if (Property == wxT("FN")){
208                 
209                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
210                         FNCount++;
211                 
212                 } else if (Property == wxT("N") && NameProcessed == FALSE){
213                 
214                         ProcessN(PropertySeg1, PropertySeg2);
215                         NameProcessed = TRUE;
216                 
217                 } else if (Property == wxT("NICKNAME")){
218                                                 
219                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
220                         NicknameCount++;
221                         
222                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
223                 
224                         ProcessGender(PropertySeg1, PropertySeg2);
225                         GenderProcessed = TRUE;
226                 
227                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
228                 
229                         ProcessBirthday(PropertySeg1, PropertySeg2);
230                         BirthdayProcessed = TRUE;
231                 
232                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
233                 
234                         ProcessAnniversary(PropertySeg1, PropertySeg2);
235                         AnniversaryProcessed = TRUE;
236                 
237                 } else if (Property == wxT("TZ")){
238                 
239                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
240                         TimeZoneCount++;
241                 
242                 } else if (Property == wxT("ADR")){
243                 
244                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
245                         AddressCount++;
246                 
247                 } else if (Property == wxT("EMAIL")){
248                                         
249                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
250                         EmailCount++;
251                 
252                 } else if (Property == wxT("IMPP")){
253                 
254                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
255                         IMCount++;
256                         
257                 } else if (Property == wxT("TEL")){
258                                 
259                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
260                         TelephoneCount++;
261                 
262                 } else if (Property == wxT("LANG")){
263                 
264                         // See frmContactEditor-LoadLanguage.cpp
265                         
266                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
267                         LanguageCount++;
268                 
269                 } else if (Property == wxT("GEO")){
270                 
271                         // See frmContactEditor-LoadGeo.cpp
272                         
273                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
274                         GeographicCount++;
275                 
276                 } else if (Property == wxT("RELATED")){
277                         
278                         // See fromContactEditor-LoadRelated.cpp
279                         
280                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
281                         RelatedCount++;
282                         
283                 } else if (Property == wxT("URL")){
285                         // See frmContactEditor-LoadURL.cpp
286                 
287                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
288                         URLCount++;
289                 
290                 } else if (Property == wxT("TITLE")) {
291                 
292                         // See frmContactEditor-LoadTitle.cpp
293                         
294                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
295                         TitleCount++;
296                         
297                 } else if (Property == wxT("ROLE")) {
298                 
299                         // See frmContactEditor-LoadTitle.cpp
300                         
301                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
302                         RoleCount++;
303                         
304                 } else if (Property == wxT("ORG")) {
305                 
306                         // See frmContactEditor-LoadOrg.cpp
307                         
308                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
309                         OrganisationCount++;
310                         
311                 } else if (Property == wxT("NOTE")) {
313                         // See frmContactEditor-LoadNote.cpp
315                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
316                         NoteCount++;    
317                         
318                 } else if (Property == wxT("CATEGORIES")) {
319                 
320                         // See frmContactEditor-LoadCategory.cpp
321                 
322                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
323                         CategoryCount++;
324                         
325                 }
326                 
327         }
328         
329         return CONTACTLOAD_OK;
333 void ContactDataObject::ProcessKind(wxString KindType){
335         if (KindType == wxT("individual")){
336                         
337                 ContactKind = CONTACTKIND_INDIVIDUAL;
338                         
339         } else if (KindType == wxT("group")){
340                         
341                 ContactKind = CONTACTKIND_GROUP;
342                         
343         } else if (KindType == wxT("org")){
344                         
345                 ContactKind = CONTACTKIND_ORGANISATION;
346                         
347         } else if (KindType == wxT("location")){
348                         
349                 ContactKind = CONTACTKIND_LOCATION;
350                         
351         } else {
352                         
353                 ContactKind = CONTACTKIND_NONE;                 
354         }
358 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
360         std::map<int, int> SplitPoints;
361         std::map<int, int> SplitLength;
363         int intPrevValue = 8;
364         int intPref = 0;                        
365         int intType = 0;
366         
367         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
369         intPrevValue = 7;
370         
371         wxString PropertyName;
372         wxString PropertyValue;
373         wxString PropertyData;
374         wxString PropertyTokens;
375         std::map<int,int>::iterator SLiter;
376         bool FirstToken = TRUE;
377         
378         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
379         intiter != SplitPoints.end(); ++intiter){
380         
381                 SLiter = SplitLength.find(intiter->first);
382         
383                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
384                 
385                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
386                 PropertyName = PropertyElement.GetNextToken();                          
387                 PropertyValue = PropertyElement.GetNextToken();
388                 
389                 intPrevValue = intiter->second;
390                 
391                 CaptureString(&PropertyValue, FALSE);
392         
393                 if (PropertyName == wxT("ALTID")){
395                         GroupsListAltID.erase(*GroupCount);
396                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
397                 
398                 } else if (PropertyName == wxT("PID")){
400                         GroupsListPID.erase(*GroupCount);
401                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
402                 
403                 } else if (PropertyName == wxT("PREF")){
405                         int PriorityNumber = 0;
406                         bool ValidNumber = TRUE;
407                         
408                         try{
409                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
410                         }
411                         
412                         catch(std::invalid_argument &e){
413                                 ValidNumber = FALSE;
414                         }
416                         if (ValidNumber == TRUE){
418                                 GroupsListPref.erase(*GroupCount);
419                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
420                 
421                         }
422                 
423                 } else if (PropertyName == wxT("MEDIATYPE")){
425                         GroupsListMediaType.erase(*GroupCount);
426                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
427                 
428                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
429                         
430                         if (FirstToken == TRUE){
431                                 
432                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
433                                 FirstToken = FALSE;
434                                 
435                         } else {
436                         
437                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
438                                 
439                         }
440                         
441                 }
442                 
443         }
445         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
447         if (!PropertyTokens.IsEmpty()){
448         
449                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
450         
451         }
456 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
458         std::map<int, int> SplitPoints;
459         std::map<int, int> SplitLength;
461         int intPrevValue = 4;
462         int intPref = 0;                        
463         int intType = 0;
464         
465         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
467         intPrevValue = 3;
468         
469         wxString PropertyName;
470         wxString PropertyValue;
471         wxString PropertyData;
472         wxString PropertyTokens;
473         std::map<int,int>::iterator SLiter;
474         bool FirstToken = TRUE;
475         
476         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
477         intiter != SplitPoints.end(); ++intiter){
478         
479                 SLiter = SplitLength.find(intiter->first);
480         
481                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
482                 
483                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
484                 PropertyName = PropertyElement.GetNextToken();                          
485                 PropertyValue = PropertyElement.GetNextToken();
486                 
487                 intPrevValue = intiter->second;
488                 
489                 CaptureString(&PropertyValue, FALSE);
490                 
491                 if (PropertyName == wxT("TYPE")){
493                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
494                                 PropertyValue == wxT("work") ){
496                                 FullNamesListType.erase(*FNCount);
497                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
498                 
499                         }
500                 
501                 } else if (PropertyName == wxT("LANGUAGE")){
503                         FullNamesListLanguage.erase(*FNCount);
504                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
505                 
506                 } else if (PropertyName == wxT("ALTID")){
507                 
508                         FullNamesListAltID.erase(*FNCount);
509                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
510                 
511                 } else if (PropertyName == wxT("PID")){
513                         FullNamesListPID.erase(*FNCount);
514                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
515                 
516                 } else if (PropertyName == wxT("PREF")){
518                         int PriorityNumber = 0;
519                         bool ValidNumber = TRUE;
520                         
521                         try{
522                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
523                         }
524                         
525                         catch(std::invalid_argument &e){
526                                 ValidNumber = FALSE;
527                         }
529                         if (ValidNumber == TRUE){
531                                 FullNamesListPref.erase(*FNCount);
532                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
534                         }
535                 
536                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
537                         
538                         if (FirstToken == TRUE){
539                                 
540                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
541                                 FirstToken = FALSE;
542                                 
543                         } else {
544                         
545                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
546                                 
547                         }
548                         
549                 } 
550         
551         }
553         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
555         if (!PropertyTokens.IsEmpty()){
556         
557                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
558         
559         }
563 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
565         std::map<int, int> SplitPoints;
566         std::map<int, int> SplitLength;
568         int intPrevValue = 3;
569         int intPref = 0;                        
570         int intType = 0;
571         
572         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
573         
574         intPrevValue = 2;
575         
576         wxString PropertyName;
577         wxString PropertyValue;
578         wxString PropertyData;
579         wxString PropertyTokens;
580         std::map<int,int>::iterator SLiter;
581         bool FirstToken = TRUE;
582         
583         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
584         intiter != SplitPoints.end(); ++intiter){
585         
586                 SLiter = SplitLength.find(intiter->first);
587         
588                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
589                 
590                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
591                 PropertyName = PropertyElement.GetNextToken();                          
592                 PropertyValue = PropertyElement.GetNextToken();
593                 
594                 intPrevValue = intiter->second;
595                 
596                 CaptureString(&PropertyValue, FALSE);
597                 
598                 if (PropertyName == wxT("ALTID")){
600                         NameAltID = PropertyValue;
601                 
602                 } else if (PropertyName == wxT("LANGUAGE")){
603                 
604                         NameLanguage = PropertyValue;
605                 
606                 } else if (PropertyName == wxT("SORT-AS")){
607                 
608                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
609                                 PropertyValue.Len() >= 3){
610                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
611                         }
612                 
613                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
614                         
615                         if (FirstToken == TRUE){
616                                 
617                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
618                                 FirstToken = FALSE;
619                                 
620                         } else {
621                         
622                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
623                                 
624                         }
625                         
626                 }
627         
628         }
629         
630         // Split the name data.
631         
632         int intSplitSeek = 0;           
633         int intSplitsFound = 0;
634         int intSplitSize = 0;
635         int intPropertyLen = PropertySeg2.Len();
636         
637         std::map<int,wxString> NameValues;
638         intPrevValue = 0;                                       
639         
640         for (int i = 0; i <= intPropertyLen; i++){
641         
642                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
643                         
644                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
645                         
646                         intSplitSeek = i;
647                         intSplitSeek++;
648                         
649                         if (intSplitsFound == 4){
650                         
651                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
652                                 break;
653                         
654                         }
655                         
656                         intSplitSize = 0;
657                         continue;
658         
659                 }
660                 
661                 intSplitSize++;
663         }
664         
665         // Split the data into several parts.
666                         
667         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
668         iter != NameValues.end(); ++iter){
669         
670                 if (iter->first == 1){
671                 
672                         // Deal with family name.
673                         
674                         NameSurname = iter->second;
675                 
676                 } else if (iter->first == 2){
677                 
678                         // Deal with given names.
679                         
680                         NameForename = iter->second;
681                 
682                 } else if (iter->first == 3){
683                 
684                         // Deal with additional names.
685                         
686                         NameOtherNames = iter->second;
687                 
688                 } else if (iter->first == 4){
689                 
690                         // Deal with honorifix prefixes and suffixes.
692                         NameTitle = iter->second;
693                 
694                         iter++;
695                         
696                         if (iter == NameValues.end()){
697                         
698                                 break;
699                         
700                         }
701                 
702                         NameSuffix = iter->second;
703                 
704                 }
705         
706         }
707         
708         // Add the name token data.
709         
710         if (!PropertyTokens.IsEmpty()){
711         
712                 NameTokens = PropertyTokens;
713         
714         }
718 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
720         std::map<int, int> SplitPoints;
721         std::map<int, int> SplitLength;
723         int intPrevValue = 10;
724         int intPref = 0;                        
725         
726         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
727         
728         intPrevValue = 9;
729         
730         PropertyType PropType = PROPERTY_NONE;
731         
732         // Look for type before continuing.
733         
734         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
735         
736         intPrevValue = 9;
737         
738         std::map<int, wxString> *NicknamesList = NULL;
739         std::map<int, wxString> *NicknamesListType = NULL;
740         std::map<int, wxString> *NicknamesListLanguage = NULL;
741         std::map<int, wxString> *NicknamesListAltID = NULL;
742         std::map<int, wxString> *NicknamesListPID = NULL;
743         std::map<int, wxString> *NicknamesListTokens = NULL;            
744         std::map<int, int> *NicknamesListPref = NULL;
745         
746         switch(PropType){
747                 case PROPERTY_NONE:
748                         NicknamesList = &GeneralNicknamesList;
749                         NicknamesListType = &GeneralNicknamesListType;
750                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
751                         NicknamesListAltID = &GeneralNicknamesListAltID;
752                         NicknamesListPID = &GeneralNicknamesListPID;
753                         NicknamesListTokens = &GeneralNicknamesListTokens;
754                         NicknamesListPref = &GeneralNicknamesListPref;
755                         break;
756                 case PROPERTY_HOME:
757                         NicknamesList = &HomeNicknamesList;
758                         NicknamesListType = &HomeNicknamesListType;
759                         NicknamesListLanguage = &HomeNicknamesListLanguage;
760                         NicknamesListAltID = &HomeNicknamesListAltID;
761                         NicknamesListPID = &HomeNicknamesListPID;
762                         NicknamesListTokens = &HomeNicknamesListTokens;
763                         NicknamesListPref = &HomeNicknamesListPref;
764                         break;
765                 case PROPERTY_WORK:
766                         NicknamesList = &BusinessNicknamesList;
767                         NicknamesListType = &BusinessNicknamesListType;
768                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
769                         NicknamesListAltID = &BusinessNicknamesListAltID;
770                         NicknamesListPID = &BusinessNicknamesListPID;
771                         NicknamesListTokens = &BusinessNicknamesListTokens;
772                         NicknamesListPref = &BusinessNicknamesListPref;
773                         break;
774         }
775         
776         std::map<int, int>::iterator SLiter;    
777         wxString PropertyData;
778         wxString PropertyName;
779         wxString PropertyValue;
780         wxString PropertyTokens;
781         bool FirstToken = TRUE;
782         
783         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
784         intiter != SplitPoints.end(); ++intiter){
785         
786                 SLiter = SplitLength.find(intiter->first);
787         
788                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
789                 
790                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
791                 PropertyName = PropertyElement.GetNextToken();                          
792                 PropertyValue = PropertyElement.GetNextToken();
793                 
794                 intPrevValue = intiter->second;
795                 
796                 CaptureString(&PropertyValue, FALSE);
797                 
798                 if (PropertyName == wxT("ALTID")){
800                         NicknamesListAltID->erase(*NicknameCount);
801                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
802                 
803                 } else if (PropertyName == wxT("PID")){
805                         NicknamesListPID->erase(*NicknameCount);
806                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
808                 } else if (PropertyName == wxT("PREF")){
810                         int PriorityNumber = 0;
811                         bool ValidNumber = TRUE;
812                         
813                         try{
814                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
815                         }
816                         
817                         catch(std::invalid_argument &e){
818                                 ValidNumber = FALSE;
819                         }
821                         if (ValidNumber == TRUE){
823                                 NicknamesListPref->erase(*NicknameCount);
824                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
826                         }
827                 
828                 } else if (PropertyName == wxT("LANGUAGE")){
830                         NicknamesListLanguage->erase(*NicknameCount);
831                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
833                 } else {
834                 
835                         // Something else we don't know about so append
836                         // to the tokens variable.
837                 
838                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
839                 
840                                 if (FirstToken == TRUE){
841                         
842                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
843                                         FirstToken = FALSE;
844                         
845                                 } else {
846                         
847                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
848                         
849                                 }
850                 
851                         }
852                 
853                 }
854                 
855         }
856         
857         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
858         
859         // Add the name token data.
860         
861         if (!PropertyTokens.IsEmpty()){
862         
863                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
864         
865         }
869 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
871         std::map<int, int> SplitPoints;
872         std::map<int, int> SplitLength;
873         std::map<int, int>::iterator SLiter;                    
874         wxString PropertyData;
875         wxString PropertyName;
876         wxString PropertyValue;
877         wxString PropertyTokens;
878         bool FirstToken = TRUE;
879         int intPrevValue = 8;
881         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
883         intPrevValue = 7;                       
884         
885         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
886         intiter != SplitPoints.end(); ++intiter){
887         
888                 SLiter = SplitLength.find(intiter->first);
889         
890                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
891                 
892                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
893                 PropertyName = PropertyElement.GetNextToken();                          
894                 PropertyValue = PropertyElement.GetNextToken();
895                 
896                 intPrevValue = intiter->second;
897                 
898                 // Process properties.
899                 
900                 size_t intPropertyValueLen = PropertyValue.Len();
901                 
902                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
903                         
904                         PropertyValue.Trim();
905                         PropertyValue.RemoveLast();
906                         
907                 }                               
908                 
909                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
910                         
911                         PropertyValue.Remove(0, 1);
912                         
913                 }                               
914                 
915                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
917                         if (FirstToken == TRUE){
918         
919                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
920                                 FirstToken = FALSE;
921         
922                         } else {
923         
924                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
925         
926                         }
928                 }
929         
930         }       
932         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
933         
934         wxString GenderComponent;
935         
936         if (GenderData.CountTokens() >= 2){
937         
938                 Gender = GenderData.GetNextToken();
939                 GenderDetails = GenderData.GetString();
940         
941                 CaptureString(&GenderDetails, FALSE);
942                                                 
943         } else {
944         
945                 Gender = GenderData.GetNextToken();
946         
947         }
948         
949         if (!PropertyTokens.IsEmpty()){
950         
951                 GenderTokens = PropertyTokens;
952         
953         }
957 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
959         // Process date. Preserve the remainder in the string.
961         std::map<int, int> SplitPoints;
962         std::map<int, int> SplitLength;
963         std::map<int, int>::iterator SLiter;                    
964         wxString PropertyData;
965         wxString PropertyName;
966         wxString PropertyValue;
967         wxString PropertyTokens;
968         bool BirthdayText = FALSE;
969         int intPrevValue = 6;
971         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
973         intPrevValue = 5;
975         // Look for type before continuing.
977         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
978         intiter != SplitPoints.end(); ++intiter){
980                 SLiter = SplitLength.find(intiter->first);
982                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
983         
984                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
985                 PropertyName = PropertyElement.GetNextToken();                          
986                 PropertyValue = PropertyElement.GetNextToken();
987         
988                 intPrevValue = intiter->second;
989         
990                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
991         
992                         CaptureString(&PropertySeg2, FALSE);
993                         Birthday = PropertySeg2;
994                         BirthdayText = TRUE;
995         
996                 }
998         }
1000         // Setup blank lines for later on.
1001         
1002         intPrevValue = 5;
1003         bool FirstToken = TRUE;
1005         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1006         intiter != SplitPoints.end(); ++intiter){
1008                 SLiter = SplitLength.find(intiter->first);
1010                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1011         
1012                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1013                 PropertyName = PropertyElement.GetNextToken();                          
1014                 PropertyValue = PropertyElement.GetNextToken();
1015         
1016                 intPrevValue = intiter->second;
1017         
1018                 // Process properties.
1019         
1020                 CaptureString(&PropertyValue, FALSE);
1021         
1022                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1023                 
1024                         PropertyValue.Trim();
1025                         PropertyValue.RemoveLast();
1026                 
1027                 }                               
1028         
1029                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1030                 
1031                         PropertyValue.Remove(0, 1);
1032                 
1033                 }                               
1034         
1035                 if (PropertyName == wxT("ALTID")){
1037                         BirthdayAltID = PropertyValue;
1038         
1039                 } else if (PropertyName == wxT("CALSCALE")){
1040         
1041                         BirthdayCalScale = PropertyValue;
1042         
1043                 } else if (PropertyName != wxT("VALUE")) {
1044         
1045                         // Something else we don't know about so append
1046                         // to the tokens variable.
1047                 
1048                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1049                 
1050                                 if (FirstToken == TRUE){
1051         
1052                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1053                                         FirstToken = FALSE;
1054         
1055                                 } else {
1056         
1057                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1058         
1059                                 }
1060                                 
1061                         }
1062                         
1063                 }
1065         }       
1067         // Add the data to the variables and form.
1068         
1069         if (BirthdayText == FALSE){
1070         
1071                 Birthday = PropertySeg2;
1073         }
1074         
1075         if (!PropertyTokens.IsEmpty()){
1076         
1077                 BirthdayTokens = PropertyTokens;
1079         }
1083 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1085         // Process date. Preserve the remainder in the string.
1087         std::map<int, int> SplitPoints;
1088         std::map<int, int> SplitLength;
1089         std::map<int, int>::iterator SLiter;                    
1090         wxString PropertyData;
1091         wxString PropertyName;
1092         wxString PropertyValue;
1093         wxString PropertyTokens;
1094         bool AnniversaryText = FALSE;
1095         int intPrevValue = 13;
1097         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1099         intPrevValue = 12;
1101         // Look for type before continuing.
1103         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1104         intiter != SplitPoints.end(); ++intiter){
1106                 SLiter = SplitLength.find(intiter->first);
1108                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1109         
1110                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1111                 PropertyName = PropertyElement.GetNextToken();                          
1112                 PropertyValue = PropertyElement.GetNextToken();
1113         
1114                 intPrevValue = intiter->second;
1115         
1116                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1117         
1118                         CaptureString(&PropertySeg2, FALSE);
1119                         Anniversary = PropertySeg2;
1120                         AnniversaryText = TRUE;
1121         
1122                 }
1124         }
1126         // Setup blank lines for later on.
1127         
1128         intPrevValue = 12;
1129         bool FirstToken = TRUE;
1131         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1132         intiter != SplitPoints.end(); ++intiter){
1134                 SLiter = SplitLength.find(intiter->first);
1136                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1137         
1138                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1139                 PropertyName = PropertyElement.GetNextToken();                          
1140                 PropertyValue = PropertyElement.GetNextToken();
1141         
1142                 intPrevValue = intiter->second;
1143         
1144                 // Process properties.
1145         
1146                 CaptureString(&PropertyValue, FALSE);
1147         
1148                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1149                 
1150                         PropertyValue.Trim();
1151                         PropertyValue.RemoveLast();
1152                 
1153                 }                               
1154         
1155                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1156                 
1157                         PropertyValue.Remove(0, 1);
1158                 
1159                 }                               
1160         
1161                 if (PropertyName == wxT("ALTID")){
1163                         AnniversaryAltID = PropertyValue;
1164         
1165                 } else if (PropertyName == wxT("CALSCALE")){
1166         
1167                         AnniversaryCalScale = PropertyValue;
1168         
1169                 } else if (PropertyName != wxT("VALUE")) {
1170         
1171                         // Something else we don't know about so append
1172                         // to the tokens variable.
1173                 
1174                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1175                 
1176                                 if (FirstToken == TRUE){
1177         
1178                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1179                                         FirstToken = FALSE;
1180         
1181                                 } else {
1182         
1183                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1184         
1185                                 }
1186                                 
1187                         }
1188                         
1189                 }
1191         }       
1193         // Add the data to the variables and form.
1194         
1195         if (AnniversaryText == FALSE){
1196         
1197                 Anniversary = PropertySeg2;
1199         }
1200         
1201         if (!PropertyTokens.IsEmpty()){
1202         
1203                 AnniversaryTokens = PropertyTokens;
1205         }
1209 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1211         std::map<int, int> SplitPoints;
1212         std::map<int, int> SplitLength;
1214         int intPrevValue = 4;
1215         int intPref = 0;                        
1216         
1217         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1218         
1219         intPrevValue = 3;
1220         
1221         PropertyType PropType = PROPERTY_NONE;
1222         
1223         // Look for type before continuing.
1224         
1225         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1226         
1227         intPrevValue = 3;
1228         
1229         std::map<int, wxString> *TZList = NULL;
1230         std::map<int, wxString> *TZListType = NULL;
1231         std::map<int, wxString> *TZListMediatype = NULL;
1232         std::map<int, wxString> *TZListAltID = NULL;
1233         std::map<int, wxString> *TZListPID = NULL;
1234         std::map<int, wxString> *TZListTokens = NULL;           
1235         std::map<int, int> *TZListPref = NULL;
1236         
1237         switch(PropType){
1238                 case PROPERTY_NONE:
1239                         TZList = &GeneralTZList;
1240                         TZListType = &GeneralTZListType;
1241                         TZListMediatype = &GeneralTZListMediatype;
1242                         TZListAltID = &GeneralTZListAltID;
1243                         TZListPID = &GeneralTZListPID;
1244                         TZListTokens = &GeneralTZListTokens;
1245                         TZListPref = &GeneralTZListPref;
1246                         break;
1247                 case PROPERTY_HOME:
1248                         TZList = &HomeTZList;
1249                         TZListType = &HomeTZListType;
1250                         TZListMediatype = &HomeTZListMediatype;
1251                         TZListAltID = &HomeTZListAltID;
1252                         TZListPID = &HomeTZListPID;
1253                         TZListTokens = &HomeTZListTokens;
1254                         TZListPref = &HomeTZListPref;
1255                         break;
1256                 case PROPERTY_WORK:
1257                         TZList = &BusinessTZList;
1258                         TZListType = &BusinessTZListType;
1259                         TZListMediatype = &BusinessTZListMediatype;
1260                         TZListAltID = &BusinessTZListAltID;
1261                         TZListPID = &BusinessTZListPID;
1262                         TZListTokens = &BusinessTZListTokens;
1263                         TZListPref = &BusinessTZListPref;
1264                         break;
1265         }
1266         
1267         std::map<int, int>::iterator SLiter;    
1268         wxString PropertyData;
1269         wxString PropertyName;
1270         wxString PropertyValue;
1271         wxString PropertyTokens;
1272         bool FirstToken = TRUE;
1273         
1274         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1275         intiter != SplitPoints.end(); ++intiter){
1276         
1277                 SLiter = SplitLength.find(intiter->first);
1278         
1279                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1280                 
1281                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1282                 PropertyName = PropertyElement.GetNextToken();                          
1283                 PropertyValue = PropertyElement.GetNextToken();
1284                 
1285                 intPrevValue = intiter->second;
1286                 
1287                 CaptureString(&PropertyValue, FALSE);
1289                 if (PropertyName == wxT("ALTID")){
1291                         TZListAltID->erase(*TimeZoneCount);
1292                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1293                 
1294                 } else if (PropertyName == wxT("PID")){
1296                         TZListPID->erase(*TimeZoneCount);
1297                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1299                 } else if (PropertyName == wxT("PREF")){
1301                         int PriorityNumber = 0;
1302                         bool ValidNumber = TRUE;
1303                         
1304                         try{
1305                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1306                         }
1307                         
1308                         catch(std::invalid_argument &e){
1309                                 ValidNumber = FALSE;
1310                         }
1312                         if (ValidNumber == TRUE){
1314                                 TZListPref->erase(*TimeZoneCount);
1315                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1317                         }
1318                 
1319                 } else if (PropertyName == wxT("MEDIATYPE")){
1321                         TZListMediatype->erase(*TimeZoneCount);
1322                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1324                 } else {
1325                 
1326                         // Something else we don't know about so append
1327                         // to the tokens variable.
1328                 
1329                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1330                 
1331                                 if (FirstToken == TRUE){
1332                         
1333                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1334                                         FirstToken = FALSE;
1335                         
1336                                 } else {
1337                         
1338                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1339                         
1340                                 }
1341                 
1342                         }
1343                 
1344                 }
1345                 
1346         }
1347         
1348         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1349         
1350         // Add the name token data.
1351         
1352         if (!PropertyTokens.IsEmpty()){
1353         
1354                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1355         
1356         }
1361 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1363         size_t intPropertyLen = PropertySeg1.Len();
1364         std::map<int, int> SplitPoints;
1365         std::map<int, int> SplitLength;
1366         std::map<int, int>::iterator SLiter;                    
1367         wxString PropertyData;
1368         wxString PropertyName;
1369         wxString PropertyValue;
1370         wxString PropertyTokens;
1371         wxString AddressLabel;
1372         wxString AddressLang;
1373         wxString AddressAltID;
1374         wxString AddressPID;
1375         wxString AddressTokens;
1376         wxString AddressGeo;
1377         wxString AddressTimezone;
1378         wxString AddressType;
1379         wxString AddressMediatype;
1380         wxString AddressPOBox;
1381         wxString AddressExtended;
1382         wxString AddressStreet;
1383         wxString AddressLocality;
1384         wxString AddressCity;
1385         wxString AddressRegion;
1386         wxString AddressPostalCode;
1387         wxString AddressCountry;
1388         bool FirstToken = TRUE;                 
1389         int intSplitsFound = 0;
1390         int intSplitSize = 0;
1391         int intPrevValue = 5;
1392         int intPref = 0;                        
1393         int intType = 0;
1394         long ListCtrlIndex;
1395         
1396         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1397         
1398         intPrevValue = 4;
1399         
1400         PropertyType PropType = PROPERTY_NONE;
1401                 
1402         // Look for type before continuing.
1403         
1404         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1405         
1406         intPrevValue = 4;
1407         
1408         std::map<int, wxString> *AddressList = NULL;
1409         std::map<int, wxString> *AddressListTown = NULL;
1410         std::map<int, wxString> *AddressListCounty = NULL;
1411         std::map<int, wxString> *AddressListPostCode = NULL;
1412         std::map<int, wxString> *AddressListCountry = NULL;
1413         std::map<int, wxString> *AddressListLabel = NULL;
1414         std::map<int, wxString> *AddressListLang = NULL;                
1415         std::map<int, wxString> *AddressListAltID = NULL;
1416         std::map<int, wxString> *AddressListPID = NULL;
1417         std::map<int, wxString> *AddressListTokens = NULL;
1418         std::map<int, wxString> *AddressListGeo = NULL;
1419         std::map<int, wxString> *AddressListTimezone = NULL;            
1420         std::map<int, wxString> *AddressListType = NULL;
1421         std::map<int, wxString> *AddressListMediatype = NULL;
1422         std::map<int, int> *AddressListPref = NULL;
1424         switch(PropType){
1425                 case PROPERTY_NONE:
1426                         AddressList = &GeneralAddressList;
1427                         AddressListTown = &GeneralAddressListTown;
1428                         AddressListCounty = &GeneralAddressListCounty;
1429                         AddressListPostCode = &GeneralAddressListPostCode;
1430                         AddressListCountry = &GeneralAddressListCountry;
1431                         AddressListLabel = &GeneralAddressListLabel;
1432                         AddressListLang = &GeneralAddressListLang;              
1433                         AddressListAltID = &GeneralAddressListAltID;
1434                         AddressListPID = &GeneralAddressListPID;
1435                         AddressListTokens = &GeneralAddressListTokens;
1436                         AddressListGeo = &GeneralAddressListGeo;
1437                         AddressListTimezone = &GeneralAddressListTimezone;
1438                         AddressListType = &GeneralAddressListType;
1439                         AddressListMediatype = &GeneralAddressListMediatype;
1440                         AddressListPref = &GeneralAddressListPref;              
1441                         break;
1442                 case PROPERTY_HOME:
1443                         AddressList = &HomeAddressList;
1444                         AddressListTown = &HomeAddressListTown;
1445                         AddressListCounty = &HomeAddressListCounty;
1446                         AddressListPostCode = &HomeAddressListPostCode;
1447                         AddressListCountry = &HomeAddressListCountry;
1448                         AddressListLabel = &HomeAddressListLabel;
1449                         AddressListLang = &HomeAddressListLang;         
1450                         AddressListAltID = &HomeAddressListAltID;
1451                         AddressListPID = &HomeAddressListPID;
1452                         AddressListTokens = &HomeAddressListTokens;
1453                         AddressListGeo = &HomeAddressListGeo;
1454                         AddressListTimezone = &HomeAddressListTimezone;
1455                         AddressListType = &HomeAddressListType;
1456                         AddressListMediatype = &HomeAddressListMediatype;
1457                         AddressListPref = &HomeAddressListPref;
1458                         break;
1459                 case PROPERTY_WORK:
1460                         AddressList = &BusinessAddressList;
1461                         AddressListTown = &BusinessAddressListTown;
1462                         AddressListCounty = &BusinessAddressListCounty;
1463                         AddressListPostCode = &BusinessAddressListPostCode;
1464                         AddressListCountry = &BusinessAddressListCountry;
1465                         AddressListLabel = &BusinessAddressListLabel;
1466                         AddressListLang = &BusinessAddressListLang;             
1467                         AddressListAltID = &BusinessAddressListAltID;
1468                         AddressListPID = &BusinessAddressListPID;
1469                         AddressListTokens = &BusinessAddressListTokens;
1470                         AddressListGeo = &BusinessAddressListGeo;
1471                         AddressListTimezone = &BusinessAddressListTimezone;
1472                         AddressListType = &BusinessAddressListType;
1473                         AddressListMediatype = &BusinessAddressListMediatype;
1474                         AddressListPref = &BusinessAddressListPref;
1475                         break;
1476         }
1477         
1478         intPrevValue = 4;
1479         
1480         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1481         intiter != SplitPoints.end(); ++intiter){
1482         
1483                 SLiter = SplitLength.find(intiter->first);
1484         
1485                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1486                 
1487                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1488                 PropertyName = PropertyElement.GetNextToken();                          
1489                 PropertyValue = PropertyElement.GetNextToken();
1490                 
1491                 intPrevValue = intiter->second;
1492                 
1493                 CaptureString(&PropertyValue, FALSE);
1494                 
1495                 // Process properties.
1496                 
1497                 if (PropertyName == wxT("LABEL")){
1498                 
1499                         AddressListLabel->erase(*AddressCount);
1500                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1501                                 
1502                 } else if (PropertyName == wxT("LANGUAGE")){
1503                 
1504                         AddressListLang->erase(*AddressCount);
1505                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1506                 
1507                 } else if (PropertyName == wxT("ALTID")){
1509                         AddressListAltID->erase(*AddressCount);
1510                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1511                 
1512                 } else if (PropertyName == wxT("PID")){
1514                         AddressListPID->erase(*AddressCount);
1515                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1516                 
1517                 } else if (PropertyName == wxT("GEO")){
1518                 
1519                         AddressListGeo->erase(*AddressCount);
1520                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1521                 
1522                 } else if (PropertyName == wxT("TZ")){
1524                         AddressListTimezone->erase(*AddressCount);
1525                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1526                 
1527                 } else if (PropertyName == wxT("MEDIATYPE")){
1529                         AddressListMediatype->erase(*AddressCount);
1530                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1531                 
1532                 } else if (PropertyName == wxT("PREF")){
1533                         
1534                         int PriorityNumber = 0;
1535                         bool ValidNumber = TRUE;
1536                         
1537                         try{
1538                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1539                         }
1540                         
1541                         catch(std::invalid_argument &e){
1542                                 ValidNumber = FALSE;
1543                         }
1545                         if (ValidNumber == TRUE){
1547                                 AddressListPref->erase(*AddressCount);
1548                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1550                         }
1551                 
1552                 } else {
1553                 
1554                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1555                         
1556                                 if (FirstToken == TRUE){
1557                                 
1558                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1559                                         FirstToken = FALSE;
1560                                 
1561                                 } else {
1562                                 
1563                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1564                                 
1565                                 }
1566                         
1567                         }
1568                 
1569                 }
1570         
1571         }                       
1572         
1573         // Split the address. 
1575         //std::map<int, int>::iterator SLiter;
1576         intPropertyLen = PropertySeg2.Len();
1577         SplitPoints.clear();
1578         SplitLength.clear();
1579         intSplitsFound = 0;
1580         intSplitSize = 0;
1581         intPrevValue = 0;
1582         
1583         for (int i = 0; i <= intPropertyLen; i++){
1585                 intSplitSize++;
1586         
1587                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1588         
1589                         intSplitsFound++;
1590                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1591                         
1592                         if (intSplitsFound == 6){ 
1593                         
1594                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1595                                 break; 
1596                                 
1597                         } else {
1598                         
1599                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1600                         
1601                         }
1602                         
1603                         intSplitSize = 0;                                       
1604         
1605                 }
1607         }
1608         
1609         // Split the data into several parts.                   
1610         
1611         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1612         intiter != SplitPoints.end(); ++intiter){
1613                         
1614                 if (intiter->first == 1){
1615                 
1616                         // Deal with PO Box.
1617                         
1618                         SLiter = SplitLength.find(1);
1619                                                                 
1620                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1621                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1622                         intPrevValue = intiter->second;
1623                 
1624                 } else if (intiter->first == 2){
1625                 
1626                         // Deal with extended address.
1627                         
1628                         SLiter = SplitLength.find(2);
1629                         
1630                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1631                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1632                         intPrevValue = intiter->second;
1633                 
1634                 } else if (intiter->first == 3){
1635                 
1636                         // Deal with street address.
1637                         
1638                         SLiter = SplitLength.find(3);
1639                                                                 
1640                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1641                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1642                         intPrevValue = intiter->second;
1643                 
1644                 } else if (intiter->first == 4){
1645                 
1646                         // Deal with locality
1648                         SLiter = SplitLength.find(4);
1649                         
1650                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1651                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1652                         intPrevValue = intiter->second;
1653                         
1654                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1655                 
1656                 } else if (intiter->first == 5){
1657                 
1658                         // Deal with region.
1660                         SLiter = SplitLength.find(5);
1661                         
1662                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1663                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1664                         intPrevValue = intiter->second;
1665                         
1666                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1667                 
1668                 } else if (intiter->first == 6){
1669                 
1670                         // Deal with post code.
1672                         SLiter = SplitLength.find(6);
1673                         
1674                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1675                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1676                         intPrevValue = intiter->second;
1677                         
1678                         // Deal with country.
1679                                                 
1680                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1681                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1682                         
1683                         break;
1684                 
1685                 }
1686         
1687         }       
1688         
1689         // Add the data to the General/Home/Work address variables.
1690         
1691         CaptureString(&AddressStreet, FALSE); 
1692         CaptureString(&AddressLocality, FALSE);
1693         CaptureString(&AddressRegion, FALSE);
1694         CaptureString(&AddressPostalCode, FALSE);
1695         CaptureString(&AddressCountry, FALSE);
1696                 
1697         if (!PropertyTokens.IsEmpty()){
1698         
1699                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1700         
1701         }
1703         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1704         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1705         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1706         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1707         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1709         switch(PropType){
1710                 case PROPERTY_NONE:
1711                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1712                         break;
1713                 case PROPERTY_HOME:
1714                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1715                         break;
1716                 case PROPERTY_WORK:
1717                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1718                         break;
1719         }
1720         
1721         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1725 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1727         std::map<int, int> SplitPoints;
1728         std::map<int, int> SplitLength;
1730         int intPrevValue = 7;
1731         int intPref = 0;                        
1732         
1733         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1734         
1735         intPrevValue = 6;
1736         
1737         PropertyType PropType = PROPERTY_NONE;
1738                 
1739         // Look for type before continuing.
1740         
1741         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1742         
1743         std::map<int, wxString> *EmailList = NULL;
1744         std::map<int, wxString> *EmailListType = NULL;
1745         std::map<int, wxString> *EmailListAltID = NULL;
1746         std::map<int, wxString> *EmailListPID = NULL;
1747         std::map<int, wxString> *EmailListTokens = NULL;                
1748         std::map<int, int> *EmailListPref = NULL;
1750         switch(PropType){
1751                 case PROPERTY_NONE:
1752                         EmailList = &GeneralEmailList;
1753                         EmailListType = &GeneralEmailListType;
1754                         EmailListAltID = &GeneralEmailListAltID;
1755                         EmailListPID = &GeneralEmailListPID;
1756                         EmailListTokens = &GeneralEmailListTokens;              
1757                         EmailListPref = &GeneralEmailListPref;  
1758                         break;
1759                 case PROPERTY_HOME:
1760                         EmailList = &HomeEmailList;
1761                         EmailListType = &HomeEmailListType;
1762                         EmailListAltID = &HomeEmailListAltID;
1763                         EmailListPID = &HomeEmailListPID;
1764                         EmailListTokens = &HomeEmailListTokens;         
1765                         EmailListPref = &HomeEmailListPref;     
1766                         break;
1767                 case PROPERTY_WORK:
1768                         EmailList = &BusinessEmailList;
1769                         EmailListType = &BusinessEmailListType;
1770                         EmailListAltID = &BusinessEmailListAltID;
1771                         EmailListPID = &BusinessEmailListPID;
1772                         EmailListTokens = &BusinessEmailListTokens;             
1773                         EmailListPref = &BusinessEmailListPref; 
1774                         break;
1775         }
1776         
1777         intPrevValue = 6;
1778         
1779         std::map<int,int>::iterator SLiter;
1780         wxString PropertyData;
1781         wxString PropertyName;
1782         wxString PropertyValue;
1783         wxString PropertyTokens;
1784         bool FirstToken = TRUE;
1785         
1786         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1787         intiter != SplitPoints.end(); ++intiter){
1788         
1789                 SLiter = SplitLength.find(intiter->first);
1790         
1791                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1792                 
1793                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1794                 PropertyName = PropertyElement.GetNextToken();                          
1795                 PropertyValue = PropertyElement.GetNextToken();
1796                 
1797                 intPrevValue = intiter->second;
1798                 
1799                 CaptureString(&PropertyValue, FALSE);
1800                 
1801                 // Process properties.
1802                 
1803                 if (PropertyName == wxT("ALTID")){
1805                         EmailListAltID->erase(*EmailCount);
1806                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1807                 
1808                 } else if (PropertyName == wxT("PID")){
1810                         EmailListPID->erase(*EmailCount);
1811                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1812                 
1813                 } else if (PropertyName == wxT("PREF")){
1814                         
1815                         int PriorityNumber = 0;
1816                         bool ValidNumber = TRUE;
1817                         
1818                         try{
1819                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1820                         }
1821                         
1822                         catch(std::invalid_argument &e){
1823                                 ValidNumber = FALSE;
1824                         }
1826                         if (ValidNumber == TRUE){
1828                                 EmailListPref->erase(*EmailCount);
1829                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1831                         }
1832                 
1833                 } else {
1834                 
1835                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1836                         
1837                                 if (FirstToken == TRUE){
1838                                 
1839                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1840                                         FirstToken = FALSE;
1841                                 
1842                                 } else {
1843                                 
1844                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1845                                 
1846                                 }
1847                         
1848                         }
1849                 
1850                 }
1851         
1852         }
1853         
1854         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1855         
1856         // Add the name token data.
1857         
1858         if (!PropertyTokens.IsEmpty()){
1859         
1860                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1861         
1862         }       
1867 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1869         std::map<int, int> SplitPoints;
1870         std::map<int, int> SplitLength;
1872         int intPrevValue = 6;
1873         int intPref = 0;                        
1874         
1875         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1876         
1877         intPrevValue = 5;
1878         
1879         PropertyType PropType = PROPERTY_NONE;
1880                 
1881         // Look for type before continuing.
1882         
1883         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1884         
1885         std::map<int, wxString> *IMList = NULL;
1886         std::map<int, wxString> *IMListType = NULL;
1887         std::map<int, wxString> *IMListAltID = NULL;
1888         std::map<int, wxString> *IMListPID = NULL;
1889         std::map<int, wxString> *IMListTokens = NULL;
1890         std::map<int, wxString> *IMListMediatype = NULL;        
1891         std::map<int, int> *IMListPref = NULL;
1893         switch(PropType){
1894                 case PROPERTY_NONE:
1895                         IMList = &GeneralIMList;
1896                         IMListType = &GeneralIMListType;
1897                         IMListAltID = &GeneralIMListAltID;
1898                         IMListPID = &GeneralIMListPID;
1899                         IMListTokens = &GeneralIMListTokens;
1900                         IMListMediatype = &GeneralIMListMediatype;
1901                         IMListPref = &GeneralIMListPref;        
1902                         break;
1903                 case PROPERTY_HOME:
1904                         IMList = &HomeIMList;
1905                         IMListType = &HomeIMListType;
1906                         IMListAltID = &HomeIMListAltID;
1907                         IMListPID = &HomeIMListPID;
1908                         IMListTokens = &HomeIMListTokens;
1909                         IMListMediatype = &HomeIMListMediatype;         
1910                         IMListPref = &HomeIMListPref;   
1911                         break;
1912                 case PROPERTY_WORK:
1913                         IMList = &BusinessIMList;
1914                         IMListType = &BusinessIMListType;
1915                         IMListAltID = &BusinessIMListAltID;
1916                         IMListPID = &BusinessIMListPID;
1917                         IMListTokens = &BusinessIMListTokens;   
1918                         IMListMediatype = &BusinessIMListMediatype;     
1919                         IMListPref = &BusinessIMListPref;       
1920                         break;
1921         }
1922         
1923         intPrevValue = 5;
1924         
1925         std::map<int,int>::iterator SLiter;
1926         wxString PropertyData;
1927         wxString PropertyName;
1928         wxString PropertyValue;
1929         wxString PropertyTokens;
1930         bool FirstToken = TRUE;
1931         
1932         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1933         intiter != SplitPoints.end(); ++intiter){
1934         
1935                 SLiter = SplitLength.find(intiter->first);
1936         
1937                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1938                 
1939                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1940                 PropertyName = PropertyElement.GetNextToken();                          
1941                 PropertyValue = PropertyElement.GetNextToken();
1942                 
1943                 intPrevValue = intiter->second;
1944                 
1945                 CaptureString(&PropertyValue, FALSE);
1946                 
1947                 // Process properties.
1948                 
1949                 if (PropertyName == wxT("ALTID")){
1951                         IMListAltID->erase(*IMCount);
1952                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1953                 
1954                 } else if (PropertyName == wxT("PID")){
1956                         IMListPID->erase(*IMCount);
1957                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1958                 
1959                 } else if (PropertyName == wxT("MEDIATYPE")){
1961                         IMListMediatype->erase(*IMCount);
1962                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1963                 
1964                 } else if (PropertyName == wxT("PREF")){
1965                         
1966                         int PriorityNumber = 0;
1967                         bool ValidNumber = TRUE;
1968                         
1969                         try{
1970                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1971                         }
1972                         
1973                         catch(std::invalid_argument &e){
1974                                 ValidNumber = FALSE;
1975                         }
1977                         if (ValidNumber == TRUE){
1979                                 IMListPref->erase(*IMCount);
1980                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1982                         }
1983                 
1984                 } else {
1985                 
1986                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1987                         
1988                                 if (FirstToken == TRUE){
1989                                 
1990                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1991                                         FirstToken = FALSE;
1992                                 
1993                                 } else {
1994                                 
1995                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1996                                 
1997                                 }
1998                         
1999                         }
2000                 
2001                 }
2002         
2003         }
2004                 
2005         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2006         
2007         // Add the name token data.
2008         
2009         if (!PropertyTokens.IsEmpty()){
2010         
2011                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2012         
2013         }
2017 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2019         std::map<int, int> SplitPoints;
2020         std::map<int, int> SplitLength;
2021         std::map<int, int>::iterator SLiter;
2022         
2023         int intPref = 0;
2024         
2025         PropertyType PropType = PROPERTY_NONE;
2026                 
2027         // Look for type before continuing.
2028         
2029         wxString TelTypeUI;
2030         wxString TelTypeDetail;
2031         wxString PropertyData;
2032         wxString PropertyName;
2033         wxString PropertyValue;
2034         wxString PropertyTokens;
2035         
2036         std::map<int,int> TypeSplitPoints;
2037         std::map<int,int> TypeSplitLength;
2038         std::map<int,int>::iterator TSLiter;
2039         
2040         int intSplitSize = 0;
2041         int intSplitsFound = 0;
2042         int intSplitPoint = 0;
2043         int intType = 0;
2044         int intPrevValue = 5;
2045                 
2046         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2047         
2048         intPrevValue = 4;
2049         
2050         // Look for type before continuing.
2051         
2052         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2053         intiter != SplitPoints.end(); ++intiter){
2054         
2055                 SLiter = SplitLength.find(intiter->first);
2056         
2057                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2058                 
2059                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2060                 PropertyName = PropertyElement.GetNextToken();                          
2061                 PropertyValue = PropertyElement.GetNextToken();
2062                 
2063                 intPrevValue = intiter->second;
2065                 if (PropertyName == wxT("TYPE")){
2066                 
2067                         // Process each value in type and translate each
2068                         // part.
2069                 
2070                         // Strip out the quotes if they are there.
2071                 
2072                         size_t intPropertyValueLen = PropertyValue.Len();
2073                 
2074                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2075                         
2076                                 PropertyValue.Trim();
2077                                 PropertyValue.RemoveLast();
2078                         
2079                         }                               
2080                 
2081                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2082                         
2083                                 PropertyValue.Remove(0, 1);
2084                         
2085                         }
2086                         
2087                         TelTypeDetail = PropertyValue;
2088                         
2089                         intSplitSize = 0;
2090                         intSplitsFound = 0;
2091                         intSplitPoint = 0;
2092                         
2093                         for (int i = 0; i <= intPropertyValueLen; i++){
2094         
2095                                 intSplitSize++;
2096         
2097                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2098         
2099                                         if (intSplitsFound == 0){
2101                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2102                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2103                         
2104                                         } else {
2105                         
2106                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2107                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2108                         
2109                                         }                       
2111                                         intSplitsFound++;
2112                                         i++;
2113                                         intSplitPoint = i;
2114                                         intSplitSize = 0;
2115         
2116                                 }
2117         
2118                         }
2119                         
2120                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2121                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2122                 
2123                         int intTypeSeek = 0;
2124                 
2125                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2126                         typeiter != TypeSplitPoints.end(); ++typeiter){
2127                         
2128                                 wxString TypePropertyName;
2129                                 
2130                                 TSLiter = TypeSplitLength.find(typeiter->first);
2131                                 
2132                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2133                                 
2134                                 if (intTypeSeek == 0){
2135                                 
2136                                 
2137                                 } else {
2138                                                                                 
2139                                         TelTypeUI.Append(wxT(","));                                                     
2140                                 
2141                                 }
2142                         
2143                                 if (TypePropertyName == wxT("home")){
2144                                 
2145                                         PropType = PROPERTY_HOME;
2146                                 
2147                                 } else if (TypePropertyName == wxT("work")){
2148                                 
2149                                         PropType = PROPERTY_WORK;
2150                                                                         
2151                                 }
2152                                 
2153                                 
2154                                 if (TypePropertyName == wxT("text")){
2155                                 
2156                                         TelTypeUI.Append(_("text"));
2157                                         intTypeSeek++;
2158                                 
2159                                 } else if (TypePropertyName == wxT("voice")){
2160                                 
2161                                         TelTypeUI.Append(_("voice"));
2162                                         intTypeSeek++;
2163                                 
2164                                 } else if (TypePropertyName == wxT("fax")){
2165                                 
2166                                         TelTypeUI.Append(_("fax"));
2167                                         intTypeSeek++;
2168                                 
2169                                 } else if (TypePropertyName == wxT("cell")){
2170                                 
2171                                         TelTypeUI.Append(_("mobile"));
2172                                         intTypeSeek++;
2173                                 
2174                                 } else if (TypePropertyName == wxT("video")){
2175                                 
2176                                         TelTypeUI.Append(_("video"));
2177                                         intTypeSeek++;
2178                                 
2179                                 } else if (TypePropertyName == wxT("pager")){
2180                                 
2181                                         TelTypeUI.Append(_("pager"));
2182                                         intTypeSeek++;
2183                                 
2184                                 } else if (TypePropertyName == wxT("textphone")){
2185                                 
2186                                         TelTypeUI.Append(_("textphone"));
2187                                         intTypeSeek++;
2188                                 
2189                                 }
2190                         
2191                         }
2192                 
2193                 }
2194                 
2195         }
2196         
2197         std::map<int, wxString> *TelephoneList = NULL;
2198         std::map<int, wxString> *TelephoneListType = NULL;
2199         std::map<int, wxString> *TelephoneListAltID = NULL;
2200         std::map<int, wxString> *TelephoneListPID = NULL;
2201         std::map<int, wxString> *TelephoneListTokens = NULL;
2202         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2203         std::map<int, int> *TelephoneListPref = NULL;
2205         switch(PropType){
2206                 case PROPERTY_NONE:
2207                         TelephoneList = &GeneralTelephoneList;
2208                         TelephoneListType = &GeneralTelephoneListType;
2209                         TelephoneListAltID = &GeneralTelephoneListAltID;
2210                         TelephoneListPID = &GeneralTelephoneListPID;
2211                         TelephoneListTokens = &GeneralTelephoneListTokens;
2212                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2213                         TelephoneListPref = &GeneralTelephoneListPref;  
2214                         break;
2215                 case PROPERTY_HOME:
2216                         TelephoneList = &HomeTelephoneList;
2217                         TelephoneListType = &HomeTelephoneListType;
2218                         TelephoneListAltID = &HomeTelephoneListAltID;
2219                         TelephoneListPID = &HomeTelephoneListPID;
2220                         TelephoneListTokens = &HomeTelephoneListTokens;
2221                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2222                         TelephoneListPref = &HomeTelephoneListPref;     
2223                         break;
2224                 case PROPERTY_WORK:
2225                         TelephoneList = &BusinessTelephoneList;
2226                         TelephoneListType = &BusinessTelephoneListType;
2227                         TelephoneListAltID = &BusinessTelephoneListAltID;
2228                         TelephoneListPID = &BusinessTelephoneListPID;
2229                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2230                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2231                         TelephoneListPref = &BusinessTelephoneListPref; 
2232                         break;
2233         }
2234                 
2235         // Process the properties.
2236         
2237         bool FirstToken = TRUE;
2238         
2239         intPrevValue = 5;
2240         SplitPoints.clear();
2241         SplitLength.clear();
2243         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2245         intPrevValue = 4;
2246         
2247         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2248         intiter != SplitPoints.end(); ++intiter){
2249         
2250                 SLiter = SplitLength.find(intiter->first);
2251         
2252                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2253                 
2254                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2255                 PropertyName = PropertyElement.GetNextToken();                          
2256                 PropertyValue = PropertyElement.GetNextToken();
2257                 
2258                 intPrevValue = intiter->second;
2259                 
2260                 CaptureString(&PropertyValue, FALSE);
2261                 
2262                 // Process properties.
2263                 
2264                 if (PropertyName == wxT("ALTID")){
2266                         TelephoneListAltID->erase(*TelephoneCount);
2267                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2268                 
2269                 } else if (PropertyName == wxT("PID")){
2271                         TelephoneListPID->erase(*TelephoneCount);
2272                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2273                 
2274                 } else if (PropertyName == wxT("PREF")){
2275                         
2276                         int PriorityNumber = 0;
2277                         bool ValidNumber = TRUE;
2278                         
2279                         try{
2280                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2281                         }
2282                         
2283                         catch(std::invalid_argument &e){
2284                                 ValidNumber = FALSE;
2285                         }
2287                         if (ValidNumber == TRUE){
2289                                 TelephoneListPref->erase(*TelephoneCount);
2290                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2292                         }
2293                 
2294                 } else {
2295                 
2296                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2297                         
2298                                 if (FirstToken == TRUE){
2299                                 
2300                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2301                                         FirstToken = FALSE;
2302                                 
2303                                 } else {
2304                                 
2305                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2306                                 
2307                                 }
2308                         
2309                         }
2310                 
2311                 }
2312         
2313         }
2314                 
2315         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2316         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2317         
2318         // Add the name token data.
2319         
2320         if (!PropertyTokens.IsEmpty()){
2321         
2322                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2323         
2324         }
2328 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2330         std::map<int, int> SplitPoints;
2331         std::map<int, int> SplitLength;
2333         int intPrevValue = 6;
2334         int intPref = 0;                        
2335         
2336         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2337         
2338         intPrevValue = 5;
2339         
2340         PropertyType PropType = PROPERTY_NONE;
2341                 
2342         // Look for type before continuing.
2343         
2344         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2345         
2346         std::map<int, wxString> *LanguageList = NULL;
2347         std::map<int, wxString> *LanguageListType = NULL;
2348         std::map<int, wxString> *LanguageListAltID = NULL;
2349         std::map<int, wxString> *LanguageListPID = NULL;
2350         std::map<int, wxString> *LanguageListTokens = NULL;
2351         std::map<int, int> *LanguageListPref = NULL;
2353         switch(PropType){
2354                 case PROPERTY_NONE:
2355                         LanguageList = &GeneralLanguageList;
2356                         LanguageListType = &GeneralLanguageListType;
2357                         LanguageListAltID = &GeneralLanguageListAltID;
2358                         LanguageListPID = &GeneralLanguageListPID;
2359                         LanguageListTokens = &GeneralLanguageListTokens;
2360                         LanguageListPref = &GeneralLanguageListPref;    
2361                         break;
2362                 case PROPERTY_HOME:
2363                         LanguageList = &HomeLanguageList;
2364                         LanguageListType = &HomeLanguageListType;
2365                         LanguageListAltID = &HomeLanguageListAltID;
2366                         LanguageListPID = &HomeLanguageListPID;
2367                         LanguageListTokens = &HomeLanguageListTokens;   
2368                         LanguageListPref = &HomeLanguageListPref;       
2369                         break;
2370                 case PROPERTY_WORK:
2371                         LanguageList = &BusinessLanguageList;
2372                         LanguageListType = &BusinessLanguageListType;
2373                         LanguageListAltID = &BusinessLanguageListAltID;
2374                         LanguageListPID = &BusinessLanguageListPID;
2375                         LanguageListTokens = &BusinessLanguageListTokens;       
2376                         LanguageListPref = &BusinessLanguageListPref;
2377                         break;
2378         }
2379         
2380         intPrevValue = 5;
2381         
2382         std::map<int,int>::iterator SLiter;
2383         wxString PropertyData;
2384         wxString PropertyName;
2385         wxString PropertyValue;
2386         wxString PropertyTokens;
2387         bool FirstToken = TRUE;
2388         
2389         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2390         intiter != SplitPoints.end(); ++intiter){
2391         
2392                 SLiter = SplitLength.find(intiter->first);
2393         
2394                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2395                 
2396                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2397                 PropertyName = PropertyElement.GetNextToken();                          
2398                 PropertyValue = PropertyElement.GetNextToken();
2399                 
2400                 intPrevValue = intiter->second;
2401                 
2402                 CaptureString(&PropertyValue, FALSE);
2403                 
2404                 // Process properties.
2405                 
2406                 if (PropertyName == wxT("ALTID")){
2408                         LanguageListAltID->erase(*LanguageCount);
2409                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2410                 
2411                 } else if (PropertyName == wxT("PID")){
2413                         LanguageListPID->erase(*LanguageCount);
2414                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2415                 
2416                 } else if (PropertyName == wxT("PREF")){
2417                         
2418                         int PriorityNumber = 0;
2419                         bool ValidNumber = TRUE;
2420                         
2421                         try{
2422                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2423                         }
2424                         
2425                         catch(std::invalid_argument &e){
2426                                 ValidNumber = FALSE;
2427                         }
2429                         if (ValidNumber == TRUE){
2431                                 LanguageListPref->erase(*LanguageCount);
2432                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2434                         }
2435                 
2436                 } else {
2437                 
2438                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2439                         
2440                                 if (FirstToken == TRUE){
2441                                 
2442                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2443                                         FirstToken = FALSE;
2444                                 
2445                                 } else {
2446                                 
2447                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2448                                 
2449                                 }
2450                         
2451                         }
2452                 
2453                 }
2454         
2455         }
2456                 
2457         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2458         
2459         // Add the name token data.
2460         
2461         if (!PropertyTokens.IsEmpty()){
2462         
2463                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2464         
2465         }
2469 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2471         std::map<int, int> SplitPoints;
2472         std::map<int, int> SplitLength;
2474         int intPrevValue = 5;
2475         int intPref = 0;                        
2476         
2477         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2478         
2479         intPrevValue = 4;
2480         
2481         PropertyType PropType = PROPERTY_NONE;
2482                 
2483         // Look for type before continuing.
2484         
2485         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2486         
2487         std::map<int, wxString> *GeopositionList = NULL;
2488         std::map<int, wxString> *GeopositionListType = NULL;
2489         std::map<int, wxString> *GeopositionListAltID = NULL;
2490         std::map<int, wxString> *GeopositionListPID = NULL;
2491         std::map<int, wxString> *GeopositionListTokens = NULL;
2492         std::map<int, wxString> *GeopositionListMediatype = NULL;
2493         std::map<int, int> *GeopositionListPref = NULL;
2495         switch(PropType){
2496                 case PROPERTY_NONE:
2497                         GeopositionList = &GeneralGeographyList;
2498                         GeopositionListType = &GeneralGeographyListType;
2499                         GeopositionListAltID = &GeneralGeographyListAltID;
2500                         GeopositionListPID = &GeneralGeographyListPID;
2501                         GeopositionListTokens = &GeneralGeographyListTokens;
2502                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2503                         GeopositionListPref = &GeneralGeographyListPref;        
2504                         break;
2505                 case PROPERTY_HOME:
2506                         GeopositionList = &HomeGeographyList;
2507                         GeopositionListType = &HomeGeographyListType;
2508                         GeopositionListAltID = &HomeGeographyListAltID;
2509                         GeopositionListPID = &HomeGeographyListPID;
2510                         GeopositionListTokens = &HomeGeographyListTokens;
2511                         GeopositionListMediatype = &HomeGeographyListMediatype;
2512                         GeopositionListPref = &HomeGeographyListPref;   
2513                         break;
2514                 case PROPERTY_WORK:
2515                         GeopositionList = &BusinessGeographyList;
2516                         GeopositionListType = &BusinessGeographyListType;
2517                         GeopositionListAltID = &BusinessGeographyListAltID;
2518                         GeopositionListPID = &BusinessGeographyListPID;
2519                         GeopositionListTokens = &BusinessGeographyListTokens;
2520                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2521                         GeopositionListPref = &BusinessGeographyListPref;
2522                         break;
2523         }
2524         
2525         intPrevValue = 4;
2526         
2527         std::map<int,int>::iterator SLiter;
2528         wxString PropertyData;
2529         wxString PropertyName;
2530         wxString PropertyValue;
2531         wxString PropertyTokens;
2532         bool FirstToken = TRUE;
2533         
2534         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2535         intiter != SplitPoints.end(); ++intiter){
2536         
2537                 SLiter = SplitLength.find(intiter->first);
2538         
2539                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2540                 
2541                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2542                 PropertyName = PropertyElement.GetNextToken();                          
2543                 PropertyValue = PropertyElement.GetNextToken();
2544                 
2545                 intPrevValue = intiter->second;
2546                 
2547                 CaptureString(&PropertyValue, FALSE);
2548                 
2549                 // Process properties.
2550                 
2551                 if (PropertyName == wxT("ALTID")){
2553                         GeopositionListAltID->erase(*GeographicCount);
2554                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2555                 
2556                 } else if (PropertyName == wxT("PID")){
2558                         GeopositionListPID->erase(*GeographicCount);
2559                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2560                 
2561                 } else if (PropertyName == wxT("MEDIATYPE")){
2563                         GeopositionListMediatype->erase(*GeographicCount);
2564                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2565                 
2566                 } else if (PropertyName == wxT("PREF")){
2567                         
2568                         int PriorityNumber = 0;
2569                         bool ValidNumber = TRUE;
2570                         
2571                         try{
2572                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2573                         }
2574                         
2575                         catch(std::invalid_argument &e){
2576                                 ValidNumber = FALSE;
2577                         }
2579                         if (ValidNumber == TRUE){
2581                                 GeopositionListPref->erase(*GeographicCount);
2582                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2584                         }
2585                 
2586                 } else {
2587                 
2588                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2589                         
2590                                 if (FirstToken == TRUE){
2591                                 
2592                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2593                                         FirstToken = FALSE;
2594                                 
2595                                 } else {
2596                                 
2597                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2598                                 
2599                                 }
2600                         
2601                         }
2602                 
2603                 }
2604         
2605         }
2606                 
2607         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2608         
2609         // Add the name token data.
2610         
2611         if (!PropertyTokens.IsEmpty()){
2612         
2613                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2614         
2615         }
2619 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2621         size_t intPropertyLen = PropertySeg1.Len();
2622         std::map<int, int> SplitPoints;
2623         std::map<int, int> SplitLength;
2624         std::map<int, int>::iterator SLiter;                    
2625         wxString PropertyData;
2626         wxString PropertyName;
2627         wxString PropertyValue;
2628         wxString PropertyTokens;
2629         wxString RelatedType;
2630         wxString RelatedTypeOriginal;                   
2631         wxString RelatedName;
2632         bool FirstToken = TRUE;                 
2633         int intSplitsFound = 0;
2634         int intSplitSize = 0;
2635         int intPrevValue = 9;
2636         int intPref = 0;
2637         long ListCtrlIndex;
2638         
2639         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2640         
2641         intPrevValue = 8;
2642         
2643         // Look for type before continuing.
2644         
2645         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2646         intiter != SplitPoints.end(); ++intiter){
2647         
2648                 SLiter = SplitLength.find(intiter->first);
2649         
2650                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2651                 
2652                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2653                 PropertyName = PropertyElement.GetNextToken();                          
2654                 PropertyValue = PropertyElement.GetNextToken();
2655                 
2656                 intPrevValue = intiter->second;
2657                 
2658                 // Process these.
2659                 
2660                 RelatedTypeOriginal = PropertyValue;
2661                 
2662                 if (PropertyName == wxT("TYPE")){
2663                 
2664                         if (PropertyValue == wxT("contact")){
2666                                 RelatedType = _("Contact");
2668                         } else if (PropertyValue == wxT("acquaintance")){
2670                                 RelatedType = _("Acquaintance");
2672                         } else if (PropertyValue == wxT("friend")){
2674                                 RelatedType = _("Friend");
2676                         } else if (PropertyValue == wxT("met")){
2678                                 RelatedType = _("Met");
2680                         } else if (PropertyValue == wxT("co-worker")){
2682                                 RelatedType = _("Co-worker");
2684                         } else if (PropertyValue == wxT("colleague")){
2686                                 RelatedType = _("Colleague");
2688                         } else if (PropertyValue == wxT("co-resident")){
2690                                 RelatedType = _("Co-resident");
2692                         } else if (PropertyValue == wxT("neighbor")){
2694                                 RelatedType = _("Neighbour");
2696                         } else if (PropertyValue == wxT("child")){
2698                                 RelatedType = _("Child");
2700                         } else if (PropertyValue == wxT("parent")){
2702                                 RelatedType = _("Parent");
2704                         } else if (PropertyValue == wxT("sibling")){
2706                                 RelatedType = _("Sibling");
2708                         } else if (PropertyValue == wxT("spouse")){
2710                                 RelatedType = _("Spouse");
2712                         } else if (PropertyValue == wxT("kin")){
2714                                 RelatedType = _("Kin");
2716                         } else if (PropertyValue == wxT("muse")){
2718                                 RelatedType = _("Muse");
2720                         } else if (PropertyValue == wxT("crush")){
2722                                 RelatedType = _("Crush");
2724                         } else if (PropertyValue == wxT("date")){
2726                                 RelatedType = _("Date");
2728                         } else if (PropertyValue == wxT("sweetheart")){
2730                                 RelatedType = _("Sweetheart");
2732                         } else if (PropertyValue == wxT("me")){
2734                                 RelatedType = _("Me");
2736                         } else if (PropertyValue == wxT("agent")){
2738                                 RelatedType = _("Agent");
2740                         } else if (PropertyValue == wxT("emergency")){
2742                                 RelatedType = _("Emergency");
2744                         } else {
2746                                 RelatedType = PropertyValue;
2748                         }
2749                 
2750                 }
2751         
2752         }
2753         
2754         intPrevValue = 8;                       
2755         
2756         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2757         intiter != SplitPoints.end(); ++intiter){
2758         
2759                 SLiter = SplitLength.find(intiter->first);
2760         
2761                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2762                 
2763                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2764                 PropertyName = PropertyElement.GetNextToken();                          
2765                 PropertyValue = PropertyElement.GetNextToken();
2766                 
2767                 intPrevValue = intiter->second;
2768                 
2769                 // Process properties.
2770                 
2771                 size_t intPropertyValueLen = PropertyValue.Len();
2772                 
2773                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2774                         
2775                         PropertyValue.Trim();
2776                         PropertyValue.RemoveLast();
2777                         
2778                 }                               
2779                 
2780                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2781                         
2782                         PropertyValue.Remove(0, 1);
2783                         
2784                 }
2785                 
2786                 CaptureString(&PropertyValue, FALSE);
2787                         
2788                 if (PropertyName == wxT("ALTID")){
2790                         GeneralRelatedListAltID.erase(*RelatedCount);
2791                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2792                 
2793                 } else if (PropertyName == wxT("PID")){
2795                         GeneralRelatedListPID.erase(*RelatedCount);
2796                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2797                 
2798                 } else if (PropertyName == wxT("PREF")){
2799                         
2800                         int PriorityNumber = 0;
2801                         bool ValidNumber = TRUE;
2802                         
2803                         try{
2804                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2805                         }
2806                         
2807                         catch(std::invalid_argument &e){
2808                                 ValidNumber = FALSE;
2809                         }
2811                         if (ValidNumber == TRUE){
2813                                 GeneralRelatedListPref.erase(*RelatedCount);
2814                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2816                         }
2817                 
2818                 } else if (PropertyName == wxT("LANGUAGE")){
2819                 
2820                         GeneralRelatedListLanguage.erase(*RelatedCount);
2821                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2822                 
2823                 } else if (PropertyName != wxT("TYPE")) {
2824                 
2825                         // Something else we don't know about so append
2826                         // to the tokens variable.
2827                 
2828                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2829                 
2830                                 if (FirstToken == TRUE){
2831                         
2832                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2833                                         FirstToken = FALSE;
2834                         
2835                                 } else {
2836                         
2837                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2838                         
2839                                 }
2840                 
2841                         }
2842                 
2843                 }
2844         
2845         }                                       
2846         
2847         // Add the data to the General/Home/Work address variables.
2848                                 
2849         GeneralRelatedList.erase(*RelatedCount);
2850         GeneralRelatedListRelType.erase(*RelatedCount);
2851         GeneralRelatedListType.erase(*RelatedCount);
2852         GeneralRelatedListTokens.erase(*RelatedCount);
2853         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2854         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2855         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2856         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2860 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2862         std::map<int, int> SplitPoints;
2863         std::map<int, int> SplitLength;
2864         std::map<int, int>::iterator SLiter;                    
2865         wxString PropertyData;
2866         wxString PropertyName;
2867         wxString PropertyValue;
2868         wxString PropertyTokens;
2869         bool FirstToken = TRUE;
2870         int intPrevValue = 5;
2871         int intPref = 0;                        
2872         int intType = 0;
2873         long ListCtrlIndex;
2874         
2875         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2876         
2877         intPrevValue = 4;
2878         
2879         PropertyType PropType = PROPERTY_NONE;
2880                 
2881         // Look for type before continuing.
2882         
2883         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2884         
2885         // Setup the pointers.
2886         
2887         std::map<int, wxString> *WebsiteList = NULL;
2888         std::map<int, wxString> *WebsiteListAltID = NULL;
2889         std::map<int, wxString> *WebsiteListPID = NULL;
2890         std::map<int, wxString> *WebsiteListType = NULL;
2891         std::map<int, wxString> *WebsiteListTokens = NULL;
2892         std::map<int, wxString> *WebsiteListMediatype = NULL;
2893         std::map<int, int> *WebsiteListPref = NULL;
2894         
2895         // Setup blank lines for later on.
2896         
2897         switch(PropType){
2898                 case PROPERTY_NONE:
2899                         WebsiteList = &GeneralWebsiteList;
2900                         WebsiteListType = &GeneralWebsiteListType;
2901                         WebsiteListAltID = &GeneralWebsiteListAltID;
2902                         WebsiteListPID = &GeneralWebsiteListPID;
2903                         WebsiteListTokens = &GeneralWebsiteListTokens;
2904                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2905                         WebsiteListPref = &GeneralWebsiteListPref;      
2906                         break;
2907                 case PROPERTY_HOME:
2908                         WebsiteList = &HomeWebsiteList;
2909                         WebsiteListType = &HomeWebsiteListType;
2910                         WebsiteListAltID = &HomeWebsiteListAltID;
2911                         WebsiteListPID = &HomeWebsiteListPID;
2912                         WebsiteListTokens = &HomeWebsiteListTokens;
2913                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2914                         WebsiteListPref = &HomeWebsiteListPref; 
2915                         break;
2916                 case PROPERTY_WORK:
2917                         WebsiteList = &BusinessWebsiteList;
2918                         WebsiteListType = &BusinessWebsiteListType;
2919                         WebsiteListAltID = &BusinessWebsiteListAltID;
2920                         WebsiteListPID = &BusinessWebsiteListPID;
2921                         WebsiteListTokens = &BusinessWebsiteListTokens;
2922                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2923                         WebsiteListPref = &BusinessWebsiteListPref;
2924                         break;
2925         }
2926         
2927         intPrevValue = 4;
2928         
2929         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2930         intiter != SplitPoints.end(); ++intiter){
2931         
2932                 SLiter = SplitLength.find(intiter->first);
2933         
2934                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2935                 
2936                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2937                 PropertyName = PropertyElement.GetNextToken();                          
2938                 PropertyValue = PropertyElement.GetNextToken();
2939                 
2940                 intPrevValue = intiter->second;
2941                 
2942                 // Process properties.
2943                 
2944                 size_t intPropertyValueLen = PropertyValue.Len();
2945                 
2946                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2947                         
2948                         PropertyValue.Trim();
2949                         PropertyValue.RemoveLast();
2950                         
2951                 }                               
2952                 
2953                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2954                         
2955                         PropertyValue.Remove(0, 1);
2956                         
2957                 }
2958                 
2959                 CaptureString(&PropertyValue, FALSE);
2960                 
2961                 if (PropertyName == wxT("ALTID")){
2963                         WebsiteListAltID->erase(*URLCount);
2964                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2965                 
2966                 } else if (PropertyName == wxT("PID")){
2968                         WebsiteListPID->erase(*URLCount);
2969                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2970                         
2971                 } else if (PropertyName == wxT("PREF")){
2972                         
2973                         int PriorityNumber = 0;
2974                         bool ValidNumber = TRUE;
2975                         
2976                         try{
2977                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2978                         }
2979                         
2980                         catch(std::invalid_argument &e){
2981                                 ValidNumber = FALSE;
2982                         }
2984                         if (ValidNumber == TRUE){
2986                                 WebsiteListPref->erase(*URLCount);
2987                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2989                         }
2990                                         
2991                 } else if (PropertyName == wxT("MEDIATYPE")){
2992                 
2993                         WebsiteListMediatype->erase(*URLCount);
2994                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2995                 
2996                 } else {
2997                 
2998                         // Something else we don't know about so append
2999                         // to the tokens variable.
3000                 
3001                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3002                 
3003                                 if (FirstToken == TRUE){
3004                         
3005                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3006                                         FirstToken = FALSE;
3007                         
3008                                 } else {
3009                         
3010                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3011                         
3012                                 }
3013                 
3014                         }
3015                 
3016                 }
3017         
3018         }
3019         
3020         // Add the data to the General/Home/Work address variables.
3021         
3022         CaptureString(&PropertySeg2, FALSE);
3023                         
3024         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3025         
3026         if (!PropertyTokens.IsEmpty()){
3027         
3028                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3029                         
3030         }
3031         
3034 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3036         std::map<int, int> SplitPoints;
3037         std::map<int, int> SplitLength;
3038         std::map<int, int>::iterator SLiter;                    
3039         wxString PropertyData;
3040         wxString PropertyName;
3041         wxString PropertyValue;
3042         wxString PropertyTokens;
3043         bool FirstToken = TRUE;
3044         int intPrevValue = 7;
3045         int intPref = 0;                        
3046         int intType = 0;
3047         long ListCtrlIndex;
3048         
3049         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3050         
3051         intPrevValue = 6;
3052         
3053         PropertyType PropType = PROPERTY_NONE;
3054                 
3055         // Look for type before continuing.
3056         
3057         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3058         
3059         // Setup the pointers.
3060         
3061         std::map<int, wxString> *TitleList = NULL;
3062         std::map<int, wxString> *TitleListAltID = NULL;
3063         std::map<int, wxString> *TitleListPID = NULL;
3064         std::map<int, wxString> *TitleListType = NULL;
3065         std::map<int, wxString> *TitleListTokens = NULL;
3066         std::map<int, wxString> *TitleListLanguage = NULL;
3067         std::map<int, int> *TitleListPref = NULL;
3068         
3069         // Setup blank lines for later on.
3070         
3071         switch(PropType){
3072                 case PROPERTY_NONE:
3073                         TitleList = &GeneralTitleList;
3074                         TitleListType = &GeneralTitleListType;
3075                         TitleListAltID = &GeneralTitleListAltID;
3076                         TitleListPID = &GeneralTitleListPID;
3077                         TitleListTokens = &GeneralTitleListTokens;
3078                         TitleListLanguage = &GeneralTitleListLanguage;
3079                         TitleListPref = &GeneralTitleListPref;  
3080                         break;
3081                 case PROPERTY_HOME:
3082                         TitleList = &HomeTitleList;
3083                         TitleListType = &HomeTitleListType;
3084                         TitleListAltID = &HomeTitleListAltID;
3085                         TitleListPID = &HomeTitleListPID;
3086                         TitleListTokens = &HomeTitleListTokens;
3087                         TitleListLanguage = &HomeTitleListLanguage;
3088                         TitleListPref = &HomeTitleListPref;     
3089                         break;
3090                 case PROPERTY_WORK:
3091                         TitleList = &BusinessTitleList;
3092                         TitleListType = &BusinessTitleListType;
3093                         TitleListAltID = &BusinessTitleListAltID;
3094                         TitleListPID = &BusinessTitleListPID;
3095                         TitleListTokens = &BusinessTitleListTokens;
3096                         TitleListLanguage = &BusinessTitleListLanguage; 
3097                         TitleListPref = &BusinessTitleListPref;
3098                         break;
3099         }
3101         intPrevValue = 6;
3102                 
3103         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3104         intiter != SplitPoints.end(); ++intiter){
3105         
3106                 SLiter = SplitLength.find(intiter->first);
3107         
3108                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3109                 
3110                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3111                 PropertyName = PropertyElement.GetNextToken();                          
3112                 PropertyValue = PropertyElement.GetNextToken();
3113                 
3114                 intPrevValue = intiter->second;
3115                 
3116                 // Process properties.
3117                 
3118                 size_t intPropertyValueLen = PropertyValue.Len();
3119                 
3120                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3121                         
3122                         PropertyValue.Trim();
3123                         PropertyValue.RemoveLast();
3124                         
3125                 }                               
3126                 
3127                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3128                         
3129                         PropertyValue.Remove(0, 1);
3130                         
3131                 }                               
3132                 
3133                 CaptureString(&PropertyValue, FALSE);
3134                 
3135                 if (PropertyName == wxT("ALTID")){
3136                 
3137                         TitleListAltID->erase(*TitleCount);
3138                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3139                 
3140                 } else if (PropertyName == wxT("PID")){
3142                         TitleListPID->erase(*TitleCount);
3143                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3144                 
3145                 } else if (PropertyName == wxT("PREF")){
3146                                 
3147                         int PriorityNumber = 0;
3148                         bool ValidNumber = TRUE;
3149                         
3150                         try{
3151                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3152                         }
3153                         
3154                         catch(std::invalid_argument &e){
3155                                 ValidNumber = FALSE;
3156                         }
3158                         if (ValidNumber == TRUE){
3160                                 TitleListPref->erase(*TitleCount);
3161                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3163                         }
3164                                         
3165                 } else if (PropertyName == wxT("LANGUAGE")){
3166                 
3167                         TitleListLanguage->erase(*TitleCount);
3168                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3169                 
3170                 } else {
3171                 
3172                         // Something else we don't know about so append
3173                         // to the tokens variable.
3174                 
3175                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3176                 
3177                                 if (FirstToken == TRUE){
3178                         
3179                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3180                                         FirstToken = FALSE;
3181                         
3182                                 } else {
3183                         
3184                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3185                         
3186                                 }
3187                 
3188                         }
3189                 
3190                 }
3191         
3192         }
3193         
3194         // Add the data to the General/Home/Work address variables.
3195         
3196         CaptureString(&PropertySeg2, FALSE);
3198         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3199         
3200         if (!PropertyTokens.IsEmpty()){
3201         
3202                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3203                         
3204         }
3208 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3210         std::map<int, int> SplitPoints;
3211         std::map<int, int> SplitLength;
3212         std::map<int, int>::iterator SLiter;                    
3213         wxString PropertyData;
3214         wxString PropertyName;
3215         wxString PropertyValue;
3216         wxString PropertyTokens;
3217         bool FirstToken = TRUE;
3218         int intPrevValue = 6;
3219         int intPref = 0;                        
3220         int intType = 0;
3221         long ListCtrlIndex;
3222         
3223         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3224         
3225         intPrevValue = 5;
3226         
3227         PropertyType PropType = PROPERTY_NONE;
3228                 
3229         // Look for type before continuing.
3230         
3231         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3232         
3233         // Setup the pointers.
3234         
3235         std::map<int, wxString> *RoleList = NULL;
3236         std::map<int, wxString> *RoleListAltID = NULL;
3237         std::map<int, wxString> *RoleListPID = NULL;
3238         std::map<int, wxString> *RoleListType = NULL;
3239         std::map<int, wxString> *RoleListTokens = NULL;
3240         std::map<int, wxString> *RoleListLanguage = NULL;
3241         std::map<int, int> *RoleListPref = NULL;
3242         
3243         // Setup blank lines for later on.
3244         
3245         switch(PropType){
3246                 case PROPERTY_NONE:
3247                         RoleList = &GeneralRoleList;
3248                         RoleListType = &GeneralRoleListType;
3249                         RoleListAltID = &GeneralRoleListAltID;
3250                         RoleListPID = &GeneralRoleListPID;
3251                         RoleListTokens = &GeneralRoleListTokens;
3252                         RoleListLanguage = &GeneralRoleListLanguage;
3253                         RoleListPref = &GeneralRoleListPref;    
3254                         break;
3255                 case PROPERTY_HOME:
3256                         RoleList = &HomeRoleList;
3257                         RoleListType = &HomeRoleListType;
3258                         RoleListAltID = &HomeRoleListAltID;
3259                         RoleListPID = &HomeRoleListPID;
3260                         RoleListTokens = &HomeRoleListTokens;
3261                         RoleListLanguage = &HomeRoleListLanguage;
3262                         RoleListPref = &HomeRoleListPref;       
3263                         break;
3264                 case PROPERTY_WORK:
3265                         RoleList = &BusinessRoleList;
3266                         RoleListType = &BusinessRoleListType;
3267                         RoleListAltID = &BusinessRoleListAltID;
3268                         RoleListPID = &BusinessRoleListPID;
3269                         RoleListTokens = &BusinessRoleListTokens;
3270                         RoleListLanguage = &BusinessRoleListLanguage;   
3271                         RoleListPref = &BusinessRoleListPref;
3272                         break;
3273         }
3275         intPrevValue = 5;
3276                 
3277         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3278         intiter != SplitPoints.end(); ++intiter){
3279         
3280                 SLiter = SplitLength.find(intiter->first);
3281         
3282                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3283                 
3284                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3285                 PropertyName = PropertyElement.GetNextToken();                          
3286                 PropertyValue = PropertyElement.GetNextToken();
3287                 
3288                 intPrevValue = intiter->second;
3289                 
3290                 // Process properties.
3291                 
3292                 size_t intPropertyValueLen = PropertyValue.Len();
3293                 
3294                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3295                         
3296                         PropertyValue.Trim();
3297                         PropertyValue.RemoveLast();
3298                         
3299                 }                               
3300                 
3301                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3302                         
3303                         PropertyValue.Remove(0, 1);
3304                         
3305                 }                               
3306                 
3307                 CaptureString(&PropertyValue, FALSE);
3308                 
3309                 if (PropertyName == wxT("ALTID")){
3310                 
3311                         RoleListAltID->erase(*RoleCount);
3312                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3313                 
3314                 } else if (PropertyName == wxT("PID")){
3316                         RoleListPID->erase(*RoleCount);
3317                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3318                 
3319                 } else if (PropertyName == wxT("PREF")){
3320                                 
3321                         int PriorityNumber = 0;
3322                         bool ValidNumber = TRUE;
3323                         
3324                         try{
3325                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3326                         }
3327                         
3328                         catch(std::invalid_argument &e){
3329                                 ValidNumber = FALSE;
3330                         }
3332                         if (ValidNumber == TRUE){
3334                                 RoleListPref->erase(*RoleCount);
3335                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3337                         }
3338                                         
3339                 } else if (PropertyName == wxT("LANGUAGE")){
3340                 
3341                         RoleListLanguage->erase(*RoleCount);
3342                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3343                 
3344                 } else {
3345                 
3346                         // Something else we don't know about so append
3347                         // to the tokens variable.
3348                 
3349                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3350                 
3351                                 if (FirstToken == TRUE){
3352                         
3353                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3354                                         FirstToken = FALSE;
3355                         
3356                                 } else {
3357                         
3358                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3359                         
3360                                 }
3361                 
3362                         }
3363                 
3364                 }
3365         
3366         }
3367         
3368         // Add the data to the General/Home/Work address variables.
3369         
3370         CaptureString(&PropertySeg2, FALSE);
3372         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3373         
3374         if (!PropertyTokens.IsEmpty()){
3375         
3376                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3377                         
3378         }
3382 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3384         std::map<int, int> SplitPoints;
3385         std::map<int, int> SplitLength;
3386         std::map<int, int>::iterator SLiter;                    
3387         wxString PropertyData;
3388         wxString PropertyName;
3389         wxString PropertyValue;
3390         wxString PropertyTokens;
3391         bool FirstToken = TRUE;
3392         int intPrevValue = 5;
3393         int intPref = 0;                        
3394         int intType = 0;
3395         long ListCtrlIndex;
3396         
3397         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3398         
3399         intPrevValue = 4;
3400         
3401         PropertyType PropType = PROPERTY_NONE;
3402                 
3403         // Look for type before continuing.
3404         
3405         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3406         
3407         // Setup the pointers.
3408         
3409         std::map<int, wxString> *OrganisationsList = NULL;
3410         std::map<int, wxString> *OrganisationsListAltID = NULL;
3411         std::map<int, wxString> *OrganisationsListPID = NULL;
3412         std::map<int, wxString> *OrganisationsListType = NULL;
3413         std::map<int, wxString> *OrganisationsListTokens = NULL;
3414         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3415         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3416         std::map<int, int> *OrganisationsListPref = NULL;
3417         
3418         // Setup blank lines for later on.
3419         
3420         switch(PropType){
3421                 case PROPERTY_NONE:
3422                         OrganisationsList = &GeneralOrganisationsList;
3423                         OrganisationsListType = &GeneralOrganisationsListType;
3424                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3425                         OrganisationsListPID = &GeneralOrganisationsListPID;
3426                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3427                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3428                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3429                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3430                         break;
3431                 case PROPERTY_HOME:
3432                         OrganisationsList = &HomeOrganisationsList;
3433                         OrganisationsListType = &HomeOrganisationsListType;
3434                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3435                         OrganisationsListPID = &HomeOrganisationsListPID;
3436                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3437                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3438                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3439                         OrganisationsListPref = &HomeOrganisationsListPref;     
3440                         break;
3441                 case PROPERTY_WORK:
3442                         OrganisationsList = &BusinessOrganisationsList;
3443                         OrganisationsListType = &BusinessOrganisationsListType;
3444                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3445                         OrganisationsListPID = &BusinessOrganisationsListPID;
3446                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3447                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3448                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3449                         OrganisationsListPref = &BusinessOrganisationsListPref;
3450                         break;
3451         }
3453         intPrevValue = 4;
3454                 
3455         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3456         intiter != SplitPoints.end(); ++intiter){
3457         
3458                 SLiter = SplitLength.find(intiter->first);
3459         
3460                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3461                 
3462                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3463                 PropertyName = PropertyElement.GetNextToken();                          
3464                 PropertyValue = PropertyElement.GetNextToken();
3465                 
3466                 intPrevValue = intiter->second;
3467                 
3468                 // Process properties.
3469                 
3470                 size_t intPropertyValueLen = PropertyValue.Len();
3471                 
3472                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3473                         
3474                         PropertyValue.Trim();
3475                         PropertyValue.RemoveLast();
3476                         
3477                 }                               
3478                 
3479                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3480                         
3481                         PropertyValue.Remove(0, 1);
3482                         
3483                 }                               
3484                 
3485                 CaptureString(&PropertyValue, FALSE);
3486                 
3487                 if (PropertyName == wxT("ALTID")){
3488                 
3489                         OrganisationsListAltID->erase(*OrganisationCount);
3490                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3491                 
3492                 } else if (PropertyName == wxT("PID")){
3494                         OrganisationsListPID->erase(*OrganisationCount);
3495                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3496                 
3497                 } else if (PropertyName == wxT("SORT-AS")){
3499                         OrganisationsListSortAs->erase(*OrganisationCount);
3500                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3501                 
3502                 } else if (PropertyName == wxT("PREF")){
3503                                 
3504                         int PriorityNumber = 0;
3505                         bool ValidNumber = TRUE;
3506                         
3507                         try{
3508                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3509                         }
3510                         
3511                         catch(std::invalid_argument &e){
3512                                 ValidNumber = FALSE;
3513                         }
3515                         if (ValidNumber == TRUE){
3517                                 OrganisationsListPref->erase(*OrganisationCount);
3518                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3520                         }
3521                                         
3522                 } else if (PropertyName == wxT("LANGUAGE")){
3523                 
3524                         OrganisationsListLanguage->erase(*OrganisationCount);
3525                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3526                 
3527                 } else {
3528                 
3529                         // Something else we don't know about so append
3530                         // to the tokens variable.
3531                 
3532                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3533                 
3534                                 if (FirstToken == TRUE){
3535                         
3536                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3537                                         FirstToken = FALSE;
3538                         
3539                                 } else {
3540                         
3541                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3542                         
3543                                 }
3544                 
3545                         }
3546                 
3547                 }
3548         
3549         }
3550         
3551         // Add the data to the General/Home/Work address variables.
3552         
3553         CaptureString(&PropertySeg2, FALSE);
3555         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3556         
3557         if (!PropertyTokens.IsEmpty()){
3558         
3559                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3560                         
3561         }
3565 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3567         std::map<int, int> SplitPoints;
3568         std::map<int, int> SplitLength;
3569         std::map<int, int>::iterator SLiter;                    
3570         wxString PropertyData;
3571         wxString PropertyName;
3572         wxString PropertyValue;
3573         wxString PropertyTokens;
3574         bool FirstToken = TRUE;
3575         int intPrevValue = 6;
3576         int intPref = 0;                        
3577         int intType = 0;
3578         long ListCtrlIndex;
3579         
3580         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3581         
3582         intPrevValue = 5;
3583         
3584         PropertyType PropType = PROPERTY_NONE;
3585                 
3586         // Look for type before continuing.
3587         
3588         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3589         
3590         // Setup the pointers.
3591         
3592         std::map<int, wxString> *NoteList = NULL;
3593         std::map<int, wxString> *NoteListAltID = NULL;
3594         std::map<int, wxString> *NoteListPID = NULL;
3595         std::map<int, wxString> *NoteListType = NULL;
3596         std::map<int, wxString> *NoteListTokens = NULL;
3597         std::map<int, wxString> *NoteListLanguage = NULL;
3598         std::map<int, int> *NoteListPref = NULL;
3599         
3600         // Setup blank lines for later on.
3601         
3602         switch(PropType){
3603                 case PROPERTY_NONE:
3604                         NoteList = &GeneralNoteList;
3605                         NoteListType = &GeneralNoteListType;
3606                         NoteListAltID = &GeneralNoteListAltID;
3607                         NoteListPID = &GeneralNoteListPID;
3608                         NoteListTokens = &GeneralNoteListTokens;
3609                         NoteListLanguage = &GeneralNoteListLanguage;
3610                         NoteListPref = &GeneralNoteListPref;    
3611                         break;
3612                 case PROPERTY_HOME:
3613                         NoteList = &HomeNoteList;
3614                         NoteListType = &HomeNoteListType;
3615                         NoteListAltID = &HomeNoteListAltID;
3616                         NoteListPID = &HomeNoteListPID;
3617                         NoteListTokens = &HomeNoteListTokens;
3618                         NoteListLanguage = &HomeNoteListLanguage;
3619                         NoteListPref = &HomeNoteListPref;       
3620                         break;
3621                 case PROPERTY_WORK:
3622                         NoteList = &BusinessNoteList;
3623                         NoteListType = &BusinessNoteListType;
3624                         NoteListAltID = &BusinessNoteListAltID;
3625                         NoteListPID = &BusinessNoteListPID;
3626                         NoteListTokens = &BusinessNoteListTokens;
3627                         NoteListLanguage = &BusinessNoteListLanguage;   
3628                         NoteListPref = &BusinessNoteListPref;
3629                         break;
3630         }
3632         intPrevValue = 5;
3633                 
3634         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3635         intiter != SplitPoints.end(); ++intiter){
3636         
3637                 SLiter = SplitLength.find(intiter->first);
3638         
3639                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3640                 
3641                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3642                 PropertyName = PropertyElement.GetNextToken();                          
3643                 PropertyValue = PropertyElement.GetNextToken();
3644                 
3645                 intPrevValue = intiter->second;
3646                 
3647                 // Process properties.
3648                 
3649                 size_t intPropertyValueLen = PropertyValue.Len();
3650                 
3651                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3652                         
3653                         PropertyValue.Trim();
3654                         PropertyValue.RemoveLast();
3655                         
3656                 }                               
3657                 
3658                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3659                         
3660                         PropertyValue.Remove(0, 1);
3661                         
3662                 }                               
3663                 
3664                 CaptureString(&PropertyValue, FALSE);
3665                 
3666                 if (PropertyName == wxT("ALTID")){
3667                 
3668                         NoteListAltID->erase(*NoteCount);
3669                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3670                 
3671                 } else if (PropertyName == wxT("PID")){
3673                         NoteListPID->erase(*NoteCount);
3674                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3675                 
3676                 } else if (PropertyName == wxT("PREF")){
3677                                 
3678                         int PriorityNumber = 0;
3679                         bool ValidNumber = TRUE;
3680                         
3681                         try{
3682                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3683                         }
3684                         
3685                         catch(std::invalid_argument &e){
3686                                 ValidNumber = FALSE;
3687                         }
3689                         if (ValidNumber == TRUE){
3691                                 NoteListPref->erase(*NoteCount);
3692                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
3694                         }
3695                                         
3696                 } else if (PropertyName == wxT("LANGUAGE")){
3697                 
3698                         NoteListLanguage->erase(*NoteCount);
3699                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3700                 
3701                 } else {
3702                 
3703                         // Something else we don't know about so append
3704                         // to the tokens variable.
3705                 
3706                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3707                 
3708                                 if (FirstToken == TRUE){
3709                         
3710                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3711                                         FirstToken = FALSE;
3712                         
3713                                 } else {
3714                         
3715                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3716                         
3717                                 }
3718                 
3719                         }
3720                 
3721                 }
3722         
3723         }
3724         
3725         // Add the data to the General/Home/Work address variables.
3726         
3727         CaptureString(&PropertySeg2, FALSE);
3729         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3730         
3731         if (!PropertyTokens.IsEmpty()){
3732         
3733                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3734                         
3735         }
3739 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3741         std::map<int, int> SplitPoints;
3742         std::map<int, int> SplitLength;
3743         std::map<int, int>::iterator SLiter;                    
3744         wxString PropertyData;
3745         wxString PropertyName;
3746         wxString PropertyValue;
3747         wxString PropertyTokens;
3748         bool FirstToken = TRUE;
3749         int intPrevValue = 12;
3750         int intPref = 0;                        
3751         int intType = 0;
3752         long ListCtrlIndex;
3753         
3754         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3755         
3756         intPrevValue = 11;
3757         
3758         PropertyType PropType = PROPERTY_NONE;
3759                 
3760         // Look for type before continuing.
3761         
3762         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3763         
3764         // Setup blank lines for later on.
3765         
3766         switch(PropType){
3767                 case PROPERTY_NONE:
3768                         break;
3769                 case PROPERTY_HOME:
3770                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3771                         break;
3772                 case PROPERTY_WORK:
3773                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3774                         break;
3775         }
3777         intPrevValue = 11;
3778                 
3779         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3780         intiter != SplitPoints.end(); ++intiter){
3781         
3782                 SLiter = SplitLength.find(intiter->first);
3783         
3784                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3785                 
3786                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3787                 PropertyName = PropertyElement.GetNextToken();                          
3788                 PropertyValue = PropertyElement.GetNextToken();
3789                 
3790                 intPrevValue = intiter->second;
3791                 
3792                 // Process properties.
3793                 
3794                 size_t intPropertyValueLen = PropertyValue.Len();
3795                 
3796                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3797                         
3798                         PropertyValue.Trim();
3799                         PropertyValue.RemoveLast();
3800                         
3801                 }                               
3802                 
3803                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3804                         
3805                         PropertyValue.Remove(0, 1);
3806                         
3807                 }                               
3808                 
3809                 CaptureString(&PropertyValue, FALSE);
3810                 
3811                 if (PropertyName == wxT("ALTID")){
3812                 
3813                         CategoriesListAltID.erase(*CategoryCount);
3814                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3815                 
3816                 } else if (PropertyName == wxT("PID")){
3818                         CategoriesListPID.erase(*CategoryCount);
3819                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3820                 
3821                 } else if (PropertyName == wxT("PREF")){
3822                                 
3823                         int PriorityNumber = 0;
3824                         bool ValidNumber = TRUE;
3825                         
3826                         try{
3827                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3828                         }
3829                         
3830                         catch(std::invalid_argument &e){
3831                                 ValidNumber = FALSE;
3832                         }
3834                         if (ValidNumber == TRUE){
3836                                 CategoriesListPref.erase(*CategoryCount);
3837                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
3839                         }
3840                                         
3841                 } else if (PropertyName == wxT("LANGUAGE")){
3842                 
3843                         CategoriesListLanguage.erase(*CategoryCount);
3844                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3845                 
3846                 } else {
3847                 
3848                         // Something else we don't know about so append
3849                         // to the tokens variable.
3850                 
3851                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3852                 
3853                                 if (FirstToken == TRUE){
3854                         
3855                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3856                                         FirstToken = FALSE;
3857                         
3858                                 } else {
3859                         
3860                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3861                         
3862                                 }
3863                 
3864                         }
3865                 
3866                 }
3867         
3868         }
3869         
3870         // Deal with multiple categories.
3871         
3872         int intOrigCatCount = *CategoryCount;
3873         bool FirstCategoryProcessed = TRUE;
3874         bool AfterFirstToken = FALSE;
3875         int intSplitSize = 0;
3876         int intSplitsFound = 0;
3877         int intSplitSeek = 0;
3878         int intPropertyLen = PropertySeg2.Len();
3879         
3880         SplitPoints.clear();
3881         SplitLength.clear();
3882         intPrevValue = 0;
3883         
3884         for (int i = 0; i <= intPropertyLen; i++){
3885         
3886                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3887         
3888                         continue;
3889                 
3890                 }
3891         
3892                 intSplitSize++;
3893         
3894                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3895         
3896                         if (AfterFirstToken == TRUE){
3897                 
3898                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3899                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3900                         
3901                         } else {
3902                         
3903                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3904                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3905                                 AfterFirstToken = TRUE;
3907                         }
3909                         intSplitsFound++;
3910                         intSplitSeek = i;
3911                         intSplitSize = 0;                               
3912         
3913                 }                       
3914         
3915         }
3916         
3917         if (SplitPoints.size() > 0){
3918         
3919                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3920                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3921         
3922         }
3923         
3924         if (SplitPoints.size() == 0){
3925         
3926                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3927         
3928                 if (!PropertyTokens.IsEmpty()){
3929                 
3930                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3931                 
3932                 }
3933         
3934         }
3935         
3936         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3937         intiter != SplitPoints.end(); ++intiter){
3938         
3939                 SLiter = SplitLength.find(intiter->first);
3940         
3941                 intPrevValue = intiter->second;
3942         
3943                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3944                 
3945                 // Add the data to the General/Home/Work address variables.
3946         
3947                 // Trim any whitespace from the start and end.
3948         
3949                 PropertyData = PropertyData.Trim(FALSE);
3950                 PropertyData = PropertyData.Trim(TRUE); 
3951         
3952                 CaptureString(&PropertyData, FALSE);
3953                 
3954                 if (FirstCategoryProcessed == TRUE){
3955                 
3956                         FirstCategoryProcessed = FALSE;
3957                         
3958                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3959         
3960                         if (!PropertyTokens.IsEmpty()){
3961                 
3962                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3963                 
3964                         }
3965                         
3966                         continue;
3967                 
3968                 } else {
3970                         (*CategoryCount)++;
3971                         
3972                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3973                 
3974                         if (!PropertyTokens.IsEmpty()){
3975                 
3976                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3977                 
3978                         }
3979                 
3980                 }
3981                 
3982                 // Copy the properties to each of the categories (if it exists).
3983                 
3984                 if (!PropertyTokens.IsEmpty()){
3985                 
3986                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3987                 
3988                 }
3989                 
3990                 // Check if ALTID was used.
3991                 
3992                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3993                 
3994                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3995                 
3996                 }
3997                 
3998                 // Check if PID was used.
3999                 
4000                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4001                 
4002                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4003                 
4004                 }
4005         
4006                 // Check if PREF was used.
4007         
4008                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4009                 
4010                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4011                 
4012                 }
4013                 
4014                 // Check if LANGUAGE was used.
4015                 
4016                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4017                 
4018                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4019                 
4020                 }
4021                 
4022                 // Check if TYPE was used.
4023                 
4024                 switch(PropType){
4025                         case PROPERTY_NONE:
4026                                 break;
4027                         case PROPERTY_HOME:
4028                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4029                                 break;
4030                         case PROPERTY_WORK:
4031                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4032                                 break;
4033                 }
4034         
4035         }
4039 void SplitValues(wxString *PropertyLine, 
4040         std::map<int,int> *SplitPoints, 
4041         std::map<int,int> *SplitLength, 
4042         int intSize){
4043         
4044         size_t intPropertyLen = PropertyLine->Len();
4045         int intSplitsFound = 0;
4046         int intSplitSize = 0;
4047         int intSplitSeek = 0;
4048         
4049         for (int i = intSize; i <= intPropertyLen; i++){
4051                 intSplitSize++;
4052         
4053                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4054                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4055            
4056                     if (intSplitsFound == 0){
4057             
4058                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4059           
4060                     } else {
4061            
4062                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4063             
4064                     }
4065             
4066                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4067             
4068                     intSplitsFound++;
4069                     intSplitSeek = i;
4070                     intSplitSize = 0;
4071             
4072                 }
4074         }
4076         if (intSplitsFound == 0){
4078                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4079                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4081         } else {
4083                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4084                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4086         }
4090 void CheckType(wxString *PropertySeg1, 
4091         std::map<int,int> *SplitPoints, 
4092         std::map<int,int> *SplitLength, 
4093         int *intPrevValue, 
4094         PropertyType *PropType){
4095         
4096         wxString PropertyData;
4097         wxString PropertyName;
4098         wxString PropertyValue;
4099         std::map<int,int>::iterator SLiter;
4100         
4101         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
4102         intiter != SplitPoints->end(); ++intiter){
4103         
4104                 SLiter = SplitLength->find(intiter->first);
4105         
4106                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4107                 
4108                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4109                 PropertyName = PropertyElement.GetNextToken();                          
4110                 PropertyValue = PropertyElement.GetNextToken();
4111                 
4112                 *intPrevValue = intiter->second;
4113                 
4114                 if (PropertyName == wxT("TYPE")){
4115                                 
4116                         if (PropertyValue == wxT("work")){
4117                         
4118                                 *PropType = PROPERTY_WORK;
4119                                                         
4120                         } else if (PropertyValue == wxT("home")){
4122                                 *PropType = PROPERTY_HOME;
4123                                                         
4124                         } else {
4125                         
4126                                 *PropType = PROPERTY_NONE;
4127                         
4128                         }
4129                 
4130                         return;
4131                 
4132                 }
4133         
4134         }
4135         
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