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