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