Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
47fe119f7b065927c9f91b2da3c83147ded63a3e
[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                 if (FirstToken == TRUE){
516                                 
517                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
518                         FirstToken = FALSE;
519                                 
520                 } else {
521                                 
522                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
523                                 
524                 }
525         
526         }       
527         
528         CaptureString(&PropertySeg2, FALSE);
529         
530         Revision = PropertySeg2;
531         
532         if (!PropertyTokens.IsEmpty()){
533         
534                 RevisionTokens = PropertyTokens;
535         
536         }
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543         size_t intPropertyLen = PropertySeg1.Len();
544         std::map<int, int> SplitPoints;
545         std::map<int, int> SplitLength;
546         std::map<int, int>::iterator SLiter;                    
547         wxString PropertyData;
548         wxString PropertyName;
549         wxString PropertyValue;
550         wxString PropertyTokens;
551         bool FirstToken = TRUE;
552         bool PropertyMatched = FALSE;
553         int intSplitsFound = 0;
554         int intSplitSize = 0;
555         int intPrevValue = 8;
556         int intPref = 0;                        
557         int intType = 0;
558         
559         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
560         
561         intPrevValue = 7;
562         
563         PropertyType PropType = PROPERTY_NONE;
564         
565         // Look for type before continuing.                     
567         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
569         intPrevValue = 7;
571         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
572         intiter != SplitPoints.end(); ++intiter){
573         
574                 SLiter = SplitLength.find(intiter->first);
575         
576                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
577                 
578                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
579                 PropertyName = PropertyElement.GetNextToken();                          
580                 PropertyValue = PropertyElement.GetNextToken();
581                 
582                 intPrevValue = intiter->second;
583                 
584                 // Process properties.
585                 
586                 size_t intPropertyValueLen = PropertyValue.Len();
587                 
588                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
589                         
590                         PropertyValue.Trim();
591                         PropertyValue.RemoveLast();
592                         
593                 }                               
594                 
595                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
596                         
597                         PropertyValue.Remove(0, 1);
598                         
599                 }                       
600                 
601                 CaptureString(&PropertyValue, FALSE);
602                 
603                 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
604                 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
605                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
606                 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
607                 
608                 if (PropertyMatched == TRUE){
609                 
610                         PropertyMatched = FALSE;
611                         continue;
612                 
613                 }
614                 
615                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
616                         
617                         if (FirstToken == TRUE){
618                                 
619                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
620                                 FirstToken = FALSE;
621                         
622                         } else {
623                         
624                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
625                         
626                         }
627                 
628                 }
629         
630         }       
631         
632         intPropertyLen = PropertySeg2.Len();
633         SplitPoints.clear();
634         SplitLength.clear();
635         intSplitsFound = 0;
636         intSplitSize = 0;
637         intPrevValue = 0;
638         
639         CaptureString(&PropertySeg2, FALSE);
640         
641         // Add the data to the General/Home/Work address variables.
642                 
643         switch(PropType){
644                 case PROPERTY_NONE:
645                         break;
646                 case PROPERTY_HOME:
647                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
648                         break;
649                 case PROPERTY_WORK:
650                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
651                         break;
652         }
653         
654         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
655         
656         if (!PropertyTokens.IsEmpty()){
657         
658                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
659         
660         }
664 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
666         std::map<int, int> SplitPoints;
667         std::map<int, int> SplitLength;
669         int intPrevValue = 5;
670         int intPref = 0;                        
671         int intType = 0;
672         
673         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
675         intPrevValue = 4;
676         
677         wxString PropertyName;
678         wxString PropertyValue;
679         wxString PropertyData;
680         wxString PropertyTokens;
681         std::map<int,int>::iterator SLiter;
682         bool FirstToken = TRUE;
683         bool PropertyMatched = FALSE;
684         
685         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
686         intiter != SplitPoints.end(); ++intiter){
687         
688                 SLiter = SplitLength.find(intiter->first);
689         
690                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
691                 
692                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
693                 PropertyName = PropertyElement.GetNextToken();                          
694                 PropertyValue = PropertyElement.GetNextToken();
695                 
696                 intPrevValue = intiter->second;
697                 
698                 CaptureString(&PropertyValue, FALSE);
699         
700                 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
701                 
702                 if (PropertyMatched == TRUE){
703                 
704                         PropertyMatched = FALSE;
705                         continue;
706                 
707                 }
708                 
709         }
711         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
715 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
717         std::map<int, int> SplitPoints;
718         std::map<int, int> SplitLength;
720         int intPrevValue = 8;
721         int intPref = 0;                        
722         int intType = 0;
723         
724         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
726         intPrevValue = 7;
727         
728         wxString PropertyName;
729         wxString PropertyValue;
730         wxString PropertyData;
731         wxString PropertyTokens;
732         std::map<int,int>::iterator SLiter;
733         bool FirstToken = TRUE;
734         
735         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
736         intiter != SplitPoints.end(); ++intiter){
737         
738                 SLiter = SplitLength.find(intiter->first);
739         
740                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
741                 
742                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
743                 PropertyName = PropertyElement.GetNextToken();                          
744                 PropertyValue = PropertyElement.GetNextToken();
745                 
746                 intPrevValue = intiter->second;
747                 
748                 CaptureString(&PropertyValue, FALSE);
749         
750                 if (PropertyName == wxT("ALTID")){
752                         GroupsListAltID.erase(*GroupCount);
753                         GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
754                 
755                 } else if (PropertyName == wxT("PID")){
757                         GroupsListPID.erase(*GroupCount);
758                         GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
759                 
760                 } else if (PropertyName == wxT("PREF")){
762                         ProcessIntegerValue(&GroupsListPref, &PropertyValue, GroupCount);
763                 
764                 } else if (PropertyName == wxT("MEDIATYPE")){
766                         GroupsListMediaType.erase(*GroupCount);
767                         GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
768                 
769                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
770                         
771                         if (FirstToken == TRUE){
772                                 
773                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
774                                 FirstToken = FALSE;
775                                 
776                         } else {
777                         
778                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
779                                 
780                         }
781                         
782                 }
783                 
784         }
786         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
788         if (!PropertyTokens.IsEmpty()){
789         
790                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
791         
792         }
797 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
799         std::map<int, int> SplitPoints;
800         std::map<int, int> SplitLength;
802         int intPrevValue = 4;
803         int intPref = 0;                        
804         int intType = 0;
805         
806         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
808         intPrevValue = 3;
809         
810         wxString PropertyName;
811         wxString PropertyValue;
812         wxString PropertyData;
813         wxString PropertyTokens;
814         std::map<int,int>::iterator SLiter;
815         bool FirstToken = TRUE;
816         
817         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
818         intiter != SplitPoints.end(); ++intiter){
819         
820                 SLiter = SplitLength.find(intiter->first);
821         
822                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
823                 
824                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
825                 PropertyName = PropertyElement.GetNextToken();                          
826                 PropertyValue = PropertyElement.GetNextToken();
827                 
828                 intPrevValue = intiter->second;
829                 
830                 CaptureString(&PropertyValue, FALSE);
831                 
832                 if (PropertyName == wxT("TYPE")){
834                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
835                                 PropertyValue == wxT("work") ){
837                                 FullNamesListType.erase(*FNCount);
838                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
839                 
840                         }
841                 
842                 } else if (PropertyName == wxT("LANGUAGE")){
844                         FullNamesListLanguage.erase(*FNCount);
845                         FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
846                 
847                 } else if (PropertyName == wxT("ALTID")){
848                 
849                         FullNamesListAltID.erase(*FNCount);
850                         FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
851                 
852                 } else if (PropertyName == wxT("PID")){
854                         FullNamesListPID.erase(*FNCount);
855                         FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
856                 
857                 } else if (PropertyName == wxT("PREF")){
859                         ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount);
860                 
861                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
862                         
863                         if (FirstToken == TRUE){
864                                 
865                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
866                                 FirstToken = FALSE;
867                                 
868                         } else {
869                         
870                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
871                                 
872                         }
873                         
874                 } 
875         
876         }
878         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
880         if (!PropertyTokens.IsEmpty()){
881         
882                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
883         
884         }
888 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
890         std::map<int, int> SplitPoints;
891         std::map<int, int> SplitLength;
893         int intPrevValue = 3;
894         int intPref = 0;                        
895         int intType = 0;
896         
897         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
898         
899         intPrevValue = 2;
900         
901         wxString PropertyName;
902         wxString PropertyValue;
903         wxString PropertyData;
904         wxString PropertyTokens;
905         std::map<int,int>::iterator SLiter;
906         bool FirstToken = TRUE;
907         
908         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
909         intiter != SplitPoints.end(); ++intiter){
910         
911                 SLiter = SplitLength.find(intiter->first);
912         
913                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
914                 
915                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
916                 PropertyName = PropertyElement.GetNextToken();                          
917                 PropertyValue = PropertyElement.GetNextToken();
918                 
919                 intPrevValue = intiter->second;
920                 
921                 CaptureString(&PropertyValue, FALSE);
922                 
923                 if (PropertyName == wxT("ALTID")){
925                         NameAltID = PropertyValue;
926                 
927                 } else if (PropertyName == wxT("LANGUAGE")){
928                 
929                         NameLanguage = PropertyValue;
930                 
931                 } else if (PropertyName == wxT("SORT-AS")){
932                 
933                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
934                                 PropertyValue.Len() >= 3){
935                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
936                         }
937                 
938                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
939                         
940                         if (FirstToken == TRUE){
941                                 
942                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
943                                 FirstToken = FALSE;
944                                 
945                         } else {
946                         
947                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
948                                 
949                         }
950                         
951                 }
952         
953         }
954         
955         // Split the name data.
956         
957         int intSplitSeek = 0;           
958         int intSplitsFound = 0;
959         int intSplitSize = 0;
960         int intPropertyLen = PropertySeg2.Len();
961         
962         std::map<int,wxString> NameValues;
963         intPrevValue = 0;                                       
964         
965         for (int i = 0; i <= intPropertyLen; i++){
966         
967                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
968                         
969                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
970                         
971                         intSplitSeek = i;
972                         intSplitSeek++;
973                         
974                         if (intSplitsFound == 4){
975                         
976                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
977                                 break;
978                         
979                         }
980                         
981                         intSplitSize = 0;
982                         continue;
983         
984                 }
985                 
986                 intSplitSize++;
988         }
989         
990         // Split the data into several parts.
991                         
992         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
993         iter != NameValues.end(); ++iter){
994         
995                 if (iter->first == 1){
996                 
997                         // Deal with family name.
998                         
999                         NameSurname = iter->second;
1000                 
1001                 } else if (iter->first == 2){
1002                 
1003                         // Deal with given names.
1004                         
1005                         NameForename = iter->second;
1006                 
1007                 } else if (iter->first == 3){
1008                 
1009                         // Deal with additional names.
1010                         
1011                         NameOtherNames = iter->second;
1012                 
1013                 } else if (iter->first == 4){
1014                 
1015                         // Deal with honorifix prefixes and suffixes.
1017                         NameTitle = iter->second;
1018                 
1019                         iter++;
1020                         
1021                         if (iter == NameValues.end()){
1022                         
1023                                 break;
1024                         
1025                         }
1026                 
1027                         NameSuffix = iter->second;
1028                 
1029                 }
1030         
1031         }
1032         
1033         // Add the name token data.
1034         
1035         if (!PropertyTokens.IsEmpty()){
1036         
1037                 NameTokens = PropertyTokens;
1038         
1039         }
1043 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1045         size_t intPropertyLen = PropertySeg1.Len();
1046         std::map<int, int> SplitPoints;
1047         std::map<int, int> SplitLength;
1048         std::map<int, int>::iterator SLiter;                    
1049         wxString PropertyData;
1050         wxString PropertyName;
1051         wxString PropertyValue;
1052         wxString PropertyTokens;
1053         bool FirstToken = TRUE;
1054         int intSplitsFound = 0;
1055         int intSplitSize = 0;
1056         int intPrevValue = 14;
1057         int intPref = 0;                        
1058         int intType = 0;
1059         
1060         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1061         
1062         intPrevValue = 13;
1064         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1065         intiter != SplitPoints.end(); ++intiter){
1066         
1067                 SLiter = SplitLength.find(intiter->first);
1068         
1069                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1070                 
1071                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1072                 PropertyName = PropertyElement.GetNextToken();                          
1073                 PropertyValue = PropertyElement.GetNextToken();
1074                 
1075                 intPrevValue = intiter->second;
1076                 
1077                 // Process properties.
1078                 
1079                 size_t intPropertyValueLen = PropertyValue.Len();
1080                 
1081                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1082                         
1083                         PropertyValue.Trim();
1084                         PropertyValue.RemoveLast();
1085                         
1086                 }                               
1087                 
1088                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1089                         
1090                         PropertyValue.Remove(0, 1);
1091                         
1092                 }                       
1093                 
1094                 CaptureString(&PropertyValue, FALSE);
1095                 
1096                 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1097                 
1098                         continue;
1099                 
1100                 }
1101                                                         
1102                 if (FirstToken == TRUE){
1103                                 
1104                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1105                         FirstToken = FALSE;
1106                                 
1107                 } else {
1108                                 
1109                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1110                                 
1111                 }
1112         
1113         }       
1114         
1115         CaptureString(&PropertySeg2, FALSE);
1116         
1117         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1118         
1119         if (!PropertyTokens.IsEmpty()){
1120         
1121                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1122         
1123         }
1127 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1129         std::map<int, int> SplitPoints;
1130         std::map<int, int> SplitLength;
1132         int intPrevValue = 10;
1133         int intPref = 0;                        
1134         
1135         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1136         
1137         intPrevValue = 9;
1138         
1139         PropertyType PropType = PROPERTY_NONE;
1140         
1141         // Look for type before continuing.
1142         
1143         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1144         
1145         intPrevValue = 9;
1146         
1147         std::map<int, wxString> *NicknamesList = NULL;
1148         std::map<int, wxString> *NicknamesListType = NULL;
1149         std::map<int, wxString> *NicknamesListLanguage = NULL;
1150         std::map<int, wxString> *NicknamesListAltID = NULL;
1151         std::map<int, wxString> *NicknamesListPID = NULL;
1152         std::map<int, wxString> *NicknamesListTokens = NULL;            
1153         std::map<int, int> *NicknamesListPref = NULL;
1154         
1155         switch(PropType){
1156                 case PROPERTY_NONE:
1157                         NicknamesList = &GeneralNicknamesList;
1158                         NicknamesListType = &GeneralNicknamesListType;
1159                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1160                         NicknamesListAltID = &GeneralNicknamesListAltID;
1161                         NicknamesListPID = &GeneralNicknamesListPID;
1162                         NicknamesListTokens = &GeneralNicknamesListTokens;
1163                         NicknamesListPref = &GeneralNicknamesListPref;
1164                         break;
1165                 case PROPERTY_HOME:
1166                         NicknamesList = &HomeNicknamesList;
1167                         NicknamesListType = &HomeNicknamesListType;
1168                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1169                         NicknamesListAltID = &HomeNicknamesListAltID;
1170                         NicknamesListPID = &HomeNicknamesListPID;
1171                         NicknamesListTokens = &HomeNicknamesListTokens;
1172                         NicknamesListPref = &HomeNicknamesListPref;
1173                         break;
1174                 case PROPERTY_WORK:
1175                         NicknamesList = &BusinessNicknamesList;
1176                         NicknamesListType = &BusinessNicknamesListType;
1177                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1178                         NicknamesListAltID = &BusinessNicknamesListAltID;
1179                         NicknamesListPID = &BusinessNicknamesListPID;
1180                         NicknamesListTokens = &BusinessNicknamesListTokens;
1181                         NicknamesListPref = &BusinessNicknamesListPref;
1182                         break;
1183         }
1184         
1185         std::map<int, int>::iterator SLiter;    
1186         wxString PropertyData;
1187         wxString PropertyName;
1188         wxString PropertyValue;
1189         wxString PropertyTokens;
1190         bool FirstToken = TRUE;
1191         
1192         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1193         intiter != SplitPoints.end(); ++intiter){
1194         
1195                 SLiter = SplitLength.find(intiter->first);
1196         
1197                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1198                 
1199                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1200                 PropertyName = PropertyElement.GetNextToken();                          
1201                 PropertyValue = PropertyElement.GetNextToken();
1202                 
1203                 intPrevValue = intiter->second;
1204                 
1205                 CaptureString(&PropertyValue, FALSE);
1206                 
1207                 if (PropertyName == wxT("ALTID")){
1209                         NicknamesListAltID->erase(*NicknameCount);
1210                         NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1211                 
1212                 } else if (PropertyName == wxT("PID")){
1214                         NicknamesListPID->erase(*NicknameCount);
1215                         NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));        
1217                 } else if (PropertyName == wxT("PREF")){
1219                         ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount);
1220                 
1221                 } else if (PropertyName == wxT("LANGUAGE")){
1223                         NicknamesListLanguage->erase(*NicknameCount);
1224                         NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));   
1226                 } else {
1227                 
1228                         // Something else we don't know about so append
1229                         // to the tokens variable.
1230                 
1231                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1232                 
1233                                 if (FirstToken == TRUE){
1234                         
1235                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1236                                         FirstToken = FALSE;
1237                         
1238                                 } else {
1239                         
1240                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1241                         
1242                                 }
1243                 
1244                         }
1245                 
1246                 }
1247                 
1248         }
1249         
1250         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1251         
1252         // Add the name token data.
1253         
1254         if (!PropertyTokens.IsEmpty()){
1255         
1256                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1257         
1258         }
1262 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1264         std::map<int, int> SplitPoints;
1265         std::map<int, int> SplitLength;
1266         std::map<int, int>::iterator SLiter;                    
1267         wxString PropertyData;
1268         wxString PropertyName;
1269         wxString PropertyValue;
1270         wxString PropertyTokens;
1271         bool FirstToken = TRUE;
1272         int intPrevValue = 8;
1274         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1276         intPrevValue = 7;                       
1277         
1278         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1279         intiter != SplitPoints.end(); ++intiter){
1280         
1281                 SLiter = SplitLength.find(intiter->first);
1282         
1283                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1284                 
1285                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1286                 PropertyName = PropertyElement.GetNextToken();                          
1287                 PropertyValue = PropertyElement.GetNextToken();
1288                 
1289                 intPrevValue = intiter->second;
1290                 
1291                 // Process properties.
1292                 
1293                 size_t intPropertyValueLen = PropertyValue.Len();
1294                 
1295                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1296                         
1297                         PropertyValue.Trim();
1298                         PropertyValue.RemoveLast();
1299                         
1300                 }                               
1301                 
1302                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1303                         
1304                         PropertyValue.Remove(0, 1);
1305                         
1306                 }                               
1307                 
1308                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1310                         if (FirstToken == TRUE){
1311         
1312                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1313                                 FirstToken = FALSE;
1314         
1315                         } else {
1316         
1317                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1318         
1319                         }
1321                 }
1322         
1323         }       
1325         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1326         
1327         wxString GenderComponent;
1328         
1329         if (GenderData.CountTokens() >= 2){
1330         
1331                 Gender = GenderData.GetNextToken();
1332                 GenderDetails = GenderData.GetString();
1333         
1334                 CaptureString(&GenderDetails, FALSE);
1335                                                 
1336         } else {
1337         
1338                 Gender = GenderData.GetNextToken();
1339         
1340         }
1341         
1342         if (!PropertyTokens.IsEmpty()){
1343         
1344                 GenderTokens = PropertyTokens;
1345         
1346         }
1350 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1352         // Process date. Preserve the remainder in the string.
1354         std::map<int, int> SplitPoints;
1355         std::map<int, int> SplitLength;
1356         std::map<int, int>::iterator SLiter;                    
1357         wxString PropertyData;
1358         wxString PropertyName;
1359         wxString PropertyValue;
1360         wxString PropertyTokens;
1361         bool BirthdayText = FALSE;
1362         int intPrevValue = 6;
1364         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1366         intPrevValue = 5;
1368         // Look for type before continuing.
1370         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1371         intiter != SplitPoints.end(); ++intiter){
1373                 SLiter = SplitLength.find(intiter->first);
1375                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1376         
1377                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1378                 PropertyName = PropertyElement.GetNextToken();                          
1379                 PropertyValue = PropertyElement.GetNextToken();
1380         
1381                 intPrevValue = intiter->second;
1382         
1383                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1384         
1385                         CaptureString(&PropertySeg2, FALSE);
1386                         Birthday = PropertySeg2;
1387                         BirthdayText = TRUE;
1388         
1389                 }
1391         }
1393         // Setup blank lines for later on.
1394         
1395         intPrevValue = 5;
1396         bool FirstToken = TRUE;
1398         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1399         intiter != SplitPoints.end(); ++intiter){
1401                 SLiter = SplitLength.find(intiter->first);
1403                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1404         
1405                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1406                 PropertyName = PropertyElement.GetNextToken();                          
1407                 PropertyValue = PropertyElement.GetNextToken();
1408         
1409                 intPrevValue = intiter->second;
1410         
1411                 // Process properties.
1412         
1413                 CaptureString(&PropertyValue, FALSE);
1414         
1415                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1416                 
1417                         PropertyValue.Trim();
1418                         PropertyValue.RemoveLast();
1419                 
1420                 }                               
1421         
1422                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1423                 
1424                         PropertyValue.Remove(0, 1);
1425                 
1426                 }                               
1427         
1428                 if (PropertyName == wxT("ALTID")){
1430                         BirthdayAltID = PropertyValue;
1431         
1432                 } else if (PropertyName == wxT("CALSCALE")){
1433         
1434                         BirthdayCalScale = PropertyValue;
1435         
1436                 } else if (PropertyName != wxT("VALUE")) {
1437         
1438                         // Something else we don't know about so append
1439                         // to the tokens variable.
1440                 
1441                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1442                 
1443                                 if (FirstToken == TRUE){
1444         
1445                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1446                                         FirstToken = FALSE;
1447         
1448                                 } else {
1449         
1450                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1451         
1452                                 }
1453                                 
1454                         }
1455                         
1456                 }
1458         }       
1460         // Add the data to the variables and form.
1461         
1462         if (BirthdayText == FALSE){
1463         
1464                 Birthday = PropertySeg2;
1466         }
1467         
1468         if (!PropertyTokens.IsEmpty()){
1469         
1470                 BirthdayTokens = PropertyTokens;
1472         }
1476 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1478         // Process date. Preserve the remainder in the string.
1480         std::map<int, int> SplitPoints;
1481         std::map<int, int> SplitLength;
1482         std::map<int, int>::iterator SLiter;                    
1483         wxString PropertyData;
1484         wxString PropertyName;
1485         wxString PropertyValue;
1486         wxString PropertyTokens;
1487         bool AnniversaryText = FALSE;
1488         int intPrevValue = 13;
1490         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1492         intPrevValue = 12;
1494         // Look for type before continuing.
1496         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1497         intiter != SplitPoints.end(); ++intiter){
1499                 SLiter = SplitLength.find(intiter->first);
1501                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1502         
1503                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1504                 PropertyName = PropertyElement.GetNextToken();                          
1505                 PropertyValue = PropertyElement.GetNextToken();
1506         
1507                 intPrevValue = intiter->second;
1508         
1509                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1510         
1511                         CaptureString(&PropertySeg2, FALSE);
1512                         Anniversary = PropertySeg2;
1513                         AnniversaryText = TRUE;
1514         
1515                 }
1517         }
1519         // Setup blank lines for later on.
1520         
1521         intPrevValue = 12;
1522         bool FirstToken = TRUE;
1524         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1525         intiter != SplitPoints.end(); ++intiter){
1527                 SLiter = SplitLength.find(intiter->first);
1529                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1530         
1531                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1532                 PropertyName = PropertyElement.GetNextToken();                          
1533                 PropertyValue = PropertyElement.GetNextToken();
1534         
1535                 intPrevValue = intiter->second;
1536         
1537                 // Process properties.
1538         
1539                 CaptureString(&PropertyValue, FALSE);
1540         
1541                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1542                 
1543                         PropertyValue.Trim();
1544                         PropertyValue.RemoveLast();
1545                 
1546                 }                               
1547         
1548                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1549                 
1550                         PropertyValue.Remove(0, 1);
1551                 
1552                 }                               
1553         
1554                 if (PropertyName == wxT("ALTID")){
1556                         AnniversaryAltID = PropertyValue;
1557         
1558                 } else if (PropertyName == wxT("CALSCALE")){
1559         
1560                         AnniversaryCalScale = PropertyValue;
1561         
1562                 } else if (PropertyName != wxT("VALUE")) {
1563         
1564                         // Something else we don't know about so append
1565                         // to the tokens variable.
1566                 
1567                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1568                 
1569                                 if (FirstToken == TRUE){
1570         
1571                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1572                                         FirstToken = FALSE;
1573         
1574                                 } else {
1575         
1576                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1577         
1578                                 }
1579                                 
1580                         }
1581                         
1582                 }
1584         }       
1586         // Add the data to the variables and form.
1587         
1588         if (AnniversaryText == FALSE){
1589         
1590                 Anniversary = PropertySeg2;
1592         }
1593         
1594         if (!PropertyTokens.IsEmpty()){
1595         
1596                 AnniversaryTokens = PropertyTokens;
1598         }
1602 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1604         std::map<int, int> SplitPoints;
1605         std::map<int, int> SplitLength;
1607         int intPrevValue = 4;
1608         int intPref = 0;                        
1609         
1610         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1611         
1612         intPrevValue = 3;
1613         
1614         PropertyType PropType = PROPERTY_NONE;
1615         
1616         // Look for type before continuing.
1617         
1618         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1619         
1620         intPrevValue = 3;
1621         
1622         std::map<int, wxString> *TZList = NULL;
1623         std::map<int, wxString> *TZListType = NULL;
1624         std::map<int, wxString> *TZListMediatype = NULL;
1625         std::map<int, wxString> *TZListAltID = NULL;
1626         std::map<int, wxString> *TZListPID = NULL;
1627         std::map<int, wxString> *TZListTokens = NULL;           
1628         std::map<int, int> *TZListPref = NULL;
1629         
1630         switch(PropType){
1631                 case PROPERTY_NONE:
1632                         TZList = &GeneralTZList;
1633                         TZListType = &GeneralTZListType;
1634                         TZListMediatype = &GeneralTZListMediatype;
1635                         TZListAltID = &GeneralTZListAltID;
1636                         TZListPID = &GeneralTZListPID;
1637                         TZListTokens = &GeneralTZListTokens;
1638                         TZListPref = &GeneralTZListPref;
1639                         break;
1640                 case PROPERTY_HOME:
1641                         TZList = &HomeTZList;
1642                         TZListType = &HomeTZListType;
1643                         TZListMediatype = &HomeTZListMediatype;
1644                         TZListAltID = &HomeTZListAltID;
1645                         TZListPID = &HomeTZListPID;
1646                         TZListTokens = &HomeTZListTokens;
1647                         TZListPref = &HomeTZListPref;
1648                         break;
1649                 case PROPERTY_WORK:
1650                         TZList = &BusinessTZList;
1651                         TZListType = &BusinessTZListType;
1652                         TZListMediatype = &BusinessTZListMediatype;
1653                         TZListAltID = &BusinessTZListAltID;
1654                         TZListPID = &BusinessTZListPID;
1655                         TZListTokens = &BusinessTZListTokens;
1656                         TZListPref = &BusinessTZListPref;
1657                         break;
1658         }
1659         
1660         std::map<int, int>::iterator SLiter;    
1661         wxString PropertyData;
1662         wxString PropertyName;
1663         wxString PropertyValue;
1664         wxString PropertyTokens;
1665         bool FirstToken = TRUE;
1666         
1667         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1668         intiter != SplitPoints.end(); ++intiter){
1669         
1670                 SLiter = SplitLength.find(intiter->first);
1671         
1672                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1673                 
1674                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1675                 PropertyName = PropertyElement.GetNextToken();                          
1676                 PropertyValue = PropertyElement.GetNextToken();
1677                 
1678                 intPrevValue = intiter->second;
1679                 
1680                 CaptureString(&PropertyValue, FALSE);
1682                 if (PropertyName == wxT("ALTID")){
1684                         TZListAltID->erase(*TimeZoneCount);
1685                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1686                 
1687                 } else if (PropertyName == wxT("PID")){
1689                         TZListPID->erase(*TimeZoneCount);
1690                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1692                 } else if (PropertyName == wxT("PREF")){
1694                         ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
1695                 
1696                 } else if (PropertyName == wxT("MEDIATYPE")){
1698                         TZListMediatype->erase(*TimeZoneCount);
1699                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1701                 } else {
1702                 
1703                         // Something else we don't know about so append
1704                         // to the tokens variable.
1705                 
1706                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1707                 
1708                                 if (FirstToken == TRUE){
1709                         
1710                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1711                                         FirstToken = FALSE;
1712                         
1713                                 } else {
1714                         
1715                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1716                         
1717                                 }
1718                 
1719                         }
1720                 
1721                 }
1722                 
1723         }
1724         
1725         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1726         
1727         // Add the name token data.
1728         
1729         if (!PropertyTokens.IsEmpty()){
1730         
1731                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1732         
1733         }
1738 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1740         size_t intPropertyLen = PropertySeg1.Len();
1741         std::map<int, int> SplitPoints;
1742         std::map<int, int> SplitLength;
1743         std::map<int, int>::iterator SLiter;                    
1744         wxString PropertyData;
1745         wxString PropertyName;
1746         wxString PropertyValue;
1747         wxString PropertyTokens;
1748         wxString AddressLabel;
1749         wxString AddressLang;
1750         wxString AddressAltID;
1751         wxString AddressPID;
1752         wxString AddressTokens;
1753         wxString AddressGeo;
1754         wxString AddressTimezone;
1755         wxString AddressType;
1756         wxString AddressMediatype;
1757         wxString AddressPOBox;
1758         wxString AddressExtended;
1759         wxString AddressStreet;
1760         wxString AddressLocality;
1761         wxString AddressCity;
1762         wxString AddressRegion;
1763         wxString AddressPostalCode;
1764         wxString AddressCountry;
1765         bool FirstToken = TRUE;                 
1766         int intSplitsFound = 0;
1767         int intSplitSize = 0;
1768         int intPrevValue = 5;
1769         int intPref = 0;                        
1770         int intType = 0;
1771         long ListCtrlIndex;
1772         
1773         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1774         
1775         intPrevValue = 4;
1776         
1777         PropertyType PropType = PROPERTY_NONE;
1778                 
1779         // Look for type before continuing.
1780         
1781         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1782         
1783         intPrevValue = 4;
1784         
1785         std::map<int, wxString> *AddressList = NULL;
1786         std::map<int, wxString> *AddressListTown = NULL;
1787         std::map<int, wxString> *AddressListCounty = NULL;
1788         std::map<int, wxString> *AddressListPostCode = NULL;
1789         std::map<int, wxString> *AddressListCountry = NULL;
1790         std::map<int, wxString> *AddressListLabel = NULL;
1791         std::map<int, wxString> *AddressListLang = NULL;                
1792         std::map<int, wxString> *AddressListAltID = NULL;
1793         std::map<int, wxString> *AddressListPID = NULL;
1794         std::map<int, wxString> *AddressListTokens = NULL;
1795         std::map<int, wxString> *AddressListGeo = NULL;
1796         std::map<int, wxString> *AddressListTimezone = NULL;            
1797         std::map<int, wxString> *AddressListType = NULL;
1798         std::map<int, wxString> *AddressListMediatype = NULL;
1799         std::map<int, int> *AddressListPref = NULL;
1801         switch(PropType){
1802                 case PROPERTY_NONE:
1803                         AddressList = &GeneralAddressList;
1804                         AddressListTown = &GeneralAddressListTown;
1805                         AddressListCounty = &GeneralAddressListCounty;
1806                         AddressListPostCode = &GeneralAddressListPostCode;
1807                         AddressListCountry = &GeneralAddressListCountry;
1808                         AddressListLabel = &GeneralAddressListLabel;
1809                         AddressListLang = &GeneralAddressListLang;              
1810                         AddressListAltID = &GeneralAddressListAltID;
1811                         AddressListPID = &GeneralAddressListPID;
1812                         AddressListTokens = &GeneralAddressListTokens;
1813                         AddressListGeo = &GeneralAddressListGeo;
1814                         AddressListTimezone = &GeneralAddressListTimezone;
1815                         AddressListType = &GeneralAddressListType;
1816                         AddressListMediatype = &GeneralAddressListMediatype;
1817                         AddressListPref = &GeneralAddressListPref;              
1818                         break;
1819                 case PROPERTY_HOME:
1820                         AddressList = &HomeAddressList;
1821                         AddressListTown = &HomeAddressListTown;
1822                         AddressListCounty = &HomeAddressListCounty;
1823                         AddressListPostCode = &HomeAddressListPostCode;
1824                         AddressListCountry = &HomeAddressListCountry;
1825                         AddressListLabel = &HomeAddressListLabel;
1826                         AddressListLang = &HomeAddressListLang;         
1827                         AddressListAltID = &HomeAddressListAltID;
1828                         AddressListPID = &HomeAddressListPID;
1829                         AddressListTokens = &HomeAddressListTokens;
1830                         AddressListGeo = &HomeAddressListGeo;
1831                         AddressListTimezone = &HomeAddressListTimezone;
1832                         AddressListType = &HomeAddressListType;
1833                         AddressListMediatype = &HomeAddressListMediatype;
1834                         AddressListPref = &HomeAddressListPref;
1835                         break;
1836                 case PROPERTY_WORK:
1837                         AddressList = &BusinessAddressList;
1838                         AddressListTown = &BusinessAddressListTown;
1839                         AddressListCounty = &BusinessAddressListCounty;
1840                         AddressListPostCode = &BusinessAddressListPostCode;
1841                         AddressListCountry = &BusinessAddressListCountry;
1842                         AddressListLabel = &BusinessAddressListLabel;
1843                         AddressListLang = &BusinessAddressListLang;             
1844                         AddressListAltID = &BusinessAddressListAltID;
1845                         AddressListPID = &BusinessAddressListPID;
1846                         AddressListTokens = &BusinessAddressListTokens;
1847                         AddressListGeo = &BusinessAddressListGeo;
1848                         AddressListTimezone = &BusinessAddressListTimezone;
1849                         AddressListType = &BusinessAddressListType;
1850                         AddressListMediatype = &BusinessAddressListMediatype;
1851                         AddressListPref = &BusinessAddressListPref;
1852                         break;
1853         }
1854         
1855         intPrevValue = 4;
1856         
1857         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1858         intiter != SplitPoints.end(); ++intiter){
1859         
1860                 SLiter = SplitLength.find(intiter->first);
1861         
1862                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1863                 
1864                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1865                 PropertyName = PropertyElement.GetNextToken();                          
1866                 PropertyValue = PropertyElement.GetNextToken();
1867                 
1868                 intPrevValue = intiter->second;
1869                 
1870                 CaptureString(&PropertyValue, FALSE);
1871                 
1872                 // Process properties.
1873                 
1874                 if (PropertyName == wxT("LABEL")){
1875                 
1876                         AddressListLabel->erase(*AddressCount);
1877                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1878                                 
1879                 } else if (PropertyName == wxT("LANGUAGE")){
1880                 
1881                         AddressListLang->erase(*AddressCount);
1882                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1883                 
1884                 } else if (PropertyName == wxT("ALTID")){
1886                         AddressListAltID->erase(*AddressCount);
1887                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1888                 
1889                 } else if (PropertyName == wxT("PID")){
1891                         AddressListPID->erase(*AddressCount);
1892                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1893                 
1894                 } else if (PropertyName == wxT("GEO")){
1895                 
1896                         AddressListGeo->erase(*AddressCount);
1897                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1898                 
1899                 } else if (PropertyName == wxT("TZ")){
1901                         AddressListTimezone->erase(*AddressCount);
1902                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1903                 
1904                 } else if (PropertyName == wxT("MEDIATYPE")){
1906                         AddressListMediatype->erase(*AddressCount);
1907                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1908                 
1909                 } else if (PropertyName == wxT("PREF")){
1911                         ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
1912                 
1913                 } else {
1914                 
1915                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1916                         
1917                                 if (FirstToken == TRUE){
1918                                 
1919                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1920                                         FirstToken = FALSE;
1921                                 
1922                                 } else {
1923                                 
1924                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1925                                 
1926                                 }
1927                         
1928                         }
1929                 
1930                 }
1931         
1932         }                       
1933         
1934         // Split the address. 
1936         //std::map<int, int>::iterator SLiter;
1937         intPropertyLen = PropertySeg2.Len();
1938         SplitPoints.clear();
1939         SplitLength.clear();
1940         intSplitsFound = 0;
1941         intSplitSize = 0;
1942         intPrevValue = 0;
1943         
1944         for (int i = 0; i <= intPropertyLen; i++){
1946                 intSplitSize++;
1947         
1948                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1949         
1950                         intSplitsFound++;
1951                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1952                         
1953                         if (intSplitsFound == 6){ 
1954                         
1955                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1956                                 break; 
1957                                 
1958                         } else {
1959                         
1960                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1961                         
1962                         }
1963                         
1964                         intSplitSize = 0;                                       
1965         
1966                 }
1968         }
1969         
1970         // Split the data into several parts.                   
1971         
1972         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1973         intiter != SplitPoints.end(); ++intiter){
1974                         
1975                 if (intiter->first == 1){
1976                 
1977                         // Deal with PO Box.
1978                         
1979                         SLiter = SplitLength.find(1);
1980                                                                 
1981                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1982                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1983                         intPrevValue = intiter->second;
1984                 
1985                 } else if (intiter->first == 2){
1986                 
1987                         // Deal with extended address.
1988                         
1989                         SLiter = SplitLength.find(2);
1990                         
1991                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1992                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1993                         intPrevValue = intiter->second;
1994                 
1995                 } else if (intiter->first == 3){
1996                 
1997                         // Deal with street address.
1998                         
1999                         SLiter = SplitLength.find(3);
2000                                                                 
2001                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2002                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2003                         intPrevValue = intiter->second;
2004                 
2005                 } else if (intiter->first == 4){
2006                 
2007                         // Deal with locality
2009                         SLiter = SplitLength.find(4);
2010                         
2011                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2012                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2013                         intPrevValue = intiter->second;
2014                         
2015                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2016                 
2017                 } else if (intiter->first == 5){
2018                 
2019                         // Deal with region.
2021                         SLiter = SplitLength.find(5);
2022                         
2023                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2024                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2025                         intPrevValue = intiter->second;
2026                         
2027                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2028                 
2029                 } else if (intiter->first == 6){
2030                 
2031                         // Deal with post code.
2033                         SLiter = SplitLength.find(6);
2034                         
2035                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2036                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2037                         intPrevValue = intiter->second;
2038                         
2039                         // Deal with country.
2040                                                 
2041                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2042                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2043                         
2044                         break;
2045                 
2046                 }
2047         
2048         }       
2049         
2050         // Add the data to the General/Home/Work address variables.
2051         
2052         CaptureString(&AddressStreet, FALSE); 
2053         CaptureString(&AddressLocality, FALSE);
2054         CaptureString(&AddressRegion, FALSE);
2055         CaptureString(&AddressPostalCode, FALSE);
2056         CaptureString(&AddressCountry, FALSE);
2057                 
2058         if (!PropertyTokens.IsEmpty()){
2059         
2060                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2061         
2062         }
2064         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2065         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2066         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2067         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2068         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2070         switch(PropType){
2071                 case PROPERTY_NONE:
2072                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2073                         break;
2074                 case PROPERTY_HOME:
2075                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2076                         break;
2077                 case PROPERTY_WORK:
2078                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2079                         break;
2080         }
2081         
2082         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2086 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2088         std::map<int, int> SplitPoints;
2089         std::map<int, int> SplitLength;
2091         int intPrevValue = 7;
2092         int intPref = 0;                        
2093         
2094         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2095         
2096         intPrevValue = 6;
2097         
2098         PropertyType PropType = PROPERTY_NONE;
2099                 
2100         // Look for type before continuing.
2101         
2102         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2103         
2104         std::map<int, wxString> *EmailList = NULL;
2105         std::map<int, wxString> *EmailListType = NULL;
2106         std::map<int, wxString> *EmailListAltID = NULL;
2107         std::map<int, wxString> *EmailListPID = NULL;
2108         std::map<int, wxString> *EmailListTokens = NULL;                
2109         std::map<int, int> *EmailListPref = NULL;
2111         switch(PropType){
2112                 case PROPERTY_NONE:
2113                         EmailList = &GeneralEmailList;
2114                         EmailListType = &GeneralEmailListType;
2115                         EmailListAltID = &GeneralEmailListAltID;
2116                         EmailListPID = &GeneralEmailListPID;
2117                         EmailListTokens = &GeneralEmailListTokens;              
2118                         EmailListPref = &GeneralEmailListPref;  
2119                         break;
2120                 case PROPERTY_HOME:
2121                         EmailList = &HomeEmailList;
2122                         EmailListType = &HomeEmailListType;
2123                         EmailListAltID = &HomeEmailListAltID;
2124                         EmailListPID = &HomeEmailListPID;
2125                         EmailListTokens = &HomeEmailListTokens;         
2126                         EmailListPref = &HomeEmailListPref;     
2127                         break;
2128                 case PROPERTY_WORK:
2129                         EmailList = &BusinessEmailList;
2130                         EmailListType = &BusinessEmailListType;
2131                         EmailListAltID = &BusinessEmailListAltID;
2132                         EmailListPID = &BusinessEmailListPID;
2133                         EmailListTokens = &BusinessEmailListTokens;             
2134                         EmailListPref = &BusinessEmailListPref; 
2135                         break;
2136         }
2137         
2138         intPrevValue = 6;
2139         
2140         std::map<int,int>::iterator SLiter;
2141         wxString PropertyData;
2142         wxString PropertyName;
2143         wxString PropertyValue;
2144         wxString PropertyTokens;
2145         bool FirstToken = TRUE;
2146         
2147         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2148         intiter != SplitPoints.end(); ++intiter){
2149         
2150                 SLiter = SplitLength.find(intiter->first);
2151         
2152                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2153                 
2154                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2155                 PropertyName = PropertyElement.GetNextToken();                          
2156                 PropertyValue = PropertyElement.GetNextToken();
2157                 
2158                 intPrevValue = intiter->second;
2159                 
2160                 CaptureString(&PropertyValue, FALSE);
2161                 
2162                 // Process properties.
2163                 
2164                 if (PropertyName == wxT("ALTID")){
2166                         EmailListAltID->erase(*EmailCount);
2167                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2168                 
2169                 } else if (PropertyName == wxT("PID")){
2171                         EmailListPID->erase(*EmailCount);
2172                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2173                 
2174                 } else if (PropertyName == wxT("PREF")){
2175                         
2176                         ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
2177                 
2178                 } else {
2179                 
2180                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2181                         
2182                                 if (FirstToken == TRUE){
2183                                 
2184                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2185                                         FirstToken = FALSE;
2186                                 
2187                                 } else {
2188                                 
2189                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2190                                 
2191                                 }
2192                         
2193                         }
2194                 
2195                 }
2196         
2197         }
2198         
2199         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2200         
2201         // Add the name token data.
2202         
2203         if (!PropertyTokens.IsEmpty()){
2204         
2205                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2206         
2207         }       
2212 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2214         std::map<int, int> SplitPoints;
2215         std::map<int, int> SplitLength;
2217         int intPrevValue = 6;
2218         int intPref = 0;                        
2219         
2220         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2221         
2222         intPrevValue = 5;
2223         
2224         PropertyType PropType = PROPERTY_NONE;
2225                 
2226         // Look for type before continuing.
2227         
2228         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2229         
2230         std::map<int, wxString> *IMList = NULL;
2231         std::map<int, wxString> *IMListType = NULL;
2232         std::map<int, wxString> *IMListAltID = NULL;
2233         std::map<int, wxString> *IMListPID = NULL;
2234         std::map<int, wxString> *IMListTokens = NULL;
2235         std::map<int, wxString> *IMListMediatype = NULL;        
2236         std::map<int, int> *IMListPref = NULL;
2238         switch(PropType){
2239                 case PROPERTY_NONE:
2240                         IMList = &GeneralIMList;
2241                         IMListType = &GeneralIMListType;
2242                         IMListAltID = &GeneralIMListAltID;
2243                         IMListPID = &GeneralIMListPID;
2244                         IMListTokens = &GeneralIMListTokens;
2245                         IMListMediatype = &GeneralIMListMediatype;
2246                         IMListPref = &GeneralIMListPref;        
2247                         break;
2248                 case PROPERTY_HOME:
2249                         IMList = &HomeIMList;
2250                         IMListType = &HomeIMListType;
2251                         IMListAltID = &HomeIMListAltID;
2252                         IMListPID = &HomeIMListPID;
2253                         IMListTokens = &HomeIMListTokens;
2254                         IMListMediatype = &HomeIMListMediatype;         
2255                         IMListPref = &HomeIMListPref;   
2256                         break;
2257                 case PROPERTY_WORK:
2258                         IMList = &BusinessIMList;
2259                         IMListType = &BusinessIMListType;
2260                         IMListAltID = &BusinessIMListAltID;
2261                         IMListPID = &BusinessIMListPID;
2262                         IMListTokens = &BusinessIMListTokens;   
2263                         IMListMediatype = &BusinessIMListMediatype;     
2264                         IMListPref = &BusinessIMListPref;       
2265                         break;
2266         }
2267         
2268         intPrevValue = 5;
2269         
2270         std::map<int,int>::iterator SLiter;
2271         wxString PropertyData;
2272         wxString PropertyName;
2273         wxString PropertyValue;
2274         wxString PropertyTokens;
2275         bool FirstToken = TRUE;
2276         
2277         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2278         intiter != SplitPoints.end(); ++intiter){
2279         
2280                 SLiter = SplitLength.find(intiter->first);
2281         
2282                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2283                 
2284                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2285                 PropertyName = PropertyElement.GetNextToken();                          
2286                 PropertyValue = PropertyElement.GetNextToken();
2287                 
2288                 intPrevValue = intiter->second;
2289                 
2290                 CaptureString(&PropertyValue, FALSE);
2291                 
2292                 // Process properties.
2293                 
2294                 if (PropertyName == wxT("ALTID")){
2296                         IMListAltID->erase(*IMCount);
2297                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2298                 
2299                 } else if (PropertyName == wxT("PID")){
2301                         IMListPID->erase(*IMCount);
2302                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2303                 
2304                 } else if (PropertyName == wxT("MEDIATYPE")){
2306                         IMListMediatype->erase(*IMCount);
2307                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2308                 
2309                 } else if (PropertyName == wxT("PREF")){
2310                         
2311                         ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2312                 
2313                 } else {
2314                 
2315                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2316                         
2317                                 if (FirstToken == TRUE){
2318                                 
2319                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2320                                         FirstToken = FALSE;
2321                                 
2322                                 } else {
2323                                 
2324                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2325                                 
2326                                 }
2327                         
2328                         }
2329                 
2330                 }
2331         
2332         }
2333                 
2334         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2335         
2336         // Add the name token data.
2337         
2338         if (!PropertyTokens.IsEmpty()){
2339         
2340                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2341         
2342         }
2346 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2348         std::map<int, int> SplitPoints;
2349         std::map<int, int> SplitLength;
2350         std::map<int, int>::iterator SLiter;
2351         
2352         int intPref = 0;
2353         
2354         PropertyType PropType = PROPERTY_NONE;
2355                 
2356         // Look for type before continuing.
2357         
2358         wxString TelTypeUI;
2359         wxString TelTypeDetail;
2360         wxString PropertyData;
2361         wxString PropertyName;
2362         wxString PropertyValue;
2363         wxString PropertyTokens;
2364         
2365         std::map<int,int> TypeSplitPoints;
2366         std::map<int,int> TypeSplitLength;
2367         std::map<int,int>::iterator TSLiter;
2368         
2369         int intSplitSize = 0;
2370         int intSplitsFound = 0;
2371         int intSplitPoint = 0;
2372         int intType = 0;
2373         int intPrevValue = 5;
2374                 
2375         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2376         
2377         intPrevValue = 4;
2378         
2379         // Look for type before continuing.
2380         
2381         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2382         intiter != SplitPoints.end(); ++intiter){
2383         
2384                 SLiter = SplitLength.find(intiter->first);
2385         
2386                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2387                 
2388                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2389                 PropertyName = PropertyElement.GetNextToken();                          
2390                 PropertyValue = PropertyElement.GetNextToken();
2391                 
2392                 intPrevValue = intiter->second;
2394                 if (PropertyName == wxT("TYPE")){
2395                 
2396                         // Process each value in type and translate each
2397                         // part.
2398                 
2399                         // Strip out the quotes if they are there.
2400                 
2401                         size_t intPropertyValueLen = PropertyValue.Len();
2402                 
2403                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2404                         
2405                                 PropertyValue.Trim();
2406                                 PropertyValue.RemoveLast();
2407                         
2408                         }                               
2409                 
2410                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2411                         
2412                                 PropertyValue.Remove(0, 1);
2413                         
2414                         }
2415                         
2416                         TelTypeDetail = PropertyValue;
2417                         
2418                         intSplitSize = 0;
2419                         intSplitsFound = 0;
2420                         intSplitPoint = 0;
2421                         
2422                         for (int i = 0; i <= intPropertyValueLen; i++){
2423         
2424                                 intSplitSize++;
2425         
2426                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2427         
2428                                         if (intSplitsFound == 0){
2430                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2431                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2432                         
2433                                         } else {
2434                         
2435                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2436                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2437                         
2438                                         }                       
2440                                         intSplitsFound++;
2441                                         i++;
2442                                         intSplitPoint = i;
2443                                         intSplitSize = 0;
2444         
2445                                 }
2446         
2447                         }
2448                         
2449                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2450                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2451                 
2452                         int intTypeSeek = 0;
2453                 
2454                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2455                         typeiter != TypeSplitPoints.end(); ++typeiter){
2456                         
2457                                 wxString TypePropertyName;
2458                                 
2459                                 TSLiter = TypeSplitLength.find(typeiter->first);
2460                                 
2461                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2462                                 
2463                                 if (intTypeSeek == 0){
2464                                 
2465                                 
2466                                 } else {
2467                                                                                 
2468                                         TelTypeUI.Append(wxT(","));                                                     
2469                                 
2470                                 }
2471                         
2472                                 if (TypePropertyName == wxT("home")){
2473                                 
2474                                         PropType = PROPERTY_HOME;
2475                                 
2476                                 } else if (TypePropertyName == wxT("work")){
2477                                 
2478                                         PropType = PROPERTY_WORK;
2479                                                                         
2480                                 }
2481                                 
2482                                 
2483                                 if (TypePropertyName == wxT("text")){
2484                                 
2485                                         TelTypeUI.Append(_("text"));
2486                                         intTypeSeek++;
2487                                 
2488                                 } else if (TypePropertyName == wxT("voice")){
2489                                 
2490                                         TelTypeUI.Append(_("voice"));
2491                                         intTypeSeek++;
2492                                 
2493                                 } else if (TypePropertyName == wxT("fax")){
2494                                 
2495                                         TelTypeUI.Append(_("fax"));
2496                                         intTypeSeek++;
2497                                 
2498                                 } else if (TypePropertyName == wxT("cell")){
2499                                 
2500                                         TelTypeUI.Append(_("mobile"));
2501                                         intTypeSeek++;
2502                                 
2503                                 } else if (TypePropertyName == wxT("video")){
2504                                 
2505                                         TelTypeUI.Append(_("video"));
2506                                         intTypeSeek++;
2507                                 
2508                                 } else if (TypePropertyName == wxT("pager")){
2509                                 
2510                                         TelTypeUI.Append(_("pager"));
2511                                         intTypeSeek++;
2512                                 
2513                                 } else if (TypePropertyName == wxT("textphone")){
2514                                 
2515                                         TelTypeUI.Append(_("textphone"));
2516                                         intTypeSeek++;
2517                                 
2518                                 }
2519                         
2520                         }
2521                 
2522                 }
2523                 
2524         }
2525         
2526         std::map<int, wxString> *TelephoneList = NULL;
2527         std::map<int, wxString> *TelephoneListType = NULL;
2528         std::map<int, wxString> *TelephoneListAltID = NULL;
2529         std::map<int, wxString> *TelephoneListPID = NULL;
2530         std::map<int, wxString> *TelephoneListTokens = NULL;
2531         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2532         std::map<int, int> *TelephoneListPref = NULL;
2534         switch(PropType){
2535                 case PROPERTY_NONE:
2536                         TelephoneList = &GeneralTelephoneList;
2537                         TelephoneListType = &GeneralTelephoneListType;
2538                         TelephoneListAltID = &GeneralTelephoneListAltID;
2539                         TelephoneListPID = &GeneralTelephoneListPID;
2540                         TelephoneListTokens = &GeneralTelephoneListTokens;
2541                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2542                         TelephoneListPref = &GeneralTelephoneListPref;  
2543                         break;
2544                 case PROPERTY_HOME:
2545                         TelephoneList = &HomeTelephoneList;
2546                         TelephoneListType = &HomeTelephoneListType;
2547                         TelephoneListAltID = &HomeTelephoneListAltID;
2548                         TelephoneListPID = &HomeTelephoneListPID;
2549                         TelephoneListTokens = &HomeTelephoneListTokens;
2550                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2551                         TelephoneListPref = &HomeTelephoneListPref;     
2552                         break;
2553                 case PROPERTY_WORK:
2554                         TelephoneList = &BusinessTelephoneList;
2555                         TelephoneListType = &BusinessTelephoneListType;
2556                         TelephoneListAltID = &BusinessTelephoneListAltID;
2557                         TelephoneListPID = &BusinessTelephoneListPID;
2558                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2559                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2560                         TelephoneListPref = &BusinessTelephoneListPref; 
2561                         break;
2562         }
2563                 
2564         // Process the properties.
2565         
2566         bool FirstToken = TRUE;
2567         
2568         intPrevValue = 5;
2569         SplitPoints.clear();
2570         SplitLength.clear();
2572         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2574         intPrevValue = 4;
2575         
2576         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2577         intiter != SplitPoints.end(); ++intiter){
2578         
2579                 SLiter = SplitLength.find(intiter->first);
2580         
2581                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2582                 
2583                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2584                 PropertyName = PropertyElement.GetNextToken();                          
2585                 PropertyValue = PropertyElement.GetNextToken();
2586                 
2587                 intPrevValue = intiter->second;
2588                 
2589                 CaptureString(&PropertyValue, FALSE);
2590                 
2591                 // Process properties.
2592                 
2593                 if (PropertyName == wxT("ALTID")){
2595                         TelephoneListAltID->erase(*TelephoneCount);
2596                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2597                 
2598                 } else if (PropertyName == wxT("PID")){
2600                         TelephoneListPID->erase(*TelephoneCount);
2601                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2602                 
2603                 } else if (PropertyName == wxT("PREF")){
2605                         ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2606                 
2607                 } else {
2608                 
2609                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2610                         
2611                                 if (FirstToken == TRUE){
2612                                 
2613                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2614                                         FirstToken = FALSE;
2615                                 
2616                                 } else {
2617                                 
2618                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2619                                 
2620                                 }
2621                         
2622                         }
2623                 
2624                 }
2625         
2626         }
2627                 
2628         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2629         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2630         
2631         // Add the name token data.
2632         
2633         if (!PropertyTokens.IsEmpty()){
2634         
2635                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2636         
2637         }
2641 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2643         std::map<int, int> SplitPoints;
2644         std::map<int, int> SplitLength;
2646         int intPrevValue = 6;
2647         int intPref = 0;                        
2648         
2649         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2650         
2651         intPrevValue = 5;
2652         
2653         PropertyType PropType = PROPERTY_NONE;
2654                 
2655         // Look for type before continuing.
2656         
2657         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2658         
2659         std::map<int, wxString> *LanguageList = NULL;
2660         std::map<int, wxString> *LanguageListType = NULL;
2661         std::map<int, wxString> *LanguageListAltID = NULL;
2662         std::map<int, wxString> *LanguageListPID = NULL;
2663         std::map<int, wxString> *LanguageListTokens = NULL;
2664         std::map<int, int> *LanguageListPref = NULL;
2666         switch(PropType){
2667                 case PROPERTY_NONE:
2668                         LanguageList = &GeneralLanguageList;
2669                         LanguageListType = &GeneralLanguageListType;
2670                         LanguageListAltID = &GeneralLanguageListAltID;
2671                         LanguageListPID = &GeneralLanguageListPID;
2672                         LanguageListTokens = &GeneralLanguageListTokens;
2673                         LanguageListPref = &GeneralLanguageListPref;    
2674                         break;
2675                 case PROPERTY_HOME:
2676                         LanguageList = &HomeLanguageList;
2677                         LanguageListType = &HomeLanguageListType;
2678                         LanguageListAltID = &HomeLanguageListAltID;
2679                         LanguageListPID = &HomeLanguageListPID;
2680                         LanguageListTokens = &HomeLanguageListTokens;   
2681                         LanguageListPref = &HomeLanguageListPref;       
2682                         break;
2683                 case PROPERTY_WORK:
2684                         LanguageList = &BusinessLanguageList;
2685                         LanguageListType = &BusinessLanguageListType;
2686                         LanguageListAltID = &BusinessLanguageListAltID;
2687                         LanguageListPID = &BusinessLanguageListPID;
2688                         LanguageListTokens = &BusinessLanguageListTokens;       
2689                         LanguageListPref = &BusinessLanguageListPref;
2690                         break;
2691         }
2692         
2693         intPrevValue = 5;
2694         
2695         std::map<int,int>::iterator SLiter;
2696         wxString PropertyData;
2697         wxString PropertyName;
2698         wxString PropertyValue;
2699         wxString PropertyTokens;
2700         bool FirstToken = TRUE;
2701         
2702         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2703         intiter != SplitPoints.end(); ++intiter){
2704         
2705                 SLiter = SplitLength.find(intiter->first);
2706         
2707                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2708                 
2709                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2710                 PropertyName = PropertyElement.GetNextToken();                          
2711                 PropertyValue = PropertyElement.GetNextToken();
2712                 
2713                 intPrevValue = intiter->second;
2714                 
2715                 CaptureString(&PropertyValue, FALSE);
2716                 
2717                 // Process properties.
2718                 
2719                 if (PropertyName == wxT("ALTID")){
2721                         LanguageListAltID->erase(*LanguageCount);
2722                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2723                 
2724                 } else if (PropertyName == wxT("PID")){
2726                         LanguageListPID->erase(*LanguageCount);
2727                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2728                 
2729                 } else if (PropertyName == wxT("PREF")){
2730                         
2731                         ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2732                 
2733                 } else {
2734                 
2735                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2736                         
2737                                 if (FirstToken == TRUE){
2738                                 
2739                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2740                                         FirstToken = FALSE;
2741                                 
2742                                 } else {
2743                                 
2744                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2745                                 
2746                                 }
2747                         
2748                         }
2749                 
2750                 }
2751         
2752         }
2753                 
2754         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2755         
2756         // Add the name token data.
2757         
2758         if (!PropertyTokens.IsEmpty()){
2759         
2760                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2761         
2762         }
2766 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2768         std::map<int, int> SplitPoints;
2769         std::map<int, int> SplitLength;
2771         int intPrevValue = 5;
2772         int intPref = 0;                        
2773         
2774         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2775         
2776         intPrevValue = 4;
2777         
2778         PropertyType PropType = PROPERTY_NONE;
2779                 
2780         // Look for type before continuing.
2781         
2782         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2783         
2784         std::map<int, wxString> *GeopositionList = NULL;
2785         std::map<int, wxString> *GeopositionListType = NULL;
2786         std::map<int, wxString> *GeopositionListAltID = NULL;
2787         std::map<int, wxString> *GeopositionListPID = NULL;
2788         std::map<int, wxString> *GeopositionListTokens = NULL;
2789         std::map<int, wxString> *GeopositionListMediatype = NULL;
2790         std::map<int, int> *GeopositionListPref = NULL;
2792         switch(PropType){
2793                 case PROPERTY_NONE:
2794                         GeopositionList = &GeneralGeographyList;
2795                         GeopositionListType = &GeneralGeographyListType;
2796                         GeopositionListAltID = &GeneralGeographyListAltID;
2797                         GeopositionListPID = &GeneralGeographyListPID;
2798                         GeopositionListTokens = &GeneralGeographyListTokens;
2799                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2800                         GeopositionListPref = &GeneralGeographyListPref;        
2801                         break;
2802                 case PROPERTY_HOME:
2803                         GeopositionList = &HomeGeographyList;
2804                         GeopositionListType = &HomeGeographyListType;
2805                         GeopositionListAltID = &HomeGeographyListAltID;
2806                         GeopositionListPID = &HomeGeographyListPID;
2807                         GeopositionListTokens = &HomeGeographyListTokens;
2808                         GeopositionListMediatype = &HomeGeographyListMediatype;
2809                         GeopositionListPref = &HomeGeographyListPref;   
2810                         break;
2811                 case PROPERTY_WORK:
2812                         GeopositionList = &BusinessGeographyList;
2813                         GeopositionListType = &BusinessGeographyListType;
2814                         GeopositionListAltID = &BusinessGeographyListAltID;
2815                         GeopositionListPID = &BusinessGeographyListPID;
2816                         GeopositionListTokens = &BusinessGeographyListTokens;
2817                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2818                         GeopositionListPref = &BusinessGeographyListPref;
2819                         break;
2820         }
2821         
2822         intPrevValue = 4;
2823         
2824         std::map<int,int>::iterator SLiter;
2825         wxString PropertyData;
2826         wxString PropertyName;
2827         wxString PropertyValue;
2828         wxString PropertyTokens;
2829         bool FirstToken = TRUE;
2830         
2831         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2832         intiter != SplitPoints.end(); ++intiter){
2833         
2834                 SLiter = SplitLength.find(intiter->first);
2835         
2836                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2837                 
2838                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2839                 PropertyName = PropertyElement.GetNextToken();                          
2840                 PropertyValue = PropertyElement.GetNextToken();
2841                 
2842                 intPrevValue = intiter->second;
2843                 
2844                 CaptureString(&PropertyValue, FALSE);
2845                 
2846                 // Process properties.
2847                 
2848                 if (PropertyName == wxT("ALTID")){
2850                         GeopositionListAltID->erase(*GeographicCount);
2851                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2852                 
2853                 } else if (PropertyName == wxT("PID")){
2855                         GeopositionListPID->erase(*GeographicCount);
2856                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2857                 
2858                 } else if (PropertyName == wxT("MEDIATYPE")){
2860                         GeopositionListMediatype->erase(*GeographicCount);
2861                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2862                 
2863                 } else if (PropertyName == wxT("PREF")){
2865                         ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2866                 
2867                 } else {
2868                 
2869                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2870                         
2871                                 if (FirstToken == TRUE){
2872                                 
2873                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2874                                         FirstToken = FALSE;
2875                                 
2876                                 } else {
2877                                 
2878                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2879                                 
2880                                 }
2881                         
2882                         }
2883                 
2884                 }
2885         
2886         }
2887                 
2888         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2889         
2890         // Add the name token data.
2891         
2892         if (!PropertyTokens.IsEmpty()){
2893         
2894                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2895         
2896         }
2900 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2902         size_t intPropertyLen = PropertySeg1.Len();
2903         std::map<int, int> SplitPoints;
2904         std::map<int, int> SplitLength;
2905         std::map<int, int>::iterator SLiter;                    
2906         wxString PropertyData;
2907         wxString PropertyName;
2908         wxString PropertyValue;
2909         wxString PropertyTokens;
2910         wxString RelatedType;
2911         wxString RelatedTypeOriginal;                   
2912         wxString RelatedName;
2913         bool FirstToken = TRUE;                 
2914         int intSplitsFound = 0;
2915         int intSplitSize = 0;
2916         int intPrevValue = 9;
2917         int intPref = 0;
2918         long ListCtrlIndex;
2919         
2920         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2921         
2922         intPrevValue = 8;
2923         
2924         // Look for type before continuing.
2925         
2926         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2927         intiter != SplitPoints.end(); ++intiter){
2928         
2929                 SLiter = SplitLength.find(intiter->first);
2930         
2931                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2932                 
2933                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2934                 PropertyName = PropertyElement.GetNextToken();                          
2935                 PropertyValue = PropertyElement.GetNextToken();
2936                 
2937                 intPrevValue = intiter->second;
2938                 
2939                 // Process these.
2940                 
2941                 RelatedTypeOriginal = PropertyValue;
2942                 
2943                 if (PropertyName == wxT("TYPE")){
2944                 
2945                         if (PropertyValue == wxT("contact")){
2947                                 RelatedType = _("Contact");
2949                         } else if (PropertyValue == wxT("acquaintance")){
2951                                 RelatedType = _("Acquaintance");
2953                         } else if (PropertyValue == wxT("friend")){
2955                                 RelatedType = _("Friend");
2957                         } else if (PropertyValue == wxT("met")){
2959                                 RelatedType = _("Met");
2961                         } else if (PropertyValue == wxT("co-worker")){
2963                                 RelatedType = _("Co-worker");
2965                         } else if (PropertyValue == wxT("colleague")){
2967                                 RelatedType = _("Colleague");
2969                         } else if (PropertyValue == wxT("co-resident")){
2971                                 RelatedType = _("Co-resident");
2973                         } else if (PropertyValue == wxT("neighbor")){
2975                                 RelatedType = _("Neighbour");
2977                         } else if (PropertyValue == wxT("child")){
2979                                 RelatedType = _("Child");
2981                         } else if (PropertyValue == wxT("parent")){
2983                                 RelatedType = _("Parent");
2985                         } else if (PropertyValue == wxT("sibling")){
2987                                 RelatedType = _("Sibling");
2989                         } else if (PropertyValue == wxT("spouse")){
2991                                 RelatedType = _("Spouse");
2993                         } else if (PropertyValue == wxT("kin")){
2995                                 RelatedType = _("Kin");
2997                         } else if (PropertyValue == wxT("muse")){
2999                                 RelatedType = _("Muse");
3001                         } else if (PropertyValue == wxT("crush")){
3003                                 RelatedType = _("Crush");
3005                         } else if (PropertyValue == wxT("date")){
3007                                 RelatedType = _("Date");
3009                         } else if (PropertyValue == wxT("sweetheart")){
3011                                 RelatedType = _("Sweetheart");
3013                         } else if (PropertyValue == wxT("me")){
3015                                 RelatedType = _("Me");
3017                         } else if (PropertyValue == wxT("agent")){
3019                                 RelatedType = _("Agent");
3021                         } else if (PropertyValue == wxT("emergency")){
3023                                 RelatedType = _("Emergency");
3025                         } else {
3027                                 RelatedType = PropertyValue;
3029                         }
3030                 
3031                 }
3032         
3033         }
3034         
3035         intPrevValue = 8;                       
3036         
3037         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3038         intiter != SplitPoints.end(); ++intiter){
3039         
3040                 SLiter = SplitLength.find(intiter->first);
3041         
3042                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3043                 
3044                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3045                 PropertyName = PropertyElement.GetNextToken();                          
3046                 PropertyValue = PropertyElement.GetNextToken();
3047                 
3048                 intPrevValue = intiter->second;
3049                 
3050                 // Process properties.
3051                 
3052                 size_t intPropertyValueLen = PropertyValue.Len();
3053                 
3054                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3055                         
3056                         PropertyValue.Trim();
3057                         PropertyValue.RemoveLast();
3058                         
3059                 }                               
3060                 
3061                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3062                         
3063                         PropertyValue.Remove(0, 1);
3064                         
3065                 }
3066                 
3067                 CaptureString(&PropertyValue, FALSE);
3068                         
3069                 if (PropertyName == wxT("ALTID")){
3071                         GeneralRelatedListAltID.erase(*RelatedCount);
3072                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3073                 
3074                 } else if (PropertyName == wxT("PID")){
3076                         GeneralRelatedListPID.erase(*RelatedCount);
3077                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3078                 
3079                 } else if (PropertyName == wxT("PREF")){
3080                         
3081                         int PriorityNumber = 0;
3082                         bool ValidNumber = TRUE;
3083                         
3084                         try{
3085                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3086                         }
3087                         
3088                         catch(std::invalid_argument &e){
3089                                 ValidNumber = FALSE;
3090                         }
3092                         if (ValidNumber == TRUE){
3094                                 GeneralRelatedListPref.erase(*RelatedCount);
3095                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3097                         }
3098                 
3099                 } else if (PropertyName == wxT("LANGUAGE")){
3101                         ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3102                 
3103                 } else if (PropertyName != wxT("TYPE")) {
3104                 
3105                         // Something else we don't know about so append
3106                         // to the tokens variable.
3107                 
3108                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3109                 
3110                                 if (FirstToken == TRUE){
3111                         
3112                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3113                                         FirstToken = FALSE;
3114                         
3115                                 } else {
3116                         
3117                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3118                         
3119                                 }
3120                 
3121                         }
3122                 
3123                 }
3124         
3125         }                                       
3126         
3127         // Add the data to the General/Home/Work address variables.
3128                                 
3129         GeneralRelatedList.erase(*RelatedCount);
3130         GeneralRelatedListRelType.erase(*RelatedCount);
3131         GeneralRelatedListType.erase(*RelatedCount);
3132         GeneralRelatedListTokens.erase(*RelatedCount);
3133         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3134         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3135         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3136         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3140 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3142         std::map<int, int> SplitPoints;
3143         std::map<int, int> SplitLength;
3144         std::map<int, int>::iterator SLiter;                    
3145         wxString PropertyData;
3146         wxString PropertyName;
3147         wxString PropertyValue;
3148         wxString PropertyTokens;
3149         bool FirstToken = TRUE;
3150         int intPrevValue = 5;
3151         int intPref = 0;                        
3152         int intType = 0;
3153         long ListCtrlIndex;
3154         
3155         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3156         
3157         intPrevValue = 4;
3158         
3159         PropertyType PropType = PROPERTY_NONE;
3160                 
3161         // Look for type before continuing.
3162         
3163         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3164         
3165         // Setup the pointers.
3166         
3167         std::map<int, wxString> *WebsiteList = NULL;
3168         std::map<int, wxString> *WebsiteListAltID = NULL;
3169         std::map<int, wxString> *WebsiteListPID = NULL;
3170         std::map<int, wxString> *WebsiteListType = NULL;
3171         std::map<int, wxString> *WebsiteListTokens = NULL;
3172         std::map<int, wxString> *WebsiteListMediatype = NULL;
3173         std::map<int, int> *WebsiteListPref = NULL;
3174         
3175         // Setup blank lines for later on.
3176         
3177         switch(PropType){
3178                 case PROPERTY_NONE:
3179                         WebsiteList = &GeneralWebsiteList;
3180                         WebsiteListType = &GeneralWebsiteListType;
3181                         WebsiteListAltID = &GeneralWebsiteListAltID;
3182                         WebsiteListPID = &GeneralWebsiteListPID;
3183                         WebsiteListTokens = &GeneralWebsiteListTokens;
3184                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3185                         WebsiteListPref = &GeneralWebsiteListPref;      
3186                         break;
3187                 case PROPERTY_HOME:
3188                         WebsiteList = &HomeWebsiteList;
3189                         WebsiteListType = &HomeWebsiteListType;
3190                         WebsiteListAltID = &HomeWebsiteListAltID;
3191                         WebsiteListPID = &HomeWebsiteListPID;
3192                         WebsiteListTokens = &HomeWebsiteListTokens;
3193                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3194                         WebsiteListPref = &HomeWebsiteListPref; 
3195                         break;
3196                 case PROPERTY_WORK:
3197                         WebsiteList = &BusinessWebsiteList;
3198                         WebsiteListType = &BusinessWebsiteListType;
3199                         WebsiteListAltID = &BusinessWebsiteListAltID;
3200                         WebsiteListPID = &BusinessWebsiteListPID;
3201                         WebsiteListTokens = &BusinessWebsiteListTokens;
3202                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3203                         WebsiteListPref = &BusinessWebsiteListPref;
3204                         break;
3205         }
3206         
3207         intPrevValue = 4;
3208         
3209         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3210         intiter != SplitPoints.end(); ++intiter){
3211         
3212                 SLiter = SplitLength.find(intiter->first);
3213         
3214                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3215                 
3216                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3217                 PropertyName = PropertyElement.GetNextToken();                          
3218                 PropertyValue = PropertyElement.GetNextToken();
3219                 
3220                 intPrevValue = intiter->second;
3221                 
3222                 // Process properties.
3223                 
3224                 size_t intPropertyValueLen = PropertyValue.Len();
3225                 
3226                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3227                         
3228                         PropertyValue.Trim();
3229                         PropertyValue.RemoveLast();
3230                         
3231                 }                               
3232                 
3233                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3234                         
3235                         PropertyValue.Remove(0, 1);
3236                         
3237                 }
3238                 
3239                 CaptureString(&PropertyValue, FALSE);
3240                 
3241                 if (PropertyName == wxT("ALTID")){
3243                         WebsiteListAltID->erase(*URLCount);
3244                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3245                 
3246                 } else if (PropertyName == wxT("PID")){
3248                         WebsiteListPID->erase(*URLCount);
3249                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3250                         
3251                 } else if (PropertyName == wxT("PREF")){
3253                         ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3254                                                         
3255                 } else if (PropertyName == wxT("MEDIATYPE")){
3256                 
3257                         WebsiteListMediatype->erase(*URLCount);
3258                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3259                 
3260                 } else {
3261                 
3262                         // Something else we don't know about so append
3263                         // to the tokens variable.
3264                 
3265                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3266                 
3267                                 if (FirstToken == TRUE){
3268                         
3269                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3270                                         FirstToken = FALSE;
3271                         
3272                                 } else {
3273                         
3274                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3275                         
3276                                 }
3277                 
3278                         }
3279                 
3280                 }
3281         
3282         }
3283         
3284         // Add the data to the General/Home/Work address variables.
3285         
3286         CaptureString(&PropertySeg2, FALSE);
3287                         
3288         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3289         
3290         if (!PropertyTokens.IsEmpty()){
3291         
3292                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3293                         
3294         }
3295         
3298 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3300         std::map<int, int> SplitPoints;
3301         std::map<int, int> SplitLength;
3302         std::map<int, int>::iterator SLiter;                    
3303         wxString PropertyData;
3304         wxString PropertyName;
3305         wxString PropertyValue;
3306         wxString PropertyTokens;
3307         bool FirstToken = TRUE;
3308         int intPrevValue = 7;
3309         int intPref = 0;                        
3310         int intType = 0;
3311         long ListCtrlIndex;
3312         
3313         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3314         
3315         intPrevValue = 6;
3316         
3317         PropertyType PropType = PROPERTY_NONE;
3318                 
3319         // Look for type before continuing.
3320         
3321         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3322         
3323         // Setup the pointers.
3324         
3325         std::map<int, wxString> *TitleList = NULL;
3326         std::map<int, wxString> *TitleListAltID = NULL;
3327         std::map<int, wxString> *TitleListPID = NULL;
3328         std::map<int, wxString> *TitleListType = NULL;
3329         std::map<int, wxString> *TitleListTokens = NULL;
3330         std::map<int, wxString> *TitleListLanguage = NULL;
3331         std::map<int, int> *TitleListPref = NULL;
3332         
3333         // Setup blank lines for later on.
3334         
3335         switch(PropType){
3336                 case PROPERTY_NONE:
3337                         TitleList = &GeneralTitleList;
3338                         TitleListType = &GeneralTitleListType;
3339                         TitleListAltID = &GeneralTitleListAltID;
3340                         TitleListPID = &GeneralTitleListPID;
3341                         TitleListTokens = &GeneralTitleListTokens;
3342                         TitleListLanguage = &GeneralTitleListLanguage;
3343                         TitleListPref = &GeneralTitleListPref;  
3344                         break;
3345                 case PROPERTY_HOME:
3346                         TitleList = &HomeTitleList;
3347                         TitleListType = &HomeTitleListType;
3348                         TitleListAltID = &HomeTitleListAltID;
3349                         TitleListPID = &HomeTitleListPID;
3350                         TitleListTokens = &HomeTitleListTokens;
3351                         TitleListLanguage = &HomeTitleListLanguage;
3352                         TitleListPref = &HomeTitleListPref;     
3353                         break;
3354                 case PROPERTY_WORK:
3355                         TitleList = &BusinessTitleList;
3356                         TitleListType = &BusinessTitleListType;
3357                         TitleListAltID = &BusinessTitleListAltID;
3358                         TitleListPID = &BusinessTitleListPID;
3359                         TitleListTokens = &BusinessTitleListTokens;
3360                         TitleListLanguage = &BusinessTitleListLanguage; 
3361                         TitleListPref = &BusinessTitleListPref;
3362                         break;
3363         }
3365         intPrevValue = 6;
3366                 
3367         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3368         intiter != SplitPoints.end(); ++intiter){
3369         
3370                 SLiter = SplitLength.find(intiter->first);
3371         
3372                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3373                 
3374                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3375                 PropertyName = PropertyElement.GetNextToken();                          
3376                 PropertyValue = PropertyElement.GetNextToken();
3377                 
3378                 intPrevValue = intiter->second;
3379                 
3380                 // Process properties.
3381                 
3382                 size_t intPropertyValueLen = PropertyValue.Len();
3383                 
3384                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3385                         
3386                         PropertyValue.Trim();
3387                         PropertyValue.RemoveLast();
3388                         
3389                 }                               
3390                 
3391                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3392                         
3393                         PropertyValue.Remove(0, 1);
3394                         
3395                 }                               
3396                 
3397                 CaptureString(&PropertyValue, FALSE);
3398                 
3399                 if (PropertyName == wxT("ALTID")){
3400                 
3401                         TitleListAltID->erase(*TitleCount);
3402                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3403                 
3404                 } else if (PropertyName == wxT("PID")){
3406                         TitleListPID->erase(*TitleCount);
3407                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3408                 
3409                 } else if (PropertyName == wxT("PREF")){
3411                         ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3412                         
3413                 } else if (PropertyName == wxT("LANGUAGE")){
3414                 
3415                         TitleListLanguage->erase(*TitleCount);
3416                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3417                 
3418                 } else {
3419                 
3420                         // Something else we don't know about so append
3421                         // to the tokens variable.
3422                 
3423                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3424                 
3425                                 if (FirstToken == TRUE){
3426                         
3427                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3428                                         FirstToken = FALSE;
3429                         
3430                                 } else {
3431                         
3432                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3433                         
3434                                 }
3435                 
3436                         }
3437                 
3438                 }
3439         
3440         }
3441         
3442         // Add the data to the General/Home/Work address variables.
3443         
3444         CaptureString(&PropertySeg2, FALSE);
3446         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3447         
3448         if (!PropertyTokens.IsEmpty()){
3449         
3450                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3451                         
3452         }
3456 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3458         std::map<int, int> SplitPoints;
3459         std::map<int, int> SplitLength;
3460         std::map<int, int>::iterator SLiter;                    
3461         wxString PropertyData;
3462         wxString PropertyName;
3463         wxString PropertyValue;
3464         wxString PropertyTokens;
3465         bool FirstToken = TRUE;
3466         int intPrevValue = 6;
3467         int intPref = 0;                        
3468         int intType = 0;
3469         long ListCtrlIndex;
3470         
3471         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3472         
3473         intPrevValue = 5;
3474         
3475         PropertyType PropType = PROPERTY_NONE;
3476                 
3477         // Look for type before continuing.
3478         
3479         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3480         
3481         // Setup the pointers.
3482         
3483         std::map<int, wxString> *RoleList = NULL;
3484         std::map<int, wxString> *RoleListAltID = NULL;
3485         std::map<int, wxString> *RoleListPID = NULL;
3486         std::map<int, wxString> *RoleListType = NULL;
3487         std::map<int, wxString> *RoleListTokens = NULL;
3488         std::map<int, wxString> *RoleListLanguage = NULL;
3489         std::map<int, int> *RoleListPref = NULL;
3490         
3491         // Setup blank lines for later on.
3492         
3493         switch(PropType){
3494                 case PROPERTY_NONE:
3495                         RoleList = &GeneralRoleList;
3496                         RoleListType = &GeneralRoleListType;
3497                         RoleListAltID = &GeneralRoleListAltID;
3498                         RoleListPID = &GeneralRoleListPID;
3499                         RoleListTokens = &GeneralRoleListTokens;
3500                         RoleListLanguage = &GeneralRoleListLanguage;
3501                         RoleListPref = &GeneralRoleListPref;    
3502                         break;
3503                 case PROPERTY_HOME:
3504                         RoleList = &HomeRoleList;
3505                         RoleListType = &HomeRoleListType;
3506                         RoleListAltID = &HomeRoleListAltID;
3507                         RoleListPID = &HomeRoleListPID;
3508                         RoleListTokens = &HomeRoleListTokens;
3509                         RoleListLanguage = &HomeRoleListLanguage;
3510                         RoleListPref = &HomeRoleListPref;       
3511                         break;
3512                 case PROPERTY_WORK:
3513                         RoleList = &BusinessRoleList;
3514                         RoleListType = &BusinessRoleListType;
3515                         RoleListAltID = &BusinessRoleListAltID;
3516                         RoleListPID = &BusinessRoleListPID;
3517                         RoleListTokens = &BusinessRoleListTokens;
3518                         RoleListLanguage = &BusinessRoleListLanguage;   
3519                         RoleListPref = &BusinessRoleListPref;
3520                         break;
3521         }
3523         intPrevValue = 5;
3524                 
3525         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3526         intiter != SplitPoints.end(); ++intiter){
3527         
3528                 SLiter = SplitLength.find(intiter->first);
3529         
3530                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3531                 
3532                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3533                 PropertyName = PropertyElement.GetNextToken();                          
3534                 PropertyValue = PropertyElement.GetNextToken();
3535                 
3536                 intPrevValue = intiter->second;
3537                 
3538                 // Process properties.
3539                 
3540                 size_t intPropertyValueLen = PropertyValue.Len();
3541                 
3542                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3543                         
3544                         PropertyValue.Trim();
3545                         PropertyValue.RemoveLast();
3546                         
3547                 }                               
3548                 
3549                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3550                         
3551                         PropertyValue.Remove(0, 1);
3552                         
3553                 }                               
3554                 
3555                 CaptureString(&PropertyValue, FALSE);
3556                 
3557                 if (PropertyName == wxT("ALTID")){
3558                 
3559                         RoleListAltID->erase(*RoleCount);
3560                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3561                 
3562                 } else if (PropertyName == wxT("PID")){
3564                         RoleListPID->erase(*RoleCount);
3565                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3566                 
3567                 } else if (PropertyName == wxT("PREF")){
3569                         ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3570                                 
3571                 } else if (PropertyName == wxT("LANGUAGE")){
3572                 
3573                         RoleListLanguage->erase(*RoleCount);
3574                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3575                 
3576                 } else {
3577                 
3578                         // Something else we don't know about so append
3579                         // to the tokens variable.
3580                 
3581                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3582                 
3583                                 if (FirstToken == TRUE){
3584                         
3585                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3586                                         FirstToken = FALSE;
3587                         
3588                                 } else {
3589                         
3590                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3591                         
3592                                 }
3593                 
3594                         }
3595                 
3596                 }
3597         
3598         }
3599         
3600         // Add the data to the General/Home/Work address variables.
3601         
3602         CaptureString(&PropertySeg2, FALSE);
3604         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3605         
3606         if (!PropertyTokens.IsEmpty()){
3607         
3608                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3609                         
3610         }
3614 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3616         std::map<int, int> SplitPoints;
3617         std::map<int, int> SplitLength;
3618         std::map<int, int>::iterator SLiter;                    
3619         wxString PropertyData;
3620         wxString PropertyName;
3621         wxString PropertyValue;
3622         wxString PropertyTokens;
3623         bool FirstToken = TRUE;
3624         int intPrevValue = 5;
3625         int intPref = 0;                        
3626         int intType = 0;
3627         long ListCtrlIndex;
3628         
3629         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3630         
3631         intPrevValue = 4;
3632         
3633         PropertyType PropType = PROPERTY_NONE;
3634                 
3635         // Look for type before continuing.
3636         
3637         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3638         
3639         // Setup the pointers.
3640         
3641         std::map<int, wxString> *OrganisationsList = NULL;
3642         std::map<int, wxString> *OrganisationsListAltID = NULL;
3643         std::map<int, wxString> *OrganisationsListPID = NULL;
3644         std::map<int, wxString> *OrganisationsListType = NULL;
3645         std::map<int, wxString> *OrganisationsListTokens = NULL;
3646         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3647         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3648         std::map<int, int> *OrganisationsListPref = NULL;
3649         
3650         // Setup blank lines for later on.
3651         
3652         switch(PropType){
3653                 case PROPERTY_NONE:
3654                         OrganisationsList = &GeneralOrganisationsList;
3655                         OrganisationsListType = &GeneralOrganisationsListType;
3656                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3657                         OrganisationsListPID = &GeneralOrganisationsListPID;
3658                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3659                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3660                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3661                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3662                         break;
3663                 case PROPERTY_HOME:
3664                         OrganisationsList = &HomeOrganisationsList;
3665                         OrganisationsListType = &HomeOrganisationsListType;
3666                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3667                         OrganisationsListPID = &HomeOrganisationsListPID;
3668                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3669                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3670                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3671                         OrganisationsListPref = &HomeOrganisationsListPref;     
3672                         break;
3673                 case PROPERTY_WORK:
3674                         OrganisationsList = &BusinessOrganisationsList;
3675                         OrganisationsListType = &BusinessOrganisationsListType;
3676                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3677                         OrganisationsListPID = &BusinessOrganisationsListPID;
3678                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3679                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3680                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3681                         OrganisationsListPref = &BusinessOrganisationsListPref;
3682                         break;
3683         }
3685         intPrevValue = 4;
3686                 
3687         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3688         intiter != SplitPoints.end(); ++intiter){
3689         
3690                 SLiter = SplitLength.find(intiter->first);
3691         
3692                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3693                 
3694                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3695                 PropertyName = PropertyElement.GetNextToken();                          
3696                 PropertyValue = PropertyElement.GetNextToken();
3697                 
3698                 intPrevValue = intiter->second;
3699                 
3700                 // Process properties.
3701                 
3702                 size_t intPropertyValueLen = PropertyValue.Len();
3703                 
3704                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3705                         
3706                         PropertyValue.Trim();
3707                         PropertyValue.RemoveLast();
3708                         
3709                 }                               
3710                 
3711                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3712                         
3713                         PropertyValue.Remove(0, 1);
3714                         
3715                 }                               
3716                 
3717                 CaptureString(&PropertyValue, FALSE);
3718                 
3719                 if (PropertyName == wxT("ALTID")){
3720                 
3721                         OrganisationsListAltID->erase(*OrganisationCount);
3722                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3723                 
3724                 } else if (PropertyName == wxT("PID")){
3726                         OrganisationsListPID->erase(*OrganisationCount);
3727                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3728                 
3729                 } else if (PropertyName == wxT("SORT-AS")){
3731                         OrganisationsListSortAs->erase(*OrganisationCount);
3732                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3733                 
3734                 } else if (PropertyName == wxT("PREF")){
3736                         ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3737                         
3738                 } else if (PropertyName == wxT("LANGUAGE")){
3739                 
3740                         OrganisationsListLanguage->erase(*OrganisationCount);
3741                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3742                 
3743                 } else {
3744                 
3745                         // Something else we don't know about so append
3746                         // to the tokens variable.
3747                 
3748                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3749                 
3750                                 if (FirstToken == TRUE){
3751                         
3752                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3753                                         FirstToken = FALSE;
3754                         
3755                                 } else {
3756                         
3757                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3758                         
3759                                 }
3760                 
3761                         }
3762                 
3763                 }
3764         
3765         }
3766         
3767         // Add the data to the General/Home/Work address variables.
3768         
3769         CaptureString(&PropertySeg2, FALSE);
3771         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3772         
3773         if (!PropertyTokens.IsEmpty()){
3774         
3775                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3776                         
3777         }
3781 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3783         std::map<int, int> SplitPoints;
3784         std::map<int, int> SplitLength;
3785         std::map<int, int>::iterator SLiter;                    
3786         wxString PropertyData;
3787         wxString PropertyName;
3788         wxString PropertyValue;
3789         wxString PropertyTokens;
3790         bool FirstToken = TRUE;
3791         int intPrevValue = 6;
3792         int intPref = 0;                        
3793         int intType = 0;
3794         long ListCtrlIndex;
3795         
3796         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3797         
3798         intPrevValue = 5;
3799         
3800         PropertyType PropType = PROPERTY_NONE;
3801                 
3802         // Look for type before continuing.
3803         
3804         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3805         
3806         // Setup the pointers.
3807         
3808         std::map<int, wxString> *NoteList = NULL;
3809         std::map<int, wxString> *NoteListAltID = NULL;
3810         std::map<int, wxString> *NoteListPID = NULL;
3811         std::map<int, wxString> *NoteListType = NULL;
3812         std::map<int, wxString> *NoteListTokens = NULL;
3813         std::map<int, wxString> *NoteListLanguage = NULL;
3814         std::map<int, int> *NoteListPref = NULL;
3815         
3816         // Setup blank lines for later on.
3817         
3818         switch(PropType){
3819                 case PROPERTY_NONE:
3820                         NoteList = &GeneralNoteList;
3821                         NoteListType = &GeneralNoteListType;
3822                         NoteListAltID = &GeneralNoteListAltID;
3823                         NoteListPID = &GeneralNoteListPID;
3824                         NoteListTokens = &GeneralNoteListTokens;
3825                         NoteListLanguage = &GeneralNoteListLanguage;
3826                         NoteListPref = &GeneralNoteListPref;    
3827                         break;
3828                 case PROPERTY_HOME:
3829                         NoteList = &HomeNoteList;
3830                         NoteListType = &HomeNoteListType;
3831                         NoteListAltID = &HomeNoteListAltID;
3832                         NoteListPID = &HomeNoteListPID;
3833                         NoteListTokens = &HomeNoteListTokens;
3834                         NoteListLanguage = &HomeNoteListLanguage;
3835                         NoteListPref = &HomeNoteListPref;       
3836                         break;
3837                 case PROPERTY_WORK:
3838                         NoteList = &BusinessNoteList;
3839                         NoteListType = &BusinessNoteListType;
3840                         NoteListAltID = &BusinessNoteListAltID;
3841                         NoteListPID = &BusinessNoteListPID;
3842                         NoteListTokens = &BusinessNoteListTokens;
3843                         NoteListLanguage = &BusinessNoteListLanguage;   
3844                         NoteListPref = &BusinessNoteListPref;
3845                         break;
3846         }
3848         intPrevValue = 5;
3849                 
3850         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3851         intiter != SplitPoints.end(); ++intiter){
3852         
3853                 SLiter = SplitLength.find(intiter->first);
3854         
3855                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3856                 
3857                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3858                 PropertyName = PropertyElement.GetNextToken();                          
3859                 PropertyValue = PropertyElement.GetNextToken();
3860                 
3861                 intPrevValue = intiter->second;
3862                 
3863                 // Process properties.
3864                 
3865                 size_t intPropertyValueLen = PropertyValue.Len();
3866                 
3867                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3868                         
3869                         PropertyValue.Trim();
3870                         PropertyValue.RemoveLast();
3871                         
3872                 }                               
3873                 
3874                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3875                         
3876                         PropertyValue.Remove(0, 1);
3877                         
3878                 }                               
3879                 
3880                 CaptureString(&PropertyValue, FALSE);
3881                 
3882                 if (PropertyName == wxT("ALTID")){
3883                 
3884                         NoteListAltID->erase(*NoteCount);
3885                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3886                 
3887                 } else if (PropertyName == wxT("PID")){
3889                         NoteListPID->erase(*NoteCount);
3890                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3891                 
3892                 } else if (PropertyName == wxT("PREF")){
3894                         ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3895                 
3896                 } else if (PropertyName == wxT("LANGUAGE")){
3897                 
3898                         NoteListLanguage->erase(*NoteCount);
3899                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3900                 
3901                 } else {
3902                 
3903                         // Something else we don't know about so append
3904                         // to the tokens variable.
3905                 
3906                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3907                 
3908                                 if (FirstToken == TRUE){
3909                         
3910                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3911                                         FirstToken = FALSE;
3912                         
3913                                 } else {
3914                         
3915                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3916                         
3917                                 }
3918                 
3919                         }
3920                 
3921                 }
3922         
3923         }
3924         
3925         // Add the data to the General/Home/Work address variables.
3926         
3927         CaptureString(&PropertySeg2, FALSE);
3929         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3930         
3931         if (!PropertyTokens.IsEmpty()){
3932         
3933                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3934                         
3935         }
3939 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3941         std::map<int, int> SplitPoints;
3942         std::map<int, int> SplitLength;
3943         std::map<int, int>::iterator SLiter;                    
3944         wxString PropertyData;
3945         wxString PropertyName;
3946         wxString PropertyValue;
3947         wxString PropertyTokens;
3948         bool FirstToken = TRUE;
3949         int intPrevValue = 12;
3950         int intPref = 0;                        
3951         int intType = 0;
3952         long ListCtrlIndex;
3953         
3954         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3955         
3956         intPrevValue = 11;
3957         
3958         PropertyType PropType = PROPERTY_NONE;
3959                 
3960         // Look for type before continuing.
3961         
3962         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3963         
3964         // Setup blank lines for later on.
3965         
3966         switch(PropType){
3967                 case PROPERTY_NONE:
3968                         break;
3969                 case PROPERTY_HOME:
3970                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3971                         break;
3972                 case PROPERTY_WORK:
3973                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3974                         break;
3975         }
3977         intPrevValue = 11;
3978                 
3979         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3980         intiter != SplitPoints.end(); ++intiter){
3981         
3982                 SLiter = SplitLength.find(intiter->first);
3983         
3984                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3985                 
3986                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3987                 PropertyName = PropertyElement.GetNextToken();                          
3988                 PropertyValue = PropertyElement.GetNextToken();
3989                 
3990                 intPrevValue = intiter->second;
3991                 
3992                 // Process properties.
3993                 
3994                 size_t intPropertyValueLen = PropertyValue.Len();
3995                 
3996                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3997                         
3998                         PropertyValue.Trim();
3999                         PropertyValue.RemoveLast();
4000                         
4001                 }                               
4002                 
4003                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4004                         
4005                         PropertyValue.Remove(0, 1);
4006                         
4007                 }                               
4008                 
4009                 CaptureString(&PropertyValue, FALSE);
4010                 
4011                 if (PropertyName == wxT("ALTID")){
4012                 
4013                         CategoriesListAltID.erase(*CategoryCount);
4014                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4015                 
4016                 } else if (PropertyName == wxT("PID")){
4018                         CategoriesListPID.erase(*CategoryCount);
4019                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4020                 
4021                 } else if (PropertyName == wxT("PREF")){
4023                         ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
4024                         
4025                 } else if (PropertyName == wxT("LANGUAGE")){
4026                 
4027                         CategoriesListLanguage.erase(*CategoryCount);
4028                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4029                 
4030                 } else {
4031                 
4032                         // Something else we don't know about so append
4033                         // to the tokens variable.
4034                 
4035                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4036                 
4037                                 if (FirstToken == TRUE){
4038                         
4039                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4040                                         FirstToken = FALSE;
4041                         
4042                                 } else {
4043                         
4044                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4045                         
4046                                 }
4047                 
4048                         }
4049                 
4050                 }
4051         
4052         }
4053         
4054         // Deal with multiple categories.
4055         
4056         int intOrigCatCount = *CategoryCount;
4057         bool FirstCategoryProcessed = TRUE;
4058         bool AfterFirstToken = FALSE;
4059         int intSplitSize = 0;
4060         int intSplitsFound = 0;
4061         int intSplitSeek = 0;
4062         int intPropertyLen = PropertySeg2.Len();
4063         
4064         SplitPoints.clear();
4065         SplitLength.clear();
4066         intPrevValue = 0;
4067         
4068         for (int i = 0; i <= intPropertyLen; i++){
4069         
4070                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4071         
4072                         continue;
4073                 
4074                 }
4075         
4076                 intSplitSize++;
4077         
4078                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4079         
4080                         if (AfterFirstToken == TRUE){
4081                 
4082                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4083                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4084                         
4085                         } else {
4086                         
4087                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4088                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4089                                 AfterFirstToken = TRUE;
4091                         }
4093                         intSplitsFound++;
4094                         intSplitSeek = i;
4095                         intSplitSize = 0;                               
4096         
4097                 }                       
4098         
4099         }
4100         
4101         if (SplitPoints.size() > 0){
4102         
4103                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4104                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4105         
4106         }
4107         
4108         if (SplitPoints.size() == 0){
4109         
4110                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4111         
4112                 if (!PropertyTokens.IsEmpty()){
4113                 
4114                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4115                 
4116                 }
4117         
4118         }
4119         
4120         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4121         intiter != SplitPoints.end(); ++intiter){
4122         
4123                 SLiter = SplitLength.find(intiter->first);
4124         
4125                 intPrevValue = intiter->second;
4126         
4127                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4128                 
4129                 // Add the data to the General/Home/Work address variables.
4130         
4131                 // Trim any whitespace from the start and end.
4132         
4133                 PropertyData = PropertyData.Trim(FALSE);
4134                 PropertyData = PropertyData.Trim(TRUE); 
4135         
4136                 CaptureString(&PropertyData, FALSE);
4137                 
4138                 if (FirstCategoryProcessed == TRUE){
4139                 
4140                         FirstCategoryProcessed = FALSE;
4141                         
4142                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4143         
4144                         if (!PropertyTokens.IsEmpty()){
4145                 
4146                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4147                 
4148                         }
4149                         
4150                         continue;
4151                 
4152                 } else {
4154                         (*CategoryCount)++;
4155                         
4156                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4157                 
4158                         if (!PropertyTokens.IsEmpty()){
4159                 
4160                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4161                 
4162                         }
4163                 
4164                 }
4165                 
4166                 // Copy the properties to each of the categories (if it exists).
4167                 
4168                 if (!PropertyTokens.IsEmpty()){
4169                 
4170                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4171                 
4172                 }
4173                 
4174                 // Check if ALTID was used.
4175                 
4176                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4177                 
4178                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4179                 
4180                 }
4181                 
4182                 // Check if PID was used.
4183                 
4184                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4185                 
4186                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4187                 
4188                 }
4189         
4190                 // Check if PREF was used.
4191         
4192                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4193                 
4194                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4195                 
4196                 }
4197                 
4198                 // Check if LANGUAGE was used.
4199                 
4200                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4201                 
4202                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4203                 
4204                 }
4205                 
4206                 // Check if TYPE was used.
4207                 
4208                 switch(PropType){
4209                         case PROPERTY_NONE:
4210                                 break;
4211                         case PROPERTY_HOME:
4212                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4213                                 break;
4214                         case PROPERTY_WORK:
4215                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4216                                 break;
4217                 }
4218         
4219         }
4223 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4225         size_t intPropertyLen = PropertySeg1.Len();
4226         std::map<int, int> SplitPoints;
4227         std::map<int, int> SplitLength;
4228         std::map<int, int>::iterator SLiter;                    
4229         wxString PropertyData;
4230         wxString PropertyName;
4231         wxString PropertyValue;
4232         wxString PropertyTokens;
4233         bool FirstToken = TRUE;
4234         int intSplitsFound = 0;
4235         int intSplitSize = 0;
4236         int intPrevValue = 7;
4237         int intPref = 0;                        
4238         int intType = 0;
4239         
4240         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4241         
4242         intPrevValue = 6;
4243         
4244         PropertyType PropType = PROPERTY_NONE;
4245                 
4246         // Look for type before continuing.
4247         
4248         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4250         intPrevValue = 6;
4252         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4253         intiter != SplitPoints.end(); ++intiter){
4254         
4255                 SLiter = SplitLength.find(intiter->first);
4256         
4257                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4258                 
4259                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4260                 PropertyName = PropertyElement.GetNextToken();                          
4261                 PropertyValue = PropertyElement.GetNextToken();
4262                 
4263                 intPrevValue = intiter->second;
4264                 
4265                 // Process properties.
4266                 
4267                 size_t intPropertyValueLen = PropertyValue.Len();
4268                 
4269                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4270                         
4271                         PropertyValue.Trim();
4272                         PropertyValue.RemoveLast();
4273                         
4274                 }                               
4275                 
4276                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4277                         
4278                         PropertyValue.Remove(0, 1);
4279                         
4280                 }
4281                 
4282                 CaptureString(&PropertyValue, FALSE);
4283                 
4284                 if (PropertyName == wxT("ALTID")){
4286                         PicturesListAltID.erase(*PhotoCount);
4287                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4288                 
4289                 } else if (PropertyName == wxT("PID")){
4291                         PicturesListPID.erase(*PhotoCount);
4292                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4293                 
4294                 } else if (PropertyName == wxT("PREF")){
4296                         ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4297                 
4298                 } else if (PropertyName == wxT("MEDIATYPE")){
4299                 
4300                         PicturesListMediatype.erase(*PhotoCount);
4301                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4302                                         
4303                 } else {
4304                 
4305                         // Something else we don't know about so append
4306                         // to the tokens variable.
4307                         
4308                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4309                         
4310                                 if (FirstToken == TRUE){
4311                                 
4312                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4313                                         FirstToken = FALSE;
4314                                 
4315                                 } else {
4316                                 
4317                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4318                                 
4319                                 }
4320                         
4321                         }
4322                 
4323                 }
4324         
4325         }       
4326         
4327         intPropertyLen = PropertySeg2.Len();
4328         SplitPoints.clear();
4329         SplitLength.clear();
4330         intSplitsFound = 0;
4331         intSplitSize = 0;
4332         intPrevValue = 0;                       
4333         
4334         CaptureString(&PropertySeg2, FALSE);
4335         
4336         for (int i = 0; i <= intPropertyLen; i++){
4338                 intSplitSize++;
4339         
4340                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4341         
4342                         intSplitsFound++;
4343                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4344                         
4345                         if (intSplitsFound == 6){ 
4346                         
4347                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4348                                 break; 
4349                                 
4350                         } else {
4351                         
4352                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4353                         
4354                         }
4355                         
4356                         intSplitSize = 0;                                       
4357         
4358                 }
4360         }
4361         
4362         wxString wxSPhotoURI;
4363         wxString wxSPhotoMIME;
4364         wxString wxSPhotoEncoding;
4365         wxString wxSPhotoData;
4366         std::string base64enc;
4367         
4368         if (intSplitsFound == 0){
4369         
4370         } else {
4371         
4372                 std::map<int, int>::iterator striter;
4373         
4374                 striter = SplitLength.find(1);
4375         
4376                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4377         
4378                 while (wSTDataType.HasMoreTokens() == TRUE){
4379                 
4380                         wxSPhotoURI = wSTDataType.GetNextToken();
4381                         wxSPhotoMIME = wSTDataType.GetNextToken();
4382                         break;
4383                 
4384                 }                       
4385         
4386                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4387         
4388                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4389                 
4390                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4391                         wxSPhotoData = wSTDataInfo.GetNextToken();
4392                         base64enc = wxSPhotoData.mb_str();
4393                         break;
4394                 
4395                 }
4396         
4397         }
4398         
4399         // Add the data to the General/Home/Work address variables.
4400         
4401         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4402         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4403         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4404         
4405         switch(PropType){
4406                 case PROPERTY_NONE:
4407                         break;
4408                 case PROPERTY_HOME:
4409                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4410                         break;
4411                 case PROPERTY_WORK:
4412                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4413                         break;
4414         }
4415         
4416         if (!PropertyTokens.IsEmpty()){
4418                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4419         
4420         }
4424 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4426         size_t intPropertyLen = PropertySeg1.Len();
4427         std::map<int, int> SplitPoints;
4428         std::map<int, int> SplitLength;
4429         std::map<int, int>::iterator SLiter;                    
4430         wxString PropertyData;
4431         wxString PropertyName;
4432         wxString PropertyValue;
4433         wxString PropertyTokens;
4434         bool FirstToken = TRUE;
4435         int intSplitsFound = 0;
4436         int intSplitSize = 0;
4437         int intPrevValue = 6;
4438         int intPref = 0;                        
4439         int intType = 0;
4440         
4441         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4442         
4443         intPrevValue = 5;
4444         
4445         PropertyType PropType = PROPERTY_NONE;
4446                 
4447         // Look for type before continuing.
4448         
4449         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4451         intPrevValue = 5;
4453         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4454         intiter != SplitPoints.end(); ++intiter){
4455         
4456                 SLiter = SplitLength.find(intiter->first);
4457         
4458                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4459                 
4460                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4461                 PropertyName = PropertyElement.GetNextToken();                          
4462                 PropertyValue = PropertyElement.GetNextToken();
4463                 
4464                 intPrevValue = intiter->second;
4465                 
4466                 // Process properties.
4467                 
4468                 size_t intPropertyValueLen = PropertyValue.Len();
4469                 
4470                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4471                         
4472                         PropertyValue.Trim();
4473                         PropertyValue.RemoveLast();
4474                         
4475                 }                               
4476                 
4477                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4478                         
4479                         PropertyValue.Remove(0, 1);
4480                         
4481                 }
4482                 
4483                 CaptureString(&PropertyValue, FALSE);
4484                 
4485                 if (PropertyName == wxT("ALTID")){
4487                         LogosListAltID.erase(*LogoCount);
4488                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4489                 
4490                 } else if (PropertyName == wxT("PID")){
4492                         LogosListPID.erase(*LogoCount);
4493                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4494                 
4495                 } else if (PropertyName == wxT("PREF")){
4497                         ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4498                 
4499                 } else if (PropertyName == wxT("MEDIATYPE")){
4500                 
4501                         LogosListMediatype.erase(*LogoCount);
4502                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4503                                         
4504                 } else {
4505                 
4506                         // Something else we don't know about so append
4507                         // to the tokens variable.
4508                         
4509                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4510                         
4511                                 if (FirstToken == TRUE){
4512                                 
4513                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4514                                         FirstToken = FALSE;
4515                                 
4516                                 } else {
4517                                 
4518                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4519                                 
4520                                 }
4521                         
4522                         }
4523                 
4524                 }
4525         
4526         }       
4527         
4528         intPropertyLen = PropertySeg2.Len();
4529         SplitPoints.clear();
4530         SplitLength.clear();
4531         intSplitsFound = 0;
4532         intSplitSize = 0;
4533         intPrevValue = 0;                       
4534         
4535         CaptureString(&PropertySeg2, FALSE);
4536         
4537         for (int i = 0; i <= intPropertyLen; i++){
4539                 intSplitSize++;
4540         
4541                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4542         
4543                         intSplitsFound++;
4544                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4545                         
4546                         if (intSplitsFound == 6){ 
4547                         
4548                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4549                                 break; 
4550                                 
4551                         } else {
4552                         
4553                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4554                         
4555                         }
4556                         
4557                         intSplitSize = 0;                                       
4558         
4559                 }
4561         }
4562         
4563         wxString wxSPhotoURI;
4564         wxString wxSPhotoMIME;
4565         wxString wxSPhotoEncoding;
4566         wxString wxSPhotoData;
4567         std::string base64enc;
4568         
4569         if (intSplitsFound == 0){
4570         
4571         } else {
4572         
4573                 std::map<int, int>::iterator striter;
4574         
4575                 striter = SplitLength.find(1);
4576         
4577                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4578         
4579                 while (wSTDataType.HasMoreTokens() == TRUE){
4580                 
4581                         wxSPhotoURI = wSTDataType.GetNextToken();
4582                         wxSPhotoMIME = wSTDataType.GetNextToken();
4583                         break;
4584                 
4585                 }                       
4586         
4587                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4588         
4589                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4590                 
4591                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4592                         wxSPhotoData = wSTDataInfo.GetNextToken();
4593                         base64enc = wxSPhotoData.mb_str();
4594                         break;
4595                 
4596                 }
4597         
4598         }
4599         
4600         // Add the data to the General/Home/Work address variables.
4601         
4602         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4603         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4604         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4605         
4606         switch(PropType){
4607                 case PROPERTY_NONE:
4608                         break;
4609                 case PROPERTY_HOME:
4610                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4611                         break;
4612                 case PROPERTY_WORK:
4613                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4614                         break;
4615         }
4616         
4617         if (!PropertyTokens.IsEmpty()){
4619                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4620         
4621         }
4625 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4627         size_t intPropertyLen = PropertySeg1.Len();
4628         std::map<int, int> SplitPoints;
4629         std::map<int, int> SplitLength;
4630         std::map<int, int>::iterator SLiter;                    
4631         wxString PropertyData;
4632         wxString PropertyName;
4633         wxString PropertyValue;
4634         wxString PropertyTokens;
4635         bool FirstToken = TRUE;
4636         int intSplitsFound = 0;
4637         int intSplitSize = 0;
4638         int intPrevValue = 7;
4639         int intPref = 0;                        
4640         int intType = 0;
4641         
4642         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4643         
4644         intPrevValue = 6;
4645         
4646         PropertyType PropType = PROPERTY_NONE;
4647         
4648         // Look for type before continuing.                     
4650         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4652         intPrevValue = 6;
4654         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4655         intiter != SplitPoints.end(); ++intiter){
4656         
4657                 SLiter = SplitLength.find(intiter->first);
4658         
4659                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4660                 
4661                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4662                 PropertyName = PropertyElement.GetNextToken();                          
4663                 PropertyValue = PropertyElement.GetNextToken();
4664                 
4665                 intPrevValue = intiter->second;
4666                 
4667                 // Process properties.
4668                 
4669                 size_t intPropertyValueLen = PropertyValue.Len();
4670                 
4671                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4672                         
4673                         PropertyValue.Trim();
4674                         PropertyValue.RemoveLast();
4675                         
4676                 }                               
4677                 
4678                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4679                         
4680                         PropertyValue.Remove(0, 1);
4681                         
4682                 }                       
4683                 
4684                 CaptureString(&PropertyValue, FALSE);
4685                 
4686                 if (PropertyName == wxT("ALTID")){
4688                         SoundsListAltID.erase(*SoundCount);
4689                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4690                 
4691                 } else if (PropertyName == wxT("PID")){
4693                         SoundsListPID.erase(*SoundCount);
4694                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4695                 
4696                 } else if (PropertyName == wxT("PREF")){
4698                         ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4699                 
4700                 } else if (PropertyName == wxT("MEDIATYPE")){
4701                 
4702                         SoundsListMediatype.erase(*SoundCount);
4703                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4705                 } else if (PropertyName == wxT("LANGUAGE")){
4706                 
4707                         SoundsListLanguage.erase(*SoundCount);
4708                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4710                 } else {
4711                 
4712                         // Something else we don't know about so append
4713                         // to the tokens variable.
4714                         
4715                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4716                         
4717                                 if (FirstToken == TRUE){
4718                                 
4719                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4720                                         FirstToken = FALSE;
4721                                 
4722                                 } else {
4723                                 
4724                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4725                                 
4726                                 }
4727                         
4728                         }
4729                 
4730                 }
4731         
4732         }       
4733         
4734         intPropertyLen = PropertySeg2.Len();
4735         SplitPoints.clear();
4736         SplitLength.clear();
4737         intSplitsFound = 0;
4738         intSplitSize = 0;
4739         intPrevValue = 0;
4740         
4741         CaptureString(&PropertySeg2, FALSE);
4742         
4743         for (int i = 0; i <= intPropertyLen; i++){
4745                 intSplitSize++;
4746         
4747                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4748         
4749                         intSplitsFound++;
4750                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4751                         
4752                         if (intSplitsFound == 6){ 
4753                         
4754                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4755                                 break; 
4756                                 
4757                         } else {
4758                         
4759                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4760                         
4761                         }
4762                         
4763                         intSplitSize = 0;                                       
4764         
4765                 }
4767         }
4768         
4769         wxString wxSSoundURI;
4770         wxString wxSSoundMIME;
4771         wxString wxSSoundEncoding;
4772         wxString wxSSoundData;
4773         std::string base64enc;
4774         
4775         if (intSplitsFound == 0){
4776         
4777         } else {
4778         
4779                 std::map<int, int>::iterator striter;
4780         
4781                 striter = SplitLength.find(1);
4782         
4783                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4784         
4785                 while (wSTDataType.HasMoreTokens() == TRUE){
4786                 
4787                         wxSSoundURI = wSTDataType.GetNextToken();
4788                         wxSSoundMIME = wSTDataType.GetNextToken();
4789                         break;
4790                 
4791                 }                       
4792         
4793                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4794         
4795                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4796                 
4797                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4798                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4799                         base64enc = wxSSoundData.mb_str();
4800                         break;
4801                 
4802                 }
4803         
4804         }
4805         
4806         // Add the data to the General/Home/Work address variables.
4807                 
4808         switch(PropType){
4809                 case PROPERTY_NONE:
4810                         break;
4811                 case PROPERTY_HOME:
4812                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4813                         break;
4814                 case PROPERTY_WORK:
4815                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4816                         break;
4817         }
4818         
4819         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4820         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4821         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4822         
4823         if (!PropertyTokens.IsEmpty()){
4824         
4825                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4826         
4827         }
4828         
4831 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4833         size_t intPropertyLen = PropertySeg1.Len();
4834         std::map<int, int> SplitPoints;
4835         std::map<int, int> SplitLength;
4836         std::map<int, int>::iterator SLiter;                    
4837         wxString PropertyData;
4838         wxString PropertyName;
4839         wxString PropertyValue;
4840         wxString PropertyTokens;
4841         bool FirstToken = TRUE;
4842         int intSplitsFound = 0;
4843         int intSplitSize = 0;
4844         int intPrevValue = 8;
4845         int intPref = 0;                        
4846         int intType = 0;
4847         
4848         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4849         
4850         intPrevValue = 7;
4851         
4852         PropertyType PropType = PROPERTY_NONE;
4853         
4854         // Look for type before continuing.                     
4856         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4858         intPrevValue = 7;
4860         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4861         intiter != SplitPoints.end(); ++intiter){
4862         
4863                 SLiter = SplitLength.find(intiter->first);
4864         
4865                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4866                 
4867                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4868                 PropertyName = PropertyElement.GetNextToken();                          
4869                 PropertyValue = PropertyElement.GetNextToken();
4870                 
4871                 intPrevValue = intiter->second;
4872                 
4873                 // Process properties.
4874                 
4875                 size_t intPropertyValueLen = PropertyValue.Len();
4876                 
4877                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4878                         
4879                         PropertyValue.Trim();
4880                         PropertyValue.RemoveLast();
4881                         
4882                 }                               
4883                 
4884                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4885                         
4886                         PropertyValue.Remove(0, 1);
4887                         
4888                 }                       
4889                 
4890                 CaptureString(&PropertyValue, FALSE);
4891                 
4892                 if (PropertyName == wxT("ALTID")){
4894                         CalendarListAltID.erase(*CalURICount);
4895                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4896                 
4897                 } else if (PropertyName == wxT("PID")){
4899                         CalendarListPID.erase(*CalURICount);
4900                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4901                 
4902                 } else if (PropertyName == wxT("PREF")){
4904                         ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4905                 
4906                 } else if (PropertyName == wxT("MEDIATYPE")){
4907                 
4908                         CalendarListMediatype.erase(*CalURICount);
4909                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4911                 } else {
4912                 
4913                         // Something else we don't know about so append
4914                         // to the tokens variable.
4915                         
4916                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4917                         
4918                                 if (FirstToken == TRUE){
4919                                 
4920                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4921                                         FirstToken = FALSE;
4922                                 
4923                                 } else {
4924                                 
4925                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4926                                 
4927                                 }
4928                         
4929                         }
4930                 
4931                 }
4932         
4933         }       
4934         
4935         intPropertyLen = PropertySeg2.Len();
4936         SplitPoints.clear();
4937         SplitLength.clear();
4938         intSplitsFound = 0;
4939         intSplitSize = 0;
4940         intPrevValue = 0;
4941         
4942         CaptureString(&PropertySeg2, FALSE);
4943         
4944         // Add the data to the General/Home/Work address variables.
4945                 
4946         switch(PropType){
4947                 case PROPERTY_NONE:
4948                         break;
4949                 case PROPERTY_HOME:
4950                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4951                         break;
4952                 case PROPERTY_WORK:
4953                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4954                         break;
4955         }
4956         
4957         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4958         
4959         if (!PropertyTokens.IsEmpty()){
4960         
4961                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4962         
4963         }
4967 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4969         size_t intPropertyLen = PropertySeg1.Len();
4970         std::map<int, int> SplitPoints;
4971         std::map<int, int> SplitLength;
4972         std::map<int, int>::iterator SLiter;                    
4973         wxString PropertyData;
4974         wxString PropertyName;
4975         wxString PropertyValue;
4976         wxString PropertyTokens;
4977         bool FirstToken = TRUE;
4978         int intSplitsFound = 0;
4979         int intSplitSize = 0;
4980         int intPrevValue = 8;
4981         int intPref = 0;                        
4982         int intType = 0;
4983         
4984         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4985         
4986         intPrevValue = 7;
4987         
4988         PropertyType PropType = PROPERTY_NONE;
4989         
4990         // Look for type before continuing.                     
4992         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4994         intPrevValue = 7;
4996         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4997         intiter != SplitPoints.end(); ++intiter){
4998         
4999                 SLiter = SplitLength.find(intiter->first);
5000         
5001                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5002                 
5003                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5004                 PropertyName = PropertyElement.GetNextToken();                          
5005                 PropertyValue = PropertyElement.GetNextToken();
5006                 
5007                 intPrevValue = intiter->second;
5008                 
5009                 // Process properties.
5010                 
5011                 size_t intPropertyValueLen = PropertyValue.Len();
5012                 
5013                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5014                         
5015                         PropertyValue.Trim();
5016                         PropertyValue.RemoveLast();
5017                         
5018                 }                               
5019                 
5020                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5021                         
5022                         PropertyValue.Remove(0, 1);
5023                         
5024                 }                       
5025                 
5026                 CaptureString(&PropertyValue, FALSE);
5027                 
5028                 if (PropertyName == wxT("ALTID")){
5030                         CalendarRequestListAltID.erase(*CalAdrURICount);
5031                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5032                 
5033                 } else if (PropertyName == wxT("PID")){
5035                         CalendarRequestListPID.erase(*CalAdrURICount);
5036                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5037                 
5038                 } else if (PropertyName == wxT("PREF")){
5040                         ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
5041                 
5042                 } else if (PropertyName == wxT("MEDIATYPE")){
5043                 
5044                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5045                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5047                 } else {
5048                 
5049                         // Something else we don't know about so append
5050                         // to the tokens variable.
5051                         
5052                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5053                         
5054                                 if (FirstToken == TRUE){
5055                                 
5056                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5057                                         FirstToken = FALSE;
5058                                 
5059                                 } else {
5060                                 
5061                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5062                                 
5063                                 }
5064                         
5065                         }
5066                 
5067                 }
5068         
5069         }       
5070         
5071         intPropertyLen = PropertySeg2.Len();
5072         SplitPoints.clear();
5073         SplitLength.clear();
5074         intSplitsFound = 0;
5075         intSplitSize = 0;
5076         intPrevValue = 0;
5077         
5078         CaptureString(&PropertySeg2, FALSE);
5079         
5080         // Add the data to the General/Home/Work address variables.
5081                 
5082         switch(PropType){
5083                 case PROPERTY_NONE:
5084                         break;
5085                 case PROPERTY_HOME:
5086                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5087                         break;
5088                 case PROPERTY_WORK:
5089                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5090                         break;
5091         }
5092         
5093         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5094         
5095         if (!PropertyTokens.IsEmpty()){
5096         
5097                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5098         
5099         }       
5100         
5103 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5105         size_t intPropertyLen = PropertySeg1.Len();
5106         std::map<int, int> SplitPoints;
5107         std::map<int, int> SplitLength;
5108         std::map<int, int>::iterator SLiter;                    
5109         wxString PropertyData;
5110         wxString PropertyName;
5111         wxString PropertyValue;
5112         wxString PropertyTokens;
5113         bool FirstToken = TRUE;
5114         int intSplitsFound = 0;
5115         int intSplitSize = 0;
5116         int intPrevValue = 7;
5117         int intPref = 0;                        
5118         int intType = 0;
5119         
5120         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5121         
5122         intPrevValue = 6;
5123         
5124         PropertyType PropType = PROPERTY_NONE;
5125         
5126         // Look for type before continuing.                     
5128         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5130         intPrevValue = 6;
5132         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5133         intiter != SplitPoints.end(); ++intiter){
5134         
5135                 SLiter = SplitLength.find(intiter->first);
5136         
5137                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5138                 
5139                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5140                 PropertyName = PropertyElement.GetNextToken();                          
5141                 PropertyValue = PropertyElement.GetNextToken();
5142                 
5143                 intPrevValue = intiter->second;
5144                 
5145                 // Process properties.
5146                 
5147                 size_t intPropertyValueLen = PropertyValue.Len();
5148                 
5149                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5150                         
5151                         PropertyValue.Trim();
5152                         PropertyValue.RemoveLast();
5153                         
5154                 }                               
5155                 
5156                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5157                         
5158                         PropertyValue.Remove(0, 1);
5159                         
5160                 }                       
5161                 
5162                 CaptureString(&PropertyValue, FALSE);
5163                 
5164                 if (PropertyName == wxT("ALTID")){
5166                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5167                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5168                 
5169                 } else if (PropertyName == wxT("PID")){
5171                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5172                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5173                 
5174                 } else if (PropertyName == wxT("PREF")){
5176                         ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5177                 
5178                 } else if (PropertyName == wxT("MEDIATYPE")){
5179                 
5180                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5181                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5183                 } else {
5184                 
5185                         // Something else we don't know about so append
5186                         // to the tokens variable.
5187                         
5188                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5189                         
5190                                 if (FirstToken == TRUE){
5191                                 
5192                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5193                                         FirstToken = FALSE;
5194                                 
5195                                 } else {
5196                                 
5197                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5198                                 
5199                                 }
5200                         
5201                         }
5202                 
5203                 }
5204         
5205         }       
5206         
5207         intPropertyLen = PropertySeg2.Len();
5208         SplitPoints.clear();
5209         SplitLength.clear();
5210         intSplitsFound = 0;
5211         intSplitSize = 0;
5212         intPrevValue = 0;
5213         
5214         CaptureString(&PropertySeg2, FALSE);
5215         
5216         // Add the data to the General/Home/Work address variables.
5217                 
5218         switch(PropType){
5219                 case PROPERTY_NONE:
5220                         break;
5221                 case PROPERTY_HOME:
5222                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5223                         break;
5224                 case PROPERTY_WORK:
5225                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5226                         break;
5227         }
5228         
5229         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5230         
5231         if (!PropertyTokens.IsEmpty()){
5232         
5233                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5234         
5235         }
5239 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5241         size_t intPropertyLen = PropertySeg1.Len();
5242         std::map<int, int> SplitPoints;
5243         std::map<int, int> SplitLength;
5244         std::map<int, int>::iterator SLiter;                    
5245         wxString PropertyData;
5246         wxString PropertyName;
5247         wxString PropertyValue;
5248         wxString PropertyTokens;
5249         bool FirstToken = TRUE;
5250         int intSplitsFound = 0;
5251         int intSplitSize = 0;
5252         int intPrevValue = 5;
5253         int intPref = 0;                        
5254         int intType = 0;
5255         long ListCtrlIndex;
5256         
5257         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5258         
5259         intPrevValue = 4;
5260         
5261         PropertyType PropType = PROPERTY_NONE;
5262         
5263         // Look for type before continuing.
5265         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5267         intPrevValue = 4;
5269         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5270         intiter != SplitPoints.end(); ++intiter){
5271         
5272                 SLiter = SplitLength.find(intiter->first);
5273         
5274                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5275                 
5276                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5277                 PropertyName = PropertyElement.GetNextToken();                          
5278                 PropertyValue = PropertyElement.GetNextToken();
5279                 
5280                 intPrevValue = intiter->second;
5281                 
5282                 // Process properties.
5283                 
5284                 size_t intPropertyValueLen = PropertyValue.Len();
5285                 
5286                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5287                         
5288                         PropertyValue.Trim();
5289                         PropertyValue.RemoveLast();
5290                         
5291                 }                               
5292                 
5293                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5294                         
5295                         PropertyValue.Remove(0, 1);
5296                         
5297                 }                               
5298                 
5299                 if (PropertyName == wxT("ALTID")){
5301                         KeyListAltID.erase(*KeyCount);
5302                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5303                 
5304                 } else if (PropertyName == wxT("PID")){
5306                         KeyListPID.erase(*KeyCount);
5307                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5308                 
5309                 } else if (PropertyName == wxT("PREF")){
5311                         ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5312                 
5313                 } else {
5314                 
5315                         // Something else we don't know about so append
5316                         // to the tokens variable.
5317                         
5318                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5319                         
5320                                 if (FirstToken == TRUE){
5321                                 
5322                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5323                                         FirstToken = FALSE;
5324                                 
5325                                 } else {
5326                                 
5327                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5328                                 
5329                                 }
5330                         
5331                         }
5332                 
5333                 }
5334         
5335         }                               
5336         
5337         intPropertyLen = PropertySeg2.Len();
5338         SplitPoints.clear();
5339         SplitLength.clear();
5340         intSplitsFound = 0;
5341         intSplitSize = 0;
5342         intPrevValue = 0;                       
5343         
5344         for (int i = 0; i <= intPropertyLen; i++){
5346                 intSplitSize++;
5347         
5348                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5349         
5350                         intSplitsFound++;
5351                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5352                         
5353                         if (intSplitsFound == 6){ 
5354                         
5355                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5356                                 break; 
5357                                 
5358                         } else {
5359                         
5360                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5361                         
5362                         }
5363                         
5364                         intSplitSize = 0;                                       
5365         
5366                 }
5368         }
5369         
5370         wxString wxSKeyURI;
5371         wxString wxSKeyMIME;
5372         wxString wxSKeyEncoding;
5373         wxString wxSKeyData;
5374         std::string base64enc;
5375         
5376         if (intSplitsFound == 0){
5377         
5378         } else {
5379         
5380                 std::map<int, int>::iterator striter;
5381         
5382                 striter = SplitLength.find(1);
5383         
5384                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5385         
5386                 while (wSTDataType.HasMoreTokens() == TRUE){
5387                 
5388                         wxSKeyURI = wSTDataType.GetNextToken();
5389                         wxSKeyMIME = wSTDataType.GetNextToken();
5390                         break;
5391                 
5392                 }                       
5393         
5394                 if (wxSKeyURI == wxT("data")){
5395                 
5396                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5397         
5398                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5399                 
5400                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5401                                 wxSKeyData = wSTDataInfo.GetNextToken();
5402                                 break;
5403                 
5404                         }
5405                 
5406                 }
5407         
5408         }
5409         
5410         // Add the data to the General/Home/Work address variables.
5411         
5412         if (wxSKeyURI == wxT("data")){
5413                 
5414                 KeyListDataEncType.erase(*KeyCount);
5415                 KeyListKeyType.erase(*KeyCount);
5416                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5417                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5418                 
5419                 KeyList.erase(*KeyCount);
5420                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5421         
5422         } else {
5423                 
5424                 KeyList.erase(*KeyCount);
5425                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5426         
5427         }
5428         
5429         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5430                 
5431         switch (PropType){
5432                 case PROPERTY_NONE:
5433                         break;
5434                 case PROPERTY_HOME: 
5435                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5436                         break;
5437                 case PROPERTY_WORK: 
5438                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5439                         break;
5440         }
5442         if (!PropertyTokens.IsEmpty()){
5444                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5446         }
5450 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5452         // Split the Vendor three ways.
5453         
5454         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5455         
5456         wxString wxSVNDID;
5457         wxString wxSVNDPropName;
5458         long ListCtrlIndex;                     
5460         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5461         
5462                 wSTVendorDetails.GetNextToken();
5463                 wxSVNDID = wSTVendorDetails.GetNextToken();
5464                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5465                 break;
5466         
5467         }
5468         
5469         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5470         
5471                 // Add the data to the vendor variables.
5472         
5473                 VendorList.erase(*VendorCount);
5474                 VendorListPEN.erase(*VendorCount);
5475                 VendorListElement.erase(*VendorCount);
5476         
5477                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5478                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5479                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5480         
5481         }
5485 void ProcessStringValue(wxString *PropertyName,
5486         wxString PropertyNameMatch,
5487         std::map<int,wxString> *MapPtr,
5488         wxString *PropertyValue,
5489         int *ItemCount,
5490         bool *PropertyMatched){
5491         
5492         if (*PropertyName == PropertyNameMatch){
5493                 MapPtr->erase(*ItemCount);
5494                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5495                 *PropertyMatched = TRUE;
5496         }
5497         
5500 void ProcessIntegerValue(wxString *PropertyName,
5501         wxString PropertyNameMatch,
5502         std::map<int,int> *PrefPtr, 
5503         wxString *PropertyValue, 
5504         int *ItemCount,
5505         bool *PropertyMatched){
5507         if (*PropertyName == PropertyNameMatch){
5508                 *PropertyMatched = TRUE;
5509         } else {
5510                 return;
5511         }
5513         int PriorityNumber = 0; 
5514         bool ValidNumber = TRUE;
5515                         
5516         try{
5517                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5518         }
5519                         
5520         catch(std::invalid_argument &e){
5521                 ValidNumber = FALSE;
5522         }
5524         if (ValidNumber == TRUE){
5526                 PrefPtr->erase(*ItemCount);
5527                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5529         }
5533 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
5534         wxString *PropertyValue, 
5535         int *ItemCount){
5537         int PriorityNumber = 0; 
5538         bool ValidNumber = TRUE;
5539                         
5540         try{
5541                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5542         }
5543                         
5544         catch(std::invalid_argument &e){
5545                 ValidNumber = FALSE;
5546         }
5548         if (ValidNumber == TRUE){
5550                 PrefPtr->erase(*ItemCount);
5551                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5553         }
5557 void SplitValues(wxString *PropertyLine, 
5558         std::map<int,int> *SplitPoints, 
5559         std::map<int,int> *SplitLength, 
5560         int intSize){
5561         
5562         size_t intPropertyLen = PropertyLine->Len();
5563         int intSplitsFound = 0;
5564         int intSplitSize = 0;
5565         int intSplitSeek = 0;
5566         
5567         for (int i = intSize; i <= intPropertyLen; i++){
5569                 intSplitSize++;
5570         
5571                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5572                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5573            
5574                     if (intSplitsFound == 0){
5575             
5576                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5577           
5578                     } else {
5579            
5580                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5581             
5582                     }
5583             
5584                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5585             
5586                     intSplitsFound++;
5587                     intSplitSeek = i;
5588                     intSplitSize = 0;
5589             
5590                 }
5592         }
5594         if (intSplitsFound == 0){
5596                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5597                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5599         } else {
5601                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5602                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5604         }
5608 void CheckType(wxString *PropertySeg1, 
5609         std::map<int,int> *SplitPoints, 
5610         std::map<int,int> *SplitLength, 
5611         int *intPrevValue, 
5612         PropertyType *PropType){
5613         
5614         wxString PropertyData;
5615         wxString PropertyName;
5616         wxString PropertyValue;
5617         std::map<int,int>::iterator SLiter;
5618         
5619         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5620         intiter != SplitPoints->end(); ++intiter){
5621         
5622                 SLiter = SplitLength->find(intiter->first);
5623         
5624                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5625                 
5626                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5627                 PropertyName = PropertyElement.GetNextToken();                          
5628                 PropertyValue = PropertyElement.GetNextToken();
5629                 
5630                 *intPrevValue = intiter->second;
5631                 
5632                 if (PropertyName == wxT("TYPE")){
5633                                 
5634                         if (PropertyValue == wxT("work")){
5635                         
5636                                 *PropType = PROPERTY_WORK;
5637                                                         
5638                         } else if (PropertyValue == wxT("home")){
5640                                 *PropType = PROPERTY_HOME;
5641                                                         
5642                         } else {
5643                         
5644                                 *PropType = PROPERTY_NONE;
5645                         
5646                         }
5647                 
5648                         return;
5649                 
5650                 }
5651         
5652         }
5653         
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