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