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