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