Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed intPref and intType from ContactDataObject as they are no longer required.
[xestiaab/.git] / source / contacteditor / cdo / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         if (!wxFileExists(Filename)){
24         
25                 return CONTACTLOAD_FILEMISSING;
26         
27         }
28         
29         wxFile ContactFile;
30         
31         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
32         
33                 return CONTACTLOAD_FILEERROR;
34         
35         }
36         
37         // Check that the vCard is a valid vCard 4.0 file.
39         vCard vCard4FormatCheck;
40         
41         vCard4FormatCheck.LoadFile(Filename);
42         
43         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
44         
45                 return CONTACTLOAD_FILEINVALIDFORMAT;
46         
47         }
49         // Check that the vCard meets the base specification.
50         
51         if (!vCard4FormatCheck.MeetBaseSpecification()){
52         
53                 return CONTACTLOAD_FILEBASESPECFAIL;
54         
55         }
56         
57         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
58         
59         std::map<int, wxString> ContactFileLines;
61         int ContactLineSeek = 0;
63         while (wSTContactFileLines.HasMoreTokens() == TRUE){
65                 wxString ContactLine = wSTContactFileLines.GetNextToken();
66                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
67                 ContactLineSeek++;              
68         
69         }
70         
71         wxString wxSPropertyNextLine;
72         
73         bool ExtraLineSeek = TRUE;
74         bool QuoteMode = FALSE;
75         bool PropertyFind = TRUE;
76         bool KindProcessed = FALSE;
77         bool NameProcessed = FALSE;
78         bool GenderProcessed = FALSE;
79         bool BirthdayProcessed = FALSE;
80         bool AnniversaryProcessed = FALSE;
81         bool UIDProcessed = FALSE;
82         bool RevisionProcessed = FALSE;
83         int ContactLineLen = 0;
84         int QuoteBreakPoint = 0;
85         int SourceCount = 0;
86         int GroupCount = 0;
87         int FNCount = 0;
88         int NicknameCount = 0;
89         int TimeZoneCount = 0;
90         int AddressCount = 0;
91         int EmailCount = 0;
92         int IMCount = 0;
93         int TelephoneCount = 0;
94         int LanguageCount = 0;
95         int GeographicCount = 0;
96         int RelatedCount = 0;
97         int URLCount = 0;
98         int TitleCount = 0;
99         int RoleCount = 0;
100         int OrganisationCount = 0;
101         int NoteCount = 0;
102         int CategoryCount = 0;
103         int PhotoCount = 0;
104         int LogoCount = 0;
105         int SoundCount = 0;
106         int CalendarCount = 0;
107         int CalendarAddressCount = 0;
108         int FreeBusyAddressCount = 0;
109         int KeyCount = 0;
110         int VendorCount = 0;
111         int XTokenCount = 0;
112         int XMLCount = 0;
113         int ClientPIDCount = 0;
114         wxString ContactLine;
115         wxString PropertyLine;
116         wxString PropertySeg1;
117         wxString PropertySeg2;
118         wxString PropertyNextLine;
119         wxString Property;
120         
121         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
122          iter != ContactFileLines.end(); ++iter){
124                 ExtraLineSeek = TRUE;
125                 QuoteMode = FALSE;
126                 PropertyFind = TRUE;
127                 ContactLineLen = 0;
128                 QuoteBreakPoint = 0;
129                 ContactLine.Clear();
130                 PropertyLine.Clear();
131                 PropertySeg1.Clear();
132                 PropertySeg2.Clear();
133                 Property.Clear();
134          
135                 ContactLine = iter->second;
136                 
137                 while (ExtraLineSeek == TRUE){
138                 
139                         // Check if there is extra data on the next line 
140                         // (indicated by space or tab at the start) and add data.
141                 
142                         iter++;
143                         
144                         if (iter == ContactFileLines.end()){
145                         
146                                 iter--;
147                                 break;
148                         
149                         }                       
150                 
151                         PropertyNextLine = iter->second;
152                 
153                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
154                 
155                                 PropertyNextLine.Remove(0, 1);
156                                 ContactLine.Append(PropertyNextLine);
157                 
158                         } else {
159                         
160                                 iter--;
161                                 ExtraLineSeek = FALSE;
162                         
163                         }
164                 
165                 }
167                 ContactLineLen = ContactLine.Len();
168                 
169                 // Make sure we are not in quotation mode.
170                 // Make sure colon does not have \ or \\ before it.
171                 
172                 for (int i = 0; i <= ContactLineLen; i++){
173                 
174                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
175                         
176                                 PropertyFind = FALSE;
177                         
178                         } else if (PropertyFind == TRUE){
179                         
180                                 Property.Append(ContactLine.Mid(i, 1));
181                         
182                         }               
183                 
184                         if (ContactLine.Mid(i, 1) == wxT("\"")){
185                         
186                                 if (QuoteMode == TRUE){
187                                 
188                                         QuoteMode = FALSE;
189                                 
190                                 } else {
191                         
192                                         QuoteMode = TRUE;
193                                         
194                                 }
195                         
196                         }
197                         
198                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
199                         
200                                 QuoteBreakPoint = i;
201                                 break;
202                         
203                         }
204                 
205                 }
206                 
207                 // Split that line at the point into two variables (ignore the colon).
208                 
209                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
211                 
212                  if (Property == wxT("KIND") && KindProcessed == FALSE){
213                                 
214                         ProcessKind(PropertySeg2);
215                 
216                 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
217                 
218                         UIDToken = PropertySeg2;
219                         UIDProcessed = TRUE;
220                 
221                 } else if (Property == wxT("SOURCE")){
222                 
223                         ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
224                         SourceCount++;
225                 
226                 } else if (Property == wxT("XML")){
227                 
228                         ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
229                         XMLCount++;
230                 
231                 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
232                 
233                         ProcessRevision(PropertySeg1, PropertySeg2);
234                         RevisionProcessed = TRUE;
235                 
236                 } else if (Property == wxT("MEMBER")){
238                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
239                         GroupCount++;   
240                 
241                 } else if (Property == wxT("FN")){
242                 
243                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
244                         FNCount++;
245                 
246                 } else if (Property == wxT("N") && NameProcessed == FALSE){
247                 
248                         ProcessN(PropertySeg1, PropertySeg2);
249                         NameProcessed = TRUE;
250                 
251                 } else if (Property == wxT("CLIENTPIDMAP")){
252                 
253                         ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
254                         ClientPIDCount++;
255                 
256                 } else if (Property == wxT("NICKNAME")){
257                                                 
258                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
259                         NicknameCount++;
260                         
261                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
262                 
263                         ProcessGender(PropertySeg1, PropertySeg2);
264                         GenderProcessed = TRUE;
265                 
266                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
267                 
268                         ProcessBirthday(PropertySeg1, PropertySeg2);
269                         BirthdayProcessed = TRUE;
270                 
271                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
272                 
273                         ProcessAnniversary(PropertySeg1, PropertySeg2);
274                         AnniversaryProcessed = TRUE;
275                 
276                 } else if (Property == wxT("TZ")){
277                 
278                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
279                         TimeZoneCount++;
280                 
281                 } else if (Property == wxT("ADR")){
282                 
283                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
284                         AddressCount++;
285                 
286                 } else if (Property == wxT("EMAIL")){
287                                         
288                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
289                         EmailCount++;
290                 
291                 } else if (Property == wxT("IMPP")){
292                 
293                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
294                         IMCount++;
295                         
296                 } else if (Property == wxT("TEL")){
297                                 
298                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
299                         TelephoneCount++;
300                 
301                 } else if (Property == wxT("LANG")){
302                 
303                         // See frmContactEditor-LoadLanguage.cpp
304                         
305                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
306                         LanguageCount++;
307                 
308                 } else if (Property == wxT("GEO")){
309                 
310                         // See frmContactEditor-LoadGeo.cpp
311                         
312                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
313                         GeographicCount++;
314                 
315                 } else if (Property == wxT("RELATED")){
316                         
317                         // See fromContactEditor-LoadRelated.cpp
318                         
319                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
320                         RelatedCount++;
321                         
322                 } else if (Property == wxT("URL")){
324                         // See frmContactEditor-LoadURL.cpp
325                 
326                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
327                         URLCount++;
328                 
329                 } else if (Property == wxT("TITLE")) {
330                 
331                         // See frmContactEditor-LoadTitle.cpp
332                         
333                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
334                         TitleCount++;
335                         
336                 } else if (Property == wxT("ROLE")) {
337                 
338                         // See frmContactEditor-LoadTitle.cpp
339                         
340                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
341                         RoleCount++;
342                         
343                 } else if (Property == wxT("ORG")) {
344                 
345                         // See frmContactEditor-LoadOrg.cpp
346                         
347                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
348                         OrganisationCount++;
349                         
350                 } else if (Property == wxT("NOTE")) {
352                         // See frmContactEditor-LoadNote.cpp
354                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
355                         NoteCount++;    
356                         
357                 } else if (Property == wxT("CATEGORIES")) {
358                 
359                         // See frmContactEditor-LoadCategory.cpp
360                 
361                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
362                         CategoryCount++;
363                         
364                 } else if (Property == wxT("PHOTO")) {
365                 
366                         // See frmContactEditor-LoadPhoto.cpp
367                         
368                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
369                         PhotoCount++;
371                 } else if (Property == wxT("LOGO")) {
372                 
373                         // See frmContactEditor-LoadPhoto.cpp
374                         
375                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
376                         LogoCount++;
378                 } else if (Property == wxT("LOGO")) {
379                 
380                         // See frmContactEditor-LoadPhoto.cpp
381                         
382                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
383                         LogoCount++;
385                 } else if (Property == wxT("SOUND")) {
386                 
387                         // See frmContactEditor-LoadSound.cpp
388                         
389                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
390                         SoundCount++;
391                         
392                 } else if (Property == wxT("CALURI")){
394                         // See frmContactEditor-LoadCalendar.cpp
395                         
396                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
397                         CalendarCount++;
398                 
399                 } else if (Property == wxT("CALADRURI")){
400                 
401                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402                         CalendarAddressCount++;
403                 
404                 } else if (Property == wxT("FBURL")){
406                         // See frmContactEditor-LoadCalendar.cpp
408                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409                         FreeBusyAddressCount++;
411                 } else if (Property == wxT("KEY")){
412                 
413                         // See frmContactEditor-LoadKey.cpp
414                         
415                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
416                         KeyCount++;
417                 
418                 } else if (Property.Mid(0, 3) == wxT("VND")){
419                 
420                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
421                         VendorCount++;
422                 
423                 } else if (Property.Mid(0, 2) == wxT("X-")){
424                         
425                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
427                         XTokenCount++;
428                 
429                 }
430                 
431         }
432         
433         return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439         if (KindType == wxT("individual")){
440                         
441                 ContactKind = CONTACTKIND_INDIVIDUAL;
442                         
443         } else if (KindType == wxT("group")){
444                         
445                 ContactKind = CONTACTKIND_GROUP;
446                         
447         } else if (KindType == wxT("org")){
448                         
449                 ContactKind = CONTACTKIND_ORGANISATION;
450                         
451         } else if (KindType == wxT("location")){
452                         
453                 ContactKind = CONTACTKIND_LOCATION;
454                         
455         } else {
456                         
457                 ContactKind = CONTACTKIND_NONE;                 
458         }
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464         size_t intPropertyLen = PropertySeg1.Len();
465         std::map<int, int> SplitPoints;
466         std::map<int, int> SplitLength;
467         std::map<int, int>::iterator SLiter;                    
468         wxString PropertyData;
469         wxString PropertyName;
470         wxString PropertyValue;
471         wxString PropertyTokens;
472         bool FirstToken = TRUE;
473         int intSplitsFound = 0;
474         int intSplitSize = 0;
475         int intPrevValue = 5;
476         
477         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
478         
479         intPrevValue = 4;
481         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
482         intiter != SplitPoints.end(); ++intiter){
483         
484                 SLiter = SplitLength.find(intiter->first);
485                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
486                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
487                 intPrevValue = intiter->second;
488                 
489                 // Process properties.
490                 
491                 size_t intPropertyValueLen = PropertyValue.Len();
492                 
493                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
494                         
495                         PropertyValue.Trim();
496                         PropertyValue.RemoveLast();
497                         
498                 }                               
499                 
500                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
501                         
502                         PropertyValue.Remove(0, 1);
503                         
504                 }                       
505                 
506                 CaptureString(&PropertyValue, FALSE);
507                 
508                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
509         
510         }       
511         
512         CaptureString(&PropertySeg2, FALSE);
513         
514         Revision = PropertySeg2;
515         
516         if (!PropertyTokens.IsEmpty()){
517         
518                 RevisionTokens = PropertyTokens;
519         
520         }
525 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
527         size_t intPropertyLen = PropertySeg1.Len();
528         std::map<int, int> SplitPoints;
529         std::map<int, int> SplitLength;
530         std::map<int, int>::iterator SLiter;                    
531         wxString PropertyData;
532         wxString PropertyName;
533         wxString PropertyValue;
534         wxString PropertyTokens;
535         bool FirstToken = TRUE;
536         bool PropertyMatched = FALSE;
537         int intSplitsFound = 0;
538         int intSplitSize = 0;
539         int intPrevValue = 8;
540         
541         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
542         
543         intPrevValue = 7;
544         
545         PropertyType PropType = PROPERTY_NONE;
546         
547         // Look for type before continuing.                     
549         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
551         intPrevValue = 7;
553         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
554         intiter != SplitPoints.end(); ++intiter){
555         
556                 SLiter = SplitLength.find(intiter->first);
557         
558                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
559                 
560                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
561                 
562                 intPrevValue = intiter->second;
563                 
564                 // Process properties.
565                 
566                 size_t intPropertyValueLen = PropertyValue.Len();
567                 
568                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
569                         
570                         PropertyValue.Trim();
571                         PropertyValue.RemoveLast();
572                         
573                 }                               
574                 
575                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
576                         
577                         PropertyValue.Remove(0, 1);
578                         
579                 }                       
580                 
581                 CaptureString(&PropertyValue, FALSE);
582                 
583                 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
584                 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
585                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
586                 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
587                 
588                 if (PropertyMatched == TRUE){
589                 
590                         PropertyMatched = FALSE;
591                         continue;
592                 
593                 }
594                 
595                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
596         
597         }       
598         
599         intPropertyLen = PropertySeg2.Len();
600         SplitPoints.clear();
601         SplitLength.clear();
602         intSplitsFound = 0;
603         intSplitSize = 0;
604         intPrevValue = 0;
605         
606         CaptureString(&PropertySeg2, FALSE);
607         
608         // Add the data to the General/Home/Work address variables.
609                 
610         switch(PropType){
611                 case PROPERTY_NONE:
612                         break;
613                 case PROPERTY_HOME:
614                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
615                         break;
616                 case PROPERTY_WORK:
617                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
618                         break;
619         }
620         
621         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
622         
623         if (!PropertyTokens.IsEmpty()){
624         
625                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
626         
627         }
631 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
633         std::map<int, int> SplitPoints;
634         std::map<int, int> SplitLength;
636         int intPrevValue = 5;
637         
638         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
640         intPrevValue = 4;
641         
642         wxString PropertyName;
643         wxString PropertyValue;
644         wxString PropertyData;
645         wxString PropertyTokens;
646         std::map<int,int>::iterator SLiter;
647         bool FirstToken = TRUE;
648         bool PropertyMatched = FALSE;
649         
650         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
651         intiter != SplitPoints.end(); ++intiter){
652         
653                 SLiter = SplitLength.find(intiter->first);
654                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
655                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
656                 intPrevValue = intiter->second;
657                 
658                 CaptureString(&PropertyValue, FALSE);
659         
660                 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
661                 
662                 if (PropertyMatched == TRUE){
663                 
664                         PropertyMatched = FALSE;
665                         continue;
666                 
667                 }
668                 
669         }
671         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
675 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
677         std::map<int, int> SplitPoints;
678         std::map<int, int> SplitLength;
680         int intPrevValue = 8;
681         
682         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
684         intPrevValue = 7;
685         
686         wxString PropertyName;
687         wxString PropertyValue;
688         wxString PropertyData;
689         wxString PropertyTokens;
690         std::map<int,int>::iterator SLiter;
691         bool FirstToken = TRUE;
692         bool PropertyMatched = FALSE;
693         
694         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
695         intiter != SplitPoints.end(); ++intiter){
696         
697                 SLiter = SplitLength.find(intiter->first);
698                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
699                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
700                 intPrevValue = intiter->second;
701                 
702                 CaptureString(&PropertyValue, FALSE);
703         
704                 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
705                 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
706                 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
707                 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
708                 
709                 if (PropertyMatched == TRUE){
710                 
711                         PropertyMatched = FALSE;
712                         continue;
713                 
714                 }
715                 
716                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
717                 
718         }
720         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
722         if (!PropertyTokens.IsEmpty()){
723         
724                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
725         
726         }
731 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
733         std::map<int, int> SplitPoints;
734         std::map<int, int> SplitLength;
736         int intPrevValue = 4;
737         
738         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
740         intPrevValue = 3;
741         
742         wxString PropertyName;
743         wxString PropertyValue;
744         wxString PropertyData;
745         wxString PropertyTokens;
746         std::map<int,int>::iterator SLiter;
747         bool FirstToken = TRUE;
748         bool PropertyMatched = FALSE;
749         
750         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
751         intiter != SplitPoints.end(); ++intiter){
752         
753                 SLiter = SplitLength.find(intiter->first);
754                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
755                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue); 
756                 intPrevValue = intiter->second;
757                 
758                 CaptureString(&PropertyValue, FALSE);
759                 
760                 if (PropertyName == wxT("TYPE")){
762                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
763                                 PropertyValue == wxT("work") ){
765                                 FullNamesListType.erase(*FNCount);
766                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
767                 
768                         }
769                         
770                         PropertyMatched = TRUE;
771                 
772                 }
773                 
774                 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
775                 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
776                 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
777                 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
778                 
779                 if (PropertyMatched == TRUE){
780                 
781                         PropertyMatched = FALSE;
782                         continue;
783                 
784                 }
785                 
786                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
787         
788         }
790         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
792         if (!PropertyTokens.IsEmpty()){
793         
794                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
795         
796         }
800 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
802         std::map<int, int> SplitPoints;
803         std::map<int, int> SplitLength;
805         int intPrevValue = 3;
806         
807         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
808         
809         intPrevValue = 2;
810         
811         wxString PropertyName;
812         wxString PropertyValue;
813         wxString PropertyData;
814         wxString PropertyTokens;
815         std::map<int,int>::iterator SLiter;
816         bool FirstToken = TRUE;
817         
818         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
819         intiter != SplitPoints.end(); ++intiter){
820         
821                 SLiter = SplitLength.find(intiter->first);
822                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
823                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
824                 intPrevValue = intiter->second;
825                 
826                 CaptureString(&PropertyValue, FALSE);
827                 
828                 if (PropertyName == wxT("ALTID")){
830                         NameAltID = PropertyValue;
831                 
832                 } else if (PropertyName == wxT("LANGUAGE")){
833                 
834                         NameLanguage = PropertyValue;
835                 
836                 } else if (PropertyName == wxT("SORT-AS")){
837                 
838                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
839                                 PropertyValue.Len() >= 3){
840                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
841                         }
842                 
843                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
844                         
845                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
846                         
847                 }
848         
849         }
850         
851         // Split the name data.
852         
853         int intSplitSeek = 0;           
854         int intSplitsFound = 0;
855         int intSplitSize = 0;
856         int intPropertyLen = PropertySeg2.Len();
857         
858         std::map<int,wxString> NameValues;
859         intPrevValue = 0;                                       
860         
861         for (int i = 0; i <= intPropertyLen; i++){
862         
863                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
864                         
865                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
866                         
867                         intSplitSeek = i;
868                         intSplitSeek++;
869                         
870                         if (intSplitsFound == 4){
871                         
872                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
873                                 break;
874                         
875                         }
876                         
877                         intSplitSize = 0;
878                         continue;
879         
880                 }
881                 
882                 intSplitSize++;
884         }
885         
886         // Split the data into several parts.
887                         
888         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
889         iter != NameValues.end(); ++iter){
890         
891                 if (iter->first == 1){
892                 
893                         // Deal with family name.
894                         
895                         NameSurname = iter->second;
896                 
897                 } else if (iter->first == 2){
898                 
899                         // Deal with given names.
900                         
901                         NameForename = iter->second;
902                 
903                 } else if (iter->first == 3){
904                 
905                         // Deal with additional names.
906                         
907                         NameOtherNames = iter->second;
908                 
909                 } else if (iter->first == 4){
910                 
911                         // Deal with honorifix prefixes and suffixes.
913                         NameTitle = iter->second;
914                 
915                         iter++;
916                         
917                         if (iter == NameValues.end()){
918                         
919                                 break;
920                         
921                         }
922                 
923                         NameSuffix = iter->second;
924                 
925                 }
926         
927         }
928         
929         // Add the name token data.
930         
931         if (!PropertyTokens.IsEmpty()){
932         
933                 NameTokens = PropertyTokens;
934         
935         }
939 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
941         size_t intPropertyLen = PropertySeg1.Len();
942         std::map<int, int> SplitPoints;
943         std::map<int, int> SplitLength;
944         std::map<int, int>::iterator SLiter;                    
945         wxString PropertyData;
946         wxString PropertyName;
947         wxString PropertyValue;
948         wxString PropertyTokens;
949         bool FirstToken = TRUE;
950         int intSplitsFound = 0;
951         int intSplitSize = 0;
952         int intPrevValue = 14;
953         
954         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
955         
956         intPrevValue = 13;
958         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
959         intiter != SplitPoints.end(); ++intiter){
960         
961                 SLiter = SplitLength.find(intiter->first);
962                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
963                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
964                 intPrevValue = intiter->second;
965                 
966                 // Process properties.
967                                 
968                 CaptureString(&PropertyValue, FALSE);
969                                         
970                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
971         
972         }       
973         
974         CaptureString(&PropertySeg2, FALSE);
975         
976         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
977         
978         if (!PropertyTokens.IsEmpty()){
979         
980                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
981         
982         }
986 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
988         std::map<int, int> SplitPoints;
989         std::map<int, int> SplitLength;
991         int intPrevValue = 10;
992         
993         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
994         
995         intPrevValue = 9;
996         
997         PropertyType PropType = PROPERTY_NONE;
998         
999         // Look for type before continuing.
1000         
1001         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1002         
1003         intPrevValue = 9;
1004         
1005         std::map<int, wxString> *NicknamesList = NULL;
1006         std::map<int, wxString> *NicknamesListType = NULL;
1007         std::map<int, wxString> *NicknamesListLanguage = NULL;
1008         std::map<int, wxString> *NicknamesListAltID = NULL;
1009         std::map<int, wxString> *NicknamesListPID = NULL;
1010         std::map<int, wxString> *NicknamesListTokens = NULL;            
1011         std::map<int, int> *NicknamesListPref = NULL;
1012         
1013         switch(PropType){
1014                 case PROPERTY_NONE:
1015                         NicknamesList = &GeneralNicknamesList;
1016                         NicknamesListType = &GeneralNicknamesListType;
1017                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1018                         NicknamesListAltID = &GeneralNicknamesListAltID;
1019                         NicknamesListPID = &GeneralNicknamesListPID;
1020                         NicknamesListTokens = &GeneralNicknamesListTokens;
1021                         NicknamesListPref = &GeneralNicknamesListPref;
1022                         break;
1023                 case PROPERTY_HOME:
1024                         NicknamesList = &HomeNicknamesList;
1025                         NicknamesListType = &HomeNicknamesListType;
1026                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1027                         NicknamesListAltID = &HomeNicknamesListAltID;
1028                         NicknamesListPID = &HomeNicknamesListPID;
1029                         NicknamesListTokens = &HomeNicknamesListTokens;
1030                         NicknamesListPref = &HomeNicknamesListPref;
1031                         break;
1032                 case PROPERTY_WORK:
1033                         NicknamesList = &BusinessNicknamesList;
1034                         NicknamesListType = &BusinessNicknamesListType;
1035                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1036                         NicknamesListAltID = &BusinessNicknamesListAltID;
1037                         NicknamesListPID = &BusinessNicknamesListPID;
1038                         NicknamesListTokens = &BusinessNicknamesListTokens;
1039                         NicknamesListPref = &BusinessNicknamesListPref;
1040                         break;
1041         }
1042         
1043         std::map<int, int>::iterator SLiter;    
1044         wxString PropertyData;
1045         wxString PropertyName;
1046         wxString PropertyValue;
1047         wxString PropertyTokens;
1048         bool FirstToken = TRUE;
1049         bool PropertyMatched = FALSE;
1050         
1051         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1052         intiter != SplitPoints.end(); ++intiter){
1053         
1054                 SLiter = SplitLength.find(intiter->first);
1055                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1056                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1057                 intPrevValue = intiter->second;
1058                 
1059                 CaptureString(&PropertyValue, FALSE);
1060                 
1061                 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1062                 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1063                 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1064                 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1065                 
1066                 if (PropertyMatched == TRUE){
1067                 
1068                         PropertyMatched = FALSE;
1069                         continue;
1070                 
1071                 }
1072                 
1073                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1074                 
1075         }
1076         
1077         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1078         
1079         // Add the name token data.
1080         
1081         if (!PropertyTokens.IsEmpty()){
1082         
1083                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1084         
1085         }
1089 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1091         std::map<int, int> SplitPoints;
1092         std::map<int, int> SplitLength;
1093         std::map<int, int>::iterator SLiter;                    
1094         wxString PropertyData;
1095         wxString PropertyName;
1096         wxString PropertyValue;
1097         wxString PropertyTokens;
1098         bool FirstToken = TRUE;
1099         int intPrevValue = 8;
1101         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1103         intPrevValue = 7;                       
1104         
1105         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1106         intiter != SplitPoints.end(); ++intiter){
1107         
1108                 SLiter = SplitLength.find(intiter->first);
1109                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1110                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1111                 intPrevValue = intiter->second;
1112                 
1113                 // Process properties.
1114                 
1115                 size_t intPropertyValueLen = PropertyValue.Len();
1116                 
1117                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1118                         
1119                         PropertyValue.Trim();
1120                         PropertyValue.RemoveLast();
1121                         
1122                 }                               
1123                 
1124                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1125                         
1126                         PropertyValue.Remove(0, 1);
1127                         
1128                 }                               
1129                 
1130                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1131         
1132         }       
1134         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1135         
1136         wxString GenderComponent;
1137         
1138         if (GenderData.CountTokens() >= 2){
1139         
1140                 Gender = GenderData.GetNextToken();
1141                 GenderDetails = GenderData.GetString();
1142         
1143                 CaptureString(&GenderDetails, FALSE);
1144                                                 
1145         } else {
1146         
1147                 Gender = GenderData.GetNextToken();
1148         
1149         }
1150         
1151         if (!PropertyTokens.IsEmpty()){
1152         
1153                 GenderTokens = PropertyTokens;
1154         
1155         }
1159 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1161         // Process date. Preserve the remainder in the string.
1163         std::map<int, int> SplitPoints;
1164         std::map<int, int> SplitLength;
1165         std::map<int, int>::iterator SLiter;                    
1166         wxString PropertyData;
1167         wxString PropertyName;
1168         wxString PropertyValue;
1169         wxString PropertyTokens;
1170         bool BirthdayText = FALSE;
1171         int intPrevValue = 6;
1173         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1175         intPrevValue = 5;
1177         // Look for type before continuing.
1179         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1180         intiter != SplitPoints.end(); ++intiter){
1182                 SLiter = SplitLength.find(intiter->first);
1183                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1184                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1185                 intPrevValue = intiter->second;
1186         
1187                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1188         
1189                         CaptureString(&PropertySeg2, FALSE);
1190                         Birthday = PropertySeg2;
1191                         BirthdayText = TRUE;
1192         
1193                 }
1195         }
1197         // Setup blank lines for later on.
1198         
1199         intPrevValue = 5;
1200         bool FirstToken = TRUE;
1202         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1203         intiter != SplitPoints.end(); ++intiter){
1205                 SLiter = SplitLength.find(intiter->first);
1206                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1207                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1208                 intPrevValue = intiter->second;
1209         
1210                 // Process properties.
1211         
1212                 CaptureString(&PropertyValue, FALSE);
1213         
1214                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1215                 
1216                         PropertyValue.Trim();
1217                         PropertyValue.RemoveLast();
1218                 
1219                 }                               
1220         
1221                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1222                 
1223                         PropertyValue.Remove(0, 1);
1224                 
1225                 }                               
1226         
1227                 if (PropertyName == wxT("ALTID")){
1229                         BirthdayAltID = PropertyValue;
1230         
1231                 } else if (PropertyName == wxT("CALSCALE")){
1232         
1233                         BirthdayCalScale = PropertyValue;
1234         
1235                 } else if (PropertyName != wxT("VALUE")) {
1236         
1237                         // Something else we don't know about so append
1238                         // to the tokens variable.
1239                 
1240                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1241                         
1242                 }
1244         }       
1246         // Add the data to the variables and form.
1247         
1248         if (BirthdayText == FALSE){
1249         
1250                 Birthday = PropertySeg2;
1252         }
1253         
1254         if (!PropertyTokens.IsEmpty()){
1255         
1256                 BirthdayTokens = PropertyTokens;
1258         }
1262 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1264         // Process date. Preserve the remainder in the string.
1266         std::map<int, int> SplitPoints;
1267         std::map<int, int> SplitLength;
1268         std::map<int, int>::iterator SLiter;                    
1269         wxString PropertyData;
1270         wxString PropertyName;
1271         wxString PropertyValue;
1272         wxString PropertyTokens;
1273         bool AnniversaryText = FALSE;
1274         int intPrevValue = 13;
1276         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1278         intPrevValue = 12;
1280         // Look for type before continuing.
1282         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1283         intiter != SplitPoints.end(); ++intiter){
1285                 SLiter = SplitLength.find(intiter->first);
1286                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1287                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1288                 intPrevValue = intiter->second;
1289         
1290                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1291         
1292                         CaptureString(&PropertySeg2, FALSE);
1293                         Anniversary = PropertySeg2;
1294                         AnniversaryText = TRUE;
1295         
1296                 }
1298         }
1300         // Setup blank lines for later on.
1301         
1302         intPrevValue = 12;
1303         bool FirstToken = TRUE;
1305         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1306         intiter != SplitPoints.end(); ++intiter){
1308                 SLiter = SplitLength.find(intiter->first);
1309                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1310                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1311                 intPrevValue = intiter->second;
1312         
1313                 // Process properties.
1314         
1315                 CaptureString(&PropertyValue, FALSE);
1316         
1317                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1318                 
1319                         PropertyValue.Trim();
1320                         PropertyValue.RemoveLast();
1321                 
1322                 }                               
1323         
1324                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1325                 
1326                         PropertyValue.Remove(0, 1);
1327                 
1328                 }                               
1329         
1330                 if (PropertyName == wxT("ALTID")){
1332                         AnniversaryAltID = PropertyValue;
1333         
1334                 } else if (PropertyName == wxT("CALSCALE")){
1335         
1336                         AnniversaryCalScale = PropertyValue;
1337         
1338                 } else if (PropertyName != wxT("VALUE")) {
1339         
1340                         // Something else we don't know about so append
1341                         // to the tokens variable.
1342                 
1343                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1344                         
1345                 }
1347         }       
1349         // Add the data to the variables and form.
1350         
1351         if (AnniversaryText == FALSE){
1352         
1353                 Anniversary = PropertySeg2;
1355         }
1356         
1357         if (!PropertyTokens.IsEmpty()){
1358         
1359                 AnniversaryTokens = PropertyTokens;
1361         }
1365 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1367         std::map<int, int> SplitPoints;
1368         std::map<int, int> SplitLength;
1370         int intPrevValue = 4;
1371         
1372         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1373         
1374         intPrevValue = 3;
1375         
1376         PropertyType PropType = PROPERTY_NONE;
1377         
1378         // Look for type before continuing.
1379         
1380         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1381         
1382         intPrevValue = 3;
1383         
1384         std::map<int, wxString> *TZList = NULL;
1385         std::map<int, wxString> *TZListType = NULL;
1386         std::map<int, wxString> *TZListMediatype = NULL;
1387         std::map<int, wxString> *TZListAltID = NULL;
1388         std::map<int, wxString> *TZListPID = NULL;
1389         std::map<int, wxString> *TZListTokens = NULL;           
1390         std::map<int, int> *TZListPref = NULL;
1391         
1392         switch(PropType){
1393                 case PROPERTY_NONE:
1394                         TZList = &GeneralTZList;
1395                         TZListType = &GeneralTZListType;
1396                         TZListMediatype = &GeneralTZListMediatype;
1397                         TZListAltID = &GeneralTZListAltID;
1398                         TZListPID = &GeneralTZListPID;
1399                         TZListTokens = &GeneralTZListTokens;
1400                         TZListPref = &GeneralTZListPref;
1401                         break;
1402                 case PROPERTY_HOME:
1403                         TZList = &HomeTZList;
1404                         TZListType = &HomeTZListType;
1405                         TZListMediatype = &HomeTZListMediatype;
1406                         TZListAltID = &HomeTZListAltID;
1407                         TZListPID = &HomeTZListPID;
1408                         TZListTokens = &HomeTZListTokens;
1409                         TZListPref = &HomeTZListPref;
1410                         break;
1411                 case PROPERTY_WORK:
1412                         TZList = &BusinessTZList;
1413                         TZListType = &BusinessTZListType;
1414                         TZListMediatype = &BusinessTZListMediatype;
1415                         TZListAltID = &BusinessTZListAltID;
1416                         TZListPID = &BusinessTZListPID;
1417                         TZListTokens = &BusinessTZListTokens;
1418                         TZListPref = &BusinessTZListPref;
1419                         break;
1420         }
1421         
1422         std::map<int, int>::iterator SLiter;    
1423         wxString PropertyData;
1424         wxString PropertyName;
1425         wxString PropertyValue;
1426         wxString PropertyTokens;
1427         bool FirstToken = TRUE;
1428         bool PropertyMatched = FALSE;
1429         
1430         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1431         intiter != SplitPoints.end(); ++intiter){
1432         
1433                 SLiter = SplitLength.find(intiter->first);      
1434                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1435                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1436                 intPrevValue = intiter->second;
1437                 
1438                 CaptureString(&PropertyValue, FALSE);
1440                 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1441                 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1442                 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1443                 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1444                 
1445                 if (PropertyMatched == TRUE){
1446                 
1447                         PropertyMatched = FALSE;
1448                         continue;
1449                 
1450                 }
1452                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1453         
1454                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1455         
1456                 }
1457                 
1458         }
1459         
1460         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1461         
1462         // Add the name token data.
1463         
1464         if (!PropertyTokens.IsEmpty()){
1465         
1466                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1467         
1468         }
1473 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1475         size_t intPropertyLen = PropertySeg1.Len();
1476         std::map<int, int> SplitPoints;
1477         std::map<int, int> SplitLength;
1478         std::map<int, int>::iterator SLiter;                    
1479         wxString PropertyData;
1480         wxString PropertyName;
1481         wxString PropertyValue;
1482         wxString PropertyTokens;
1483         wxString AddressLabel;
1484         wxString AddressLang;
1485         wxString AddressAltID;
1486         wxString AddressPID;
1487         wxString AddressTokens;
1488         wxString AddressGeo;
1489         wxString AddressTimezone;
1490         wxString AddressType;
1491         wxString AddressMediatype;
1492         wxString AddressPOBox;
1493         wxString AddressExtended;
1494         wxString AddressStreet;
1495         wxString AddressLocality;
1496         wxString AddressCity;
1497         wxString AddressRegion;
1498         wxString AddressPostalCode;
1499         wxString AddressCountry;
1500         bool FirstToken = TRUE;                 
1501         int intSplitsFound = 0;
1502         int intSplitSize = 0;
1503         int intPrevValue = 5;
1504         bool PropertyMatched = FALSE;
1505         
1506         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1507         
1508         intPrevValue = 4;
1509         
1510         PropertyType PropType = PROPERTY_NONE;
1511                 
1512         // Look for type before continuing.
1513         
1514         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1515         
1516         intPrevValue = 4;
1517         
1518         std::map<int, wxString> *AddressList = NULL;
1519         std::map<int, wxString> *AddressListTown = NULL;
1520         std::map<int, wxString> *AddressListCounty = NULL;
1521         std::map<int, wxString> *AddressListPostCode = NULL;
1522         std::map<int, wxString> *AddressListCountry = NULL;
1523         std::map<int, wxString> *AddressListLabel = NULL;
1524         std::map<int, wxString> *AddressListLang = NULL;                
1525         std::map<int, wxString> *AddressListAltID = NULL;
1526         std::map<int, wxString> *AddressListPID = NULL;
1527         std::map<int, wxString> *AddressListTokens = NULL;
1528         std::map<int, wxString> *AddressListGeo = NULL;
1529         std::map<int, wxString> *AddressListTimezone = NULL;            
1530         std::map<int, wxString> *AddressListType = NULL;
1531         std::map<int, wxString> *AddressListMediatype = NULL;
1532         std::map<int, int> *AddressListPref = NULL;
1534         switch(PropType){
1535                 case PROPERTY_NONE:
1536                         AddressList = &GeneralAddressList;
1537                         AddressListTown = &GeneralAddressListTown;
1538                         AddressListCounty = &GeneralAddressListCounty;
1539                         AddressListPostCode = &GeneralAddressListPostCode;
1540                         AddressListCountry = &GeneralAddressListCountry;
1541                         AddressListLabel = &GeneralAddressListLabel;
1542                         AddressListLang = &GeneralAddressListLang;              
1543                         AddressListAltID = &GeneralAddressListAltID;
1544                         AddressListPID = &GeneralAddressListPID;
1545                         AddressListTokens = &GeneralAddressListTokens;
1546                         AddressListGeo = &GeneralAddressListGeo;
1547                         AddressListTimezone = &GeneralAddressListTimezone;
1548                         AddressListType = &GeneralAddressListType;
1549                         AddressListMediatype = &GeneralAddressListMediatype;
1550                         AddressListPref = &GeneralAddressListPref;              
1551                         break;
1552                 case PROPERTY_HOME:
1553                         AddressList = &HomeAddressList;
1554                         AddressListTown = &HomeAddressListTown;
1555                         AddressListCounty = &HomeAddressListCounty;
1556                         AddressListPostCode = &HomeAddressListPostCode;
1557                         AddressListCountry = &HomeAddressListCountry;
1558                         AddressListLabel = &HomeAddressListLabel;
1559                         AddressListLang = &HomeAddressListLang;         
1560                         AddressListAltID = &HomeAddressListAltID;
1561                         AddressListPID = &HomeAddressListPID;
1562                         AddressListTokens = &HomeAddressListTokens;
1563                         AddressListGeo = &HomeAddressListGeo;
1564                         AddressListTimezone = &HomeAddressListTimezone;
1565                         AddressListType = &HomeAddressListType;
1566                         AddressListMediatype = &HomeAddressListMediatype;
1567                         AddressListPref = &HomeAddressListPref;
1568                         break;
1569                 case PROPERTY_WORK:
1570                         AddressList = &BusinessAddressList;
1571                         AddressListTown = &BusinessAddressListTown;
1572                         AddressListCounty = &BusinessAddressListCounty;
1573                         AddressListPostCode = &BusinessAddressListPostCode;
1574                         AddressListCountry = &BusinessAddressListCountry;
1575                         AddressListLabel = &BusinessAddressListLabel;
1576                         AddressListLang = &BusinessAddressListLang;             
1577                         AddressListAltID = &BusinessAddressListAltID;
1578                         AddressListPID = &BusinessAddressListPID;
1579                         AddressListTokens = &BusinessAddressListTokens;
1580                         AddressListGeo = &BusinessAddressListGeo;
1581                         AddressListTimezone = &BusinessAddressListTimezone;
1582                         AddressListType = &BusinessAddressListType;
1583                         AddressListMediatype = &BusinessAddressListMediatype;
1584                         AddressListPref = &BusinessAddressListPref;
1585                         break;
1586         }
1587         
1588         intPrevValue = 4;
1589         
1590         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1591         intiter != SplitPoints.end(); ++intiter){
1592         
1593                 SLiter = SplitLength.find(intiter->first);
1594                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1595                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1596                 intPrevValue = intiter->second;
1597                 
1598                 CaptureString(&PropertyValue, FALSE);
1599                 
1600                 // Process properties.
1601                 
1602                 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1603                 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1604                 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1605                 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1606                 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1607                 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1608                 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1609                 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1610                 
1611                 if (PropertyMatched == TRUE){
1612                 
1613                         PropertyMatched = FALSE;
1614                         continue;
1615                 
1616                 }
1617                 
1618                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1619         
1620         }                       
1621         
1622         // Split the address. 
1624         //std::map<int, int>::iterator SLiter;
1625         intPropertyLen = PropertySeg2.Len();
1626         SplitPoints.clear();
1627         SplitLength.clear();
1628         intSplitsFound = 0;
1629         intSplitSize = 0;
1630         intPrevValue = 0;
1631         
1632         for (int i = 0; i <= intPropertyLen; i++){
1634                 intSplitSize++;
1635         
1636                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1637         
1638                         intSplitsFound++;
1639                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1640                         
1641                         if (intSplitsFound == 6){ 
1642                         
1643                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1644                                 break; 
1645                                 
1646                         } else {
1647                         
1648                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1649                         
1650                         }
1651                         
1652                         intSplitSize = 0;                                       
1653         
1654                 }
1656         }
1657         
1658         // Split the data into several parts.                   
1659         
1660         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1661         intiter != SplitPoints.end(); ++intiter){
1662                         
1663                 if (intiter->first == 1){
1664                 
1665                         // Deal with PO Box.
1666                         
1667                         SLiter = SplitLength.find(1);
1668                                                                 
1669                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1670                         intPrevValue = intiter->second;
1671                 
1672                 } else if (intiter->first == 2){
1673                 
1674                         // Deal with extended address.
1675                         
1676                         SLiter = SplitLength.find(2);
1677                         
1678                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1679                         intPrevValue = intiter->second;
1680                 
1681                 } else if (intiter->first == 3){
1682                 
1683                         // Deal with street address.
1684                         
1685                         SLiter = SplitLength.find(3);
1686                                                                 
1687                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1688                         intPrevValue = intiter->second;
1689                 
1690                 } else if (intiter->first == 4){
1691                 
1692                         // Deal with locality
1694                         SLiter = SplitLength.find(4);
1695                         
1696                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1697                         intPrevValue = intiter->second;
1698                 
1699                 } else if (intiter->first == 5){
1700                 
1701                         // Deal with region.
1703                         SLiter = SplitLength.find(5);
1704                         
1705                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1706                         intPrevValue = intiter->second;
1707                         
1708                 
1709                 } else if (intiter->first == 6){
1710                 
1711                         // Deal with post code.
1713                         SLiter = SplitLength.find(6);
1714                         
1715                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1716                         intPrevValue = intiter->second;
1717                         
1718                         // Deal with country.
1719                                                 
1720                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1722                         break;
1723                 
1724                 }
1725         
1726         }       
1727         
1728         // Add the data to the General/Home/Work address variables.
1729         
1730         CaptureString(&AddressStreet, FALSE); 
1731         CaptureString(&AddressLocality, FALSE);
1732         CaptureString(&AddressRegion, FALSE);
1733         CaptureString(&AddressPostalCode, FALSE);
1734         CaptureString(&AddressCountry, FALSE);
1735                 
1736         if (!PropertyTokens.IsEmpty()){
1737         
1738                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1739         
1740         }
1742         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1743         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1744         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1745         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1746         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1748         switch(PropType){
1749                 case PROPERTY_NONE:
1750                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1751                         break;
1752                 case PROPERTY_HOME:
1753                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1754                         break;
1755                 case PROPERTY_WORK:
1756                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1757                         break;
1758         }
1759         
1760         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1764 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1766         std::map<int, int> SplitPoints;
1767         std::map<int, int> SplitLength;
1769         int intPrevValue = 7;
1770         
1771         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1772         
1773         intPrevValue = 6;
1774         
1775         PropertyType PropType = PROPERTY_NONE;
1776                 
1777         // Look for type before continuing.
1778         
1779         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1780         
1781         std::map<int, wxString> *EmailList = NULL;
1782         std::map<int, wxString> *EmailListType = NULL;
1783         std::map<int, wxString> *EmailListAltID = NULL;
1784         std::map<int, wxString> *EmailListPID = NULL;
1785         std::map<int, wxString> *EmailListTokens = NULL;                
1786         std::map<int, int> *EmailListPref = NULL;
1788         switch(PropType){
1789                 case PROPERTY_NONE:
1790                         EmailList = &GeneralEmailList;
1791                         EmailListType = &GeneralEmailListType;
1792                         EmailListAltID = &GeneralEmailListAltID;
1793                         EmailListPID = &GeneralEmailListPID;
1794                         EmailListTokens = &GeneralEmailListTokens;              
1795                         EmailListPref = &GeneralEmailListPref;  
1796                         break;
1797                 case PROPERTY_HOME:
1798                         EmailList = &HomeEmailList;
1799                         EmailListType = &HomeEmailListType;
1800                         EmailListAltID = &HomeEmailListAltID;
1801                         EmailListPID = &HomeEmailListPID;
1802                         EmailListTokens = &HomeEmailListTokens;         
1803                         EmailListPref = &HomeEmailListPref;     
1804                         break;
1805                 case PROPERTY_WORK:
1806                         EmailList = &BusinessEmailList;
1807                         EmailListType = &BusinessEmailListType;
1808                         EmailListAltID = &BusinessEmailListAltID;
1809                         EmailListPID = &BusinessEmailListPID;
1810                         EmailListTokens = &BusinessEmailListTokens;             
1811                         EmailListPref = &BusinessEmailListPref; 
1812                         break;
1813         }
1814         
1815         intPrevValue = 6;
1816         
1817         std::map<int,int>::iterator SLiter;
1818         wxString PropertyData;
1819         wxString PropertyName;
1820         wxString PropertyValue;
1821         wxString PropertyTokens;
1822         bool FirstToken = TRUE;
1823         bool PropertyMatched = FALSE;
1824         
1825         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1826         intiter != SplitPoints.end(); ++intiter){
1827         
1828                 SLiter = SplitLength.find(intiter->first);
1829                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1830                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1831                 intPrevValue = intiter->second;
1832                 
1833                 CaptureString(&PropertyValue, FALSE);
1834                 
1835                 // Process properties.
1836                 
1837                 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
1838                 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
1839                 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
1840                 
1841                 if (PropertyMatched == TRUE){
1842                 
1843                         PropertyMatched = FALSE;
1844                         continue;
1845                 
1846                 }
1847                 
1848                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1849         
1850         }
1851         
1852         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1853         
1854         // Add the name token data.
1855         
1856         if (!PropertyTokens.IsEmpty()){
1857         
1858                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1859         
1860         }       
1865 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1867         std::map<int, int> SplitPoints;
1868         std::map<int, int> SplitLength;
1870         int intPrevValue = 6;
1871         
1872         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1873         
1874         intPrevValue = 5;
1875         
1876         PropertyType PropType = PROPERTY_NONE;
1877                 
1878         // Look for type before continuing.
1879         
1880         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1881         
1882         std::map<int, wxString> *IMList = NULL;
1883         std::map<int, wxString> *IMListType = NULL;
1884         std::map<int, wxString> *IMListAltID = NULL;
1885         std::map<int, wxString> *IMListPID = NULL;
1886         std::map<int, wxString> *IMListTokens = NULL;
1887         std::map<int, wxString> *IMListMediatype = NULL;        
1888         std::map<int, int> *IMListPref = NULL;
1890         switch(PropType){
1891                 case PROPERTY_NONE:
1892                         IMList = &GeneralIMList;
1893                         IMListType = &GeneralIMListType;
1894                         IMListAltID = &GeneralIMListAltID;
1895                         IMListPID = &GeneralIMListPID;
1896                         IMListTokens = &GeneralIMListTokens;
1897                         IMListMediatype = &GeneralIMListMediatype;
1898                         IMListPref = &GeneralIMListPref;        
1899                         break;
1900                 case PROPERTY_HOME:
1901                         IMList = &HomeIMList;
1902                         IMListType = &HomeIMListType;
1903                         IMListAltID = &HomeIMListAltID;
1904                         IMListPID = &HomeIMListPID;
1905                         IMListTokens = &HomeIMListTokens;
1906                         IMListMediatype = &HomeIMListMediatype;         
1907                         IMListPref = &HomeIMListPref;   
1908                         break;
1909                 case PROPERTY_WORK:
1910                         IMList = &BusinessIMList;
1911                         IMListType = &BusinessIMListType;
1912                         IMListAltID = &BusinessIMListAltID;
1913                         IMListPID = &BusinessIMListPID;
1914                         IMListTokens = &BusinessIMListTokens;   
1915                         IMListMediatype = &BusinessIMListMediatype;     
1916                         IMListPref = &BusinessIMListPref;       
1917                         break;
1918         }
1919         
1920         intPrevValue = 5;
1921         
1922         std::map<int,int>::iterator SLiter;
1923         wxString PropertyData;
1924         wxString PropertyName;
1925         wxString PropertyValue;
1926         wxString PropertyTokens;
1927         bool FirstToken = TRUE;
1928         bool PropertyMatched = FALSE;
1929         
1930         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1931         intiter != SplitPoints.end(); ++intiter){
1932         
1933                 SLiter = SplitLength.find(intiter->first);
1934                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1935                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1936                 intPrevValue = intiter->second;
1937                 
1938                 CaptureString(&PropertyValue, FALSE);
1939                 
1940                 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
1941                 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
1942                 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
1943                 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
1944                 
1945                 // Process properties.
1946                 
1947                 if (PropertyMatched == TRUE){
1948                         
1949                         PropertyMatched = FALSE;
1950                         continue;
1951                 
1952                 }
1953                 
1954                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1955         
1956         }
1957                 
1958         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1959         
1960         // Add the name token data.
1961         
1962         if (!PropertyTokens.IsEmpty()){
1963         
1964                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1965         
1966         }
1970 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1972         std::map<int, int> SplitPoints;
1973         std::map<int, int> SplitLength;
1974         std::map<int, int>::iterator SLiter;
1975         
1976         PropertyType PropType = PROPERTY_NONE;
1977                 
1978         // Look for type before continuing.
1979         
1980         wxString TelTypeUI;
1981         wxString TelTypeDetail;
1982         wxString PropertyData;
1983         wxString PropertyName;
1984         wxString PropertyValue;
1985         wxString PropertyTokens;
1986         
1987         std::map<int,int> TypeSplitPoints;
1988         std::map<int,int> TypeSplitLength;
1989         std::map<int,int>::iterator TSLiter;
1990         
1991         int intSplitSize = 0;
1992         int intSplitsFound = 0;
1993         int intSplitPoint = 0;
1994         int intType = 0;
1995         int intPrevValue = 5;
1996                 
1997         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1998         
1999         intPrevValue = 4;
2000         
2001         // Look for type before continuing.
2002         
2003         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2004         intiter != SplitPoints.end(); ++intiter){
2005         
2006                 SLiter = SplitLength.find(intiter->first);
2007                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2008                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2009                 intPrevValue = intiter->second;
2011                 if (PropertyName == wxT("TYPE")){
2012                 
2013                         // Process each value in type and translate each
2014                         // part.
2015                 
2016                         // Strip out the quotes if they are there.
2017                 
2018                         size_t intPropertyValueLen = PropertyValue.Len();
2019                 
2020                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2021                         
2022                                 PropertyValue.Trim();
2023                                 PropertyValue.RemoveLast();
2024                         
2025                         }                               
2026                 
2027                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2028                         
2029                                 PropertyValue.Remove(0, 1);
2030                         
2031                         }
2032                         
2033                         TelTypeDetail = PropertyValue;
2034                         
2035                         intSplitSize = 0;
2036                         intSplitsFound = 0;
2037                         intSplitPoint = 0;
2038                         
2039                         for (int i = 0; i <= intPropertyValueLen; i++){
2040         
2041                                 intSplitSize++;
2042         
2043                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2044         
2045                                         if (intSplitsFound == 0){
2047                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2048                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2049                         
2050                                         } else {
2051                         
2052                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2053                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2054                         
2055                                         }                       
2057                                         intSplitsFound++;
2058                                         i++;
2059                                         intSplitPoint = i;
2060                                         intSplitSize = 0;
2061         
2062                                 }
2063         
2064                         }
2065                         
2066                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2067                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2068                 
2069                         int intTypeSeek = 0;
2070                 
2071                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2072                         typeiter != TypeSplitPoints.end(); ++typeiter){
2073                         
2074                                 wxString TypePropertyName;
2075                                 
2076                                 TSLiter = TypeSplitLength.find(typeiter->first);
2077                                 
2078                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2079                                 
2080                                 if (intTypeSeek == 0){
2081                                 
2082                                 
2083                                 } else {
2084                                                                                 
2085                                         TelTypeUI.Append(wxT(","));                                                     
2086                                 
2087                                 }
2088                         
2089                                 if (TypePropertyName == wxT("home")){
2090                                 
2091                                         PropType = PROPERTY_HOME;
2092                                 
2093                                 } else if (TypePropertyName == wxT("work")){
2094                                 
2095                                         PropType = PROPERTY_WORK;
2096                                                                         
2097                                 }
2098                                 
2099                                 
2100                                 if (TypePropertyName == wxT("text")){
2101                                 
2102                                         TelTypeUI.Append(_("text"));
2103                                         intTypeSeek++;
2104                                 
2105                                 } else if (TypePropertyName == wxT("voice")){
2106                                 
2107                                         TelTypeUI.Append(_("voice"));
2108                                         intTypeSeek++;
2109                                 
2110                                 } else if (TypePropertyName == wxT("fax")){
2111                                 
2112                                         TelTypeUI.Append(_("fax"));
2113                                         intTypeSeek++;
2114                                 
2115                                 } else if (TypePropertyName == wxT("cell")){
2116                                 
2117                                         TelTypeUI.Append(_("mobile"));
2118                                         intTypeSeek++;
2119                                 
2120                                 } else if (TypePropertyName == wxT("video")){
2121                                 
2122                                         TelTypeUI.Append(_("video"));
2123                                         intTypeSeek++;
2124                                 
2125                                 } else if (TypePropertyName == wxT("pager")){
2126                                 
2127                                         TelTypeUI.Append(_("pager"));
2128                                         intTypeSeek++;
2129                                 
2130                                 } else if (TypePropertyName == wxT("textphone")){
2131                                 
2132                                         TelTypeUI.Append(_("textphone"));
2133                                         intTypeSeek++;
2134                                 
2135                                 }
2136                         
2137                         }
2138                 
2139                 }
2140                 
2141         }
2142         
2143         std::map<int, wxString> *TelephoneList = NULL;
2144         std::map<int, wxString> *TelephoneListType = NULL;
2145         std::map<int, wxString> *TelephoneListAltID = NULL;
2146         std::map<int, wxString> *TelephoneListPID = NULL;
2147         std::map<int, wxString> *TelephoneListTokens = NULL;
2148         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2149         std::map<int, int> *TelephoneListPref = NULL;
2151         switch(PropType){
2152                 case PROPERTY_NONE:
2153                         TelephoneList = &GeneralTelephoneList;
2154                         TelephoneListType = &GeneralTelephoneListType;
2155                         TelephoneListAltID = &GeneralTelephoneListAltID;
2156                         TelephoneListPID = &GeneralTelephoneListPID;
2157                         TelephoneListTokens = &GeneralTelephoneListTokens;
2158                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2159                         TelephoneListPref = &GeneralTelephoneListPref;  
2160                         break;
2161                 case PROPERTY_HOME:
2162                         TelephoneList = &HomeTelephoneList;
2163                         TelephoneListType = &HomeTelephoneListType;
2164                         TelephoneListAltID = &HomeTelephoneListAltID;
2165                         TelephoneListPID = &HomeTelephoneListPID;
2166                         TelephoneListTokens = &HomeTelephoneListTokens;
2167                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2168                         TelephoneListPref = &HomeTelephoneListPref;     
2169                         break;
2170                 case PROPERTY_WORK:
2171                         TelephoneList = &BusinessTelephoneList;
2172                         TelephoneListType = &BusinessTelephoneListType;
2173                         TelephoneListAltID = &BusinessTelephoneListAltID;
2174                         TelephoneListPID = &BusinessTelephoneListPID;
2175                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2176                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2177                         TelephoneListPref = &BusinessTelephoneListPref; 
2178                         break;
2179         }
2180                 
2181         // Process the properties.
2182         
2183         bool FirstToken = TRUE;
2184         
2185         intPrevValue = 5;
2186         SplitPoints.clear();
2187         SplitLength.clear();
2189         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2191         intPrevValue = 4;
2192         
2193         bool PropertyMatched = FALSE;
2194         
2195         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2196         intiter != SplitPoints.end(); ++intiter){
2197         
2198                 SLiter = SplitLength.find(intiter->first);
2199                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2200                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2201                 intPrevValue = intiter->second;
2202                 
2203                 CaptureString(&PropertyValue, FALSE);
2204                 
2205                 // Process properties.
2206                 
2207                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2208                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2209                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2210                 
2211                 if (PropertyMatched == TRUE){
2212                 
2213                         PropertyMatched = FALSE;
2214                         continue;
2215                 
2216                 }
2218                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2219         
2220         }
2221                 
2222         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2223         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2224         
2225         // Add the name token data.
2226         
2227         if (!PropertyTokens.IsEmpty()){
2228         
2229                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2230         
2231         }
2235 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2237         std::map<int, int> SplitPoints;
2238         std::map<int, int> SplitLength;
2240         int intPrevValue = 6;
2241         
2242         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2243         
2244         intPrevValue = 5;
2245         
2246         PropertyType PropType = PROPERTY_NONE;
2247                 
2248         // Look for type before continuing.
2249         
2250         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2251         
2252         std::map<int, wxString> *LanguageList = NULL;
2253         std::map<int, wxString> *LanguageListType = NULL;
2254         std::map<int, wxString> *LanguageListAltID = NULL;
2255         std::map<int, wxString> *LanguageListPID = NULL;
2256         std::map<int, wxString> *LanguageListTokens = NULL;
2257         std::map<int, int> *LanguageListPref = NULL;
2259         switch(PropType){
2260                 case PROPERTY_NONE:
2261                         LanguageList = &GeneralLanguageList;
2262                         LanguageListType = &GeneralLanguageListType;
2263                         LanguageListAltID = &GeneralLanguageListAltID;
2264                         LanguageListPID = &GeneralLanguageListPID;
2265                         LanguageListTokens = &GeneralLanguageListTokens;
2266                         LanguageListPref = &GeneralLanguageListPref;    
2267                         break;
2268                 case PROPERTY_HOME:
2269                         LanguageList = &HomeLanguageList;
2270                         LanguageListType = &HomeLanguageListType;
2271                         LanguageListAltID = &HomeLanguageListAltID;
2272                         LanguageListPID = &HomeLanguageListPID;
2273                         LanguageListTokens = &HomeLanguageListTokens;   
2274                         LanguageListPref = &HomeLanguageListPref;       
2275                         break;
2276                 case PROPERTY_WORK:
2277                         LanguageList = &BusinessLanguageList;
2278                         LanguageListType = &BusinessLanguageListType;
2279                         LanguageListAltID = &BusinessLanguageListAltID;
2280                         LanguageListPID = &BusinessLanguageListPID;
2281                         LanguageListTokens = &BusinessLanguageListTokens;       
2282                         LanguageListPref = &BusinessLanguageListPref;
2283                         break;
2284         }
2285         
2286         intPrevValue = 5;
2287         
2288         std::map<int,int>::iterator SLiter;
2289         wxString PropertyData;
2290         wxString PropertyName;
2291         wxString PropertyValue;
2292         wxString PropertyTokens;
2293         bool FirstToken = TRUE;
2294         bool PropertyMatched = FALSE;
2295         
2296         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2297         intiter != SplitPoints.end(); ++intiter){
2298         
2299                 SLiter = SplitLength.find(intiter->first);
2300                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2301                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2302                 intPrevValue = intiter->second;
2304                 CaptureString(&PropertyValue, FALSE);
2305                 
2306                 // Process properties.
2307                 
2308                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2309                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2310                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2312                 if (PropertyMatched == TRUE){
2313                 
2314                         PropertyMatched = FALSE;
2315                         continue;
2316                 
2317                 }
2318                 
2319                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2320         
2321         }
2322                 
2323         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2324         
2325         // Add the name token data.
2326         
2327         if (!PropertyTokens.IsEmpty()){
2328         
2329                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2330         
2331         }
2335 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2337         std::map<int, int> SplitPoints;
2338         std::map<int, int> SplitLength;
2340         int intPrevValue = 5;
2341         
2342         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2343         
2344         intPrevValue = 4;
2345         
2346         PropertyType PropType = PROPERTY_NONE;
2347                 
2348         // Look for type before continuing.
2349         
2350         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2351         
2352         std::map<int, wxString> *GeopositionList = NULL;
2353         std::map<int, wxString> *GeopositionListType = NULL;
2354         std::map<int, wxString> *GeopositionListAltID = NULL;
2355         std::map<int, wxString> *GeopositionListPID = NULL;
2356         std::map<int, wxString> *GeopositionListTokens = NULL;
2357         std::map<int, wxString> *GeopositionListMediatype = NULL;
2358         std::map<int, int> *GeopositionListPref = NULL;
2360         switch(PropType){
2361                 case PROPERTY_NONE:
2362                         GeopositionList = &GeneralGeographyList;
2363                         GeopositionListType = &GeneralGeographyListType;
2364                         GeopositionListAltID = &GeneralGeographyListAltID;
2365                         GeopositionListPID = &GeneralGeographyListPID;
2366                         GeopositionListTokens = &GeneralGeographyListTokens;
2367                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2368                         GeopositionListPref = &GeneralGeographyListPref;        
2369                         break;
2370                 case PROPERTY_HOME:
2371                         GeopositionList = &HomeGeographyList;
2372                         GeopositionListType = &HomeGeographyListType;
2373                         GeopositionListAltID = &HomeGeographyListAltID;
2374                         GeopositionListPID = &HomeGeographyListPID;
2375                         GeopositionListTokens = &HomeGeographyListTokens;
2376                         GeopositionListMediatype = &HomeGeographyListMediatype;
2377                         GeopositionListPref = &HomeGeographyListPref;   
2378                         break;
2379                 case PROPERTY_WORK:
2380                         GeopositionList = &BusinessGeographyList;
2381                         GeopositionListType = &BusinessGeographyListType;
2382                         GeopositionListAltID = &BusinessGeographyListAltID;
2383                         GeopositionListPID = &BusinessGeographyListPID;
2384                         GeopositionListTokens = &BusinessGeographyListTokens;
2385                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2386                         GeopositionListPref = &BusinessGeographyListPref;
2387                         break;
2388         }
2389         
2390         intPrevValue = 4;
2391         
2392         std::map<int,int>::iterator SLiter;
2393         wxString PropertyData;
2394         wxString PropertyName;
2395         wxString PropertyValue;
2396         wxString PropertyTokens;
2397         bool FirstToken = TRUE;
2398         bool PropertyMatched = FALSE;
2399         
2400         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2401         intiter != SplitPoints.end(); ++intiter){
2402         
2403                 SLiter = SplitLength.find(intiter->first);
2404                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2405                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2406                 intPrevValue = intiter->second;
2407                 
2408                 CaptureString(&PropertyValue, FALSE);
2409                 
2410                 // Process properties.
2411                 
2412                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2413                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2414                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2415                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2416                 
2417                 if (PropertyMatched == TRUE){
2418                 
2419                         PropertyMatched = FALSE;
2420                         continue;
2421                 
2422                 }
2423                 
2424                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2425         
2426         }
2427                 
2428         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2429         
2430         // Add the name token data.
2431         
2432         if (!PropertyTokens.IsEmpty()){
2433         
2434                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2435         
2436         }
2440 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2442         size_t intPropertyLen = PropertySeg1.Len();
2443         std::map<int, int> SplitPoints;
2444         std::map<int, int> SplitLength;
2445         std::map<int, int>::iterator SLiter;                    
2446         wxString PropertyData;
2447         wxString PropertyName;
2448         wxString PropertyValue;
2449         wxString PropertyTokens;
2450         wxString RelatedType;
2451         wxString RelatedTypeOriginal;                   
2452         wxString RelatedName;
2453         bool FirstToken = TRUE;                 
2454         int intSplitsFound = 0;
2455         int intSplitSize = 0;
2456         int intPrevValue = 9;
2457         
2458         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2459         
2460         intPrevValue = 8;
2461         
2462         // Look for type before continuing.
2463         
2464         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2465         intiter != SplitPoints.end(); ++intiter){
2466         
2467                 SLiter = SplitLength.find(intiter->first);
2468                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2469                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2470                 intPrevValue = intiter->second;
2471                 
2472                 // Process these.
2473                 
2474                 RelatedTypeOriginal = PropertyValue;
2475                 
2476                 if (PropertyName == wxT("TYPE")){
2477                 
2478                         if (PropertyValue == wxT("contact")){
2480                                 RelatedType = _("Contact");
2482                         } else if (PropertyValue == wxT("acquaintance")){
2484                                 RelatedType = _("Acquaintance");
2486                         } else if (PropertyValue == wxT("friend")){
2488                                 RelatedType = _("Friend");
2490                         } else if (PropertyValue == wxT("met")){
2492                                 RelatedType = _("Met");
2494                         } else if (PropertyValue == wxT("co-worker")){
2496                                 RelatedType = _("Co-worker");
2498                         } else if (PropertyValue == wxT("colleague")){
2500                                 RelatedType = _("Colleague");
2502                         } else if (PropertyValue == wxT("co-resident")){
2504                                 RelatedType = _("Co-resident");
2506                         } else if (PropertyValue == wxT("neighbor")){
2508                                 RelatedType = _("Neighbour");
2510                         } else if (PropertyValue == wxT("child")){
2512                                 RelatedType = _("Child");
2514                         } else if (PropertyValue == wxT("parent")){
2516                                 RelatedType = _("Parent");
2518                         } else if (PropertyValue == wxT("sibling")){
2520                                 RelatedType = _("Sibling");
2522                         } else if (PropertyValue == wxT("spouse")){
2524                                 RelatedType = _("Spouse");
2526                         } else if (PropertyValue == wxT("kin")){
2528                                 RelatedType = _("Kin");
2530                         } else if (PropertyValue == wxT("muse")){
2532                                 RelatedType = _("Muse");
2534                         } else if (PropertyValue == wxT("crush")){
2536                                 RelatedType = _("Crush");
2538                         } else if (PropertyValue == wxT("date")){
2540                                 RelatedType = _("Date");
2542                         } else if (PropertyValue == wxT("sweetheart")){
2544                                 RelatedType = _("Sweetheart");
2546                         } else if (PropertyValue == wxT("me")){
2548                                 RelatedType = _("Me");
2550                         } else if (PropertyValue == wxT("agent")){
2552                                 RelatedType = _("Agent");
2554                         } else if (PropertyValue == wxT("emergency")){
2556                                 RelatedType = _("Emergency");
2558                         } else {
2560                                 RelatedType = PropertyValue;
2562                         }
2563                 
2564                 }
2565         
2566         }
2567         
2568         intPrevValue = 8;                       
2569         
2570         bool PropertyMatched = FALSE;
2571         
2572         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2573         intiter != SplitPoints.end(); ++intiter){
2574         
2575                 SLiter = SplitLength.find(intiter->first);
2576                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2577                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2578                 intPrevValue = intiter->second;
2579                 
2580                 // Process properties.
2581                 
2582                 size_t intPropertyValueLen = PropertyValue.Len();
2583                 
2584                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2585                         
2586                         PropertyValue.Trim();
2587                         PropertyValue.RemoveLast();
2588                         
2589                 }                               
2590                 
2591                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2592                         
2593                         PropertyValue.Remove(0, 1);
2594                         
2595                 }
2596                 
2597                 CaptureString(&PropertyValue, FALSE);
2598                         
2599                 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2600                 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2601                 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2602                 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2604                 if (PropertyMatched == TRUE){
2605                 
2606                         PropertyMatched = FALSE;
2607                         continue;
2608                 
2609                 }
2611                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2612         
2613         }                                       
2614         
2615         // Add the data to the General/Home/Work address variables.
2616                                 
2617         GeneralRelatedList.erase(*RelatedCount);
2618         GeneralRelatedListRelType.erase(*RelatedCount);
2619         GeneralRelatedListType.erase(*RelatedCount);
2620         GeneralRelatedListTokens.erase(*RelatedCount);
2621         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2622         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2623         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2624         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2628 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2630         std::map<int, int> SplitPoints;
2631         std::map<int, int> SplitLength;
2632         std::map<int, int>::iterator SLiter;                    
2633         wxString PropertyData;
2634         wxString PropertyName;
2635         wxString PropertyValue;
2636         wxString PropertyTokens;
2637         bool FirstToken = TRUE;
2638         int intPrevValue = 5;
2639         
2640         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2641         
2642         intPrevValue = 4;
2643         
2644         PropertyType PropType = PROPERTY_NONE;
2645                 
2646         // Look for type before continuing.
2647         
2648         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2649         
2650         // Setup the pointers.
2651         
2652         std::map<int, wxString> *WebsiteList = NULL;
2653         std::map<int, wxString> *WebsiteListAltID = NULL;
2654         std::map<int, wxString> *WebsiteListPID = NULL;
2655         std::map<int, wxString> *WebsiteListType = NULL;
2656         std::map<int, wxString> *WebsiteListTokens = NULL;
2657         std::map<int, wxString> *WebsiteListMediatype = NULL;
2658         std::map<int, int> *WebsiteListPref = NULL;
2659         
2660         // Setup blank lines for later on.
2661         
2662         switch(PropType){
2663                 case PROPERTY_NONE:
2664                         WebsiteList = &GeneralWebsiteList;
2665                         WebsiteListType = &GeneralWebsiteListType;
2666                         WebsiteListAltID = &GeneralWebsiteListAltID;
2667                         WebsiteListPID = &GeneralWebsiteListPID;
2668                         WebsiteListTokens = &GeneralWebsiteListTokens;
2669                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2670                         WebsiteListPref = &GeneralWebsiteListPref;      
2671                         break;
2672                 case PROPERTY_HOME:
2673                         WebsiteList = &HomeWebsiteList;
2674                         WebsiteListType = &HomeWebsiteListType;
2675                         WebsiteListAltID = &HomeWebsiteListAltID;
2676                         WebsiteListPID = &HomeWebsiteListPID;
2677                         WebsiteListTokens = &HomeWebsiteListTokens;
2678                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2679                         WebsiteListPref = &HomeWebsiteListPref; 
2680                         break;
2681                 case PROPERTY_WORK:
2682                         WebsiteList = &BusinessWebsiteList;
2683                         WebsiteListType = &BusinessWebsiteListType;
2684                         WebsiteListAltID = &BusinessWebsiteListAltID;
2685                         WebsiteListPID = &BusinessWebsiteListPID;
2686                         WebsiteListTokens = &BusinessWebsiteListTokens;
2687                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2688                         WebsiteListPref = &BusinessWebsiteListPref;
2689                         break;
2690         }
2691         
2692         intPrevValue = 4;
2693         bool PropertyMatched = FALSE;
2694         
2695         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2696         intiter != SplitPoints.end(); ++intiter){
2697         
2698                 SLiter = SplitLength.find(intiter->first);
2699                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2700                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2701                 intPrevValue = intiter->second;
2702                 
2703                 // Process properties.
2704                 
2705                 size_t intPropertyValueLen = PropertyValue.Len();
2706                 
2707                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2708                         
2709                         PropertyValue.Trim();
2710                         PropertyValue.RemoveLast();
2711                         
2712                 }                               
2713                 
2714                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2715                         
2716                         PropertyValue.Remove(0, 1);
2717                         
2718                 }
2719                 
2720                 CaptureString(&PropertyValue, FALSE);
2721                 
2722                 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
2723                 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
2724                 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
2725                 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
2726                 
2727                 if (PropertyMatched == TRUE){
2728                 
2729                         PropertyMatched = FALSE;
2730                         continue;
2731                 
2732                 }
2733                 
2734                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2735         
2736         }
2737         
2738         // Add the data to the General/Home/Work address variables.
2739         
2740         CaptureString(&PropertySeg2, FALSE);
2741                         
2742         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2743         
2744         if (!PropertyTokens.IsEmpty()){
2745         
2746                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2747                         
2748         }
2749         
2752 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
2754         std::map<int, int> SplitPoints;
2755         std::map<int, int> SplitLength;
2756         std::map<int, int>::iterator SLiter;                    
2757         wxString PropertyData;
2758         wxString PropertyName;
2759         wxString PropertyValue;
2760         wxString PropertyTokens;
2761         bool FirstToken = TRUE;
2762         int intPrevValue = 7;
2763         
2764         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2765         
2766         intPrevValue = 6;
2767         
2768         PropertyType PropType = PROPERTY_NONE;
2769                 
2770         // Look for type before continuing.
2771         
2772         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2773         
2774         // Setup the pointers.
2775         
2776         std::map<int, wxString> *TitleList = NULL;
2777         std::map<int, wxString> *TitleListAltID = NULL;
2778         std::map<int, wxString> *TitleListPID = NULL;
2779         std::map<int, wxString> *TitleListType = NULL;
2780         std::map<int, wxString> *TitleListTokens = NULL;
2781         std::map<int, wxString> *TitleListLanguage = NULL;
2782         std::map<int, int> *TitleListPref = NULL;
2783         
2784         // Setup blank lines for later on.
2785         
2786         switch(PropType){
2787                 case PROPERTY_NONE:
2788                         TitleList = &GeneralTitleList;
2789                         TitleListType = &GeneralTitleListType;
2790                         TitleListAltID = &GeneralTitleListAltID;
2791                         TitleListPID = &GeneralTitleListPID;
2792                         TitleListTokens = &GeneralTitleListTokens;
2793                         TitleListLanguage = &GeneralTitleListLanguage;
2794                         TitleListPref = &GeneralTitleListPref;  
2795                         break;
2796                 case PROPERTY_HOME:
2797                         TitleList = &HomeTitleList;
2798                         TitleListType = &HomeTitleListType;
2799                         TitleListAltID = &HomeTitleListAltID;
2800                         TitleListPID = &HomeTitleListPID;
2801                         TitleListTokens = &HomeTitleListTokens;
2802                         TitleListLanguage = &HomeTitleListLanguage;
2803                         TitleListPref = &HomeTitleListPref;     
2804                         break;
2805                 case PROPERTY_WORK:
2806                         TitleList = &BusinessTitleList;
2807                         TitleListType = &BusinessTitleListType;
2808                         TitleListAltID = &BusinessTitleListAltID;
2809                         TitleListPID = &BusinessTitleListPID;
2810                         TitleListTokens = &BusinessTitleListTokens;
2811                         TitleListLanguage = &BusinessTitleListLanguage; 
2812                         TitleListPref = &BusinessTitleListPref;
2813                         break;
2814         }
2816         intPrevValue = 6;
2817         bool PropertyMatched = FALSE;
2818                 
2819         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2820         intiter != SplitPoints.end(); ++intiter){
2821         
2822                 SLiter = SplitLength.find(intiter->first);
2823                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2824                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2825                 intPrevValue = intiter->second;
2826                 
2827                 // Process properties.
2828                 
2829                 size_t intPropertyValueLen = PropertyValue.Len();
2830                 
2831                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2832                         
2833                         PropertyValue.Trim();
2834                         PropertyValue.RemoveLast();
2835                         
2836                 }                               
2837                 
2838                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2839                         
2840                         PropertyValue.Remove(0, 1);
2841                         
2842                 }                               
2843                 
2844                 CaptureString(&PropertyValue, FALSE);
2845                 
2846                 ProcessStringValue(&PropertyName, "ALTID", TitleListAltID, &PropertyValue, TitleCount, &PropertyMatched);
2847                 ProcessStringValue(&PropertyName, "PID", TitleListPID, &PropertyValue, TitleCount, &PropertyMatched);
2848                 ProcessStringValue(&PropertyName, "LANGUAGE", TitleListLanguage, &PropertyValue, TitleCount, &PropertyMatched);
2849                 ProcessIntegerValue(&PropertyName, "PREF", TitleListPref, &PropertyValue, TitleCount, &PropertyMatched);
2850                 
2851                 if (PropertyMatched == TRUE){
2852                 
2853                         PropertyMatched = FALSE;
2854                         continue;
2855                 
2856                 }
2858                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2859         
2860         }
2861         
2862         // Add the data to the General/Home/Work address variables.
2863         
2864         CaptureString(&PropertySeg2, FALSE);
2866         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
2867         
2868         if (!PropertyTokens.IsEmpty()){
2869         
2870                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
2871                         
2872         }
2876 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
2878         std::map<int, int> SplitPoints;
2879         std::map<int, int> SplitLength;
2880         std::map<int, int>::iterator SLiter;                    
2881         wxString PropertyData;
2882         wxString PropertyName;
2883         wxString PropertyValue;
2884         wxString PropertyTokens;
2885         bool FirstToken = TRUE;
2886         int intPrevValue = 6;
2887         
2888         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2889         
2890         intPrevValue = 5;
2891         
2892         PropertyType PropType = PROPERTY_NONE;
2893                 
2894         // Look for type before continuing.
2895         
2896         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2897         
2898         // Setup the pointers.
2899         
2900         std::map<int, wxString> *RoleList = NULL;
2901         std::map<int, wxString> *RoleListAltID = NULL;
2902         std::map<int, wxString> *RoleListPID = NULL;
2903         std::map<int, wxString> *RoleListType = NULL;
2904         std::map<int, wxString> *RoleListTokens = NULL;
2905         std::map<int, wxString> *RoleListLanguage = NULL;
2906         std::map<int, int> *RoleListPref = NULL;
2907         
2908         // Setup blank lines for later on.
2909         
2910         switch(PropType){
2911                 case PROPERTY_NONE:
2912                         RoleList = &GeneralRoleList;
2913                         RoleListType = &GeneralRoleListType;
2914                         RoleListAltID = &GeneralRoleListAltID;
2915                         RoleListPID = &GeneralRoleListPID;
2916                         RoleListTokens = &GeneralRoleListTokens;
2917                         RoleListLanguage = &GeneralRoleListLanguage;
2918                         RoleListPref = &GeneralRoleListPref;    
2919                         break;
2920                 case PROPERTY_HOME:
2921                         RoleList = &HomeRoleList;
2922                         RoleListType = &HomeRoleListType;
2923                         RoleListAltID = &HomeRoleListAltID;
2924                         RoleListPID = &HomeRoleListPID;
2925                         RoleListTokens = &HomeRoleListTokens;
2926                         RoleListLanguage = &HomeRoleListLanguage;
2927                         RoleListPref = &HomeRoleListPref;       
2928                         break;
2929                 case PROPERTY_WORK:
2930                         RoleList = &BusinessRoleList;
2931                         RoleListType = &BusinessRoleListType;
2932                         RoleListAltID = &BusinessRoleListAltID;
2933                         RoleListPID = &BusinessRoleListPID;
2934                         RoleListTokens = &BusinessRoleListTokens;
2935                         RoleListLanguage = &BusinessRoleListLanguage;   
2936                         RoleListPref = &BusinessRoleListPref;
2937                         break;
2938         }
2940         intPrevValue = 5;
2941         bool PropertyMatched = FALSE;
2942                 
2943         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2944         intiter != SplitPoints.end(); ++intiter){
2945         
2946                 SLiter = SplitLength.find(intiter->first);
2947                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2948                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2949                 intPrevValue = intiter->second;
2950                 
2951                 // Process properties.
2952                 
2953                 size_t intPropertyValueLen = PropertyValue.Len();
2954                 
2955                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2956                         
2957                         PropertyValue.Trim();
2958                         PropertyValue.RemoveLast();
2959                         
2960                 }                               
2961                 
2962                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2963                         
2964                         PropertyValue.Remove(0, 1);
2965                         
2966                 }                               
2967                 
2968                 CaptureString(&PropertyValue, FALSE);
2969                 
2970                 ProcessStringValue(&PropertyName, "ALTID", RoleListAltID, &PropertyValue, RoleCount, &PropertyMatched);
2971                 ProcessStringValue(&PropertyName, "PID", RoleListPID, &PropertyValue, RoleCount, &PropertyMatched);
2972                 ProcessStringValue(&PropertyName, "LANGUAGE", RoleListLanguage, &PropertyValue, RoleCount, &PropertyMatched);
2973                 ProcessIntegerValue(&PropertyName, "PREF", RoleListPref, &PropertyValue, RoleCount, &PropertyMatched);
2974                 
2975                 if (PropertyMatched == TRUE){
2976                 
2977                         PropertyMatched = FALSE;
2978                         continue;
2979                 
2980                 }
2981                 
2982                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2983                 
2984         }
2985         
2986         // Add the data to the General/Home/Work address variables.
2987         
2988         CaptureString(&PropertySeg2, FALSE);
2990         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
2991         
2992         if (!PropertyTokens.IsEmpty()){
2993         
2994                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
2995                         
2996         }
3000 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3002         std::map<int, int> SplitPoints;
3003         std::map<int, int> SplitLength;
3004         std::map<int, int>::iterator SLiter;                    
3005         wxString PropertyData;
3006         wxString PropertyName;
3007         wxString PropertyValue;
3008         wxString PropertyTokens;
3009         bool FirstToken = TRUE;
3010         int intPrevValue = 5;
3011         
3012         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3013         
3014         intPrevValue = 4;
3015         
3016         PropertyType PropType = PROPERTY_NONE;
3017                 
3018         // Look for type before continuing.
3019         
3020         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3021         
3022         // Setup the pointers.
3023         
3024         std::map<int, wxString> *OrganisationsList = NULL;
3025         std::map<int, wxString> *OrganisationsListAltID = NULL;
3026         std::map<int, wxString> *OrganisationsListPID = NULL;
3027         std::map<int, wxString> *OrganisationsListType = NULL;
3028         std::map<int, wxString> *OrganisationsListTokens = NULL;
3029         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3030         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3031         std::map<int, int> *OrganisationsListPref = NULL;
3032         
3033         // Setup blank lines for later on.
3034         
3035         switch(PropType){
3036                 case PROPERTY_NONE:
3037                         OrganisationsList = &GeneralOrganisationsList;
3038                         OrganisationsListType = &GeneralOrganisationsListType;
3039                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3040                         OrganisationsListPID = &GeneralOrganisationsListPID;
3041                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3042                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3043                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3044                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3045                         break;
3046                 case PROPERTY_HOME:
3047                         OrganisationsList = &HomeOrganisationsList;
3048                         OrganisationsListType = &HomeOrganisationsListType;
3049                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3050                         OrganisationsListPID = &HomeOrganisationsListPID;
3051                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3052                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3053                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3054                         OrganisationsListPref = &HomeOrganisationsListPref;     
3055                         break;
3056                 case PROPERTY_WORK:
3057                         OrganisationsList = &BusinessOrganisationsList;
3058                         OrganisationsListType = &BusinessOrganisationsListType;
3059                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3060                         OrganisationsListPID = &BusinessOrganisationsListPID;
3061                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3062                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3063                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3064                         OrganisationsListPref = &BusinessOrganisationsListPref;
3065                         break;
3066         }
3068         intPrevValue = 4;
3069         bool PropertyMatched = FALSE;
3070                 
3071         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3072         intiter != SplitPoints.end(); ++intiter){
3073         
3074                 SLiter = SplitLength.find(intiter->first);
3075                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3076                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3077                 intPrevValue = intiter->second;
3078                 
3079                 // Process properties.
3080                 
3081                 size_t intPropertyValueLen = PropertyValue.Len();
3082                 
3083                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3084                         
3085                         PropertyValue.Trim();
3086                         PropertyValue.RemoveLast();
3087                         
3088                 }                               
3089                 
3090                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3091                         
3092                         PropertyValue.Remove(0, 1);
3093                         
3094                 }                               
3095                 
3096                 CaptureString(&PropertyValue, FALSE);
3097                 
3098                 ProcessStringValue(&PropertyName, "ALTID", OrganisationsListAltID, &PropertyValue, OrganisationCount, &PropertyMatched);
3099                 ProcessStringValue(&PropertyName, "PID", OrganisationsListPID, &PropertyValue, OrganisationCount, &PropertyMatched);
3100                 ProcessStringValue(&PropertyName, "LANGUAGE", OrganisationsListLanguage, &PropertyValue, OrganisationCount, &PropertyMatched);
3101                 ProcessStringValue(&PropertyName, "SORT-AS", OrganisationsListSortAs, &PropertyValue, OrganisationCount, &PropertyMatched);
3102                 ProcessIntegerValue(&PropertyName, "PREF", OrganisationsListPref, &PropertyValue, OrganisationCount, &PropertyMatched);
3103                 
3104                 if (PropertyMatched == TRUE){
3105                 
3106                         PropertyMatched = FALSE;
3107                         continue;
3108                 
3109                 }
3110                 
3111                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3113         }
3114         
3115         // Add the data to the General/Home/Work address variables.
3116         
3117         CaptureString(&PropertySeg2, FALSE);
3119         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3120         
3121         if (!PropertyTokens.IsEmpty()){
3122         
3123                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3124                         
3125         }
3129 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3131         std::map<int, int> SplitPoints;
3132         std::map<int, int> SplitLength;
3133         std::map<int, int>::iterator SLiter;                    
3134         wxString PropertyData;
3135         wxString PropertyName;
3136         wxString PropertyValue;
3137         wxString PropertyTokens;
3138         bool FirstToken = TRUE;
3139         int intPrevValue = 6;
3140         
3141         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3142         
3143         intPrevValue = 5;
3144         
3145         PropertyType PropType = PROPERTY_NONE;
3146                 
3147         // Look for type before continuing.
3148         
3149         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3150         
3151         // Setup the pointers.
3152         
3153         std::map<int, wxString> *NoteList = NULL;
3154         std::map<int, wxString> *NoteListAltID = NULL;
3155         std::map<int, wxString> *NoteListPID = NULL;
3156         std::map<int, wxString> *NoteListType = NULL;
3157         std::map<int, wxString> *NoteListTokens = NULL;
3158         std::map<int, wxString> *NoteListLanguage = NULL;
3159         std::map<int, int> *NoteListPref = NULL;
3160         
3161         // Setup blank lines for later on.
3162         
3163         switch(PropType){
3164                 case PROPERTY_NONE:
3165                         NoteList = &GeneralNoteList;
3166                         NoteListType = &GeneralNoteListType;
3167                         NoteListAltID = &GeneralNoteListAltID;
3168                         NoteListPID = &GeneralNoteListPID;
3169                         NoteListTokens = &GeneralNoteListTokens;
3170                         NoteListLanguage = &GeneralNoteListLanguage;
3171                         NoteListPref = &GeneralNoteListPref;    
3172                         break;
3173                 case PROPERTY_HOME:
3174                         NoteList = &HomeNoteList;
3175                         NoteListType = &HomeNoteListType;
3176                         NoteListAltID = &HomeNoteListAltID;
3177                         NoteListPID = &HomeNoteListPID;
3178                         NoteListTokens = &HomeNoteListTokens;
3179                         NoteListLanguage = &HomeNoteListLanguage;
3180                         NoteListPref = &HomeNoteListPref;       
3181                         break;
3182                 case PROPERTY_WORK:
3183                         NoteList = &BusinessNoteList;
3184                         NoteListType = &BusinessNoteListType;
3185                         NoteListAltID = &BusinessNoteListAltID;
3186                         NoteListPID = &BusinessNoteListPID;
3187                         NoteListTokens = &BusinessNoteListTokens;
3188                         NoteListLanguage = &BusinessNoteListLanguage;   
3189                         NoteListPref = &BusinessNoteListPref;
3190                         break;
3191         }
3193         intPrevValue = 5;
3194         bool PropertyMatched = FALSE;
3195                 
3196         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3197         intiter != SplitPoints.end(); ++intiter){
3198         
3199                 SLiter = SplitLength.find(intiter->first);
3200                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3201                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3202                 intPrevValue = intiter->second;
3203                 
3204                 // Process properties.
3205                 
3206                 size_t intPropertyValueLen = PropertyValue.Len();
3207                 
3208                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3209                         
3210                         PropertyValue.Trim();
3211                         PropertyValue.RemoveLast();
3212                         
3213                 }                               
3214                 
3215                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3216                         
3217                         PropertyValue.Remove(0, 1);
3218                         
3219                 }                               
3220                 
3221                 CaptureString(&PropertyValue, FALSE);
3222                 
3223                 ProcessStringValue(&PropertyName, "ALTID", NoteListAltID, &PropertyValue, NoteCount, &PropertyMatched);
3224                 ProcessStringValue(&PropertyName, "PID", NoteListPID, &PropertyValue, NoteCount, &PropertyMatched);
3225                 ProcessStringValue(&PropertyName, "LANGUAGE", NoteListLanguage, &PropertyValue, NoteCount, &PropertyMatched);
3226                 ProcessIntegerValue(&PropertyName, "PREF", NoteListPref, &PropertyValue, NoteCount, &PropertyMatched);
3227                 
3228                 if (PropertyMatched == TRUE){
3229                 
3230                         PropertyMatched = FALSE;
3231                         continue;
3232                 
3233                 }
3235                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3236         
3237         }
3238         
3239         // Add the data to the General/Home/Work address variables.
3240         
3241         CaptureString(&PropertySeg2, FALSE);
3243         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3244         
3245         if (!PropertyTokens.IsEmpty()){
3246         
3247                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3248                         
3249         }
3253 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3255         std::map<int, int> SplitPoints;
3256         std::map<int, int> SplitLength;
3257         std::map<int, int>::iterator SLiter;                    
3258         wxString PropertyData;
3259         wxString PropertyName;
3260         wxString PropertyValue;
3261         wxString PropertyTokens;
3262         bool FirstToken = TRUE;
3263         int intPrevValue = 12;
3264         
3265         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3266         
3267         intPrevValue = 11;
3268         
3269         PropertyType PropType = PROPERTY_NONE;
3270                 
3271         // Look for type before continuing.
3272         
3273         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3274         
3275         // Setup blank lines for later on.
3276         
3277         switch(PropType){
3278                 case PROPERTY_NONE:
3279                         break;
3280                 case PROPERTY_HOME:
3281                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3282                         break;
3283                 case PROPERTY_WORK:
3284                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3285                         break;
3286         }
3288         intPrevValue = 11;
3289         bool PropertyMatched = FALSE;
3290                 
3291         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3292         intiter != SplitPoints.end(); ++intiter){
3293         
3294                 SLiter = SplitLength.find(intiter->first);
3295                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3296                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3297                 intPrevValue = intiter->second;
3298                 
3299                 // Process properties.
3300                 
3301                 size_t intPropertyValueLen = PropertyValue.Len();
3302                 
3303                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3304                         
3305                         PropertyValue.Trim();
3306                         PropertyValue.RemoveLast();
3307                         
3308                 }                               
3309                 
3310                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3311                         
3312                         PropertyValue.Remove(0, 1);
3313                         
3314                 }                               
3315                 
3316                 CaptureString(&PropertyValue, FALSE);
3317                 
3318                 ProcessStringValue(&PropertyName, "ALTID", &CategoriesListAltID, &PropertyValue, CategoryCount, &PropertyMatched);
3319                 ProcessStringValue(&PropertyName, "PID", &CategoriesListPID, &PropertyValue, CategoryCount, &PropertyMatched);
3320                 ProcessStringValue(&PropertyName, "LANGUAGE", &CategoriesListLanguage, &PropertyValue, CategoryCount, &PropertyMatched);
3321                 ProcessIntegerValue(&PropertyName, "PREF", &CategoriesListPref, &PropertyValue, CategoryCount, &PropertyMatched);
3322                 
3323                 if (PropertyMatched == TRUE){
3324                 
3325                         PropertyMatched = FALSE;
3326                         continue;
3327                 
3328                 }
3330                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3331         
3332         }
3333         
3334         // Deal with multiple categories.
3335         
3336         int intOrigCatCount = *CategoryCount;
3337         bool FirstCategoryProcessed = TRUE;
3338         bool AfterFirstToken = FALSE;
3339         int intSplitSize = 0;
3340         int intSplitsFound = 0;
3341         int intSplitSeek = 0;
3342         int intPropertyLen = PropertySeg2.Len();
3343         
3344         SplitPoints.clear();
3345         SplitLength.clear();
3346         intPrevValue = 0;
3347         
3348         for (int i = 0; i <= intPropertyLen; i++){
3349         
3350                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3351         
3352                         continue;
3353                 
3354                 }
3355         
3356                 intSplitSize++;
3357         
3358                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3359         
3360                         if (AfterFirstToken == TRUE){
3361                 
3362                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3363                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3364                         
3365                         } else {
3366                         
3367                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3368                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3369                                 AfterFirstToken = TRUE;
3371                         }
3373                         intSplitsFound++;
3374                         intSplitSeek = i;
3375                         intSplitSize = 0;                               
3376         
3377                 }                       
3378         
3379         }
3380         
3381         if (SplitPoints.size() > 0){
3382         
3383                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3384                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3385         
3386         }
3387         
3388         if (SplitPoints.size() == 0){
3389         
3390                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3391         
3392                 if (!PropertyTokens.IsEmpty()){
3393                 
3394                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3395                 
3396                 }
3397         
3398         }
3399         
3400         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3401         intiter != SplitPoints.end(); ++intiter){
3402         
3403                 SLiter = SplitLength.find(intiter->first);
3404         
3405                 intPrevValue = intiter->second;
3406         
3407                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3408                 
3409                 // Add the data to the General/Home/Work address variables.
3410         
3411                 // Trim any whitespace from the start and end.
3412         
3413                 PropertyData = PropertyData.Trim(FALSE);
3414                 PropertyData = PropertyData.Trim(TRUE); 
3415         
3416                 CaptureString(&PropertyData, FALSE);
3417                 
3418                 if (FirstCategoryProcessed == TRUE){
3419                 
3420                         FirstCategoryProcessed = FALSE;
3421                         
3422                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3423         
3424                         if (!PropertyTokens.IsEmpty()){
3425                 
3426                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3427                 
3428                         }
3429                         
3430                         continue;
3431                 
3432                 } else {
3434                         (*CategoryCount)++;
3435                         
3436                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3437                 
3438                         if (!PropertyTokens.IsEmpty()){
3439                 
3440                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3441                 
3442                         }
3443                 
3444                 }
3445                 
3446                 // Copy the properties to each of the categories (if it exists).
3447                 
3448                 if (!PropertyTokens.IsEmpty()){
3449                 
3450                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3451                 
3452                 }
3453                 
3454                 // Check if ALTID was used.
3455                 
3456                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3457                 
3458                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3459                 
3460                 }
3461                 
3462                 // Check if PID was used.
3463                 
3464                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
3465                 
3466                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
3467                 
3468                 }
3469         
3470                 // Check if PREF was used.
3471         
3472                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
3473                 
3474                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
3475                 
3476                 }
3477                 
3478                 // Check if LANGUAGE was used.
3479                 
3480                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
3481                 
3482                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
3483                 
3484                 }
3485                 
3486                 // Check if TYPE was used.
3487                 
3488                 switch(PropType){
3489                         case PROPERTY_NONE:
3490                                 break;
3491                         case PROPERTY_HOME:
3492                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3493                                 break;
3494                         case PROPERTY_WORK:
3495                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3496                                 break;
3497                 }
3498         
3499         }
3503 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
3505         size_t intPropertyLen = PropertySeg1.Len();
3506         std::map<int, int> SplitPoints;
3507         std::map<int, int> SplitLength;
3508         std::map<int, int>::iterator SLiter;                    
3509         wxString PropertyData;
3510         wxString PropertyName;
3511         wxString PropertyValue;
3512         wxString PropertyTokens;
3513         bool FirstToken = TRUE;
3514         int intSplitsFound = 0;
3515         int intSplitSize = 0;
3516         int intPrevValue = 7;
3517         
3518         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3519         
3520         intPrevValue = 6;
3521         
3522         PropertyType PropType = PROPERTY_NONE;
3523                 
3524         // Look for type before continuing.
3525         
3526         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3528         intPrevValue = 6;
3529         bool PropertyMatched = FALSE;
3531         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3532         intiter != SplitPoints.end(); ++intiter){
3533         
3534                 SLiter = SplitLength.find(intiter->first);
3535                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3536                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3537                 intPrevValue = intiter->second;
3538                 
3539                 // Process properties.
3540                 
3541                 size_t intPropertyValueLen = PropertyValue.Len();
3542                 
3543                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3544                         
3545                         PropertyValue.Trim();
3546                         PropertyValue.RemoveLast();
3547                         
3548                 }                               
3549                 
3550                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3551                         
3552                         PropertyValue.Remove(0, 1);
3553                         
3554                 }
3555                 
3556                 CaptureString(&PropertyValue, FALSE);
3557                 
3558                 ProcessStringValue(&PropertyName, "ALTID", &PicturesListAltID, &PropertyValue, PhotoCount, &PropertyMatched);
3559                 ProcessStringValue(&PropertyName, "PID", &PicturesListPID, &PropertyValue, PhotoCount, &PropertyMatched);
3560                 ProcessStringValue(&PropertyName, "MEDIATYPE", &PicturesListMediatype, &PropertyValue, PhotoCount, &PropertyMatched);
3561                 ProcessIntegerValue(&PropertyName, "PREF", &PicturesListPref, &PropertyValue, PhotoCount, &PropertyMatched);
3562                 
3563                 if (PropertyMatched == TRUE){
3564                 
3565                         PropertyMatched = FALSE;
3566                         continue;
3567                 
3568                 }
3570                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3571                         
3572         }       
3573         
3574         intPropertyLen = PropertySeg2.Len();
3575         SplitPoints.clear();
3576         SplitLength.clear();
3577         intSplitsFound = 0;
3578         intSplitSize = 0;
3579         intPrevValue = 0;                       
3580         
3581         CaptureString(&PropertySeg2, FALSE);
3582         
3583         for (int i = 0; i <= intPropertyLen; i++){
3585                 intSplitSize++;
3586         
3587                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3588         
3589                         intSplitsFound++;
3590                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3591                         
3592                         if (intSplitsFound == 6){ 
3593                         
3594                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3595                                 break; 
3596                                 
3597                         } else {
3598                         
3599                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3600                         
3601                         }
3602                         
3603                         intSplitSize = 0;                                       
3604         
3605                 }
3607         }
3608         
3609         wxString wxSPhotoURI;
3610         wxString wxSPhotoMIME;
3611         wxString wxSPhotoEncoding;
3612         wxString wxSPhotoData;
3613         std::string base64enc;
3614         
3615         if (intSplitsFound == 0){
3616         
3617         } else {
3618         
3619                 std::map<int, int>::iterator striter;
3620         
3621                 striter = SplitLength.find(1);
3622         
3623                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3624         
3625                 while (wSTDataType.HasMoreTokens() == TRUE){
3626                 
3627                         wxSPhotoURI = wSTDataType.GetNextToken();
3628                         wxSPhotoMIME = wSTDataType.GetNextToken();
3629                         break;
3630                 
3631                 }                       
3632         
3633                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3634         
3635                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3636                 
3637                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3638                         wxSPhotoData = wSTDataInfo.GetNextToken();
3639                         base64enc = wxSPhotoData.mb_str();
3640                         break;
3641                 
3642                 }
3643         
3644         }
3645         
3646         // Add the data to the General/Home/Work address variables.
3647         
3648         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
3649         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
3650         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
3651         
3652         switch(PropType){
3653                 case PROPERTY_NONE:
3654                         break;
3655                 case PROPERTY_HOME:
3656                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
3657                         break;
3658                 case PROPERTY_WORK:
3659                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
3660                         break;
3661         }
3662         
3663         if (!PropertyTokens.IsEmpty()){
3665                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
3666         
3667         }
3671 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
3673         size_t intPropertyLen = PropertySeg1.Len();
3674         std::map<int, int> SplitPoints;
3675         std::map<int, int> SplitLength;
3676         std::map<int, int>::iterator SLiter;                    
3677         wxString PropertyData;
3678         wxString PropertyName;
3679         wxString PropertyValue;
3680         wxString PropertyTokens;
3681         bool FirstToken = TRUE;
3682         int intSplitsFound = 0;
3683         int intSplitSize = 0;
3684         int intPrevValue = 6;
3685         
3686         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3687         
3688         intPrevValue = 5;
3689         
3690         PropertyType PropType = PROPERTY_NONE;
3691                 
3692         // Look for type before continuing.
3693         
3694         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3696         intPrevValue = 5;
3697         bool PropertyMatched = FALSE;
3699         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3700         intiter != SplitPoints.end(); ++intiter){
3701         
3702                 SLiter = SplitLength.find(intiter->first);
3703                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3704                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3705                 intPrevValue = intiter->second;
3706                 
3707                 // Process properties.
3708                 
3709                 size_t intPropertyValueLen = PropertyValue.Len();
3710                 
3711                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3712                         
3713                         PropertyValue.Trim();
3714                         PropertyValue.RemoveLast();
3715                         
3716                 }                               
3717                 
3718                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3719                         
3720                         PropertyValue.Remove(0, 1);
3721                         
3722                 }
3723                 
3724                 CaptureString(&PropertyValue, FALSE);
3725                 
3726                 ProcessStringValue(&PropertyName, "ALTID", &LogosListAltID, &PropertyValue, LogoCount, &PropertyMatched);
3727                 ProcessStringValue(&PropertyName, "PID", &LogosListPID, &PropertyValue, LogoCount, &PropertyMatched);
3728                 ProcessStringValue(&PropertyName, "MEDIATYPE", &LogosListMediatype, &PropertyValue, LogoCount, &PropertyMatched);
3729                 ProcessIntegerValue(&PropertyName, "PREF", &LogosListPref, &PropertyValue, LogoCount, &PropertyMatched);
3730                 
3731                 if (PropertyMatched == TRUE){
3732                 
3733                         PropertyMatched = FALSE;
3734                         continue;
3735                 
3736                 }
3738                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3739         
3740         }       
3741         
3742         intPropertyLen = PropertySeg2.Len();
3743         SplitPoints.clear();
3744         SplitLength.clear();
3745         intSplitsFound = 0;
3746         intSplitSize = 0;
3747         intPrevValue = 0;                       
3748         
3749         CaptureString(&PropertySeg2, FALSE);
3750         
3751         for (int i = 0; i <= intPropertyLen; i++){
3753                 intSplitSize++;
3754         
3755                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3756         
3757                         intSplitsFound++;
3758                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3759                         
3760                         if (intSplitsFound == 6){ 
3761                         
3762                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3763                                 break; 
3764                                 
3765                         } else {
3766                         
3767                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3768                         
3769                         }
3770                         
3771                         intSplitSize = 0;                                       
3772         
3773                 }
3775         }
3776         
3777         wxString wxSPhotoURI;
3778         wxString wxSPhotoMIME;
3779         wxString wxSPhotoEncoding;
3780         wxString wxSPhotoData;
3781         std::string base64enc;
3782         
3783         if (intSplitsFound == 0){
3784         
3785         } else {
3786         
3787                 std::map<int, int>::iterator striter;
3788         
3789                 striter = SplitLength.find(1);
3790         
3791                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3792         
3793                 while (wSTDataType.HasMoreTokens() == TRUE){
3794                 
3795                         wxSPhotoURI = wSTDataType.GetNextToken();
3796                         wxSPhotoMIME = wSTDataType.GetNextToken();
3797                         break;
3798                 
3799                 }                       
3800         
3801                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3802         
3803                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3804                 
3805                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3806                         wxSPhotoData = wSTDataInfo.GetNextToken();
3807                         base64enc = wxSPhotoData.mb_str();
3808                         break;
3809                 
3810                 }
3811         
3812         }
3813         
3814         // Add the data to the General/Home/Work address variables.
3815         
3816         LogosList.insert(std::make_pair(*LogoCount, base64enc));
3817         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
3818         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
3819         
3820         switch(PropType){
3821                 case PROPERTY_NONE:
3822                         break;
3823                 case PROPERTY_HOME:
3824                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
3825                         break;
3826                 case PROPERTY_WORK:
3827                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
3828                         break;
3829         }
3830         
3831         if (!PropertyTokens.IsEmpty()){
3833                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
3834         
3835         }
3839 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
3841         size_t intPropertyLen = PropertySeg1.Len();
3842         std::map<int, int> SplitPoints;
3843         std::map<int, int> SplitLength;
3844         std::map<int, int>::iterator SLiter;                    
3845         wxString PropertyData;
3846         wxString PropertyName;
3847         wxString PropertyValue;
3848         wxString PropertyTokens;
3849         bool FirstToken = TRUE;
3850         int intSplitsFound = 0;
3851         int intSplitSize = 0;
3852         int intPrevValue = 7;
3853         
3854         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3855         
3856         intPrevValue = 6;
3857         
3858         PropertyType PropType = PROPERTY_NONE;
3859         
3860         // Look for type before continuing.                     
3862         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3864         intPrevValue = 6;
3865         bool PropertyMatched = FALSE;
3867         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3868         intiter != SplitPoints.end(); ++intiter){
3869         
3870                 SLiter = SplitLength.find(intiter->first);
3871                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3872                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3873                 intPrevValue = intiter->second;
3874                 
3875                 // Process properties.
3876                 
3877                 size_t intPropertyValueLen = PropertyValue.Len();
3878                 
3879                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3880                         
3881                         PropertyValue.Trim();
3882                         PropertyValue.RemoveLast();
3883                         
3884                 }                               
3885                 
3886                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3887                         
3888                         PropertyValue.Remove(0, 1);
3889                         
3890                 }                       
3891                 
3892                 CaptureString(&PropertyValue, FALSE);
3893                 
3894                 ProcessStringValue(&PropertyName, "ALTID", &SoundsListAltID, &PropertyValue, SoundCount, &PropertyMatched);
3895                 ProcessStringValue(&PropertyName, "PID", &SoundsListPID, &PropertyValue, SoundCount, &PropertyMatched);
3896                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SoundsListMediatype, &PropertyValue, SoundCount, &PropertyMatched);
3897                 ProcessStringValue(&PropertyName, "LANGUAGE", &SoundsListLanguage, &PropertyValue, SoundCount, &PropertyMatched);
3898                 ProcessIntegerValue(&PropertyName, "PREF", &SoundsListPref, &PropertyValue, SoundCount, &PropertyMatched);
3899                 
3900                 if (PropertyMatched == TRUE){
3901                 
3902                         PropertyMatched = FALSE;
3903                         continue;
3904                 
3905                 }
3907                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3908         
3909         }       
3910         
3911         intPropertyLen = PropertySeg2.Len();
3912         SplitPoints.clear();
3913         SplitLength.clear();
3914         intSplitsFound = 0;
3915         intSplitSize = 0;
3916         intPrevValue = 0;
3917         
3918         CaptureString(&PropertySeg2, FALSE);
3919         
3920         for (int i = 0; i <= intPropertyLen; i++){
3922                 intSplitSize++;
3923         
3924                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3925         
3926                         intSplitsFound++;
3927                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3928                         
3929                         if (intSplitsFound == 6){ 
3930                         
3931                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3932                                 break; 
3933                                 
3934                         } else {
3935                         
3936                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3937                         
3938                         }
3939                         
3940                         intSplitSize = 0;                                       
3941         
3942                 }
3944         }
3945         
3946         wxString wxSSoundURI;
3947         wxString wxSSoundMIME;
3948         wxString wxSSoundEncoding;
3949         wxString wxSSoundData;
3950         std::string base64enc;
3951         
3952         if (intSplitsFound == 0){
3953         
3954         } else {
3955         
3956                 std::map<int, int>::iterator striter;
3957         
3958                 striter = SplitLength.find(1);
3959         
3960                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3961         
3962                 while (wSTDataType.HasMoreTokens() == TRUE){
3963                 
3964                         wxSSoundURI = wSTDataType.GetNextToken();
3965                         wxSSoundMIME = wSTDataType.GetNextToken();
3966                         break;
3967                 
3968                 }                       
3969         
3970                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3971         
3972                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3973                 
3974                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
3975                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
3976                         base64enc = wxSSoundData.mb_str();
3977                         break;
3978                 
3979                 }
3980         
3981         }
3982         
3983         // Add the data to the General/Home/Work address variables.
3984                 
3985         switch(PropType){
3986                 case PROPERTY_NONE:
3987                         break;
3988                 case PROPERTY_HOME:
3989                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
3990                         break;
3991                 case PROPERTY_WORK:
3992                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
3993                         break;
3994         }
3995         
3996         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
3997         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
3998         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
3999         
4000         if (!PropertyTokens.IsEmpty()){
4001         
4002                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4003         
4004         }
4005         
4008 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4010         size_t intPropertyLen = PropertySeg1.Len();
4011         std::map<int, int> SplitPoints;
4012         std::map<int, int> SplitLength;
4013         std::map<int, int>::iterator SLiter;                    
4014         wxString PropertyData;
4015         wxString PropertyName;
4016         wxString PropertyValue;
4017         wxString PropertyTokens;
4018         bool FirstToken = TRUE;
4019         int intSplitsFound = 0;
4020         int intSplitSize = 0;
4021         int intPrevValue = 8;
4022         
4023         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4024         
4025         intPrevValue = 7;
4026         
4027         PropertyType PropType = PROPERTY_NONE;
4028         
4029         // Look for type before continuing.                     
4031         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4033         intPrevValue = 7;
4034         bool PropertyMatched = FALSE;
4036         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4037         intiter != SplitPoints.end(); ++intiter){
4038         
4039                 SLiter = SplitLength.find(intiter->first);
4040                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4041                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4042                 intPrevValue = intiter->second;
4043                 
4044                 // Process properties.
4045                 
4046                 size_t intPropertyValueLen = PropertyValue.Len();
4047                 
4048                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4049                         
4050                         PropertyValue.Trim();
4051                         PropertyValue.RemoveLast();
4052                         
4053                 }                               
4054                 
4055                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4056                         
4057                         PropertyValue.Remove(0, 1);
4058                         
4059                 }                       
4060                 
4061                 CaptureString(&PropertyValue, FALSE);
4062                 
4063                 ProcessStringValue(&PropertyName, "ALTID", &CalendarListAltID, &PropertyValue, CalURICount, &PropertyMatched);
4064                 ProcessStringValue(&PropertyName, "PID", &CalendarListPID, &PropertyValue, CalURICount, &PropertyMatched);
4065                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarListMediatype, &PropertyValue, CalURICount, &PropertyMatched);
4066                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarListPref, &PropertyValue, CalURICount, &PropertyMatched);
4067                 
4068                 if (PropertyMatched == TRUE){
4069                 
4070                         PropertyMatched = FALSE;
4071                         continue;
4072                 
4073                 }
4075                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4076         
4077         }       
4078         
4079         intPropertyLen = PropertySeg2.Len();
4080         SplitPoints.clear();
4081         SplitLength.clear();
4082         intSplitsFound = 0;
4083         intSplitSize = 0;
4084         intPrevValue = 0;
4085         
4086         CaptureString(&PropertySeg2, FALSE);
4087         
4088         // Add the data to the General/Home/Work address variables.
4089                 
4090         switch(PropType){
4091                 case PROPERTY_NONE:
4092                         break;
4093                 case PROPERTY_HOME:
4094                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4095                         break;
4096                 case PROPERTY_WORK:
4097                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4098                         break;
4099         }
4100         
4101         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4102         
4103         if (!PropertyTokens.IsEmpty()){
4104         
4105                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4106         
4107         }
4111 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4113         size_t intPropertyLen = PropertySeg1.Len();
4114         std::map<int, int> SplitPoints;
4115         std::map<int, int> SplitLength;
4116         std::map<int, int>::iterator SLiter;                    
4117         wxString PropertyData;
4118         wxString PropertyName;
4119         wxString PropertyValue;
4120         wxString PropertyTokens;
4121         bool FirstToken = TRUE;
4122         int intSplitsFound = 0;
4123         int intSplitSize = 0;
4124         int intPrevValue = 8;
4125         
4126         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4127         
4128         intPrevValue = 7;
4129         
4130         PropertyType PropType = PROPERTY_NONE;
4131         
4132         // Look for type before continuing.                     
4134         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4136         intPrevValue = 7;
4137         bool PropertyMatched = FALSE;
4139         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4140         intiter != SplitPoints.end(); ++intiter){
4141         
4142                 SLiter = SplitLength.find(intiter->first);
4143                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4144                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4145                 intPrevValue = intiter->second;
4146                 
4147                 // Process properties.
4148                 
4149                 size_t intPropertyValueLen = PropertyValue.Len();
4150                 
4151                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4152                         
4153                         PropertyValue.Trim();
4154                         PropertyValue.RemoveLast();
4155                         
4156                 }                               
4157                 
4158                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4159                         
4160                         PropertyValue.Remove(0, 1);
4161                         
4162                 }                       
4163                 
4164                 CaptureString(&PropertyValue, FALSE);
4165                 
4166                 ProcessStringValue(&PropertyName, "ALTID", &CalendarRequestListAltID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4167                 ProcessStringValue(&PropertyName, "PID", &CalendarRequestListPID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4168                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarRequestListMediatype, &PropertyValue, CalAdrURICount, &PropertyMatched);
4169                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarRequestListPref, &PropertyValue, CalAdrURICount, &PropertyMatched);
4170                 
4171                 if (PropertyMatched == TRUE){
4172                 
4173                         PropertyMatched = FALSE;
4174                         continue;
4175                 
4176                 }
4178                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4179         
4180         }       
4181         
4182         intPropertyLen = PropertySeg2.Len();
4183         SplitPoints.clear();
4184         SplitLength.clear();
4185         intSplitsFound = 0;
4186         intSplitSize = 0;
4187         intPrevValue = 0;
4188         
4189         CaptureString(&PropertySeg2, FALSE);
4190         
4191         // Add the data to the General/Home/Work address variables.
4192                 
4193         switch(PropType){
4194                 case PROPERTY_NONE:
4195                         break;
4196                 case PROPERTY_HOME:
4197                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4198                         break;
4199                 case PROPERTY_WORK:
4200                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4201                         break;
4202         }
4203         
4204         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4205         
4206         if (!PropertyTokens.IsEmpty()){
4207         
4208                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4209         
4210         }       
4211         
4214 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4216         size_t intPropertyLen = PropertySeg1.Len();
4217         std::map<int, int> SplitPoints;
4218         std::map<int, int> SplitLength;
4219         std::map<int, int>::iterator SLiter;                    
4220         wxString PropertyData;
4221         wxString PropertyName;
4222         wxString PropertyValue;
4223         wxString PropertyTokens;
4224         bool FirstToken = TRUE;
4225         int intSplitsFound = 0;
4226         int intSplitSize = 0;
4227         int intPrevValue = 7;
4228         
4229         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4230         
4231         intPrevValue = 6;
4232         
4233         PropertyType PropType = PROPERTY_NONE;
4234         
4235         // Look for type before continuing.                     
4237         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4239         intPrevValue = 6;
4240         bool PropertyMatched = FALSE;
4242         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4243         intiter != SplitPoints.end(); ++intiter){
4244         
4245                 SLiter = SplitLength.find(intiter->first);
4246                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4247                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4248                 intPrevValue = intiter->second;
4249                 
4250                 // Process properties.
4251                 
4252                 size_t intPropertyValueLen = PropertyValue.Len();
4253                 
4254                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4255                         
4256                         PropertyValue.Trim();
4257                         PropertyValue.RemoveLast();
4258                         
4259                 }                               
4260                 
4261                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4262                         
4263                         PropertyValue.Remove(0, 1);
4264                         
4265                 }                       
4266                 
4267                 CaptureString(&PropertyValue, FALSE);
4268                 
4269                 ProcessStringValue(&PropertyName, "ALTID", &FreeBusyListAltID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4270                 ProcessStringValue(&PropertyName, "PID", &FreeBusyListPID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4271                 ProcessStringValue(&PropertyName, "MEDIATYPE", &FreeBusyListMediatype, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4272                 ProcessIntegerValue(&PropertyName, "PREF", &FreeBusyListPref, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4273                 
4274                 if (PropertyMatched == TRUE){
4275                 
4276                         PropertyMatched = FALSE;
4277                         continue;
4278                 
4279                 }
4281                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4282         
4283         }       
4284         
4285         intPropertyLen = PropertySeg2.Len();
4286         SplitPoints.clear();
4287         SplitLength.clear();
4288         intSplitsFound = 0;
4289         intSplitSize = 0;
4290         intPrevValue = 0;
4291         
4292         CaptureString(&PropertySeg2, FALSE);
4293         
4294         // Add the data to the General/Home/Work address variables.
4295                 
4296         switch(PropType){
4297                 case PROPERTY_NONE:
4298                         break;
4299                 case PROPERTY_HOME:
4300                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
4301                         break;
4302                 case PROPERTY_WORK:
4303                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
4304                         break;
4305         }
4306         
4307         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
4308         
4309         if (!PropertyTokens.IsEmpty()){
4310         
4311                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
4312         
4313         }
4317 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
4319         size_t intPropertyLen = PropertySeg1.Len();
4320         std::map<int, int> SplitPoints;
4321         std::map<int, int> SplitLength;
4322         std::map<int, int>::iterator SLiter;                    
4323         wxString PropertyData;
4324         wxString PropertyName;
4325         wxString PropertyValue;
4326         wxString PropertyTokens;
4327         bool FirstToken = TRUE;
4328         int intSplitsFound = 0;
4329         int intSplitSize = 0;
4330         int intPrevValue = 5;
4331         
4332         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4333         
4334         intPrevValue = 4;
4335         
4336         PropertyType PropType = PROPERTY_NONE;
4337         
4338         // Look for type before continuing.
4340         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4342         intPrevValue = 4;
4343         bool PropertyMatched = FALSE;
4345         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4346         intiter != SplitPoints.end(); ++intiter){
4347         
4348                 SLiter = SplitLength.find(intiter->first);
4349                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4350                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4351                 intPrevValue = intiter->second;
4352                 
4353                 // Process properties.
4354                 
4355                 size_t intPropertyValueLen = PropertyValue.Len();
4356                 
4357                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4358                         
4359                         PropertyValue.Trim();
4360                         PropertyValue.RemoveLast();
4361                         
4362                 }                               
4363                 
4364                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4365                         
4366                         PropertyValue.Remove(0, 1);
4367                         
4368                 }
4369                 
4370                 ProcessStringValue(&PropertyName, "ALTID", &KeyListAltID, &PropertyValue, KeyCount, &PropertyMatched);
4371                 ProcessStringValue(&PropertyName, "PID", &KeyListPID, &PropertyValue, KeyCount, &PropertyMatched);
4372                 ProcessIntegerValue(&PropertyName, "PREF", &KeyListPref, &PropertyValue, KeyCount, &PropertyMatched);
4373                 
4374                 if (PropertyMatched == TRUE){
4375                 
4376                         PropertyMatched = FALSE;
4377                         continue;
4378                 
4379                 }
4381                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4382         
4383         }                               
4384         
4385         intPropertyLen = PropertySeg2.Len();
4386         SplitPoints.clear();
4387         SplitLength.clear();
4388         intSplitsFound = 0;
4389         intSplitSize = 0;
4390         intPrevValue = 0;                       
4391         
4392         for (int i = 0; i <= intPropertyLen; i++){
4394                 intSplitSize++;
4395         
4396                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4397         
4398                         intSplitsFound++;
4399                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4400                         
4401                         if (intSplitsFound == 6){ 
4402                         
4403                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4404                                 break; 
4405                                 
4406                         } else {
4407                         
4408                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4409                         
4410                         }
4411                         
4412                         intSplitSize = 0;                                       
4413         
4414                 }
4416         }
4417         
4418         wxString wxSKeyURI;
4419         wxString wxSKeyMIME;
4420         wxString wxSKeyEncoding;
4421         wxString wxSKeyData;
4422         std::string base64enc;
4423         
4424         if (intSplitsFound == 0){
4425         
4426         } else {
4427         
4428                 std::map<int, int>::iterator striter;
4429         
4430                 striter = SplitLength.find(1);
4431         
4432                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4433         
4434                 while (wSTDataType.HasMoreTokens() == TRUE){
4435                 
4436                         wxSKeyURI = wSTDataType.GetNextToken();
4437                         wxSKeyMIME = wSTDataType.GetNextToken();
4438                         break;
4439                 
4440                 }                       
4441         
4442                 if (wxSKeyURI == wxT("data")){
4443                 
4444                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4445         
4446                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4447                 
4448                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
4449                                 wxSKeyData = wSTDataInfo.GetNextToken();
4450                                 break;
4451                 
4452                         }
4453                 
4454                 }
4455         
4456         }
4457         
4458         // Add the data to the General/Home/Work address variables.
4459         
4460         if (wxSKeyURI == wxT("data")){
4461                 
4462                 KeyListDataEncType.erase(*KeyCount);
4463                 KeyListKeyType.erase(*KeyCount);
4464                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
4465                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
4466                 
4467                 KeyList.erase(*KeyCount);
4468                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
4469         
4470         } else {
4471                 
4472                 KeyList.erase(*KeyCount);
4473                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
4474         
4475         }
4476         
4477         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
4478                 
4479         switch (PropType){
4480                 case PROPERTY_NONE:
4481                         break;
4482                 case PROPERTY_HOME: 
4483                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
4484                         break;
4485                 case PROPERTY_WORK: 
4486                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
4487                         break;
4488         }
4490         if (!PropertyTokens.IsEmpty()){
4492                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
4494         }
4498 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
4500         // Split the Vendor three ways.
4501         
4502         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
4503         
4504         wxString wxSVNDID;
4505         wxString wxSVNDPropName;
4507         while (wSTVendorDetails.HasMoreTokens() == TRUE){
4508         
4509                 wSTVendorDetails.GetNextToken();
4510                 wxSVNDID = wSTVendorDetails.GetNextToken();
4511                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
4512                 break;
4513         
4514         }
4515         
4516         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
4517         
4518                 // Add the data to the vendor variables.
4519         
4520                 VendorList.erase(*VendorCount);
4521                 VendorListPEN.erase(*VendorCount);
4522                 VendorListElement.erase(*VendorCount);
4523         
4524                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
4525                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
4526                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
4527         
4528         }
4532 void ProcessNameValue(wxString *PropertyData, 
4533         wxString *PropertyName, 
4534         wxString *PropertyValue){
4536         wxStringTokenizer PropertyElement (*PropertyData, wxT("="));
4537         *PropertyName = PropertyElement.GetNextToken();                         
4538         *PropertyValue = PropertyElement.GetNextToken();
4542 void ProcessTokens(wxString *PropertyName,
4543         wxString *PropertyValue,
4544         wxString *PropertyTokens,
4545         bool *FirstToken){
4546         
4547         if (!PropertyName->IsEmpty() && !PropertyValue->IsEmpty() && *PropertyName != wxT("TYPE")){
4548                 
4549                 if (*FirstToken == TRUE){
4550                         
4551                         PropertyTokens->Append(*PropertyName + wxT("=") + *PropertyValue);
4552                         *FirstToken = FALSE;
4553                         
4554                 } else {
4555                         
4556                         PropertyTokens->Append(wxT(";") + *PropertyName + wxT("=") + *PropertyValue);
4557                         
4558                 }
4559                 
4560         }
4561         
4564 void ProcessStringValue(wxString *PropertyName,
4565         wxString PropertyNameMatch,
4566         std::map<int,wxString> *MapPtr,
4567         wxString *PropertyValue,
4568         int *ItemCount,
4569         bool *PropertyMatched){
4570         
4571         if (*PropertyName == PropertyNameMatch){
4572                 MapPtr->erase(*ItemCount);
4573                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
4574                 *PropertyMatched = TRUE;
4575         }
4576         
4579 void ProcessIntegerValue(wxString *PropertyName,
4580         wxString PropertyNameMatch,
4581         std::map<int,int> *PrefPtr, 
4582         wxString *PropertyValue, 
4583         int *ItemCount,
4584         bool *PropertyMatched){
4586         if (*PropertyName == PropertyNameMatch){
4587                 *PropertyMatched = TRUE;
4588         } else {
4589                 return;
4590         }
4592         int PriorityNumber = 0; 
4593         bool ValidNumber = TRUE;
4594                         
4595         try{
4596                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
4597         }
4598                         
4599         catch(std::invalid_argument &e){
4600                 ValidNumber = FALSE;
4601         }
4603         if (ValidNumber == TRUE){
4605                 PrefPtr->erase(*ItemCount);
4606                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
4608         }
4612 void SplitValues(wxString *PropertyLine, 
4613         std::map<int,int> *SplitPoints, 
4614         std::map<int,int> *SplitLength, 
4615         int intSize){
4616         
4617         size_t intPropertyLen = PropertyLine->Len();
4618         int intSplitsFound = 0;
4619         int intSplitSize = 0;
4620         int intSplitSeek = 0;
4621         
4622         for (int i = intSize; i <= intPropertyLen; i++){
4624                 intSplitSize++;
4625         
4626                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4627                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4628            
4629                     if (intSplitsFound == 0){
4630             
4631                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4632           
4633                     } else {
4634            
4635                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4636             
4637                     }
4638             
4639                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4640             
4641                     intSplitsFound++;
4642                     intSplitSeek = i;
4643                     intSplitSize = 0;
4644             
4645                 }
4647         }
4649         if (intSplitsFound == 0){
4651                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4652                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4654         } else {
4656                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4657                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4659         }
4663 void CheckType(wxString *PropertySeg1, 
4664         std::map<int,int> *SplitPoints, 
4665         std::map<int,int> *SplitLength, 
4666         int *intPrevValue, 
4667         PropertyType *PropType){
4668         
4669         wxString PropertyData;
4670         wxString PropertyName;
4671         wxString PropertyValue;
4672         std::map<int,int>::iterator SLiter;
4673         
4674         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
4675         intiter != SplitPoints->end(); ++intiter){
4676         
4677                 SLiter = SplitLength->find(intiter->first);     
4678                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4679                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);         
4680                 *intPrevValue = intiter->second;
4681                 
4682                 if (PropertyName == wxT("TYPE")){
4683                                 
4684                         if (PropertyValue == wxT("work")){
4685                         
4686                                 *PropType = PROPERTY_WORK;
4687                                                         
4688                         } else if (PropertyValue == wxT("home")){
4690                                 *PropType = PROPERTY_HOME;
4691                                                         
4692                         } else {
4693                         
4694                                 *PropType = PROPERTY_NONE;
4695                         
4696                         }
4697                 
4698                         return;
4699                 
4700                 }
4701         
4702         }
4703         
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