Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditor: Stop XAB crashing when pressing Modify/Delete
[xestiaab/.git] / source / contacteditor / cdo / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         // Load the ContactDataObject using the Filename given.
24         
25         if (!wxFileExists(Filename)){
26         
27                 return CONTACTLOAD_FILEMISSING;
28         
29         }
30         
31         wxFile ContactFile;
32         
33         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
34         
35                 return CONTACTLOAD_FILEERROR;
36         
37         }
38         
39         // Check that the vCard is a valid vCard 4.0 file.
41         vCard vCard4FormatCheck;
42         
43         vCard4FormatCheck.LoadFile(Filename);
44         
45         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
46         
47                 return CONTACTLOAD_FILEINVALIDFORMAT;
48         
49         }
51         // Check that the vCard meets the base specification.
52         
53         if (!vCard4FormatCheck.MeetBaseSpecification()){
54         
55                 return CONTACTLOAD_FILEBASESPECFAIL;
56         
57         }
58         
59         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
60         
61         std::map<int, wxString> ContactFileLines;
63         int ContactLineSeek = 0;
65         while (wSTContactFileLines.HasMoreTokens() == TRUE){
67                 wxString ContactLine = wSTContactFileLines.GetNextToken();
68                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
69                 ContactLineSeek++;              
70         
71         }
72         
73         wxString wxSPropertyNextLine;
74         
75         bool ExtraLineSeek = TRUE;
76         bool QuoteMode = FALSE;
77         bool PropertyFind = TRUE;
78         bool KindProcessed = FALSE;
79         bool NameProcessed = FALSE;
80         bool GenderProcessed = FALSE;
81         bool BirthdayProcessed = FALSE;
82         bool AnniversaryProcessed = FALSE;
83         bool UIDProcessed = FALSE;
84         bool RevisionProcessed = FALSE;
85         int ContactLineLen = 0;
86         int QuoteBreakPoint = 0;
87         int SourceCount = 0;
88         int GroupCount = 0;
89         int FNCount = 0;
90         int NicknameCount = 0;
91         int TimeZoneCount = 0;
92         int AddressCount = 0;
93         int EmailCount = 0;
94         int IMCount = 0;
95         int TelephoneCount = 0;
96         int LanguageCount = 0;
97         int GeographicCount = 0;
98         int RelatedCount = 0;
99         int URLCount = 0;
100         int TitleCount = 0;
101         int RoleCount = 0;
102         int OrganisationCount = 0;
103         int NoteCount = 0;
104         int CategoryCount = 0;
105         int PhotoCount = 0;
106         int LogoCount = 0;
107         int SoundCount = 0;
108         int CalendarCount = 0;
109         int CalendarAddressCount = 0;
110         int FreeBusyAddressCount = 0;
111         int KeyCount = 0;
112         int VendorCount = 0;
113         int XTokenCount = 0;
114         int XMLCount = 0;
115         int ClientPIDCount = 0;
116         wxString ContactLine;
117         wxString PropertyLine;
118         wxString PropertySeg1;
119         wxString PropertySeg2;
120         wxString PropertyNextLine;
121         wxString Property;
122         
123         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
124          iter != ContactFileLines.end(); ++iter){
126                 ExtraLineSeek = TRUE;
127                 QuoteMode = FALSE;
128                 PropertyFind = TRUE;
129                 ContactLineLen = 0;
130                 QuoteBreakPoint = 0;
131                 ContactLine.Clear();
132                 PropertyLine.Clear();
133                 PropertySeg1.Clear();
134                 PropertySeg2.Clear();
135                 Property.Clear();
136          
137                 ContactLine = iter->second;
138                 
139                 while (ExtraLineSeek == TRUE){
140                 
141                         // Check if there is extra data on the next line 
142                         // (indicated by space or tab at the start) and add data.
143                 
144                         iter++;
145                         
146                         if (iter == ContactFileLines.end()){
147                         
148                                 iter--;
149                                 break;
150                         
151                         }                       
152                 
153                         PropertyNextLine = iter->second;
154                 
155                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
156                 
157                                 PropertyNextLine.Remove(0, 1);
158                                 ContactLine.Append(PropertyNextLine);
159                 
160                         } else {
161                         
162                                 iter--;
163                                 ExtraLineSeek = FALSE;
164                         
165                         }
166                 
167                 }
169                 ContactLineLen = ContactLine.Len();
170                 
171                 // Make sure we are not in quotation mode.
172                 // Make sure colon does not have \ or \\ before it.
173                 
174                 for (int i = 0; i <= ContactLineLen; i++){
175                 
176                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
177                         
178                                 PropertyFind = FALSE;
179                         
180                         } else if (PropertyFind == TRUE){
181                         
182                                 Property.Append(ContactLine.Mid(i, 1));
183                         
184                         }               
185                 
186                         if (ContactLine.Mid(i, 1) == wxT("\"")){
187                         
188                                 if (QuoteMode == TRUE){
189                                 
190                                         QuoteMode = FALSE;
191                                 
192                                 } else {
193                         
194                                         QuoteMode = TRUE;
195                                         
196                                 }
197                         
198                         }
199                         
200                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
201                         
202                                 QuoteBreakPoint = i;
203                                 break;
204                         
205                         }
206                 
207                 }
208                 
209                 // Split that line at the point into two variables (ignore the colon).
210                 
211                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
212                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
213                 
214                  if (Property == wxT("KIND") && KindProcessed == FALSE){
215                                 
216                         ProcessKind(PropertySeg2);
217                 
218                 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
219                 
220                         UIDToken = PropertySeg2;
221                         UIDProcessed = TRUE;
222                 
223                 } else if (Property == wxT("SOURCE")){
224                 
225                         ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
226                         SourceCount++;
227                 
228                 } else if (Property == wxT("XML")){
229                 
230                         ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
231                         XMLCount++;
232                 
233                 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
234                 
235                         ProcessRevision(PropertySeg1, PropertySeg2);
236                         RevisionProcessed = TRUE;
237                 
238                 } else if (Property == wxT("MEMBER")){
240                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
241                         GroupCount++;   
242                 
243                 } else if (Property == wxT("FN")){
244                 
245                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
246                         FNCount++;
247                 
248                 } else if (Property == wxT("N") && NameProcessed == FALSE){
249                 
250                         ProcessN(PropertySeg1, PropertySeg2);
251                         NameProcessed = TRUE;
252                 
253                 } else if (Property == wxT("CLIENTPIDMAP")){
254                 
255                         ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
256                         ClientPIDCount++;
257                 
258                 } else if (Property == wxT("NICKNAME")){
259                                                 
260                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
261                         NicknameCount++;
262                         
263                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
264                 
265                         ProcessGender(PropertySeg1, PropertySeg2);
266                         GenderProcessed = TRUE;
267                 
268                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
269                 
270                         ProcessBirthday(PropertySeg1, PropertySeg2);
271                         BirthdayProcessed = TRUE;
272                 
273                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
274                 
275                         ProcessAnniversary(PropertySeg1, PropertySeg2);
276                         AnniversaryProcessed = TRUE;
277                 
278                 } else if (Property == wxT("TZ")){
279                 
280                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
281                         TimeZoneCount++;
282                 
283                 } else if (Property == wxT("ADR")){
284                 
285                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
286                         AddressCount++;
287                 
288                 } else if (Property == wxT("EMAIL")){
289                                         
290                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
291                         EmailCount++;
292                 
293                 } else if (Property == wxT("IMPP")){
294                 
295                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
296                         IMCount++;
297                         
298                 } else if (Property == wxT("TEL")){
299                                 
300                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
301                         TelephoneCount++;
302                 
303                 } else if (Property == wxT("LANG")){
304                 
305                         // See frmContactEditor-LoadLanguage.cpp
306                         
307                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
308                         LanguageCount++;
309                 
310                 } else if (Property == wxT("GEO")){
311                 
312                         // See frmContactEditor-LoadGeo.cpp
313                         
314                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
315                         GeographicCount++;
316                 
317                 } else if (Property == wxT("RELATED")){
318                         
319                         // See fromContactEditor-LoadRelated.cpp
320                         
321                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
322                         RelatedCount++;
323                         
324                 } else if (Property == wxT("URL")){
326                         // See frmContactEditor-LoadURL.cpp
327                 
328                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
329                         URLCount++;
330                 
331                 } else if (Property == wxT("TITLE")) {
332                 
333                         // See frmContactEditor-LoadTitle.cpp
334                         
335                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
336                         TitleCount++;
337                         
338                 } else if (Property == wxT("ROLE")) {
339                 
340                         // See frmContactEditor-LoadTitle.cpp
341                         
342                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
343                         RoleCount++;
344                         
345                 } else if (Property == wxT("ORG")) {
346                 
347                         // See frmContactEditor-LoadOrg.cpp
348                         
349                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
350                         OrganisationCount++;
351                         
352                 } else if (Property == wxT("NOTE")) {
354                         // See frmContactEditor-LoadNote.cpp
356                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
357                         NoteCount++;    
358                         
359                 } else if (Property == wxT("CATEGORIES")) {
360                 
361                         // See frmContactEditor-LoadCategory.cpp
362                 
363                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
364                         CategoryCount++;
365                         
366                 } else if (Property == wxT("PHOTO")) {
367                 
368                         // See frmContactEditor-LoadPhoto.cpp
369                         
370                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
371                         PhotoCount++;
373                 } else if (Property == wxT("LOGO")) {
374                 
375                         // See frmContactEditor-LoadPhoto.cpp
376                         
377                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
378                         LogoCount++;
380                 } else if (Property == wxT("SOUND")) {
381                 
382                         // See frmContactEditor-LoadSound.cpp
383                         
384                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
385                         SoundCount++;
386                         
387                 } else if (Property == wxT("CALURI")){
389                         // See frmContactEditor-LoadCalendar.cpp
390                         
391                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
392                         CalendarCount++;
393                 
394                 } else if (Property == wxT("CALADRURI")){
395                 
396                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
397                         CalendarAddressCount++;
398                 
399                 } else if (Property == wxT("FBURL")){
401                         // See frmContactEditor-LoadCalendar.cpp
403                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
404                         FreeBusyAddressCount++;
406                 } else if (Property == wxT("KEY")){
407                 
408                         // See frmContactEditor-LoadKey.cpp
409                         
410                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
411                         KeyCount++;
412                 
413                 } else if (Property.Mid(0, 3) == wxT("VND")){
414                 
415                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
416                         VendorCount++;
417                 
418                 } else if (Property.Mid(0, 2) == wxT("X-")){
419                         
420                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
421                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
422                         XTokenCount++;
423                 
424                 }
425                 
426         }
427         
428         return CONTACTLOAD_OK;
432 void ContactDataObject::ProcessKind(wxString KindType){
434         // Process the type of contact.
435         
436         if (KindType == wxT("individual")){
437                         
438                 ContactKind = CONTACTKIND_INDIVIDUAL;
439                         
440         } else if (KindType == wxT("group")){
441                         
442                 ContactKind = CONTACTKIND_GROUP;
443                         
444         } else if (KindType == wxT("org")){
445                         
446                 ContactKind = CONTACTKIND_ORGANISATION;
447                         
448         } else if (KindType == wxT("location")){
449                         
450                 ContactKind = CONTACTKIND_LOCATION;
451                         
452         } else {
453                         
454                 ContactKind = CONTACTKIND_NONE;                 
455         }
459 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
461         // Process the revision date.
462         
463         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                                         TypeFound = TRUE;
2127                                 
2128                                 } else if (TypePropertyName == wxT("work") && TypeFound == FALSE){
2129                                 
2130                                         PropType = PROPERTY_WORK;
2131                                         TypeFound = TRUE;
2132                                                 
2133                                 }
2134                                 
2135                                 if (TypePropertyName == wxT("text")){
2136                                 
2137                                         TelTypeUI.Append(_("text"));
2138                                         intTypeSeek++;
2139                                 
2140                                 } else if (TypePropertyName == wxT("voice")){
2141                                 
2142                                         TelTypeUI.Append(_("voice"));
2143                                         intTypeSeek++;
2144                                 
2145                                 } else if (TypePropertyName == wxT("fax")){
2146                                 
2147                                         TelTypeUI.Append(_("fax"));
2148                                         intTypeSeek++;
2149                                 
2150                                 } else if (TypePropertyName == wxT("cell")){
2151                                 
2152                                         TelTypeUI.Append(_("cell"));
2153                                         intTypeSeek++;
2154                                 
2155                                 } else if (TypePropertyName == wxT("video")){
2156                                 
2157                                         TelTypeUI.Append(_("video"));
2158                                         intTypeSeek++;
2159                                 
2160                                 } else if (TypePropertyName == wxT("pager")){
2161                                 
2162                                         TelTypeUI.Append(_("pager"));
2163                                         intTypeSeek++;
2164                                 
2165                                 } else if (TypePropertyName == wxT("textphone")){
2166                                 
2167                                         TelTypeUI.Append(_("textphone"));
2168                                         intTypeSeek++;
2169                                 
2170                                 }
2171                         
2172                         }
2173                 
2174                 }
2175                 
2176         }
2177         
2178         std::map<int, wxString> *TelephoneList = NULL;
2179         std::map<int, wxString> *TelephoneListType = NULL;
2180         std::map<int, wxString> *TelephoneListAltID = NULL;
2181         std::map<int, wxString> *TelephoneListPID = NULL;
2182         std::map<int, wxString> *TelephoneListTokens = NULL;
2183         std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2184         std::map<int, wxString> *TelephoneListDataType = NULL;
2185         std::map<int, int> *TelephoneListPref = NULL;
2187         switch(PropType){
2188                 case PROPERTY_NONE:
2189                         TelephoneList = &GeneralTelephoneList;
2190                         TelephoneListType = &GeneralTelephoneListType;
2191                         TelephoneListAltID = &GeneralTelephoneListAltID;
2192                         TelephoneListPID = &GeneralTelephoneListPID;
2193                         TelephoneListTokens = &GeneralTelephoneListTokens;
2194                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2195                         TelephoneListDataType = &GeneralTelephoneListDataType;
2196                         TelephoneListPref = &GeneralTelephoneListPref;  
2197                         break;
2198                 case PROPERTY_HOME:
2199                         TelephoneList = &HomeTelephoneList;
2200                         TelephoneListType = &HomeTelephoneListType;
2201                         TelephoneListAltID = &HomeTelephoneListAltID;
2202                         TelephoneListPID = &HomeTelephoneListPID;
2203                         TelephoneListTokens = &HomeTelephoneListTokens;
2204                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2205                         TelephoneListDataType = &HomeTelephoneListDataType;
2206                         TelephoneListPref = &HomeTelephoneListPref;     
2207                         break;
2208                 case PROPERTY_WORK:
2209                         TelephoneList = &BusinessTelephoneList;
2210                         TelephoneListType = &BusinessTelephoneListType;
2211                         TelephoneListAltID = &BusinessTelephoneListAltID;
2212                         TelephoneListPID = &BusinessTelephoneListPID;
2213                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2214                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2215                         TelephoneListDataType = &BusinessTelephoneListDataType;
2216                         TelephoneListPref = &BusinessTelephoneListPref; 
2217                         break;
2218         }
2219                 
2220         // Process the properties.
2221         
2222         bool FirstToken = TRUE;
2223         
2224         intPrevValue = 5;
2225         SplitPoints.clear();
2226         SplitLength.clear();
2228         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2230         intPrevValue = 4;
2231         
2232         bool PropertyMatched = FALSE;
2233         
2234         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2235         intiter != SplitPoints.end(); ++intiter){
2236         
2237                 SLiter = SplitLength.find(intiter->first);
2238                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2239                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2240                 intPrevValue = intiter->second;
2241                 
2242                 CaptureString(&PropertyValue, FALSE);
2243                 
2244                 // Process properties.
2245                 
2246                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2247                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2248                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2249                 
2250                 if (PropertyMatched == TRUE){
2251                 
2252                         PropertyMatched = FALSE;
2253                         continue;
2254                 
2255                 }
2257                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2258         
2259         }
2260                 
2261         // Check for the type information and split it down.
2262         
2263         wxStringTokenizer TelSplitData(PropertySeg2, wxT(":"));
2264                 
2265         if (TelSplitData.CountTokens() > 1){
2267                 TelephoneListDataType->insert(std::make_pair(*TelephoneCount, TelSplitData.GetNextToken()));                    
2268                 TelephoneList->insert(std::make_pair(*TelephoneCount, TelSplitData.GetString()));
2269         
2270         } else {
2271         
2272                 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2273                 TelephoneListDataType->insert(std::make_pair(*TelephoneCount, "tel"));
2274         
2275         }
2276                 
2277         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2278                 
2279         // Add the name token data.
2280         
2281         if (!PropertyTokens.IsEmpty()){
2282         
2283                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2284         
2285         }
2289 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2291         // Process the language.
2292         
2293         std::map<int, int> SplitPoints;
2294         std::map<int, int> SplitLength;
2296         int intPrevValue = 6;
2297         
2298         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2299         
2300         intPrevValue = 5;
2301         
2302         PropertyType PropType = PROPERTY_NONE;
2303                 
2304         // Look for type before continuing.
2305         
2306         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2307         
2308         std::map<int, wxString> *LanguageList = NULL;
2309         std::map<int, wxString> *LanguageListType = NULL;
2310         std::map<int, wxString> *LanguageListAltID = NULL;
2311         std::map<int, wxString> *LanguageListPID = NULL;
2312         std::map<int, wxString> *LanguageListTokens = NULL;
2313         std::map<int, int> *LanguageListPref = NULL;
2315         switch(PropType){
2316                 case PROPERTY_NONE:
2317                         LanguageList = &GeneralLanguageList;
2318                         LanguageListType = &GeneralLanguageListType;
2319                         LanguageListAltID = &GeneralLanguageListAltID;
2320                         LanguageListPID = &GeneralLanguageListPID;
2321                         LanguageListTokens = &GeneralLanguageListTokens;
2322                         LanguageListPref = &GeneralLanguageListPref;    
2323                         break;
2324                 case PROPERTY_HOME:
2325                         LanguageList = &HomeLanguageList;
2326                         LanguageListType = &HomeLanguageListType;
2327                         LanguageListAltID = &HomeLanguageListAltID;
2328                         LanguageListPID = &HomeLanguageListPID;
2329                         LanguageListTokens = &HomeLanguageListTokens;   
2330                         LanguageListPref = &HomeLanguageListPref;       
2331                         break;
2332                 case PROPERTY_WORK:
2333                         LanguageList = &BusinessLanguageList;
2334                         LanguageListType = &BusinessLanguageListType;
2335                         LanguageListAltID = &BusinessLanguageListAltID;
2336                         LanguageListPID = &BusinessLanguageListPID;
2337                         LanguageListTokens = &BusinessLanguageListTokens;       
2338                         LanguageListPref = &BusinessLanguageListPref;
2339                         break;
2340         }
2341         
2342         intPrevValue = 5;
2343         
2344         std::map<int,int>::iterator SLiter;
2345         wxString PropertyData;
2346         wxString PropertyName;
2347         wxString PropertyValue;
2348         wxString PropertyTokens;
2349         bool FirstToken = TRUE;
2350         bool PropertyMatched = FALSE;
2351         
2352         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2353         intiter != SplitPoints.end(); ++intiter){
2354         
2355                 SLiter = SplitLength.find(intiter->first);
2356                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2357                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2358                 intPrevValue = intiter->second;
2360                 CaptureString(&PropertyValue, FALSE);
2361                 
2362                 // Process properties.
2363                 
2364                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2365                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2366                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2368                 if (PropertyMatched == TRUE){
2369                 
2370                         PropertyMatched = FALSE;
2371                         continue;
2372                 
2373                 }
2374                 
2375                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2376         
2377         }
2378                 
2379         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2380         
2381         // Add the name token data.
2382         
2383         if (!PropertyTokens.IsEmpty()){
2384         
2385                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2386         
2387         }
2391 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2393         // Process the geographic location.
2394         
2395         std::map<int, int> SplitPoints;
2396         std::map<int, int> SplitLength;
2398         int intPrevValue = 5;
2399         
2400         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2401         
2402         intPrevValue = 4;
2403         
2404         PropertyType PropType = PROPERTY_NONE;
2405                 
2406         // Look for type before continuing.
2407         
2408         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2409         
2410         std::map<int, wxString> *GeopositionList = NULL;
2411         std::map<int, wxString> *GeopositionListType = NULL;
2412         std::map<int, wxString> *GeopositionListAltID = NULL;
2413         std::map<int, wxString> *GeopositionListPID = NULL;
2414         std::map<int, wxString> *GeopositionListTokens = NULL;
2415         std::map<int, wxString> *GeopositionListMediatype = NULL;
2416         std::map<int, wxString> *GeopositionListDataType = NULL;
2417         std::map<int, int> *GeopositionListPref = NULL;
2419         switch(PropType){
2420                 case PROPERTY_NONE:
2421                         GeopositionList = &GeneralGeographyList;
2422                         GeopositionListType = &GeneralGeographyListType;
2423                         GeopositionListAltID = &GeneralGeographyListAltID;
2424                         GeopositionListPID = &GeneralGeographyListPID;
2425                         GeopositionListTokens = &GeneralGeographyListTokens;
2426                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2427                         GeopositionListDataType = &GeneralGeographyListDataType;
2428                         GeopositionListPref = &GeneralGeographyListPref;        
2429                         break;
2430                 case PROPERTY_HOME:
2431                         GeopositionList = &HomeGeographyList;
2432                         GeopositionListType = &HomeGeographyListType;
2433                         GeopositionListAltID = &HomeGeographyListAltID;
2434                         GeopositionListPID = &HomeGeographyListPID;
2435                         GeopositionListTokens = &HomeGeographyListTokens;
2436                         GeopositionListMediatype = &HomeGeographyListMediatype;
2437                         GeopositionListDataType = &HomeGeographyListDataType;
2438                         GeopositionListPref = &HomeGeographyListPref;   
2439                         break;
2440                 case PROPERTY_WORK:
2441                         GeopositionList = &BusinessGeographyList;
2442                         GeopositionListType = &BusinessGeographyListType;
2443                         GeopositionListAltID = &BusinessGeographyListAltID;
2444                         GeopositionListPID = &BusinessGeographyListPID;
2445                         GeopositionListTokens = &BusinessGeographyListTokens;
2446                         GeopositionListMediatype = &BusinessGeographyListMediatype;
2447                         GeopositionListDataType = &BusinessGeographyListDataType;
2448                         GeopositionListPref = &BusinessGeographyListPref;
2449                         break;
2450         }
2451         
2452         intPrevValue = 4;
2453         
2454         std::map<int,int>::iterator SLiter;
2455         wxString PropertyData;
2456         wxString PropertyName;
2457         wxString PropertyValue;
2458         wxString PropertyTokens;
2459         bool FirstToken = TRUE;
2460         bool PropertyMatched = FALSE;
2461         
2462         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2463         intiter != SplitPoints.end(); ++intiter){
2464         
2465                 SLiter = SplitLength.find(intiter->first);
2466                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2467                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2468                 intPrevValue = intiter->second;
2469                 
2470                 CaptureString(&PropertyValue, FALSE);
2471                 
2472                 // Process properties.
2473                 
2474                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2475                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2476                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2477                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2478                 
2479                 if (PropertyMatched == TRUE){
2480                 
2481                         PropertyMatched = FALSE;
2482                         continue;
2483                 
2484                 }
2485                 
2486                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2487         
2488         }
2489         
2490         wxStringTokenizer GeoSplitData(PropertySeg2, wxT(":"));
2491                 
2492         if (GeoSplitData.CountTokens() > 1){
2494                 GeopositionListDataType->insert(std::make_pair(*GeographicCount, GeoSplitData.GetNextToken()));                 
2495                 GeopositionList->insert(std::make_pair(*GeographicCount, GeoSplitData.GetString()));
2496         
2497         } else {
2498         
2499                 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2500                 GeopositionListDataType->insert(std::make_pair(*GeographicCount, "tel"));
2501         
2502         }
2503                 
2504         // Add the name token data.
2505         
2506         if (!PropertyTokens.IsEmpty()){
2507         
2508                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2509         
2510         }
2514 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2516         // Process the relation.
2517         
2518         std::map<int, int> SplitPoints;
2519         std::map<int, int> SplitLength;
2520         std::map<int, int>::iterator SLiter;                    
2521         wxString PropertyData;
2522         wxString PropertyName;
2523         wxString PropertyValue;
2524         wxString PropertyTokens;
2525         wxString RelatedType;
2526         wxString RelatedTypeOriginal;                   
2527         wxString RelatedName;
2528         bool FirstToken = TRUE;                 
2529         int intPrevValue = 9;
2530         
2531         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2532         
2533         intPrevValue = 8;
2534         
2535         // Look for type before continuing.
2536         
2537         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2538         intiter != SplitPoints.end(); ++intiter){
2539         
2540                 SLiter = SplitLength.find(intiter->first);
2541                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2542                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2543                 intPrevValue = intiter->second;
2544                 
2545                 // Process these.
2546                 
2547                 RelatedTypeOriginal = PropertyValue;
2548                 
2549                 if (PropertyName == wxT("TYPE")){
2550                 
2551                         if (PropertyValue == wxT("contact")){
2553                                 RelatedType = _("Contact");
2555                         } else if (PropertyValue == wxT("acquaintance")){
2557                                 RelatedType = _("Acquaintance");
2559                         } else if (PropertyValue == wxT("friend")){
2561                                 RelatedType = _("Friend");
2563                         } else if (PropertyValue == wxT("met")){
2565                                 RelatedType = _("Met");
2567                         } else if (PropertyValue == wxT("co-worker")){
2569                                 RelatedType = _("Co-worker");
2571                         } else if (PropertyValue == wxT("colleague")){
2573                                 RelatedType = _("Colleague");
2575                         } else if (PropertyValue == wxT("co-resident")){
2577                                 RelatedType = _("Co-resident");
2579                         } else if (PropertyValue == wxT("neighbor")){
2581                                 RelatedType = _("Neighbour");
2583                         } else if (PropertyValue == wxT("child")){
2585                                 RelatedType = _("Child");
2587                         } else if (PropertyValue == wxT("parent")){
2589                                 RelatedType = _("Parent");
2591                         } else if (PropertyValue == wxT("sibling")){
2593                                 RelatedType = _("Sibling");
2595                         } else if (PropertyValue == wxT("spouse")){
2597                                 RelatedType = _("Spouse");
2599                         } else if (PropertyValue == wxT("kin")){
2601                                 RelatedType = _("Kin");
2603                         } else if (PropertyValue == wxT("muse")){
2605                                 RelatedType = _("Muse");
2607                         } else if (PropertyValue == wxT("crush")){
2609                                 RelatedType = _("Crush");
2611                         } else if (PropertyValue == wxT("date")){
2613                                 RelatedType = _("Date");
2615                         } else if (PropertyValue == wxT("sweetheart")){
2617                                 RelatedType = _("Sweetheart");
2619                         } else if (PropertyValue == wxT("me")){
2621                                 RelatedType = _("Me");
2623                         } else if (PropertyValue == wxT("agent")){
2625                                 RelatedType = _("Agent");
2627                         } else if (PropertyValue == wxT("emergency")){
2629                                 RelatedType = _("Emergency");
2631                         } else {
2633                                 RelatedType = PropertyValue;
2635                         }
2636                 
2637                 }
2638         
2639         }
2640         
2641         intPrevValue = 8;                       
2642         
2643         bool PropertyMatched = FALSE;
2644         
2645         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2646         intiter != SplitPoints.end(); ++intiter){
2647         
2648                 SLiter = SplitLength.find(intiter->first);
2649                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2650                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2651                 intPrevValue = intiter->second;
2652                 
2653                 // Process properties.
2654                 
2655                 size_t intPropertyValueLen = PropertyValue.Len();
2656                 
2657                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2658                         
2659                         PropertyValue.Trim();
2660                         PropertyValue.RemoveLast();
2661                         
2662                 }                               
2663                 
2664                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2665                         
2666                         PropertyValue.Remove(0, 1);
2667                         
2668                 }
2669                 
2670                 CaptureString(&PropertyValue, FALSE);
2671                         
2672                 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2673                 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2674                 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2675                 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2677                 if (PropertyMatched == TRUE){
2678                 
2679                         PropertyMatched = FALSE;
2680                         continue;
2681                 
2682                 }
2684                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2685         
2686         }                                       
2687         
2688         // Add the data to the General/Home/Work address variables.
2689                                 
2690         GeneralRelatedList.erase(*RelatedCount);
2691         GeneralRelatedListRelType.erase(*RelatedCount);
2692         GeneralRelatedListType.erase(*RelatedCount);
2693         GeneralRelatedListTokens.erase(*RelatedCount);
2694         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2695         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2696         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2697         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2701 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2703         // Process the URL.
2704         
2705         std::map<int, int> SplitPoints;
2706         std::map<int, int> SplitLength;
2707         std::map<int, int>::iterator SLiter;                    
2708         wxString PropertyData;
2709         wxString PropertyName;
2710         wxString PropertyValue;
2711         wxString PropertyTokens;
2712         bool FirstToken = TRUE;
2713         int intPrevValue = 5;
2714         
2715         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2716         
2717         intPrevValue = 4;
2718         
2719         PropertyType PropType = PROPERTY_NONE;
2720                 
2721         // Look for type before continuing.
2722         
2723         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2724         
2725         // Setup the pointers.
2726         
2727         std::map<int, wxString> *WebsiteList = NULL;
2728         std::map<int, wxString> *WebsiteListAltID = NULL;
2729         std::map<int, wxString> *WebsiteListPID = NULL;
2730         std::map<int, wxString> *WebsiteListType = NULL;
2731         std::map<int, wxString> *WebsiteListTokens = NULL;
2732         std::map<int, wxString> *WebsiteListMediatype = NULL;
2733         std::map<int, int> *WebsiteListPref = NULL;
2734         
2735         // Setup blank lines for later on.
2736         
2737         switch(PropType){
2738                 case PROPERTY_NONE:
2739                         WebsiteList = &GeneralWebsiteList;
2740                         WebsiteListType = &GeneralWebsiteListType;
2741                         WebsiteListAltID = &GeneralWebsiteListAltID;
2742                         WebsiteListPID = &GeneralWebsiteListPID;
2743                         WebsiteListTokens = &GeneralWebsiteListTokens;
2744                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2745                         WebsiteListPref = &GeneralWebsiteListPref;      
2746                         break;
2747                 case PROPERTY_HOME:
2748                         WebsiteList = &HomeWebsiteList;
2749                         WebsiteListType = &HomeWebsiteListType;
2750                         WebsiteListAltID = &HomeWebsiteListAltID;
2751                         WebsiteListPID = &HomeWebsiteListPID;
2752                         WebsiteListTokens = &HomeWebsiteListTokens;
2753                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2754                         WebsiteListPref = &HomeWebsiteListPref; 
2755                         break;
2756                 case PROPERTY_WORK:
2757                         WebsiteList = &BusinessWebsiteList;
2758                         WebsiteListType = &BusinessWebsiteListType;
2759                         WebsiteListAltID = &BusinessWebsiteListAltID;
2760                         WebsiteListPID = &BusinessWebsiteListPID;
2761                         WebsiteListTokens = &BusinessWebsiteListTokens;
2762                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2763                         WebsiteListPref = &BusinessWebsiteListPref;
2764                         break;
2765         }
2766         
2767         intPrevValue = 4;
2768         bool PropertyMatched = FALSE;
2769         
2770         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2771         intiter != SplitPoints.end(); ++intiter){
2772         
2773                 SLiter = SplitLength.find(intiter->first);
2774                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2775                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2776                 intPrevValue = intiter->second;
2777                 
2778                 // Process properties.
2779                 
2780                 size_t intPropertyValueLen = PropertyValue.Len();
2781                 
2782                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2783                         
2784                         PropertyValue.Trim();
2785                         PropertyValue.RemoveLast();
2786                         
2787                 }                               
2788                 
2789                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2790                         
2791                         PropertyValue.Remove(0, 1);
2792                         
2793                 }
2794                 
2795                 CaptureString(&PropertyValue, FALSE);
2796                 
2797                 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
2798                 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
2799                 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
2800                 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
2801                 
2802                 if (PropertyMatched == TRUE){
2803                 
2804                         PropertyMatched = FALSE;
2805                         continue;
2806                 
2807                 }
2808                 
2809                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2810         
2811         }
2812         
2813         // Add the data to the General/Home/Work address variables.
2814         
2815         CaptureString(&PropertySeg2, FALSE);
2816                         
2817         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2818         
2819         if (!PropertyTokens.IsEmpty()){
2820         
2821                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2822                         
2823         }
2824         
2827 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
2829         // Process the title.
2830         
2831         std::map<int, int> SplitPoints;
2832         std::map<int, int> SplitLength;
2833         std::map<int, int>::iterator SLiter;                    
2834         wxString PropertyData;
2835         wxString PropertyName;
2836         wxString PropertyValue;
2837         wxString PropertyTokens;
2838         bool FirstToken = TRUE;
2839         int intPrevValue = 7;
2840         
2841         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2842         
2843         intPrevValue = 6;
2844         
2845         PropertyType PropType = PROPERTY_NONE;
2846                 
2847         // Look for type before continuing.
2848         
2849         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2850         
2851         // Setup the pointers.
2852         
2853         std::map<int, wxString> *TitleList = NULL;
2854         std::map<int, wxString> *TitleListAltID = NULL;
2855         std::map<int, wxString> *TitleListPID = NULL;
2856         std::map<int, wxString> *TitleListType = NULL;
2857         std::map<int, wxString> *TitleListTokens = NULL;
2858         std::map<int, wxString> *TitleListLanguage = NULL;
2859         std::map<int, int> *TitleListPref = NULL;
2860         
2861         // Setup blank lines for later on.
2862         
2863         switch(PropType){
2864                 case PROPERTY_NONE:
2865                         TitleList = &GeneralTitleList;
2866                         TitleListType = &GeneralTitleListType;
2867                         TitleListAltID = &GeneralTitleListAltID;
2868                         TitleListPID = &GeneralTitleListPID;
2869                         TitleListTokens = &GeneralTitleListTokens;
2870                         TitleListLanguage = &GeneralTitleListLanguage;
2871                         TitleListPref = &GeneralTitleListPref;  
2872                         break;
2873                 case PROPERTY_HOME:
2874                         TitleList = &HomeTitleList;
2875                         TitleListType = &HomeTitleListType;
2876                         TitleListAltID = &HomeTitleListAltID;
2877                         TitleListPID = &HomeTitleListPID;
2878                         TitleListTokens = &HomeTitleListTokens;
2879                         TitleListLanguage = &HomeTitleListLanguage;
2880                         TitleListPref = &HomeTitleListPref;     
2881                         break;
2882                 case PROPERTY_WORK:
2883                         TitleList = &BusinessTitleList;
2884                         TitleListType = &BusinessTitleListType;
2885                         TitleListAltID = &BusinessTitleListAltID;
2886                         TitleListPID = &BusinessTitleListPID;
2887                         TitleListTokens = &BusinessTitleListTokens;
2888                         TitleListLanguage = &BusinessTitleListLanguage; 
2889                         TitleListPref = &BusinessTitleListPref;
2890                         break;
2891         }
2893         intPrevValue = 6;
2894         bool PropertyMatched = FALSE;
2895                 
2896         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2897         intiter != SplitPoints.end(); ++intiter){
2898         
2899                 SLiter = SplitLength.find(intiter->first);
2900                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2901                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2902                 intPrevValue = intiter->second;
2903                 
2904                 // Process properties.
2905                 
2906                 size_t intPropertyValueLen = PropertyValue.Len();
2907                 
2908                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2909                         
2910                         PropertyValue.Trim();
2911                         PropertyValue.RemoveLast();
2912                         
2913                 }                               
2914                 
2915                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2916                         
2917                         PropertyValue.Remove(0, 1);
2918                         
2919                 }                               
2920                 
2921                 CaptureString(&PropertyValue, FALSE);
2922                 
2923                 ProcessStringValue(&PropertyName, "ALTID", TitleListAltID, &PropertyValue, TitleCount, &PropertyMatched);
2924                 ProcessStringValue(&PropertyName, "PID", TitleListPID, &PropertyValue, TitleCount, &PropertyMatched);
2925                 ProcessStringValue(&PropertyName, "LANGUAGE", TitleListLanguage, &PropertyValue, TitleCount, &PropertyMatched);
2926                 ProcessIntegerValue(&PropertyName, "PREF", TitleListPref, &PropertyValue, TitleCount, &PropertyMatched);
2927                 
2928                 if (PropertyMatched == TRUE){
2929                 
2930                         PropertyMatched = FALSE;
2931                         continue;
2932                 
2933                 }
2935                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2936         
2937         }
2938         
2939         // Add the data to the General/Home/Work address variables.
2940         
2941         CaptureString(&PropertySeg2, FALSE);
2943         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
2944         
2945         if (!PropertyTokens.IsEmpty()){
2946         
2947                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
2948                         
2949         }
2953 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
2955         // Process the role.
2956         
2957         std::map<int, int> SplitPoints;
2958         std::map<int, int> SplitLength;
2959         std::map<int, int>::iterator SLiter;                    
2960         wxString PropertyData;
2961         wxString PropertyName;
2962         wxString PropertyValue;
2963         wxString PropertyTokens;
2964         bool FirstToken = TRUE;
2965         int intPrevValue = 6;
2966         
2967         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2968         
2969         intPrevValue = 5;
2970         
2971         PropertyType PropType = PROPERTY_NONE;
2972                 
2973         // Look for type before continuing.
2974         
2975         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2976         
2977         // Setup the pointers.
2978         
2979         std::map<int, wxString> *RoleList = NULL;
2980         std::map<int, wxString> *RoleListAltID = NULL;
2981         std::map<int, wxString> *RoleListPID = NULL;
2982         std::map<int, wxString> *RoleListType = NULL;
2983         std::map<int, wxString> *RoleListTokens = NULL;
2984         std::map<int, wxString> *RoleListLanguage = NULL;
2985         std::map<int, int> *RoleListPref = NULL;
2986         
2987         // Setup blank lines for later on.
2988         
2989         switch(PropType){
2990                 case PROPERTY_NONE:
2991                         RoleList = &GeneralRoleList;
2992                         RoleListType = &GeneralRoleListType;
2993                         RoleListAltID = &GeneralRoleListAltID;
2994                         RoleListPID = &GeneralRoleListPID;
2995                         RoleListTokens = &GeneralRoleListTokens;
2996                         RoleListLanguage = &GeneralRoleListLanguage;
2997                         RoleListPref = &GeneralRoleListPref;    
2998                         break;
2999                 case PROPERTY_HOME:
3000                         RoleList = &HomeRoleList;
3001                         RoleListType = &HomeRoleListType;
3002                         RoleListAltID = &HomeRoleListAltID;
3003                         RoleListPID = &HomeRoleListPID;
3004                         RoleListTokens = &HomeRoleListTokens;
3005                         RoleListLanguage = &HomeRoleListLanguage;
3006                         RoleListPref = &HomeRoleListPref;       
3007                         break;
3008                 case PROPERTY_WORK:
3009                         RoleList = &BusinessRoleList;
3010                         RoleListType = &BusinessRoleListType;
3011                         RoleListAltID = &BusinessRoleListAltID;
3012                         RoleListPID = &BusinessRoleListPID;
3013                         RoleListTokens = &BusinessRoleListTokens;
3014                         RoleListLanguage = &BusinessRoleListLanguage;   
3015                         RoleListPref = &BusinessRoleListPref;
3016                         break;
3017         }
3019         intPrevValue = 5;
3020         bool PropertyMatched = FALSE;
3021                 
3022         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3023         intiter != SplitPoints.end(); ++intiter){
3024         
3025                 SLiter = SplitLength.find(intiter->first);
3026                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3027                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3028                 intPrevValue = intiter->second;
3029                 
3030                 // Process properties.
3031                 
3032                 size_t intPropertyValueLen = PropertyValue.Len();
3033                 
3034                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3035                         
3036                         PropertyValue.Trim();
3037                         PropertyValue.RemoveLast();
3038                         
3039                 }                               
3040                 
3041                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3042                         
3043                         PropertyValue.Remove(0, 1);
3044                         
3045                 }                               
3046                 
3047                 CaptureString(&PropertyValue, FALSE);
3048                 
3049                 ProcessStringValue(&PropertyName, "ALTID", RoleListAltID, &PropertyValue, RoleCount, &PropertyMatched);
3050                 ProcessStringValue(&PropertyName, "PID", RoleListPID, &PropertyValue, RoleCount, &PropertyMatched);
3051                 ProcessStringValue(&PropertyName, "LANGUAGE", RoleListLanguage, &PropertyValue, RoleCount, &PropertyMatched);
3052                 ProcessIntegerValue(&PropertyName, "PREF", RoleListPref, &PropertyValue, RoleCount, &PropertyMatched);
3053                 
3054                 if (PropertyMatched == TRUE){
3055                 
3056                         PropertyMatched = FALSE;
3057                         continue;
3058                 
3059                 }
3060                 
3061                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3062                 
3063         }
3064         
3065         // Add the data to the General/Home/Work address variables.
3066         
3067         CaptureString(&PropertySeg2, FALSE);
3069         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3070         
3071         if (!PropertyTokens.IsEmpty()){
3072         
3073                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3074                         
3075         }
3079 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3081         // Process the organisation.
3082         
3083         std::map<int, int> SplitPoints;
3084         std::map<int, int> SplitLength;
3085         std::map<int, int>::iterator SLiter;                    
3086         wxString PropertyData;
3087         wxString PropertyName;
3088         wxString PropertyValue;
3089         wxString PropertyTokens;
3090         bool FirstToken = TRUE;
3091         int intPrevValue = 5;
3092         
3093         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3094         
3095         intPrevValue = 4;
3096         
3097         PropertyType PropType = PROPERTY_NONE;
3098                 
3099         // Look for type before continuing.
3100         
3101         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3102         
3103         // Setup the pointers.
3104         
3105         std::map<int, wxString> *OrganisationsList = NULL;
3106         std::map<int, wxString> *OrganisationsListAltID = NULL;
3107         std::map<int, wxString> *OrganisationsListPID = NULL;
3108         std::map<int, wxString> *OrganisationsListType = NULL;
3109         std::map<int, wxString> *OrganisationsListTokens = NULL;
3110         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3111         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3112         std::map<int, int> *OrganisationsListPref = NULL;
3113         
3114         // Setup blank lines for later on.
3115         
3116         switch(PropType){
3117                 case PROPERTY_NONE:
3118                         OrganisationsList = &GeneralOrganisationsList;
3119                         OrganisationsListType = &GeneralOrganisationsListType;
3120                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3121                         OrganisationsListPID = &GeneralOrganisationsListPID;
3122                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3123                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3124                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3125                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3126                         break;
3127                 case PROPERTY_HOME:
3128                         OrganisationsList = &HomeOrganisationsList;
3129                         OrganisationsListType = &HomeOrganisationsListType;
3130                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3131                         OrganisationsListPID = &HomeOrganisationsListPID;
3132                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3133                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3134                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3135                         OrganisationsListPref = &HomeOrganisationsListPref;     
3136                         break;
3137                 case PROPERTY_WORK:
3138                         OrganisationsList = &BusinessOrganisationsList;
3139                         OrganisationsListType = &BusinessOrganisationsListType;
3140                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3141                         OrganisationsListPID = &BusinessOrganisationsListPID;
3142                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3143                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3144                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3145                         OrganisationsListPref = &BusinessOrganisationsListPref;
3146                         break;
3147         }
3149         intPrevValue = 4;
3150         bool PropertyMatched = FALSE;
3151                 
3152         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3153         intiter != SplitPoints.end(); ++intiter){
3154         
3155                 SLiter = SplitLength.find(intiter->first);
3156                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3157                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3158                 intPrevValue = intiter->second;
3159                 
3160                 // Process properties.
3161                 
3162                 size_t intPropertyValueLen = PropertyValue.Len();
3163                 
3164                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3165                         
3166                         PropertyValue.Trim();
3167                         PropertyValue.RemoveLast();
3168                         
3169                 }                               
3170                 
3171                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3172                         
3173                         PropertyValue.Remove(0, 1);
3174                         
3175                 }                               
3176                 
3177                 CaptureString(&PropertyValue, FALSE);
3178                 
3179                 ProcessStringValue(&PropertyName, "ALTID", OrganisationsListAltID, &PropertyValue, OrganisationCount, &PropertyMatched);
3180                 ProcessStringValue(&PropertyName, "PID", OrganisationsListPID, &PropertyValue, OrganisationCount, &PropertyMatched);
3181                 ProcessStringValue(&PropertyName, "LANGUAGE", OrganisationsListLanguage, &PropertyValue, OrganisationCount, &PropertyMatched);
3182                 ProcessStringValue(&PropertyName, "SORT-AS", OrganisationsListSortAs, &PropertyValue, OrganisationCount, &PropertyMatched);
3183                 ProcessIntegerValue(&PropertyName, "PREF", OrganisationsListPref, &PropertyValue, OrganisationCount, &PropertyMatched);
3184                 
3185                 if (PropertyMatched == TRUE){
3186                 
3187                         PropertyMatched = FALSE;
3188                         continue;
3189                 
3190                 }
3191                 
3192                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3194         }
3195         
3196         // Add the data to the General/Home/Work address variables.
3197         
3198         CaptureString(&PropertySeg2, FALSE);
3200         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3201         
3202         if (!PropertyTokens.IsEmpty()){
3203         
3204                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3205                         
3206         }
3210 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3212         // Process the note.
3213         
3214         std::map<int, int> SplitPoints;
3215         std::map<int, int> SplitLength;
3216         std::map<int, int>::iterator SLiter;                    
3217         wxString PropertyData;
3218         wxString PropertyName;
3219         wxString PropertyValue;
3220         wxString PropertyTokens;
3221         bool FirstToken = TRUE;
3222         int intPrevValue = 6;
3223         
3224         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3225         
3226         intPrevValue = 5;
3227         
3228         PropertyType PropType = PROPERTY_NONE;
3229                 
3230         // Look for type before continuing.
3231         
3232         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3233         
3234         // Setup the pointers.
3235         
3236         std::map<int, wxString> *NoteList = NULL;
3237         std::map<int, wxString> *NoteListAltID = NULL;
3238         std::map<int, wxString> *NoteListPID = NULL;
3239         std::map<int, wxString> *NoteListType = NULL;
3240         std::map<int, wxString> *NoteListTokens = NULL;
3241         std::map<int, wxString> *NoteListLanguage = NULL;
3242         std::map<int, int> *NoteListPref = NULL;
3243         
3244         // Setup blank lines for later on.
3245         
3246         switch(PropType){
3247                 case PROPERTY_NONE:
3248                         NoteList = &GeneralNoteList;
3249                         NoteListType = &GeneralNoteListType;
3250                         NoteListAltID = &GeneralNoteListAltID;
3251                         NoteListPID = &GeneralNoteListPID;
3252                         NoteListTokens = &GeneralNoteListTokens;
3253                         NoteListLanguage = &GeneralNoteListLanguage;
3254                         NoteListPref = &GeneralNoteListPref;    
3255                         break;
3256                 case PROPERTY_HOME:
3257                         NoteList = &HomeNoteList;
3258                         NoteListType = &HomeNoteListType;
3259                         NoteListAltID = &HomeNoteListAltID;
3260                         NoteListPID = &HomeNoteListPID;
3261                         NoteListTokens = &HomeNoteListTokens;
3262                         NoteListLanguage = &HomeNoteListLanguage;
3263                         NoteListPref = &HomeNoteListPref;       
3264                         break;
3265                 case PROPERTY_WORK:
3266                         NoteList = &BusinessNoteList;
3267                         NoteListType = &BusinessNoteListType;
3268                         NoteListAltID = &BusinessNoteListAltID;
3269                         NoteListPID = &BusinessNoteListPID;
3270                         NoteListTokens = &BusinessNoteListTokens;
3271                         NoteListLanguage = &BusinessNoteListLanguage;   
3272                         NoteListPref = &BusinessNoteListPref;
3273                         break;
3274         }
3276         intPrevValue = 5;
3277         bool PropertyMatched = FALSE;
3278                 
3279         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3280         intiter != SplitPoints.end(); ++intiter){
3281         
3282                 SLiter = SplitLength.find(intiter->first);
3283                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3284                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3285                 intPrevValue = intiter->second;
3286                 
3287                 // Process properties.
3288                 
3289                 size_t intPropertyValueLen = PropertyValue.Len();
3290                 
3291                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3292                         
3293                         PropertyValue.Trim();
3294                         PropertyValue.RemoveLast();
3295                         
3296                 }                               
3297                 
3298                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3299                         
3300                         PropertyValue.Remove(0, 1);
3301                         
3302                 }                               
3303                 
3304                 CaptureString(&PropertyValue, FALSE);
3305                 
3306                 ProcessStringValue(&PropertyName, "ALTID", NoteListAltID, &PropertyValue, NoteCount, &PropertyMatched);
3307                 ProcessStringValue(&PropertyName, "PID", NoteListPID, &PropertyValue, NoteCount, &PropertyMatched);
3308                 ProcessStringValue(&PropertyName, "LANGUAGE", NoteListLanguage, &PropertyValue, NoteCount, &PropertyMatched);
3309                 ProcessIntegerValue(&PropertyName, "PREF", NoteListPref, &PropertyValue, NoteCount, &PropertyMatched);
3310                 
3311                 if (PropertyMatched == TRUE){
3312                 
3313                         PropertyMatched = FALSE;
3314                         continue;
3315                 
3316                 }
3318                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3319         
3320         }
3321         
3322         // Add the data to the General/Home/Work address variables.
3323         
3324         CaptureString(&PropertySeg2, FALSE);
3326         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3327         
3328         if (!PropertyTokens.IsEmpty()){
3329         
3330                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3331                         
3332         }
3336 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3338         // Process the category.
3339         
3340         std::map<int, int> SplitPoints;
3341         std::map<int, int> SplitLength;
3342         std::map<int, int>::iterator SLiter;                    
3343         wxString PropertyData;
3344         wxString PropertyName;
3345         wxString PropertyValue;
3346         wxString PropertyTokens;
3347         bool FirstToken = TRUE;
3348         int intPrevValue = 12;
3349         
3350         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3351         
3352         intPrevValue = 11;
3353         
3354         PropertyType PropType = PROPERTY_NONE;
3355                 
3356         // Look for type before continuing.
3357         
3358         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3359         
3360         // Setup blank lines for later on.
3361         
3362         switch(PropType){
3363                 case PROPERTY_NONE:
3364                         break;
3365                 case PROPERTY_HOME:
3366                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3367                         break;
3368                 case PROPERTY_WORK:
3369                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3370                         break;
3371         }
3373         intPrevValue = 11;
3374         bool PropertyMatched = FALSE;
3375                 
3376         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3377         intiter != SplitPoints.end(); ++intiter){
3378         
3379                 SLiter = SplitLength.find(intiter->first);
3380                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3381                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3382                 intPrevValue = intiter->second;
3383                 
3384                 // Process properties.
3385                 
3386                 size_t intPropertyValueLen = PropertyValue.Len();
3387                 
3388                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3389                         
3390                         PropertyValue.Trim();
3391                         PropertyValue.RemoveLast();
3392                         
3393                 }                               
3394                 
3395                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3396                         
3397                         PropertyValue.Remove(0, 1);
3398                         
3399                 }                               
3400                 
3401                 CaptureString(&PropertyValue, FALSE);
3402                 
3403                 ProcessStringValue(&PropertyName, "ALTID", &CategoriesListAltID, &PropertyValue, CategoryCount, &PropertyMatched);
3404                 ProcessStringValue(&PropertyName, "PID", &CategoriesListPID, &PropertyValue, CategoryCount, &PropertyMatched);
3405                 ProcessStringValue(&PropertyName, "LANGUAGE", &CategoriesListLanguage, &PropertyValue, CategoryCount, &PropertyMatched);
3406                 ProcessIntegerValue(&PropertyName, "PREF", &CategoriesListPref, &PropertyValue, CategoryCount, &PropertyMatched);
3407                 
3408                 if (PropertyMatched == TRUE){
3409                 
3410                         PropertyMatched = FALSE;
3411                         continue;
3412                 
3413                 }
3415                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3416         
3417         }
3418         
3419         // Deal with multiple categories.
3420         
3421         int intOrigCatCount = *CategoryCount;
3422         bool FirstCategoryProcessed = TRUE;
3423         bool AfterFirstToken = FALSE;
3424         int intSplitSize = 0;
3425         int intSplitsFound = 0;
3426         int intSplitSeek = 0;
3427         int intPropertyLen = PropertySeg2.Len();
3428         
3429         SplitPoints.clear();
3430         SplitLength.clear();
3431         intPrevValue = 0;
3432         
3433         for (int i = 0; i <= intPropertyLen; i++){
3434         
3435                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3436         
3437                         continue;
3438                 
3439                 }
3440         
3441                 intSplitSize++;
3442         
3443                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3444         
3445                         if (AfterFirstToken == TRUE){
3446                 
3447                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3448                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3449                         
3450                         } else {
3451                         
3452                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3453                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3454                                 AfterFirstToken = TRUE;
3456                         }
3458                         intSplitsFound++;
3459                         intSplitSeek = i;
3460                         intSplitSize = 0;                               
3461         
3462                 }                       
3463         
3464         }
3465         
3466         if (SplitPoints.size() > 0){
3467         
3468                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3469                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3470         
3471         }
3472         
3473         if (SplitPoints.size() == 0){
3474         
3475                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3476         
3477                 if (!PropertyTokens.IsEmpty()){
3478                 
3479                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3480                 
3481                 }
3482         
3483         }
3484         
3485         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3486         intiter != SplitPoints.end(); ++intiter){
3487         
3488                 SLiter = SplitLength.find(intiter->first);
3489         
3490                 intPrevValue = intiter->second;
3491         
3492                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3493                 
3494                 // Add the data to the General/Home/Work address variables.
3495         
3496                 // Trim any whitespace from the start and end.
3497         
3498                 PropertyData = PropertyData.Trim(FALSE);
3499                 PropertyData = PropertyData.Trim(TRUE); 
3500         
3501                 CaptureString(&PropertyData, FALSE);
3502                 
3503                 if (FirstCategoryProcessed == TRUE){
3504                 
3505                         FirstCategoryProcessed = FALSE;
3506                         
3507                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3508         
3509                         if (!PropertyTokens.IsEmpty()){
3510                 
3511                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3512                 
3513                         }
3514                         
3515                         continue;
3516                 
3517                 } else {
3519                         (*CategoryCount)++;
3520                         
3521                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3522                 
3523                         if (!PropertyTokens.IsEmpty()){
3524                 
3525                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3526                 
3527                         }
3528                 
3529                 }
3530                 
3531                 // Copy the properties to each of the categories (if it exists).
3532                 
3533                 if (!PropertyTokens.IsEmpty()){
3534                 
3535                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3536                 
3537                 }
3538                 
3539                 // Check if ALTID was used.
3540                 
3541                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3542                 
3543                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3544                 
3545                 }
3546                 
3547                 // Check if PID was used.
3548                 
3549                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
3550                 
3551                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
3552                 
3553                 }
3554         
3555                 // Check if PREF was used.
3556         
3557                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
3558                 
3559                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
3560                 
3561                 }
3562                 
3563                 // Check if LANGUAGE was used.
3564                 
3565                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
3566                 
3567                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
3568                 
3569                 }
3570                 
3571                 // Check if TYPE was used.
3572                 
3573                 switch(PropType){
3574                         case PROPERTY_NONE:
3575                                 break;
3576                         case PROPERTY_HOME:
3577                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3578                                 break;
3579                         case PROPERTY_WORK:
3580                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3581                                 break;
3582                 }
3583         
3584         }
3588 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
3590         // Process the photo.
3591         
3592         size_t intPropertyLen = PropertySeg1.Len();
3593         std::map<int, int> SplitPoints;
3594         std::map<int, int> SplitLength;
3595         std::map<int, int>::iterator SLiter;                    
3596         wxString PropertyData;
3597         wxString PropertyName;
3598         wxString PropertyValue;
3599         wxString PropertyTokens;
3600         bool FirstToken = TRUE;
3601         int intSplitsFound = 0;
3602         int intSplitSize = 0;
3603         int intPrevValue = 7;
3604         
3605         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3606         
3607         intPrevValue = 6;
3608         
3609         PropertyType PropType = PROPERTY_NONE;
3610                 
3611         // Look for type before continuing.
3612         
3613         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3615         intPrevValue = 6;
3616         bool PropertyMatched = FALSE;
3618         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3619         intiter != SplitPoints.end(); ++intiter){
3620         
3621                 SLiter = SplitLength.find(intiter->first);
3622                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3623                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3624                 intPrevValue = intiter->second;
3625                 
3626                 // Process properties.
3627                 
3628                 size_t intPropertyValueLen = PropertyValue.Len();
3629                 
3630                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3631                         
3632                         PropertyValue.Trim();
3633                         PropertyValue.RemoveLast();
3634                         
3635                 }                               
3636                 
3637                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3638                         
3639                         PropertyValue.Remove(0, 1);
3640                         
3641                 }
3642                 
3643                 CaptureString(&PropertyValue, FALSE);
3644                 
3645                 ProcessStringValue(&PropertyName, "ALTID", &PicturesListAltID, &PropertyValue, PhotoCount, &PropertyMatched);
3646                 ProcessStringValue(&PropertyName, "PID", &PicturesListPID, &PropertyValue, PhotoCount, &PropertyMatched);
3647                 ProcessStringValue(&PropertyName, "MEDIATYPE", &PicturesListMediatype, &PropertyValue, PhotoCount, &PropertyMatched);
3648                 ProcessIntegerValue(&PropertyName, "PREF", &PicturesListPref, &PropertyValue, PhotoCount, &PropertyMatched);
3649                 
3650                 if (PropertyMatched == TRUE){
3651                 
3652                         PropertyMatched = FALSE;
3653                         continue;
3654                 
3655                 }
3657                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3658                         
3659         }       
3660         
3661         intPropertyLen = PropertySeg2.Len();
3662         SplitPoints.clear();
3663         SplitLength.clear();
3664         intSplitsFound = 0;
3665         intSplitSize = 0;
3666         intPrevValue = 0;                       
3667         
3668         CaptureString(&PropertySeg2, FALSE);
3669         
3670         for (int i = 0; i <= intPropertyLen; i++){
3672                 intSplitSize++;
3673         
3674                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3675         
3676                         intSplitsFound++;
3677                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3678                         
3679                         if (intSplitsFound == 6){ 
3680                         
3681                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3682                                 break; 
3683                                 
3684                         } else {
3685                         
3686                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3687                         
3688                         }
3689                         
3690                         intSplitSize = 0;                                       
3691         
3692                 }
3694         }
3695         
3696         wxString wxSPhotoURI;
3697         wxString wxSPhotoMIME;
3698         wxString wxSPhotoEncoding;
3699         wxString wxSPhotoData;
3700         std::string base64enc;
3701         
3702         if (intSplitsFound == 0){
3703         
3704         } else {
3705         
3706                 std::map<int, int>::iterator striter;
3707         
3708                 striter = SplitLength.find(1);
3709         
3710                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3711         
3712                 while (wSTDataType.HasMoreTokens() == TRUE){
3713                 
3714                         wxSPhotoURI = wSTDataType.GetNextToken();
3715                         wxSPhotoMIME = wSTDataType.GetNextToken();
3716                         break;
3717                 
3718                 }                       
3719         
3720                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3721         
3722                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3723                 
3724                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3725                         wxSPhotoData = wSTDataInfo.GetNextToken();
3726                         base64enc = wxSPhotoData.mb_str();
3727                         break;
3728                 
3729                 }
3730         
3731         }
3732         
3733         // Add the data to the General/Home/Work address variables.
3734         
3735         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
3736         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
3737         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
3738         
3739         switch(PropType){
3740                 case PROPERTY_NONE:
3741                         break;
3742                 case PROPERTY_HOME:
3743                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
3744                         break;
3745                 case PROPERTY_WORK:
3746                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
3747                         break;
3748         }
3749         
3750         if (!PropertyTokens.IsEmpty()){
3752                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
3753         
3754         }
3758 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
3760         // Process the logo.
3761         
3762         size_t intPropertyLen = PropertySeg1.Len();
3763         std::map<int, int> SplitPoints;
3764         std::map<int, int> SplitLength;
3765         std::map<int, int>::iterator SLiter;                    
3766         wxString PropertyData;
3767         wxString PropertyName;
3768         wxString PropertyValue;
3769         wxString PropertyTokens;
3770         bool FirstToken = TRUE;
3771         int intSplitsFound = 0;
3772         int intSplitSize = 0;
3773         int intPrevValue = 6;
3774         
3775         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3776         
3777         intPrevValue = 5;
3778         
3779         PropertyType PropType = PROPERTY_NONE;
3780                 
3781         // Look for type before continuing.
3782         
3783         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3785         intPrevValue = 5;
3786         bool PropertyMatched = FALSE;
3788         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3789         intiter != SplitPoints.end(); ++intiter){
3790         
3791                 SLiter = SplitLength.find(intiter->first);
3792                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3793                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3794                 intPrevValue = intiter->second;
3795                 
3796                 // Process properties.
3797                 
3798                 size_t intPropertyValueLen = PropertyValue.Len();
3799                 
3800                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3801                         
3802                         PropertyValue.Trim();
3803                         PropertyValue.RemoveLast();
3804                         
3805                 }                               
3806                 
3807                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3808                         
3809                         PropertyValue.Remove(0, 1);
3810                         
3811                 }
3812                 
3813                 CaptureString(&PropertyValue, FALSE);
3814                 
3815                 ProcessStringValue(&PropertyName, "ALTID", &LogosListAltID, &PropertyValue, LogoCount, &PropertyMatched);
3816                 ProcessStringValue(&PropertyName, "PID", &LogosListPID, &PropertyValue, LogoCount, &PropertyMatched);
3817                 ProcessStringValue(&PropertyName, "MEDIATYPE", &LogosListMediatype, &PropertyValue, LogoCount, &PropertyMatched);
3818                 ProcessIntegerValue(&PropertyName, "PREF", &LogosListPref, &PropertyValue, LogoCount, &PropertyMatched);
3819                 
3820                 if (PropertyMatched == TRUE){
3821                 
3822                         PropertyMatched = FALSE;
3823                         continue;
3824                 
3825                 }
3827                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3828         
3829         }       
3830         
3831         intPropertyLen = PropertySeg2.Len();
3832         SplitPoints.clear();
3833         SplitLength.clear();
3834         intSplitsFound = 0;
3835         intSplitSize = 0;
3836         intPrevValue = 0;                       
3837         
3838         CaptureString(&PropertySeg2, FALSE);
3839         
3840         for (int i = 0; i <= intPropertyLen; i++){
3842                 intSplitSize++;
3843         
3844                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3845         
3846                         intSplitsFound++;
3847                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3848                         
3849                         if (intSplitsFound == 6){ 
3850                         
3851                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3852                                 break; 
3853                                 
3854                         } else {
3855                         
3856                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3857                         
3858                         }
3859                         
3860                         intSplitSize = 0;                                       
3861         
3862                 }
3864         }
3865         
3866         wxString wxSPhotoURI;
3867         wxString wxSPhotoMIME;
3868         wxString wxSPhotoEncoding;
3869         wxString wxSPhotoData;
3870         std::string base64enc;
3871         
3872         if (intSplitsFound == 0){
3873         
3874         } else {
3875         
3876                 std::map<int, int>::iterator striter;
3877         
3878                 striter = SplitLength.find(1);
3879         
3880                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3881         
3882                 while (wSTDataType.HasMoreTokens() == TRUE){
3883                 
3884                         wxSPhotoURI = wSTDataType.GetNextToken();
3885                         wxSPhotoMIME = wSTDataType.GetNextToken();
3886                         break;
3887                 
3888                 }                       
3889         
3890                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3891         
3892                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3893                 
3894                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3895                         wxSPhotoData = wSTDataInfo.GetNextToken();
3896                         base64enc = wxSPhotoData.mb_str();
3897                         break;
3898                 
3899                 }
3900         
3901         }
3902         
3903         // Add the data to the General/Home/Work address variables.
3904                 
3905         LogosList.insert(std::make_pair(*LogoCount, base64enc));
3906         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
3907         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
3908         
3909         switch(PropType){
3910                 case PROPERTY_NONE:
3911                         break;
3912                 case PROPERTY_HOME:
3913                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
3914                         break;
3915                 case PROPERTY_WORK:
3916                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
3917                         break;
3918         }
3919         
3920         if (!PropertyTokens.IsEmpty()){
3922                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
3923         
3924         }
3928 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
3930         // Process the sound.
3931         
3932         size_t intPropertyLen = PropertySeg1.Len();
3933         std::map<int, int> SplitPoints;
3934         std::map<int, int> SplitLength;
3935         std::map<int, int>::iterator SLiter;                    
3936         wxString PropertyData;
3937         wxString PropertyName;
3938         wxString PropertyValue;
3939         wxString PropertyTokens;
3940         bool FirstToken = TRUE;
3941         int intSplitsFound = 0;
3942         int intSplitSize = 0;
3943         int intPrevValue = 7;
3944         
3945         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3946         
3947         intPrevValue = 6;
3948         
3949         PropertyType PropType = PROPERTY_NONE;
3950         
3951         // Look for type before continuing.                     
3953         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3955         intPrevValue = 6;
3956         bool PropertyMatched = FALSE;
3958         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3959         intiter != SplitPoints.end(); ++intiter){
3960         
3961                 SLiter = SplitLength.find(intiter->first);
3962                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3963                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3964                 intPrevValue = intiter->second;
3965                 
3966                 // Process properties.
3967                 
3968                 size_t intPropertyValueLen = PropertyValue.Len();
3969                 
3970                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3971                         
3972                         PropertyValue.Trim();
3973                         PropertyValue.RemoveLast();
3974                         
3975                 }                               
3976                 
3977                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3978                         
3979                         PropertyValue.Remove(0, 1);
3980                         
3981                 }                       
3982                 
3983                 CaptureString(&PropertyValue, FALSE);
3984                 
3985                 ProcessStringValue(&PropertyName, "ALTID", &SoundsListAltID, &PropertyValue, SoundCount, &PropertyMatched);
3986                 ProcessStringValue(&PropertyName, "PID", &SoundsListPID, &PropertyValue, SoundCount, &PropertyMatched);
3987                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SoundsListMediatype, &PropertyValue, SoundCount, &PropertyMatched);
3988                 ProcessStringValue(&PropertyName, "LANGUAGE", &SoundsListLanguage, &PropertyValue, SoundCount, &PropertyMatched);
3989                 ProcessIntegerValue(&PropertyName, "PREF", &SoundsListPref, &PropertyValue, SoundCount, &PropertyMatched);
3990                 
3991                 if (PropertyMatched == TRUE){
3992                 
3993                         PropertyMatched = FALSE;
3994                         continue;
3995                 
3996                 }
3998                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3999         
4000         }       
4001         
4002         intPropertyLen = PropertySeg2.Len();
4003         SplitPoints.clear();
4004         SplitLength.clear();
4005         intSplitsFound = 0;
4006         intSplitSize = 0;
4007         intPrevValue = 0;
4008         
4009         CaptureString(&PropertySeg2, FALSE);
4010         
4011         for (int i = 0; i <= intPropertyLen; i++){
4013                 intSplitSize++;
4014         
4015                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4016         
4017                         intSplitsFound++;
4018                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4019                         
4020                         if (intSplitsFound == 6){ 
4021                         
4022                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4023                                 break; 
4024                                 
4025                         } else {
4026                         
4027                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4028                         
4029                         }
4030                         
4031                         intSplitSize = 0;                                       
4032         
4033                 }
4035         }
4036         
4037         wxString wxSSoundURI;
4038         wxString wxSSoundMIME;
4039         wxString wxSSoundEncoding;
4040         wxString wxSSoundData;
4041         std::string base64enc;
4042         
4043         if (intSplitsFound == 0){
4044         
4045         } else {
4046         
4047                 std::map<int, int>::iterator striter;
4048         
4049                 striter = SplitLength.find(1);
4050         
4051                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4052         
4053                 while (wSTDataType.HasMoreTokens() == TRUE){
4054                 
4055                         wxSSoundURI = wSTDataType.GetNextToken();
4056                         wxSSoundMIME = wSTDataType.GetNextToken();
4057                         break;
4058                 
4059                 }                       
4060         
4061                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4062         
4063                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4064                 
4065                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4066                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4067                         base64enc = wxSSoundData.mb_str();
4068                         break;
4069                 
4070                 }
4071         
4072         }
4073         
4074         // Add the data to the General/Home/Work address variables.
4075                 
4076         switch(PropType){
4077                 case PROPERTY_NONE:
4078                         break;
4079                 case PROPERTY_HOME:
4080                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4081                         break;
4082                 case PROPERTY_WORK:
4083                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4084                         break;
4085         }
4086         
4087         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4088         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4089         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4090         
4091         if (!PropertyTokens.IsEmpty()){
4092         
4093                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4094         
4095         }
4096         
4099 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4101         // Process the calendar URI.
4102         
4103         size_t intPropertyLen = PropertySeg1.Len();
4104         std::map<int, int> SplitPoints;
4105         std::map<int, int> SplitLength;
4106         std::map<int, int>::iterator SLiter;                    
4107         wxString PropertyData;
4108         wxString PropertyName;
4109         wxString PropertyValue;
4110         wxString PropertyTokens;
4111         bool FirstToken = TRUE;
4112         int intPrevValue = 8;
4113         
4114         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4115         
4116         intPrevValue = 7;
4117         
4118         PropertyType PropType = PROPERTY_NONE;
4119         
4120         // Look for type before continuing.                     
4122         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4124         intPrevValue = 7;
4125         bool PropertyMatched = FALSE;
4127         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4128         intiter != SplitPoints.end(); ++intiter){
4129         
4130                 SLiter = SplitLength.find(intiter->first);
4131                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4132                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4133                 intPrevValue = intiter->second;
4134                 
4135                 // Process properties.
4136                 
4137                 size_t intPropertyValueLen = PropertyValue.Len();
4138                 
4139                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4140                         
4141                         PropertyValue.Trim();
4142                         PropertyValue.RemoveLast();
4143                         
4144                 }                               
4145                 
4146                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4147                         
4148                         PropertyValue.Remove(0, 1);
4149                         
4150                 }                       
4151                 
4152                 CaptureString(&PropertyValue, FALSE);
4153                 
4154                 ProcessStringValue(&PropertyName, "ALTID", &CalendarListAltID, &PropertyValue, CalURICount, &PropertyMatched);
4155                 ProcessStringValue(&PropertyName, "PID", &CalendarListPID, &PropertyValue, CalURICount, &PropertyMatched);
4156                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarListMediatype, &PropertyValue, CalURICount, &PropertyMatched);
4157                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarListPref, &PropertyValue, CalURICount, &PropertyMatched);
4158                 
4159                 if (PropertyMatched == TRUE){
4160                 
4161                         PropertyMatched = FALSE;
4162                         continue;
4163                 
4164                 }
4166                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4167         
4168         }       
4169         
4170         SplitPoints.clear();
4171         SplitLength.clear();
4172         intPrevValue = 0;
4173         
4174         CaptureString(&PropertySeg2, FALSE);
4175         
4176         // Add the data to the General/Home/Work address variables.
4177                 
4178         switch(PropType){
4179                 case PROPERTY_NONE:
4180                         break;
4181                 case PROPERTY_HOME:
4182                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4183                         break;
4184                 case PROPERTY_WORK:
4185                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4186                         break;
4187         }
4188         
4189         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4190         
4191         if (!PropertyTokens.IsEmpty()){
4192         
4193                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4194         
4195         }
4199 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4201         // Process the calendar address URI.
4203         std::map<int, int> SplitPoints;
4204         std::map<int, int> SplitLength;
4205         std::map<int, int>::iterator SLiter;                    
4206         wxString PropertyData;
4207         wxString PropertyName;
4208         wxString PropertyValue;
4209         wxString PropertyTokens;
4210         bool FirstToken = TRUE;
4211         int intPrevValue = 8;
4212         
4213         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4214         
4215         intPrevValue = 7;
4216         
4217         PropertyType PropType = PROPERTY_NONE;
4218         
4219         // Look for type before continuing.                     
4221         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4223         intPrevValue = 7;
4224         bool PropertyMatched = FALSE;
4226         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4227         intiter != SplitPoints.end(); ++intiter){
4228         
4229                 SLiter = SplitLength.find(intiter->first);
4230                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4231                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4232                 intPrevValue = intiter->second;
4233                 
4234                 // Process properties.
4235                 
4236                 size_t intPropertyValueLen = PropertyValue.Len();
4237                 
4238                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4239                         
4240                         PropertyValue.Trim();
4241                         PropertyValue.RemoveLast();
4242                         
4243                 }                               
4244                 
4245                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4246                         
4247                         PropertyValue.Remove(0, 1);
4248                         
4249                 }                       
4250                 
4251                 CaptureString(&PropertyValue, FALSE);
4252                 
4253                 ProcessStringValue(&PropertyName, "ALTID", &CalendarRequestListAltID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4254                 ProcessStringValue(&PropertyName, "PID", &CalendarRequestListPID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4255                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarRequestListMediatype, &PropertyValue, CalAdrURICount, &PropertyMatched);
4256                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarRequestListPref, &PropertyValue, CalAdrURICount, &PropertyMatched);
4257                 
4258                 if (PropertyMatched == TRUE){
4259                 
4260                         PropertyMatched = FALSE;
4261                         continue;
4262                 
4263                 }
4265                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4266         
4267         }       
4268         
4269         SplitPoints.clear();
4270         SplitLength.clear();
4271         intPrevValue = 0;
4272         
4273         CaptureString(&PropertySeg2, FALSE);
4274         
4275         // Add the data to the General/Home/Work address variables.
4276                 
4277         switch(PropType){
4278                 case PROPERTY_NONE:
4279                         break;
4280                 case PROPERTY_HOME:
4281                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4282                         break;
4283                 case PROPERTY_WORK:
4284                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4285                         break;
4286         }
4287         
4288         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4289         
4290         if (!PropertyTokens.IsEmpty()){
4291         
4292                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4293         
4294         }       
4295         
4298 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4300         // Process the calendar free busy URL.
4301         
4302         size_t intPropertyLen = PropertySeg1.Len();
4303         std::map<int, int> SplitPoints;
4304         std::map<int, int> SplitLength;
4305         std::map<int, int>::iterator SLiter;                    
4306         wxString PropertyData;
4307         wxString PropertyName;
4308         wxString PropertyValue;
4309         wxString PropertyTokens;
4310         bool FirstToken = TRUE;
4311         int intPrevValue = 7;
4312         
4313         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4314         
4315         intPrevValue = 6;
4316         
4317         PropertyType PropType = PROPERTY_NONE;
4318         
4319         // Look for type before continuing.                     
4321         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4323         intPrevValue = 6;
4324         bool PropertyMatched = FALSE;
4326         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4327         intiter != SplitPoints.end(); ++intiter){
4328         
4329                 SLiter = SplitLength.find(intiter->first);
4330                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4331                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4332                 intPrevValue = intiter->second;
4333                 
4334                 // Process properties.
4335                 
4336                 size_t intPropertyValueLen = PropertyValue.Len();
4337                 
4338                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4339                         
4340                         PropertyValue.Trim();
4341                         PropertyValue.RemoveLast();
4342                         
4343                 }                               
4344                 
4345                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4346                         
4347                         PropertyValue.Remove(0, 1);
4348                         
4349                 }                       
4350                 
4351                 CaptureString(&PropertyValue, FALSE);
4352                 
4353                 ProcessStringValue(&PropertyName, "ALTID", &FreeBusyListAltID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4354                 ProcessStringValue(&PropertyName, "PID", &FreeBusyListPID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4355                 ProcessStringValue(&PropertyName, "MEDIATYPE", &FreeBusyListMediatype, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4356                 ProcessIntegerValue(&PropertyName, "PREF", &FreeBusyListPref, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4357                 
4358                 if (PropertyMatched == TRUE){
4359                 
4360                         PropertyMatched = FALSE;
4361                         continue;
4362                 
4363                 }
4365                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4366         
4367         }       
4368         
4369         intPropertyLen = PropertySeg2.Len();
4370         SplitPoints.clear();
4371         SplitLength.clear();
4372         intPrevValue = 0;
4373         
4374         CaptureString(&PropertySeg2, FALSE);
4375         
4376         // Add the data to the General/Home/Work address variables.
4377                 
4378         switch(PropType){
4379                 case PROPERTY_NONE:
4380                         break;
4381                 case PROPERTY_HOME:
4382                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
4383                         break;
4384                 case PROPERTY_WORK:
4385                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
4386                         break;
4387         }
4388         
4389         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
4390         
4391         if (!PropertyTokens.IsEmpty()){
4392         
4393                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
4394         
4395         }
4399 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
4401         // Process the key.
4403         std::map<int, int> SplitPoints;
4404         std::map<int, int> SplitLength;
4405         std::map<int, int>::iterator SLiter;                    
4406         wxString PropertyData;
4407         wxString PropertyName;
4408         wxString PropertyValue;
4409         wxString PropertyTokens;
4410         bool FirstToken = TRUE;
4411         int intSplitsFound = 0;
4412         int intSplitSize = 0;
4413         int intPrevValue = 5;
4414         
4415         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4416         
4417         intPrevValue = 4;
4418         
4419         PropertyType PropType = PROPERTY_NONE;
4420         
4421         // Look for type before continuing.
4423         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4425         intPrevValue = 4;
4426         bool PropertyMatched = FALSE;
4428         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4429         intiter != SplitPoints.end(); ++intiter){
4430         
4431                 SLiter = SplitLength.find(intiter->first);
4432                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4433                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4434                 intPrevValue = intiter->second;
4435                 
4436                 // Process properties.
4437                 
4438                 size_t intPropertyValueLen = PropertyValue.Len();
4439                 
4440                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4441                         
4442                         PropertyValue.Trim();
4443                         PropertyValue.RemoveLast();
4444                         
4445                 }                               
4446                 
4447                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4448                         
4449                         PropertyValue.Remove(0, 1);
4450                         
4451                 }
4452                 
4453                 ProcessStringValue(&PropertyName, "ALTID", &KeyListAltID, &PropertyValue, KeyCount, &PropertyMatched);
4454                 ProcessStringValue(&PropertyName, "PID", &KeyListPID, &PropertyValue, KeyCount, &PropertyMatched);
4455                 ProcessIntegerValue(&PropertyName, "PREF", &KeyListPref, &PropertyValue, KeyCount, &PropertyMatched);
4456                 
4457                 if (PropertyMatched == TRUE){
4458                 
4459                         PropertyMatched = FALSE;
4460                         continue;
4461                 
4462                 }
4464                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4465         
4466         }                               
4467         
4468         size_t intPropertyLen = PropertySeg2.Len();
4469         SplitPoints.clear();
4470         SplitLength.clear();
4471         intSplitsFound = 0;
4472         intSplitSize = 0;
4473         intPrevValue = 0;                       
4474         
4475         for (int i = 0; i <= intPropertyLen; i++){
4477                 intSplitSize++;
4478         
4479                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4480         
4481                         intSplitsFound++;
4482                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4483                         
4484                         if (intSplitsFound == 6){ 
4485                         
4486                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4487                                 break; 
4488                                 
4489                         } else {
4490                         
4491                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4492                         
4493                         }
4494                         
4495                         intSplitSize = 0;                                       
4496         
4497                 }
4499         }
4500         
4501         wxString wxSKeyURI;
4502         wxString wxSKeyMIME;
4503         wxString wxSKeyEncoding;
4504         wxString wxSKeyData;
4505         std::string base64enc;
4506         
4507         if (intSplitsFound == 0){
4508         
4509         } else {
4510         
4511                 std::map<int, int>::iterator striter;
4512         
4513                 striter = SplitLength.find(1);
4514         
4515                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4516         
4517                 while (wSTDataType.HasMoreTokens() == TRUE){
4518                 
4519                         wxSKeyURI = wSTDataType.GetNextToken();
4520                         wxSKeyMIME = wSTDataType.GetNextToken();
4521                         break;
4522                 
4523                 }                       
4524         
4525                 if (wxSKeyURI == wxT("data")){
4526                 
4527                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4528         
4529                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4530                 
4531                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
4532                                 wxSKeyData = wSTDataInfo.GetNextToken();
4533                                 break;
4534                 
4535                         }
4536                 
4537                 }
4538         
4539         }
4540         
4541         // Add the data to the General/Home/Work address variables.
4542         
4543         if (wxSKeyURI == wxT("data")){
4544                 
4545                 KeyListDataEncType.erase(*KeyCount);
4546                 KeyListKeyType.erase(*KeyCount);
4547                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
4548                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
4549                 
4550                 KeyList.erase(*KeyCount);
4551                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
4552         
4553         } else {
4554                 
4555                 KeyList.erase(*KeyCount);
4556                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
4557         
4558         }
4559         
4560         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
4561                 
4562         switch (PropType){
4563                 case PROPERTY_NONE:
4564                         break;
4565                 case PROPERTY_HOME: 
4566                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
4567                         break;
4568                 case PROPERTY_WORK: 
4569                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
4570                         break;
4571         }
4573         if (!PropertyTokens.IsEmpty()){
4575                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
4577         }
4581 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
4583         // Process the vendor information.
4584         
4585         // Split the Vendor three ways.
4586         
4587         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
4588         
4589         wxString wxSVNDID;
4590         wxString wxSVNDPropName;
4592         while (wSTVendorDetails.HasMoreTokens() == TRUE){
4593         
4594                 wSTVendorDetails.GetNextToken();
4595                 wxSVNDID = wSTVendorDetails.GetNextToken();
4596                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
4597                 break;
4598         
4599         }
4600         
4601         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
4602         
4603                 // Add the data to the vendor variables.
4604         
4605                 VendorList.erase(*VendorCount);
4606                 VendorListPEN.erase(*VendorCount);
4607                 VendorListElement.erase(*VendorCount);
4608         
4609                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
4610                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
4611                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
4612         
4613         }
4617 void ContactDataObject::ClearData(){
4619         // Clear the contact information.
4621         NameTitle.clear();
4622         NameForename.clear();
4623         NameSurname.clear();
4624         NameOtherNames.clear();
4625         NameSuffix.clear();
4626         NameNickname.clear();
4627         NameDisplayAs.clear();
4628         NameLanguage.clear();
4629         NameAltID.clear();
4630         NameTokens.clear();
4632         Birthday.clear();
4633         BirthdayAltID.clear();
4634         BirthdayCalScale.clear();
4635         BirthdayTokens.clear();
4636         Anniversary.clear();
4637         AnniversaryAltID.clear();
4638         AnniversaryCalScale.clear();
4639         AnniversaryTokens.clear();
4641         Gender.clear();
4642         GenderDetails.clear();
4643         GenderTokens.clear();
4645         UIDToken.clear();
4646         Revision.clear();
4647         RevisionTokens.clear();
4649         SourceList.clear();
4650         SourceListAltID.clear();
4651         SourceListPID.clear();
4652         SourceListType.clear();
4653         SourceListTokens.clear();
4654         SourceListMediatype.clear();
4655         SourceListPref.clear();
4657         XMLList.clear();
4658         XMLListAltID.clear();
4660         ClientPIDList.clear();
4661         ClientPIDListTokens.clear();
4663         FullNamesList.clear();    
4664         FullNamesListType.clear();
4665         FullNamesListLanguage.clear();
4666         FullNamesListAltID.clear();
4667         FullNamesListPID.clear();
4668         FullNamesListTokens.clear();
4669         FullNamesListPref.clear();
4671         GeneralNicknamesList.clear();
4672         GeneralNicknamesListType.clear();
4673         GeneralNicknamesListLanguage.clear();
4674         GeneralNicknamesListAltID.clear();
4675         GeneralNicknamesListPID.clear();
4676         GeneralNicknamesListTokens.clear();        
4677         GeneralNicknamesListPref.clear();        
4679         GeneralAddressList.clear();
4680         GeneralAddressListTown.clear();
4681         GeneralAddressListCounty.clear();
4682         GeneralAddressListPostCode.clear();
4683         GeneralAddressListCountry.clear();
4684         GeneralAddressListLabel.clear();
4685         GeneralAddressListLang.clear();        
4686         GeneralAddressListAltID.clear();
4687         GeneralAddressListPID.clear();
4688         GeneralAddressListTokens.clear();
4689         GeneralAddressListGeo.clear();
4690         GeneralAddressListTimezone.clear();        
4691         GeneralAddressListType.clear();
4692         GeneralAddressListMediatype.clear();
4693         GeneralAddressListPref.clear();
4695         GeneralEmailList.clear();
4696         GeneralEmailListAltID.clear();
4697         GeneralEmailListPID.clear();
4698         GeneralEmailListType.clear();
4699         GeneralEmailListTokens.clear();
4700         GeneralEmailListPref.clear();
4702         GeneralIMList.clear();
4703         GeneralIMListAltID.clear();
4704         GeneralIMListPID.clear();
4705         GeneralIMListType.clear();
4706         GeneralIMListTypeInfo.clear();
4707         GeneralIMListTokens.clear();
4708         GeneralIMListMediatype.clear();
4709         GeneralIMListPref.clear();
4711         GeneralTelephoneList.clear();
4712         GeneralTelephoneListAltID.clear();
4713         GeneralTelephoneListPID.clear();
4714         GeneralTelephoneListType.clear();
4715         GeneralTelephoneListTokens.clear();
4716         GeneralTelephoneListTypeInfo.clear();
4717         GeneralTelephoneListPref.clear();
4719         GeneralLanguageList.clear();
4720         GeneralLanguageListAltID.clear();
4721         GeneralLanguageListPID.clear();
4722         GeneralLanguageListType.clear();
4723         GeneralLanguageListTokens.clear();
4724         GeneralLanguageListPref.clear();
4726         GeneralTZList.clear();
4727         GeneralTZListAltID.clear();
4728         GeneralTZListPID.clear();
4729         GeneralTZListType.clear();
4730         GeneralTZListTokens.clear();
4731         GeneralTZListMediatype.clear();
4732         GeneralTZListPref.clear();
4734         GeneralGeographyList.clear();
4735         GeneralGeographyListAltID.clear();
4736         GeneralGeographyListPID.clear();
4737         GeneralGeographyListType.clear();
4738         GeneralGeographyListTokens.clear();
4739         GeneralGeographyListMediatype.clear();
4740         GeneralGeographyListPref.clear();
4742         GeneralRelatedList.clear();
4743         GeneralRelatedListRelType.clear();
4744         GeneralRelatedListLanguage.clear();
4745         GeneralRelatedListAltID.clear();
4746         GeneralRelatedListPID.clear();
4747         GeneralRelatedListType.clear();
4748         GeneralRelatedListTokens.clear();
4749         GeneralRelatedListPref.clear();
4751         GeneralWebsiteList.clear();
4752         GeneralWebsiteListAltID.clear();
4753         GeneralWebsiteListPID.clear();
4754         GeneralWebsiteListType.clear();
4755         GeneralWebsiteListTokens.clear();
4756         GeneralWebsiteListMediatype.clear();
4757         GeneralWebsiteListPref.clear();
4759         GeneralTitleList.clear();
4760         GeneralTitleListLanguage.clear();        
4761         GeneralTitleListAltID.clear();
4762         GeneralTitleListPID.clear();
4763         GeneralTitleListType.clear();
4764         GeneralTitleListTokens.clear();
4765         GeneralTitleListPref.clear();
4767         GeneralRoleList.clear();
4768         GeneralRoleListLanguage.clear();        
4769         GeneralRoleListAltID.clear();
4770         GeneralRoleListPID.clear();
4771         GeneralRoleListType.clear();
4772         GeneralRoleListTokens.clear();
4773         GeneralRoleListPref.clear();
4775         GeneralOrganisationsList.clear();
4776         GeneralOrganisationsListLanguage.clear();        
4777         GeneralOrganisationsListAltID.clear();
4778         GeneralOrganisationsListPID.clear();
4779         GeneralOrganisationsListType.clear();
4780         GeneralOrganisationsListTokens.clear();
4781         GeneralOrganisationsListSortAs.clear();
4782         GeneralOrganisationsListPref.clear();
4784         GeneralNoteList.clear();
4785         GeneralNoteListLanguage.clear();        
4786         GeneralNoteListAltID.clear();
4787         GeneralNoteListPID.clear();
4788         GeneralNoteListType.clear();
4789         GeneralNoteListTokens.clear();
4790         GeneralNoteListPref.clear();
4792         /* Items on Home Tab */        
4794         HomeNicknamesList.clear();
4795         HomeNicknamesListType.clear();
4796         HomeNicknamesListLanguage.clear();
4797         HomeNicknamesListAltID.clear();
4798         HomeNicknamesListPID.clear();
4799         HomeNicknamesListTokens.clear();        
4800         HomeNicknamesListPref.clear();        
4802         HomeAddressList.clear();
4803         HomeAddressListTown.clear();
4804         HomeAddressListCounty.clear();
4805         HomeAddressListPostCode.clear();
4806         HomeAddressListCountry.clear();
4807         HomeAddressListLabel.clear();
4808         HomeAddressListLang.clear();        
4809         HomeAddressListAltID.clear();
4810         HomeAddressListPID.clear();
4811         HomeAddressListTokens.clear();
4812         HomeAddressListGeo.clear();
4813         HomeAddressListTimezone.clear();        
4814         HomeAddressListType.clear();
4815         HomeAddressListMediatype.clear();
4816         HomeAddressListPref.clear();
4818         HomeEmailList.clear();
4819         HomeEmailListAltID.clear();
4820         HomeEmailListPID.clear();
4821         HomeEmailListType.clear();
4822         HomeEmailListTokens.clear();
4823         HomeEmailListPref.clear();
4825         HomeIMList.clear();
4826         HomeIMListAltID.clear();
4827         HomeIMListPID.clear();
4828         HomeIMListType.clear();
4829         HomeIMListTypeInfo.clear();
4830         HomeIMListTokens.clear();
4831         HomeIMListMediatype.clear();
4832         HomeIMListPref.clear();
4834         HomeTelephoneList.clear();
4835         HomeTelephoneListAltID.clear();
4836         HomeTelephoneListPID.clear();
4837         HomeTelephoneListType.clear();
4838         HomeTelephoneListTokens.clear();
4839         HomeTelephoneListTypeInfo.clear();
4840         HomeTelephoneListPref.clear();
4842         HomeLanguageList.clear();
4843         HomeLanguageListAltID.clear();
4844         HomeLanguageListPID.clear();
4845         HomeLanguageListType.clear();
4846         HomeLanguageListTokens.clear();
4847         HomeLanguageListPref.clear();
4849         HomeTZList.clear();
4850         HomeTZListAltID.clear();
4851         HomeTZListPID.clear();
4852         HomeTZListType.clear();
4853         HomeTZListTokens.clear();
4854         HomeTZListMediatype.clear();
4855         HomeTZListPref.clear();
4857         HomeGeographyList.clear();
4858         HomeGeographyListAltID.clear();
4859         HomeGeographyListPID.clear();
4860         HomeGeographyListType.clear();
4861         HomeGeographyListTokens.clear();
4862         HomeGeographyListMediatype.clear();
4863         HomeGeographyListPref.clear();       
4865         HomeWebsiteList.clear();
4866         HomeWebsiteListAltID.clear();
4867         HomeWebsiteListPID.clear();
4868         HomeWebsiteListType.clear();
4869         HomeWebsiteListTokens.clear();
4870         HomeWebsiteListMediatype.clear();
4871         HomeWebsiteListPref.clear();
4873         HomeTitleList.clear();
4874         HomeTitleListLanguage.clear();
4875         HomeTitleListAltID.clear();
4876         HomeTitleListPID.clear();
4877         HomeTitleListType.clear();
4878         HomeTitleListTokens.clear();
4879         HomeTitleListPref.clear();
4881         HomeRoleList.clear();
4882         HomeRoleListLanguage.clear();        
4883         HomeRoleListAltID.clear();
4884         HomeRoleListPID.clear();
4885         HomeRoleListType.clear();
4886         HomeRoleListTokens.clear();
4887         HomeRoleListPref.clear();
4889         HomeOrganisationsList.clear();
4890         HomeOrganisationsListLanguage.clear();        
4891         HomeOrganisationsListAltID.clear();
4892         HomeOrganisationsListPID.clear();
4893         HomeOrganisationsListType.clear();
4894         HomeOrganisationsListTokens.clear();
4895         HomeOrganisationsListSortAs.clear();
4896         HomeOrganisationsListPref.clear();
4898         HomeNoteList.clear();
4899         HomeNoteListLanguage.clear();        
4900         HomeNoteListAltID.clear();
4901         HomeNoteListPID.clear();
4902         HomeNoteListType.clear();
4903         HomeNoteListTokens.clear();
4904         HomeNoteListPref.clear();        
4906         /* Items on the Business tab */
4908         BusinessNicknamesList.clear();
4909         BusinessNicknamesListType.clear();
4910         BusinessNicknamesListLanguage.clear();
4911         BusinessNicknamesListAltID.clear();
4912         BusinessNicknamesListPID.clear();
4913         BusinessNicknamesListTokens.clear();        
4914         BusinessNicknamesListPref.clear();        
4916         BusinessAddressList.clear();
4917         BusinessAddressListTown.clear();
4918         BusinessAddressListCounty.clear();
4919         BusinessAddressListPostCode.clear();
4920         BusinessAddressListCountry.clear();
4921         BusinessAddressListLabel.clear();
4922         BusinessAddressListLang.clear();        
4923         BusinessAddressListAltID.clear();
4924         BusinessAddressListPID.clear();
4925         BusinessAddressListTokens.clear();
4926         BusinessAddressListGeo.clear();
4927         BusinessAddressListTimezone.clear();        
4928         BusinessAddressListType.clear();
4929         BusinessAddressListMediatype.clear();
4930         BusinessAddressListPref.clear();
4932         BusinessEmailList.clear();
4933         BusinessEmailListAltID.clear();
4934         BusinessEmailListPID.clear();
4935         BusinessEmailListType.clear();
4936         BusinessEmailListTokens.clear();
4937         BusinessEmailListPref.clear();
4939         BusinessIMList.clear();
4940         BusinessIMListAltID.clear();
4941         BusinessIMListPID.clear();
4942         BusinessIMListType.clear();
4943         BusinessIMListTokens.clear();
4944         BusinessIMListMediatype.clear();
4945         BusinessIMListPref.clear();
4947         BusinessTelephoneList.clear();
4948         BusinessTelephoneListAltID.clear();
4949         BusinessTelephoneListPID.clear();
4950         BusinessTelephoneListType.clear();
4951         BusinessTelephoneListTokens.clear();
4952         BusinessTelephoneListPref.clear();
4954         BusinessLanguageList.clear();
4955         BusinessLanguageListAltID.clear();
4956         BusinessLanguageListPID.clear();
4957         BusinessLanguageListType.clear();
4958         BusinessLanguageListTokens.clear();
4959         BusinessLanguageListPref.clear();
4961         BusinessTZList.clear();
4962         BusinessTZListAltID.clear();
4963         BusinessTZListPID.clear();
4964         BusinessTZListType.clear();
4965         BusinessTZListTokens.clear();
4966         BusinessTZListMediatype.clear();
4967         BusinessTZListPref.clear();
4969         BusinessGeographyList.clear();
4970         BusinessGeographyListAltID.clear();
4971         BusinessGeographyListPID.clear();
4972         BusinessGeographyListType.clear();
4973         BusinessGeographyListTokens.clear();
4974         BusinessGeographyListMediatype.clear();
4975         BusinessGeographyListPref.clear();          
4977         BusinessWebsiteList.clear();
4978         BusinessWebsiteListAltID.clear();
4979         BusinessWebsiteListPID.clear();
4980         BusinessWebsiteListType.clear();
4981         BusinessWebsiteListTokens.clear();
4982         BusinessWebsiteListMediatype.clear();
4983         BusinessWebsiteListPref.clear();
4985         BusinessTitleList.clear();
4986         BusinessTitleListLanguage.clear();        
4987         BusinessTitleListAltID.clear();
4988         BusinessTitleListPID.clear();
4989         BusinessTitleListType.clear();
4990         BusinessTitleListTokens.clear();
4991         BusinessTitleListPref.clear();
4993         BusinessRoleList.clear();
4994         BusinessRoleListLanguage.clear();        
4995         BusinessRoleListAltID.clear();
4996         BusinessRoleListPID.clear();
4997         BusinessRoleListType.clear();
4998         BusinessRoleListTokens.clear();
4999         BusinessRoleListPref.clear();
5001         BusinessOrganisationsList.clear();
5002         BusinessOrganisationsListLanguage.clear();        
5003         BusinessOrganisationsListAltID.clear();
5004         BusinessOrganisationsListPID.clear();
5005         BusinessOrganisationsListType.clear();
5006         BusinessOrganisationsListTokens.clear();
5007         BusinessOrganisationsListSortAs.clear();        
5008         BusinessOrganisationsListPref.clear();
5010         BusinessNoteList.clear();
5011         BusinessNoteListLanguage.clear();        
5012         BusinessNoteListAltID.clear();
5013         BusinessNoteListPID.clear();
5014         BusinessNoteListType.clear();
5015         BusinessNoteListTokens.clear();
5016         BusinessNoteListPref.clear();        
5018         /* Items on the Categories tab */
5020         CategoriesList.clear();
5021         CategoriesListAltID.clear();
5022         CategoriesListPID.clear();
5023         CategoriesListType.clear();
5024         CategoriesListTokens.clear();
5025         CategoriesListLanguage.clear();
5026         CategoriesListPref.clear();    
5028         /* Items on the Groups tab */
5030         GroupsList.clear();
5031         GroupsListAltID.clear();
5032         GroupsListPID.clear();
5033         GroupsListType.clear();
5034         GroupsListMediaType.clear();
5035         GroupsListTokens.clear();
5036         GroupsListPref.clear();
5038         /* Items on the Pictures tab */
5040         PicturesList.clear();
5041         PicturesListAltID.clear();
5042         PicturesListPID.clear();
5043         PicturesListType.clear();
5044         PicturesListPicEncType.clear();
5045         PicturesListPictureType.clear();
5046         PicturesListTokens.clear();
5047         PicturesListMediatype.clear();        
5048         PicturesListPref.clear();
5050         /* Items on the Logos tab */
5052         LogosList.clear();
5053         LogosListAltID.clear();
5054         LogosListPID.clear();
5055         LogosListType.clear();
5056         LogosListPicEncType.clear();        
5057         LogosListPictureType.clear();
5058         LogosListTokens.clear();
5059         LogosListMediatype.clear();        
5060         LogosListPref.clear();
5062         /* Items on the Sounds tab */
5064         SoundsList.clear();
5065         SoundsListAltID.clear();
5066         SoundsListPID.clear();
5067         SoundsListType.clear();
5068         SoundsListAudioEncType.clear();        
5069         SoundsListAudioType.clear();        
5070         SoundsListTokens.clear();
5071         SoundsListMediatype.clear();        
5072         SoundsListPref.clear();    
5074         /* Items on the Calendaring tab */
5076         CalendarList.clear();
5077         CalendarListAltID.clear();
5078         CalendarListPID.clear();
5079         CalendarListType.clear();
5080         CalendarListTokens.clear();
5081         CalendarListMediatype.clear();        
5082         CalendarListPref.clear();
5084         CalendarRequestList.clear();
5085         CalendarRequestListAltID.clear();
5086         CalendarRequestListPID.clear();
5087         CalendarRequestListType.clear();
5088         CalendarRequestListTokens.clear();
5089         CalendarRequestListMediatype.clear();        
5090         CalendarRequestListPref.clear();        
5092         FreeBusyList.clear();
5093         FreeBusyListAltID.clear();
5094         FreeBusyListPID.clear();
5095         FreeBusyListType.clear();
5096         FreeBusyListTokens.clear();
5097         FreeBusyListMediatype.clear();        
5098         FreeBusyListPref.clear();
5100         /* Items on the Security tab */
5102         KeyList.clear();
5103         KeyListAltID.clear();
5104         KeyListPID.clear();
5105         KeyListKeyType.clear();        
5106         KeyListDataType.clear();        
5107         KeyListDataEncType.clear();
5108         KeyListType.clear();
5109         KeyListTokens.clear();
5110         KeyListPref.clear();
5112         /* Items on the Other tab */
5114         VendorList.clear();
5115         VendorListPEN.clear();
5116         VendorListElement.clear();
5118         XTokenList.clear();
5119         XTokenListTokens.clear();
5123 void ProcessNameValue(wxString *PropertyData, 
5124         wxString *PropertyName, 
5125         wxString *PropertyValue){
5127         // Proces the name and value information.
5128                 
5129         wxStringTokenizer PropertyElement (*PropertyData, wxT("="));
5130         *PropertyName = PropertyElement.GetNextToken();                         
5131         *PropertyValue = PropertyElement.GetNextToken();
5135 void ProcessTokens(wxString *PropertyName,
5136         wxString *PropertyValue,
5137         wxString *PropertyTokens,
5138         bool *FirstToken){
5139         
5140         // Process the tokens.
5141                 
5142         if (!PropertyName->IsEmpty() && !PropertyValue->IsEmpty() && *PropertyName != wxT("TYPE")){
5143                 
5144                 if (*FirstToken == TRUE){
5145                         
5146                         PropertyTokens->Append(*PropertyName + wxT("=") + *PropertyValue);
5147                         *FirstToken = FALSE;
5148                         
5149                 } else {
5150                         
5151                         PropertyTokens->Append(wxT(";") + *PropertyName + wxT("=") + *PropertyValue);
5152                         
5153                 }
5154                 
5155         }
5156         
5159 void ProcessStringValue(wxString *PropertyName,
5160         wxString PropertyNameMatch,
5161         std::map<int,wxString> *MapPtr,
5162         wxString *PropertyValue,
5163         int *ItemCount,
5164         bool *PropertyMatched){
5165         
5166         // Process the string value.
5167                 
5168         if (*PropertyName == PropertyNameMatch){
5169                 MapPtr->erase(*ItemCount);
5170                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5171                 *PropertyMatched = TRUE;
5172         }
5173         
5176 void ProcessIntegerValue(wxString *PropertyName,
5177         wxString PropertyNameMatch,
5178         std::map<int,int> *PrefPtr, 
5179         wxString *PropertyValue, 
5180         int *ItemCount,
5181         bool *PropertyMatched){
5183         // Process the integer value.
5184                 
5185         if (*PropertyName == PropertyNameMatch){
5186                 *PropertyMatched = TRUE;
5187         } else {
5188                 return;
5189         }
5191         int PriorityNumber = 0; 
5192         bool ValidNumber = TRUE;
5193                         
5194         try{
5195                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5196         }
5197                         
5198         catch(std::invalid_argument &e){
5199                 ValidNumber = FALSE;
5200         }
5202         if (ValidNumber == TRUE){
5204                 PrefPtr->erase(*ItemCount);
5205                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5207         }
5211 void SplitValues(wxString *PropertyLine, 
5212         std::map<int,int> *SplitPoints, 
5213         std::map<int,int> *SplitLength, 
5214         int intSize){
5215                 
5216         // Split values from a string supplied by PropertyLine.
5217                 
5218         size_t intPropertyLen = PropertyLine->Len();
5219         int intSplitsFound = 0;
5220         int intSplitSize = 0;
5221         int intSplitSeek = 0;
5222         
5223         for (int i = intSize; i <= intPropertyLen; i++){
5225                 intSplitSize++;
5226         
5227                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5228                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5229            
5230                     if (intSplitsFound == 0){
5231             
5232                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5233           
5234                     } else {
5235            
5236                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5237             
5238                     }
5239             
5240                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5241             
5242                     intSplitsFound++;
5243                     intSplitSeek = i;
5244                     intSplitSize = 0;
5245             
5246                 }
5248         }
5250         if (intSplitsFound == 0){
5252                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5253                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5255         } else {
5257                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5258                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5260         }
5264 void CheckType(wxString *PropertySeg1, 
5265         std::map<int,int> *SplitPoints, 
5266         std::map<int,int> *SplitLength, 
5267         int *intPrevValue, 
5268         PropertyType *PropType){
5269         
5270         // Check the information type.
5271                 
5272         wxString PropertyData;
5273         wxString PropertyName;
5274         wxString PropertyValue;
5275         std::map<int,int>::iterator SLiter;
5276         
5277         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5278         intiter != SplitPoints->end(); ++intiter){
5279         
5280                 SLiter = SplitLength->find(intiter->first);     
5281                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5282                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);         
5283                 *intPrevValue = intiter->second;
5284                 
5285                 if (PropertyName == wxT("TYPE")){
5286                                 
5287                         if (PropertyValue == wxT("work")){
5288                         
5289                                 *PropType = PROPERTY_WORK;
5290                                                         
5291                         } else if (PropertyValue == wxT("home")){
5293                                 *PropType = PROPERTY_HOME;
5294                                                         
5295                         } else {
5296                         
5297                                 *PropType = PROPERTY_NONE;
5298                         
5299                         }
5300                 
5301                         return;
5302                 
5303                 }
5304         
5305         }
5306         
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