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