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