Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced code from PREF for FN with ProcessIntegerValue.
[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                         ProcessIntegerValue(this, &SourceListPref, &PropertyValue, SourceCount);
616                 } else if (PropertyName == wxT("MEDIATYPE")){
617                 
618                         SourceListMediatype.erase(*SourceCount);
619                         SourceListMediatype.insert(std::make_pair(*SourceCount, PropertyValue));
621                 } else {
622                 
623                         // Something else we don't know about so append
624                         // to the tokens variable.
625                         
626                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
627                         
628                                 if (FirstToken == TRUE){
629                                 
630                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
631                                         FirstToken = FALSE;
632                                 
633                                 } else {
634                                 
635                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
636                                 
637                                 }
638                         
639                         }
640                 
641                 }
642         
643         }       
644         
645         intPropertyLen = PropertySeg2.Len();
646         SplitPoints.clear();
647         SplitLength.clear();
648         intSplitsFound = 0;
649         intSplitSize = 0;
650         intPrevValue = 0;
651         
652         CaptureString(&PropertySeg2, FALSE);
653         
654         // Add the data to the General/Home/Work address variables.
655                 
656         switch(PropType){
657                 case PROPERTY_NONE:
658                         break;
659                 case PROPERTY_HOME:
660                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
661                         break;
662                 case PROPERTY_WORK:
663                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
664                         break;
665         }
666         
667         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
668         
669         if (!PropertyTokens.IsEmpty()){
670         
671                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
672         
673         }
677 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
679         std::map<int, int> SplitPoints;
680         std::map<int, int> SplitLength;
682         int intPrevValue = 5;
683         int intPref = 0;                        
684         int intType = 0;
685         
686         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
688         intPrevValue = 4;
689         
690         wxString PropertyName;
691         wxString PropertyValue;
692         wxString PropertyData;
693         wxString PropertyTokens;
694         std::map<int,int>::iterator SLiter;
695         bool FirstToken = TRUE;
696         
697         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
698         intiter != SplitPoints.end(); ++intiter){
699         
700                 SLiter = SplitLength.find(intiter->first);
701         
702                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
703                 
704                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
705                 PropertyName = PropertyElement.GetNextToken();                          
706                 PropertyValue = PropertyElement.GetNextToken();
707                 
708                 intPrevValue = intiter->second;
709                 
710                 CaptureString(&PropertyValue, FALSE);
711         
712                 if (PropertyName == wxT("ALTID")){
714                         XMLListAltID.erase(*XMLCount);
715                         XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
716                 
717                 }
718                 
719         }
721         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
725 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
727         std::map<int, int> SplitPoints;
728         std::map<int, int> SplitLength;
730         int intPrevValue = 8;
731         int intPref = 0;                        
732         int intType = 0;
733         
734         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
736         intPrevValue = 7;
737         
738         wxString PropertyName;
739         wxString PropertyValue;
740         wxString PropertyData;
741         wxString PropertyTokens;
742         std::map<int,int>::iterator SLiter;
743         bool FirstToken = TRUE;
744         
745         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
746         intiter != SplitPoints.end(); ++intiter){
747         
748                 SLiter = SplitLength.find(intiter->first);
749         
750                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
751                 
752                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
753                 PropertyName = PropertyElement.GetNextToken();                          
754                 PropertyValue = PropertyElement.GetNextToken();
755                 
756                 intPrevValue = intiter->second;
757                 
758                 CaptureString(&PropertyValue, FALSE);
759         
760                 if (PropertyName == wxT("ALTID")){
762                         GroupsListAltID.erase(*GroupCount);
763                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
764                 
765                 } else if (PropertyName == wxT("PID")){
767                         GroupsListPID.erase(*GroupCount);
768                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
769                 
770                 } else if (PropertyName == wxT("PREF")){
772                         ProcessIntegerValue(this, &GroupsListPref, &PropertyValue, GroupCount);
773                 
774                 } else if (PropertyName == wxT("MEDIATYPE")){
776                         GroupsListMediaType.erase(*GroupCount);
777                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
778                 
779                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
780                         
781                         if (FirstToken == TRUE){
782                                 
783                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
784                                 FirstToken = FALSE;
785                                 
786                         } else {
787                         
788                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
789                                 
790                         }
791                         
792                 }
793                 
794         }
796         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
798         if (!PropertyTokens.IsEmpty()){
799         
800                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
801         
802         }
807 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
809         std::map<int, int> SplitPoints;
810         std::map<int, int> SplitLength;
812         int intPrevValue = 4;
813         int intPref = 0;                        
814         int intType = 0;
815         
816         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
818         intPrevValue = 3;
819         
820         wxString PropertyName;
821         wxString PropertyValue;
822         wxString PropertyData;
823         wxString PropertyTokens;
824         std::map<int,int>::iterator SLiter;
825         bool FirstToken = TRUE;
826         
827         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
828         intiter != SplitPoints.end(); ++intiter){
829         
830                 SLiter = SplitLength.find(intiter->first);
831         
832                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
833                 
834                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
835                 PropertyName = PropertyElement.GetNextToken();                          
836                 PropertyValue = PropertyElement.GetNextToken();
837                 
838                 intPrevValue = intiter->second;
839                 
840                 CaptureString(&PropertyValue, FALSE);
841                 
842                 if (PropertyName == wxT("TYPE")){
844                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
845                                 PropertyValue == wxT("work") ){
847                                 FullNamesListType.erase(*FNCount);
848                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
849                 
850                         }
851                 
852                 } else if (PropertyName == wxT("LANGUAGE")){
854                         FullNamesListLanguage.erase(*FNCount);
855                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
856                 
857                 } else if (PropertyName == wxT("ALTID")){
858                 
859                         FullNamesListAltID.erase(*FNCount);
860                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
861                 
862                 } else if (PropertyName == wxT("PID")){
864                         FullNamesListPID.erase(*FNCount);
865                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
866                 
867                 } else if (PropertyName == wxT("PREF")){
869                         ProcessIntegerValue(this, &FullNamesListPref, &PropertyValue, FNCount);
870                 
871                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
872                         
873                         if (FirstToken == TRUE){
874                                 
875                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
876                                 FirstToken = FALSE;
877                                 
878                         } else {
879                         
880                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
881                                 
882                         }
883                         
884                 } 
885         
886         }
888         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
890         if (!PropertyTokens.IsEmpty()){
891         
892                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
893         
894         }
898 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
900         std::map<int, int> SplitPoints;
901         std::map<int, int> SplitLength;
903         int intPrevValue = 3;
904         int intPref = 0;                        
905         int intType = 0;
906         
907         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
908         
909         intPrevValue = 2;
910         
911         wxString PropertyName;
912         wxString PropertyValue;
913         wxString PropertyData;
914         wxString PropertyTokens;
915         std::map<int,int>::iterator SLiter;
916         bool FirstToken = TRUE;
917         
918         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
919         intiter != SplitPoints.end(); ++intiter){
920         
921                 SLiter = SplitLength.find(intiter->first);
922         
923                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
924                 
925                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
926                 PropertyName = PropertyElement.GetNextToken();                          
927                 PropertyValue = PropertyElement.GetNextToken();
928                 
929                 intPrevValue = intiter->second;
930                 
931                 CaptureString(&PropertyValue, FALSE);
932                 
933                 if (PropertyName == wxT("ALTID")){
935                         NameAltID = PropertyValue;
936                 
937                 } else if (PropertyName == wxT("LANGUAGE")){
938                 
939                         NameLanguage = PropertyValue;
940                 
941                 } else if (PropertyName == wxT("SORT-AS")){
942                 
943                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
944                                 PropertyValue.Len() >= 3){
945                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
946                         }
947                 
948                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
949                         
950                         if (FirstToken == TRUE){
951                                 
952                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
953                                 FirstToken = FALSE;
954                                 
955                         } else {
956                         
957                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
958                                 
959                         }
960                         
961                 }
962         
963         }
964         
965         // Split the name data.
966         
967         int intSplitSeek = 0;           
968         int intSplitsFound = 0;
969         int intSplitSize = 0;
970         int intPropertyLen = PropertySeg2.Len();
971         
972         std::map<int,wxString> NameValues;
973         intPrevValue = 0;                                       
974         
975         for (int i = 0; i <= intPropertyLen; i++){
976         
977                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
978                         
979                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
980                         
981                         intSplitSeek = i;
982                         intSplitSeek++;
983                         
984                         if (intSplitsFound == 4){
985                         
986                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
987                                 break;
988                         
989                         }
990                         
991                         intSplitSize = 0;
992                         continue;
993         
994                 }
995                 
996                 intSplitSize++;
998         }
999         
1000         // Split the data into several parts.
1001                         
1002         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
1003         iter != NameValues.end(); ++iter){
1004         
1005                 if (iter->first == 1){
1006                 
1007                         // Deal with family name.
1008                         
1009                         NameSurname = iter->second;
1010                 
1011                 } else if (iter->first == 2){
1012                 
1013                         // Deal with given names.
1014                         
1015                         NameForename = iter->second;
1016                 
1017                 } else if (iter->first == 3){
1018                 
1019                         // Deal with additional names.
1020                         
1021                         NameOtherNames = iter->second;
1022                 
1023                 } else if (iter->first == 4){
1024                 
1025                         // Deal with honorifix prefixes and suffixes.
1027                         NameTitle = iter->second;
1028                 
1029                         iter++;
1030                         
1031                         if (iter == NameValues.end()){
1032                         
1033                                 break;
1034                         
1035                         }
1036                 
1037                         NameSuffix = iter->second;
1038                 
1039                 }
1040         
1041         }
1042         
1043         // Add the name token data.
1044         
1045         if (!PropertyTokens.IsEmpty()){
1046         
1047                 NameTokens = PropertyTokens;
1048         
1049         }
1053 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1055         size_t intPropertyLen = PropertySeg1.Len();
1056         std::map<int, int> SplitPoints;
1057         std::map<int, int> SplitLength;
1058         std::map<int, int>::iterator SLiter;                    
1059         wxString PropertyData;
1060         wxString PropertyName;
1061         wxString PropertyValue;
1062         wxString PropertyTokens;
1063         bool FirstToken = TRUE;
1064         int intSplitsFound = 0;
1065         int intSplitSize = 0;
1066         int intPrevValue = 14;
1067         int intPref = 0;                        
1068         int intType = 0;
1069         
1070         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1071         
1072         intPrevValue = 13;
1074         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1075         intiter != SplitPoints.end(); ++intiter){
1076         
1077                 SLiter = SplitLength.find(intiter->first);
1078         
1079                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1080                 
1081                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1082                 PropertyName = PropertyElement.GetNextToken();                          
1083                 PropertyValue = PropertyElement.GetNextToken();
1084                 
1085                 intPrevValue = intiter->second;
1086                 
1087                 // Process properties.
1088                 
1089                 size_t intPropertyValueLen = PropertyValue.Len();
1090                 
1091                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1092                         
1093                         PropertyValue.Trim();
1094                         PropertyValue.RemoveLast();
1095                         
1096                 }                               
1097                 
1098                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1099                         
1100                         PropertyValue.Remove(0, 1);
1101                         
1102                 }                       
1103                 
1104                 CaptureString(&PropertyValue, FALSE);
1105                 
1106                 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1107                 
1108                         continue;
1109                 
1110                 }
1111                                                         
1112                 if (FirstToken == TRUE){
1113                                 
1114                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1115                         FirstToken = FALSE;
1116                                 
1117                 } else {
1118                                 
1119                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1120                                 
1121                 }
1122         
1123         }       
1124         
1125         CaptureString(&PropertySeg2, FALSE);
1126         
1127         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1128         
1129         if (!PropertyTokens.IsEmpty()){
1130         
1131                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1132         
1133         }
1137 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1139         std::map<int, int> SplitPoints;
1140         std::map<int, int> SplitLength;
1142         int intPrevValue = 10;
1143         int intPref = 0;                        
1144         
1145         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1146         
1147         intPrevValue = 9;
1148         
1149         PropertyType PropType = PROPERTY_NONE;
1150         
1151         // Look for type before continuing.
1152         
1153         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1154         
1155         intPrevValue = 9;
1156         
1157         std::map<int, wxString> *NicknamesList = NULL;
1158         std::map<int, wxString> *NicknamesListType = NULL;
1159         std::map<int, wxString> *NicknamesListLanguage = NULL;
1160         std::map<int, wxString> *NicknamesListAltID = NULL;
1161         std::map<int, wxString> *NicknamesListPID = NULL;
1162         std::map<int, wxString> *NicknamesListTokens = NULL;            
1163         std::map<int, int> *NicknamesListPref = NULL;
1164         
1165         switch(PropType){
1166                 case PROPERTY_NONE:
1167                         NicknamesList = &GeneralNicknamesList;
1168                         NicknamesListType = &GeneralNicknamesListType;
1169                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1170                         NicknamesListAltID = &GeneralNicknamesListAltID;
1171                         NicknamesListPID = &GeneralNicknamesListPID;
1172                         NicknamesListTokens = &GeneralNicknamesListTokens;
1173                         NicknamesListPref = &GeneralNicknamesListPref;
1174                         break;
1175                 case PROPERTY_HOME:
1176                         NicknamesList = &HomeNicknamesList;
1177                         NicknamesListType = &HomeNicknamesListType;
1178                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1179                         NicknamesListAltID = &HomeNicknamesListAltID;
1180                         NicknamesListPID = &HomeNicknamesListPID;
1181                         NicknamesListTokens = &HomeNicknamesListTokens;
1182                         NicknamesListPref = &HomeNicknamesListPref;
1183                         break;
1184                 case PROPERTY_WORK:
1185                         NicknamesList = &BusinessNicknamesList;
1186                         NicknamesListType = &BusinessNicknamesListType;
1187                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1188                         NicknamesListAltID = &BusinessNicknamesListAltID;
1189                         NicknamesListPID = &BusinessNicknamesListPID;
1190                         NicknamesListTokens = &BusinessNicknamesListTokens;
1191                         NicknamesListPref = &BusinessNicknamesListPref;
1192                         break;
1193         }
1194         
1195         std::map<int, int>::iterator SLiter;    
1196         wxString PropertyData;
1197         wxString PropertyName;
1198         wxString PropertyValue;
1199         wxString PropertyTokens;
1200         bool FirstToken = TRUE;
1201         
1202         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1203         intiter != SplitPoints.end(); ++intiter){
1204         
1205                 SLiter = SplitLength.find(intiter->first);
1206         
1207                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1208                 
1209                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1210                 PropertyName = PropertyElement.GetNextToken();                          
1211                 PropertyValue = PropertyElement.GetNextToken();
1212                 
1213                 intPrevValue = intiter->second;
1214                 
1215                 CaptureString(&PropertyValue, FALSE);
1216                 
1217                 if (PropertyName == wxT("ALTID")){
1219                         NicknamesListAltID->erase(*NicknameCount);
1220                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1221                 
1222                 } else if (PropertyName == wxT("PID")){
1224                         NicknamesListPID->erase(*NicknameCount);
1225                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
1227                 } else if (PropertyName == wxT("PREF")){
1229                         int PriorityNumber = 0;
1230                         bool ValidNumber = TRUE;
1231                         
1232                         try{
1233                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1234                         }
1235                         
1236                         catch(std::invalid_argument &e){
1237                                 ValidNumber = FALSE;
1238                         }
1240                         if (ValidNumber == TRUE){
1242                                 NicknamesListPref->erase(*NicknameCount);
1243                                 NicknamesListPref->insert(std::make_pair(*NicknameCount, PriorityNumber));
1245                         }
1246                 
1247                 } else if (PropertyName == wxT("LANGUAGE")){
1249                         NicknamesListLanguage->erase(*NicknameCount);
1250                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
1252                 } else {
1253                 
1254                         // Something else we don't know about so append
1255                         // to the tokens variable.
1256                 
1257                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1258                 
1259                                 if (FirstToken == TRUE){
1260                         
1261                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1262                                         FirstToken = FALSE;
1263                         
1264                                 } else {
1265                         
1266                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1267                         
1268                                 }
1269                 
1270                         }
1271                 
1272                 }
1273                 
1274         }
1275         
1276         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1277         
1278         // Add the name token data.
1279         
1280         if (!PropertyTokens.IsEmpty()){
1281         
1282                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1283         
1284         }
1288 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1290         std::map<int, int> SplitPoints;
1291         std::map<int, int> SplitLength;
1292         std::map<int, int>::iterator SLiter;                    
1293         wxString PropertyData;
1294         wxString PropertyName;
1295         wxString PropertyValue;
1296         wxString PropertyTokens;
1297         bool FirstToken = TRUE;
1298         int intPrevValue = 8;
1300         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1302         intPrevValue = 7;                       
1303         
1304         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1305         intiter != SplitPoints.end(); ++intiter){
1306         
1307                 SLiter = SplitLength.find(intiter->first);
1308         
1309                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1310                 
1311                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1312                 PropertyName = PropertyElement.GetNextToken();                          
1313                 PropertyValue = PropertyElement.GetNextToken();
1314                 
1315                 intPrevValue = intiter->second;
1316                 
1317                 // Process properties.
1318                 
1319                 size_t intPropertyValueLen = PropertyValue.Len();
1320                 
1321                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1322                         
1323                         PropertyValue.Trim();
1324                         PropertyValue.RemoveLast();
1325                         
1326                 }                               
1327                 
1328                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1329                         
1330                         PropertyValue.Remove(0, 1);
1331                         
1332                 }                               
1333                 
1334                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1336                         if (FirstToken == TRUE){
1337         
1338                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1339                                 FirstToken = FALSE;
1340         
1341                         } else {
1342         
1343                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1344         
1345                         }
1347                 }
1348         
1349         }       
1351         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1352         
1353         wxString GenderComponent;
1354         
1355         if (GenderData.CountTokens() >= 2){
1356         
1357                 Gender = GenderData.GetNextToken();
1358                 GenderDetails = GenderData.GetString();
1359         
1360                 CaptureString(&GenderDetails, FALSE);
1361                                                 
1362         } else {
1363         
1364                 Gender = GenderData.GetNextToken();
1365         
1366         }
1367         
1368         if (!PropertyTokens.IsEmpty()){
1369         
1370                 GenderTokens = PropertyTokens;
1371         
1372         }
1376 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1378         // Process date. Preserve the remainder in the string.
1380         std::map<int, int> SplitPoints;
1381         std::map<int, int> SplitLength;
1382         std::map<int, int>::iterator SLiter;                    
1383         wxString PropertyData;
1384         wxString PropertyName;
1385         wxString PropertyValue;
1386         wxString PropertyTokens;
1387         bool BirthdayText = FALSE;
1388         int intPrevValue = 6;
1390         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1392         intPrevValue = 5;
1394         // Look for type before continuing.
1396         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1397         intiter != SplitPoints.end(); ++intiter){
1399                 SLiter = SplitLength.find(intiter->first);
1401                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1402         
1403                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1404                 PropertyName = PropertyElement.GetNextToken();                          
1405                 PropertyValue = PropertyElement.GetNextToken();
1406         
1407                 intPrevValue = intiter->second;
1408         
1409                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1410         
1411                         CaptureString(&PropertySeg2, FALSE);
1412                         Birthday = PropertySeg2;
1413                         BirthdayText = TRUE;
1414         
1415                 }
1417         }
1419         // Setup blank lines for later on.
1420         
1421         intPrevValue = 5;
1422         bool FirstToken = TRUE;
1424         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1425         intiter != SplitPoints.end(); ++intiter){
1427                 SLiter = SplitLength.find(intiter->first);
1429                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1430         
1431                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1432                 PropertyName = PropertyElement.GetNextToken();                          
1433                 PropertyValue = PropertyElement.GetNextToken();
1434         
1435                 intPrevValue = intiter->second;
1436         
1437                 // Process properties.
1438         
1439                 CaptureString(&PropertyValue, FALSE);
1440         
1441                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1442                 
1443                         PropertyValue.Trim();
1444                         PropertyValue.RemoveLast();
1445                 
1446                 }                               
1447         
1448                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1449                 
1450                         PropertyValue.Remove(0, 1);
1451                 
1452                 }                               
1453         
1454                 if (PropertyName == wxT("ALTID")){
1456                         BirthdayAltID = PropertyValue;
1457         
1458                 } else if (PropertyName == wxT("CALSCALE")){
1459         
1460                         BirthdayCalScale = PropertyValue;
1461         
1462                 } else if (PropertyName != wxT("VALUE")) {
1463         
1464                         // Something else we don't know about so append
1465                         // to the tokens variable.
1466                 
1467                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1468                 
1469                                 if (FirstToken == TRUE){
1470         
1471                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1472                                         FirstToken = FALSE;
1473         
1474                                 } else {
1475         
1476                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1477         
1478                                 }
1479                                 
1480                         }
1481                         
1482                 }
1484         }       
1486         // Add the data to the variables and form.
1487         
1488         if (BirthdayText == FALSE){
1489         
1490                 Birthday = PropertySeg2;
1492         }
1493         
1494         if (!PropertyTokens.IsEmpty()){
1495         
1496                 BirthdayTokens = PropertyTokens;
1498         }
1502 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1504         // Process date. Preserve the remainder in the string.
1506         std::map<int, int> SplitPoints;
1507         std::map<int, int> SplitLength;
1508         std::map<int, int>::iterator SLiter;                    
1509         wxString PropertyData;
1510         wxString PropertyName;
1511         wxString PropertyValue;
1512         wxString PropertyTokens;
1513         bool AnniversaryText = FALSE;
1514         int intPrevValue = 13;
1516         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1518         intPrevValue = 12;
1520         // Look for type before continuing.
1522         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1523         intiter != SplitPoints.end(); ++intiter){
1525                 SLiter = SplitLength.find(intiter->first);
1527                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1528         
1529                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1530                 PropertyName = PropertyElement.GetNextToken();                          
1531                 PropertyValue = PropertyElement.GetNextToken();
1532         
1533                 intPrevValue = intiter->second;
1534         
1535                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1536         
1537                         CaptureString(&PropertySeg2, FALSE);
1538                         Anniversary = PropertySeg2;
1539                         AnniversaryText = TRUE;
1540         
1541                 }
1543         }
1545         // Setup blank lines for later on.
1546         
1547         intPrevValue = 12;
1548         bool FirstToken = TRUE;
1550         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1551         intiter != SplitPoints.end(); ++intiter){
1553                 SLiter = SplitLength.find(intiter->first);
1555                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1556         
1557                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1558                 PropertyName = PropertyElement.GetNextToken();                          
1559                 PropertyValue = PropertyElement.GetNextToken();
1560         
1561                 intPrevValue = intiter->second;
1562         
1563                 // Process properties.
1564         
1565                 CaptureString(&PropertyValue, FALSE);
1566         
1567                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1568                 
1569                         PropertyValue.Trim();
1570                         PropertyValue.RemoveLast();
1571                 
1572                 }                               
1573         
1574                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1575                 
1576                         PropertyValue.Remove(0, 1);
1577                 
1578                 }                               
1579         
1580                 if (PropertyName == wxT("ALTID")){
1582                         AnniversaryAltID = PropertyValue;
1583         
1584                 } else if (PropertyName == wxT("CALSCALE")){
1585         
1586                         AnniversaryCalScale = PropertyValue;
1587         
1588                 } else if (PropertyName != wxT("VALUE")) {
1589         
1590                         // Something else we don't know about so append
1591                         // to the tokens variable.
1592                 
1593                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1594                 
1595                                 if (FirstToken == TRUE){
1596         
1597                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1598                                         FirstToken = FALSE;
1599         
1600                                 } else {
1601         
1602                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1603         
1604                                 }
1605                                 
1606                         }
1607                         
1608                 }
1610         }       
1612         // Add the data to the variables and form.
1613         
1614         if (AnniversaryText == FALSE){
1615         
1616                 Anniversary = PropertySeg2;
1618         }
1619         
1620         if (!PropertyTokens.IsEmpty()){
1621         
1622                 AnniversaryTokens = PropertyTokens;
1624         }
1628 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1630         std::map<int, int> SplitPoints;
1631         std::map<int, int> SplitLength;
1633         int intPrevValue = 4;
1634         int intPref = 0;                        
1635         
1636         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1637         
1638         intPrevValue = 3;
1639         
1640         PropertyType PropType = PROPERTY_NONE;
1641         
1642         // Look for type before continuing.
1643         
1644         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1645         
1646         intPrevValue = 3;
1647         
1648         std::map<int, wxString> *TZList = NULL;
1649         std::map<int, wxString> *TZListType = NULL;
1650         std::map<int, wxString> *TZListMediatype = NULL;
1651         std::map<int, wxString> *TZListAltID = NULL;
1652         std::map<int, wxString> *TZListPID = NULL;
1653         std::map<int, wxString> *TZListTokens = NULL;           
1654         std::map<int, int> *TZListPref = NULL;
1655         
1656         switch(PropType){
1657                 case PROPERTY_NONE:
1658                         TZList = &GeneralTZList;
1659                         TZListType = &GeneralTZListType;
1660                         TZListMediatype = &GeneralTZListMediatype;
1661                         TZListAltID = &GeneralTZListAltID;
1662                         TZListPID = &GeneralTZListPID;
1663                         TZListTokens = &GeneralTZListTokens;
1664                         TZListPref = &GeneralTZListPref;
1665                         break;
1666                 case PROPERTY_HOME:
1667                         TZList = &HomeTZList;
1668                         TZListType = &HomeTZListType;
1669                         TZListMediatype = &HomeTZListMediatype;
1670                         TZListAltID = &HomeTZListAltID;
1671                         TZListPID = &HomeTZListPID;
1672                         TZListTokens = &HomeTZListTokens;
1673                         TZListPref = &HomeTZListPref;
1674                         break;
1675                 case PROPERTY_WORK:
1676                         TZList = &BusinessTZList;
1677                         TZListType = &BusinessTZListType;
1678                         TZListMediatype = &BusinessTZListMediatype;
1679                         TZListAltID = &BusinessTZListAltID;
1680                         TZListPID = &BusinessTZListPID;
1681                         TZListTokens = &BusinessTZListTokens;
1682                         TZListPref = &BusinessTZListPref;
1683                         break;
1684         }
1685         
1686         std::map<int, int>::iterator SLiter;    
1687         wxString PropertyData;
1688         wxString PropertyName;
1689         wxString PropertyValue;
1690         wxString PropertyTokens;
1691         bool FirstToken = TRUE;
1692         
1693         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1694         intiter != SplitPoints.end(); ++intiter){
1695         
1696                 SLiter = SplitLength.find(intiter->first);
1697         
1698                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1699                 
1700                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1701                 PropertyName = PropertyElement.GetNextToken();                          
1702                 PropertyValue = PropertyElement.GetNextToken();
1703                 
1704                 intPrevValue = intiter->second;
1705                 
1706                 CaptureString(&PropertyValue, FALSE);
1708                 if (PropertyName == wxT("ALTID")){
1710                         TZListAltID->erase(*TimeZoneCount);
1711                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1712                 
1713                 } else if (PropertyName == wxT("PID")){
1715                         TZListPID->erase(*TimeZoneCount);
1716                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1718                 } else if (PropertyName == wxT("PREF")){
1720                         int PriorityNumber = 0;
1721                         bool ValidNumber = TRUE;
1722                         
1723                         try{
1724                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1725                         }
1726                         
1727                         catch(std::invalid_argument &e){
1728                                 ValidNumber = FALSE;
1729                         }
1731                         if (ValidNumber == TRUE){
1733                                 TZListPref->erase(*TimeZoneCount);
1734                                 TZListPref->insert(std::make_pair(*TimeZoneCount, PriorityNumber));
1736                         }
1737                 
1738                 } else if (PropertyName == wxT("MEDIATYPE")){
1740                         TZListMediatype->erase(*TimeZoneCount);
1741                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1743                 } else {
1744                 
1745                         // Something else we don't know about so append
1746                         // to the tokens variable.
1747                 
1748                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1749                 
1750                                 if (FirstToken == TRUE){
1751                         
1752                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1753                                         FirstToken = FALSE;
1754                         
1755                                 } else {
1756                         
1757                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1758                         
1759                                 }
1760                 
1761                         }
1762                 
1763                 }
1764                 
1765         }
1766         
1767         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1768         
1769         // Add the name token data.
1770         
1771         if (!PropertyTokens.IsEmpty()){
1772         
1773                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1774         
1775         }
1780 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1782         size_t intPropertyLen = PropertySeg1.Len();
1783         std::map<int, int> SplitPoints;
1784         std::map<int, int> SplitLength;
1785         std::map<int, int>::iterator SLiter;                    
1786         wxString PropertyData;
1787         wxString PropertyName;
1788         wxString PropertyValue;
1789         wxString PropertyTokens;
1790         wxString AddressLabel;
1791         wxString AddressLang;
1792         wxString AddressAltID;
1793         wxString AddressPID;
1794         wxString AddressTokens;
1795         wxString AddressGeo;
1796         wxString AddressTimezone;
1797         wxString AddressType;
1798         wxString AddressMediatype;
1799         wxString AddressPOBox;
1800         wxString AddressExtended;
1801         wxString AddressStreet;
1802         wxString AddressLocality;
1803         wxString AddressCity;
1804         wxString AddressRegion;
1805         wxString AddressPostalCode;
1806         wxString AddressCountry;
1807         bool FirstToken = TRUE;                 
1808         int intSplitsFound = 0;
1809         int intSplitSize = 0;
1810         int intPrevValue = 5;
1811         int intPref = 0;                        
1812         int intType = 0;
1813         long ListCtrlIndex;
1814         
1815         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1816         
1817         intPrevValue = 4;
1818         
1819         PropertyType PropType = PROPERTY_NONE;
1820                 
1821         // Look for type before continuing.
1822         
1823         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1824         
1825         intPrevValue = 4;
1826         
1827         std::map<int, wxString> *AddressList = NULL;
1828         std::map<int, wxString> *AddressListTown = NULL;
1829         std::map<int, wxString> *AddressListCounty = NULL;
1830         std::map<int, wxString> *AddressListPostCode = NULL;
1831         std::map<int, wxString> *AddressListCountry = NULL;
1832         std::map<int, wxString> *AddressListLabel = NULL;
1833         std::map<int, wxString> *AddressListLang = NULL;                
1834         std::map<int, wxString> *AddressListAltID = NULL;
1835         std::map<int, wxString> *AddressListPID = NULL;
1836         std::map<int, wxString> *AddressListTokens = NULL;
1837         std::map<int, wxString> *AddressListGeo = NULL;
1838         std::map<int, wxString> *AddressListTimezone = NULL;            
1839         std::map<int, wxString> *AddressListType = NULL;
1840         std::map<int, wxString> *AddressListMediatype = NULL;
1841         std::map<int, int> *AddressListPref = NULL;
1843         switch(PropType){
1844                 case PROPERTY_NONE:
1845                         AddressList = &GeneralAddressList;
1846                         AddressListTown = &GeneralAddressListTown;
1847                         AddressListCounty = &GeneralAddressListCounty;
1848                         AddressListPostCode = &GeneralAddressListPostCode;
1849                         AddressListCountry = &GeneralAddressListCountry;
1850                         AddressListLabel = &GeneralAddressListLabel;
1851                         AddressListLang = &GeneralAddressListLang;              
1852                         AddressListAltID = &GeneralAddressListAltID;
1853                         AddressListPID = &GeneralAddressListPID;
1854                         AddressListTokens = &GeneralAddressListTokens;
1855                         AddressListGeo = &GeneralAddressListGeo;
1856                         AddressListTimezone = &GeneralAddressListTimezone;
1857                         AddressListType = &GeneralAddressListType;
1858                         AddressListMediatype = &GeneralAddressListMediatype;
1859                         AddressListPref = &GeneralAddressListPref;              
1860                         break;
1861                 case PROPERTY_HOME:
1862                         AddressList = &HomeAddressList;
1863                         AddressListTown = &HomeAddressListTown;
1864                         AddressListCounty = &HomeAddressListCounty;
1865                         AddressListPostCode = &HomeAddressListPostCode;
1866                         AddressListCountry = &HomeAddressListCountry;
1867                         AddressListLabel = &HomeAddressListLabel;
1868                         AddressListLang = &HomeAddressListLang;         
1869                         AddressListAltID = &HomeAddressListAltID;
1870                         AddressListPID = &HomeAddressListPID;
1871                         AddressListTokens = &HomeAddressListTokens;
1872                         AddressListGeo = &HomeAddressListGeo;
1873                         AddressListTimezone = &HomeAddressListTimezone;
1874                         AddressListType = &HomeAddressListType;
1875                         AddressListMediatype = &HomeAddressListMediatype;
1876                         AddressListPref = &HomeAddressListPref;
1877                         break;
1878                 case PROPERTY_WORK:
1879                         AddressList = &BusinessAddressList;
1880                         AddressListTown = &BusinessAddressListTown;
1881                         AddressListCounty = &BusinessAddressListCounty;
1882                         AddressListPostCode = &BusinessAddressListPostCode;
1883                         AddressListCountry = &BusinessAddressListCountry;
1884                         AddressListLabel = &BusinessAddressListLabel;
1885                         AddressListLang = &BusinessAddressListLang;             
1886                         AddressListAltID = &BusinessAddressListAltID;
1887                         AddressListPID = &BusinessAddressListPID;
1888                         AddressListTokens = &BusinessAddressListTokens;
1889                         AddressListGeo = &BusinessAddressListGeo;
1890                         AddressListTimezone = &BusinessAddressListTimezone;
1891                         AddressListType = &BusinessAddressListType;
1892                         AddressListMediatype = &BusinessAddressListMediatype;
1893                         AddressListPref = &BusinessAddressListPref;
1894                         break;
1895         }
1896         
1897         intPrevValue = 4;
1898         
1899         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1900         intiter != SplitPoints.end(); ++intiter){
1901         
1902                 SLiter = SplitLength.find(intiter->first);
1903         
1904                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1905                 
1906                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1907                 PropertyName = PropertyElement.GetNextToken();                          
1908                 PropertyValue = PropertyElement.GetNextToken();
1909                 
1910                 intPrevValue = intiter->second;
1911                 
1912                 CaptureString(&PropertyValue, FALSE);
1913                 
1914                 // Process properties.
1915                 
1916                 if (PropertyName == wxT("LABEL")){
1917                 
1918                         AddressListLabel->erase(*AddressCount);
1919                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1920                                 
1921                 } else if (PropertyName == wxT("LANGUAGE")){
1922                 
1923                         AddressListLang->erase(*AddressCount);
1924                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1925                 
1926                 } else if (PropertyName == wxT("ALTID")){
1928                         AddressListAltID->erase(*AddressCount);
1929                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1930                 
1931                 } else if (PropertyName == wxT("PID")){
1933                         AddressListPID->erase(*AddressCount);
1934                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1935                 
1936                 } else if (PropertyName == wxT("GEO")){
1937                 
1938                         AddressListGeo->erase(*AddressCount);
1939                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1940                 
1941                 } else if (PropertyName == wxT("TZ")){
1943                         AddressListTimezone->erase(*AddressCount);
1944                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1945                 
1946                 } else if (PropertyName == wxT("MEDIATYPE")){
1948                         AddressListMediatype->erase(*AddressCount);
1949                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1950                 
1951                 } else if (PropertyName == wxT("PREF")){
1952                         
1953                         int PriorityNumber = 0;
1954                         bool ValidNumber = TRUE;
1955                         
1956                         try{
1957                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1958                         }
1959                         
1960                         catch(std::invalid_argument &e){
1961                                 ValidNumber = FALSE;
1962                         }
1964                         if (ValidNumber == TRUE){
1966                                 AddressListPref->erase(*AddressCount);
1967                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1969                         }
1970                 
1971                 } else {
1972                 
1973                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1974                         
1975                                 if (FirstToken == TRUE){
1976                                 
1977                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1978                                         FirstToken = FALSE;
1979                                 
1980                                 } else {
1981                                 
1982                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1983                                 
1984                                 }
1985                         
1986                         }
1987                 
1988                 }
1989         
1990         }                       
1991         
1992         // Split the address. 
1994         //std::map<int, int>::iterator SLiter;
1995         intPropertyLen = PropertySeg2.Len();
1996         SplitPoints.clear();
1997         SplitLength.clear();
1998         intSplitsFound = 0;
1999         intSplitSize = 0;
2000         intPrevValue = 0;
2001         
2002         for (int i = 0; i <= intPropertyLen; i++){
2004                 intSplitSize++;
2005         
2006                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
2007         
2008                         intSplitsFound++;
2009                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
2010                         
2011                         if (intSplitsFound == 6){ 
2012                         
2013                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2014                                 break; 
2015                                 
2016                         } else {
2017                         
2018                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2019                         
2020                         }
2021                         
2022                         intSplitSize = 0;                                       
2023         
2024                 }
2026         }
2027         
2028         // Split the data into several parts.                   
2029         
2030         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2031         intiter != SplitPoints.end(); ++intiter){
2032                         
2033                 if (intiter->first == 1){
2034                 
2035                         // Deal with PO Box.
2036                         
2037                         SLiter = SplitLength.find(1);
2038                                                                 
2039                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2040                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2041                         intPrevValue = intiter->second;
2042                 
2043                 } else if (intiter->first == 2){
2044                 
2045                         // Deal with extended address.
2046                         
2047                         SLiter = SplitLength.find(2);
2048                         
2049                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2050                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2051                         intPrevValue = intiter->second;
2052                 
2053                 } else if (intiter->first == 3){
2054                 
2055                         // Deal with street address.
2056                         
2057                         SLiter = SplitLength.find(3);
2058                                                                 
2059                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2060                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2061                         intPrevValue = intiter->second;
2062                 
2063                 } else if (intiter->first == 4){
2064                 
2065                         // Deal with locality
2067                         SLiter = SplitLength.find(4);
2068                         
2069                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2070                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2071                         intPrevValue = intiter->second;
2072                         
2073                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2074                 
2075                 } else if (intiter->first == 5){
2076                 
2077                         // Deal with region.
2079                         SLiter = SplitLength.find(5);
2080                         
2081                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2082                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2083                         intPrevValue = intiter->second;
2084                         
2085                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2086                 
2087                 } else if (intiter->first == 6){
2088                 
2089                         // Deal with post code.
2091                         SLiter = SplitLength.find(6);
2092                         
2093                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2094                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2095                         intPrevValue = intiter->second;
2096                         
2097                         // Deal with country.
2098                                                 
2099                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2100                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2101                         
2102                         break;
2103                 
2104                 }
2105         
2106         }       
2107         
2108         // Add the data to the General/Home/Work address variables.
2109         
2110         CaptureString(&AddressStreet, FALSE); 
2111         CaptureString(&AddressLocality, FALSE);
2112         CaptureString(&AddressRegion, FALSE);
2113         CaptureString(&AddressPostalCode, FALSE);
2114         CaptureString(&AddressCountry, FALSE);
2115                 
2116         if (!PropertyTokens.IsEmpty()){
2117         
2118                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2119         
2120         }
2122         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2123         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2124         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2125         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2126         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2128         switch(PropType){
2129                 case PROPERTY_NONE:
2130                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2131                         break;
2132                 case PROPERTY_HOME:
2133                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2134                         break;
2135                 case PROPERTY_WORK:
2136                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2137                         break;
2138         }
2139         
2140         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2144 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2146         std::map<int, int> SplitPoints;
2147         std::map<int, int> SplitLength;
2149         int intPrevValue = 7;
2150         int intPref = 0;                        
2151         
2152         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2153         
2154         intPrevValue = 6;
2155         
2156         PropertyType PropType = PROPERTY_NONE;
2157                 
2158         // Look for type before continuing.
2159         
2160         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2161         
2162         std::map<int, wxString> *EmailList = NULL;
2163         std::map<int, wxString> *EmailListType = NULL;
2164         std::map<int, wxString> *EmailListAltID = NULL;
2165         std::map<int, wxString> *EmailListPID = NULL;
2166         std::map<int, wxString> *EmailListTokens = NULL;                
2167         std::map<int, int> *EmailListPref = NULL;
2169         switch(PropType){
2170                 case PROPERTY_NONE:
2171                         EmailList = &GeneralEmailList;
2172                         EmailListType = &GeneralEmailListType;
2173                         EmailListAltID = &GeneralEmailListAltID;
2174                         EmailListPID = &GeneralEmailListPID;
2175                         EmailListTokens = &GeneralEmailListTokens;              
2176                         EmailListPref = &GeneralEmailListPref;  
2177                         break;
2178                 case PROPERTY_HOME:
2179                         EmailList = &HomeEmailList;
2180                         EmailListType = &HomeEmailListType;
2181                         EmailListAltID = &HomeEmailListAltID;
2182                         EmailListPID = &HomeEmailListPID;
2183                         EmailListTokens = &HomeEmailListTokens;         
2184                         EmailListPref = &HomeEmailListPref;     
2185                         break;
2186                 case PROPERTY_WORK:
2187                         EmailList = &BusinessEmailList;
2188                         EmailListType = &BusinessEmailListType;
2189                         EmailListAltID = &BusinessEmailListAltID;
2190                         EmailListPID = &BusinessEmailListPID;
2191                         EmailListTokens = &BusinessEmailListTokens;             
2192                         EmailListPref = &BusinessEmailListPref; 
2193                         break;
2194         }
2195         
2196         intPrevValue = 6;
2197         
2198         std::map<int,int>::iterator SLiter;
2199         wxString PropertyData;
2200         wxString PropertyName;
2201         wxString PropertyValue;
2202         wxString PropertyTokens;
2203         bool FirstToken = TRUE;
2204         
2205         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2206         intiter != SplitPoints.end(); ++intiter){
2207         
2208                 SLiter = SplitLength.find(intiter->first);
2209         
2210                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2211                 
2212                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2213                 PropertyName = PropertyElement.GetNextToken();                          
2214                 PropertyValue = PropertyElement.GetNextToken();
2215                 
2216                 intPrevValue = intiter->second;
2217                 
2218                 CaptureString(&PropertyValue, FALSE);
2219                 
2220                 // Process properties.
2221                 
2222                 if (PropertyName == wxT("ALTID")){
2224                         EmailListAltID->erase(*EmailCount);
2225                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2226                 
2227                 } else if (PropertyName == wxT("PID")){
2229                         EmailListPID->erase(*EmailCount);
2230                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2231                 
2232                 } else if (PropertyName == wxT("PREF")){
2233                         
2234                         int PriorityNumber = 0;
2235                         bool ValidNumber = TRUE;
2236                         
2237                         try{
2238                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2239                         }
2240                         
2241                         catch(std::invalid_argument &e){
2242                                 ValidNumber = FALSE;
2243                         }
2245                         if (ValidNumber == TRUE){
2247                                 EmailListPref->erase(*EmailCount);
2248                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2250                         }
2251                 
2252                 } else {
2253                 
2254                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2255                         
2256                                 if (FirstToken == TRUE){
2257                                 
2258                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2259                                         FirstToken = FALSE;
2260                                 
2261                                 } else {
2262                                 
2263                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2264                                 
2265                                 }
2266                         
2267                         }
2268                 
2269                 }
2270         
2271         }
2272         
2273         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2274         
2275         // Add the name token data.
2276         
2277         if (!PropertyTokens.IsEmpty()){
2278         
2279                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2280         
2281         }       
2286 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2288         std::map<int, int> SplitPoints;
2289         std::map<int, int> SplitLength;
2291         int intPrevValue = 6;
2292         int intPref = 0;                        
2293         
2294         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2295         
2296         intPrevValue = 5;
2297         
2298         PropertyType PropType = PROPERTY_NONE;
2299                 
2300         // Look for type before continuing.
2301         
2302         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2303         
2304         std::map<int, wxString> *IMList = NULL;
2305         std::map<int, wxString> *IMListType = NULL;
2306         std::map<int, wxString> *IMListAltID = NULL;
2307         std::map<int, wxString> *IMListPID = NULL;
2308         std::map<int, wxString> *IMListTokens = NULL;
2309         std::map<int, wxString> *IMListMediatype = NULL;        
2310         std::map<int, int> *IMListPref = NULL;
2312         switch(PropType){
2313                 case PROPERTY_NONE:
2314                         IMList = &GeneralIMList;
2315                         IMListType = &GeneralIMListType;
2316                         IMListAltID = &GeneralIMListAltID;
2317                         IMListPID = &GeneralIMListPID;
2318                         IMListTokens = &GeneralIMListTokens;
2319                         IMListMediatype = &GeneralIMListMediatype;
2320                         IMListPref = &GeneralIMListPref;        
2321                         break;
2322                 case PROPERTY_HOME:
2323                         IMList = &HomeIMList;
2324                         IMListType = &HomeIMListType;
2325                         IMListAltID = &HomeIMListAltID;
2326                         IMListPID = &HomeIMListPID;
2327                         IMListTokens = &HomeIMListTokens;
2328                         IMListMediatype = &HomeIMListMediatype;         
2329                         IMListPref = &HomeIMListPref;   
2330                         break;
2331                 case PROPERTY_WORK:
2332                         IMList = &BusinessIMList;
2333                         IMListType = &BusinessIMListType;
2334                         IMListAltID = &BusinessIMListAltID;
2335                         IMListPID = &BusinessIMListPID;
2336                         IMListTokens = &BusinessIMListTokens;   
2337                         IMListMediatype = &BusinessIMListMediatype;     
2338                         IMListPref = &BusinessIMListPref;       
2339                         break;
2340         }
2341         
2342         intPrevValue = 5;
2343         
2344         std::map<int,int>::iterator SLiter;
2345         wxString PropertyData;
2346         wxString PropertyName;
2347         wxString PropertyValue;
2348         wxString PropertyTokens;
2349         bool FirstToken = TRUE;
2350         
2351         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2352         intiter != SplitPoints.end(); ++intiter){
2353         
2354                 SLiter = SplitLength.find(intiter->first);
2355         
2356                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2357                 
2358                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2359                 PropertyName = PropertyElement.GetNextToken();                          
2360                 PropertyValue = PropertyElement.GetNextToken();
2361                 
2362                 intPrevValue = intiter->second;
2363                 
2364                 CaptureString(&PropertyValue, FALSE);
2365                 
2366                 // Process properties.
2367                 
2368                 if (PropertyName == wxT("ALTID")){
2370                         IMListAltID->erase(*IMCount);
2371                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2372                 
2373                 } else if (PropertyName == wxT("PID")){
2375                         IMListPID->erase(*IMCount);
2376                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2377                 
2378                 } else if (PropertyName == wxT("MEDIATYPE")){
2380                         IMListMediatype->erase(*IMCount);
2381                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2382                 
2383                 } else if (PropertyName == wxT("PREF")){
2384                         
2385                         int PriorityNumber = 0;
2386                         bool ValidNumber = TRUE;
2387                         
2388                         try{
2389                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2390                         }
2391                         
2392                         catch(std::invalid_argument &e){
2393                                 ValidNumber = FALSE;
2394                         }
2396                         if (ValidNumber == TRUE){
2398                                 IMListPref->erase(*IMCount);
2399                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2401                         }
2402                 
2403                 } else {
2404                 
2405                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2406                         
2407                                 if (FirstToken == TRUE){
2408                                 
2409                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2410                                         FirstToken = FALSE;
2411                                 
2412                                 } else {
2413                                 
2414                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2415                                 
2416                                 }
2417                         
2418                         }
2419                 
2420                 }
2421         
2422         }
2423                 
2424         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2425         
2426         // Add the name token data.
2427         
2428         if (!PropertyTokens.IsEmpty()){
2429         
2430                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2431         
2432         }
2436 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2438         std::map<int, int> SplitPoints;
2439         std::map<int, int> SplitLength;
2440         std::map<int, int>::iterator SLiter;
2441         
2442         int intPref = 0;
2443         
2444         PropertyType PropType = PROPERTY_NONE;
2445                 
2446         // Look for type before continuing.
2447         
2448         wxString TelTypeUI;
2449         wxString TelTypeDetail;
2450         wxString PropertyData;
2451         wxString PropertyName;
2452         wxString PropertyValue;
2453         wxString PropertyTokens;
2454         
2455         std::map<int,int> TypeSplitPoints;
2456         std::map<int,int> TypeSplitLength;
2457         std::map<int,int>::iterator TSLiter;
2458         
2459         int intSplitSize = 0;
2460         int intSplitsFound = 0;
2461         int intSplitPoint = 0;
2462         int intType = 0;
2463         int intPrevValue = 5;
2464                 
2465         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2466         
2467         intPrevValue = 4;
2468         
2469         // Look for type before continuing.
2470         
2471         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2472         intiter != SplitPoints.end(); ++intiter){
2473         
2474                 SLiter = SplitLength.find(intiter->first);
2475         
2476                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2477                 
2478                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2479                 PropertyName = PropertyElement.GetNextToken();                          
2480                 PropertyValue = PropertyElement.GetNextToken();
2481                 
2482                 intPrevValue = intiter->second;
2484                 if (PropertyName == wxT("TYPE")){
2485                 
2486                         // Process each value in type and translate each
2487                         // part.
2488                 
2489                         // Strip out the quotes if they are there.
2490                 
2491                         size_t intPropertyValueLen = PropertyValue.Len();
2492                 
2493                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2494                         
2495                                 PropertyValue.Trim();
2496                                 PropertyValue.RemoveLast();
2497                         
2498                         }                               
2499                 
2500                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2501                         
2502                                 PropertyValue.Remove(0, 1);
2503                         
2504                         }
2505                         
2506                         TelTypeDetail = PropertyValue;
2507                         
2508                         intSplitSize = 0;
2509                         intSplitsFound = 0;
2510                         intSplitPoint = 0;
2511                         
2512                         for (int i = 0; i <= intPropertyValueLen; i++){
2513         
2514                                 intSplitSize++;
2515         
2516                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2517         
2518                                         if (intSplitsFound == 0){
2520                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2521                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2522                         
2523                                         } else {
2524                         
2525                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2526                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2527                         
2528                                         }                       
2530                                         intSplitsFound++;
2531                                         i++;
2532                                         intSplitPoint = i;
2533                                         intSplitSize = 0;
2534         
2535                                 }
2536         
2537                         }
2538                         
2539                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2540                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2541                 
2542                         int intTypeSeek = 0;
2543                 
2544                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2545                         typeiter != TypeSplitPoints.end(); ++typeiter){
2546                         
2547                                 wxString TypePropertyName;
2548                                 
2549                                 TSLiter = TypeSplitLength.find(typeiter->first);
2550                                 
2551                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2552                                 
2553                                 if (intTypeSeek == 0){
2554                                 
2555                                 
2556                                 } else {
2557                                                                                 
2558                                         TelTypeUI.Append(wxT(","));                                                     
2559                                 
2560                                 }
2561                         
2562                                 if (TypePropertyName == wxT("home")){
2563                                 
2564                                         PropType = PROPERTY_HOME;
2565                                 
2566                                 } else if (TypePropertyName == wxT("work")){
2567                                 
2568                                         PropType = PROPERTY_WORK;
2569                                                                         
2570                                 }
2571                                 
2572                                 
2573                                 if (TypePropertyName == wxT("text")){
2574                                 
2575                                         TelTypeUI.Append(_("text"));
2576                                         intTypeSeek++;
2577                                 
2578                                 } else if (TypePropertyName == wxT("voice")){
2579                                 
2580                                         TelTypeUI.Append(_("voice"));
2581                                         intTypeSeek++;
2582                                 
2583                                 } else if (TypePropertyName == wxT("fax")){
2584                                 
2585                                         TelTypeUI.Append(_("fax"));
2586                                         intTypeSeek++;
2587                                 
2588                                 } else if (TypePropertyName == wxT("cell")){
2589                                 
2590                                         TelTypeUI.Append(_("mobile"));
2591                                         intTypeSeek++;
2592                                 
2593                                 } else if (TypePropertyName == wxT("video")){
2594                                 
2595                                         TelTypeUI.Append(_("video"));
2596                                         intTypeSeek++;
2597                                 
2598                                 } else if (TypePropertyName == wxT("pager")){
2599                                 
2600                                         TelTypeUI.Append(_("pager"));
2601                                         intTypeSeek++;
2602                                 
2603                                 } else if (TypePropertyName == wxT("textphone")){
2604                                 
2605                                         TelTypeUI.Append(_("textphone"));
2606                                         intTypeSeek++;
2607                                 
2608                                 }
2609                         
2610                         }
2611                 
2612                 }
2613                 
2614         }
2615         
2616         std::map<int, wxString> *TelephoneList = NULL;
2617         std::map<int, wxString> *TelephoneListType = NULL;
2618         std::map<int, wxString> *TelephoneListAltID = NULL;
2619         std::map<int, wxString> *TelephoneListPID = NULL;
2620         std::map<int, wxString> *TelephoneListTokens = NULL;
2621         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2622         std::map<int, int> *TelephoneListPref = NULL;
2624         switch(PropType){
2625                 case PROPERTY_NONE:
2626                         TelephoneList = &GeneralTelephoneList;
2627                         TelephoneListType = &GeneralTelephoneListType;
2628                         TelephoneListAltID = &GeneralTelephoneListAltID;
2629                         TelephoneListPID = &GeneralTelephoneListPID;
2630                         TelephoneListTokens = &GeneralTelephoneListTokens;
2631                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2632                         TelephoneListPref = &GeneralTelephoneListPref;  
2633                         break;
2634                 case PROPERTY_HOME:
2635                         TelephoneList = &HomeTelephoneList;
2636                         TelephoneListType = &HomeTelephoneListType;
2637                         TelephoneListAltID = &HomeTelephoneListAltID;
2638                         TelephoneListPID = &HomeTelephoneListPID;
2639                         TelephoneListTokens = &HomeTelephoneListTokens;
2640                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2641                         TelephoneListPref = &HomeTelephoneListPref;     
2642                         break;
2643                 case PROPERTY_WORK:
2644                         TelephoneList = &BusinessTelephoneList;
2645                         TelephoneListType = &BusinessTelephoneListType;
2646                         TelephoneListAltID = &BusinessTelephoneListAltID;
2647                         TelephoneListPID = &BusinessTelephoneListPID;
2648                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2649                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2650                         TelephoneListPref = &BusinessTelephoneListPref; 
2651                         break;
2652         }
2653                 
2654         // Process the properties.
2655         
2656         bool FirstToken = TRUE;
2657         
2658         intPrevValue = 5;
2659         SplitPoints.clear();
2660         SplitLength.clear();
2662         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2664         intPrevValue = 4;
2665         
2666         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2667         intiter != SplitPoints.end(); ++intiter){
2668         
2669                 SLiter = SplitLength.find(intiter->first);
2670         
2671                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2672                 
2673                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2674                 PropertyName = PropertyElement.GetNextToken();                          
2675                 PropertyValue = PropertyElement.GetNextToken();
2676                 
2677                 intPrevValue = intiter->second;
2678                 
2679                 CaptureString(&PropertyValue, FALSE);
2680                 
2681                 // Process properties.
2682                 
2683                 if (PropertyName == wxT("ALTID")){
2685                         TelephoneListAltID->erase(*TelephoneCount);
2686                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2687                 
2688                 } else if (PropertyName == wxT("PID")){
2690                         TelephoneListPID->erase(*TelephoneCount);
2691                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2692                 
2693                 } else if (PropertyName == wxT("PREF")){
2694                         
2695                         int PriorityNumber = 0;
2696                         bool ValidNumber = TRUE;
2697                         
2698                         try{
2699                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2700                         }
2701                         
2702                         catch(std::invalid_argument &e){
2703                                 ValidNumber = FALSE;
2704                         }
2706                         if (ValidNumber == TRUE){
2708                                 TelephoneListPref->erase(*TelephoneCount);
2709                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2711                         }
2712                 
2713                 } else {
2714                 
2715                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2716                         
2717                                 if (FirstToken == TRUE){
2718                                 
2719                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2720                                         FirstToken = FALSE;
2721                                 
2722                                 } else {
2723                                 
2724                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2725                                 
2726                                 }
2727                         
2728                         }
2729                 
2730                 }
2731         
2732         }
2733                 
2734         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2735         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2736         
2737         // Add the name token data.
2738         
2739         if (!PropertyTokens.IsEmpty()){
2740         
2741                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2742         
2743         }
2747 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2749         std::map<int, int> SplitPoints;
2750         std::map<int, int> SplitLength;
2752         int intPrevValue = 6;
2753         int intPref = 0;                        
2754         
2755         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2756         
2757         intPrevValue = 5;
2758         
2759         PropertyType PropType = PROPERTY_NONE;
2760                 
2761         // Look for type before continuing.
2762         
2763         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2764         
2765         std::map<int, wxString> *LanguageList = NULL;
2766         std::map<int, wxString> *LanguageListType = NULL;
2767         std::map<int, wxString> *LanguageListAltID = NULL;
2768         std::map<int, wxString> *LanguageListPID = NULL;
2769         std::map<int, wxString> *LanguageListTokens = NULL;
2770         std::map<int, int> *LanguageListPref = NULL;
2772         switch(PropType){
2773                 case PROPERTY_NONE:
2774                         LanguageList = &GeneralLanguageList;
2775                         LanguageListType = &GeneralLanguageListType;
2776                         LanguageListAltID = &GeneralLanguageListAltID;
2777                         LanguageListPID = &GeneralLanguageListPID;
2778                         LanguageListTokens = &GeneralLanguageListTokens;
2779                         LanguageListPref = &GeneralLanguageListPref;    
2780                         break;
2781                 case PROPERTY_HOME:
2782                         LanguageList = &HomeLanguageList;
2783                         LanguageListType = &HomeLanguageListType;
2784                         LanguageListAltID = &HomeLanguageListAltID;
2785                         LanguageListPID = &HomeLanguageListPID;
2786                         LanguageListTokens = &HomeLanguageListTokens;   
2787                         LanguageListPref = &HomeLanguageListPref;       
2788                         break;
2789                 case PROPERTY_WORK:
2790                         LanguageList = &BusinessLanguageList;
2791                         LanguageListType = &BusinessLanguageListType;
2792                         LanguageListAltID = &BusinessLanguageListAltID;
2793                         LanguageListPID = &BusinessLanguageListPID;
2794                         LanguageListTokens = &BusinessLanguageListTokens;       
2795                         LanguageListPref = &BusinessLanguageListPref;
2796                         break;
2797         }
2798         
2799         intPrevValue = 5;
2800         
2801         std::map<int,int>::iterator SLiter;
2802         wxString PropertyData;
2803         wxString PropertyName;
2804         wxString PropertyValue;
2805         wxString PropertyTokens;
2806         bool FirstToken = TRUE;
2807         
2808         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2809         intiter != SplitPoints.end(); ++intiter){
2810         
2811                 SLiter = SplitLength.find(intiter->first);
2812         
2813                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2814                 
2815                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2816                 PropertyName = PropertyElement.GetNextToken();                          
2817                 PropertyValue = PropertyElement.GetNextToken();
2818                 
2819                 intPrevValue = intiter->second;
2820                 
2821                 CaptureString(&PropertyValue, FALSE);
2822                 
2823                 // Process properties.
2824                 
2825                 if (PropertyName == wxT("ALTID")){
2827                         LanguageListAltID->erase(*LanguageCount);
2828                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2829                 
2830                 } else if (PropertyName == wxT("PID")){
2832                         LanguageListPID->erase(*LanguageCount);
2833                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2834                 
2835                 } else if (PropertyName == wxT("PREF")){
2836                         
2837                         int PriorityNumber = 0;
2838                         bool ValidNumber = TRUE;
2839                         
2840                         try{
2841                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2842                         }
2843                         
2844                         catch(std::invalid_argument &e){
2845                                 ValidNumber = FALSE;
2846                         }
2848                         if (ValidNumber == TRUE){
2850                                 LanguageListPref->erase(*LanguageCount);
2851                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2853                         }
2854                 
2855                 } else {
2856                 
2857                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2858                         
2859                                 if (FirstToken == TRUE){
2860                                 
2861                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2862                                         FirstToken = FALSE;
2863                                 
2864                                 } else {
2865                                 
2866                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2867                                 
2868                                 }
2869                         
2870                         }
2871                 
2872                 }
2873         
2874         }
2875                 
2876         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2877         
2878         // Add the name token data.
2879         
2880         if (!PropertyTokens.IsEmpty()){
2881         
2882                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2883         
2884         }
2888 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2890         std::map<int, int> SplitPoints;
2891         std::map<int, int> SplitLength;
2893         int intPrevValue = 5;
2894         int intPref = 0;                        
2895         
2896         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2897         
2898         intPrevValue = 4;
2899         
2900         PropertyType PropType = PROPERTY_NONE;
2901                 
2902         // Look for type before continuing.
2903         
2904         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2905         
2906         std::map<int, wxString> *GeopositionList = NULL;
2907         std::map<int, wxString> *GeopositionListType = NULL;
2908         std::map<int, wxString> *GeopositionListAltID = NULL;
2909         std::map<int, wxString> *GeopositionListPID = NULL;
2910         std::map<int, wxString> *GeopositionListTokens = NULL;
2911         std::map<int, wxString> *GeopositionListMediatype = NULL;
2912         std::map<int, int> *GeopositionListPref = NULL;
2914         switch(PropType){
2915                 case PROPERTY_NONE:
2916                         GeopositionList = &GeneralGeographyList;
2917                         GeopositionListType = &GeneralGeographyListType;
2918                         GeopositionListAltID = &GeneralGeographyListAltID;
2919                         GeopositionListPID = &GeneralGeographyListPID;
2920                         GeopositionListTokens = &GeneralGeographyListTokens;
2921                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2922                         GeopositionListPref = &GeneralGeographyListPref;        
2923                         break;
2924                 case PROPERTY_HOME:
2925                         GeopositionList = &HomeGeographyList;
2926                         GeopositionListType = &HomeGeographyListType;
2927                         GeopositionListAltID = &HomeGeographyListAltID;
2928                         GeopositionListPID = &HomeGeographyListPID;
2929                         GeopositionListTokens = &HomeGeographyListTokens;
2930                         GeopositionListMediatype = &HomeGeographyListMediatype;
2931                         GeopositionListPref = &HomeGeographyListPref;   
2932                         break;
2933                 case PROPERTY_WORK:
2934                         GeopositionList = &BusinessGeographyList;
2935                         GeopositionListType = &BusinessGeographyListType;
2936                         GeopositionListAltID = &BusinessGeographyListAltID;
2937                         GeopositionListPID = &BusinessGeographyListPID;
2938                         GeopositionListTokens = &BusinessGeographyListTokens;
2939                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2940                         GeopositionListPref = &BusinessGeographyListPref;
2941                         break;
2942         }
2943         
2944         intPrevValue = 4;
2945         
2946         std::map<int,int>::iterator SLiter;
2947         wxString PropertyData;
2948         wxString PropertyName;
2949         wxString PropertyValue;
2950         wxString PropertyTokens;
2951         bool FirstToken = TRUE;
2952         
2953         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2954         intiter != SplitPoints.end(); ++intiter){
2955         
2956                 SLiter = SplitLength.find(intiter->first);
2957         
2958                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2959                 
2960                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2961                 PropertyName = PropertyElement.GetNextToken();                          
2962                 PropertyValue = PropertyElement.GetNextToken();
2963                 
2964                 intPrevValue = intiter->second;
2965                 
2966                 CaptureString(&PropertyValue, FALSE);
2967                 
2968                 // Process properties.
2969                 
2970                 if (PropertyName == wxT("ALTID")){
2972                         GeopositionListAltID->erase(*GeographicCount);
2973                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2974                 
2975                 } else if (PropertyName == wxT("PID")){
2977                         GeopositionListPID->erase(*GeographicCount);
2978                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2979                 
2980                 } else if (PropertyName == wxT("MEDIATYPE")){
2982                         GeopositionListMediatype->erase(*GeographicCount);
2983                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2984                 
2985                 } else if (PropertyName == wxT("PREF")){
2986                         
2987                         int PriorityNumber = 0;
2988                         bool ValidNumber = TRUE;
2989                         
2990                         try{
2991                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2992                         }
2993                         
2994                         catch(std::invalid_argument &e){
2995                                 ValidNumber = FALSE;
2996                         }
2998                         if (ValidNumber == TRUE){
3000                                 GeopositionListPref->erase(*GeographicCount);
3001                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
3003                         }
3004                 
3005                 } else {
3006                 
3007                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3008                         
3009                                 if (FirstToken == TRUE){
3010                                 
3011                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3012                                         FirstToken = FALSE;
3013                                 
3014                                 } else {
3015                                 
3016                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3017                                 
3018                                 }
3019                         
3020                         }
3021                 
3022                 }
3023         
3024         }
3025                 
3026         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
3027         
3028         // Add the name token data.
3029         
3030         if (!PropertyTokens.IsEmpty()){
3031         
3032                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3033         
3034         }
3038 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3040         size_t intPropertyLen = PropertySeg1.Len();
3041         std::map<int, int> SplitPoints;
3042         std::map<int, int> SplitLength;
3043         std::map<int, int>::iterator SLiter;                    
3044         wxString PropertyData;
3045         wxString PropertyName;
3046         wxString PropertyValue;
3047         wxString PropertyTokens;
3048         wxString RelatedType;
3049         wxString RelatedTypeOriginal;                   
3050         wxString RelatedName;
3051         bool FirstToken = TRUE;                 
3052         int intSplitsFound = 0;
3053         int intSplitSize = 0;
3054         int intPrevValue = 9;
3055         int intPref = 0;
3056         long ListCtrlIndex;
3057         
3058         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3059         
3060         intPrevValue = 8;
3061         
3062         // Look for type before continuing.
3063         
3064         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3065         intiter != SplitPoints.end(); ++intiter){
3066         
3067                 SLiter = SplitLength.find(intiter->first);
3068         
3069                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3070                 
3071                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3072                 PropertyName = PropertyElement.GetNextToken();                          
3073                 PropertyValue = PropertyElement.GetNextToken();
3074                 
3075                 intPrevValue = intiter->second;
3076                 
3077                 // Process these.
3078                 
3079                 RelatedTypeOriginal = PropertyValue;
3080                 
3081                 if (PropertyName == wxT("TYPE")){
3082                 
3083                         if (PropertyValue == wxT("contact")){
3085                                 RelatedType = _("Contact");
3087                         } else if (PropertyValue == wxT("acquaintance")){
3089                                 RelatedType = _("Acquaintance");
3091                         } else if (PropertyValue == wxT("friend")){
3093                                 RelatedType = _("Friend");
3095                         } else if (PropertyValue == wxT("met")){
3097                                 RelatedType = _("Met");
3099                         } else if (PropertyValue == wxT("co-worker")){
3101                                 RelatedType = _("Co-worker");
3103                         } else if (PropertyValue == wxT("colleague")){
3105                                 RelatedType = _("Colleague");
3107                         } else if (PropertyValue == wxT("co-resident")){
3109                                 RelatedType = _("Co-resident");
3111                         } else if (PropertyValue == wxT("neighbor")){
3113                                 RelatedType = _("Neighbour");
3115                         } else if (PropertyValue == wxT("child")){
3117                                 RelatedType = _("Child");
3119                         } else if (PropertyValue == wxT("parent")){
3121                                 RelatedType = _("Parent");
3123                         } else if (PropertyValue == wxT("sibling")){
3125                                 RelatedType = _("Sibling");
3127                         } else if (PropertyValue == wxT("spouse")){
3129                                 RelatedType = _("Spouse");
3131                         } else if (PropertyValue == wxT("kin")){
3133                                 RelatedType = _("Kin");
3135                         } else if (PropertyValue == wxT("muse")){
3137                                 RelatedType = _("Muse");
3139                         } else if (PropertyValue == wxT("crush")){
3141                                 RelatedType = _("Crush");
3143                         } else if (PropertyValue == wxT("date")){
3145                                 RelatedType = _("Date");
3147                         } else if (PropertyValue == wxT("sweetheart")){
3149                                 RelatedType = _("Sweetheart");
3151                         } else if (PropertyValue == wxT("me")){
3153                                 RelatedType = _("Me");
3155                         } else if (PropertyValue == wxT("agent")){
3157                                 RelatedType = _("Agent");
3159                         } else if (PropertyValue == wxT("emergency")){
3161                                 RelatedType = _("Emergency");
3163                         } else {
3165                                 RelatedType = PropertyValue;
3167                         }
3168                 
3169                 }
3170         
3171         }
3172         
3173         intPrevValue = 8;                       
3174         
3175         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3176         intiter != SplitPoints.end(); ++intiter){
3177         
3178                 SLiter = SplitLength.find(intiter->first);
3179         
3180                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3181                 
3182                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3183                 PropertyName = PropertyElement.GetNextToken();                          
3184                 PropertyValue = PropertyElement.GetNextToken();
3185                 
3186                 intPrevValue = intiter->second;
3187                 
3188                 // Process properties.
3189                 
3190                 size_t intPropertyValueLen = PropertyValue.Len();
3191                 
3192                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3193                         
3194                         PropertyValue.Trim();
3195                         PropertyValue.RemoveLast();
3196                         
3197                 }                               
3198                 
3199                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3200                         
3201                         PropertyValue.Remove(0, 1);
3202                         
3203                 }
3204                 
3205                 CaptureString(&PropertyValue, FALSE);
3206                         
3207                 if (PropertyName == wxT("ALTID")){
3209                         GeneralRelatedListAltID.erase(*RelatedCount);
3210                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3211                 
3212                 } else if (PropertyName == wxT("PID")){
3214                         GeneralRelatedListPID.erase(*RelatedCount);
3215                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3216                 
3217                 } else if (PropertyName == wxT("PREF")){
3218                         
3219                         int PriorityNumber = 0;
3220                         bool ValidNumber = TRUE;
3221                         
3222                         try{
3223                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3224                         }
3225                         
3226                         catch(std::invalid_argument &e){
3227                                 ValidNumber = FALSE;
3228                         }
3230                         if (ValidNumber == TRUE){
3232                                 GeneralRelatedListPref.erase(*RelatedCount);
3233                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3235                         }
3236                 
3237                 } else if (PropertyName == wxT("LANGUAGE")){
3238                 
3239                         GeneralRelatedListLanguage.erase(*RelatedCount);
3240                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3241                 
3242                 } else if (PropertyName != wxT("TYPE")) {
3243                 
3244                         // Something else we don't know about so append
3245                         // to the tokens variable.
3246                 
3247                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3248                 
3249                                 if (FirstToken == TRUE){
3250                         
3251                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3252                                         FirstToken = FALSE;
3253                         
3254                                 } else {
3255                         
3256                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3257                         
3258                                 }
3259                 
3260                         }
3261                 
3262                 }
3263         
3264         }                                       
3265         
3266         // Add the data to the General/Home/Work address variables.
3267                                 
3268         GeneralRelatedList.erase(*RelatedCount);
3269         GeneralRelatedListRelType.erase(*RelatedCount);
3270         GeneralRelatedListType.erase(*RelatedCount);
3271         GeneralRelatedListTokens.erase(*RelatedCount);
3272         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3273         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3274         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3275         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3279 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3281         std::map<int, int> SplitPoints;
3282         std::map<int, int> SplitLength;
3283         std::map<int, int>::iterator SLiter;                    
3284         wxString PropertyData;
3285         wxString PropertyName;
3286         wxString PropertyValue;
3287         wxString PropertyTokens;
3288         bool FirstToken = TRUE;
3289         int intPrevValue = 5;
3290         int intPref = 0;                        
3291         int intType = 0;
3292         long ListCtrlIndex;
3293         
3294         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3295         
3296         intPrevValue = 4;
3297         
3298         PropertyType PropType = PROPERTY_NONE;
3299                 
3300         // Look for type before continuing.
3301         
3302         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3303         
3304         // Setup the pointers.
3305         
3306         std::map<int, wxString> *WebsiteList = NULL;
3307         std::map<int, wxString> *WebsiteListAltID = NULL;
3308         std::map<int, wxString> *WebsiteListPID = NULL;
3309         std::map<int, wxString> *WebsiteListType = NULL;
3310         std::map<int, wxString> *WebsiteListTokens = NULL;
3311         std::map<int, wxString> *WebsiteListMediatype = NULL;
3312         std::map<int, int> *WebsiteListPref = NULL;
3313         
3314         // Setup blank lines for later on.
3315         
3316         switch(PropType){
3317                 case PROPERTY_NONE:
3318                         WebsiteList = &GeneralWebsiteList;
3319                         WebsiteListType = &GeneralWebsiteListType;
3320                         WebsiteListAltID = &GeneralWebsiteListAltID;
3321                         WebsiteListPID = &GeneralWebsiteListPID;
3322                         WebsiteListTokens = &GeneralWebsiteListTokens;
3323                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3324                         WebsiteListPref = &GeneralWebsiteListPref;      
3325                         break;
3326                 case PROPERTY_HOME:
3327                         WebsiteList = &HomeWebsiteList;
3328                         WebsiteListType = &HomeWebsiteListType;
3329                         WebsiteListAltID = &HomeWebsiteListAltID;
3330                         WebsiteListPID = &HomeWebsiteListPID;
3331                         WebsiteListTokens = &HomeWebsiteListTokens;
3332                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3333                         WebsiteListPref = &HomeWebsiteListPref; 
3334                         break;
3335                 case PROPERTY_WORK:
3336                         WebsiteList = &BusinessWebsiteList;
3337                         WebsiteListType = &BusinessWebsiteListType;
3338                         WebsiteListAltID = &BusinessWebsiteListAltID;
3339                         WebsiteListPID = &BusinessWebsiteListPID;
3340                         WebsiteListTokens = &BusinessWebsiteListTokens;
3341                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3342                         WebsiteListPref = &BusinessWebsiteListPref;
3343                         break;
3344         }
3345         
3346         intPrevValue = 4;
3347         
3348         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3349         intiter != SplitPoints.end(); ++intiter){
3350         
3351                 SLiter = SplitLength.find(intiter->first);
3352         
3353                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3354                 
3355                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3356                 PropertyName = PropertyElement.GetNextToken();                          
3357                 PropertyValue = PropertyElement.GetNextToken();
3358                 
3359                 intPrevValue = intiter->second;
3360                 
3361                 // Process properties.
3362                 
3363                 size_t intPropertyValueLen = PropertyValue.Len();
3364                 
3365                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3366                         
3367                         PropertyValue.Trim();
3368                         PropertyValue.RemoveLast();
3369                         
3370                 }                               
3371                 
3372                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3373                         
3374                         PropertyValue.Remove(0, 1);
3375                         
3376                 }
3377                 
3378                 CaptureString(&PropertyValue, FALSE);
3379                 
3380                 if (PropertyName == wxT("ALTID")){
3382                         WebsiteListAltID->erase(*URLCount);
3383                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3384                 
3385                 } else if (PropertyName == wxT("PID")){
3387                         WebsiteListPID->erase(*URLCount);
3388                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3389                         
3390                 } else if (PropertyName == wxT("PREF")){
3391                         
3392                         int PriorityNumber = 0;
3393                         bool ValidNumber = TRUE;
3394                         
3395                         try{
3396                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3397                         }
3398                         
3399                         catch(std::invalid_argument &e){
3400                                 ValidNumber = FALSE;
3401                         }
3403                         if (ValidNumber == TRUE){
3405                                 WebsiteListPref->erase(*URLCount);
3406                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3408                         }
3409                                         
3410                 } else if (PropertyName == wxT("MEDIATYPE")){
3411                 
3412                         WebsiteListMediatype->erase(*URLCount);
3413                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3414                 
3415                 } else {
3416                 
3417                         // Something else we don't know about so append
3418                         // to the tokens variable.
3419                 
3420                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3421                 
3422                                 if (FirstToken == TRUE){
3423                         
3424                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3425                                         FirstToken = FALSE;
3426                         
3427                                 } else {
3428                         
3429                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3430                         
3431                                 }
3432                 
3433                         }
3434                 
3435                 }
3436         
3437         }
3438         
3439         // Add the data to the General/Home/Work address variables.
3440         
3441         CaptureString(&PropertySeg2, FALSE);
3442                         
3443         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3444         
3445         if (!PropertyTokens.IsEmpty()){
3446         
3447                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3448                         
3449         }
3450         
3453 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3455         std::map<int, int> SplitPoints;
3456         std::map<int, int> SplitLength;
3457         std::map<int, int>::iterator SLiter;                    
3458         wxString PropertyData;
3459         wxString PropertyName;
3460         wxString PropertyValue;
3461         wxString PropertyTokens;
3462         bool FirstToken = TRUE;
3463         int intPrevValue = 7;
3464         int intPref = 0;                        
3465         int intType = 0;
3466         long ListCtrlIndex;
3467         
3468         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3469         
3470         intPrevValue = 6;
3471         
3472         PropertyType PropType = PROPERTY_NONE;
3473                 
3474         // Look for type before continuing.
3475         
3476         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3477         
3478         // Setup the pointers.
3479         
3480         std::map<int, wxString> *TitleList = NULL;
3481         std::map<int, wxString> *TitleListAltID = NULL;
3482         std::map<int, wxString> *TitleListPID = NULL;
3483         std::map<int, wxString> *TitleListType = NULL;
3484         std::map<int, wxString> *TitleListTokens = NULL;
3485         std::map<int, wxString> *TitleListLanguage = NULL;
3486         std::map<int, int> *TitleListPref = NULL;
3487         
3488         // Setup blank lines for later on.
3489         
3490         switch(PropType){
3491                 case PROPERTY_NONE:
3492                         TitleList = &GeneralTitleList;
3493                         TitleListType = &GeneralTitleListType;
3494                         TitleListAltID = &GeneralTitleListAltID;
3495                         TitleListPID = &GeneralTitleListPID;
3496                         TitleListTokens = &GeneralTitleListTokens;
3497                         TitleListLanguage = &GeneralTitleListLanguage;
3498                         TitleListPref = &GeneralTitleListPref;  
3499                         break;
3500                 case PROPERTY_HOME:
3501                         TitleList = &HomeTitleList;
3502                         TitleListType = &HomeTitleListType;
3503                         TitleListAltID = &HomeTitleListAltID;
3504                         TitleListPID = &HomeTitleListPID;
3505                         TitleListTokens = &HomeTitleListTokens;
3506                         TitleListLanguage = &HomeTitleListLanguage;
3507                         TitleListPref = &HomeTitleListPref;     
3508                         break;
3509                 case PROPERTY_WORK:
3510                         TitleList = &BusinessTitleList;
3511                         TitleListType = &BusinessTitleListType;
3512                         TitleListAltID = &BusinessTitleListAltID;
3513                         TitleListPID = &BusinessTitleListPID;
3514                         TitleListTokens = &BusinessTitleListTokens;
3515                         TitleListLanguage = &BusinessTitleListLanguage; 
3516                         TitleListPref = &BusinessTitleListPref;
3517                         break;
3518         }
3520         intPrevValue = 6;
3521                 
3522         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3523         intiter != SplitPoints.end(); ++intiter){
3524         
3525                 SLiter = SplitLength.find(intiter->first);
3526         
3527                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3528                 
3529                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3530                 PropertyName = PropertyElement.GetNextToken();                          
3531                 PropertyValue = PropertyElement.GetNextToken();
3532                 
3533                 intPrevValue = intiter->second;
3534                 
3535                 // Process properties.
3536                 
3537                 size_t intPropertyValueLen = PropertyValue.Len();
3538                 
3539                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3540                         
3541                         PropertyValue.Trim();
3542                         PropertyValue.RemoveLast();
3543                         
3544                 }                               
3545                 
3546                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3547                         
3548                         PropertyValue.Remove(0, 1);
3549                         
3550                 }                               
3551                 
3552                 CaptureString(&PropertyValue, FALSE);
3553                 
3554                 if (PropertyName == wxT("ALTID")){
3555                 
3556                         TitleListAltID->erase(*TitleCount);
3557                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3558                 
3559                 } else if (PropertyName == wxT("PID")){
3561                         TitleListPID->erase(*TitleCount);
3562                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3563                 
3564                 } else if (PropertyName == wxT("PREF")){
3565                                 
3566                         int PriorityNumber = 0;
3567                         bool ValidNumber = TRUE;
3568                         
3569                         try{
3570                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3571                         }
3572                         
3573                         catch(std::invalid_argument &e){
3574                                 ValidNumber = FALSE;
3575                         }
3577                         if (ValidNumber == TRUE){
3579                                 TitleListPref->erase(*TitleCount);
3580                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3582                         }
3583                                         
3584                 } else if (PropertyName == wxT("LANGUAGE")){
3585                 
3586                         TitleListLanguage->erase(*TitleCount);
3587                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3588                 
3589                 } else {
3590                 
3591                         // Something else we don't know about so append
3592                         // to the tokens variable.
3593                 
3594                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3595                 
3596                                 if (FirstToken == TRUE){
3597                         
3598                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3599                                         FirstToken = FALSE;
3600                         
3601                                 } else {
3602                         
3603                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3604                         
3605                                 }
3606                 
3607                         }
3608                 
3609                 }
3610         
3611         }
3612         
3613         // Add the data to the General/Home/Work address variables.
3614         
3615         CaptureString(&PropertySeg2, FALSE);
3617         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3618         
3619         if (!PropertyTokens.IsEmpty()){
3620         
3621                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3622                         
3623         }
3627 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3629         std::map<int, int> SplitPoints;
3630         std::map<int, int> SplitLength;
3631         std::map<int, int>::iterator SLiter;                    
3632         wxString PropertyData;
3633         wxString PropertyName;
3634         wxString PropertyValue;
3635         wxString PropertyTokens;
3636         bool FirstToken = TRUE;
3637         int intPrevValue = 6;
3638         int intPref = 0;                        
3639         int intType = 0;
3640         long ListCtrlIndex;
3641         
3642         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3643         
3644         intPrevValue = 5;
3645         
3646         PropertyType PropType = PROPERTY_NONE;
3647                 
3648         // Look for type before continuing.
3649         
3650         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3651         
3652         // Setup the pointers.
3653         
3654         std::map<int, wxString> *RoleList = NULL;
3655         std::map<int, wxString> *RoleListAltID = NULL;
3656         std::map<int, wxString> *RoleListPID = NULL;
3657         std::map<int, wxString> *RoleListType = NULL;
3658         std::map<int, wxString> *RoleListTokens = NULL;
3659         std::map<int, wxString> *RoleListLanguage = NULL;
3660         std::map<int, int> *RoleListPref = NULL;
3661         
3662         // Setup blank lines for later on.
3663         
3664         switch(PropType){
3665                 case PROPERTY_NONE:
3666                         RoleList = &GeneralRoleList;
3667                         RoleListType = &GeneralRoleListType;
3668                         RoleListAltID = &GeneralRoleListAltID;
3669                         RoleListPID = &GeneralRoleListPID;
3670                         RoleListTokens = &GeneralRoleListTokens;
3671                         RoleListLanguage = &GeneralRoleListLanguage;
3672                         RoleListPref = &GeneralRoleListPref;    
3673                         break;
3674                 case PROPERTY_HOME:
3675                         RoleList = &HomeRoleList;
3676                         RoleListType = &HomeRoleListType;
3677                         RoleListAltID = &HomeRoleListAltID;
3678                         RoleListPID = &HomeRoleListPID;
3679                         RoleListTokens = &HomeRoleListTokens;
3680                         RoleListLanguage = &HomeRoleListLanguage;
3681                         RoleListPref = &HomeRoleListPref;       
3682                         break;
3683                 case PROPERTY_WORK:
3684                         RoleList = &BusinessRoleList;
3685                         RoleListType = &BusinessRoleListType;
3686                         RoleListAltID = &BusinessRoleListAltID;
3687                         RoleListPID = &BusinessRoleListPID;
3688                         RoleListTokens = &BusinessRoleListTokens;
3689                         RoleListLanguage = &BusinessRoleListLanguage;   
3690                         RoleListPref = &BusinessRoleListPref;
3691                         break;
3692         }
3694         intPrevValue = 5;
3695                 
3696         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3697         intiter != SplitPoints.end(); ++intiter){
3698         
3699                 SLiter = SplitLength.find(intiter->first);
3700         
3701                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3702                 
3703                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3704                 PropertyName = PropertyElement.GetNextToken();                          
3705                 PropertyValue = PropertyElement.GetNextToken();
3706                 
3707                 intPrevValue = intiter->second;
3708                 
3709                 // Process properties.
3710                 
3711                 size_t intPropertyValueLen = PropertyValue.Len();
3712                 
3713                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3714                         
3715                         PropertyValue.Trim();
3716                         PropertyValue.RemoveLast();
3717                         
3718                 }                               
3719                 
3720                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3721                         
3722                         PropertyValue.Remove(0, 1);
3723                         
3724                 }                               
3725                 
3726                 CaptureString(&PropertyValue, FALSE);
3727                 
3728                 if (PropertyName == wxT("ALTID")){
3729                 
3730                         RoleListAltID->erase(*RoleCount);
3731                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3732                 
3733                 } else if (PropertyName == wxT("PID")){
3735                         RoleListPID->erase(*RoleCount);
3736                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3737                 
3738                 } else if (PropertyName == wxT("PREF")){
3739                                 
3740                         int PriorityNumber = 0;
3741                         bool ValidNumber = TRUE;
3742                         
3743                         try{
3744                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3745                         }
3746                         
3747                         catch(std::invalid_argument &e){
3748                                 ValidNumber = FALSE;
3749                         }
3751                         if (ValidNumber == TRUE){
3753                                 RoleListPref->erase(*RoleCount);
3754                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3756                         }
3757                                         
3758                 } else if (PropertyName == wxT("LANGUAGE")){
3759                 
3760                         RoleListLanguage->erase(*RoleCount);
3761                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3762                 
3763                 } else {
3764                 
3765                         // Something else we don't know about so append
3766                         // to the tokens variable.
3767                 
3768                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3769                 
3770                                 if (FirstToken == TRUE){
3771                         
3772                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3773                                         FirstToken = FALSE;
3774                         
3775                                 } else {
3776                         
3777                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3778                         
3779                                 }
3780                 
3781                         }
3782                 
3783                 }
3784         
3785         }
3786         
3787         // Add the data to the General/Home/Work address variables.
3788         
3789         CaptureString(&PropertySeg2, FALSE);
3791         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3792         
3793         if (!PropertyTokens.IsEmpty()){
3794         
3795                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3796                         
3797         }
3801 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3803         std::map<int, int> SplitPoints;
3804         std::map<int, int> SplitLength;
3805         std::map<int, int>::iterator SLiter;                    
3806         wxString PropertyData;
3807         wxString PropertyName;
3808         wxString PropertyValue;
3809         wxString PropertyTokens;
3810         bool FirstToken = TRUE;
3811         int intPrevValue = 5;
3812         int intPref = 0;                        
3813         int intType = 0;
3814         long ListCtrlIndex;
3815         
3816         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3817         
3818         intPrevValue = 4;
3819         
3820         PropertyType PropType = PROPERTY_NONE;
3821                 
3822         // Look for type before continuing.
3823         
3824         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3825         
3826         // Setup the pointers.
3827         
3828         std::map<int, wxString> *OrganisationsList = NULL;
3829         std::map<int, wxString> *OrganisationsListAltID = NULL;
3830         std::map<int, wxString> *OrganisationsListPID = NULL;
3831         std::map<int, wxString> *OrganisationsListType = NULL;
3832         std::map<int, wxString> *OrganisationsListTokens = NULL;
3833         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3834         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3835         std::map<int, int> *OrganisationsListPref = NULL;
3836         
3837         // Setup blank lines for later on.
3838         
3839         switch(PropType){
3840                 case PROPERTY_NONE:
3841                         OrganisationsList = &GeneralOrganisationsList;
3842                         OrganisationsListType = &GeneralOrganisationsListType;
3843                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3844                         OrganisationsListPID = &GeneralOrganisationsListPID;
3845                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3846                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3847                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3848                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3849                         break;
3850                 case PROPERTY_HOME:
3851                         OrganisationsList = &HomeOrganisationsList;
3852                         OrganisationsListType = &HomeOrganisationsListType;
3853                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3854                         OrganisationsListPID = &HomeOrganisationsListPID;
3855                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3856                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3857                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3858                         OrganisationsListPref = &HomeOrganisationsListPref;     
3859                         break;
3860                 case PROPERTY_WORK:
3861                         OrganisationsList = &BusinessOrganisationsList;
3862                         OrganisationsListType = &BusinessOrganisationsListType;
3863                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3864                         OrganisationsListPID = &BusinessOrganisationsListPID;
3865                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3866                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3867                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3868                         OrganisationsListPref = &BusinessOrganisationsListPref;
3869                         break;
3870         }
3872         intPrevValue = 4;
3873                 
3874         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3875         intiter != SplitPoints.end(); ++intiter){
3876         
3877                 SLiter = SplitLength.find(intiter->first);
3878         
3879                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3880                 
3881                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3882                 PropertyName = PropertyElement.GetNextToken();                          
3883                 PropertyValue = PropertyElement.GetNextToken();
3884                 
3885                 intPrevValue = intiter->second;
3886                 
3887                 // Process properties.
3888                 
3889                 size_t intPropertyValueLen = PropertyValue.Len();
3890                 
3891                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3892                         
3893                         PropertyValue.Trim();
3894                         PropertyValue.RemoveLast();
3895                         
3896                 }                               
3897                 
3898                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3899                         
3900                         PropertyValue.Remove(0, 1);
3901                         
3902                 }                               
3903                 
3904                 CaptureString(&PropertyValue, FALSE);
3905                 
3906                 if (PropertyName == wxT("ALTID")){
3907                 
3908                         OrganisationsListAltID->erase(*OrganisationCount);
3909                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3910                 
3911                 } else if (PropertyName == wxT("PID")){
3913                         OrganisationsListPID->erase(*OrganisationCount);
3914                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3915                 
3916                 } else if (PropertyName == wxT("SORT-AS")){
3918                         OrganisationsListSortAs->erase(*OrganisationCount);
3919                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3920                 
3921                 } else if (PropertyName == wxT("PREF")){
3922                                 
3923                         int PriorityNumber = 0;
3924                         bool ValidNumber = TRUE;
3925                         
3926                         try{
3927                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3928                         }
3929                         
3930                         catch(std::invalid_argument &e){
3931                                 ValidNumber = FALSE;
3932                         }
3934                         if (ValidNumber == TRUE){
3936                                 OrganisationsListPref->erase(*OrganisationCount);
3937                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3939                         }
3940                                         
3941                 } else if (PropertyName == wxT("LANGUAGE")){
3942                 
3943                         OrganisationsListLanguage->erase(*OrganisationCount);
3944                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3945                 
3946                 } else {
3947                 
3948                         // Something else we don't know about so append
3949                         // to the tokens variable.
3950                 
3951                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3952                 
3953                                 if (FirstToken == TRUE){
3954                         
3955                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3956                                         FirstToken = FALSE;
3957                         
3958                                 } else {
3959                         
3960                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3961                         
3962                                 }
3963                 
3964                         }
3965                 
3966                 }
3967         
3968         }
3969         
3970         // Add the data to the General/Home/Work address variables.
3971         
3972         CaptureString(&PropertySeg2, FALSE);
3974         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3975         
3976         if (!PropertyTokens.IsEmpty()){
3977         
3978                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3979                         
3980         }
3984 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3986         std::map<int, int> SplitPoints;
3987         std::map<int, int> SplitLength;
3988         std::map<int, int>::iterator SLiter;                    
3989         wxString PropertyData;
3990         wxString PropertyName;
3991         wxString PropertyValue;
3992         wxString PropertyTokens;
3993         bool FirstToken = TRUE;
3994         int intPrevValue = 6;
3995         int intPref = 0;                        
3996         int intType = 0;
3997         long ListCtrlIndex;
3998         
3999         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4000         
4001         intPrevValue = 5;
4002         
4003         PropertyType PropType = PROPERTY_NONE;
4004                 
4005         // Look for type before continuing.
4006         
4007         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4008         
4009         // Setup the pointers.
4010         
4011         std::map<int, wxString> *NoteList = NULL;
4012         std::map<int, wxString> *NoteListAltID = NULL;
4013         std::map<int, wxString> *NoteListPID = NULL;
4014         std::map<int, wxString> *NoteListType = NULL;
4015         std::map<int, wxString> *NoteListTokens = NULL;
4016         std::map<int, wxString> *NoteListLanguage = NULL;
4017         std::map<int, int> *NoteListPref = NULL;
4018         
4019         // Setup blank lines for later on.
4020         
4021         switch(PropType){
4022                 case PROPERTY_NONE:
4023                         NoteList = &GeneralNoteList;
4024                         NoteListType = &GeneralNoteListType;
4025                         NoteListAltID = &GeneralNoteListAltID;
4026                         NoteListPID = &GeneralNoteListPID;
4027                         NoteListTokens = &GeneralNoteListTokens;
4028                         NoteListLanguage = &GeneralNoteListLanguage;
4029                         NoteListPref = &GeneralNoteListPref;    
4030                         break;
4031                 case PROPERTY_HOME:
4032                         NoteList = &HomeNoteList;
4033                         NoteListType = &HomeNoteListType;
4034                         NoteListAltID = &HomeNoteListAltID;
4035                         NoteListPID = &HomeNoteListPID;
4036                         NoteListTokens = &HomeNoteListTokens;
4037                         NoteListLanguage = &HomeNoteListLanguage;
4038                         NoteListPref = &HomeNoteListPref;       
4039                         break;
4040                 case PROPERTY_WORK:
4041                         NoteList = &BusinessNoteList;
4042                         NoteListType = &BusinessNoteListType;
4043                         NoteListAltID = &BusinessNoteListAltID;
4044                         NoteListPID = &BusinessNoteListPID;
4045                         NoteListTokens = &BusinessNoteListTokens;
4046                         NoteListLanguage = &BusinessNoteListLanguage;   
4047                         NoteListPref = &BusinessNoteListPref;
4048                         break;
4049         }
4051         intPrevValue = 5;
4052                 
4053         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4054         intiter != SplitPoints.end(); ++intiter){
4055         
4056                 SLiter = SplitLength.find(intiter->first);
4057         
4058                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4059                 
4060                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4061                 PropertyName = PropertyElement.GetNextToken();                          
4062                 PropertyValue = PropertyElement.GetNextToken();
4063                 
4064                 intPrevValue = intiter->second;
4065                 
4066                 // Process properties.
4067                 
4068                 size_t intPropertyValueLen = PropertyValue.Len();
4069                 
4070                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4071                         
4072                         PropertyValue.Trim();
4073                         PropertyValue.RemoveLast();
4074                         
4075                 }                               
4076                 
4077                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4078                         
4079                         PropertyValue.Remove(0, 1);
4080                         
4081                 }                               
4082                 
4083                 CaptureString(&PropertyValue, FALSE);
4084                 
4085                 if (PropertyName == wxT("ALTID")){
4086                 
4087                         NoteListAltID->erase(*NoteCount);
4088                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4089                 
4090                 } else if (PropertyName == wxT("PID")){
4092                         NoteListPID->erase(*NoteCount);
4093                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4094                 
4095                 } else if (PropertyName == wxT("PREF")){
4096                                 
4097                         int PriorityNumber = 0;
4098                         bool ValidNumber = TRUE;
4099                         
4100                         try{
4101                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4102                         }
4103                         
4104                         catch(std::invalid_argument &e){
4105                                 ValidNumber = FALSE;
4106                         }
4108                         if (ValidNumber == TRUE){
4110                                 NoteListPref->erase(*NoteCount);
4111                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4113                         }
4114                                         
4115                 } else if (PropertyName == wxT("LANGUAGE")){
4116                 
4117                         NoteListLanguage->erase(*NoteCount);
4118                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4119                 
4120                 } else {
4121                 
4122                         // Something else we don't know about so append
4123                         // to the tokens variable.
4124                 
4125                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4126                 
4127                                 if (FirstToken == TRUE){
4128                         
4129                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4130                                         FirstToken = FALSE;
4131                         
4132                                 } else {
4133                         
4134                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4135                         
4136                                 }
4137                 
4138                         }
4139                 
4140                 }
4141         
4142         }
4143         
4144         // Add the data to the General/Home/Work address variables.
4145         
4146         CaptureString(&PropertySeg2, FALSE);
4148         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4149         
4150         if (!PropertyTokens.IsEmpty()){
4151         
4152                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4153                         
4154         }
4158 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4160         std::map<int, int> SplitPoints;
4161         std::map<int, int> SplitLength;
4162         std::map<int, int>::iterator SLiter;                    
4163         wxString PropertyData;
4164         wxString PropertyName;
4165         wxString PropertyValue;
4166         wxString PropertyTokens;
4167         bool FirstToken = TRUE;
4168         int intPrevValue = 12;
4169         int intPref = 0;                        
4170         int intType = 0;
4171         long ListCtrlIndex;
4172         
4173         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4174         
4175         intPrevValue = 11;
4176         
4177         PropertyType PropType = PROPERTY_NONE;
4178                 
4179         // Look for type before continuing.
4180         
4181         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4182         
4183         // Setup blank lines for later on.
4184         
4185         switch(PropType){
4186                 case PROPERTY_NONE:
4187                         break;
4188                 case PROPERTY_HOME:
4189                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4190                         break;
4191                 case PROPERTY_WORK:
4192                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4193                         break;
4194         }
4196         intPrevValue = 11;
4197                 
4198         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4199         intiter != SplitPoints.end(); ++intiter){
4200         
4201                 SLiter = SplitLength.find(intiter->first);
4202         
4203                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4204                 
4205                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4206                 PropertyName = PropertyElement.GetNextToken();                          
4207                 PropertyValue = PropertyElement.GetNextToken();
4208                 
4209                 intPrevValue = intiter->second;
4210                 
4211                 // Process properties.
4212                 
4213                 size_t intPropertyValueLen = PropertyValue.Len();
4214                 
4215                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4216                         
4217                         PropertyValue.Trim();
4218                         PropertyValue.RemoveLast();
4219                         
4220                 }                               
4221                 
4222                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4223                         
4224                         PropertyValue.Remove(0, 1);
4225                         
4226                 }                               
4227                 
4228                 CaptureString(&PropertyValue, FALSE);
4229                 
4230                 if (PropertyName == wxT("ALTID")){
4231                 
4232                         CategoriesListAltID.erase(*CategoryCount);
4233                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4234                 
4235                 } else if (PropertyName == wxT("PID")){
4237                         CategoriesListPID.erase(*CategoryCount);
4238                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4239                 
4240                 } else if (PropertyName == wxT("PREF")){
4241                                 
4242                         int PriorityNumber = 0;
4243                         bool ValidNumber = TRUE;
4244                         
4245                         try{
4246                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4247                         }
4248                         
4249                         catch(std::invalid_argument &e){
4250                                 ValidNumber = FALSE;
4251                         }
4253                         if (ValidNumber == TRUE){
4255                                 CategoriesListPref.erase(*CategoryCount);
4256                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4258                         }
4259                                         
4260                 } else if (PropertyName == wxT("LANGUAGE")){
4261                 
4262                         CategoriesListLanguage.erase(*CategoryCount);
4263                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4264                 
4265                 } else {
4266                 
4267                         // Something else we don't know about so append
4268                         // to the tokens variable.
4269                 
4270                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4271                 
4272                                 if (FirstToken == TRUE){
4273                         
4274                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4275                                         FirstToken = FALSE;
4276                         
4277                                 } else {
4278                         
4279                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4280                         
4281                                 }
4282                 
4283                         }
4284                 
4285                 }
4286         
4287         }
4288         
4289         // Deal with multiple categories.
4290         
4291         int intOrigCatCount = *CategoryCount;
4292         bool FirstCategoryProcessed = TRUE;
4293         bool AfterFirstToken = FALSE;
4294         int intSplitSize = 0;
4295         int intSplitsFound = 0;
4296         int intSplitSeek = 0;
4297         int intPropertyLen = PropertySeg2.Len();
4298         
4299         SplitPoints.clear();
4300         SplitLength.clear();
4301         intPrevValue = 0;
4302         
4303         for (int i = 0; i <= intPropertyLen; i++){
4304         
4305                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4306         
4307                         continue;
4308                 
4309                 }
4310         
4311                 intSplitSize++;
4312         
4313                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4314         
4315                         if (AfterFirstToken == TRUE){
4316                 
4317                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4318                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4319                         
4320                         } else {
4321                         
4322                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4323                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4324                                 AfterFirstToken = TRUE;
4326                         }
4328                         intSplitsFound++;
4329                         intSplitSeek = i;
4330                         intSplitSize = 0;                               
4331         
4332                 }                       
4333         
4334         }
4335         
4336         if (SplitPoints.size() > 0){
4337         
4338                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4339                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4340         
4341         }
4342         
4343         if (SplitPoints.size() == 0){
4344         
4345                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4346         
4347                 if (!PropertyTokens.IsEmpty()){
4348                 
4349                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4350                 
4351                 }
4352         
4353         }
4354         
4355         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4356         intiter != SplitPoints.end(); ++intiter){
4357         
4358                 SLiter = SplitLength.find(intiter->first);
4359         
4360                 intPrevValue = intiter->second;
4361         
4362                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4363                 
4364                 // Add the data to the General/Home/Work address variables.
4365         
4366                 // Trim any whitespace from the start and end.
4367         
4368                 PropertyData = PropertyData.Trim(FALSE);
4369                 PropertyData = PropertyData.Trim(TRUE); 
4370         
4371                 CaptureString(&PropertyData, FALSE);
4372                 
4373                 if (FirstCategoryProcessed == TRUE){
4374                 
4375                         FirstCategoryProcessed = FALSE;
4376                         
4377                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4378         
4379                         if (!PropertyTokens.IsEmpty()){
4380                 
4381                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4382                 
4383                         }
4384                         
4385                         continue;
4386                 
4387                 } else {
4389                         (*CategoryCount)++;
4390                         
4391                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4392                 
4393                         if (!PropertyTokens.IsEmpty()){
4394                 
4395                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4396                 
4397                         }
4398                 
4399                 }
4400                 
4401                 // Copy the properties to each of the categories (if it exists).
4402                 
4403                 if (!PropertyTokens.IsEmpty()){
4404                 
4405                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4406                 
4407                 }
4408                 
4409                 // Check if ALTID was used.
4410                 
4411                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4412                 
4413                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4414                 
4415                 }
4416                 
4417                 // Check if PID was used.
4418                 
4419                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4420                 
4421                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4422                 
4423                 }
4424         
4425                 // Check if PREF was used.
4426         
4427                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4428                 
4429                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4430                 
4431                 }
4432                 
4433                 // Check if LANGUAGE was used.
4434                 
4435                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4436                 
4437                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4438                 
4439                 }
4440                 
4441                 // Check if TYPE was used.
4442                 
4443                 switch(PropType){
4444                         case PROPERTY_NONE:
4445                                 break;
4446                         case PROPERTY_HOME:
4447                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4448                                 break;
4449                         case PROPERTY_WORK:
4450                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4451                                 break;
4452                 }
4453         
4454         }
4458 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4460         size_t intPropertyLen = PropertySeg1.Len();
4461         std::map<int, int> SplitPoints;
4462         std::map<int, int> SplitLength;
4463         std::map<int, int>::iterator SLiter;                    
4464         wxString PropertyData;
4465         wxString PropertyName;
4466         wxString PropertyValue;
4467         wxString PropertyTokens;
4468         bool FirstToken = TRUE;
4469         int intSplitsFound = 0;
4470         int intSplitSize = 0;
4471         int intPrevValue = 7;
4472         int intPref = 0;                        
4473         int intType = 0;
4474         
4475         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4476         
4477         intPrevValue = 6;
4478         
4479         PropertyType PropType = PROPERTY_NONE;
4480                 
4481         // Look for type before continuing.
4482         
4483         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4485         intPrevValue = 6;
4487         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4488         intiter != SplitPoints.end(); ++intiter){
4489         
4490                 SLiter = SplitLength.find(intiter->first);
4491         
4492                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4493                 
4494                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4495                 PropertyName = PropertyElement.GetNextToken();                          
4496                 PropertyValue = PropertyElement.GetNextToken();
4497                 
4498                 intPrevValue = intiter->second;
4499                 
4500                 // Process properties.
4501                 
4502                 size_t intPropertyValueLen = PropertyValue.Len();
4503                 
4504                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4505                         
4506                         PropertyValue.Trim();
4507                         PropertyValue.RemoveLast();
4508                         
4509                 }                               
4510                 
4511                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4512                         
4513                         PropertyValue.Remove(0, 1);
4514                         
4515                 }
4516                 
4517                 CaptureString(&PropertyValue, FALSE);
4518                 
4519                 if (PropertyName == wxT("ALTID")){
4521                         PicturesListAltID.erase(*PhotoCount);
4522                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4523                 
4524                 } else if (PropertyName == wxT("PID")){
4526                         PicturesListPID.erase(*PhotoCount);
4527                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4528                 
4529                 } else if (PropertyName == wxT("PREF")){
4530                         
4531                         int PriorityNumber = 0;
4532                         bool ValidNumber = TRUE;
4533                         
4534                         try{
4535                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4536                         }
4537                         
4538                         catch(std::invalid_argument &e){
4539                                 ValidNumber = FALSE;
4540                         }
4542                         if (ValidNumber == TRUE){
4544                                 PicturesListPref.erase(*PhotoCount);
4545                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4547                         }
4548                 
4549                 } else if (PropertyName == wxT("MEDIATYPE")){
4550                 
4551                         PicturesListMediatype.erase(*PhotoCount);
4552                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4553                                         
4554                 } else {
4555                 
4556                         // Something else we don't know about so append
4557                         // to the tokens variable.
4558                         
4559                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4560                         
4561                                 if (FirstToken == TRUE){
4562                                 
4563                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4564                                         FirstToken = FALSE;
4565                                 
4566                                 } else {
4567                                 
4568                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4569                                 
4570                                 }
4571                         
4572                         }
4573                 
4574                 }
4575         
4576         }       
4577         
4578         intPropertyLen = PropertySeg2.Len();
4579         SplitPoints.clear();
4580         SplitLength.clear();
4581         intSplitsFound = 0;
4582         intSplitSize = 0;
4583         intPrevValue = 0;                       
4584         
4585         CaptureString(&PropertySeg2, FALSE);
4586         
4587         for (int i = 0; i <= intPropertyLen; i++){
4589                 intSplitSize++;
4590         
4591                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4592         
4593                         intSplitsFound++;
4594                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4595                         
4596                         if (intSplitsFound == 6){ 
4597                         
4598                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4599                                 break; 
4600                                 
4601                         } else {
4602                         
4603                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4604                         
4605                         }
4606                         
4607                         intSplitSize = 0;                                       
4608         
4609                 }
4611         }
4612         
4613         wxString wxSPhotoURI;
4614         wxString wxSPhotoMIME;
4615         wxString wxSPhotoEncoding;
4616         wxString wxSPhotoData;
4617         std::string base64enc;
4618         
4619         if (intSplitsFound == 0){
4620         
4621         } else {
4622         
4623                 std::map<int, int>::iterator striter;
4624         
4625                 striter = SplitLength.find(1);
4626         
4627                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4628         
4629                 while (wSTDataType.HasMoreTokens() == TRUE){
4630                 
4631                         wxSPhotoURI = wSTDataType.GetNextToken();
4632                         wxSPhotoMIME = wSTDataType.GetNextToken();
4633                         break;
4634                 
4635                 }                       
4636         
4637                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4638         
4639                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4640                 
4641                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4642                         wxSPhotoData = wSTDataInfo.GetNextToken();
4643                         base64enc = wxSPhotoData.mb_str();
4644                         break;
4645                 
4646                 }
4647         
4648         }
4649         
4650         // Add the data to the General/Home/Work address variables.
4651         
4652         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4653         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4654         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4655         
4656         switch(PropType){
4657                 case PROPERTY_NONE:
4658                         break;
4659                 case PROPERTY_HOME:
4660                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4661                         break;
4662                 case PROPERTY_WORK:
4663                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4664                         break;
4665         }
4666         
4667         if (!PropertyTokens.IsEmpty()){
4669                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4670         
4671         }
4675 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4677         size_t intPropertyLen = PropertySeg1.Len();
4678         std::map<int, int> SplitPoints;
4679         std::map<int, int> SplitLength;
4680         std::map<int, int>::iterator SLiter;                    
4681         wxString PropertyData;
4682         wxString PropertyName;
4683         wxString PropertyValue;
4684         wxString PropertyTokens;
4685         bool FirstToken = TRUE;
4686         int intSplitsFound = 0;
4687         int intSplitSize = 0;
4688         int intPrevValue = 6;
4689         int intPref = 0;                        
4690         int intType = 0;
4691         
4692         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4693         
4694         intPrevValue = 5;
4695         
4696         PropertyType PropType = PROPERTY_NONE;
4697                 
4698         // Look for type before continuing.
4699         
4700         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4702         intPrevValue = 5;
4704         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4705         intiter != SplitPoints.end(); ++intiter){
4706         
4707                 SLiter = SplitLength.find(intiter->first);
4708         
4709                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4710                 
4711                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4712                 PropertyName = PropertyElement.GetNextToken();                          
4713                 PropertyValue = PropertyElement.GetNextToken();
4714                 
4715                 intPrevValue = intiter->second;
4716                 
4717                 // Process properties.
4718                 
4719                 size_t intPropertyValueLen = PropertyValue.Len();
4720                 
4721                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4722                         
4723                         PropertyValue.Trim();
4724                         PropertyValue.RemoveLast();
4725                         
4726                 }                               
4727                 
4728                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4729                         
4730                         PropertyValue.Remove(0, 1);
4731                         
4732                 }
4733                 
4734                 CaptureString(&PropertyValue, FALSE);
4735                 
4736                 if (PropertyName == wxT("ALTID")){
4738                         LogosListAltID.erase(*LogoCount);
4739                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4740                 
4741                 } else if (PropertyName == wxT("PID")){
4743                         LogosListPID.erase(*LogoCount);
4744                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4745                 
4746                 } else if (PropertyName == wxT("PREF")){
4747                         
4748                         int PriorityNumber = 0;
4749                         bool ValidNumber = TRUE;
4750                         
4751                         try{
4752                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4753                         }
4754                         
4755                         catch(std::invalid_argument &e){
4756                                 ValidNumber = FALSE;
4757                         }
4759                         if (ValidNumber == TRUE){
4761                                 LogosListPref.erase(*LogoCount);
4762                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4764                         }
4765                 
4766                 } else if (PropertyName == wxT("MEDIATYPE")){
4767                 
4768                         LogosListMediatype.erase(*LogoCount);
4769                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4770                                         
4771                 } else {
4772                 
4773                         // Something else we don't know about so append
4774                         // to the tokens variable.
4775                         
4776                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4777                         
4778                                 if (FirstToken == TRUE){
4779                                 
4780                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4781                                         FirstToken = FALSE;
4782                                 
4783                                 } else {
4784                                 
4785                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4786                                 
4787                                 }
4788                         
4789                         }
4790                 
4791                 }
4792         
4793         }       
4794         
4795         intPropertyLen = PropertySeg2.Len();
4796         SplitPoints.clear();
4797         SplitLength.clear();
4798         intSplitsFound = 0;
4799         intSplitSize = 0;
4800         intPrevValue = 0;                       
4801         
4802         CaptureString(&PropertySeg2, FALSE);
4803         
4804         for (int i = 0; i <= intPropertyLen; i++){
4806                 intSplitSize++;
4807         
4808                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4809         
4810                         intSplitsFound++;
4811                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4812                         
4813                         if (intSplitsFound == 6){ 
4814                         
4815                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4816                                 break; 
4817                                 
4818                         } else {
4819                         
4820                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4821                         
4822                         }
4823                         
4824                         intSplitSize = 0;                                       
4825         
4826                 }
4828         }
4829         
4830         wxString wxSPhotoURI;
4831         wxString wxSPhotoMIME;
4832         wxString wxSPhotoEncoding;
4833         wxString wxSPhotoData;
4834         std::string base64enc;
4835         
4836         if (intSplitsFound == 0){
4837         
4838         } else {
4839         
4840                 std::map<int, int>::iterator striter;
4841         
4842                 striter = SplitLength.find(1);
4843         
4844                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4845         
4846                 while (wSTDataType.HasMoreTokens() == TRUE){
4847                 
4848                         wxSPhotoURI = wSTDataType.GetNextToken();
4849                         wxSPhotoMIME = wSTDataType.GetNextToken();
4850                         break;
4851                 
4852                 }                       
4853         
4854                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4855         
4856                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4857                 
4858                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4859                         wxSPhotoData = wSTDataInfo.GetNextToken();
4860                         base64enc = wxSPhotoData.mb_str();
4861                         break;
4862                 
4863                 }
4864         
4865         }
4866         
4867         // Add the data to the General/Home/Work address variables.
4868         
4869         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4870         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4871         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4872         
4873         switch(PropType){
4874                 case PROPERTY_NONE:
4875                         break;
4876                 case PROPERTY_HOME:
4877                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4878                         break;
4879                 case PROPERTY_WORK:
4880                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4881                         break;
4882         }
4883         
4884         if (!PropertyTokens.IsEmpty()){
4886                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4887         
4888         }
4892 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4894         size_t intPropertyLen = PropertySeg1.Len();
4895         std::map<int, int> SplitPoints;
4896         std::map<int, int> SplitLength;
4897         std::map<int, int>::iterator SLiter;                    
4898         wxString PropertyData;
4899         wxString PropertyName;
4900         wxString PropertyValue;
4901         wxString PropertyTokens;
4902         bool FirstToken = TRUE;
4903         int intSplitsFound = 0;
4904         int intSplitSize = 0;
4905         int intPrevValue = 7;
4906         int intPref = 0;                        
4907         int intType = 0;
4908         
4909         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4910         
4911         intPrevValue = 6;
4912         
4913         PropertyType PropType = PROPERTY_NONE;
4914         
4915         // Look for type before continuing.                     
4917         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4919         intPrevValue = 6;
4921         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4922         intiter != SplitPoints.end(); ++intiter){
4923         
4924                 SLiter = SplitLength.find(intiter->first);
4925         
4926                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4927                 
4928                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4929                 PropertyName = PropertyElement.GetNextToken();                          
4930                 PropertyValue = PropertyElement.GetNextToken();
4931                 
4932                 intPrevValue = intiter->second;
4933                 
4934                 // Process properties.
4935                 
4936                 size_t intPropertyValueLen = PropertyValue.Len();
4937                 
4938                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4939                         
4940                         PropertyValue.Trim();
4941                         PropertyValue.RemoveLast();
4942                         
4943                 }                               
4944                 
4945                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4946                         
4947                         PropertyValue.Remove(0, 1);
4948                         
4949                 }                       
4950                 
4951                 CaptureString(&PropertyValue, FALSE);
4952                 
4953                 if (PropertyName == wxT("ALTID")){
4955                         SoundsListAltID.erase(*SoundCount);
4956                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4957                 
4958                 } else if (PropertyName == wxT("PID")){
4960                         SoundsListPID.erase(*SoundCount);
4961                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4962                 
4963                 } else if (PropertyName == wxT("PREF")){
4964                         
4965                         int PriorityNumber = 0;
4966                         bool ValidNumber = TRUE;
4967                         
4968                         try{
4969                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4970                         }
4971                         
4972                         catch(std::invalid_argument &e){
4973                                 ValidNumber = FALSE;
4974                         }
4976                         if (ValidNumber == TRUE){
4978                                 SoundsListPref.erase(*SoundCount);
4979                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4981                         }
4982                 
4983                 } else if (PropertyName == wxT("MEDIATYPE")){
4984                 
4985                         SoundsListMediatype.erase(*SoundCount);
4986                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4988                 } else if (PropertyName == wxT("LANGUAGE")){
4989                 
4990                         SoundsListLanguage.erase(*SoundCount);
4991                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4993                 } else {
4994                 
4995                         // Something else we don't know about so append
4996                         // to the tokens variable.
4997                         
4998                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4999                         
5000                                 if (FirstToken == TRUE){
5001                                 
5002                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5003                                         FirstToken = FALSE;
5004                                 
5005                                 } else {
5006                                 
5007                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5008                                 
5009                                 }
5010                         
5011                         }
5012                 
5013                 }
5014         
5015         }       
5016         
5017         intPropertyLen = PropertySeg2.Len();
5018         SplitPoints.clear();
5019         SplitLength.clear();
5020         intSplitsFound = 0;
5021         intSplitSize = 0;
5022         intPrevValue = 0;
5023         
5024         CaptureString(&PropertySeg2, FALSE);
5025         
5026         for (int i = 0; i <= intPropertyLen; i++){
5028                 intSplitSize++;
5029         
5030                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
5031         
5032                         intSplitsFound++;
5033                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5034                         
5035                         if (intSplitsFound == 6){ 
5036                         
5037                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5038                                 break; 
5039                                 
5040                         } else {
5041                         
5042                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5043                         
5044                         }
5045                         
5046                         intSplitSize = 0;                                       
5047         
5048                 }
5050         }
5051         
5052         wxString wxSSoundURI;
5053         wxString wxSSoundMIME;
5054         wxString wxSSoundEncoding;
5055         wxString wxSSoundData;
5056         std::string base64enc;
5057         
5058         if (intSplitsFound == 0){
5059         
5060         } else {
5061         
5062                 std::map<int, int>::iterator striter;
5063         
5064                 striter = SplitLength.find(1);
5065         
5066                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5067         
5068                 while (wSTDataType.HasMoreTokens() == TRUE){
5069                 
5070                         wxSSoundURI = wSTDataType.GetNextToken();
5071                         wxSSoundMIME = wSTDataType.GetNextToken();
5072                         break;
5073                 
5074                 }                       
5075         
5076                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5077         
5078                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5079                 
5080                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
5081                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
5082                         base64enc = wxSSoundData.mb_str();
5083                         break;
5084                 
5085                 }
5086         
5087         }
5088         
5089         // Add the data to the General/Home/Work address variables.
5090                 
5091         switch(PropType){
5092                 case PROPERTY_NONE:
5093                         break;
5094                 case PROPERTY_HOME:
5095                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5096                         break;
5097                 case PROPERTY_WORK:
5098                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5099                         break;
5100         }
5101         
5102         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5103         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5104         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5105         
5106         if (!PropertyTokens.IsEmpty()){
5107         
5108                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5109         
5110         }
5111         
5114 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5116         size_t intPropertyLen = PropertySeg1.Len();
5117         std::map<int, int> SplitPoints;
5118         std::map<int, int> SplitLength;
5119         std::map<int, int>::iterator SLiter;                    
5120         wxString PropertyData;
5121         wxString PropertyName;
5122         wxString PropertyValue;
5123         wxString PropertyTokens;
5124         bool FirstToken = TRUE;
5125         int intSplitsFound = 0;
5126         int intSplitSize = 0;
5127         int intPrevValue = 8;
5128         int intPref = 0;                        
5129         int intType = 0;
5130         
5131         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5132         
5133         intPrevValue = 7;
5134         
5135         PropertyType PropType = PROPERTY_NONE;
5136         
5137         // Look for type before continuing.                     
5139         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5141         intPrevValue = 7;
5143         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5144         intiter != SplitPoints.end(); ++intiter){
5145         
5146                 SLiter = SplitLength.find(intiter->first);
5147         
5148                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5149                 
5150                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5151                 PropertyName = PropertyElement.GetNextToken();                          
5152                 PropertyValue = PropertyElement.GetNextToken();
5153                 
5154                 intPrevValue = intiter->second;
5155                 
5156                 // Process properties.
5157                 
5158                 size_t intPropertyValueLen = PropertyValue.Len();
5159                 
5160                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5161                         
5162                         PropertyValue.Trim();
5163                         PropertyValue.RemoveLast();
5164                         
5165                 }                               
5166                 
5167                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5168                         
5169                         PropertyValue.Remove(0, 1);
5170                         
5171                 }                       
5172                 
5173                 CaptureString(&PropertyValue, FALSE);
5174                 
5175                 if (PropertyName == wxT("ALTID")){
5177                         CalendarListAltID.erase(*CalURICount);
5178                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5179                 
5180                 } else if (PropertyName == wxT("PID")){
5182                         CalendarListPID.erase(*CalURICount);
5183                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5184                 
5185                 } else if (PropertyName == wxT("PREF")){
5186                         
5187                         int PriorityNumber = 0;
5188                         bool ValidNumber = TRUE;
5189                         
5190                         try{
5191                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5192                         }
5193                         
5194                         catch(std::invalid_argument &e){
5195                                 ValidNumber = FALSE;
5196                         }
5198                         if (ValidNumber == TRUE){
5200                                 CalendarListPref.erase(*CalURICount);
5201                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5203                         }
5204                 
5205                 } else if (PropertyName == wxT("MEDIATYPE")){
5206                 
5207                         CalendarListMediatype.erase(*CalURICount);
5208                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5210                 } else {
5211                 
5212                         // Something else we don't know about so append
5213                         // to the tokens variable.
5214                         
5215                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5216                         
5217                                 if (FirstToken == TRUE){
5218                                 
5219                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5220                                         FirstToken = FALSE;
5221                                 
5222                                 } else {
5223                                 
5224                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5225                                 
5226                                 }
5227                         
5228                         }
5229                 
5230                 }
5231         
5232         }       
5233         
5234         intPropertyLen = PropertySeg2.Len();
5235         SplitPoints.clear();
5236         SplitLength.clear();
5237         intSplitsFound = 0;
5238         intSplitSize = 0;
5239         intPrevValue = 0;
5240         
5241         CaptureString(&PropertySeg2, FALSE);
5242         
5243         // Add the data to the General/Home/Work address variables.
5244                 
5245         switch(PropType){
5246                 case PROPERTY_NONE:
5247                         break;
5248                 case PROPERTY_HOME:
5249                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5250                         break;
5251                 case PROPERTY_WORK:
5252                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5253                         break;
5254         }
5255         
5256         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5257         
5258         if (!PropertyTokens.IsEmpty()){
5259         
5260                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5261         
5262         }
5266 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5268         size_t intPropertyLen = PropertySeg1.Len();
5269         std::map<int, int> SplitPoints;
5270         std::map<int, int> SplitLength;
5271         std::map<int, int>::iterator SLiter;                    
5272         wxString PropertyData;
5273         wxString PropertyName;
5274         wxString PropertyValue;
5275         wxString PropertyTokens;
5276         bool FirstToken = TRUE;
5277         int intSplitsFound = 0;
5278         int intSplitSize = 0;
5279         int intPrevValue = 8;
5280         int intPref = 0;                        
5281         int intType = 0;
5282         
5283         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5284         
5285         intPrevValue = 7;
5286         
5287         PropertyType PropType = PROPERTY_NONE;
5288         
5289         // Look for type before continuing.                     
5291         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5293         intPrevValue = 7;
5295         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5296         intiter != SplitPoints.end(); ++intiter){
5297         
5298                 SLiter = SplitLength.find(intiter->first);
5299         
5300                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5301                 
5302                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5303                 PropertyName = PropertyElement.GetNextToken();                          
5304                 PropertyValue = PropertyElement.GetNextToken();
5305                 
5306                 intPrevValue = intiter->second;
5307                 
5308                 // Process properties.
5309                 
5310                 size_t intPropertyValueLen = PropertyValue.Len();
5311                 
5312                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5313                         
5314                         PropertyValue.Trim();
5315                         PropertyValue.RemoveLast();
5316                         
5317                 }                               
5318                 
5319                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5320                         
5321                         PropertyValue.Remove(0, 1);
5322                         
5323                 }                       
5324                 
5325                 CaptureString(&PropertyValue, FALSE);
5326                 
5327                 if (PropertyName == wxT("ALTID")){
5329                         CalendarRequestListAltID.erase(*CalAdrURICount);
5330                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5331                 
5332                 } else if (PropertyName == wxT("PID")){
5334                         CalendarRequestListPID.erase(*CalAdrURICount);
5335                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5336                 
5337                 } else if (PropertyName == wxT("PREF")){
5338                         
5339                         int PriorityNumber = 0;
5340                         bool ValidNumber = TRUE;
5341                         
5342                         try{
5343                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5344                         }
5345                         
5346                         catch(std::invalid_argument &e){
5347                                 ValidNumber = FALSE;
5348                         }
5350                         if (ValidNumber == TRUE){
5352                                 CalendarRequestListPref.erase(*CalAdrURICount);
5353                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5355                         }
5356                 
5357                 } else if (PropertyName == wxT("MEDIATYPE")){
5358                 
5359                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5360                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5362                 } else {
5363                 
5364                         // Something else we don't know about so append
5365                         // to the tokens variable.
5366                         
5367                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5368                         
5369                                 if (FirstToken == TRUE){
5370                                 
5371                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5372                                         FirstToken = FALSE;
5373                                 
5374                                 } else {
5375                                 
5376                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5377                                 
5378                                 }
5379                         
5380                         }
5381                 
5382                 }
5383         
5384         }       
5385         
5386         intPropertyLen = PropertySeg2.Len();
5387         SplitPoints.clear();
5388         SplitLength.clear();
5389         intSplitsFound = 0;
5390         intSplitSize = 0;
5391         intPrevValue = 0;
5392         
5393         CaptureString(&PropertySeg2, FALSE);
5394         
5395         // Add the data to the General/Home/Work address variables.
5396                 
5397         switch(PropType){
5398                 case PROPERTY_NONE:
5399                         break;
5400                 case PROPERTY_HOME:
5401                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5402                         break;
5403                 case PROPERTY_WORK:
5404                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5405                         break;
5406         }
5407         
5408         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5409         
5410         if (!PropertyTokens.IsEmpty()){
5411         
5412                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5413         
5414         }       
5415         
5418 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5420         size_t intPropertyLen = PropertySeg1.Len();
5421         std::map<int, int> SplitPoints;
5422         std::map<int, int> SplitLength;
5423         std::map<int, int>::iterator SLiter;                    
5424         wxString PropertyData;
5425         wxString PropertyName;
5426         wxString PropertyValue;
5427         wxString PropertyTokens;
5428         bool FirstToken = TRUE;
5429         int intSplitsFound = 0;
5430         int intSplitSize = 0;
5431         int intPrevValue = 7;
5432         int intPref = 0;                        
5433         int intType = 0;
5434         
5435         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5436         
5437         intPrevValue = 6;
5438         
5439         PropertyType PropType = PROPERTY_NONE;
5440         
5441         // Look for type before continuing.                     
5443         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5445         intPrevValue = 6;
5447         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5448         intiter != SplitPoints.end(); ++intiter){
5449         
5450                 SLiter = SplitLength.find(intiter->first);
5451         
5452                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5453                 
5454                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5455                 PropertyName = PropertyElement.GetNextToken();                          
5456                 PropertyValue = PropertyElement.GetNextToken();
5457                 
5458                 intPrevValue = intiter->second;
5459                 
5460                 // Process properties.
5461                 
5462                 size_t intPropertyValueLen = PropertyValue.Len();
5463                 
5464                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5465                         
5466                         PropertyValue.Trim();
5467                         PropertyValue.RemoveLast();
5468                         
5469                 }                               
5470                 
5471                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5472                         
5473                         PropertyValue.Remove(0, 1);
5474                         
5475                 }                       
5476                 
5477                 CaptureString(&PropertyValue, FALSE);
5478                 
5479                 if (PropertyName == wxT("ALTID")){
5481                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5482                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5483                 
5484                 } else if (PropertyName == wxT("PID")){
5486                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5487                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5488                 
5489                 } else if (PropertyName == wxT("PREF")){
5490                         
5491                         int PriorityNumber = 0;
5492                         bool ValidNumber = TRUE;
5493                         
5494                         try{
5495                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5496                         }
5497                         
5498                         catch(std::invalid_argument &e){
5499                                 ValidNumber = FALSE;
5500                         }
5502                         if (ValidNumber == TRUE){
5504                                 FreeBusyListPref.erase(*FreeBusyAddressCount);
5505                                 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5507                         }
5508                 
5509                 } else if (PropertyName == wxT("MEDIATYPE")){
5510                 
5511                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5512                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5514                 } else {
5515                 
5516                         // Something else we don't know about so append
5517                         // to the tokens variable.
5518                         
5519                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5520                         
5521                                 if (FirstToken == TRUE){
5522                                 
5523                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5524                                         FirstToken = FALSE;
5525                                 
5526                                 } else {
5527                                 
5528                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5529                                 
5530                                 }
5531                         
5532                         }
5533                 
5534                 }
5535         
5536         }       
5537         
5538         intPropertyLen = PropertySeg2.Len();
5539         SplitPoints.clear();
5540         SplitLength.clear();
5541         intSplitsFound = 0;
5542         intSplitSize = 0;
5543         intPrevValue = 0;
5544         
5545         CaptureString(&PropertySeg2, FALSE);
5546         
5547         // Add the data to the General/Home/Work address variables.
5548                 
5549         switch(PropType){
5550                 case PROPERTY_NONE:
5551                         break;
5552                 case PROPERTY_HOME:
5553                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5554                         break;
5555                 case PROPERTY_WORK:
5556                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5557                         break;
5558         }
5559         
5560         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5561         
5562         if (!PropertyTokens.IsEmpty()){
5563         
5564                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5565         
5566         }
5570 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5572         size_t intPropertyLen = PropertySeg1.Len();
5573         std::map<int, int> SplitPoints;
5574         std::map<int, int> SplitLength;
5575         std::map<int, int>::iterator SLiter;                    
5576         wxString PropertyData;
5577         wxString PropertyName;
5578         wxString PropertyValue;
5579         wxString PropertyTokens;
5580         bool FirstToken = TRUE;
5581         int intSplitsFound = 0;
5582         int intSplitSize = 0;
5583         int intPrevValue = 5;
5584         int intPref = 0;                        
5585         int intType = 0;
5586         long ListCtrlIndex;
5587         
5588         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5589         
5590         intPrevValue = 4;
5591         
5592         PropertyType PropType = PROPERTY_NONE;
5593         
5594         // Look for type before continuing.
5596         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5598         intPrevValue = 4;
5600         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5601         intiter != SplitPoints.end(); ++intiter){
5602         
5603                 SLiter = SplitLength.find(intiter->first);
5604         
5605                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5606                 
5607                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5608                 PropertyName = PropertyElement.GetNextToken();                          
5609                 PropertyValue = PropertyElement.GetNextToken();
5610                 
5611                 intPrevValue = intiter->second;
5612                 
5613                 // Process properties.
5614                 
5615                 size_t intPropertyValueLen = PropertyValue.Len();
5616                 
5617                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5618                         
5619                         PropertyValue.Trim();
5620                         PropertyValue.RemoveLast();
5621                         
5622                 }                               
5623                 
5624                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5625                         
5626                         PropertyValue.Remove(0, 1);
5627                         
5628                 }                               
5629                 
5630                 if (PropertyName == wxT("ALTID")){
5632                         KeyListAltID.erase(*KeyCount);
5633                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5634                 
5635                 } else if (PropertyName == wxT("PID")){
5637                         KeyListPID.erase(*KeyCount);
5638                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5639                 
5640                 } else if (PropertyName == wxT("PREF")){
5641                         
5642                         int PriorityNumber = 0;
5643                         bool ValidNumber = TRUE;
5644                         
5645                         try{
5646                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5647                         }
5648                         
5649                         catch(std::invalid_argument &e){
5650                                 ValidNumber = FALSE;
5651                         }
5653                         if (ValidNumber == TRUE){
5655                                 KeyListPref.erase(*KeyCount);
5656                                 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5658                         }
5659                 
5660                 } else {
5661                 
5662                         // Something else we don't know about so append
5663                         // to the tokens variable.
5664                         
5665                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5666                         
5667                                 if (FirstToken == TRUE){
5668                                 
5669                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5670                                         FirstToken = FALSE;
5671                                 
5672                                 } else {
5673                                 
5674                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5675                                 
5676                                 }
5677                         
5678                         }
5679                 
5680                 }
5681         
5682         }                               
5683         
5684         intPropertyLen = PropertySeg2.Len();
5685         SplitPoints.clear();
5686         SplitLength.clear();
5687         intSplitsFound = 0;
5688         intSplitSize = 0;
5689         intPrevValue = 0;                       
5690         
5691         for (int i = 0; i <= intPropertyLen; i++){
5693                 intSplitSize++;
5694         
5695                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5696         
5697                         intSplitsFound++;
5698                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5699                         
5700                         if (intSplitsFound == 6){ 
5701                         
5702                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5703                                 break; 
5704                                 
5705                         } else {
5706                         
5707                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5708                         
5709                         }
5710                         
5711                         intSplitSize = 0;                                       
5712         
5713                 }
5715         }
5716         
5717         wxString wxSKeyURI;
5718         wxString wxSKeyMIME;
5719         wxString wxSKeyEncoding;
5720         wxString wxSKeyData;
5721         std::string base64enc;
5722         
5723         if (intSplitsFound == 0){
5724         
5725         } else {
5726         
5727                 std::map<int, int>::iterator striter;
5728         
5729                 striter = SplitLength.find(1);
5730         
5731                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5732         
5733                 while (wSTDataType.HasMoreTokens() == TRUE){
5734                 
5735                         wxSKeyURI = wSTDataType.GetNextToken();
5736                         wxSKeyMIME = wSTDataType.GetNextToken();
5737                         break;
5738                 
5739                 }                       
5740         
5741                 if (wxSKeyURI == wxT("data")){
5742                 
5743                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5744         
5745                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5746                 
5747                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5748                                 wxSKeyData = wSTDataInfo.GetNextToken();
5749                                 break;
5750                 
5751                         }
5752                 
5753                 }
5754         
5755         }
5756         
5757         // Add the data to the General/Home/Work address variables.
5758         
5759         if (wxSKeyURI == wxT("data")){
5760                 
5761                 KeyListDataEncType.erase(*KeyCount);
5762                 KeyListKeyType.erase(*KeyCount);
5763                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5764                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5765                 
5766                 KeyList.erase(*KeyCount);
5767                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5768         
5769         } else {
5770                 
5771                 KeyList.erase(*KeyCount);
5772                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5773         
5774         }
5775         
5776         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5777                 
5778         switch (PropType){
5779                 case PROPERTY_NONE:
5780                         break;
5781                 case PROPERTY_HOME: 
5782                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5783                         break;
5784                 case PROPERTY_WORK: 
5785                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5786                         break;
5787         }
5789         if (!PropertyTokens.IsEmpty()){
5791                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5793         }
5797 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5799         // Split the Vendor three ways.
5800         
5801         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5802         
5803         wxString wxSVNDID;
5804         wxString wxSVNDPropName;
5805         long ListCtrlIndex;                     
5807         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5808         
5809                 wSTVendorDetails.GetNextToken();
5810                 wxSVNDID = wSTVendorDetails.GetNextToken();
5811                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5812                 break;
5813         
5814         }
5815         
5816         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5817         
5818                 // Add the data to the vendor variables.
5819         
5820                 VendorList.erase(*VendorCount);
5821                 VendorListPEN.erase(*VendorCount);
5822                 VendorListElement.erase(*VendorCount);
5823         
5824                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5825                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5826                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5827         
5828         }
5832 void ProcessIntegerValue(ContactDataObject *ContactData,
5833         std::map<int,int> *PrefPtr, 
5834         wxString *PropertyValue, 
5835         int *ItemCount){
5837         int PriorityNumber = 0; 
5838         bool ValidNumber = TRUE;
5839                         
5840         try{
5841                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5842         }
5843                         
5844         catch(std::invalid_argument &e){
5845                 ValidNumber = FALSE;
5846         }
5848         if (ValidNumber == TRUE){
5850                 PrefPtr->erase(*ItemCount);
5851                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5853         }
5857 void SplitValues(wxString *PropertyLine, 
5858         std::map<int,int> *SplitPoints, 
5859         std::map<int,int> *SplitLength, 
5860         int intSize){
5861         
5862         size_t intPropertyLen = PropertyLine->Len();
5863         int intSplitsFound = 0;
5864         int intSplitSize = 0;
5865         int intSplitSeek = 0;
5866         
5867         for (int i = intSize; i <= intPropertyLen; i++){
5869                 intSplitSize++;
5870         
5871                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5872                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5873            
5874                     if (intSplitsFound == 0){
5875             
5876                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5877           
5878                     } else {
5879            
5880                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5881             
5882                     }
5883             
5884                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5885             
5886                     intSplitsFound++;
5887                     intSplitSeek = i;
5888                     intSplitSize = 0;
5889             
5890                 }
5892         }
5894         if (intSplitsFound == 0){
5896                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5897                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5899         } else {
5901                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5902                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5904         }
5908 void CheckType(wxString *PropertySeg1, 
5909         std::map<int,int> *SplitPoints, 
5910         std::map<int,int> *SplitLength, 
5911         int *intPrevValue, 
5912         PropertyType *PropType){
5913         
5914         wxString PropertyData;
5915         wxString PropertyName;
5916         wxString PropertyValue;
5917         std::map<int,int>::iterator SLiter;
5918         
5919         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5920         intiter != SplitPoints->end(); ++intiter){
5921         
5922                 SLiter = SplitLength->find(intiter->first);
5923         
5924                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5925                 
5926                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5927                 PropertyName = PropertyElement.GetNextToken();                          
5928                 PropertyValue = PropertyElement.GetNextToken();
5929                 
5930                 *intPrevValue = intiter->second;
5931                 
5932                 if (PropertyName == wxT("TYPE")){
5933                                 
5934                         if (PropertyValue == wxT("work")){
5935                         
5936                                 *PropType = PROPERTY_WORK;
5937                                                         
5938                         } else if (PropertyValue == wxT("home")){
5940                                 *PropType = PROPERTY_HOME;
5941                                                         
5942                         } else {
5943                         
5944                                 *PropType = PROPERTY_NONE;
5945                         
5946                         }
5947                 
5948                         return;
5949                 
5950                 }
5951         
5952         }
5953         
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