Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added source code, headers and unit tests for the CLIENTPIDMAP vCard Property for...
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         if (!wxFileExists(Filename)){
24         
25                 return CONTACTLOAD_FILEMISSING;
26         
27         }
28         
29         wxFile ContactFile;
30         
31         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
32         
33                 return CONTACTLOAD_FILEERROR;
34         
35         }
36         
37         // Check that the vCard is a valid vCard 4.0 file.
39         vCard vCard4FormatCheck;
40         
41         vCard4FormatCheck.LoadFile(Filename);
42         
43         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
44         
45                 return CONTACTLOAD_FILEINVALIDFORMAT;
46         
47         }
49         // Check that the vCard meets the base specification.
50         
51         if (!vCard4FormatCheck.MeetBaseSpecification()){
52         
53                 return CONTACTLOAD_FILEBASESPECFAIL;
54         
55         }
56         
57         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
58         
59         std::map<int, wxString> ContactFileLines;
61         int ContactLineSeek = 0;
63         while (wSTContactFileLines.HasMoreTokens() == TRUE){
65                 wxString ContactLine = wSTContactFileLines.GetNextToken();
66                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
67                 ContactLineSeek++;              
68         
69         }
70         
71         wxString wxSPropertyNextLine;
72         
73         bool ExtraLineSeek = TRUE;
74         bool QuoteMode = FALSE;
75         bool PropertyFind = TRUE;
76         bool KindProcessed = FALSE;
77         bool NameProcessed = FALSE;
78         bool GenderProcessed = FALSE;
79         bool BirthdayProcessed = FALSE;
80         bool AnniversaryProcessed = FALSE;
81         bool UIDProcessed = FALSE;
82         bool RevisionProcessed = FALSE;
83         int ContactLineLen = 0;
84         int QuoteBreakPoint = 0;
85         int SourceCount = 0;
86         int GroupCount = 0;
87         int FNCount = 0;
88         int NicknameCount = 0;
89         int TimeZoneCount = 0;
90         int AddressCount = 0;
91         int EmailCount = 0;
92         int IMCount = 0;
93         int TelephoneCount = 0;
94         int LanguageCount = 0;
95         int GeographicCount = 0;
96         int RelatedCount = 0;
97         int URLCount = 0;
98         int TitleCount = 0;
99         int RoleCount = 0;
100         int OrganisationCount = 0;
101         int NoteCount = 0;
102         int CategoryCount = 0;
103         int PhotoCount = 0;
104         int LogoCount = 0;
105         int SoundCount = 0;
106         int CalendarCount = 0;
107         int CalendarAddressCount = 0;
108         int FreeBusyAddressCount = 0;
109         int KeyCount = 0;
110         int VendorCount = 0;
111         int XTokenCount = 0;
112         int XMLCount = 0;
113         int ClientPIDCount = 0;
114         wxString ContactLine;
115         wxString PropertyLine;
116         wxString PropertySeg1;
117         wxString PropertySeg2;
118         wxString PropertyNextLine;
119         wxString Property;
120         
121         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
122          iter != ContactFileLines.end(); ++iter){
124                 ExtraLineSeek = TRUE;
125                 QuoteMode = FALSE;
126                 PropertyFind = TRUE;
127                 ContactLineLen = 0;
128                 QuoteBreakPoint = 0;
129                 ContactLine.Clear();
130                 PropertyLine.Clear();
131                 PropertySeg1.Clear();
132                 PropertySeg2.Clear();
133                 Property.Clear();
134          
135                 ContactLine = iter->second;
136                 
137                 while (ExtraLineSeek == TRUE){
138                 
139                         // Check if there is extra data on the next line 
140                         // (indicated by space or tab at the start) and add data.
141                 
142                         iter++;
143                         
144                         if (iter == ContactFileLines.end()){
145                         
146                                 iter--;
147                                 break;
148                         
149                         }                       
150                 
151                         PropertyNextLine = iter->second;
152                 
153                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
154                 
155                                 PropertyNextLine.Remove(0, 1);
156                                 ContactLine.Append(PropertyNextLine);
157                 
158                         } else {
159                         
160                                 iter--;
161                                 ExtraLineSeek = FALSE;
162                         
163                         }
164                 
165                 }
167                 ContactLineLen = ContactLine.Len();
168                 
169                 // Make sure we are not in quotation mode.
170                 // Make sure colon does not have \ or \\ before it.
171                 
172                 for (int i = 0; i <= ContactLineLen; i++){
173                 
174                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
175                         
176                                 PropertyFind = FALSE;
177                         
178                         } else if (PropertyFind == TRUE){
179                         
180                                 Property.Append(ContactLine.Mid(i, 1));
181                         
182                         }               
183                 
184                         if (ContactLine.Mid(i, 1) == wxT("\"")){
185                         
186                                 if (QuoteMode == TRUE){
187                                 
188                                         QuoteMode = FALSE;
189                                 
190                                 } else {
191                         
192                                         QuoteMode = TRUE;
193                                         
194                                 }
195                         
196                         }
197                         
198                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
199                         
200                                 QuoteBreakPoint = i;
201                                 break;
202                         
203                         }
204                 
205                 }
206                 
207                 // Split that line at the point into two variables (ignore the colon).
208                 
209                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
211                 
212                  if (Property == wxT("KIND") && KindProcessed == FALSE){
213                                 
214                         ProcessKind(PropertySeg2);
215                 
216                 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
217                 
218                         UIDToken = PropertySeg2;
219                         UIDProcessed = TRUE;
220                 
221                 } else if (Property == wxT("SOURCE")){
222                 
223                         ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
224                         SourceCount++;
225                 
226                 } else if (Property == wxT("XML")){
227                 
228                         ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
229                         XMLCount++;
230                 
231                 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
232                 
233                         ProcessRevision(PropertySeg1, PropertySeg2);
234                         RevisionProcessed = TRUE;
235                 
236                 } else if (Property == wxT("MEMBER")){
238                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
239                         GroupCount++;   
240                 
241                 } else if (Property == wxT("FN")){
242                 
243                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
244                         FNCount++;
245                 
246                 } else if (Property == wxT("N") && NameProcessed == FALSE){
247                 
248                         ProcessN(PropertySeg1, PropertySeg2);
249                         NameProcessed = TRUE;
250                 
251                 } else if (Property == wxT("CLIENTPIDMAP")){
252                 
253                         ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
254                         ClientPIDCount++;
255                 
256                 } else if (Property == wxT("NICKNAME")){
257                                                 
258                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
259                         NicknameCount++;
260                         
261                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
262                 
263                         ProcessGender(PropertySeg1, PropertySeg2);
264                         GenderProcessed = TRUE;
265                 
266                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
267                 
268                         ProcessBirthday(PropertySeg1, PropertySeg2);
269                         BirthdayProcessed = TRUE;
270                 
271                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
272                 
273                         ProcessAnniversary(PropertySeg1, PropertySeg2);
274                         AnniversaryProcessed = TRUE;
275                 
276                 } else if (Property == wxT("TZ")){
277                 
278                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
279                         TimeZoneCount++;
280                 
281                 } else if (Property == wxT("ADR")){
282                 
283                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
284                         AddressCount++;
285                 
286                 } else if (Property == wxT("EMAIL")){
287                                         
288                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
289                         EmailCount++;
290                 
291                 } else if (Property == wxT("IMPP")){
292                 
293                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
294                         IMCount++;
295                         
296                 } else if (Property == wxT("TEL")){
297                                 
298                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
299                         TelephoneCount++;
300                 
301                 } else if (Property == wxT("LANG")){
302                 
303                         // See frmContactEditor-LoadLanguage.cpp
304                         
305                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
306                         LanguageCount++;
307                 
308                 } else if (Property == wxT("GEO")){
309                 
310                         // See frmContactEditor-LoadGeo.cpp
311                         
312                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
313                         GeographicCount++;
314                 
315                 } else if (Property == wxT("RELATED")){
316                         
317                         // See fromContactEditor-LoadRelated.cpp
318                         
319                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
320                         RelatedCount++;
321                         
322                 } else if (Property == wxT("URL")){
324                         // See frmContactEditor-LoadURL.cpp
325                 
326                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
327                         URLCount++;
328                 
329                 } else if (Property == wxT("TITLE")) {
330                 
331                         // See frmContactEditor-LoadTitle.cpp
332                         
333                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
334                         TitleCount++;
335                         
336                 } else if (Property == wxT("ROLE")) {
337                 
338                         // See frmContactEditor-LoadTitle.cpp
339                         
340                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
341                         RoleCount++;
342                         
343                 } else if (Property == wxT("ORG")) {
344                 
345                         // See frmContactEditor-LoadOrg.cpp
346                         
347                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
348                         OrganisationCount++;
349                         
350                 } else if (Property == wxT("NOTE")) {
352                         // See frmContactEditor-LoadNote.cpp
354                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
355                         NoteCount++;    
356                         
357                 } else if (Property == wxT("CATEGORIES")) {
358                 
359                         // See frmContactEditor-LoadCategory.cpp
360                 
361                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
362                         CategoryCount++;
363                         
364                 } else if (Property == wxT("PHOTO")) {
365                 
366                         // See frmContactEditor-LoadPhoto.cpp
367                         
368                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
369                         PhotoCount++;
371                 } else if (Property == wxT("LOGO")) {
372                 
373                         // See frmContactEditor-LoadPhoto.cpp
374                         
375                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
376                         LogoCount++;
378                 } else if (Property == wxT("LOGO")) {
379                 
380                         // See frmContactEditor-LoadPhoto.cpp
381                         
382                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
383                         LogoCount++;
385                 } else if (Property == wxT("SOUND")) {
386                 
387                         // See frmContactEditor-LoadSound.cpp
388                         
389                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
390                         SoundCount++;
391                         
392                 } else if (Property == wxT("CALURI")){
394                         // See frmContactEditor-LoadCalendar.cpp
395                         
396                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
397                         CalendarCount++;
398                 
399                 } else if (Property == wxT("CALADRURI")){
400                 
401                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402                         CalendarAddressCount++;
403                 
404                 } else if (Property == wxT("FBURL")){
406                         // See frmContactEditor-LoadCalendar.cpp
408                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409                         FreeBusyAddressCount++;
411                 } else if (Property == wxT("KEY")){
412                 
413                         // See frmContactEditor-LoadKey.cpp
414                         
415                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
416                         KeyCount++;
417                 
418                 } else if (Property.Mid(0, 3) == wxT("VND")){
419                 
420                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
421                         VendorCount++;
422                 
423                 } else if (Property.Mid(0, 2) == wxT("X-")){
424                         
425                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
427                         XTokenCount++;
428                 
429                 }
430                 
431         }
432         
433         return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439         if (KindType == wxT("individual")){
440                         
441                 ContactKind = CONTACTKIND_INDIVIDUAL;
442                         
443         } else if (KindType == wxT("group")){
444                         
445                 ContactKind = CONTACTKIND_GROUP;
446                         
447         } else if (KindType == wxT("org")){
448                         
449                 ContactKind = CONTACTKIND_ORGANISATION;
450                         
451         } else if (KindType == wxT("location")){
452                         
453                 ContactKind = CONTACTKIND_LOCATION;
454                         
455         } else {
456                         
457                 ContactKind = CONTACTKIND_NONE;                 
458         }
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464         size_t intPropertyLen = PropertySeg1.Len();
465         std::map<int, int> SplitPoints;
466         std::map<int, int> SplitLength;
467         std::map<int, int>::iterator SLiter;                    
468         wxString PropertyData;
469         wxString PropertyName;
470         wxString PropertyValue;
471         wxString PropertyTokens;
472         bool FirstToken = TRUE;
473         int intSplitsFound = 0;
474         int intSplitSize = 0;
475         int intPrevValue = 5;
476         int intPref = 0;                        
477         int intType = 0;
478         
479         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
480         
481         intPrevValue = 4;
483         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
484         intiter != SplitPoints.end(); ++intiter){
485         
486                 SLiter = SplitLength.find(intiter->first);
487         
488                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
489                 
490                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
491                 PropertyName = PropertyElement.GetNextToken();                          
492                 PropertyValue = PropertyElement.GetNextToken();
493                 
494                 intPrevValue = intiter->second;
495                 
496                 // Process properties.
497                 
498                 size_t intPropertyValueLen = PropertyValue.Len();
499                 
500                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
501                         
502                         PropertyValue.Trim();
503                         PropertyValue.RemoveLast();
504                         
505                 }                               
506                 
507                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
508                         
509                         PropertyValue.Remove(0, 1);
510                         
511                 }                       
512                 
513                 CaptureString(&PropertyValue, FALSE);
514                                                                 
515                 if (FirstToken == TRUE){
516                                 
517                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
518                         FirstToken = FALSE;
519                                 
520                 } else {
521                                 
522                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
523                                 
524                 }
525         
526         }       
527         
528         CaptureString(&PropertySeg2, FALSE);
529         
530         Revision = PropertySeg2;
531         
532         if (!PropertyTokens.IsEmpty()){
533         
534                 RevisionTokens = PropertyTokens;
535         
536         }
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543         size_t intPropertyLen = PropertySeg1.Len();
544         std::map<int, int> SplitPoints;
545         std::map<int, int> SplitLength;
546         std::map<int, int>::iterator SLiter;                    
547         wxString PropertyData;
548         wxString PropertyName;
549         wxString PropertyValue;
550         wxString PropertyTokens;
551         bool FirstToken = TRUE;
552         int intSplitsFound = 0;
553         int intSplitSize = 0;
554         int intPrevValue = 8;
555         int intPref = 0;                        
556         int intType = 0;
557         
558         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
559         
560         intPrevValue = 7;
561         
562         PropertyType PropType = PROPERTY_NONE;
563         
564         // Look for type before continuing.                     
566         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
568         intPrevValue = 7;
570         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
571         intiter != SplitPoints.end(); ++intiter){
572         
573                 SLiter = SplitLength.find(intiter->first);
574         
575                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
576                 
577                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
578                 PropertyName = PropertyElement.GetNextToken();                          
579                 PropertyValue = PropertyElement.GetNextToken();
580                 
581                 intPrevValue = intiter->second;
582                 
583                 // Process properties.
584                 
585                 size_t intPropertyValueLen = PropertyValue.Len();
586                 
587                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
588                         
589                         PropertyValue.Trim();
590                         PropertyValue.RemoveLast();
591                         
592                 }                               
593                 
594                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
595                         
596                         PropertyValue.Remove(0, 1);
597                         
598                 }                       
599                 
600                 CaptureString(&PropertyValue, FALSE);
601                 
602                 if (PropertyName == wxT("ALTID")){
604                         SourceListAltID.erase(*SourceCount);
605                         SourceListAltID.insert(std::make_pair(*SourceCount, PropertyValue));
606                 
607                 } else if (PropertyName == wxT("PID")){
609                         SourceListPID.erase(*SourceCount);
610                         SourceListPID.insert(std::make_pair(*SourceCount, PropertyValue));
611                 
612                 } else if (PropertyName == wxT("PREF")){
613                         
614                         int PriorityNumber = 0;
615                         bool ValidNumber = TRUE;
616                         
617                         try{
618                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
619                         }
620                         
621                         catch(std::invalid_argument &e){
622                                 ValidNumber = FALSE;
623                         }
625                         if (ValidNumber == TRUE){
627                                 SourceListPref.erase(*SourceCount);
628                                 SourceListPref.insert(std::make_pair(*SourceCount, PriorityNumber));
630                         }
631                 
632                 } else if (PropertyName == wxT("MEDIATYPE")){
633                 
634                         SourceListMediatype.erase(*SourceCount);
635                         SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
637                 } else {
638                 
639                         // Something else we don't know about so append
640                         // to the tokens variable.
641                         
642                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
643                         
644                                 if (FirstToken == TRUE){
645                                 
646                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
647                                         FirstToken = FALSE;
648                                 
649                                 } else {
650                                 
651                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
652                                 
653                                 }
654                         
655                         }
656                 
657                 }
658         
659         }       
660         
661         intPropertyLen = PropertySeg2.Len();
662         SplitPoints.clear();
663         SplitLength.clear();
664         intSplitsFound = 0;
665         intSplitSize = 0;
666         intPrevValue = 0;
667         
668         CaptureString(&PropertySeg2, FALSE);
669         
670         // Add the data to the General/Home/Work address variables.
671                 
672         switch(PropType){
673                 case PROPERTY_NONE:
674                         break;
675                 case PROPERTY_HOME:
676                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
677                         break;
678                 case PROPERTY_WORK:
679                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
680                         break;
681         }
682         
683         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
684         
685         if (!PropertyTokens.IsEmpty()){
686         
687                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
688         
689         }
693 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
695         std::map<int, int> SplitPoints;
696         std::map<int, int> SplitLength;
698         int intPrevValue = 5;
699         int intPref = 0;                        
700         int intType = 0;
701         
702         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
704         intPrevValue = 4;
705         
706         wxString PropertyName;
707         wxString PropertyValue;
708         wxString PropertyData;
709         wxString PropertyTokens;
710         std::map<int,int>::iterator SLiter;
711         bool FirstToken = TRUE;
712         
713         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
714         intiter != SplitPoints.end(); ++intiter){
715         
716                 SLiter = SplitLength.find(intiter->first);
717         
718                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
719                 
720                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
721                 PropertyName = PropertyElement.GetNextToken();                          
722                 PropertyValue = PropertyElement.GetNextToken();
723                 
724                 intPrevValue = intiter->second;
725                 
726                 CaptureString(&PropertyValue, FALSE);
727         
728                 if (PropertyName == wxT("ALTID")){
730                         XMLListAltID.erase(*XMLCount);
731                         XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
732                 
733                 }
734                 
735         }
737         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
741 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
743         std::map<int, int> SplitPoints;
744         std::map<int, int> SplitLength;
746         int intPrevValue = 8;
747         int intPref = 0;                        
748         int intType = 0;
749         
750         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
752         intPrevValue = 7;
753         
754         wxString PropertyName;
755         wxString PropertyValue;
756         wxString PropertyData;
757         wxString PropertyTokens;
758         std::map<int,int>::iterator SLiter;
759         bool FirstToken = TRUE;
760         
761         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
762         intiter != SplitPoints.end(); ++intiter){
763         
764                 SLiter = SplitLength.find(intiter->first);
765         
766                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
767                 
768                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
769                 PropertyName = PropertyElement.GetNextToken();                          
770                 PropertyValue = PropertyElement.GetNextToken();
771                 
772                 intPrevValue = intiter->second;
773                 
774                 CaptureString(&PropertyValue, FALSE);
775         
776                 if (PropertyName == wxT("ALTID")){
778                         GroupsListAltID.erase(*GroupCount);
779                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
780                 
781                 } else if (PropertyName == wxT("PID")){
783                         GroupsListPID.erase(*GroupCount);
784                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
785                 
786                 } else if (PropertyName == wxT("PREF")){
788                         int PriorityNumber = 0;
789                         bool ValidNumber = TRUE;
790                         
791                         try{
792                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
793                         }
794                         
795                         catch(std::invalid_argument &e){
796                                 ValidNumber = FALSE;
797                         }
799                         if (ValidNumber == TRUE){
801                                 GroupsListPref.erase(*GroupCount);
802                                 GroupsListPref.insert(std::make_pair(*GroupCount, PriorityNumber));
803                 
804                         }
805                 
806                 } else if (PropertyName == wxT("MEDIATYPE")){
808                         GroupsListMediaType.erase(*GroupCount);
809                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
810                 
811                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
812                         
813                         if (FirstToken == TRUE){
814                                 
815                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
816                                 FirstToken = FALSE;
817                                 
818                         } else {
819                         
820                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
821                                 
822                         }
823                         
824                 }
825                 
826         }
828         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
830         if (!PropertyTokens.IsEmpty()){
831         
832                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
833         
834         }
839 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
841         std::map<int, int> SplitPoints;
842         std::map<int, int> SplitLength;
844         int intPrevValue = 4;
845         int intPref = 0;                        
846         int intType = 0;
847         
848         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
850         intPrevValue = 3;
851         
852         wxString PropertyName;
853         wxString PropertyValue;
854         wxString PropertyData;
855         wxString PropertyTokens;
856         std::map<int,int>::iterator SLiter;
857         bool FirstToken = TRUE;
858         
859         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
860         intiter != SplitPoints.end(); ++intiter){
861         
862                 SLiter = SplitLength.find(intiter->first);
863         
864                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
865                 
866                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
867                 PropertyName = PropertyElement.GetNextToken();                          
868                 PropertyValue = PropertyElement.GetNextToken();
869                 
870                 intPrevValue = intiter->second;
871                 
872                 CaptureString(&PropertyValue, FALSE);
873                 
874                 if (PropertyName == wxT("TYPE")){
876                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
877                                 PropertyValue == wxT("work") ){
879                                 FullNamesListType.erase(*FNCount);
880                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
881                 
882                         }
883                 
884                 } else if (PropertyName == wxT("LANGUAGE")){
886                         FullNamesListLanguage.erase(*FNCount);
887                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
888                 
889                 } else if (PropertyName == wxT("ALTID")){
890                 
891                         FullNamesListAltID.erase(*FNCount);
892                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
893                 
894                 } else if (PropertyName == wxT("PID")){
896                         FullNamesListPID.erase(*FNCount);
897                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
898                 
899                 } else if (PropertyName == wxT("PREF")){
901                         int PriorityNumber = 0;
902                         bool ValidNumber = TRUE;
903                         
904                         try{
905                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
906                         }
907                         
908                         catch(std::invalid_argument &e){
909                                 ValidNumber = FALSE;
910                         }
912                         if (ValidNumber == TRUE){
914                                 FullNamesListPref.erase(*FNCount);
915                                 FullNamesListPref.insert(std::make_pair(*FNCount, PriorityNumber));
917                         }
918                 
919                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
920                         
921                         if (FirstToken == TRUE){
922                                 
923                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
924                                 FirstToken = FALSE;
925                                 
926                         } else {
927                         
928                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
929                                 
930                         }
931                         
932                 } 
933         
934         }
936         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
938         if (!PropertyTokens.IsEmpty()){
939         
940                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
941         
942         }
946 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
948         std::map<int, int> SplitPoints;
949         std::map<int, int> SplitLength;
951         int intPrevValue = 3;
952         int intPref = 0;                        
953         int intType = 0;
954         
955         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
956         
957         intPrevValue = 2;
958         
959         wxString PropertyName;
960         wxString PropertyValue;
961         wxString PropertyData;
962         wxString PropertyTokens;
963         std::map<int,int>::iterator SLiter;
964         bool FirstToken = TRUE;
965         
966         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
967         intiter != SplitPoints.end(); ++intiter){
968         
969                 SLiter = SplitLength.find(intiter->first);
970         
971                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
972                 
973                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
974                 PropertyName = PropertyElement.GetNextToken();                          
975                 PropertyValue = PropertyElement.GetNextToken();
976                 
977                 intPrevValue = intiter->second;
978                 
979                 CaptureString(&PropertyValue, FALSE);
980                 
981                 if (PropertyName == wxT("ALTID")){
983                         NameAltID = PropertyValue;
984                 
985                 } else if (PropertyName == wxT("LANGUAGE")){
986                 
987                         NameLanguage = PropertyValue;
988                 
989                 } else if (PropertyName == wxT("SORT-AS")){
990                 
991                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
992                                 PropertyValue.Len() >= 3){
993                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
994                         }
995                 
996                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
997                         
998                         if (FirstToken == TRUE){
999                                 
1000                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1001                                 FirstToken = FALSE;
1002                                 
1003                         } else {
1004                         
1005                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1006                                 
1007                         }
1008                         
1009                 }
1010         
1011         }
1012         
1013         // Split the name data.
1014         
1015         int intSplitSeek = 0;           
1016         int intSplitsFound = 0;
1017         int intSplitSize = 0;
1018         int intPropertyLen = PropertySeg2.Len();
1019         
1020         std::map<int,wxString> NameValues;
1021         intPrevValue = 0;                                       
1022         
1023         for (int i = 0; i <= intPropertyLen; i++){
1024         
1025                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1026                         
1027                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
1028                         
1029                         intSplitSeek = i;
1030                         intSplitSeek++;
1031                         
1032                         if (intSplitsFound == 4){
1033                         
1034                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
1035                                 break;
1036                         
1037                         }
1038                         
1039                         intSplitSize = 0;
1040                         continue;
1041         
1042                 }
1043                 
1044                 intSplitSize++;
1046         }
1047         
1048         // Split the data into several parts.
1049                         
1050         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
1051         iter != NameValues.end(); ++iter){
1052         
1053                 if (iter->first == 1){
1054                 
1055                         // Deal with family name.
1056                         
1057                         NameSurname = iter->second;
1058                 
1059                 } else if (iter->first == 2){
1060                 
1061                         // Deal with given names.
1062                         
1063                         NameForename = iter->second;
1064                 
1065                 } else if (iter->first == 3){
1066                 
1067                         // Deal with additional names.
1068                         
1069                         NameOtherNames = iter->second;
1070                 
1071                 } else if (iter->first == 4){
1072                 
1073                         // Deal with honorifix prefixes and suffixes.
1075                         NameTitle = iter->second;
1076                 
1077                         iter++;
1078                         
1079                         if (iter == NameValues.end()){
1080                         
1081                                 break;
1082                         
1083                         }
1084                 
1085                         NameSuffix = iter->second;
1086                 
1087                 }
1088         
1089         }
1090         
1091         // Add the name token data.
1092         
1093         if (!PropertyTokens.IsEmpty()){
1094         
1095                 NameTokens = PropertyTokens;
1096         
1097         }
1101 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1103         size_t intPropertyLen = PropertySeg1.Len();
1104         std::map<int, int> SplitPoints;
1105         std::map<int, int> SplitLength;
1106         std::map<int, int>::iterator SLiter;                    
1107         wxString PropertyData;
1108         wxString PropertyName;
1109         wxString PropertyValue;
1110         wxString PropertyTokens;
1111         bool FirstToken = TRUE;
1112         int intSplitsFound = 0;
1113         int intSplitSize = 0;
1114         int intPrevValue = 14;
1115         int intPref = 0;                        
1116         int intType = 0;
1117         
1118         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1119         
1120         intPrevValue = 13;
1122         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1123         intiter != SplitPoints.end(); ++intiter){
1124         
1125                 SLiter = SplitLength.find(intiter->first);
1126         
1127                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1128                 
1129                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1130                 PropertyName = PropertyElement.GetNextToken();                          
1131                 PropertyValue = PropertyElement.GetNextToken();
1132                 
1133                 intPrevValue = intiter->second;
1134                 
1135                 // Process properties.
1136                 
1137                 size_t intPropertyValueLen = PropertyValue.Len();
1138                 
1139                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1140                         
1141                         PropertyValue.Trim();
1142                         PropertyValue.RemoveLast();
1143                         
1144                 }                               
1145                 
1146                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1147                         
1148                         PropertyValue.Remove(0, 1);
1149                         
1150                 }                       
1151                 
1152                 CaptureString(&PropertyValue, FALSE);
1153                 
1154                 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1155                 
1156                         continue;
1157                 
1158                 }
1159                                                         
1160                 if (FirstToken == TRUE){
1161                                 
1162                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1163                         FirstToken = FALSE;
1164                                 
1165                 } else {
1166                                 
1167                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1168                                 
1169                 }
1170         
1171         }       
1172         
1173         CaptureString(&PropertySeg2, FALSE);
1174         
1175         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1176         
1177         if (!PropertyTokens.IsEmpty()){
1178         
1179                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1180         
1181         }
1185 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1187         std::map<int, int> SplitPoints;
1188         std::map<int, int> SplitLength;
1190         int intPrevValue = 10;
1191         int intPref = 0;                        
1192         
1193         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1194         
1195         intPrevValue = 9;
1196         
1197         PropertyType PropType = PROPERTY_NONE;
1198         
1199         // Look for type before continuing.
1200         
1201         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1202         
1203         intPrevValue = 9;
1204         
1205         std::map<int, wxString> *NicknamesList = NULL;
1206         std::map<int, wxString> *NicknamesListType = NULL;
1207         std::map<int, wxString> *NicknamesListLanguage = NULL;
1208         std::map<int, wxString> *NicknamesListAltID = NULL;
1209         std::map<int, wxString> *NicknamesListPID = NULL;
1210         std::map<int, wxString> *NicknamesListTokens = NULL;            
1211         std::map<int, int> *NicknamesListPref = NULL;
1212         
1213         switch(PropType){
1214                 case PROPERTY_NONE:
1215                         NicknamesList = &GeneralNicknamesList;
1216                         NicknamesListType = &GeneralNicknamesListType;
1217                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1218                         NicknamesListAltID = &GeneralNicknamesListAltID;
1219                         NicknamesListPID = &GeneralNicknamesListPID;
1220                         NicknamesListTokens = &GeneralNicknamesListTokens;
1221                         NicknamesListPref = &GeneralNicknamesListPref;
1222                         break;
1223                 case PROPERTY_HOME:
1224                         NicknamesList = &HomeNicknamesList;
1225                         NicknamesListType = &HomeNicknamesListType;
1226                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1227                         NicknamesListAltID = &HomeNicknamesListAltID;
1228                         NicknamesListPID = &HomeNicknamesListPID;
1229                         NicknamesListTokens = &HomeNicknamesListTokens;
1230                         NicknamesListPref = &HomeNicknamesListPref;
1231                         break;
1232                 case PROPERTY_WORK:
1233                         NicknamesList = &BusinessNicknamesList;
1234                         NicknamesListType = &BusinessNicknamesListType;
1235                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1236                         NicknamesListAltID = &BusinessNicknamesListAltID;
1237                         NicknamesListPID = &BusinessNicknamesListPID;
1238                         NicknamesListTokens = &BusinessNicknamesListTokens;
1239                         NicknamesListPref = &BusinessNicknamesListPref;
1240                         break;
1241         }
1242         
1243         std::map<int, int>::iterator SLiter;    
1244         wxString PropertyData;
1245         wxString PropertyName;
1246         wxString PropertyValue;
1247         wxString PropertyTokens;
1248         bool FirstToken = TRUE;
1249         
1250         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1251         intiter != SplitPoints.end(); ++intiter){
1252         
1253                 SLiter = SplitLength.find(intiter->first);
1254         
1255                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1256                 
1257                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1258                 PropertyName = PropertyElement.GetNextToken();                          
1259                 PropertyValue = PropertyElement.GetNextToken();
1260                 
1261                 intPrevValue = intiter->second;
1262                 
1263                 CaptureString(&PropertyValue, FALSE);
1264                 
1265                 if (PropertyName == wxT("ALTID")){
1267                         NicknamesListAltID->erase(*NicknameCount);
1268                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1269                 
1270                 } else if (PropertyName == wxT("PID")){
1272                         NicknamesListPID->erase(*NicknameCount);
1273                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
1275                 } else if (PropertyName == wxT("PREF")){
1277                         int PriorityNumber = 0;
1278                         bool ValidNumber = TRUE;
1279                         
1280                         try{
1281                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1282                         }
1283                         
1284                         catch(std::invalid_argument &e){
1285                                 ValidNumber = FALSE;
1286                         }
1288                         if (ValidNumber == TRUE){
1290                                 NicknamesListPref->erase(*NicknameCount);
1291                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1293                         }
1294                 
1295                 } else if (PropertyName == wxT("LANGUAGE")){
1297                         NicknamesListLanguage->erase(*NicknameCount);
1298                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
1300                 } else {
1301                 
1302                         // Something else we don't know about so append
1303                         // to the tokens variable.
1304                 
1305                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1306                 
1307                                 if (FirstToken == TRUE){
1308                         
1309                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1310                                         FirstToken = FALSE;
1311                         
1312                                 } else {
1313                         
1314                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1315                         
1316                                 }
1317                 
1318                         }
1319                 
1320                 }
1321                 
1322         }
1323         
1324         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1325         
1326         // Add the name token data.
1327         
1328         if (!PropertyTokens.IsEmpty()){
1329         
1330                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1331         
1332         }
1336 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1338         std::map<int, int> SplitPoints;
1339         std::map<int, int> SplitLength;
1340         std::map<int, int>::iterator SLiter;                    
1341         wxString PropertyData;
1342         wxString PropertyName;
1343         wxString PropertyValue;
1344         wxString PropertyTokens;
1345         bool FirstToken = TRUE;
1346         int intPrevValue = 8;
1348         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1350         intPrevValue = 7;                       
1351         
1352         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1353         intiter != SplitPoints.end(); ++intiter){
1354         
1355                 SLiter = SplitLength.find(intiter->first);
1356         
1357                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1358                 
1359                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1360                 PropertyName = PropertyElement.GetNextToken();                          
1361                 PropertyValue = PropertyElement.GetNextToken();
1362                 
1363                 intPrevValue = intiter->second;
1364                 
1365                 // Process properties.
1366                 
1367                 size_t intPropertyValueLen = PropertyValue.Len();
1368                 
1369                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1370                         
1371                         PropertyValue.Trim();
1372                         PropertyValue.RemoveLast();
1373                         
1374                 }                               
1375                 
1376                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1377                         
1378                         PropertyValue.Remove(0, 1);
1379                         
1380                 }                               
1381                 
1382                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
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                         }
1395                 }
1396         
1397         }       
1399         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1400         
1401         wxString GenderComponent;
1402         
1403         if (GenderData.CountTokens() >= 2){
1404         
1405                 Gender = GenderData.GetNextToken();
1406                 GenderDetails = GenderData.GetString();
1407         
1408                 CaptureString(&GenderDetails, FALSE);
1409                                                 
1410         } else {
1411         
1412                 Gender = GenderData.GetNextToken();
1413         
1414         }
1415         
1416         if (!PropertyTokens.IsEmpty()){
1417         
1418                 GenderTokens = PropertyTokens;
1419         
1420         }
1424 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1426         // Process date. Preserve the remainder in the string.
1428         std::map<int, int> SplitPoints;
1429         std::map<int, int> SplitLength;
1430         std::map<int, int>::iterator SLiter;                    
1431         wxString PropertyData;
1432         wxString PropertyName;
1433         wxString PropertyValue;
1434         wxString PropertyTokens;
1435         bool BirthdayText = FALSE;
1436         int intPrevValue = 6;
1438         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1440         intPrevValue = 5;
1442         // Look for type before continuing.
1444         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1445         intiter != SplitPoints.end(); ++intiter){
1447                 SLiter = SplitLength.find(intiter->first);
1449                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1450         
1451                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1452                 PropertyName = PropertyElement.GetNextToken();                          
1453                 PropertyValue = PropertyElement.GetNextToken();
1454         
1455                 intPrevValue = intiter->second;
1456         
1457                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1458         
1459                         CaptureString(&PropertySeg2, FALSE);
1460                         Birthday = PropertySeg2;
1461                         BirthdayText = TRUE;
1462         
1463                 }
1465         }
1467         // Setup blank lines for later on.
1468         
1469         intPrevValue = 5;
1470         bool FirstToken = TRUE;
1472         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1473         intiter != SplitPoints.end(); ++intiter){
1475                 SLiter = SplitLength.find(intiter->first);
1477                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1478         
1479                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1480                 PropertyName = PropertyElement.GetNextToken();                          
1481                 PropertyValue = PropertyElement.GetNextToken();
1482         
1483                 intPrevValue = intiter->second;
1484         
1485                 // Process properties.
1486         
1487                 CaptureString(&PropertyValue, FALSE);
1488         
1489                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1490                 
1491                         PropertyValue.Trim();
1492                         PropertyValue.RemoveLast();
1493                 
1494                 }                               
1495         
1496                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1497                 
1498                         PropertyValue.Remove(0, 1);
1499                 
1500                 }                               
1501         
1502                 if (PropertyName == wxT("ALTID")){
1504                         BirthdayAltID = PropertyValue;
1505         
1506                 } else if (PropertyName == wxT("CALSCALE")){
1507         
1508                         BirthdayCalScale = PropertyValue;
1509         
1510                 } else if (PropertyName != wxT("VALUE")) {
1511         
1512                         // Something else we don't know about so append
1513                         // to the tokens variable.
1514                 
1515                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1516                 
1517                                 if (FirstToken == TRUE){
1518         
1519                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1520                                         FirstToken = FALSE;
1521         
1522                                 } else {
1523         
1524                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1525         
1526                                 }
1527                                 
1528                         }
1529                         
1530                 }
1532         }       
1534         // Add the data to the variables and form.
1535         
1536         if (BirthdayText == FALSE){
1537         
1538                 Birthday = PropertySeg2;
1540         }
1541         
1542         if (!PropertyTokens.IsEmpty()){
1543         
1544                 BirthdayTokens = PropertyTokens;
1546         }
1550 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1552         // Process date. Preserve the remainder in the string.
1554         std::map<int, int> SplitPoints;
1555         std::map<int, int> SplitLength;
1556         std::map<int, int>::iterator SLiter;                    
1557         wxString PropertyData;
1558         wxString PropertyName;
1559         wxString PropertyValue;
1560         wxString PropertyTokens;
1561         bool AnniversaryText = FALSE;
1562         int intPrevValue = 13;
1564         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1566         intPrevValue = 12;
1568         // Look for type before continuing.
1570         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1571         intiter != SplitPoints.end(); ++intiter){
1573                 SLiter = SplitLength.find(intiter->first);
1575                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1576         
1577                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1578                 PropertyName = PropertyElement.GetNextToken();                          
1579                 PropertyValue = PropertyElement.GetNextToken();
1580         
1581                 intPrevValue = intiter->second;
1582         
1583                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1584         
1585                         CaptureString(&PropertySeg2, FALSE);
1586                         Anniversary = PropertySeg2;
1587                         AnniversaryText = TRUE;
1588         
1589                 }
1591         }
1593         // Setup blank lines for later on.
1594         
1595         intPrevValue = 12;
1596         bool FirstToken = TRUE;
1598         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1599         intiter != SplitPoints.end(); ++intiter){
1601                 SLiter = SplitLength.find(intiter->first);
1603                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1604         
1605                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1606                 PropertyName = PropertyElement.GetNextToken();                          
1607                 PropertyValue = PropertyElement.GetNextToken();
1608         
1609                 intPrevValue = intiter->second;
1610         
1611                 // Process properties.
1612         
1613                 CaptureString(&PropertyValue, FALSE);
1614         
1615                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1616                 
1617                         PropertyValue.Trim();
1618                         PropertyValue.RemoveLast();
1619                 
1620                 }                               
1621         
1622                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1623                 
1624                         PropertyValue.Remove(0, 1);
1625                 
1626                 }                               
1627         
1628                 if (PropertyName == wxT("ALTID")){
1630                         AnniversaryAltID = PropertyValue;
1631         
1632                 } else if (PropertyName == wxT("CALSCALE")){
1633         
1634                         AnniversaryCalScale = PropertyValue;
1635         
1636                 } else if (PropertyName != wxT("VALUE")) {
1637         
1638                         // Something else we don't know about so append
1639                         // to the tokens variable.
1640                 
1641                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1642                 
1643                                 if (FirstToken == TRUE){
1644         
1645                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1646                                         FirstToken = FALSE;
1647         
1648                                 } else {
1649         
1650                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1651         
1652                                 }
1653                                 
1654                         }
1655                         
1656                 }
1658         }       
1660         // Add the data to the variables and form.
1661         
1662         if (AnniversaryText == FALSE){
1663         
1664                 Anniversary = PropertySeg2;
1666         }
1667         
1668         if (!PropertyTokens.IsEmpty()){
1669         
1670                 AnniversaryTokens = PropertyTokens;
1672         }
1676 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1678         std::map<int, int> SplitPoints;
1679         std::map<int, int> SplitLength;
1681         int intPrevValue = 4;
1682         int intPref = 0;                        
1683         
1684         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1685         
1686         intPrevValue = 3;
1687         
1688         PropertyType PropType = PROPERTY_NONE;
1689         
1690         // Look for type before continuing.
1691         
1692         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1693         
1694         intPrevValue = 3;
1695         
1696         std::map<int, wxString> *TZList = NULL;
1697         std::map<int, wxString> *TZListType = NULL;
1698         std::map<int, wxString> *TZListMediatype = NULL;
1699         std::map<int, wxString> *TZListAltID = NULL;
1700         std::map<int, wxString> *TZListPID = NULL;
1701         std::map<int, wxString> *TZListTokens = NULL;           
1702         std::map<int, int> *TZListPref = NULL;
1703         
1704         switch(PropType){
1705                 case PROPERTY_NONE:
1706                         TZList = &GeneralTZList;
1707                         TZListType = &GeneralTZListType;
1708                         TZListMediatype = &GeneralTZListMediatype;
1709                         TZListAltID = &GeneralTZListAltID;
1710                         TZListPID = &GeneralTZListPID;
1711                         TZListTokens = &GeneralTZListTokens;
1712                         TZListPref = &GeneralTZListPref;
1713                         break;
1714                 case PROPERTY_HOME:
1715                         TZList = &HomeTZList;
1716                         TZListType = &HomeTZListType;
1717                         TZListMediatype = &HomeTZListMediatype;
1718                         TZListAltID = &HomeTZListAltID;
1719                         TZListPID = &HomeTZListPID;
1720                         TZListTokens = &HomeTZListTokens;
1721                         TZListPref = &HomeTZListPref;
1722                         break;
1723                 case PROPERTY_WORK:
1724                         TZList = &BusinessTZList;
1725                         TZListType = &BusinessTZListType;
1726                         TZListMediatype = &BusinessTZListMediatype;
1727                         TZListAltID = &BusinessTZListAltID;
1728                         TZListPID = &BusinessTZListPID;
1729                         TZListTokens = &BusinessTZListTokens;
1730                         TZListPref = &BusinessTZListPref;
1731                         break;
1732         }
1733         
1734         std::map<int, int>::iterator SLiter;    
1735         wxString PropertyData;
1736         wxString PropertyName;
1737         wxString PropertyValue;
1738         wxString PropertyTokens;
1739         bool FirstToken = TRUE;
1740         
1741         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1742         intiter != SplitPoints.end(); ++intiter){
1743         
1744                 SLiter = SplitLength.find(intiter->first);
1745         
1746                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1747                 
1748                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1749                 PropertyName = PropertyElement.GetNextToken();                          
1750                 PropertyValue = PropertyElement.GetNextToken();
1751                 
1752                 intPrevValue = intiter->second;
1753                 
1754                 CaptureString(&PropertyValue, FALSE);
1756                 if (PropertyName == wxT("ALTID")){
1758                         TZListAltID->erase(*TimeZoneCount);
1759                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1760                 
1761                 } else if (PropertyName == wxT("PID")){
1763                         TZListPID->erase(*TimeZoneCount);
1764                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1766                 } else if (PropertyName == wxT("PREF")){
1768                         int PriorityNumber = 0;
1769                         bool ValidNumber = TRUE;
1770                         
1771                         try{
1772                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1773                         }
1774                         
1775                         catch(std::invalid_argument &e){
1776                                 ValidNumber = FALSE;
1777                         }
1779                         if (ValidNumber == TRUE){
1781                                 TZListPref->erase(*TimeZoneCount);
1782                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1784                         }
1785                 
1786                 } else if (PropertyName == wxT("MEDIATYPE")){
1788                         TZListMediatype->erase(*TimeZoneCount);
1789                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1791                 } else {
1792                 
1793                         // Something else we don't know about so append
1794                         // to the tokens variable.
1795                 
1796                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1797                 
1798                                 if (FirstToken == TRUE){
1799                         
1800                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1801                                         FirstToken = FALSE;
1802                         
1803                                 } else {
1804                         
1805                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1806                         
1807                                 }
1808                 
1809                         }
1810                 
1811                 }
1812                 
1813         }
1814         
1815         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1816         
1817         // Add the name token data.
1818         
1819         if (!PropertyTokens.IsEmpty()){
1820         
1821                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1822         
1823         }
1828 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1830         size_t intPropertyLen = PropertySeg1.Len();
1831         std::map<int, int> SplitPoints;
1832         std::map<int, int> SplitLength;
1833         std::map<int, int>::iterator SLiter;                    
1834         wxString PropertyData;
1835         wxString PropertyName;
1836         wxString PropertyValue;
1837         wxString PropertyTokens;
1838         wxString AddressLabel;
1839         wxString AddressLang;
1840         wxString AddressAltID;
1841         wxString AddressPID;
1842         wxString AddressTokens;
1843         wxString AddressGeo;
1844         wxString AddressTimezone;
1845         wxString AddressType;
1846         wxString AddressMediatype;
1847         wxString AddressPOBox;
1848         wxString AddressExtended;
1849         wxString AddressStreet;
1850         wxString AddressLocality;
1851         wxString AddressCity;
1852         wxString AddressRegion;
1853         wxString AddressPostalCode;
1854         wxString AddressCountry;
1855         bool FirstToken = TRUE;                 
1856         int intSplitsFound = 0;
1857         int intSplitSize = 0;
1858         int intPrevValue = 5;
1859         int intPref = 0;                        
1860         int intType = 0;
1861         long ListCtrlIndex;
1862         
1863         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1864         
1865         intPrevValue = 4;
1866         
1867         PropertyType PropType = PROPERTY_NONE;
1868                 
1869         // Look for type before continuing.
1870         
1871         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1872         
1873         intPrevValue = 4;
1874         
1875         std::map<int, wxString> *AddressList = NULL;
1876         std::map<int, wxString> *AddressListTown = NULL;
1877         std::map<int, wxString> *AddressListCounty = NULL;
1878         std::map<int, wxString> *AddressListPostCode = NULL;
1879         std::map<int, wxString> *AddressListCountry = NULL;
1880         std::map<int, wxString> *AddressListLabel = NULL;
1881         std::map<int, wxString> *AddressListLang = NULL;                
1882         std::map<int, wxString> *AddressListAltID = NULL;
1883         std::map<int, wxString> *AddressListPID = NULL;
1884         std::map<int, wxString> *AddressListTokens = NULL;
1885         std::map<int, wxString> *AddressListGeo = NULL;
1886         std::map<int, wxString> *AddressListTimezone = NULL;            
1887         std::map<int, wxString> *AddressListType = NULL;
1888         std::map<int, wxString> *AddressListMediatype = NULL;
1889         std::map<int, int> *AddressListPref = NULL;
1891         switch(PropType){
1892                 case PROPERTY_NONE:
1893                         AddressList = &GeneralAddressList;
1894                         AddressListTown = &GeneralAddressListTown;
1895                         AddressListCounty = &GeneralAddressListCounty;
1896                         AddressListPostCode = &GeneralAddressListPostCode;
1897                         AddressListCountry = &GeneralAddressListCountry;
1898                         AddressListLabel = &GeneralAddressListLabel;
1899                         AddressListLang = &GeneralAddressListLang;              
1900                         AddressListAltID = &GeneralAddressListAltID;
1901                         AddressListPID = &GeneralAddressListPID;
1902                         AddressListTokens = &GeneralAddressListTokens;
1903                         AddressListGeo = &GeneralAddressListGeo;
1904                         AddressListTimezone = &GeneralAddressListTimezone;
1905                         AddressListType = &GeneralAddressListType;
1906                         AddressListMediatype = &GeneralAddressListMediatype;
1907                         AddressListPref = &GeneralAddressListPref;              
1908                         break;
1909                 case PROPERTY_HOME:
1910                         AddressList = &HomeAddressList;
1911                         AddressListTown = &HomeAddressListTown;
1912                         AddressListCounty = &HomeAddressListCounty;
1913                         AddressListPostCode = &HomeAddressListPostCode;
1914                         AddressListCountry = &HomeAddressListCountry;
1915                         AddressListLabel = &HomeAddressListLabel;
1916                         AddressListLang = &HomeAddressListLang;         
1917                         AddressListAltID = &HomeAddressListAltID;
1918                         AddressListPID = &HomeAddressListPID;
1919                         AddressListTokens = &HomeAddressListTokens;
1920                         AddressListGeo = &HomeAddressListGeo;
1921                         AddressListTimezone = &HomeAddressListTimezone;
1922                         AddressListType = &HomeAddressListType;
1923                         AddressListMediatype = &HomeAddressListMediatype;
1924                         AddressListPref = &HomeAddressListPref;
1925                         break;
1926                 case PROPERTY_WORK:
1927                         AddressList = &BusinessAddressList;
1928                         AddressListTown = &BusinessAddressListTown;
1929                         AddressListCounty = &BusinessAddressListCounty;
1930                         AddressListPostCode = &BusinessAddressListPostCode;
1931                         AddressListCountry = &BusinessAddressListCountry;
1932                         AddressListLabel = &BusinessAddressListLabel;
1933                         AddressListLang = &BusinessAddressListLang;             
1934                         AddressListAltID = &BusinessAddressListAltID;
1935                         AddressListPID = &BusinessAddressListPID;
1936                         AddressListTokens = &BusinessAddressListTokens;
1937                         AddressListGeo = &BusinessAddressListGeo;
1938                         AddressListTimezone = &BusinessAddressListTimezone;
1939                         AddressListType = &BusinessAddressListType;
1940                         AddressListMediatype = &BusinessAddressListMediatype;
1941                         AddressListPref = &BusinessAddressListPref;
1942                         break;
1943         }
1944         
1945         intPrevValue = 4;
1946         
1947         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1948         intiter != SplitPoints.end(); ++intiter){
1949         
1950                 SLiter = SplitLength.find(intiter->first);
1951         
1952                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1953                 
1954                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1955                 PropertyName = PropertyElement.GetNextToken();                          
1956                 PropertyValue = PropertyElement.GetNextToken();
1957                 
1958                 intPrevValue = intiter->second;
1959                 
1960                 CaptureString(&PropertyValue, FALSE);
1961                 
1962                 // Process properties.
1963                 
1964                 if (PropertyName == wxT("LABEL")){
1965                 
1966                         AddressListLabel->erase(*AddressCount);
1967                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1968                                 
1969                 } else if (PropertyName == wxT("LANGUAGE")){
1970                 
1971                         AddressListLang->erase(*AddressCount);
1972                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1973                 
1974                 } else if (PropertyName == wxT("ALTID")){
1976                         AddressListAltID->erase(*AddressCount);
1977                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1978                 
1979                 } else if (PropertyName == wxT("PID")){
1981                         AddressListPID->erase(*AddressCount);
1982                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1983                 
1984                 } else if (PropertyName == wxT("GEO")){
1985                 
1986                         AddressListGeo->erase(*AddressCount);
1987                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1988                 
1989                 } else if (PropertyName == wxT("TZ")){
1991                         AddressListTimezone->erase(*AddressCount);
1992                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1993                 
1994                 } else if (PropertyName == wxT("MEDIATYPE")){
1996                         AddressListMediatype->erase(*AddressCount);
1997                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1998                 
1999                 } else if (PropertyName == wxT("PREF")){
2000                         
2001                         int PriorityNumber = 0;
2002                         bool ValidNumber = TRUE;
2003                         
2004                         try{
2005                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2006                         }
2007                         
2008                         catch(std::invalid_argument &e){
2009                                 ValidNumber = FALSE;
2010                         }
2012                         if (ValidNumber == TRUE){
2014                                 AddressListPref->erase(*AddressCount);
2015                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
2017                         }
2018                 
2019                 } else {
2020                 
2021                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2022                         
2023                                 if (FirstToken == TRUE){
2024                                 
2025                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2026                                         FirstToken = FALSE;
2027                                 
2028                                 } else {
2029                                 
2030                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2031                                 
2032                                 }
2033                         
2034                         }
2035                 
2036                 }
2037         
2038         }                       
2039         
2040         // Split the address. 
2042         //std::map<int, int>::iterator SLiter;
2043         intPropertyLen = PropertySeg2.Len();
2044         SplitPoints.clear();
2045         SplitLength.clear();
2046         intSplitsFound = 0;
2047         intSplitSize = 0;
2048         intPrevValue = 0;
2049         
2050         for (int i = 0; i <= intPropertyLen; i++){
2052                 intSplitSize++;
2053         
2054                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2055         
2056                         intSplitsFound++;
2057                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2058                         
2059                         if (intSplitsFound == 6){ 
2060                         
2061                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2062                                 break; 
2063                                 
2064                         } else {
2065                         
2066                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2067                         
2068                         }
2069                         
2070                         intSplitSize = 0;                                       
2071         
2072                 }
2074         }
2075         
2076         // Split the data into several parts.                   
2077         
2078         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2079         intiter != SplitPoints.end(); ++intiter){
2080                         
2081                 if (intiter->first == 1){
2082                 
2083                         // Deal with PO Box.
2084                         
2085                         SLiter = SplitLength.find(1);
2086                                                                 
2087                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2088                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2089                         intPrevValue = intiter->second;
2090                 
2091                 } else if (intiter->first == 2){
2092                 
2093                         // Deal with extended address.
2094                         
2095                         SLiter = SplitLength.find(2);
2096                         
2097                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2098                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2099                         intPrevValue = intiter->second;
2100                 
2101                 } else if (intiter->first == 3){
2102                 
2103                         // Deal with street address.
2104                         
2105                         SLiter = SplitLength.find(3);
2106                                                                 
2107                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2108                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2109                         intPrevValue = intiter->second;
2110                 
2111                 } else if (intiter->first == 4){
2112                 
2113                         // Deal with locality
2115                         SLiter = SplitLength.find(4);
2116                         
2117                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2118                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2119                         intPrevValue = intiter->second;
2120                         
2121                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2122                 
2123                 } else if (intiter->first == 5){
2124                 
2125                         // Deal with region.
2127                         SLiter = SplitLength.find(5);
2128                         
2129                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2130                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2131                         intPrevValue = intiter->second;
2132                         
2133                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2134                 
2135                 } else if (intiter->first == 6){
2136                 
2137                         // Deal with post code.
2139                         SLiter = SplitLength.find(6);
2140                         
2141                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2142                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2143                         intPrevValue = intiter->second;
2144                         
2145                         // Deal with country.
2146                                                 
2147                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2148                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2149                         
2150                         break;
2151                 
2152                 }
2153         
2154         }       
2155         
2156         // Add the data to the General/Home/Work address variables.
2157         
2158         CaptureString(&AddressStreet, FALSE); 
2159         CaptureString(&AddressLocality, FALSE);
2160         CaptureString(&AddressRegion, FALSE);
2161         CaptureString(&AddressPostalCode, FALSE);
2162         CaptureString(&AddressCountry, FALSE);
2163                 
2164         if (!PropertyTokens.IsEmpty()){
2165         
2166                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2167         
2168         }
2170         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2171         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2172         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2173         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2174         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2176         switch(PropType){
2177                 case PROPERTY_NONE:
2178                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2179                         break;
2180                 case PROPERTY_HOME:
2181                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2182                         break;
2183                 case PROPERTY_WORK:
2184                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2185                         break;
2186         }
2187         
2188         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2192 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2194         std::map<int, int> SplitPoints;
2195         std::map<int, int> SplitLength;
2197         int intPrevValue = 7;
2198         int intPref = 0;                        
2199         
2200         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2201         
2202         intPrevValue = 6;
2203         
2204         PropertyType PropType = PROPERTY_NONE;
2205                 
2206         // Look for type before continuing.
2207         
2208         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2209         
2210         std::map<int, wxString> *EmailList = NULL;
2211         std::map<int, wxString> *EmailListType = NULL;
2212         std::map<int, wxString> *EmailListAltID = NULL;
2213         std::map<int, wxString> *EmailListPID = NULL;
2214         std::map<int, wxString> *EmailListTokens = NULL;                
2215         std::map<int, int> *EmailListPref = NULL;
2217         switch(PropType){
2218                 case PROPERTY_NONE:
2219                         EmailList = &GeneralEmailList;
2220                         EmailListType = &GeneralEmailListType;
2221                         EmailListAltID = &GeneralEmailListAltID;
2222                         EmailListPID = &GeneralEmailListPID;
2223                         EmailListTokens = &GeneralEmailListTokens;              
2224                         EmailListPref = &GeneralEmailListPref;  
2225                         break;
2226                 case PROPERTY_HOME:
2227                         EmailList = &HomeEmailList;
2228                         EmailListType = &HomeEmailListType;
2229                         EmailListAltID = &HomeEmailListAltID;
2230                         EmailListPID = &HomeEmailListPID;
2231                         EmailListTokens = &HomeEmailListTokens;         
2232                         EmailListPref = &HomeEmailListPref;     
2233                         break;
2234                 case PROPERTY_WORK:
2235                         EmailList = &BusinessEmailList;
2236                         EmailListType = &BusinessEmailListType;
2237                         EmailListAltID = &BusinessEmailListAltID;
2238                         EmailListPID = &BusinessEmailListPID;
2239                         EmailListTokens = &BusinessEmailListTokens;             
2240                         EmailListPref = &BusinessEmailListPref; 
2241                         break;
2242         }
2243         
2244         intPrevValue = 6;
2245         
2246         std::map<int,int>::iterator SLiter;
2247         wxString PropertyData;
2248         wxString PropertyName;
2249         wxString PropertyValue;
2250         wxString PropertyTokens;
2251         bool FirstToken = TRUE;
2252         
2253         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2254         intiter != SplitPoints.end(); ++intiter){
2255         
2256                 SLiter = SplitLength.find(intiter->first);
2257         
2258                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2259                 
2260                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2261                 PropertyName = PropertyElement.GetNextToken();                          
2262                 PropertyValue = PropertyElement.GetNextToken();
2263                 
2264                 intPrevValue = intiter->second;
2265                 
2266                 CaptureString(&PropertyValue, FALSE);
2267                 
2268                 // Process properties.
2269                 
2270                 if (PropertyName == wxT("ALTID")){
2272                         EmailListAltID->erase(*EmailCount);
2273                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2274                 
2275                 } else if (PropertyName == wxT("PID")){
2277                         EmailListPID->erase(*EmailCount);
2278                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2279                 
2280                 } else if (PropertyName == wxT("PREF")){
2281                         
2282                         int PriorityNumber = 0;
2283                         bool ValidNumber = TRUE;
2284                         
2285                         try{
2286                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2287                         }
2288                         
2289                         catch(std::invalid_argument &e){
2290                                 ValidNumber = FALSE;
2291                         }
2293                         if (ValidNumber == TRUE){
2295                                 EmailListPref->erase(*EmailCount);
2296                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2298                         }
2299                 
2300                 } else {
2301                 
2302                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2303                         
2304                                 if (FirstToken == TRUE){
2305                                 
2306                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2307                                         FirstToken = FALSE;
2308                                 
2309                                 } else {
2310                                 
2311                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2312                                 
2313                                 }
2314                         
2315                         }
2316                 
2317                 }
2318         
2319         }
2320         
2321         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2322         
2323         // Add the name token data.
2324         
2325         if (!PropertyTokens.IsEmpty()){
2326         
2327                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2328         
2329         }       
2334 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2336         std::map<int, int> SplitPoints;
2337         std::map<int, int> SplitLength;
2339         int intPrevValue = 6;
2340         int intPref = 0;                        
2341         
2342         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2343         
2344         intPrevValue = 5;
2345         
2346         PropertyType PropType = PROPERTY_NONE;
2347                 
2348         // Look for type before continuing.
2349         
2350         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2351         
2352         std::map<int, wxString> *IMList = NULL;
2353         std::map<int, wxString> *IMListType = NULL;
2354         std::map<int, wxString> *IMListAltID = NULL;
2355         std::map<int, wxString> *IMListPID = NULL;
2356         std::map<int, wxString> *IMListTokens = NULL;
2357         std::map<int, wxString> *IMListMediatype = NULL;        
2358         std::map<int, int> *IMListPref = NULL;
2360         switch(PropType){
2361                 case PROPERTY_NONE:
2362                         IMList = &GeneralIMList;
2363                         IMListType = &GeneralIMListType;
2364                         IMListAltID = &GeneralIMListAltID;
2365                         IMListPID = &GeneralIMListPID;
2366                         IMListTokens = &GeneralIMListTokens;
2367                         IMListMediatype = &GeneralIMListMediatype;
2368                         IMListPref = &GeneralIMListPref;        
2369                         break;
2370                 case PROPERTY_HOME:
2371                         IMList = &HomeIMList;
2372                         IMListType = &HomeIMListType;
2373                         IMListAltID = &HomeIMListAltID;
2374                         IMListPID = &HomeIMListPID;
2375                         IMListTokens = &HomeIMListTokens;
2376                         IMListMediatype = &HomeIMListMediatype;         
2377                         IMListPref = &HomeIMListPref;   
2378                         break;
2379                 case PROPERTY_WORK:
2380                         IMList = &BusinessIMList;
2381                         IMListType = &BusinessIMListType;
2382                         IMListAltID = &BusinessIMListAltID;
2383                         IMListPID = &BusinessIMListPID;
2384                         IMListTokens = &BusinessIMListTokens;   
2385                         IMListMediatype = &BusinessIMListMediatype;     
2386                         IMListPref = &BusinessIMListPref;       
2387                         break;
2388         }
2389         
2390         intPrevValue = 5;
2391         
2392         std::map<int,int>::iterator SLiter;
2393         wxString PropertyData;
2394         wxString PropertyName;
2395         wxString PropertyValue;
2396         wxString PropertyTokens;
2397         bool FirstToken = TRUE;
2398         
2399         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2400         intiter != SplitPoints.end(); ++intiter){
2401         
2402                 SLiter = SplitLength.find(intiter->first);
2403         
2404                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2405                 
2406                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2407                 PropertyName = PropertyElement.GetNextToken();                          
2408                 PropertyValue = PropertyElement.GetNextToken();
2409                 
2410                 intPrevValue = intiter->second;
2411                 
2412                 CaptureString(&PropertyValue, FALSE);
2413                 
2414                 // Process properties.
2415                 
2416                 if (PropertyName == wxT("ALTID")){
2418                         IMListAltID->erase(*IMCount);
2419                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2420                 
2421                 } else if (PropertyName == wxT("PID")){
2423                         IMListPID->erase(*IMCount);
2424                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2425                 
2426                 } else if (PropertyName == wxT("MEDIATYPE")){
2428                         IMListMediatype->erase(*IMCount);
2429                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2430                 
2431                 } else if (PropertyName == wxT("PREF")){
2432                         
2433                         int PriorityNumber = 0;
2434                         bool ValidNumber = TRUE;
2435                         
2436                         try{
2437                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2438                         }
2439                         
2440                         catch(std::invalid_argument &e){
2441                                 ValidNumber = FALSE;
2442                         }
2444                         if (ValidNumber == TRUE){
2446                                 IMListPref->erase(*IMCount);
2447                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2449                         }
2450                 
2451                 } else {
2452                 
2453                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2454                         
2455                                 if (FirstToken == TRUE){
2456                                 
2457                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2458                                         FirstToken = FALSE;
2459                                 
2460                                 } else {
2461                                 
2462                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2463                                 
2464                                 }
2465                         
2466                         }
2467                 
2468                 }
2469         
2470         }
2471                 
2472         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2473         
2474         // Add the name token data.
2475         
2476         if (!PropertyTokens.IsEmpty()){
2477         
2478                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2479         
2480         }
2484 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2486         std::map<int, int> SplitPoints;
2487         std::map<int, int> SplitLength;
2488         std::map<int, int>::iterator SLiter;
2489         
2490         int intPref = 0;
2491         
2492         PropertyType PropType = PROPERTY_NONE;
2493                 
2494         // Look for type before continuing.
2495         
2496         wxString TelTypeUI;
2497         wxString TelTypeDetail;
2498         wxString PropertyData;
2499         wxString PropertyName;
2500         wxString PropertyValue;
2501         wxString PropertyTokens;
2502         
2503         std::map<int,int> TypeSplitPoints;
2504         std::map<int,int> TypeSplitLength;
2505         std::map<int,int>::iterator TSLiter;
2506         
2507         int intSplitSize = 0;
2508         int intSplitsFound = 0;
2509         int intSplitPoint = 0;
2510         int intType = 0;
2511         int intPrevValue = 5;
2512                 
2513         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2514         
2515         intPrevValue = 4;
2516         
2517         // Look for type before continuing.
2518         
2519         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2520         intiter != SplitPoints.end(); ++intiter){
2521         
2522                 SLiter = SplitLength.find(intiter->first);
2523         
2524                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2525                 
2526                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2527                 PropertyName = PropertyElement.GetNextToken();                          
2528                 PropertyValue = PropertyElement.GetNextToken();
2529                 
2530                 intPrevValue = intiter->second;
2532                 if (PropertyName == wxT("TYPE")){
2533                 
2534                         // Process each value in type and translate each
2535                         // part.
2536                 
2537                         // Strip out the quotes if they are there.
2538                 
2539                         size_t intPropertyValueLen = PropertyValue.Len();
2540                 
2541                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2542                         
2543                                 PropertyValue.Trim();
2544                                 PropertyValue.RemoveLast();
2545                         
2546                         }                               
2547                 
2548                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2549                         
2550                                 PropertyValue.Remove(0, 1);
2551                         
2552                         }
2553                         
2554                         TelTypeDetail = PropertyValue;
2555                         
2556                         intSplitSize = 0;
2557                         intSplitsFound = 0;
2558                         intSplitPoint = 0;
2559                         
2560                         for (int i = 0; i <= intPropertyValueLen; i++){
2561         
2562                                 intSplitSize++;
2563         
2564                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2565         
2566                                         if (intSplitsFound == 0){
2568                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2569                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2570                         
2571                                         } else {
2572                         
2573                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2574                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2575                         
2576                                         }                       
2578                                         intSplitsFound++;
2579                                         i++;
2580                                         intSplitPoint = i;
2581                                         intSplitSize = 0;
2582         
2583                                 }
2584         
2585                         }
2586                         
2587                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2588                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2589                 
2590                         int intTypeSeek = 0;
2591                 
2592                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2593                         typeiter != TypeSplitPoints.end(); ++typeiter){
2594                         
2595                                 wxString TypePropertyName;
2596                                 
2597                                 TSLiter = TypeSplitLength.find(typeiter->first);
2598                                 
2599                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2600                                 
2601                                 if (intTypeSeek == 0){
2602                                 
2603                                 
2604                                 } else {
2605                                                                                 
2606                                         TelTypeUI.Append(wxT(","));                                                     
2607                                 
2608                                 }
2609                         
2610                                 if (TypePropertyName == wxT("home")){
2611                                 
2612                                         PropType = PROPERTY_HOME;
2613                                 
2614                                 } else if (TypePropertyName == wxT("work")){
2615                                 
2616                                         PropType = PROPERTY_WORK;
2617                                                                         
2618                                 }
2619                                 
2620                                 
2621                                 if (TypePropertyName == wxT("text")){
2622                                 
2623                                         TelTypeUI.Append(_("text"));
2624                                         intTypeSeek++;
2625                                 
2626                                 } else if (TypePropertyName == wxT("voice")){
2627                                 
2628                                         TelTypeUI.Append(_("voice"));
2629                                         intTypeSeek++;
2630                                 
2631                                 } else if (TypePropertyName == wxT("fax")){
2632                                 
2633                                         TelTypeUI.Append(_("fax"));
2634                                         intTypeSeek++;
2635                                 
2636                                 } else if (TypePropertyName == wxT("cell")){
2637                                 
2638                                         TelTypeUI.Append(_("mobile"));
2639                                         intTypeSeek++;
2640                                 
2641                                 } else if (TypePropertyName == wxT("video")){
2642                                 
2643                                         TelTypeUI.Append(_("video"));
2644                                         intTypeSeek++;
2645                                 
2646                                 } else if (TypePropertyName == wxT("pager")){
2647                                 
2648                                         TelTypeUI.Append(_("pager"));
2649                                         intTypeSeek++;
2650                                 
2651                                 } else if (TypePropertyName == wxT("textphone")){
2652                                 
2653                                         TelTypeUI.Append(_("textphone"));
2654                                         intTypeSeek++;
2655                                 
2656                                 }
2657                         
2658                         }
2659                 
2660                 }
2661                 
2662         }
2663         
2664         std::map<int, wxString> *TelephoneList = NULL;
2665         std::map<int, wxString> *TelephoneListType = NULL;
2666         std::map<int, wxString> *TelephoneListAltID = NULL;
2667         std::map<int, wxString> *TelephoneListPID = NULL;
2668         std::map<int, wxString> *TelephoneListTokens = NULL;
2669         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2670         std::map<int, int> *TelephoneListPref = NULL;
2672         switch(PropType){
2673                 case PROPERTY_NONE:
2674                         TelephoneList = &GeneralTelephoneList;
2675                         TelephoneListType = &GeneralTelephoneListType;
2676                         TelephoneListAltID = &GeneralTelephoneListAltID;
2677                         TelephoneListPID = &GeneralTelephoneListPID;
2678                         TelephoneListTokens = &GeneralTelephoneListTokens;
2679                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2680                         TelephoneListPref = &GeneralTelephoneListPref;  
2681                         break;
2682                 case PROPERTY_HOME:
2683                         TelephoneList = &HomeTelephoneList;
2684                         TelephoneListType = &HomeTelephoneListType;
2685                         TelephoneListAltID = &HomeTelephoneListAltID;
2686                         TelephoneListPID = &HomeTelephoneListPID;
2687                         TelephoneListTokens = &HomeTelephoneListTokens;
2688                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2689                         TelephoneListPref = &HomeTelephoneListPref;     
2690                         break;
2691                 case PROPERTY_WORK:
2692                         TelephoneList = &BusinessTelephoneList;
2693                         TelephoneListType = &BusinessTelephoneListType;
2694                         TelephoneListAltID = &BusinessTelephoneListAltID;
2695                         TelephoneListPID = &BusinessTelephoneListPID;
2696                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2697                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2698                         TelephoneListPref = &BusinessTelephoneListPref; 
2699                         break;
2700         }
2701                 
2702         // Process the properties.
2703         
2704         bool FirstToken = TRUE;
2705         
2706         intPrevValue = 5;
2707         SplitPoints.clear();
2708         SplitLength.clear();
2710         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2712         intPrevValue = 4;
2713         
2714         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2715         intiter != SplitPoints.end(); ++intiter){
2716         
2717                 SLiter = SplitLength.find(intiter->first);
2718         
2719                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2720                 
2721                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2722                 PropertyName = PropertyElement.GetNextToken();                          
2723                 PropertyValue = PropertyElement.GetNextToken();
2724                 
2725                 intPrevValue = intiter->second;
2726                 
2727                 CaptureString(&PropertyValue, FALSE);
2728                 
2729                 // Process properties.
2730                 
2731                 if (PropertyName == wxT("ALTID")){
2733                         TelephoneListAltID->erase(*TelephoneCount);
2734                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2735                 
2736                 } else if (PropertyName == wxT("PID")){
2738                         TelephoneListPID->erase(*TelephoneCount);
2739                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2740                 
2741                 } else if (PropertyName == wxT("PREF")){
2742                         
2743                         int PriorityNumber = 0;
2744                         bool ValidNumber = TRUE;
2745                         
2746                         try{
2747                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2748                         }
2749                         
2750                         catch(std::invalid_argument &e){
2751                                 ValidNumber = FALSE;
2752                         }
2754                         if (ValidNumber == TRUE){
2756                                 TelephoneListPref->erase(*TelephoneCount);
2757                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2759                         }
2760                 
2761                 } else {
2762                 
2763                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2764                         
2765                                 if (FirstToken == TRUE){
2766                                 
2767                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2768                                         FirstToken = FALSE;
2769                                 
2770                                 } else {
2771                                 
2772                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2773                                 
2774                                 }
2775                         
2776                         }
2777                 
2778                 }
2779         
2780         }
2781                 
2782         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2783         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2784         
2785         // Add the name token data.
2786         
2787         if (!PropertyTokens.IsEmpty()){
2788         
2789                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2790         
2791         }
2795 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2797         std::map<int, int> SplitPoints;
2798         std::map<int, int> SplitLength;
2800         int intPrevValue = 6;
2801         int intPref = 0;                        
2802         
2803         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2804         
2805         intPrevValue = 5;
2806         
2807         PropertyType PropType = PROPERTY_NONE;
2808                 
2809         // Look for type before continuing.
2810         
2811         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2812         
2813         std::map<int, wxString> *LanguageList = NULL;
2814         std::map<int, wxString> *LanguageListType = NULL;
2815         std::map<int, wxString> *LanguageListAltID = NULL;
2816         std::map<int, wxString> *LanguageListPID = NULL;
2817         std::map<int, wxString> *LanguageListTokens = NULL;
2818         std::map<int, int> *LanguageListPref = NULL;
2820         switch(PropType){
2821                 case PROPERTY_NONE:
2822                         LanguageList = &GeneralLanguageList;
2823                         LanguageListType = &GeneralLanguageListType;
2824                         LanguageListAltID = &GeneralLanguageListAltID;
2825                         LanguageListPID = &GeneralLanguageListPID;
2826                         LanguageListTokens = &GeneralLanguageListTokens;
2827                         LanguageListPref = &GeneralLanguageListPref;    
2828                         break;
2829                 case PROPERTY_HOME:
2830                         LanguageList = &HomeLanguageList;
2831                         LanguageListType = &HomeLanguageListType;
2832                         LanguageListAltID = &HomeLanguageListAltID;
2833                         LanguageListPID = &HomeLanguageListPID;
2834                         LanguageListTokens = &HomeLanguageListTokens;   
2835                         LanguageListPref = &HomeLanguageListPref;       
2836                         break;
2837                 case PROPERTY_WORK:
2838                         LanguageList = &BusinessLanguageList;
2839                         LanguageListType = &BusinessLanguageListType;
2840                         LanguageListAltID = &BusinessLanguageListAltID;
2841                         LanguageListPID = &BusinessLanguageListPID;
2842                         LanguageListTokens = &BusinessLanguageListTokens;       
2843                         LanguageListPref = &BusinessLanguageListPref;
2844                         break;
2845         }
2846         
2847         intPrevValue = 5;
2848         
2849         std::map<int,int>::iterator SLiter;
2850         wxString PropertyData;
2851         wxString PropertyName;
2852         wxString PropertyValue;
2853         wxString PropertyTokens;
2854         bool FirstToken = TRUE;
2855         
2856         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2857         intiter != SplitPoints.end(); ++intiter){
2858         
2859                 SLiter = SplitLength.find(intiter->first);
2860         
2861                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2862                 
2863                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2864                 PropertyName = PropertyElement.GetNextToken();                          
2865                 PropertyValue = PropertyElement.GetNextToken();
2866                 
2867                 intPrevValue = intiter->second;
2868                 
2869                 CaptureString(&PropertyValue, FALSE);
2870                 
2871                 // Process properties.
2872                 
2873                 if (PropertyName == wxT("ALTID")){
2875                         LanguageListAltID->erase(*LanguageCount);
2876                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2877                 
2878                 } else if (PropertyName == wxT("PID")){
2880                         LanguageListPID->erase(*LanguageCount);
2881                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2882                 
2883                 } else if (PropertyName == wxT("PREF")){
2884                         
2885                         int PriorityNumber = 0;
2886                         bool ValidNumber = TRUE;
2887                         
2888                         try{
2889                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2890                         }
2891                         
2892                         catch(std::invalid_argument &e){
2893                                 ValidNumber = FALSE;
2894                         }
2896                         if (ValidNumber == TRUE){
2898                                 LanguageListPref->erase(*LanguageCount);
2899                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2901                         }
2902                 
2903                 } else {
2904                 
2905                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2906                         
2907                                 if (FirstToken == TRUE){
2908                                 
2909                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2910                                         FirstToken = FALSE;
2911                                 
2912                                 } else {
2913                                 
2914                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2915                                 
2916                                 }
2917                         
2918                         }
2919                 
2920                 }
2921         
2922         }
2923                 
2924         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2925         
2926         // Add the name token data.
2927         
2928         if (!PropertyTokens.IsEmpty()){
2929         
2930                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2931         
2932         }
2936 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2938         std::map<int, int> SplitPoints;
2939         std::map<int, int> SplitLength;
2941         int intPrevValue = 5;
2942         int intPref = 0;                        
2943         
2944         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2945         
2946         intPrevValue = 4;
2947         
2948         PropertyType PropType = PROPERTY_NONE;
2949                 
2950         // Look for type before continuing.
2951         
2952         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2953         
2954         std::map<int, wxString> *GeopositionList = NULL;
2955         std::map<int, wxString> *GeopositionListType = NULL;
2956         std::map<int, wxString> *GeopositionListAltID = NULL;
2957         std::map<int, wxString> *GeopositionListPID = NULL;
2958         std::map<int, wxString> *GeopositionListTokens = NULL;
2959         std::map<int, wxString> *GeopositionListMediatype = NULL;
2960         std::map<int, int> *GeopositionListPref = NULL;
2962         switch(PropType){
2963                 case PROPERTY_NONE:
2964                         GeopositionList = &GeneralGeographyList;
2965                         GeopositionListType = &GeneralGeographyListType;
2966                         GeopositionListAltID = &GeneralGeographyListAltID;
2967                         GeopositionListPID = &GeneralGeographyListPID;
2968                         GeopositionListTokens = &GeneralGeographyListTokens;
2969                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2970                         GeopositionListPref = &GeneralGeographyListPref;        
2971                         break;
2972                 case PROPERTY_HOME:
2973                         GeopositionList = &HomeGeographyList;
2974                         GeopositionListType = &HomeGeographyListType;
2975                         GeopositionListAltID = &HomeGeographyListAltID;
2976                         GeopositionListPID = &HomeGeographyListPID;
2977                         GeopositionListTokens = &HomeGeographyListTokens;
2978                         GeopositionListMediatype = &HomeGeographyListMediatype;
2979                         GeopositionListPref = &HomeGeographyListPref;   
2980                         break;
2981                 case PROPERTY_WORK:
2982                         GeopositionList = &BusinessGeographyList;
2983                         GeopositionListType = &BusinessGeographyListType;
2984                         GeopositionListAltID = &BusinessGeographyListAltID;
2985                         GeopositionListPID = &BusinessGeographyListPID;
2986                         GeopositionListTokens = &BusinessGeographyListTokens;
2987                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2988                         GeopositionListPref = &BusinessGeographyListPref;
2989                         break;
2990         }
2991         
2992         intPrevValue = 4;
2993         
2994         std::map<int,int>::iterator SLiter;
2995         wxString PropertyData;
2996         wxString PropertyName;
2997         wxString PropertyValue;
2998         wxString PropertyTokens;
2999         bool FirstToken = TRUE;
3000         
3001         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3002         intiter != SplitPoints.end(); ++intiter){
3003         
3004                 SLiter = SplitLength.find(intiter->first);
3005         
3006                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3007                 
3008                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3009                 PropertyName = PropertyElement.GetNextToken();                          
3010                 PropertyValue = PropertyElement.GetNextToken();
3011                 
3012                 intPrevValue = intiter->second;
3013                 
3014                 CaptureString(&PropertyValue, FALSE);
3015                 
3016                 // Process properties.
3017                 
3018                 if (PropertyName == wxT("ALTID")){
3020                         GeopositionListAltID->erase(*GeographicCount);
3021                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
3022                 
3023                 } else if (PropertyName == wxT("PID")){
3025                         GeopositionListPID->erase(*GeographicCount);
3026                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
3027                 
3028                 } else if (PropertyName == wxT("MEDIATYPE")){
3030                         GeopositionListMediatype->erase(*GeographicCount);
3031                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
3032                 
3033                 } else if (PropertyName == wxT("PREF")){
3034                         
3035                         int PriorityNumber = 0;
3036                         bool ValidNumber = TRUE;
3037                         
3038                         try{
3039                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3040                         }
3041                         
3042                         catch(std::invalid_argument &e){
3043                                 ValidNumber = FALSE;
3044                         }
3046                         if (ValidNumber == TRUE){
3048                                 GeopositionListPref->erase(*GeographicCount);
3049                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
3051                         }
3052                 
3053                 } else {
3054                 
3055                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3056                         
3057                                 if (FirstToken == TRUE){
3058                                 
3059                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3060                                         FirstToken = FALSE;
3061                                 
3062                                 } else {
3063                                 
3064                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3065                                 
3066                                 }
3067                         
3068                         }
3069                 
3070                 }
3071         
3072         }
3073                 
3074         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3075         
3076         // Add the name token data.
3077         
3078         if (!PropertyTokens.IsEmpty()){
3079         
3080                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3081         
3082         }
3086 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3088         size_t intPropertyLen = PropertySeg1.Len();
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         wxString RelatedType;
3097         wxString RelatedTypeOriginal;                   
3098         wxString RelatedName;
3099         bool FirstToken = TRUE;                 
3100         int intSplitsFound = 0;
3101         int intSplitSize = 0;
3102         int intPrevValue = 9;
3103         int intPref = 0;
3104         long ListCtrlIndex;
3105         
3106         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3107         
3108         intPrevValue = 8;
3109         
3110         // Look for type before continuing.
3111         
3112         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3113         intiter != SplitPoints.end(); ++intiter){
3114         
3115                 SLiter = SplitLength.find(intiter->first);
3116         
3117                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3118                 
3119                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3120                 PropertyName = PropertyElement.GetNextToken();                          
3121                 PropertyValue = PropertyElement.GetNextToken();
3122                 
3123                 intPrevValue = intiter->second;
3124                 
3125                 // Process these.
3126                 
3127                 RelatedTypeOriginal = PropertyValue;
3128                 
3129                 if (PropertyName == wxT("TYPE")){
3130                 
3131                         if (PropertyValue == wxT("contact")){
3133                                 RelatedType = _("Contact");
3135                         } else if (PropertyValue == wxT("acquaintance")){
3137                                 RelatedType = _("Acquaintance");
3139                         } else if (PropertyValue == wxT("friend")){
3141                                 RelatedType = _("Friend");
3143                         } else if (PropertyValue == wxT("met")){
3145                                 RelatedType = _("Met");
3147                         } else if (PropertyValue == wxT("co-worker")){
3149                                 RelatedType = _("Co-worker");
3151                         } else if (PropertyValue == wxT("colleague")){
3153                                 RelatedType = _("Colleague");
3155                         } else if (PropertyValue == wxT("co-resident")){
3157                                 RelatedType = _("Co-resident");
3159                         } else if (PropertyValue == wxT("neighbor")){
3161                                 RelatedType = _("Neighbour");
3163                         } else if (PropertyValue == wxT("child")){
3165                                 RelatedType = _("Child");
3167                         } else if (PropertyValue == wxT("parent")){
3169                                 RelatedType = _("Parent");
3171                         } else if (PropertyValue == wxT("sibling")){
3173                                 RelatedType = _("Sibling");
3175                         } else if (PropertyValue == wxT("spouse")){
3177                                 RelatedType = _("Spouse");
3179                         } else if (PropertyValue == wxT("kin")){
3181                                 RelatedType = _("Kin");
3183                         } else if (PropertyValue == wxT("muse")){
3185                                 RelatedType = _("Muse");
3187                         } else if (PropertyValue == wxT("crush")){
3189                                 RelatedType = _("Crush");
3191                         } else if (PropertyValue == wxT("date")){
3193                                 RelatedType = _("Date");
3195                         } else if (PropertyValue == wxT("sweetheart")){
3197                                 RelatedType = _("Sweetheart");
3199                         } else if (PropertyValue == wxT("me")){
3201                                 RelatedType = _("Me");
3203                         } else if (PropertyValue == wxT("agent")){
3205                                 RelatedType = _("Agent");
3207                         } else if (PropertyValue == wxT("emergency")){
3209                                 RelatedType = _("Emergency");
3211                         } else {
3213                                 RelatedType = PropertyValue;
3215                         }
3216                 
3217                 }
3218         
3219         }
3220         
3221         intPrevValue = 8;                       
3222         
3223         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3224         intiter != SplitPoints.end(); ++intiter){
3225         
3226                 SLiter = SplitLength.find(intiter->first);
3227         
3228                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3229                 
3230                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3231                 PropertyName = PropertyElement.GetNextToken();                          
3232                 PropertyValue = PropertyElement.GetNextToken();
3233                 
3234                 intPrevValue = intiter->second;
3235                 
3236                 // Process properties.
3237                 
3238                 size_t intPropertyValueLen = PropertyValue.Len();
3239                 
3240                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3241                         
3242                         PropertyValue.Trim();
3243                         PropertyValue.RemoveLast();
3244                         
3245                 }                               
3246                 
3247                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3248                         
3249                         PropertyValue.Remove(0, 1);
3250                         
3251                 }
3252                 
3253                 CaptureString(&PropertyValue, FALSE);
3254                         
3255                 if (PropertyName == wxT("ALTID")){
3257                         GeneralRelatedListAltID.erase(*RelatedCount);
3258                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3259                 
3260                 } else if (PropertyName == wxT("PID")){
3262                         GeneralRelatedListPID.erase(*RelatedCount);
3263                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3264                 
3265                 } else if (PropertyName == wxT("PREF")){
3266                         
3267                         int PriorityNumber = 0;
3268                         bool ValidNumber = TRUE;
3269                         
3270                         try{
3271                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3272                         }
3273                         
3274                         catch(std::invalid_argument &e){
3275                                 ValidNumber = FALSE;
3276                         }
3278                         if (ValidNumber == TRUE){
3280                                 GeneralRelatedListPref.erase(*RelatedCount);
3281                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3283                         }
3284                 
3285                 } else if (PropertyName == wxT("LANGUAGE")){
3286                 
3287                         GeneralRelatedListLanguage.erase(*RelatedCount);
3288                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3289                 
3290                 } else if (PropertyName != wxT("TYPE")) {
3291                 
3292                         // Something else we don't know about so append
3293                         // to the tokens variable.
3294                 
3295                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3296                 
3297                                 if (FirstToken == TRUE){
3298                         
3299                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3300                                         FirstToken = FALSE;
3301                         
3302                                 } else {
3303                         
3304                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3305                         
3306                                 }
3307                 
3308                         }
3309                 
3310                 }
3311         
3312         }                                       
3313         
3314         // Add the data to the General/Home/Work address variables.
3315                                 
3316         GeneralRelatedList.erase(*RelatedCount);
3317         GeneralRelatedListRelType.erase(*RelatedCount);
3318         GeneralRelatedListType.erase(*RelatedCount);
3319         GeneralRelatedListTokens.erase(*RelatedCount);
3320         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3321         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3322         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3323         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3327 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3329         std::map<int, int> SplitPoints;
3330         std::map<int, int> SplitLength;
3331         std::map<int, int>::iterator SLiter;                    
3332         wxString PropertyData;
3333         wxString PropertyName;
3334         wxString PropertyValue;
3335         wxString PropertyTokens;
3336         bool FirstToken = TRUE;
3337         int intPrevValue = 5;
3338         int intPref = 0;                        
3339         int intType = 0;
3340         long ListCtrlIndex;
3341         
3342         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3343         
3344         intPrevValue = 4;
3345         
3346         PropertyType PropType = PROPERTY_NONE;
3347                 
3348         // Look for type before continuing.
3349         
3350         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3351         
3352         // Setup the pointers.
3353         
3354         std::map<int, wxString> *WebsiteList = NULL;
3355         std::map<int, wxString> *WebsiteListAltID = NULL;
3356         std::map<int, wxString> *WebsiteListPID = NULL;
3357         std::map<int, wxString> *WebsiteListType = NULL;
3358         std::map<int, wxString> *WebsiteListTokens = NULL;
3359         std::map<int, wxString> *WebsiteListMediatype = NULL;
3360         std::map<int, int> *WebsiteListPref = NULL;
3361         
3362         // Setup blank lines for later on.
3363         
3364         switch(PropType){
3365                 case PROPERTY_NONE:
3366                         WebsiteList = &GeneralWebsiteList;
3367                         WebsiteListType = &GeneralWebsiteListType;
3368                         WebsiteListAltID = &GeneralWebsiteListAltID;
3369                         WebsiteListPID = &GeneralWebsiteListPID;
3370                         WebsiteListTokens = &GeneralWebsiteListTokens;
3371                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3372                         WebsiteListPref = &GeneralWebsiteListPref;      
3373                         break;
3374                 case PROPERTY_HOME:
3375                         WebsiteList = &HomeWebsiteList;
3376                         WebsiteListType = &HomeWebsiteListType;
3377                         WebsiteListAltID = &HomeWebsiteListAltID;
3378                         WebsiteListPID = &HomeWebsiteListPID;
3379                         WebsiteListTokens = &HomeWebsiteListTokens;
3380                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3381                         WebsiteListPref = &HomeWebsiteListPref; 
3382                         break;
3383                 case PROPERTY_WORK:
3384                         WebsiteList = &BusinessWebsiteList;
3385                         WebsiteListType = &BusinessWebsiteListType;
3386                         WebsiteListAltID = &BusinessWebsiteListAltID;
3387                         WebsiteListPID = &BusinessWebsiteListPID;
3388                         WebsiteListTokens = &BusinessWebsiteListTokens;
3389                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3390                         WebsiteListPref = &BusinessWebsiteListPref;
3391                         break;
3392         }
3393         
3394         intPrevValue = 4;
3395         
3396         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3397         intiter != SplitPoints.end(); ++intiter){
3398         
3399                 SLiter = SplitLength.find(intiter->first);
3400         
3401                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3402                 
3403                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3404                 PropertyName = PropertyElement.GetNextToken();                          
3405                 PropertyValue = PropertyElement.GetNextToken();
3406                 
3407                 intPrevValue = intiter->second;
3408                 
3409                 // Process properties.
3410                 
3411                 size_t intPropertyValueLen = PropertyValue.Len();
3412                 
3413                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3414                         
3415                         PropertyValue.Trim();
3416                         PropertyValue.RemoveLast();
3417                         
3418                 }                               
3419                 
3420                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3421                         
3422                         PropertyValue.Remove(0, 1);
3423                         
3424                 }
3425                 
3426                 CaptureString(&PropertyValue, FALSE);
3427                 
3428                 if (PropertyName == wxT("ALTID")){
3430                         WebsiteListAltID->erase(*URLCount);
3431                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3432                 
3433                 } else if (PropertyName == wxT("PID")){
3435                         WebsiteListPID->erase(*URLCount);
3436                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3437                         
3438                 } else if (PropertyName == wxT("PREF")){
3439                         
3440                         int PriorityNumber = 0;
3441                         bool ValidNumber = TRUE;
3442                         
3443                         try{
3444                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3445                         }
3446                         
3447                         catch(std::invalid_argument &e){
3448                                 ValidNumber = FALSE;
3449                         }
3451                         if (ValidNumber == TRUE){
3453                                 WebsiteListPref->erase(*URLCount);
3454                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3456                         }
3457                                         
3458                 } else if (PropertyName == wxT("MEDIATYPE")){
3459                 
3460                         WebsiteListMediatype->erase(*URLCount);
3461                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3462                 
3463                 } else {
3464                 
3465                         // Something else we don't know about so append
3466                         // to the tokens variable.
3467                 
3468                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3469                 
3470                                 if (FirstToken == TRUE){
3471                         
3472                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3473                                         FirstToken = FALSE;
3474                         
3475                                 } else {
3476                         
3477                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3478                         
3479                                 }
3480                 
3481                         }
3482                 
3483                 }
3484         
3485         }
3486         
3487         // Add the data to the General/Home/Work address variables.
3488         
3489         CaptureString(&PropertySeg2, FALSE);
3490                         
3491         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3492         
3493         if (!PropertyTokens.IsEmpty()){
3494         
3495                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3496                         
3497         }
3498         
3501 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3503         std::map<int, int> SplitPoints;
3504         std::map<int, int> SplitLength;
3505         std::map<int, int>::iterator SLiter;                    
3506         wxString PropertyData;
3507         wxString PropertyName;
3508         wxString PropertyValue;
3509         wxString PropertyTokens;
3510         bool FirstToken = TRUE;
3511         int intPrevValue = 7;
3512         int intPref = 0;                        
3513         int intType = 0;
3514         long ListCtrlIndex;
3515         
3516         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3517         
3518         intPrevValue = 6;
3519         
3520         PropertyType PropType = PROPERTY_NONE;
3521                 
3522         // Look for type before continuing.
3523         
3524         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3525         
3526         // Setup the pointers.
3527         
3528         std::map<int, wxString> *TitleList = NULL;
3529         std::map<int, wxString> *TitleListAltID = NULL;
3530         std::map<int, wxString> *TitleListPID = NULL;
3531         std::map<int, wxString> *TitleListType = NULL;
3532         std::map<int, wxString> *TitleListTokens = NULL;
3533         std::map<int, wxString> *TitleListLanguage = NULL;
3534         std::map<int, int> *TitleListPref = NULL;
3535         
3536         // Setup blank lines for later on.
3537         
3538         switch(PropType){
3539                 case PROPERTY_NONE:
3540                         TitleList = &GeneralTitleList;
3541                         TitleListType = &GeneralTitleListType;
3542                         TitleListAltID = &GeneralTitleListAltID;
3543                         TitleListPID = &GeneralTitleListPID;
3544                         TitleListTokens = &GeneralTitleListTokens;
3545                         TitleListLanguage = &GeneralTitleListLanguage;
3546                         TitleListPref = &GeneralTitleListPref;  
3547                         break;
3548                 case PROPERTY_HOME:
3549                         TitleList = &HomeTitleList;
3550                         TitleListType = &HomeTitleListType;
3551                         TitleListAltID = &HomeTitleListAltID;
3552                         TitleListPID = &HomeTitleListPID;
3553                         TitleListTokens = &HomeTitleListTokens;
3554                         TitleListLanguage = &HomeTitleListLanguage;
3555                         TitleListPref = &HomeTitleListPref;     
3556                         break;
3557                 case PROPERTY_WORK:
3558                         TitleList = &BusinessTitleList;
3559                         TitleListType = &BusinessTitleListType;
3560                         TitleListAltID = &BusinessTitleListAltID;
3561                         TitleListPID = &BusinessTitleListPID;
3562                         TitleListTokens = &BusinessTitleListTokens;
3563                         TitleListLanguage = &BusinessTitleListLanguage; 
3564                         TitleListPref = &BusinessTitleListPref;
3565                         break;
3566         }
3568         intPrevValue = 6;
3569                 
3570         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3571         intiter != SplitPoints.end(); ++intiter){
3572         
3573                 SLiter = SplitLength.find(intiter->first);
3574         
3575                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3576                 
3577                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3578                 PropertyName = PropertyElement.GetNextToken();                          
3579                 PropertyValue = PropertyElement.GetNextToken();
3580                 
3581                 intPrevValue = intiter->second;
3582                 
3583                 // Process properties.
3584                 
3585                 size_t intPropertyValueLen = PropertyValue.Len();
3586                 
3587                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3588                         
3589                         PropertyValue.Trim();
3590                         PropertyValue.RemoveLast();
3591                         
3592                 }                               
3593                 
3594                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3595                         
3596                         PropertyValue.Remove(0, 1);
3597                         
3598                 }                               
3599                 
3600                 CaptureString(&PropertyValue, FALSE);
3601                 
3602                 if (PropertyName == wxT("ALTID")){
3603                 
3604                         TitleListAltID->erase(*TitleCount);
3605                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3606                 
3607                 } else if (PropertyName == wxT("PID")){
3609                         TitleListPID->erase(*TitleCount);
3610                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3611                 
3612                 } else if (PropertyName == wxT("PREF")){
3613                                 
3614                         int PriorityNumber = 0;
3615                         bool ValidNumber = TRUE;
3616                         
3617                         try{
3618                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3619                         }
3620                         
3621                         catch(std::invalid_argument &e){
3622                                 ValidNumber = FALSE;
3623                         }
3625                         if (ValidNumber == TRUE){
3627                                 TitleListPref->erase(*TitleCount);
3628                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3630                         }
3631                                         
3632                 } else if (PropertyName == wxT("LANGUAGE")){
3633                 
3634                         TitleListLanguage->erase(*TitleCount);
3635                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3636                 
3637                 } else {
3638                 
3639                         // Something else we don't know about so append
3640                         // to the tokens variable.
3641                 
3642                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3643                 
3644                                 if (FirstToken == TRUE){
3645                         
3646                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3647                                         FirstToken = FALSE;
3648                         
3649                                 } else {
3650                         
3651                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3652                         
3653                                 }
3654                 
3655                         }
3656                 
3657                 }
3658         
3659         }
3660         
3661         // Add the data to the General/Home/Work address variables.
3662         
3663         CaptureString(&PropertySeg2, FALSE);
3665         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3666         
3667         if (!PropertyTokens.IsEmpty()){
3668         
3669                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3670                         
3671         }
3675 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3677         std::map<int, int> SplitPoints;
3678         std::map<int, int> SplitLength;
3679         std::map<int, int>::iterator SLiter;                    
3680         wxString PropertyData;
3681         wxString PropertyName;
3682         wxString PropertyValue;
3683         wxString PropertyTokens;
3684         bool FirstToken = TRUE;
3685         int intPrevValue = 6;
3686         int intPref = 0;                        
3687         int intType = 0;
3688         long ListCtrlIndex;
3689         
3690         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3691         
3692         intPrevValue = 5;
3693         
3694         PropertyType PropType = PROPERTY_NONE;
3695                 
3696         // Look for type before continuing.
3697         
3698         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3699         
3700         // Setup the pointers.
3701         
3702         std::map<int, wxString> *RoleList = NULL;
3703         std::map<int, wxString> *RoleListAltID = NULL;
3704         std::map<int, wxString> *RoleListPID = NULL;
3705         std::map<int, wxString> *RoleListType = NULL;
3706         std::map<int, wxString> *RoleListTokens = NULL;
3707         std::map<int, wxString> *RoleListLanguage = NULL;
3708         std::map<int, int> *RoleListPref = NULL;
3709         
3710         // Setup blank lines for later on.
3711         
3712         switch(PropType){
3713                 case PROPERTY_NONE:
3714                         RoleList = &GeneralRoleList;
3715                         RoleListType = &GeneralRoleListType;
3716                         RoleListAltID = &GeneralRoleListAltID;
3717                         RoleListPID = &GeneralRoleListPID;
3718                         RoleListTokens = &GeneralRoleListTokens;
3719                         RoleListLanguage = &GeneralRoleListLanguage;
3720                         RoleListPref = &GeneralRoleListPref;    
3721                         break;
3722                 case PROPERTY_HOME:
3723                         RoleList = &HomeRoleList;
3724                         RoleListType = &HomeRoleListType;
3725                         RoleListAltID = &HomeRoleListAltID;
3726                         RoleListPID = &HomeRoleListPID;
3727                         RoleListTokens = &HomeRoleListTokens;
3728                         RoleListLanguage = &HomeRoleListLanguage;
3729                         RoleListPref = &HomeRoleListPref;       
3730                         break;
3731                 case PROPERTY_WORK:
3732                         RoleList = &BusinessRoleList;
3733                         RoleListType = &BusinessRoleListType;
3734                         RoleListAltID = &BusinessRoleListAltID;
3735                         RoleListPID = &BusinessRoleListPID;
3736                         RoleListTokens = &BusinessRoleListTokens;
3737                         RoleListLanguage = &BusinessRoleListLanguage;   
3738                         RoleListPref = &BusinessRoleListPref;
3739                         break;
3740         }
3742         intPrevValue = 5;
3743                 
3744         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3745         intiter != SplitPoints.end(); ++intiter){
3746         
3747                 SLiter = SplitLength.find(intiter->first);
3748         
3749                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3750                 
3751                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3752                 PropertyName = PropertyElement.GetNextToken();                          
3753                 PropertyValue = PropertyElement.GetNextToken();
3754                 
3755                 intPrevValue = intiter->second;
3756                 
3757                 // Process properties.
3758                 
3759                 size_t intPropertyValueLen = PropertyValue.Len();
3760                 
3761                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3762                         
3763                         PropertyValue.Trim();
3764                         PropertyValue.RemoveLast();
3765                         
3766                 }                               
3767                 
3768                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3769                         
3770                         PropertyValue.Remove(0, 1);
3771                         
3772                 }                               
3773                 
3774                 CaptureString(&PropertyValue, FALSE);
3775                 
3776                 if (PropertyName == wxT("ALTID")){
3777                 
3778                         RoleListAltID->erase(*RoleCount);
3779                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3780                 
3781                 } else if (PropertyName == wxT("PID")){
3783                         RoleListPID->erase(*RoleCount);
3784                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3785                 
3786                 } else if (PropertyName == wxT("PREF")){
3787                                 
3788                         int PriorityNumber = 0;
3789                         bool ValidNumber = TRUE;
3790                         
3791                         try{
3792                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3793                         }
3794                         
3795                         catch(std::invalid_argument &e){
3796                                 ValidNumber = FALSE;
3797                         }
3799                         if (ValidNumber == TRUE){
3801                                 RoleListPref->erase(*RoleCount);
3802                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3804                         }
3805                                         
3806                 } else if (PropertyName == wxT("LANGUAGE")){
3807                 
3808                         RoleListLanguage->erase(*RoleCount);
3809                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3810                 
3811                 } else {
3812                 
3813                         // Something else we don't know about so append
3814                         // to the tokens variable.
3815                 
3816                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3817                 
3818                                 if (FirstToken == TRUE){
3819                         
3820                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3821                                         FirstToken = FALSE;
3822                         
3823                                 } else {
3824                         
3825                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3826                         
3827                                 }
3828                 
3829                         }
3830                 
3831                 }
3832         
3833         }
3834         
3835         // Add the data to the General/Home/Work address variables.
3836         
3837         CaptureString(&PropertySeg2, FALSE);
3839         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3840         
3841         if (!PropertyTokens.IsEmpty()){
3842         
3843                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3844                         
3845         }
3849 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3851         std::map<int, int> SplitPoints;
3852         std::map<int, int> SplitLength;
3853         std::map<int, int>::iterator SLiter;                    
3854         wxString PropertyData;
3855         wxString PropertyName;
3856         wxString PropertyValue;
3857         wxString PropertyTokens;
3858         bool FirstToken = TRUE;
3859         int intPrevValue = 5;
3860         int intPref = 0;                        
3861         int intType = 0;
3862         long ListCtrlIndex;
3863         
3864         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3865         
3866         intPrevValue = 4;
3867         
3868         PropertyType PropType = PROPERTY_NONE;
3869                 
3870         // Look for type before continuing.
3871         
3872         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3873         
3874         // Setup the pointers.
3875         
3876         std::map<int, wxString> *OrganisationsList = NULL;
3877         std::map<int, wxString> *OrganisationsListAltID = NULL;
3878         std::map<int, wxString> *OrganisationsListPID = NULL;
3879         std::map<int, wxString> *OrganisationsListType = NULL;
3880         std::map<int, wxString> *OrganisationsListTokens = NULL;
3881         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3882         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3883         std::map<int, int> *OrganisationsListPref = NULL;
3884         
3885         // Setup blank lines for later on.
3886         
3887         switch(PropType){
3888                 case PROPERTY_NONE:
3889                         OrganisationsList = &GeneralOrganisationsList;
3890                         OrganisationsListType = &GeneralOrganisationsListType;
3891                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3892                         OrganisationsListPID = &GeneralOrganisationsListPID;
3893                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3894                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3895                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3896                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3897                         break;
3898                 case PROPERTY_HOME:
3899                         OrganisationsList = &HomeOrganisationsList;
3900                         OrganisationsListType = &HomeOrganisationsListType;
3901                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3902                         OrganisationsListPID = &HomeOrganisationsListPID;
3903                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3904                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3905                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3906                         OrganisationsListPref = &HomeOrganisationsListPref;     
3907                         break;
3908                 case PROPERTY_WORK:
3909                         OrganisationsList = &BusinessOrganisationsList;
3910                         OrganisationsListType = &BusinessOrganisationsListType;
3911                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3912                         OrganisationsListPID = &BusinessOrganisationsListPID;
3913                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3914                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3915                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3916                         OrganisationsListPref = &BusinessOrganisationsListPref;
3917                         break;
3918         }
3920         intPrevValue = 4;
3921                 
3922         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3923         intiter != SplitPoints.end(); ++intiter){
3924         
3925                 SLiter = SplitLength.find(intiter->first);
3926         
3927                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3928                 
3929                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3930                 PropertyName = PropertyElement.GetNextToken();                          
3931                 PropertyValue = PropertyElement.GetNextToken();
3932                 
3933                 intPrevValue = intiter->second;
3934                 
3935                 // Process properties.
3936                 
3937                 size_t intPropertyValueLen = PropertyValue.Len();
3938                 
3939                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3940                         
3941                         PropertyValue.Trim();
3942                         PropertyValue.RemoveLast();
3943                         
3944                 }                               
3945                 
3946                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3947                         
3948                         PropertyValue.Remove(0, 1);
3949                         
3950                 }                               
3951                 
3952                 CaptureString(&PropertyValue, FALSE);
3953                 
3954                 if (PropertyName == wxT("ALTID")){
3955                 
3956                         OrganisationsListAltID->erase(*OrganisationCount);
3957                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3958                 
3959                 } else if (PropertyName == wxT("PID")){
3961                         OrganisationsListPID->erase(*OrganisationCount);
3962                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3963                 
3964                 } else if (PropertyName == wxT("SORT-AS")){
3966                         OrganisationsListSortAs->erase(*OrganisationCount);
3967                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3968                 
3969                 } else if (PropertyName == wxT("PREF")){
3970                                 
3971                         int PriorityNumber = 0;
3972                         bool ValidNumber = TRUE;
3973                         
3974                         try{
3975                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3976                         }
3977                         
3978                         catch(std::invalid_argument &e){
3979                                 ValidNumber = FALSE;
3980                         }
3982                         if (ValidNumber == TRUE){
3984                                 OrganisationsListPref->erase(*OrganisationCount);
3985                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3987                         }
3988                                         
3989                 } else if (PropertyName == wxT("LANGUAGE")){
3990                 
3991                         OrganisationsListLanguage->erase(*OrganisationCount);
3992                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3993                 
3994                 } else {
3995                 
3996                         // Something else we don't know about so append
3997                         // to the tokens variable.
3998                 
3999                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4000                 
4001                                 if (FirstToken == TRUE){
4002                         
4003                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4004                                         FirstToken = FALSE;
4005                         
4006                                 } else {
4007                         
4008                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4009                         
4010                                 }
4011                 
4012                         }
4013                 
4014                 }
4015         
4016         }
4017         
4018         // Add the data to the General/Home/Work address variables.
4019         
4020         CaptureString(&PropertySeg2, FALSE);
4022         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
4023         
4024         if (!PropertyTokens.IsEmpty()){
4025         
4026                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
4027                         
4028         }
4032 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
4034         std::map<int, int> SplitPoints;
4035         std::map<int, int> SplitLength;
4036         std::map<int, int>::iterator SLiter;                    
4037         wxString PropertyData;
4038         wxString PropertyName;
4039         wxString PropertyValue;
4040         wxString PropertyTokens;
4041         bool FirstToken = TRUE;
4042         int intPrevValue = 6;
4043         int intPref = 0;                        
4044         int intType = 0;
4045         long ListCtrlIndex;
4046         
4047         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4048         
4049         intPrevValue = 5;
4050         
4051         PropertyType PropType = PROPERTY_NONE;
4052                 
4053         // Look for type before continuing.
4054         
4055         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4056         
4057         // Setup the pointers.
4058         
4059         std::map<int, wxString> *NoteList = NULL;
4060         std::map<int, wxString> *NoteListAltID = NULL;
4061         std::map<int, wxString> *NoteListPID = NULL;
4062         std::map<int, wxString> *NoteListType = NULL;
4063         std::map<int, wxString> *NoteListTokens = NULL;
4064         std::map<int, wxString> *NoteListLanguage = NULL;
4065         std::map<int, int> *NoteListPref = NULL;
4066         
4067         // Setup blank lines for later on.
4068         
4069         switch(PropType){
4070                 case PROPERTY_NONE:
4071                         NoteList = &GeneralNoteList;
4072                         NoteListType = &GeneralNoteListType;
4073                         NoteListAltID = &GeneralNoteListAltID;
4074                         NoteListPID = &GeneralNoteListPID;
4075                         NoteListTokens = &GeneralNoteListTokens;
4076                         NoteListLanguage = &GeneralNoteListLanguage;
4077                         NoteListPref = &GeneralNoteListPref;    
4078                         break;
4079                 case PROPERTY_HOME:
4080                         NoteList = &HomeNoteList;
4081                         NoteListType = &HomeNoteListType;
4082                         NoteListAltID = &HomeNoteListAltID;
4083                         NoteListPID = &HomeNoteListPID;
4084                         NoteListTokens = &HomeNoteListTokens;
4085                         NoteListLanguage = &HomeNoteListLanguage;
4086                         NoteListPref = &HomeNoteListPref;       
4087                         break;
4088                 case PROPERTY_WORK:
4089                         NoteList = &BusinessNoteList;
4090                         NoteListType = &BusinessNoteListType;
4091                         NoteListAltID = &BusinessNoteListAltID;
4092                         NoteListPID = &BusinessNoteListPID;
4093                         NoteListTokens = &BusinessNoteListTokens;
4094                         NoteListLanguage = &BusinessNoteListLanguage;   
4095                         NoteListPref = &BusinessNoteListPref;
4096                         break;
4097         }
4099         intPrevValue = 5;
4100                 
4101         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4102         intiter != SplitPoints.end(); ++intiter){
4103         
4104                 SLiter = SplitLength.find(intiter->first);
4105         
4106                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4107                 
4108                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4109                 PropertyName = PropertyElement.GetNextToken();                          
4110                 PropertyValue = PropertyElement.GetNextToken();
4111                 
4112                 intPrevValue = intiter->second;
4113                 
4114                 // Process properties.
4115                 
4116                 size_t intPropertyValueLen = PropertyValue.Len();
4117                 
4118                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4119                         
4120                         PropertyValue.Trim();
4121                         PropertyValue.RemoveLast();
4122                         
4123                 }                               
4124                 
4125                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4126                         
4127                         PropertyValue.Remove(0, 1);
4128                         
4129                 }                               
4130                 
4131                 CaptureString(&PropertyValue, FALSE);
4132                 
4133                 if (PropertyName == wxT("ALTID")){
4134                 
4135                         NoteListAltID->erase(*NoteCount);
4136                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4137                 
4138                 } else if (PropertyName == wxT("PID")){
4140                         NoteListPID->erase(*NoteCount);
4141                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4142                 
4143                 } else if (PropertyName == wxT("PREF")){
4144                                 
4145                         int PriorityNumber = 0;
4146                         bool ValidNumber = TRUE;
4147                         
4148                         try{
4149                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4150                         }
4151                         
4152                         catch(std::invalid_argument &e){
4153                                 ValidNumber = FALSE;
4154                         }
4156                         if (ValidNumber == TRUE){
4158                                 NoteListPref->erase(*NoteCount);
4159                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4161                         }
4162                                         
4163                 } else if (PropertyName == wxT("LANGUAGE")){
4164                 
4165                         NoteListLanguage->erase(*NoteCount);
4166                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4167                 
4168                 } else {
4169                 
4170                         // Something else we don't know about so append
4171                         // to the tokens variable.
4172                 
4173                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4174                 
4175                                 if (FirstToken == TRUE){
4176                         
4177                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4178                                         FirstToken = FALSE;
4179                         
4180                                 } else {
4181                         
4182                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4183                         
4184                                 }
4185                 
4186                         }
4187                 
4188                 }
4189         
4190         }
4191         
4192         // Add the data to the General/Home/Work address variables.
4193         
4194         CaptureString(&PropertySeg2, FALSE);
4196         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4197         
4198         if (!PropertyTokens.IsEmpty()){
4199         
4200                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4201                         
4202         }
4206 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4208         std::map<int, int> SplitPoints;
4209         std::map<int, int> SplitLength;
4210         std::map<int, int>::iterator SLiter;                    
4211         wxString PropertyData;
4212         wxString PropertyName;
4213         wxString PropertyValue;
4214         wxString PropertyTokens;
4215         bool FirstToken = TRUE;
4216         int intPrevValue = 12;
4217         int intPref = 0;                        
4218         int intType = 0;
4219         long ListCtrlIndex;
4220         
4221         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4222         
4223         intPrevValue = 11;
4224         
4225         PropertyType PropType = PROPERTY_NONE;
4226                 
4227         // Look for type before continuing.
4228         
4229         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4230         
4231         // Setup blank lines for later on.
4232         
4233         switch(PropType){
4234                 case PROPERTY_NONE:
4235                         break;
4236                 case PROPERTY_HOME:
4237                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4238                         break;
4239                 case PROPERTY_WORK:
4240                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4241                         break;
4242         }
4244         intPrevValue = 11;
4245                 
4246         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4247         intiter != SplitPoints.end(); ++intiter){
4248         
4249                 SLiter = SplitLength.find(intiter->first);
4250         
4251                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4252                 
4253                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4254                 PropertyName = PropertyElement.GetNextToken();                          
4255                 PropertyValue = PropertyElement.GetNextToken();
4256                 
4257                 intPrevValue = intiter->second;
4258                 
4259                 // Process properties.
4260                 
4261                 size_t intPropertyValueLen = PropertyValue.Len();
4262                 
4263                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4264                         
4265                         PropertyValue.Trim();
4266                         PropertyValue.RemoveLast();
4267                         
4268                 }                               
4269                 
4270                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4271                         
4272                         PropertyValue.Remove(0, 1);
4273                         
4274                 }                               
4275                 
4276                 CaptureString(&PropertyValue, FALSE);
4277                 
4278                 if (PropertyName == wxT("ALTID")){
4279                 
4280                         CategoriesListAltID.erase(*CategoryCount);
4281                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4282                 
4283                 } else if (PropertyName == wxT("PID")){
4285                         CategoriesListPID.erase(*CategoryCount);
4286                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4287                 
4288                 } else if (PropertyName == wxT("PREF")){
4289                                 
4290                         int PriorityNumber = 0;
4291                         bool ValidNumber = TRUE;
4292                         
4293                         try{
4294                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4295                         }
4296                         
4297                         catch(std::invalid_argument &e){
4298                                 ValidNumber = FALSE;
4299                         }
4301                         if (ValidNumber == TRUE){
4303                                 CategoriesListPref.erase(*CategoryCount);
4304                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4306                         }
4307                                         
4308                 } else if (PropertyName == wxT("LANGUAGE")){
4309                 
4310                         CategoriesListLanguage.erase(*CategoryCount);
4311                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4312                 
4313                 } else {
4314                 
4315                         // Something else we don't know about so append
4316                         // to the tokens variable.
4317                 
4318                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4319                 
4320                                 if (FirstToken == TRUE){
4321                         
4322                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4323                                         FirstToken = FALSE;
4324                         
4325                                 } else {
4326                         
4327                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4328                         
4329                                 }
4330                 
4331                         }
4332                 
4333                 }
4334         
4335         }
4336         
4337         // Deal with multiple categories.
4338         
4339         int intOrigCatCount = *CategoryCount;
4340         bool FirstCategoryProcessed = TRUE;
4341         bool AfterFirstToken = FALSE;
4342         int intSplitSize = 0;
4343         int intSplitsFound = 0;
4344         int intSplitSeek = 0;
4345         int intPropertyLen = PropertySeg2.Len();
4346         
4347         SplitPoints.clear();
4348         SplitLength.clear();
4349         intPrevValue = 0;
4350         
4351         for (int i = 0; i <= intPropertyLen; i++){
4352         
4353                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4354         
4355                         continue;
4356                 
4357                 }
4358         
4359                 intSplitSize++;
4360         
4361                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4362         
4363                         if (AfterFirstToken == TRUE){
4364                 
4365                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4366                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4367                         
4368                         } else {
4369                         
4370                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4371                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4372                                 AfterFirstToken = TRUE;
4374                         }
4376                         intSplitsFound++;
4377                         intSplitSeek = i;
4378                         intSplitSize = 0;                               
4379         
4380                 }                       
4381         
4382         }
4383         
4384         if (SplitPoints.size() > 0){
4385         
4386                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4387                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4388         
4389         }
4390         
4391         if (SplitPoints.size() == 0){
4392         
4393                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4394         
4395                 if (!PropertyTokens.IsEmpty()){
4396                 
4397                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4398                 
4399                 }
4400         
4401         }
4402         
4403         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4404         intiter != SplitPoints.end(); ++intiter){
4405         
4406                 SLiter = SplitLength.find(intiter->first);
4407         
4408                 intPrevValue = intiter->second;
4409         
4410                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4411                 
4412                 // Add the data to the General/Home/Work address variables.
4413         
4414                 // Trim any whitespace from the start and end.
4415         
4416                 PropertyData = PropertyData.Trim(FALSE);
4417                 PropertyData = PropertyData.Trim(TRUE); 
4418         
4419                 CaptureString(&PropertyData, FALSE);
4420                 
4421                 if (FirstCategoryProcessed == TRUE){
4422                 
4423                         FirstCategoryProcessed = FALSE;
4424                         
4425                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4426         
4427                         if (!PropertyTokens.IsEmpty()){
4428                 
4429                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4430                 
4431                         }
4432                         
4433                         continue;
4434                 
4435                 } else {
4437                         (*CategoryCount)++;
4438                         
4439                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4440                 
4441                         if (!PropertyTokens.IsEmpty()){
4442                 
4443                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4444                 
4445                         }
4446                 
4447                 }
4448                 
4449                 // Copy the properties to each of the categories (if it exists).
4450                 
4451                 if (!PropertyTokens.IsEmpty()){
4452                 
4453                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4454                 
4455                 }
4456                 
4457                 // Check if ALTID was used.
4458                 
4459                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4460                 
4461                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4462                 
4463                 }
4464                 
4465                 // Check if PID was used.
4466                 
4467                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4468                 
4469                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4470                 
4471                 }
4472         
4473                 // Check if PREF was used.
4474         
4475                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4476                 
4477                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4478                 
4479                 }
4480                 
4481                 // Check if LANGUAGE was used.
4482                 
4483                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4484                 
4485                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4486                 
4487                 }
4488                 
4489                 // Check if TYPE was used.
4490                 
4491                 switch(PropType){
4492                         case PROPERTY_NONE:
4493                                 break;
4494                         case PROPERTY_HOME:
4495                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4496                                 break;
4497                         case PROPERTY_WORK:
4498                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4499                                 break;
4500                 }
4501         
4502         }
4506 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4508         size_t intPropertyLen = PropertySeg1.Len();
4509         std::map<int, int> SplitPoints;
4510         std::map<int, int> SplitLength;
4511         std::map<int, int>::iterator SLiter;                    
4512         wxString PropertyData;
4513         wxString PropertyName;
4514         wxString PropertyValue;
4515         wxString PropertyTokens;
4516         bool FirstToken = TRUE;
4517         int intSplitsFound = 0;
4518         int intSplitSize = 0;
4519         int intPrevValue = 7;
4520         int intPref = 0;                        
4521         int intType = 0;
4522         
4523         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4524         
4525         intPrevValue = 6;
4526         
4527         PropertyType PropType = PROPERTY_NONE;
4528                 
4529         // Look for type before continuing.
4530         
4531         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4533         intPrevValue = 6;
4535         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4536         intiter != SplitPoints.end(); ++intiter){
4537         
4538                 SLiter = SplitLength.find(intiter->first);
4539         
4540                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4541                 
4542                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4543                 PropertyName = PropertyElement.GetNextToken();                          
4544                 PropertyValue = PropertyElement.GetNextToken();
4545                 
4546                 intPrevValue = intiter->second;
4547                 
4548                 // Process properties.
4549                 
4550                 size_t intPropertyValueLen = PropertyValue.Len();
4551                 
4552                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4553                         
4554                         PropertyValue.Trim();
4555                         PropertyValue.RemoveLast();
4556                         
4557                 }                               
4558                 
4559                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4560                         
4561                         PropertyValue.Remove(0, 1);
4562                         
4563                 }
4564                 
4565                 CaptureString(&PropertyValue, FALSE);
4566                 
4567                 if (PropertyName == wxT("ALTID")){
4569                         PicturesListAltID.erase(*PhotoCount);
4570                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4571                 
4572                 } else if (PropertyName == wxT("PID")){
4574                         PicturesListPID.erase(*PhotoCount);
4575                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4576                 
4577                 } else if (PropertyName == wxT("PREF")){
4578                         
4579                         int PriorityNumber = 0;
4580                         bool ValidNumber = TRUE;
4581                         
4582                         try{
4583                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4584                         }
4585                         
4586                         catch(std::invalid_argument &e){
4587                                 ValidNumber = FALSE;
4588                         }
4590                         if (ValidNumber == TRUE){
4592                                 PicturesListPref.erase(*PhotoCount);
4593                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4595                         }
4596                 
4597                 } else if (PropertyName == wxT("MEDIATYPE")){
4598                 
4599                         PicturesListMediatype.erase(*PhotoCount);
4600                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4601                                         
4602                 } else {
4603                 
4604                         // Something else we don't know about so append
4605                         // to the tokens variable.
4606                         
4607                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4608                         
4609                                 if (FirstToken == TRUE){
4610                                 
4611                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4612                                         FirstToken = FALSE;
4613                                 
4614                                 } else {
4615                                 
4616                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4617                                 
4618                                 }
4619                         
4620                         }
4621                 
4622                 }
4623         
4624         }       
4625         
4626         intPropertyLen = PropertySeg2.Len();
4627         SplitPoints.clear();
4628         SplitLength.clear();
4629         intSplitsFound = 0;
4630         intSplitSize = 0;
4631         intPrevValue = 0;                       
4632         
4633         CaptureString(&PropertySeg2, FALSE);
4634         
4635         for (int i = 0; i <= intPropertyLen; i++){
4637                 intSplitSize++;
4638         
4639                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4640         
4641                         intSplitsFound++;
4642                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4643                         
4644                         if (intSplitsFound == 6){ 
4645                         
4646                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4647                                 break; 
4648                                 
4649                         } else {
4650                         
4651                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4652                         
4653                         }
4654                         
4655                         intSplitSize = 0;                                       
4656         
4657                 }
4659         }
4660         
4661         wxString wxSPhotoURI;
4662         wxString wxSPhotoMIME;
4663         wxString wxSPhotoEncoding;
4664         wxString wxSPhotoData;
4665         std::string base64enc;
4666         
4667         if (intSplitsFound == 0){
4668         
4669         } else {
4670         
4671                 std::map<int, int>::iterator striter;
4672         
4673                 striter = SplitLength.find(1);
4674         
4675                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4676         
4677                 while (wSTDataType.HasMoreTokens() == TRUE){
4678                 
4679                         wxSPhotoURI = wSTDataType.GetNextToken();
4680                         wxSPhotoMIME = wSTDataType.GetNextToken();
4681                         break;
4682                 
4683                 }                       
4684         
4685                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4686         
4687                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4688                 
4689                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4690                         wxSPhotoData = wSTDataInfo.GetNextToken();
4691                         base64enc = wxSPhotoData.mb_str();
4692                         break;
4693                 
4694                 }
4695         
4696         }
4697         
4698         // Add the data to the General/Home/Work address variables.
4699         
4700         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4701         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4702         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4703         
4704         switch(PropType){
4705                 case PROPERTY_NONE:
4706                         break;
4707                 case PROPERTY_HOME:
4708                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4709                         break;
4710                 case PROPERTY_WORK:
4711                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4712                         break;
4713         }
4714         
4715         if (!PropertyTokens.IsEmpty()){
4717                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4718         
4719         }
4723 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4725         size_t intPropertyLen = PropertySeg1.Len();
4726         std::map<int, int> SplitPoints;
4727         std::map<int, int> SplitLength;
4728         std::map<int, int>::iterator SLiter;                    
4729         wxString PropertyData;
4730         wxString PropertyName;
4731         wxString PropertyValue;
4732         wxString PropertyTokens;
4733         bool FirstToken = TRUE;
4734         int intSplitsFound = 0;
4735         int intSplitSize = 0;
4736         int intPrevValue = 6;
4737         int intPref = 0;                        
4738         int intType = 0;
4739         
4740         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4741         
4742         intPrevValue = 5;
4743         
4744         PropertyType PropType = PROPERTY_NONE;
4745                 
4746         // Look for type before continuing.
4747         
4748         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4750         intPrevValue = 5;
4752         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4753         intiter != SplitPoints.end(); ++intiter){
4754         
4755                 SLiter = SplitLength.find(intiter->first);
4756         
4757                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4758                 
4759                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4760                 PropertyName = PropertyElement.GetNextToken();                          
4761                 PropertyValue = PropertyElement.GetNextToken();
4762                 
4763                 intPrevValue = intiter->second;
4764                 
4765                 // Process properties.
4766                 
4767                 size_t intPropertyValueLen = PropertyValue.Len();
4768                 
4769                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4770                         
4771                         PropertyValue.Trim();
4772                         PropertyValue.RemoveLast();
4773                         
4774                 }                               
4775                 
4776                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4777                         
4778                         PropertyValue.Remove(0, 1);
4779                         
4780                 }
4781                 
4782                 CaptureString(&PropertyValue, FALSE);
4783                 
4784                 if (PropertyName == wxT("ALTID")){
4786                         LogosListAltID.erase(*LogoCount);
4787                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4788                 
4789                 } else if (PropertyName == wxT("PID")){
4791                         LogosListPID.erase(*LogoCount);
4792                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4793                 
4794                 } else if (PropertyName == wxT("PREF")){
4795                         
4796                         int PriorityNumber = 0;
4797                         bool ValidNumber = TRUE;
4798                         
4799                         try{
4800                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4801                         }
4802                         
4803                         catch(std::invalid_argument &e){
4804                                 ValidNumber = FALSE;
4805                         }
4807                         if (ValidNumber == TRUE){
4809                                 LogosListPref.erase(*LogoCount);
4810                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4812                         }
4813                 
4814                 } else if (PropertyName == wxT("MEDIATYPE")){
4815                 
4816                         LogosListMediatype.erase(*LogoCount);
4817                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4818                                         
4819                 } else {
4820                 
4821                         // Something else we don't know about so append
4822                         // to the tokens variable.
4823                         
4824                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4825                         
4826                                 if (FirstToken == TRUE){
4827                                 
4828                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4829                                         FirstToken = FALSE;
4830                                 
4831                                 } else {
4832                                 
4833                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4834                                 
4835                                 }
4836                         
4837                         }
4838                 
4839                 }
4840         
4841         }       
4842         
4843         intPropertyLen = PropertySeg2.Len();
4844         SplitPoints.clear();
4845         SplitLength.clear();
4846         intSplitsFound = 0;
4847         intSplitSize = 0;
4848         intPrevValue = 0;                       
4849         
4850         CaptureString(&PropertySeg2, FALSE);
4851         
4852         for (int i = 0; i <= intPropertyLen; i++){
4854                 intSplitSize++;
4855         
4856                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4857         
4858                         intSplitsFound++;
4859                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4860                         
4861                         if (intSplitsFound == 6){ 
4862                         
4863                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4864                                 break; 
4865                                 
4866                         } else {
4867                         
4868                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4869                         
4870                         }
4871                         
4872                         intSplitSize = 0;                                       
4873         
4874                 }
4876         }
4877         
4878         wxString wxSPhotoURI;
4879         wxString wxSPhotoMIME;
4880         wxString wxSPhotoEncoding;
4881         wxString wxSPhotoData;
4882         std::string base64enc;
4883         
4884         if (intSplitsFound == 0){
4885         
4886         } else {
4887         
4888                 std::map<int, int>::iterator striter;
4889         
4890                 striter = SplitLength.find(1);
4891         
4892                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4893         
4894                 while (wSTDataType.HasMoreTokens() == TRUE){
4895                 
4896                         wxSPhotoURI = wSTDataType.GetNextToken();
4897                         wxSPhotoMIME = wSTDataType.GetNextToken();
4898                         break;
4899                 
4900                 }                       
4901         
4902                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4903         
4904                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4905                 
4906                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4907                         wxSPhotoData = wSTDataInfo.GetNextToken();
4908                         base64enc = wxSPhotoData.mb_str();
4909                         break;
4910                 
4911                 }
4912         
4913         }
4914         
4915         // Add the data to the General/Home/Work address variables.
4916         
4917         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4918         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4919         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4920         
4921         switch(PropType){
4922                 case PROPERTY_NONE:
4923                         break;
4924                 case PROPERTY_HOME:
4925                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4926                         break;
4927                 case PROPERTY_WORK:
4928                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4929                         break;
4930         }
4931         
4932         if (!PropertyTokens.IsEmpty()){
4934                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4935         
4936         }
4940 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4942         size_t intPropertyLen = PropertySeg1.Len();
4943         std::map<int, int> SplitPoints;
4944         std::map<int, int> SplitLength;
4945         std::map<int, int>::iterator SLiter;                    
4946         wxString PropertyData;
4947         wxString PropertyName;
4948         wxString PropertyValue;
4949         wxString PropertyTokens;
4950         bool FirstToken = TRUE;
4951         int intSplitsFound = 0;
4952         int intSplitSize = 0;
4953         int intPrevValue = 7;
4954         int intPref = 0;                        
4955         int intType = 0;
4956         
4957         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4958         
4959         intPrevValue = 6;
4960         
4961         PropertyType PropType = PROPERTY_NONE;
4962         
4963         // Look for type before continuing.                     
4965         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4967         intPrevValue = 6;
4969         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4970         intiter != SplitPoints.end(); ++intiter){
4971         
4972                 SLiter = SplitLength.find(intiter->first);
4973         
4974                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4975                 
4976                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4977                 PropertyName = PropertyElement.GetNextToken();                          
4978                 PropertyValue = PropertyElement.GetNextToken();
4979                 
4980                 intPrevValue = intiter->second;
4981                 
4982                 // Process properties.
4983                 
4984                 size_t intPropertyValueLen = PropertyValue.Len();
4985                 
4986                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4987                         
4988                         PropertyValue.Trim();
4989                         PropertyValue.RemoveLast();
4990                         
4991                 }                               
4992                 
4993                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4994                         
4995                         PropertyValue.Remove(0, 1);
4996                         
4997                 }                       
4998                 
4999                 CaptureString(&PropertyValue, FALSE);
5000                 
5001                 if (PropertyName == wxT("ALTID")){
5003                         SoundsListAltID.erase(*SoundCount);
5004                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
5005                 
5006                 } else if (PropertyName == wxT("PID")){
5008                         SoundsListPID.erase(*SoundCount);
5009                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
5010                 
5011                 } else if (PropertyName == wxT("PREF")){
5012                         
5013                         int PriorityNumber = 0;
5014                         bool ValidNumber = TRUE;
5015                         
5016                         try{
5017                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5018                         }
5019                         
5020                         catch(std::invalid_argument &e){
5021                                 ValidNumber = FALSE;
5022                         }
5024                         if (ValidNumber == TRUE){
5026                                 SoundsListPref.erase(*SoundCount);
5027                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
5029                         }
5030                 
5031                 } else if (PropertyName == wxT("MEDIATYPE")){
5032                 
5033                         SoundsListMediatype.erase(*SoundCount);
5034                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
5036                 } else if (PropertyName == wxT("LANGUAGE")){
5037                 
5038                         SoundsListLanguage.erase(*SoundCount);
5039                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
5041                 } else {
5042                 
5043                         // Something else we don't know about so append
5044                         // to the tokens variable.
5045                         
5046                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5047                         
5048                                 if (FirstToken == TRUE){
5049                                 
5050                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5051                                         FirstToken = FALSE;
5052                                 
5053                                 } else {
5054                                 
5055                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5056                                 
5057                                 }
5058                         
5059                         }
5060                 
5061                 }
5062         
5063         }       
5064         
5065         intPropertyLen = PropertySeg2.Len();
5066         SplitPoints.clear();
5067         SplitLength.clear();
5068         intSplitsFound = 0;
5069         intSplitSize = 0;
5070         intPrevValue = 0;
5071         
5072         CaptureString(&PropertySeg2, FALSE);
5073         
5074         for (int i = 0; i <= intPropertyLen; i++){
5076                 intSplitSize++;
5077         
5078                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5079         
5080                         intSplitsFound++;
5081                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5082                         
5083                         if (intSplitsFound == 6){ 
5084                         
5085                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5086                                 break; 
5087                                 
5088                         } else {
5089                         
5090                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5091                         
5092                         }
5093                         
5094                         intSplitSize = 0;                                       
5095         
5096                 }
5098         }
5099         
5100         wxString wxSSoundURI;
5101         wxString wxSSoundMIME;
5102         wxString wxSSoundEncoding;
5103         wxString wxSSoundData;
5104         std::string base64enc;
5105         
5106         if (intSplitsFound == 0){
5107         
5108         } else {
5109         
5110                 std::map<int, int>::iterator striter;
5111         
5112                 striter = SplitLength.find(1);
5113         
5114                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5115         
5116                 while (wSTDataType.HasMoreTokens() == TRUE){
5117                 
5118                         wxSSoundURI = wSTDataType.GetNextToken();
5119                         wxSSoundMIME = wSTDataType.GetNextToken();
5120                         break;
5121                 
5122                 }                       
5123         
5124                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5125         
5126                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5127                 
5128                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
5129                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
5130                         base64enc = wxSSoundData.mb_str();
5131                         break;
5132                 
5133                 }
5134         
5135         }
5136         
5137         // Add the data to the General/Home/Work address variables.
5138                 
5139         switch(PropType){
5140                 case PROPERTY_NONE:
5141                         break;
5142                 case PROPERTY_HOME:
5143                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5144                         break;
5145                 case PROPERTY_WORK:
5146                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5147                         break;
5148         }
5149         
5150         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5151         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5152         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5153         
5154         if (!PropertyTokens.IsEmpty()){
5155         
5156                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5157         
5158         }
5159         
5162 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5164         size_t intPropertyLen = PropertySeg1.Len();
5165         std::map<int, int> SplitPoints;
5166         std::map<int, int> SplitLength;
5167         std::map<int, int>::iterator SLiter;                    
5168         wxString PropertyData;
5169         wxString PropertyName;
5170         wxString PropertyValue;
5171         wxString PropertyTokens;
5172         bool FirstToken = TRUE;
5173         int intSplitsFound = 0;
5174         int intSplitSize = 0;
5175         int intPrevValue = 8;
5176         int intPref = 0;                        
5177         int intType = 0;
5178         
5179         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5180         
5181         intPrevValue = 7;
5182         
5183         PropertyType PropType = PROPERTY_NONE;
5184         
5185         // Look for type before continuing.                     
5187         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5189         intPrevValue = 7;
5191         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5192         intiter != SplitPoints.end(); ++intiter){
5193         
5194                 SLiter = SplitLength.find(intiter->first);
5195         
5196                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5197                 
5198                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5199                 PropertyName = PropertyElement.GetNextToken();                          
5200                 PropertyValue = PropertyElement.GetNextToken();
5201                 
5202                 intPrevValue = intiter->second;
5203                 
5204                 // Process properties.
5205                 
5206                 size_t intPropertyValueLen = PropertyValue.Len();
5207                 
5208                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5209                         
5210                         PropertyValue.Trim();
5211                         PropertyValue.RemoveLast();
5212                         
5213                 }                               
5214                 
5215                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5216                         
5217                         PropertyValue.Remove(0, 1);
5218                         
5219                 }                       
5220                 
5221                 CaptureString(&PropertyValue, FALSE);
5222                 
5223                 if (PropertyName == wxT("ALTID")){
5225                         CalendarListAltID.erase(*CalURICount);
5226                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5227                 
5228                 } else if (PropertyName == wxT("PID")){
5230                         CalendarListPID.erase(*CalURICount);
5231                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5232                 
5233                 } else if (PropertyName == wxT("PREF")){
5234                         
5235                         int PriorityNumber = 0;
5236                         bool ValidNumber = TRUE;
5237                         
5238                         try{
5239                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5240                         }
5241                         
5242                         catch(std::invalid_argument &e){
5243                                 ValidNumber = FALSE;
5244                         }
5246                         if (ValidNumber == TRUE){
5248                                 CalendarListPref.erase(*CalURICount);
5249                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5251                         }
5252                 
5253                 } else if (PropertyName == wxT("MEDIATYPE")){
5254                 
5255                         CalendarListMediatype.erase(*CalURICount);
5256                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5258                 } else {
5259                 
5260                         // Something else we don't know about so append
5261                         // to the tokens variable.
5262                         
5263                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5264                         
5265                                 if (FirstToken == TRUE){
5266                                 
5267                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5268                                         FirstToken = FALSE;
5269                                 
5270                                 } else {
5271                                 
5272                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5273                                 
5274                                 }
5275                         
5276                         }
5277                 
5278                 }
5279         
5280         }       
5281         
5282         intPropertyLen = PropertySeg2.Len();
5283         SplitPoints.clear();
5284         SplitLength.clear();
5285         intSplitsFound = 0;
5286         intSplitSize = 0;
5287         intPrevValue = 0;
5288         
5289         CaptureString(&PropertySeg2, FALSE);
5290         
5291         // Add the data to the General/Home/Work address variables.
5292                 
5293         switch(PropType){
5294                 case PROPERTY_NONE:
5295                         break;
5296                 case PROPERTY_HOME:
5297                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5298                         break;
5299                 case PROPERTY_WORK:
5300                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5301                         break;
5302         }
5303         
5304         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5305         
5306         if (!PropertyTokens.IsEmpty()){
5307         
5308                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5309         
5310         }
5314 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5316         size_t intPropertyLen = PropertySeg1.Len();
5317         std::map<int, int> SplitPoints;
5318         std::map<int, int> SplitLength;
5319         std::map<int, int>::iterator SLiter;                    
5320         wxString PropertyData;
5321         wxString PropertyName;
5322         wxString PropertyValue;
5323         wxString PropertyTokens;
5324         bool FirstToken = TRUE;
5325         int intSplitsFound = 0;
5326         int intSplitSize = 0;
5327         int intPrevValue = 8;
5328         int intPref = 0;                        
5329         int intType = 0;
5330         
5331         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5332         
5333         intPrevValue = 7;
5334         
5335         PropertyType PropType = PROPERTY_NONE;
5336         
5337         // Look for type before continuing.                     
5339         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5341         intPrevValue = 7;
5343         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5344         intiter != SplitPoints.end(); ++intiter){
5345         
5346                 SLiter = SplitLength.find(intiter->first);
5347         
5348                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5349                 
5350                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5351                 PropertyName = PropertyElement.GetNextToken();                          
5352                 PropertyValue = PropertyElement.GetNextToken();
5353                 
5354                 intPrevValue = intiter->second;
5355                 
5356                 // Process properties.
5357                 
5358                 size_t intPropertyValueLen = PropertyValue.Len();
5359                 
5360                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5361                         
5362                         PropertyValue.Trim();
5363                         PropertyValue.RemoveLast();
5364                         
5365                 }                               
5366                 
5367                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5368                         
5369                         PropertyValue.Remove(0, 1);
5370                         
5371                 }                       
5372                 
5373                 CaptureString(&PropertyValue, FALSE);
5374                 
5375                 if (PropertyName == wxT("ALTID")){
5377                         CalendarRequestListAltID.erase(*CalAdrURICount);
5378                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5379                 
5380                 } else if (PropertyName == wxT("PID")){
5382                         CalendarRequestListPID.erase(*CalAdrURICount);
5383                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5384                 
5385                 } else if (PropertyName == wxT("PREF")){
5386                         
5387                         int PriorityNumber = 0;
5388                         bool ValidNumber = TRUE;
5389                         
5390                         try{
5391                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5392                         }
5393                         
5394                         catch(std::invalid_argument &e){
5395                                 ValidNumber = FALSE;
5396                         }
5398                         if (ValidNumber == TRUE){
5400                                 CalendarRequestListPref.erase(*CalAdrURICount);
5401                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5403                         }
5404                 
5405                 } else if (PropertyName == wxT("MEDIATYPE")){
5406                 
5407                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5408                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5410                 } else {
5411                 
5412                         // Something else we don't know about so append
5413                         // to the tokens variable.
5414                         
5415                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5416                         
5417                                 if (FirstToken == TRUE){
5418                                 
5419                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5420                                         FirstToken = FALSE;
5421                                 
5422                                 } else {
5423                                 
5424                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5425                                 
5426                                 }
5427                         
5428                         }
5429                 
5430                 }
5431         
5432         }       
5433         
5434         intPropertyLen = PropertySeg2.Len();
5435         SplitPoints.clear();
5436         SplitLength.clear();
5437         intSplitsFound = 0;
5438         intSplitSize = 0;
5439         intPrevValue = 0;
5440         
5441         CaptureString(&PropertySeg2, FALSE);
5442         
5443         // Add the data to the General/Home/Work address variables.
5444                 
5445         switch(PropType){
5446                 case PROPERTY_NONE:
5447                         break;
5448                 case PROPERTY_HOME:
5449                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5450                         break;
5451                 case PROPERTY_WORK:
5452                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5453                         break;
5454         }
5455         
5456         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5457         
5458         if (!PropertyTokens.IsEmpty()){
5459         
5460                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5461         
5462         }       
5463         
5466 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5468         size_t intPropertyLen = PropertySeg1.Len();
5469         std::map<int, int> SplitPoints;
5470         std::map<int, int> SplitLength;
5471         std::map<int, int>::iterator SLiter;                    
5472         wxString PropertyData;
5473         wxString PropertyName;
5474         wxString PropertyValue;
5475         wxString PropertyTokens;
5476         bool FirstToken = TRUE;
5477         int intSplitsFound = 0;
5478         int intSplitSize = 0;
5479         int intPrevValue = 7;
5480         int intPref = 0;                        
5481         int intType = 0;
5482         
5483         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5484         
5485         intPrevValue = 6;
5486         
5487         PropertyType PropType = PROPERTY_NONE;
5488         
5489         // Look for type before continuing.                     
5491         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5493         intPrevValue = 6;
5495         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5496         intiter != SplitPoints.end(); ++intiter){
5497         
5498                 SLiter = SplitLength.find(intiter->first);
5499         
5500                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5501                 
5502                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5503                 PropertyName = PropertyElement.GetNextToken();                          
5504                 PropertyValue = PropertyElement.GetNextToken();
5505                 
5506                 intPrevValue = intiter->second;
5507                 
5508                 // Process properties.
5509                 
5510                 size_t intPropertyValueLen = PropertyValue.Len();
5511                 
5512                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5513                         
5514                         PropertyValue.Trim();
5515                         PropertyValue.RemoveLast();
5516                         
5517                 }                               
5518                 
5519                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5520                         
5521                         PropertyValue.Remove(0, 1);
5522                         
5523                 }                       
5524                 
5525                 CaptureString(&PropertyValue, FALSE);
5526                 
5527                 if (PropertyName == wxT("ALTID")){
5529                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5530                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5531                 
5532                 } else if (PropertyName == wxT("PID")){
5534                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5535                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5536                 
5537                 } else if (PropertyName == wxT("PREF")){
5538                         
5539                         int PriorityNumber = 0;
5540                         bool ValidNumber = TRUE;
5541                         
5542                         try{
5543                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5544                         }
5545                         
5546                         catch(std::invalid_argument &e){
5547                                 ValidNumber = FALSE;
5548                         }
5550                         if (ValidNumber == TRUE){
5552                                 FreeBusyListPref.erase(*FreeBusyAddressCount);
5553                                 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5555                         }
5556                 
5557                 } else if (PropertyName == wxT("MEDIATYPE")){
5558                 
5559                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5560                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5562                 } else {
5563                 
5564                         // Something else we don't know about so append
5565                         // to the tokens variable.
5566                         
5567                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5568                         
5569                                 if (FirstToken == TRUE){
5570                                 
5571                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5572                                         FirstToken = FALSE;
5573                                 
5574                                 } else {
5575                                 
5576                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5577                                 
5578                                 }
5579                         
5580                         }
5581                 
5582                 }
5583         
5584         }       
5585         
5586         intPropertyLen = PropertySeg2.Len();
5587         SplitPoints.clear();
5588         SplitLength.clear();
5589         intSplitsFound = 0;
5590         intSplitSize = 0;
5591         intPrevValue = 0;
5592         
5593         CaptureString(&PropertySeg2, FALSE);
5594         
5595         // Add the data to the General/Home/Work address variables.
5596                 
5597         switch(PropType){
5598                 case PROPERTY_NONE:
5599                         break;
5600                 case PROPERTY_HOME:
5601                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5602                         break;
5603                 case PROPERTY_WORK:
5604                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5605                         break;
5606         }
5607         
5608         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5609         
5610         if (!PropertyTokens.IsEmpty()){
5611         
5612                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5613         
5614         }
5618 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5620         size_t intPropertyLen = PropertySeg1.Len();
5621         std::map<int, int> SplitPoints;
5622         std::map<int, int> SplitLength;
5623         std::map<int, int>::iterator SLiter;                    
5624         wxString PropertyData;
5625         wxString PropertyName;
5626         wxString PropertyValue;
5627         wxString PropertyTokens;
5628         bool FirstToken = TRUE;
5629         int intSplitsFound = 0;
5630         int intSplitSize = 0;
5631         int intPrevValue = 5;
5632         int intPref = 0;                        
5633         int intType = 0;
5634         long ListCtrlIndex;
5635         
5636         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5637         
5638         intPrevValue = 4;
5639         
5640         PropertyType PropType = PROPERTY_NONE;
5641         
5642         // Look for type before continuing.
5644         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5646         intPrevValue = 4;
5648         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5649         intiter != SplitPoints.end(); ++intiter){
5650         
5651                 SLiter = SplitLength.find(intiter->first);
5652         
5653                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5654                 
5655                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5656                 PropertyName = PropertyElement.GetNextToken();                          
5657                 PropertyValue = PropertyElement.GetNextToken();
5658                 
5659                 intPrevValue = intiter->second;
5660                 
5661                 // Process properties.
5662                 
5663                 size_t intPropertyValueLen = PropertyValue.Len();
5664                 
5665                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5666                         
5667                         PropertyValue.Trim();
5668                         PropertyValue.RemoveLast();
5669                         
5670                 }                               
5671                 
5672                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5673                         
5674                         PropertyValue.Remove(0, 1);
5675                         
5676                 }                               
5677                 
5678                 if (PropertyName == wxT("ALTID")){
5680                         KeyListAltID.erase(*KeyCount);
5681                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5682                 
5683                 } else if (PropertyName == wxT("PID")){
5685                         KeyListPID.erase(*KeyCount);
5686                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5687                 
5688                 } else if (PropertyName == wxT("PREF")){
5689                         
5690                         int PriorityNumber = 0;
5691                         bool ValidNumber = TRUE;
5692                         
5693                         try{
5694                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5695                         }
5696                         
5697                         catch(std::invalid_argument &e){
5698                                 ValidNumber = FALSE;
5699                         }
5701                         if (ValidNumber == TRUE){
5703                                 KeyListPref.erase(*KeyCount);
5704                                 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5706                         }
5707                 
5708                 } else {
5709                 
5710                         // Something else we don't know about so append
5711                         // to the tokens variable.
5712                         
5713                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5714                         
5715                                 if (FirstToken == TRUE){
5716                                 
5717                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5718                                         FirstToken = FALSE;
5719                                 
5720                                 } else {
5721                                 
5722                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5723                                 
5724                                 }
5725                         
5726                         }
5727                 
5728                 }
5729         
5730         }                               
5731         
5732         intPropertyLen = PropertySeg2.Len();
5733         SplitPoints.clear();
5734         SplitLength.clear();
5735         intSplitsFound = 0;
5736         intSplitSize = 0;
5737         intPrevValue = 0;                       
5738         
5739         for (int i = 0; i <= intPropertyLen; i++){
5741                 intSplitSize++;
5742         
5743                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5744         
5745                         intSplitsFound++;
5746                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5747                         
5748                         if (intSplitsFound == 6){ 
5749                         
5750                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5751                                 break; 
5752                                 
5753                         } else {
5754                         
5755                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5756                         
5757                         }
5758                         
5759                         intSplitSize = 0;                                       
5760         
5761                 }
5763         }
5764         
5765         wxString wxSKeyURI;
5766         wxString wxSKeyMIME;
5767         wxString wxSKeyEncoding;
5768         wxString wxSKeyData;
5769         std::string base64enc;
5770         
5771         if (intSplitsFound == 0){
5772         
5773         } else {
5774         
5775                 std::map<int, int>::iterator striter;
5776         
5777                 striter = SplitLength.find(1);
5778         
5779                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5780         
5781                 while (wSTDataType.HasMoreTokens() == TRUE){
5782                 
5783                         wxSKeyURI = wSTDataType.GetNextToken();
5784                         wxSKeyMIME = wSTDataType.GetNextToken();
5785                         break;
5786                 
5787                 }                       
5788         
5789                 if (wxSKeyURI == wxT("data")){
5790                 
5791                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5792         
5793                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5794                 
5795                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5796                                 wxSKeyData = wSTDataInfo.GetNextToken();
5797                                 break;
5798                 
5799                         }
5800                 
5801                 }
5802         
5803         }
5804         
5805         // Add the data to the General/Home/Work address variables.
5806         
5807         if (wxSKeyURI == wxT("data")){
5808                 
5809                 KeyListDataEncType.erase(*KeyCount);
5810                 KeyListKeyType.erase(*KeyCount);
5811                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5812                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5813                 
5814                 KeyList.erase(*KeyCount);
5815                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5816         
5817         } else {
5818                 
5819                 KeyList.erase(*KeyCount);
5820                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5821         
5822         }
5823         
5824         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5825                 
5826         switch (PropType){
5827                 case PROPERTY_NONE:
5828                         break;
5829                 case PROPERTY_HOME: 
5830                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5831                         break;
5832                 case PROPERTY_WORK: 
5833                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5834                         break;
5835         }
5837         if (!PropertyTokens.IsEmpty()){
5839                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5841         }
5845 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5847         // Split the Vendor three ways.
5848         
5849         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5850         
5851         wxString wxSVNDID;
5852         wxString wxSVNDPropName;
5853         long ListCtrlIndex;                     
5855         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5856         
5857                 wSTVendorDetails.GetNextToken();
5858                 wxSVNDID = wSTVendorDetails.GetNextToken();
5859                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5860                 break;
5861         
5862         }
5863         
5864         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5865         
5866                 // Add the data to the vendor variables.
5867         
5868                 VendorList.erase(*VendorCount);
5869                 VendorListPEN.erase(*VendorCount);
5870                 VendorListElement.erase(*VendorCount);
5871         
5872                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5873                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5874                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5875         
5876         }
5880 void SplitValues(wxString *PropertyLine, 
5881         std::map<int,int> *SplitPoints, 
5882         std::map<int,int> *SplitLength, 
5883         int intSize){
5884         
5885         size_t intPropertyLen = PropertyLine->Len();
5886         int intSplitsFound = 0;
5887         int intSplitSize = 0;
5888         int intSplitSeek = 0;
5889         
5890         for (int i = intSize; i <= intPropertyLen; i++){
5892                 intSplitSize++;
5893         
5894                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5895                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5896            
5897                     if (intSplitsFound == 0){
5898             
5899                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5900           
5901                     } else {
5902            
5903                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5904             
5905                     }
5906             
5907                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5908             
5909                     intSplitsFound++;
5910                     intSplitSeek = i;
5911                     intSplitSize = 0;
5912             
5913                 }
5915         }
5917         if (intSplitsFound == 0){
5919                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5920                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5922         } else {
5924                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5925                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5927         }
5931 void CheckType(wxString *PropertySeg1, 
5932         std::map<int,int> *SplitPoints, 
5933         std::map<int,int> *SplitLength, 
5934         int *intPrevValue, 
5935         PropertyType *PropType){
5936         
5937         wxString PropertyData;
5938         wxString PropertyName;
5939         wxString PropertyValue;
5940         std::map<int,int>::iterator SLiter;
5941         
5942         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5943         intiter != SplitPoints->end(); ++intiter){
5944         
5945                 SLiter = SplitLength->find(intiter->first);
5946         
5947                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5948                 
5949                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5950                 PropertyName = PropertyElement.GetNextToken();                          
5951                 PropertyValue = PropertyElement.GetNextToken();
5952                 
5953                 *intPrevValue = intiter->second;
5954                 
5955                 if (PropertyName == wxT("TYPE")){
5956                                 
5957                         if (PropertyValue == wxT("work")){
5958                         
5959                                 *PropType = PROPERTY_WORK;
5960                                                         
5961                         } else if (PropertyValue == wxT("home")){
5963                                 *PropType = PROPERTY_HOME;
5964                                                         
5965                         } else {
5966                         
5967                                 *PropType = PROPERTY_NONE;
5968                         
5969                         }
5970                 
5971                         return;
5972                 
5973                 }
5974         
5975         }
5976         
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