Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
f6a3da2d3fe464fd2316b82929b0858885098a4c
[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")){
1920                         
1921                         int PriorityNumber = 0;
1922                         bool ValidNumber = TRUE;
1923                         
1924                         try{
1925                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
1926                         }
1927                         
1928                         catch(std::invalid_argument &e){
1929                                 ValidNumber = FALSE;
1930                         }
1932                         if (ValidNumber == TRUE){
1934                                 AddressListPref->erase(*AddressCount);
1935                                 AddressListPref->insert(std::make_pair(*AddressCount, PriorityNumber));
1937                         }
1938                 
1939                 } else {
1940                 
1941                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1942                         
1943                                 if (FirstToken == TRUE){
1944                                 
1945                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1946                                         FirstToken = FALSE;
1947                                 
1948                                 } else {
1949                                 
1950                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1951                                 
1952                                 }
1953                         
1954                         }
1955                 
1956                 }
1957         
1958         }                       
1959         
1960         // Split the address. 
1962         //std::map<int, int>::iterator SLiter;
1963         intPropertyLen = PropertySeg2.Len();
1964         SplitPoints.clear();
1965         SplitLength.clear();
1966         intSplitsFound = 0;
1967         intSplitSize = 0;
1968         intPrevValue = 0;
1969         
1970         for (int i = 0; i <= intPropertyLen; i++){
1972                 intSplitSize++;
1973         
1974                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1975         
1976                         intSplitsFound++;
1977                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1978                         
1979                         if (intSplitsFound == 6){ 
1980                         
1981                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1982                                 break; 
1983                                 
1984                         } else {
1985                         
1986                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1987                         
1988                         }
1989                         
1990                         intSplitSize = 0;                                       
1991         
1992                 }
1994         }
1995         
1996         // Split the data into several parts.                   
1997         
1998         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1999         intiter != SplitPoints.end(); ++intiter){
2000                         
2001                 if (intiter->first == 1){
2002                 
2003                         // Deal with PO Box.
2004                         
2005                         SLiter = SplitLength.find(1);
2006                                                                 
2007                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
2008                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
2009                         intPrevValue = intiter->second;
2010                 
2011                 } else if (intiter->first == 2){
2012                 
2013                         // Deal with extended address.
2014                         
2015                         SLiter = SplitLength.find(2);
2016                         
2017                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
2018                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2019                         intPrevValue = intiter->second;
2020                 
2021                 } else if (intiter->first == 3){
2022                 
2023                         // Deal with street address.
2024                         
2025                         SLiter = SplitLength.find(3);
2026                                                                 
2027                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2028                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2029                         intPrevValue = intiter->second;
2030                 
2031                 } else if (intiter->first == 4){
2032                 
2033                         // Deal with locality
2035                         SLiter = SplitLength.find(4);
2036                         
2037                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2038                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2039                         intPrevValue = intiter->second;
2040                         
2041                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2042                 
2043                 } else if (intiter->first == 5){
2044                 
2045                         // Deal with region.
2047                         SLiter = SplitLength.find(5);
2048                         
2049                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2050                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2051                         intPrevValue = intiter->second;
2052                         
2053                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2054                 
2055                 } else if (intiter->first == 6){
2056                 
2057                         // Deal with post code.
2059                         SLiter = SplitLength.find(6);
2060                         
2061                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2062                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2063                         intPrevValue = intiter->second;
2064                         
2065                         // Deal with country.
2066                                                 
2067                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2068                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2069                         
2070                         break;
2071                 
2072                 }
2073         
2074         }       
2075         
2076         // Add the data to the General/Home/Work address variables.
2077         
2078         CaptureString(&AddressStreet, FALSE); 
2079         CaptureString(&AddressLocality, FALSE);
2080         CaptureString(&AddressRegion, FALSE);
2081         CaptureString(&AddressPostalCode, FALSE);
2082         CaptureString(&AddressCountry, FALSE);
2083                 
2084         if (!PropertyTokens.IsEmpty()){
2085         
2086                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2087         
2088         }
2090         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2091         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2092         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2093         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2094         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2096         switch(PropType){
2097                 case PROPERTY_NONE:
2098                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2099                         break;
2100                 case PROPERTY_HOME:
2101                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2102                         break;
2103                 case PROPERTY_WORK:
2104                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2105                         break;
2106         }
2107         
2108         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2112 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2114         std::map<int, int> SplitPoints;
2115         std::map<int, int> SplitLength;
2117         int intPrevValue = 7;
2118         int intPref = 0;                        
2119         
2120         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2121         
2122         intPrevValue = 6;
2123         
2124         PropertyType PropType = PROPERTY_NONE;
2125                 
2126         // Look for type before continuing.
2127         
2128         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2129         
2130         std::map<int, wxString> *EmailList = NULL;
2131         std::map<int, wxString> *EmailListType = NULL;
2132         std::map<int, wxString> *EmailListAltID = NULL;
2133         std::map<int, wxString> *EmailListPID = NULL;
2134         std::map<int, wxString> *EmailListTokens = NULL;                
2135         std::map<int, int> *EmailListPref = NULL;
2137         switch(PropType){
2138                 case PROPERTY_NONE:
2139                         EmailList = &GeneralEmailList;
2140                         EmailListType = &GeneralEmailListType;
2141                         EmailListAltID = &GeneralEmailListAltID;
2142                         EmailListPID = &GeneralEmailListPID;
2143                         EmailListTokens = &GeneralEmailListTokens;              
2144                         EmailListPref = &GeneralEmailListPref;  
2145                         break;
2146                 case PROPERTY_HOME:
2147                         EmailList = &HomeEmailList;
2148                         EmailListType = &HomeEmailListType;
2149                         EmailListAltID = &HomeEmailListAltID;
2150                         EmailListPID = &HomeEmailListPID;
2151                         EmailListTokens = &HomeEmailListTokens;         
2152                         EmailListPref = &HomeEmailListPref;     
2153                         break;
2154                 case PROPERTY_WORK:
2155                         EmailList = &BusinessEmailList;
2156                         EmailListType = &BusinessEmailListType;
2157                         EmailListAltID = &BusinessEmailListAltID;
2158                         EmailListPID = &BusinessEmailListPID;
2159                         EmailListTokens = &BusinessEmailListTokens;             
2160                         EmailListPref = &BusinessEmailListPref; 
2161                         break;
2162         }
2163         
2164         intPrevValue = 6;
2165         
2166         std::map<int,int>::iterator SLiter;
2167         wxString PropertyData;
2168         wxString PropertyName;
2169         wxString PropertyValue;
2170         wxString PropertyTokens;
2171         bool FirstToken = TRUE;
2172         
2173         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2174         intiter != SplitPoints.end(); ++intiter){
2175         
2176                 SLiter = SplitLength.find(intiter->first);
2177         
2178                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2179                 
2180                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2181                 PropertyName = PropertyElement.GetNextToken();                          
2182                 PropertyValue = PropertyElement.GetNextToken();
2183                 
2184                 intPrevValue = intiter->second;
2185                 
2186                 CaptureString(&PropertyValue, FALSE);
2187                 
2188                 // Process properties.
2189                 
2190                 if (PropertyName == wxT("ALTID")){
2192                         EmailListAltID->erase(*EmailCount);
2193                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2194                 
2195                 } else if (PropertyName == wxT("PID")){
2197                         EmailListPID->erase(*EmailCount);
2198                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2199                 
2200                 } else if (PropertyName == wxT("PREF")){
2201                         
2202                         int PriorityNumber = 0;
2203                         bool ValidNumber = TRUE;
2204                         
2205                         try{
2206                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2207                         }
2208                         
2209                         catch(std::invalid_argument &e){
2210                                 ValidNumber = FALSE;
2211                         }
2213                         if (ValidNumber == TRUE){
2215                                 EmailListPref->erase(*EmailCount);
2216                                 EmailListPref->insert(std::make_pair(*EmailCount, PriorityNumber));
2218                         }
2219                 
2220                 } else {
2221                 
2222                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2223                         
2224                                 if (FirstToken == TRUE){
2225                                 
2226                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2227                                         FirstToken = FALSE;
2228                                 
2229                                 } else {
2230                                 
2231                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2232                                 
2233                                 }
2234                         
2235                         }
2236                 
2237                 }
2238         
2239         }
2240         
2241         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2242         
2243         // Add the name token data.
2244         
2245         if (!PropertyTokens.IsEmpty()){
2246         
2247                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2248         
2249         }       
2254 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2256         std::map<int, int> SplitPoints;
2257         std::map<int, int> SplitLength;
2259         int intPrevValue = 6;
2260         int intPref = 0;                        
2261         
2262         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2263         
2264         intPrevValue = 5;
2265         
2266         PropertyType PropType = PROPERTY_NONE;
2267                 
2268         // Look for type before continuing.
2269         
2270         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2271         
2272         std::map<int, wxString> *IMList = NULL;
2273         std::map<int, wxString> *IMListType = NULL;
2274         std::map<int, wxString> *IMListAltID = NULL;
2275         std::map<int, wxString> *IMListPID = NULL;
2276         std::map<int, wxString> *IMListTokens = NULL;
2277         std::map<int, wxString> *IMListMediatype = NULL;        
2278         std::map<int, int> *IMListPref = NULL;
2280         switch(PropType){
2281                 case PROPERTY_NONE:
2282                         IMList = &GeneralIMList;
2283                         IMListType = &GeneralIMListType;
2284                         IMListAltID = &GeneralIMListAltID;
2285                         IMListPID = &GeneralIMListPID;
2286                         IMListTokens = &GeneralIMListTokens;
2287                         IMListMediatype = &GeneralIMListMediatype;
2288                         IMListPref = &GeneralIMListPref;        
2289                         break;
2290                 case PROPERTY_HOME:
2291                         IMList = &HomeIMList;
2292                         IMListType = &HomeIMListType;
2293                         IMListAltID = &HomeIMListAltID;
2294                         IMListPID = &HomeIMListPID;
2295                         IMListTokens = &HomeIMListTokens;
2296                         IMListMediatype = &HomeIMListMediatype;         
2297                         IMListPref = &HomeIMListPref;   
2298                         break;
2299                 case PROPERTY_WORK:
2300                         IMList = &BusinessIMList;
2301                         IMListType = &BusinessIMListType;
2302                         IMListAltID = &BusinessIMListAltID;
2303                         IMListPID = &BusinessIMListPID;
2304                         IMListTokens = &BusinessIMListTokens;   
2305                         IMListMediatype = &BusinessIMListMediatype;     
2306                         IMListPref = &BusinessIMListPref;       
2307                         break;
2308         }
2309         
2310         intPrevValue = 5;
2311         
2312         std::map<int,int>::iterator SLiter;
2313         wxString PropertyData;
2314         wxString PropertyName;
2315         wxString PropertyValue;
2316         wxString PropertyTokens;
2317         bool FirstToken = TRUE;
2318         
2319         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2320         intiter != SplitPoints.end(); ++intiter){
2321         
2322                 SLiter = SplitLength.find(intiter->first);
2323         
2324                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2325                 
2326                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2327                 PropertyName = PropertyElement.GetNextToken();                          
2328                 PropertyValue = PropertyElement.GetNextToken();
2329                 
2330                 intPrevValue = intiter->second;
2331                 
2332                 CaptureString(&PropertyValue, FALSE);
2333                 
2334                 // Process properties.
2335                 
2336                 if (PropertyName == wxT("ALTID")){
2338                         IMListAltID->erase(*IMCount);
2339                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2340                 
2341                 } else if (PropertyName == wxT("PID")){
2343                         IMListPID->erase(*IMCount);
2344                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2345                 
2346                 } else if (PropertyName == wxT("MEDIATYPE")){
2348                         IMListMediatype->erase(*IMCount);
2349                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2350                 
2351                 } else if (PropertyName == wxT("PREF")){
2352                         
2353                         int PriorityNumber = 0;
2354                         bool ValidNumber = TRUE;
2355                         
2356                         try{
2357                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2358                         }
2359                         
2360                         catch(std::invalid_argument &e){
2361                                 ValidNumber = FALSE;
2362                         }
2364                         if (ValidNumber == TRUE){
2366                                 IMListPref->erase(*IMCount);
2367                                 IMListPref->insert(std::make_pair(*IMCount, PriorityNumber));
2369                         }
2370                 
2371                 } else {
2372                 
2373                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2374                         
2375                                 if (FirstToken == TRUE){
2376                                 
2377                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2378                                         FirstToken = FALSE;
2379                                 
2380                                 } else {
2381                                 
2382                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2383                                 
2384                                 }
2385                         
2386                         }
2387                 
2388                 }
2389         
2390         }
2391                 
2392         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2393         
2394         // Add the name token data.
2395         
2396         if (!PropertyTokens.IsEmpty()){
2397         
2398                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2399         
2400         }
2404 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2406         std::map<int, int> SplitPoints;
2407         std::map<int, int> SplitLength;
2408         std::map<int, int>::iterator SLiter;
2409         
2410         int intPref = 0;
2411         
2412         PropertyType PropType = PROPERTY_NONE;
2413                 
2414         // Look for type before continuing.
2415         
2416         wxString TelTypeUI;
2417         wxString TelTypeDetail;
2418         wxString PropertyData;
2419         wxString PropertyName;
2420         wxString PropertyValue;
2421         wxString PropertyTokens;
2422         
2423         std::map<int,int> TypeSplitPoints;
2424         std::map<int,int> TypeSplitLength;
2425         std::map<int,int>::iterator TSLiter;
2426         
2427         int intSplitSize = 0;
2428         int intSplitsFound = 0;
2429         int intSplitPoint = 0;
2430         int intType = 0;
2431         int intPrevValue = 5;
2432                 
2433         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2434         
2435         intPrevValue = 4;
2436         
2437         // Look for type before continuing.
2438         
2439         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2440         intiter != SplitPoints.end(); ++intiter){
2441         
2442                 SLiter = SplitLength.find(intiter->first);
2443         
2444                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2445                 
2446                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2447                 PropertyName = PropertyElement.GetNextToken();                          
2448                 PropertyValue = PropertyElement.GetNextToken();
2449                 
2450                 intPrevValue = intiter->second;
2452                 if (PropertyName == wxT("TYPE")){
2453                 
2454                         // Process each value in type and translate each
2455                         // part.
2456                 
2457                         // Strip out the quotes if they are there.
2458                 
2459                         size_t intPropertyValueLen = PropertyValue.Len();
2460                 
2461                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2462                         
2463                                 PropertyValue.Trim();
2464                                 PropertyValue.RemoveLast();
2465                         
2466                         }                               
2467                 
2468                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2469                         
2470                                 PropertyValue.Remove(0, 1);
2471                         
2472                         }
2473                         
2474                         TelTypeDetail = PropertyValue;
2475                         
2476                         intSplitSize = 0;
2477                         intSplitsFound = 0;
2478                         intSplitPoint = 0;
2479                         
2480                         for (int i = 0; i <= intPropertyValueLen; i++){
2481         
2482                                 intSplitSize++;
2483         
2484                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2485         
2486                                         if (intSplitsFound == 0){
2488                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2489                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2490                         
2491                                         } else {
2492                         
2493                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2494                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2495                         
2496                                         }                       
2498                                         intSplitsFound++;
2499                                         i++;
2500                                         intSplitPoint = i;
2501                                         intSplitSize = 0;
2502         
2503                                 }
2504         
2505                         }
2506                         
2507                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2508                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2509                 
2510                         int intTypeSeek = 0;
2511                 
2512                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2513                         typeiter != TypeSplitPoints.end(); ++typeiter){
2514                         
2515                                 wxString TypePropertyName;
2516                                 
2517                                 TSLiter = TypeSplitLength.find(typeiter->first);
2518                                 
2519                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2520                                 
2521                                 if (intTypeSeek == 0){
2522                                 
2523                                 
2524                                 } else {
2525                                                                                 
2526                                         TelTypeUI.Append(wxT(","));                                                     
2527                                 
2528                                 }
2529                         
2530                                 if (TypePropertyName == wxT("home")){
2531                                 
2532                                         PropType = PROPERTY_HOME;
2533                                 
2534                                 } else if (TypePropertyName == wxT("work")){
2535                                 
2536                                         PropType = PROPERTY_WORK;
2537                                                                         
2538                                 }
2539                                 
2540                                 
2541                                 if (TypePropertyName == wxT("text")){
2542                                 
2543                                         TelTypeUI.Append(_("text"));
2544                                         intTypeSeek++;
2545                                 
2546                                 } else if (TypePropertyName == wxT("voice")){
2547                                 
2548                                         TelTypeUI.Append(_("voice"));
2549                                         intTypeSeek++;
2550                                 
2551                                 } else if (TypePropertyName == wxT("fax")){
2552                                 
2553                                         TelTypeUI.Append(_("fax"));
2554                                         intTypeSeek++;
2555                                 
2556                                 } else if (TypePropertyName == wxT("cell")){
2557                                 
2558                                         TelTypeUI.Append(_("mobile"));
2559                                         intTypeSeek++;
2560                                 
2561                                 } else if (TypePropertyName == wxT("video")){
2562                                 
2563                                         TelTypeUI.Append(_("video"));
2564                                         intTypeSeek++;
2565                                 
2566                                 } else if (TypePropertyName == wxT("pager")){
2567                                 
2568                                         TelTypeUI.Append(_("pager"));
2569                                         intTypeSeek++;
2570                                 
2571                                 } else if (TypePropertyName == wxT("textphone")){
2572                                 
2573                                         TelTypeUI.Append(_("textphone"));
2574                                         intTypeSeek++;
2575                                 
2576                                 }
2577                         
2578                         }
2579                 
2580                 }
2581                 
2582         }
2583         
2584         std::map<int, wxString> *TelephoneList = NULL;
2585         std::map<int, wxString> *TelephoneListType = NULL;
2586         std::map<int, wxString> *TelephoneListAltID = NULL;
2587         std::map<int, wxString> *TelephoneListPID = NULL;
2588         std::map<int, wxString> *TelephoneListTokens = NULL;
2589         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2590         std::map<int, int> *TelephoneListPref = NULL;
2592         switch(PropType){
2593                 case PROPERTY_NONE:
2594                         TelephoneList = &GeneralTelephoneList;
2595                         TelephoneListType = &GeneralTelephoneListType;
2596                         TelephoneListAltID = &GeneralTelephoneListAltID;
2597                         TelephoneListPID = &GeneralTelephoneListPID;
2598                         TelephoneListTokens = &GeneralTelephoneListTokens;
2599                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2600                         TelephoneListPref = &GeneralTelephoneListPref;  
2601                         break;
2602                 case PROPERTY_HOME:
2603                         TelephoneList = &HomeTelephoneList;
2604                         TelephoneListType = &HomeTelephoneListType;
2605                         TelephoneListAltID = &HomeTelephoneListAltID;
2606                         TelephoneListPID = &HomeTelephoneListPID;
2607                         TelephoneListTokens = &HomeTelephoneListTokens;
2608                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2609                         TelephoneListPref = &HomeTelephoneListPref;     
2610                         break;
2611                 case PROPERTY_WORK:
2612                         TelephoneList = &BusinessTelephoneList;
2613                         TelephoneListType = &BusinessTelephoneListType;
2614                         TelephoneListAltID = &BusinessTelephoneListAltID;
2615                         TelephoneListPID = &BusinessTelephoneListPID;
2616                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2617                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2618                         TelephoneListPref = &BusinessTelephoneListPref; 
2619                         break;
2620         }
2621                 
2622         // Process the properties.
2623         
2624         bool FirstToken = TRUE;
2625         
2626         intPrevValue = 5;
2627         SplitPoints.clear();
2628         SplitLength.clear();
2630         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2632         intPrevValue = 4;
2633         
2634         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2635         intiter != SplitPoints.end(); ++intiter){
2636         
2637                 SLiter = SplitLength.find(intiter->first);
2638         
2639                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2640                 
2641                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2642                 PropertyName = PropertyElement.GetNextToken();                          
2643                 PropertyValue = PropertyElement.GetNextToken();
2644                 
2645                 intPrevValue = intiter->second;
2646                 
2647                 CaptureString(&PropertyValue, FALSE);
2648                 
2649                 // Process properties.
2650                 
2651                 if (PropertyName == wxT("ALTID")){
2653                         TelephoneListAltID->erase(*TelephoneCount);
2654                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2655                 
2656                 } else if (PropertyName == wxT("PID")){
2658                         TelephoneListPID->erase(*TelephoneCount);
2659                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2660                 
2661                 } else if (PropertyName == wxT("PREF")){
2662                         
2663                         int PriorityNumber = 0;
2664                         bool ValidNumber = TRUE;
2665                         
2666                         try{
2667                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2668                         }
2669                         
2670                         catch(std::invalid_argument &e){
2671                                 ValidNumber = FALSE;
2672                         }
2674                         if (ValidNumber == TRUE){
2676                                 TelephoneListPref->erase(*TelephoneCount);
2677                                 TelephoneListPref->insert(std::make_pair(*TelephoneCount, PriorityNumber));
2679                         }
2680                 
2681                 } else {
2682                 
2683                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2684                         
2685                                 if (FirstToken == TRUE){
2686                                 
2687                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2688                                         FirstToken = FALSE;
2689                                 
2690                                 } else {
2691                                 
2692                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2693                                 
2694                                 }
2695                         
2696                         }
2697                 
2698                 }
2699         
2700         }
2701                 
2702         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2703         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2704         
2705         // Add the name token data.
2706         
2707         if (!PropertyTokens.IsEmpty()){
2708         
2709                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2710         
2711         }
2715 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2717         std::map<int, int> SplitPoints;
2718         std::map<int, int> SplitLength;
2720         int intPrevValue = 6;
2721         int intPref = 0;                        
2722         
2723         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2724         
2725         intPrevValue = 5;
2726         
2727         PropertyType PropType = PROPERTY_NONE;
2728                 
2729         // Look for type before continuing.
2730         
2731         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2732         
2733         std::map<int, wxString> *LanguageList = NULL;
2734         std::map<int, wxString> *LanguageListType = NULL;
2735         std::map<int, wxString> *LanguageListAltID = NULL;
2736         std::map<int, wxString> *LanguageListPID = NULL;
2737         std::map<int, wxString> *LanguageListTokens = NULL;
2738         std::map<int, int> *LanguageListPref = NULL;
2740         switch(PropType){
2741                 case PROPERTY_NONE:
2742                         LanguageList = &GeneralLanguageList;
2743                         LanguageListType = &GeneralLanguageListType;
2744                         LanguageListAltID = &GeneralLanguageListAltID;
2745                         LanguageListPID = &GeneralLanguageListPID;
2746                         LanguageListTokens = &GeneralLanguageListTokens;
2747                         LanguageListPref = &GeneralLanguageListPref;    
2748                         break;
2749                 case PROPERTY_HOME:
2750                         LanguageList = &HomeLanguageList;
2751                         LanguageListType = &HomeLanguageListType;
2752                         LanguageListAltID = &HomeLanguageListAltID;
2753                         LanguageListPID = &HomeLanguageListPID;
2754                         LanguageListTokens = &HomeLanguageListTokens;   
2755                         LanguageListPref = &HomeLanguageListPref;       
2756                         break;
2757                 case PROPERTY_WORK:
2758                         LanguageList = &BusinessLanguageList;
2759                         LanguageListType = &BusinessLanguageListType;
2760                         LanguageListAltID = &BusinessLanguageListAltID;
2761                         LanguageListPID = &BusinessLanguageListPID;
2762                         LanguageListTokens = &BusinessLanguageListTokens;       
2763                         LanguageListPref = &BusinessLanguageListPref;
2764                         break;
2765         }
2766         
2767         intPrevValue = 5;
2768         
2769         std::map<int,int>::iterator SLiter;
2770         wxString PropertyData;
2771         wxString PropertyName;
2772         wxString PropertyValue;
2773         wxString PropertyTokens;
2774         bool FirstToken = TRUE;
2775         
2776         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2777         intiter != SplitPoints.end(); ++intiter){
2778         
2779                 SLiter = SplitLength.find(intiter->first);
2780         
2781                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2782                 
2783                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2784                 PropertyName = PropertyElement.GetNextToken();                          
2785                 PropertyValue = PropertyElement.GetNextToken();
2786                 
2787                 intPrevValue = intiter->second;
2788                 
2789                 CaptureString(&PropertyValue, FALSE);
2790                 
2791                 // Process properties.
2792                 
2793                 if (PropertyName == wxT("ALTID")){
2795                         LanguageListAltID->erase(*LanguageCount);
2796                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2797                 
2798                 } else if (PropertyName == wxT("PID")){
2800                         LanguageListPID->erase(*LanguageCount);
2801                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2802                 
2803                 } else if (PropertyName == wxT("PREF")){
2804                         
2805                         int PriorityNumber = 0;
2806                         bool ValidNumber = TRUE;
2807                         
2808                         try{
2809                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2810                         }
2811                         
2812                         catch(std::invalid_argument &e){
2813                                 ValidNumber = FALSE;
2814                         }
2816                         if (ValidNumber == TRUE){
2818                                 LanguageListPref->erase(*LanguageCount);
2819                                 LanguageListPref->insert(std::make_pair(*LanguageCount, PriorityNumber));
2821                         }
2822                 
2823                 } else {
2824                 
2825                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2826                         
2827                                 if (FirstToken == TRUE){
2828                                 
2829                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2830                                         FirstToken = FALSE;
2831                                 
2832                                 } else {
2833                                 
2834                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2835                                 
2836                                 }
2837                         
2838                         }
2839                 
2840                 }
2841         
2842         }
2843                 
2844         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2845         
2846         // Add the name token data.
2847         
2848         if (!PropertyTokens.IsEmpty()){
2849         
2850                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2851         
2852         }
2856 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2858         std::map<int, int> SplitPoints;
2859         std::map<int, int> SplitLength;
2861         int intPrevValue = 5;
2862         int intPref = 0;                        
2863         
2864         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2865         
2866         intPrevValue = 4;
2867         
2868         PropertyType PropType = PROPERTY_NONE;
2869                 
2870         // Look for type before continuing.
2871         
2872         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2873         
2874         std::map<int, wxString> *GeopositionList = NULL;
2875         std::map<int, wxString> *GeopositionListType = NULL;
2876         std::map<int, wxString> *GeopositionListAltID = NULL;
2877         std::map<int, wxString> *GeopositionListPID = NULL;
2878         std::map<int, wxString> *GeopositionListTokens = NULL;
2879         std::map<int, wxString> *GeopositionListMediatype = NULL;
2880         std::map<int, int> *GeopositionListPref = NULL;
2882         switch(PropType){
2883                 case PROPERTY_NONE:
2884                         GeopositionList = &GeneralGeographyList;
2885                         GeopositionListType = &GeneralGeographyListType;
2886                         GeopositionListAltID = &GeneralGeographyListAltID;
2887                         GeopositionListPID = &GeneralGeographyListPID;
2888                         GeopositionListTokens = &GeneralGeographyListTokens;
2889                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2890                         GeopositionListPref = &GeneralGeographyListPref;        
2891                         break;
2892                 case PROPERTY_HOME:
2893                         GeopositionList = &HomeGeographyList;
2894                         GeopositionListType = &HomeGeographyListType;
2895                         GeopositionListAltID = &HomeGeographyListAltID;
2896                         GeopositionListPID = &HomeGeographyListPID;
2897                         GeopositionListTokens = &HomeGeographyListTokens;
2898                         GeopositionListMediatype = &HomeGeographyListMediatype;
2899                         GeopositionListPref = &HomeGeographyListPref;   
2900                         break;
2901                 case PROPERTY_WORK:
2902                         GeopositionList = &BusinessGeographyList;
2903                         GeopositionListType = &BusinessGeographyListType;
2904                         GeopositionListAltID = &BusinessGeographyListAltID;
2905                         GeopositionListPID = &BusinessGeographyListPID;
2906                         GeopositionListTokens = &BusinessGeographyListTokens;
2907                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2908                         GeopositionListPref = &BusinessGeographyListPref;
2909                         break;
2910         }
2911         
2912         intPrevValue = 4;
2913         
2914         std::map<int,int>::iterator SLiter;
2915         wxString PropertyData;
2916         wxString PropertyName;
2917         wxString PropertyValue;
2918         wxString PropertyTokens;
2919         bool FirstToken = TRUE;
2920         
2921         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2922         intiter != SplitPoints.end(); ++intiter){
2923         
2924                 SLiter = SplitLength.find(intiter->first);
2925         
2926                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2927                 
2928                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2929                 PropertyName = PropertyElement.GetNextToken();                          
2930                 PropertyValue = PropertyElement.GetNextToken();
2931                 
2932                 intPrevValue = intiter->second;
2933                 
2934                 CaptureString(&PropertyValue, FALSE);
2935                 
2936                 // Process properties.
2937                 
2938                 if (PropertyName == wxT("ALTID")){
2940                         GeopositionListAltID->erase(*GeographicCount);
2941                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2942                 
2943                 } else if (PropertyName == wxT("PID")){
2945                         GeopositionListPID->erase(*GeographicCount);
2946                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2947                 
2948                 } else if (PropertyName == wxT("MEDIATYPE")){
2950                         GeopositionListMediatype->erase(*GeographicCount);
2951                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2952                 
2953                 } else if (PropertyName == wxT("PREF")){
2954                         
2955                         int PriorityNumber = 0;
2956                         bool ValidNumber = TRUE;
2957                         
2958                         try{
2959                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2960                         }
2961                         
2962                         catch(std::invalid_argument &e){
2963                                 ValidNumber = FALSE;
2964                         }
2966                         if (ValidNumber == TRUE){
2968                                 GeopositionListPref->erase(*GeographicCount);
2969                                 GeopositionListPref->insert(std::make_pair(*GeographicCount, PriorityNumber));
2971                         }
2972                 
2973                 } else {
2974                 
2975                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2976                         
2977                                 if (FirstToken == TRUE){
2978                                 
2979                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2980                                         FirstToken = FALSE;
2981                                 
2982                                 } else {
2983                                 
2984                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2985                                 
2986                                 }
2987                         
2988                         }
2989                 
2990                 }
2991         
2992         }
2993                 
2994         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2995         
2996         // Add the name token data.
2997         
2998         if (!PropertyTokens.IsEmpty()){
2999         
3000                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
3001         
3002         }
3006 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
3008         size_t intPropertyLen = PropertySeg1.Len();
3009         std::map<int, int> SplitPoints;
3010         std::map<int, int> SplitLength;
3011         std::map<int, int>::iterator SLiter;                    
3012         wxString PropertyData;
3013         wxString PropertyName;
3014         wxString PropertyValue;
3015         wxString PropertyTokens;
3016         wxString RelatedType;
3017         wxString RelatedTypeOriginal;                   
3018         wxString RelatedName;
3019         bool FirstToken = TRUE;                 
3020         int intSplitsFound = 0;
3021         int intSplitSize = 0;
3022         int intPrevValue = 9;
3023         int intPref = 0;
3024         long ListCtrlIndex;
3025         
3026         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3027         
3028         intPrevValue = 8;
3029         
3030         // Look for type before continuing.
3031         
3032         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3033         intiter != SplitPoints.end(); ++intiter){
3034         
3035                 SLiter = SplitLength.find(intiter->first);
3036         
3037                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3038                 
3039                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3040                 PropertyName = PropertyElement.GetNextToken();                          
3041                 PropertyValue = PropertyElement.GetNextToken();
3042                 
3043                 intPrevValue = intiter->second;
3044                 
3045                 // Process these.
3046                 
3047                 RelatedTypeOriginal = PropertyValue;
3048                 
3049                 if (PropertyName == wxT("TYPE")){
3050                 
3051                         if (PropertyValue == wxT("contact")){
3053                                 RelatedType = _("Contact");
3055                         } else if (PropertyValue == wxT("acquaintance")){
3057                                 RelatedType = _("Acquaintance");
3059                         } else if (PropertyValue == wxT("friend")){
3061                                 RelatedType = _("Friend");
3063                         } else if (PropertyValue == wxT("met")){
3065                                 RelatedType = _("Met");
3067                         } else if (PropertyValue == wxT("co-worker")){
3069                                 RelatedType = _("Co-worker");
3071                         } else if (PropertyValue == wxT("colleague")){
3073                                 RelatedType = _("Colleague");
3075                         } else if (PropertyValue == wxT("co-resident")){
3077                                 RelatedType = _("Co-resident");
3079                         } else if (PropertyValue == wxT("neighbor")){
3081                                 RelatedType = _("Neighbour");
3083                         } else if (PropertyValue == wxT("child")){
3085                                 RelatedType = _("Child");
3087                         } else if (PropertyValue == wxT("parent")){
3089                                 RelatedType = _("Parent");
3091                         } else if (PropertyValue == wxT("sibling")){
3093                                 RelatedType = _("Sibling");
3095                         } else if (PropertyValue == wxT("spouse")){
3097                                 RelatedType = _("Spouse");
3099                         } else if (PropertyValue == wxT("kin")){
3101                                 RelatedType = _("Kin");
3103                         } else if (PropertyValue == wxT("muse")){
3105                                 RelatedType = _("Muse");
3107                         } else if (PropertyValue == wxT("crush")){
3109                                 RelatedType = _("Crush");
3111                         } else if (PropertyValue == wxT("date")){
3113                                 RelatedType = _("Date");
3115                         } else if (PropertyValue == wxT("sweetheart")){
3117                                 RelatedType = _("Sweetheart");
3119                         } else if (PropertyValue == wxT("me")){
3121                                 RelatedType = _("Me");
3123                         } else if (PropertyValue == wxT("agent")){
3125                                 RelatedType = _("Agent");
3127                         } else if (PropertyValue == wxT("emergency")){
3129                                 RelatedType = _("Emergency");
3131                         } else {
3133                                 RelatedType = PropertyValue;
3135                         }
3136                 
3137                 }
3138         
3139         }
3140         
3141         intPrevValue = 8;                       
3142         
3143         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3144         intiter != SplitPoints.end(); ++intiter){
3145         
3146                 SLiter = SplitLength.find(intiter->first);
3147         
3148                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3149                 
3150                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3151                 PropertyName = PropertyElement.GetNextToken();                          
3152                 PropertyValue = PropertyElement.GetNextToken();
3153                 
3154                 intPrevValue = intiter->second;
3155                 
3156                 // Process properties.
3157                 
3158                 size_t intPropertyValueLen = PropertyValue.Len();
3159                 
3160                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3161                         
3162                         PropertyValue.Trim();
3163                         PropertyValue.RemoveLast();
3164                         
3165                 }                               
3166                 
3167                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3168                         
3169                         PropertyValue.Remove(0, 1);
3170                         
3171                 }
3172                 
3173                 CaptureString(&PropertyValue, FALSE);
3174                         
3175                 if (PropertyName == wxT("ALTID")){
3177                         GeneralRelatedListAltID.erase(*RelatedCount);
3178                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3179                 
3180                 } else if (PropertyName == wxT("PID")){
3182                         GeneralRelatedListPID.erase(*RelatedCount);
3183                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3184                 
3185                 } else if (PropertyName == wxT("PREF")){
3186                         
3187                         int PriorityNumber = 0;
3188                         bool ValidNumber = TRUE;
3189                         
3190                         try{
3191                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3192                         }
3193                         
3194                         catch(std::invalid_argument &e){
3195                                 ValidNumber = FALSE;
3196                         }
3198                         if (ValidNumber == TRUE){
3200                                 GeneralRelatedListPref.erase(*RelatedCount);
3201                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3203                         }
3204                 
3205                 } else if (PropertyName == wxT("LANGUAGE")){
3206                 
3207                         GeneralRelatedListLanguage.erase(*RelatedCount);
3208                         GeneralRelatedListLanguage.insert(std::make_pair(*RelatedCount, PropertyValue));
3209                 
3210                 } else if (PropertyName != wxT("TYPE")) {
3211                 
3212                         // Something else we don't know about so append
3213                         // to the tokens variable.
3214                 
3215                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3216                 
3217                                 if (FirstToken == TRUE){
3218                         
3219                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3220                                         FirstToken = FALSE;
3221                         
3222                                 } else {
3223                         
3224                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3225                         
3226                                 }
3227                 
3228                         }
3229                 
3230                 }
3231         
3232         }                                       
3233         
3234         // Add the data to the General/Home/Work address variables.
3235                                 
3236         GeneralRelatedList.erase(*RelatedCount);
3237         GeneralRelatedListRelType.erase(*RelatedCount);
3238         GeneralRelatedListType.erase(*RelatedCount);
3239         GeneralRelatedListTokens.erase(*RelatedCount);
3240         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3241         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3242         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3243         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3247 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3249         std::map<int, int> SplitPoints;
3250         std::map<int, int> SplitLength;
3251         std::map<int, int>::iterator SLiter;                    
3252         wxString PropertyData;
3253         wxString PropertyName;
3254         wxString PropertyValue;
3255         wxString PropertyTokens;
3256         bool FirstToken = TRUE;
3257         int intPrevValue = 5;
3258         int intPref = 0;                        
3259         int intType = 0;
3260         long ListCtrlIndex;
3261         
3262         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3263         
3264         intPrevValue = 4;
3265         
3266         PropertyType PropType = PROPERTY_NONE;
3267                 
3268         // Look for type before continuing.
3269         
3270         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3271         
3272         // Setup the pointers.
3273         
3274         std::map<int, wxString> *WebsiteList = NULL;
3275         std::map<int, wxString> *WebsiteListAltID = NULL;
3276         std::map<int, wxString> *WebsiteListPID = NULL;
3277         std::map<int, wxString> *WebsiteListType = NULL;
3278         std::map<int, wxString> *WebsiteListTokens = NULL;
3279         std::map<int, wxString> *WebsiteListMediatype = NULL;
3280         std::map<int, int> *WebsiteListPref = NULL;
3281         
3282         // Setup blank lines for later on.
3283         
3284         switch(PropType){
3285                 case PROPERTY_NONE:
3286                         WebsiteList = &GeneralWebsiteList;
3287                         WebsiteListType = &GeneralWebsiteListType;
3288                         WebsiteListAltID = &GeneralWebsiteListAltID;
3289                         WebsiteListPID = &GeneralWebsiteListPID;
3290                         WebsiteListTokens = &GeneralWebsiteListTokens;
3291                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3292                         WebsiteListPref = &GeneralWebsiteListPref;      
3293                         break;
3294                 case PROPERTY_HOME:
3295                         WebsiteList = &HomeWebsiteList;
3296                         WebsiteListType = &HomeWebsiteListType;
3297                         WebsiteListAltID = &HomeWebsiteListAltID;
3298                         WebsiteListPID = &HomeWebsiteListPID;
3299                         WebsiteListTokens = &HomeWebsiteListTokens;
3300                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3301                         WebsiteListPref = &HomeWebsiteListPref; 
3302                         break;
3303                 case PROPERTY_WORK:
3304                         WebsiteList = &BusinessWebsiteList;
3305                         WebsiteListType = &BusinessWebsiteListType;
3306                         WebsiteListAltID = &BusinessWebsiteListAltID;
3307                         WebsiteListPID = &BusinessWebsiteListPID;
3308                         WebsiteListTokens = &BusinessWebsiteListTokens;
3309                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3310                         WebsiteListPref = &BusinessWebsiteListPref;
3311                         break;
3312         }
3313         
3314         intPrevValue = 4;
3315         
3316         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3317         intiter != SplitPoints.end(); ++intiter){
3318         
3319                 SLiter = SplitLength.find(intiter->first);
3320         
3321                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3322                 
3323                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3324                 PropertyName = PropertyElement.GetNextToken();                          
3325                 PropertyValue = PropertyElement.GetNextToken();
3326                 
3327                 intPrevValue = intiter->second;
3328                 
3329                 // Process properties.
3330                 
3331                 size_t intPropertyValueLen = PropertyValue.Len();
3332                 
3333                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3334                         
3335                         PropertyValue.Trim();
3336                         PropertyValue.RemoveLast();
3337                         
3338                 }                               
3339                 
3340                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3341                         
3342                         PropertyValue.Remove(0, 1);
3343                         
3344                 }
3345                 
3346                 CaptureString(&PropertyValue, FALSE);
3347                 
3348                 if (PropertyName == wxT("ALTID")){
3350                         WebsiteListAltID->erase(*URLCount);
3351                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3352                 
3353                 } else if (PropertyName == wxT("PID")){
3355                         WebsiteListPID->erase(*URLCount);
3356                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3357                         
3358                 } else if (PropertyName == wxT("PREF")){
3359                         
3360                         int PriorityNumber = 0;
3361                         bool ValidNumber = TRUE;
3362                         
3363                         try{
3364                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3365                         }
3366                         
3367                         catch(std::invalid_argument &e){
3368                                 ValidNumber = FALSE;
3369                         }
3371                         if (ValidNumber == TRUE){
3373                                 WebsiteListPref->erase(*URLCount);
3374                                 WebsiteListPref->insert(std::make_pair(*URLCount, PriorityNumber));
3376                         }
3377                                         
3378                 } else if (PropertyName == wxT("MEDIATYPE")){
3379                 
3380                         WebsiteListMediatype->erase(*URLCount);
3381                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3382                 
3383                 } else {
3384                 
3385                         // Something else we don't know about so append
3386                         // to the tokens variable.
3387                 
3388                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3389                 
3390                                 if (FirstToken == TRUE){
3391                         
3392                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3393                                         FirstToken = FALSE;
3394                         
3395                                 } else {
3396                         
3397                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3398                         
3399                                 }
3400                 
3401                         }
3402                 
3403                 }
3404         
3405         }
3406         
3407         // Add the data to the General/Home/Work address variables.
3408         
3409         CaptureString(&PropertySeg2, FALSE);
3410                         
3411         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3412         
3413         if (!PropertyTokens.IsEmpty()){
3414         
3415                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3416                         
3417         }
3418         
3421 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3423         std::map<int, int> SplitPoints;
3424         std::map<int, int> SplitLength;
3425         std::map<int, int>::iterator SLiter;                    
3426         wxString PropertyData;
3427         wxString PropertyName;
3428         wxString PropertyValue;
3429         wxString PropertyTokens;
3430         bool FirstToken = TRUE;
3431         int intPrevValue = 7;
3432         int intPref = 0;                        
3433         int intType = 0;
3434         long ListCtrlIndex;
3435         
3436         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3437         
3438         intPrevValue = 6;
3439         
3440         PropertyType PropType = PROPERTY_NONE;
3441                 
3442         // Look for type before continuing.
3443         
3444         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3445         
3446         // Setup the pointers.
3447         
3448         std::map<int, wxString> *TitleList = NULL;
3449         std::map<int, wxString> *TitleListAltID = NULL;
3450         std::map<int, wxString> *TitleListPID = NULL;
3451         std::map<int, wxString> *TitleListType = NULL;
3452         std::map<int, wxString> *TitleListTokens = NULL;
3453         std::map<int, wxString> *TitleListLanguage = NULL;
3454         std::map<int, int> *TitleListPref = NULL;
3455         
3456         // Setup blank lines for later on.
3457         
3458         switch(PropType){
3459                 case PROPERTY_NONE:
3460                         TitleList = &GeneralTitleList;
3461                         TitleListType = &GeneralTitleListType;
3462                         TitleListAltID = &GeneralTitleListAltID;
3463                         TitleListPID = &GeneralTitleListPID;
3464                         TitleListTokens = &GeneralTitleListTokens;
3465                         TitleListLanguage = &GeneralTitleListLanguage;
3466                         TitleListPref = &GeneralTitleListPref;  
3467                         break;
3468                 case PROPERTY_HOME:
3469                         TitleList = &HomeTitleList;
3470                         TitleListType = &HomeTitleListType;
3471                         TitleListAltID = &HomeTitleListAltID;
3472                         TitleListPID = &HomeTitleListPID;
3473                         TitleListTokens = &HomeTitleListTokens;
3474                         TitleListLanguage = &HomeTitleListLanguage;
3475                         TitleListPref = &HomeTitleListPref;     
3476                         break;
3477                 case PROPERTY_WORK:
3478                         TitleList = &BusinessTitleList;
3479                         TitleListType = &BusinessTitleListType;
3480                         TitleListAltID = &BusinessTitleListAltID;
3481                         TitleListPID = &BusinessTitleListPID;
3482                         TitleListTokens = &BusinessTitleListTokens;
3483                         TitleListLanguage = &BusinessTitleListLanguage; 
3484                         TitleListPref = &BusinessTitleListPref;
3485                         break;
3486         }
3488         intPrevValue = 6;
3489                 
3490         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3491         intiter != SplitPoints.end(); ++intiter){
3492         
3493                 SLiter = SplitLength.find(intiter->first);
3494         
3495                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3496                 
3497                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3498                 PropertyName = PropertyElement.GetNextToken();                          
3499                 PropertyValue = PropertyElement.GetNextToken();
3500                 
3501                 intPrevValue = intiter->second;
3502                 
3503                 // Process properties.
3504                 
3505                 size_t intPropertyValueLen = PropertyValue.Len();
3506                 
3507                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3508                         
3509                         PropertyValue.Trim();
3510                         PropertyValue.RemoveLast();
3511                         
3512                 }                               
3513                 
3514                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3515                         
3516                         PropertyValue.Remove(0, 1);
3517                         
3518                 }                               
3519                 
3520                 CaptureString(&PropertyValue, FALSE);
3521                 
3522                 if (PropertyName == wxT("ALTID")){
3523                 
3524                         TitleListAltID->erase(*TitleCount);
3525                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3526                 
3527                 } else if (PropertyName == wxT("PID")){
3529                         TitleListPID->erase(*TitleCount);
3530                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3531                 
3532                 } else if (PropertyName == wxT("PREF")){
3533                                 
3534                         int PriorityNumber = 0;
3535                         bool ValidNumber = TRUE;
3536                         
3537                         try{
3538                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3539                         }
3540                         
3541                         catch(std::invalid_argument &e){
3542                                 ValidNumber = FALSE;
3543                         }
3545                         if (ValidNumber == TRUE){
3547                                 TitleListPref->erase(*TitleCount);
3548                                 TitleListPref->insert(std::make_pair(*TitleCount, PriorityNumber));
3550                         }
3551                                         
3552                 } else if (PropertyName == wxT("LANGUAGE")){
3553                 
3554                         TitleListLanguage->erase(*TitleCount);
3555                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3556                 
3557                 } else {
3558                 
3559                         // Something else we don't know about so append
3560                         // to the tokens variable.
3561                 
3562                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3563                 
3564                                 if (FirstToken == TRUE){
3565                         
3566                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3567                                         FirstToken = FALSE;
3568                         
3569                                 } else {
3570                         
3571                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3572                         
3573                                 }
3574                 
3575                         }
3576                 
3577                 }
3578         
3579         }
3580         
3581         // Add the data to the General/Home/Work address variables.
3582         
3583         CaptureString(&PropertySeg2, FALSE);
3585         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3586         
3587         if (!PropertyTokens.IsEmpty()){
3588         
3589                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3590                         
3591         }
3595 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3597         std::map<int, int> SplitPoints;
3598         std::map<int, int> SplitLength;
3599         std::map<int, int>::iterator SLiter;                    
3600         wxString PropertyData;
3601         wxString PropertyName;
3602         wxString PropertyValue;
3603         wxString PropertyTokens;
3604         bool FirstToken = TRUE;
3605         int intPrevValue = 6;
3606         int intPref = 0;                        
3607         int intType = 0;
3608         long ListCtrlIndex;
3609         
3610         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3611         
3612         intPrevValue = 5;
3613         
3614         PropertyType PropType = PROPERTY_NONE;
3615                 
3616         // Look for type before continuing.
3617         
3618         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3619         
3620         // Setup the pointers.
3621         
3622         std::map<int, wxString> *RoleList = NULL;
3623         std::map<int, wxString> *RoleListAltID = NULL;
3624         std::map<int, wxString> *RoleListPID = NULL;
3625         std::map<int, wxString> *RoleListType = NULL;
3626         std::map<int, wxString> *RoleListTokens = NULL;
3627         std::map<int, wxString> *RoleListLanguage = NULL;
3628         std::map<int, int> *RoleListPref = NULL;
3629         
3630         // Setup blank lines for later on.
3631         
3632         switch(PropType){
3633                 case PROPERTY_NONE:
3634                         RoleList = &GeneralRoleList;
3635                         RoleListType = &GeneralRoleListType;
3636                         RoleListAltID = &GeneralRoleListAltID;
3637                         RoleListPID = &GeneralRoleListPID;
3638                         RoleListTokens = &GeneralRoleListTokens;
3639                         RoleListLanguage = &GeneralRoleListLanguage;
3640                         RoleListPref = &GeneralRoleListPref;    
3641                         break;
3642                 case PROPERTY_HOME:
3643                         RoleList = &HomeRoleList;
3644                         RoleListType = &HomeRoleListType;
3645                         RoleListAltID = &HomeRoleListAltID;
3646                         RoleListPID = &HomeRoleListPID;
3647                         RoleListTokens = &HomeRoleListTokens;
3648                         RoleListLanguage = &HomeRoleListLanguage;
3649                         RoleListPref = &HomeRoleListPref;       
3650                         break;
3651                 case PROPERTY_WORK:
3652                         RoleList = &BusinessRoleList;
3653                         RoleListType = &BusinessRoleListType;
3654                         RoleListAltID = &BusinessRoleListAltID;
3655                         RoleListPID = &BusinessRoleListPID;
3656                         RoleListTokens = &BusinessRoleListTokens;
3657                         RoleListLanguage = &BusinessRoleListLanguage;   
3658                         RoleListPref = &BusinessRoleListPref;
3659                         break;
3660         }
3662         intPrevValue = 5;
3663                 
3664         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3665         intiter != SplitPoints.end(); ++intiter){
3666         
3667                 SLiter = SplitLength.find(intiter->first);
3668         
3669                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3670                 
3671                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3672                 PropertyName = PropertyElement.GetNextToken();                          
3673                 PropertyValue = PropertyElement.GetNextToken();
3674                 
3675                 intPrevValue = intiter->second;
3676                 
3677                 // Process properties.
3678                 
3679                 size_t intPropertyValueLen = PropertyValue.Len();
3680                 
3681                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3682                         
3683                         PropertyValue.Trim();
3684                         PropertyValue.RemoveLast();
3685                         
3686                 }                               
3687                 
3688                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3689                         
3690                         PropertyValue.Remove(0, 1);
3691                         
3692                 }                               
3693                 
3694                 CaptureString(&PropertyValue, FALSE);
3695                 
3696                 if (PropertyName == wxT("ALTID")){
3697                 
3698                         RoleListAltID->erase(*RoleCount);
3699                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3700                 
3701                 } else if (PropertyName == wxT("PID")){
3703                         RoleListPID->erase(*RoleCount);
3704                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3705                 
3706                 } else if (PropertyName == wxT("PREF")){
3707                                 
3708                         int PriorityNumber = 0;
3709                         bool ValidNumber = TRUE;
3710                         
3711                         try{
3712                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3713                         }
3714                         
3715                         catch(std::invalid_argument &e){
3716                                 ValidNumber = FALSE;
3717                         }
3719                         if (ValidNumber == TRUE){
3721                                 RoleListPref->erase(*RoleCount);
3722                                 RoleListPref->insert(std::make_pair(*RoleCount, PriorityNumber));
3724                         }
3725                                         
3726                 } else if (PropertyName == wxT("LANGUAGE")){
3727                 
3728                         RoleListLanguage->erase(*RoleCount);
3729                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3730                 
3731                 } else {
3732                 
3733                         // Something else we don't know about so append
3734                         // to the tokens variable.
3735                 
3736                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3737                 
3738                                 if (FirstToken == TRUE){
3739                         
3740                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3741                                         FirstToken = FALSE;
3742                         
3743                                 } else {
3744                         
3745                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3746                         
3747                                 }
3748                 
3749                         }
3750                 
3751                 }
3752         
3753         }
3754         
3755         // Add the data to the General/Home/Work address variables.
3756         
3757         CaptureString(&PropertySeg2, FALSE);
3759         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3760         
3761         if (!PropertyTokens.IsEmpty()){
3762         
3763                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3764                         
3765         }
3769 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3771         std::map<int, int> SplitPoints;
3772         std::map<int, int> SplitLength;
3773         std::map<int, int>::iterator SLiter;                    
3774         wxString PropertyData;
3775         wxString PropertyName;
3776         wxString PropertyValue;
3777         wxString PropertyTokens;
3778         bool FirstToken = TRUE;
3779         int intPrevValue = 5;
3780         int intPref = 0;                        
3781         int intType = 0;
3782         long ListCtrlIndex;
3783         
3784         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3785         
3786         intPrevValue = 4;
3787         
3788         PropertyType PropType = PROPERTY_NONE;
3789                 
3790         // Look for type before continuing.
3791         
3792         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3793         
3794         // Setup the pointers.
3795         
3796         std::map<int, wxString> *OrganisationsList = NULL;
3797         std::map<int, wxString> *OrganisationsListAltID = NULL;
3798         std::map<int, wxString> *OrganisationsListPID = NULL;
3799         std::map<int, wxString> *OrganisationsListType = NULL;
3800         std::map<int, wxString> *OrganisationsListTokens = NULL;
3801         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3802         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3803         std::map<int, int> *OrganisationsListPref = NULL;
3804         
3805         // Setup blank lines for later on.
3806         
3807         switch(PropType){
3808                 case PROPERTY_NONE:
3809                         OrganisationsList = &GeneralOrganisationsList;
3810                         OrganisationsListType = &GeneralOrganisationsListType;
3811                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3812                         OrganisationsListPID = &GeneralOrganisationsListPID;
3813                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3814                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3815                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3816                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3817                         break;
3818                 case PROPERTY_HOME:
3819                         OrganisationsList = &HomeOrganisationsList;
3820                         OrganisationsListType = &HomeOrganisationsListType;
3821                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3822                         OrganisationsListPID = &HomeOrganisationsListPID;
3823                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3824                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3825                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3826                         OrganisationsListPref = &HomeOrganisationsListPref;     
3827                         break;
3828                 case PROPERTY_WORK:
3829                         OrganisationsList = &BusinessOrganisationsList;
3830                         OrganisationsListType = &BusinessOrganisationsListType;
3831                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3832                         OrganisationsListPID = &BusinessOrganisationsListPID;
3833                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3834                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3835                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3836                         OrganisationsListPref = &BusinessOrganisationsListPref;
3837                         break;
3838         }
3840         intPrevValue = 4;
3841                 
3842         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3843         intiter != SplitPoints.end(); ++intiter){
3844         
3845                 SLiter = SplitLength.find(intiter->first);
3846         
3847                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3848                 
3849                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3850                 PropertyName = PropertyElement.GetNextToken();                          
3851                 PropertyValue = PropertyElement.GetNextToken();
3852                 
3853                 intPrevValue = intiter->second;
3854                 
3855                 // Process properties.
3856                 
3857                 size_t intPropertyValueLen = PropertyValue.Len();
3858                 
3859                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3860                         
3861                         PropertyValue.Trim();
3862                         PropertyValue.RemoveLast();
3863                         
3864                 }                               
3865                 
3866                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3867                         
3868                         PropertyValue.Remove(0, 1);
3869                         
3870                 }                               
3871                 
3872                 CaptureString(&PropertyValue, FALSE);
3873                 
3874                 if (PropertyName == wxT("ALTID")){
3875                 
3876                         OrganisationsListAltID->erase(*OrganisationCount);
3877                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3878                 
3879                 } else if (PropertyName == wxT("PID")){
3881                         OrganisationsListPID->erase(*OrganisationCount);
3882                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3883                 
3884                 } else if (PropertyName == wxT("SORT-AS")){
3886                         OrganisationsListSortAs->erase(*OrganisationCount);
3887                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3888                 
3889                 } else if (PropertyName == wxT("PREF")){
3890                                 
3891                         int PriorityNumber = 0;
3892                         bool ValidNumber = TRUE;
3893                         
3894                         try{
3895                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3896                         }
3897                         
3898                         catch(std::invalid_argument &e){
3899                                 ValidNumber = FALSE;
3900                         }
3902                         if (ValidNumber == TRUE){
3904                                 OrganisationsListPref->erase(*OrganisationCount);
3905                                 OrganisationsListPref->insert(std::make_pair(*OrganisationCount, PriorityNumber));
3907                         }
3908                                         
3909                 } else if (PropertyName == wxT("LANGUAGE")){
3910                 
3911                         OrganisationsListLanguage->erase(*OrganisationCount);
3912                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3913                 
3914                 } else {
3915                 
3916                         // Something else we don't know about so append
3917                         // to the tokens variable.
3918                 
3919                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3920                 
3921                                 if (FirstToken == TRUE){
3922                         
3923                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3924                                         FirstToken = FALSE;
3925                         
3926                                 } else {
3927                         
3928                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3929                         
3930                                 }
3931                 
3932                         }
3933                 
3934                 }
3935         
3936         }
3937         
3938         // Add the data to the General/Home/Work address variables.
3939         
3940         CaptureString(&PropertySeg2, FALSE);
3942         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3943         
3944         if (!PropertyTokens.IsEmpty()){
3945         
3946                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3947                         
3948         }
3952 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3954         std::map<int, int> SplitPoints;
3955         std::map<int, int> SplitLength;
3956         std::map<int, int>::iterator SLiter;                    
3957         wxString PropertyData;
3958         wxString PropertyName;
3959         wxString PropertyValue;
3960         wxString PropertyTokens;
3961         bool FirstToken = TRUE;
3962         int intPrevValue = 6;
3963         int intPref = 0;                        
3964         int intType = 0;
3965         long ListCtrlIndex;
3966         
3967         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3968         
3969         intPrevValue = 5;
3970         
3971         PropertyType PropType = PROPERTY_NONE;
3972                 
3973         // Look for type before continuing.
3974         
3975         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3976         
3977         // Setup the pointers.
3978         
3979         std::map<int, wxString> *NoteList = NULL;
3980         std::map<int, wxString> *NoteListAltID = NULL;
3981         std::map<int, wxString> *NoteListPID = NULL;
3982         std::map<int, wxString> *NoteListType = NULL;
3983         std::map<int, wxString> *NoteListTokens = NULL;
3984         std::map<int, wxString> *NoteListLanguage = NULL;
3985         std::map<int, int> *NoteListPref = NULL;
3986         
3987         // Setup blank lines for later on.
3988         
3989         switch(PropType){
3990                 case PROPERTY_NONE:
3991                         NoteList = &GeneralNoteList;
3992                         NoteListType = &GeneralNoteListType;
3993                         NoteListAltID = &GeneralNoteListAltID;
3994                         NoteListPID = &GeneralNoteListPID;
3995                         NoteListTokens = &GeneralNoteListTokens;
3996                         NoteListLanguage = &GeneralNoteListLanguage;
3997                         NoteListPref = &GeneralNoteListPref;    
3998                         break;
3999                 case PROPERTY_HOME:
4000                         NoteList = &HomeNoteList;
4001                         NoteListType = &HomeNoteListType;
4002                         NoteListAltID = &HomeNoteListAltID;
4003                         NoteListPID = &HomeNoteListPID;
4004                         NoteListTokens = &HomeNoteListTokens;
4005                         NoteListLanguage = &HomeNoteListLanguage;
4006                         NoteListPref = &HomeNoteListPref;       
4007                         break;
4008                 case PROPERTY_WORK:
4009                         NoteList = &BusinessNoteList;
4010                         NoteListType = &BusinessNoteListType;
4011                         NoteListAltID = &BusinessNoteListAltID;
4012                         NoteListPID = &BusinessNoteListPID;
4013                         NoteListTokens = &BusinessNoteListTokens;
4014                         NoteListLanguage = &BusinessNoteListLanguage;   
4015                         NoteListPref = &BusinessNoteListPref;
4016                         break;
4017         }
4019         intPrevValue = 5;
4020                 
4021         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4022         intiter != SplitPoints.end(); ++intiter){
4023         
4024                 SLiter = SplitLength.find(intiter->first);
4025         
4026                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4027                 
4028                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4029                 PropertyName = PropertyElement.GetNextToken();                          
4030                 PropertyValue = PropertyElement.GetNextToken();
4031                 
4032                 intPrevValue = intiter->second;
4033                 
4034                 // Process properties.
4035                 
4036                 size_t intPropertyValueLen = PropertyValue.Len();
4037                 
4038                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4039                         
4040                         PropertyValue.Trim();
4041                         PropertyValue.RemoveLast();
4042                         
4043                 }                               
4044                 
4045                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4046                         
4047                         PropertyValue.Remove(0, 1);
4048                         
4049                 }                               
4050                 
4051                 CaptureString(&PropertyValue, FALSE);
4052                 
4053                 if (PropertyName == wxT("ALTID")){
4054                 
4055                         NoteListAltID->erase(*NoteCount);
4056                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
4057                 
4058                 } else if (PropertyName == wxT("PID")){
4060                         NoteListPID->erase(*NoteCount);
4061                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
4062                 
4063                 } else if (PropertyName == wxT("PREF")){
4064                                 
4065                         int PriorityNumber = 0;
4066                         bool ValidNumber = TRUE;
4067                         
4068                         try{
4069                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4070                         }
4071                         
4072                         catch(std::invalid_argument &e){
4073                                 ValidNumber = FALSE;
4074                         }
4076                         if (ValidNumber == TRUE){
4078                                 NoteListPref->erase(*NoteCount);
4079                                 NoteListPref->insert(std::make_pair(*NoteCount, PriorityNumber));
4081                         }
4082                                         
4083                 } else if (PropertyName == wxT("LANGUAGE")){
4084                 
4085                         NoteListLanguage->erase(*NoteCount);
4086                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
4087                 
4088                 } else {
4089                 
4090                         // Something else we don't know about so append
4091                         // to the tokens variable.
4092                 
4093                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4094                 
4095                                 if (FirstToken == TRUE){
4096                         
4097                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4098                                         FirstToken = FALSE;
4099                         
4100                                 } else {
4101                         
4102                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4103                         
4104                                 }
4105                 
4106                         }
4107                 
4108                 }
4109         
4110         }
4111         
4112         // Add the data to the General/Home/Work address variables.
4113         
4114         CaptureString(&PropertySeg2, FALSE);
4116         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
4117         
4118         if (!PropertyTokens.IsEmpty()){
4119         
4120                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
4121                         
4122         }
4126 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
4128         std::map<int, int> SplitPoints;
4129         std::map<int, int> SplitLength;
4130         std::map<int, int>::iterator SLiter;                    
4131         wxString PropertyData;
4132         wxString PropertyName;
4133         wxString PropertyValue;
4134         wxString PropertyTokens;
4135         bool FirstToken = TRUE;
4136         int intPrevValue = 12;
4137         int intPref = 0;                        
4138         int intType = 0;
4139         long ListCtrlIndex;
4140         
4141         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4142         
4143         intPrevValue = 11;
4144         
4145         PropertyType PropType = PROPERTY_NONE;
4146                 
4147         // Look for type before continuing.
4148         
4149         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4150         
4151         // Setup blank lines for later on.
4152         
4153         switch(PropType){
4154                 case PROPERTY_NONE:
4155                         break;
4156                 case PROPERTY_HOME:
4157                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4158                         break;
4159                 case PROPERTY_WORK:
4160                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4161                         break;
4162         }
4164         intPrevValue = 11;
4165                 
4166         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4167         intiter != SplitPoints.end(); ++intiter){
4168         
4169                 SLiter = SplitLength.find(intiter->first);
4170         
4171                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4172                 
4173                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4174                 PropertyName = PropertyElement.GetNextToken();                          
4175                 PropertyValue = PropertyElement.GetNextToken();
4176                 
4177                 intPrevValue = intiter->second;
4178                 
4179                 // Process properties.
4180                 
4181                 size_t intPropertyValueLen = PropertyValue.Len();
4182                 
4183                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4184                         
4185                         PropertyValue.Trim();
4186                         PropertyValue.RemoveLast();
4187                         
4188                 }                               
4189                 
4190                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4191                         
4192                         PropertyValue.Remove(0, 1);
4193                         
4194                 }                               
4195                 
4196                 CaptureString(&PropertyValue, FALSE);
4197                 
4198                 if (PropertyName == wxT("ALTID")){
4199                 
4200                         CategoriesListAltID.erase(*CategoryCount);
4201                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4202                 
4203                 } else if (PropertyName == wxT("PID")){
4205                         CategoriesListPID.erase(*CategoryCount);
4206                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4207                 
4208                 } else if (PropertyName == wxT("PREF")){
4209                                 
4210                         int PriorityNumber = 0;
4211                         bool ValidNumber = TRUE;
4212                         
4213                         try{
4214                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4215                         }
4216                         
4217                         catch(std::invalid_argument &e){
4218                                 ValidNumber = FALSE;
4219                         }
4221                         if (ValidNumber == TRUE){
4223                                 CategoriesListPref.erase(*CategoryCount);
4224                                 CategoriesListPref.insert(std::make_pair(*CategoryCount, PriorityNumber));
4226                         }
4227                                         
4228                 } else if (PropertyName == wxT("LANGUAGE")){
4229                 
4230                         CategoriesListLanguage.erase(*CategoryCount);
4231                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4232                 
4233                 } else {
4234                 
4235                         // Something else we don't know about so append
4236                         // to the tokens variable.
4237                 
4238                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4239                 
4240                                 if (FirstToken == TRUE){
4241                         
4242                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4243                                         FirstToken = FALSE;
4244                         
4245                                 } else {
4246                         
4247                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4248                         
4249                                 }
4250                 
4251                         }
4252                 
4253                 }
4254         
4255         }
4256         
4257         // Deal with multiple categories.
4258         
4259         int intOrigCatCount = *CategoryCount;
4260         bool FirstCategoryProcessed = TRUE;
4261         bool AfterFirstToken = FALSE;
4262         int intSplitSize = 0;
4263         int intSplitsFound = 0;
4264         int intSplitSeek = 0;
4265         int intPropertyLen = PropertySeg2.Len();
4266         
4267         SplitPoints.clear();
4268         SplitLength.clear();
4269         intPrevValue = 0;
4270         
4271         for (int i = 0; i <= intPropertyLen; i++){
4272         
4273                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4274         
4275                         continue;
4276                 
4277                 }
4278         
4279                 intSplitSize++;
4280         
4281                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4282         
4283                         if (AfterFirstToken == TRUE){
4284                 
4285                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4286                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4287                         
4288                         } else {
4289                         
4290                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4291                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4292                                 AfterFirstToken = TRUE;
4294                         }
4296                         intSplitsFound++;
4297                         intSplitSeek = i;
4298                         intSplitSize = 0;                               
4299         
4300                 }                       
4301         
4302         }
4303         
4304         if (SplitPoints.size() > 0){
4305         
4306                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4307                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4308         
4309         }
4310         
4311         if (SplitPoints.size() == 0){
4312         
4313                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4314         
4315                 if (!PropertyTokens.IsEmpty()){
4316                 
4317                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4318                 
4319                 }
4320         
4321         }
4322         
4323         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4324         intiter != SplitPoints.end(); ++intiter){
4325         
4326                 SLiter = SplitLength.find(intiter->first);
4327         
4328                 intPrevValue = intiter->second;
4329         
4330                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4331                 
4332                 // Add the data to the General/Home/Work address variables.
4333         
4334                 // Trim any whitespace from the start and end.
4335         
4336                 PropertyData = PropertyData.Trim(FALSE);
4337                 PropertyData = PropertyData.Trim(TRUE); 
4338         
4339                 CaptureString(&PropertyData, FALSE);
4340                 
4341                 if (FirstCategoryProcessed == TRUE){
4342                 
4343                         FirstCategoryProcessed = FALSE;
4344                         
4345                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4346         
4347                         if (!PropertyTokens.IsEmpty()){
4348                 
4349                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4350                 
4351                         }
4352                         
4353                         continue;
4354                 
4355                 } else {
4357                         (*CategoryCount)++;
4358                         
4359                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4360                 
4361                         if (!PropertyTokens.IsEmpty()){
4362                 
4363                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4364                 
4365                         }
4366                 
4367                 }
4368                 
4369                 // Copy the properties to each of the categories (if it exists).
4370                 
4371                 if (!PropertyTokens.IsEmpty()){
4372                 
4373                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4374                 
4375                 }
4376                 
4377                 // Check if ALTID was used.
4378                 
4379                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4380                 
4381                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4382                 
4383                 }
4384                 
4385                 // Check if PID was used.
4386                 
4387                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4388                 
4389                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4390                 
4391                 }
4392         
4393                 // Check if PREF was used.
4394         
4395                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4396                 
4397                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4398                 
4399                 }
4400                 
4401                 // Check if LANGUAGE was used.
4402                 
4403                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4404                 
4405                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4406                 
4407                 }
4408                 
4409                 // Check if TYPE was used.
4410                 
4411                 switch(PropType){
4412                         case PROPERTY_NONE:
4413                                 break;
4414                         case PROPERTY_HOME:
4415                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4416                                 break;
4417                         case PROPERTY_WORK:
4418                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4419                                 break;
4420                 }
4421         
4422         }
4426 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4428         size_t intPropertyLen = PropertySeg1.Len();
4429         std::map<int, int> SplitPoints;
4430         std::map<int, int> SplitLength;
4431         std::map<int, int>::iterator SLiter;                    
4432         wxString PropertyData;
4433         wxString PropertyName;
4434         wxString PropertyValue;
4435         wxString PropertyTokens;
4436         bool FirstToken = TRUE;
4437         int intSplitsFound = 0;
4438         int intSplitSize = 0;
4439         int intPrevValue = 7;
4440         int intPref = 0;                        
4441         int intType = 0;
4442         
4443         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4444         
4445         intPrevValue = 6;
4446         
4447         PropertyType PropType = PROPERTY_NONE;
4448                 
4449         // Look for type before continuing.
4450         
4451         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4453         intPrevValue = 6;
4455         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4456         intiter != SplitPoints.end(); ++intiter){
4457         
4458                 SLiter = SplitLength.find(intiter->first);
4459         
4460                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4461                 
4462                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4463                 PropertyName = PropertyElement.GetNextToken();                          
4464                 PropertyValue = PropertyElement.GetNextToken();
4465                 
4466                 intPrevValue = intiter->second;
4467                 
4468                 // Process properties.
4469                 
4470                 size_t intPropertyValueLen = PropertyValue.Len();
4471                 
4472                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4473                         
4474                         PropertyValue.Trim();
4475                         PropertyValue.RemoveLast();
4476                         
4477                 }                               
4478                 
4479                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4480                         
4481                         PropertyValue.Remove(0, 1);
4482                         
4483                 }
4484                 
4485                 CaptureString(&PropertyValue, FALSE);
4486                 
4487                 if (PropertyName == wxT("ALTID")){
4489                         PicturesListAltID.erase(*PhotoCount);
4490                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4491                 
4492                 } else if (PropertyName == wxT("PID")){
4494                         PicturesListPID.erase(*PhotoCount);
4495                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4496                 
4497                 } else if (PropertyName == wxT("PREF")){
4498                         
4499                         int PriorityNumber = 0;
4500                         bool ValidNumber = TRUE;
4501                         
4502                         try{
4503                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4504                         }
4505                         
4506                         catch(std::invalid_argument &e){
4507                                 ValidNumber = FALSE;
4508                         }
4510                         if (ValidNumber == TRUE){
4512                                 PicturesListPref.erase(*PhotoCount);
4513                                 PicturesListPref.insert(std::make_pair(*PhotoCount, PriorityNumber));
4515                         }
4516                 
4517                 } else if (PropertyName == wxT("MEDIATYPE")){
4518                 
4519                         PicturesListMediatype.erase(*PhotoCount);
4520                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4521                                         
4522                 } else {
4523                 
4524                         // Something else we don't know about so append
4525                         // to the tokens variable.
4526                         
4527                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4528                         
4529                                 if (FirstToken == TRUE){
4530                                 
4531                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4532                                         FirstToken = FALSE;
4533                                 
4534                                 } else {
4535                                 
4536                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4537                                 
4538                                 }
4539                         
4540                         }
4541                 
4542                 }
4543         
4544         }       
4545         
4546         intPropertyLen = PropertySeg2.Len();
4547         SplitPoints.clear();
4548         SplitLength.clear();
4549         intSplitsFound = 0;
4550         intSplitSize = 0;
4551         intPrevValue = 0;                       
4552         
4553         CaptureString(&PropertySeg2, FALSE);
4554         
4555         for (int i = 0; i <= intPropertyLen; i++){
4557                 intSplitSize++;
4558         
4559                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4560         
4561                         intSplitsFound++;
4562                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4563                         
4564                         if (intSplitsFound == 6){ 
4565                         
4566                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4567                                 break; 
4568                                 
4569                         } else {
4570                         
4571                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4572                         
4573                         }
4574                         
4575                         intSplitSize = 0;                                       
4576         
4577                 }
4579         }
4580         
4581         wxString wxSPhotoURI;
4582         wxString wxSPhotoMIME;
4583         wxString wxSPhotoEncoding;
4584         wxString wxSPhotoData;
4585         std::string base64enc;
4586         
4587         if (intSplitsFound == 0){
4588         
4589         } else {
4590         
4591                 std::map<int, int>::iterator striter;
4592         
4593                 striter = SplitLength.find(1);
4594         
4595                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4596         
4597                 while (wSTDataType.HasMoreTokens() == TRUE){
4598                 
4599                         wxSPhotoURI = wSTDataType.GetNextToken();
4600                         wxSPhotoMIME = wSTDataType.GetNextToken();
4601                         break;
4602                 
4603                 }                       
4604         
4605                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4606         
4607                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4608                 
4609                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4610                         wxSPhotoData = wSTDataInfo.GetNextToken();
4611                         base64enc = wxSPhotoData.mb_str();
4612                         break;
4613                 
4614                 }
4615         
4616         }
4617         
4618         // Add the data to the General/Home/Work address variables.
4619         
4620         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4621         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4622         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4623         
4624         switch(PropType){
4625                 case PROPERTY_NONE:
4626                         break;
4627                 case PROPERTY_HOME:
4628                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4629                         break;
4630                 case PROPERTY_WORK:
4631                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4632                         break;
4633         }
4634         
4635         if (!PropertyTokens.IsEmpty()){
4637                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4638         
4639         }
4643 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4645         size_t intPropertyLen = PropertySeg1.Len();
4646         std::map<int, int> SplitPoints;
4647         std::map<int, int> SplitLength;
4648         std::map<int, int>::iterator SLiter;                    
4649         wxString PropertyData;
4650         wxString PropertyName;
4651         wxString PropertyValue;
4652         wxString PropertyTokens;
4653         bool FirstToken = TRUE;
4654         int intSplitsFound = 0;
4655         int intSplitSize = 0;
4656         int intPrevValue = 6;
4657         int intPref = 0;                        
4658         int intType = 0;
4659         
4660         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4661         
4662         intPrevValue = 5;
4663         
4664         PropertyType PropType = PROPERTY_NONE;
4665                 
4666         // Look for type before continuing.
4667         
4668         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4670         intPrevValue = 5;
4672         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4673         intiter != SplitPoints.end(); ++intiter){
4674         
4675                 SLiter = SplitLength.find(intiter->first);
4676         
4677                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4678                 
4679                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4680                 PropertyName = PropertyElement.GetNextToken();                          
4681                 PropertyValue = PropertyElement.GetNextToken();
4682                 
4683                 intPrevValue = intiter->second;
4684                 
4685                 // Process properties.
4686                 
4687                 size_t intPropertyValueLen = PropertyValue.Len();
4688                 
4689                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4690                         
4691                         PropertyValue.Trim();
4692                         PropertyValue.RemoveLast();
4693                         
4694                 }                               
4695                 
4696                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4697                         
4698                         PropertyValue.Remove(0, 1);
4699                         
4700                 }
4701                 
4702                 CaptureString(&PropertyValue, FALSE);
4703                 
4704                 if (PropertyName == wxT("ALTID")){
4706                         LogosListAltID.erase(*LogoCount);
4707                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4708                 
4709                 } else if (PropertyName == wxT("PID")){
4711                         LogosListPID.erase(*LogoCount);
4712                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4713                 
4714                 } else if (PropertyName == wxT("PREF")){
4715                         
4716                         int PriorityNumber = 0;
4717                         bool ValidNumber = TRUE;
4718                         
4719                         try{
4720                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4721                         }
4722                         
4723                         catch(std::invalid_argument &e){
4724                                 ValidNumber = FALSE;
4725                         }
4727                         if (ValidNumber == TRUE){
4729                                 LogosListPref.erase(*LogoCount);
4730                                 LogosListPref.insert(std::make_pair(*LogoCount, PriorityNumber));
4732                         }
4733                 
4734                 } else if (PropertyName == wxT("MEDIATYPE")){
4735                 
4736                         LogosListMediatype.erase(*LogoCount);
4737                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4738                                         
4739                 } else {
4740                 
4741                         // Something else we don't know about so append
4742                         // to the tokens variable.
4743                         
4744                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4745                         
4746                                 if (FirstToken == TRUE){
4747                                 
4748                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4749                                         FirstToken = FALSE;
4750                                 
4751                                 } else {
4752                                 
4753                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4754                                 
4755                                 }
4756                         
4757                         }
4758                 
4759                 }
4760         
4761         }       
4762         
4763         intPropertyLen = PropertySeg2.Len();
4764         SplitPoints.clear();
4765         SplitLength.clear();
4766         intSplitsFound = 0;
4767         intSplitSize = 0;
4768         intPrevValue = 0;                       
4769         
4770         CaptureString(&PropertySeg2, FALSE);
4771         
4772         for (int i = 0; i <= intPropertyLen; i++){
4774                 intSplitSize++;
4775         
4776                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4777         
4778                         intSplitsFound++;
4779                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4780                         
4781                         if (intSplitsFound == 6){ 
4782                         
4783                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4784                                 break; 
4785                                 
4786                         } else {
4787                         
4788                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4789                         
4790                         }
4791                         
4792                         intSplitSize = 0;                                       
4793         
4794                 }
4796         }
4797         
4798         wxString wxSPhotoURI;
4799         wxString wxSPhotoMIME;
4800         wxString wxSPhotoEncoding;
4801         wxString wxSPhotoData;
4802         std::string base64enc;
4803         
4804         if (intSplitsFound == 0){
4805         
4806         } else {
4807         
4808                 std::map<int, int>::iterator striter;
4809         
4810                 striter = SplitLength.find(1);
4811         
4812                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4813         
4814                 while (wSTDataType.HasMoreTokens() == TRUE){
4815                 
4816                         wxSPhotoURI = wSTDataType.GetNextToken();
4817                         wxSPhotoMIME = wSTDataType.GetNextToken();
4818                         break;
4819                 
4820                 }                       
4821         
4822                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4823         
4824                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4825                 
4826                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4827                         wxSPhotoData = wSTDataInfo.GetNextToken();
4828                         base64enc = wxSPhotoData.mb_str();
4829                         break;
4830                 
4831                 }
4832         
4833         }
4834         
4835         // Add the data to the General/Home/Work address variables.
4836         
4837         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4838         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4839         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4840         
4841         switch(PropType){
4842                 case PROPERTY_NONE:
4843                         break;
4844                 case PROPERTY_HOME:
4845                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4846                         break;
4847                 case PROPERTY_WORK:
4848                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4849                         break;
4850         }
4851         
4852         if (!PropertyTokens.IsEmpty()){
4854                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4855         
4856         }
4860 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4862         size_t intPropertyLen = PropertySeg1.Len();
4863         std::map<int, int> SplitPoints;
4864         std::map<int, int> SplitLength;
4865         std::map<int, int>::iterator SLiter;                    
4866         wxString PropertyData;
4867         wxString PropertyName;
4868         wxString PropertyValue;
4869         wxString PropertyTokens;
4870         bool FirstToken = TRUE;
4871         int intSplitsFound = 0;
4872         int intSplitSize = 0;
4873         int intPrevValue = 7;
4874         int intPref = 0;                        
4875         int intType = 0;
4876         
4877         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4878         
4879         intPrevValue = 6;
4880         
4881         PropertyType PropType = PROPERTY_NONE;
4882         
4883         // Look for type before continuing.                     
4885         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4887         intPrevValue = 6;
4889         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4890         intiter != SplitPoints.end(); ++intiter){
4891         
4892                 SLiter = SplitLength.find(intiter->first);
4893         
4894                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4895                 
4896                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4897                 PropertyName = PropertyElement.GetNextToken();                          
4898                 PropertyValue = PropertyElement.GetNextToken();
4899                 
4900                 intPrevValue = intiter->second;
4901                 
4902                 // Process properties.
4903                 
4904                 size_t intPropertyValueLen = PropertyValue.Len();
4905                 
4906                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4907                         
4908                         PropertyValue.Trim();
4909                         PropertyValue.RemoveLast();
4910                         
4911                 }                               
4912                 
4913                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4914                         
4915                         PropertyValue.Remove(0, 1);
4916                         
4917                 }                       
4918                 
4919                 CaptureString(&PropertyValue, FALSE);
4920                 
4921                 if (PropertyName == wxT("ALTID")){
4923                         SoundsListAltID.erase(*SoundCount);
4924                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4925                 
4926                 } else if (PropertyName == wxT("PID")){
4928                         SoundsListPID.erase(*SoundCount);
4929                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4930                 
4931                 } else if (PropertyName == wxT("PREF")){
4932                         
4933                         int PriorityNumber = 0;
4934                         bool ValidNumber = TRUE;
4935                         
4936                         try{
4937                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
4938                         }
4939                         
4940                         catch(std::invalid_argument &e){
4941                                 ValidNumber = FALSE;
4942                         }
4944                         if (ValidNumber == TRUE){
4946                                 SoundsListPref.erase(*SoundCount);
4947                                 SoundsListPref.insert(std::make_pair(*SoundCount, PriorityNumber));
4949                         }
4950                 
4951                 } else if (PropertyName == wxT("MEDIATYPE")){
4952                 
4953                         SoundsListMediatype.erase(*SoundCount);
4954                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4956                 } else if (PropertyName == wxT("LANGUAGE")){
4957                 
4958                         SoundsListLanguage.erase(*SoundCount);
4959                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4961                 } else {
4962                 
4963                         // Something else we don't know about so append
4964                         // to the tokens variable.
4965                         
4966                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4967                         
4968                                 if (FirstToken == TRUE){
4969                                 
4970                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4971                                         FirstToken = FALSE;
4972                                 
4973                                 } else {
4974                                 
4975                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4976                                 
4977                                 }
4978                         
4979                         }
4980                 
4981                 }
4982         
4983         }       
4984         
4985         intPropertyLen = PropertySeg2.Len();
4986         SplitPoints.clear();
4987         SplitLength.clear();
4988         intSplitsFound = 0;
4989         intSplitSize = 0;
4990         intPrevValue = 0;
4991         
4992         CaptureString(&PropertySeg2, FALSE);
4993         
4994         for (int i = 0; i <= intPropertyLen; i++){
4996                 intSplitSize++;
4997         
4998                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4999         
5000                         intSplitsFound++;
5001                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5002                         
5003                         if (intSplitsFound == 6){ 
5004                         
5005                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5006                                 break; 
5007                                 
5008                         } else {
5009                         
5010                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5011                         
5012                         }
5013                         
5014                         intSplitSize = 0;                                       
5015         
5016                 }
5018         }
5019         
5020         wxString wxSSoundURI;
5021         wxString wxSSoundMIME;
5022         wxString wxSSoundEncoding;
5023         wxString wxSSoundData;
5024         std::string base64enc;
5025         
5026         if (intSplitsFound == 0){
5027         
5028         } else {
5029         
5030                 std::map<int, int>::iterator striter;
5031         
5032                 striter = SplitLength.find(1);
5033         
5034                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5035         
5036                 while (wSTDataType.HasMoreTokens() == TRUE){
5037                 
5038                         wxSSoundURI = wSTDataType.GetNextToken();
5039                         wxSSoundMIME = wSTDataType.GetNextToken();
5040                         break;
5041                 
5042                 }                       
5043         
5044                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5045         
5046                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5047                 
5048                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
5049                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
5050                         base64enc = wxSSoundData.mb_str();
5051                         break;
5052                 
5053                 }
5054         
5055         }
5056         
5057         // Add the data to the General/Home/Work address variables.
5058                 
5059         switch(PropType){
5060                 case PROPERTY_NONE:
5061                         break;
5062                 case PROPERTY_HOME:
5063                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
5064                         break;
5065                 case PROPERTY_WORK:
5066                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
5067                         break;
5068         }
5069         
5070         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
5071         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
5072         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
5073         
5074         if (!PropertyTokens.IsEmpty()){
5075         
5076                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
5077         
5078         }
5079         
5082 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
5084         size_t intPropertyLen = PropertySeg1.Len();
5085         std::map<int, int> SplitPoints;
5086         std::map<int, int> SplitLength;
5087         std::map<int, int>::iterator SLiter;                    
5088         wxString PropertyData;
5089         wxString PropertyName;
5090         wxString PropertyValue;
5091         wxString PropertyTokens;
5092         bool FirstToken = TRUE;
5093         int intSplitsFound = 0;
5094         int intSplitSize = 0;
5095         int intPrevValue = 8;
5096         int intPref = 0;                        
5097         int intType = 0;
5098         
5099         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5100         
5101         intPrevValue = 7;
5102         
5103         PropertyType PropType = PROPERTY_NONE;
5104         
5105         // Look for type before continuing.                     
5107         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5109         intPrevValue = 7;
5111         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5112         intiter != SplitPoints.end(); ++intiter){
5113         
5114                 SLiter = SplitLength.find(intiter->first);
5115         
5116                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5117                 
5118                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5119                 PropertyName = PropertyElement.GetNextToken();                          
5120                 PropertyValue = PropertyElement.GetNextToken();
5121                 
5122                 intPrevValue = intiter->second;
5123                 
5124                 // Process properties.
5125                 
5126                 size_t intPropertyValueLen = PropertyValue.Len();
5127                 
5128                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5129                         
5130                         PropertyValue.Trim();
5131                         PropertyValue.RemoveLast();
5132                         
5133                 }                               
5134                 
5135                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5136                         
5137                         PropertyValue.Remove(0, 1);
5138                         
5139                 }                       
5140                 
5141                 CaptureString(&PropertyValue, FALSE);
5142                 
5143                 if (PropertyName == wxT("ALTID")){
5145                         CalendarListAltID.erase(*CalURICount);
5146                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
5147                 
5148                 } else if (PropertyName == wxT("PID")){
5150                         CalendarListPID.erase(*CalURICount);
5151                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
5152                 
5153                 } else if (PropertyName == wxT("PREF")){
5154                         
5155                         int PriorityNumber = 0;
5156                         bool ValidNumber = TRUE;
5157                         
5158                         try{
5159                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5160                         }
5161                         
5162                         catch(std::invalid_argument &e){
5163                                 ValidNumber = FALSE;
5164                         }
5166                         if (ValidNumber == TRUE){
5168                                 CalendarListPref.erase(*CalURICount);
5169                                 CalendarListPref.insert(std::make_pair(*CalURICount, PriorityNumber));
5171                         }
5172                 
5173                 } else if (PropertyName == wxT("MEDIATYPE")){
5174                 
5175                         CalendarListMediatype.erase(*CalURICount);
5176                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
5178                 } else {
5179                 
5180                         // Something else we don't know about so append
5181                         // to the tokens variable.
5182                         
5183                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5184                         
5185                                 if (FirstToken == TRUE){
5186                                 
5187                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5188                                         FirstToken = FALSE;
5189                                 
5190                                 } else {
5191                                 
5192                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5193                                 
5194                                 }
5195                         
5196                         }
5197                 
5198                 }
5199         
5200         }       
5201         
5202         intPropertyLen = PropertySeg2.Len();
5203         SplitPoints.clear();
5204         SplitLength.clear();
5205         intSplitsFound = 0;
5206         intSplitSize = 0;
5207         intPrevValue = 0;
5208         
5209         CaptureString(&PropertySeg2, FALSE);
5210         
5211         // Add the data to the General/Home/Work address variables.
5212                 
5213         switch(PropType){
5214                 case PROPERTY_NONE:
5215                         break;
5216                 case PROPERTY_HOME:
5217                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
5218                         break;
5219                 case PROPERTY_WORK:
5220                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
5221                         break;
5222         }
5223         
5224         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
5225         
5226         if (!PropertyTokens.IsEmpty()){
5227         
5228                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
5229         
5230         }
5234 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
5236         size_t intPropertyLen = PropertySeg1.Len();
5237         std::map<int, int> SplitPoints;
5238         std::map<int, int> SplitLength;
5239         std::map<int, int>::iterator SLiter;                    
5240         wxString PropertyData;
5241         wxString PropertyName;
5242         wxString PropertyValue;
5243         wxString PropertyTokens;
5244         bool FirstToken = TRUE;
5245         int intSplitsFound = 0;
5246         int intSplitSize = 0;
5247         int intPrevValue = 8;
5248         int intPref = 0;                        
5249         int intType = 0;
5250         
5251         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5252         
5253         intPrevValue = 7;
5254         
5255         PropertyType PropType = PROPERTY_NONE;
5256         
5257         // Look for type before continuing.                     
5259         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5261         intPrevValue = 7;
5263         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5264         intiter != SplitPoints.end(); ++intiter){
5265         
5266                 SLiter = SplitLength.find(intiter->first);
5267         
5268                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5269                 
5270                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5271                 PropertyName = PropertyElement.GetNextToken();                          
5272                 PropertyValue = PropertyElement.GetNextToken();
5273                 
5274                 intPrevValue = intiter->second;
5275                 
5276                 // Process properties.
5277                 
5278                 size_t intPropertyValueLen = PropertyValue.Len();
5279                 
5280                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5281                         
5282                         PropertyValue.Trim();
5283                         PropertyValue.RemoveLast();
5284                         
5285                 }                               
5286                 
5287                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5288                         
5289                         PropertyValue.Remove(0, 1);
5290                         
5291                 }                       
5292                 
5293                 CaptureString(&PropertyValue, FALSE);
5294                 
5295                 if (PropertyName == wxT("ALTID")){
5297                         CalendarRequestListAltID.erase(*CalAdrURICount);
5298                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5299                 
5300                 } else if (PropertyName == wxT("PID")){
5302                         CalendarRequestListPID.erase(*CalAdrURICount);
5303                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5304                 
5305                 } else if (PropertyName == wxT("PREF")){
5306                         
5307                         int PriorityNumber = 0;
5308                         bool ValidNumber = TRUE;
5309                         
5310                         try{
5311                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5312                         }
5313                         
5314                         catch(std::invalid_argument &e){
5315                                 ValidNumber = FALSE;
5316                         }
5318                         if (ValidNumber == TRUE){
5320                                 CalendarRequestListPref.erase(*CalAdrURICount);
5321                                 CalendarRequestListPref.insert(std::make_pair(*CalAdrURICount, PriorityNumber));
5323                         }
5324                 
5325                 } else if (PropertyName == wxT("MEDIATYPE")){
5326                 
5327                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5328                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5330                 } else {
5331                 
5332                         // Something else we don't know about so append
5333                         // to the tokens variable.
5334                         
5335                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5336                         
5337                                 if (FirstToken == TRUE){
5338                                 
5339                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5340                                         FirstToken = FALSE;
5341                                 
5342                                 } else {
5343                                 
5344                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5345                                 
5346                                 }
5347                         
5348                         }
5349                 
5350                 }
5351         
5352         }       
5353         
5354         intPropertyLen = PropertySeg2.Len();
5355         SplitPoints.clear();
5356         SplitLength.clear();
5357         intSplitsFound = 0;
5358         intSplitSize = 0;
5359         intPrevValue = 0;
5360         
5361         CaptureString(&PropertySeg2, FALSE);
5362         
5363         // Add the data to the General/Home/Work address variables.
5364                 
5365         switch(PropType){
5366                 case PROPERTY_NONE:
5367                         break;
5368                 case PROPERTY_HOME:
5369                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5370                         break;
5371                 case PROPERTY_WORK:
5372                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5373                         break;
5374         }
5375         
5376         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5377         
5378         if (!PropertyTokens.IsEmpty()){
5379         
5380                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5381         
5382         }       
5383         
5386 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5388         size_t intPropertyLen = PropertySeg1.Len();
5389         std::map<int, int> SplitPoints;
5390         std::map<int, int> SplitLength;
5391         std::map<int, int>::iterator SLiter;                    
5392         wxString PropertyData;
5393         wxString PropertyName;
5394         wxString PropertyValue;
5395         wxString PropertyTokens;
5396         bool FirstToken = TRUE;
5397         int intSplitsFound = 0;
5398         int intSplitSize = 0;
5399         int intPrevValue = 7;
5400         int intPref = 0;                        
5401         int intType = 0;
5402         
5403         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5404         
5405         intPrevValue = 6;
5406         
5407         PropertyType PropType = PROPERTY_NONE;
5408         
5409         // Look for type before continuing.                     
5411         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5413         intPrevValue = 6;
5415         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5416         intiter != SplitPoints.end(); ++intiter){
5417         
5418                 SLiter = SplitLength.find(intiter->first);
5419         
5420                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5421                 
5422                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5423                 PropertyName = PropertyElement.GetNextToken();                          
5424                 PropertyValue = PropertyElement.GetNextToken();
5425                 
5426                 intPrevValue = intiter->second;
5427                 
5428                 // Process properties.
5429                 
5430                 size_t intPropertyValueLen = PropertyValue.Len();
5431                 
5432                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5433                         
5434                         PropertyValue.Trim();
5435                         PropertyValue.RemoveLast();
5436                         
5437                 }                               
5438                 
5439                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5440                         
5441                         PropertyValue.Remove(0, 1);
5442                         
5443                 }                       
5444                 
5445                 CaptureString(&PropertyValue, FALSE);
5446                 
5447                 if (PropertyName == wxT("ALTID")){
5449                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5450                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5451                 
5452                 } else if (PropertyName == wxT("PID")){
5454                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5455                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5456                 
5457                 } else if (PropertyName == wxT("PREF")){
5458                         
5459                         int PriorityNumber = 0;
5460                         bool ValidNumber = TRUE;
5461                         
5462                         try{
5463                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5464                         }
5465                         
5466                         catch(std::invalid_argument &e){
5467                                 ValidNumber = FALSE;
5468                         }
5470                         if (ValidNumber == TRUE){
5472                                 FreeBusyListPref.erase(*FreeBusyAddressCount);
5473                                 FreeBusyListPref.insert(std::make_pair(*FreeBusyAddressCount, PriorityNumber));
5475                         }
5476                 
5477                 } else if (PropertyName == wxT("MEDIATYPE")){
5478                 
5479                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5480                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5482                 } else {
5483                 
5484                         // Something else we don't know about so append
5485                         // to the tokens variable.
5486                         
5487                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5488                         
5489                                 if (FirstToken == TRUE){
5490                                 
5491                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5492                                         FirstToken = FALSE;
5493                                 
5494                                 } else {
5495                                 
5496                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5497                                 
5498                                 }
5499                         
5500                         }
5501                 
5502                 }
5503         
5504         }       
5505         
5506         intPropertyLen = PropertySeg2.Len();
5507         SplitPoints.clear();
5508         SplitLength.clear();
5509         intSplitsFound = 0;
5510         intSplitSize = 0;
5511         intPrevValue = 0;
5512         
5513         CaptureString(&PropertySeg2, FALSE);
5514         
5515         // Add the data to the General/Home/Work address variables.
5516                 
5517         switch(PropType){
5518                 case PROPERTY_NONE:
5519                         break;
5520                 case PROPERTY_HOME:
5521                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5522                         break;
5523                 case PROPERTY_WORK:
5524                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5525                         break;
5526         }
5527         
5528         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5529         
5530         if (!PropertyTokens.IsEmpty()){
5531         
5532                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5533         
5534         }
5538 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5540         size_t intPropertyLen = PropertySeg1.Len();
5541         std::map<int, int> SplitPoints;
5542         std::map<int, int> SplitLength;
5543         std::map<int, int>::iterator SLiter;                    
5544         wxString PropertyData;
5545         wxString PropertyName;
5546         wxString PropertyValue;
5547         wxString PropertyTokens;
5548         bool FirstToken = TRUE;
5549         int intSplitsFound = 0;
5550         int intSplitSize = 0;
5551         int intPrevValue = 5;
5552         int intPref = 0;                        
5553         int intType = 0;
5554         long ListCtrlIndex;
5555         
5556         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5557         
5558         intPrevValue = 4;
5559         
5560         PropertyType PropType = PROPERTY_NONE;
5561         
5562         // Look for type before continuing.
5564         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5566         intPrevValue = 4;
5568         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5569         intiter != SplitPoints.end(); ++intiter){
5570         
5571                 SLiter = SplitLength.find(intiter->first);
5572         
5573                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5574                 
5575                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5576                 PropertyName = PropertyElement.GetNextToken();                          
5577                 PropertyValue = PropertyElement.GetNextToken();
5578                 
5579                 intPrevValue = intiter->second;
5580                 
5581                 // Process properties.
5582                 
5583                 size_t intPropertyValueLen = PropertyValue.Len();
5584                 
5585                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5586                         
5587                         PropertyValue.Trim();
5588                         PropertyValue.RemoveLast();
5589                         
5590                 }                               
5591                 
5592                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5593                         
5594                         PropertyValue.Remove(0, 1);
5595                         
5596                 }                               
5597                 
5598                 if (PropertyName == wxT("ALTID")){
5600                         KeyListAltID.erase(*KeyCount);
5601                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5602                 
5603                 } else if (PropertyName == wxT("PID")){
5605                         KeyListPID.erase(*KeyCount);
5606                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5607                 
5608                 } else if (PropertyName == wxT("PREF")){
5609                         
5610                         int PriorityNumber = 0;
5611                         bool ValidNumber = TRUE;
5612                         
5613                         try{
5614                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
5615                         }
5616                         
5617                         catch(std::invalid_argument &e){
5618                                 ValidNumber = FALSE;
5619                         }
5621                         if (ValidNumber == TRUE){
5623                                 KeyListPref.erase(*KeyCount);
5624                                 KeyListPref.insert(std::make_pair(*KeyCount, PriorityNumber));
5626                         }
5627                 
5628                 } else {
5629                 
5630                         // Something else we don't know about so append
5631                         // to the tokens variable.
5632                         
5633                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5634                         
5635                                 if (FirstToken == TRUE){
5636                                 
5637                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5638                                         FirstToken = FALSE;
5639                                 
5640                                 } else {
5641                                 
5642                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5643                                 
5644                                 }
5645                         
5646                         }
5647                 
5648                 }
5649         
5650         }                               
5651         
5652         intPropertyLen = PropertySeg2.Len();
5653         SplitPoints.clear();
5654         SplitLength.clear();
5655         intSplitsFound = 0;
5656         intSplitSize = 0;
5657         intPrevValue = 0;                       
5658         
5659         for (int i = 0; i <= intPropertyLen; i++){
5661                 intSplitSize++;
5662         
5663                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5664         
5665                         intSplitsFound++;
5666                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5667                         
5668                         if (intSplitsFound == 6){ 
5669                         
5670                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5671                                 break; 
5672                                 
5673                         } else {
5674                         
5675                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5676                         
5677                         }
5678                         
5679                         intSplitSize = 0;                                       
5680         
5681                 }
5683         }
5684         
5685         wxString wxSKeyURI;
5686         wxString wxSKeyMIME;
5687         wxString wxSKeyEncoding;
5688         wxString wxSKeyData;
5689         std::string base64enc;
5690         
5691         if (intSplitsFound == 0){
5692         
5693         } else {
5694         
5695                 std::map<int, int>::iterator striter;
5696         
5697                 striter = SplitLength.find(1);
5698         
5699                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5700         
5701                 while (wSTDataType.HasMoreTokens() == TRUE){
5702                 
5703                         wxSKeyURI = wSTDataType.GetNextToken();
5704                         wxSKeyMIME = wSTDataType.GetNextToken();
5705                         break;
5706                 
5707                 }                       
5708         
5709                 if (wxSKeyURI == wxT("data")){
5710                 
5711                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5712         
5713                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5714                 
5715                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5716                                 wxSKeyData = wSTDataInfo.GetNextToken();
5717                                 break;
5718                 
5719                         }
5720                 
5721                 }
5722         
5723         }
5724         
5725         // Add the data to the General/Home/Work address variables.
5726         
5727         if (wxSKeyURI == wxT("data")){
5728                 
5729                 KeyListDataEncType.erase(*KeyCount);
5730                 KeyListKeyType.erase(*KeyCount);
5731                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5732                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5733                 
5734                 KeyList.erase(*KeyCount);
5735                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5736         
5737         } else {
5738                 
5739                 KeyList.erase(*KeyCount);
5740                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5741         
5742         }
5743         
5744         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5745                 
5746         switch (PropType){
5747                 case PROPERTY_NONE:
5748                         break;
5749                 case PROPERTY_HOME: 
5750                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5751                         break;
5752                 case PROPERTY_WORK: 
5753                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5754                         break;
5755         }
5757         if (!PropertyTokens.IsEmpty()){
5759                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5761         }
5765 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5767         // Split the Vendor three ways.
5768         
5769         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5770         
5771         wxString wxSVNDID;
5772         wxString wxSVNDPropName;
5773         long ListCtrlIndex;                     
5775         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5776         
5777                 wSTVendorDetails.GetNextToken();
5778                 wxSVNDID = wSTVendorDetails.GetNextToken();
5779                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5780                 break;
5781         
5782         }
5783         
5784         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5785         
5786                 // Add the data to the vendor variables.
5787         
5788                 VendorList.erase(*VendorCount);
5789                 VendorListPEN.erase(*VendorCount);
5790                 VendorListElement.erase(*VendorCount);
5791         
5792                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5793                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5794                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5795         
5796         }
5800 void ProcessIntegerValue(ContactDataObject *ContactData,
5801         std::map<int,int> *PrefPtr, 
5802         wxString *PropertyValue, 
5803         int *ItemCount){
5805         int PriorityNumber = 0; 
5806         bool ValidNumber = TRUE;
5807                         
5808         try{
5809                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5810         }
5811                         
5812         catch(std::invalid_argument &e){
5813                 ValidNumber = FALSE;
5814         }
5816         if (ValidNumber == TRUE){
5818                 PrefPtr->erase(*ItemCount);
5819                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5821         }
5825 void SplitValues(wxString *PropertyLine, 
5826         std::map<int,int> *SplitPoints, 
5827         std::map<int,int> *SplitLength, 
5828         int intSize){
5829         
5830         size_t intPropertyLen = PropertyLine->Len();
5831         int intSplitsFound = 0;
5832         int intSplitSize = 0;
5833         int intSplitSeek = 0;
5834         
5835         for (int i = intSize; i <= intPropertyLen; i++){
5837                 intSplitSize++;
5838         
5839                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5840                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5841            
5842                     if (intSplitsFound == 0){
5843             
5844                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5845           
5846                     } else {
5847            
5848                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5849             
5850                     }
5851             
5852                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5853             
5854                     intSplitsFound++;
5855                     intSplitSeek = i;
5856                     intSplitSize = 0;
5857             
5858                 }
5860         }
5862         if (intSplitsFound == 0){
5864                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5865                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5867         } else {
5869                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5870                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5872         }
5876 void CheckType(wxString *PropertySeg1, 
5877         std::map<int,int> *SplitPoints, 
5878         std::map<int,int> *SplitLength, 
5879         int *intPrevValue, 
5880         PropertyType *PropType){
5881         
5882         wxString PropertyData;
5883         wxString PropertyName;
5884         wxString PropertyValue;
5885         std::map<int,int>::iterator SLiter;
5886         
5887         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5888         intiter != SplitPoints->end(); ++intiter){
5889         
5890                 SLiter = SplitLength->find(intiter->first);
5891         
5892                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5893                 
5894                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5895                 PropertyName = PropertyElement.GetNextToken();                          
5896                 PropertyValue = PropertyElement.GetNextToken();
5897                 
5898                 *intPrevValue = intiter->second;
5899                 
5900                 if (PropertyName == wxT("TYPE")){
5901                                 
5902                         if (PropertyValue == wxT("work")){
5903                         
5904                                 *PropType = PROPERTY_WORK;
5905                                                         
5906                         } else if (PropertyValue == wxT("home")){
5908                                 *PropType = PROPERTY_HOME;
5909                                                         
5910                         } else {
5911                         
5912                                 *PropType = PROPERTY_NONE;
5913                         
5914                         }
5915                 
5916                         return;
5917                 
5918                 }
5919         
5920         }
5921         
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