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