Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
667c8df28b4bcaec9f12bb3eaac4bd0c5e5a84c5
[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                 
2086                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2087                         typeiter != TypeSplitPoints.end(); ++typeiter){
2088                                                 
2089                                 wxString TypePropertyName;
2090                                 
2091                                 TSLiter = TypeSplitLength.find(typeiter->first);
2092                                 
2093                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2094                                 
2095                                 if (intTypeSeek == 0){
2096                                 
2097                                 
2098                                 } else {
2099                                                                                 
2100                                         TelTypeUI.Append(wxT(","));                                                     
2101                                 
2102                                 }
2104                                 if (TypePropertyName == wxT("home")){
2105                                 
2106                                         PropType = PROPERTY_HOME;
2107                                 
2108                                 } else if (TypePropertyName == wxT("work")){
2109                                 
2110                                         PropType = PROPERTY_WORK;
2111                                                                         
2112                                 }
2113                                 
2114                                 
2115                                 if (TypePropertyName == wxT("text")){
2116                                 
2117                                         TelTypeUI.Append(_("text"));
2118                                         intTypeSeek++;
2119                                 
2120                                 } else if (TypePropertyName == wxT("voice")){
2121                                 
2122                                         TelTypeUI.Append(_("voice"));
2123                                         intTypeSeek++;
2124                                 
2125                                 } else if (TypePropertyName == wxT("fax")){
2126                                 
2127                                         TelTypeUI.Append(_("fax"));
2128                                         intTypeSeek++;
2129                                 
2130                                 } else if (TypePropertyName == wxT("cell")){
2131                                 
2132                                         TelTypeUI.Append(_("cell"));
2133                                         intTypeSeek++;
2134                                 
2135                                 } else if (TypePropertyName == wxT("video")){
2136                                 
2137                                         TelTypeUI.Append(_("video"));
2138                                         intTypeSeek++;
2139                                 
2140                                 } else if (TypePropertyName == wxT("pager")){
2141                                 
2142                                         TelTypeUI.Append(_("pager"));
2143                                         intTypeSeek++;
2144                                 
2145                                 } else if (TypePropertyName == wxT("textphone")){
2146                                 
2147                                         TelTypeUI.Append(_("textphone"));
2148                                         intTypeSeek++;
2149                                 
2150                                 }
2151                         
2152                         }
2153                 
2154                 }
2155                 
2156         }
2157         
2158         std::map<int, wxString> *TelephoneList = NULL;
2159         std::map<int, wxString> *TelephoneListType = NULL;
2160         std::map<int, wxString> *TelephoneListAltID = NULL;
2161         std::map<int, wxString> *TelephoneListPID = NULL;
2162         std::map<int, wxString> *TelephoneListTokens = NULL;
2163         std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2164         std::map<int, wxString> *TelephoneListDataType = NULL;
2165         std::map<int, int> *TelephoneListPref = NULL;
2167         switch(PropType){
2168                 case PROPERTY_NONE:
2169                         TelephoneList = &GeneralTelephoneList;
2170                         TelephoneListType = &GeneralTelephoneListType;
2171                         TelephoneListAltID = &GeneralTelephoneListAltID;
2172                         TelephoneListPID = &GeneralTelephoneListPID;
2173                         TelephoneListTokens = &GeneralTelephoneListTokens;
2174                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2175                         TelephoneListDataType = &GeneralTelephoneListDataType;
2176                         TelephoneListPref = &GeneralTelephoneListPref;  
2177                         break;
2178                 case PROPERTY_HOME:
2179                         TelephoneList = &HomeTelephoneList;
2180                         TelephoneListType = &HomeTelephoneListType;
2181                         TelephoneListAltID = &HomeTelephoneListAltID;
2182                         TelephoneListPID = &HomeTelephoneListPID;
2183                         TelephoneListTokens = &HomeTelephoneListTokens;
2184                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2185                         TelephoneListDataType = &HomeTelephoneListDataType;
2186                         TelephoneListPref = &HomeTelephoneListPref;     
2187                         break;
2188                 case PROPERTY_WORK:
2189                         TelephoneList = &BusinessTelephoneList;
2190                         TelephoneListType = &BusinessTelephoneListType;
2191                         TelephoneListAltID = &BusinessTelephoneListAltID;
2192                         TelephoneListPID = &BusinessTelephoneListPID;
2193                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2194                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2195                         TelephoneListDataType = &BusinessTelephoneListDataType;
2196                         TelephoneListPref = &BusinessTelephoneListPref; 
2197                         break;
2198         }
2199                 
2200         // Process the properties.
2201         
2202         bool FirstToken = TRUE;
2203         
2204         intPrevValue = 5;
2205         SplitPoints.clear();
2206         SplitLength.clear();
2208         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2210         intPrevValue = 4;
2211         
2212         bool PropertyMatched = FALSE;
2213         
2214         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2215         intiter != SplitPoints.end(); ++intiter){
2216         
2217                 SLiter = SplitLength.find(intiter->first);
2218                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2219                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2220                 intPrevValue = intiter->second;
2221                 
2222                 CaptureString(&PropertyValue, FALSE);
2223                 
2224                 // Process properties.
2225                 
2226                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2227                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2228                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2229                 
2230                 if (PropertyMatched == TRUE){
2231                 
2232                         PropertyMatched = FALSE;
2233                         continue;
2234                 
2235                 }
2237                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2238         
2239         }
2240                 
2241         // Check for the type information and split it down.
2242         
2243         wxStringTokenizer TelSplitData(PropertySeg2, wxT(":"));
2244                 
2245         if (TelSplitData.CountTokens() > 1){
2247                 TelephoneListDataType->insert(std::make_pair(*TelephoneCount, TelSplitData.GetNextToken()));                    
2248                 TelephoneList->insert(std::make_pair(*TelephoneCount, TelSplitData.GetString()));
2249         
2250         } else {
2251         
2252                 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2253                 TelephoneListDataType->insert(std::make_pair(*TelephoneCount, "tel"));
2254         
2255         }
2256                 
2257         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2258                 
2259         // Add the name token data.
2260         
2261         if (!PropertyTokens.IsEmpty()){
2262         
2263                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2264         
2265         }
2269 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2271         std::map<int, int> SplitPoints;
2272         std::map<int, int> SplitLength;
2274         int intPrevValue = 6;
2275         
2276         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2277         
2278         intPrevValue = 5;
2279         
2280         PropertyType PropType = PROPERTY_NONE;
2281                 
2282         // Look for type before continuing.
2283         
2284         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2285         
2286         std::map<int, wxString> *LanguageList = NULL;
2287         std::map<int, wxString> *LanguageListType = NULL;
2288         std::map<int, wxString> *LanguageListAltID = NULL;
2289         std::map<int, wxString> *LanguageListPID = NULL;
2290         std::map<int, wxString> *LanguageListTokens = NULL;
2291         std::map<int, int> *LanguageListPref = NULL;
2293         switch(PropType){
2294                 case PROPERTY_NONE:
2295                         LanguageList = &GeneralLanguageList;
2296                         LanguageListType = &GeneralLanguageListType;
2297                         LanguageListAltID = &GeneralLanguageListAltID;
2298                         LanguageListPID = &GeneralLanguageListPID;
2299                         LanguageListTokens = &GeneralLanguageListTokens;
2300                         LanguageListPref = &GeneralLanguageListPref;    
2301                         break;
2302                 case PROPERTY_HOME:
2303                         LanguageList = &HomeLanguageList;
2304                         LanguageListType = &HomeLanguageListType;
2305                         LanguageListAltID = &HomeLanguageListAltID;
2306                         LanguageListPID = &HomeLanguageListPID;
2307                         LanguageListTokens = &HomeLanguageListTokens;   
2308                         LanguageListPref = &HomeLanguageListPref;       
2309                         break;
2310                 case PROPERTY_WORK:
2311                         LanguageList = &BusinessLanguageList;
2312                         LanguageListType = &BusinessLanguageListType;
2313                         LanguageListAltID = &BusinessLanguageListAltID;
2314                         LanguageListPID = &BusinessLanguageListPID;
2315                         LanguageListTokens = &BusinessLanguageListTokens;       
2316                         LanguageListPref = &BusinessLanguageListPref;
2317                         break;
2318         }
2319         
2320         intPrevValue = 5;
2321         
2322         std::map<int,int>::iterator SLiter;
2323         wxString PropertyData;
2324         wxString PropertyName;
2325         wxString PropertyValue;
2326         wxString PropertyTokens;
2327         bool FirstToken = TRUE;
2328         bool PropertyMatched = FALSE;
2329         
2330         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2331         intiter != SplitPoints.end(); ++intiter){
2332         
2333                 SLiter = SplitLength.find(intiter->first);
2334                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2335                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2336                 intPrevValue = intiter->second;
2338                 CaptureString(&PropertyValue, FALSE);
2339                 
2340                 // Process properties.
2341                 
2342                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2343                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2344                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2346                 if (PropertyMatched == TRUE){
2347                 
2348                         PropertyMatched = FALSE;
2349                         continue;
2350                 
2351                 }
2352                 
2353                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2354         
2355         }
2356                 
2357         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2358         
2359         // Add the name token data.
2360         
2361         if (!PropertyTokens.IsEmpty()){
2362         
2363                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2364         
2365         }
2369 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2371         std::map<int, int> SplitPoints;
2372         std::map<int, int> SplitLength;
2374         int intPrevValue = 5;
2375         
2376         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2377         
2378         intPrevValue = 4;
2379         
2380         PropertyType PropType = PROPERTY_NONE;
2381                 
2382         // Look for type before continuing.
2383         
2384         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2385         
2386         std::map<int, wxString> *GeopositionList = NULL;
2387         std::map<int, wxString> *GeopositionListType = NULL;
2388         std::map<int, wxString> *GeopositionListAltID = NULL;
2389         std::map<int, wxString> *GeopositionListPID = NULL;
2390         std::map<int, wxString> *GeopositionListTokens = NULL;
2391         std::map<int, wxString> *GeopositionListMediatype = NULL;
2392         std::map<int, wxString> *GeopositionListDataType = NULL;
2393         std::map<int, int> *GeopositionListPref = NULL;
2395         switch(PropType){
2396                 case PROPERTY_NONE:
2397                         GeopositionList = &GeneralGeographyList;
2398                         GeopositionListType = &GeneralGeographyListType;
2399                         GeopositionListAltID = &GeneralGeographyListAltID;
2400                         GeopositionListPID = &GeneralGeographyListPID;
2401                         GeopositionListTokens = &GeneralGeographyListTokens;
2402                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2403                         GeopositionListDataType = &GeneralGeographyListDataType;
2404                         GeopositionListPref = &GeneralGeographyListPref;        
2405                         break;
2406                 case PROPERTY_HOME:
2407                         GeopositionList = &HomeGeographyList;
2408                         GeopositionListType = &HomeGeographyListType;
2409                         GeopositionListAltID = &HomeGeographyListAltID;
2410                         GeopositionListPID = &HomeGeographyListPID;
2411                         GeopositionListTokens = &HomeGeographyListTokens;
2412                         GeopositionListMediatype = &HomeGeographyListMediatype;
2413                         GeopositionListDataType = &HomeGeographyListDataType;
2414                         GeopositionListPref = &HomeGeographyListPref;   
2415                         break;
2416                 case PROPERTY_WORK:
2417                         GeopositionList = &BusinessGeographyList;
2418                         GeopositionListType = &BusinessGeographyListType;
2419                         GeopositionListAltID = &BusinessGeographyListAltID;
2420                         GeopositionListPID = &BusinessGeographyListPID;
2421                         GeopositionListTokens = &BusinessGeographyListTokens;
2422                         GeopositionListMediatype = &BusinessGeographyListMediatype;
2423                         GeopositionListDataType = &BusinessGeographyListDataType;
2424                         GeopositionListPref = &BusinessGeographyListPref;
2425                         break;
2426         }
2427         
2428         intPrevValue = 4;
2429         
2430         std::map<int,int>::iterator SLiter;
2431         wxString PropertyData;
2432         wxString PropertyName;
2433         wxString PropertyValue;
2434         wxString PropertyTokens;
2435         bool FirstToken = TRUE;
2436         bool PropertyMatched = FALSE;
2437         
2438         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2439         intiter != SplitPoints.end(); ++intiter){
2440         
2441                 SLiter = SplitLength.find(intiter->first);
2442                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2443                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2444                 intPrevValue = intiter->second;
2445                 
2446                 CaptureString(&PropertyValue, FALSE);
2447                 
2448                 // Process properties.
2449                 
2450                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2451                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2452                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2453                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2454                 
2455                 if (PropertyMatched == TRUE){
2456                 
2457                         PropertyMatched = FALSE;
2458                         continue;
2459                 
2460                 }
2461                 
2462                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2463         
2464         }
2465                 
2466         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2467         
2468         // Add the name token data.
2469         
2470         if (!PropertyTokens.IsEmpty()){
2471         
2472                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2473         
2474         }
2478 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2480         size_t intPropertyLen = PropertySeg1.Len();
2481         std::map<int, int> SplitPoints;
2482         std::map<int, int> SplitLength;
2483         std::map<int, int>::iterator SLiter;                    
2484         wxString PropertyData;
2485         wxString PropertyName;
2486         wxString PropertyValue;
2487         wxString PropertyTokens;
2488         wxString RelatedType;
2489         wxString RelatedTypeOriginal;                   
2490         wxString RelatedName;
2491         bool FirstToken = TRUE;                 
2492         int intSplitsFound = 0;
2493         int intSplitSize = 0;
2494         int intPrevValue = 9;
2495         
2496         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2497         
2498         intPrevValue = 8;
2499         
2500         // Look for type before continuing.
2501         
2502         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2503         intiter != SplitPoints.end(); ++intiter){
2504         
2505                 SLiter = SplitLength.find(intiter->first);
2506                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2507                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2508                 intPrevValue = intiter->second;
2509                 
2510                 // Process these.
2511                 
2512                 RelatedTypeOriginal = PropertyValue;
2513                 
2514                 if (PropertyName == wxT("TYPE")){
2515                 
2516                         if (PropertyValue == wxT("contact")){
2518                                 RelatedType = _("Contact");
2520                         } else if (PropertyValue == wxT("acquaintance")){
2522                                 RelatedType = _("Acquaintance");
2524                         } else if (PropertyValue == wxT("friend")){
2526                                 RelatedType = _("Friend");
2528                         } else if (PropertyValue == wxT("met")){
2530                                 RelatedType = _("Met");
2532                         } else if (PropertyValue == wxT("co-worker")){
2534                                 RelatedType = _("Co-worker");
2536                         } else if (PropertyValue == wxT("colleague")){
2538                                 RelatedType = _("Colleague");
2540                         } else if (PropertyValue == wxT("co-resident")){
2542                                 RelatedType = _("Co-resident");
2544                         } else if (PropertyValue == wxT("neighbor")){
2546                                 RelatedType = _("Neighbour");
2548                         } else if (PropertyValue == wxT("child")){
2550                                 RelatedType = _("Child");
2552                         } else if (PropertyValue == wxT("parent")){
2554                                 RelatedType = _("Parent");
2556                         } else if (PropertyValue == wxT("sibling")){
2558                                 RelatedType = _("Sibling");
2560                         } else if (PropertyValue == wxT("spouse")){
2562                                 RelatedType = _("Spouse");
2564                         } else if (PropertyValue == wxT("kin")){
2566                                 RelatedType = _("Kin");
2568                         } else if (PropertyValue == wxT("muse")){
2570                                 RelatedType = _("Muse");
2572                         } else if (PropertyValue == wxT("crush")){
2574                                 RelatedType = _("Crush");
2576                         } else if (PropertyValue == wxT("date")){
2578                                 RelatedType = _("Date");
2580                         } else if (PropertyValue == wxT("sweetheart")){
2582                                 RelatedType = _("Sweetheart");
2584                         } else if (PropertyValue == wxT("me")){
2586                                 RelatedType = _("Me");
2588                         } else if (PropertyValue == wxT("agent")){
2590                                 RelatedType = _("Agent");
2592                         } else if (PropertyValue == wxT("emergency")){
2594                                 RelatedType = _("Emergency");
2596                         } else {
2598                                 RelatedType = PropertyValue;
2600                         }
2601                 
2602                 }
2603         
2604         }
2605         
2606         intPrevValue = 8;                       
2607         
2608         bool PropertyMatched = FALSE;
2609         
2610         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2611         intiter != SplitPoints.end(); ++intiter){
2612         
2613                 SLiter = SplitLength.find(intiter->first);
2614                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2615                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2616                 intPrevValue = intiter->second;
2617                 
2618                 // Process properties.
2619                 
2620                 size_t intPropertyValueLen = PropertyValue.Len();
2621                 
2622                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2623                         
2624                         PropertyValue.Trim();
2625                         PropertyValue.RemoveLast();
2626                         
2627                 }                               
2628                 
2629                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2630                         
2631                         PropertyValue.Remove(0, 1);
2632                         
2633                 }
2634                 
2635                 CaptureString(&PropertyValue, FALSE);
2636                         
2637                 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2638                 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2639                 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2640                 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2642                 if (PropertyMatched == TRUE){
2643                 
2644                         PropertyMatched = FALSE;
2645                         continue;
2646                 
2647                 }
2649                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2650         
2651         }                                       
2652         
2653         // Add the data to the General/Home/Work address variables.
2654                                 
2655         GeneralRelatedList.erase(*RelatedCount);
2656         GeneralRelatedListRelType.erase(*RelatedCount);
2657         GeneralRelatedListType.erase(*RelatedCount);
2658         GeneralRelatedListTokens.erase(*RelatedCount);
2659         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2660         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2661         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2662         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2666 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2668         std::map<int, int> SplitPoints;
2669         std::map<int, int> SplitLength;
2670         std::map<int, int>::iterator SLiter;                    
2671         wxString PropertyData;
2672         wxString PropertyName;
2673         wxString PropertyValue;
2674         wxString PropertyTokens;
2675         bool FirstToken = TRUE;
2676         int intPrevValue = 5;
2677         
2678         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2679         
2680         intPrevValue = 4;
2681         
2682         PropertyType PropType = PROPERTY_NONE;
2683                 
2684         // Look for type before continuing.
2685         
2686         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2687         
2688         // Setup the pointers.
2689         
2690         std::map<int, wxString> *WebsiteList = NULL;
2691         std::map<int, wxString> *WebsiteListAltID = NULL;
2692         std::map<int, wxString> *WebsiteListPID = NULL;
2693         std::map<int, wxString> *WebsiteListType = NULL;
2694         std::map<int, wxString> *WebsiteListTokens = NULL;
2695         std::map<int, wxString> *WebsiteListMediatype = NULL;
2696         std::map<int, int> *WebsiteListPref = NULL;
2697         
2698         // Setup blank lines for later on.
2699         
2700         switch(PropType){
2701                 case PROPERTY_NONE:
2702                         WebsiteList = &GeneralWebsiteList;
2703                         WebsiteListType = &GeneralWebsiteListType;
2704                         WebsiteListAltID = &GeneralWebsiteListAltID;
2705                         WebsiteListPID = &GeneralWebsiteListPID;
2706                         WebsiteListTokens = &GeneralWebsiteListTokens;
2707                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2708                         WebsiteListPref = &GeneralWebsiteListPref;      
2709                         break;
2710                 case PROPERTY_HOME:
2711                         WebsiteList = &HomeWebsiteList;
2712                         WebsiteListType = &HomeWebsiteListType;
2713                         WebsiteListAltID = &HomeWebsiteListAltID;
2714                         WebsiteListPID = &HomeWebsiteListPID;
2715                         WebsiteListTokens = &HomeWebsiteListTokens;
2716                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2717                         WebsiteListPref = &HomeWebsiteListPref; 
2718                         break;
2719                 case PROPERTY_WORK:
2720                         WebsiteList = &BusinessWebsiteList;
2721                         WebsiteListType = &BusinessWebsiteListType;
2722                         WebsiteListAltID = &BusinessWebsiteListAltID;
2723                         WebsiteListPID = &BusinessWebsiteListPID;
2724                         WebsiteListTokens = &BusinessWebsiteListTokens;
2725                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2726                         WebsiteListPref = &BusinessWebsiteListPref;
2727                         break;
2728         }
2729         
2730         intPrevValue = 4;
2731         bool PropertyMatched = FALSE;
2732         
2733         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2734         intiter != SplitPoints.end(); ++intiter){
2735         
2736                 SLiter = SplitLength.find(intiter->first);
2737                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2738                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2739                 intPrevValue = intiter->second;
2740                 
2741                 // Process properties.
2742                 
2743                 size_t intPropertyValueLen = PropertyValue.Len();
2744                 
2745                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2746                         
2747                         PropertyValue.Trim();
2748                         PropertyValue.RemoveLast();
2749                         
2750                 }                               
2751                 
2752                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2753                         
2754                         PropertyValue.Remove(0, 1);
2755                         
2756                 }
2757                 
2758                 CaptureString(&PropertyValue, FALSE);
2759                 
2760                 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
2761                 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
2762                 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
2763                 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
2764                 
2765                 if (PropertyMatched == TRUE){
2766                 
2767                         PropertyMatched = FALSE;
2768                         continue;
2769                 
2770                 }
2771                 
2772                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2773         
2774         }
2775         
2776         // Add the data to the General/Home/Work address variables.
2777         
2778         CaptureString(&PropertySeg2, FALSE);
2779                         
2780         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2781         
2782         if (!PropertyTokens.IsEmpty()){
2783         
2784                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2785                         
2786         }
2787         
2790 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
2792         std::map<int, int> SplitPoints;
2793         std::map<int, int> SplitLength;
2794         std::map<int, int>::iterator SLiter;                    
2795         wxString PropertyData;
2796         wxString PropertyName;
2797         wxString PropertyValue;
2798         wxString PropertyTokens;
2799         bool FirstToken = TRUE;
2800         int intPrevValue = 7;
2801         
2802         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2803         
2804         intPrevValue = 6;
2805         
2806         PropertyType PropType = PROPERTY_NONE;
2807                 
2808         // Look for type before continuing.
2809         
2810         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2811         
2812         // Setup the pointers.
2813         
2814         std::map<int, wxString> *TitleList = NULL;
2815         std::map<int, wxString> *TitleListAltID = NULL;
2816         std::map<int, wxString> *TitleListPID = NULL;
2817         std::map<int, wxString> *TitleListType = NULL;
2818         std::map<int, wxString> *TitleListTokens = NULL;
2819         std::map<int, wxString> *TitleListLanguage = NULL;
2820         std::map<int, int> *TitleListPref = NULL;
2821         
2822         // Setup blank lines for later on.
2823         
2824         switch(PropType){
2825                 case PROPERTY_NONE:
2826                         TitleList = &GeneralTitleList;
2827                         TitleListType = &GeneralTitleListType;
2828                         TitleListAltID = &GeneralTitleListAltID;
2829                         TitleListPID = &GeneralTitleListPID;
2830                         TitleListTokens = &GeneralTitleListTokens;
2831                         TitleListLanguage = &GeneralTitleListLanguage;
2832                         TitleListPref = &GeneralTitleListPref;  
2833                         break;
2834                 case PROPERTY_HOME:
2835                         TitleList = &HomeTitleList;
2836                         TitleListType = &HomeTitleListType;
2837                         TitleListAltID = &HomeTitleListAltID;
2838                         TitleListPID = &HomeTitleListPID;
2839                         TitleListTokens = &HomeTitleListTokens;
2840                         TitleListLanguage = &HomeTitleListLanguage;
2841                         TitleListPref = &HomeTitleListPref;     
2842                         break;
2843                 case PROPERTY_WORK:
2844                         TitleList = &BusinessTitleList;
2845                         TitleListType = &BusinessTitleListType;
2846                         TitleListAltID = &BusinessTitleListAltID;
2847                         TitleListPID = &BusinessTitleListPID;
2848                         TitleListTokens = &BusinessTitleListTokens;
2849                         TitleListLanguage = &BusinessTitleListLanguage; 
2850                         TitleListPref = &BusinessTitleListPref;
2851                         break;
2852         }
2854         intPrevValue = 6;
2855         bool PropertyMatched = FALSE;
2856                 
2857         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2858         intiter != SplitPoints.end(); ++intiter){
2859         
2860                 SLiter = SplitLength.find(intiter->first);
2861                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2862                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2863                 intPrevValue = intiter->second;
2864                 
2865                 // Process properties.
2866                 
2867                 size_t intPropertyValueLen = PropertyValue.Len();
2868                 
2869                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2870                         
2871                         PropertyValue.Trim();
2872                         PropertyValue.RemoveLast();
2873                         
2874                 }                               
2875                 
2876                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2877                         
2878                         PropertyValue.Remove(0, 1);
2879                         
2880                 }                               
2881                 
2882                 CaptureString(&PropertyValue, FALSE);
2883                 
2884                 ProcessStringValue(&PropertyName, "ALTID", TitleListAltID, &PropertyValue, TitleCount, &PropertyMatched);
2885                 ProcessStringValue(&PropertyName, "PID", TitleListPID, &PropertyValue, TitleCount, &PropertyMatched);
2886                 ProcessStringValue(&PropertyName, "LANGUAGE", TitleListLanguage, &PropertyValue, TitleCount, &PropertyMatched);
2887                 ProcessIntegerValue(&PropertyName, "PREF", TitleListPref, &PropertyValue, TitleCount, &PropertyMatched);
2888                 
2889                 if (PropertyMatched == TRUE){
2890                 
2891                         PropertyMatched = FALSE;
2892                         continue;
2893                 
2894                 }
2896                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2897         
2898         }
2899         
2900         // Add the data to the General/Home/Work address variables.
2901         
2902         CaptureString(&PropertySeg2, FALSE);
2904         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
2905         
2906         if (!PropertyTokens.IsEmpty()){
2907         
2908                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
2909                         
2910         }
2914 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
2916         std::map<int, int> SplitPoints;
2917         std::map<int, int> SplitLength;
2918         std::map<int, int>::iterator SLiter;                    
2919         wxString PropertyData;
2920         wxString PropertyName;
2921         wxString PropertyValue;
2922         wxString PropertyTokens;
2923         bool FirstToken = TRUE;
2924         int intPrevValue = 6;
2925         
2926         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2927         
2928         intPrevValue = 5;
2929         
2930         PropertyType PropType = PROPERTY_NONE;
2931                 
2932         // Look for type before continuing.
2933         
2934         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2935         
2936         // Setup the pointers.
2937         
2938         std::map<int, wxString> *RoleList = NULL;
2939         std::map<int, wxString> *RoleListAltID = NULL;
2940         std::map<int, wxString> *RoleListPID = NULL;
2941         std::map<int, wxString> *RoleListType = NULL;
2942         std::map<int, wxString> *RoleListTokens = NULL;
2943         std::map<int, wxString> *RoleListLanguage = NULL;
2944         std::map<int, int> *RoleListPref = NULL;
2945         
2946         // Setup blank lines for later on.
2947         
2948         switch(PropType){
2949                 case PROPERTY_NONE:
2950                         RoleList = &GeneralRoleList;
2951                         RoleListType = &GeneralRoleListType;
2952                         RoleListAltID = &GeneralRoleListAltID;
2953                         RoleListPID = &GeneralRoleListPID;
2954                         RoleListTokens = &GeneralRoleListTokens;
2955                         RoleListLanguage = &GeneralRoleListLanguage;
2956                         RoleListPref = &GeneralRoleListPref;    
2957                         break;
2958                 case PROPERTY_HOME:
2959                         RoleList = &HomeRoleList;
2960                         RoleListType = &HomeRoleListType;
2961                         RoleListAltID = &HomeRoleListAltID;
2962                         RoleListPID = &HomeRoleListPID;
2963                         RoleListTokens = &HomeRoleListTokens;
2964                         RoleListLanguage = &HomeRoleListLanguage;
2965                         RoleListPref = &HomeRoleListPref;       
2966                         break;
2967                 case PROPERTY_WORK:
2968                         RoleList = &BusinessRoleList;
2969                         RoleListType = &BusinessRoleListType;
2970                         RoleListAltID = &BusinessRoleListAltID;
2971                         RoleListPID = &BusinessRoleListPID;
2972                         RoleListTokens = &BusinessRoleListTokens;
2973                         RoleListLanguage = &BusinessRoleListLanguage;   
2974                         RoleListPref = &BusinessRoleListPref;
2975                         break;
2976         }
2978         intPrevValue = 5;
2979         bool PropertyMatched = FALSE;
2980                 
2981         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2982         intiter != SplitPoints.end(); ++intiter){
2983         
2984                 SLiter = SplitLength.find(intiter->first);
2985                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2986                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2987                 intPrevValue = intiter->second;
2988                 
2989                 // Process properties.
2990                 
2991                 size_t intPropertyValueLen = PropertyValue.Len();
2992                 
2993                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2994                         
2995                         PropertyValue.Trim();
2996                         PropertyValue.RemoveLast();
2997                         
2998                 }                               
2999                 
3000                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3001                         
3002                         PropertyValue.Remove(0, 1);
3003                         
3004                 }                               
3005                 
3006                 CaptureString(&PropertyValue, FALSE);
3007                 
3008                 ProcessStringValue(&PropertyName, "ALTID", RoleListAltID, &PropertyValue, RoleCount, &PropertyMatched);
3009                 ProcessStringValue(&PropertyName, "PID", RoleListPID, &PropertyValue, RoleCount, &PropertyMatched);
3010                 ProcessStringValue(&PropertyName, "LANGUAGE", RoleListLanguage, &PropertyValue, RoleCount, &PropertyMatched);
3011                 ProcessIntegerValue(&PropertyName, "PREF", RoleListPref, &PropertyValue, RoleCount, &PropertyMatched);
3012                 
3013                 if (PropertyMatched == TRUE){
3014                 
3015                         PropertyMatched = FALSE;
3016                         continue;
3017                 
3018                 }
3019                 
3020                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3021                 
3022         }
3023         
3024         // Add the data to the General/Home/Work address variables.
3025         
3026         CaptureString(&PropertySeg2, FALSE);
3028         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3029         
3030         if (!PropertyTokens.IsEmpty()){
3031         
3032                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3033                         
3034         }
3038 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3040         std::map<int, int> SplitPoints;
3041         std::map<int, int> SplitLength;
3042         std::map<int, int>::iterator SLiter;                    
3043         wxString PropertyData;
3044         wxString PropertyName;
3045         wxString PropertyValue;
3046         wxString PropertyTokens;
3047         bool FirstToken = TRUE;
3048         int intPrevValue = 5;
3049         
3050         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3051         
3052         intPrevValue = 4;
3053         
3054         PropertyType PropType = PROPERTY_NONE;
3055                 
3056         // Look for type before continuing.
3057         
3058         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3059         
3060         // Setup the pointers.
3061         
3062         std::map<int, wxString> *OrganisationsList = NULL;
3063         std::map<int, wxString> *OrganisationsListAltID = NULL;
3064         std::map<int, wxString> *OrganisationsListPID = NULL;
3065         std::map<int, wxString> *OrganisationsListType = NULL;
3066         std::map<int, wxString> *OrganisationsListTokens = NULL;
3067         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3068         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3069         std::map<int, int> *OrganisationsListPref = NULL;
3070         
3071         // Setup blank lines for later on.
3072         
3073         switch(PropType){
3074                 case PROPERTY_NONE:
3075                         OrganisationsList = &GeneralOrganisationsList;
3076                         OrganisationsListType = &GeneralOrganisationsListType;
3077                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3078                         OrganisationsListPID = &GeneralOrganisationsListPID;
3079                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3080                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3081                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3082                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3083                         break;
3084                 case PROPERTY_HOME:
3085                         OrganisationsList = &HomeOrganisationsList;
3086                         OrganisationsListType = &HomeOrganisationsListType;
3087                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3088                         OrganisationsListPID = &HomeOrganisationsListPID;
3089                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3090                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3091                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3092                         OrganisationsListPref = &HomeOrganisationsListPref;     
3093                         break;
3094                 case PROPERTY_WORK:
3095                         OrganisationsList = &BusinessOrganisationsList;
3096                         OrganisationsListType = &BusinessOrganisationsListType;
3097                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3098                         OrganisationsListPID = &BusinessOrganisationsListPID;
3099                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3100                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3101                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3102                         OrganisationsListPref = &BusinessOrganisationsListPref;
3103                         break;
3104         }
3106         intPrevValue = 4;
3107         bool PropertyMatched = FALSE;
3108                 
3109         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3110         intiter != SplitPoints.end(); ++intiter){
3111         
3112                 SLiter = SplitLength.find(intiter->first);
3113                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3114                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3115                 intPrevValue = intiter->second;
3116                 
3117                 // Process properties.
3118                 
3119                 size_t intPropertyValueLen = PropertyValue.Len();
3120                 
3121                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3122                         
3123                         PropertyValue.Trim();
3124                         PropertyValue.RemoveLast();
3125                         
3126                 }                               
3127                 
3128                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3129                         
3130                         PropertyValue.Remove(0, 1);
3131                         
3132                 }                               
3133                 
3134                 CaptureString(&PropertyValue, FALSE);
3135                 
3136                 ProcessStringValue(&PropertyName, "ALTID", OrganisationsListAltID, &PropertyValue, OrganisationCount, &PropertyMatched);
3137                 ProcessStringValue(&PropertyName, "PID", OrganisationsListPID, &PropertyValue, OrganisationCount, &PropertyMatched);
3138                 ProcessStringValue(&PropertyName, "LANGUAGE", OrganisationsListLanguage, &PropertyValue, OrganisationCount, &PropertyMatched);
3139                 ProcessStringValue(&PropertyName, "SORT-AS", OrganisationsListSortAs, &PropertyValue, OrganisationCount, &PropertyMatched);
3140                 ProcessIntegerValue(&PropertyName, "PREF", OrganisationsListPref, &PropertyValue, OrganisationCount, &PropertyMatched);
3141                 
3142                 if (PropertyMatched == TRUE){
3143                 
3144                         PropertyMatched = FALSE;
3145                         continue;
3146                 
3147                 }
3148                 
3149                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3151         }
3152         
3153         // Add the data to the General/Home/Work address variables.
3154         
3155         CaptureString(&PropertySeg2, FALSE);
3157         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3158         
3159         if (!PropertyTokens.IsEmpty()){
3160         
3161                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3162                         
3163         }
3167 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3169         std::map<int, int> SplitPoints;
3170         std::map<int, int> SplitLength;
3171         std::map<int, int>::iterator SLiter;                    
3172         wxString PropertyData;
3173         wxString PropertyName;
3174         wxString PropertyValue;
3175         wxString PropertyTokens;
3176         bool FirstToken = TRUE;
3177         int intPrevValue = 6;
3178         
3179         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3180         
3181         intPrevValue = 5;
3182         
3183         PropertyType PropType = PROPERTY_NONE;
3184                 
3185         // Look for type before continuing.
3186         
3187         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3188         
3189         // Setup the pointers.
3190         
3191         std::map<int, wxString> *NoteList = NULL;
3192         std::map<int, wxString> *NoteListAltID = NULL;
3193         std::map<int, wxString> *NoteListPID = NULL;
3194         std::map<int, wxString> *NoteListType = NULL;
3195         std::map<int, wxString> *NoteListTokens = NULL;
3196         std::map<int, wxString> *NoteListLanguage = NULL;
3197         std::map<int, int> *NoteListPref = NULL;
3198         
3199         // Setup blank lines for later on.
3200         
3201         switch(PropType){
3202                 case PROPERTY_NONE:
3203                         NoteList = &GeneralNoteList;
3204                         NoteListType = &GeneralNoteListType;
3205                         NoteListAltID = &GeneralNoteListAltID;
3206                         NoteListPID = &GeneralNoteListPID;
3207                         NoteListTokens = &GeneralNoteListTokens;
3208                         NoteListLanguage = &GeneralNoteListLanguage;
3209                         NoteListPref = &GeneralNoteListPref;    
3210                         break;
3211                 case PROPERTY_HOME:
3212                         NoteList = &HomeNoteList;
3213                         NoteListType = &HomeNoteListType;
3214                         NoteListAltID = &HomeNoteListAltID;
3215                         NoteListPID = &HomeNoteListPID;
3216                         NoteListTokens = &HomeNoteListTokens;
3217                         NoteListLanguage = &HomeNoteListLanguage;
3218                         NoteListPref = &HomeNoteListPref;       
3219                         break;
3220                 case PROPERTY_WORK:
3221                         NoteList = &BusinessNoteList;
3222                         NoteListType = &BusinessNoteListType;
3223                         NoteListAltID = &BusinessNoteListAltID;
3224                         NoteListPID = &BusinessNoteListPID;
3225                         NoteListTokens = &BusinessNoteListTokens;
3226                         NoteListLanguage = &BusinessNoteListLanguage;   
3227                         NoteListPref = &BusinessNoteListPref;
3228                         break;
3229         }
3231         intPrevValue = 5;
3232         bool PropertyMatched = FALSE;
3233                 
3234         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3235         intiter != SplitPoints.end(); ++intiter){
3236         
3237                 SLiter = SplitLength.find(intiter->first);
3238                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3239                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3240                 intPrevValue = intiter->second;
3241                 
3242                 // Process properties.
3243                 
3244                 size_t intPropertyValueLen = PropertyValue.Len();
3245                 
3246                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3247                         
3248                         PropertyValue.Trim();
3249                         PropertyValue.RemoveLast();
3250                         
3251                 }                               
3252                 
3253                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3254                         
3255                         PropertyValue.Remove(0, 1);
3256                         
3257                 }                               
3258                 
3259                 CaptureString(&PropertyValue, FALSE);
3260                 
3261                 ProcessStringValue(&PropertyName, "ALTID", NoteListAltID, &PropertyValue, NoteCount, &PropertyMatched);
3262                 ProcessStringValue(&PropertyName, "PID", NoteListPID, &PropertyValue, NoteCount, &PropertyMatched);
3263                 ProcessStringValue(&PropertyName, "LANGUAGE", NoteListLanguage, &PropertyValue, NoteCount, &PropertyMatched);
3264                 ProcessIntegerValue(&PropertyName, "PREF", NoteListPref, &PropertyValue, NoteCount, &PropertyMatched);
3265                 
3266                 if (PropertyMatched == TRUE){
3267                 
3268                         PropertyMatched = FALSE;
3269                         continue;
3270                 
3271                 }
3273                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3274         
3275         }
3276         
3277         // Add the data to the General/Home/Work address variables.
3278         
3279         CaptureString(&PropertySeg2, FALSE);
3281         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3282         
3283         if (!PropertyTokens.IsEmpty()){
3284         
3285                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3286                         
3287         }
3291 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3293         std::map<int, int> SplitPoints;
3294         std::map<int, int> SplitLength;
3295         std::map<int, int>::iterator SLiter;                    
3296         wxString PropertyData;
3297         wxString PropertyName;
3298         wxString PropertyValue;
3299         wxString PropertyTokens;
3300         bool FirstToken = TRUE;
3301         int intPrevValue = 12;
3302         
3303         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3304         
3305         intPrevValue = 11;
3306         
3307         PropertyType PropType = PROPERTY_NONE;
3308                 
3309         // Look for type before continuing.
3310         
3311         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3312         
3313         // Setup blank lines for later on.
3314         
3315         switch(PropType){
3316                 case PROPERTY_NONE:
3317                         break;
3318                 case PROPERTY_HOME:
3319                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3320                         break;
3321                 case PROPERTY_WORK:
3322                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3323                         break;
3324         }
3326         intPrevValue = 11;
3327         bool PropertyMatched = FALSE;
3328                 
3329         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3330         intiter != SplitPoints.end(); ++intiter){
3331         
3332                 SLiter = SplitLength.find(intiter->first);
3333                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3334                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3335                 intPrevValue = intiter->second;
3336                 
3337                 // Process properties.
3338                 
3339                 size_t intPropertyValueLen = PropertyValue.Len();
3340                 
3341                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3342                         
3343                         PropertyValue.Trim();
3344                         PropertyValue.RemoveLast();
3345                         
3346                 }                               
3347                 
3348                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3349                         
3350                         PropertyValue.Remove(0, 1);
3351                         
3352                 }                               
3353                 
3354                 CaptureString(&PropertyValue, FALSE);
3355                 
3356                 ProcessStringValue(&PropertyName, "ALTID", &CategoriesListAltID, &PropertyValue, CategoryCount, &PropertyMatched);
3357                 ProcessStringValue(&PropertyName, "PID", &CategoriesListPID, &PropertyValue, CategoryCount, &PropertyMatched);
3358                 ProcessStringValue(&PropertyName, "LANGUAGE", &CategoriesListLanguage, &PropertyValue, CategoryCount, &PropertyMatched);
3359                 ProcessIntegerValue(&PropertyName, "PREF", &CategoriesListPref, &PropertyValue, CategoryCount, &PropertyMatched);
3360                 
3361                 if (PropertyMatched == TRUE){
3362                 
3363                         PropertyMatched = FALSE;
3364                         continue;
3365                 
3366                 }
3368                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3369         
3370         }
3371         
3372         // Deal with multiple categories.
3373         
3374         int intOrigCatCount = *CategoryCount;
3375         bool FirstCategoryProcessed = TRUE;
3376         bool AfterFirstToken = FALSE;
3377         int intSplitSize = 0;
3378         int intSplitsFound = 0;
3379         int intSplitSeek = 0;
3380         int intPropertyLen = PropertySeg2.Len();
3381         
3382         SplitPoints.clear();
3383         SplitLength.clear();
3384         intPrevValue = 0;
3385         
3386         for (int i = 0; i <= intPropertyLen; i++){
3387         
3388                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3389         
3390                         continue;
3391                 
3392                 }
3393         
3394                 intSplitSize++;
3395         
3396                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3397         
3398                         if (AfterFirstToken == TRUE){
3399                 
3400                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3401                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3402                         
3403                         } else {
3404                         
3405                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3406                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3407                                 AfterFirstToken = TRUE;
3409                         }
3411                         intSplitsFound++;
3412                         intSplitSeek = i;
3413                         intSplitSize = 0;                               
3414         
3415                 }                       
3416         
3417         }
3418         
3419         if (SplitPoints.size() > 0){
3420         
3421                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3422                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3423         
3424         }
3425         
3426         if (SplitPoints.size() == 0){
3427         
3428                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3429         
3430                 if (!PropertyTokens.IsEmpty()){
3431                 
3432                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3433                 
3434                 }
3435         
3436         }
3437         
3438         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3439         intiter != SplitPoints.end(); ++intiter){
3440         
3441                 SLiter = SplitLength.find(intiter->first);
3442         
3443                 intPrevValue = intiter->second;
3444         
3445                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3446                 
3447                 // Add the data to the General/Home/Work address variables.
3448         
3449                 // Trim any whitespace from the start and end.
3450         
3451                 PropertyData = PropertyData.Trim(FALSE);
3452                 PropertyData = PropertyData.Trim(TRUE); 
3453         
3454                 CaptureString(&PropertyData, FALSE);
3455                 
3456                 if (FirstCategoryProcessed == TRUE){
3457                 
3458                         FirstCategoryProcessed = FALSE;
3459                         
3460                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3461         
3462                         if (!PropertyTokens.IsEmpty()){
3463                 
3464                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3465                 
3466                         }
3467                         
3468                         continue;
3469                 
3470                 } else {
3472                         (*CategoryCount)++;
3473                         
3474                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3475                 
3476                         if (!PropertyTokens.IsEmpty()){
3477                 
3478                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3479                 
3480                         }
3481                 
3482                 }
3483                 
3484                 // Copy the properties to each of the categories (if it exists).
3485                 
3486                 if (!PropertyTokens.IsEmpty()){
3487                 
3488                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3489                 
3490                 }
3491                 
3492                 // Check if ALTID was used.
3493                 
3494                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3495                 
3496                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3497                 
3498                 }
3499                 
3500                 // Check if PID was used.
3501                 
3502                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
3503                 
3504                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
3505                 
3506                 }
3507         
3508                 // Check if PREF was used.
3509         
3510                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
3511                 
3512                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
3513                 
3514                 }
3515                 
3516                 // Check if LANGUAGE was used.
3517                 
3518                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
3519                 
3520                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
3521                 
3522                 }
3523                 
3524                 // Check if TYPE was used.
3525                 
3526                 switch(PropType){
3527                         case PROPERTY_NONE:
3528                                 break;
3529                         case PROPERTY_HOME:
3530                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3531                                 break;
3532                         case PROPERTY_WORK:
3533                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3534                                 break;
3535                 }
3536         
3537         }
3541 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
3543         size_t intPropertyLen = PropertySeg1.Len();
3544         std::map<int, int> SplitPoints;
3545         std::map<int, int> SplitLength;
3546         std::map<int, int>::iterator SLiter;                    
3547         wxString PropertyData;
3548         wxString PropertyName;
3549         wxString PropertyValue;
3550         wxString PropertyTokens;
3551         bool FirstToken = TRUE;
3552         int intSplitsFound = 0;
3553         int intSplitSize = 0;
3554         int intPrevValue = 7;
3555         
3556         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3557         
3558         intPrevValue = 6;
3559         
3560         PropertyType PropType = PROPERTY_NONE;
3561                 
3562         // Look for type before continuing.
3563         
3564         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3566         intPrevValue = 6;
3567         bool PropertyMatched = FALSE;
3569         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3570         intiter != SplitPoints.end(); ++intiter){
3571         
3572                 SLiter = SplitLength.find(intiter->first);
3573                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3574                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3575                 intPrevValue = intiter->second;
3576                 
3577                 // Process properties.
3578                 
3579                 size_t intPropertyValueLen = PropertyValue.Len();
3580                 
3581                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3582                         
3583                         PropertyValue.Trim();
3584                         PropertyValue.RemoveLast();
3585                         
3586                 }                               
3587                 
3588                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3589                         
3590                         PropertyValue.Remove(0, 1);
3591                         
3592                 }
3593                 
3594                 CaptureString(&PropertyValue, FALSE);
3595                 
3596                 ProcessStringValue(&PropertyName, "ALTID", &PicturesListAltID, &PropertyValue, PhotoCount, &PropertyMatched);
3597                 ProcessStringValue(&PropertyName, "PID", &PicturesListPID, &PropertyValue, PhotoCount, &PropertyMatched);
3598                 ProcessStringValue(&PropertyName, "MEDIATYPE", &PicturesListMediatype, &PropertyValue, PhotoCount, &PropertyMatched);
3599                 ProcessIntegerValue(&PropertyName, "PREF", &PicturesListPref, &PropertyValue, PhotoCount, &PropertyMatched);
3600                 
3601                 if (PropertyMatched == TRUE){
3602                 
3603                         PropertyMatched = FALSE;
3604                         continue;
3605                 
3606                 }
3608                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3609                         
3610         }       
3611         
3612         intPropertyLen = PropertySeg2.Len();
3613         SplitPoints.clear();
3614         SplitLength.clear();
3615         intSplitsFound = 0;
3616         intSplitSize = 0;
3617         intPrevValue = 0;                       
3618         
3619         CaptureString(&PropertySeg2, FALSE);
3620         
3621         for (int i = 0; i <= intPropertyLen; i++){
3623                 intSplitSize++;
3624         
3625                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3626         
3627                         intSplitsFound++;
3628                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3629                         
3630                         if (intSplitsFound == 6){ 
3631                         
3632                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3633                                 break; 
3634                                 
3635                         } else {
3636                         
3637                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3638                         
3639                         }
3640                         
3641                         intSplitSize = 0;                                       
3642         
3643                 }
3645         }
3646         
3647         wxString wxSPhotoURI;
3648         wxString wxSPhotoMIME;
3649         wxString wxSPhotoEncoding;
3650         wxString wxSPhotoData;
3651         std::string base64enc;
3652         
3653         if (intSplitsFound == 0){
3654         
3655         } else {
3656         
3657                 std::map<int, int>::iterator striter;
3658         
3659                 striter = SplitLength.find(1);
3660         
3661                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3662         
3663                 while (wSTDataType.HasMoreTokens() == TRUE){
3664                 
3665                         wxSPhotoURI = wSTDataType.GetNextToken();
3666                         wxSPhotoMIME = wSTDataType.GetNextToken();
3667                         break;
3668                 
3669                 }                       
3670         
3671                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3672         
3673                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3674                 
3675                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3676                         wxSPhotoData = wSTDataInfo.GetNextToken();
3677                         base64enc = wxSPhotoData.mb_str();
3678                         break;
3679                 
3680                 }
3681         
3682         }
3683         
3684         // Add the data to the General/Home/Work address variables.
3685         
3686         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
3687         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
3688         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
3689         
3690         switch(PropType){
3691                 case PROPERTY_NONE:
3692                         break;
3693                 case PROPERTY_HOME:
3694                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
3695                         break;
3696                 case PROPERTY_WORK:
3697                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
3698                         break;
3699         }
3700         
3701         if (!PropertyTokens.IsEmpty()){
3703                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
3704         
3705         }
3709 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
3711         size_t intPropertyLen = PropertySeg1.Len();
3712         std::map<int, int> SplitPoints;
3713         std::map<int, int> SplitLength;
3714         std::map<int, int>::iterator SLiter;                    
3715         wxString PropertyData;
3716         wxString PropertyName;
3717         wxString PropertyValue;
3718         wxString PropertyTokens;
3719         bool FirstToken = TRUE;
3720         int intSplitsFound = 0;
3721         int intSplitSize = 0;
3722         int intPrevValue = 6;
3723         
3724         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3725         
3726         intPrevValue = 5;
3727         
3728         PropertyType PropType = PROPERTY_NONE;
3729                 
3730         // Look for type before continuing.
3731         
3732         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3734         intPrevValue = 5;
3735         bool PropertyMatched = FALSE;
3737         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3738         intiter != SplitPoints.end(); ++intiter){
3739         
3740                 SLiter = SplitLength.find(intiter->first);
3741                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3742                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3743                 intPrevValue = intiter->second;
3744                 
3745                 // Process properties.
3746                 
3747                 size_t intPropertyValueLen = PropertyValue.Len();
3748                 
3749                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3750                         
3751                         PropertyValue.Trim();
3752                         PropertyValue.RemoveLast();
3753                         
3754                 }                               
3755                 
3756                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3757                         
3758                         PropertyValue.Remove(0, 1);
3759                         
3760                 }
3761                 
3762                 CaptureString(&PropertyValue, FALSE);
3763                 
3764                 ProcessStringValue(&PropertyName, "ALTID", &LogosListAltID, &PropertyValue, LogoCount, &PropertyMatched);
3765                 ProcessStringValue(&PropertyName, "PID", &LogosListPID, &PropertyValue, LogoCount, &PropertyMatched);
3766                 ProcessStringValue(&PropertyName, "MEDIATYPE", &LogosListMediatype, &PropertyValue, LogoCount, &PropertyMatched);
3767                 ProcessIntegerValue(&PropertyName, "PREF", &LogosListPref, &PropertyValue, LogoCount, &PropertyMatched);
3768                 
3769                 if (PropertyMatched == TRUE){
3770                 
3771                         PropertyMatched = FALSE;
3772                         continue;
3773                 
3774                 }
3776                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3777         
3778         }       
3779         
3780         intPropertyLen = PropertySeg2.Len();
3781         SplitPoints.clear();
3782         SplitLength.clear();
3783         intSplitsFound = 0;
3784         intSplitSize = 0;
3785         intPrevValue = 0;                       
3786         
3787         CaptureString(&PropertySeg2, FALSE);
3788         
3789         for (int i = 0; i <= intPropertyLen; i++){
3791                 intSplitSize++;
3792         
3793                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3794         
3795                         intSplitsFound++;
3796                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3797                         
3798                         if (intSplitsFound == 6){ 
3799                         
3800                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3801                                 break; 
3802                                 
3803                         } else {
3804                         
3805                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3806                         
3807                         }
3808                         
3809                         intSplitSize = 0;                                       
3810         
3811                 }
3813         }
3814         
3815         wxString wxSPhotoURI;
3816         wxString wxSPhotoMIME;
3817         wxString wxSPhotoEncoding;
3818         wxString wxSPhotoData;
3819         std::string base64enc;
3820         
3821         if (intSplitsFound == 0){
3822         
3823         } else {
3824         
3825                 std::map<int, int>::iterator striter;
3826         
3827                 striter = SplitLength.find(1);
3828         
3829                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3830         
3831                 while (wSTDataType.HasMoreTokens() == TRUE){
3832                 
3833                         wxSPhotoURI = wSTDataType.GetNextToken();
3834                         wxSPhotoMIME = wSTDataType.GetNextToken();
3835                         break;
3836                 
3837                 }                       
3838         
3839                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3840         
3841                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3842                 
3843                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3844                         wxSPhotoData = wSTDataInfo.GetNextToken();
3845                         base64enc = wxSPhotoData.mb_str();
3846                         break;
3847                 
3848                 }
3849         
3850         }
3851         
3852         // Add the data to the General/Home/Work address variables.
3853                 
3854         LogosList.insert(std::make_pair(*LogoCount, base64enc));
3855         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
3856         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
3857         
3858         switch(PropType){
3859                 case PROPERTY_NONE:
3860                         break;
3861                 case PROPERTY_HOME:
3862                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
3863                         break;
3864                 case PROPERTY_WORK:
3865                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
3866                         break;
3867         }
3868         
3869         if (!PropertyTokens.IsEmpty()){
3871                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
3872         
3873         }
3877 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
3879         size_t intPropertyLen = PropertySeg1.Len();
3880         std::map<int, int> SplitPoints;
3881         std::map<int, int> SplitLength;
3882         std::map<int, int>::iterator SLiter;                    
3883         wxString PropertyData;
3884         wxString PropertyName;
3885         wxString PropertyValue;
3886         wxString PropertyTokens;
3887         bool FirstToken = TRUE;
3888         int intSplitsFound = 0;
3889         int intSplitSize = 0;
3890         int intPrevValue = 7;
3891         
3892         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3893         
3894         intPrevValue = 6;
3895         
3896         PropertyType PropType = PROPERTY_NONE;
3897         
3898         // Look for type before continuing.                     
3900         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3902         intPrevValue = 6;
3903         bool PropertyMatched = FALSE;
3905         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3906         intiter != SplitPoints.end(); ++intiter){
3907         
3908                 SLiter = SplitLength.find(intiter->first);
3909                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3910                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3911                 intPrevValue = intiter->second;
3912                 
3913                 // Process properties.
3914                 
3915                 size_t intPropertyValueLen = PropertyValue.Len();
3916                 
3917                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3918                         
3919                         PropertyValue.Trim();
3920                         PropertyValue.RemoveLast();
3921                         
3922                 }                               
3923                 
3924                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3925                         
3926                         PropertyValue.Remove(0, 1);
3927                         
3928                 }                       
3929                 
3930                 CaptureString(&PropertyValue, FALSE);
3931                 
3932                 ProcessStringValue(&PropertyName, "ALTID", &SoundsListAltID, &PropertyValue, SoundCount, &PropertyMatched);
3933                 ProcessStringValue(&PropertyName, "PID", &SoundsListPID, &PropertyValue, SoundCount, &PropertyMatched);
3934                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SoundsListMediatype, &PropertyValue, SoundCount, &PropertyMatched);
3935                 ProcessStringValue(&PropertyName, "LANGUAGE", &SoundsListLanguage, &PropertyValue, SoundCount, &PropertyMatched);
3936                 ProcessIntegerValue(&PropertyName, "PREF", &SoundsListPref, &PropertyValue, SoundCount, &PropertyMatched);
3937                 
3938                 if (PropertyMatched == TRUE){
3939                 
3940                         PropertyMatched = FALSE;
3941                         continue;
3942                 
3943                 }
3945                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3946         
3947         }       
3948         
3949         intPropertyLen = PropertySeg2.Len();
3950         SplitPoints.clear();
3951         SplitLength.clear();
3952         intSplitsFound = 0;
3953         intSplitSize = 0;
3954         intPrevValue = 0;
3955         
3956         CaptureString(&PropertySeg2, FALSE);
3957         
3958         for (int i = 0; i <= intPropertyLen; i++){
3960                 intSplitSize++;
3961         
3962                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3963         
3964                         intSplitsFound++;
3965                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3966                         
3967                         if (intSplitsFound == 6){ 
3968                         
3969                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3970                                 break; 
3971                                 
3972                         } else {
3973                         
3974                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3975                         
3976                         }
3977                         
3978                         intSplitSize = 0;                                       
3979         
3980                 }
3982         }
3983         
3984         wxString wxSSoundURI;
3985         wxString wxSSoundMIME;
3986         wxString wxSSoundEncoding;
3987         wxString wxSSoundData;
3988         std::string base64enc;
3989         
3990         if (intSplitsFound == 0){
3991         
3992         } else {
3993         
3994                 std::map<int, int>::iterator striter;
3995         
3996                 striter = SplitLength.find(1);
3997         
3998                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3999         
4000                 while (wSTDataType.HasMoreTokens() == TRUE){
4001                 
4002                         wxSSoundURI = wSTDataType.GetNextToken();
4003                         wxSSoundMIME = wSTDataType.GetNextToken();
4004                         break;
4005                 
4006                 }                       
4007         
4008                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4009         
4010                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4011                 
4012                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4013                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4014                         base64enc = wxSSoundData.mb_str();
4015                         break;
4016                 
4017                 }
4018         
4019         }
4020         
4021         // Add the data to the General/Home/Work address variables.
4022                 
4023         switch(PropType){
4024                 case PROPERTY_NONE:
4025                         break;
4026                 case PROPERTY_HOME:
4027                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4028                         break;
4029                 case PROPERTY_WORK:
4030                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4031                         break;
4032         }
4033         
4034         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4035         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4036         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4037         
4038         if (!PropertyTokens.IsEmpty()){
4039         
4040                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4041         
4042         }
4043         
4046 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4048         size_t intPropertyLen = PropertySeg1.Len();
4049         std::map<int, int> SplitPoints;
4050         std::map<int, int> SplitLength;
4051         std::map<int, int>::iterator SLiter;                    
4052         wxString PropertyData;
4053         wxString PropertyName;
4054         wxString PropertyValue;
4055         wxString PropertyTokens;
4056         bool FirstToken = TRUE;
4057         int intSplitsFound = 0;
4058         int intSplitSize = 0;
4059         int intPrevValue = 8;
4060         
4061         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4062         
4063         intPrevValue = 7;
4064         
4065         PropertyType PropType = PROPERTY_NONE;
4066         
4067         // Look for type before continuing.                     
4069         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4071         intPrevValue = 7;
4072         bool PropertyMatched = FALSE;
4074         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4075         intiter != SplitPoints.end(); ++intiter){
4076         
4077                 SLiter = SplitLength.find(intiter->first);
4078                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4079                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4080                 intPrevValue = intiter->second;
4081                 
4082                 // Process properties.
4083                 
4084                 size_t intPropertyValueLen = PropertyValue.Len();
4085                 
4086                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4087                         
4088                         PropertyValue.Trim();
4089                         PropertyValue.RemoveLast();
4090                         
4091                 }                               
4092                 
4093                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4094                         
4095                         PropertyValue.Remove(0, 1);
4096                         
4097                 }                       
4098                 
4099                 CaptureString(&PropertyValue, FALSE);
4100                 
4101                 ProcessStringValue(&PropertyName, "ALTID", &CalendarListAltID, &PropertyValue, CalURICount, &PropertyMatched);
4102                 ProcessStringValue(&PropertyName, "PID", &CalendarListPID, &PropertyValue, CalURICount, &PropertyMatched);
4103                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarListMediatype, &PropertyValue, CalURICount, &PropertyMatched);
4104                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarListPref, &PropertyValue, CalURICount, &PropertyMatched);
4105                 
4106                 if (PropertyMatched == TRUE){
4107                 
4108                         PropertyMatched = FALSE;
4109                         continue;
4110                 
4111                 }
4113                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4114         
4115         }       
4116         
4117         intPropertyLen = PropertySeg2.Len();
4118         SplitPoints.clear();
4119         SplitLength.clear();
4120         intSplitsFound = 0;
4121         intSplitSize = 0;
4122         intPrevValue = 0;
4123         
4124         CaptureString(&PropertySeg2, FALSE);
4125         
4126         // Add the data to the General/Home/Work address variables.
4127                 
4128         switch(PropType){
4129                 case PROPERTY_NONE:
4130                         break;
4131                 case PROPERTY_HOME:
4132                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4133                         break;
4134                 case PROPERTY_WORK:
4135                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4136                         break;
4137         }
4138         
4139         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4140         
4141         if (!PropertyTokens.IsEmpty()){
4142         
4143                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4144         
4145         }
4149 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4151         size_t intPropertyLen = PropertySeg1.Len();
4152         std::map<int, int> SplitPoints;
4153         std::map<int, int> SplitLength;
4154         std::map<int, int>::iterator SLiter;                    
4155         wxString PropertyData;
4156         wxString PropertyName;
4157         wxString PropertyValue;
4158         wxString PropertyTokens;
4159         bool FirstToken = TRUE;
4160         int intSplitsFound = 0;
4161         int intSplitSize = 0;
4162         int intPrevValue = 8;
4163         
4164         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4165         
4166         intPrevValue = 7;
4167         
4168         PropertyType PropType = PROPERTY_NONE;
4169         
4170         // Look for type before continuing.                     
4172         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4174         intPrevValue = 7;
4175         bool PropertyMatched = FALSE;
4177         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4178         intiter != SplitPoints.end(); ++intiter){
4179         
4180                 SLiter = SplitLength.find(intiter->first);
4181                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4182                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4183                 intPrevValue = intiter->second;
4184                 
4185                 // Process properties.
4186                 
4187                 size_t intPropertyValueLen = PropertyValue.Len();
4188                 
4189                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4190                         
4191                         PropertyValue.Trim();
4192                         PropertyValue.RemoveLast();
4193                         
4194                 }                               
4195                 
4196                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4197                         
4198                         PropertyValue.Remove(0, 1);
4199                         
4200                 }                       
4201                 
4202                 CaptureString(&PropertyValue, FALSE);
4203                 
4204                 ProcessStringValue(&PropertyName, "ALTID", &CalendarRequestListAltID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4205                 ProcessStringValue(&PropertyName, "PID", &CalendarRequestListPID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4206                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarRequestListMediatype, &PropertyValue, CalAdrURICount, &PropertyMatched);
4207                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarRequestListPref, &PropertyValue, CalAdrURICount, &PropertyMatched);
4208                 
4209                 if (PropertyMatched == TRUE){
4210                 
4211                         PropertyMatched = FALSE;
4212                         continue;
4213                 
4214                 }
4216                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4217         
4218         }       
4219         
4220         intPropertyLen = PropertySeg2.Len();
4221         SplitPoints.clear();
4222         SplitLength.clear();
4223         intSplitsFound = 0;
4224         intSplitSize = 0;
4225         intPrevValue = 0;
4226         
4227         CaptureString(&PropertySeg2, FALSE);
4228         
4229         // Add the data to the General/Home/Work address variables.
4230                 
4231         switch(PropType){
4232                 case PROPERTY_NONE:
4233                         break;
4234                 case PROPERTY_HOME:
4235                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4236                         break;
4237                 case PROPERTY_WORK:
4238                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4239                         break;
4240         }
4241         
4242         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4243         
4244         if (!PropertyTokens.IsEmpty()){
4245         
4246                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4247         
4248         }       
4249         
4252 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4254         size_t intPropertyLen = PropertySeg1.Len();
4255         std::map<int, int> SplitPoints;
4256         std::map<int, int> SplitLength;
4257         std::map<int, int>::iterator SLiter;                    
4258         wxString PropertyData;
4259         wxString PropertyName;
4260         wxString PropertyValue;
4261         wxString PropertyTokens;
4262         bool FirstToken = TRUE;
4263         int intSplitsFound = 0;
4264         int intSplitSize = 0;
4265         int intPrevValue = 7;
4266         
4267         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4268         
4269         intPrevValue = 6;
4270         
4271         PropertyType PropType = PROPERTY_NONE;
4272         
4273         // Look for type before continuing.                     
4275         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4277         intPrevValue = 6;
4278         bool PropertyMatched = FALSE;
4280         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4281         intiter != SplitPoints.end(); ++intiter){
4282         
4283                 SLiter = SplitLength.find(intiter->first);
4284                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4285                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4286                 intPrevValue = intiter->second;
4287                 
4288                 // Process properties.
4289                 
4290                 size_t intPropertyValueLen = PropertyValue.Len();
4291                 
4292                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4293                         
4294                         PropertyValue.Trim();
4295                         PropertyValue.RemoveLast();
4296                         
4297                 }                               
4298                 
4299                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4300                         
4301                         PropertyValue.Remove(0, 1);
4302                         
4303                 }                       
4304                 
4305                 CaptureString(&PropertyValue, FALSE);
4306                 
4307                 ProcessStringValue(&PropertyName, "ALTID", &FreeBusyListAltID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4308                 ProcessStringValue(&PropertyName, "PID", &FreeBusyListPID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4309                 ProcessStringValue(&PropertyName, "MEDIATYPE", &FreeBusyListMediatype, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4310                 ProcessIntegerValue(&PropertyName, "PREF", &FreeBusyListPref, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4311                 
4312                 if (PropertyMatched == TRUE){
4313                 
4314                         PropertyMatched = FALSE;
4315                         continue;
4316                 
4317                 }
4319                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4320         
4321         }       
4322         
4323         intPropertyLen = PropertySeg2.Len();
4324         SplitPoints.clear();
4325         SplitLength.clear();
4326         intSplitsFound = 0;
4327         intSplitSize = 0;
4328         intPrevValue = 0;
4329         
4330         CaptureString(&PropertySeg2, FALSE);
4331         
4332         // Add the data to the General/Home/Work address variables.
4333                 
4334         switch(PropType){
4335                 case PROPERTY_NONE:
4336                         break;
4337                 case PROPERTY_HOME:
4338                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
4339                         break;
4340                 case PROPERTY_WORK:
4341                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
4342                         break;
4343         }
4344         
4345         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
4346         
4347         if (!PropertyTokens.IsEmpty()){
4348         
4349                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
4350         
4351         }
4355 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
4357         size_t intPropertyLen = PropertySeg1.Len();
4358         std::map<int, int> SplitPoints;
4359         std::map<int, int> SplitLength;
4360         std::map<int, int>::iterator SLiter;                    
4361         wxString PropertyData;
4362         wxString PropertyName;
4363         wxString PropertyValue;
4364         wxString PropertyTokens;
4365         bool FirstToken = TRUE;
4366         int intSplitsFound = 0;
4367         int intSplitSize = 0;
4368         int intPrevValue = 5;
4369         
4370         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4371         
4372         intPrevValue = 4;
4373         
4374         PropertyType PropType = PROPERTY_NONE;
4375         
4376         // Look for type before continuing.
4378         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4380         intPrevValue = 4;
4381         bool PropertyMatched = FALSE;
4383         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4384         intiter != SplitPoints.end(); ++intiter){
4385         
4386                 SLiter = SplitLength.find(intiter->first);
4387                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4388                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4389                 intPrevValue = intiter->second;
4390                 
4391                 // Process properties.
4392                 
4393                 size_t intPropertyValueLen = PropertyValue.Len();
4394                 
4395                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4396                         
4397                         PropertyValue.Trim();
4398                         PropertyValue.RemoveLast();
4399                         
4400                 }                               
4401                 
4402                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4403                         
4404                         PropertyValue.Remove(0, 1);
4405                         
4406                 }
4407                 
4408                 ProcessStringValue(&PropertyName, "ALTID", &KeyListAltID, &PropertyValue, KeyCount, &PropertyMatched);
4409                 ProcessStringValue(&PropertyName, "PID", &KeyListPID, &PropertyValue, KeyCount, &PropertyMatched);
4410                 ProcessIntegerValue(&PropertyName, "PREF", &KeyListPref, &PropertyValue, KeyCount, &PropertyMatched);
4411                 
4412                 if (PropertyMatched == TRUE){
4413                 
4414                         PropertyMatched = FALSE;
4415                         continue;
4416                 
4417                 }
4419                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4420         
4421         }                               
4422         
4423         intPropertyLen = PropertySeg2.Len();
4424         SplitPoints.clear();
4425         SplitLength.clear();
4426         intSplitsFound = 0;
4427         intSplitSize = 0;
4428         intPrevValue = 0;                       
4429         
4430         for (int i = 0; i <= intPropertyLen; i++){
4432                 intSplitSize++;
4433         
4434                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4435         
4436                         intSplitsFound++;
4437                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4438                         
4439                         if (intSplitsFound == 6){ 
4440                         
4441                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4442                                 break; 
4443                                 
4444                         } else {
4445                         
4446                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4447                         
4448                         }
4449                         
4450                         intSplitSize = 0;                                       
4451         
4452                 }
4454         }
4455         
4456         wxString wxSKeyURI;
4457         wxString wxSKeyMIME;
4458         wxString wxSKeyEncoding;
4459         wxString wxSKeyData;
4460         std::string base64enc;
4461         
4462         if (intSplitsFound == 0){
4463         
4464         } else {
4465         
4466                 std::map<int, int>::iterator striter;
4467         
4468                 striter = SplitLength.find(1);
4469         
4470                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4471         
4472                 while (wSTDataType.HasMoreTokens() == TRUE){
4473                 
4474                         wxSKeyURI = wSTDataType.GetNextToken();
4475                         wxSKeyMIME = wSTDataType.GetNextToken();
4476                         break;
4477                 
4478                 }                       
4479         
4480                 if (wxSKeyURI == wxT("data")){
4481                 
4482                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4483         
4484                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4485                 
4486                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
4487                                 wxSKeyData = wSTDataInfo.GetNextToken();
4488                                 break;
4489                 
4490                         }
4491                 
4492                 }
4493         
4494         }
4495         
4496         // Add the data to the General/Home/Work address variables.
4497         
4498         if (wxSKeyURI == wxT("data")){
4499                 
4500                 KeyListDataEncType.erase(*KeyCount);
4501                 KeyListKeyType.erase(*KeyCount);
4502                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
4503                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
4504                 
4505                 KeyList.erase(*KeyCount);
4506                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
4507         
4508         } else {
4509                 
4510                 KeyList.erase(*KeyCount);
4511                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
4512         
4513         }
4514         
4515         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
4516                 
4517         switch (PropType){
4518                 case PROPERTY_NONE:
4519                         break;
4520                 case PROPERTY_HOME: 
4521                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
4522                         break;
4523                 case PROPERTY_WORK: 
4524                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
4525                         break;
4526         }
4528         if (!PropertyTokens.IsEmpty()){
4530                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
4532         }
4536 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
4538         // Split the Vendor three ways.
4539         
4540         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
4541         
4542         wxString wxSVNDID;
4543         wxString wxSVNDPropName;
4545         while (wSTVendorDetails.HasMoreTokens() == TRUE){
4546         
4547                 wSTVendorDetails.GetNextToken();
4548                 wxSVNDID = wSTVendorDetails.GetNextToken();
4549                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
4550                 break;
4551         
4552         }
4553         
4554         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
4555         
4556                 // Add the data to the vendor variables.
4557         
4558                 VendorList.erase(*VendorCount);
4559                 VendorListPEN.erase(*VendorCount);
4560                 VendorListElement.erase(*VendorCount);
4561         
4562                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
4563                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
4564                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
4565         
4566         }
4570 void ContactDataObject::ClearData(){
4572     NameTitle.clear();
4573     NameForename.clear();
4574     NameSurname.clear();
4575     NameOtherNames.clear();
4576     NameSuffix.clear();
4577     NameNickname.clear();
4578     NameDisplayAs.clear();
4579     NameLanguage.clear();
4580     NameAltID.clear();
4581     NameTokens.clear();
4582     
4583     Birthday.clear();
4584     BirthdayAltID.clear();
4585     BirthdayCalScale.clear();
4586     BirthdayTokens.clear();
4587     Anniversary.clear();
4588     AnniversaryAltID.clear();
4589     AnniversaryCalScale.clear();
4590     AnniversaryTokens.clear();
4591     
4592     Gender.clear();
4593     GenderDetails.clear();
4594     GenderTokens.clear();
4595     
4596     UIDToken.clear();
4597     Revision.clear();
4598     RevisionTokens.clear();
4599     
4600     SourceList.clear();
4601     SourceListAltID.clear();
4602     SourceListPID.clear();
4603     SourceListType.clear();
4604     SourceListTokens.clear();
4605     SourceListMediatype.clear();
4606     SourceListPref.clear();
4607     
4608     XMLList.clear();
4609     XMLListAltID.clear();
4610     
4611     ClientPIDList.clear();
4612     ClientPIDListTokens.clear();
4613     
4614     FullNamesList.clear();    
4615     FullNamesListType.clear();
4616     FullNamesListLanguage.clear();
4617     FullNamesListAltID.clear();
4618     FullNamesListPID.clear();
4619     FullNamesListTokens.clear();
4620     FullNamesListPref.clear();
4621     
4622     GeneralNicknamesList.clear();
4623     GeneralNicknamesListType.clear();
4624     GeneralNicknamesListLanguage.clear();
4625     GeneralNicknamesListAltID.clear();
4626     GeneralNicknamesListPID.clear();
4627     GeneralNicknamesListTokens.clear();        
4628     GeneralNicknamesListPref.clear();        
4629     
4630     GeneralAddressList.clear();
4631     GeneralAddressListTown.clear();
4632     GeneralAddressListCounty.clear();
4633     GeneralAddressListPostCode.clear();
4634     GeneralAddressListCountry.clear();
4635     GeneralAddressListLabel.clear();
4636     GeneralAddressListLang.clear();        
4637     GeneralAddressListAltID.clear();
4638     GeneralAddressListPID.clear();
4639     GeneralAddressListTokens.clear();
4640     GeneralAddressListGeo.clear();
4641     GeneralAddressListTimezone.clear();        
4642     GeneralAddressListType.clear();
4643     GeneralAddressListMediatype.clear();
4644     GeneralAddressListPref.clear();
4645     
4646     GeneralEmailList.clear();
4647     GeneralEmailListAltID.clear();
4648     GeneralEmailListPID.clear();
4649     GeneralEmailListType.clear();
4650     GeneralEmailListTokens.clear();
4651     GeneralEmailListPref.clear();
4652     
4653     GeneralIMList.clear();
4654     GeneralIMListAltID.clear();
4655     GeneralIMListPID.clear();
4656     GeneralIMListType.clear();
4657     GeneralIMListTypeInfo.clear();
4658     GeneralIMListTokens.clear();
4659     GeneralIMListMediatype.clear();
4660     GeneralIMListPref.clear();
4661     
4662     GeneralTelephoneList.clear();
4663     GeneralTelephoneListAltID.clear();
4664     GeneralTelephoneListPID.clear();
4665     GeneralTelephoneListType.clear();
4666     GeneralTelephoneListTokens.clear();
4667     GeneralTelephoneListTypeInfo.clear();
4668     GeneralTelephoneListPref.clear();
4669     
4670     GeneralLanguageList.clear();
4671     GeneralLanguageListAltID.clear();
4672     GeneralLanguageListPID.clear();
4673     GeneralLanguageListType.clear();
4674     GeneralLanguageListTokens.clear();
4675     GeneralLanguageListPref.clear();
4676     
4677     GeneralTZList.clear();
4678     GeneralTZListAltID.clear();
4679     GeneralTZListPID.clear();
4680     GeneralTZListType.clear();
4681     GeneralTZListTokens.clear();
4682     GeneralTZListMediatype.clear();
4683     GeneralTZListPref.clear();
4684     
4685     GeneralGeographyList.clear();
4686     GeneralGeographyListAltID.clear();
4687     GeneralGeographyListPID.clear();
4688     GeneralGeographyListType.clear();
4689     GeneralGeographyListTokens.clear();
4690     GeneralGeographyListMediatype.clear();
4691     GeneralGeographyListPref.clear();
4692     
4693     GeneralRelatedList.clear();
4694     GeneralRelatedListRelType.clear();
4695     GeneralRelatedListLanguage.clear();
4696     GeneralRelatedListAltID.clear();
4697     GeneralRelatedListPID.clear();
4698     GeneralRelatedListType.clear();
4699     GeneralRelatedListTokens.clear();
4700     GeneralRelatedListPref.clear();
4701     
4702     GeneralWebsiteList.clear();
4703     GeneralWebsiteListAltID.clear();
4704     GeneralWebsiteListPID.clear();
4705     GeneralWebsiteListType.clear();
4706     GeneralWebsiteListTokens.clear();
4707     GeneralWebsiteListMediatype.clear();
4708     GeneralWebsiteListPref.clear();
4709     
4710     GeneralTitleList.clear();
4711     GeneralTitleListLanguage.clear();        
4712     GeneralTitleListAltID.clear();
4713     GeneralTitleListPID.clear();
4714     GeneralTitleListType.clear();
4715     GeneralTitleListTokens.clear();
4716     GeneralTitleListPref.clear();
4717     
4718     GeneralRoleList.clear();
4719     GeneralRoleListLanguage.clear();        
4720     GeneralRoleListAltID.clear();
4721     GeneralRoleListPID.clear();
4722     GeneralRoleListType.clear();
4723     GeneralRoleListTokens.clear();
4724     GeneralRoleListPref.clear();
4725     
4726     GeneralOrganisationsList.clear();
4727     GeneralOrganisationsListLanguage.clear();        
4728     GeneralOrganisationsListAltID.clear();
4729     GeneralOrganisationsListPID.clear();
4730     GeneralOrganisationsListType.clear();
4731     GeneralOrganisationsListTokens.clear();
4732     GeneralOrganisationsListSortAs.clear();
4733     GeneralOrganisationsListPref.clear();
4734     
4735     GeneralNoteList.clear();
4736     GeneralNoteListLanguage.clear();        
4737     GeneralNoteListAltID.clear();
4738     GeneralNoteListPID.clear();
4739     GeneralNoteListType.clear();
4740     GeneralNoteListTokens.clear();
4741     GeneralNoteListPref.clear();
4742     
4743     /* Items on Home Tab */        
4744     
4745     HomeNicknamesList.clear();
4746     HomeNicknamesListType.clear();
4747     HomeNicknamesListLanguage.clear();
4748     HomeNicknamesListAltID.clear();
4749     HomeNicknamesListPID.clear();
4750     HomeNicknamesListTokens.clear();        
4751     HomeNicknamesListPref.clear();        
4752     
4753     HomeAddressList.clear();
4754     HomeAddressListTown.clear();
4755     HomeAddressListCounty.clear();
4756     HomeAddressListPostCode.clear();
4757     HomeAddressListCountry.clear();
4758     HomeAddressListLabel.clear();
4759     HomeAddressListLang.clear();        
4760     HomeAddressListAltID.clear();
4761     HomeAddressListPID.clear();
4762     HomeAddressListTokens.clear();
4763     HomeAddressListGeo.clear();
4764     HomeAddressListTimezone.clear();        
4765     HomeAddressListType.clear();
4766     HomeAddressListMediatype.clear();
4767     HomeAddressListPref.clear();
4768     
4769     HomeEmailList.clear();
4770     HomeEmailListAltID.clear();
4771     HomeEmailListPID.clear();
4772     HomeEmailListType.clear();
4773     HomeEmailListTokens.clear();
4774     HomeEmailListPref.clear();
4775     
4776     HomeIMList.clear();
4777     HomeIMListAltID.clear();
4778     HomeIMListPID.clear();
4779     HomeIMListType.clear();
4780     HomeIMListTypeInfo.clear();
4781     HomeIMListTokens.clear();
4782     HomeIMListMediatype.clear();
4783     HomeIMListPref.clear();
4784     
4785     HomeTelephoneList.clear();
4786     HomeTelephoneListAltID.clear();
4787     HomeTelephoneListPID.clear();
4788     HomeTelephoneListType.clear();
4789     HomeTelephoneListTokens.clear();
4790     HomeTelephoneListTypeInfo.clear();
4791     HomeTelephoneListPref.clear();
4792     
4793     HomeLanguageList.clear();
4794     HomeLanguageListAltID.clear();
4795     HomeLanguageListPID.clear();
4796     HomeLanguageListType.clear();
4797     HomeLanguageListTokens.clear();
4798     HomeLanguageListPref.clear();
4799     
4800     HomeTZList.clear();
4801     HomeTZListAltID.clear();
4802     HomeTZListPID.clear();
4803     HomeTZListType.clear();
4804     HomeTZListTokens.clear();
4805     HomeTZListMediatype.clear();
4806     HomeTZListPref.clear();
4807     
4808     HomeGeographyList.clear();
4809     HomeGeographyListAltID.clear();
4810     HomeGeographyListPID.clear();
4811     HomeGeographyListType.clear();
4812     HomeGeographyListTokens.clear();
4813     HomeGeographyListMediatype.clear();
4814     HomeGeographyListPref.clear();       
4815     
4816     HomeWebsiteList.clear();
4817     HomeWebsiteListAltID.clear();
4818     HomeWebsiteListPID.clear();
4819     HomeWebsiteListType.clear();
4820     HomeWebsiteListTokens.clear();
4821     HomeWebsiteListMediatype.clear();
4822     HomeWebsiteListPref.clear();
4823     
4824     HomeTitleList.clear();
4825     HomeTitleListLanguage.clear();
4826     HomeTitleListAltID.clear();
4827     HomeTitleListPID.clear();
4828     HomeTitleListType.clear();
4829     HomeTitleListTokens.clear();
4830     HomeTitleListPref.clear();
4831     
4832     HomeRoleList.clear();
4833     HomeRoleListLanguage.clear();        
4834     HomeRoleListAltID.clear();
4835     HomeRoleListPID.clear();
4836     HomeRoleListType.clear();
4837     HomeRoleListTokens.clear();
4838     HomeRoleListPref.clear();
4839     
4840     HomeOrganisationsList.clear();
4841     HomeOrganisationsListLanguage.clear();        
4842     HomeOrganisationsListAltID.clear();
4843     HomeOrganisationsListPID.clear();
4844     HomeOrganisationsListType.clear();
4845     HomeOrganisationsListTokens.clear();
4846     HomeOrganisationsListSortAs.clear();
4847     HomeOrganisationsListPref.clear();
4848     
4849     HomeNoteList.clear();
4850     HomeNoteListLanguage.clear();        
4851     HomeNoteListAltID.clear();
4852     HomeNoteListPID.clear();
4853     HomeNoteListType.clear();
4854     HomeNoteListTokens.clear();
4855     HomeNoteListPref.clear();        
4856     
4857     /* Items on the Business tab */
4858     
4859     BusinessNicknamesList.clear();
4860     BusinessNicknamesListType.clear();
4861     BusinessNicknamesListLanguage.clear();
4862     BusinessNicknamesListAltID.clear();
4863     BusinessNicknamesListPID.clear();
4864     BusinessNicknamesListTokens.clear();        
4865     BusinessNicknamesListPref.clear();        
4866     
4867     BusinessAddressList.clear();
4868     BusinessAddressListTown.clear();
4869     BusinessAddressListCounty.clear();
4870     BusinessAddressListPostCode.clear();
4871     BusinessAddressListCountry.clear();
4872     BusinessAddressListLabel.clear();
4873     BusinessAddressListLang.clear();        
4874     BusinessAddressListAltID.clear();
4875     BusinessAddressListPID.clear();
4876     BusinessAddressListTokens.clear();
4877     BusinessAddressListGeo.clear();
4878     BusinessAddressListTimezone.clear();        
4879     BusinessAddressListType.clear();
4880     BusinessAddressListMediatype.clear();
4881     BusinessAddressListPref.clear();
4882     
4883     BusinessEmailList.clear();
4884     BusinessEmailListAltID.clear();
4885     BusinessEmailListPID.clear();
4886     BusinessEmailListType.clear();
4887     BusinessEmailListTokens.clear();
4888     BusinessEmailListPref.clear();
4889     
4890     BusinessIMList.clear();
4891     BusinessIMListAltID.clear();
4892     BusinessIMListPID.clear();
4893     BusinessIMListType.clear();
4894     BusinessIMListTokens.clear();
4895     BusinessIMListMediatype.clear();
4896     BusinessIMListPref.clear();
4897     
4898     BusinessTelephoneList.clear();
4899     BusinessTelephoneListAltID.clear();
4900     BusinessTelephoneListPID.clear();
4901     BusinessTelephoneListType.clear();
4902     BusinessTelephoneListTokens.clear();
4903     BusinessTelephoneListPref.clear();
4904     
4905     BusinessLanguageList.clear();
4906     BusinessLanguageListAltID.clear();
4907     BusinessLanguageListPID.clear();
4908     BusinessLanguageListType.clear();
4909     BusinessLanguageListTokens.clear();
4910     BusinessLanguageListPref.clear();
4911     
4912     BusinessTZList.clear();
4913     BusinessTZListAltID.clear();
4914     BusinessTZListPID.clear();
4915     BusinessTZListType.clear();
4916     BusinessTZListTokens.clear();
4917     BusinessTZListMediatype.clear();
4918     BusinessTZListPref.clear();
4919     
4920     BusinessGeographyList.clear();
4921     BusinessGeographyListAltID.clear();
4922     BusinessGeographyListPID.clear();
4923     BusinessGeographyListType.clear();
4924     BusinessGeographyListTokens.clear();
4925     BusinessGeographyListMediatype.clear();
4926     BusinessGeographyListPref.clear();          
4927     
4928     BusinessWebsiteList.clear();
4929     BusinessWebsiteListAltID.clear();
4930     BusinessWebsiteListPID.clear();
4931     BusinessWebsiteListType.clear();
4932     BusinessWebsiteListTokens.clear();
4933     BusinessWebsiteListMediatype.clear();
4934     BusinessWebsiteListPref.clear();
4935     
4936     BusinessTitleList.clear();
4937     BusinessTitleListLanguage.clear();        
4938     BusinessTitleListAltID.clear();
4939     BusinessTitleListPID.clear();
4940     BusinessTitleListType.clear();
4941     BusinessTitleListTokens.clear();
4942     BusinessTitleListPref.clear();
4943     
4944     BusinessRoleList.clear();
4945     BusinessRoleListLanguage.clear();        
4946     BusinessRoleListAltID.clear();
4947     BusinessRoleListPID.clear();
4948     BusinessRoleListType.clear();
4949     BusinessRoleListTokens.clear();
4950     BusinessRoleListPref.clear();
4951     
4952     BusinessOrganisationsList.clear();
4953     BusinessOrganisationsListLanguage.clear();        
4954     BusinessOrganisationsListAltID.clear();
4955     BusinessOrganisationsListPID.clear();
4956     BusinessOrganisationsListType.clear();
4957     BusinessOrganisationsListTokens.clear();
4958     BusinessOrganisationsListSortAs.clear();        
4959     BusinessOrganisationsListPref.clear();
4960     
4961     BusinessNoteList.clear();
4962     BusinessNoteListLanguage.clear();        
4963     BusinessNoteListAltID.clear();
4964     BusinessNoteListPID.clear();
4965     BusinessNoteListType.clear();
4966     BusinessNoteListTokens.clear();
4967     BusinessNoteListPref.clear();        
4968     
4969     /* Items on the Categories tab */
4970     
4971     CategoriesList.clear();
4972     CategoriesListAltID.clear();
4973     CategoriesListPID.clear();
4974     CategoriesListType.clear();
4975     CategoriesListTokens.clear();
4976     CategoriesListLanguage.clear();
4977     CategoriesListPref.clear();    
4978     
4979     /* Items on the Groups tab */
4980     
4981     GroupsList.clear();
4982     GroupsListAltID.clear();
4983     GroupsListPID.clear();
4984     GroupsListType.clear();
4985     GroupsListMediaType.clear();
4986     GroupsListTokens.clear();
4987     GroupsListPref.clear();
4988     
4989     /* Items on the Pictures tab */
4990     
4991     PicturesList.clear();
4992     PicturesListAltID.clear();
4993     PicturesListPID.clear();
4994     PicturesListType.clear();
4995     PicturesListPicEncType.clear();
4996     PicturesListPictureType.clear();
4997     PicturesListTokens.clear();
4998     PicturesListMediatype.clear();        
4999     PicturesListPref.clear();
5000     
5001     /* Items on the Logos tab */
5002     
5003     LogosList.clear();
5004     LogosListAltID.clear();
5005     LogosListPID.clear();
5006     LogosListType.clear();
5007     LogosListPicEncType.clear();        
5008     LogosListPictureType.clear();
5009     LogosListTokens.clear();
5010     LogosListMediatype.clear();        
5011     LogosListPref.clear();
5012     
5013     /* Items on the Sounds tab */
5014     
5015     SoundsList.clear();
5016     SoundsListAltID.clear();
5017     SoundsListPID.clear();
5018     SoundsListType.clear();
5019     SoundsListAudioEncType.clear();        
5020     SoundsListAudioType.clear();        
5021     SoundsListTokens.clear();
5022     SoundsListMediatype.clear();        
5023     SoundsListPref.clear();    
5024     
5025     /* Items on the Calendaring tab */
5026     
5027     CalendarList.clear();
5028     CalendarListAltID.clear();
5029     CalendarListPID.clear();
5030     CalendarListType.clear();
5031     CalendarListTokens.clear();
5032     CalendarListMediatype.clear();        
5033     CalendarListPref.clear();
5034     
5035     CalendarRequestList.clear();
5036     CalendarRequestListAltID.clear();
5037     CalendarRequestListPID.clear();
5038     CalendarRequestListType.clear();
5039     CalendarRequestListTokens.clear();
5040     CalendarRequestListMediatype.clear();        
5041     CalendarRequestListPref.clear();        
5042     
5043     FreeBusyList.clear();
5044     FreeBusyListAltID.clear();
5045     FreeBusyListPID.clear();
5046     FreeBusyListType.clear();
5047     FreeBusyListTokens.clear();
5048     FreeBusyListMediatype.clear();        
5049     FreeBusyListPref.clear();
5050     
5051     /* Items on the Security tab */
5052     
5053     KeyList.clear();
5054     KeyListAltID.clear();
5055     KeyListPID.clear();
5056     KeyListKeyType.clear();        
5057     KeyListDataType.clear();        
5058     KeyListDataEncType.clear();
5059     KeyListType.clear();
5060     KeyListTokens.clear();
5061     KeyListPref.clear();
5062     
5063     /* Items on the Other tab */
5064     
5065     VendorList.clear();
5066     VendorListPEN.clear();
5067     VendorListElement.clear();
5068     
5069     XTokenList.clear();
5070     XTokenListTokens.clear();
5074 void ProcessNameValue(wxString *PropertyData, 
5075         wxString *PropertyName, 
5076         wxString *PropertyValue){
5078         wxStringTokenizer PropertyElement (*PropertyData, wxT("="));
5079         *PropertyName = PropertyElement.GetNextToken();                         
5080         *PropertyValue = PropertyElement.GetNextToken();
5084 void ProcessTokens(wxString *PropertyName,
5085         wxString *PropertyValue,
5086         wxString *PropertyTokens,
5087         bool *FirstToken){
5088         
5089         if (!PropertyName->IsEmpty() && !PropertyValue->IsEmpty() && *PropertyName != wxT("TYPE")){
5090                 
5091                 if (*FirstToken == TRUE){
5092                         
5093                         PropertyTokens->Append(*PropertyName + wxT("=") + *PropertyValue);
5094                         *FirstToken = FALSE;
5095                         
5096                 } else {
5097                         
5098                         PropertyTokens->Append(wxT(";") + *PropertyName + wxT("=") + *PropertyValue);
5099                         
5100                 }
5101                 
5102         }
5103         
5106 void ProcessStringValue(wxString *PropertyName,
5107         wxString PropertyNameMatch,
5108         std::map<int,wxString> *MapPtr,
5109         wxString *PropertyValue,
5110         int *ItemCount,
5111         bool *PropertyMatched){
5112         
5113         if (*PropertyName == PropertyNameMatch){
5114                 MapPtr->erase(*ItemCount);
5115                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5116                 *PropertyMatched = TRUE;
5117         }
5118         
5121 void ProcessIntegerValue(wxString *PropertyName,
5122         wxString PropertyNameMatch,
5123         std::map<int,int> *PrefPtr, 
5124         wxString *PropertyValue, 
5125         int *ItemCount,
5126         bool *PropertyMatched){
5128         if (*PropertyName == PropertyNameMatch){
5129                 *PropertyMatched = TRUE;
5130         } else {
5131                 return;
5132         }
5134         int PriorityNumber = 0; 
5135         bool ValidNumber = TRUE;
5136                         
5137         try{
5138                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5139         }
5140                         
5141         catch(std::invalid_argument &e){
5142                 ValidNumber = FALSE;
5143         }
5145         if (ValidNumber == TRUE){
5147                 PrefPtr->erase(*ItemCount);
5148                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5150         }
5154 void SplitValues(wxString *PropertyLine, 
5155         std::map<int,int> *SplitPoints, 
5156         std::map<int,int> *SplitLength, 
5157         int intSize){
5158         
5159         size_t intPropertyLen = PropertyLine->Len();
5160         int intSplitsFound = 0;
5161         int intSplitSize = 0;
5162         int intSplitSeek = 0;
5163         
5164         for (int i = intSize; i <= intPropertyLen; i++){
5166                 intSplitSize++;
5167         
5168                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5169                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5170            
5171                     if (intSplitsFound == 0){
5172             
5173                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5174           
5175                     } else {
5176            
5177                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5178             
5179                     }
5180             
5181                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5182             
5183                     intSplitsFound++;
5184                     intSplitSeek = i;
5185                     intSplitSize = 0;
5186             
5187                 }
5189         }
5191         if (intSplitsFound == 0){
5193                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5194                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5196         } else {
5198                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5199                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5201         }
5205 void CheckType(wxString *PropertySeg1, 
5206         std::map<int,int> *SplitPoints, 
5207         std::map<int,int> *SplitLength, 
5208         int *intPrevValue, 
5209         PropertyType *PropType){
5210         
5211         wxString PropertyData;
5212         wxString PropertyName;
5213         wxString PropertyValue;
5214         std::map<int,int>::iterator SLiter;
5215         
5216         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5217         intiter != SplitPoints->end(); ++intiter){
5218         
5219                 SLiter = SplitLength->find(intiter->first);     
5220                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5221                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);         
5222                 *intPrevValue = intiter->second;
5223                 
5224                 if (PropertyName == wxT("TYPE")){
5225                                 
5226                         if (PropertyValue == wxT("work")){
5227                         
5228                                 *PropType = PROPERTY_WORK;
5229                                                         
5230                         } else if (PropertyValue == wxT("home")){
5232                                 *PropType = PROPERTY_HOME;
5233                                                         
5234                         } else {
5235                         
5236                                 *PropType = PROPERTY_NONE;
5237                         
5238                         }
5239                 
5240                         return;
5241                 
5242                 }
5243         
5244         }
5245         
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