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