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