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