Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
23c53f3999116a01fe7332b5962439067289d744
[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                         ProcessIntegerValue(this, NicknamesListPref, &PropertyValue, NicknameCount);
1230                 
1231                 } else if (PropertyName == wxT("LANGUAGE")){
1233                         NicknamesListLanguage->erase(*NicknameCount);
1234                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
1236                 } else {
1237                 
1238                         // Something else we don't know about so append
1239                         // to the tokens variable.
1240                 
1241                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1242                 
1243                                 if (FirstToken == TRUE){
1244                         
1245                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1246                                         FirstToken = FALSE;
1247                         
1248                                 } else {
1249                         
1250                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1251                         
1252                                 }
1253                 
1254                         }
1255                 
1256                 }
1257                 
1258         }
1259         
1260         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1261         
1262         // Add the name token data.
1263         
1264         if (!PropertyTokens.IsEmpty()){
1265         
1266                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1267         
1268         }
1272 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1274         std::map<int, int> SplitPoints;
1275         std::map<int, int> SplitLength;
1276         std::map<int, int>::iterator SLiter;                    
1277         wxString PropertyData;
1278         wxString PropertyName;
1279         wxString PropertyValue;
1280         wxString PropertyTokens;
1281         bool FirstToken = TRUE;
1282         int intPrevValue = 8;
1284         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1286         intPrevValue = 7;                       
1287         
1288         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1289         intiter != SplitPoints.end(); ++intiter){
1290         
1291                 SLiter = SplitLength.find(intiter->first);
1292         
1293                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1294                 
1295                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1296                 PropertyName = PropertyElement.GetNextToken();                          
1297                 PropertyValue = PropertyElement.GetNextToken();
1298                 
1299                 intPrevValue = intiter->second;
1300                 
1301                 // Process properties.
1302                 
1303                 size_t intPropertyValueLen = PropertyValue.Len();
1304                 
1305                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1306                         
1307                         PropertyValue.Trim();
1308                         PropertyValue.RemoveLast();
1309                         
1310                 }                               
1311                 
1312                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1313                         
1314                         PropertyValue.Remove(0, 1);
1315                         
1316                 }                               
1317                 
1318                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1320                         if (FirstToken == TRUE){
1321         
1322                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1323                                 FirstToken = FALSE;
1324         
1325                         } else {
1326         
1327                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1328         
1329                         }
1331                 }
1332         
1333         }       
1335         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1336         
1337         wxString GenderComponent;
1338         
1339         if (GenderData.CountTokens() >= 2){
1340         
1341                 Gender = GenderData.GetNextToken();
1342                 GenderDetails = GenderData.GetString();
1343         
1344                 CaptureString(&GenderDetails, FALSE);
1345                                                 
1346         } else {
1347         
1348                 Gender = GenderData.GetNextToken();
1349         
1350         }
1351         
1352         if (!PropertyTokens.IsEmpty()){
1353         
1354                 GenderTokens = PropertyTokens;
1355         
1356         }
1360 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1362         // Process date. Preserve the remainder in the string.
1364         std::map<int, int> SplitPoints;
1365         std::map<int, int> SplitLength;
1366         std::map<int, int>::iterator SLiter;                    
1367         wxString PropertyData;
1368         wxString PropertyName;
1369         wxString PropertyValue;
1370         wxString PropertyTokens;
1371         bool BirthdayText = FALSE;
1372         int intPrevValue = 6;
1374         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1376         intPrevValue = 5;
1378         // Look for type before continuing.
1380         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1381         intiter != SplitPoints.end(); ++intiter){
1383                 SLiter = SplitLength.find(intiter->first);
1385                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1386         
1387                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1388                 PropertyName = PropertyElement.GetNextToken();                          
1389                 PropertyValue = PropertyElement.GetNextToken();
1390         
1391                 intPrevValue = intiter->second;
1392         
1393                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1394         
1395                         CaptureString(&PropertySeg2, FALSE);
1396                         Birthday = PropertySeg2;
1397                         BirthdayText = TRUE;
1398         
1399                 }
1401         }
1403         // Setup blank lines for later on.
1404         
1405         intPrevValue = 5;
1406         bool FirstToken = TRUE;
1408         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1409         intiter != SplitPoints.end(); ++intiter){
1411                 SLiter = SplitLength.find(intiter->first);
1413                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1414         
1415                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1416                 PropertyName = PropertyElement.GetNextToken();                          
1417                 PropertyValue = PropertyElement.GetNextToken();
1418         
1419                 intPrevValue = intiter->second;
1420         
1421                 // Process properties.
1422         
1423                 CaptureString(&PropertyValue, FALSE);
1424         
1425                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1426                 
1427                         PropertyValue.Trim();
1428                         PropertyValue.RemoveLast();
1429                 
1430                 }                               
1431         
1432                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1433                 
1434                         PropertyValue.Remove(0, 1);
1435                 
1436                 }                               
1437         
1438                 if (PropertyName == wxT("ALTID")){
1440                         BirthdayAltID = PropertyValue;
1441         
1442                 } else if (PropertyName == wxT("CALSCALE")){
1443         
1444                         BirthdayCalScale = PropertyValue;
1445         
1446                 } else if (PropertyName != wxT("VALUE")) {
1447         
1448                         // Something else we don't know about so append
1449                         // to the tokens variable.
1450                 
1451                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1452                 
1453                                 if (FirstToken == TRUE){
1454         
1455                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1456                                         FirstToken = FALSE;
1457         
1458                                 } else {
1459         
1460                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1461         
1462                                 }
1463                                 
1464                         }
1465                         
1466                 }
1468         }       
1470         // Add the data to the variables and form.
1471         
1472         if (BirthdayText == FALSE){
1473         
1474                 Birthday = PropertySeg2;
1476         }
1477         
1478         if (!PropertyTokens.IsEmpty()){
1479         
1480                 BirthdayTokens = PropertyTokens;
1482         }
1486 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1488         // Process date. Preserve the remainder in the string.
1490         std::map<int, int> SplitPoints;
1491         std::map<int, int> SplitLength;
1492         std::map<int, int>::iterator SLiter;                    
1493         wxString PropertyData;
1494         wxString PropertyName;
1495         wxString PropertyValue;
1496         wxString PropertyTokens;
1497         bool AnniversaryText = FALSE;
1498         int intPrevValue = 13;
1500         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1502         intPrevValue = 12;
1504         // Look for type before continuing.
1506         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1507         intiter != SplitPoints.end(); ++intiter){
1509                 SLiter = SplitLength.find(intiter->first);
1511                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1512         
1513                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1514                 PropertyName = PropertyElement.GetNextToken();                          
1515                 PropertyValue = PropertyElement.GetNextToken();
1516         
1517                 intPrevValue = intiter->second;
1518         
1519                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1520         
1521                         CaptureString(&PropertySeg2, FALSE);
1522                         Anniversary = PropertySeg2;
1523                         AnniversaryText = TRUE;
1524         
1525                 }
1527         }
1529         // Setup blank lines for later on.
1530         
1531         intPrevValue = 12;
1532         bool FirstToken = TRUE;
1534         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1535         intiter != SplitPoints.end(); ++intiter){
1537                 SLiter = SplitLength.find(intiter->first);
1539                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1540         
1541                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1542                 PropertyName = PropertyElement.GetNextToken();                          
1543                 PropertyValue = PropertyElement.GetNextToken();
1544         
1545                 intPrevValue = intiter->second;
1546         
1547                 // Process properties.
1548         
1549                 CaptureString(&PropertyValue, FALSE);
1550         
1551                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1552                 
1553                         PropertyValue.Trim();
1554                         PropertyValue.RemoveLast();
1555                 
1556                 }                               
1557         
1558                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1559                 
1560                         PropertyValue.Remove(0, 1);
1561                 
1562                 }                               
1563         
1564                 if (PropertyName == wxT("ALTID")){
1566                         AnniversaryAltID = PropertyValue;
1567         
1568                 } else if (PropertyName == wxT("CALSCALE")){
1569         
1570                         AnniversaryCalScale = PropertyValue;
1571         
1572                 } else if (PropertyName != wxT("VALUE")) {
1573         
1574                         // Something else we don't know about so append
1575                         // to the tokens variable.
1576                 
1577                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1578                 
1579                                 if (FirstToken == TRUE){
1580         
1581                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1582                                         FirstToken = FALSE;
1583         
1584                                 } else {
1585         
1586                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1587         
1588                                 }
1589                                 
1590                         }
1591                         
1592                 }
1594         }       
1596         // Add the data to the variables and form.
1597         
1598         if (AnniversaryText == FALSE){
1599         
1600                 Anniversary = PropertySeg2;
1602         }
1603         
1604         if (!PropertyTokens.IsEmpty()){
1605         
1606                 AnniversaryTokens = PropertyTokens;
1608         }
1612 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1614         std::map<int, int> SplitPoints;
1615         std::map<int, int> SplitLength;
1617         int intPrevValue = 4;
1618         int intPref = 0;                        
1619         
1620         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1621         
1622         intPrevValue = 3;
1623         
1624         PropertyType PropType = PROPERTY_NONE;
1625         
1626         // Look for type before continuing.
1627         
1628         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1629         
1630         intPrevValue = 3;
1631         
1632         std::map<int, wxString> *TZList = NULL;
1633         std::map<int, wxString> *TZListType = NULL;
1634         std::map<int, wxString> *TZListMediatype = NULL;
1635         std::map<int, wxString> *TZListAltID = NULL;
1636         std::map<int, wxString> *TZListPID = NULL;
1637         std::map<int, wxString> *TZListTokens = NULL;           
1638         std::map<int, int> *TZListPref = NULL;
1639         
1640         switch(PropType){
1641                 case PROPERTY_NONE:
1642                         TZList = &GeneralTZList;
1643                         TZListType = &GeneralTZListType;
1644                         TZListMediatype = &GeneralTZListMediatype;
1645                         TZListAltID = &GeneralTZListAltID;
1646                         TZListPID = &GeneralTZListPID;
1647                         TZListTokens = &GeneralTZListTokens;
1648                         TZListPref = &GeneralTZListPref;
1649                         break;
1650                 case PROPERTY_HOME:
1651                         TZList = &HomeTZList;
1652                         TZListType = &HomeTZListType;
1653                         TZListMediatype = &HomeTZListMediatype;
1654                         TZListAltID = &HomeTZListAltID;
1655                         TZListPID = &HomeTZListPID;
1656                         TZListTokens = &HomeTZListTokens;
1657                         TZListPref = &HomeTZListPref;
1658                         break;
1659                 case PROPERTY_WORK:
1660                         TZList = &BusinessTZList;
1661                         TZListType = &BusinessTZListType;
1662                         TZListMediatype = &BusinessTZListMediatype;
1663                         TZListAltID = &BusinessTZListAltID;
1664                         TZListPID = &BusinessTZListPID;
1665                         TZListTokens = &BusinessTZListTokens;
1666                         TZListPref = &BusinessTZListPref;
1667                         break;
1668         }
1669         
1670         std::map<int, int>::iterator SLiter;    
1671         wxString PropertyData;
1672         wxString PropertyName;
1673         wxString PropertyValue;
1674         wxString PropertyTokens;
1675         bool FirstToken = TRUE;
1676         
1677         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1678         intiter != SplitPoints.end(); ++intiter){
1679         
1680                 SLiter = SplitLength.find(intiter->first);
1681         
1682                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1683                 
1684                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1685                 PropertyName = PropertyElement.GetNextToken();                          
1686                 PropertyValue = PropertyElement.GetNextToken();
1687                 
1688                 intPrevValue = intiter->second;
1689                 
1690                 CaptureString(&PropertyValue, FALSE);
1692                 if (PropertyName == wxT("ALTID")){
1694                         TZListAltID->erase(*TimeZoneCount);
1695                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1696                 
1697                 } else if (PropertyName == wxT("PID")){
1699                         TZListPID->erase(*TimeZoneCount);
1700                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1702                 } else if (PropertyName == wxT("PREF")){
1704                         ProcessIntegerValue(this, TZListPref, &PropertyValue, TimeZoneCount);
1705                 
1706                 } else if (PropertyName == wxT("MEDIATYPE")){
1708                         TZListMediatype->erase(*TimeZoneCount);
1709                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1711                 } else {
1712                 
1713                         // Something else we don't know about so append
1714                         // to the tokens variable.
1715                 
1716                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1717                 
1718                                 if (FirstToken == TRUE){
1719                         
1720                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1721                                         FirstToken = FALSE;
1722                         
1723                                 } else {
1724                         
1725                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1726                         
1727                                 }
1728                 
1729                         }
1730                 
1731                 }
1732                 
1733         }
1734         
1735         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1736         
1737         // Add the name token data.
1738         
1739         if (!PropertyTokens.IsEmpty()){
1740         
1741                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1742         
1743         }
1748 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1750         size_t intPropertyLen = PropertySeg1.Len();
1751         std::map<int, int> SplitPoints;
1752         std::map<int, int> SplitLength;
1753         std::map<int, int>::iterator SLiter;                    
1754         wxString PropertyData;
1755         wxString PropertyName;
1756         wxString PropertyValue;
1757         wxString PropertyTokens;
1758         wxString AddressLabel;
1759         wxString AddressLang;
1760         wxString AddressAltID;
1761         wxString AddressPID;
1762         wxString AddressTokens;
1763         wxString AddressGeo;
1764         wxString AddressTimezone;
1765         wxString AddressType;
1766         wxString AddressMediatype;
1767         wxString AddressPOBox;
1768         wxString AddressExtended;
1769         wxString AddressStreet;
1770         wxString AddressLocality;
1771         wxString AddressCity;
1772         wxString AddressRegion;
1773         wxString AddressPostalCode;
1774         wxString AddressCountry;
1775         bool FirstToken = TRUE;                 
1776         int intSplitsFound = 0;
1777         int intSplitSize = 0;
1778         int intPrevValue = 5;
1779         int intPref = 0;                        
1780         int intType = 0;
1781         long ListCtrlIndex;
1782         
1783         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1784         
1785         intPrevValue = 4;
1786         
1787         PropertyType PropType = PROPERTY_NONE;
1788                 
1789         // Look for type before continuing.
1790         
1791         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1792         
1793         intPrevValue = 4;
1794         
1795         std::map<int, wxString> *AddressList = NULL;
1796         std::map<int, wxString> *AddressListTown = NULL;
1797         std::map<int, wxString> *AddressListCounty = NULL;
1798         std::map<int, wxString> *AddressListPostCode = NULL;
1799         std::map<int, wxString> *AddressListCountry = NULL;
1800         std::map<int, wxString> *AddressListLabel = NULL;
1801         std::map<int, wxString> *AddressListLang = NULL;                
1802         std::map<int, wxString> *AddressListAltID = NULL;
1803         std::map<int, wxString> *AddressListPID = NULL;
1804         std::map<int, wxString> *AddressListTokens = NULL;
1805         std::map<int, wxString> *AddressListGeo = NULL;
1806         std::map<int, wxString> *AddressListTimezone = NULL;            
1807         std::map<int, wxString> *AddressListType = NULL;
1808         std::map<int, wxString> *AddressListMediatype = NULL;
1809         std::map<int, int> *AddressListPref = NULL;
1811         switch(PropType){
1812                 case PROPERTY_NONE:
1813                         AddressList = &GeneralAddressList;
1814                         AddressListTown = &GeneralAddressListTown;
1815                         AddressListCounty = &GeneralAddressListCounty;
1816                         AddressListPostCode = &GeneralAddressListPostCode;
1817                         AddressListCountry = &GeneralAddressListCountry;
1818                         AddressListLabel = &GeneralAddressListLabel;
1819                         AddressListLang = &GeneralAddressListLang;              
1820                         AddressListAltID = &GeneralAddressListAltID;
1821                         AddressListPID = &GeneralAddressListPID;
1822                         AddressListTokens = &GeneralAddressListTokens;
1823                         AddressListGeo = &GeneralAddressListGeo;
1824                         AddressListTimezone = &GeneralAddressListTimezone;
1825                         AddressListType = &GeneralAddressListType;
1826                         AddressListMediatype = &GeneralAddressListMediatype;
1827                         AddressListPref = &GeneralAddressListPref;              
1828                         break;
1829                 case PROPERTY_HOME:
1830                         AddressList = &HomeAddressList;
1831                         AddressListTown = &HomeAddressListTown;
1832                         AddressListCounty = &HomeAddressListCounty;
1833                         AddressListPostCode = &HomeAddressListPostCode;
1834                         AddressListCountry = &HomeAddressListCountry;
1835                         AddressListLabel = &HomeAddressListLabel;
1836                         AddressListLang = &HomeAddressListLang;         
1837                         AddressListAltID = &HomeAddressListAltID;
1838                         AddressListPID = &HomeAddressListPID;
1839                         AddressListTokens = &HomeAddressListTokens;
1840                         AddressListGeo = &HomeAddressListGeo;
1841                         AddressListTimezone = &HomeAddressListTimezone;
1842                         AddressListType = &HomeAddressListType;
1843                         AddressListMediatype = &HomeAddressListMediatype;
1844                         AddressListPref = &HomeAddressListPref;
1845                         break;
1846                 case PROPERTY_WORK:
1847                         AddressList = &BusinessAddressList;
1848                         AddressListTown = &BusinessAddressListTown;
1849                         AddressListCounty = &BusinessAddressListCounty;
1850                         AddressListPostCode = &BusinessAddressListPostCode;
1851                         AddressListCountry = &BusinessAddressListCountry;
1852                         AddressListLabel = &BusinessAddressListLabel;
1853                         AddressListLang = &BusinessAddressListLang;             
1854                         AddressListAltID = &BusinessAddressListAltID;
1855                         AddressListPID = &BusinessAddressListPID;
1856                         AddressListTokens = &BusinessAddressListTokens;
1857                         AddressListGeo = &BusinessAddressListGeo;
1858                         AddressListTimezone = &BusinessAddressListTimezone;
1859                         AddressListType = &BusinessAddressListType;
1860                         AddressListMediatype = &BusinessAddressListMediatype;
1861                         AddressListPref = &BusinessAddressListPref;
1862                         break;
1863         }
1864         
1865         intPrevValue = 4;
1866         
1867         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1868         intiter != SplitPoints.end(); ++intiter){
1869         
1870                 SLiter = SplitLength.find(intiter->first);
1871         
1872                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1873                 
1874                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1875                 PropertyName = PropertyElement.GetNextToken();                          
1876                 PropertyValue = PropertyElement.GetNextToken();
1877                 
1878                 intPrevValue = intiter->second;
1879                 
1880                 CaptureString(&PropertyValue, FALSE);
1881                 
1882                 // Process properties.
1883                 
1884                 if (PropertyName == wxT("LABEL")){
1885                 
1886                         AddressListLabel->erase(*AddressCount);
1887                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1888                                 
1889                 } else if (PropertyName == wxT("LANGUAGE")){
1890                 
1891                         AddressListLang->erase(*AddressCount);
1892                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1893                 
1894                 } else if (PropertyName == wxT("ALTID")){
1896                         AddressListAltID->erase(*AddressCount);
1897                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1898                 
1899                 } else if (PropertyName == wxT("PID")){
1901                         AddressListPID->erase(*AddressCount);
1902                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1903                 
1904                 } else if (PropertyName == wxT("GEO")){
1905                 
1906                         AddressListGeo->erase(*AddressCount);
1907                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1908                 
1909                 } else if (PropertyName == wxT("TZ")){
1911                         AddressListTimezone->erase(*AddressCount);
1912                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1913                 
1914                 } else if (PropertyName == wxT("MEDIATYPE")){
1916                         AddressListMediatype->erase(*AddressCount);
1917                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1918                 
1919                 } else if (PropertyName == wxT("PREF")){
1921                         ProcessIntegerValue(this, AddressListPref, &PropertyValue, AddressCount);
1922                 
1923                 } else {
1924                 
1925                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1926                         
1927                                 if (FirstToken == TRUE){
1928                                 
1929                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1930                                         FirstToken = FALSE;
1931                                 
1932                                 } else {
1933                                 
1934                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1935                                 
1936                                 }
1937                         
1938                         }
1939                 
1940                 }
1941         
1942         }                       
1943         
1944         // Split the address. 
1946         //std::map<int, int>::iterator SLiter;
1947         intPropertyLen = PropertySeg2.Len();
1948         SplitPoints.clear();
1949         SplitLength.clear();
1950         intSplitsFound = 0;
1951         intSplitSize = 0;
1952         intPrevValue = 0;
1953         
1954         for (int i = 0; i <= intPropertyLen; i++){
1956                 intSplitSize++;
1957         
1958                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1959         
1960                         intSplitsFound++;
1961                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1962                         
1963                         if (intSplitsFound == 6){ 
1964                         
1965                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1966                                 break; 
1967                                 
1968                         } else {
1969                         
1970                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1971                         
1972                         }
1973                         
1974                         intSplitSize = 0;                                       
1975         
1976                 }
1978         }
1979         
1980         // Split the data into several parts.                   
1981         
1982         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1983         intiter != SplitPoints.end(); ++intiter){
1984                         
1985                 if (intiter->first == 1){
1986                 
1987                         // Deal with PO Box.
1988                         
1989                         SLiter = SplitLength.find(1);
1990                                                                 
1991                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1992                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1993                         intPrevValue = intiter->second;
1994                 
1995                 } else if (intiter->first == 2){
1996                 
1997                         // Deal with extended address.
1998                         
1999                         SLiter = SplitLength.find(2);
2000                         
2001                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2002                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2003                         intPrevValue = intiter->second;
2004                 
2005                 } else if (intiter->first == 3){
2006                 
2007                         // Deal with street address.
2008                         
2009                         SLiter = SplitLength.find(3);
2010                                                                 
2011                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2012                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2013                         intPrevValue = intiter->second;
2014                 
2015                 } else if (intiter->first == 4){
2016                 
2017                         // Deal with locality
2019                         SLiter = SplitLength.find(4);
2020                         
2021                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2022                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2023                         intPrevValue = intiter->second;
2024                         
2025                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2026                 
2027                 } else if (intiter->first == 5){
2028                 
2029                         // Deal with region.
2031                         SLiter = SplitLength.find(5);
2032                         
2033                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2034                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2035                         intPrevValue = intiter->second;
2036                         
2037                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2038                 
2039                 } else if (intiter->first == 6){
2040                 
2041                         // Deal with post code.
2043                         SLiter = SplitLength.find(6);
2044                         
2045                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2046                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2047                         intPrevValue = intiter->second;
2048                         
2049                         // Deal with country.
2050                                                 
2051                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2052                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2053                         
2054                         break;
2055                 
2056                 }
2057         
2058         }       
2059         
2060         // Add the data to the General/Home/Work address variables.
2061         
2062         CaptureString(&AddressStreet, FALSE); 
2063         CaptureString(&AddressLocality, FALSE);
2064         CaptureString(&AddressRegion, FALSE);
2065         CaptureString(&AddressPostalCode, FALSE);
2066         CaptureString(&AddressCountry, FALSE);
2067                 
2068         if (!PropertyTokens.IsEmpty()){
2069         
2070                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2071         
2072         }
2074         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2075         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2076         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2077         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2078         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2080         switch(PropType){
2081                 case PROPERTY_NONE:
2082                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2083                         break;
2084                 case PROPERTY_HOME:
2085                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2086                         break;
2087                 case PROPERTY_WORK:
2088                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2089                         break;
2090         }
2091         
2092         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2096 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2098         std::map<int, int> SplitPoints;
2099         std::map<int, int> SplitLength;
2101         int intPrevValue = 7;
2102         int intPref = 0;                        
2103         
2104         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2105         
2106         intPrevValue = 6;
2107         
2108         PropertyType PropType = PROPERTY_NONE;
2109                 
2110         // Look for type before continuing.
2111         
2112         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2113         
2114         std::map<int, wxString> *EmailList = NULL;
2115         std::map<int, wxString> *EmailListType = NULL;
2116         std::map<int, wxString> *EmailListAltID = NULL;
2117         std::map<int, wxString> *EmailListPID = NULL;
2118         std::map<int, wxString> *EmailListTokens = NULL;                
2119         std::map<int, int> *EmailListPref = NULL;
2121         switch(PropType){
2122                 case PROPERTY_NONE:
2123                         EmailList = &GeneralEmailList;
2124                         EmailListType = &GeneralEmailListType;
2125                         EmailListAltID = &GeneralEmailListAltID;
2126                         EmailListPID = &GeneralEmailListPID;
2127                         EmailListTokens = &GeneralEmailListTokens;              
2128                         EmailListPref = &GeneralEmailListPref;  
2129                         break;
2130                 case PROPERTY_HOME:
2131                         EmailList = &HomeEmailList;
2132                         EmailListType = &HomeEmailListType;
2133                         EmailListAltID = &HomeEmailListAltID;
2134                         EmailListPID = &HomeEmailListPID;
2135                         EmailListTokens = &HomeEmailListTokens;         
2136                         EmailListPref = &HomeEmailListPref;     
2137                         break;
2138                 case PROPERTY_WORK:
2139                         EmailList = &BusinessEmailList;
2140                         EmailListType = &BusinessEmailListType;
2141                         EmailListAltID = &BusinessEmailListAltID;
2142                         EmailListPID = &BusinessEmailListPID;
2143                         EmailListTokens = &BusinessEmailListTokens;             
2144                         EmailListPref = &BusinessEmailListPref; 
2145                         break;
2146         }
2147         
2148         intPrevValue = 6;
2149         
2150         std::map<int,int>::iterator SLiter;
2151         wxString PropertyData;
2152         wxString PropertyName;
2153         wxString PropertyValue;
2154         wxString PropertyTokens;
2155         bool FirstToken = TRUE;
2156         
2157         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2158         intiter != SplitPoints.end(); ++intiter){
2159         
2160                 SLiter = SplitLength.find(intiter->first);
2161         
2162                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2163                 
2164                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2165                 PropertyName = PropertyElement.GetNextToken();                          
2166                 PropertyValue = PropertyElement.GetNextToken();
2167                 
2168                 intPrevValue = intiter->second;
2169                 
2170                 CaptureString(&PropertyValue, FALSE);
2171                 
2172                 // Process properties.
2173                 
2174                 if (PropertyName == wxT("ALTID")){
2176                         EmailListAltID->erase(*EmailCount);
2177                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2178                 
2179                 } else if (PropertyName == wxT("PID")){
2181                         EmailListPID->erase(*EmailCount);
2182                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2183                 
2184                 } else if (PropertyName == wxT("PREF")){
2185                         
2186                         ProcessIntegerValue(this, EmailListPref, &PropertyValue, EmailCount);
2187                 
2188                 } else {
2189                 
2190                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2191                         
2192                                 if (FirstToken == TRUE){
2193                                 
2194                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2195                                         FirstToken = FALSE;
2196                                 
2197                                 } else {
2198                                 
2199                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2200                                 
2201                                 }
2202                         
2203                         }
2204                 
2205                 }
2206         
2207         }
2208         
2209         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2210         
2211         // Add the name token data.
2212         
2213         if (!PropertyTokens.IsEmpty()){
2214         
2215                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2216         
2217         }       
2222 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2224         std::map<int, int> SplitPoints;
2225         std::map<int, int> SplitLength;
2227         int intPrevValue = 6;
2228         int intPref = 0;                        
2229         
2230         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2231         
2232         intPrevValue = 5;
2233         
2234         PropertyType PropType = PROPERTY_NONE;
2235                 
2236         // Look for type before continuing.
2237         
2238         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2239         
2240         std::map<int, wxString> *IMList = NULL;
2241         std::map<int, wxString> *IMListType = NULL;
2242         std::map<int, wxString> *IMListAltID = NULL;
2243         std::map<int, wxString> *IMListPID = NULL;
2244         std::map<int, wxString> *IMListTokens = NULL;
2245         std::map<int, wxString> *IMListMediatype = NULL;        
2246         std::map<int, int> *IMListPref = NULL;
2248         switch(PropType){
2249                 case PROPERTY_NONE:
2250                         IMList = &GeneralIMList;
2251                         IMListType = &GeneralIMListType;
2252                         IMListAltID = &GeneralIMListAltID;
2253                         IMListPID = &GeneralIMListPID;
2254                         IMListTokens = &GeneralIMListTokens;
2255                         IMListMediatype = &GeneralIMListMediatype;
2256                         IMListPref = &GeneralIMListPref;        
2257                         break;
2258                 case PROPERTY_HOME:
2259                         IMList = &HomeIMList;
2260                         IMListType = &HomeIMListType;
2261                         IMListAltID = &HomeIMListAltID;
2262                         IMListPID = &HomeIMListPID;
2263                         IMListTokens = &HomeIMListTokens;
2264                         IMListMediatype = &HomeIMListMediatype;         
2265                         IMListPref = &HomeIMListPref;   
2266                         break;
2267                 case PROPERTY_WORK:
2268                         IMList = &BusinessIMList;
2269                         IMListType = &BusinessIMListType;
2270                         IMListAltID = &BusinessIMListAltID;
2271                         IMListPID = &BusinessIMListPID;
2272                         IMListTokens = &BusinessIMListTokens;   
2273                         IMListMediatype = &BusinessIMListMediatype;     
2274                         IMListPref = &BusinessIMListPref;       
2275                         break;
2276         }
2277         
2278         intPrevValue = 5;
2279         
2280         std::map<int,int>::iterator SLiter;
2281         wxString PropertyData;
2282         wxString PropertyName;
2283         wxString PropertyValue;
2284         wxString PropertyTokens;
2285         bool FirstToken = TRUE;
2286         
2287         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2288         intiter != SplitPoints.end(); ++intiter){
2289         
2290                 SLiter = SplitLength.find(intiter->first);
2291         
2292                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2293                 
2294                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2295                 PropertyName = PropertyElement.GetNextToken();                          
2296                 PropertyValue = PropertyElement.GetNextToken();
2297                 
2298                 intPrevValue = intiter->second;
2299                 
2300                 CaptureString(&PropertyValue, FALSE);
2301                 
2302                 // Process properties.
2303                 
2304                 if (PropertyName == wxT("ALTID")){
2306                         IMListAltID->erase(*IMCount);
2307                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2308                 
2309                 } else if (PropertyName == wxT("PID")){
2311                         IMListPID->erase(*IMCount);
2312                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2313                 
2314                 } else if (PropertyName == wxT("MEDIATYPE")){
2316                         IMListMediatype->erase(*IMCount);
2317                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2318                 
2319                 } else if (PropertyName == wxT("PREF")){
2320                         
2321                         ProcessIntegerValue(this, IMListPref, &PropertyValue, IMCount);
2322                 
2323                 } else {
2324                 
2325                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2326                         
2327                                 if (FirstToken == TRUE){
2328                                 
2329                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2330                                         FirstToken = FALSE;
2331                                 
2332                                 } else {
2333                                 
2334                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2335                                 
2336                                 }
2337                         
2338                         }
2339                 
2340                 }
2341         
2342         }
2343                 
2344         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2345         
2346         // Add the name token data.
2347         
2348         if (!PropertyTokens.IsEmpty()){
2349         
2350                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2351         
2352         }
2356 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2358         std::map<int, int> SplitPoints;
2359         std::map<int, int> SplitLength;
2360         std::map<int, int>::iterator SLiter;
2361         
2362         int intPref = 0;
2363         
2364         PropertyType PropType = PROPERTY_NONE;
2365                 
2366         // Look for type before continuing.
2367         
2368         wxString TelTypeUI;
2369         wxString TelTypeDetail;
2370         wxString PropertyData;
2371         wxString PropertyName;
2372         wxString PropertyValue;
2373         wxString PropertyTokens;
2374         
2375         std::map<int,int> TypeSplitPoints;
2376         std::map<int,int> TypeSplitLength;
2377         std::map<int,int>::iterator TSLiter;
2378         
2379         int intSplitSize = 0;
2380         int intSplitsFound = 0;
2381         int intSplitPoint = 0;
2382         int intType = 0;
2383         int intPrevValue = 5;
2384                 
2385         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2386         
2387         intPrevValue = 4;
2388         
2389         // Look for type before continuing.
2390         
2391         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2392         intiter != SplitPoints.end(); ++intiter){
2393         
2394                 SLiter = SplitLength.find(intiter->first);
2395         
2396                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2397                 
2398                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2399                 PropertyName = PropertyElement.GetNextToken();                          
2400                 PropertyValue = PropertyElement.GetNextToken();
2401                 
2402                 intPrevValue = intiter->second;
2404                 if (PropertyName == wxT("TYPE")){
2405                 
2406                         // Process each value in type and translate each
2407                         // part.
2408                 
2409                         // Strip out the quotes if they are there.
2410                 
2411                         size_t intPropertyValueLen = PropertyValue.Len();
2412                 
2413                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2414                         
2415                                 PropertyValue.Trim();
2416                                 PropertyValue.RemoveLast();
2417                         
2418                         }                               
2419                 
2420                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2421                         
2422                                 PropertyValue.Remove(0, 1);
2423                         
2424                         }
2425                         
2426                         TelTypeDetail = PropertyValue;
2427                         
2428                         intSplitSize = 0;
2429                         intSplitsFound = 0;
2430                         intSplitPoint = 0;
2431                         
2432                         for (int i = 0; i <= intPropertyValueLen; i++){
2433         
2434                                 intSplitSize++;
2435         
2436                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2437         
2438                                         if (intSplitsFound == 0){
2440                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2441                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2442                         
2443                                         } else {
2444                         
2445                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2446                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2447                         
2448                                         }                       
2450                                         intSplitsFound++;
2451                                         i++;
2452                                         intSplitPoint = i;
2453                                         intSplitSize = 0;
2454         
2455                                 }
2456         
2457                         }
2458                         
2459                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2460                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2461                 
2462                         int intTypeSeek = 0;
2463                 
2464                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2465                         typeiter != TypeSplitPoints.end(); ++typeiter){
2466                         
2467                                 wxString TypePropertyName;
2468                                 
2469                                 TSLiter = TypeSplitLength.find(typeiter->first);
2470                                 
2471                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2472                                 
2473                                 if (intTypeSeek == 0){
2474                                 
2475                                 
2476                                 } else {
2477                                                                                 
2478                                         TelTypeUI.Append(wxT(","));                                                     
2479                                 
2480                                 }
2481                         
2482                                 if (TypePropertyName == wxT("home")){
2483                                 
2484                                         PropType = PROPERTY_HOME;
2485                                 
2486                                 } else if (TypePropertyName == wxT("work")){
2487                                 
2488                                         PropType = PROPERTY_WORK;
2489                                                                         
2490                                 }
2491                                 
2492                                 
2493                                 if (TypePropertyName == wxT("text")){
2494                                 
2495                                         TelTypeUI.Append(_("text"));
2496                                         intTypeSeek++;
2497                                 
2498                                 } else if (TypePropertyName == wxT("voice")){
2499                                 
2500                                         TelTypeUI.Append(_("voice"));
2501                                         intTypeSeek++;
2502                                 
2503                                 } else if (TypePropertyName == wxT("fax")){
2504                                 
2505                                         TelTypeUI.Append(_("fax"));
2506                                         intTypeSeek++;
2507                                 
2508                                 } else if (TypePropertyName == wxT("cell")){
2509                                 
2510                                         TelTypeUI.Append(_("mobile"));
2511                                         intTypeSeek++;
2512                                 
2513                                 } else if (TypePropertyName == wxT("video")){
2514                                 
2515                                         TelTypeUI.Append(_("video"));
2516                                         intTypeSeek++;
2517                                 
2518                                 } else if (TypePropertyName == wxT("pager")){
2519                                 
2520                                         TelTypeUI.Append(_("pager"));
2521                                         intTypeSeek++;
2522                                 
2523                                 } else if (TypePropertyName == wxT("textphone")){
2524                                 
2525                                         TelTypeUI.Append(_("textphone"));
2526                                         intTypeSeek++;
2527                                 
2528                                 }
2529                         
2530                         }
2531                 
2532                 }
2533                 
2534         }
2535         
2536         std::map<int, wxString> *TelephoneList = NULL;
2537         std::map<int, wxString> *TelephoneListType = NULL;
2538         std::map<int, wxString> *TelephoneListAltID = NULL;
2539         std::map<int, wxString> *TelephoneListPID = NULL;
2540         std::map<int, wxString> *TelephoneListTokens = NULL;
2541         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2542         std::map<int, int> *TelephoneListPref = NULL;
2544         switch(PropType){
2545                 case PROPERTY_NONE:
2546                         TelephoneList = &GeneralTelephoneList;
2547                         TelephoneListType = &GeneralTelephoneListType;
2548                         TelephoneListAltID = &GeneralTelephoneListAltID;
2549                         TelephoneListPID = &GeneralTelephoneListPID;
2550                         TelephoneListTokens = &GeneralTelephoneListTokens;
2551                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2552                         TelephoneListPref = &GeneralTelephoneListPref;  
2553                         break;
2554                 case PROPERTY_HOME:
2555                         TelephoneList = &HomeTelephoneList;
2556                         TelephoneListType = &HomeTelephoneListType;
2557                         TelephoneListAltID = &HomeTelephoneListAltID;
2558                         TelephoneListPID = &HomeTelephoneListPID;
2559                         TelephoneListTokens = &HomeTelephoneListTokens;
2560                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2561                         TelephoneListPref = &HomeTelephoneListPref;     
2562                         break;
2563                 case PROPERTY_WORK:
2564                         TelephoneList = &BusinessTelephoneList;
2565                         TelephoneListType = &BusinessTelephoneListType;
2566                         TelephoneListAltID = &BusinessTelephoneListAltID;
2567                         TelephoneListPID = &BusinessTelephoneListPID;
2568                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2569                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2570                         TelephoneListPref = &BusinessTelephoneListPref; 
2571                         break;
2572         }
2573                 
2574         // Process the properties.
2575         
2576         bool FirstToken = TRUE;
2577         
2578         intPrevValue = 5;
2579         SplitPoints.clear();
2580         SplitLength.clear();
2582         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2584         intPrevValue = 4;
2585         
2586         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2587         intiter != SplitPoints.end(); ++intiter){
2588         
2589                 SLiter = SplitLength.find(intiter->first);
2590         
2591                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2592                 
2593                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2594                 PropertyName = PropertyElement.GetNextToken();                          
2595                 PropertyValue = PropertyElement.GetNextToken();
2596                 
2597                 intPrevValue = intiter->second;
2598                 
2599                 CaptureString(&PropertyValue, FALSE);
2600                 
2601                 // Process properties.
2602                 
2603                 if (PropertyName == wxT("ALTID")){
2605                         TelephoneListAltID->erase(*TelephoneCount);
2606                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2607                 
2608                 } else if (PropertyName == wxT("PID")){
2610                         TelephoneListPID->erase(*TelephoneCount);
2611                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2612                 
2613                 } else if (PropertyName == wxT("PREF")){
2614                         
2615                         int PriorityNumber = 0;
2616                         bool ValidNumber = TRUE;
2617                         
2618                         try{
2619                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2620                         }
2621                         
2622                         catch(std::invalid_argument &e){
2623                                 ValidNumber = FALSE;
2624                         }
2626                         if (ValidNumber == TRUE){
2628                                 TelephoneListPref->erase(*TelephoneCount);
2629                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2631                         }
2632                 
2633                 } else {
2634                 
2635                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2636                         
2637                                 if (FirstToken == TRUE){
2638                                 
2639                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2640                                         FirstToken = FALSE;
2641                                 
2642                                 } else {
2643                                 
2644                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2645                                 
2646                                 }
2647                         
2648                         }
2649                 
2650                 }
2651         
2652         }
2653                 
2654         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2655         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2656         
2657         // Add the name token data.
2658         
2659         if (!PropertyTokens.IsEmpty()){
2660         
2661                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2662         
2663         }
2667 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2669         std::map<int, int> SplitPoints;
2670         std::map<int, int> SplitLength;
2672         int intPrevValue = 6;
2673         int intPref = 0;                        
2674         
2675         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2676         
2677         intPrevValue = 5;
2678         
2679         PropertyType PropType = PROPERTY_NONE;
2680                 
2681         // Look for type before continuing.
2682         
2683         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2684         
2685         std::map<int, wxString> *LanguageList = NULL;
2686         std::map<int, wxString> *LanguageListType = NULL;
2687         std::map<int, wxString> *LanguageListAltID = NULL;
2688         std::map<int, wxString> *LanguageListPID = NULL;
2689         std::map<int, wxString> *LanguageListTokens = NULL;
2690         std::map<int, int> *LanguageListPref = NULL;
2692         switch(PropType){
2693                 case PROPERTY_NONE:
2694                         LanguageList = &GeneralLanguageList;
2695                         LanguageListType = &GeneralLanguageListType;
2696                         LanguageListAltID = &GeneralLanguageListAltID;
2697                         LanguageListPID = &GeneralLanguageListPID;
2698                         LanguageListTokens = &GeneralLanguageListTokens;
2699                         LanguageListPref = &GeneralLanguageListPref;    
2700                         break;
2701                 case PROPERTY_HOME:
2702                         LanguageList = &HomeLanguageList;
2703                         LanguageListType = &HomeLanguageListType;
2704                         LanguageListAltID = &HomeLanguageListAltID;
2705                         LanguageListPID = &HomeLanguageListPID;
2706                         LanguageListTokens = &HomeLanguageListTokens;   
2707                         LanguageListPref = &HomeLanguageListPref;       
2708                         break;
2709                 case PROPERTY_WORK:
2710                         LanguageList = &BusinessLanguageList;
2711                         LanguageListType = &BusinessLanguageListType;
2712                         LanguageListAltID = &BusinessLanguageListAltID;
2713                         LanguageListPID = &BusinessLanguageListPID;
2714                         LanguageListTokens = &BusinessLanguageListTokens;       
2715                         LanguageListPref = &BusinessLanguageListPref;
2716                         break;
2717         }
2718         
2719         intPrevValue = 5;
2720         
2721         std::map<int,int>::iterator SLiter;
2722         wxString PropertyData;
2723         wxString PropertyName;
2724         wxString PropertyValue;
2725         wxString PropertyTokens;
2726         bool FirstToken = TRUE;
2727         
2728         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2729         intiter != SplitPoints.end(); ++intiter){
2730         
2731                 SLiter = SplitLength.find(intiter->first);
2732         
2733                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2734                 
2735                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2736                 PropertyName = PropertyElement.GetNextToken();                          
2737                 PropertyValue = PropertyElement.GetNextToken();
2738                 
2739                 intPrevValue = intiter->second;
2740                 
2741                 CaptureString(&PropertyValue, FALSE);
2742                 
2743                 // Process properties.
2744                 
2745                 if (PropertyName == wxT("ALTID")){
2747                         LanguageListAltID->erase(*LanguageCount);
2748                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2749                 
2750                 } else if (PropertyName == wxT("PID")){
2752                         LanguageListPID->erase(*LanguageCount);
2753                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2754                 
2755                 } else if (PropertyName == wxT("PREF")){
2756                         
2757                         int PriorityNumber = 0;
2758                         bool ValidNumber = TRUE;
2759                         
2760                         try{
2761                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2762                         }
2763                         
2764                         catch(std::invalid_argument &e){
2765                                 ValidNumber = FALSE;
2766                         }
2768                         if (ValidNumber == TRUE){
2770                                 LanguageListPref->erase(*LanguageCount);
2771                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2773                         }
2774                 
2775                 } else {
2776                 
2777                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2778                         
2779                                 if (FirstToken == TRUE){
2780                                 
2781                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2782                                         FirstToken = FALSE;
2783                                 
2784                                 } else {
2785                                 
2786                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2787                                 
2788                                 }
2789                         
2790                         }
2791                 
2792                 }
2793         
2794         }
2795                 
2796         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2797         
2798         // Add the name token data.
2799         
2800         if (!PropertyTokens.IsEmpty()){
2801         
2802                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2803         
2804         }
2808 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2810         std::map<int, int> SplitPoints;
2811         std::map<int, int> SplitLength;
2813         int intPrevValue = 5;
2814         int intPref = 0;                        
2815         
2816         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2817         
2818         intPrevValue = 4;
2819         
2820         PropertyType PropType = PROPERTY_NONE;
2821                 
2822         // Look for type before continuing.
2823         
2824         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2825         
2826         std::map<int, wxString> *GeopositionList = NULL;
2827         std::map<int, wxString> *GeopositionListType = NULL;
2828         std::map<int, wxString> *GeopositionListAltID = NULL;
2829         std::map<int, wxString> *GeopositionListPID = NULL;
2830         std::map<int, wxString> *GeopositionListTokens = NULL;
2831         std::map<int, wxString> *GeopositionListMediatype = NULL;
2832         std::map<int, int> *GeopositionListPref = NULL;
2834         switch(PropType){
2835                 case PROPERTY_NONE:
2836                         GeopositionList = &GeneralGeographyList;
2837                         GeopositionListType = &GeneralGeographyListType;
2838                         GeopositionListAltID = &GeneralGeographyListAltID;
2839                         GeopositionListPID = &GeneralGeographyListPID;
2840                         GeopositionListTokens = &GeneralGeographyListTokens;
2841                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2842                         GeopositionListPref = &GeneralGeographyListPref;        
2843                         break;
2844                 case PROPERTY_HOME:
2845                         GeopositionList = &HomeGeographyList;
2846                         GeopositionListType = &HomeGeographyListType;
2847                         GeopositionListAltID = &HomeGeographyListAltID;
2848                         GeopositionListPID = &HomeGeographyListPID;
2849                         GeopositionListTokens = &HomeGeographyListTokens;
2850                         GeopositionListMediatype = &HomeGeographyListMediatype;
2851                         GeopositionListPref = &HomeGeographyListPref;   
2852                         break;
2853                 case PROPERTY_WORK:
2854                         GeopositionList = &BusinessGeographyList;
2855                         GeopositionListType = &BusinessGeographyListType;
2856                         GeopositionListAltID = &BusinessGeographyListAltID;
2857                         GeopositionListPID = &BusinessGeographyListPID;
2858                         GeopositionListTokens = &BusinessGeographyListTokens;
2859                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2860                         GeopositionListPref = &BusinessGeographyListPref;
2861                         break;
2862         }
2863         
2864         intPrevValue = 4;
2865         
2866         std::map<int,int>::iterator SLiter;
2867         wxString PropertyData;
2868         wxString PropertyName;
2869         wxString PropertyValue;
2870         wxString PropertyTokens;
2871         bool FirstToken = TRUE;
2872         
2873         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2874         intiter != SplitPoints.end(); ++intiter){
2875         
2876                 SLiter = SplitLength.find(intiter->first);
2877         
2878                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2879                 
2880                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2881                 PropertyName = PropertyElement.GetNextToken();                          
2882                 PropertyValue = PropertyElement.GetNextToken();
2883                 
2884                 intPrevValue = intiter->second;
2885                 
2886                 CaptureString(&PropertyValue, FALSE);
2887                 
2888                 // Process properties.
2889                 
2890                 if (PropertyName == wxT("ALTID")){
2892                         GeopositionListAltID->erase(*GeographicCount);
2893                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2894                 
2895                 } else if (PropertyName == wxT("PID")){
2897                         GeopositionListPID->erase(*GeographicCount);
2898                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2899                 
2900                 } else if (PropertyName == wxT("MEDIATYPE")){
2902                         GeopositionListMediatype->erase(*GeographicCount);
2903                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2904                 
2905                 } else if (PropertyName == wxT("PREF")){
2906                         
2907                         int PriorityNumber = 0;
2908                         bool ValidNumber = TRUE;
2909                         
2910                         try{
2911                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2912                         }
2913                         
2914                         catch(std::invalid_argument &e){
2915                                 ValidNumber = FALSE;
2916                         }
2918                         if (ValidNumber == TRUE){
2920                                 GeopositionListPref->erase(*GeographicCount);
2921                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2923                         }
2924                 
2925                 } else {
2926                 
2927                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2928                         
2929                                 if (FirstToken == TRUE){
2930                                 
2931                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2932                                         FirstToken = FALSE;
2933                                 
2934                                 } else {
2935                                 
2936                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2937                                 
2938                                 }
2939                         
2940                         }
2941                 
2942                 }
2943         
2944         }
2945                 
2946         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2947         
2948         // Add the name token data.
2949         
2950         if (!PropertyTokens.IsEmpty()){
2951         
2952                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2953         
2954         }
2958 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2960         size_t intPropertyLen = PropertySeg1.Len();
2961         std::map<int, int> SplitPoints;
2962         std::map<int, int> SplitLength;
2963         std::map<int, int>::iterator SLiter;                    
2964         wxString PropertyData;
2965         wxString PropertyName;
2966         wxString PropertyValue;
2967         wxString PropertyTokens;
2968         wxString RelatedType;
2969         wxString RelatedTypeOriginal;                   
2970         wxString RelatedName;
2971         bool FirstToken = TRUE;                 
2972         int intSplitsFound = 0;
2973         int intSplitSize = 0;
2974         int intPrevValue = 9;
2975         int intPref = 0;
2976         long ListCtrlIndex;
2977         
2978         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2979         
2980         intPrevValue = 8;
2981         
2982         // Look for type before continuing.
2983         
2984         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2985         intiter != SplitPoints.end(); ++intiter){
2986         
2987                 SLiter = SplitLength.find(intiter->first);
2988         
2989                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2990                 
2991                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2992                 PropertyName = PropertyElement.GetNextToken();                          
2993                 PropertyValue = PropertyElement.GetNextToken();
2994                 
2995                 intPrevValue = intiter->second;
2996                 
2997                 // Process these.
2998                 
2999                 RelatedTypeOriginal = PropertyValue;
3000                 
3001                 if (PropertyName == wxT("TYPE")){
3002                 
3003                         if (PropertyValue == wxT("contact")){
3005                                 RelatedType = _("Contact");
3007                         } else if (PropertyValue == wxT("acquaintance")){
3009                                 RelatedType = _("Acquaintance");
3011                         } else if (PropertyValue == wxT("friend")){
3013                                 RelatedType = _("Friend");
3015                         } else if (PropertyValue == wxT("met")){
3017                                 RelatedType = _("Met");
3019                         } else if (PropertyValue == wxT("co-worker")){
3021                                 RelatedType = _("Co-worker");
3023                         } else if (PropertyValue == wxT("colleague")){
3025                                 RelatedType = _("Colleague");
3027                         } else if (PropertyValue == wxT("co-resident")){
3029                                 RelatedType = _("Co-resident");
3031                         } else if (PropertyValue == wxT("neighbor")){
3033                                 RelatedType = _("Neighbour");
3035                         } else if (PropertyValue == wxT("child")){
3037                                 RelatedType = _("Child");
3039                         } else if (PropertyValue == wxT("parent")){
3041                                 RelatedType = _("Parent");
3043                         } else if (PropertyValue == wxT("sibling")){
3045                                 RelatedType = _("Sibling");
3047                         } else if (PropertyValue == wxT("spouse")){
3049                                 RelatedType = _("Spouse");
3051                         } else if (PropertyValue == wxT("kin")){
3053                                 RelatedType = _("Kin");
3055                         } else if (PropertyValue == wxT("muse")){
3057                                 RelatedType = _("Muse");
3059                         } else if (PropertyValue == wxT("crush")){
3061                                 RelatedType = _("Crush");
3063                         } else if (PropertyValue == wxT("date")){
3065                                 RelatedType = _("Date");
3067                         } else if (PropertyValue == wxT("sweetheart")){
3069                                 RelatedType = _("Sweetheart");
3071                         } else if (PropertyValue == wxT("me")){
3073                                 RelatedType = _("Me");
3075                         } else if (PropertyValue == wxT("agent")){
3077                                 RelatedType = _("Agent");
3079                         } else if (PropertyValue == wxT("emergency")){
3081                                 RelatedType = _("Emergency");
3083                         } else {
3085                                 RelatedType = PropertyValue;
3087                         }
3088                 
3089                 }
3090         
3091         }
3092         
3093         intPrevValue = 8;                       
3094         
3095         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3096         intiter != SplitPoints.end(); ++intiter){
3097         
3098                 SLiter = SplitLength.find(intiter->first);
3099         
3100                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3101                 
3102                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3103                 PropertyName = PropertyElement.GetNextToken();                          
3104                 PropertyValue = PropertyElement.GetNextToken();
3105                 
3106                 intPrevValue = intiter->second;
3107                 
3108                 // Process properties.
3109                 
3110                 size_t intPropertyValueLen = PropertyValue.Len();
3111                 
3112                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3113                         
3114                         PropertyValue.Trim();
3115                         PropertyValue.RemoveLast();
3116                         
3117                 }                               
3118                 
3119                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3120                         
3121                         PropertyValue.Remove(0, 1);
3122                         
3123                 }
3124                 
3125                 CaptureString(&PropertyValue, FALSE);
3126                         
3127                 if (PropertyName == wxT("ALTID")){
3129                         GeneralRelatedListAltID.erase(*RelatedCount);
3130                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3131                 
3132                 } else if (PropertyName == wxT("PID")){
3134                         GeneralRelatedListPID.erase(*RelatedCount);
3135                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3136                 
3137                 } else if (PropertyName == wxT("PREF")){
3138                         
3139                         int PriorityNumber = 0;
3140                         bool ValidNumber = TRUE;
3141                         
3142                         try{
3143                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3144                         }
3145                         
3146                         catch(std::invalid_argument &e){
3147                                 ValidNumber = FALSE;
3148                         }
3150                         if (ValidNumber == TRUE){
3152                                 GeneralRelatedListPref.erase(*RelatedCount);
3153                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3155                         }
3156                 
3157                 } else if (PropertyName == wxT("LANGUAGE")){
3158                 
3159                         GeneralRelatedListLanguage.erase(*RelatedCount);
3160                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3161                 
3162                 } else if (PropertyName != wxT("TYPE")) {
3163                 
3164                         // Something else we don't know about so append
3165                         // to the tokens variable.
3166                 
3167                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3168                 
3169                                 if (FirstToken == TRUE){
3170                         
3171                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3172                                         FirstToken = FALSE;
3173                         
3174                                 } else {
3175                         
3176                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3177                         
3178                                 }
3179                 
3180                         }
3181                 
3182                 }
3183         
3184         }                                       
3185         
3186         // Add the data to the General/Home/Work address variables.
3187                                 
3188         GeneralRelatedList.erase(*RelatedCount);
3189         GeneralRelatedListRelType.erase(*RelatedCount);
3190         GeneralRelatedListType.erase(*RelatedCount);
3191         GeneralRelatedListTokens.erase(*RelatedCount);
3192         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3193         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3194         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3195         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3199 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3201         std::map<int, int> SplitPoints;
3202         std::map<int, int> SplitLength;
3203         std::map<int, int>::iterator SLiter;                    
3204         wxString PropertyData;
3205         wxString PropertyName;
3206         wxString PropertyValue;
3207         wxString PropertyTokens;
3208         bool FirstToken = TRUE;
3209         int intPrevValue = 5;
3210         int intPref = 0;                        
3211         int intType = 0;
3212         long ListCtrlIndex;
3213         
3214         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3215         
3216         intPrevValue = 4;
3217         
3218         PropertyType PropType = PROPERTY_NONE;
3219                 
3220         // Look for type before continuing.
3221         
3222         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3223         
3224         // Setup the pointers.
3225         
3226         std::map<int, wxString> *WebsiteList = NULL;
3227         std::map<int, wxString> *WebsiteListAltID = NULL;
3228         std::map<int, wxString> *WebsiteListPID = NULL;
3229         std::map<int, wxString> *WebsiteListType = NULL;
3230         std::map<int, wxString> *WebsiteListTokens = NULL;
3231         std::map<int, wxString> *WebsiteListMediatype = NULL;
3232         std::map<int, int> *WebsiteListPref = NULL;
3233         
3234         // Setup blank lines for later on.
3235         
3236         switch(PropType){
3237                 case PROPERTY_NONE:
3238                         WebsiteList = &GeneralWebsiteList;
3239                         WebsiteListType = &GeneralWebsiteListType;
3240                         WebsiteListAltID = &GeneralWebsiteListAltID;
3241                         WebsiteListPID = &GeneralWebsiteListPID;
3242                         WebsiteListTokens = &GeneralWebsiteListTokens;
3243                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3244                         WebsiteListPref = &GeneralWebsiteListPref;      
3245                         break;
3246                 case PROPERTY_HOME:
3247                         WebsiteList = &HomeWebsiteList;
3248                         WebsiteListType = &HomeWebsiteListType;
3249                         WebsiteListAltID = &HomeWebsiteListAltID;
3250                         WebsiteListPID = &HomeWebsiteListPID;
3251                         WebsiteListTokens = &HomeWebsiteListTokens;
3252                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3253                         WebsiteListPref = &HomeWebsiteListPref; 
3254                         break;
3255                 case PROPERTY_WORK:
3256                         WebsiteList = &BusinessWebsiteList;
3257                         WebsiteListType = &BusinessWebsiteListType;
3258                         WebsiteListAltID = &BusinessWebsiteListAltID;
3259                         WebsiteListPID = &BusinessWebsiteListPID;
3260                         WebsiteListTokens = &BusinessWebsiteListTokens;
3261                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3262                         WebsiteListPref = &BusinessWebsiteListPref;
3263                         break;
3264         }
3265         
3266         intPrevValue = 4;
3267         
3268         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3269         intiter != SplitPoints.end(); ++intiter){
3270         
3271                 SLiter = SplitLength.find(intiter->first);
3272         
3273                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3274                 
3275                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3276                 PropertyName = PropertyElement.GetNextToken();                          
3277                 PropertyValue = PropertyElement.GetNextToken();
3278                 
3279                 intPrevValue = intiter->second;
3280                 
3281                 // Process properties.
3282                 
3283                 size_t intPropertyValueLen = PropertyValue.Len();
3284                 
3285                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3286                         
3287                         PropertyValue.Trim();
3288                         PropertyValue.RemoveLast();
3289                         
3290                 }                               
3291                 
3292                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3293                         
3294                         PropertyValue.Remove(0, 1);
3295                         
3296                 }
3297                 
3298                 CaptureString(&PropertyValue, FALSE);
3299                 
3300                 if (PropertyName == wxT("ALTID")){
3302                         WebsiteListAltID->erase(*URLCount);
3303                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3304                 
3305                 } else if (PropertyName == wxT("PID")){
3307                         WebsiteListPID->erase(*URLCount);
3308                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3309                         
3310                 } else if (PropertyName == wxT("PREF")){
3311                         
3312                         int PriorityNumber = 0;
3313                         bool ValidNumber = TRUE;
3314                         
3315                         try{
3316                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3317                         }
3318                         
3319                         catch(std::invalid_argument &e){
3320                                 ValidNumber = FALSE;
3321                         }
3323                         if (ValidNumber == TRUE){
3325                                 WebsiteListPref->erase(*URLCount);
3326                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3328                         }
3329                                         
3330                 } else if (PropertyName == wxT("MEDIATYPE")){
3331                 
3332                         WebsiteListMediatype->erase(*URLCount);
3333                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3334                 
3335                 } else {
3336                 
3337                         // Something else we don't know about so append
3338                         // to the tokens variable.
3339                 
3340                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3341                 
3342                                 if (FirstToken == TRUE){
3343                         
3344                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3345                                         FirstToken = FALSE;
3346                         
3347                                 } else {
3348                         
3349                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3350                         
3351                                 }
3352                 
3353                         }
3354                 
3355                 }
3356         
3357         }
3358         
3359         // Add the data to the General/Home/Work address variables.
3360         
3361         CaptureString(&PropertySeg2, FALSE);
3362                         
3363         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3364         
3365         if (!PropertyTokens.IsEmpty()){
3366         
3367                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3368                         
3369         }
3370         
3373 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3375         std::map<int, int> SplitPoints;
3376         std::map<int, int> SplitLength;
3377         std::map<int, int>::iterator SLiter;                    
3378         wxString PropertyData;
3379         wxString PropertyName;
3380         wxString PropertyValue;
3381         wxString PropertyTokens;
3382         bool FirstToken = TRUE;
3383         int intPrevValue = 7;
3384         int intPref = 0;                        
3385         int intType = 0;
3386         long ListCtrlIndex;
3387         
3388         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3389         
3390         intPrevValue = 6;
3391         
3392         PropertyType PropType = PROPERTY_NONE;
3393                 
3394         // Look for type before continuing.
3395         
3396         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3397         
3398         // Setup the pointers.
3399         
3400         std::map<int, wxString> *TitleList = NULL;
3401         std::map<int, wxString> *TitleListAltID = NULL;
3402         std::map<int, wxString> *TitleListPID = NULL;
3403         std::map<int, wxString> *TitleListType = NULL;
3404         std::map<int, wxString> *TitleListTokens = NULL;
3405         std::map<int, wxString> *TitleListLanguage = NULL;
3406         std::map<int, int> *TitleListPref = NULL;
3407         
3408         // Setup blank lines for later on.
3409         
3410         switch(PropType){
3411                 case PROPERTY_NONE:
3412                         TitleList = &GeneralTitleList;
3413                         TitleListType = &GeneralTitleListType;
3414                         TitleListAltID = &GeneralTitleListAltID;
3415                         TitleListPID = &GeneralTitleListPID;
3416                         TitleListTokens = &GeneralTitleListTokens;
3417                         TitleListLanguage = &GeneralTitleListLanguage;
3418                         TitleListPref = &GeneralTitleListPref;  
3419                         break;
3420                 case PROPERTY_HOME:
3421                         TitleList = &HomeTitleList;
3422                         TitleListType = &HomeTitleListType;
3423                         TitleListAltID = &HomeTitleListAltID;
3424                         TitleListPID = &HomeTitleListPID;
3425                         TitleListTokens = &HomeTitleListTokens;
3426                         TitleListLanguage = &HomeTitleListLanguage;
3427                         TitleListPref = &HomeTitleListPref;     
3428                         break;
3429                 case PROPERTY_WORK:
3430                         TitleList = &BusinessTitleList;
3431                         TitleListType = &BusinessTitleListType;
3432                         TitleListAltID = &BusinessTitleListAltID;
3433                         TitleListPID = &BusinessTitleListPID;
3434                         TitleListTokens = &BusinessTitleListTokens;
3435                         TitleListLanguage = &BusinessTitleListLanguage; 
3436                         TitleListPref = &BusinessTitleListPref;
3437                         break;
3438         }
3440         intPrevValue = 6;
3441                 
3442         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3443         intiter != SplitPoints.end(); ++intiter){
3444         
3445                 SLiter = SplitLength.find(intiter->first);
3446         
3447                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3448                 
3449                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3450                 PropertyName = PropertyElement.GetNextToken();                          
3451                 PropertyValue = PropertyElement.GetNextToken();
3452                 
3453                 intPrevValue = intiter->second;
3454                 
3455                 // Process properties.
3456                 
3457                 size_t intPropertyValueLen = PropertyValue.Len();
3458                 
3459                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3460                         
3461                         PropertyValue.Trim();
3462                         PropertyValue.RemoveLast();
3463                         
3464                 }                               
3465                 
3466                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3467                         
3468                         PropertyValue.Remove(0, 1);
3469                         
3470                 }                               
3471                 
3472                 CaptureString(&PropertyValue, FALSE);
3473                 
3474                 if (PropertyName == wxT("ALTID")){
3475                 
3476                         TitleListAltID->erase(*TitleCount);
3477                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3478                 
3479                 } else if (PropertyName == wxT("PID")){
3481                         TitleListPID->erase(*TitleCount);
3482                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3483                 
3484                 } else if (PropertyName == wxT("PREF")){
3485                                 
3486                         int PriorityNumber = 0;
3487                         bool ValidNumber = TRUE;
3488                         
3489                         try{
3490                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3491                         }
3492                         
3493                         catch(std::invalid_argument &e){
3494                                 ValidNumber = FALSE;
3495                         }
3497                         if (ValidNumber == TRUE){
3499                                 TitleListPref->erase(*TitleCount);
3500                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3502                         }
3503                                         
3504                 } else if (PropertyName == wxT("LANGUAGE")){
3505                 
3506                         TitleListLanguage->erase(*TitleCount);
3507                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3508                 
3509                 } else {
3510                 
3511                         // Something else we don't know about so append
3512                         // to the tokens variable.
3513                 
3514                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3515                 
3516                                 if (FirstToken == TRUE){
3517                         
3518                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3519                                         FirstToken = FALSE;
3520                         
3521                                 } else {
3522                         
3523                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3524                         
3525                                 }
3526                 
3527                         }
3528                 
3529                 }
3530         
3531         }
3532         
3533         // Add the data to the General/Home/Work address variables.
3534         
3535         CaptureString(&PropertySeg2, FALSE);
3537         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3538         
3539         if (!PropertyTokens.IsEmpty()){
3540         
3541                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3542                         
3543         }
3547 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3549         std::map<int, int> SplitPoints;
3550         std::map<int, int> SplitLength;
3551         std::map<int, int>::iterator SLiter;                    
3552         wxString PropertyData;
3553         wxString PropertyName;
3554         wxString PropertyValue;
3555         wxString PropertyTokens;
3556         bool FirstToken = TRUE;
3557         int intPrevValue = 6;
3558         int intPref = 0;                        
3559         int intType = 0;
3560         long ListCtrlIndex;
3561         
3562         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3563         
3564         intPrevValue = 5;
3565         
3566         PropertyType PropType = PROPERTY_NONE;
3567                 
3568         // Look for type before continuing.
3569         
3570         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3571         
3572         // Setup the pointers.
3573         
3574         std::map<int, wxString> *RoleList = NULL;
3575         std::map<int, wxString> *RoleListAltID = NULL;
3576         std::map<int, wxString> *RoleListPID = NULL;
3577         std::map<int, wxString> *RoleListType = NULL;
3578         std::map<int, wxString> *RoleListTokens = NULL;
3579         std::map<int, wxString> *RoleListLanguage = NULL;
3580         std::map<int, int> *RoleListPref = NULL;
3581         
3582         // Setup blank lines for later on.
3583         
3584         switch(PropType){
3585                 case PROPERTY_NONE:
3586                         RoleList = &GeneralRoleList;
3587                         RoleListType = &GeneralRoleListType;
3588                         RoleListAltID = &GeneralRoleListAltID;
3589                         RoleListPID = &GeneralRoleListPID;
3590                         RoleListTokens = &GeneralRoleListTokens;
3591                         RoleListLanguage = &GeneralRoleListLanguage;
3592                         RoleListPref = &GeneralRoleListPref;    
3593                         break;
3594                 case PROPERTY_HOME:
3595                         RoleList = &HomeRoleList;
3596                         RoleListType = &HomeRoleListType;
3597                         RoleListAltID = &HomeRoleListAltID;
3598                         RoleListPID = &HomeRoleListPID;
3599                         RoleListTokens = &HomeRoleListTokens;
3600                         RoleListLanguage = &HomeRoleListLanguage;
3601                         RoleListPref = &HomeRoleListPref;       
3602                         break;
3603                 case PROPERTY_WORK:
3604                         RoleList = &BusinessRoleList;
3605                         RoleListType = &BusinessRoleListType;
3606                         RoleListAltID = &BusinessRoleListAltID;
3607                         RoleListPID = &BusinessRoleListPID;
3608                         RoleListTokens = &BusinessRoleListTokens;
3609                         RoleListLanguage = &BusinessRoleListLanguage;   
3610                         RoleListPref = &BusinessRoleListPref;
3611                         break;
3612         }
3614         intPrevValue = 5;
3615                 
3616         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3617         intiter != SplitPoints.end(); ++intiter){
3618         
3619                 SLiter = SplitLength.find(intiter->first);
3620         
3621                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3622                 
3623                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3624                 PropertyName = PropertyElement.GetNextToken();                          
3625                 PropertyValue = PropertyElement.GetNextToken();
3626                 
3627                 intPrevValue = intiter->second;
3628                 
3629                 // Process properties.
3630                 
3631                 size_t intPropertyValueLen = PropertyValue.Len();
3632                 
3633                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3634                         
3635                         PropertyValue.Trim();
3636                         PropertyValue.RemoveLast();
3637                         
3638                 }                               
3639                 
3640                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3641                         
3642                         PropertyValue.Remove(0, 1);
3643                         
3644                 }                               
3645                 
3646                 CaptureString(&PropertyValue, FALSE);
3647                 
3648                 if (PropertyName == wxT("ALTID")){
3649                 
3650                         RoleListAltID->erase(*RoleCount);
3651                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3652                 
3653                 } else if (PropertyName == wxT("PID")){
3655                         RoleListPID->erase(*RoleCount);
3656                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3657                 
3658                 } else if (PropertyName == wxT("PREF")){
3659                                 
3660                         int PriorityNumber = 0;
3661                         bool ValidNumber = TRUE;
3662                         
3663                         try{
3664                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3665                         }
3666                         
3667                         catch(std::invalid_argument &e){
3668                                 ValidNumber = FALSE;
3669                         }
3671                         if (ValidNumber == TRUE){
3673                                 RoleListPref->erase(*RoleCount);
3674                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3676                         }
3677                                         
3678                 } else if (PropertyName == wxT("LANGUAGE")){
3679                 
3680                         RoleListLanguage->erase(*RoleCount);
3681                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3682                 
3683                 } else {
3684                 
3685                         // Something else we don't know about so append
3686                         // to the tokens variable.
3687                 
3688                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3689                 
3690                                 if (FirstToken == TRUE){
3691                         
3692                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3693                                         FirstToken = FALSE;
3694                         
3695                                 } else {
3696                         
3697                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3698                         
3699                                 }
3700                 
3701                         }
3702                 
3703                 }
3704         
3705         }
3706         
3707         // Add the data to the General/Home/Work address variables.
3708         
3709         CaptureString(&PropertySeg2, FALSE);
3711         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3712         
3713         if (!PropertyTokens.IsEmpty()){
3714         
3715                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3716                         
3717         }
3721 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3723         std::map<int, int> SplitPoints;
3724         std::map<int, int> SplitLength;
3725         std::map<int, int>::iterator SLiter;                    
3726         wxString PropertyData;
3727         wxString PropertyName;
3728         wxString PropertyValue;
3729         wxString PropertyTokens;
3730         bool FirstToken = TRUE;
3731         int intPrevValue = 5;
3732         int intPref = 0;                        
3733         int intType = 0;
3734         long ListCtrlIndex;
3735         
3736         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3737         
3738         intPrevValue = 4;
3739         
3740         PropertyType PropType = PROPERTY_NONE;
3741                 
3742         // Look for type before continuing.
3743         
3744         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3745         
3746         // Setup the pointers.
3747         
3748         std::map<int, wxString> *OrganisationsList = NULL;
3749         std::map<int, wxString> *OrganisationsListAltID = NULL;
3750         std::map<int, wxString> *OrganisationsListPID = NULL;
3751         std::map<int, wxString> *OrganisationsListType = NULL;
3752         std::map<int, wxString> *OrganisationsListTokens = NULL;
3753         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3754         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3755         std::map<int, int> *OrganisationsListPref = NULL;
3756         
3757         // Setup blank lines for later on.
3758         
3759         switch(PropType){
3760                 case PROPERTY_NONE:
3761                         OrganisationsList = &GeneralOrganisationsList;
3762                         OrganisationsListType = &GeneralOrganisationsListType;
3763                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3764                         OrganisationsListPID = &GeneralOrganisationsListPID;
3765                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3766                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3767                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3768                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3769                         break;
3770                 case PROPERTY_HOME:
3771                         OrganisationsList = &HomeOrganisationsList;
3772                         OrganisationsListType = &HomeOrganisationsListType;
3773                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3774                         OrganisationsListPID = &HomeOrganisationsListPID;
3775                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3776                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3777                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3778                         OrganisationsListPref = &HomeOrganisationsListPref;     
3779                         break;
3780                 case PROPERTY_WORK:
3781                         OrganisationsList = &BusinessOrganisationsList;
3782                         OrganisationsListType = &BusinessOrganisationsListType;
3783                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3784                         OrganisationsListPID = &BusinessOrganisationsListPID;
3785                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3786                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3787                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3788                         OrganisationsListPref = &BusinessOrganisationsListPref;
3789                         break;
3790         }
3792         intPrevValue = 4;
3793                 
3794         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3795         intiter != SplitPoints.end(); ++intiter){
3796         
3797                 SLiter = SplitLength.find(intiter->first);
3798         
3799                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3800                 
3801                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3802                 PropertyName = PropertyElement.GetNextToken();                          
3803                 PropertyValue = PropertyElement.GetNextToken();
3804                 
3805                 intPrevValue = intiter->second;
3806                 
3807                 // Process properties.
3808                 
3809                 size_t intPropertyValueLen = PropertyValue.Len();
3810                 
3811                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3812                         
3813                         PropertyValue.Trim();
3814                         PropertyValue.RemoveLast();
3815                         
3816                 }                               
3817                 
3818                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3819                         
3820                         PropertyValue.Remove(0, 1);
3821                         
3822                 }                               
3823                 
3824                 CaptureString(&PropertyValue, FALSE);
3825                 
3826                 if (PropertyName == wxT("ALTID")){
3827                 
3828                         OrganisationsListAltID->erase(*OrganisationCount);
3829                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3830                 
3831                 } else if (PropertyName == wxT("PID")){
3833                         OrganisationsListPID->erase(*OrganisationCount);
3834                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3835                 
3836                 } else if (PropertyName == wxT("SORT-AS")){
3838                         OrganisationsListSortAs->erase(*OrganisationCount);
3839                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3840                 
3841                 } else if (PropertyName == wxT("PREF")){
3842                                 
3843                         int PriorityNumber = 0;
3844                         bool ValidNumber = TRUE;
3845                         
3846                         try{
3847                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3848                         }
3849                         
3850                         catch(std::invalid_argument &e){
3851                                 ValidNumber = FALSE;
3852                         }
3854                         if (ValidNumber == TRUE){
3856                                 OrganisationsListPref->erase(*OrganisationCount);
3857                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3859                         }
3860                                         
3861                 } else if (PropertyName == wxT("LANGUAGE")){
3862                 
3863                         OrganisationsListLanguage->erase(*OrganisationCount);
3864                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3865                 
3866                 } else {
3867                 
3868                         // Something else we don't know about so append
3869                         // to the tokens variable.
3870                 
3871                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3872                 
3873                                 if (FirstToken == TRUE){
3874                         
3875                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3876                                         FirstToken = FALSE;
3877                         
3878                                 } else {
3879                         
3880                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3881                         
3882                                 }
3883                 
3884                         }
3885                 
3886                 }
3887         
3888         }
3889         
3890         // Add the data to the General/Home/Work address variables.
3891         
3892         CaptureString(&PropertySeg2, FALSE);
3894         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3895         
3896         if (!PropertyTokens.IsEmpty()){
3897         
3898                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3899                         
3900         }
3904 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3906         std::map<int, int> SplitPoints;
3907         std::map<int, int> SplitLength;
3908         std::map<int, int>::iterator SLiter;                    
3909         wxString PropertyData;
3910         wxString PropertyName;
3911         wxString PropertyValue;
3912         wxString PropertyTokens;
3913         bool FirstToken = TRUE;
3914         int intPrevValue = 6;
3915         int intPref = 0;                        
3916         int intType = 0;
3917         long ListCtrlIndex;
3918         
3919         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3920         
3921         intPrevValue = 5;
3922         
3923         PropertyType PropType = PROPERTY_NONE;
3924                 
3925         // Look for type before continuing.
3926         
3927         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3928         
3929         // Setup the pointers.
3930         
3931         std::map<int, wxString> *NoteList = NULL;
3932         std::map<int, wxString> *NoteListAltID = NULL;
3933         std::map<int, wxString> *NoteListPID = NULL;
3934         std::map<int, wxString> *NoteListType = NULL;
3935         std::map<int, wxString> *NoteListTokens = NULL;
3936         std::map<int, wxString> *NoteListLanguage = NULL;
3937         std::map<int, int> *NoteListPref = NULL;
3938         
3939         // Setup blank lines for later on.
3940         
3941         switch(PropType){
3942                 case PROPERTY_NONE:
3943                         NoteList = &GeneralNoteList;
3944                         NoteListType = &GeneralNoteListType;
3945                         NoteListAltID = &GeneralNoteListAltID;
3946                         NoteListPID = &GeneralNoteListPID;
3947                         NoteListTokens = &GeneralNoteListTokens;
3948                         NoteListLanguage = &GeneralNoteListLanguage;
3949                         NoteListPref = &GeneralNoteListPref;    
3950                         break;
3951                 case PROPERTY_HOME:
3952                         NoteList = &HomeNoteList;
3953                         NoteListType = &HomeNoteListType;
3954                         NoteListAltID = &HomeNoteListAltID;
3955                         NoteListPID = &HomeNoteListPID;
3956                         NoteListTokens = &HomeNoteListTokens;
3957                         NoteListLanguage = &HomeNoteListLanguage;
3958                         NoteListPref = &HomeNoteListPref;       
3959                         break;
3960                 case PROPERTY_WORK:
3961                         NoteList = &BusinessNoteList;
3962                         NoteListType = &BusinessNoteListType;
3963                         NoteListAltID = &BusinessNoteListAltID;
3964                         NoteListPID = &BusinessNoteListPID;
3965                         NoteListTokens = &BusinessNoteListTokens;
3966                         NoteListLanguage = &BusinessNoteListLanguage;   
3967                         NoteListPref = &BusinessNoteListPref;
3968                         break;
3969         }
3971         intPrevValue = 5;
3972                 
3973         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3974         intiter != SplitPoints.end(); ++intiter){
3975         
3976                 SLiter = SplitLength.find(intiter->first);
3977         
3978                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3979                 
3980                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3981                 PropertyName = PropertyElement.GetNextToken();                          
3982                 PropertyValue = PropertyElement.GetNextToken();
3983                 
3984                 intPrevValue = intiter->second;
3985                 
3986                 // Process properties.
3987                 
3988                 size_t intPropertyValueLen = PropertyValue.Len();
3989                 
3990                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3991                         
3992                         PropertyValue.Trim();
3993                         PropertyValue.RemoveLast();
3994                         
3995                 }                               
3996                 
3997                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3998                         
3999                         PropertyValue.Remove(0, 1);
4000                         
4001                 }                               
4002                 
4003                 CaptureString(&PropertyValue, FALSE);
4004                 
4005                 if (PropertyName == wxT("ALTID")){
4006                 
4007                         NoteListAltID->erase(*NoteCount);
4008                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4009                 
4010                 } else if (PropertyName == wxT("PID")){
4012                         NoteListPID->erase(*NoteCount);
4013                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4014                 
4015                 } else if (PropertyName == wxT("PREF")){
4016                                 
4017                         int PriorityNumber = 0;
4018                         bool ValidNumber = TRUE;
4019                         
4020                         try{
4021                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4022                         }
4023                         
4024                         catch(std::invalid_argument &e){
4025                                 ValidNumber = FALSE;
4026                         }
4028                         if (ValidNumber == TRUE){
4030                                 NoteListPref->erase(*NoteCount);
4031                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4033                         }
4034                                         
4035                 } else if (PropertyName == wxT("LANGUAGE")){
4036                 
4037                         NoteListLanguage->erase(*NoteCount);
4038                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4039                 
4040                 } else {
4041                 
4042                         // Something else we don't know about so append
4043                         // to the tokens variable.
4044                 
4045                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4046                 
4047                                 if (FirstToken == TRUE){
4048                         
4049                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4050                                         FirstToken = FALSE;
4051                         
4052                                 } else {
4053                         
4054                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4055                         
4056                                 }
4057                 
4058                         }
4059                 
4060                 }
4061         
4062         }
4063         
4064         // Add the data to the General/Home/Work address variables.
4065         
4066         CaptureString(&PropertySeg2, FALSE);
4068         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4069         
4070         if (!PropertyTokens.IsEmpty()){
4071         
4072                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4073                         
4074         }
4078 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4080         std::map<int, int> SplitPoints;
4081         std::map<int, int> SplitLength;
4082         std::map<int, int>::iterator SLiter;                    
4083         wxString PropertyData;
4084         wxString PropertyName;
4085         wxString PropertyValue;
4086         wxString PropertyTokens;
4087         bool FirstToken = TRUE;
4088         int intPrevValue = 12;
4089         int intPref = 0;                        
4090         int intType = 0;
4091         long ListCtrlIndex;
4092         
4093         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4094         
4095         intPrevValue = 11;
4096         
4097         PropertyType PropType = PROPERTY_NONE;
4098                 
4099         // Look for type before continuing.
4100         
4101         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4102         
4103         // Setup blank lines for later on.
4104         
4105         switch(PropType){
4106                 case PROPERTY_NONE:
4107                         break;
4108                 case PROPERTY_HOME:
4109                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4110                         break;
4111                 case PROPERTY_WORK:
4112                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4113                         break;
4114         }
4116         intPrevValue = 11;
4117                 
4118         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4119         intiter != SplitPoints.end(); ++intiter){
4120         
4121                 SLiter = SplitLength.find(intiter->first);
4122         
4123                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4124                 
4125                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4126                 PropertyName = PropertyElement.GetNextToken();                          
4127                 PropertyValue = PropertyElement.GetNextToken();
4128                 
4129                 intPrevValue = intiter->second;
4130                 
4131                 // Process properties.
4132                 
4133                 size_t intPropertyValueLen = PropertyValue.Len();
4134                 
4135                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4136                         
4137                         PropertyValue.Trim();
4138                         PropertyValue.RemoveLast();
4139                         
4140                 }                               
4141                 
4142                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4143                         
4144                         PropertyValue.Remove(0, 1);
4145                         
4146                 }                               
4147                 
4148                 CaptureString(&PropertyValue, FALSE);
4149                 
4150                 if (PropertyName == wxT("ALTID")){
4151                 
4152                         CategoriesListAltID.erase(*CategoryCount);
4153                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4154                 
4155                 } else if (PropertyName == wxT("PID")){
4157                         CategoriesListPID.erase(*CategoryCount);
4158                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4159                 
4160                 } else if (PropertyName == wxT("PREF")){
4161                                 
4162                         int PriorityNumber = 0;
4163                         bool ValidNumber = TRUE;
4164                         
4165                         try{
4166                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4167                         }
4168                         
4169                         catch(std::invalid_argument &e){
4170                                 ValidNumber = FALSE;
4171                         }
4173                         if (ValidNumber == TRUE){
4175                                 CategoriesListPref.erase(*CategoryCount);
4176                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4178                         }
4179                                         
4180                 } else if (PropertyName == wxT("LANGUAGE")){
4181                 
4182                         CategoriesListLanguage.erase(*CategoryCount);
4183                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4184                 
4185                 } else {
4186                 
4187                         // Something else we don't know about so append
4188                         // to the tokens variable.
4189                 
4190                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4191                 
4192                                 if (FirstToken == TRUE){
4193                         
4194                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4195                                         FirstToken = FALSE;
4196                         
4197                                 } else {
4198                         
4199                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4200                         
4201                                 }
4202                 
4203                         }
4204                 
4205                 }
4206         
4207         }
4208         
4209         // Deal with multiple categories.
4210         
4211         int intOrigCatCount = *CategoryCount;
4212         bool FirstCategoryProcessed = TRUE;
4213         bool AfterFirstToken = FALSE;
4214         int intSplitSize = 0;
4215         int intSplitsFound = 0;
4216         int intSplitSeek = 0;
4217         int intPropertyLen = PropertySeg2.Len();
4218         
4219         SplitPoints.clear();
4220         SplitLength.clear();
4221         intPrevValue = 0;
4222         
4223         for (int i = 0; i <= intPropertyLen; i++){
4224         
4225                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4226         
4227                         continue;
4228                 
4229                 }
4230         
4231                 intSplitSize++;
4232         
4233                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4234         
4235                         if (AfterFirstToken == TRUE){
4236                 
4237                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4238                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4239                         
4240                         } else {
4241                         
4242                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4243                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4244                                 AfterFirstToken = TRUE;
4246                         }
4248                         intSplitsFound++;
4249                         intSplitSeek = i;
4250                         intSplitSize = 0;                               
4251         
4252                 }                       
4253         
4254         }
4255         
4256         if (SplitPoints.size() > 0){
4257         
4258                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4259                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4260         
4261         }
4262         
4263         if (SplitPoints.size() == 0){
4264         
4265                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4266         
4267                 if (!PropertyTokens.IsEmpty()){
4268                 
4269                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4270                 
4271                 }
4272         
4273         }
4274         
4275         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4276         intiter != SplitPoints.end(); ++intiter){
4277         
4278                 SLiter = SplitLength.find(intiter->first);
4279         
4280                 intPrevValue = intiter->second;
4281         
4282                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4283                 
4284                 // Add the data to the General/Home/Work address variables.
4285         
4286                 // Trim any whitespace from the start and end.
4287         
4288                 PropertyData = PropertyData.Trim(FALSE);
4289                 PropertyData = PropertyData.Trim(TRUE); 
4290         
4291                 CaptureString(&PropertyData, FALSE);
4292                 
4293                 if (FirstCategoryProcessed == TRUE){
4294                 
4295                         FirstCategoryProcessed = FALSE;
4296                         
4297                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4298         
4299                         if (!PropertyTokens.IsEmpty()){
4300                 
4301                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4302                 
4303                         }
4304                         
4305                         continue;
4306                 
4307                 } else {
4309                         (*CategoryCount)++;
4310                         
4311                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4312                 
4313                         if (!PropertyTokens.IsEmpty()){
4314                 
4315                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4316                 
4317                         }
4318                 
4319                 }
4320                 
4321                 // Copy the properties to each of the categories (if it exists).
4322                 
4323                 if (!PropertyTokens.IsEmpty()){
4324                 
4325                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4326                 
4327                 }
4328                 
4329                 // Check if ALTID was used.
4330                 
4331                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4332                 
4333                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4334                 
4335                 }
4336                 
4337                 // Check if PID was used.
4338                 
4339                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4340                 
4341                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4342                 
4343                 }
4344         
4345                 // Check if PREF was used.
4346         
4347                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4348                 
4349                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4350                 
4351                 }
4352                 
4353                 // Check if LANGUAGE was used.
4354                 
4355                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4356                 
4357                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4358                 
4359                 }
4360                 
4361                 // Check if TYPE was used.
4362                 
4363                 switch(PropType){
4364                         case PROPERTY_NONE:
4365                                 break;
4366                         case PROPERTY_HOME:
4367                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4368                                 break;
4369                         case PROPERTY_WORK:
4370                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4371                                 break;
4372                 }
4373         
4374         }
4378 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4380         size_t intPropertyLen = PropertySeg1.Len();
4381         std::map<int, int> SplitPoints;
4382         std::map<int, int> SplitLength;
4383         std::map<int, int>::iterator SLiter;                    
4384         wxString PropertyData;
4385         wxString PropertyName;
4386         wxString PropertyValue;
4387         wxString PropertyTokens;
4388         bool FirstToken = TRUE;
4389         int intSplitsFound = 0;
4390         int intSplitSize = 0;
4391         int intPrevValue = 7;
4392         int intPref = 0;                        
4393         int intType = 0;
4394         
4395         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4396         
4397         intPrevValue = 6;
4398         
4399         PropertyType PropType = PROPERTY_NONE;
4400                 
4401         // Look for type before continuing.
4402         
4403         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4405         intPrevValue = 6;
4407         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4408         intiter != SplitPoints.end(); ++intiter){
4409         
4410                 SLiter = SplitLength.find(intiter->first);
4411         
4412                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4413                 
4414                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4415                 PropertyName = PropertyElement.GetNextToken();                          
4416                 PropertyValue = PropertyElement.GetNextToken();
4417                 
4418                 intPrevValue = intiter->second;
4419                 
4420                 // Process properties.
4421                 
4422                 size_t intPropertyValueLen = PropertyValue.Len();
4423                 
4424                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4425                         
4426                         PropertyValue.Trim();
4427                         PropertyValue.RemoveLast();
4428                         
4429                 }                               
4430                 
4431                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4432                         
4433                         PropertyValue.Remove(0, 1);
4434                         
4435                 }
4436                 
4437                 CaptureString(&PropertyValue, FALSE);
4438                 
4439                 if (PropertyName == wxT("ALTID")){
4441                         PicturesListAltID.erase(*PhotoCount);
4442                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4443                 
4444                 } else if (PropertyName == wxT("PID")){
4446                         PicturesListPID.erase(*PhotoCount);
4447                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4448                 
4449                 } else if (PropertyName == wxT("PREF")){
4450                         
4451                         int PriorityNumber = 0;
4452                         bool ValidNumber = TRUE;
4453                         
4454                         try{
4455                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4456                         }
4457                         
4458                         catch(std::invalid_argument &e){
4459                                 ValidNumber = FALSE;
4460                         }
4462                         if (ValidNumber == TRUE){
4464                                 PicturesListPref.erase(*PhotoCount);
4465                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4467                         }
4468                 
4469                 } else if (PropertyName == wxT("MEDIATYPE")){
4470                 
4471                         PicturesListMediatype.erase(*PhotoCount);
4472                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4473                                         
4474                 } else {
4475                 
4476                         // Something else we don't know about so append
4477                         // to the tokens variable.
4478                         
4479                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4480                         
4481                                 if (FirstToken == TRUE){
4482                                 
4483                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4484                                         FirstToken = FALSE;
4485                                 
4486                                 } else {
4487                                 
4488                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4489                                 
4490                                 }
4491                         
4492                         }
4493                 
4494                 }
4495         
4496         }       
4497         
4498         intPropertyLen = PropertySeg2.Len();
4499         SplitPoints.clear();
4500         SplitLength.clear();
4501         intSplitsFound = 0;
4502         intSplitSize = 0;
4503         intPrevValue = 0;                       
4504         
4505         CaptureString(&PropertySeg2, FALSE);
4506         
4507         for (int i = 0; i <= intPropertyLen; i++){
4509                 intSplitSize++;
4510         
4511                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4512         
4513                         intSplitsFound++;
4514                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4515                         
4516                         if (intSplitsFound == 6){ 
4517                         
4518                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4519                                 break; 
4520                                 
4521                         } else {
4522                         
4523                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4524                         
4525                         }
4526                         
4527                         intSplitSize = 0;                                       
4528         
4529                 }
4531         }
4532         
4533         wxString wxSPhotoURI;
4534         wxString wxSPhotoMIME;
4535         wxString wxSPhotoEncoding;
4536         wxString wxSPhotoData;
4537         std::string base64enc;
4538         
4539         if (intSplitsFound == 0){
4540         
4541         } else {
4542         
4543                 std::map<int, int>::iterator striter;
4544         
4545                 striter = SplitLength.find(1);
4546         
4547                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4548         
4549                 while (wSTDataType.HasMoreTokens() == TRUE){
4550                 
4551                         wxSPhotoURI = wSTDataType.GetNextToken();
4552                         wxSPhotoMIME = wSTDataType.GetNextToken();
4553                         break;
4554                 
4555                 }                       
4556         
4557                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4558         
4559                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4560                 
4561                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4562                         wxSPhotoData = wSTDataInfo.GetNextToken();
4563                         base64enc = wxSPhotoData.mb_str();
4564                         break;
4565                 
4566                 }
4567         
4568         }
4569         
4570         // Add the data to the General/Home/Work address variables.
4571         
4572         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4573         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4574         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4575         
4576         switch(PropType){
4577                 case PROPERTY_NONE:
4578                         break;
4579                 case PROPERTY_HOME:
4580                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4581                         break;
4582                 case PROPERTY_WORK:
4583                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4584                         break;
4585         }
4586         
4587         if (!PropertyTokens.IsEmpty()){
4589                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4590         
4591         }
4595 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4597         size_t intPropertyLen = PropertySeg1.Len();
4598         std::map<int, int> SplitPoints;
4599         std::map<int, int> SplitLength;
4600         std::map<int, int>::iterator SLiter;                    
4601         wxString PropertyData;
4602         wxString PropertyName;
4603         wxString PropertyValue;
4604         wxString PropertyTokens;
4605         bool FirstToken = TRUE;
4606         int intSplitsFound = 0;
4607         int intSplitSize = 0;
4608         int intPrevValue = 6;
4609         int intPref = 0;                        
4610         int intType = 0;
4611         
4612         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4613         
4614         intPrevValue = 5;
4615         
4616         PropertyType PropType = PROPERTY_NONE;
4617                 
4618         // Look for type before continuing.
4619         
4620         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4622         intPrevValue = 5;
4624         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4625         intiter != SplitPoints.end(); ++intiter){
4626         
4627                 SLiter = SplitLength.find(intiter->first);
4628         
4629                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4630                 
4631                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4632                 PropertyName = PropertyElement.GetNextToken();                          
4633                 PropertyValue = PropertyElement.GetNextToken();
4634                 
4635                 intPrevValue = intiter->second;
4636                 
4637                 // Process properties.
4638                 
4639                 size_t intPropertyValueLen = PropertyValue.Len();
4640                 
4641                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4642                         
4643                         PropertyValue.Trim();
4644                         PropertyValue.RemoveLast();
4645                         
4646                 }                               
4647                 
4648                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4649                         
4650                         PropertyValue.Remove(0, 1);
4651                         
4652                 }
4653                 
4654                 CaptureString(&PropertyValue, FALSE);
4655                 
4656                 if (PropertyName == wxT("ALTID")){
4658                         LogosListAltID.erase(*LogoCount);
4659                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4660                 
4661                 } else if (PropertyName == wxT("PID")){
4663                         LogosListPID.erase(*LogoCount);
4664                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4665                 
4666                 } else if (PropertyName == wxT("PREF")){
4667                         
4668                         int PriorityNumber = 0;
4669                         bool ValidNumber = TRUE;
4670                         
4671                         try{
4672                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4673                         }
4674                         
4675                         catch(std::invalid_argument &e){
4676                                 ValidNumber = FALSE;
4677                         }
4679                         if (ValidNumber == TRUE){
4681                                 LogosListPref.erase(*LogoCount);
4682                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4684                         }
4685                 
4686                 } else if (PropertyName == wxT("MEDIATYPE")){
4687                 
4688                         LogosListMediatype.erase(*LogoCount);
4689                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4690                                         
4691                 } else {
4692                 
4693                         // Something else we don't know about so append
4694                         // to the tokens variable.
4695                         
4696                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4697                         
4698                                 if (FirstToken == TRUE){
4699                                 
4700                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4701                                         FirstToken = FALSE;
4702                                 
4703                                 } else {
4704                                 
4705                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4706                                 
4707                                 }
4708                         
4709                         }
4710                 
4711                 }
4712         
4713         }       
4714         
4715         intPropertyLen = PropertySeg2.Len();
4716         SplitPoints.clear();
4717         SplitLength.clear();
4718         intSplitsFound = 0;
4719         intSplitSize = 0;
4720         intPrevValue = 0;                       
4721         
4722         CaptureString(&PropertySeg2, FALSE);
4723         
4724         for (int i = 0; i <= intPropertyLen; i++){
4726                 intSplitSize++;
4727         
4728                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4729         
4730                         intSplitsFound++;
4731                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4732                         
4733                         if (intSplitsFound == 6){ 
4734                         
4735                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4736                                 break; 
4737                                 
4738                         } else {
4739                         
4740                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4741                         
4742                         }
4743                         
4744                         intSplitSize = 0;                                       
4745         
4746                 }
4748         }
4749         
4750         wxString wxSPhotoURI;
4751         wxString wxSPhotoMIME;
4752         wxString wxSPhotoEncoding;
4753         wxString wxSPhotoData;
4754         std::string base64enc;
4755         
4756         if (intSplitsFound == 0){
4757         
4758         } else {
4759         
4760                 std::map<int, int>::iterator striter;
4761         
4762                 striter = SplitLength.find(1);
4763         
4764                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4765         
4766                 while (wSTDataType.HasMoreTokens() == TRUE){
4767                 
4768                         wxSPhotoURI = wSTDataType.GetNextToken();
4769                         wxSPhotoMIME = wSTDataType.GetNextToken();
4770                         break;
4771                 
4772                 }                       
4773         
4774                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4775         
4776                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4777                 
4778                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4779                         wxSPhotoData = wSTDataInfo.GetNextToken();
4780                         base64enc = wxSPhotoData.mb_str();
4781                         break;
4782                 
4783                 }
4784         
4785         }
4786         
4787         // Add the data to the General/Home/Work address variables.
4788         
4789         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4790         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4791         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4792         
4793         switch(PropType){
4794                 case PROPERTY_NONE:
4795                         break;
4796                 case PROPERTY_HOME:
4797                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4798                         break;
4799                 case PROPERTY_WORK:
4800                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4801                         break;
4802         }
4803         
4804         if (!PropertyTokens.IsEmpty()){
4806                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4807         
4808         }
4812 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4814         size_t intPropertyLen = PropertySeg1.Len();
4815         std::map<int, int> SplitPoints;
4816         std::map<int, int> SplitLength;
4817         std::map<int, int>::iterator SLiter;                    
4818         wxString PropertyData;
4819         wxString PropertyName;
4820         wxString PropertyValue;
4821         wxString PropertyTokens;
4822         bool FirstToken = TRUE;
4823         int intSplitsFound = 0;
4824         int intSplitSize = 0;
4825         int intPrevValue = 7;
4826         int intPref = 0;                        
4827         int intType = 0;
4828         
4829         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4830         
4831         intPrevValue = 6;
4832         
4833         PropertyType PropType = PROPERTY_NONE;
4834         
4835         // Look for type before continuing.                     
4837         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4839         intPrevValue = 6;
4841         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4842         intiter != SplitPoints.end(); ++intiter){
4843         
4844                 SLiter = SplitLength.find(intiter->first);
4845         
4846                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4847                 
4848                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4849                 PropertyName = PropertyElement.GetNextToken();                          
4850                 PropertyValue = PropertyElement.GetNextToken();
4851                 
4852                 intPrevValue = intiter->second;
4853                 
4854                 // Process properties.
4855                 
4856                 size_t intPropertyValueLen = PropertyValue.Len();
4857                 
4858                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4859                         
4860                         PropertyValue.Trim();
4861                         PropertyValue.RemoveLast();
4862                         
4863                 }                               
4864                 
4865                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4866                         
4867                         PropertyValue.Remove(0, 1);
4868                         
4869                 }                       
4870                 
4871                 CaptureString(&PropertyValue, FALSE);
4872                 
4873                 if (PropertyName == wxT("ALTID")){
4875                         SoundsListAltID.erase(*SoundCount);
4876                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4877                 
4878                 } else if (PropertyName == wxT("PID")){
4880                         SoundsListPID.erase(*SoundCount);
4881                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4882                 
4883                 } else if (PropertyName == wxT("PREF")){
4884                         
4885                         int PriorityNumber = 0;
4886                         bool ValidNumber = TRUE;
4887                         
4888                         try{
4889                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4890                         }
4891                         
4892                         catch(std::invalid_argument &e){
4893                                 ValidNumber = FALSE;
4894                         }
4896                         if (ValidNumber == TRUE){
4898                                 SoundsListPref.erase(*SoundCount);
4899                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4901                         }
4902                 
4903                 } else if (PropertyName == wxT("MEDIATYPE")){
4904                 
4905                         SoundsListMediatype.erase(*SoundCount);
4906                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4908                 } else if (PropertyName == wxT("LANGUAGE")){
4909                 
4910                         SoundsListLanguage.erase(*SoundCount);
4911                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4913                 } else {
4914                 
4915                         // Something else we don't know about so append
4916                         // to the tokens variable.
4917                         
4918                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4919                         
4920                                 if (FirstToken == TRUE){
4921                                 
4922                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4923                                         FirstToken = FALSE;
4924                                 
4925                                 } else {
4926                                 
4927                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4928                                 
4929                                 }
4930                         
4931                         }
4932                 
4933                 }
4934         
4935         }       
4936         
4937         intPropertyLen = PropertySeg2.Len();
4938         SplitPoints.clear();
4939         SplitLength.clear();
4940         intSplitsFound = 0;
4941         intSplitSize = 0;
4942         intPrevValue = 0;
4943         
4944         CaptureString(&PropertySeg2, FALSE);
4945         
4946         for (int i = 0; i <= intPropertyLen; i++){
4948                 intSplitSize++;
4949         
4950                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4951         
4952                         intSplitsFound++;
4953                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4954                         
4955                         if (intSplitsFound == 6){ 
4956                         
4957                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4958                                 break; 
4959                                 
4960                         } else {
4961                         
4962                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4963                         
4964                         }
4965                         
4966                         intSplitSize = 0;                                       
4967         
4968                 }
4970         }
4971         
4972         wxString wxSSoundURI;
4973         wxString wxSSoundMIME;
4974         wxString wxSSoundEncoding;
4975         wxString wxSSoundData;
4976         std::string base64enc;
4977         
4978         if (intSplitsFound == 0){
4979         
4980         } else {
4981         
4982                 std::map<int, int>::iterator striter;
4983         
4984                 striter = SplitLength.find(1);
4985         
4986                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4987         
4988                 while (wSTDataType.HasMoreTokens() == TRUE){
4989                 
4990                         wxSSoundURI = wSTDataType.GetNextToken();
4991                         wxSSoundMIME = wSTDataType.GetNextToken();
4992                         break;
4993                 
4994                 }                       
4995         
4996                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4997         
4998                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4999                 
5000                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
5001                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
5002                         base64enc = wxSSoundData.mb_str();
5003                         break;
5004                 
5005                 }
5006         
5007         }
5008         
5009         // Add the data to the General/Home/Work address variables.
5010                 
5011         switch(PropType){
5012                 case PROPERTY_NONE:
5013                         break;
5014                 case PROPERTY_HOME:
5015                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5016                         break;
5017                 case PROPERTY_WORK:
5018                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5019                         break;
5020         }
5021         
5022         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5023         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5024         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5025         
5026         if (!PropertyTokens.IsEmpty()){
5027         
5028                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5029         
5030         }
5031         
5034 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5036         size_t intPropertyLen = PropertySeg1.Len();
5037         std::map<int, int> SplitPoints;
5038         std::map<int, int> SplitLength;
5039         std::map<int, int>::iterator SLiter;                    
5040         wxString PropertyData;
5041         wxString PropertyName;
5042         wxString PropertyValue;
5043         wxString PropertyTokens;
5044         bool FirstToken = TRUE;
5045         int intSplitsFound = 0;
5046         int intSplitSize = 0;
5047         int intPrevValue = 8;
5048         int intPref = 0;                        
5049         int intType = 0;
5050         
5051         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5052         
5053         intPrevValue = 7;
5054         
5055         PropertyType PropType = PROPERTY_NONE;
5056         
5057         // Look for type before continuing.                     
5059         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5061         intPrevValue = 7;
5063         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5064         intiter != SplitPoints.end(); ++intiter){
5065         
5066                 SLiter = SplitLength.find(intiter->first);
5067         
5068                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5069                 
5070                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5071                 PropertyName = PropertyElement.GetNextToken();                          
5072                 PropertyValue = PropertyElement.GetNextToken();
5073                 
5074                 intPrevValue = intiter->second;
5075                 
5076                 // Process properties.
5077                 
5078                 size_t intPropertyValueLen = PropertyValue.Len();
5079                 
5080                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5081                         
5082                         PropertyValue.Trim();
5083                         PropertyValue.RemoveLast();
5084                         
5085                 }                               
5086                 
5087                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5088                         
5089                         PropertyValue.Remove(0, 1);
5090                         
5091                 }                       
5092                 
5093                 CaptureString(&PropertyValue, FALSE);
5094                 
5095                 if (PropertyName == wxT("ALTID")){
5097                         CalendarListAltID.erase(*CalURICount);
5098                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5099                 
5100                 } else if (PropertyName == wxT("PID")){
5102                         CalendarListPID.erase(*CalURICount);
5103                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5104                 
5105                 } else if (PropertyName == wxT("PREF")){
5106                         
5107                         int PriorityNumber = 0;
5108                         bool ValidNumber = TRUE;
5109                         
5110                         try{
5111                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5112                         }
5113                         
5114                         catch(std::invalid_argument &e){
5115                                 ValidNumber = FALSE;
5116                         }
5118                         if (ValidNumber == TRUE){
5120                                 CalendarListPref.erase(*CalURICount);
5121                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5123                         }
5124                 
5125                 } else if (PropertyName == wxT("MEDIATYPE")){
5126                 
5127                         CalendarListMediatype.erase(*CalURICount);
5128                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5130                 } else {
5131                 
5132                         // Something else we don't know about so append
5133                         // to the tokens variable.
5134                         
5135                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5136                         
5137                                 if (FirstToken == TRUE){
5138                                 
5139                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5140                                         FirstToken = FALSE;
5141                                 
5142                                 } else {
5143                                 
5144                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5145                                 
5146                                 }
5147                         
5148                         }
5149                 
5150                 }
5151         
5152         }       
5153         
5154         intPropertyLen = PropertySeg2.Len();
5155         SplitPoints.clear();
5156         SplitLength.clear();
5157         intSplitsFound = 0;
5158         intSplitSize = 0;
5159         intPrevValue = 0;
5160         
5161         CaptureString(&PropertySeg2, FALSE);
5162         
5163         // Add the data to the General/Home/Work address variables.
5164                 
5165         switch(PropType){
5166                 case PROPERTY_NONE:
5167                         break;
5168                 case PROPERTY_HOME:
5169                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5170                         break;
5171                 case PROPERTY_WORK:
5172                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5173                         break;
5174         }
5175         
5176         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5177         
5178         if (!PropertyTokens.IsEmpty()){
5179         
5180                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5181         
5182         }
5186 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5188         size_t intPropertyLen = PropertySeg1.Len();
5189         std::map<int, int> SplitPoints;
5190         std::map<int, int> SplitLength;
5191         std::map<int, int>::iterator SLiter;                    
5192         wxString PropertyData;
5193         wxString PropertyName;
5194         wxString PropertyValue;
5195         wxString PropertyTokens;
5196         bool FirstToken = TRUE;
5197         int intSplitsFound = 0;
5198         int intSplitSize = 0;
5199         int intPrevValue = 8;
5200         int intPref = 0;                        
5201         int intType = 0;
5202         
5203         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5204         
5205         intPrevValue = 7;
5206         
5207         PropertyType PropType = PROPERTY_NONE;
5208         
5209         // Look for type before continuing.                     
5211         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5213         intPrevValue = 7;
5215         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5216         intiter != SplitPoints.end(); ++intiter){
5217         
5218                 SLiter = SplitLength.find(intiter->first);
5219         
5220                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5221                 
5222                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5223                 PropertyName = PropertyElement.GetNextToken();                          
5224                 PropertyValue = PropertyElement.GetNextToken();
5225                 
5226                 intPrevValue = intiter->second;
5227                 
5228                 // Process properties.
5229                 
5230                 size_t intPropertyValueLen = PropertyValue.Len();
5231                 
5232                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5233                         
5234                         PropertyValue.Trim();
5235                         PropertyValue.RemoveLast();
5236                         
5237                 }                               
5238                 
5239                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5240                         
5241                         PropertyValue.Remove(0, 1);
5242                         
5243                 }                       
5244                 
5245                 CaptureString(&PropertyValue, FALSE);
5246                 
5247                 if (PropertyName == wxT("ALTID")){
5249                         CalendarRequestListAltID.erase(*CalAdrURICount);
5250                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5251                 
5252                 } else if (PropertyName == wxT("PID")){
5254                         CalendarRequestListPID.erase(*CalAdrURICount);
5255                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5256                 
5257                 } else if (PropertyName == wxT("PREF")){
5258                         
5259                         int PriorityNumber = 0;
5260                         bool ValidNumber = TRUE;
5261                         
5262                         try{
5263                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5264                         }
5265                         
5266                         catch(std::invalid_argument &e){
5267                                 ValidNumber = FALSE;
5268                         }
5270                         if (ValidNumber == TRUE){
5272                                 CalendarRequestListPref.erase(*CalAdrURICount);
5273                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5275                         }
5276                 
5277                 } else if (PropertyName == wxT("MEDIATYPE")){
5278                 
5279                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5280                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5282                 } else {
5283                 
5284                         // Something else we don't know about so append
5285                         // to the tokens variable.
5286                         
5287                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5288                         
5289                                 if (FirstToken == TRUE){
5290                                 
5291                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5292                                         FirstToken = FALSE;
5293                                 
5294                                 } else {
5295                                 
5296                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5297                                 
5298                                 }
5299                         
5300                         }
5301                 
5302                 }
5303         
5304         }       
5305         
5306         intPropertyLen = PropertySeg2.Len();
5307         SplitPoints.clear();
5308         SplitLength.clear();
5309         intSplitsFound = 0;
5310         intSplitSize = 0;
5311         intPrevValue = 0;
5312         
5313         CaptureString(&PropertySeg2, FALSE);
5314         
5315         // Add the data to the General/Home/Work address variables.
5316                 
5317         switch(PropType){
5318                 case PROPERTY_NONE:
5319                         break;
5320                 case PROPERTY_HOME:
5321                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5322                         break;
5323                 case PROPERTY_WORK:
5324                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5325                         break;
5326         }
5327         
5328         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5329         
5330         if (!PropertyTokens.IsEmpty()){
5331         
5332                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5333         
5334         }       
5335         
5338 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5340         size_t intPropertyLen = PropertySeg1.Len();
5341         std::map<int, int> SplitPoints;
5342         std::map<int, int> SplitLength;
5343         std::map<int, int>::iterator SLiter;                    
5344         wxString PropertyData;
5345         wxString PropertyName;
5346         wxString PropertyValue;
5347         wxString PropertyTokens;
5348         bool FirstToken = TRUE;
5349         int intSplitsFound = 0;
5350         int intSplitSize = 0;
5351         int intPrevValue = 7;
5352         int intPref = 0;                        
5353         int intType = 0;
5354         
5355         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5356         
5357         intPrevValue = 6;
5358         
5359         PropertyType PropType = PROPERTY_NONE;
5360         
5361         // Look for type before continuing.                     
5363         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5365         intPrevValue = 6;
5367         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5368         intiter != SplitPoints.end(); ++intiter){
5369         
5370                 SLiter = SplitLength.find(intiter->first);
5371         
5372                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5373                 
5374                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5375                 PropertyName = PropertyElement.GetNextToken();                          
5376                 PropertyValue = PropertyElement.GetNextToken();
5377                 
5378                 intPrevValue = intiter->second;
5379                 
5380                 // Process properties.
5381                 
5382                 size_t intPropertyValueLen = PropertyValue.Len();
5383                 
5384                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5385                         
5386                         PropertyValue.Trim();
5387                         PropertyValue.RemoveLast();
5388                         
5389                 }                               
5390                 
5391                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5392                         
5393                         PropertyValue.Remove(0, 1);
5394                         
5395                 }                       
5396                 
5397                 CaptureString(&PropertyValue, FALSE);
5398                 
5399                 if (PropertyName == wxT("ALTID")){
5401                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5402                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5403                 
5404                 } else if (PropertyName == wxT("PID")){
5406                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5407                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5408                 
5409                 } else if (PropertyName == wxT("PREF")){
5410                         
5411                         int PriorityNumber = 0;
5412                         bool ValidNumber = TRUE;
5413                         
5414                         try{
5415                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5416                         }
5417                         
5418                         catch(std::invalid_argument &e){
5419                                 ValidNumber = FALSE;
5420                         }
5422                         if (ValidNumber == TRUE){
5424                                 FreeBusyListPref.erase(*FreeBusyAddressCount);
5425                                 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5427                         }
5428                 
5429                 } else if (PropertyName == wxT("MEDIATYPE")){
5430                 
5431                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5432                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5434                 } else {
5435                 
5436                         // Something else we don't know about so append
5437                         // to the tokens variable.
5438                         
5439                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5440                         
5441                                 if (FirstToken == TRUE){
5442                                 
5443                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5444                                         FirstToken = FALSE;
5445                                 
5446                                 } else {
5447                                 
5448                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5449                                 
5450                                 }
5451                         
5452                         }
5453                 
5454                 }
5455         
5456         }       
5457         
5458         intPropertyLen = PropertySeg2.Len();
5459         SplitPoints.clear();
5460         SplitLength.clear();
5461         intSplitsFound = 0;
5462         intSplitSize = 0;
5463         intPrevValue = 0;
5464         
5465         CaptureString(&PropertySeg2, FALSE);
5466         
5467         // Add the data to the General/Home/Work address variables.
5468                 
5469         switch(PropType){
5470                 case PROPERTY_NONE:
5471                         break;
5472                 case PROPERTY_HOME:
5473                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5474                         break;
5475                 case PROPERTY_WORK:
5476                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5477                         break;
5478         }
5479         
5480         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5481         
5482         if (!PropertyTokens.IsEmpty()){
5483         
5484                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5485         
5486         }
5490 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5492         size_t intPropertyLen = PropertySeg1.Len();
5493         std::map<int, int> SplitPoints;
5494         std::map<int, int> SplitLength;
5495         std::map<int, int>::iterator SLiter;                    
5496         wxString PropertyData;
5497         wxString PropertyName;
5498         wxString PropertyValue;
5499         wxString PropertyTokens;
5500         bool FirstToken = TRUE;
5501         int intSplitsFound = 0;
5502         int intSplitSize = 0;
5503         int intPrevValue = 5;
5504         int intPref = 0;                        
5505         int intType = 0;
5506         long ListCtrlIndex;
5507         
5508         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5509         
5510         intPrevValue = 4;
5511         
5512         PropertyType PropType = PROPERTY_NONE;
5513         
5514         // Look for type before continuing.
5516         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5518         intPrevValue = 4;
5520         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5521         intiter != SplitPoints.end(); ++intiter){
5522         
5523                 SLiter = SplitLength.find(intiter->first);
5524         
5525                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5526                 
5527                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5528                 PropertyName = PropertyElement.GetNextToken();                          
5529                 PropertyValue = PropertyElement.GetNextToken();
5530                 
5531                 intPrevValue = intiter->second;
5532                 
5533                 // Process properties.
5534                 
5535                 size_t intPropertyValueLen = PropertyValue.Len();
5536                 
5537                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5538                         
5539                         PropertyValue.Trim();
5540                         PropertyValue.RemoveLast();
5541                         
5542                 }                               
5543                 
5544                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5545                         
5546                         PropertyValue.Remove(0, 1);
5547                         
5548                 }                               
5549                 
5550                 if (PropertyName == wxT("ALTID")){
5552                         KeyListAltID.erase(*KeyCount);
5553                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5554                 
5555                 } else if (PropertyName == wxT("PID")){
5557                         KeyListPID.erase(*KeyCount);
5558                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5559                 
5560                 } else if (PropertyName == wxT("PREF")){
5561                         
5562                         int PriorityNumber = 0;
5563                         bool ValidNumber = TRUE;
5564                         
5565                         try{
5566                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5567                         }
5568                         
5569                         catch(std::invalid_argument &e){
5570                                 ValidNumber = FALSE;
5571                         }
5573                         if (ValidNumber == TRUE){
5575                                 KeyListPref.erase(*KeyCount);
5576                                 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5578                         }
5579                 
5580                 } else {
5581                 
5582                         // Something else we don't know about so append
5583                         // to the tokens variable.
5584                         
5585                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5586                         
5587                                 if (FirstToken == TRUE){
5588                                 
5589                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5590                                         FirstToken = FALSE;
5591                                 
5592                                 } else {
5593                                 
5594                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5595                                 
5596                                 }
5597                         
5598                         }
5599                 
5600                 }
5601         
5602         }                               
5603         
5604         intPropertyLen = PropertySeg2.Len();
5605         SplitPoints.clear();
5606         SplitLength.clear();
5607         intSplitsFound = 0;
5608         intSplitSize = 0;
5609         intPrevValue = 0;                       
5610         
5611         for (int i = 0; i <= intPropertyLen; i++){
5613                 intSplitSize++;
5614         
5615                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5616         
5617                         intSplitsFound++;
5618                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5619                         
5620                         if (intSplitsFound == 6){ 
5621                         
5622                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5623                                 break; 
5624                                 
5625                         } else {
5626                         
5627                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5628                         
5629                         }
5630                         
5631                         intSplitSize = 0;                                       
5632         
5633                 }
5635         }
5636         
5637         wxString wxSKeyURI;
5638         wxString wxSKeyMIME;
5639         wxString wxSKeyEncoding;
5640         wxString wxSKeyData;
5641         std::string base64enc;
5642         
5643         if (intSplitsFound == 0){
5644         
5645         } else {
5646         
5647                 std::map<int, int>::iterator striter;
5648         
5649                 striter = SplitLength.find(1);
5650         
5651                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5652         
5653                 while (wSTDataType.HasMoreTokens() == TRUE){
5654                 
5655                         wxSKeyURI = wSTDataType.GetNextToken();
5656                         wxSKeyMIME = wSTDataType.GetNextToken();
5657                         break;
5658                 
5659                 }                       
5660         
5661                 if (wxSKeyURI == wxT("data")){
5662                 
5663                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5664         
5665                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5666                 
5667                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5668                                 wxSKeyData = wSTDataInfo.GetNextToken();
5669                                 break;
5670                 
5671                         }
5672                 
5673                 }
5674         
5675         }
5676         
5677         // Add the data to the General/Home/Work address variables.
5678         
5679         if (wxSKeyURI == wxT("data")){
5680                 
5681                 KeyListDataEncType.erase(*KeyCount);
5682                 KeyListKeyType.erase(*KeyCount);
5683                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5684                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5685                 
5686                 KeyList.erase(*KeyCount);
5687                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5688         
5689         } else {
5690                 
5691                 KeyList.erase(*KeyCount);
5692                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5693         
5694         }
5695         
5696         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5697                 
5698         switch (PropType){
5699                 case PROPERTY_NONE:
5700                         break;
5701                 case PROPERTY_HOME: 
5702                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5703                         break;
5704                 case PROPERTY_WORK: 
5705                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5706                         break;
5707         }
5709         if (!PropertyTokens.IsEmpty()){
5711                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5713         }
5717 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5719         // Split the Vendor three ways.
5720         
5721         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5722         
5723         wxString wxSVNDID;
5724         wxString wxSVNDPropName;
5725         long ListCtrlIndex;                     
5727         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5728         
5729                 wSTVendorDetails.GetNextToken();
5730                 wxSVNDID = wSTVendorDetails.GetNextToken();
5731                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5732                 break;
5733         
5734         }
5735         
5736         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5737         
5738                 // Add the data to the vendor variables.
5739         
5740                 VendorList.erase(*VendorCount);
5741                 VendorListPEN.erase(*VendorCount);
5742                 VendorListElement.erase(*VendorCount);
5743         
5744                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5745                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5746                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5747         
5748         }
5752 void ProcessIntegerValue(ContactDataObject *ContactData,
5753         std::map<int,int> *PrefPtr, 
5754         wxString *PropertyValue, 
5755         int *ItemCount){
5757         int PriorityNumber = 0; 
5758         bool ValidNumber = TRUE;
5759                         
5760         try{
5761                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5762         }
5763                         
5764         catch(std::invalid_argument &e){
5765                 ValidNumber = FALSE;
5766         }
5768         if (ValidNumber == TRUE){
5770                 PrefPtr->erase(*ItemCount);
5771                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5773         }
5777 void SplitValues(wxString *PropertyLine, 
5778         std::map<int,int> *SplitPoints, 
5779         std::map<int,int> *SplitLength, 
5780         int intSize){
5781         
5782         size_t intPropertyLen = PropertyLine->Len();
5783         int intSplitsFound = 0;
5784         int intSplitSize = 0;
5785         int intSplitSeek = 0;
5786         
5787         for (int i = intSize; i <= intPropertyLen; i++){
5789                 intSplitSize++;
5790         
5791                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5792                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5793            
5794                     if (intSplitsFound == 0){
5795             
5796                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5797           
5798                     } else {
5799            
5800                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5801             
5802                     }
5803             
5804                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5805             
5806                     intSplitsFound++;
5807                     intSplitSeek = i;
5808                     intSplitSize = 0;
5809             
5810                 }
5812         }
5814         if (intSplitsFound == 0){
5816                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5817                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5819         } else {
5821                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5822                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5824         }
5828 void CheckType(wxString *PropertySeg1, 
5829         std::map<int,int> *SplitPoints, 
5830         std::map<int,int> *SplitLength, 
5831         int *intPrevValue, 
5832         PropertyType *PropType){
5833         
5834         wxString PropertyData;
5835         wxString PropertyName;
5836         wxString PropertyValue;
5837         std::map<int,int>::iterator SLiter;
5838         
5839         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5840         intiter != SplitPoints->end(); ++intiter){
5841         
5842                 SLiter = SplitLength->find(intiter->first);
5843         
5844                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5845                 
5846                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5847                 PropertyName = PropertyElement.GetNextToken();                          
5848                 PropertyValue = PropertyElement.GetNextToken();
5849                 
5850                 *intPrevValue = intiter->second;
5851                 
5852                 if (PropertyName == wxT("TYPE")){
5853                                 
5854                         if (PropertyValue == wxT("work")){
5855                         
5856                                 *PropType = PROPERTY_WORK;
5857                                                         
5858                         } else if (PropertyValue == wxT("home")){
5860                                 *PropType = PROPERTY_HOME;
5861                                                         
5862                         } else {
5863                         
5864                                 *PropType = PROPERTY_NONE;
5865                         
5866                         }
5867                 
5868                         return;
5869                 
5870                 }
5871         
5872         }
5873         
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