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