Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit testing for the TITLE vCard Property for ContactD...
[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         wxString ContactLine;
97         wxString PropertyLine;
98         wxString PropertySeg1;
99         wxString PropertySeg2;
100         wxString PropertyNextLine;
101         wxString Property;
102         
103         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
104          iter != ContactFileLines.end(); ++iter){
106                 ExtraLineSeek = TRUE;
107                 QuoteMode = FALSE;
108                 PropertyFind = TRUE;
109                 ContactLineLen = 0;
110                 QuoteBreakPoint = 0;
111                 ContactLine.Clear();
112                 PropertyLine.Clear();
113                 PropertySeg1.Clear();
114                 PropertySeg2.Clear();
115                 Property.Clear();
116          
117                 ContactLine = iter->second;
118                 
119                 while (ExtraLineSeek == TRUE){
120                 
121                         // Check if there is extra data on the next line 
122                         // (indicated by space or tab at the start) and add data.
123                 
124                         iter++;
125                         
126                         if (iter == ContactFileLines.end()){
127                         
128                                 iter--;
129                                 break;
130                         
131                         }                       
132                 
133                         PropertyNextLine = iter->second;
134                 
135                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
136                 
137                                 PropertyNextLine.Remove(0, 1);
138                                 ContactLine.Append(PropertyNextLine);
139                 
140                         } else {
141                         
142                                 iter--;
143                                 ExtraLineSeek = FALSE;
144                         
145                         }
146                 
147                 }
149                 ContactLineLen = ContactLine.Len();
150                 
151                 // Make sure we are not in quotation mode.
152                 // Make sure colon does not have \ or \\ before it.
153                 
154                 for (int i = 0; i <= ContactLineLen; i++){
155                 
156                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
157                         
158                                 PropertyFind = FALSE;
159                         
160                         } else if (PropertyFind == TRUE){
161                         
162                                 Property.Append(ContactLine.Mid(i, 1));
163                         
164                         }               
165                 
166                         if (ContactLine.Mid(i, 1) == wxT("\"")){
167                         
168                                 if (QuoteMode == TRUE){
169                                 
170                                         QuoteMode = FALSE;
171                                 
172                                 } else {
173                         
174                                         QuoteMode = TRUE;
175                                         
176                                 }
177                         
178                         }
179                         
180                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
181                         
182                                 QuoteBreakPoint = i;
183                                 break;
184                         
185                         }
186                 
187                 }
188                 
189                 // Split that line at the point into two variables (ignore the colon).
190                 
191                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
192                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
193                 
194                  if (Property == wxT("KIND") && KindProcessed == FALSE){
195                                 
196                         ProcessKind(PropertySeg2);
197                 
198                 } else if (Property == wxT("MEMBER")){
200                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
201                         GroupCount++;   
202                 
203                 } else if (Property == wxT("FN")){
204                 
205                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
206                         FNCount++;
207                 
208                 } else if (Property == wxT("N") && NameProcessed == FALSE){
209                 
210                         ProcessN(PropertySeg1, PropertySeg2);
211                         NameProcessed = TRUE;
212                 
213                 } else if (Property == wxT("NICKNAME")){
214                                                 
215                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
216                         NicknameCount++;
217                         
218                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
219                 
220                         ProcessGender(PropertySeg1, PropertySeg2);
221                         GenderProcessed = TRUE;
222                 
223                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
224                 
225                         ProcessBirthday(PropertySeg1, PropertySeg2);
226                         BirthdayProcessed = TRUE;
227                 
228                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
229                 
230                         ProcessAnniversary(PropertySeg1, PropertySeg2);
231                         AnniversaryProcessed = TRUE;
232                 
233                 } else if (Property == wxT("TZ")){
234                 
235                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
236                         TimeZoneCount++;
237                 
238                 } else if (Property == wxT("ADR")){
239                 
240                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
241                         AddressCount++;
242                 
243                 } else if (Property == wxT("EMAIL")){
244                                         
245                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
246                         EmailCount++;
247                 
248                 } else if (Property == wxT("IMPP")){
249                 
250                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
251                         IMCount++;
252                         
253                 } else if (Property == wxT("TEL")){
254                                 
255                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
256                         TelephoneCount++;
257                 
258                 } else if (Property == wxT("LANG")){
259                 
260                         // See frmContactEditor-LoadLanguage.cpp
261                         
262                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
263                         LanguageCount++;
264                 
265                 } else if (Property == wxT("GEO")){
266                 
267                         // See frmContactEditor-LoadGeo.cpp
268                         
269                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
270                         GeographicCount++;
271                 
272                 } else if (Property == wxT("RELATED")){
273                         
274                         // See fromContactEditor-LoadRelated.cpp
275                         
276                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
277                         RelatedCount++;
278                         
279                 } else if (Property == wxT("URL")){
281                         // See frmContactEditor-LoadURL.cpp
282                 
283                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
284                         URLCount++;
285                 
286                 } else if (Property == wxT("TITLE")) {
287                 
288                         // See frmContactEditor-LoadTitle.cpp
289                         
290                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
291                         TitleCount++;
292                         
293                 }
294                 
295         }
296         
297         return CONTACTLOAD_OK;
301 void ContactDataObject::ProcessKind(wxString KindType){
303         if (KindType == wxT("individual")){
304                         
305                 ContactKind = CONTACTKIND_INDIVIDUAL;
306                         
307         } else if (KindType == wxT("group")){
308                         
309                 ContactKind = CONTACTKIND_GROUP;
310                         
311         } else if (KindType == wxT("org")){
312                         
313                 ContactKind = CONTACTKIND_ORGANISATION;
314                         
315         } else if (KindType == wxT("location")){
316                         
317                 ContactKind = CONTACTKIND_LOCATION;
318                         
319         } else {
320                         
321                 ContactKind = CONTACTKIND_NONE;                 
322         }
326 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
328         std::map<int, int> SplitPoints;
329         std::map<int, int> SplitLength;
331         int intPrevValue = 8;
332         int intPref = 0;                        
333         int intType = 0;
334         
335         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
337         intPrevValue = 7;
338         
339         wxString PropertyName;
340         wxString PropertyValue;
341         wxString PropertyData;
342         wxString PropertyTokens;
343         std::map<int,int>::iterator SLiter;
344         bool FirstToken = TRUE;
345         
346         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
347         intiter != SplitPoints.end(); ++intiter){
348         
349                 SLiter = SplitLength.find(intiter->first);
350         
351                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
352                 
353                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
354                 PropertyName = PropertyElement.GetNextToken();                          
355                 PropertyValue = PropertyElement.GetNextToken();
356                 
357                 intPrevValue = intiter->second;
358                 
359                 CaptureString(&PropertyValue, FALSE);
360         
361                 if (PropertyName == wxT("ALTID")){
363                         GroupsListAltID.erase(*GroupCount);
364                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
365                 
366                 } else if (PropertyName == wxT("PID")){
368                         GroupsListPID.erase(*GroupCount);
369                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
370                 
371                 } else if (PropertyName == wxT("PREF")){
373                         int PriorityNumber = 0;
374                         bool ValidNumber = TRUE;
375                         
376                         try{
377                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
378                         }
379                         
380                         catch(std::invalid_argument &e){
381                                 ValidNumber = FALSE;
382                         }
384                         if (ValidNumber == TRUE){
386                                 GroupsListPref.erase(*GroupCount);
387                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
388                 
389                         }
390                 
391                 } else if (PropertyName == wxT("MEDIATYPE")){
393                         GroupsListMediaType.erase(*GroupCount);
394                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
395                 
396                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
397                         
398                         if (FirstToken == TRUE){
399                                 
400                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
401                                 FirstToken = FALSE;
402                                 
403                         } else {
404                         
405                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
406                                 
407                         }
408                         
409                 }
410                 
411         }
413         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
415         if (!PropertyTokens.IsEmpty()){
416         
417                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
418         
419         }
424 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
426         std::map<int, int> SplitPoints;
427         std::map<int, int> SplitLength;
429         int intPrevValue = 4;
430         int intPref = 0;                        
431         int intType = 0;
432         
433         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
435         intPrevValue = 3;
436         
437         wxString PropertyName;
438         wxString PropertyValue;
439         wxString PropertyData;
440         wxString PropertyTokens;
441         std::map<int,int>::iterator SLiter;
442         bool FirstToken = TRUE;
443         
444         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
445         intiter != SplitPoints.end(); ++intiter){
446         
447                 SLiter = SplitLength.find(intiter->first);
448         
449                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
450                 
451                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
452                 PropertyName = PropertyElement.GetNextToken();                          
453                 PropertyValue = PropertyElement.GetNextToken();
454                 
455                 intPrevValue = intiter->second;
456                 
457                 CaptureString(&PropertyValue, FALSE);
458                 
459                 if (PropertyName == wxT("TYPE")){
461                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
462                                 PropertyValue == wxT("work") ){
464                                 FullNamesListType.erase(*FNCount);
465                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
466                 
467                         }
468                 
469                 } else if (PropertyName == wxT("LANGUAGE")){
471                         FullNamesListLanguage.erase(*FNCount);
472                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
473                 
474                 } else if (PropertyName == wxT("ALTID")){
475                 
476                         FullNamesListAltID.erase(*FNCount);
477                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
478                 
479                 } else if (PropertyName == wxT("PID")){
481                         FullNamesListPID.erase(*FNCount);
482                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
483                 
484                 } else if (PropertyName == wxT("PREF")){
486                         int PriorityNumber = 0;
487                         bool ValidNumber = TRUE;
488                         
489                         try{
490                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
491                         }
492                         
493                         catch(std::invalid_argument &e){
494                                 ValidNumber = FALSE;
495                         }
497                         if (ValidNumber == TRUE){
499                                 FullNamesListPref.erase(*FNCount);
500                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
502                         }
503                 
504                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
505                         
506                         if (FirstToken == TRUE){
507                                 
508                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
509                                 FirstToken = FALSE;
510                                 
511                         } else {
512                         
513                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
514                                 
515                         }
516                         
517                 } 
518         
519         }
521         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
523         if (!PropertyTokens.IsEmpty()){
524         
525                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
526         
527         }
531 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
533         std::map<int, int> SplitPoints;
534         std::map<int, int> SplitLength;
536         int intPrevValue = 3;
537         int intPref = 0;                        
538         int intType = 0;
539         
540         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
541         
542         intPrevValue = 2;
543         
544         wxString PropertyName;
545         wxString PropertyValue;
546         wxString PropertyData;
547         wxString PropertyTokens;
548         std::map<int,int>::iterator SLiter;
549         bool FirstToken = TRUE;
550         
551         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
552         intiter != SplitPoints.end(); ++intiter){
553         
554                 SLiter = SplitLength.find(intiter->first);
555         
556                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
557                 
558                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
559                 PropertyName = PropertyElement.GetNextToken();                          
560                 PropertyValue = PropertyElement.GetNextToken();
561                 
562                 intPrevValue = intiter->second;
563                 
564                 CaptureString(&PropertyValue, FALSE);
565                 
566                 if (PropertyName == wxT("ALTID")){
568                         NameAltID = PropertyValue;
569                 
570                 } else if (PropertyName == wxT("LANGUAGE")){
571                 
572                         NameLanguage = PropertyValue;
573                 
574                 } else if (PropertyName == wxT("SORT-AS")){
575                 
576                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
577                                 PropertyValue.Len() >= 3){
578                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
579                         }
580                 
581                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
582                         
583                         if (FirstToken == TRUE){
584                                 
585                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
586                                 FirstToken = FALSE;
587                                 
588                         } else {
589                         
590                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
591                                 
592                         }
593                         
594                 }
595         
596         }
597         
598         // Split the name data.
599         
600         int intSplitSeek = 0;           
601         int intSplitsFound = 0;
602         int intSplitSize = 0;
603         int intPropertyLen = PropertySeg2.Len();
604         
605         std::map<int,wxString> NameValues;
606         intPrevValue = 0;                                       
607         
608         for (int i = 0; i <= intPropertyLen; i++){
609         
610                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
611                         
612                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
613                         
614                         intSplitSeek = i;
615                         intSplitSeek++;
616                         
617                         if (intSplitsFound == 4){
618                         
619                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
620                                 break;
621                         
622                         }
623                         
624                         intSplitSize = 0;
625                         continue;
626         
627                 }
628                 
629                 intSplitSize++;
631         }
632         
633         // Split the data into several parts.
634                         
635         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
636         iter != NameValues.end(); ++iter){
637         
638                 if (iter->first == 1){
639                 
640                         // Deal with family name.
641                         
642                         NameSurname = iter->second;
643                 
644                 } else if (iter->first == 2){
645                 
646                         // Deal with given names.
647                         
648                         NameForename = iter->second;
649                 
650                 } else if (iter->first == 3){
651                 
652                         // Deal with additional names.
653                         
654                         NameOtherNames = iter->second;
655                 
656                 } else if (iter->first == 4){
657                 
658                         // Deal with honorifix prefixes and suffixes.
660                         NameTitle = iter->second;
661                 
662                         iter++;
663                         
664                         if (iter == NameValues.end()){
665                         
666                                 break;
667                         
668                         }
669                 
670                         NameSuffix = iter->second;
671                 
672                 }
673         
674         }
675         
676         // Add the name token data.
677         
678         if (!PropertyTokens.IsEmpty()){
679         
680                 NameTokens = PropertyTokens;
681         
682         }
686 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
688         std::map<int, int> SplitPoints;
689         std::map<int, int> SplitLength;
691         int intPrevValue = 10;
692         int intPref = 0;                        
693         
694         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
695         
696         intPrevValue = 9;
697         
698         PropertyType PropType = PROPERTY_NONE;
699         
700         // Look for type before continuing.
701         
702         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
703         
704         intPrevValue = 9;
705         
706         std::map<int, wxString> *NicknamesList = NULL;
707         std::map<int, wxString> *NicknamesListType = NULL;
708         std::map<int, wxString> *NicknamesListLanguage = NULL;
709         std::map<int, wxString> *NicknamesListAltID = NULL;
710         std::map<int, wxString> *NicknamesListPID = NULL;
711         std::map<int, wxString> *NicknamesListTokens = NULL;            
712         std::map<int, int> *NicknamesListPref = NULL;
713         
714         switch(PropType){
715                 case PROPERTY_NONE:
716                         NicknamesList = &GeneralNicknamesList;
717                         NicknamesListType = &GeneralNicknamesListType;
718                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
719                         NicknamesListAltID = &GeneralNicknamesListAltID;
720                         NicknamesListPID = &GeneralNicknamesListPID;
721                         NicknamesListTokens = &GeneralNicknamesListTokens;
722                         NicknamesListPref = &GeneralNicknamesListPref;
723                         break;
724                 case PROPERTY_HOME:
725                         NicknamesList = &HomeNicknamesList;
726                         NicknamesListType = &HomeNicknamesListType;
727                         NicknamesListLanguage = &HomeNicknamesListLanguage;
728                         NicknamesListAltID = &HomeNicknamesListAltID;
729                         NicknamesListPID = &HomeNicknamesListPID;
730                         NicknamesListTokens = &HomeNicknamesListTokens;
731                         NicknamesListPref = &HomeNicknamesListPref;
732                         break;
733                 case PROPERTY_WORK:
734                         NicknamesList = &BusinessNicknamesList;
735                         NicknamesListType = &BusinessNicknamesListType;
736                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
737                         NicknamesListAltID = &BusinessNicknamesListAltID;
738                         NicknamesListPID = &BusinessNicknamesListPID;
739                         NicknamesListTokens = &BusinessNicknamesListTokens;
740                         NicknamesListPref = &BusinessNicknamesListPref;
741                         break;
742         }
743         
744         std::map<int, int>::iterator SLiter;    
745         wxString PropertyData;
746         wxString PropertyName;
747         wxString PropertyValue;
748         wxString PropertyTokens;
749         bool FirstToken = TRUE;
750         
751         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
752         intiter != SplitPoints.end(); ++intiter){
753         
754                 SLiter = SplitLength.find(intiter->first);
755         
756                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
757                 
758                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
759                 PropertyName = PropertyElement.GetNextToken();                          
760                 PropertyValue = PropertyElement.GetNextToken();
761                 
762                 intPrevValue = intiter->second;
763                 
764                 CaptureString(&PropertyValue, FALSE);
765                 
766                 if (PropertyName == wxT("ALTID")){
768                         NicknamesListAltID->erase(*NicknameCount);
769                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
770                 
771                 } else if (PropertyName == wxT("PID")){
773                         NicknamesListPID->erase(*NicknameCount);
774                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
776                 } else if (PropertyName == wxT("PREF")){
778                         int PriorityNumber = 0;
779                         bool ValidNumber = TRUE;
780                         
781                         try{
782                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
783                         }
784                         
785                         catch(std::invalid_argument &e){
786                                 ValidNumber = FALSE;
787                         }
789                         if (ValidNumber == TRUE){
791                                 NicknamesListPref->erase(*NicknameCount);
792                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
794                         }
795                 
796                 } else if (PropertyName == wxT("LANGUAGE")){
798                         NicknamesListLanguage->erase(*NicknameCount);
799                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
801                 } else {
802                 
803                         // Something else we don't know about so append
804                         // to the tokens variable.
805                 
806                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
807                 
808                                 if (FirstToken == TRUE){
809                         
810                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
811                                         FirstToken = FALSE;
812                         
813                                 } else {
814                         
815                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
816                         
817                                 }
818                 
819                         }
820                 
821                 }
822                 
823         }
824         
825         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
826         
827         // Add the name token data.
828         
829         if (!PropertyTokens.IsEmpty()){
830         
831                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
832         
833         }
837 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
839         std::map<int, int> SplitPoints;
840         std::map<int, int> SplitLength;
841         std::map<int, int>::iterator SLiter;                    
842         wxString PropertyData;
843         wxString PropertyName;
844         wxString PropertyValue;
845         wxString PropertyTokens;
846         bool FirstToken = TRUE;
847         int intPrevValue = 8;
849         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
851         intPrevValue = 7;                       
852         
853         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
854         intiter != SplitPoints.end(); ++intiter){
855         
856                 SLiter = SplitLength.find(intiter->first);
857         
858                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
859                 
860                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
861                 PropertyName = PropertyElement.GetNextToken();                          
862                 PropertyValue = PropertyElement.GetNextToken();
863                 
864                 intPrevValue = intiter->second;
865                 
866                 // Process properties.
867                 
868                 size_t intPropertyValueLen = PropertyValue.Len();
869                 
870                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
871                         
872                         PropertyValue.Trim();
873                         PropertyValue.RemoveLast();
874                         
875                 }                               
876                 
877                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
878                         
879                         PropertyValue.Remove(0, 1);
880                         
881                 }                               
882                 
883                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
885                         if (FirstToken == TRUE){
886         
887                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
888                                 FirstToken = FALSE;
889         
890                         } else {
891         
892                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
893         
894                         }
896                 }
897         
898         }       
900         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
901         
902         wxString GenderComponent;
903         
904         if (GenderData.CountTokens() >= 2){
905         
906                 Gender = GenderData.GetNextToken();
907                 GenderDetails = GenderData.GetString();
908         
909                 CaptureString(&GenderDetails, FALSE);
910                                                 
911         } else {
912         
913                 Gender = GenderData.GetNextToken();
914         
915         }
916         
917         if (!PropertyTokens.IsEmpty()){
918         
919                 GenderTokens = PropertyTokens;
920         
921         }
925 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
927         // Process date. Preserve the remainder in the string.
929         std::map<int, int> SplitPoints;
930         std::map<int, int> SplitLength;
931         std::map<int, int>::iterator SLiter;                    
932         wxString PropertyData;
933         wxString PropertyName;
934         wxString PropertyValue;
935         wxString PropertyTokens;
936         bool BirthdayText = FALSE;
937         int intPrevValue = 6;
939         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
941         intPrevValue = 5;
943         // Look for type before continuing.
945         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
946         intiter != SplitPoints.end(); ++intiter){
948                 SLiter = SplitLength.find(intiter->first);
950                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
951         
952                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
953                 PropertyName = PropertyElement.GetNextToken();                          
954                 PropertyValue = PropertyElement.GetNextToken();
955         
956                 intPrevValue = intiter->second;
957         
958                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
959         
960                         CaptureString(&PropertySeg2, FALSE);
961                         Birthday = PropertySeg2;
962                         BirthdayText = TRUE;
963         
964                 }
966         }
968         // Setup blank lines for later on.
969         
970         intPrevValue = 5;
971         bool FirstToken = TRUE;
973         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
974         intiter != SplitPoints.end(); ++intiter){
976                 SLiter = SplitLength.find(intiter->first);
978                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
979         
980                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
981                 PropertyName = PropertyElement.GetNextToken();                          
982                 PropertyValue = PropertyElement.GetNextToken();
983         
984                 intPrevValue = intiter->second;
985         
986                 // Process properties.
987         
988                 CaptureString(&PropertyValue, FALSE);
989         
990                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
991                 
992                         PropertyValue.Trim();
993                         PropertyValue.RemoveLast();
994                 
995                 }                               
996         
997                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
998                 
999                         PropertyValue.Remove(0, 1);
1000                 
1001                 }                               
1002         
1003                 if (PropertyName == wxT("ALTID")){
1005                         BirthdayAltID = PropertyValue;
1006         
1007                 } else if (PropertyName == wxT("CALSCALE")){
1008         
1009                         BirthdayCalScale = PropertyValue;
1010         
1011                 } else if (PropertyName != wxT("VALUE")) {
1012         
1013                         // Something else we don't know about so append
1014                         // to the tokens variable.
1015                 
1016                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1017                 
1018                                 if (FirstToken == TRUE){
1019         
1020                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1021                                         FirstToken = FALSE;
1022         
1023                                 } else {
1024         
1025                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1026         
1027                                 }
1028                                 
1029                         }
1030                         
1031                 }
1033         }       
1035         // Add the data to the variables and form.
1036         
1037         if (BirthdayText == FALSE){
1038         
1039                 Birthday = PropertySeg2;
1041         }
1042         
1043         if (!PropertyTokens.IsEmpty()){
1044         
1045                 BirthdayTokens = PropertyTokens;
1047         }
1051 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1053         // Process date. Preserve the remainder in the string.
1055         std::map<int, int> SplitPoints;
1056         std::map<int, int> SplitLength;
1057         std::map<int, int>::iterator SLiter;                    
1058         wxString PropertyData;
1059         wxString PropertyName;
1060         wxString PropertyValue;
1061         wxString PropertyTokens;
1062         bool AnniversaryText = FALSE;
1063         int intPrevValue = 13;
1065         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1067         intPrevValue = 12;
1069         // Look for type before continuing.
1071         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1072         intiter != SplitPoints.end(); ++intiter){
1074                 SLiter = SplitLength.find(intiter->first);
1076                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1077         
1078                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1079                 PropertyName = PropertyElement.GetNextToken();                          
1080                 PropertyValue = PropertyElement.GetNextToken();
1081         
1082                 intPrevValue = intiter->second;
1083         
1084                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1085         
1086                         CaptureString(&PropertySeg2, FALSE);
1087                         Anniversary = PropertySeg2;
1088                         AnniversaryText = TRUE;
1089         
1090                 }
1092         }
1094         // Setup blank lines for later on.
1095         
1096         intPrevValue = 12;
1097         bool FirstToken = TRUE;
1099         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1100         intiter != SplitPoints.end(); ++intiter){
1102                 SLiter = SplitLength.find(intiter->first);
1104                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1105         
1106                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1107                 PropertyName = PropertyElement.GetNextToken();                          
1108                 PropertyValue = PropertyElement.GetNextToken();
1109         
1110                 intPrevValue = intiter->second;
1111         
1112                 // Process properties.
1113         
1114                 CaptureString(&PropertyValue, FALSE);
1115         
1116                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1117                 
1118                         PropertyValue.Trim();
1119                         PropertyValue.RemoveLast();
1120                 
1121                 }                               
1122         
1123                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1124                 
1125                         PropertyValue.Remove(0, 1);
1126                 
1127                 }                               
1128         
1129                 if (PropertyName == wxT("ALTID")){
1131                         AnniversaryAltID = PropertyValue;
1132         
1133                 } else if (PropertyName == wxT("CALSCALE")){
1134         
1135                         AnniversaryCalScale = PropertyValue;
1136         
1137                 } else if (PropertyName != wxT("VALUE")) {
1138         
1139                         // Something else we don't know about so append
1140                         // to the tokens variable.
1141                 
1142                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1143                 
1144                                 if (FirstToken == TRUE){
1145         
1146                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1147                                         FirstToken = FALSE;
1148         
1149                                 } else {
1150         
1151                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1152         
1153                                 }
1154                                 
1155                         }
1156                         
1157                 }
1159         }       
1161         // Add the data to the variables and form.
1162         
1163         if (AnniversaryText == FALSE){
1164         
1165                 Anniversary = PropertySeg2;
1167         }
1168         
1169         if (!PropertyTokens.IsEmpty()){
1170         
1171                 AnniversaryTokens = PropertyTokens;
1173         }
1177 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1179         std::map<int, int> SplitPoints;
1180         std::map<int, int> SplitLength;
1182         int intPrevValue = 4;
1183         int intPref = 0;                        
1184         
1185         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1186         
1187         intPrevValue = 3;
1188         
1189         PropertyType PropType = PROPERTY_NONE;
1190         
1191         // Look for type before continuing.
1192         
1193         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1194         
1195         intPrevValue = 3;
1196         
1197         std::map<int, wxString> *TZList = NULL;
1198         std::map<int, wxString> *TZListType = NULL;
1199         std::map<int, wxString> *TZListMediatype = NULL;
1200         std::map<int, wxString> *TZListAltID = NULL;
1201         std::map<int, wxString> *TZListPID = NULL;
1202         std::map<int, wxString> *TZListTokens = NULL;           
1203         std::map<int, int> *TZListPref = NULL;
1204         
1205         switch(PropType){
1206                 case PROPERTY_NONE:
1207                         TZList = &GeneralTZList;
1208                         TZListType = &GeneralTZListType;
1209                         TZListMediatype = &GeneralTZListMediatype;
1210                         TZListAltID = &GeneralTZListAltID;
1211                         TZListPID = &GeneralTZListPID;
1212                         TZListTokens = &GeneralTZListTokens;
1213                         TZListPref = &GeneralTZListPref;
1214                         break;
1215                 case PROPERTY_HOME:
1216                         TZList = &HomeTZList;
1217                         TZListType = &HomeTZListType;
1218                         TZListMediatype = &HomeTZListMediatype;
1219                         TZListAltID = &HomeTZListAltID;
1220                         TZListPID = &HomeTZListPID;
1221                         TZListTokens = &HomeTZListTokens;
1222                         TZListPref = &HomeTZListPref;
1223                         break;
1224                 case PROPERTY_WORK:
1225                         TZList = &BusinessTZList;
1226                         TZListType = &BusinessTZListType;
1227                         TZListMediatype = &BusinessTZListMediatype;
1228                         TZListAltID = &BusinessTZListAltID;
1229                         TZListPID = &BusinessTZListPID;
1230                         TZListTokens = &BusinessTZListTokens;
1231                         TZListPref = &BusinessTZListPref;
1232                         break;
1233         }
1234         
1235         std::map<int, int>::iterator SLiter;    
1236         wxString PropertyData;
1237         wxString PropertyName;
1238         wxString PropertyValue;
1239         wxString PropertyTokens;
1240         bool FirstToken = TRUE;
1241         
1242         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1243         intiter != SplitPoints.end(); ++intiter){
1244         
1245                 SLiter = SplitLength.find(intiter->first);
1246         
1247                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1248                 
1249                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1250                 PropertyName = PropertyElement.GetNextToken();                          
1251                 PropertyValue = PropertyElement.GetNextToken();
1252                 
1253                 intPrevValue = intiter->second;
1254                 
1255                 CaptureString(&PropertyValue, FALSE);
1257                 if (PropertyName == wxT("ALTID")){
1259                         TZListAltID->erase(*TimeZoneCount);
1260                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1261                 
1262                 } else if (PropertyName == wxT("PID")){
1264                         TZListPID->erase(*TimeZoneCount);
1265                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1267                 } else if (PropertyName == wxT("PREF")){
1269                         int PriorityNumber = 0;
1270                         bool ValidNumber = TRUE;
1271                         
1272                         try{
1273                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1274                         }
1275                         
1276                         catch(std::invalid_argument &e){
1277                                 ValidNumber = FALSE;
1278                         }
1280                         if (ValidNumber == TRUE){
1282                                 TZListPref->erase(*TimeZoneCount);
1283                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1285                         }
1286                 
1287                 } else if (PropertyName == wxT("MEDIATYPE")){
1289                         TZListMediatype->erase(*TimeZoneCount);
1290                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1292                 } else {
1293                 
1294                         // Something else we don't know about so append
1295                         // to the tokens variable.
1296                 
1297                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1298                 
1299                                 if (FirstToken == TRUE){
1300                         
1301                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1302                                         FirstToken = FALSE;
1303                         
1304                                 } else {
1305                         
1306                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1307                         
1308                                 }
1309                 
1310                         }
1311                 
1312                 }
1313                 
1314         }
1315         
1316         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1317         
1318         // Add the name token data.
1319         
1320         if (!PropertyTokens.IsEmpty()){
1321         
1322                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1323         
1324         }
1329 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1331         size_t intPropertyLen = PropertySeg1.Len();
1332         std::map<int, int> SplitPoints;
1333         std::map<int, int> SplitLength;
1334         std::map<int, int>::iterator SLiter;                    
1335         wxString PropertyData;
1336         wxString PropertyName;
1337         wxString PropertyValue;
1338         wxString PropertyTokens;
1339         wxString AddressLabel;
1340         wxString AddressLang;
1341         wxString AddressAltID;
1342         wxString AddressPID;
1343         wxString AddressTokens;
1344         wxString AddressGeo;
1345         wxString AddressTimezone;
1346         wxString AddressType;
1347         wxString AddressMediatype;
1348         wxString AddressPOBox;
1349         wxString AddressExtended;
1350         wxString AddressStreet;
1351         wxString AddressLocality;
1352         wxString AddressCity;
1353         wxString AddressRegion;
1354         wxString AddressPostalCode;
1355         wxString AddressCountry;
1356         bool FirstToken = TRUE;                 
1357         int intSplitsFound = 0;
1358         int intSplitSize = 0;
1359         int intPrevValue = 5;
1360         int intPref = 0;                        
1361         int intType = 0;
1362         long ListCtrlIndex;
1363         
1364         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1365         
1366         intPrevValue = 4;
1367         
1368         PropertyType PropType = PROPERTY_NONE;
1369                 
1370         // Look for type before continuing.
1371         
1372         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1373         
1374         intPrevValue = 4;
1375         
1376         std::map<int, wxString> *AddressList = NULL;
1377         std::map<int, wxString> *AddressListTown = NULL;
1378         std::map<int, wxString> *AddressListCounty = NULL;
1379         std::map<int, wxString> *AddressListPostCode = NULL;
1380         std::map<int, wxString> *AddressListCountry = NULL;
1381         std::map<int, wxString> *AddressListLabel = NULL;
1382         std::map<int, wxString> *AddressListLang = NULL;                
1383         std::map<int, wxString> *AddressListAltID = NULL;
1384         std::map<int, wxString> *AddressListPID = NULL;
1385         std::map<int, wxString> *AddressListTokens = NULL;
1386         std::map<int, wxString> *AddressListGeo = NULL;
1387         std::map<int, wxString> *AddressListTimezone = NULL;            
1388         std::map<int, wxString> *AddressListType = NULL;
1389         std::map<int, wxString> *AddressListMediatype = NULL;
1390         std::map<int, int> *AddressListPref = NULL;
1392         switch(PropType){
1393                 case PROPERTY_NONE:
1394                         AddressList = &GeneralAddressList;
1395                         AddressListTown = &GeneralAddressListTown;
1396                         AddressListCounty = &GeneralAddressListCounty;
1397                         AddressListPostCode = &GeneralAddressListPostCode;
1398                         AddressListCountry = &GeneralAddressListCountry;
1399                         AddressListLabel = &GeneralAddressListLabel;
1400                         AddressListLang = &GeneralAddressListLang;              
1401                         AddressListAltID = &GeneralAddressListAltID;
1402                         AddressListPID = &GeneralAddressListPID;
1403                         AddressListTokens = &GeneralAddressListTokens;
1404                         AddressListGeo = &GeneralAddressListGeo;
1405                         AddressListTimezone = &GeneralAddressListTimezone;
1406                         AddressListType = &GeneralAddressListType;
1407                         AddressListMediatype = &GeneralAddressListMediatype;
1408                         AddressListPref = &GeneralAddressListPref;              
1409                         break;
1410                 case PROPERTY_HOME:
1411                         AddressList = &HomeAddressList;
1412                         AddressListTown = &HomeAddressListTown;
1413                         AddressListCounty = &HomeAddressListCounty;
1414                         AddressListPostCode = &HomeAddressListPostCode;
1415                         AddressListCountry = &HomeAddressListCountry;
1416                         AddressListLabel = &HomeAddressListLabel;
1417                         AddressListLang = &HomeAddressListLang;         
1418                         AddressListAltID = &HomeAddressListAltID;
1419                         AddressListPID = &HomeAddressListPID;
1420                         AddressListTokens = &HomeAddressListTokens;
1421                         AddressListGeo = &HomeAddressListGeo;
1422                         AddressListTimezone = &HomeAddressListTimezone;
1423                         AddressListType = &HomeAddressListType;
1424                         AddressListMediatype = &HomeAddressListMediatype;
1425                         AddressListPref = &HomeAddressListPref;
1426                         break;
1427                 case PROPERTY_WORK:
1428                         AddressList = &BusinessAddressList;
1429                         AddressListTown = &BusinessAddressListTown;
1430                         AddressListCounty = &BusinessAddressListCounty;
1431                         AddressListPostCode = &BusinessAddressListPostCode;
1432                         AddressListCountry = &BusinessAddressListCountry;
1433                         AddressListLabel = &BusinessAddressListLabel;
1434                         AddressListLang = &BusinessAddressListLang;             
1435                         AddressListAltID = &BusinessAddressListAltID;
1436                         AddressListPID = &BusinessAddressListPID;
1437                         AddressListTokens = &BusinessAddressListTokens;
1438                         AddressListGeo = &BusinessAddressListGeo;
1439                         AddressListTimezone = &BusinessAddressListTimezone;
1440                         AddressListType = &BusinessAddressListType;
1441                         AddressListMediatype = &BusinessAddressListMediatype;
1442                         AddressListPref = &BusinessAddressListPref;
1443                         break;
1444         }
1445         
1446         intPrevValue = 4;
1447         
1448         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1449         intiter != SplitPoints.end(); ++intiter){
1450         
1451                 SLiter = SplitLength.find(intiter->first);
1452         
1453                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1454                 
1455                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1456                 PropertyName = PropertyElement.GetNextToken();                          
1457                 PropertyValue = PropertyElement.GetNextToken();
1458                 
1459                 intPrevValue = intiter->second;
1460                 
1461                 CaptureString(&PropertyValue, FALSE);
1462                 
1463                 // Process properties.
1464                 
1465                 if (PropertyName == wxT("LABEL")){
1466                 
1467                         AddressListLabel->erase(*AddressCount);
1468                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1469                                 
1470                 } else if (PropertyName == wxT("LANGUAGE")){
1471                 
1472                         AddressListLang->erase(*AddressCount);
1473                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1474                 
1475                 } else if (PropertyName == wxT("ALTID")){
1477                         AddressListAltID->erase(*AddressCount);
1478                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1479                 
1480                 } else if (PropertyName == wxT("PID")){
1482                         AddressListPID->erase(*AddressCount);
1483                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1484                 
1485                 } else if (PropertyName == wxT("GEO")){
1486                 
1487                         AddressListGeo->erase(*AddressCount);
1488                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1489                 
1490                 } else if (PropertyName == wxT("TZ")){
1492                         AddressListTimezone->erase(*AddressCount);
1493                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1494                 
1495                 } else if (PropertyName == wxT("MEDIATYPE")){
1497                         AddressListMediatype->erase(*AddressCount);
1498                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1499                 
1500                 } else if (PropertyName == wxT("PREF")){
1501                         
1502                         int PriorityNumber = 0;
1503                         bool ValidNumber = TRUE;
1504                         
1505                         try{
1506                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1507                         }
1508                         
1509                         catch(std::invalid_argument &e){
1510                                 ValidNumber = FALSE;
1511                         }
1513                         if (ValidNumber == TRUE){
1515                                 AddressListPref->erase(*AddressCount);
1516                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1518                         }
1519                 
1520                 } else {
1521                 
1522                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1523                         
1524                                 if (FirstToken == TRUE){
1525                                 
1526                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1527                                         FirstToken = FALSE;
1528                                 
1529                                 } else {
1530                                 
1531                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1532                                 
1533                                 }
1534                         
1535                         }
1536                 
1537                 }
1538         
1539         }                       
1540         
1541         // Split the address. 
1543         //std::map<int, int>::iterator SLiter;
1544         intPropertyLen = PropertySeg2.Len();
1545         SplitPoints.clear();
1546         SplitLength.clear();
1547         intSplitsFound = 0;
1548         intSplitSize = 0;
1549         intPrevValue = 0;
1550         
1551         for (int i = 0; i <= intPropertyLen; i++){
1553                 intSplitSize++;
1554         
1555                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1556         
1557                         intSplitsFound++;
1558                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1559                         
1560                         if (intSplitsFound == 6){ 
1561                         
1562                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1563                                 break; 
1564                                 
1565                         } else {
1566                         
1567                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1568                         
1569                         }
1570                         
1571                         intSplitSize = 0;                                       
1572         
1573                 }
1575         }
1576         
1577         // Split the data into several parts.                   
1578         
1579         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1580         intiter != SplitPoints.end(); ++intiter){
1581                         
1582                 if (intiter->first == 1){
1583                 
1584                         // Deal with PO Box.
1585                         
1586                         SLiter = SplitLength.find(1);
1587                                                                 
1588                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1589                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1590                         intPrevValue = intiter->second;
1591                 
1592                 } else if (intiter->first == 2){
1593                 
1594                         // Deal with extended address.
1595                         
1596                         SLiter = SplitLength.find(2);
1597                         
1598                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1599                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1600                         intPrevValue = intiter->second;
1601                 
1602                 } else if (intiter->first == 3){
1603                 
1604                         // Deal with street address.
1605                         
1606                         SLiter = SplitLength.find(3);
1607                                                                 
1608                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1609                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1610                         intPrevValue = intiter->second;
1611                 
1612                 } else if (intiter->first == 4){
1613                 
1614                         // Deal with locality
1616                         SLiter = SplitLength.find(4);
1617                         
1618                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1619                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1620                         intPrevValue = intiter->second;
1621                         
1622                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1623                 
1624                 } else if (intiter->first == 5){
1625                 
1626                         // Deal with region.
1628                         SLiter = SplitLength.find(5);
1629                         
1630                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1631                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1632                         intPrevValue = intiter->second;
1633                         
1634                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1635                 
1636                 } else if (intiter->first == 6){
1637                 
1638                         // Deal with post code.
1640                         SLiter = SplitLength.find(6);
1641                         
1642                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1643                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1644                         intPrevValue = intiter->second;
1645                         
1646                         // Deal with country.
1647                                                 
1648                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1649                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1650                         
1651                         break;
1652                 
1653                 }
1654         
1655         }       
1656         
1657         // Add the data to the General/Home/Work address variables.
1658         
1659         CaptureString(&AddressStreet, FALSE); 
1660         CaptureString(&AddressLocality, FALSE);
1661         CaptureString(&AddressRegion, FALSE);
1662         CaptureString(&AddressPostalCode, FALSE);
1663         CaptureString(&AddressCountry, FALSE);
1664                 
1665         if (!PropertyTokens.IsEmpty()){
1666         
1667                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1668         
1669         }
1671         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1672         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1673         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1674         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1675         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1677         switch(PropType){
1678                 case PROPERTY_NONE:
1679                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1680                         break;
1681                 case PROPERTY_HOME:
1682                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1683                         break;
1684                 case PROPERTY_WORK:
1685                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1686                         break;
1687         }
1688         
1689         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1693 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1695         std::map<int, int> SplitPoints;
1696         std::map<int, int> SplitLength;
1698         int intPrevValue = 7;
1699         int intPref = 0;                        
1700         
1701         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1702         
1703         intPrevValue = 6;
1704         
1705         PropertyType PropType = PROPERTY_NONE;
1706                 
1707         // Look for type before continuing.
1708         
1709         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1710         
1711         std::map<int, wxString> *EmailList = NULL;
1712         std::map<int, wxString> *EmailListType = NULL;
1713         std::map<int, wxString> *EmailListAltID = NULL;
1714         std::map<int, wxString> *EmailListPID = NULL;
1715         std::map<int, wxString> *EmailListTokens = NULL;                
1716         std::map<int, int> *EmailListPref = NULL;
1718         switch(PropType){
1719                 case PROPERTY_NONE:
1720                         EmailList = &GeneralEmailList;
1721                         EmailListType = &GeneralEmailListType;
1722                         EmailListAltID = &GeneralEmailListAltID;
1723                         EmailListPID = &GeneralEmailListPID;
1724                         EmailListTokens = &GeneralEmailListTokens;              
1725                         EmailListPref = &GeneralEmailListPref;  
1726                         break;
1727                 case PROPERTY_HOME:
1728                         EmailList = &HomeEmailList;
1729                         EmailListType = &HomeEmailListType;
1730                         EmailListAltID = &HomeEmailListAltID;
1731                         EmailListPID = &HomeEmailListPID;
1732                         EmailListTokens = &HomeEmailListTokens;         
1733                         EmailListPref = &HomeEmailListPref;     
1734                         break;
1735                 case PROPERTY_WORK:
1736                         EmailList = &BusinessEmailList;
1737                         EmailListType = &BusinessEmailListType;
1738                         EmailListAltID = &BusinessEmailListAltID;
1739                         EmailListPID = &BusinessEmailListPID;
1740                         EmailListTokens = &BusinessEmailListTokens;             
1741                         EmailListPref = &BusinessEmailListPref; 
1742                         break;
1743         }
1744         
1745         intPrevValue = 6;
1746         
1747         std::map<int,int>::iterator SLiter;
1748         wxString PropertyData;
1749         wxString PropertyName;
1750         wxString PropertyValue;
1751         wxString PropertyTokens;
1752         bool FirstToken = TRUE;
1753         
1754         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1755         intiter != SplitPoints.end(); ++intiter){
1756         
1757                 SLiter = SplitLength.find(intiter->first);
1758         
1759                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1760                 
1761                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1762                 PropertyName = PropertyElement.GetNextToken();                          
1763                 PropertyValue = PropertyElement.GetNextToken();
1764                 
1765                 intPrevValue = intiter->second;
1766                 
1767                 CaptureString(&PropertyValue, FALSE);
1768                 
1769                 // Process properties.
1770                 
1771                 if (PropertyName == wxT("ALTID")){
1773                         EmailListAltID->erase(*EmailCount);
1774                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
1775                 
1776                 } else if (PropertyName == wxT("PID")){
1778                         EmailListPID->erase(*EmailCount);
1779                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
1780                 
1781                 } else if (PropertyName == wxT("PREF")){
1782                         
1783                         int PriorityNumber = 0;
1784                         bool ValidNumber = TRUE;
1785                         
1786                         try{
1787                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1788                         }
1789                         
1790                         catch(std::invalid_argument &e){
1791                                 ValidNumber = FALSE;
1792                         }
1794                         if (ValidNumber == TRUE){
1796                                 EmailListPref->erase(*EmailCount);
1797                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
1799                         }
1800                 
1801                 } else {
1802                 
1803                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1804                         
1805                                 if (FirstToken == TRUE){
1806                                 
1807                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1808                                         FirstToken = FALSE;
1809                                 
1810                                 } else {
1811                                 
1812                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1813                                 
1814                                 }
1815                         
1816                         }
1817                 
1818                 }
1819         
1820         }
1821         
1822         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1823         
1824         // Add the name token data.
1825         
1826         if (!PropertyTokens.IsEmpty()){
1827         
1828                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1829         
1830         }       
1835 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1837         std::map<int, int> SplitPoints;
1838         std::map<int, int> SplitLength;
1840         int intPrevValue = 6;
1841         int intPref = 0;                        
1842         
1843         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1844         
1845         intPrevValue = 5;
1846         
1847         PropertyType PropType = PROPERTY_NONE;
1848                 
1849         // Look for type before continuing.
1850         
1851         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1852         
1853         std::map<int, wxString> *IMList = NULL;
1854         std::map<int, wxString> *IMListType = NULL;
1855         std::map<int, wxString> *IMListAltID = NULL;
1856         std::map<int, wxString> *IMListPID = NULL;
1857         std::map<int, wxString> *IMListTokens = NULL;
1858         std::map<int, wxString> *IMListMediatype = NULL;        
1859         std::map<int, int> *IMListPref = NULL;
1861         switch(PropType){
1862                 case PROPERTY_NONE:
1863                         IMList = &GeneralIMList;
1864                         IMListType = &GeneralIMListType;
1865                         IMListAltID = &GeneralIMListAltID;
1866                         IMListPID = &GeneralIMListPID;
1867                         IMListTokens = &GeneralIMListTokens;
1868                         IMListMediatype = &GeneralIMListMediatype;
1869                         IMListPref = &GeneralIMListPref;        
1870                         break;
1871                 case PROPERTY_HOME:
1872                         IMList = &HomeIMList;
1873                         IMListType = &HomeIMListType;
1874                         IMListAltID = &HomeIMListAltID;
1875                         IMListPID = &HomeIMListPID;
1876                         IMListTokens = &HomeIMListTokens;
1877                         IMListMediatype = &HomeIMListMediatype;         
1878                         IMListPref = &HomeIMListPref;   
1879                         break;
1880                 case PROPERTY_WORK:
1881                         IMList = &BusinessIMList;
1882                         IMListType = &BusinessIMListType;
1883                         IMListAltID = &BusinessIMListAltID;
1884                         IMListPID = &BusinessIMListPID;
1885                         IMListTokens = &BusinessIMListTokens;   
1886                         IMListMediatype = &BusinessIMListMediatype;     
1887                         IMListPref = &BusinessIMListPref;       
1888                         break;
1889         }
1890         
1891         intPrevValue = 5;
1892         
1893         std::map<int,int>::iterator SLiter;
1894         wxString PropertyData;
1895         wxString PropertyName;
1896         wxString PropertyValue;
1897         wxString PropertyTokens;
1898         bool FirstToken = TRUE;
1899         
1900         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1901         intiter != SplitPoints.end(); ++intiter){
1902         
1903                 SLiter = SplitLength.find(intiter->first);
1904         
1905                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1906                 
1907                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1908                 PropertyName = PropertyElement.GetNextToken();                          
1909                 PropertyValue = PropertyElement.GetNextToken();
1910                 
1911                 intPrevValue = intiter->second;
1912                 
1913                 CaptureString(&PropertyValue, FALSE);
1914                 
1915                 // Process properties.
1916                 
1917                 if (PropertyName == wxT("ALTID")){
1919                         IMListAltID->erase(*IMCount);
1920                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
1921                 
1922                 } else if (PropertyName == wxT("PID")){
1924                         IMListPID->erase(*IMCount);
1925                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
1926                 
1927                 } else if (PropertyName == wxT("MEDIATYPE")){
1929                         IMListMediatype->erase(*IMCount);
1930                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
1931                 
1932                 } else if (PropertyName == wxT("PREF")){
1933                         
1934                         int PriorityNumber = 0;
1935                         bool ValidNumber = TRUE;
1936                         
1937                         try{
1938                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1939                         }
1940                         
1941                         catch(std::invalid_argument &e){
1942                                 ValidNumber = FALSE;
1943                         }
1945                         if (ValidNumber == TRUE){
1947                                 IMListPref->erase(*IMCount);
1948                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
1950                         }
1951                 
1952                 } else {
1953                 
1954                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1955                         
1956                                 if (FirstToken == TRUE){
1957                                 
1958                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1959                                         FirstToken = FALSE;
1960                                 
1961                                 } else {
1962                                 
1963                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1964                                 
1965                                 }
1966                         
1967                         }
1968                 
1969                 }
1970         
1971         }
1972                 
1973         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1974         
1975         // Add the name token data.
1976         
1977         if (!PropertyTokens.IsEmpty()){
1978         
1979                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1980         
1981         }
1985 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1987         std::map<int, int> SplitPoints;
1988         std::map<int, int> SplitLength;
1989         std::map<int, int>::iterator SLiter;
1990         
1991         int intPref = 0;
1992         
1993         PropertyType PropType = PROPERTY_NONE;
1994                 
1995         // Look for type before continuing.
1996         
1997         wxString TelTypeUI;
1998         wxString TelTypeDetail;
1999         wxString PropertyData;
2000         wxString PropertyName;
2001         wxString PropertyValue;
2002         wxString PropertyTokens;
2003         
2004         std::map<int,int> TypeSplitPoints;
2005         std::map<int,int> TypeSplitLength;
2006         std::map<int,int>::iterator TSLiter;
2007         
2008         int intSplitSize = 0;
2009         int intSplitsFound = 0;
2010         int intSplitPoint = 0;
2011         int intType = 0;
2012         int intPrevValue = 5;
2013                 
2014         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2015         
2016         intPrevValue = 4;
2017         
2018         // Look for type before continuing.
2019         
2020         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2021         intiter != SplitPoints.end(); ++intiter){
2022         
2023                 SLiter = SplitLength.find(intiter->first);
2024         
2025                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2026                 
2027                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2028                 PropertyName = PropertyElement.GetNextToken();                          
2029                 PropertyValue = PropertyElement.GetNextToken();
2030                 
2031                 intPrevValue = intiter->second;
2033                 if (PropertyName == wxT("TYPE")){
2034                 
2035                         // Process each value in type and translate each
2036                         // part.
2037                 
2038                         // Strip out the quotes if they are there.
2039                 
2040                         size_t intPropertyValueLen = PropertyValue.Len();
2041                 
2042                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2043                         
2044                                 PropertyValue.Trim();
2045                                 PropertyValue.RemoveLast();
2046                         
2047                         }                               
2048                 
2049                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2050                         
2051                                 PropertyValue.Remove(0, 1);
2052                         
2053                         }
2054                         
2055                         TelTypeDetail = PropertyValue;
2056                         
2057                         intSplitSize = 0;
2058                         intSplitsFound = 0;
2059                         intSplitPoint = 0;
2060                         
2061                         for (int i = 0; i <= intPropertyValueLen; i++){
2062         
2063                                 intSplitSize++;
2064         
2065                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2066         
2067                                         if (intSplitsFound == 0){
2069                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2070                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2071                         
2072                                         } else {
2073                         
2074                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2075                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2076                         
2077                                         }                       
2079                                         intSplitsFound++;
2080                                         i++;
2081                                         intSplitPoint = i;
2082                                         intSplitSize = 0;
2083         
2084                                 }
2085         
2086                         }
2087                         
2088                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2089                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2090                 
2091                         int intTypeSeek = 0;
2092                 
2093                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2094                         typeiter != TypeSplitPoints.end(); ++typeiter){
2095                         
2096                                 wxString TypePropertyName;
2097                                 
2098                                 TSLiter = TypeSplitLength.find(typeiter->first);
2099                                 
2100                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2101                                 
2102                                 if (intTypeSeek == 0){
2103                                 
2104                                 
2105                                 } else {
2106                                                                                 
2107                                         TelTypeUI.Append(wxT(","));                                                     
2108                                 
2109                                 }
2110                         
2111                                 if (TypePropertyName == wxT("home")){
2112                                 
2113                                         PropType = PROPERTY_HOME;
2114                                 
2115                                 } else if (TypePropertyName == wxT("work")){
2116                                 
2117                                         PropType = PROPERTY_WORK;
2118                                                                         
2119                                 }
2120                                 
2121                                 
2122                                 if (TypePropertyName == wxT("text")){
2123                                 
2124                                         TelTypeUI.Append(_("text"));
2125                                         intTypeSeek++;
2126                                 
2127                                 } else if (TypePropertyName == wxT("voice")){
2128                                 
2129                                         TelTypeUI.Append(_("voice"));
2130                                         intTypeSeek++;
2131                                 
2132                                 } else if (TypePropertyName == wxT("fax")){
2133                                 
2134                                         TelTypeUI.Append(_("fax"));
2135                                         intTypeSeek++;
2136                                 
2137                                 } else if (TypePropertyName == wxT("cell")){
2138                                 
2139                                         TelTypeUI.Append(_("mobile"));
2140                                         intTypeSeek++;
2141                                 
2142                                 } else if (TypePropertyName == wxT("video")){
2143                                 
2144                                         TelTypeUI.Append(_("video"));
2145                                         intTypeSeek++;
2146                                 
2147                                 } else if (TypePropertyName == wxT("pager")){
2148                                 
2149                                         TelTypeUI.Append(_("pager"));
2150                                         intTypeSeek++;
2151                                 
2152                                 } else if (TypePropertyName == wxT("textphone")){
2153                                 
2154                                         TelTypeUI.Append(_("textphone"));
2155                                         intTypeSeek++;
2156                                 
2157                                 }
2158                         
2159                         }
2160                 
2161                 }
2162                 
2163         }
2164         
2165         std::map<int, wxString> *TelephoneList = NULL;
2166         std::map<int, wxString> *TelephoneListType = NULL;
2167         std::map<int, wxString> *TelephoneListAltID = NULL;
2168         std::map<int, wxString> *TelephoneListPID = NULL;
2169         std::map<int, wxString> *TelephoneListTokens = NULL;
2170         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2171         std::map<int, int> *TelephoneListPref = NULL;
2173         switch(PropType){
2174                 case PROPERTY_NONE:
2175                         TelephoneList = &GeneralTelephoneList;
2176                         TelephoneListType = &GeneralTelephoneListType;
2177                         TelephoneListAltID = &GeneralTelephoneListAltID;
2178                         TelephoneListPID = &GeneralTelephoneListPID;
2179                         TelephoneListTokens = &GeneralTelephoneListTokens;
2180                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2181                         TelephoneListPref = &GeneralTelephoneListPref;  
2182                         break;
2183                 case PROPERTY_HOME:
2184                         TelephoneList = &HomeTelephoneList;
2185                         TelephoneListType = &HomeTelephoneListType;
2186                         TelephoneListAltID = &HomeTelephoneListAltID;
2187                         TelephoneListPID = &HomeTelephoneListPID;
2188                         TelephoneListTokens = &HomeTelephoneListTokens;
2189                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2190                         TelephoneListPref = &HomeTelephoneListPref;     
2191                         break;
2192                 case PROPERTY_WORK:
2193                         TelephoneList = &BusinessTelephoneList;
2194                         TelephoneListType = &BusinessTelephoneListType;
2195                         TelephoneListAltID = &BusinessTelephoneListAltID;
2196                         TelephoneListPID = &BusinessTelephoneListPID;
2197                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2198                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2199                         TelephoneListPref = &BusinessTelephoneListPref; 
2200                         break;
2201         }
2202                 
2203         // Process the properties.
2204         
2205         bool FirstToken = TRUE;
2206         
2207         intPrevValue = 5;
2208         SplitPoints.clear();
2209         SplitLength.clear();
2211         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2213         intPrevValue = 4;
2214         
2215         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2216         intiter != SplitPoints.end(); ++intiter){
2217         
2218                 SLiter = SplitLength.find(intiter->first);
2219         
2220                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2221                 
2222                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2223                 PropertyName = PropertyElement.GetNextToken();                          
2224                 PropertyValue = PropertyElement.GetNextToken();
2225                 
2226                 intPrevValue = intiter->second;
2227                 
2228                 CaptureString(&PropertyValue, FALSE);
2229                 
2230                 // Process properties.
2231                 
2232                 if (PropertyName == wxT("ALTID")){
2234                         TelephoneListAltID->erase(*TelephoneCount);
2235                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2236                 
2237                 } else if (PropertyName == wxT("PID")){
2239                         TelephoneListPID->erase(*TelephoneCount);
2240                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2241                 
2242                 } else if (PropertyName == wxT("PREF")){
2243                         
2244                         int PriorityNumber = 0;
2245                         bool ValidNumber = TRUE;
2246                         
2247                         try{
2248                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2249                         }
2250                         
2251                         catch(std::invalid_argument &e){
2252                                 ValidNumber = FALSE;
2253                         }
2255                         if (ValidNumber == TRUE){
2257                                 TelephoneListPref->erase(*TelephoneCount);
2258                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2260                         }
2261                 
2262                 } else {
2263                 
2264                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2265                         
2266                                 if (FirstToken == TRUE){
2267                                 
2268                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2269                                         FirstToken = FALSE;
2270                                 
2271                                 } else {
2272                                 
2273                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2274                                 
2275                                 }
2276                         
2277                         }
2278                 
2279                 }
2280         
2281         }
2282                 
2283         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2284         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2285         
2286         // Add the name token data.
2287         
2288         if (!PropertyTokens.IsEmpty()){
2289         
2290                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2291         
2292         }
2296 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2298         std::map<int, int> SplitPoints;
2299         std::map<int, int> SplitLength;
2301         int intPrevValue = 6;
2302         int intPref = 0;                        
2303         
2304         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2305         
2306         intPrevValue = 5;
2307         
2308         PropertyType PropType = PROPERTY_NONE;
2309                 
2310         // Look for type before continuing.
2311         
2312         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2313         
2314         std::map<int, wxString> *LanguageList = NULL;
2315         std::map<int, wxString> *LanguageListType = NULL;
2316         std::map<int, wxString> *LanguageListAltID = NULL;
2317         std::map<int, wxString> *LanguageListPID = NULL;
2318         std::map<int, wxString> *LanguageListTokens = NULL;
2319         std::map<int, int> *LanguageListPref = NULL;
2321         switch(PropType){
2322                 case PROPERTY_NONE:
2323                         LanguageList = &GeneralLanguageList;
2324                         LanguageListType = &GeneralLanguageListType;
2325                         LanguageListAltID = &GeneralLanguageListAltID;
2326                         LanguageListPID = &GeneralLanguageListPID;
2327                         LanguageListTokens = &GeneralLanguageListTokens;
2328                         LanguageListPref = &GeneralLanguageListPref;    
2329                         break;
2330                 case PROPERTY_HOME:
2331                         LanguageList = &HomeLanguageList;
2332                         LanguageListType = &HomeLanguageListType;
2333                         LanguageListAltID = &HomeLanguageListAltID;
2334                         LanguageListPID = &HomeLanguageListPID;
2335                         LanguageListTokens = &HomeLanguageListTokens;   
2336                         LanguageListPref = &HomeLanguageListPref;       
2337                         break;
2338                 case PROPERTY_WORK:
2339                         LanguageList = &BusinessLanguageList;
2340                         LanguageListType = &BusinessLanguageListType;
2341                         LanguageListAltID = &BusinessLanguageListAltID;
2342                         LanguageListPID = &BusinessLanguageListPID;
2343                         LanguageListTokens = &BusinessLanguageListTokens;       
2344                         LanguageListPref = &BusinessLanguageListPref;
2345                         break;
2346         }
2347         
2348         intPrevValue = 5;
2349         
2350         std::map<int,int>::iterator SLiter;
2351         wxString PropertyData;
2352         wxString PropertyName;
2353         wxString PropertyValue;
2354         wxString PropertyTokens;
2355         bool FirstToken = TRUE;
2356         
2357         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2358         intiter != SplitPoints.end(); ++intiter){
2359         
2360                 SLiter = SplitLength.find(intiter->first);
2361         
2362                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2363                 
2364                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2365                 PropertyName = PropertyElement.GetNextToken();                          
2366                 PropertyValue = PropertyElement.GetNextToken();
2367                 
2368                 intPrevValue = intiter->second;
2369                 
2370                 CaptureString(&PropertyValue, FALSE);
2371                 
2372                 // Process properties.
2373                 
2374                 if (PropertyName == wxT("ALTID")){
2376                         LanguageListAltID->erase(*LanguageCount);
2377                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2378                 
2379                 } else if (PropertyName == wxT("PID")){
2381                         LanguageListPID->erase(*LanguageCount);
2382                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2383                 
2384                 } else if (PropertyName == wxT("PREF")){
2385                         
2386                         int PriorityNumber = 0;
2387                         bool ValidNumber = TRUE;
2388                         
2389                         try{
2390                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2391                         }
2392                         
2393                         catch(std::invalid_argument &e){
2394                                 ValidNumber = FALSE;
2395                         }
2397                         if (ValidNumber == TRUE){
2399                                 LanguageListPref->erase(*LanguageCount);
2400                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2402                         }
2403                 
2404                 } else {
2405                 
2406                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2407                         
2408                                 if (FirstToken == TRUE){
2409                                 
2410                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2411                                         FirstToken = FALSE;
2412                                 
2413                                 } else {
2414                                 
2415                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2416                                 
2417                                 }
2418                         
2419                         }
2420                 
2421                 }
2422         
2423         }
2424                 
2425         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2426         
2427         // Add the name token data.
2428         
2429         if (!PropertyTokens.IsEmpty()){
2430         
2431                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2432         
2433         }
2437 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2439         std::map<int, int> SplitPoints;
2440         std::map<int, int> SplitLength;
2442         int intPrevValue = 5;
2443         int intPref = 0;                        
2444         
2445         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2446         
2447         intPrevValue = 4;
2448         
2449         PropertyType PropType = PROPERTY_NONE;
2450                 
2451         // Look for type before continuing.
2452         
2453         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2454         
2455         std::map<int, wxString> *GeopositionList = NULL;
2456         std::map<int, wxString> *GeopositionListType = NULL;
2457         std::map<int, wxString> *GeopositionListAltID = NULL;
2458         std::map<int, wxString> *GeopositionListPID = NULL;
2459         std::map<int, wxString> *GeopositionListTokens = NULL;
2460         std::map<int, wxString> *GeopositionListMediatype = NULL;
2461         std::map<int, int> *GeopositionListPref = NULL;
2463         switch(PropType){
2464                 case PROPERTY_NONE:
2465                         GeopositionList = &GeneralGeographyList;
2466                         GeopositionListType = &GeneralGeographyListType;
2467                         GeopositionListAltID = &GeneralGeographyListAltID;
2468                         GeopositionListPID = &GeneralGeographyListPID;
2469                         GeopositionListTokens = &GeneralGeographyListTokens;
2470                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2471                         GeopositionListPref = &GeneralGeographyListPref;        
2472                         break;
2473                 case PROPERTY_HOME:
2474                         GeopositionList = &HomeGeographyList;
2475                         GeopositionListType = &HomeGeographyListType;
2476                         GeopositionListAltID = &HomeGeographyListAltID;
2477                         GeopositionListPID = &HomeGeographyListPID;
2478                         GeopositionListTokens = &HomeGeographyListTokens;
2479                         GeopositionListMediatype = &HomeGeographyListMediatype;
2480                         GeopositionListPref = &HomeGeographyListPref;   
2481                         break;
2482                 case PROPERTY_WORK:
2483                         GeopositionList = &BusinessGeographyList;
2484                         GeopositionListType = &BusinessGeographyListType;
2485                         GeopositionListAltID = &BusinessGeographyListAltID;
2486                         GeopositionListPID = &BusinessGeographyListPID;
2487                         GeopositionListTokens = &BusinessGeographyListTokens;
2488                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2489                         GeopositionListPref = &BusinessGeographyListPref;
2490                         break;
2491         }
2492         
2493         intPrevValue = 4;
2494         
2495         std::map<int,int>::iterator SLiter;
2496         wxString PropertyData;
2497         wxString PropertyName;
2498         wxString PropertyValue;
2499         wxString PropertyTokens;
2500         bool FirstToken = TRUE;
2501         
2502         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2503         intiter != SplitPoints.end(); ++intiter){
2504         
2505                 SLiter = SplitLength.find(intiter->first);
2506         
2507                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2508                 
2509                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2510                 PropertyName = PropertyElement.GetNextToken();                          
2511                 PropertyValue = PropertyElement.GetNextToken();
2512                 
2513                 intPrevValue = intiter->second;
2514                 
2515                 CaptureString(&PropertyValue, FALSE);
2516                 
2517                 // Process properties.
2518                 
2519                 if (PropertyName == wxT("ALTID")){
2521                         GeopositionListAltID->erase(*GeographicCount);
2522                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2523                 
2524                 } else if (PropertyName == wxT("PID")){
2526                         GeopositionListPID->erase(*GeographicCount);
2527                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2528                 
2529                 } else if (PropertyName == wxT("MEDIATYPE")){
2531                         GeopositionListMediatype->erase(*GeographicCount);
2532                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2533                 
2534                 } else if (PropertyName == wxT("PREF")){
2535                         
2536                         int PriorityNumber = 0;
2537                         bool ValidNumber = TRUE;
2538                         
2539                         try{
2540                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2541                         }
2542                         
2543                         catch(std::invalid_argument &e){
2544                                 ValidNumber = FALSE;
2545                         }
2547                         if (ValidNumber == TRUE){
2549                                 GeopositionListPref->erase(*GeographicCount);
2550                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2552                         }
2553                 
2554                 } else {
2555                 
2556                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2557                         
2558                                 if (FirstToken == TRUE){
2559                                 
2560                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2561                                         FirstToken = FALSE;
2562                                 
2563                                 } else {
2564                                 
2565                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2566                                 
2567                                 }
2568                         
2569                         }
2570                 
2571                 }
2572         
2573         }
2574                 
2575         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2576         
2577         // Add the name token data.
2578         
2579         if (!PropertyTokens.IsEmpty()){
2580         
2581                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2582         
2583         }
2587 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2589         size_t intPropertyLen = PropertySeg1.Len();
2590         std::map<int, int> SplitPoints;
2591         std::map<int, int> SplitLength;
2592         std::map<int, int>::iterator SLiter;                    
2593         wxString PropertyData;
2594         wxString PropertyName;
2595         wxString PropertyValue;
2596         wxString PropertyTokens;
2597         wxString RelatedType;
2598         wxString RelatedTypeOriginal;                   
2599         wxString RelatedName;
2600         bool FirstToken = TRUE;                 
2601         int intSplitsFound = 0;
2602         int intSplitSize = 0;
2603         int intPrevValue = 9;
2604         int intPref = 0;
2605         long ListCtrlIndex;
2606         
2607         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2608         
2609         intPrevValue = 8;
2610         
2611         // Look for type before continuing.
2612         
2613         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2614         intiter != SplitPoints.end(); ++intiter){
2615         
2616                 SLiter = SplitLength.find(intiter->first);
2617         
2618                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2619                 
2620                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2621                 PropertyName = PropertyElement.GetNextToken();                          
2622                 PropertyValue = PropertyElement.GetNextToken();
2623                 
2624                 intPrevValue = intiter->second;
2625                 
2626                 // Process these.
2627                 
2628                 RelatedTypeOriginal = PropertyValue;
2629                 
2630                 if (PropertyName == wxT("TYPE")){
2631                 
2632                         if (PropertyValue == wxT("contact")){
2634                                 RelatedType = _("Contact");
2636                         } else if (PropertyValue == wxT("acquaintance")){
2638                                 RelatedType = _("Acquaintance");
2640                         } else if (PropertyValue == wxT("friend")){
2642                                 RelatedType = _("Friend");
2644                         } else if (PropertyValue == wxT("met")){
2646                                 RelatedType = _("Met");
2648                         } else if (PropertyValue == wxT("co-worker")){
2650                                 RelatedType = _("Co-worker");
2652                         } else if (PropertyValue == wxT("colleague")){
2654                                 RelatedType = _("Colleague");
2656                         } else if (PropertyValue == wxT("co-resident")){
2658                                 RelatedType = _("Co-resident");
2660                         } else if (PropertyValue == wxT("neighbor")){
2662                                 RelatedType = _("Neighbour");
2664                         } else if (PropertyValue == wxT("child")){
2666                                 RelatedType = _("Child");
2668                         } else if (PropertyValue == wxT("parent")){
2670                                 RelatedType = _("Parent");
2672                         } else if (PropertyValue == wxT("sibling")){
2674                                 RelatedType = _("Sibling");
2676                         } else if (PropertyValue == wxT("spouse")){
2678                                 RelatedType = _("Spouse");
2680                         } else if (PropertyValue == wxT("kin")){
2682                                 RelatedType = _("Kin");
2684                         } else if (PropertyValue == wxT("muse")){
2686                                 RelatedType = _("Muse");
2688                         } else if (PropertyValue == wxT("crush")){
2690                                 RelatedType = _("Crush");
2692                         } else if (PropertyValue == wxT("date")){
2694                                 RelatedType = _("Date");
2696                         } else if (PropertyValue == wxT("sweetheart")){
2698                                 RelatedType = _("Sweetheart");
2700                         } else if (PropertyValue == wxT("me")){
2702                                 RelatedType = _("Me");
2704                         } else if (PropertyValue == wxT("agent")){
2706                                 RelatedType = _("Agent");
2708                         } else if (PropertyValue == wxT("emergency")){
2710                                 RelatedType = _("Emergency");
2712                         } else {
2714                                 RelatedType = PropertyValue;
2716                         }
2717                 
2718                 }
2719         
2720         }
2721         
2722         intPrevValue = 8;                       
2723         
2724         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2725         intiter != SplitPoints.end(); ++intiter){
2726         
2727                 SLiter = SplitLength.find(intiter->first);
2728         
2729                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2730                 
2731                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2732                 PropertyName = PropertyElement.GetNextToken();                          
2733                 PropertyValue = PropertyElement.GetNextToken();
2734                 
2735                 intPrevValue = intiter->second;
2736                 
2737                 // Process properties.
2738                 
2739                 size_t intPropertyValueLen = PropertyValue.Len();
2740                 
2741                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2742                         
2743                         PropertyValue.Trim();
2744                         PropertyValue.RemoveLast();
2745                         
2746                 }                               
2747                 
2748                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2749                         
2750                         PropertyValue.Remove(0, 1);
2751                         
2752                 }
2753                 
2754                 CaptureString(&PropertyValue, FALSE);
2755                         
2756                 if (PropertyName == wxT("ALTID")){
2758                         GeneralRelatedListAltID.erase(*RelatedCount);
2759                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2760                 
2761                 } else if (PropertyName == wxT("PID")){
2763                         GeneralRelatedListPID.erase(*RelatedCount);
2764                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2765                 
2766                 } else if (PropertyName == wxT("PREF")){
2767                         
2768                         int PriorityNumber = 0;
2769                         bool ValidNumber = TRUE;
2770                         
2771                         try{
2772                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2773                         }
2774                         
2775                         catch(std::invalid_argument &e){
2776                                 ValidNumber = FALSE;
2777                         }
2779                         if (ValidNumber == TRUE){
2781                                 GeneralRelatedListPref.erase(*RelatedCount);
2782                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2784                         }
2785                 
2786                 } else if (PropertyName == wxT("LANGUAGE")){
2787                 
2788                         GeneralRelatedListLanguage.erase(*RelatedCount);
2789                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
2790                 
2791                 } else if (PropertyName != wxT("TYPE")) {
2792                 
2793                         // Something else we don't know about so append
2794                         // to the tokens variable.
2795                 
2796                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2797                 
2798                                 if (FirstToken == TRUE){
2799                         
2800                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2801                                         FirstToken = FALSE;
2802                         
2803                                 } else {
2804                         
2805                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2806                         
2807                                 }
2808                 
2809                         }
2810                 
2811                 }
2812         
2813         }                                       
2814         
2815         // Add the data to the General/Home/Work address variables.
2816                                 
2817         GeneralRelatedList.erase(*RelatedCount);
2818         GeneralRelatedListRelType.erase(*RelatedCount);
2819         GeneralRelatedListType.erase(*RelatedCount);
2820         GeneralRelatedListTokens.erase(*RelatedCount);
2821         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2822         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2823         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2824         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2828 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2830         std::map<int, int> SplitPoints;
2831         std::map<int, int> SplitLength;
2832         std::map<int, int>::iterator SLiter;                    
2833         wxString PropertyData;
2834         wxString PropertyName;
2835         wxString PropertyValue;
2836         wxString PropertyTokens;
2837         bool FirstToken = TRUE;
2838         int intPrevValue = 5;
2839         int intPref = 0;                        
2840         int intType = 0;
2841         long ListCtrlIndex;
2842         
2843         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2844         
2845         intPrevValue = 4;
2846         
2847         PropertyType PropType = PROPERTY_NONE;
2848                 
2849         // Look for type before continuing.
2850         
2851         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2852         
2853         // Setup the pointers.
2854         
2855         std::map<int, wxString> *WebsiteList = NULL;
2856         std::map<int, wxString> *WebsiteListAltID = NULL;
2857         std::map<int, wxString> *WebsiteListPID = NULL;
2858         std::map<int, wxString> *WebsiteListType = NULL;
2859         std::map<int, wxString> *WebsiteListTokens = NULL;
2860         std::map<int, wxString> *WebsiteListMediatype = NULL;
2861         std::map<int, int> *WebsiteListPref = NULL;
2862         
2863         // Setup blank lines for later on.
2864         
2865         switch(PropType){
2866                 case PROPERTY_NONE:
2867                         WebsiteList = &GeneralWebsiteList;
2868                         WebsiteListType = &GeneralWebsiteListType;
2869                         WebsiteListAltID = &GeneralWebsiteListAltID;
2870                         WebsiteListPID = &GeneralWebsiteListPID;
2871                         WebsiteListTokens = &GeneralWebsiteListTokens;
2872                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2873                         WebsiteListPref = &GeneralWebsiteListPref;      
2874                         break;
2875                 case PROPERTY_HOME:
2876                         WebsiteList = &HomeWebsiteList;
2877                         WebsiteListType = &HomeWebsiteListType;
2878                         WebsiteListAltID = &HomeWebsiteListAltID;
2879                         WebsiteListPID = &HomeWebsiteListPID;
2880                         WebsiteListTokens = &HomeWebsiteListTokens;
2881                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2882                         WebsiteListPref = &HomeWebsiteListPref; 
2883                         break;
2884                 case PROPERTY_WORK:
2885                         WebsiteList = &BusinessWebsiteList;
2886                         WebsiteListType = &BusinessWebsiteListType;
2887                         WebsiteListAltID = &BusinessWebsiteListAltID;
2888                         WebsiteListPID = &BusinessWebsiteListPID;
2889                         WebsiteListTokens = &BusinessWebsiteListTokens;
2890                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2891                         WebsiteListPref = &BusinessWebsiteListPref;
2892                         break;
2893         }
2894         
2895         intPrevValue = 4;
2896         
2897         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2898         intiter != SplitPoints.end(); ++intiter){
2899         
2900                 SLiter = SplitLength.find(intiter->first);
2901         
2902                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2903                 
2904                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2905                 PropertyName = PropertyElement.GetNextToken();                          
2906                 PropertyValue = PropertyElement.GetNextToken();
2907                 
2908                 intPrevValue = intiter->second;
2909                 
2910                 // Process properties.
2911                 
2912                 size_t intPropertyValueLen = PropertyValue.Len();
2913                 
2914                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2915                         
2916                         PropertyValue.Trim();
2917                         PropertyValue.RemoveLast();
2918                         
2919                 }                               
2920                 
2921                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2922                         
2923                         PropertyValue.Remove(0, 1);
2924                         
2925                 }
2926                 
2927                 CaptureString(&PropertyValue, FALSE);
2928                 
2929                 if (PropertyName == wxT("ALTID")){
2931                         WebsiteListAltID->erase(*URLCount);
2932                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
2933                 
2934                 } else if (PropertyName == wxT("PID")){
2936                         WebsiteListPID->erase(*URLCount);
2937                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
2938                         
2939                 } else if (PropertyName == wxT("PREF")){
2940                         
2941                         int PriorityNumber = 0;
2942                         bool ValidNumber = TRUE;
2943                         
2944                         try{
2945                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2946                         }
2947                         
2948                         catch(std::invalid_argument &e){
2949                                 ValidNumber = FALSE;
2950                         }
2952                         if (ValidNumber == TRUE){
2954                                 WebsiteListPref->erase(*URLCount);
2955                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
2957                         }
2958                                         
2959                 } else if (PropertyName == wxT("MEDIATYPE")){
2960                 
2961                         WebsiteListMediatype->erase(*URLCount);
2962                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
2963                 
2964                 } else {
2965                 
2966                         // Something else we don't know about so append
2967                         // to the tokens variable.
2968                 
2969                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2970                 
2971                                 if (FirstToken == TRUE){
2972                         
2973                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2974                                         FirstToken = FALSE;
2975                         
2976                                 } else {
2977                         
2978                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2979                         
2980                                 }
2981                 
2982                         }
2983                 
2984                 }
2985         
2986         }
2987         
2988         // Add the data to the General/Home/Work address variables.
2989         
2990         CaptureString(&PropertySeg2, FALSE);
2991                         
2992         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2993         
2994         if (!PropertyTokens.IsEmpty()){
2995         
2996                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2997                         
2998         }
2999         
3002 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3004         std::map<int, int> SplitPoints;
3005         std::map<int, int> SplitLength;
3006         std::map<int, int>::iterator SLiter;                    
3007         wxString PropertyData;
3008         wxString PropertyName;
3009         wxString PropertyValue;
3010         wxString PropertyTokens;
3011         bool FirstToken = TRUE;
3012         int intPrevValue = 7;
3013         int intPref = 0;                        
3014         int intType = 0;
3015         long ListCtrlIndex;
3016         
3017         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3018         
3019         intPrevValue = 6;
3020         
3021         PropertyType PropType = PROPERTY_NONE;
3022                 
3023         // Look for type before continuing.
3024         
3025         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3026         
3027         // Setup the pointers.
3028         
3029         std::map<int, wxString> *TitleList = NULL;
3030         std::map<int, wxString> *TitleListAltID = NULL;
3031         std::map<int, wxString> *TitleListPID = NULL;
3032         std::map<int, wxString> *TitleListType = NULL;
3033         std::map<int, wxString> *TitleListTokens = NULL;
3034         std::map<int, wxString> *TitleListLanguage = NULL;
3035         std::map<int, int> *TitleListPref = NULL;
3036         
3037         // Setup blank lines for later on.
3038         
3039         switch(PropType){
3040                 case PROPERTY_NONE:
3041                         TitleList = &GeneralTitleList;
3042                         TitleListType = &GeneralTitleListType;
3043                         TitleListAltID = &GeneralTitleListAltID;
3044                         TitleListPID = &GeneralTitleListPID;
3045                         TitleListTokens = &GeneralTitleListTokens;
3046                         TitleListLanguage = &GeneralTitleListLanguage;
3047                         TitleListPref = &GeneralTitleListPref;  
3048                         break;
3049                 case PROPERTY_HOME:
3050                         TitleList = &HomeTitleList;
3051                         TitleListType = &HomeTitleListType;
3052                         TitleListAltID = &HomeTitleListAltID;
3053                         TitleListPID = &HomeTitleListPID;
3054                         TitleListTokens = &HomeTitleListTokens;
3055                         TitleListLanguage = &HomeTitleListLanguage;
3056                         TitleListPref = &HomeTitleListPref;     
3057                         break;
3058                 case PROPERTY_WORK:
3059                         TitleList = &BusinessTitleList;
3060                         TitleListType = &BusinessTitleListType;
3061                         TitleListAltID = &BusinessTitleListAltID;
3062                         TitleListPID = &BusinessTitleListPID;
3063                         TitleListTokens = &BusinessTitleListTokens;
3064                         TitleListLanguage = &BusinessTitleListLanguage; 
3065                         TitleListPref = &BusinessTitleListPref;
3066                         break;
3067         }
3069         intPrevValue = 6;
3070                 
3071         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3072         intiter != SplitPoints.end(); ++intiter){
3073         
3074                 SLiter = SplitLength.find(intiter->first);
3075         
3076                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3077                 
3078                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3079                 PropertyName = PropertyElement.GetNextToken();                          
3080                 PropertyValue = PropertyElement.GetNextToken();
3081                 
3082                 intPrevValue = intiter->second;
3083                 
3084                 // Process properties.
3085                 
3086                 size_t intPropertyValueLen = PropertyValue.Len();
3087                 
3088                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3089                         
3090                         PropertyValue.Trim();
3091                         PropertyValue.RemoveLast();
3092                         
3093                 }                               
3094                 
3095                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3096                         
3097                         PropertyValue.Remove(0, 1);
3098                         
3099                 }                               
3100                 
3101                 CaptureString(&PropertyValue, FALSE);
3102                 
3103                 if (PropertyName == wxT("ALTID")){
3104                 
3105                         TitleListAltID->erase(*TitleCount);
3106                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3107                 
3108                 } else if (PropertyName == wxT("PID")){
3110                         TitleListPID->erase(*TitleCount);
3111                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3112                 
3113                 } else if (PropertyName == wxT("PREF")){
3114                                 
3115                         int PriorityNumber = 0;
3116                         bool ValidNumber = TRUE;
3117                         
3118                         try{
3119                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3120                         }
3121                         
3122                         catch(std::invalid_argument &e){
3123                                 ValidNumber = FALSE;
3124                         }
3126                         if (ValidNumber == TRUE){
3128                                 TitleListPref->erase(*TitleCount);
3129                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3131                         }
3132                                         
3133                 } else if (PropertyName == wxT("LANGUAGE")){
3134                 
3135                         TitleListLanguage->erase(*TitleCount);
3136                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3137                 
3138                 } else {
3139                 
3140                         // Something else we don't know about so append
3141                         // to the tokens variable.
3142                 
3143                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3144                 
3145                                 if (FirstToken == TRUE){
3146                         
3147                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3148                                         FirstToken = FALSE;
3149                         
3150                                 } else {
3151                         
3152                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3153                         
3154                                 }
3155                 
3156                         }
3157                 
3158                 }
3159         
3160         }
3161         
3162         // Add the data to the General/Home/Work address variables.
3163         
3164         CaptureString(&PropertySeg2, FALSE);
3166         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3167         
3168         if (!PropertyTokens.IsEmpty()){
3169         
3170                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3171                         
3172         }
3176 void SplitValues(wxString *PropertyLine, 
3177         std::map<int,int> *SplitPoints, 
3178         std::map<int,int> *SplitLength, 
3179         int intSize){
3180         
3181         size_t intPropertyLen = PropertyLine->Len();
3182         int intSplitsFound = 0;
3183         int intSplitSize = 0;
3184         int intSplitSeek = 0;
3185         
3186         for (int i = intSize; i <= intPropertyLen; i++){
3188                 intSplitSize++;
3189         
3190                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
3191                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
3192            
3193                     if (intSplitsFound == 0){
3194             
3195                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
3196           
3197                     } else {
3198            
3199                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3200             
3201                     }
3202             
3203                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
3204             
3205                     intSplitsFound++;
3206                     intSplitSeek = i;
3207                     intSplitSize = 0;
3208             
3209                 }
3211         }
3213         if (intSplitsFound == 0){
3215                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
3216                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3218         } else {
3220                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3221                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
3223         }
3227 void CheckType(wxString *PropertySeg1, 
3228         std::map<int,int> *SplitPoints, 
3229         std::map<int,int> *SplitLength, 
3230         int *intPrevValue, 
3231         PropertyType *PropType){
3232         
3233         wxString PropertyData;
3234         wxString PropertyName;
3235         wxString PropertyValue;
3236         std::map<int,int>::iterator SLiter;
3237         
3238         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
3239         intiter != SplitPoints->end(); ++intiter){
3240         
3241                 SLiter = SplitLength->find(intiter->first);
3242         
3243                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
3244                 
3245                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3246                 PropertyName = PropertyElement.GetNextToken();                          
3247                 PropertyValue = PropertyElement.GetNextToken();
3248                 
3249                 *intPrevValue = intiter->second;
3250                 
3251                 if (PropertyName == wxT("TYPE")){
3252                                 
3253                         if (PropertyValue == wxT("work")){
3254                         
3255                                 *PropType = PROPERTY_WORK;
3256                                                         
3257                         } else if (PropertyValue == wxT("home")){
3259                                 *PropType = PROPERTY_HOME;
3260                                                         
3261                         } else {
3262                         
3263                                 *PropType = PROPERTY_NONE;
3264                         
3265                         }
3266                 
3267                         return;
3268                 
3269                 }
3270         
3271         }
3272         
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