Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented ProcessNameValue into ContactDataObject.
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2015 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("LOGO")) {
379                 
380                         // See frmContactEditor-LoadPhoto.cpp
381                         
382                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
383                         LogoCount++;
385                 } else if (Property == wxT("SOUND")) {
386                 
387                         // See frmContactEditor-LoadSound.cpp
388                         
389                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
390                         SoundCount++;
391                         
392                 } else if (Property == wxT("CALURI")){
394                         // See frmContactEditor-LoadCalendar.cpp
395                         
396                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
397                         CalendarCount++;
398                 
399                 } else if (Property == wxT("CALADRURI")){
400                 
401                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402                         CalendarAddressCount++;
403                 
404                 } else if (Property == wxT("FBURL")){
406                         // See frmContactEditor-LoadCalendar.cpp
408                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409                         FreeBusyAddressCount++;
411                 } else if (Property == wxT("KEY")){
412                 
413                         // See frmContactEditor-LoadKey.cpp
414                         
415                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
416                         KeyCount++;
417                 
418                 } else if (Property.Mid(0, 3) == wxT("VND")){
419                 
420                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
421                         VendorCount++;
422                 
423                 } else if (Property.Mid(0, 2) == wxT("X-")){
424                         
425                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
427                         XTokenCount++;
428                 
429                 }
430                 
431         }
432         
433         return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439         if (KindType == wxT("individual")){
440                         
441                 ContactKind = CONTACTKIND_INDIVIDUAL;
442                         
443         } else if (KindType == wxT("group")){
444                         
445                 ContactKind = CONTACTKIND_GROUP;
446                         
447         } else if (KindType == wxT("org")){
448                         
449                 ContactKind = CONTACTKIND_ORGANISATION;
450                         
451         } else if (KindType == wxT("location")){
452                         
453                 ContactKind = CONTACTKIND_LOCATION;
454                         
455         } else {
456                         
457                 ContactKind = CONTACTKIND_NONE;                 
458         }
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464         size_t intPropertyLen = PropertySeg1.Len();
465         std::map<int, int> SplitPoints;
466         std::map<int, int> SplitLength;
467         std::map<int, int>::iterator SLiter;                    
468         wxString PropertyData;
469         wxString PropertyName;
470         wxString PropertyValue;
471         wxString PropertyTokens;
472         bool FirstToken = TRUE;
473         int intSplitsFound = 0;
474         int intSplitSize = 0;
475         int intPrevValue = 5;
476         int intPref = 0;                        
477         int intType = 0;
478         
479         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
480         
481         intPrevValue = 4;
483         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
484         intiter != SplitPoints.end(); ++intiter){
485         
486                 SLiter = SplitLength.find(intiter->first);
487                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
488                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
489                 intPrevValue = intiter->second;
490                 
491                 // Process properties.
492                 
493                 size_t intPropertyValueLen = PropertyValue.Len();
494                 
495                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
496                         
497                         PropertyValue.Trim();
498                         PropertyValue.RemoveLast();
499                         
500                 }                               
501                 
502                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
503                         
504                         PropertyValue.Remove(0, 1);
505                         
506                 }                       
507                 
508                 CaptureString(&PropertyValue, FALSE);
509                 
510                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
511         
512         }       
513         
514         CaptureString(&PropertySeg2, FALSE);
515         
516         Revision = PropertySeg2;
517         
518         if (!PropertyTokens.IsEmpty()){
519         
520                 RevisionTokens = PropertyTokens;
521         
522         }
527 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
529         size_t intPropertyLen = PropertySeg1.Len();
530         std::map<int, int> SplitPoints;
531         std::map<int, int> SplitLength;
532         std::map<int, int>::iterator SLiter;                    
533         wxString PropertyData;
534         wxString PropertyName;
535         wxString PropertyValue;
536         wxString PropertyTokens;
537         bool FirstToken = TRUE;
538         bool PropertyMatched = FALSE;
539         int intSplitsFound = 0;
540         int intSplitSize = 0;
541         int intPrevValue = 8;
542         int intPref = 0;                        
543         int intType = 0;
544         
545         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
546         
547         intPrevValue = 7;
548         
549         PropertyType PropType = PROPERTY_NONE;
550         
551         // Look for type before continuing.                     
553         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
555         intPrevValue = 7;
557         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
558         intiter != SplitPoints.end(); ++intiter){
559         
560                 SLiter = SplitLength.find(intiter->first);
561         
562                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
563                 
564                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
565                 
566                 intPrevValue = intiter->second;
567                 
568                 // Process properties.
569                 
570                 size_t intPropertyValueLen = PropertyValue.Len();
571                 
572                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
573                         
574                         PropertyValue.Trim();
575                         PropertyValue.RemoveLast();
576                         
577                 }                               
578                 
579                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
580                         
581                         PropertyValue.Remove(0, 1);
582                         
583                 }                       
584                 
585                 CaptureString(&PropertyValue, FALSE);
586                 
587                 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
588                 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
589                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
590                 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
591                 
592                 if (PropertyMatched == TRUE){
593                 
594                         PropertyMatched = FALSE;
595                         continue;
596                 
597                 }
598                 
599                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
600         
601         }       
602         
603         intPropertyLen = PropertySeg2.Len();
604         SplitPoints.clear();
605         SplitLength.clear();
606         intSplitsFound = 0;
607         intSplitSize = 0;
608         intPrevValue = 0;
609         
610         CaptureString(&PropertySeg2, FALSE);
611         
612         // Add the data to the General/Home/Work address variables.
613                 
614         switch(PropType){
615                 case PROPERTY_NONE:
616                         break;
617                 case PROPERTY_HOME:
618                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
619                         break;
620                 case PROPERTY_WORK:
621                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
622                         break;
623         }
624         
625         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
626         
627         if (!PropertyTokens.IsEmpty()){
628         
629                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
630         
631         }
635 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
637         std::map<int, int> SplitPoints;
638         std::map<int, int> SplitLength;
640         int intPrevValue = 5;
641         int intPref = 0;                        
642         int intType = 0;
643         
644         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
646         intPrevValue = 4;
647         
648         wxString PropertyName;
649         wxString PropertyValue;
650         wxString PropertyData;
651         wxString PropertyTokens;
652         std::map<int,int>::iterator SLiter;
653         bool FirstToken = TRUE;
654         bool PropertyMatched = FALSE;
655         
656         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
657         intiter != SplitPoints.end(); ++intiter){
658         
659                 SLiter = SplitLength.find(intiter->first);
660                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
661                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
662                 intPrevValue = intiter->second;
663                 
664                 CaptureString(&PropertyValue, FALSE);
665         
666                 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
667                 
668                 if (PropertyMatched == TRUE){
669                 
670                         PropertyMatched = FALSE;
671                         continue;
672                 
673                 }
674                 
675         }
677         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
681 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
683         std::map<int, int> SplitPoints;
684         std::map<int, int> SplitLength;
686         int intPrevValue = 8;
687         int intPref = 0;                        
688         int intType = 0;
689         
690         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
692         intPrevValue = 7;
693         
694         wxString PropertyName;
695         wxString PropertyValue;
696         wxString PropertyData;
697         wxString PropertyTokens;
698         std::map<int,int>::iterator SLiter;
699         bool FirstToken = TRUE;
700         bool PropertyMatched = FALSE;
701         
702         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
703         intiter != SplitPoints.end(); ++intiter){
704         
705                 SLiter = SplitLength.find(intiter->first);
706                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
707                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
708                 intPrevValue = intiter->second;
709                 
710                 CaptureString(&PropertyValue, FALSE);
711         
712                 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
713                 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
714                 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
715                 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
716                 
717                 if (PropertyMatched == TRUE){
718                 
719                         PropertyMatched = FALSE;
720                         continue;
721                 
722                 }
723                 
724                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
725                 
726         }
728         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
730         if (!PropertyTokens.IsEmpty()){
731         
732                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
733         
734         }
739 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
741         std::map<int, int> SplitPoints;
742         std::map<int, int> SplitLength;
744         int intPrevValue = 4;
745         int intPref = 0;                        
746         int intType = 0;
747         
748         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
750         intPrevValue = 3;
751         
752         wxString PropertyName;
753         wxString PropertyValue;
754         wxString PropertyData;
755         wxString PropertyTokens;
756         std::map<int,int>::iterator SLiter;
757         bool FirstToken = TRUE;
758         bool PropertyMatched = FALSE;
759         
760         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
761         intiter != SplitPoints.end(); ++intiter){
762         
763                 SLiter = SplitLength.find(intiter->first);
764                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
765                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue); 
766                 intPrevValue = intiter->second;
767                 
768                 CaptureString(&PropertyValue, FALSE);
769                 
770                 if (PropertyName == wxT("TYPE")){
772                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
773                                 PropertyValue == wxT("work") ){
775                                 FullNamesListType.erase(*FNCount);
776                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
777                 
778                         }
779                         
780                         PropertyMatched = TRUE;
781                 
782                 }
783                 
784                 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
785                 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
786                 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
787                 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
788                 
789                 if (PropertyMatched == TRUE){
790                 
791                         PropertyMatched = FALSE;
792                         continue;
793                 
794                 }
795                 
796                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
797         
798         }
800         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
802         if (!PropertyTokens.IsEmpty()){
803         
804                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
805         
806         }
810 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
812         std::map<int, int> SplitPoints;
813         std::map<int, int> SplitLength;
815         int intPrevValue = 3;
816         int intPref = 0;                        
817         int intType = 0;
818         
819         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
820         
821         intPrevValue = 2;
822         
823         wxString PropertyName;
824         wxString PropertyValue;
825         wxString PropertyData;
826         wxString PropertyTokens;
827         std::map<int,int>::iterator SLiter;
828         bool FirstToken = TRUE;
829         
830         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
831         intiter != SplitPoints.end(); ++intiter){
832         
833                 SLiter = SplitLength.find(intiter->first);
834                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
835                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
836                 intPrevValue = intiter->second;
837                 
838                 CaptureString(&PropertyValue, FALSE);
839                 
840                 if (PropertyName == wxT("ALTID")){
842                         NameAltID = PropertyValue;
843                 
844                 } else if (PropertyName == wxT("LANGUAGE")){
845                 
846                         NameLanguage = PropertyValue;
847                 
848                 } else if (PropertyName == wxT("SORT-AS")){
849                 
850                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
851                                 PropertyValue.Len() >= 3){
852                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
853                         }
854                 
855                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
856                         
857                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
858                         
859                 }
860         
861         }
862         
863         // Split the name data.
864         
865         int intSplitSeek = 0;           
866         int intSplitsFound = 0;
867         int intSplitSize = 0;
868         int intPropertyLen = PropertySeg2.Len();
869         
870         std::map<int,wxString> NameValues;
871         intPrevValue = 0;                                       
872         
873         for (int i = 0; i <= intPropertyLen; i++){
874         
875                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
876                         
877                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
878                         
879                         intSplitSeek = i;
880                         intSplitSeek++;
881                         
882                         if (intSplitsFound == 4){
883                         
884                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
885                                 break;
886                         
887                         }
888                         
889                         intSplitSize = 0;
890                         continue;
891         
892                 }
893                 
894                 intSplitSize++;
896         }
897         
898         // Split the data into several parts.
899                         
900         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
901         iter != NameValues.end(); ++iter){
902         
903                 if (iter->first == 1){
904                 
905                         // Deal with family name.
906                         
907                         NameSurname = iter->second;
908                 
909                 } else if (iter->first == 2){
910                 
911                         // Deal with given names.
912                         
913                         NameForename = iter->second;
914                 
915                 } else if (iter->first == 3){
916                 
917                         // Deal with additional names.
918                         
919                         NameOtherNames = iter->second;
920                 
921                 } else if (iter->first == 4){
922                 
923                         // Deal with honorifix prefixes and suffixes.
925                         NameTitle = iter->second;
926                 
927                         iter++;
928                         
929                         if (iter == NameValues.end()){
930                         
931                                 break;
932                         
933                         }
934                 
935                         NameSuffix = iter->second;
936                 
937                 }
938         
939         }
940         
941         // Add the name token data.
942         
943         if (!PropertyTokens.IsEmpty()){
944         
945                 NameTokens = PropertyTokens;
946         
947         }
951 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
953         size_t intPropertyLen = PropertySeg1.Len();
954         std::map<int, int> SplitPoints;
955         std::map<int, int> SplitLength;
956         std::map<int, int>::iterator SLiter;                    
957         wxString PropertyData;
958         wxString PropertyName;
959         wxString PropertyValue;
960         wxString PropertyTokens;
961         bool FirstToken = TRUE;
962         int intSplitsFound = 0;
963         int intSplitSize = 0;
964         int intPrevValue = 14;
965         int intPref = 0;                        
966         int intType = 0;
967         
968         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
969         
970         intPrevValue = 13;
972         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
973         intiter != SplitPoints.end(); ++intiter){
974         
975                 SLiter = SplitLength.find(intiter->first);
976                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
977                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
978                 intPrevValue = intiter->second;
979                 
980                 // Process properties.
981                                 
982                 CaptureString(&PropertyValue, FALSE);
983                                         
984                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
985         
986         }       
987         
988         CaptureString(&PropertySeg2, FALSE);
989         
990         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
991         
992         if (!PropertyTokens.IsEmpty()){
993         
994                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
995         
996         }
1000 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1002         std::map<int, int> SplitPoints;
1003         std::map<int, int> SplitLength;
1005         int intPrevValue = 10;
1006         int intPref = 0;                        
1007         
1008         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1009         
1010         intPrevValue = 9;
1011         
1012         PropertyType PropType = PROPERTY_NONE;
1013         
1014         // Look for type before continuing.
1015         
1016         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1017         
1018         intPrevValue = 9;
1019         
1020         std::map<int, wxString> *NicknamesList = NULL;
1021         std::map<int, wxString> *NicknamesListType = NULL;
1022         std::map<int, wxString> *NicknamesListLanguage = NULL;
1023         std::map<int, wxString> *NicknamesListAltID = NULL;
1024         std::map<int, wxString> *NicknamesListPID = NULL;
1025         std::map<int, wxString> *NicknamesListTokens = NULL;            
1026         std::map<int, int> *NicknamesListPref = NULL;
1027         
1028         switch(PropType){
1029                 case PROPERTY_NONE:
1030                         NicknamesList = &GeneralNicknamesList;
1031                         NicknamesListType = &GeneralNicknamesListType;
1032                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1033                         NicknamesListAltID = &GeneralNicknamesListAltID;
1034                         NicknamesListPID = &GeneralNicknamesListPID;
1035                         NicknamesListTokens = &GeneralNicknamesListTokens;
1036                         NicknamesListPref = &GeneralNicknamesListPref;
1037                         break;
1038                 case PROPERTY_HOME:
1039                         NicknamesList = &HomeNicknamesList;
1040                         NicknamesListType = &HomeNicknamesListType;
1041                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1042                         NicknamesListAltID = &HomeNicknamesListAltID;
1043                         NicknamesListPID = &HomeNicknamesListPID;
1044                         NicknamesListTokens = &HomeNicknamesListTokens;
1045                         NicknamesListPref = &HomeNicknamesListPref;
1046                         break;
1047                 case PROPERTY_WORK:
1048                         NicknamesList = &BusinessNicknamesList;
1049                         NicknamesListType = &BusinessNicknamesListType;
1050                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1051                         NicknamesListAltID = &BusinessNicknamesListAltID;
1052                         NicknamesListPID = &BusinessNicknamesListPID;
1053                         NicknamesListTokens = &BusinessNicknamesListTokens;
1054                         NicknamesListPref = &BusinessNicknamesListPref;
1055                         break;
1056         }
1057         
1058         std::map<int, int>::iterator SLiter;    
1059         wxString PropertyData;
1060         wxString PropertyName;
1061         wxString PropertyValue;
1062         wxString PropertyTokens;
1063         bool FirstToken = TRUE;
1064         bool PropertyMatched = FALSE;
1065         
1066         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1067         intiter != SplitPoints.end(); ++intiter){
1068         
1069                 SLiter = SplitLength.find(intiter->first);
1070                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1071                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1072                 intPrevValue = intiter->second;
1073                 
1074                 CaptureString(&PropertyValue, FALSE);
1075                 
1076                 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1077                 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1078                 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1079                 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1080                 
1081                 if (PropertyMatched == TRUE){
1082                 
1083                         PropertyMatched = FALSE;
1084                         continue;
1085                 
1086                 }
1087                 
1088                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1089                 
1090         }
1091         
1092         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1093         
1094         // Add the name token data.
1095         
1096         if (!PropertyTokens.IsEmpty()){
1097         
1098                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1099         
1100         }
1104 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1106         std::map<int, int> SplitPoints;
1107         std::map<int, int> SplitLength;
1108         std::map<int, int>::iterator SLiter;                    
1109         wxString PropertyData;
1110         wxString PropertyName;
1111         wxString PropertyValue;
1112         wxString PropertyTokens;
1113         bool FirstToken = TRUE;
1114         int intPrevValue = 8;
1116         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1118         intPrevValue = 7;                       
1119         
1120         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1121         intiter != SplitPoints.end(); ++intiter){
1122         
1123                 SLiter = SplitLength.find(intiter->first);
1124                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1125                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1126                 intPrevValue = intiter->second;
1127                 
1128                 // Process properties.
1129                 
1130                 size_t intPropertyValueLen = PropertyValue.Len();
1131                 
1132                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1133                         
1134                         PropertyValue.Trim();
1135                         PropertyValue.RemoveLast();
1136                         
1137                 }                               
1138                 
1139                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1140                         
1141                         PropertyValue.Remove(0, 1);
1142                         
1143                 }                               
1144                 
1145                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1146         
1147         }       
1149         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1150         
1151         wxString GenderComponent;
1152         
1153         if (GenderData.CountTokens() >= 2){
1154         
1155                 Gender = GenderData.GetNextToken();
1156                 GenderDetails = GenderData.GetString();
1157         
1158                 CaptureString(&GenderDetails, FALSE);
1159                                                 
1160         } else {
1161         
1162                 Gender = GenderData.GetNextToken();
1163         
1164         }
1165         
1166         if (!PropertyTokens.IsEmpty()){
1167         
1168                 GenderTokens = PropertyTokens;
1169         
1170         }
1174 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1176         // Process date. Preserve the remainder in the string.
1178         std::map<int, int> SplitPoints;
1179         std::map<int, int> SplitLength;
1180         std::map<int, int>::iterator SLiter;                    
1181         wxString PropertyData;
1182         wxString PropertyName;
1183         wxString PropertyValue;
1184         wxString PropertyTokens;
1185         bool BirthdayText = FALSE;
1186         int intPrevValue = 6;
1188         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1190         intPrevValue = 5;
1192         // Look for type before continuing.
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                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1203         
1204                         CaptureString(&PropertySeg2, FALSE);
1205                         Birthday = PropertySeg2;
1206                         BirthdayText = TRUE;
1207         
1208                 }
1210         }
1212         // Setup blank lines for later on.
1213         
1214         intPrevValue = 5;
1215         bool FirstToken = TRUE;
1217         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1218         intiter != SplitPoints.end(); ++intiter){
1220                 SLiter = SplitLength.find(intiter->first);
1221                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1222                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1223                 intPrevValue = intiter->second;
1224         
1225                 // Process properties.
1226         
1227                 CaptureString(&PropertyValue, FALSE);
1228         
1229                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1230                 
1231                         PropertyValue.Trim();
1232                         PropertyValue.RemoveLast();
1233                 
1234                 }                               
1235         
1236                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1237                 
1238                         PropertyValue.Remove(0, 1);
1239                 
1240                 }                               
1241         
1242                 if (PropertyName == wxT("ALTID")){
1244                         BirthdayAltID = PropertyValue;
1245         
1246                 } else if (PropertyName == wxT("CALSCALE")){
1247         
1248                         BirthdayCalScale = PropertyValue;
1249         
1250                 } else if (PropertyName != wxT("VALUE")) {
1251         
1252                         // Something else we don't know about so append
1253                         // to the tokens variable.
1254                 
1255                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1256                         
1257                 }
1259         }       
1261         // Add the data to the variables and form.
1262         
1263         if (BirthdayText == FALSE){
1264         
1265                 Birthday = PropertySeg2;
1267         }
1268         
1269         if (!PropertyTokens.IsEmpty()){
1270         
1271                 BirthdayTokens = PropertyTokens;
1273         }
1277 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1279         // Process date. Preserve the remainder in the string.
1281         std::map<int, int> SplitPoints;
1282         std::map<int, int> SplitLength;
1283         std::map<int, int>::iterator SLiter;                    
1284         wxString PropertyData;
1285         wxString PropertyName;
1286         wxString PropertyValue;
1287         wxString PropertyTokens;
1288         bool AnniversaryText = FALSE;
1289         int intPrevValue = 13;
1291         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1293         intPrevValue = 12;
1295         // Look for type before continuing.
1297         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1298         intiter != SplitPoints.end(); ++intiter){
1300                 SLiter = SplitLength.find(intiter->first);
1301                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1302                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1303                 intPrevValue = intiter->second;
1304         
1305                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1306         
1307                         CaptureString(&PropertySeg2, FALSE);
1308                         Anniversary = PropertySeg2;
1309                         AnniversaryText = TRUE;
1310         
1311                 }
1313         }
1315         // Setup blank lines for later on.
1316         
1317         intPrevValue = 12;
1318         bool FirstToken = TRUE;
1320         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1321         intiter != SplitPoints.end(); ++intiter){
1323                 SLiter = SplitLength.find(intiter->first);
1324                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1325                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1326                 intPrevValue = intiter->second;
1327         
1328                 // Process properties.
1329         
1330                 CaptureString(&PropertyValue, FALSE);
1331         
1332                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1333                 
1334                         PropertyValue.Trim();
1335                         PropertyValue.RemoveLast();
1336                 
1337                 }                               
1338         
1339                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1340                 
1341                         PropertyValue.Remove(0, 1);
1342                 
1343                 }                               
1344         
1345                 if (PropertyName == wxT("ALTID")){
1347                         AnniversaryAltID = PropertyValue;
1348         
1349                 } else if (PropertyName == wxT("CALSCALE")){
1350         
1351                         AnniversaryCalScale = PropertyValue;
1352         
1353                 } else if (PropertyName != wxT("VALUE")) {
1354         
1355                         // Something else we don't know about so append
1356                         // to the tokens variable.
1357                 
1358                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1359                         
1360                 }
1362         }       
1364         // Add the data to the variables and form.
1365         
1366         if (AnniversaryText == FALSE){
1367         
1368                 Anniversary = PropertySeg2;
1370         }
1371         
1372         if (!PropertyTokens.IsEmpty()){
1373         
1374                 AnniversaryTokens = PropertyTokens;
1376         }
1380 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1382         std::map<int, int> SplitPoints;
1383         std::map<int, int> SplitLength;
1385         int intPrevValue = 4;
1386         int intPref = 0;                        
1387         
1388         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1389         
1390         intPrevValue = 3;
1391         
1392         PropertyType PropType = PROPERTY_NONE;
1393         
1394         // Look for type before continuing.
1395         
1396         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1397         
1398         intPrevValue = 3;
1399         
1400         std::map<int, wxString> *TZList = NULL;
1401         std::map<int, wxString> *TZListType = NULL;
1402         std::map<int, wxString> *TZListMediatype = NULL;
1403         std::map<int, wxString> *TZListAltID = NULL;
1404         std::map<int, wxString> *TZListPID = NULL;
1405         std::map<int, wxString> *TZListTokens = NULL;           
1406         std::map<int, int> *TZListPref = NULL;
1407         
1408         switch(PropType){
1409                 case PROPERTY_NONE:
1410                         TZList = &GeneralTZList;
1411                         TZListType = &GeneralTZListType;
1412                         TZListMediatype = &GeneralTZListMediatype;
1413                         TZListAltID = &GeneralTZListAltID;
1414                         TZListPID = &GeneralTZListPID;
1415                         TZListTokens = &GeneralTZListTokens;
1416                         TZListPref = &GeneralTZListPref;
1417                         break;
1418                 case PROPERTY_HOME:
1419                         TZList = &HomeTZList;
1420                         TZListType = &HomeTZListType;
1421                         TZListMediatype = &HomeTZListMediatype;
1422                         TZListAltID = &HomeTZListAltID;
1423                         TZListPID = &HomeTZListPID;
1424                         TZListTokens = &HomeTZListTokens;
1425                         TZListPref = &HomeTZListPref;
1426                         break;
1427                 case PROPERTY_WORK:
1428                         TZList = &BusinessTZList;
1429                         TZListType = &BusinessTZListType;
1430                         TZListMediatype = &BusinessTZListMediatype;
1431                         TZListAltID = &BusinessTZListAltID;
1432                         TZListPID = &BusinessTZListPID;
1433                         TZListTokens = &BusinessTZListTokens;
1434                         TZListPref = &BusinessTZListPref;
1435                         break;
1436         }
1437         
1438         std::map<int, int>::iterator SLiter;    
1439         wxString PropertyData;
1440         wxString PropertyName;
1441         wxString PropertyValue;
1442         wxString PropertyTokens;
1443         bool FirstToken = TRUE;
1444         bool PropertyMatched = FALSE;
1445         
1446         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1447         intiter != SplitPoints.end(); ++intiter){
1448         
1449                 SLiter = SplitLength.find(intiter->first);      
1450                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1451                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1452                 intPrevValue = intiter->second;
1453                 
1454                 CaptureString(&PropertyValue, FALSE);
1456                 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1457                 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1458                 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1459                 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1460                 
1461                 if (PropertyMatched == TRUE){
1462                 
1463                         PropertyMatched = FALSE;
1464                         continue;
1465                 
1466                 }
1468                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1469         
1470                         ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1471         
1472                 }
1473                 
1474         }
1475         
1476         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1477         
1478         // Add the name token data.
1479         
1480         if (!PropertyTokens.IsEmpty()){
1481         
1482                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1483         
1484         }
1489 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1491         size_t intPropertyLen = PropertySeg1.Len();
1492         std::map<int, int> SplitPoints;
1493         std::map<int, int> SplitLength;
1494         std::map<int, int>::iterator SLiter;                    
1495         wxString PropertyData;
1496         wxString PropertyName;
1497         wxString PropertyValue;
1498         wxString PropertyTokens;
1499         wxString AddressLabel;
1500         wxString AddressLang;
1501         wxString AddressAltID;
1502         wxString AddressPID;
1503         wxString AddressTokens;
1504         wxString AddressGeo;
1505         wxString AddressTimezone;
1506         wxString AddressType;
1507         wxString AddressMediatype;
1508         wxString AddressPOBox;
1509         wxString AddressExtended;
1510         wxString AddressStreet;
1511         wxString AddressLocality;
1512         wxString AddressCity;
1513         wxString AddressRegion;
1514         wxString AddressPostalCode;
1515         wxString AddressCountry;
1516         bool FirstToken = TRUE;                 
1517         int intSplitsFound = 0;
1518         int intSplitSize = 0;
1519         int intPrevValue = 5;
1520         int intPref = 0;                        
1521         int intType = 0;
1522         long ListCtrlIndex;
1523         bool PropertyMatched = FALSE;
1524         
1525         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1526         
1527         intPrevValue = 4;
1528         
1529         PropertyType PropType = PROPERTY_NONE;
1530                 
1531         // Look for type before continuing.
1532         
1533         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1534         
1535         intPrevValue = 4;
1536         
1537         std::map<int, wxString> *AddressList = NULL;
1538         std::map<int, wxString> *AddressListTown = NULL;
1539         std::map<int, wxString> *AddressListCounty = NULL;
1540         std::map<int, wxString> *AddressListPostCode = NULL;
1541         std::map<int, wxString> *AddressListCountry = NULL;
1542         std::map<int, wxString> *AddressListLabel = NULL;
1543         std::map<int, wxString> *AddressListLang = NULL;                
1544         std::map<int, wxString> *AddressListAltID = NULL;
1545         std::map<int, wxString> *AddressListPID = NULL;
1546         std::map<int, wxString> *AddressListTokens = NULL;
1547         std::map<int, wxString> *AddressListGeo = NULL;
1548         std::map<int, wxString> *AddressListTimezone = NULL;            
1549         std::map<int, wxString> *AddressListType = NULL;
1550         std::map<int, wxString> *AddressListMediatype = NULL;
1551         std::map<int, int> *AddressListPref = NULL;
1553         switch(PropType){
1554                 case PROPERTY_NONE:
1555                         AddressList = &GeneralAddressList;
1556                         AddressListTown = &GeneralAddressListTown;
1557                         AddressListCounty = &GeneralAddressListCounty;
1558                         AddressListPostCode = &GeneralAddressListPostCode;
1559                         AddressListCountry = &GeneralAddressListCountry;
1560                         AddressListLabel = &GeneralAddressListLabel;
1561                         AddressListLang = &GeneralAddressListLang;              
1562                         AddressListAltID = &GeneralAddressListAltID;
1563                         AddressListPID = &GeneralAddressListPID;
1564                         AddressListTokens = &GeneralAddressListTokens;
1565                         AddressListGeo = &GeneralAddressListGeo;
1566                         AddressListTimezone = &GeneralAddressListTimezone;
1567                         AddressListType = &GeneralAddressListType;
1568                         AddressListMediatype = &GeneralAddressListMediatype;
1569                         AddressListPref = &GeneralAddressListPref;              
1570                         break;
1571                 case PROPERTY_HOME:
1572                         AddressList = &HomeAddressList;
1573                         AddressListTown = &HomeAddressListTown;
1574                         AddressListCounty = &HomeAddressListCounty;
1575                         AddressListPostCode = &HomeAddressListPostCode;
1576                         AddressListCountry = &HomeAddressListCountry;
1577                         AddressListLabel = &HomeAddressListLabel;
1578                         AddressListLang = &HomeAddressListLang;         
1579                         AddressListAltID = &HomeAddressListAltID;
1580                         AddressListPID = &HomeAddressListPID;
1581                         AddressListTokens = &HomeAddressListTokens;
1582                         AddressListGeo = &HomeAddressListGeo;
1583                         AddressListTimezone = &HomeAddressListTimezone;
1584                         AddressListType = &HomeAddressListType;
1585                         AddressListMediatype = &HomeAddressListMediatype;
1586                         AddressListPref = &HomeAddressListPref;
1587                         break;
1588                 case PROPERTY_WORK:
1589                         AddressList = &BusinessAddressList;
1590                         AddressListTown = &BusinessAddressListTown;
1591                         AddressListCounty = &BusinessAddressListCounty;
1592                         AddressListPostCode = &BusinessAddressListPostCode;
1593                         AddressListCountry = &BusinessAddressListCountry;
1594                         AddressListLabel = &BusinessAddressListLabel;
1595                         AddressListLang = &BusinessAddressListLang;             
1596                         AddressListAltID = &BusinessAddressListAltID;
1597                         AddressListPID = &BusinessAddressListPID;
1598                         AddressListTokens = &BusinessAddressListTokens;
1599                         AddressListGeo = &BusinessAddressListGeo;
1600                         AddressListTimezone = &BusinessAddressListTimezone;
1601                         AddressListType = &BusinessAddressListType;
1602                         AddressListMediatype = &BusinessAddressListMediatype;
1603                         AddressListPref = &BusinessAddressListPref;
1604                         break;
1605         }
1606         
1607         intPrevValue = 4;
1608         
1609         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1610         intiter != SplitPoints.end(); ++intiter){
1611         
1612                 SLiter = SplitLength.find(intiter->first);
1613                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1614                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1615                 intPrevValue = intiter->second;
1616                 
1617                 CaptureString(&PropertyValue, FALSE);
1618                 
1619                 // Process properties.
1620                 
1621                 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1622                 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1623                 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1624                 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1625                 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1626                 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1627                 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1628                 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1629                 
1630                 if (PropertyMatched == TRUE){
1631                 
1632                         PropertyMatched = FALSE;
1633                         continue;
1634                 
1635                 }
1636                 
1637                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1638         
1639         }                       
1640         
1641         // Split the address. 
1643         //std::map<int, int>::iterator SLiter;
1644         intPropertyLen = PropertySeg2.Len();
1645         SplitPoints.clear();
1646         SplitLength.clear();
1647         intSplitsFound = 0;
1648         intSplitSize = 0;
1649         intPrevValue = 0;
1650         
1651         for (int i = 0; i <= intPropertyLen; i++){
1653                 intSplitSize++;
1654         
1655                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1656         
1657                         intSplitsFound++;
1658                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1659                         
1660                         if (intSplitsFound == 6){ 
1661                         
1662                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1663                                 break; 
1664                                 
1665                         } else {
1666                         
1667                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1668                         
1669                         }
1670                         
1671                         intSplitSize = 0;                                       
1672         
1673                 }
1675         }
1676         
1677         // Split the data into several parts.                   
1678         
1679         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1680         intiter != SplitPoints.end(); ++intiter){
1681                         
1682                 if (intiter->first == 1){
1683                 
1684                         // Deal with PO Box.
1685                         
1686                         SLiter = SplitLength.find(1);
1687                                                                 
1688                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1689                         intPrevValue = intiter->second;
1690                 
1691                 } else if (intiter->first == 2){
1692                 
1693                         // Deal with extended address.
1694                         
1695                         SLiter = SplitLength.find(2);
1696                         
1697                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1698                         intPrevValue = intiter->second;
1699                 
1700                 } else if (intiter->first == 3){
1701                 
1702                         // Deal with street address.
1703                         
1704                         SLiter = SplitLength.find(3);
1705                                                                 
1706                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1707                         intPrevValue = intiter->second;
1708                 
1709                 } else if (intiter->first == 4){
1710                 
1711                         // Deal with locality
1713                         SLiter = SplitLength.find(4);
1714                         
1715                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1716                         intPrevValue = intiter->second;
1717                 
1718                 } else if (intiter->first == 5){
1719                 
1720                         // Deal with region.
1722                         SLiter = SplitLength.find(5);
1723                         
1724                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1725                         intPrevValue = intiter->second;
1726                         
1727                 
1728                 } else if (intiter->first == 6){
1729                 
1730                         // Deal with post code.
1732                         SLiter = SplitLength.find(6);
1733                         
1734                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1735                         intPrevValue = intiter->second;
1736                         
1737                         // Deal with country.
1738                                                 
1739                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1741                         break;
1742                 
1743                 }
1744         
1745         }       
1746         
1747         // Add the data to the General/Home/Work address variables.
1748         
1749         CaptureString(&AddressStreet, FALSE); 
1750         CaptureString(&AddressLocality, FALSE);
1751         CaptureString(&AddressRegion, FALSE);
1752         CaptureString(&AddressPostalCode, FALSE);
1753         CaptureString(&AddressCountry, FALSE);
1754                 
1755         if (!PropertyTokens.IsEmpty()){
1756         
1757                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1758         
1759         }
1761         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1762         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1763         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1764         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1765         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1767         switch(PropType){
1768                 case PROPERTY_NONE:
1769                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1770                         break;
1771                 case PROPERTY_HOME:
1772                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1773                         break;
1774                 case PROPERTY_WORK:
1775                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1776                         break;
1777         }
1778         
1779         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1783 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1785         std::map<int, int> SplitPoints;
1786         std::map<int, int> SplitLength;
1788         int intPrevValue = 7;
1789         int intPref = 0;                        
1790         
1791         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1792         
1793         intPrevValue = 6;
1794         
1795         PropertyType PropType = PROPERTY_NONE;
1796                 
1797         // Look for type before continuing.
1798         
1799         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1800         
1801         std::map<int, wxString> *EmailList = NULL;
1802         std::map<int, wxString> *EmailListType = NULL;
1803         std::map<int, wxString> *EmailListAltID = NULL;
1804         std::map<int, wxString> *EmailListPID = NULL;
1805         std::map<int, wxString> *EmailListTokens = NULL;                
1806         std::map<int, int> *EmailListPref = NULL;
1808         switch(PropType){
1809                 case PROPERTY_NONE:
1810                         EmailList = &GeneralEmailList;
1811                         EmailListType = &GeneralEmailListType;
1812                         EmailListAltID = &GeneralEmailListAltID;
1813                         EmailListPID = &GeneralEmailListPID;
1814                         EmailListTokens = &GeneralEmailListTokens;              
1815                         EmailListPref = &GeneralEmailListPref;  
1816                         break;
1817                 case PROPERTY_HOME:
1818                         EmailList = &HomeEmailList;
1819                         EmailListType = &HomeEmailListType;
1820                         EmailListAltID = &HomeEmailListAltID;
1821                         EmailListPID = &HomeEmailListPID;
1822                         EmailListTokens = &HomeEmailListTokens;         
1823                         EmailListPref = &HomeEmailListPref;     
1824                         break;
1825                 case PROPERTY_WORK:
1826                         EmailList = &BusinessEmailList;
1827                         EmailListType = &BusinessEmailListType;
1828                         EmailListAltID = &BusinessEmailListAltID;
1829                         EmailListPID = &BusinessEmailListPID;
1830                         EmailListTokens = &BusinessEmailListTokens;             
1831                         EmailListPref = &BusinessEmailListPref; 
1832                         break;
1833         }
1834         
1835         intPrevValue = 6;
1836         
1837         std::map<int,int>::iterator SLiter;
1838         wxString PropertyData;
1839         wxString PropertyName;
1840         wxString PropertyValue;
1841         wxString PropertyTokens;
1842         bool FirstToken = TRUE;
1843         bool PropertyMatched = FALSE;
1844         
1845         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1846         intiter != SplitPoints.end(); ++intiter){
1847         
1848                 SLiter = SplitLength.find(intiter->first);
1849                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1850                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1851                 intPrevValue = intiter->second;
1852                 
1853                 CaptureString(&PropertyValue, FALSE);
1854                 
1855                 // Process properties.
1856                 
1857                 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
1858                 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
1859                 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
1860                 
1861                 if (PropertyMatched == TRUE){
1862                 
1863                         PropertyMatched = FALSE;
1864                         continue;
1865                 
1866                 }
1867                 
1868                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1869         
1870         }
1871         
1872         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1873         
1874         // Add the name token data.
1875         
1876         if (!PropertyTokens.IsEmpty()){
1877         
1878                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1879         
1880         }       
1885 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1887         std::map<int, int> SplitPoints;
1888         std::map<int, int> SplitLength;
1890         int intPrevValue = 6;
1891         int intPref = 0;                        
1892         
1893         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1894         
1895         intPrevValue = 5;
1896         
1897         PropertyType PropType = PROPERTY_NONE;
1898                 
1899         // Look for type before continuing.
1900         
1901         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1902         
1903         std::map<int, wxString> *IMList = NULL;
1904         std::map<int, wxString> *IMListType = NULL;
1905         std::map<int, wxString> *IMListAltID = NULL;
1906         std::map<int, wxString> *IMListPID = NULL;
1907         std::map<int, wxString> *IMListTokens = NULL;
1908         std::map<int, wxString> *IMListMediatype = NULL;        
1909         std::map<int, int> *IMListPref = NULL;
1911         switch(PropType){
1912                 case PROPERTY_NONE:
1913                         IMList = &GeneralIMList;
1914                         IMListType = &GeneralIMListType;
1915                         IMListAltID = &GeneralIMListAltID;
1916                         IMListPID = &GeneralIMListPID;
1917                         IMListTokens = &GeneralIMListTokens;
1918                         IMListMediatype = &GeneralIMListMediatype;
1919                         IMListPref = &GeneralIMListPref;        
1920                         break;
1921                 case PROPERTY_HOME:
1922                         IMList = &HomeIMList;
1923                         IMListType = &HomeIMListType;
1924                         IMListAltID = &HomeIMListAltID;
1925                         IMListPID = &HomeIMListPID;
1926                         IMListTokens = &HomeIMListTokens;
1927                         IMListMediatype = &HomeIMListMediatype;         
1928                         IMListPref = &HomeIMListPref;   
1929                         break;
1930                 case PROPERTY_WORK:
1931                         IMList = &BusinessIMList;
1932                         IMListType = &BusinessIMListType;
1933                         IMListAltID = &BusinessIMListAltID;
1934                         IMListPID = &BusinessIMListPID;
1935                         IMListTokens = &BusinessIMListTokens;   
1936                         IMListMediatype = &BusinessIMListMediatype;     
1937                         IMListPref = &BusinessIMListPref;       
1938                         break;
1939         }
1940         
1941         intPrevValue = 5;
1942         
1943         std::map<int,int>::iterator SLiter;
1944         wxString PropertyData;
1945         wxString PropertyName;
1946         wxString PropertyValue;
1947         wxString PropertyTokens;
1948         bool FirstToken = TRUE;
1949         bool PropertyMatched = FALSE;
1950         
1951         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1952         intiter != SplitPoints.end(); ++intiter){
1953         
1954                 SLiter = SplitLength.find(intiter->first);
1955                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1956                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1957                 intPrevValue = intiter->second;
1958                 
1959                 CaptureString(&PropertyValue, FALSE);
1960                 
1961                 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
1962                 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
1963                 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
1964                 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
1965                 
1966                 // Process properties.
1967                 
1968                 if (PropertyMatched == TRUE){
1969                         
1970                         PropertyMatched = FALSE;
1971                         continue;
1972                 
1973                 }
1974                 
1975                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1976         
1977         }
1978                 
1979         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1980         
1981         // Add the name token data.
1982         
1983         if (!PropertyTokens.IsEmpty()){
1984         
1985                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1986         
1987         }
1991 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1993         std::map<int, int> SplitPoints;
1994         std::map<int, int> SplitLength;
1995         std::map<int, int>::iterator SLiter;
1996         
1997         int intPref = 0;
1998         
1999         PropertyType PropType = PROPERTY_NONE;
2000                 
2001         // Look for type before continuing.
2002         
2003         wxString TelTypeUI;
2004         wxString TelTypeDetail;
2005         wxString PropertyData;
2006         wxString PropertyName;
2007         wxString PropertyValue;
2008         wxString PropertyTokens;
2009         
2010         std::map<int,int> TypeSplitPoints;
2011         std::map<int,int> TypeSplitLength;
2012         std::map<int,int>::iterator TSLiter;
2013         
2014         int intSplitSize = 0;
2015         int intSplitsFound = 0;
2016         int intSplitPoint = 0;
2017         int intType = 0;
2018         int intPrevValue = 5;
2019                 
2020         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2021         
2022         intPrevValue = 4;
2023         
2024         // Look for type before continuing.
2025         
2026         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2027         intiter != SplitPoints.end(); ++intiter){
2028         
2029                 SLiter = SplitLength.find(intiter->first);
2030                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2031                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2032                 intPrevValue = intiter->second;
2034                 if (PropertyName == wxT("TYPE")){
2035                 
2036                         // Process each value in type and translate each
2037                         // part.
2038                 
2039                         // Strip out the quotes if they are there.
2040                 
2041                         size_t intPropertyValueLen = PropertyValue.Len();
2042                 
2043                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2044                         
2045                                 PropertyValue.Trim();
2046                                 PropertyValue.RemoveLast();
2047                         
2048                         }                               
2049                 
2050                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2051                         
2052                                 PropertyValue.Remove(0, 1);
2053                         
2054                         }
2055                         
2056                         TelTypeDetail = PropertyValue;
2057                         
2058                         intSplitSize = 0;
2059                         intSplitsFound = 0;
2060                         intSplitPoint = 0;
2061                         
2062                         for (int i = 0; i <= intPropertyValueLen; i++){
2063         
2064                                 intSplitSize++;
2065         
2066                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2067         
2068                                         if (intSplitsFound == 0){
2070                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2071                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2072                         
2073                                         } else {
2074                         
2075                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2076                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2077                         
2078                                         }                       
2080                                         intSplitsFound++;
2081                                         i++;
2082                                         intSplitPoint = i;
2083                                         intSplitSize = 0;
2084         
2085                                 }
2086         
2087                         }
2088                         
2089                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2090                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2091                 
2092                         int intTypeSeek = 0;
2093                 
2094                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2095                         typeiter != TypeSplitPoints.end(); ++typeiter){
2096                         
2097                                 wxString TypePropertyName;
2098                                 
2099                                 TSLiter = TypeSplitLength.find(typeiter->first);
2100                                 
2101                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2102                                 
2103                                 if (intTypeSeek == 0){
2104                                 
2105                                 
2106                                 } else {
2107                                                                                 
2108                                         TelTypeUI.Append(wxT(","));                                                     
2109                                 
2110                                 }
2111                         
2112                                 if (TypePropertyName == wxT("home")){
2113                                 
2114                                         PropType = PROPERTY_HOME;
2115                                 
2116                                 } else if (TypePropertyName == wxT("work")){
2117                                 
2118                                         PropType = PROPERTY_WORK;
2119                                                                         
2120                                 }
2121                                 
2122                                 
2123                                 if (TypePropertyName == wxT("text")){
2124                                 
2125                                         TelTypeUI.Append(_("text"));
2126                                         intTypeSeek++;
2127                                 
2128                                 } else if (TypePropertyName == wxT("voice")){
2129                                 
2130                                         TelTypeUI.Append(_("voice"));
2131                                         intTypeSeek++;
2132                                 
2133                                 } else if (TypePropertyName == wxT("fax")){
2134                                 
2135                                         TelTypeUI.Append(_("fax"));
2136                                         intTypeSeek++;
2137                                 
2138                                 } else if (TypePropertyName == wxT("cell")){
2139                                 
2140                                         TelTypeUI.Append(_("mobile"));
2141                                         intTypeSeek++;
2142                                 
2143                                 } else if (TypePropertyName == wxT("video")){
2144                                 
2145                                         TelTypeUI.Append(_("video"));
2146                                         intTypeSeek++;
2147                                 
2148                                 } else if (TypePropertyName == wxT("pager")){
2149                                 
2150                                         TelTypeUI.Append(_("pager"));
2151                                         intTypeSeek++;
2152                                 
2153                                 } else if (TypePropertyName == wxT("textphone")){
2154                                 
2155                                         TelTypeUI.Append(_("textphone"));
2156                                         intTypeSeek++;
2157                                 
2158                                 }
2159                         
2160                         }
2161                 
2162                 }
2163                 
2164         }
2165         
2166         std::map<int, wxString> *TelephoneList = NULL;
2167         std::map<int, wxString> *TelephoneListType = NULL;
2168         std::map<int, wxString> *TelephoneListAltID = NULL;
2169         std::map<int, wxString> *TelephoneListPID = NULL;
2170         std::map<int, wxString> *TelephoneListTokens = NULL;
2171         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2172         std::map<int, int> *TelephoneListPref = NULL;
2174         switch(PropType){
2175                 case PROPERTY_NONE:
2176                         TelephoneList = &GeneralTelephoneList;
2177                         TelephoneListType = &GeneralTelephoneListType;
2178                         TelephoneListAltID = &GeneralTelephoneListAltID;
2179                         TelephoneListPID = &GeneralTelephoneListPID;
2180                         TelephoneListTokens = &GeneralTelephoneListTokens;
2181                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2182                         TelephoneListPref = &GeneralTelephoneListPref;  
2183                         break;
2184                 case PROPERTY_HOME:
2185                         TelephoneList = &HomeTelephoneList;
2186                         TelephoneListType = &HomeTelephoneListType;
2187                         TelephoneListAltID = &HomeTelephoneListAltID;
2188                         TelephoneListPID = &HomeTelephoneListPID;
2189                         TelephoneListTokens = &HomeTelephoneListTokens;
2190                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2191                         TelephoneListPref = &HomeTelephoneListPref;     
2192                         break;
2193                 case PROPERTY_WORK:
2194                         TelephoneList = &BusinessTelephoneList;
2195                         TelephoneListType = &BusinessTelephoneListType;
2196                         TelephoneListAltID = &BusinessTelephoneListAltID;
2197                         TelephoneListPID = &BusinessTelephoneListPID;
2198                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2199                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2200                         TelephoneListPref = &BusinessTelephoneListPref; 
2201                         break;
2202         }
2203                 
2204         // Process the properties.
2205         
2206         bool FirstToken = TRUE;
2207         
2208         intPrevValue = 5;
2209         SplitPoints.clear();
2210         SplitLength.clear();
2212         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2214         intPrevValue = 4;
2215         
2216         bool PropertyMatched = FALSE;
2217         
2218         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2219         intiter != SplitPoints.end(); ++intiter){
2220         
2221                 SLiter = SplitLength.find(intiter->first);
2222                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2223                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2224                 intPrevValue = intiter->second;
2225                 
2226                 CaptureString(&PropertyValue, FALSE);
2227                 
2228                 // Process properties.
2229                 
2230                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2231                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2232                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2233                 
2234                 if (PropertyMatched == TRUE){
2235                 
2236                         PropertyMatched = FALSE;
2237                         continue;
2238                 
2239                 }
2241                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2242         
2243         }
2244                 
2245         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2246         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2247         
2248         // Add the name token data.
2249         
2250         if (!PropertyTokens.IsEmpty()){
2251         
2252                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2253         
2254         }
2258 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2260         std::map<int, int> SplitPoints;
2261         std::map<int, int> SplitLength;
2263         int intPrevValue = 6;
2264         int intPref = 0;                        
2265         
2266         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2267         
2268         intPrevValue = 5;
2269         
2270         PropertyType PropType = PROPERTY_NONE;
2271                 
2272         // Look for type before continuing.
2273         
2274         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2275         
2276         std::map<int, wxString> *LanguageList = NULL;
2277         std::map<int, wxString> *LanguageListType = NULL;
2278         std::map<int, wxString> *LanguageListAltID = NULL;
2279         std::map<int, wxString> *LanguageListPID = NULL;
2280         std::map<int, wxString> *LanguageListTokens = NULL;
2281         std::map<int, int> *LanguageListPref = NULL;
2283         switch(PropType){
2284                 case PROPERTY_NONE:
2285                         LanguageList = &GeneralLanguageList;
2286                         LanguageListType = &GeneralLanguageListType;
2287                         LanguageListAltID = &GeneralLanguageListAltID;
2288                         LanguageListPID = &GeneralLanguageListPID;
2289                         LanguageListTokens = &GeneralLanguageListTokens;
2290                         LanguageListPref = &GeneralLanguageListPref;    
2291                         break;
2292                 case PROPERTY_HOME:
2293                         LanguageList = &HomeLanguageList;
2294                         LanguageListType = &HomeLanguageListType;
2295                         LanguageListAltID = &HomeLanguageListAltID;
2296                         LanguageListPID = &HomeLanguageListPID;
2297                         LanguageListTokens = &HomeLanguageListTokens;   
2298                         LanguageListPref = &HomeLanguageListPref;       
2299                         break;
2300                 case PROPERTY_WORK:
2301                         LanguageList = &BusinessLanguageList;
2302                         LanguageListType = &BusinessLanguageListType;
2303                         LanguageListAltID = &BusinessLanguageListAltID;
2304                         LanguageListPID = &BusinessLanguageListPID;
2305                         LanguageListTokens = &BusinessLanguageListTokens;       
2306                         LanguageListPref = &BusinessLanguageListPref;
2307                         break;
2308         }
2309         
2310         intPrevValue = 5;
2311         
2312         std::map<int,int>::iterator SLiter;
2313         wxString PropertyData;
2314         wxString PropertyName;
2315         wxString PropertyValue;
2316         wxString PropertyTokens;
2317         bool FirstToken = TRUE;
2318         bool PropertyMatched = FALSE;
2319         
2320         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2321         intiter != SplitPoints.end(); ++intiter){
2322         
2323                 SLiter = SplitLength.find(intiter->first);
2324                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2325                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2326                 intPrevValue = intiter->second;
2328                 CaptureString(&PropertyValue, FALSE);
2329                 
2330                 // Process properties.
2331                 
2332                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2333                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2334                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2336                 if (PropertyMatched == TRUE){
2337                 
2338                         PropertyMatched = FALSE;
2339                         continue;
2340                 
2341                 }
2342                 
2343                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2344         
2345         }
2346                 
2347         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2348         
2349         // Add the name token data.
2350         
2351         if (!PropertyTokens.IsEmpty()){
2352         
2353                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2354         
2355         }
2359 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2361         std::map<int, int> SplitPoints;
2362         std::map<int, int> SplitLength;
2364         int intPrevValue = 5;
2365         int intPref = 0;                        
2366         
2367         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2368         
2369         intPrevValue = 4;
2370         
2371         PropertyType PropType = PROPERTY_NONE;
2372                 
2373         // Look for type before continuing.
2374         
2375         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2376         
2377         std::map<int, wxString> *GeopositionList = NULL;
2378         std::map<int, wxString> *GeopositionListType = NULL;
2379         std::map<int, wxString> *GeopositionListAltID = NULL;
2380         std::map<int, wxString> *GeopositionListPID = NULL;
2381         std::map<int, wxString> *GeopositionListTokens = NULL;
2382         std::map<int, wxString> *GeopositionListMediatype = NULL;
2383         std::map<int, int> *GeopositionListPref = NULL;
2385         switch(PropType){
2386                 case PROPERTY_NONE:
2387                         GeopositionList = &GeneralGeographyList;
2388                         GeopositionListType = &GeneralGeographyListType;
2389                         GeopositionListAltID = &GeneralGeographyListAltID;
2390                         GeopositionListPID = &GeneralGeographyListPID;
2391                         GeopositionListTokens = &GeneralGeographyListTokens;
2392                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2393                         GeopositionListPref = &GeneralGeographyListPref;        
2394                         break;
2395                 case PROPERTY_HOME:
2396                         GeopositionList = &HomeGeographyList;
2397                         GeopositionListType = &HomeGeographyListType;
2398                         GeopositionListAltID = &HomeGeographyListAltID;
2399                         GeopositionListPID = &HomeGeographyListPID;
2400                         GeopositionListTokens = &HomeGeographyListTokens;
2401                         GeopositionListMediatype = &HomeGeographyListMediatype;
2402                         GeopositionListPref = &HomeGeographyListPref;   
2403                         break;
2404                 case PROPERTY_WORK:
2405                         GeopositionList = &BusinessGeographyList;
2406                         GeopositionListType = &BusinessGeographyListType;
2407                         GeopositionListAltID = &BusinessGeographyListAltID;
2408                         GeopositionListPID = &BusinessGeographyListPID;
2409                         GeopositionListTokens = &BusinessGeographyListTokens;
2410                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2411                         GeopositionListPref = &BusinessGeographyListPref;
2412                         break;
2413         }
2414         
2415         intPrevValue = 4;
2416         
2417         std::map<int,int>::iterator SLiter;
2418         wxString PropertyData;
2419         wxString PropertyName;
2420         wxString PropertyValue;
2421         wxString PropertyTokens;
2422         bool FirstToken = TRUE;
2423         bool PropertyMatched = FALSE;
2424         
2425         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2426         intiter != SplitPoints.end(); ++intiter){
2427         
2428                 SLiter = SplitLength.find(intiter->first);
2429                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2430                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2431                 intPrevValue = intiter->second;
2432                 
2433                 CaptureString(&PropertyValue, FALSE);
2434                 
2435                 // Process properties.
2436                 
2437                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2438                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2439                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2440                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2441                 
2442                 if (PropertyMatched == TRUE){
2443                 
2444                         PropertyMatched = FALSE;
2445                         continue;
2446                 
2447                 }
2448                 
2449                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2450         
2451         }
2452                 
2453         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2454         
2455         // Add the name token data.
2456         
2457         if (!PropertyTokens.IsEmpty()){
2458         
2459                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2460         
2461         }
2465 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2467         size_t intPropertyLen = PropertySeg1.Len();
2468         std::map<int, int> SplitPoints;
2469         std::map<int, int> SplitLength;
2470         std::map<int, int>::iterator SLiter;                    
2471         wxString PropertyData;
2472         wxString PropertyName;
2473         wxString PropertyValue;
2474         wxString PropertyTokens;
2475         wxString RelatedType;
2476         wxString RelatedTypeOriginal;                   
2477         wxString RelatedName;
2478         bool FirstToken = TRUE;                 
2479         int intSplitsFound = 0;
2480         int intSplitSize = 0;
2481         int intPrevValue = 9;
2482         int intPref = 0;
2483         long ListCtrlIndex;
2484         
2485         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2486         
2487         intPrevValue = 8;
2488         
2489         // Look for type before continuing.
2490         
2491         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2492         intiter != SplitPoints.end(); ++intiter){
2493         
2494                 SLiter = SplitLength.find(intiter->first);
2495                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2496                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2497                 intPrevValue = intiter->second;
2498                 
2499                 // Process these.
2500                 
2501                 RelatedTypeOriginal = PropertyValue;
2502                 
2503                 if (PropertyName == wxT("TYPE")){
2504                 
2505                         if (PropertyValue == wxT("contact")){
2507                                 RelatedType = _("Contact");
2509                         } else if (PropertyValue == wxT("acquaintance")){
2511                                 RelatedType = _("Acquaintance");
2513                         } else if (PropertyValue == wxT("friend")){
2515                                 RelatedType = _("Friend");
2517                         } else if (PropertyValue == wxT("met")){
2519                                 RelatedType = _("Met");
2521                         } else if (PropertyValue == wxT("co-worker")){
2523                                 RelatedType = _("Co-worker");
2525                         } else if (PropertyValue == wxT("colleague")){
2527                                 RelatedType = _("Colleague");
2529                         } else if (PropertyValue == wxT("co-resident")){
2531                                 RelatedType = _("Co-resident");
2533                         } else if (PropertyValue == wxT("neighbor")){
2535                                 RelatedType = _("Neighbour");
2537                         } else if (PropertyValue == wxT("child")){
2539                                 RelatedType = _("Child");
2541                         } else if (PropertyValue == wxT("parent")){
2543                                 RelatedType = _("Parent");
2545                         } else if (PropertyValue == wxT("sibling")){
2547                                 RelatedType = _("Sibling");
2549                         } else if (PropertyValue == wxT("spouse")){
2551                                 RelatedType = _("Spouse");
2553                         } else if (PropertyValue == wxT("kin")){
2555                                 RelatedType = _("Kin");
2557                         } else if (PropertyValue == wxT("muse")){
2559                                 RelatedType = _("Muse");
2561                         } else if (PropertyValue == wxT("crush")){
2563                                 RelatedType = _("Crush");
2565                         } else if (PropertyValue == wxT("date")){
2567                                 RelatedType = _("Date");
2569                         } else if (PropertyValue == wxT("sweetheart")){
2571                                 RelatedType = _("Sweetheart");
2573                         } else if (PropertyValue == wxT("me")){
2575                                 RelatedType = _("Me");
2577                         } else if (PropertyValue == wxT("agent")){
2579                                 RelatedType = _("Agent");
2581                         } else if (PropertyValue == wxT("emergency")){
2583                                 RelatedType = _("Emergency");
2585                         } else {
2587                                 RelatedType = PropertyValue;
2589                         }
2590                 
2591                 }
2592         
2593         }
2594         
2595         intPrevValue = 8;                       
2596         
2597         bool PropertyMatched = FALSE;
2598         
2599         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2600         intiter != SplitPoints.end(); ++intiter){
2601         
2602                 SLiter = SplitLength.find(intiter->first);
2603                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2604                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2605                 intPrevValue = intiter->second;
2606                 
2607                 // Process properties.
2608                 
2609                 size_t intPropertyValueLen = PropertyValue.Len();
2610                 
2611                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2612                         
2613                         PropertyValue.Trim();
2614                         PropertyValue.RemoveLast();
2615                         
2616                 }                               
2617                 
2618                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2619                         
2620                         PropertyValue.Remove(0, 1);
2621                         
2622                 }
2623                 
2624                 CaptureString(&PropertyValue, FALSE);
2625                         
2626                 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2627                 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2628                 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2629                 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2631                 if (PropertyMatched == TRUE){
2632                 
2633                         PropertyMatched = FALSE;
2634                         continue;
2635                 
2636                 }
2638                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2639         
2640         }                                       
2641         
2642         // Add the data to the General/Home/Work address variables.
2643                                 
2644         GeneralRelatedList.erase(*RelatedCount);
2645         GeneralRelatedListRelType.erase(*RelatedCount);
2646         GeneralRelatedListType.erase(*RelatedCount);
2647         GeneralRelatedListTokens.erase(*RelatedCount);
2648         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2649         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
2650         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2651         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2655 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2657         std::map<int, int> SplitPoints;
2658         std::map<int, int> SplitLength;
2659         std::map<int, int>::iterator SLiter;                    
2660         wxString PropertyData;
2661         wxString PropertyName;
2662         wxString PropertyValue;
2663         wxString PropertyTokens;
2664         bool FirstToken = TRUE;
2665         int intPrevValue = 5;
2666         int intPref = 0;                        
2667         int intType = 0;
2668         long ListCtrlIndex;
2669         
2670         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2671         
2672         intPrevValue = 4;
2673         
2674         PropertyType PropType = PROPERTY_NONE;
2675                 
2676         // Look for type before continuing.
2677         
2678         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2679         
2680         // Setup the pointers.
2681         
2682         std::map<int, wxString> *WebsiteList = NULL;
2683         std::map<int, wxString> *WebsiteListAltID = NULL;
2684         std::map<int, wxString> *WebsiteListPID = NULL;
2685         std::map<int, wxString> *WebsiteListType = NULL;
2686         std::map<int, wxString> *WebsiteListTokens = NULL;
2687         std::map<int, wxString> *WebsiteListMediatype = NULL;
2688         std::map<int, int> *WebsiteListPref = NULL;
2689         
2690         // Setup blank lines for later on.
2691         
2692         switch(PropType){
2693                 case PROPERTY_NONE:
2694                         WebsiteList = &GeneralWebsiteList;
2695                         WebsiteListType = &GeneralWebsiteListType;
2696                         WebsiteListAltID = &GeneralWebsiteListAltID;
2697                         WebsiteListPID = &GeneralWebsiteListPID;
2698                         WebsiteListTokens = &GeneralWebsiteListTokens;
2699                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
2700                         WebsiteListPref = &GeneralWebsiteListPref;      
2701                         break;
2702                 case PROPERTY_HOME:
2703                         WebsiteList = &HomeWebsiteList;
2704                         WebsiteListType = &HomeWebsiteListType;
2705                         WebsiteListAltID = &HomeWebsiteListAltID;
2706                         WebsiteListPID = &HomeWebsiteListPID;
2707                         WebsiteListTokens = &HomeWebsiteListTokens;
2708                         WebsiteListMediatype = &HomeWebsiteListMediatype;
2709                         WebsiteListPref = &HomeWebsiteListPref; 
2710                         break;
2711                 case PROPERTY_WORK:
2712                         WebsiteList = &BusinessWebsiteList;
2713                         WebsiteListType = &BusinessWebsiteListType;
2714                         WebsiteListAltID = &BusinessWebsiteListAltID;
2715                         WebsiteListPID = &BusinessWebsiteListPID;
2716                         WebsiteListTokens = &BusinessWebsiteListTokens;
2717                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
2718                         WebsiteListPref = &BusinessWebsiteListPref;
2719                         break;
2720         }
2721         
2722         intPrevValue = 4;
2723         bool PropertyMatched = FALSE;
2724         
2725         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2726         intiter != SplitPoints.end(); ++intiter){
2727         
2728                 SLiter = SplitLength.find(intiter->first);
2729                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2730                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2731                 intPrevValue = intiter->second;
2732                 
2733                 // Process properties.
2734                 
2735                 size_t intPropertyValueLen = PropertyValue.Len();
2736                 
2737                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2738                         
2739                         PropertyValue.Trim();
2740                         PropertyValue.RemoveLast();
2741                         
2742                 }                               
2743                 
2744                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2745                         
2746                         PropertyValue.Remove(0, 1);
2747                         
2748                 }
2749                 
2750                 CaptureString(&PropertyValue, FALSE);
2751                 
2752                 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
2753                 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
2754                 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
2755                 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
2756                 
2757                 if (PropertyMatched == TRUE){
2758                 
2759                         PropertyMatched = FALSE;
2760                         continue;
2761                 
2762                 }
2763                 
2764                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2765         
2766         }
2767         
2768         // Add the data to the General/Home/Work address variables.
2769         
2770         CaptureString(&PropertySeg2, FALSE);
2771                         
2772         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2773         
2774         if (!PropertyTokens.IsEmpty()){
2775         
2776                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2777                         
2778         }
2779         
2782 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
2784         std::map<int, int> SplitPoints;
2785         std::map<int, int> SplitLength;
2786         std::map<int, int>::iterator SLiter;                    
2787         wxString PropertyData;
2788         wxString PropertyName;
2789         wxString PropertyValue;
2790         wxString PropertyTokens;
2791         bool FirstToken = TRUE;
2792         int intPrevValue = 7;
2793         int intPref = 0;                        
2794         int intType = 0;
2795         long ListCtrlIndex;
2796         
2797         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2798         
2799         intPrevValue = 6;
2800         
2801         PropertyType PropType = PROPERTY_NONE;
2802                 
2803         // Look for type before continuing.
2804         
2805         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2806         
2807         // Setup the pointers.
2808         
2809         std::map<int, wxString> *TitleList = NULL;
2810         std::map<int, wxString> *TitleListAltID = NULL;
2811         std::map<int, wxString> *TitleListPID = NULL;
2812         std::map<int, wxString> *TitleListType = NULL;
2813         std::map<int, wxString> *TitleListTokens = NULL;
2814         std::map<int, wxString> *TitleListLanguage = NULL;
2815         std::map<int, int> *TitleListPref = NULL;
2816         
2817         // Setup blank lines for later on.
2818         
2819         switch(PropType){
2820                 case PROPERTY_NONE:
2821                         TitleList = &GeneralTitleList;
2822                         TitleListType = &GeneralTitleListType;
2823                         TitleListAltID = &GeneralTitleListAltID;
2824                         TitleListPID = &GeneralTitleListPID;
2825                         TitleListTokens = &GeneralTitleListTokens;
2826                         TitleListLanguage = &GeneralTitleListLanguage;
2827                         TitleListPref = &GeneralTitleListPref;  
2828                         break;
2829                 case PROPERTY_HOME:
2830                         TitleList = &HomeTitleList;
2831                         TitleListType = &HomeTitleListType;
2832                         TitleListAltID = &HomeTitleListAltID;
2833                         TitleListPID = &HomeTitleListPID;
2834                         TitleListTokens = &HomeTitleListTokens;
2835                         TitleListLanguage = &HomeTitleListLanguage;
2836                         TitleListPref = &HomeTitleListPref;     
2837                         break;
2838                 case PROPERTY_WORK:
2839                         TitleList = &BusinessTitleList;
2840                         TitleListType = &BusinessTitleListType;
2841                         TitleListAltID = &BusinessTitleListAltID;
2842                         TitleListPID = &BusinessTitleListPID;
2843                         TitleListTokens = &BusinessTitleListTokens;
2844                         TitleListLanguage = &BusinessTitleListLanguage; 
2845                         TitleListPref = &BusinessTitleListPref;
2846                         break;
2847         }
2849         intPrevValue = 6;
2850         bool PropertyMatched = FALSE;
2851                 
2852         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2853         intiter != SplitPoints.end(); ++intiter){
2854         
2855                 SLiter = SplitLength.find(intiter->first);
2856                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2857                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2858                 intPrevValue = intiter->second;
2859                 
2860                 // Process properties.
2861                 
2862                 size_t intPropertyValueLen = PropertyValue.Len();
2863                 
2864                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2865                         
2866                         PropertyValue.Trim();
2867                         PropertyValue.RemoveLast();
2868                         
2869                 }                               
2870                 
2871                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2872                         
2873                         PropertyValue.Remove(0, 1);
2874                         
2875                 }                               
2876                 
2877                 CaptureString(&PropertyValue, FALSE);
2878                 
2879                 ProcessStringValue(&PropertyName, "ALTID", TitleListAltID, &PropertyValue, TitleCount, &PropertyMatched);
2880                 ProcessStringValue(&PropertyName, "PID", TitleListPID, &PropertyValue, TitleCount, &PropertyMatched);
2881                 ProcessStringValue(&PropertyName, "LANGUAGE", TitleListLanguage, &PropertyValue, TitleCount, &PropertyMatched);
2882                 ProcessIntegerValue(&PropertyName, "PREF", TitleListPref, &PropertyValue, TitleCount, &PropertyMatched);
2883                 
2884                 if (PropertyMatched == TRUE){
2885                 
2886                         PropertyMatched = FALSE;
2887                         continue;
2888                 
2889                 }
2891                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2892         
2893         }
2894         
2895         // Add the data to the General/Home/Work address variables.
2896         
2897         CaptureString(&PropertySeg2, FALSE);
2899         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
2900         
2901         if (!PropertyTokens.IsEmpty()){
2902         
2903                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
2904                         
2905         }
2909 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
2911         std::map<int, int> SplitPoints;
2912         std::map<int, int> SplitLength;
2913         std::map<int, int>::iterator SLiter;                    
2914         wxString PropertyData;
2915         wxString PropertyName;
2916         wxString PropertyValue;
2917         wxString PropertyTokens;
2918         bool FirstToken = TRUE;
2919         int intPrevValue = 6;
2920         int intPref = 0;                        
2921         int intType = 0;
2922         long ListCtrlIndex;
2923         
2924         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2925         
2926         intPrevValue = 5;
2927         
2928         PropertyType PropType = PROPERTY_NONE;
2929                 
2930         // Look for type before continuing.
2931         
2932         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2933         
2934         // Setup the pointers.
2935         
2936         std::map<int, wxString> *RoleList = NULL;
2937         std::map<int, wxString> *RoleListAltID = NULL;
2938         std::map<int, wxString> *RoleListPID = NULL;
2939         std::map<int, wxString> *RoleListType = NULL;
2940         std::map<int, wxString> *RoleListTokens = NULL;
2941         std::map<int, wxString> *RoleListLanguage = NULL;
2942         std::map<int, int> *RoleListPref = NULL;
2943         
2944         // Setup blank lines for later on.
2945         
2946         switch(PropType){
2947                 case PROPERTY_NONE:
2948                         RoleList = &GeneralRoleList;
2949                         RoleListType = &GeneralRoleListType;
2950                         RoleListAltID = &GeneralRoleListAltID;
2951                         RoleListPID = &GeneralRoleListPID;
2952                         RoleListTokens = &GeneralRoleListTokens;
2953                         RoleListLanguage = &GeneralRoleListLanguage;
2954                         RoleListPref = &GeneralRoleListPref;    
2955                         break;
2956                 case PROPERTY_HOME:
2957                         RoleList = &HomeRoleList;
2958                         RoleListType = &HomeRoleListType;
2959                         RoleListAltID = &HomeRoleListAltID;
2960                         RoleListPID = &HomeRoleListPID;
2961                         RoleListTokens = &HomeRoleListTokens;
2962                         RoleListLanguage = &HomeRoleListLanguage;
2963                         RoleListPref = &HomeRoleListPref;       
2964                         break;
2965                 case PROPERTY_WORK:
2966                         RoleList = &BusinessRoleList;
2967                         RoleListType = &BusinessRoleListType;
2968                         RoleListAltID = &BusinessRoleListAltID;
2969                         RoleListPID = &BusinessRoleListPID;
2970                         RoleListTokens = &BusinessRoleListTokens;
2971                         RoleListLanguage = &BusinessRoleListLanguage;   
2972                         RoleListPref = &BusinessRoleListPref;
2973                         break;
2974         }
2976         intPrevValue = 5;
2977         bool PropertyMatched = FALSE;
2978                 
2979         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2980         intiter != SplitPoints.end(); ++intiter){
2981         
2982                 SLiter = SplitLength.find(intiter->first);
2983                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2984                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2985                 intPrevValue = intiter->second;
2986                 
2987                 // Process properties.
2988                 
2989                 size_t intPropertyValueLen = PropertyValue.Len();
2990                 
2991                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2992                         
2993                         PropertyValue.Trim();
2994                         PropertyValue.RemoveLast();
2995                         
2996                 }                               
2997                 
2998                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2999                         
3000                         PropertyValue.Remove(0, 1);
3001                         
3002                 }                               
3003                 
3004                 CaptureString(&PropertyValue, FALSE);
3005                 
3006                 ProcessStringValue(&PropertyName, "ALTID", RoleListAltID, &PropertyValue, RoleCount, &PropertyMatched);
3007                 ProcessStringValue(&PropertyName, "PID", RoleListPID, &PropertyValue, RoleCount, &PropertyMatched);
3008                 ProcessStringValue(&PropertyName, "LANGUAGE", RoleListLanguage, &PropertyValue, RoleCount, &PropertyMatched);
3009                 ProcessIntegerValue(&PropertyName, "PREF", RoleListPref, &PropertyValue, RoleCount, &PropertyMatched);
3010                 
3011                 if (PropertyMatched == TRUE){
3012                 
3013                         PropertyMatched = FALSE;
3014                         continue;
3015                 
3016                 }
3017                 
3018                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3019                 
3020         }
3021         
3022         // Add the data to the General/Home/Work address variables.
3023         
3024         CaptureString(&PropertySeg2, FALSE);
3026         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3027         
3028         if (!PropertyTokens.IsEmpty()){
3029         
3030                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3031                         
3032         }
3036 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3038         std::map<int, int> SplitPoints;
3039         std::map<int, int> SplitLength;
3040         std::map<int, int>::iterator SLiter;                    
3041         wxString PropertyData;
3042         wxString PropertyName;
3043         wxString PropertyValue;
3044         wxString PropertyTokens;
3045         bool FirstToken = TRUE;
3046         int intPrevValue = 5;
3047         int intPref = 0;                        
3048         int intType = 0;
3049         long ListCtrlIndex;
3050         
3051         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3052         
3053         intPrevValue = 4;
3054         
3055         PropertyType PropType = PROPERTY_NONE;
3056                 
3057         // Look for type before continuing.
3058         
3059         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3060         
3061         // Setup the pointers.
3062         
3063         std::map<int, wxString> *OrganisationsList = NULL;
3064         std::map<int, wxString> *OrganisationsListAltID = NULL;
3065         std::map<int, wxString> *OrganisationsListPID = NULL;
3066         std::map<int, wxString> *OrganisationsListType = NULL;
3067         std::map<int, wxString> *OrganisationsListTokens = NULL;
3068         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3069         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3070         std::map<int, int> *OrganisationsListPref = NULL;
3071         
3072         // Setup blank lines for later on.
3073         
3074         switch(PropType){
3075                 case PROPERTY_NONE:
3076                         OrganisationsList = &GeneralOrganisationsList;
3077                         OrganisationsListType = &GeneralOrganisationsListType;
3078                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3079                         OrganisationsListPID = &GeneralOrganisationsListPID;
3080                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3081                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3082                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3083                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3084                         break;
3085                 case PROPERTY_HOME:
3086                         OrganisationsList = &HomeOrganisationsList;
3087                         OrganisationsListType = &HomeOrganisationsListType;
3088                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3089                         OrganisationsListPID = &HomeOrganisationsListPID;
3090                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3091                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3092                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3093                         OrganisationsListPref = &HomeOrganisationsListPref;     
3094                         break;
3095                 case PROPERTY_WORK:
3096                         OrganisationsList = &BusinessOrganisationsList;
3097                         OrganisationsListType = &BusinessOrganisationsListType;
3098                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3099                         OrganisationsListPID = &BusinessOrganisationsListPID;
3100                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3101                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3102                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3103                         OrganisationsListPref = &BusinessOrganisationsListPref;
3104                         break;
3105         }
3107         intPrevValue = 4;
3108         bool PropertyMatched = FALSE;
3109                 
3110         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3111         intiter != SplitPoints.end(); ++intiter){
3112         
3113                 SLiter = SplitLength.find(intiter->first);
3114                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3115                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3116                 intPrevValue = intiter->second;
3117                 
3118                 // Process properties.
3119                 
3120                 size_t intPropertyValueLen = PropertyValue.Len();
3121                 
3122                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3123                         
3124                         PropertyValue.Trim();
3125                         PropertyValue.RemoveLast();
3126                         
3127                 }                               
3128                 
3129                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3130                         
3131                         PropertyValue.Remove(0, 1);
3132                         
3133                 }                               
3134                 
3135                 CaptureString(&PropertyValue, FALSE);
3136                 
3137                 ProcessStringValue(&PropertyName, "ALTID", OrganisationsListAltID, &PropertyValue, OrganisationCount, &PropertyMatched);
3138                 ProcessStringValue(&PropertyName, "PID", OrganisationsListPID, &PropertyValue, OrganisationCount, &PropertyMatched);
3139                 ProcessStringValue(&PropertyName, "LANGUAGE", OrganisationsListLanguage, &PropertyValue, OrganisationCount, &PropertyMatched);
3140                 ProcessStringValue(&PropertyName, "SORT-AS", OrganisationsListSortAs, &PropertyValue, OrganisationCount, &PropertyMatched);
3141                 ProcessIntegerValue(&PropertyName, "PREF", OrganisationsListPref, &PropertyValue, OrganisationCount, &PropertyMatched);
3142                 
3143                 if (PropertyMatched == TRUE){
3144                 
3145                         PropertyMatched = FALSE;
3146                         continue;
3147                 
3148                 }
3149                 
3150                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3152         }
3153         
3154         // Add the data to the General/Home/Work address variables.
3155         
3156         CaptureString(&PropertySeg2, FALSE);
3158         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3159         
3160         if (!PropertyTokens.IsEmpty()){
3161         
3162                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3163                         
3164         }
3168 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3170         std::map<int, int> SplitPoints;
3171         std::map<int, int> SplitLength;
3172         std::map<int, int>::iterator SLiter;                    
3173         wxString PropertyData;
3174         wxString PropertyName;
3175         wxString PropertyValue;
3176         wxString PropertyTokens;
3177         bool FirstToken = TRUE;
3178         int intPrevValue = 6;
3179         int intPref = 0;                        
3180         int intType = 0;
3181         long ListCtrlIndex;
3182         
3183         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3184         
3185         intPrevValue = 5;
3186         
3187         PropertyType PropType = PROPERTY_NONE;
3188                 
3189         // Look for type before continuing.
3190         
3191         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3192         
3193         // Setup the pointers.
3194         
3195         std::map<int, wxString> *NoteList = NULL;
3196         std::map<int, wxString> *NoteListAltID = NULL;
3197         std::map<int, wxString> *NoteListPID = NULL;
3198         std::map<int, wxString> *NoteListType = NULL;
3199         std::map<int, wxString> *NoteListTokens = NULL;
3200         std::map<int, wxString> *NoteListLanguage = NULL;
3201         std::map<int, int> *NoteListPref = NULL;
3202         
3203         // Setup blank lines for later on.
3204         
3205         switch(PropType){
3206                 case PROPERTY_NONE:
3207                         NoteList = &GeneralNoteList;
3208                         NoteListType = &GeneralNoteListType;
3209                         NoteListAltID = &GeneralNoteListAltID;
3210                         NoteListPID = &GeneralNoteListPID;
3211                         NoteListTokens = &GeneralNoteListTokens;
3212                         NoteListLanguage = &GeneralNoteListLanguage;
3213                         NoteListPref = &GeneralNoteListPref;    
3214                         break;
3215                 case PROPERTY_HOME:
3216                         NoteList = &HomeNoteList;
3217                         NoteListType = &HomeNoteListType;
3218                         NoteListAltID = &HomeNoteListAltID;
3219                         NoteListPID = &HomeNoteListPID;
3220                         NoteListTokens = &HomeNoteListTokens;
3221                         NoteListLanguage = &HomeNoteListLanguage;
3222                         NoteListPref = &HomeNoteListPref;       
3223                         break;
3224                 case PROPERTY_WORK:
3225                         NoteList = &BusinessNoteList;
3226                         NoteListType = &BusinessNoteListType;
3227                         NoteListAltID = &BusinessNoteListAltID;
3228                         NoteListPID = &BusinessNoteListPID;
3229                         NoteListTokens = &BusinessNoteListTokens;
3230                         NoteListLanguage = &BusinessNoteListLanguage;   
3231                         NoteListPref = &BusinessNoteListPref;
3232                         break;
3233         }
3235         intPrevValue = 5;
3236         bool PropertyMatched = FALSE;
3237                 
3238         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3239         intiter != SplitPoints.end(); ++intiter){
3240         
3241                 SLiter = SplitLength.find(intiter->first);
3242                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3243                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3244                 intPrevValue = intiter->second;
3245                 
3246                 // Process properties.
3247                 
3248                 size_t intPropertyValueLen = PropertyValue.Len();
3249                 
3250                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3251                         
3252                         PropertyValue.Trim();
3253                         PropertyValue.RemoveLast();
3254                         
3255                 }                               
3256                 
3257                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3258                         
3259                         PropertyValue.Remove(0, 1);
3260                         
3261                 }                               
3262                 
3263                 CaptureString(&PropertyValue, FALSE);
3264                 
3265                 ProcessStringValue(&PropertyName, "ALTID", NoteListAltID, &PropertyValue, NoteCount, &PropertyMatched);
3266                 ProcessStringValue(&PropertyName, "PID", NoteListPID, &PropertyValue, NoteCount, &PropertyMatched);
3267                 ProcessStringValue(&PropertyName, "LANGUAGE", NoteListLanguage, &PropertyValue, NoteCount, &PropertyMatched);
3268                 ProcessIntegerValue(&PropertyName, "PREF", NoteListPref, &PropertyValue, NoteCount, &PropertyMatched);
3269                 
3270                 if (PropertyMatched == TRUE){
3271                 
3272                         PropertyMatched = FALSE;
3273                         continue;
3274                 
3275                 }
3277                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3278         
3279         }
3280         
3281         // Add the data to the General/Home/Work address variables.
3282         
3283         CaptureString(&PropertySeg2, FALSE);
3285         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3286         
3287         if (!PropertyTokens.IsEmpty()){
3288         
3289                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3290                         
3291         }
3295 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3297         std::map<int, int> SplitPoints;
3298         std::map<int, int> SplitLength;
3299         std::map<int, int>::iterator SLiter;                    
3300         wxString PropertyData;
3301         wxString PropertyName;
3302         wxString PropertyValue;
3303         wxString PropertyTokens;
3304         bool FirstToken = TRUE;
3305         int intPrevValue = 12;
3306         int intPref = 0;                        
3307         int intType = 0;
3308         long ListCtrlIndex;
3309         
3310         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3311         
3312         intPrevValue = 11;
3313         
3314         PropertyType PropType = PROPERTY_NONE;
3315                 
3316         // Look for type before continuing.
3317         
3318         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3319         
3320         // Setup blank lines for later on.
3321         
3322         switch(PropType){
3323                 case PROPERTY_NONE:
3324                         break;
3325                 case PROPERTY_HOME:
3326                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3327                         break;
3328                 case PROPERTY_WORK:
3329                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3330                         break;
3331         }
3333         intPrevValue = 11;
3334         bool PropertyMatched = FALSE;
3335                 
3336         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3337         intiter != SplitPoints.end(); ++intiter){
3338         
3339                 SLiter = SplitLength.find(intiter->first);
3340                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3341                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3342                 intPrevValue = intiter->second;
3343                 
3344                 // Process properties.
3345                 
3346                 size_t intPropertyValueLen = PropertyValue.Len();
3347                 
3348                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3349                         
3350                         PropertyValue.Trim();
3351                         PropertyValue.RemoveLast();
3352                         
3353                 }                               
3354                 
3355                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3356                         
3357                         PropertyValue.Remove(0, 1);
3358                         
3359                 }                               
3360                 
3361                 CaptureString(&PropertyValue, FALSE);
3362                 
3363                 ProcessStringValue(&PropertyName, "ALTID", &CategoriesListAltID, &PropertyValue, CategoryCount, &PropertyMatched);
3364                 ProcessStringValue(&PropertyName, "PID", &CategoriesListPID, &PropertyValue, CategoryCount, &PropertyMatched);
3365                 ProcessStringValue(&PropertyName, "LANGUAGE", &CategoriesListLanguage, &PropertyValue, CategoryCount, &PropertyMatched);
3366                 ProcessIntegerValue(&PropertyName, "PREF", &CategoriesListPref, &PropertyValue, CategoryCount, &PropertyMatched);
3367                 
3368                 if (PropertyMatched == TRUE){
3369                 
3370                         PropertyMatched = FALSE;
3371                         continue;
3372                 
3373                 }
3375                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3376         
3377         }
3378         
3379         // Deal with multiple categories.
3380         
3381         int intOrigCatCount = *CategoryCount;
3382         bool FirstCategoryProcessed = TRUE;
3383         bool AfterFirstToken = FALSE;
3384         int intSplitSize = 0;
3385         int intSplitsFound = 0;
3386         int intSplitSeek = 0;
3387         int intPropertyLen = PropertySeg2.Len();
3388         
3389         SplitPoints.clear();
3390         SplitLength.clear();
3391         intPrevValue = 0;
3392         
3393         for (int i = 0; i <= intPropertyLen; i++){
3394         
3395                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3396         
3397                         continue;
3398                 
3399                 }
3400         
3401                 intSplitSize++;
3402         
3403                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3404         
3405                         if (AfterFirstToken == TRUE){
3406                 
3407                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3408                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3409                         
3410                         } else {
3411                         
3412                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3413                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3414                                 AfterFirstToken = TRUE;
3416                         }
3418                         intSplitsFound++;
3419                         intSplitSeek = i;
3420                         intSplitSize = 0;                               
3421         
3422                 }                       
3423         
3424         }
3425         
3426         if (SplitPoints.size() > 0){
3427         
3428                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3429                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3430         
3431         }
3432         
3433         if (SplitPoints.size() == 0){
3434         
3435                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3436         
3437                 if (!PropertyTokens.IsEmpty()){
3438                 
3439                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3440                 
3441                 }
3442         
3443         }
3444         
3445         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3446         intiter != SplitPoints.end(); ++intiter){
3447         
3448                 SLiter = SplitLength.find(intiter->first);
3449         
3450                 intPrevValue = intiter->second;
3451         
3452                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3453                 
3454                 // Add the data to the General/Home/Work address variables.
3455         
3456                 // Trim any whitespace from the start and end.
3457         
3458                 PropertyData = PropertyData.Trim(FALSE);
3459                 PropertyData = PropertyData.Trim(TRUE); 
3460         
3461                 CaptureString(&PropertyData, FALSE);
3462                 
3463                 if (FirstCategoryProcessed == TRUE){
3464                 
3465                         FirstCategoryProcessed = FALSE;
3466                         
3467                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3468         
3469                         if (!PropertyTokens.IsEmpty()){
3470                 
3471                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3472                 
3473                         }
3474                         
3475                         continue;
3476                 
3477                 } else {
3479                         (*CategoryCount)++;
3480                         
3481                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3482                 
3483                         if (!PropertyTokens.IsEmpty()){
3484                 
3485                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3486                 
3487                         }
3488                 
3489                 }
3490                 
3491                 // Copy the properties to each of the categories (if it exists).
3492                 
3493                 if (!PropertyTokens.IsEmpty()){
3494                 
3495                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3496                 
3497                 }
3498                 
3499                 // Check if ALTID was used.
3500                 
3501                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3502                 
3503                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3504                 
3505                 }
3506                 
3507                 // Check if PID was used.
3508                 
3509                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
3510                 
3511                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
3512                 
3513                 }
3514         
3515                 // Check if PREF was used.
3516         
3517                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
3518                 
3519                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
3520                 
3521                 }
3522                 
3523                 // Check if LANGUAGE was used.
3524                 
3525                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
3526                 
3527                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
3528                 
3529                 }
3530                 
3531                 // Check if TYPE was used.
3532                 
3533                 switch(PropType){
3534                         case PROPERTY_NONE:
3535                                 break;
3536                         case PROPERTY_HOME:
3537                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3538                                 break;
3539                         case PROPERTY_WORK:
3540                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3541                                 break;
3542                 }
3543         
3544         }
3548 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
3550         size_t intPropertyLen = PropertySeg1.Len();
3551         std::map<int, int> SplitPoints;
3552         std::map<int, int> SplitLength;
3553         std::map<int, int>::iterator SLiter;                    
3554         wxString PropertyData;
3555         wxString PropertyName;
3556         wxString PropertyValue;
3557         wxString PropertyTokens;
3558         bool FirstToken = TRUE;
3559         int intSplitsFound = 0;
3560         int intSplitSize = 0;
3561         int intPrevValue = 7;
3562         int intPref = 0;                        
3563         int intType = 0;
3564         
3565         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3566         
3567         intPrevValue = 6;
3568         
3569         PropertyType PropType = PROPERTY_NONE;
3570                 
3571         // Look for type before continuing.
3572         
3573         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3575         intPrevValue = 6;
3576         bool PropertyMatched = FALSE;
3578         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3579         intiter != SplitPoints.end(); ++intiter){
3580         
3581                 SLiter = SplitLength.find(intiter->first);
3582                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3583                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3584                 intPrevValue = intiter->second;
3585                 
3586                 // Process properties.
3587                 
3588                 size_t intPropertyValueLen = PropertyValue.Len();
3589                 
3590                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3591                         
3592                         PropertyValue.Trim();
3593                         PropertyValue.RemoveLast();
3594                         
3595                 }                               
3596                 
3597                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3598                         
3599                         PropertyValue.Remove(0, 1);
3600                         
3601                 }
3602                 
3603                 CaptureString(&PropertyValue, FALSE);
3604                 
3605                 ProcessStringValue(&PropertyName, "ALTID", &PicturesListAltID, &PropertyValue, PhotoCount, &PropertyMatched);
3606                 ProcessStringValue(&PropertyName, "PID", &PicturesListPID, &PropertyValue, PhotoCount, &PropertyMatched);
3607                 ProcessStringValue(&PropertyName, "MEDIATYPE", &PicturesListMediatype, &PropertyValue, PhotoCount, &PropertyMatched);
3608                 ProcessIntegerValue(&PropertyName, "PREF", &PicturesListPref, &PropertyValue, PhotoCount, &PropertyMatched);
3609                 
3610                 if (PropertyMatched == TRUE){
3611                 
3612                         PropertyMatched = FALSE;
3613                         continue;
3614                 
3615                 }
3617                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3618                         
3619         }       
3620         
3621         intPropertyLen = PropertySeg2.Len();
3622         SplitPoints.clear();
3623         SplitLength.clear();
3624         intSplitsFound = 0;
3625         intSplitSize = 0;
3626         intPrevValue = 0;                       
3627         
3628         CaptureString(&PropertySeg2, FALSE);
3629         
3630         for (int i = 0; i <= intPropertyLen; i++){
3632                 intSplitSize++;
3633         
3634                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3635         
3636                         intSplitsFound++;
3637                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3638                         
3639                         if (intSplitsFound == 6){ 
3640                         
3641                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3642                                 break; 
3643                                 
3644                         } else {
3645                         
3646                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3647                         
3648                         }
3649                         
3650                         intSplitSize = 0;                                       
3651         
3652                 }
3654         }
3655         
3656         wxString wxSPhotoURI;
3657         wxString wxSPhotoMIME;
3658         wxString wxSPhotoEncoding;
3659         wxString wxSPhotoData;
3660         std::string base64enc;
3661         
3662         if (intSplitsFound == 0){
3663         
3664         } else {
3665         
3666                 std::map<int, int>::iterator striter;
3667         
3668                 striter = SplitLength.find(1);
3669         
3670                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3671         
3672                 while (wSTDataType.HasMoreTokens() == TRUE){
3673                 
3674                         wxSPhotoURI = wSTDataType.GetNextToken();
3675                         wxSPhotoMIME = wSTDataType.GetNextToken();
3676                         break;
3677                 
3678                 }                       
3679         
3680                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3681         
3682                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3683                 
3684                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3685                         wxSPhotoData = wSTDataInfo.GetNextToken();
3686                         base64enc = wxSPhotoData.mb_str();
3687                         break;
3688                 
3689                 }
3690         
3691         }
3692         
3693         // Add the data to the General/Home/Work address variables.
3694         
3695         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
3696         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
3697         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
3698         
3699         switch(PropType){
3700                 case PROPERTY_NONE:
3701                         break;
3702                 case PROPERTY_HOME:
3703                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
3704                         break;
3705                 case PROPERTY_WORK:
3706                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
3707                         break;
3708         }
3709         
3710         if (!PropertyTokens.IsEmpty()){
3712                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
3713         
3714         }
3718 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
3720         size_t intPropertyLen = PropertySeg1.Len();
3721         std::map<int, int> SplitPoints;
3722         std::map<int, int> SplitLength;
3723         std::map<int, int>::iterator SLiter;                    
3724         wxString PropertyData;
3725         wxString PropertyName;
3726         wxString PropertyValue;
3727         wxString PropertyTokens;
3728         bool FirstToken = TRUE;
3729         int intSplitsFound = 0;
3730         int intSplitSize = 0;
3731         int intPrevValue = 6;
3732         int intPref = 0;                        
3733         int intType = 0;
3734         
3735         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3736         
3737         intPrevValue = 5;
3738         
3739         PropertyType PropType = PROPERTY_NONE;
3740                 
3741         // Look for type before continuing.
3742         
3743         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3745         intPrevValue = 5;
3746         bool PropertyMatched = FALSE;
3748         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3749         intiter != SplitPoints.end(); ++intiter){
3750         
3751                 SLiter = SplitLength.find(intiter->first);
3752                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3753                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3754                 intPrevValue = intiter->second;
3755                 
3756                 // Process properties.
3757                 
3758                 size_t intPropertyValueLen = PropertyValue.Len();
3759                 
3760                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3761                         
3762                         PropertyValue.Trim();
3763                         PropertyValue.RemoveLast();
3764                         
3765                 }                               
3766                 
3767                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3768                         
3769                         PropertyValue.Remove(0, 1);
3770                         
3771                 }
3772                 
3773                 CaptureString(&PropertyValue, FALSE);
3774                 
3775                 ProcessStringValue(&PropertyName, "ALTID", &LogosListAltID, &PropertyValue, LogoCount, &PropertyMatched);
3776                 ProcessStringValue(&PropertyName, "PID", &LogosListPID, &PropertyValue, LogoCount, &PropertyMatched);
3777                 ProcessStringValue(&PropertyName, "MEDIATYPE", &LogosListMediatype, &PropertyValue, LogoCount, &PropertyMatched);
3778                 ProcessIntegerValue(&PropertyName, "PREF", &LogosListPref, &PropertyValue, LogoCount, &PropertyMatched);
3779                 
3780                 if (PropertyMatched == TRUE){
3781                 
3782                         PropertyMatched = FALSE;
3783                         continue;
3784                 
3785                 }
3787                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3788         
3789         }       
3790         
3791         intPropertyLen = PropertySeg2.Len();
3792         SplitPoints.clear();
3793         SplitLength.clear();
3794         intSplitsFound = 0;
3795         intSplitSize = 0;
3796         intPrevValue = 0;                       
3797         
3798         CaptureString(&PropertySeg2, FALSE);
3799         
3800         for (int i = 0; i <= intPropertyLen; i++){
3802                 intSplitSize++;
3803         
3804                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3805         
3806                         intSplitsFound++;
3807                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3808                         
3809                         if (intSplitsFound == 6){ 
3810                         
3811                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3812                                 break; 
3813                                 
3814                         } else {
3815                         
3816                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3817                         
3818                         }
3819                         
3820                         intSplitSize = 0;                                       
3821         
3822                 }
3824         }
3825         
3826         wxString wxSPhotoURI;
3827         wxString wxSPhotoMIME;
3828         wxString wxSPhotoEncoding;
3829         wxString wxSPhotoData;
3830         std::string base64enc;
3831         
3832         if (intSplitsFound == 0){
3833         
3834         } else {
3835         
3836                 std::map<int, int>::iterator striter;
3837         
3838                 striter = SplitLength.find(1);
3839         
3840                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3841         
3842                 while (wSTDataType.HasMoreTokens() == TRUE){
3843                 
3844                         wxSPhotoURI = wSTDataType.GetNextToken();
3845                         wxSPhotoMIME = wSTDataType.GetNextToken();
3846                         break;
3847                 
3848                 }                       
3849         
3850                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
3851         
3852                 while (wSTDataInfo.HasMoreTokens() == TRUE){
3853                 
3854                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3855                         wxSPhotoData = wSTDataInfo.GetNextToken();
3856                         base64enc = wxSPhotoData.mb_str();
3857                         break;
3858                 
3859                 }
3860         
3861         }
3862         
3863         // Add the data to the General/Home/Work address variables.
3864         
3865         LogosList.insert(std::make_pair(*LogoCount, base64enc));
3866         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
3867         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
3868         
3869         switch(PropType){
3870                 case PROPERTY_NONE:
3871                         break;
3872                 case PROPERTY_HOME:
3873                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
3874                         break;
3875                 case PROPERTY_WORK:
3876                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
3877                         break;
3878         }
3879         
3880         if (!PropertyTokens.IsEmpty()){
3882                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
3883         
3884         }
3888 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
3890         size_t intPropertyLen = PropertySeg1.Len();
3891         std::map<int, int> SplitPoints;
3892         std::map<int, int> SplitLength;
3893         std::map<int, int>::iterator SLiter;                    
3894         wxString PropertyData;
3895         wxString PropertyName;
3896         wxString PropertyValue;
3897         wxString PropertyTokens;
3898         bool FirstToken = TRUE;
3899         int intSplitsFound = 0;
3900         int intSplitSize = 0;
3901         int intPrevValue = 7;
3902         int intPref = 0;                        
3903         int intType = 0;
3904         
3905         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3906         
3907         intPrevValue = 6;
3908         
3909         PropertyType PropType = PROPERTY_NONE;
3910         
3911         // Look for type before continuing.                     
3913         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3915         intPrevValue = 6;
3916         bool PropertyMatched = FALSE;
3918         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3919         intiter != SplitPoints.end(); ++intiter){
3920         
3921                 SLiter = SplitLength.find(intiter->first);
3922                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3923                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3924                 intPrevValue = intiter->second;
3925                 
3926                 // Process properties.
3927                 
3928                 size_t intPropertyValueLen = PropertyValue.Len();
3929                 
3930                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3931                         
3932                         PropertyValue.Trim();
3933                         PropertyValue.RemoveLast();
3934                         
3935                 }                               
3936                 
3937                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3938                         
3939                         PropertyValue.Remove(0, 1);
3940                         
3941                 }                       
3942                 
3943                 CaptureString(&PropertyValue, FALSE);
3944                 
3945                 ProcessStringValue(&PropertyName, "ALTID", &SoundsListAltID, &PropertyValue, SoundCount, &PropertyMatched);
3946                 ProcessStringValue(&PropertyName, "PID", &SoundsListPID, &PropertyValue, SoundCount, &PropertyMatched);
3947                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SoundsListMediatype, &PropertyValue, SoundCount, &PropertyMatched);
3948                 ProcessStringValue(&PropertyName, "LANGUAGE", &SoundsListLanguage, &PropertyValue, SoundCount, &PropertyMatched);
3949                 ProcessIntegerValue(&PropertyName, "PREF", &SoundsListPref, &PropertyValue, SoundCount, &PropertyMatched);
3950                 
3951                 if (PropertyMatched == TRUE){
3952                 
3953                         PropertyMatched = FALSE;
3954                         continue;
3955                 
3956                 }
3958                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3959         
3960         }       
3961         
3962         intPropertyLen = PropertySeg2.Len();
3963         SplitPoints.clear();
3964         SplitLength.clear();
3965         intSplitsFound = 0;
3966         intSplitSize = 0;
3967         intPrevValue = 0;
3968         
3969         CaptureString(&PropertySeg2, FALSE);
3970         
3971         for (int i = 0; i <= intPropertyLen; i++){
3973                 intSplitSize++;
3974         
3975                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3976         
3977                         intSplitsFound++;
3978                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3979                         
3980                         if (intSplitsFound == 6){ 
3981                         
3982                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3983                                 break; 
3984                                 
3985                         } else {
3986                         
3987                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3988                         
3989                         }
3990                         
3991                         intSplitSize = 0;                                       
3992         
3993                 }
3995         }
3996         
3997         wxString wxSSoundURI;
3998         wxString wxSSoundMIME;
3999         wxString wxSSoundEncoding;
4000         wxString wxSSoundData;
4001         std::string base64enc;
4002         
4003         if (intSplitsFound == 0){
4004         
4005         } else {
4006         
4007                 std::map<int, int>::iterator striter;
4008         
4009                 striter = SplitLength.find(1);
4010         
4011                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4012         
4013                 while (wSTDataType.HasMoreTokens() == TRUE){
4014                 
4015                         wxSSoundURI = wSTDataType.GetNextToken();
4016                         wxSSoundMIME = wSTDataType.GetNextToken();
4017                         break;
4018                 
4019                 }                       
4020         
4021                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4022         
4023                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4024                 
4025                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4026                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4027                         base64enc = wxSSoundData.mb_str();
4028                         break;
4029                 
4030                 }
4031         
4032         }
4033         
4034         // Add the data to the General/Home/Work address variables.
4035                 
4036         switch(PropType){
4037                 case PROPERTY_NONE:
4038                         break;
4039                 case PROPERTY_HOME:
4040                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4041                         break;
4042                 case PROPERTY_WORK:
4043                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4044                         break;
4045         }
4046         
4047         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4048         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4049         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4050         
4051         if (!PropertyTokens.IsEmpty()){
4052         
4053                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4054         
4055         }
4056         
4059 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4061         size_t intPropertyLen = PropertySeg1.Len();
4062         std::map<int, int> SplitPoints;
4063         std::map<int, int> SplitLength;
4064         std::map<int, int>::iterator SLiter;                    
4065         wxString PropertyData;
4066         wxString PropertyName;
4067         wxString PropertyValue;
4068         wxString PropertyTokens;
4069         bool FirstToken = TRUE;
4070         int intSplitsFound = 0;
4071         int intSplitSize = 0;
4072         int intPrevValue = 8;
4073         int intPref = 0;                        
4074         int intType = 0;
4075         
4076         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4077         
4078         intPrevValue = 7;
4079         
4080         PropertyType PropType = PROPERTY_NONE;
4081         
4082         // Look for type before continuing.                     
4084         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4086         intPrevValue = 7;
4087         bool PropertyMatched = FALSE;
4089         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4090         intiter != SplitPoints.end(); ++intiter){
4091         
4092                 SLiter = SplitLength.find(intiter->first);
4093                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4094                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4095                 intPrevValue = intiter->second;
4096                 
4097                 // Process properties.
4098                 
4099                 size_t intPropertyValueLen = PropertyValue.Len();
4100                 
4101                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4102                         
4103                         PropertyValue.Trim();
4104                         PropertyValue.RemoveLast();
4105                         
4106                 }                               
4107                 
4108                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4109                         
4110                         PropertyValue.Remove(0, 1);
4111                         
4112                 }                       
4113                 
4114                 CaptureString(&PropertyValue, FALSE);
4115                 
4116                 ProcessStringValue(&PropertyName, "ALTID", &CalendarListAltID, &PropertyValue, CalURICount, &PropertyMatched);
4117                 ProcessStringValue(&PropertyName, "PID", &CalendarListPID, &PropertyValue, CalURICount, &PropertyMatched);
4118                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarListMediatype, &PropertyValue, CalURICount, &PropertyMatched);
4119                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarListPref, &PropertyValue, CalURICount, &PropertyMatched);
4120                 
4121                 if (PropertyMatched == TRUE){
4122                 
4123                         PropertyMatched = FALSE;
4124                         continue;
4125                 
4126                 }
4128                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4129         
4130         }       
4131         
4132         intPropertyLen = PropertySeg2.Len();
4133         SplitPoints.clear();
4134         SplitLength.clear();
4135         intSplitsFound = 0;
4136         intSplitSize = 0;
4137         intPrevValue = 0;
4138         
4139         CaptureString(&PropertySeg2, FALSE);
4140         
4141         // Add the data to the General/Home/Work address variables.
4142                 
4143         switch(PropType){
4144                 case PROPERTY_NONE:
4145                         break;
4146                 case PROPERTY_HOME:
4147                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4148                         break;
4149                 case PROPERTY_WORK:
4150                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4151                         break;
4152         }
4153         
4154         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4155         
4156         if (!PropertyTokens.IsEmpty()){
4157         
4158                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4159         
4160         }
4164 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4166         size_t intPropertyLen = PropertySeg1.Len();
4167         std::map<int, int> SplitPoints;
4168         std::map<int, int> SplitLength;
4169         std::map<int, int>::iterator SLiter;                    
4170         wxString PropertyData;
4171         wxString PropertyName;
4172         wxString PropertyValue;
4173         wxString PropertyTokens;
4174         bool FirstToken = TRUE;
4175         int intSplitsFound = 0;
4176         int intSplitSize = 0;
4177         int intPrevValue = 8;
4178         int intPref = 0;                        
4179         int intType = 0;
4180         
4181         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4182         
4183         intPrevValue = 7;
4184         
4185         PropertyType PropType = PROPERTY_NONE;
4186         
4187         // Look for type before continuing.                     
4189         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4191         intPrevValue = 7;
4192         bool PropertyMatched = FALSE;
4194         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4195         intiter != SplitPoints.end(); ++intiter){
4196         
4197                 SLiter = SplitLength.find(intiter->first);
4198                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4199                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4200                 intPrevValue = intiter->second;
4201                 
4202                 // Process properties.
4203                 
4204                 size_t intPropertyValueLen = PropertyValue.Len();
4205                 
4206                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4207                         
4208                         PropertyValue.Trim();
4209                         PropertyValue.RemoveLast();
4210                         
4211                 }                               
4212                 
4213                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4214                         
4215                         PropertyValue.Remove(0, 1);
4216                         
4217                 }                       
4218                 
4219                 CaptureString(&PropertyValue, FALSE);
4220                 
4221                 ProcessStringValue(&PropertyName, "ALTID", &CalendarRequestListAltID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4222                 ProcessStringValue(&PropertyName, "PID", &CalendarRequestListPID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4223                 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarRequestListMediatype, &PropertyValue, CalAdrURICount, &PropertyMatched);
4224                 ProcessIntegerValue(&PropertyName, "PREF", &CalendarRequestListPref, &PropertyValue, CalAdrURICount, &PropertyMatched);
4225                 
4226                 if (PropertyMatched == TRUE){
4227                 
4228                         PropertyMatched = FALSE;
4229                         continue;
4230                 
4231                 }
4233                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4234         
4235         }       
4236         
4237         intPropertyLen = PropertySeg2.Len();
4238         SplitPoints.clear();
4239         SplitLength.clear();
4240         intSplitsFound = 0;
4241         intSplitSize = 0;
4242         intPrevValue = 0;
4243         
4244         CaptureString(&PropertySeg2, FALSE);
4245         
4246         // Add the data to the General/Home/Work address variables.
4247                 
4248         switch(PropType){
4249                 case PROPERTY_NONE:
4250                         break;
4251                 case PROPERTY_HOME:
4252                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4253                         break;
4254                 case PROPERTY_WORK:
4255                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4256                         break;
4257         }
4258         
4259         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4260         
4261         if (!PropertyTokens.IsEmpty()){
4262         
4263                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4264         
4265         }       
4266         
4269 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4271         size_t intPropertyLen = PropertySeg1.Len();
4272         std::map<int, int> SplitPoints;
4273         std::map<int, int> SplitLength;
4274         std::map<int, int>::iterator SLiter;                    
4275         wxString PropertyData;
4276         wxString PropertyName;
4277         wxString PropertyValue;
4278         wxString PropertyTokens;
4279         bool FirstToken = TRUE;
4280         int intSplitsFound = 0;
4281         int intSplitSize = 0;
4282         int intPrevValue = 7;
4283         int intPref = 0;                        
4284         int intType = 0;
4285         
4286         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4287         
4288         intPrevValue = 6;
4289         
4290         PropertyType PropType = PROPERTY_NONE;
4291         
4292         // Look for type before continuing.                     
4294         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4296         intPrevValue = 6;
4297         bool PropertyMatched = FALSE;
4299         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4300         intiter != SplitPoints.end(); ++intiter){
4301         
4302                 SLiter = SplitLength.find(intiter->first);
4303                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4304                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4305                 intPrevValue = intiter->second;
4306                 
4307                 // Process properties.
4308                 
4309                 size_t intPropertyValueLen = PropertyValue.Len();
4310                 
4311                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4312                         
4313                         PropertyValue.Trim();
4314                         PropertyValue.RemoveLast();
4315                         
4316                 }                               
4317                 
4318                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4319                         
4320                         PropertyValue.Remove(0, 1);
4321                         
4322                 }                       
4323                 
4324                 CaptureString(&PropertyValue, FALSE);
4325                 
4326                 ProcessStringValue(&PropertyName, "ALTID", &FreeBusyListAltID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4327                 ProcessStringValue(&PropertyName, "PID", &FreeBusyListPID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4328                 ProcessStringValue(&PropertyName, "MEDIATYPE", &FreeBusyListMediatype, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4329                 ProcessIntegerValue(&PropertyName, "PREF", &FreeBusyListPref, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4330                 
4331                 if (PropertyMatched == TRUE){
4332                 
4333                         PropertyMatched = FALSE;
4334                         continue;
4335                 
4336                 }
4338                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4339         
4340         }       
4341         
4342         intPropertyLen = PropertySeg2.Len();
4343         SplitPoints.clear();
4344         SplitLength.clear();
4345         intSplitsFound = 0;
4346         intSplitSize = 0;
4347         intPrevValue = 0;
4348         
4349         CaptureString(&PropertySeg2, FALSE);
4350         
4351         // Add the data to the General/Home/Work address variables.
4352                 
4353         switch(PropType){
4354                 case PROPERTY_NONE:
4355                         break;
4356                 case PROPERTY_HOME:
4357                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
4358                         break;
4359                 case PROPERTY_WORK:
4360                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
4361                         break;
4362         }
4363         
4364         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
4365         
4366         if (!PropertyTokens.IsEmpty()){
4367         
4368                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
4369         
4370         }
4374 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
4376         size_t intPropertyLen = PropertySeg1.Len();
4377         std::map<int, int> SplitPoints;
4378         std::map<int, int> SplitLength;
4379         std::map<int, int>::iterator SLiter;                    
4380         wxString PropertyData;
4381         wxString PropertyName;
4382         wxString PropertyValue;
4383         wxString PropertyTokens;
4384         bool FirstToken = TRUE;
4385         int intSplitsFound = 0;
4386         int intSplitSize = 0;
4387         int intPrevValue = 5;
4388         int intPref = 0;                        
4389         int intType = 0;
4390         long ListCtrlIndex;
4391         
4392         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4393         
4394         intPrevValue = 4;
4395         
4396         PropertyType PropType = PROPERTY_NONE;
4397         
4398         // Look for type before continuing.
4400         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4402         intPrevValue = 4;
4403         bool PropertyMatched = FALSE;
4405         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4406         intiter != SplitPoints.end(); ++intiter){
4407         
4408                 SLiter = SplitLength.find(intiter->first);
4409                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4410                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4411                 intPrevValue = intiter->second;
4412                 
4413                 // Process properties.
4414                 
4415                 size_t intPropertyValueLen = PropertyValue.Len();
4416                 
4417                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4418                         
4419                         PropertyValue.Trim();
4420                         PropertyValue.RemoveLast();
4421                         
4422                 }                               
4423                 
4424                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4425                         
4426                         PropertyValue.Remove(0, 1);
4427                         
4428                 }
4429                 
4430                 ProcessStringValue(&PropertyName, "ALTID", &KeyListAltID, &PropertyValue, KeyCount, &PropertyMatched);
4431                 ProcessStringValue(&PropertyName, "PID", &KeyListPID, &PropertyValue, KeyCount, &PropertyMatched);
4432                 ProcessIntegerValue(&PropertyName, "PREF", &KeyListPref, &PropertyValue, KeyCount, &PropertyMatched);
4433                 
4434                 if (PropertyMatched == TRUE){
4435                 
4436                         PropertyMatched = FALSE;
4437                         continue;
4438                 
4439                 }
4441                 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4442         
4443         }                               
4444         
4445         intPropertyLen = PropertySeg2.Len();
4446         SplitPoints.clear();
4447         SplitLength.clear();
4448         intSplitsFound = 0;
4449         intSplitSize = 0;
4450         intPrevValue = 0;                       
4451         
4452         for (int i = 0; i <= intPropertyLen; i++){
4454                 intSplitSize++;
4455         
4456                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4457         
4458                         intSplitsFound++;
4459                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4460                         
4461                         if (intSplitsFound == 6){ 
4462                         
4463                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4464                                 break; 
4465                                 
4466                         } else {
4467                         
4468                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4469                         
4470                         }
4471                         
4472                         intSplitSize = 0;                                       
4473         
4474                 }
4476         }
4477         
4478         wxString wxSKeyURI;
4479         wxString wxSKeyMIME;
4480         wxString wxSKeyEncoding;
4481         wxString wxSKeyData;
4482         std::string base64enc;
4483         
4484         if (intSplitsFound == 0){
4485         
4486         } else {
4487         
4488                 std::map<int, int>::iterator striter;
4489         
4490                 striter = SplitLength.find(1);
4491         
4492                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4493         
4494                 while (wSTDataType.HasMoreTokens() == TRUE){
4495                 
4496                         wxSKeyURI = wSTDataType.GetNextToken();
4497                         wxSKeyMIME = wSTDataType.GetNextToken();
4498                         break;
4499                 
4500                 }                       
4501         
4502                 if (wxSKeyURI == wxT("data")){
4503                 
4504                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4505         
4506                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4507                 
4508                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
4509                                 wxSKeyData = wSTDataInfo.GetNextToken();
4510                                 break;
4511                 
4512                         }
4513                 
4514                 }
4515         
4516         }
4517         
4518         // Add the data to the General/Home/Work address variables.
4519         
4520         if (wxSKeyURI == wxT("data")){
4521                 
4522                 KeyListDataEncType.erase(*KeyCount);
4523                 KeyListKeyType.erase(*KeyCount);
4524                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
4525                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
4526                 
4527                 KeyList.erase(*KeyCount);
4528                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
4529         
4530         } else {
4531                 
4532                 KeyList.erase(*KeyCount);
4533                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
4534         
4535         }
4536         
4537         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
4538                 
4539         switch (PropType){
4540                 case PROPERTY_NONE:
4541                         break;
4542                 case PROPERTY_HOME: 
4543                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
4544                         break;
4545                 case PROPERTY_WORK: 
4546                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
4547                         break;
4548         }
4550         if (!PropertyTokens.IsEmpty()){
4552                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
4554         }
4558 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
4560         // Split the Vendor three ways.
4561         
4562         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
4563         
4564         wxString wxSVNDID;
4565         wxString wxSVNDPropName;
4566         long ListCtrlIndex;                     
4568         while (wSTVendorDetails.HasMoreTokens() == TRUE){
4569         
4570                 wSTVendorDetails.GetNextToken();
4571                 wxSVNDID = wSTVendorDetails.GetNextToken();
4572                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
4573                 break;
4574         
4575         }
4576         
4577         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
4578         
4579                 // Add the data to the vendor variables.
4580         
4581                 VendorList.erase(*VendorCount);
4582                 VendorListPEN.erase(*VendorCount);
4583                 VendorListElement.erase(*VendorCount);
4584         
4585                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
4586                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
4587                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
4588         
4589         }
4593 void ProcessNameValue(wxString *PropertyData, 
4594         wxString *PropertyName, 
4595         wxString *PropertyValue){
4597         wxStringTokenizer PropertyElement (*PropertyData, wxT("="));
4598         *PropertyName = PropertyElement.GetNextToken();                         
4599         *PropertyValue = PropertyElement.GetNextToken();
4603 void ProcessTokens(wxString *PropertyName,
4604         wxString *PropertyValue,
4605         wxString *PropertyTokens,
4606         bool *FirstToken){
4607         
4608         if (!PropertyName->IsEmpty() && !PropertyValue->IsEmpty() && *PropertyName != wxT("TYPE")){
4609                 
4610                 if (*FirstToken == TRUE){
4611                         
4612                         PropertyTokens->Append(*PropertyName + wxT("=") + *PropertyValue);
4613                         *FirstToken = FALSE;
4614                         
4615                 } else {
4616                         
4617                         PropertyTokens->Append(wxT(";") + *PropertyName + wxT("=") + *PropertyValue);
4618                         
4619                 }
4620                 
4621         }
4622         
4625 void ProcessStringValue(wxString *PropertyName,
4626         wxString PropertyNameMatch,
4627         std::map<int,wxString> *MapPtr,
4628         wxString *PropertyValue,
4629         int *ItemCount,
4630         bool *PropertyMatched){
4631         
4632         if (*PropertyName == PropertyNameMatch){
4633                 MapPtr->erase(*ItemCount);
4634                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
4635                 *PropertyMatched = TRUE;
4636         }
4637         
4640 void ProcessIntegerValue(wxString *PropertyName,
4641         wxString PropertyNameMatch,
4642         std::map<int,int> *PrefPtr, 
4643         wxString *PropertyValue, 
4644         int *ItemCount,
4645         bool *PropertyMatched){
4647         if (*PropertyName == PropertyNameMatch){
4648                 *PropertyMatched = TRUE;
4649         } else {
4650                 return;
4651         }
4653         int PriorityNumber = 0; 
4654         bool ValidNumber = TRUE;
4655                         
4656         try{
4657                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
4658         }
4659                         
4660         catch(std::invalid_argument &e){
4661                 ValidNumber = FALSE;
4662         }
4664         if (ValidNumber == TRUE){
4666                 PrefPtr->erase(*ItemCount);
4667                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
4669         }
4673 void SplitValues(wxString *PropertyLine, 
4674         std::map<int,int> *SplitPoints, 
4675         std::map<int,int> *SplitLength, 
4676         int intSize){
4677         
4678         size_t intPropertyLen = PropertyLine->Len();
4679         int intSplitsFound = 0;
4680         int intSplitSize = 0;
4681         int intSplitSeek = 0;
4682         
4683         for (int i = intSize; i <= intPropertyLen; i++){
4685                 intSplitSize++;
4686         
4687                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4688                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4689            
4690                     if (intSplitsFound == 0){
4691             
4692                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4693           
4694                     } else {
4695            
4696                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4697             
4698                     }
4699             
4700                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4701             
4702                     intSplitsFound++;
4703                     intSplitSeek = i;
4704                     intSplitSize = 0;
4705             
4706                 }
4708         }
4710         if (intSplitsFound == 0){
4712                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4713                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4715         } else {
4717                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4718                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4720         }
4724 void CheckType(wxString *PropertySeg1, 
4725         std::map<int,int> *SplitPoints, 
4726         std::map<int,int> *SplitLength, 
4727         int *intPrevValue, 
4728         PropertyType *PropType){
4729         
4730         wxString PropertyData;
4731         wxString PropertyName;
4732         wxString PropertyValue;
4733         std::map<int,int>::iterator SLiter;
4734         
4735         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
4736         intiter != SplitPoints->end(); ++intiter){
4737         
4738                 SLiter = SplitLength->find(intiter->first);     
4739                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4740                 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);         
4741                 *intPrevValue = intiter->second;
4742                 
4743                 if (PropertyName == wxT("TYPE")){
4744                                 
4745                         if (PropertyValue == wxT("work")){
4746                         
4747                                 *PropType = PROPERTY_WORK;
4748                                                         
4749                         } else if (PropertyValue == wxT("home")){
4751                                 *PropType = PROPERTY_HOME;
4752                                                         
4753                         } else {
4754                         
4755                                 *PropType = PROPERTY_NONE;
4756                         
4757                         }
4758                 
4759                         return;
4760                 
4761                 }
4762         
4763         }
4764         
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