Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
cda6933e4572d5f30166ffc1ded678b6ca07124d
[xestiaab/.git] / source / contacteditor / cdo / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2016 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("SOUND")) {
379                 
380                         // See frmContactEditor-LoadSound.cpp
381                         
382                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
383                         SoundCount++;
384                         
385                 } else if (Property == wxT("CALURI")){
387                         // See frmContactEditor-LoadCalendar.cpp
388                         
389                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
390                         CalendarCount++;
391                 
392                 } else if (Property == wxT("CALADRURI")){
393                 
394                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
395                         CalendarAddressCount++;
396                 
397                 } else if (Property == wxT("FBURL")){
399                         // See frmContactEditor-LoadCalendar.cpp
401                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
402                         FreeBusyAddressCount++;
404                 } else if (Property == wxT("KEY")){
405                 
406                         // See frmContactEditor-LoadKey.cpp
407                         
408                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
409                         KeyCount++;
410                 
411                 } else if (Property.Mid(0, 3) == wxT("VND")){
412                 
413                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
414                         VendorCount++;
415                 
416                 } else if (Property.Mid(0, 2) == wxT("X-")){
417                         
418                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
419                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
420                         XTokenCount++;
421                 
422                 }
423                 
424         }
425         
426         return CONTACTLOAD_OK;
430 void ContactDataObject::ProcessKind(wxString KindType){
432         if (KindType == wxT("individual")){
433                         
434                 ContactKind = CONTACTKIND_INDIVIDUAL;
435                         
436         } else if (KindType == wxT("group")){
437                         
438                 ContactKind = CONTACTKIND_GROUP;
439                         
440         } else if (KindType == wxT("org")){
441                         
442                 ContactKind = CONTACTKIND_ORGANISATION;
443                         
444         } else if (KindType == wxT("location")){
445                         
446                 ContactKind = CONTACTKIND_LOCATION;
447                         
448         } else {
449                         
450                 ContactKind = CONTACTKIND_NONE;                 
451         }
455 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
457         size_t intPropertyLen = PropertySeg1.Len();
458         std::map<int, int> SplitPoints;
459         std::map<int, int> SplitLength;
460         std::map<int, int>::iterator SLiter;                    
461         wxString PropertyData;
462         wxString PropertyName;
463         wxString PropertyValue;
464         wxString PropertyTokens;
465         bool FirstToken = TRUE;
466         int intSplitsFound = 0;
467         int intSplitSize = 0;
468         int intPrevValue = 5;
469         
470         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
471         
472         intPrevValue = 4;
474         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
475         intiter != SplitPoints.end(); ++intiter){
476         
477                 SLiter = SplitLength.find(intiter->first);
478                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
479                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
480                 intPrevValue = intiter->second;
481                 
482                 // Process properties.
483                 
484                 size_t intPropertyValueLen = PropertyValue.Len();
485                 
486                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
487                         
488                         PropertyValue.Trim();
489                         PropertyValue.RemoveLast();
490                         
491                 }                               
492                 
493                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
494                         
495                         PropertyValue.Remove(0, 1);
496                         
497                 }                       
498                 
499                 CaptureString(&PropertyValue, FALSE);
500                 
501                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
502         
503         }       
504         
505         CaptureString(&PropertySeg2, FALSE);
506         
507         Revision = PropertySeg2;
508         
509         if (!PropertyTokens.IsEmpty()){
510         
511                 RevisionTokens = PropertyTokens;
512         
513         }
518 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
520         size_t intPropertyLen = PropertySeg1.Len();
521         std::map<int, int> SplitPoints;
522         std::map<int, int> SplitLength;
523         std::map<int, int>::iterator SLiter;                    
524         wxString PropertyData;
525         wxString PropertyName;
526         wxString PropertyValue;
527         wxString PropertyTokens;
528         bool FirstToken = TRUE;
529         bool PropertyMatched = FALSE;
530         int intSplitsFound = 0;
531         int intSplitSize = 0;
532         int intPrevValue = 8;
533         
534         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
535         
536         intPrevValue = 7;
537         
538         PropertyType PropType = PROPERTY_NONE;
539         
540         // Look for type before continuing.                     
542         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
544         intPrevValue = 7;
546         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
547         intiter != SplitPoints.end(); ++intiter){
548         
549                 SLiter = SplitLength.find(intiter->first);
550         
551                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
552                 
553                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
554                 
555                 intPrevValue = intiter->second;
556                 
557                 // Process properties.
558                 
559                 size_t intPropertyValueLen = PropertyValue.Len();
560                 
561                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
562                         
563                         PropertyValue.Trim();
564                         PropertyValue.RemoveLast();
565                         
566                 }                               
567                 
568                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
569                         
570                         PropertyValue.Remove(0, 1);
571                         
572                 }                       
573                 
574                 CaptureString(&PropertyValue, FALSE);
575                 
576                 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
577                 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
578                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
579                 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
580                 
581                 if (PropertyMatched == TRUE){
582                 
583                         PropertyMatched = FALSE;
584                         continue;
585                 
586                 }
587                 
588                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
589         
590         }       
591         
592         intPropertyLen = PropertySeg2.Len();
593         SplitPoints.clear();
594         SplitLength.clear();
595         intSplitsFound = 0;
596         intSplitSize = 0;
597         intPrevValue = 0;
598         
599         CaptureString(&PropertySeg2, FALSE);
600         
601         // Add the data to the General/Home/Work address variables.
602                 
603         switch(PropType){
604                 case PROPERTY_NONE:
605                         break;
606                 case PROPERTY_HOME:
607                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
608                         break;
609                 case PROPERTY_WORK:
610                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
611                         break;
612         }
613         
614         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
615         
616         if (!PropertyTokens.IsEmpty()){
617         
618                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
619         
620         }
624 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
626         std::map<int, int> SplitPoints;
627         std::map<int, int> SplitLength;
629         int intPrevValue = 5;
630         
631         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
633         intPrevValue = 4;
634         
635         wxString PropertyName;
636         wxString PropertyValue;
637         wxString PropertyData;
638         wxString PropertyTokens;
639         std::map<int,int>::iterator SLiter;
640         bool FirstToken = TRUE;
641         bool PropertyMatched = FALSE;
642         
643         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
644         intiter != SplitPoints.end(); ++intiter){
645         
646                 SLiter = SplitLength.find(intiter->first);
647                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
648                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
649                 intPrevValue = intiter->second;
650                 
651                 CaptureString(&PropertyValue, FALSE);
652         
653                 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
654                 
655                 if (PropertyMatched == TRUE){
656                 
657                         PropertyMatched = FALSE;
658                         continue;
659                 
660                 }
661                 
662         }
664         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
668 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
670         std::map<int, int> SplitPoints;
671         std::map<int, int> SplitLength;
673         int intPrevValue = 8;
674         
675         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
677         intPrevValue = 7;
678         
679         wxString PropertyName;
680         wxString PropertyValue;
681         wxString PropertyData;
682         wxString PropertyTokens;
683         std::map<int,int>::iterator SLiter;
684         bool FirstToken = TRUE;
685         bool PropertyMatched = FALSE;
686         
687         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
688         intiter != SplitPoints.end(); ++intiter){
689         
690                 SLiter = SplitLength.find(intiter->first);
691                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
692                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
693                 intPrevValue = intiter->second;
694                 
695                 CaptureString(&PropertyValue, FALSE);
696         
697                 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
698                 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
699                 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
700                 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
701                 
702                 if (PropertyMatched == TRUE){
703                 
704                         PropertyMatched = FALSE;
705                         continue;
706                 
707                 }
708                 
709                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
710                 
711         }
713         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
715         if (!PropertyTokens.IsEmpty()){
716         
717                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
718         
719         }
724 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
726         std::map<int, int> SplitPoints;
727         std::map<int, int> SplitLength;
729         int intPrevValue = 4;
730         
731         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
733         intPrevValue = 3;
734         
735         wxString PropertyName;
736         wxString PropertyValue;
737         wxString PropertyData;
738         wxString PropertyTokens;
739         std::map<int,int>::iterator SLiter;
740         bool FirstToken = TRUE;
741         bool PropertyMatched = FALSE;
742         
743         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
744         intiter != SplitPoints.end(); ++intiter){
745         
746                 SLiter = SplitLength.find(intiter->first);
747                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
748                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue); 
749                 intPrevValue = intiter->second;
750                 
751                 CaptureString(&PropertyValue, FALSE);
752                 
753                 if (PropertyName == wxT("TYPE")){
755                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
756                                 PropertyValue == wxT("work") ){
758                                 FullNamesListType.erase(*FNCount);
759                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
760                 
761                         }
762                         
763                         PropertyMatched = TRUE;
764                 
765                 }
766                 
767                 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
768                 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
769                 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
770                 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
771                 
772                 if (PropertyMatched == TRUE){
773                 
774                         PropertyMatched = FALSE;
775                         continue;
776                 
777                 }
778                 
779                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
780         
781         }
783         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
785         if (!PropertyTokens.IsEmpty()){
786         
787                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
788         
789         }
793 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
795         std::map<int, int> SplitPoints;
796         std::map<int, int> SplitLength;
798         int intPrevValue = 3;
799         
800         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
801         
802         intPrevValue = 2;
803         
804         wxString PropertyName;
805         wxString PropertyValue;
806         wxString PropertyData;
807         wxString PropertyTokens;
808         std::map<int,int>::iterator SLiter;
809         bool FirstToken = TRUE;
810         
811         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
812         intiter != SplitPoints.end(); ++intiter){
813         
814                 SLiter = SplitLength.find(intiter->first);
815                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
816                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
817                 intPrevValue = intiter->second;
818                 
819                 CaptureString(&PropertyValue, FALSE);
820                 
821                 if (PropertyName == wxT("ALTID")){
823                         NameAltID = PropertyValue;
824                 
825                 } else if (PropertyName == wxT("LANGUAGE")){
826                 
827                         NameLanguage = PropertyValue;
828                 
829                 } else if (PropertyName == wxT("SORT-AS")){
830                 
831                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
832                                 PropertyValue.Len() >= 3){
833                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
834                         }
835                 
836                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
837                         
838                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
839                         
840                 }
841         
842         }
843         
844         // Split the name data.
845         
846         int intSplitSeek = 0;           
847         int intSplitsFound = 0;
848         int intSplitSize = 0;
849         int intPropertyLen = PropertySeg2.Len();
850         
851         std::map<int,wxString> NameValues;
852         intPrevValue = 0;                                       
853         
854         for (int i = 0; i <= intPropertyLen; i++){
855         
856                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
857                         
858                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
859                         
860                         intSplitSeek = i;
861                         intSplitSeek++;
862                         
863                         if (intSplitsFound == 4){
864                         
865                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
866                                 break;
867                         
868                         }
869                         
870                         intSplitSize = 0;
871                         continue;
872         
873                 }
874                 
875                 intSplitSize++;
877         }
878         
879         // Split the data into several parts.
880                         
881         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
882         iter != NameValues.end(); ++iter){
883         
884                 if (iter->first == 1){
885                 
886                         // Deal with family name.
887                         
888                         NameSurname = iter->second;
889                 
890                 } else if (iter->first == 2){
891                 
892                         // Deal with given names.
893                         
894                         NameForename = iter->second;
895                 
896                 } else if (iter->first == 3){
897                 
898                         // Deal with additional names.
899                         
900                         NameOtherNames = iter->second;
901                 
902                 } else if (iter->first == 4){
903                 
904                         // Deal with honorifix prefixes and suffixes.
906                         NameTitle = iter->second;
907                 
908                         iter++;
909                         
910                         if (iter == NameValues.end()){
911                         
912                                 break;
913                         
914                         }
915                 
916                         NameSuffix = iter->second;
917                 
918                 }
919         
920         }
921         
922         // Add the name token data.
923         
924         if (!PropertyTokens.IsEmpty()){
925         
926                 NameTokens = PropertyTokens;
927         
928         }
932 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
934         size_t intPropertyLen = PropertySeg1.Len();
935         std::map<int, int> SplitPoints;
936         std::map<int, int> SplitLength;
937         std::map<int, int>::iterator SLiter;                    
938         wxString PropertyData;
939         wxString PropertyName;
940         wxString PropertyValue;
941         wxString PropertyTokens;
942         bool FirstToken = TRUE;
943         int intSplitsFound = 0;
944         int intSplitSize = 0;
945         int intPrevValue = 14;
946         
947         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
948         
949         intPrevValue = 13;
951         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
952         intiter != SplitPoints.end(); ++intiter){
953         
954                 SLiter = SplitLength.find(intiter->first);
955                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
956                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
957                 intPrevValue = intiter->second;
958                 
959                 // Process properties.
960                                 
961                 CaptureString(&PropertyValue, FALSE);
962                                         
963                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
964         
965         }       
966         
967         CaptureString(&PropertySeg2, FALSE);
968         
969         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
970         
971         if (!PropertyTokens.IsEmpty()){
972         
973                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
974         
975         }
979 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
981         std::map<int, int> SplitPoints;
982         std::map<int, int> SplitLength;
984         int intPrevValue = 10;
985         
986         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
987         
988         intPrevValue = 9;
989         
990         PropertyType PropType = PROPERTY_NONE;
991         
992         // Look for type before continuing.
993         
994         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
995         
996         intPrevValue = 9;
997         
998         std::map<int, wxString> *NicknamesList = NULL;
999         std::map<int, wxString> *NicknamesListType = NULL;
1000         std::map<int, wxString> *NicknamesListLanguage = NULL;
1001         std::map<int, wxString> *NicknamesListAltID = NULL;
1002         std::map<int, wxString> *NicknamesListPID = NULL;
1003         std::map<int, wxString> *NicknamesListTokens = NULL;            
1004         std::map<int, int> *NicknamesListPref = NULL;
1005         
1006         switch(PropType){
1007                 case PROPERTY_NONE:
1008                         NicknamesList = &GeneralNicknamesList;
1009                         NicknamesListType = &GeneralNicknamesListType;
1010                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1011                         NicknamesListAltID = &GeneralNicknamesListAltID;
1012                         NicknamesListPID = &GeneralNicknamesListPID;
1013                         NicknamesListTokens = &GeneralNicknamesListTokens;
1014                         NicknamesListPref = &GeneralNicknamesListPref;
1015                         break;
1016                 case PROPERTY_HOME:
1017                         NicknamesList = &HomeNicknamesList;
1018                         NicknamesListType = &HomeNicknamesListType;
1019                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1020                         NicknamesListAltID = &HomeNicknamesListAltID;
1021                         NicknamesListPID = &HomeNicknamesListPID;
1022                         NicknamesListTokens = &HomeNicknamesListTokens;
1023                         NicknamesListPref = &HomeNicknamesListPref;
1024                         break;
1025                 case PROPERTY_WORK:
1026                         NicknamesList = &BusinessNicknamesList;
1027                         NicknamesListType = &BusinessNicknamesListType;
1028                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1029                         NicknamesListAltID = &BusinessNicknamesListAltID;
1030                         NicknamesListPID = &BusinessNicknamesListPID;
1031                         NicknamesListTokens = &BusinessNicknamesListTokens;
1032                         NicknamesListPref = &BusinessNicknamesListPref;
1033                         break;
1034         }
1035         
1036         std::map<int, int>::iterator SLiter;    
1037         wxString PropertyData;
1038         wxString PropertyName;
1039         wxString PropertyValue;
1040         wxString PropertyTokens;
1041         bool FirstToken = TRUE;
1042         bool PropertyMatched = FALSE;
1043         
1044         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1045         intiter != SplitPoints.end(); ++intiter){
1046         
1047                 SLiter = SplitLength.find(intiter->first);
1048                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1049                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1050                 intPrevValue = intiter->second;
1051                 
1052                 CaptureString(&PropertyValue, FALSE);
1053                 
1054                 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1055                 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1056                 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1057                 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1058                 
1059                 if (PropertyMatched == TRUE){
1060                 
1061                         PropertyMatched = FALSE;
1062                         continue;
1063                 
1064                 }
1065                 
1066                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1067                 
1068         }
1069         
1070         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1071         
1072         // Add the name token data.
1073         
1074         if (!PropertyTokens.IsEmpty()){
1075         
1076                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1077         
1078         }
1082 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1084         std::map<int, int> SplitPoints;
1085         std::map<int, int> SplitLength;
1086         std::map<int, int>::iterator SLiter;                    
1087         wxString PropertyData;
1088         wxString PropertyName;
1089         wxString PropertyValue;
1090         wxString PropertyTokens;
1091         bool FirstToken = TRUE;
1092         int intPrevValue = 8;
1094         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1096         intPrevValue = 7;                       
1097         
1098         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1099         intiter != SplitPoints.end(); ++intiter){
1100         
1101                 SLiter = SplitLength.find(intiter->first);
1102                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1103                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1104                 intPrevValue = intiter->second;
1105                 
1106                 // Process properties.
1107                 
1108                 size_t intPropertyValueLen = PropertyValue.Len();
1109                 
1110                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1111                         
1112                         PropertyValue.Trim();
1113                         PropertyValue.RemoveLast();
1114                         
1115                 }                               
1116                 
1117                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1118                         
1119                         PropertyValue.Remove(0, 1);
1120                         
1121                 }                               
1122                 
1123                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1124         
1125         }       
1127         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1128         
1129         wxString GenderComponent;
1130         
1131         if (GenderData.CountTokens() >= 2){
1132         
1133                 Gender = GenderData.GetNextToken();
1134                 GenderDetails = GenderData.GetString();
1135         
1136                 CaptureString(&GenderDetails, FALSE);
1137                                                 
1138         } else {
1139         
1140                 Gender = GenderData.GetNextToken();
1141         
1142         }
1143         
1144         if (!PropertyTokens.IsEmpty()){
1145         
1146                 GenderTokens = PropertyTokens;
1147         
1148         }
1152 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1154         // Process date. Preserve the remainder in the string.
1156         std::map<int, int> SplitPoints;
1157         std::map<int, int> SplitLength;
1158         std::map<int, int>::iterator SLiter;                    
1159         wxString PropertyData;
1160         wxString PropertyName;
1161         wxString PropertyValue;
1162         wxString PropertyTokens;
1163         int intPrevValue = 6;
1165         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1167         intPrevValue = 5;
1169         // Look for type before continuing.
1171         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1172         intiter != SplitPoints.end(); ++intiter){
1174                 SLiter = SplitLength.find(intiter->first);
1175                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1176                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1177                 intPrevValue = intiter->second;
1178         
1179                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1180         
1181                         CaptureString(&PropertySeg2, FALSE);
1182                         Birthday = PropertySeg2;
1183                         BirthdayText = TRUE;
1184         
1185                 }
1187         }
1189         // Setup blank lines for later on.
1190         
1191         intPrevValue = 5;
1192         bool FirstToken = TRUE;
1194         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1195         intiter != SplitPoints.end(); ++intiter){
1197                 SLiter = SplitLength.find(intiter->first);
1198                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1199                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1200                 intPrevValue = intiter->second;
1201         
1202                 // Process properties.
1203         
1204                 CaptureString(&PropertyValue, FALSE);
1205         
1206                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1207                 
1208                         PropertyValue.Trim();
1209                         PropertyValue.RemoveLast();
1210                 
1211                 }                               
1212         
1213                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1214                 
1215                         PropertyValue.Remove(0, 1);
1216                 
1217                 }                               
1218         
1219                 if (PropertyName == wxT("ALTID")){
1221                         BirthdayAltID = PropertyValue;
1222         
1223                 } else if (PropertyName == wxT("CALSCALE")){
1224         
1225                         BirthdayCalScale = PropertyValue;
1226         
1227                 } else if (PropertyName != wxT("VALUE")) {
1228         
1229                         // Something else we don't know about so append
1230                         // to the tokens variable.
1231                 
1232                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1233                         
1234                 }
1236         }       
1238         // Add the data to the variables and form.
1239         
1240         if (BirthdayText == FALSE){
1241         
1242                 Birthday = PropertySeg2;
1244         }
1245         
1246         if (!PropertyTokens.IsEmpty()){
1247         
1248                 BirthdayTokens = PropertyTokens;
1250         }
1254 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1256         // Process date. Preserve the remainder in the string.
1258         std::map<int, int> SplitPoints;
1259         std::map<int, int> SplitLength;
1260         std::map<int, int>::iterator SLiter;                    
1261         wxString PropertyData;
1262         wxString PropertyName;
1263         wxString PropertyValue;
1264         wxString PropertyTokens;
1265         int intPrevValue = 13;
1267         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1269         intPrevValue = 12;
1271         // Look for type before continuing.
1273         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1274         intiter != SplitPoints.end(); ++intiter){
1276                 SLiter = SplitLength.find(intiter->first);
1277                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1278                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1279                 intPrevValue = intiter->second;
1280         
1281                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1282         
1283                         CaptureString(&PropertySeg2, FALSE);
1284                         Anniversary = PropertySeg2;
1285                         AnniversaryText = TRUE;
1286         
1287                 }
1289         }
1291         // Setup blank lines for later on.
1292         
1293         intPrevValue = 12;
1294         bool FirstToken = TRUE;
1296         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1297         intiter != SplitPoints.end(); ++intiter){
1299                 SLiter = SplitLength.find(intiter->first);
1300                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1301                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1302                 intPrevValue = intiter->second;
1303         
1304                 // Process properties.
1305         
1306                 CaptureString(&PropertyValue, FALSE);
1307         
1308                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1309                 
1310                         PropertyValue.Trim();
1311                         PropertyValue.RemoveLast();
1312                 
1313                 }                               
1314         
1315                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1316                 
1317                         PropertyValue.Remove(0, 1);
1318                 
1319                 }                               
1320         
1321                 if (PropertyName == wxT("ALTID")){
1323                         AnniversaryAltID = PropertyValue;
1324         
1325                 } else if (PropertyName == wxT("CALSCALE")){
1326         
1327                         AnniversaryCalScale = PropertyValue;
1328         
1329                 } else if (PropertyName != wxT("VALUE")) {
1330         
1331                         // Something else we don't know about so append
1332                         // to the tokens variable.
1333                 
1334                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1335                         
1336                 }
1338         }       
1340         // Add the data to the variables and form.
1341         
1342         if (AnniversaryText == FALSE){
1343         
1344                 Anniversary = PropertySeg2;
1346         }
1347         
1348         if (!PropertyTokens.IsEmpty()){
1349         
1350                 AnniversaryTokens = PropertyTokens;
1352         }
1356 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1358         std::map<int, int> SplitPoints;
1359         std::map<int, int> SplitLength;
1361         int intPrevValue = 4;
1362         
1363         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1364         
1365         intPrevValue = 3;
1366         
1367         PropertyType PropType = PROPERTY_NONE;
1368         
1369         // Look for type before continuing.
1370         
1371         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1372         
1373         intPrevValue = 3;
1374         
1375         std::map<int, wxString> *TZList = NULL;
1376         std::map<int, wxString> *TZListType = NULL;
1377         std::map<int, wxString> *TZListMediatype = NULL;
1378         std::map<int, wxString> *TZListAltID = NULL;
1379         std::map<int, wxString> *TZListPID = NULL;
1380         std::map<int, wxString> *TZListTokens = NULL;           
1381         std::map<int, int> *TZListPref = NULL;
1382         
1383         switch(PropType){
1384                 case PROPERTY_NONE:
1385                         TZList = &GeneralTZList;
1386                         TZListType = &GeneralTZListType;
1387                         TZListMediatype = &GeneralTZListMediatype;
1388                         TZListAltID = &GeneralTZListAltID;
1389                         TZListPID = &GeneralTZListPID;
1390                         TZListTokens = &GeneralTZListTokens;
1391                         TZListPref = &GeneralTZListPref;
1392                         break;
1393                 case PROPERTY_HOME:
1394                         TZList = &HomeTZList;
1395                         TZListType = &HomeTZListType;
1396                         TZListMediatype = &HomeTZListMediatype;
1397                         TZListAltID = &HomeTZListAltID;
1398                         TZListPID = &HomeTZListPID;
1399                         TZListTokens = &HomeTZListTokens;
1400                         TZListPref = &HomeTZListPref;
1401                         break;
1402                 case PROPERTY_WORK:
1403                         TZList = &BusinessTZList;
1404                         TZListType = &BusinessTZListType;
1405                         TZListMediatype = &BusinessTZListMediatype;
1406                         TZListAltID = &BusinessTZListAltID;
1407                         TZListPID = &BusinessTZListPID;
1408                         TZListTokens = &BusinessTZListTokens;
1409                         TZListPref = &BusinessTZListPref;
1410                         break;
1411         }
1412         
1413         std::map<int, int>::iterator SLiter;    
1414         wxString PropertyData;
1415         wxString PropertyName;
1416         wxString PropertyValue;
1417         wxString PropertyTokens;
1418         bool FirstToken = TRUE;
1419         bool PropertyMatched = FALSE;
1420         
1421         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1422         intiter != SplitPoints.end(); ++intiter){
1423         
1424                 SLiter = SplitLength.find(intiter->first);      
1425                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1426                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1427                 intPrevValue = intiter->second;
1428                 
1429                 CaptureString(&PropertyValue, FALSE);
1431                 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1432                 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1433                 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1434                 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1435                 
1436                 if (PropertyMatched == TRUE){
1437                 
1438                         PropertyMatched = FALSE;
1439                         continue;
1440                 
1441                 }
1443                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1444         
1445                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1446         
1447                 }
1448                 
1449         }
1450         
1451         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1452         
1453         // Add the name token data.
1454         
1455         if (!PropertyTokens.IsEmpty()){
1456         
1457                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1458         
1459         }
1464 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1466         size_t intPropertyLen = PropertySeg1.Len();
1467         std::map<int, int> SplitPoints;
1468         std::map<int, int> SplitLength;
1469         std::map<int, int>::iterator SLiter;                    
1470         wxString PropertyData;
1471         wxString PropertyName;
1472         wxString PropertyValue;
1473         wxString PropertyTokens;
1474         wxString AddressLabel;
1475         wxString AddressLang;
1476         wxString AddressAltID;
1477         wxString AddressPID;
1478         wxString AddressTokens;
1479         wxString AddressGeo;
1480         wxString AddressTimezone;
1481         wxString AddressType;
1482         wxString AddressMediatype;
1483         wxString AddressPOBox;
1484         wxString AddressExtended;
1485         wxString AddressStreet;
1486         wxString AddressLocality;
1487         wxString AddressCity;
1488         wxString AddressRegion;
1489         wxString AddressPostalCode;
1490         wxString AddressCountry;
1491         bool FirstToken = TRUE;                 
1492         int intSplitsFound = 0;
1493         int intSplitSize = 0;
1494         int intPrevValue = 5;
1495         bool PropertyMatched = FALSE;
1496         
1497         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1498         
1499         intPrevValue = 4;
1500         
1501         PropertyType PropType = PROPERTY_NONE;
1502                 
1503         // Look for type before continuing.
1504         
1505         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1506         
1507         intPrevValue = 4;
1508         
1509         std::map<int, wxString> *AddressList = NULL;
1510         std::map<int, wxString> *AddressListTown = NULL;
1511         std::map<int, wxString> *AddressListCounty = NULL;
1512         std::map<int, wxString> *AddressListPostCode = NULL;
1513         std::map<int, wxString> *AddressListCountry = NULL;
1514         std::map<int, wxString> *AddressListLabel = NULL;
1515         std::map<int, wxString> *AddressListLang = NULL;                
1516         std::map<int, wxString> *AddressListAltID = NULL;
1517         std::map<int, wxString> *AddressListPID = NULL;
1518         std::map<int, wxString> *AddressListTokens = NULL;
1519         std::map<int, wxString> *AddressListGeo = NULL;
1520         std::map<int, wxString> *AddressListTimezone = NULL;            
1521         std::map<int, wxString> *AddressListType = NULL;
1522         std::map<int, wxString> *AddressListMediatype = NULL;
1523         std::map<int, int> *AddressListPref = NULL;
1525         switch(PropType){
1526                 case PROPERTY_NONE:
1527                         AddressList = &GeneralAddressList;
1528                         AddressListTown = &GeneralAddressListTown;
1529                         AddressListCounty = &GeneralAddressListCounty;
1530                         AddressListPostCode = &GeneralAddressListPostCode;
1531                         AddressListCountry = &GeneralAddressListCountry;
1532                         AddressListLabel = &GeneralAddressListLabel;
1533                         AddressListLang = &GeneralAddressListLang;              
1534                         AddressListAltID = &GeneralAddressListAltID;
1535                         AddressListPID = &GeneralAddressListPID;
1536                         AddressListTokens = &GeneralAddressListTokens;
1537                         AddressListGeo = &GeneralAddressListGeo;
1538                         AddressListTimezone = &GeneralAddressListTimezone;
1539                         AddressListType = &GeneralAddressListType;
1540                         AddressListMediatype = &GeneralAddressListMediatype;
1541                         AddressListPref = &GeneralAddressListPref;              
1542                         break;
1543                 case PROPERTY_HOME:
1544                         AddressList = &HomeAddressList;
1545                         AddressListTown = &HomeAddressListTown;
1546                         AddressListCounty = &HomeAddressListCounty;
1547                         AddressListPostCode = &HomeAddressListPostCode;
1548                         AddressListCountry = &HomeAddressListCountry;
1549                         AddressListLabel = &HomeAddressListLabel;
1550                         AddressListLang = &HomeAddressListLang;         
1551                         AddressListAltID = &HomeAddressListAltID;
1552                         AddressListPID = &HomeAddressListPID;
1553                         AddressListTokens = &HomeAddressListTokens;
1554                         AddressListGeo = &HomeAddressListGeo;
1555                         AddressListTimezone = &HomeAddressListTimezone;
1556                         AddressListType = &HomeAddressListType;
1557                         AddressListMediatype = &HomeAddressListMediatype;
1558                         AddressListPref = &HomeAddressListPref;
1559                         break;
1560                 case PROPERTY_WORK:
1561                         AddressList = &BusinessAddressList;
1562                         AddressListTown = &BusinessAddressListTown;
1563                         AddressListCounty = &BusinessAddressListCounty;
1564                         AddressListPostCode = &BusinessAddressListPostCode;
1565                         AddressListCountry = &BusinessAddressListCountry;
1566                         AddressListLabel = &BusinessAddressListLabel;
1567                         AddressListLang = &BusinessAddressListLang;             
1568                         AddressListAltID = &BusinessAddressListAltID;
1569                         AddressListPID = &BusinessAddressListPID;
1570                         AddressListTokens = &BusinessAddressListTokens;
1571                         AddressListGeo = &BusinessAddressListGeo;
1572                         AddressListTimezone = &BusinessAddressListTimezone;
1573                         AddressListType = &BusinessAddressListType;
1574                         AddressListMediatype = &BusinessAddressListMediatype;
1575                         AddressListPref = &BusinessAddressListPref;
1576                         break;
1577         }
1578         
1579         intPrevValue = 4;
1580         
1581         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1582         intiter != SplitPoints.end(); ++intiter){
1583         
1584                 SLiter = SplitLength.find(intiter->first);
1585                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1586                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1587                 intPrevValue = intiter->second;
1588                 
1589                 CaptureString(&PropertyValue, FALSE);
1590                 
1591                 // Process properties.
1592                 
1593                 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1594                 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1595                 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1596                 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1597                 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1598                 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1599                 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1600                 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1601                 
1602                 if (PropertyMatched == TRUE){
1603                 
1604                         PropertyMatched = FALSE;
1605                         continue;
1606                 
1607                 }
1608                 
1609                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1610         
1611         }                       
1612         
1613         // Split the address. 
1615         //std::map<int, int>::iterator SLiter;
1616         intPropertyLen = PropertySeg2.Len();
1617         SplitPoints.clear();
1618         SplitLength.clear();
1619         intSplitsFound = 0;
1620         intSplitSize = 0;
1621         intPrevValue = 0;
1622         
1623         for (int i = 0; i <= intPropertyLen; i++){
1625                 intSplitSize++;
1626         
1627                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1628         
1629                         intSplitsFound++;
1630                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1631                         
1632                         if (intSplitsFound == 6){ 
1633                         
1634                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1635                                 break; 
1636                                 
1637                         } else {
1638                         
1639                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1640                         
1641                         }
1642                         
1643                         intSplitSize = 0;                                       
1644         
1645                 }
1647         }
1648         
1649         // Split the data into several parts.                   
1650         
1651         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1652         intiter != SplitPoints.end(); ++intiter){
1653                         
1654                 if (intiter->first == 1){
1655                 
1656                         // Deal with PO Box.
1657                         
1658                         SLiter = SplitLength.find(1);
1659                                                                 
1660                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1661                         intPrevValue = intiter->second;
1662                 
1663                 } else if (intiter->first == 2){
1664                 
1665                         // Deal with extended address.
1666                         
1667                         SLiter = SplitLength.find(2);
1668                         
1669                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1670                         intPrevValue = intiter->second;
1671                 
1672                 } else if (intiter->first == 3){
1673                 
1674                         // Deal with street address.
1675                         
1676                         SLiter = SplitLength.find(3);
1677                                                                 
1678                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1679                         intPrevValue = intiter->second;
1680                 
1681                 } else if (intiter->first == 4){
1682                 
1683                         // Deal with locality
1685                         SLiter = SplitLength.find(4);
1686                         
1687                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1688                         intPrevValue = intiter->second;
1689                 
1690                 } else if (intiter->first == 5){
1691                 
1692                         // Deal with region.
1694                         SLiter = SplitLength.find(5);
1695                         
1696                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1697                         intPrevValue = intiter->second;
1698                         
1699                 
1700                 } else if (intiter->first == 6){
1701                 
1702                         // Deal with post code.
1704                         SLiter = SplitLength.find(6);
1705                         
1706                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1707                         intPrevValue = intiter->second;
1708                         
1709                         // Deal with country.
1710                                                 
1711                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1713                         break;
1714                 
1715                 }
1716         
1717         }       
1718         
1719         // Add the data to the General/Home/Work address variables.
1720         
1721         CaptureString(&AddressStreet, FALSE); 
1722         CaptureString(&AddressLocality, FALSE);
1723         CaptureString(&AddressRegion, FALSE);
1724         CaptureString(&AddressPostalCode, FALSE);
1725         CaptureString(&AddressCountry, FALSE);
1726                 
1727         if (!PropertyTokens.IsEmpty()){
1728         
1729                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1730         
1731         }
1733         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1734         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1735         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1736         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1737         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1739         switch(PropType){
1740                 case PROPERTY_NONE:
1741                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1742                         break;
1743                 case PROPERTY_HOME:
1744                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1745                         break;
1746                 case PROPERTY_WORK:
1747                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1748                         break;
1749         }
1750         
1751         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1755 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1757         std::map<int, int> SplitPoints;
1758         std::map<int, int> SplitLength;
1760         int intPrevValue = 7;
1761         
1762         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1763         
1764         intPrevValue = 6;
1765         
1766         PropertyType PropType = PROPERTY_NONE;
1767                 
1768         // Look for type before continuing.
1769         
1770         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1771         
1772         std::map<int, wxString> *EmailList = NULL;
1773         std::map<int, wxString> *EmailListType = NULL;
1774         std::map<int, wxString> *EmailListAltID = NULL;
1775         std::map<int, wxString> *EmailListPID = NULL;
1776         std::map<int, wxString> *EmailListTokens = NULL;                
1777         std::map<int, int> *EmailListPref = NULL;
1779         switch(PropType){
1780                 case PROPERTY_NONE:
1781                         EmailList = &GeneralEmailList;
1782                         EmailListType = &GeneralEmailListType;
1783                         EmailListAltID = &GeneralEmailListAltID;
1784                         EmailListPID = &GeneralEmailListPID;
1785                         EmailListTokens = &GeneralEmailListTokens;              
1786                         EmailListPref = &GeneralEmailListPref;  
1787                         break;
1788                 case PROPERTY_HOME:
1789                         EmailList = &HomeEmailList;
1790                         EmailListType = &HomeEmailListType;
1791                         EmailListAltID = &HomeEmailListAltID;
1792                         EmailListPID = &HomeEmailListPID;
1793                         EmailListTokens = &HomeEmailListTokens;         
1794                         EmailListPref = &HomeEmailListPref;     
1795                         break;
1796                 case PROPERTY_WORK:
1797                         EmailList = &BusinessEmailList;
1798                         EmailListType = &BusinessEmailListType;
1799                         EmailListAltID = &BusinessEmailListAltID;
1800                         EmailListPID = &BusinessEmailListPID;
1801                         EmailListTokens = &BusinessEmailListTokens;             
1802                         EmailListPref = &BusinessEmailListPref; 
1803                         break;
1804         }
1805         
1806         intPrevValue = 6;
1807         
1808         std::map<int,int>::iterator SLiter;
1809         wxString PropertyData;
1810         wxString PropertyName;
1811         wxString PropertyValue;
1812         wxString PropertyTokens;
1813         bool FirstToken = TRUE;
1814         bool PropertyMatched = FALSE;
1815         
1816         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1817         intiter != SplitPoints.end(); ++intiter){
1818         
1819                 SLiter = SplitLength.find(intiter->first);
1820                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1821                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1822                 intPrevValue = intiter->second;
1823                 
1824                 CaptureString(&PropertyValue, FALSE);
1825                 
1826                 // Process properties.
1827                 
1828                 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
1829                 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
1830                 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
1831                 
1832                 if (PropertyMatched == TRUE){
1833                 
1834                         PropertyMatched = FALSE;
1835                         continue;
1836                 
1837                 }
1838                 
1839                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1840         
1841         }
1842         
1843         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1844         
1845         // Add the name token data.
1846         
1847         if (!PropertyTokens.IsEmpty()){
1848         
1849                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1850         
1851         }       
1856 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1858         std::map<int, int> SplitPoints;
1859         std::map<int, int> SplitLength;
1861         int intPrevValue = 6;
1862         
1863         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1864         
1865         intPrevValue = 5;
1866         
1867         PropertyType PropType = PROPERTY_NONE;
1868                 
1869         // Look for type before continuing.
1870         
1871         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1872         
1873         std::map<int, wxString> *IMList = NULL;
1874         std::map<int, wxString> *IMListType = NULL;
1875         std::map<int, wxString> *IMListAltID = NULL;
1876         std::map<int, wxString> *IMListPID = NULL;
1877         std::map<int, wxString> *IMListTokens = NULL;
1878         std::map<int, wxString> *IMListMediatype = NULL;
1879         std::map<int, wxString> *IMListTypeInfo = NULL;
1880         std::map<int, int> *IMListPref = NULL;
1882         switch(PropType){
1883                 case PROPERTY_NONE:
1884                         IMList = &GeneralIMList;
1885                         IMListType = &GeneralIMListType;
1886                         IMListAltID = &GeneralIMListAltID;
1887                         IMListPID = &GeneralIMListPID;
1888                         IMListTokens = &GeneralIMListTokens;
1889                         IMListMediatype = &GeneralIMListMediatype;
1890                         IMListTypeInfo = &GeneralIMListTypeInfo;
1891                         IMListPref = &GeneralIMListPref;        
1892                         break;
1893                 case PROPERTY_HOME:
1894                         IMList = &HomeIMList;
1895                         IMListType = &HomeIMListType;
1896                         IMListAltID = &HomeIMListAltID;
1897                         IMListPID = &HomeIMListPID;
1898                         IMListTokens = &HomeIMListTokens;
1899                         IMListMediatype = &HomeIMListMediatype; 
1900                         IMListTypeInfo = &HomeIMListTypeInfo;   
1901                         IMListPref = &HomeIMListPref;   
1902                         break;
1903                 case PROPERTY_WORK:
1904                         IMList = &BusinessIMList;
1905                         IMListType = &BusinessIMListType;
1906                         IMListAltID = &BusinessIMListAltID;
1907                         IMListPID = &BusinessIMListPID;
1908                         IMListTokens = &BusinessIMListTokens;   
1909                         IMListMediatype = &BusinessIMListMediatype;
1910                         IMListTypeInfo = &BusinessIMListTypeInfo;
1911                         IMListPref = &BusinessIMListPref;       
1912                         break;
1913         }
1914         
1915         intPrevValue = 5;
1916         
1917         std::map<int,int>::iterator SLiter;
1918         wxString PropertyData;
1919         wxString PropertyName;
1920         wxString PropertyValue;
1921         wxString PropertyTokens;
1922         bool FirstToken = TRUE;
1923         bool PropertyMatched = FALSE;
1924         
1925         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1926         intiter != SplitPoints.end(); ++intiter){
1927         
1928                 SLiter = SplitLength.find(intiter->first);
1929                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1930                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1931                 intPrevValue = intiter->second;
1932                 
1933                 CaptureString(&PropertyValue, FALSE);
1934                 
1935                 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
1936                 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
1937                 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
1938                 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
1939                 
1940                 // Process properties.
1941                 
1942                 if (PropertyMatched == TRUE){
1943                         
1944                         PropertyMatched = FALSE;
1945                         continue;
1946                 
1947                 }
1948                 
1949                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1950         
1951         }
1952                 
1953         wxStringTokenizer IMPPSplitData(PropertySeg2, wxT(":"));
1954                 
1955         if (IMPPSplitData.CountTokens() > 1){
1957                 IMListTypeInfo->insert(std::make_pair(*IMCount, IMPPSplitData.GetNextToken()));
1958                 IMList->insert(std::make_pair(*IMCount, IMPPSplitData.GetString()));
1959         
1960         } else {
1961         
1962                 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1963                 IMListTypeInfo->insert(std::make_pair(*IMCount, "none"));
1964         
1965         }
1966         
1967         // Add the name token data.
1968         
1969         if (!PropertyTokens.IsEmpty()){
1970         
1971                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1972         
1973         }
1977 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1979         std::map<int, int> SplitPoints;
1980         std::map<int, int> SplitLength;
1981         std::map<int, int>::iterator SLiter;
1982         
1983         PropertyType PropType = PROPERTY_NONE;
1984                 
1985         // Look for type before continuing.
1986         
1987         wxString TelTypeUI;
1988         wxString TelTypeDetail;
1989         wxString PropertyData;
1990         wxString PropertyName;
1991         wxString PropertyValue;
1992         wxString PropertyTokens;
1993         
1994         std::map<int,int> TypeSplitPoints;
1995         std::map<int,int> TypeSplitLength;
1996         std::map<int,int>::iterator TSLiter;
1997         
1998         int intSplitSize = 0;
1999         int intSplitsFound = 0;
2000         int intSplitPoint = 0;
2001         int intType = 0;
2002         int intPrevValue = 5;
2003                 
2004         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2005         
2006         intPrevValue = 4;
2007         
2008         // Look for type before continuing.
2009         
2010         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2011         intiter != SplitPoints.end(); ++intiter){
2012         
2013                 SLiter = SplitLength.find(intiter->first);
2014                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2015                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2016                 intPrevValue = intiter->second;
2018                 if (PropertyName == wxT("TYPE")){
2019                 
2020                         // Process each value in type and translate each
2021                         // part.
2022                 
2023                         // Strip out the quotes if they are there.
2024                 
2025                         size_t intPropertyValueLen = PropertyValue.Len();
2026                 
2027                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2028                         
2029                                 PropertyValue.Trim();
2030                                 PropertyValue.RemoveLast();
2031                         
2032                         }                               
2033                 
2034                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2035                         
2036                                 PropertyValue.Remove(0, 1);
2037                         
2038                         }
2039                         
2040                         TelTypeDetail = PropertyValue;
2041                         
2042                         intSplitSize = 0;
2043                         intSplitsFound = 0;
2044                         intSplitPoint = 0;
2045                         
2046                         for (int i = 0; i <= intPropertyValueLen; i++){
2047         
2048                                 intSplitSize++;
2049         
2050                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2051         
2052                                         if (intSplitsFound == 0){
2054                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2055                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2056                         
2057                                         } else {
2058                         
2059                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2060                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2061                         
2062                                         }                       
2064                                         intSplitsFound++;
2065                                         i++;
2066                                         intSplitPoint = i;
2067                                         intSplitSize = 0;
2068         
2069                                 }
2070         
2071                         }
2072                         
2073                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2074                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2075                 
2076                         int intTypeSeek = 0;
2077                 
2078                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2079                         typeiter != TypeSplitPoints.end(); ++typeiter){
2080                                                 
2081                                 wxString TypePropertyName;
2082                                 
2083                                 TSLiter = TypeSplitLength.find(typeiter->first);
2084                                 
2085                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2086                                 
2087                                 if (intTypeSeek == 0){
2088                                 
2089                                 
2090                                 } else {
2091                                                                                 
2092                                         TelTypeUI.Append(wxT(","));                                                     
2093                                 
2094                                 }
2096                                 if (TypePropertyName == wxT("home")){
2097                                 
2098                                         PropType = PROPERTY_HOME;
2099                                 
2100                                 } else if (TypePropertyName == wxT("work")){
2101                                 
2102                                         PropType = PROPERTY_WORK;
2103                                                                         
2104                                 }
2105                                 
2106                                 
2107                                 if (TypePropertyName == wxT("text")){
2108                                 
2109                                         TelTypeUI.Append(_("text"));
2110                                         intTypeSeek++;
2111                                 
2112                                 } else if (TypePropertyName == wxT("voice")){
2113                                 
2114                                         TelTypeUI.Append(_("voice"));
2115                                         intTypeSeek++;
2116                                 
2117                                 } else if (TypePropertyName == wxT("fax")){
2118                                 
2119                                         TelTypeUI.Append(_("fax"));
2120                                         intTypeSeek++;
2121                                 
2122                                 } else if (TypePropertyName == wxT("cell")){
2123                                 
2124                                         TelTypeUI.Append(_("cell"));
2125                                         intTypeSeek++;
2126                                 
2127                                 } else if (TypePropertyName == wxT("video")){
2128                                 
2129                                         TelTypeUI.Append(_("video"));
2130                                         intTypeSeek++;
2131                                 
2132                                 } else if (TypePropertyName == wxT("pager")){
2133                                 
2134                                         TelTypeUI.Append(_("pager"));
2135                                         intTypeSeek++;
2136                                 
2137                                 } else if (TypePropertyName == wxT("textphone")){
2138                                 
2139                                         TelTypeUI.Append(_("textphone"));
2140                                         intTypeSeek++;
2141                                 
2142                                 }
2143                         
2144                         }
2145                 
2146                 }
2147                 
2148         }
2149         
2150         std::map<int, wxString> *TelephoneList = NULL;
2151         std::map<int, wxString> *TelephoneListType = NULL;
2152         std::map<int, wxString> *TelephoneListAltID = NULL;
2153         std::map<int, wxString> *TelephoneListPID = NULL;
2154         std::map<int, wxString> *TelephoneListTokens = NULL;
2155         std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2156         std::map<int, wxString> *TelephoneListDataType = NULL;
2157         std::map<int, int> *TelephoneListPref = NULL;
2159         switch(PropType){
2160                 case PROPERTY_NONE:
2161                         TelephoneList = &GeneralTelephoneList;
2162                         TelephoneListType = &GeneralTelephoneListType;
2163                         TelephoneListAltID = &GeneralTelephoneListAltID;
2164                         TelephoneListPID = &GeneralTelephoneListPID;
2165                         TelephoneListTokens = &GeneralTelephoneListTokens;
2166                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2167                         TelephoneListDataType = &GeneralTelephoneListDataType;
2168                         TelephoneListPref = &GeneralTelephoneListPref;  
2169                         break;
2170                 case PROPERTY_HOME:
2171                         TelephoneList = &HomeTelephoneList;
2172                         TelephoneListType = &HomeTelephoneListType;
2173                         TelephoneListAltID = &HomeTelephoneListAltID;
2174                         TelephoneListPID = &HomeTelephoneListPID;
2175                         TelephoneListTokens = &HomeTelephoneListTokens;
2176                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2177                         TelephoneListDataType = &HomeTelephoneListDataType;
2178                         TelephoneListPref = &HomeTelephoneListPref;     
2179                         break;
2180                 case PROPERTY_WORK:
2181                         TelephoneList = &BusinessTelephoneList;
2182                         TelephoneListType = &BusinessTelephoneListType;
2183                         TelephoneListAltID = &BusinessTelephoneListAltID;
2184                         TelephoneListPID = &BusinessTelephoneListPID;
2185                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2186                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2187                         TelephoneListDataType = &BusinessTelephoneListDataType;
2188                         TelephoneListPref = &BusinessTelephoneListPref; 
2189                         break;
2190         }
2191                 
2192         // Process the properties.
2193         
2194         bool FirstToken = TRUE;
2195         
2196         intPrevValue = 5;
2197         SplitPoints.clear();
2198         SplitLength.clear();
2200         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2202         intPrevValue = 4;
2203         
2204         bool PropertyMatched = FALSE;
2205         
2206         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2207         intiter != SplitPoints.end(); ++intiter){
2208         
2209                 SLiter = SplitLength.find(intiter->first);
2210                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2211                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2212                 intPrevValue = intiter->second;
2213                 
2214                 CaptureString(&PropertyValue, FALSE);
2215                 
2216                 // Process properties.
2217                 
2218                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2219                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2220                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2221                 
2222                 if (PropertyMatched == TRUE){
2223                 
2224                         PropertyMatched = FALSE;
2225                         continue;
2226                 
2227                 }
2229                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2230         
2231         }
2232                 
2233         // Check for the type information and split it down.
2234         
2235         wxStringTokenizer TelSplitData(PropertySeg2, wxT(":"));
2236                 
2237         if (TelSplitData.CountTokens() > 1){
2239                 TelephoneListDataType->insert(std::make_pair(*TelephoneCount, TelSplitData.GetNextToken()));                    
2240                 TelephoneList->insert(std::make_pair(*TelephoneCount, TelSplitData.GetString()));
2241         
2242         } else {
2243         
2244                 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2245                 TelephoneListDataType->insert(std::make_pair(*TelephoneCount, "tel"));
2246         
2247         }
2248                 
2249         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2250                 
2251         // Add the name token data.
2252         
2253         if (!PropertyTokens.IsEmpty()){
2254         
2255                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2256         
2257         }
2261 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2263         std::map<int, int> SplitPoints;
2264         std::map<int, int> SplitLength;
2266         int intPrevValue = 6;
2267         
2268         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2269         
2270         intPrevValue = 5;
2271         
2272         PropertyType PropType = PROPERTY_NONE;
2273                 
2274         // Look for type before continuing.
2275         
2276         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2277         
2278         std::map<int, wxString> *LanguageList = NULL;
2279         std::map<int, wxString> *LanguageListType = NULL;
2280         std::map<int, wxString> *LanguageListAltID = NULL;
2281         std::map<int, wxString> *LanguageListPID = NULL;
2282         std::map<int, wxString> *LanguageListTokens = NULL;
2283         std::map<int, int> *LanguageListPref = NULL;
2285         switch(PropType){
2286                 case PROPERTY_NONE:
2287                         LanguageList = &GeneralLanguageList;
2288                         LanguageListType = &GeneralLanguageListType;
2289                         LanguageListAltID = &GeneralLanguageListAltID;
2290                         LanguageListPID = &GeneralLanguageListPID;
2291                         LanguageListTokens = &GeneralLanguageListTokens;
2292                         LanguageListPref = &GeneralLanguageListPref;    
2293                         break;
2294                 case PROPERTY_HOME:
2295                         LanguageList = &HomeLanguageList;
2296                         LanguageListType = &HomeLanguageListType;
2297                         LanguageListAltID = &HomeLanguageListAltID;
2298                         LanguageListPID = &HomeLanguageListPID;
2299                         LanguageListTokens = &HomeLanguageListTokens;   
2300                         LanguageListPref = &HomeLanguageListPref;       
2301                         break;
2302                 case PROPERTY_WORK:
2303                         LanguageList = &BusinessLanguageList;
2304                         LanguageListType = &BusinessLanguageListType;
2305                         LanguageListAltID = &BusinessLanguageListAltID;
2306                         LanguageListPID = &BusinessLanguageListPID;
2307                         LanguageListTokens = &BusinessLanguageListTokens;       
2308                         LanguageListPref = &BusinessLanguageListPref;
2309                         break;
2310         }
2311         
2312         intPrevValue = 5;
2313         
2314         std::map<int,int>::iterator SLiter;
2315         wxString PropertyData;
2316         wxString PropertyName;
2317         wxString PropertyValue;
2318         wxString PropertyTokens;
2319         bool FirstToken = TRUE;
2320         bool PropertyMatched = FALSE;
2321         
2322         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2323         intiter != SplitPoints.end(); ++intiter){
2324         
2325                 SLiter = SplitLength.find(intiter->first);
2326                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2327                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2328                 intPrevValue = intiter->second;
2330                 CaptureString(&PropertyValue, FALSE);
2331                 
2332                 // Process properties.
2333                 
2334                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2335                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2336                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2338                 if (PropertyMatched == TRUE){
2339                 
2340                         PropertyMatched = FALSE;
2341                         continue;
2342                 
2343                 }
2344                 
2345                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2346         
2347         }
2348                 
2349         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2350         
2351         // Add the name token data.
2352         
2353         if (!PropertyTokens.IsEmpty()){
2354         
2355                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2356         
2357         }
2361 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2363         std::map<int, int> SplitPoints;
2364         std::map<int, int> SplitLength;
2366         int intPrevValue = 5;
2367         
2368         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2369         
2370         intPrevValue = 4;
2371         
2372         PropertyType PropType = PROPERTY_NONE;
2373                 
2374         // Look for type before continuing.
2375         
2376         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2377         
2378         std::map<int, wxString> *GeopositionList = NULL;
2379         std::map<int, wxString> *GeopositionListType = NULL;
2380         std::map<int, wxString> *GeopositionListAltID = NULL;
2381         std::map<int, wxString> *GeopositionListPID = NULL;
2382         std::map<int, wxString> *GeopositionListTokens = NULL;
2383         std::map<int, wxString> *GeopositionListMediatype = NULL;
2384         std::map<int, int> *GeopositionListPref = NULL;
2386         switch(PropType){
2387                 case PROPERTY_NONE:
2388                         GeopositionList = &GeneralGeographyList;
2389                         GeopositionListType = &GeneralGeographyListType;
2390                         GeopositionListAltID = &GeneralGeographyListAltID;
2391                         GeopositionListPID = &GeneralGeographyListPID;
2392                         GeopositionListTokens = &GeneralGeographyListTokens;
2393                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2394                         GeopositionListPref = &GeneralGeographyListPref;        
2395                         break;
2396                 case PROPERTY_HOME:
2397                         GeopositionList = &HomeGeographyList;
2398                         GeopositionListType = &HomeGeographyListType;
2399                         GeopositionListAltID = &HomeGeographyListAltID;
2400                         GeopositionListPID = &HomeGeographyListPID;
2401                         GeopositionListTokens = &HomeGeographyListTokens;
2402                         GeopositionListMediatype = &HomeGeographyListMediatype;
2403                         GeopositionListPref = &HomeGeographyListPref;   
2404                         break;
2405                 case PROPERTY_WORK:
2406                         GeopositionList = &BusinessGeographyList;
2407                         GeopositionListType = &BusinessGeographyListType;
2408                         GeopositionListAltID = &BusinessGeographyListAltID;
2409                         GeopositionListPID = &BusinessGeographyListPID;
2410                         GeopositionListTokens = &BusinessGeographyListTokens;
2411                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2412                         GeopositionListPref = &BusinessGeographyListPref;
2413                         break;
2414         }
2415         
2416         intPrevValue = 4;
2417         
2418         std::map<int,int>::iterator SLiter;
2419         wxString PropertyData;
2420         wxString PropertyName;
2421         wxString PropertyValue;
2422         wxString PropertyTokens;
2423         bool FirstToken = TRUE;
2424         bool PropertyMatched = FALSE;
2425         
2426         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2427         intiter != SplitPoints.end(); ++intiter){
2428         
2429                 SLiter = SplitLength.find(intiter->first);
2430                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2431                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2432                 intPrevValue = intiter->second;
2433                 
2434                 CaptureString(&PropertyValue, FALSE);
2435                 
2436                 // Process properties.
2437                 
2438                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2439                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2440                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2441                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2442                 
2443                 if (PropertyMatched == TRUE){
2444                 
2445                         PropertyMatched = FALSE;
2446                         continue;
2447                 
2448                 }
2449                 
2450                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2451         
2452         }
2453                 
2454         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2455         
2456         // Add the name token data.
2457         
2458         if (!PropertyTokens.IsEmpty()){
2459         
2460                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2461         
2462         }
2466 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2468         size_t intPropertyLen = PropertySeg1.Len();
2469         std::map<int, int> SplitPoints;
2470         std::map<int, int> SplitLength;
2471         std::map<int, int>::iterator SLiter;                    
2472         wxString PropertyData;
2473         wxString PropertyName;
2474         wxString PropertyValue;
2475         wxString PropertyTokens;
2476         wxString RelatedType;
2477         wxString RelatedTypeOriginal;                   
2478         wxString RelatedName;
2479         bool FirstToken = TRUE;                 
2480         int intSplitsFound = 0;
2481         int intSplitSize = 0;
2482         int intPrevValue = 9;
2483         
2484         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2485         
2486         intPrevValue = 8;
2487         
2488         // Look for type before continuing.
2489         
2490         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2491         intiter != SplitPoints.end(); ++intiter){
2492         
2493                 SLiter = SplitLength.find(intiter->first);
2494                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2495                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2496                 intPrevValue = intiter->second;
2497                 
2498                 // Process these.
2499                 
2500                 RelatedTypeOriginal = PropertyValue;
2501                 
2502                 if (PropertyName == wxT("TYPE")){
2503                 
2504                         if (PropertyValue == wxT("contact")){
2506                                 RelatedType = _("Contact");
2508                         } else if (PropertyValue == wxT("acquaintance")){
2510                                 RelatedType = _("Acquaintance");
2512                         } else if (PropertyValue == wxT("friend")){
2514                                 RelatedType = _("Friend");
2516                         } else if (PropertyValue == wxT("met")){
2518                                 RelatedType = _("Met");
2520                         } else if (PropertyValue == wxT("co-worker")){
2522                                 RelatedType = _("Co-worker");
2524                         } else if (PropertyValue == wxT("colleague")){
2526                                 RelatedType = _("Colleague");
2528                         } else if (PropertyValue == wxT("co-resident")){
2530                                 RelatedType = _("Co-resident");
2532                         } else if (PropertyValue == wxT("neighbor")){
2534                                 RelatedType = _("Neighbour");
2536                         } else if (PropertyValue == wxT("child")){
2538                                 RelatedType = _("Child");
2540                         } else if (PropertyValue == wxT("parent")){
2542                                 RelatedType = _("Parent");
2544                         } else if (PropertyValue == wxT("sibling")){
2546                                 RelatedType = _("Sibling");
2548                         } else if (PropertyValue == wxT("spouse")){
2550                                 RelatedType = _("Spouse");
2552                         } else if (PropertyValue == wxT("kin")){
2554                                 RelatedType = _("Kin");
2556                         } else if (PropertyValue == wxT("muse")){
2558                                 RelatedType = _("Muse");
2560                         } else if (PropertyValue == wxT("crush")){
2562                                 RelatedType = _("Crush");
2564                         } else if (PropertyValue == wxT("date")){
2566                                 RelatedType = _("Date");
2568                         } else if (PropertyValue == wxT("sweetheart")){
2570                                 RelatedType = _("Sweetheart");
2572                         } else if (PropertyValue == wxT("me")){
2574                                 RelatedType = _("Me");
2576                         } else if (PropertyValue == wxT("agent")){
2578                                 RelatedType = _("Agent");
2580                         } else if (PropertyValue == wxT("emergency")){
2582                                 RelatedType = _("Emergency");
2584                         } else {
2586                                 RelatedType = PropertyValue;
2588                         }
2589                 
2590                 }
2591         
2592         }
2593         
2594         intPrevValue = 8;                       
2595         
2596         bool PropertyMatched = FALSE;
2597         
2598         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2599         intiter != SplitPoints.end(); ++intiter){
2600         
2601                 SLiter = SplitLength.find(intiter->first);
2602                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2603                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2604                 intPrevValue = intiter->second;
2605                 
2606                 // Process properties.
2607                 
2608                 size_t intPropertyValueLen = PropertyValue.Len();
2609                 
2610                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2611                         
2612                         PropertyValue.Trim();
2613                         PropertyValue.RemoveLast();
2614                         
2615                 }                               
2616                 
2617                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2618                         
2619                         PropertyValue.Remove(0, 1);
2620                         
2621                 }
2622                 
2623                 CaptureString(&PropertyValue, FALSE);
2624                         
2625                 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2626                 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2627                 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2628                 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2630                 if (PropertyMatched == TRUE){
2631                 
2632                         PropertyMatched = FALSE;
2633                         continue;
2634                 
2635                 }
2637                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2638         
2639         }                                       
2640         
2641         // Add the data to the General/Home/Work address variables.
2642                                 
2643         GeneralRelatedList.erase(*RelatedCount);
2644         GeneralRelatedListRelType.erase(*RelatedCount);
2645         GeneralRelatedListType.erase(*RelatedCount);
2646         GeneralRelatedListTokens.erase(*RelatedCount);
2647         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2648         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2649         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2650         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2654 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2656         std::map<int, int> SplitPoints;
2657         std::map<int, int> SplitLength;
2658         std::map<int, int>::iterator SLiter;                    
2659         wxString PropertyData;
2660         wxString PropertyName;
2661         wxString PropertyValue;
2662         wxString PropertyTokens;
2663         bool FirstToken = TRUE;
2664         int intPrevValue = 5;
2665         
2666         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2667         
2668         intPrevValue = 4;
2669         
2670         PropertyType PropType = PROPERTY_NONE;
2671                 
2672         // Look for type before continuing.
2673         
2674         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2675         
2676         // Setup the pointers.
2677         
2678         std::map<int, wxString> *WebsiteList = NULL;
2679         std::map<int, wxString> *WebsiteListAltID = NULL;
2680         std::map<int, wxString> *WebsiteListPID = NULL;
2681         std::map<int, wxString> *WebsiteListType = NULL;
2682         std::map<int, wxString> *WebsiteListTokens = NULL;
2683         std::map<int, wxString> *WebsiteListMediatype = NULL;
2684         std::map<int, int> *WebsiteListPref = NULL;
2685         
2686         // Setup blank lines for later on.
2687         
2688         switch(PropType){
2689                 case PROPERTY_NONE:
2690                         WebsiteList = &GeneralWebsiteList;
2691                         WebsiteListType = &GeneralWebsiteListType;
2692                         WebsiteListAltID = &GeneralWebsiteListAltID;
2693                         WebsiteListPID = &GeneralWebsiteListPID;
2694                         WebsiteListTokens = &GeneralWebsiteListTokens;
2695                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2696                         WebsiteListPref = &GeneralWebsiteListPref;      
2697                         break;
2698                 case PROPERTY_HOME:
2699                         WebsiteList = &HomeWebsiteList;
2700                         WebsiteListType = &HomeWebsiteListType;
2701                         WebsiteListAltID = &HomeWebsiteListAltID;
2702                         WebsiteListPID = &HomeWebsiteListPID;
2703                         WebsiteListTokens = &HomeWebsiteListTokens;
2704                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2705                         WebsiteListPref = &HomeWebsiteListPref; 
2706                         break;
2707                 case PROPERTY_WORK:
2708                         WebsiteList = &BusinessWebsiteList;
2709                         WebsiteListType = &BusinessWebsiteListType;
2710                         WebsiteListAltID = &BusinessWebsiteListAltID;
2711                         WebsiteListPID = &BusinessWebsiteListPID;
2712                         WebsiteListTokens = &BusinessWebsiteListTokens;
2713                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2714                         WebsiteListPref = &BusinessWebsiteListPref;
2715                         break;
2716         }
2717         
2718         intPrevValue = 4;
2719         bool PropertyMatched = FALSE;
2720         
2721         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2722         intiter != SplitPoints.end(); ++intiter){
2723         
2724                 SLiter = SplitLength.find(intiter->first);
2725                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2726                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2727                 intPrevValue = intiter->second;
2728                 
2729                 // Process properties.
2730                 
2731                 size_t intPropertyValueLen = PropertyValue.Len();
2732                 
2733                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2734                         
2735                         PropertyValue.Trim();
2736                         PropertyValue.RemoveLast();
2737                         
2738                 }                               
2739                 
2740                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2741                         
2742                         PropertyValue.Remove(0, 1);
2743                         
2744                 }
2745                 
2746                 CaptureString(&PropertyValue, FALSE);
2747                 
2748                 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
2749                 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
2750                 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
2751                 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
2752                 
2753                 if (PropertyMatched == TRUE){
2754                 
2755                         PropertyMatched = FALSE;
2756                         continue;
2757                 
2758                 }
2759                 
2760                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2761         
2762         }
2763         
2764         // Add the data to the General/Home/Work address variables.
2765         
2766         CaptureString(&PropertySeg2, FALSE);
2767                         
2768         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2769         
2770         if (!PropertyTokens.IsEmpty()){
2771         
2772                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2773                         
2774         }
2775         
2778 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
2780         std::map<int, int> SplitPoints;
2781         std::map<int, int> SplitLength;
2782         std::map<int, int>::iterator SLiter;                    
2783         wxString PropertyData;
2784         wxString PropertyName;
2785         wxString PropertyValue;
2786         wxString PropertyTokens;
2787         bool FirstToken = TRUE;
2788         int intPrevValue = 7;
2789         
2790         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2791         
2792         intPrevValue = 6;
2793         
2794         PropertyType PropType = PROPERTY_NONE;
2795                 
2796         // Look for type before continuing.
2797         
2798         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2799         
2800         // Setup the pointers.
2801         
2802         std::map<int, wxString> *TitleList = NULL;
2803         std::map<int, wxString> *TitleListAltID = NULL;
2804         std::map<int, wxString> *TitleListPID = NULL;
2805         std::map<int, wxString> *TitleListType = NULL;
2806         std::map<int, wxString> *TitleListTokens = NULL;
2807         std::map<int, wxString> *TitleListLanguage = NULL;
2808         std::map<int, int> *TitleListPref = NULL;
2809         
2810         // Setup blank lines for later on.
2811         
2812         switch(PropType){
2813                 case PROPERTY_NONE:
2814                         TitleList = &GeneralTitleList;
2815                         TitleListType = &GeneralTitleListType;
2816                         TitleListAltID = &GeneralTitleListAltID;
2817                         TitleListPID = &GeneralTitleListPID;
2818                         TitleListTokens = &GeneralTitleListTokens;
2819                         TitleListLanguage = &GeneralTitleListLanguage;
2820                         TitleListPref = &GeneralTitleListPref;  
2821                         break;
2822                 case PROPERTY_HOME:
2823                         TitleList = &HomeTitleList;
2824                         TitleListType = &HomeTitleListType;
2825                         TitleListAltID = &HomeTitleListAltID;
2826                         TitleListPID = &HomeTitleListPID;
2827                         TitleListTokens = &HomeTitleListTokens;
2828                         TitleListLanguage = &HomeTitleListLanguage;
2829                         TitleListPref = &HomeTitleListPref;     
2830                         break;
2831                 case PROPERTY_WORK:
2832                         TitleList = &BusinessTitleList;
2833                         TitleListType = &BusinessTitleListType;
2834                         TitleListAltID = &BusinessTitleListAltID;
2835                         TitleListPID = &BusinessTitleListPID;
2836                         TitleListTokens = &BusinessTitleListTokens;
2837                         TitleListLanguage = &BusinessTitleListLanguage; 
2838                         TitleListPref = &BusinessTitleListPref;
2839                         break;
2840         }
2842         intPrevValue = 6;
2843         bool PropertyMatched = FALSE;
2844                 
2845         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2846         intiter != SplitPoints.end(); ++intiter){
2847         
2848                 SLiter = SplitLength.find(intiter->first);
2849                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2850                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2851                 intPrevValue = intiter->second;
2852                 
2853                 // Process properties.
2854                 
2855                 size_t intPropertyValueLen = PropertyValue.Len();
2856                 
2857                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2858                         
2859                         PropertyValue.Trim();
2860                         PropertyValue.RemoveLast();
2861                         
2862                 }                               
2863                 
2864                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2865                         
2866                         PropertyValue.Remove(0, 1);
2867                         
2868                 }                               
2869                 
2870                 CaptureString(&PropertyValue, FALSE);
2871                 
2872                 ProcessStringValue(&PropertyName, "ALTID", TitleListAltID, &PropertyValue, TitleCount, &PropertyMatched);
2873                 ProcessStringValue(&PropertyName, "PID", TitleListPID, &PropertyValue, TitleCount, &PropertyMatched);
2874                 ProcessStringValue(&PropertyName, "LANGUAGE", TitleListLanguage, &PropertyValue, TitleCount, &PropertyMatched);
2875                 ProcessIntegerValue(&PropertyName, "PREF", TitleListPref, &PropertyValue, TitleCount, &PropertyMatched);
2876                 
2877                 if (PropertyMatched == TRUE){
2878                 
2879                         PropertyMatched = FALSE;
2880                         continue;
2881                 
2882                 }
2884                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2885         
2886         }
2887         
2888         // Add the data to the General/Home/Work address variables.
2889         
2890         CaptureString(&PropertySeg2, FALSE);
2892         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
2893         
2894         if (!PropertyTokens.IsEmpty()){
2895         
2896                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
2897                         
2898         }
2902 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
2904         std::map<int, int> SplitPoints;
2905         std::map<int, int> SplitLength;
2906         std::map<int, int>::iterator SLiter;                    
2907         wxString PropertyData;
2908         wxString PropertyName;
2909         wxString PropertyValue;
2910         wxString PropertyTokens;
2911         bool FirstToken = TRUE;
2912         int intPrevValue = 6;
2913         
2914         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2915         
2916         intPrevValue = 5;
2917         
2918         PropertyType PropType = PROPERTY_NONE;
2919                 
2920         // Look for type before continuing.
2921         
2922         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2923         
2924         // Setup the pointers.
2925         
2926         std::map<int, wxString> *RoleList = NULL;
2927         std::map<int, wxString> *RoleListAltID = NULL;
2928         std::map<int, wxString> *RoleListPID = NULL;
2929         std::map<int, wxString> *RoleListType = NULL;
2930         std::map<int, wxString> *RoleListTokens = NULL;
2931         std::map<int, wxString> *RoleListLanguage = NULL;
2932         std::map<int, int> *RoleListPref = NULL;
2933         
2934         // Setup blank lines for later on.
2935         
2936         switch(PropType){
2937                 case PROPERTY_NONE:
2938                         RoleList = &GeneralRoleList;
2939                         RoleListType = &GeneralRoleListType;
2940                         RoleListAltID = &GeneralRoleListAltID;
2941                         RoleListPID = &GeneralRoleListPID;
2942                         RoleListTokens = &GeneralRoleListTokens;
2943                         RoleListLanguage = &GeneralRoleListLanguage;
2944                         RoleListPref = &GeneralRoleListPref;    
2945                         break;
2946                 case PROPERTY_HOME:
2947                         RoleList = &HomeRoleList;
2948                         RoleListType = &HomeRoleListType;
2949                         RoleListAltID = &HomeRoleListAltID;
2950                         RoleListPID = &HomeRoleListPID;
2951                         RoleListTokens = &HomeRoleListTokens;
2952                         RoleListLanguage = &HomeRoleListLanguage;
2953                         RoleListPref = &HomeRoleListPref;       
2954                         break;
2955                 case PROPERTY_WORK:
2956                         RoleList = &BusinessRoleList;
2957                         RoleListType = &BusinessRoleListType;
2958                         RoleListAltID = &BusinessRoleListAltID;
2959                         RoleListPID = &BusinessRoleListPID;
2960                         RoleListTokens = &BusinessRoleListTokens;
2961                         RoleListLanguage = &BusinessRoleListLanguage;   
2962                         RoleListPref = &BusinessRoleListPref;
2963                         break;
2964         }
2966         intPrevValue = 5;
2967         bool PropertyMatched = FALSE;
2968                 
2969         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2970         intiter != SplitPoints.end(); ++intiter){
2971         
2972                 SLiter = SplitLength.find(intiter->first);
2973                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2974                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2975                 intPrevValue = intiter->second;
2976                 
2977                 // Process properties.
2978                 
2979                 size_t intPropertyValueLen = PropertyValue.Len();
2980                 
2981                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2982                         
2983                         PropertyValue.Trim();
2984                         PropertyValue.RemoveLast();
2985                         
2986                 }                               
2987                 
2988                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2989                         
2990                         PropertyValue.Remove(0, 1);
2991                         
2992                 }                               
2993                 
2994                 CaptureString(&PropertyValue, FALSE);
2995                 
2996                 ProcessStringValue(&PropertyName, "ALTID", RoleListAltID, &PropertyValue, RoleCount, &PropertyMatched);
2997                 ProcessStringValue(&PropertyName, "PID", RoleListPID, &PropertyValue, RoleCount, &PropertyMatched);
2998                 ProcessStringValue(&PropertyName, "LANGUAGE", RoleListLanguage, &PropertyValue, RoleCount, &PropertyMatched);
2999                 ProcessIntegerValue(&PropertyName, "PREF", RoleListPref, &PropertyValue, RoleCount, &PropertyMatched);
3000                 
3001                 if (PropertyMatched == TRUE){
3002                 
3003                         PropertyMatched = FALSE;
3004                         continue;
3005                 
3006                 }
3007                 
3008                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3009                 
3010         }
3011         
3012         // Add the data to the General/Home/Work address variables.
3013         
3014         CaptureString(&PropertySeg2, FALSE);
3016         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3017         
3018         if (!PropertyTokens.IsEmpty()){
3019         
3020                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3021                         
3022         }
3026 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3028         std::map<int, int> SplitPoints;
3029         std::map<int, int> SplitLength;
3030         std::map<int, int>::iterator SLiter;                    
3031         wxString PropertyData;
3032         wxString PropertyName;
3033         wxString PropertyValue;
3034         wxString PropertyTokens;
3035         bool FirstToken = TRUE;
3036         int intPrevValue = 5;
3037         
3038         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3039         
3040         intPrevValue = 4;
3041         
3042         PropertyType PropType = PROPERTY_NONE;
3043                 
3044         // Look for type before continuing.
3045         
3046         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3047         
3048         // Setup the pointers.
3049         
3050         std::map<int, wxString> *OrganisationsList = NULL;
3051         std::map<int, wxString> *OrganisationsListAltID = NULL;
3052         std::map<int, wxString> *OrganisationsListPID = NULL;
3053         std::map<int, wxString> *OrganisationsListType = NULL;
3054         std::map<int, wxString> *OrganisationsListTokens = NULL;
3055         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3056         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3057         std::map<int, int> *OrganisationsListPref = NULL;
3058         
3059         // Setup blank lines for later on.
3060         
3061         switch(PropType){
3062                 case PROPERTY_NONE:
3063                         OrganisationsList = &GeneralOrganisationsList;
3064                         OrganisationsListType = &GeneralOrganisationsListType;
3065                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3066                         OrganisationsListPID = &GeneralOrganisationsListPID;
3067                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3068                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3069                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3070                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3071                         break;
3072                 case PROPERTY_HOME:
3073                         OrganisationsList = &HomeOrganisationsList;
3074                         OrganisationsListType = &HomeOrganisationsListType;
3075                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3076                         OrganisationsListPID = &HomeOrganisationsListPID;
3077                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3078                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3079                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3080                         OrganisationsListPref = &HomeOrganisationsListPref;     
3081                         break;
3082                 case PROPERTY_WORK:
3083                         OrganisationsList = &BusinessOrganisationsList;
3084                         OrganisationsListType = &BusinessOrganisationsListType;
3085                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3086                         OrganisationsListPID = &BusinessOrganisationsListPID;
3087                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3088                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3089                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3090                         OrganisationsListPref = &BusinessOrganisationsListPref;
3091                         break;
3092         }
3094         intPrevValue = 4;
3095         bool PropertyMatched = FALSE;
3096                 
3097         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3098         intiter != SplitPoints.end(); ++intiter){
3099         
3100                 SLiter = SplitLength.find(intiter->first);
3101                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3102                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3103                 intPrevValue = intiter->second;
3104                 
3105                 // Process properties.
3106                 
3107                 size_t intPropertyValueLen = PropertyValue.Len();
3108                 
3109                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3110                         
3111                         PropertyValue.Trim();
3112                         PropertyValue.RemoveLast();
3113                         
3114                 }                               
3115                 
3116                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3117                         
3118                         PropertyValue.Remove(0, 1);
3119                         
3120                 }                               
3121                 
3122                 CaptureString(&PropertyValue, FALSE);
3123                 
3124                 ProcessStringValue(&PropertyName, "ALTID", OrganisationsListAltID, &PropertyValue, OrganisationCount, &PropertyMatched);
3125                 ProcessStringValue(&PropertyName, "PID", OrganisationsListPID, &PropertyValue, OrganisationCount, &PropertyMatched);
3126                 ProcessStringValue(&PropertyName, "LANGUAGE", OrganisationsListLanguage, &PropertyValue, OrganisationCount, &PropertyMatched);
3127                 ProcessStringValue(&PropertyName, "SORT-AS", OrganisationsListSortAs, &PropertyValue, OrganisationCount, &PropertyMatched);
3128                 ProcessIntegerValue(&PropertyName, "PREF", OrganisationsListPref, &PropertyValue, OrganisationCount, &PropertyMatched);
3129                 
3130                 if (PropertyMatched == TRUE){
3131                 
3132                         PropertyMatched = FALSE;
3133                         continue;
3134                 
3135                 }
3136                 
3137                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3139         }
3140         
3141         // Add the data to the General/Home/Work address variables.
3142         
3143         CaptureString(&PropertySeg2, FALSE);
3145         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3146         
3147         if (!PropertyTokens.IsEmpty()){
3148         
3149                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3150                         
3151         }
3155 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3157         std::map<int, int> SplitPoints;
3158         std::map<int, int> SplitLength;
3159         std::map<int, int>::iterator SLiter;                    
3160         wxString PropertyData;
3161         wxString PropertyName;
3162         wxString PropertyValue;
3163         wxString PropertyTokens;
3164         bool FirstToken = TRUE;
3165         int intPrevValue = 6;
3166         
3167         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3168         
3169         intPrevValue = 5;
3170         
3171         PropertyType PropType = PROPERTY_NONE;
3172                 
3173         // Look for type before continuing.
3174         
3175         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3176         
3177         // Setup the pointers.
3178         
3179         std::map<int, wxString> *NoteList = NULL;
3180         std::map<int, wxString> *NoteListAltID = NULL;
3181         std::map<int, wxString> *NoteListPID = NULL;
3182         std::map<int, wxString> *NoteListType = NULL;
3183         std::map<int, wxString> *NoteListTokens = NULL;
3184         std::map<int, wxString> *NoteListLanguage = NULL;
3185         std::map<int, int> *NoteListPref = NULL;
3186         
3187         // Setup blank lines for later on.
3188         
3189         switch(PropType){
3190                 case PROPERTY_NONE:
3191                         NoteList = &GeneralNoteList;
3192                         NoteListType = &GeneralNoteListType;
3193                         NoteListAltID = &GeneralNoteListAltID;
3194                         NoteListPID = &GeneralNoteListPID;
3195                         NoteListTokens = &GeneralNoteListTokens;
3196                         NoteListLanguage = &GeneralNoteListLanguage;
3197                         NoteListPref = &GeneralNoteListPref;    
3198                         break;
3199                 case PROPERTY_HOME:
3200                         NoteList = &HomeNoteList;
3201                         NoteListType = &HomeNoteListType;
3202                         NoteListAltID = &HomeNoteListAltID;
3203                         NoteListPID = &HomeNoteListPID;
3204                         NoteListTokens = &HomeNoteListTokens;
3205                         NoteListLanguage = &HomeNoteListLanguage;
3206                         NoteListPref = &HomeNoteListPref;       
3207                         break;
3208                 case PROPERTY_WORK:
3209                         NoteList = &BusinessNoteList;
3210                         NoteListType = &BusinessNoteListType;
3211                         NoteListAltID = &BusinessNoteListAltID;
3212                         NoteListPID = &BusinessNoteListPID;
3213                         NoteListTokens = &BusinessNoteListTokens;
3214                         NoteListLanguage = &BusinessNoteListLanguage;   
3215                         NoteListPref = &BusinessNoteListPref;
3216                         break;
3217         }
3219         intPrevValue = 5;
3220         bool PropertyMatched = FALSE;
3221                 
3222         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3223         intiter != SplitPoints.end(); ++intiter){
3224         
3225                 SLiter = SplitLength.find(intiter->first);
3226                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3227                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3228                 intPrevValue = intiter->second;
3229                 
3230                 // Process properties.
3231                 
3232                 size_t intPropertyValueLen = PropertyValue.Len();
3233                 
3234                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3235                         
3236                         PropertyValue.Trim();
3237                         PropertyValue.RemoveLast();
3238                         
3239                 }                               
3240                 
3241                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3242                         
3243                         PropertyValue.Remove(0, 1);
3244                         
3245                 }                               
3246                 
3247                 CaptureString(&PropertyValue, FALSE);
3248                 
3249                 ProcessStringValue(&PropertyName, "ALTID", NoteListAltID, &PropertyValue, NoteCount, &PropertyMatched);
3250                 ProcessStringValue(&PropertyName, "PID", NoteListPID, &PropertyValue, NoteCount, &PropertyMatched);
3251                 ProcessStringValue(&PropertyName, "LANGUAGE", NoteListLanguage, &PropertyValue, NoteCount, &PropertyMatched);
3252                 ProcessIntegerValue(&PropertyName, "PREF", NoteListPref, &PropertyValue, NoteCount, &PropertyMatched);
3253                 
3254                 if (PropertyMatched == TRUE){
3255                 
3256                         PropertyMatched = FALSE;
3257                         continue;
3258                 
3259                 }
3261                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3262         
3263         }
3264         
3265         // Add the data to the General/Home/Work address variables.
3266         
3267         CaptureString(&PropertySeg2, FALSE);
3269         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3270         
3271         if (!PropertyTokens.IsEmpty()){
3272         
3273                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3274                         
3275         }
3279 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3281         std::map<int, int> SplitPoints;
3282         std::map<int, int> SplitLength;
3283         std::map<int, int>::iterator SLiter;                    
3284         wxString PropertyData;
3285         wxString PropertyName;
3286         wxString PropertyValue;
3287         wxString PropertyTokens;
3288         bool FirstToken = TRUE;
3289         int intPrevValue = 12;
3290         
3291         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3292         
3293         intPrevValue = 11;
3294         
3295         PropertyType PropType = PROPERTY_NONE;
3296                 
3297         // Look for type before continuing.
3298         
3299         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3300         
3301         // Setup blank lines for later on.
3302         
3303         switch(PropType){
3304                 case PROPERTY_NONE:
3305                         break;
3306                 case PROPERTY_HOME:
3307                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3308                         break;
3309                 case PROPERTY_WORK:
3310                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3311                         break;
3312         }
3314         intPrevValue = 11;
3315         bool PropertyMatched = FALSE;
3316                 
3317         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3318         intiter != SplitPoints.end(); ++intiter){
3319         
3320                 SLiter = SplitLength.find(intiter->first);
3321                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3322                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3323                 intPrevValue = intiter->second;
3324                 
3325                 // Process properties.
3326                 
3327                 size_t intPropertyValueLen = PropertyValue.Len();
3328                 
3329                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3330                         
3331                         PropertyValue.Trim();
3332                         PropertyValue.RemoveLast();
3333                         
3334                 }                               
3335                 
3336                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3337                         
3338                         PropertyValue.Remove(0, 1);
3339                         
3340                 }                               
3341                 
3342                 CaptureString(&PropertyValue, FALSE);
3343                 
3344                 ProcessStringValue(&PropertyName, "ALTID", &CategoriesListAltID, &PropertyValue, CategoryCount, &PropertyMatched);
3345                 ProcessStringValue(&PropertyName, "PID", &CategoriesListPID, &PropertyValue, CategoryCount, &PropertyMatched);
3346                 ProcessStringValue(&PropertyName, "LANGUAGE", &CategoriesListLanguage, &PropertyValue, CategoryCount, &PropertyMatched);
3347                 ProcessIntegerValue(&PropertyName, "PREF", &CategoriesListPref, &PropertyValue, CategoryCount, &PropertyMatched);
3348                 
3349                 if (PropertyMatched == TRUE){
3350                 
3351                         PropertyMatched = FALSE;
3352                         continue;
3353                 
3354                 }
3356                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3357         
3358         }
3359         
3360         // Deal with multiple categories.
3361         
3362         int intOrigCatCount = *CategoryCount;
3363         bool FirstCategoryProcessed = TRUE;
3364         bool AfterFirstToken = FALSE;
3365         int intSplitSize = 0;
3366         int intSplitsFound = 0;
3367         int intSplitSeek = 0;
3368         int intPropertyLen = PropertySeg2.Len();
3369         
3370         SplitPoints.clear();
3371         SplitLength.clear();
3372         intPrevValue = 0;
3373         
3374         for (int i = 0; i <= intPropertyLen; i++){
3375         
3376                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3377         
3378                         continue;
3379                 
3380                 }
3381         
3382                 intSplitSize++;
3383         
3384                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3385         
3386                         if (AfterFirstToken == TRUE){
3387                 
3388                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3389                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3390                         
3391                         } else {
3392                         
3393                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3394                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3395                                 AfterFirstToken = TRUE;
3397                         }
3399                         intSplitsFound++;
3400                         intSplitSeek = i;
3401                         intSplitSize = 0;                               
3402         
3403                 }                       
3404         
3405         }
3406         
3407         if (SplitPoints.size() > 0){
3408         
3409                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3410                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3411         
3412         }
3413         
3414         if (SplitPoints.size() == 0){
3415         
3416                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3417         
3418                 if (!PropertyTokens.IsEmpty()){
3419                 
3420                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3421                 
3422                 }
3423         
3424         }
3425         
3426         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3427         intiter != SplitPoints.end(); ++intiter){
3428         
3429                 SLiter = SplitLength.find(intiter->first);
3430         
3431                 intPrevValue = intiter->second;
3432         
3433                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3434                 
3435                 // Add the data to the General/Home/Work address variables.
3436         
3437                 // Trim any whitespace from the start and end.
3438         
3439                 PropertyData = PropertyData.Trim(FALSE);
3440                 PropertyData = PropertyData.Trim(TRUE); 
3441         
3442                 CaptureString(&PropertyData, FALSE);
3443                 
3444                 if (FirstCategoryProcessed == TRUE){
3445                 
3446                         FirstCategoryProcessed = FALSE;
3447                         
3448                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3449         
3450                         if (!PropertyTokens.IsEmpty()){
3451                 
3452                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3453                 
3454                         }
3455                         
3456                         continue;
3457                 
3458                 } else {
3460                         (*CategoryCount)++;
3461                         
3462                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3463                 
3464                         if (!PropertyTokens.IsEmpty()){
3465                 
3466                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3467                 
3468                         }
3469                 
3470                 }
3471                 
3472                 // Copy the properties to each of the categories (if it exists).
3473                 
3474                 if (!PropertyTokens.IsEmpty()){
3475                 
3476                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3477                 
3478                 }
3479                 
3480                 // Check if ALTID was used.
3481                 
3482                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3483                 
3484                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3485                 
3486                 }
3487                 
3488                 // Check if PID was used.
3489                 
3490                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
3491                 
3492                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
3493                 
3494                 }
3495         
3496                 // Check if PREF was used.
3497         
3498                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
3499                 
3500                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
3501                 
3502                 }
3503                 
3504                 // Check if LANGUAGE was used.
3505                 
3506                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
3507                 
3508                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
3509                 
3510                 }
3511                 
3512                 // Check if TYPE was used.
3513                 
3514                 switch(PropType){
3515                         case PROPERTY_NONE:
3516                                 break;
3517                         case PROPERTY_HOME:
3518                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3519                                 break;
3520                         case PROPERTY_WORK:
3521                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3522                                 break;
3523                 }
3524         
3525         }
3529 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
3531         size_t intPropertyLen = PropertySeg1.Len();
3532         std::map<int, int> SplitPoints;
3533         std::map<int, int> SplitLength;
3534         std::map<int, int>::iterator SLiter;                    
3535         wxString PropertyData;
3536         wxString PropertyName;
3537         wxString PropertyValue;
3538         wxString PropertyTokens;
3539         bool FirstToken = TRUE;
3540         int intSplitsFound = 0;
3541         int intSplitSize = 0;
3542         int intPrevValue = 7;
3543         
3544         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3545         
3546         intPrevValue = 6;
3547         
3548         PropertyType PropType = PROPERTY_NONE;
3549                 
3550         // Look for type before continuing.
3551         
3552         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3554         intPrevValue = 6;
3555         bool PropertyMatched = FALSE;
3557         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3558         intiter != SplitPoints.end(); ++intiter){
3559         
3560                 SLiter = SplitLength.find(intiter->first);
3561                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3562                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3563                 intPrevValue = intiter->second;
3564                 
3565                 // Process properties.
3566                 
3567                 size_t intPropertyValueLen = PropertyValue.Len();
3568                 
3569                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3570                         
3571                         PropertyValue.Trim();
3572                         PropertyValue.RemoveLast();
3573                         
3574                 }                               
3575                 
3576                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3577                         
3578                         PropertyValue.Remove(0, 1);
3579                         
3580                 }
3581                 
3582                 CaptureString(&PropertyValue, FALSE);
3583                 
3584                 ProcessStringValue(&PropertyName, "ALTID", &PicturesListAltID, &PropertyValue, PhotoCount, &PropertyMatched);
3585                 ProcessStringValue(&PropertyName, "PID", &PicturesListPID, &PropertyValue, PhotoCount, &PropertyMatched);
3586                 ProcessStringValue(&PropertyName, "MEDIATYPE", &PicturesListMediatype, &PropertyValue, PhotoCount, &PropertyMatched);
3587                 ProcessIntegerValue(&PropertyName, "PREF", &PicturesListPref, &PropertyValue, PhotoCount, &PropertyMatched);
3588                 
3589                 if (PropertyMatched == TRUE){
3590                 
3591                         PropertyMatched = FALSE;
3592                         continue;
3593                 
3594                 }
3596                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3597                         
3598         }       
3599         
3600         intPropertyLen = PropertySeg2.Len();
3601         SplitPoints.clear();
3602         SplitLength.clear();
3603         intSplitsFound = 0;
3604         intSplitSize = 0;
3605         intPrevValue = 0;                       
3606         
3607         CaptureString(&PropertySeg2, FALSE);
3608         
3609         for (int i = 0; i <= intPropertyLen; i++){
3611                 intSplitSize++;
3612         
3613                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3614         
3615                         intSplitsFound++;
3616                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3617                         
3618                         if (intSplitsFound == 6){ 
3619                         
3620                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3621                                 break; 
3622                                 
3623                         } else {
3624                         
3625                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3626                         
3627                         }
3628                         
3629                         intSplitSize = 0;                                       
3630         
3631                 }
3633         }
3634         
3635         wxString wxSPhotoURI;
3636         wxString wxSPhotoMIME;
3637         wxString wxSPhotoEncoding;
3638         wxString wxSPhotoData;
3639         std::string base64enc;
3640         
3641         if (intSplitsFound == 0){
3642         
3643         } else {
3644         
3645                 std::map<int, int>::iterator striter;
3646         
3647                 striter = SplitLength.find(1);
3648         
3649                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3650         
3651                 while (wSTDataType.HasMoreTokens() == TRUE){
3652                 
3653                         wxSPhotoURI = wSTDataType.GetNextToken();
3654                         wxSPhotoMIME = wSTDataType.GetNextToken();
3655                         break;
3656                 
3657                 }                       
3658         
3659                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3660         
3661                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3662                 
3663                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3664                         wxSPhotoData = wSTDataInfo.GetNextToken();
3665                         base64enc = wxSPhotoData.mb_str();
3666                         break;
3667                 
3668                 }
3669         
3670         }
3671         
3672         // Add the data to the General/Home/Work address variables.
3673         
3674         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
3675         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
3676         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
3677         
3678         switch(PropType){
3679                 case PROPERTY_NONE:
3680                         break;
3681                 case PROPERTY_HOME:
3682                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
3683                         break;
3684                 case PROPERTY_WORK:
3685                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
3686                         break;
3687         }
3688         
3689         if (!PropertyTokens.IsEmpty()){
3691                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
3692         
3693         }
3697 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
3699         size_t intPropertyLen = PropertySeg1.Len();
3700         std::map<int, int> SplitPoints;
3701         std::map<int, int> SplitLength;
3702         std::map<int, int>::iterator SLiter;                    
3703         wxString PropertyData;
3704         wxString PropertyName;
3705         wxString PropertyValue;
3706         wxString PropertyTokens;
3707         bool FirstToken = TRUE;
3708         int intSplitsFound = 0;
3709         int intSplitSize = 0;
3710         int intPrevValue = 6;
3711         
3712         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3713         
3714         intPrevValue = 5;
3715         
3716         PropertyType PropType = PROPERTY_NONE;
3717                 
3718         // Look for type before continuing.
3719         
3720         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3722         intPrevValue = 5;
3723         bool PropertyMatched = FALSE;
3725         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3726         intiter != SplitPoints.end(); ++intiter){
3727         
3728                 SLiter = SplitLength.find(intiter->first);
3729                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3730                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3731                 intPrevValue = intiter->second;
3732                 
3733                 // Process properties.
3734                 
3735                 size_t intPropertyValueLen = PropertyValue.Len();
3736                 
3737                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3738                         
3739                         PropertyValue.Trim();
3740                         PropertyValue.RemoveLast();
3741                         
3742                 }                               
3743                 
3744                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3745                         
3746                         PropertyValue.Remove(0, 1);
3747                         
3748                 }
3749                 
3750                 CaptureString(&PropertyValue, FALSE);
3751                 
3752                 ProcessStringValue(&PropertyName, "ALTID", &LogosListAltID, &PropertyValue, LogoCount, &PropertyMatched);
3753                 ProcessStringValue(&PropertyName, "PID", &LogosListPID, &PropertyValue, LogoCount, &PropertyMatched);
3754                 ProcessStringValue(&PropertyName, "MEDIATYPE", &LogosListMediatype, &PropertyValue, LogoCount, &PropertyMatched);
3755                 ProcessIntegerValue(&PropertyName, "PREF", &LogosListPref, &PropertyValue, LogoCount, &PropertyMatched);
3756                 
3757                 if (PropertyMatched == TRUE){
3758                 
3759                         PropertyMatched = FALSE;
3760                         continue;
3761                 
3762                 }
3764                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3765         
3766         }       
3767         
3768         intPropertyLen = PropertySeg2.Len();
3769         SplitPoints.clear();
3770         SplitLength.clear();
3771         intSplitsFound = 0;
3772         intSplitSize = 0;
3773         intPrevValue = 0;                       
3774         
3775         CaptureString(&PropertySeg2, FALSE);
3776         
3777         for (int i = 0; i <= intPropertyLen; i++){
3779                 intSplitSize++;
3780         
3781                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3782         
3783                         intSplitsFound++;
3784                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3785                         
3786                         if (intSplitsFound == 6){ 
3787                         
3788                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3789                                 break; 
3790                                 
3791                         } else {
3792                         
3793                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3794                         
3795                         }
3796                         
3797                         intSplitSize = 0;                                       
3798         
3799                 }
3801         }
3802         
3803         wxString wxSPhotoURI;
3804         wxString wxSPhotoMIME;
3805         wxString wxSPhotoEncoding;
3806         wxString wxSPhotoData;
3807         std::string base64enc;
3808         
3809         if (intSplitsFound == 0){
3810         
3811         } else {
3812         
3813                 std::map<int, int>::iterator striter;
3814         
3815                 striter = SplitLength.find(1);
3816         
3817                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3818         
3819                 while (wSTDataType.HasMoreTokens() == TRUE){
3820                 
3821                         wxSPhotoURI = wSTDataType.GetNextToken();
3822                         wxSPhotoMIME = wSTDataType.GetNextToken();
3823                         break;
3824                 
3825                 }                       
3826         
3827                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3828         
3829                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3830                 
3831                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3832                         wxSPhotoData = wSTDataInfo.GetNextToken();
3833                         base64enc = wxSPhotoData.mb_str();
3834                         break;
3835                 
3836                 }
3837         
3838         }
3839         
3840         // Add the data to the General/Home/Work address variables.
3841                 
3842         LogosList.insert(std::make_pair(*LogoCount, base64enc));
3843         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
3844         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
3845         
3846         switch(PropType){
3847                 case PROPERTY_NONE:
3848                         break;
3849                 case PROPERTY_HOME:
3850                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
3851                         break;
3852                 case PROPERTY_WORK:
3853                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
3854                         break;
3855         }
3856         
3857         if (!PropertyTokens.IsEmpty()){
3859                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
3860         
3861         }
3865 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
3867         size_t intPropertyLen = PropertySeg1.Len();
3868         std::map<int, int> SplitPoints;
3869         std::map<int, int> SplitLength;
3870         std::map<int, int>::iterator SLiter;                    
3871         wxString PropertyData;
3872         wxString PropertyName;
3873         wxString PropertyValue;
3874         wxString PropertyTokens;
3875         bool FirstToken = TRUE;
3876         int intSplitsFound = 0;
3877         int intSplitSize = 0;
3878         int intPrevValue = 7;
3879         
3880         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3881         
3882         intPrevValue = 6;
3883         
3884         PropertyType PropType = PROPERTY_NONE;
3885         
3886         // Look for type before continuing.                     
3888         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3890         intPrevValue = 6;
3891         bool PropertyMatched = FALSE;
3893         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3894         intiter != SplitPoints.end(); ++intiter){
3895         
3896                 SLiter = SplitLength.find(intiter->first);
3897                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3898                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3899                 intPrevValue = intiter->second;
3900                 
3901                 // Process properties.
3902                 
3903                 size_t intPropertyValueLen = PropertyValue.Len();
3904                 
3905                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3906                         
3907                         PropertyValue.Trim();
3908                         PropertyValue.RemoveLast();
3909                         
3910                 }                               
3911                 
3912                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3913                         
3914                         PropertyValue.Remove(0, 1);
3915                         
3916                 }                       
3917                 
3918                 CaptureString(&PropertyValue, FALSE);
3919                 
3920                 ProcessStringValue(&PropertyName, "ALTID", &SoundsListAltID, &PropertyValue, SoundCount, &PropertyMatched);
3921                 ProcessStringValue(&PropertyName, "PID", &SoundsListPID, &PropertyValue, SoundCount, &PropertyMatched);
3922                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SoundsListMediatype, &PropertyValue, SoundCount, &PropertyMatched);
3923                 ProcessStringValue(&PropertyName, "LANGUAGE", &SoundsListLanguage, &PropertyValue, SoundCount, &PropertyMatched);
3924                 ProcessIntegerValue(&PropertyName, "PREF", &SoundsListPref, &PropertyValue, SoundCount, &PropertyMatched);
3925                 
3926                 if (PropertyMatched == TRUE){
3927                 
3928                         PropertyMatched = FALSE;
3929                         continue;
3930                 
3931                 }
3933                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3934         
3935         }       
3936         
3937         intPropertyLen = PropertySeg2.Len();
3938         SplitPoints.clear();
3939         SplitLength.clear();
3940         intSplitsFound = 0;
3941         intSplitSize = 0;
3942         intPrevValue = 0;
3943         
3944         CaptureString(&PropertySeg2, FALSE);
3945         
3946         for (int i = 0; i <= intPropertyLen; i++){
3948                 intSplitSize++;
3949         
3950                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3951         
3952                         intSplitsFound++;
3953                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3954                         
3955                         if (intSplitsFound == 6){ 
3956                         
3957                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3958                                 break; 
3959                                 
3960                         } else {
3961                         
3962                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3963                         
3964                         }
3965                         
3966                         intSplitSize = 0;                                       
3967         
3968                 }
3970         }
3971         
3972         wxString wxSSoundURI;
3973         wxString wxSSoundMIME;
3974         wxString wxSSoundEncoding;
3975         wxString wxSSoundData;
3976         std::string base64enc;
3977         
3978         if (intSplitsFound == 0){
3979         
3980         } else {
3981         
3982                 std::map<int, int>::iterator striter;
3983         
3984                 striter = SplitLength.find(1);
3985         
3986                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3987         
3988                 while (wSTDataType.HasMoreTokens() == TRUE){
3989                 
3990                         wxSSoundURI = wSTDataType.GetNextToken();
3991                         wxSSoundMIME = wSTDataType.GetNextToken();
3992                         break;
3993                 
3994                 }                       
3995         
3996                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3997         
3998                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3999                 
4000                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4001                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4002                         base64enc = wxSSoundData.mb_str();
4003                         break;
4004                 
4005                 }
4006         
4007         }
4008         
4009         // Add the data to the General/Home/Work address variables.
4010                 
4011         switch(PropType){
4012                 case PROPERTY_NONE:
4013                         break;
4014                 case PROPERTY_HOME:
4015                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4016                         break;
4017                 case PROPERTY_WORK:
4018                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4019                         break;
4020         }
4021         
4022         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4023         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4024         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4025         
4026         if (!PropertyTokens.IsEmpty()){
4027         
4028                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4029         
4030         }
4031         
4034 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4036         size_t intPropertyLen = PropertySeg1.Len();
4037         std::map<int, int> SplitPoints;
4038         std::map<int, int> SplitLength;
4039         std::map<int, int>::iterator SLiter;                    
4040         wxString PropertyData;
4041         wxString PropertyName;
4042         wxString PropertyValue;
4043         wxString PropertyTokens;
4044         bool FirstToken = TRUE;
4045         int intSplitsFound = 0;
4046         int intSplitSize = 0;
4047         int intPrevValue = 8;
4048         
4049         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4050         
4051         intPrevValue = 7;
4052         
4053         PropertyType PropType = PROPERTY_NONE;
4054         
4055         // Look for type before continuing.                     
4057         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4059         intPrevValue = 7;
4060         bool PropertyMatched = FALSE;
4062         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4063         intiter != SplitPoints.end(); ++intiter){
4064         
4065                 SLiter = SplitLength.find(intiter->first);
4066                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4067                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4068                 intPrevValue = intiter->second;
4069                 
4070                 // Process properties.
4071                 
4072                 size_t intPropertyValueLen = PropertyValue.Len();
4073                 
4074                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4075                         
4076                         PropertyValue.Trim();
4077                         PropertyValue.RemoveLast();
4078                         
4079                 }                               
4080                 
4081                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4082                         
4083                         PropertyValue.Remove(0, 1);
4084                         
4085                 }                       
4086                 
4087                 CaptureString(&PropertyValue, FALSE);
4088                 
4089                 ProcessStringValue(&PropertyName, "ALTID", &CalendarListAltID, &PropertyValue, CalURICount, &PropertyMatched);
4090                 ProcessStringValue(&PropertyName, "PID", &CalendarListPID, &PropertyValue, CalURICount, &PropertyMatched);
4091                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarListMediatype, &PropertyValue, CalURICount, &PropertyMatched);
4092                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarListPref, &PropertyValue, CalURICount, &PropertyMatched);
4093                 
4094                 if (PropertyMatched == TRUE){
4095                 
4096                         PropertyMatched = FALSE;
4097                         continue;
4098                 
4099                 }
4101                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4102         
4103         }       
4104         
4105         intPropertyLen = PropertySeg2.Len();
4106         SplitPoints.clear();
4107         SplitLength.clear();
4108         intSplitsFound = 0;
4109         intSplitSize = 0;
4110         intPrevValue = 0;
4111         
4112         CaptureString(&PropertySeg2, FALSE);
4113         
4114         // Add the data to the General/Home/Work address variables.
4115                 
4116         switch(PropType){
4117                 case PROPERTY_NONE:
4118                         break;
4119                 case PROPERTY_HOME:
4120                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4121                         break;
4122                 case PROPERTY_WORK:
4123                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4124                         break;
4125         }
4126         
4127         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4128         
4129         if (!PropertyTokens.IsEmpty()){
4130         
4131                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4132         
4133         }
4137 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4139         size_t intPropertyLen = PropertySeg1.Len();
4140         std::map<int, int> SplitPoints;
4141         std::map<int, int> SplitLength;
4142         std::map<int, int>::iterator SLiter;                    
4143         wxString PropertyData;
4144         wxString PropertyName;
4145         wxString PropertyValue;
4146         wxString PropertyTokens;
4147         bool FirstToken = TRUE;
4148         int intSplitsFound = 0;
4149         int intSplitSize = 0;
4150         int intPrevValue = 8;
4151         
4152         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4153         
4154         intPrevValue = 7;
4155         
4156         PropertyType PropType = PROPERTY_NONE;
4157         
4158         // Look for type before continuing.                     
4160         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4162         intPrevValue = 7;
4163         bool PropertyMatched = FALSE;
4165         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4166         intiter != SplitPoints.end(); ++intiter){
4167         
4168                 SLiter = SplitLength.find(intiter->first);
4169                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4170                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4171                 intPrevValue = intiter->second;
4172                 
4173                 // Process properties.
4174                 
4175                 size_t intPropertyValueLen = PropertyValue.Len();
4176                 
4177                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4178                         
4179                         PropertyValue.Trim();
4180                         PropertyValue.RemoveLast();
4181                         
4182                 }                               
4183                 
4184                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4185                         
4186                         PropertyValue.Remove(0, 1);
4187                         
4188                 }                       
4189                 
4190                 CaptureString(&PropertyValue, FALSE);
4191                 
4192                 ProcessStringValue(&PropertyName, "ALTID", &CalendarRequestListAltID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4193                 ProcessStringValue(&PropertyName, "PID", &CalendarRequestListPID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4194                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarRequestListMediatype, &PropertyValue, CalAdrURICount, &PropertyMatched);
4195                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarRequestListPref, &PropertyValue, CalAdrURICount, &PropertyMatched);
4196                 
4197                 if (PropertyMatched == TRUE){
4198                 
4199                         PropertyMatched = FALSE;
4200                         continue;
4201                 
4202                 }
4204                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4205         
4206         }       
4207         
4208         intPropertyLen = PropertySeg2.Len();
4209         SplitPoints.clear();
4210         SplitLength.clear();
4211         intSplitsFound = 0;
4212         intSplitSize = 0;
4213         intPrevValue = 0;
4214         
4215         CaptureString(&PropertySeg2, FALSE);
4216         
4217         // Add the data to the General/Home/Work address variables.
4218                 
4219         switch(PropType){
4220                 case PROPERTY_NONE:
4221                         break;
4222                 case PROPERTY_HOME:
4223                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4224                         break;
4225                 case PROPERTY_WORK:
4226                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4227                         break;
4228         }
4229         
4230         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4231         
4232         if (!PropertyTokens.IsEmpty()){
4233         
4234                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4235         
4236         }       
4237         
4240 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4242         size_t intPropertyLen = PropertySeg1.Len();
4243         std::map<int, int> SplitPoints;
4244         std::map<int, int> SplitLength;
4245         std::map<int, int>::iterator SLiter;                    
4246         wxString PropertyData;
4247         wxString PropertyName;
4248         wxString PropertyValue;
4249         wxString PropertyTokens;
4250         bool FirstToken = TRUE;
4251         int intSplitsFound = 0;
4252         int intSplitSize = 0;
4253         int intPrevValue = 7;
4254         
4255         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4256         
4257         intPrevValue = 6;
4258         
4259         PropertyType PropType = PROPERTY_NONE;
4260         
4261         // Look for type before continuing.                     
4263         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4265         intPrevValue = 6;
4266         bool PropertyMatched = FALSE;
4268         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4269         intiter != SplitPoints.end(); ++intiter){
4270         
4271                 SLiter = SplitLength.find(intiter->first);
4272                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4273                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4274                 intPrevValue = intiter->second;
4275                 
4276                 // Process properties.
4277                 
4278                 size_t intPropertyValueLen = PropertyValue.Len();
4279                 
4280                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4281                         
4282                         PropertyValue.Trim();
4283                         PropertyValue.RemoveLast();
4284                         
4285                 }                               
4286                 
4287                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4288                         
4289                         PropertyValue.Remove(0, 1);
4290                         
4291                 }                       
4292                 
4293                 CaptureString(&PropertyValue, FALSE);
4294                 
4295                 ProcessStringValue(&PropertyName, "ALTID", &FreeBusyListAltID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4296                 ProcessStringValue(&PropertyName, "PID", &FreeBusyListPID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4297                 ProcessStringValue(&PropertyName, "MEDIATYPE", &FreeBusyListMediatype, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4298                 ProcessIntegerValue(&PropertyName, "PREF", &FreeBusyListPref, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4299                 
4300                 if (PropertyMatched == TRUE){
4301                 
4302                         PropertyMatched = FALSE;
4303                         continue;
4304                 
4305                 }
4307                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4308         
4309         }       
4310         
4311         intPropertyLen = PropertySeg2.Len();
4312         SplitPoints.clear();
4313         SplitLength.clear();
4314         intSplitsFound = 0;
4315         intSplitSize = 0;
4316         intPrevValue = 0;
4317         
4318         CaptureString(&PropertySeg2, FALSE);
4319         
4320         // Add the data to the General/Home/Work address variables.
4321                 
4322         switch(PropType){
4323                 case PROPERTY_NONE:
4324                         break;
4325                 case PROPERTY_HOME:
4326                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
4327                         break;
4328                 case PROPERTY_WORK:
4329                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
4330                         break;
4331         }
4332         
4333         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
4334         
4335         if (!PropertyTokens.IsEmpty()){
4336         
4337                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
4338         
4339         }
4343 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
4345         size_t intPropertyLen = PropertySeg1.Len();
4346         std::map<int, int> SplitPoints;
4347         std::map<int, int> SplitLength;
4348         std::map<int, int>::iterator SLiter;                    
4349         wxString PropertyData;
4350         wxString PropertyName;
4351         wxString PropertyValue;
4352         wxString PropertyTokens;
4353         bool FirstToken = TRUE;
4354         int intSplitsFound = 0;
4355         int intSplitSize = 0;
4356         int intPrevValue = 5;
4357         
4358         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4359         
4360         intPrevValue = 4;
4361         
4362         PropertyType PropType = PROPERTY_NONE;
4363         
4364         // Look for type before continuing.
4366         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4368         intPrevValue = 4;
4369         bool PropertyMatched = FALSE;
4371         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4372         intiter != SplitPoints.end(); ++intiter){
4373         
4374                 SLiter = SplitLength.find(intiter->first);
4375                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4376                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4377                 intPrevValue = intiter->second;
4378                 
4379                 // Process properties.
4380                 
4381                 size_t intPropertyValueLen = PropertyValue.Len();
4382                 
4383                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4384                         
4385                         PropertyValue.Trim();
4386                         PropertyValue.RemoveLast();
4387                         
4388                 }                               
4389                 
4390                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4391                         
4392                         PropertyValue.Remove(0, 1);
4393                         
4394                 }
4395                 
4396                 ProcessStringValue(&PropertyName, "ALTID", &KeyListAltID, &PropertyValue, KeyCount, &PropertyMatched);
4397                 ProcessStringValue(&PropertyName, "PID", &KeyListPID, &PropertyValue, KeyCount, &PropertyMatched);
4398                 ProcessIntegerValue(&PropertyName, "PREF", &KeyListPref, &PropertyValue, KeyCount, &PropertyMatched);
4399                 
4400                 if (PropertyMatched == TRUE){
4401                 
4402                         PropertyMatched = FALSE;
4403                         continue;
4404                 
4405                 }
4407                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4408         
4409         }                               
4410         
4411         intPropertyLen = PropertySeg2.Len();
4412         SplitPoints.clear();
4413         SplitLength.clear();
4414         intSplitsFound = 0;
4415         intSplitSize = 0;
4416         intPrevValue = 0;                       
4417         
4418         for (int i = 0; i <= intPropertyLen; i++){
4420                 intSplitSize++;
4421         
4422                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4423         
4424                         intSplitsFound++;
4425                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4426                         
4427                         if (intSplitsFound == 6){ 
4428                         
4429                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4430                                 break; 
4431                                 
4432                         } else {
4433                         
4434                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4435                         
4436                         }
4437                         
4438                         intSplitSize = 0;                                       
4439         
4440                 }
4442         }
4443         
4444         wxString wxSKeyURI;
4445         wxString wxSKeyMIME;
4446         wxString wxSKeyEncoding;
4447         wxString wxSKeyData;
4448         std::string base64enc;
4449         
4450         if (intSplitsFound == 0){
4451         
4452         } else {
4453         
4454                 std::map<int, int>::iterator striter;
4455         
4456                 striter = SplitLength.find(1);
4457         
4458                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4459         
4460                 while (wSTDataType.HasMoreTokens() == TRUE){
4461                 
4462                         wxSKeyURI = wSTDataType.GetNextToken();
4463                         wxSKeyMIME = wSTDataType.GetNextToken();
4464                         break;
4465                 
4466                 }                       
4467         
4468                 if (wxSKeyURI == wxT("data")){
4469                 
4470                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4471         
4472                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4473                 
4474                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
4475                                 wxSKeyData = wSTDataInfo.GetNextToken();
4476                                 break;
4477                 
4478                         }
4479                 
4480                 }
4481         
4482         }
4483         
4484         // Add the data to the General/Home/Work address variables.
4485         
4486         if (wxSKeyURI == wxT("data")){
4487                 
4488                 KeyListDataEncType.erase(*KeyCount);
4489                 KeyListKeyType.erase(*KeyCount);
4490                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
4491                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
4492                 
4493                 KeyList.erase(*KeyCount);
4494                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
4495         
4496         } else {
4497                 
4498                 KeyList.erase(*KeyCount);
4499                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
4500         
4501         }
4502         
4503         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
4504                 
4505         switch (PropType){
4506                 case PROPERTY_NONE:
4507                         break;
4508                 case PROPERTY_HOME: 
4509                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
4510                         break;
4511                 case PROPERTY_WORK: 
4512                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
4513                         break;
4514         }
4516         if (!PropertyTokens.IsEmpty()){
4518                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
4520         }
4524 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
4526         // Split the Vendor three ways.
4527         
4528         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
4529         
4530         wxString wxSVNDID;
4531         wxString wxSVNDPropName;
4533         while (wSTVendorDetails.HasMoreTokens() == TRUE){
4534         
4535                 wSTVendorDetails.GetNextToken();
4536                 wxSVNDID = wSTVendorDetails.GetNextToken();
4537                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
4538                 break;
4539         
4540         }
4541         
4542         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
4543         
4544                 // Add the data to the vendor variables.
4545         
4546                 VendorList.erase(*VendorCount);
4547                 VendorListPEN.erase(*VendorCount);
4548                 VendorListElement.erase(*VendorCount);
4549         
4550                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
4551                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
4552                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
4553         
4554         }
4558 void ContactDataObject::ClearData(){
4560     NameTitle.clear();
4561     NameForename.clear();
4562     NameSurname.clear();
4563     NameOtherNames.clear();
4564     NameSuffix.clear();
4565     NameNickname.clear();
4566     NameDisplayAs.clear();
4567     NameLanguage.clear();
4568     NameAltID.clear();
4569     NameTokens.clear();
4570     
4571     Birthday.clear();
4572     BirthdayAltID.clear();
4573     BirthdayCalScale.clear();
4574     BirthdayTokens.clear();
4575     Anniversary.clear();
4576     AnniversaryAltID.clear();
4577     AnniversaryCalScale.clear();
4578     AnniversaryTokens.clear();
4579     
4580     Gender.clear();
4581     GenderDetails.clear();
4582     GenderTokens.clear();
4583     
4584     UIDToken.clear();
4585     Revision.clear();
4586     RevisionTokens.clear();
4587     
4588     SourceList.clear();
4589     SourceListAltID.clear();
4590     SourceListPID.clear();
4591     SourceListType.clear();
4592     SourceListTokens.clear();
4593     SourceListMediatype.clear();
4594     SourceListPref.clear();
4595     
4596     XMLList.clear();
4597     XMLListAltID.clear();
4598     
4599     ClientPIDList.clear();
4600     ClientPIDListTokens.clear();
4601     
4602     FullNamesList.clear();    
4603     FullNamesListType.clear();
4604     FullNamesListLanguage.clear();
4605     FullNamesListAltID.clear();
4606     FullNamesListPID.clear();
4607     FullNamesListTokens.clear();
4608     FullNamesListPref.clear();
4609     
4610     GeneralNicknamesList.clear();
4611     GeneralNicknamesListType.clear();
4612     GeneralNicknamesListLanguage.clear();
4613     GeneralNicknamesListAltID.clear();
4614     GeneralNicknamesListPID.clear();
4615     GeneralNicknamesListTokens.clear();        
4616     GeneralNicknamesListPref.clear();        
4617     
4618     GeneralAddressList.clear();
4619     GeneralAddressListTown.clear();
4620     GeneralAddressListCounty.clear();
4621     GeneralAddressListPostCode.clear();
4622     GeneralAddressListCountry.clear();
4623     GeneralAddressListLabel.clear();
4624     GeneralAddressListLang.clear();        
4625     GeneralAddressListAltID.clear();
4626     GeneralAddressListPID.clear();
4627     GeneralAddressListTokens.clear();
4628     GeneralAddressListGeo.clear();
4629     GeneralAddressListTimezone.clear();        
4630     GeneralAddressListType.clear();
4631     GeneralAddressListMediatype.clear();
4632     GeneralAddressListPref.clear();
4633     
4634     GeneralEmailList.clear();
4635     GeneralEmailListAltID.clear();
4636     GeneralEmailListPID.clear();
4637     GeneralEmailListType.clear();
4638     GeneralEmailListTokens.clear();
4639     GeneralEmailListPref.clear();
4640     
4641     GeneralIMList.clear();
4642     GeneralIMListAltID.clear();
4643     GeneralIMListPID.clear();
4644     GeneralIMListType.clear();
4645     GeneralIMListTypeInfo.clear();
4646     GeneralIMListTokens.clear();
4647     GeneralIMListMediatype.clear();
4648     GeneralIMListPref.clear();
4649     
4650     GeneralTelephoneList.clear();
4651     GeneralTelephoneListAltID.clear();
4652     GeneralTelephoneListPID.clear();
4653     GeneralTelephoneListType.clear();
4654     GeneralTelephoneListTokens.clear();
4655     GeneralTelephoneListTypeInfo.clear();
4656     GeneralTelephoneListPref.clear();
4657     
4658     GeneralLanguageList.clear();
4659     GeneralLanguageListAltID.clear();
4660     GeneralLanguageListPID.clear();
4661     GeneralLanguageListType.clear();
4662     GeneralLanguageListTokens.clear();
4663     GeneralLanguageListPref.clear();
4664     
4665     GeneralTZList.clear();
4666     GeneralTZListAltID.clear();
4667     GeneralTZListPID.clear();
4668     GeneralTZListType.clear();
4669     GeneralTZListTokens.clear();
4670     GeneralTZListMediatype.clear();
4671     GeneralTZListPref.clear();
4672     
4673     GeneralGeographyList.clear();
4674     GeneralGeographyListAltID.clear();
4675     GeneralGeographyListPID.clear();
4676     GeneralGeographyListType.clear();
4677     GeneralGeographyListTokens.clear();
4678     GeneralGeographyListMediatype.clear();
4679     GeneralGeographyListPref.clear();
4680     
4681     GeneralRelatedList.clear();
4682     GeneralRelatedListRelType.clear();
4683     GeneralRelatedListLanguage.clear();
4684     GeneralRelatedListAltID.clear();
4685     GeneralRelatedListPID.clear();
4686     GeneralRelatedListType.clear();
4687     GeneralRelatedListTokens.clear();
4688     GeneralRelatedListPref.clear();
4689     
4690     GeneralWebsiteList.clear();
4691     GeneralWebsiteListAltID.clear();
4692     GeneralWebsiteListPID.clear();
4693     GeneralWebsiteListType.clear();
4694     GeneralWebsiteListTokens.clear();
4695     GeneralWebsiteListMediatype.clear();
4696     GeneralWebsiteListPref.clear();
4697     
4698     GeneralTitleList.clear();
4699     GeneralTitleListLanguage.clear();        
4700     GeneralTitleListAltID.clear();
4701     GeneralTitleListPID.clear();
4702     GeneralTitleListType.clear();
4703     GeneralTitleListTokens.clear();
4704     GeneralTitleListPref.clear();
4705     
4706     GeneralRoleList.clear();
4707     GeneralRoleListLanguage.clear();        
4708     GeneralRoleListAltID.clear();
4709     GeneralRoleListPID.clear();
4710     GeneralRoleListType.clear();
4711     GeneralRoleListTokens.clear();
4712     GeneralRoleListPref.clear();
4713     
4714     GeneralOrganisationsList.clear();
4715     GeneralOrganisationsListLanguage.clear();        
4716     GeneralOrganisationsListAltID.clear();
4717     GeneralOrganisationsListPID.clear();
4718     GeneralOrganisationsListType.clear();
4719     GeneralOrganisationsListTokens.clear();
4720     GeneralOrganisationsListSortAs.clear();
4721     GeneralOrganisationsListPref.clear();
4722     
4723     GeneralNoteList.clear();
4724     GeneralNoteListLanguage.clear();        
4725     GeneralNoteListAltID.clear();
4726     GeneralNoteListPID.clear();
4727     GeneralNoteListType.clear();
4728     GeneralNoteListTokens.clear();
4729     GeneralNoteListPref.clear();
4730     
4731     /* Items on Home Tab */        
4732     
4733     HomeNicknamesList.clear();
4734     HomeNicknamesListType.clear();
4735     HomeNicknamesListLanguage.clear();
4736     HomeNicknamesListAltID.clear();
4737     HomeNicknamesListPID.clear();
4738     HomeNicknamesListTokens.clear();        
4739     HomeNicknamesListPref.clear();        
4740     
4741     HomeAddressList.clear();
4742     HomeAddressListTown.clear();
4743     HomeAddressListCounty.clear();
4744     HomeAddressListPostCode.clear();
4745     HomeAddressListCountry.clear();
4746     HomeAddressListLabel.clear();
4747     HomeAddressListLang.clear();        
4748     HomeAddressListAltID.clear();
4749     HomeAddressListPID.clear();
4750     HomeAddressListTokens.clear();
4751     HomeAddressListGeo.clear();
4752     HomeAddressListTimezone.clear();        
4753     HomeAddressListType.clear();
4754     HomeAddressListMediatype.clear();
4755     HomeAddressListPref.clear();
4756     
4757     HomeEmailList.clear();
4758     HomeEmailListAltID.clear();
4759     HomeEmailListPID.clear();
4760     HomeEmailListType.clear();
4761     HomeEmailListTokens.clear();
4762     HomeEmailListPref.clear();
4763     
4764     HomeIMList.clear();
4765     HomeIMListAltID.clear();
4766     HomeIMListPID.clear();
4767     HomeIMListType.clear();
4768     HomeIMListTypeInfo.clear();
4769     HomeIMListTokens.clear();
4770     HomeIMListMediatype.clear();
4771     HomeIMListPref.clear();
4772     
4773     HomeTelephoneList.clear();
4774     HomeTelephoneListAltID.clear();
4775     HomeTelephoneListPID.clear();
4776     HomeTelephoneListType.clear();
4777     HomeTelephoneListTokens.clear();
4778     HomeTelephoneListTypeInfo.clear();
4779     HomeTelephoneListPref.clear();
4780     
4781     HomeLanguageList.clear();
4782     HomeLanguageListAltID.clear();
4783     HomeLanguageListPID.clear();
4784     HomeLanguageListType.clear();
4785     HomeLanguageListTokens.clear();
4786     HomeLanguageListPref.clear();
4787     
4788     HomeTZList.clear();
4789     HomeTZListAltID.clear();
4790     HomeTZListPID.clear();
4791     HomeTZListType.clear();
4792     HomeTZListTokens.clear();
4793     HomeTZListMediatype.clear();
4794     HomeTZListPref.clear();
4795     
4796     HomeGeographyList.clear();
4797     HomeGeographyListAltID.clear();
4798     HomeGeographyListPID.clear();
4799     HomeGeographyListType.clear();
4800     HomeGeographyListTokens.clear();
4801     HomeGeographyListMediatype.clear();
4802     HomeGeographyListPref.clear();       
4803     
4804     HomeWebsiteList.clear();
4805     HomeWebsiteListAltID.clear();
4806     HomeWebsiteListPID.clear();
4807     HomeWebsiteListType.clear();
4808     HomeWebsiteListTokens.clear();
4809     HomeWebsiteListMediatype.clear();
4810     HomeWebsiteListPref.clear();
4811     
4812     HomeTitleList.clear();
4813     HomeTitleListLanguage.clear();
4814     HomeTitleListAltID.clear();
4815     HomeTitleListPID.clear();
4816     HomeTitleListType.clear();
4817     HomeTitleListTokens.clear();
4818     HomeTitleListPref.clear();
4819     
4820     HomeRoleList.clear();
4821     HomeRoleListLanguage.clear();        
4822     HomeRoleListAltID.clear();
4823     HomeRoleListPID.clear();
4824     HomeRoleListType.clear();
4825     HomeRoleListTokens.clear();
4826     HomeRoleListPref.clear();
4827     
4828     HomeOrganisationsList.clear();
4829     HomeOrganisationsListLanguage.clear();        
4830     HomeOrganisationsListAltID.clear();
4831     HomeOrganisationsListPID.clear();
4832     HomeOrganisationsListType.clear();
4833     HomeOrganisationsListTokens.clear();
4834     HomeOrganisationsListSortAs.clear();
4835     HomeOrganisationsListPref.clear();
4836     
4837     HomeNoteList.clear();
4838     HomeNoteListLanguage.clear();        
4839     HomeNoteListAltID.clear();
4840     HomeNoteListPID.clear();
4841     HomeNoteListType.clear();
4842     HomeNoteListTokens.clear();
4843     HomeNoteListPref.clear();        
4844     
4845     /* Items on the Business tab */
4846     
4847     BusinessNicknamesList.clear();
4848     BusinessNicknamesListType.clear();
4849     BusinessNicknamesListLanguage.clear();
4850     BusinessNicknamesListAltID.clear();
4851     BusinessNicknamesListPID.clear();
4852     BusinessNicknamesListTokens.clear();        
4853     BusinessNicknamesListPref.clear();        
4854     
4855     BusinessAddressList.clear();
4856     BusinessAddressListTown.clear();
4857     BusinessAddressListCounty.clear();
4858     BusinessAddressListPostCode.clear();
4859     BusinessAddressListCountry.clear();
4860     BusinessAddressListLabel.clear();
4861     BusinessAddressListLang.clear();        
4862     BusinessAddressListAltID.clear();
4863     BusinessAddressListPID.clear();
4864     BusinessAddressListTokens.clear();
4865     BusinessAddressListGeo.clear();
4866     BusinessAddressListTimezone.clear();        
4867     BusinessAddressListType.clear();
4868     BusinessAddressListMediatype.clear();
4869     BusinessAddressListPref.clear();
4870     
4871     BusinessEmailList.clear();
4872     BusinessEmailListAltID.clear();
4873     BusinessEmailListPID.clear();
4874     BusinessEmailListType.clear();
4875     BusinessEmailListTokens.clear();
4876     BusinessEmailListPref.clear();
4877     
4878     BusinessIMList.clear();
4879     BusinessIMListAltID.clear();
4880     BusinessIMListPID.clear();
4881     BusinessIMListType.clear();
4882     BusinessIMListTokens.clear();
4883     BusinessIMListMediatype.clear();
4884     BusinessIMListPref.clear();
4885     
4886     BusinessTelephoneList.clear();
4887     BusinessTelephoneListAltID.clear();
4888     BusinessTelephoneListPID.clear();
4889     BusinessTelephoneListType.clear();
4890     BusinessTelephoneListTokens.clear();
4891     BusinessTelephoneListPref.clear();
4892     
4893     BusinessLanguageList.clear();
4894     BusinessLanguageListAltID.clear();
4895     BusinessLanguageListPID.clear();
4896     BusinessLanguageListType.clear();
4897     BusinessLanguageListTokens.clear();
4898     BusinessLanguageListPref.clear();
4899     
4900     BusinessTZList.clear();
4901     BusinessTZListAltID.clear();
4902     BusinessTZListPID.clear();
4903     BusinessTZListType.clear();
4904     BusinessTZListTokens.clear();
4905     BusinessTZListMediatype.clear();
4906     BusinessTZListPref.clear();
4907     
4908     BusinessGeographyList.clear();
4909     BusinessGeographyListAltID.clear();
4910     BusinessGeographyListPID.clear();
4911     BusinessGeographyListType.clear();
4912     BusinessGeographyListTokens.clear();
4913     BusinessGeographyListMediatype.clear();
4914     BusinessGeographyListPref.clear();          
4915     
4916     BusinessWebsiteList.clear();
4917     BusinessWebsiteListAltID.clear();
4918     BusinessWebsiteListPID.clear();
4919     BusinessWebsiteListType.clear();
4920     BusinessWebsiteListTokens.clear();
4921     BusinessWebsiteListMediatype.clear();
4922     BusinessWebsiteListPref.clear();
4923     
4924     BusinessTitleList.clear();
4925     BusinessTitleListLanguage.clear();        
4926     BusinessTitleListAltID.clear();
4927     BusinessTitleListPID.clear();
4928     BusinessTitleListType.clear();
4929     BusinessTitleListTokens.clear();
4930     BusinessTitleListPref.clear();
4931     
4932     BusinessRoleList.clear();
4933     BusinessRoleListLanguage.clear();        
4934     BusinessRoleListAltID.clear();
4935     BusinessRoleListPID.clear();
4936     BusinessRoleListType.clear();
4937     BusinessRoleListTokens.clear();
4938     BusinessRoleListPref.clear();
4939     
4940     BusinessOrganisationsList.clear();
4941     BusinessOrganisationsListLanguage.clear();        
4942     BusinessOrganisationsListAltID.clear();
4943     BusinessOrganisationsListPID.clear();
4944     BusinessOrganisationsListType.clear();
4945     BusinessOrganisationsListTokens.clear();
4946     BusinessOrganisationsListSortAs.clear();        
4947     BusinessOrganisationsListPref.clear();
4948     
4949     BusinessNoteList.clear();
4950     BusinessNoteListLanguage.clear();        
4951     BusinessNoteListAltID.clear();
4952     BusinessNoteListPID.clear();
4953     BusinessNoteListType.clear();
4954     BusinessNoteListTokens.clear();
4955     BusinessNoteListPref.clear();        
4956     
4957     /* Items on the Categories tab */
4958     
4959     CategoriesList.clear();
4960     CategoriesListAltID.clear();
4961     CategoriesListPID.clear();
4962     CategoriesListType.clear();
4963     CategoriesListTokens.clear();
4964     CategoriesListLanguage.clear();
4965     CategoriesListPref.clear();    
4966     
4967     /* Items on the Groups tab */
4968     
4969     GroupsList.clear();
4970     GroupsListAltID.clear();
4971     GroupsListPID.clear();
4972     GroupsListType.clear();
4973     GroupsListMediaType.clear();
4974     GroupsListTokens.clear();
4975     GroupsListPref.clear();
4976     
4977     /* Items on the Pictures tab */
4978     
4979     PicturesList.clear();
4980     PicturesListAltID.clear();
4981     PicturesListPID.clear();
4982     PicturesListType.clear();
4983     PicturesListPicEncType.clear();
4984     PicturesListPictureType.clear();
4985     PicturesListTokens.clear();
4986     PicturesListMediatype.clear();        
4987     PicturesListPref.clear();
4988     
4989     /* Items on the Logos tab */
4990     
4991     LogosList.clear();
4992     LogosListAltID.clear();
4993     LogosListPID.clear();
4994     LogosListType.clear();
4995     LogosListPicEncType.clear();        
4996     LogosListPictureType.clear();
4997     LogosListTokens.clear();
4998     LogosListMediatype.clear();        
4999     LogosListPref.clear();
5000     
5001     /* Items on the Sounds tab */
5002     
5003     SoundsList.clear();
5004     SoundsListAltID.clear();
5005     SoundsListPID.clear();
5006     SoundsListType.clear();
5007     SoundsListAudioEncType.clear();        
5008     SoundsListAudioType.clear();        
5009     SoundsListTokens.clear();
5010     SoundsListMediatype.clear();        
5011     SoundsListPref.clear();    
5012     
5013     /* Items on the Calendaring tab */
5014     
5015     CalendarList.clear();
5016     CalendarListAltID.clear();
5017     CalendarListPID.clear();
5018     CalendarListType.clear();
5019     CalendarListTokens.clear();
5020     CalendarListMediatype.clear();        
5021     CalendarListPref.clear();
5022     
5023     CalendarRequestList.clear();
5024     CalendarRequestListAltID.clear();
5025     CalendarRequestListPID.clear();
5026     CalendarRequestListType.clear();
5027     CalendarRequestListTokens.clear();
5028     CalendarRequestListMediatype.clear();        
5029     CalendarRequestListPref.clear();        
5030     
5031     FreeBusyList.clear();
5032     FreeBusyListAltID.clear();
5033     FreeBusyListPID.clear();
5034     FreeBusyListType.clear();
5035     FreeBusyListTokens.clear();
5036     FreeBusyListMediatype.clear();        
5037     FreeBusyListPref.clear();
5038     
5039     /* Items on the Security tab */
5040     
5041     KeyList.clear();
5042     KeyListAltID.clear();
5043     KeyListPID.clear();
5044     KeyListKeyType.clear();        
5045     KeyListDataType.clear();        
5046     KeyListDataEncType.clear();
5047     KeyListType.clear();
5048     KeyListTokens.clear();
5049     KeyListPref.clear();
5050     
5051     /* Items on the Other tab */
5052     
5053     VendorList.clear();
5054     VendorListPEN.clear();
5055     VendorListElement.clear();
5056     
5057     XTokenList.clear();
5058     XTokenListTokens.clear();
5062 void ProcessNameValue(wxString *PropertyData, 
5063         wxString *PropertyName, 
5064         wxString *PropertyValue){
5066         wxStringTokenizer PropertyElement (*PropertyData, wxT("="));
5067         *PropertyName = PropertyElement.GetNextToken();                         
5068         *PropertyValue = PropertyElement.GetNextToken();
5072 void ProcessTokens(wxString *PropertyName,
5073         wxString *PropertyValue,
5074         wxString *PropertyTokens,
5075         bool *FirstToken){
5076         
5077         if (!PropertyName->IsEmpty() && !PropertyValue->IsEmpty() && *PropertyName != wxT("TYPE")){
5078                 
5079                 if (*FirstToken == TRUE){
5080                         
5081                         PropertyTokens->Append(*PropertyName + wxT("=") + *PropertyValue);
5082                         *FirstToken = FALSE;
5083                         
5084                 } else {
5085                         
5086                         PropertyTokens->Append(wxT(";") + *PropertyName + wxT("=") + *PropertyValue);
5087                         
5088                 }
5089                 
5090         }
5091         
5094 void ProcessStringValue(wxString *PropertyName,
5095         wxString PropertyNameMatch,
5096         std::map<int,wxString> *MapPtr,
5097         wxString *PropertyValue,
5098         int *ItemCount,
5099         bool *PropertyMatched){
5100         
5101         if (*PropertyName == PropertyNameMatch){
5102                 MapPtr->erase(*ItemCount);
5103                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5104                 *PropertyMatched = TRUE;
5105         }
5106         
5109 void ProcessIntegerValue(wxString *PropertyName,
5110         wxString PropertyNameMatch,
5111         std::map<int,int> *PrefPtr, 
5112         wxString *PropertyValue, 
5113         int *ItemCount,
5114         bool *PropertyMatched){
5116         if (*PropertyName == PropertyNameMatch){
5117                 *PropertyMatched = TRUE;
5118         } else {
5119                 return;
5120         }
5122         int PriorityNumber = 0; 
5123         bool ValidNumber = TRUE;
5124                         
5125         try{
5126                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5127         }
5128                         
5129         catch(std::invalid_argument &e){
5130                 ValidNumber = FALSE;
5131         }
5133         if (ValidNumber == TRUE){
5135                 PrefPtr->erase(*ItemCount);
5136                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5138         }
5142 void SplitValues(wxString *PropertyLine, 
5143         std::map<int,int> *SplitPoints, 
5144         std::map<int,int> *SplitLength, 
5145         int intSize){
5146         
5147         size_t intPropertyLen = PropertyLine->Len();
5148         int intSplitsFound = 0;
5149         int intSplitSize = 0;
5150         int intSplitSeek = 0;
5151         
5152         for (int i = intSize; i <= intPropertyLen; i++){
5154                 intSplitSize++;
5155         
5156                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5157                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5158            
5159                     if (intSplitsFound == 0){
5160             
5161                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5162           
5163                     } else {
5164            
5165                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5166             
5167                     }
5168             
5169                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5170             
5171                     intSplitsFound++;
5172                     intSplitSeek = i;
5173                     intSplitSize = 0;
5174             
5175                 }
5177         }
5179         if (intSplitsFound == 0){
5181                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5182                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5184         } else {
5186                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5187                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5189         }
5193 void CheckType(wxString *PropertySeg1, 
5194         std::map<int,int> *SplitPoints, 
5195         std::map<int,int> *SplitLength, 
5196         int *intPrevValue, 
5197         PropertyType *PropType){
5198         
5199         wxString PropertyData;
5200         wxString PropertyName;
5201         wxString PropertyValue;
5202         std::map<int,int>::iterator SLiter;
5203         
5204         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5205         intiter != SplitPoints->end(); ++intiter){
5206         
5207                 SLiter = SplitLength->find(intiter->first);     
5208                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5209                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);         
5210                 *intPrevValue = intiter->second;
5211                 
5212                 if (PropertyName == wxT("TYPE")){
5213                                 
5214                         if (PropertyValue == wxT("work")){
5215                         
5216                                 *PropType = PROPERTY_WORK;
5217                                                         
5218                         } else if (PropertyValue == wxT("home")){
5220                                 *PropType = PROPERTY_HOME;
5221                                                         
5222                         } else {
5223                         
5224                                 *PropType = PROPERTY_NONE;
5225                         
5226                         }
5227                 
5228                         return;
5229                 
5230                 }
5231         
5232         }
5233         
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