Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced string processing in NICKNAME with ProcessStringValue.
[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         
1629         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1630         intiter != SplitPoints.end(); ++intiter){
1631         
1632                 SLiter = SplitLength.find(intiter->first);
1633         
1634                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1635                 
1636                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1637                 PropertyName = PropertyElement.GetNextToken();                          
1638                 PropertyValue = PropertyElement.GetNextToken();
1639                 
1640                 intPrevValue = intiter->second;
1641                 
1642                 CaptureString(&PropertyValue, FALSE);
1644                 if (PropertyName == wxT("ALTID")){
1646                         TZListAltID->erase(*TimeZoneCount);
1647                         TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1648                 
1649                 } else if (PropertyName == wxT("PID")){
1651                         TZListPID->erase(*TimeZoneCount);
1652                         TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));       
1654                 } else if (PropertyName == wxT("PREF")){
1656                         ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
1657                 
1658                 } else if (PropertyName == wxT("MEDIATYPE")){
1660                         TZListMediatype->erase(*TimeZoneCount);
1661                         TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue)); 
1663                 } else {
1664                 
1665                         // Something else we don't know about so append
1666                         // to the tokens variable.
1667                 
1668                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1669                 
1670                                 if (FirstToken == TRUE){
1671                         
1672                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1673                                         FirstToken = FALSE;
1674                         
1675                                 } else {
1676                         
1677                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1678                         
1679                                 }
1680                 
1681                         }
1682                 
1683                 }
1684                 
1685         }
1686         
1687         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1688         
1689         // Add the name token data.
1690         
1691         if (!PropertyTokens.IsEmpty()){
1692         
1693                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1694         
1695         }
1700 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1702         size_t intPropertyLen = PropertySeg1.Len();
1703         std::map<int, int> SplitPoints;
1704         std::map<int, int> SplitLength;
1705         std::map<int, int>::iterator SLiter;                    
1706         wxString PropertyData;
1707         wxString PropertyName;
1708         wxString PropertyValue;
1709         wxString PropertyTokens;
1710         wxString AddressLabel;
1711         wxString AddressLang;
1712         wxString AddressAltID;
1713         wxString AddressPID;
1714         wxString AddressTokens;
1715         wxString AddressGeo;
1716         wxString AddressTimezone;
1717         wxString AddressType;
1718         wxString AddressMediatype;
1719         wxString AddressPOBox;
1720         wxString AddressExtended;
1721         wxString AddressStreet;
1722         wxString AddressLocality;
1723         wxString AddressCity;
1724         wxString AddressRegion;
1725         wxString AddressPostalCode;
1726         wxString AddressCountry;
1727         bool FirstToken = TRUE;                 
1728         int intSplitsFound = 0;
1729         int intSplitSize = 0;
1730         int intPrevValue = 5;
1731         int intPref = 0;                        
1732         int intType = 0;
1733         long ListCtrlIndex;
1734         
1735         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1736         
1737         intPrevValue = 4;
1738         
1739         PropertyType PropType = PROPERTY_NONE;
1740                 
1741         // Look for type before continuing.
1742         
1743         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1744         
1745         intPrevValue = 4;
1746         
1747         std::map<int, wxString> *AddressList = NULL;
1748         std::map<int, wxString> *AddressListTown = NULL;
1749         std::map<int, wxString> *AddressListCounty = NULL;
1750         std::map<int, wxString> *AddressListPostCode = NULL;
1751         std::map<int, wxString> *AddressListCountry = NULL;
1752         std::map<int, wxString> *AddressListLabel = NULL;
1753         std::map<int, wxString> *AddressListLang = NULL;                
1754         std::map<int, wxString> *AddressListAltID = NULL;
1755         std::map<int, wxString> *AddressListPID = NULL;
1756         std::map<int, wxString> *AddressListTokens = NULL;
1757         std::map<int, wxString> *AddressListGeo = NULL;
1758         std::map<int, wxString> *AddressListTimezone = NULL;            
1759         std::map<int, wxString> *AddressListType = NULL;
1760         std::map<int, wxString> *AddressListMediatype = NULL;
1761         std::map<int, int> *AddressListPref = NULL;
1763         switch(PropType){
1764                 case PROPERTY_NONE:
1765                         AddressList = &GeneralAddressList;
1766                         AddressListTown = &GeneralAddressListTown;
1767                         AddressListCounty = &GeneralAddressListCounty;
1768                         AddressListPostCode = &GeneralAddressListPostCode;
1769                         AddressListCountry = &GeneralAddressListCountry;
1770                         AddressListLabel = &GeneralAddressListLabel;
1771                         AddressListLang = &GeneralAddressListLang;              
1772                         AddressListAltID = &GeneralAddressListAltID;
1773                         AddressListPID = &GeneralAddressListPID;
1774                         AddressListTokens = &GeneralAddressListTokens;
1775                         AddressListGeo = &GeneralAddressListGeo;
1776                         AddressListTimezone = &GeneralAddressListTimezone;
1777                         AddressListType = &GeneralAddressListType;
1778                         AddressListMediatype = &GeneralAddressListMediatype;
1779                         AddressListPref = &GeneralAddressListPref;              
1780                         break;
1781                 case PROPERTY_HOME:
1782                         AddressList = &HomeAddressList;
1783                         AddressListTown = &HomeAddressListTown;
1784                         AddressListCounty = &HomeAddressListCounty;
1785                         AddressListPostCode = &HomeAddressListPostCode;
1786                         AddressListCountry = &HomeAddressListCountry;
1787                         AddressListLabel = &HomeAddressListLabel;
1788                         AddressListLang = &HomeAddressListLang;         
1789                         AddressListAltID = &HomeAddressListAltID;
1790                         AddressListPID = &HomeAddressListPID;
1791                         AddressListTokens = &HomeAddressListTokens;
1792                         AddressListGeo = &HomeAddressListGeo;
1793                         AddressListTimezone = &HomeAddressListTimezone;
1794                         AddressListType = &HomeAddressListType;
1795                         AddressListMediatype = &HomeAddressListMediatype;
1796                         AddressListPref = &HomeAddressListPref;
1797                         break;
1798                 case PROPERTY_WORK:
1799                         AddressList = &BusinessAddressList;
1800                         AddressListTown = &BusinessAddressListTown;
1801                         AddressListCounty = &BusinessAddressListCounty;
1802                         AddressListPostCode = &BusinessAddressListPostCode;
1803                         AddressListCountry = &BusinessAddressListCountry;
1804                         AddressListLabel = &BusinessAddressListLabel;
1805                         AddressListLang = &BusinessAddressListLang;             
1806                         AddressListAltID = &BusinessAddressListAltID;
1807                         AddressListPID = &BusinessAddressListPID;
1808                         AddressListTokens = &BusinessAddressListTokens;
1809                         AddressListGeo = &BusinessAddressListGeo;
1810                         AddressListTimezone = &BusinessAddressListTimezone;
1811                         AddressListType = &BusinessAddressListType;
1812                         AddressListMediatype = &BusinessAddressListMediatype;
1813                         AddressListPref = &BusinessAddressListPref;
1814                         break;
1815         }
1816         
1817         intPrevValue = 4;
1818         
1819         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1820         intiter != SplitPoints.end(); ++intiter){
1821         
1822                 SLiter = SplitLength.find(intiter->first);
1823         
1824                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1825                 
1826                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1827                 PropertyName = PropertyElement.GetNextToken();                          
1828                 PropertyValue = PropertyElement.GetNextToken();
1829                 
1830                 intPrevValue = intiter->second;
1831                 
1832                 CaptureString(&PropertyValue, FALSE);
1833                 
1834                 // Process properties.
1835                 
1836                 if (PropertyName == wxT("LABEL")){
1837                 
1838                         AddressListLabel->erase(*AddressCount);
1839                         AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1840                                 
1841                 } else if (PropertyName == wxT("LANGUAGE")){
1842                 
1843                         AddressListLang->erase(*AddressCount);
1844                         AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));                  
1845                 
1846                 } else if (PropertyName == wxT("ALTID")){
1848                         AddressListAltID->erase(*AddressCount);
1849                         AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1850                 
1851                 } else if (PropertyName == wxT("PID")){
1853                         AddressListPID->erase(*AddressCount);
1854                         AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1855                 
1856                 } else if (PropertyName == wxT("GEO")){
1857                 
1858                         AddressListGeo->erase(*AddressCount);
1859                         AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1860                 
1861                 } else if (PropertyName == wxT("TZ")){
1863                         AddressListTimezone->erase(*AddressCount);
1864                         AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1865                 
1866                 } else if (PropertyName == wxT("MEDIATYPE")){
1868                         AddressListMediatype->erase(*AddressCount);
1869                         AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1870                 
1871                 } else if (PropertyName == wxT("PREF")){
1873                         ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
1874                 
1875                 } else {
1876                 
1877                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1878                         
1879                                 if (FirstToken == TRUE){
1880                                 
1881                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1882                                         FirstToken = FALSE;
1883                                 
1884                                 } else {
1885                                 
1886                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1887                                 
1888                                 }
1889                         
1890                         }
1891                 
1892                 }
1893         
1894         }                       
1895         
1896         // Split the address. 
1898         //std::map<int, int>::iterator SLiter;
1899         intPropertyLen = PropertySeg2.Len();
1900         SplitPoints.clear();
1901         SplitLength.clear();
1902         intSplitsFound = 0;
1903         intSplitSize = 0;
1904         intPrevValue = 0;
1905         
1906         for (int i = 0; i <= intPropertyLen; i++){
1908                 intSplitSize++;
1909         
1910                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1911         
1912                         intSplitsFound++;
1913                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1914                         
1915                         if (intSplitsFound == 6){ 
1916                         
1917                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1918                                 break; 
1919                                 
1920                         } else {
1921                         
1922                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1923                         
1924                         }
1925                         
1926                         intSplitSize = 0;                                       
1927         
1928                 }
1930         }
1931         
1932         // Split the data into several parts.                   
1933         
1934         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1935         intiter != SplitPoints.end(); ++intiter){
1936                         
1937                 if (intiter->first == 1){
1938                 
1939                         // Deal with PO Box.
1940                         
1941                         SLiter = SplitLength.find(1);
1942                                                                 
1943                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1944                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1945                         intPrevValue = intiter->second;
1946                 
1947                 } else if (intiter->first == 2){
1948                 
1949                         // Deal with extended address.
1950                         
1951                         SLiter = SplitLength.find(2);
1952                         
1953                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1954                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1955                         intPrevValue = intiter->second;
1956                 
1957                 } else if (intiter->first == 3){
1958                 
1959                         // Deal with street address.
1960                         
1961                         SLiter = SplitLength.find(3);
1962                                                                 
1963                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1964                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1965                         intPrevValue = intiter->second;
1966                 
1967                 } else if (intiter->first == 4){
1968                 
1969                         // Deal with locality
1971                         SLiter = SplitLength.find(4);
1972                         
1973                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1974                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1975                         intPrevValue = intiter->second;
1976                         
1977                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1978                 
1979                 } else if (intiter->first == 5){
1980                 
1981                         // Deal with region.
1983                         SLiter = SplitLength.find(5);
1984                         
1985                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1986                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1987                         intPrevValue = intiter->second;
1988                         
1989                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1990                 
1991                 } else if (intiter->first == 6){
1992                 
1993                         // Deal with post code.
1995                         SLiter = SplitLength.find(6);
1996                         
1997                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1998                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1999                         intPrevValue = intiter->second;
2000                         
2001                         // Deal with country.
2002                                                 
2003                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2004                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2005                         
2006                         break;
2007                 
2008                 }
2009         
2010         }       
2011         
2012         // Add the data to the General/Home/Work address variables.
2013         
2014         CaptureString(&AddressStreet, FALSE); 
2015         CaptureString(&AddressLocality, FALSE);
2016         CaptureString(&AddressRegion, FALSE);
2017         CaptureString(&AddressPostalCode, FALSE);
2018         CaptureString(&AddressCountry, FALSE);
2019                 
2020         if (!PropertyTokens.IsEmpty()){
2021         
2022                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2023         
2024         }
2026         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
2027         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2028         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2029         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2030         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2032         switch(PropType){
2033                 case PROPERTY_NONE:
2034                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2035                         break;
2036                 case PROPERTY_HOME:
2037                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2038                         break;
2039                 case PROPERTY_WORK:
2040                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
2041                         break;
2042         }
2043         
2044         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2048 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2050         std::map<int, int> SplitPoints;
2051         std::map<int, int> SplitLength;
2053         int intPrevValue = 7;
2054         int intPref = 0;                        
2055         
2056         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2057         
2058         intPrevValue = 6;
2059         
2060         PropertyType PropType = PROPERTY_NONE;
2061                 
2062         // Look for type before continuing.
2063         
2064         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2065         
2066         std::map<int, wxString> *EmailList = NULL;
2067         std::map<int, wxString> *EmailListType = NULL;
2068         std::map<int, wxString> *EmailListAltID = NULL;
2069         std::map<int, wxString> *EmailListPID = NULL;
2070         std::map<int, wxString> *EmailListTokens = NULL;                
2071         std::map<int, int> *EmailListPref = NULL;
2073         switch(PropType){
2074                 case PROPERTY_NONE:
2075                         EmailList = &GeneralEmailList;
2076                         EmailListType = &GeneralEmailListType;
2077                         EmailListAltID = &GeneralEmailListAltID;
2078                         EmailListPID = &GeneralEmailListPID;
2079                         EmailListTokens = &GeneralEmailListTokens;              
2080                         EmailListPref = &GeneralEmailListPref;  
2081                         break;
2082                 case PROPERTY_HOME:
2083                         EmailList = &HomeEmailList;
2084                         EmailListType = &HomeEmailListType;
2085                         EmailListAltID = &HomeEmailListAltID;
2086                         EmailListPID = &HomeEmailListPID;
2087                         EmailListTokens = &HomeEmailListTokens;         
2088                         EmailListPref = &HomeEmailListPref;     
2089                         break;
2090                 case PROPERTY_WORK:
2091                         EmailList = &BusinessEmailList;
2092                         EmailListType = &BusinessEmailListType;
2093                         EmailListAltID = &BusinessEmailListAltID;
2094                         EmailListPID = &BusinessEmailListPID;
2095                         EmailListTokens = &BusinessEmailListTokens;             
2096                         EmailListPref = &BusinessEmailListPref; 
2097                         break;
2098         }
2099         
2100         intPrevValue = 6;
2101         
2102         std::map<int,int>::iterator SLiter;
2103         wxString PropertyData;
2104         wxString PropertyName;
2105         wxString PropertyValue;
2106         wxString PropertyTokens;
2107         bool FirstToken = TRUE;
2108         
2109         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2110         intiter != SplitPoints.end(); ++intiter){
2111         
2112                 SLiter = SplitLength.find(intiter->first);
2113         
2114                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2115                 
2116                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2117                 PropertyName = PropertyElement.GetNextToken();                          
2118                 PropertyValue = PropertyElement.GetNextToken();
2119                 
2120                 intPrevValue = intiter->second;
2121                 
2122                 CaptureString(&PropertyValue, FALSE);
2123                 
2124                 // Process properties.
2125                 
2126                 if (PropertyName == wxT("ALTID")){
2128                         EmailListAltID->erase(*EmailCount);
2129                         EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2130                 
2131                 } else if (PropertyName == wxT("PID")){
2133                         EmailListPID->erase(*EmailCount);
2134                         EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2135                 
2136                 } else if (PropertyName == wxT("PREF")){
2137                         
2138                         ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
2139                 
2140                 } else {
2141                 
2142                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2143                         
2144                                 if (FirstToken == TRUE){
2145                                 
2146                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2147                                         FirstToken = FALSE;
2148                                 
2149                                 } else {
2150                                 
2151                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2152                                 
2153                                 }
2154                         
2155                         }
2156                 
2157                 }
2158         
2159         }
2160         
2161         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2162         
2163         // Add the name token data.
2164         
2165         if (!PropertyTokens.IsEmpty()){
2166         
2167                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2168         
2169         }       
2174 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2176         std::map<int, int> SplitPoints;
2177         std::map<int, int> SplitLength;
2179         int intPrevValue = 6;
2180         int intPref = 0;                        
2181         
2182         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2183         
2184         intPrevValue = 5;
2185         
2186         PropertyType PropType = PROPERTY_NONE;
2187                 
2188         // Look for type before continuing.
2189         
2190         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2191         
2192         std::map<int, wxString> *IMList = NULL;
2193         std::map<int, wxString> *IMListType = NULL;
2194         std::map<int, wxString> *IMListAltID = NULL;
2195         std::map<int, wxString> *IMListPID = NULL;
2196         std::map<int, wxString> *IMListTokens = NULL;
2197         std::map<int, wxString> *IMListMediatype = NULL;        
2198         std::map<int, int> *IMListPref = NULL;
2200         switch(PropType){
2201                 case PROPERTY_NONE:
2202                         IMList = &GeneralIMList;
2203                         IMListType = &GeneralIMListType;
2204                         IMListAltID = &GeneralIMListAltID;
2205                         IMListPID = &GeneralIMListPID;
2206                         IMListTokens = &GeneralIMListTokens;
2207                         IMListMediatype = &GeneralIMListMediatype;
2208                         IMListPref = &GeneralIMListPref;        
2209                         break;
2210                 case PROPERTY_HOME:
2211                         IMList = &HomeIMList;
2212                         IMListType = &HomeIMListType;
2213                         IMListAltID = &HomeIMListAltID;
2214                         IMListPID = &HomeIMListPID;
2215                         IMListTokens = &HomeIMListTokens;
2216                         IMListMediatype = &HomeIMListMediatype;         
2217                         IMListPref = &HomeIMListPref;   
2218                         break;
2219                 case PROPERTY_WORK:
2220                         IMList = &BusinessIMList;
2221                         IMListType = &BusinessIMListType;
2222                         IMListAltID = &BusinessIMListAltID;
2223                         IMListPID = &BusinessIMListPID;
2224                         IMListTokens = &BusinessIMListTokens;   
2225                         IMListMediatype = &BusinessIMListMediatype;     
2226                         IMListPref = &BusinessIMListPref;       
2227                         break;
2228         }
2229         
2230         intPrevValue = 5;
2231         
2232         std::map<int,int>::iterator SLiter;
2233         wxString PropertyData;
2234         wxString PropertyName;
2235         wxString PropertyValue;
2236         wxString PropertyTokens;
2237         bool FirstToken = TRUE;
2238         
2239         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2240         intiter != SplitPoints.end(); ++intiter){
2241         
2242                 SLiter = SplitLength.find(intiter->first);
2243         
2244                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2245                 
2246                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2247                 PropertyName = PropertyElement.GetNextToken();                          
2248                 PropertyValue = PropertyElement.GetNextToken();
2249                 
2250                 intPrevValue = intiter->second;
2251                 
2252                 CaptureString(&PropertyValue, FALSE);
2253                 
2254                 // Process properties.
2255                 
2256                 if (PropertyName == wxT("ALTID")){
2258                         IMListAltID->erase(*IMCount);
2259                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2260                 
2261                 } else if (PropertyName == wxT("PID")){
2263                         IMListPID->erase(*IMCount);
2264                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2265                 
2266                 } else if (PropertyName == wxT("MEDIATYPE")){
2268                         IMListMediatype->erase(*IMCount);
2269                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2270                 
2271                 } else if (PropertyName == wxT("PREF")){
2272                         
2273                         ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2274                 
2275                 } else {
2276                 
2277                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2278                         
2279                                 if (FirstToken == TRUE){
2280                                 
2281                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2282                                         FirstToken = FALSE;
2283                                 
2284                                 } else {
2285                                 
2286                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2287                                 
2288                                 }
2289                         
2290                         }
2291                 
2292                 }
2293         
2294         }
2295                 
2296         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2297         
2298         // Add the name token data.
2299         
2300         if (!PropertyTokens.IsEmpty()){
2301         
2302                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2303         
2304         }
2308 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2310         std::map<int, int> SplitPoints;
2311         std::map<int, int> SplitLength;
2312         std::map<int, int>::iterator SLiter;
2313         
2314         int intPref = 0;
2315         
2316         PropertyType PropType = PROPERTY_NONE;
2317                 
2318         // Look for type before continuing.
2319         
2320         wxString TelTypeUI;
2321         wxString TelTypeDetail;
2322         wxString PropertyData;
2323         wxString PropertyName;
2324         wxString PropertyValue;
2325         wxString PropertyTokens;
2326         
2327         std::map<int,int> TypeSplitPoints;
2328         std::map<int,int> TypeSplitLength;
2329         std::map<int,int>::iterator TSLiter;
2330         
2331         int intSplitSize = 0;
2332         int intSplitsFound = 0;
2333         int intSplitPoint = 0;
2334         int intType = 0;
2335         int intPrevValue = 5;
2336                 
2337         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2338         
2339         intPrevValue = 4;
2340         
2341         // Look for type before continuing.
2342         
2343         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2344         intiter != SplitPoints.end(); ++intiter){
2345         
2346                 SLiter = SplitLength.find(intiter->first);
2347         
2348                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2349                 
2350                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2351                 PropertyName = PropertyElement.GetNextToken();                          
2352                 PropertyValue = PropertyElement.GetNextToken();
2353                 
2354                 intPrevValue = intiter->second;
2356                 if (PropertyName == wxT("TYPE")){
2357                 
2358                         // Process each value in type and translate each
2359                         // part.
2360                 
2361                         // Strip out the quotes if they are there.
2362                 
2363                         size_t intPropertyValueLen = PropertyValue.Len();
2364                 
2365                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2366                         
2367                                 PropertyValue.Trim();
2368                                 PropertyValue.RemoveLast();
2369                         
2370                         }                               
2371                 
2372                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2373                         
2374                                 PropertyValue.Remove(0, 1);
2375                         
2376                         }
2377                         
2378                         TelTypeDetail = PropertyValue;
2379                         
2380                         intSplitSize = 0;
2381                         intSplitsFound = 0;
2382                         intSplitPoint = 0;
2383                         
2384                         for (int i = 0; i <= intPropertyValueLen; i++){
2385         
2386                                 intSplitSize++;
2387         
2388                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2389         
2390                                         if (intSplitsFound == 0){
2392                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2393                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2394                         
2395                                         } else {
2396                         
2397                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2398                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2399                         
2400                                         }                       
2402                                         intSplitsFound++;
2403                                         i++;
2404                                         intSplitPoint = i;
2405                                         intSplitSize = 0;
2406         
2407                                 }
2408         
2409                         }
2410                         
2411                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2412                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2413                 
2414                         int intTypeSeek = 0;
2415                 
2416                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2417                         typeiter != TypeSplitPoints.end(); ++typeiter){
2418                         
2419                                 wxString TypePropertyName;
2420                                 
2421                                 TSLiter = TypeSplitLength.find(typeiter->first);
2422                                 
2423                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2424                                 
2425                                 if (intTypeSeek == 0){
2426                                 
2427                                 
2428                                 } else {
2429                                                                                 
2430                                         TelTypeUI.Append(wxT(","));                                                     
2431                                 
2432                                 }
2433                         
2434                                 if (TypePropertyName == wxT("home")){
2435                                 
2436                                         PropType = PROPERTY_HOME;
2437                                 
2438                                 } else if (TypePropertyName == wxT("work")){
2439                                 
2440                                         PropType = PROPERTY_WORK;
2441                                                                         
2442                                 }
2443                                 
2444                                 
2445                                 if (TypePropertyName == wxT("text")){
2446                                 
2447                                         TelTypeUI.Append(_("text"));
2448                                         intTypeSeek++;
2449                                 
2450                                 } else if (TypePropertyName == wxT("voice")){
2451                                 
2452                                         TelTypeUI.Append(_("voice"));
2453                                         intTypeSeek++;
2454                                 
2455                                 } else if (TypePropertyName == wxT("fax")){
2456                                 
2457                                         TelTypeUI.Append(_("fax"));
2458                                         intTypeSeek++;
2459                                 
2460                                 } else if (TypePropertyName == wxT("cell")){
2461                                 
2462                                         TelTypeUI.Append(_("mobile"));
2463                                         intTypeSeek++;
2464                                 
2465                                 } else if (TypePropertyName == wxT("video")){
2466                                 
2467                                         TelTypeUI.Append(_("video"));
2468                                         intTypeSeek++;
2469                                 
2470                                 } else if (TypePropertyName == wxT("pager")){
2471                                 
2472                                         TelTypeUI.Append(_("pager"));
2473                                         intTypeSeek++;
2474                                 
2475                                 } else if (TypePropertyName == wxT("textphone")){
2476                                 
2477                                         TelTypeUI.Append(_("textphone"));
2478                                         intTypeSeek++;
2479                                 
2480                                 }
2481                         
2482                         }
2483                 
2484                 }
2485                 
2486         }
2487         
2488         std::map<int, wxString> *TelephoneList = NULL;
2489         std::map<int, wxString> *TelephoneListType = NULL;
2490         std::map<int, wxString> *TelephoneListAltID = NULL;
2491         std::map<int, wxString> *TelephoneListPID = NULL;
2492         std::map<int, wxString> *TelephoneListTokens = NULL;
2493         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2494         std::map<int, int> *TelephoneListPref = NULL;
2496         switch(PropType){
2497                 case PROPERTY_NONE:
2498                         TelephoneList = &GeneralTelephoneList;
2499                         TelephoneListType = &GeneralTelephoneListType;
2500                         TelephoneListAltID = &GeneralTelephoneListAltID;
2501                         TelephoneListPID = &GeneralTelephoneListPID;
2502                         TelephoneListTokens = &GeneralTelephoneListTokens;
2503                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2504                         TelephoneListPref = &GeneralTelephoneListPref;  
2505                         break;
2506                 case PROPERTY_HOME:
2507                         TelephoneList = &HomeTelephoneList;
2508                         TelephoneListType = &HomeTelephoneListType;
2509                         TelephoneListAltID = &HomeTelephoneListAltID;
2510                         TelephoneListPID = &HomeTelephoneListPID;
2511                         TelephoneListTokens = &HomeTelephoneListTokens;
2512                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2513                         TelephoneListPref = &HomeTelephoneListPref;     
2514                         break;
2515                 case PROPERTY_WORK:
2516                         TelephoneList = &BusinessTelephoneList;
2517                         TelephoneListType = &BusinessTelephoneListType;
2518                         TelephoneListAltID = &BusinessTelephoneListAltID;
2519                         TelephoneListPID = &BusinessTelephoneListPID;
2520                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2521                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2522                         TelephoneListPref = &BusinessTelephoneListPref; 
2523                         break;
2524         }
2525                 
2526         // Process the properties.
2527         
2528         bool FirstToken = TRUE;
2529         
2530         intPrevValue = 5;
2531         SplitPoints.clear();
2532         SplitLength.clear();
2534         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2536         intPrevValue = 4;
2537         
2538         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2539         intiter != SplitPoints.end(); ++intiter){
2540         
2541                 SLiter = SplitLength.find(intiter->first);
2542         
2543                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2544                 
2545                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2546                 PropertyName = PropertyElement.GetNextToken();                          
2547                 PropertyValue = PropertyElement.GetNextToken();
2548                 
2549                 intPrevValue = intiter->second;
2550                 
2551                 CaptureString(&PropertyValue, FALSE);
2552                 
2553                 // Process properties.
2554                 
2555                 if (PropertyName == wxT("ALTID")){
2557                         TelephoneListAltID->erase(*TelephoneCount);
2558                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2559                 
2560                 } else if (PropertyName == wxT("PID")){
2562                         TelephoneListPID->erase(*TelephoneCount);
2563                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2564                 
2565                 } else if (PropertyName == wxT("PREF")){
2567                         ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2568                 
2569                 } else {
2570                 
2571                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2572                         
2573                                 if (FirstToken == TRUE){
2574                                 
2575                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2576                                         FirstToken = FALSE;
2577                                 
2578                                 } else {
2579                                 
2580                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2581                                 
2582                                 }
2583                         
2584                         }
2585                 
2586                 }
2587         
2588         }
2589                 
2590         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2591         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2592         
2593         // Add the name token data.
2594         
2595         if (!PropertyTokens.IsEmpty()){
2596         
2597                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2598         
2599         }
2603 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2605         std::map<int, int> SplitPoints;
2606         std::map<int, int> SplitLength;
2608         int intPrevValue = 6;
2609         int intPref = 0;                        
2610         
2611         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2612         
2613         intPrevValue = 5;
2614         
2615         PropertyType PropType = PROPERTY_NONE;
2616                 
2617         // Look for type before continuing.
2618         
2619         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2620         
2621         std::map<int, wxString> *LanguageList = NULL;
2622         std::map<int, wxString> *LanguageListType = NULL;
2623         std::map<int, wxString> *LanguageListAltID = NULL;
2624         std::map<int, wxString> *LanguageListPID = NULL;
2625         std::map<int, wxString> *LanguageListTokens = NULL;
2626         std::map<int, int> *LanguageListPref = NULL;
2628         switch(PropType){
2629                 case PROPERTY_NONE:
2630                         LanguageList = &GeneralLanguageList;
2631                         LanguageListType = &GeneralLanguageListType;
2632                         LanguageListAltID = &GeneralLanguageListAltID;
2633                         LanguageListPID = &GeneralLanguageListPID;
2634                         LanguageListTokens = &GeneralLanguageListTokens;
2635                         LanguageListPref = &GeneralLanguageListPref;    
2636                         break;
2637                 case PROPERTY_HOME:
2638                         LanguageList = &HomeLanguageList;
2639                         LanguageListType = &HomeLanguageListType;
2640                         LanguageListAltID = &HomeLanguageListAltID;
2641                         LanguageListPID = &HomeLanguageListPID;
2642                         LanguageListTokens = &HomeLanguageListTokens;   
2643                         LanguageListPref = &HomeLanguageListPref;       
2644                         break;
2645                 case PROPERTY_WORK:
2646                         LanguageList = &BusinessLanguageList;
2647                         LanguageListType = &BusinessLanguageListType;
2648                         LanguageListAltID = &BusinessLanguageListAltID;
2649                         LanguageListPID = &BusinessLanguageListPID;
2650                         LanguageListTokens = &BusinessLanguageListTokens;       
2651                         LanguageListPref = &BusinessLanguageListPref;
2652                         break;
2653         }
2654         
2655         intPrevValue = 5;
2656         
2657         std::map<int,int>::iterator SLiter;
2658         wxString PropertyData;
2659         wxString PropertyName;
2660         wxString PropertyValue;
2661         wxString PropertyTokens;
2662         bool FirstToken = TRUE;
2663         
2664         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2665         intiter != SplitPoints.end(); ++intiter){
2666         
2667                 SLiter = SplitLength.find(intiter->first);
2668         
2669                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2670                 
2671                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2672                 PropertyName = PropertyElement.GetNextToken();                          
2673                 PropertyValue = PropertyElement.GetNextToken();
2674                 
2675                 intPrevValue = intiter->second;
2676                 
2677                 CaptureString(&PropertyValue, FALSE);
2678                 
2679                 // Process properties.
2680                 
2681                 if (PropertyName == wxT("ALTID")){
2683                         LanguageListAltID->erase(*LanguageCount);
2684                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2685                 
2686                 } else if (PropertyName == wxT("PID")){
2688                         LanguageListPID->erase(*LanguageCount);
2689                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2690                 
2691                 } else if (PropertyName == wxT("PREF")){
2692                         
2693                         ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2694                 
2695                 } else {
2696                 
2697                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2698                         
2699                                 if (FirstToken == TRUE){
2700                                 
2701                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2702                                         FirstToken = FALSE;
2703                                 
2704                                 } else {
2705                                 
2706                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2707                                 
2708                                 }
2709                         
2710                         }
2711                 
2712                 }
2713         
2714         }
2715                 
2716         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2717         
2718         // Add the name token data.
2719         
2720         if (!PropertyTokens.IsEmpty()){
2721         
2722                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2723         
2724         }
2728 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2730         std::map<int, int> SplitPoints;
2731         std::map<int, int> SplitLength;
2733         int intPrevValue = 5;
2734         int intPref = 0;                        
2735         
2736         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2737         
2738         intPrevValue = 4;
2739         
2740         PropertyType PropType = PROPERTY_NONE;
2741                 
2742         // Look for type before continuing.
2743         
2744         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2745         
2746         std::map<int, wxString> *GeopositionList = NULL;
2747         std::map<int, wxString> *GeopositionListType = NULL;
2748         std::map<int, wxString> *GeopositionListAltID = NULL;
2749         std::map<int, wxString> *GeopositionListPID = NULL;
2750         std::map<int, wxString> *GeopositionListTokens = NULL;
2751         std::map<int, wxString> *GeopositionListMediatype = NULL;
2752         std::map<int, int> *GeopositionListPref = NULL;
2754         switch(PropType){
2755                 case PROPERTY_NONE:
2756                         GeopositionList = &GeneralGeographyList;
2757                         GeopositionListType = &GeneralGeographyListType;
2758                         GeopositionListAltID = &GeneralGeographyListAltID;
2759                         GeopositionListPID = &GeneralGeographyListPID;
2760                         GeopositionListTokens = &GeneralGeographyListTokens;
2761                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2762                         GeopositionListPref = &GeneralGeographyListPref;        
2763                         break;
2764                 case PROPERTY_HOME:
2765                         GeopositionList = &HomeGeographyList;
2766                         GeopositionListType = &HomeGeographyListType;
2767                         GeopositionListAltID = &HomeGeographyListAltID;
2768                         GeopositionListPID = &HomeGeographyListPID;
2769                         GeopositionListTokens = &HomeGeographyListTokens;
2770                         GeopositionListMediatype = &HomeGeographyListMediatype;
2771                         GeopositionListPref = &HomeGeographyListPref;   
2772                         break;
2773                 case PROPERTY_WORK:
2774                         GeopositionList = &BusinessGeographyList;
2775                         GeopositionListType = &BusinessGeographyListType;
2776                         GeopositionListAltID = &BusinessGeographyListAltID;
2777                         GeopositionListPID = &BusinessGeographyListPID;
2778                         GeopositionListTokens = &BusinessGeographyListTokens;
2779                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2780                         GeopositionListPref = &BusinessGeographyListPref;
2781                         break;
2782         }
2783         
2784         intPrevValue = 4;
2785         
2786         std::map<int,int>::iterator SLiter;
2787         wxString PropertyData;
2788         wxString PropertyName;
2789         wxString PropertyValue;
2790         wxString PropertyTokens;
2791         bool FirstToken = TRUE;
2792         
2793         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2794         intiter != SplitPoints.end(); ++intiter){
2795         
2796                 SLiter = SplitLength.find(intiter->first);
2797         
2798                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2799                 
2800                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2801                 PropertyName = PropertyElement.GetNextToken();                          
2802                 PropertyValue = PropertyElement.GetNextToken();
2803                 
2804                 intPrevValue = intiter->second;
2805                 
2806                 CaptureString(&PropertyValue, FALSE);
2807                 
2808                 // Process properties.
2809                 
2810                 if (PropertyName == wxT("ALTID")){
2812                         GeopositionListAltID->erase(*GeographicCount);
2813                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2814                 
2815                 } else if (PropertyName == wxT("PID")){
2817                         GeopositionListPID->erase(*GeographicCount);
2818                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2819                 
2820                 } else if (PropertyName == wxT("MEDIATYPE")){
2822                         GeopositionListMediatype->erase(*GeographicCount);
2823                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2824                 
2825                 } else if (PropertyName == wxT("PREF")){
2827                         ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2828                 
2829                 } else {
2830                 
2831                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2832                         
2833                                 if (FirstToken == TRUE){
2834                                 
2835                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2836                                         FirstToken = FALSE;
2837                                 
2838                                 } else {
2839                                 
2840                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2841                                 
2842                                 }
2843                         
2844                         }
2845                 
2846                 }
2847         
2848         }
2849                 
2850         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2851         
2852         // Add the name token data.
2853         
2854         if (!PropertyTokens.IsEmpty()){
2855         
2856                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2857         
2858         }
2862 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2864         size_t intPropertyLen = PropertySeg1.Len();
2865         std::map<int, int> SplitPoints;
2866         std::map<int, int> SplitLength;
2867         std::map<int, int>::iterator SLiter;                    
2868         wxString PropertyData;
2869         wxString PropertyName;
2870         wxString PropertyValue;
2871         wxString PropertyTokens;
2872         wxString RelatedType;
2873         wxString RelatedTypeOriginal;                   
2874         wxString RelatedName;
2875         bool FirstToken = TRUE;                 
2876         int intSplitsFound = 0;
2877         int intSplitSize = 0;
2878         int intPrevValue = 9;
2879         int intPref = 0;
2880         long ListCtrlIndex;
2881         
2882         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2883         
2884         intPrevValue = 8;
2885         
2886         // Look for type before continuing.
2887         
2888         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2889         intiter != SplitPoints.end(); ++intiter){
2890         
2891                 SLiter = SplitLength.find(intiter->first);
2892         
2893                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2894                 
2895                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2896                 PropertyName = PropertyElement.GetNextToken();                          
2897                 PropertyValue = PropertyElement.GetNextToken();
2898                 
2899                 intPrevValue = intiter->second;
2900                 
2901                 // Process these.
2902                 
2903                 RelatedTypeOriginal = PropertyValue;
2904                 
2905                 if (PropertyName == wxT("TYPE")){
2906                 
2907                         if (PropertyValue == wxT("contact")){
2909                                 RelatedType = _("Contact");
2911                         } else if (PropertyValue == wxT("acquaintance")){
2913                                 RelatedType = _("Acquaintance");
2915                         } else if (PropertyValue == wxT("friend")){
2917                                 RelatedType = _("Friend");
2919                         } else if (PropertyValue == wxT("met")){
2921                                 RelatedType = _("Met");
2923                         } else if (PropertyValue == wxT("co-worker")){
2925                                 RelatedType = _("Co-worker");
2927                         } else if (PropertyValue == wxT("colleague")){
2929                                 RelatedType = _("Colleague");
2931                         } else if (PropertyValue == wxT("co-resident")){
2933                                 RelatedType = _("Co-resident");
2935                         } else if (PropertyValue == wxT("neighbor")){
2937                                 RelatedType = _("Neighbour");
2939                         } else if (PropertyValue == wxT("child")){
2941                                 RelatedType = _("Child");
2943                         } else if (PropertyValue == wxT("parent")){
2945                                 RelatedType = _("Parent");
2947                         } else if (PropertyValue == wxT("sibling")){
2949                                 RelatedType = _("Sibling");
2951                         } else if (PropertyValue == wxT("spouse")){
2953                                 RelatedType = _("Spouse");
2955                         } else if (PropertyValue == wxT("kin")){
2957                                 RelatedType = _("Kin");
2959                         } else if (PropertyValue == wxT("muse")){
2961                                 RelatedType = _("Muse");
2963                         } else if (PropertyValue == wxT("crush")){
2965                                 RelatedType = _("Crush");
2967                         } else if (PropertyValue == wxT("date")){
2969                                 RelatedType = _("Date");
2971                         } else if (PropertyValue == wxT("sweetheart")){
2973                                 RelatedType = _("Sweetheart");
2975                         } else if (PropertyValue == wxT("me")){
2977                                 RelatedType = _("Me");
2979                         } else if (PropertyValue == wxT("agent")){
2981                                 RelatedType = _("Agent");
2983                         } else if (PropertyValue == wxT("emergency")){
2985                                 RelatedType = _("Emergency");
2987                         } else {
2989                                 RelatedType = PropertyValue;
2991                         }
2992                 
2993                 }
2994         
2995         }
2996         
2997         intPrevValue = 8;                       
2998         
2999         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3000         intiter != SplitPoints.end(); ++intiter){
3001         
3002                 SLiter = SplitLength.find(intiter->first);
3003         
3004                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3005                 
3006                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3007                 PropertyName = PropertyElement.GetNextToken();                          
3008                 PropertyValue = PropertyElement.GetNextToken();
3009                 
3010                 intPrevValue = intiter->second;
3011                 
3012                 // Process properties.
3013                 
3014                 size_t intPropertyValueLen = PropertyValue.Len();
3015                 
3016                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3017                         
3018                         PropertyValue.Trim();
3019                         PropertyValue.RemoveLast();
3020                         
3021                 }                               
3022                 
3023                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3024                         
3025                         PropertyValue.Remove(0, 1);
3026                         
3027                 }
3028                 
3029                 CaptureString(&PropertyValue, FALSE);
3030                         
3031                 if (PropertyName == wxT("ALTID")){
3033                         GeneralRelatedListAltID.erase(*RelatedCount);
3034                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3035                 
3036                 } else if (PropertyName == wxT("PID")){
3038                         GeneralRelatedListPID.erase(*RelatedCount);
3039                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3040                 
3041                 } else if (PropertyName == wxT("PREF")){
3042                         
3043                         int PriorityNumber = 0;
3044                         bool ValidNumber = TRUE;
3045                         
3046                         try{
3047                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3048                         }
3049                         
3050                         catch(std::invalid_argument &e){
3051                                 ValidNumber = FALSE;
3052                         }
3054                         if (ValidNumber == TRUE){
3056                                 GeneralRelatedListPref.erase(*RelatedCount);
3057                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3059                         }
3060                 
3061                 } else if (PropertyName == wxT("LANGUAGE")){
3063                         ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3064                 
3065                 } else if (PropertyName != wxT("TYPE")) {
3066                 
3067                         // Something else we don't know about so append
3068                         // to the tokens variable.
3069                 
3070                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3071                 
3072                                 if (FirstToken == TRUE){
3073                         
3074                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3075                                         FirstToken = FALSE;
3076                         
3077                                 } else {
3078                         
3079                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3080                         
3081                                 }
3082                 
3083                         }
3084                 
3085                 }
3086         
3087         }                                       
3088         
3089         // Add the data to the General/Home/Work address variables.
3090                                 
3091         GeneralRelatedList.erase(*RelatedCount);
3092         GeneralRelatedListRelType.erase(*RelatedCount);
3093         GeneralRelatedListType.erase(*RelatedCount);
3094         GeneralRelatedListTokens.erase(*RelatedCount);
3095         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3096         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3097         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3098         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3102 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3104         std::map<int, int> SplitPoints;
3105         std::map<int, int> SplitLength;
3106         std::map<int, int>::iterator SLiter;                    
3107         wxString PropertyData;
3108         wxString PropertyName;
3109         wxString PropertyValue;
3110         wxString PropertyTokens;
3111         bool FirstToken = TRUE;
3112         int intPrevValue = 5;
3113         int intPref = 0;                        
3114         int intType = 0;
3115         long ListCtrlIndex;
3116         
3117         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3118         
3119         intPrevValue = 4;
3120         
3121         PropertyType PropType = PROPERTY_NONE;
3122                 
3123         // Look for type before continuing.
3124         
3125         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3126         
3127         // Setup the pointers.
3128         
3129         std::map<int, wxString> *WebsiteList = NULL;
3130         std::map<int, wxString> *WebsiteListAltID = NULL;
3131         std::map<int, wxString> *WebsiteListPID = NULL;
3132         std::map<int, wxString> *WebsiteListType = NULL;
3133         std::map<int, wxString> *WebsiteListTokens = NULL;
3134         std::map<int, wxString> *WebsiteListMediatype = NULL;
3135         std::map<int, int> *WebsiteListPref = NULL;
3136         
3137         // Setup blank lines for later on.
3138         
3139         switch(PropType){
3140                 case PROPERTY_NONE:
3141                         WebsiteList = &GeneralWebsiteList;
3142                         WebsiteListType = &GeneralWebsiteListType;
3143                         WebsiteListAltID = &GeneralWebsiteListAltID;
3144                         WebsiteListPID = &GeneralWebsiteListPID;
3145                         WebsiteListTokens = &GeneralWebsiteListTokens;
3146                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3147                         WebsiteListPref = &GeneralWebsiteListPref;      
3148                         break;
3149                 case PROPERTY_HOME:
3150                         WebsiteList = &HomeWebsiteList;
3151                         WebsiteListType = &HomeWebsiteListType;
3152                         WebsiteListAltID = &HomeWebsiteListAltID;
3153                         WebsiteListPID = &HomeWebsiteListPID;
3154                         WebsiteListTokens = &HomeWebsiteListTokens;
3155                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3156                         WebsiteListPref = &HomeWebsiteListPref; 
3157                         break;
3158                 case PROPERTY_WORK:
3159                         WebsiteList = &BusinessWebsiteList;
3160                         WebsiteListType = &BusinessWebsiteListType;
3161                         WebsiteListAltID = &BusinessWebsiteListAltID;
3162                         WebsiteListPID = &BusinessWebsiteListPID;
3163                         WebsiteListTokens = &BusinessWebsiteListTokens;
3164                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3165                         WebsiteListPref = &BusinessWebsiteListPref;
3166                         break;
3167         }
3168         
3169         intPrevValue = 4;
3170         
3171         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3172         intiter != SplitPoints.end(); ++intiter){
3173         
3174                 SLiter = SplitLength.find(intiter->first);
3175         
3176                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3177                 
3178                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3179                 PropertyName = PropertyElement.GetNextToken();                          
3180                 PropertyValue = PropertyElement.GetNextToken();
3181                 
3182                 intPrevValue = intiter->second;
3183                 
3184                 // Process properties.
3185                 
3186                 size_t intPropertyValueLen = PropertyValue.Len();
3187                 
3188                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3189                         
3190                         PropertyValue.Trim();
3191                         PropertyValue.RemoveLast();
3192                         
3193                 }                               
3194                 
3195                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3196                         
3197                         PropertyValue.Remove(0, 1);
3198                         
3199                 }
3200                 
3201                 CaptureString(&PropertyValue, FALSE);
3202                 
3203                 if (PropertyName == wxT("ALTID")){
3205                         WebsiteListAltID->erase(*URLCount);
3206                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3207                 
3208                 } else if (PropertyName == wxT("PID")){
3210                         WebsiteListPID->erase(*URLCount);
3211                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3212                         
3213                 } else if (PropertyName == wxT("PREF")){
3215                         ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3216                                                         
3217                 } else if (PropertyName == wxT("MEDIATYPE")){
3218                 
3219                         WebsiteListMediatype->erase(*URLCount);
3220                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3221                 
3222                 } else {
3223                 
3224                         // Something else we don't know about so append
3225                         // to the tokens variable.
3226                 
3227                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3228                 
3229                                 if (FirstToken == TRUE){
3230                         
3231                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3232                                         FirstToken = FALSE;
3233                         
3234                                 } else {
3235                         
3236                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3237                         
3238                                 }
3239                 
3240                         }
3241                 
3242                 }
3243         
3244         }
3245         
3246         // Add the data to the General/Home/Work address variables.
3247         
3248         CaptureString(&PropertySeg2, FALSE);
3249                         
3250         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3251         
3252         if (!PropertyTokens.IsEmpty()){
3253         
3254                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3255                         
3256         }
3257         
3260 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3262         std::map<int, int> SplitPoints;
3263         std::map<int, int> SplitLength;
3264         std::map<int, int>::iterator SLiter;                    
3265         wxString PropertyData;
3266         wxString PropertyName;
3267         wxString PropertyValue;
3268         wxString PropertyTokens;
3269         bool FirstToken = TRUE;
3270         int intPrevValue = 7;
3271         int intPref = 0;                        
3272         int intType = 0;
3273         long ListCtrlIndex;
3274         
3275         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3276         
3277         intPrevValue = 6;
3278         
3279         PropertyType PropType = PROPERTY_NONE;
3280                 
3281         // Look for type before continuing.
3282         
3283         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3284         
3285         // Setup the pointers.
3286         
3287         std::map<int, wxString> *TitleList = NULL;
3288         std::map<int, wxString> *TitleListAltID = NULL;
3289         std::map<int, wxString> *TitleListPID = NULL;
3290         std::map<int, wxString> *TitleListType = NULL;
3291         std::map<int, wxString> *TitleListTokens = NULL;
3292         std::map<int, wxString> *TitleListLanguage = NULL;
3293         std::map<int, int> *TitleListPref = NULL;
3294         
3295         // Setup blank lines for later on.
3296         
3297         switch(PropType){
3298                 case PROPERTY_NONE:
3299                         TitleList = &GeneralTitleList;
3300                         TitleListType = &GeneralTitleListType;
3301                         TitleListAltID = &GeneralTitleListAltID;
3302                         TitleListPID = &GeneralTitleListPID;
3303                         TitleListTokens = &GeneralTitleListTokens;
3304                         TitleListLanguage = &GeneralTitleListLanguage;
3305                         TitleListPref = &GeneralTitleListPref;  
3306                         break;
3307                 case PROPERTY_HOME:
3308                         TitleList = &HomeTitleList;
3309                         TitleListType = &HomeTitleListType;
3310                         TitleListAltID = &HomeTitleListAltID;
3311                         TitleListPID = &HomeTitleListPID;
3312                         TitleListTokens = &HomeTitleListTokens;
3313                         TitleListLanguage = &HomeTitleListLanguage;
3314                         TitleListPref = &HomeTitleListPref;     
3315                         break;
3316                 case PROPERTY_WORK:
3317                         TitleList = &BusinessTitleList;
3318                         TitleListType = &BusinessTitleListType;
3319                         TitleListAltID = &BusinessTitleListAltID;
3320                         TitleListPID = &BusinessTitleListPID;
3321                         TitleListTokens = &BusinessTitleListTokens;
3322                         TitleListLanguage = &BusinessTitleListLanguage; 
3323                         TitleListPref = &BusinessTitleListPref;
3324                         break;
3325         }
3327         intPrevValue = 6;
3328                 
3329         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3330         intiter != SplitPoints.end(); ++intiter){
3331         
3332                 SLiter = SplitLength.find(intiter->first);
3333         
3334                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3335                 
3336                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3337                 PropertyName = PropertyElement.GetNextToken();                          
3338                 PropertyValue = PropertyElement.GetNextToken();
3339                 
3340                 intPrevValue = intiter->second;
3341                 
3342                 // Process properties.
3343                 
3344                 size_t intPropertyValueLen = PropertyValue.Len();
3345                 
3346                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3347                         
3348                         PropertyValue.Trim();
3349                         PropertyValue.RemoveLast();
3350                         
3351                 }                               
3352                 
3353                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3354                         
3355                         PropertyValue.Remove(0, 1);
3356                         
3357                 }                               
3358                 
3359                 CaptureString(&PropertyValue, FALSE);
3360                 
3361                 if (PropertyName == wxT("ALTID")){
3362                 
3363                         TitleListAltID->erase(*TitleCount);
3364                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3365                 
3366                 } else if (PropertyName == wxT("PID")){
3368                         TitleListPID->erase(*TitleCount);
3369                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3370                 
3371                 } else if (PropertyName == wxT("PREF")){
3373                         ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3374                         
3375                 } else if (PropertyName == wxT("LANGUAGE")){
3376                 
3377                         TitleListLanguage->erase(*TitleCount);
3378                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3379                 
3380                 } else {
3381                 
3382                         // Something else we don't know about so append
3383                         // to the tokens variable.
3384                 
3385                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3386                 
3387                                 if (FirstToken == TRUE){
3388                         
3389                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3390                                         FirstToken = FALSE;
3391                         
3392                                 } else {
3393                         
3394                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3395                         
3396                                 }
3397                 
3398                         }
3399                 
3400                 }
3401         
3402         }
3403         
3404         // Add the data to the General/Home/Work address variables.
3405         
3406         CaptureString(&PropertySeg2, FALSE);
3408         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3409         
3410         if (!PropertyTokens.IsEmpty()){
3411         
3412                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3413                         
3414         }
3418 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3420         std::map<int, int> SplitPoints;
3421         std::map<int, int> SplitLength;
3422         std::map<int, int>::iterator SLiter;                    
3423         wxString PropertyData;
3424         wxString PropertyName;
3425         wxString PropertyValue;
3426         wxString PropertyTokens;
3427         bool FirstToken = TRUE;
3428         int intPrevValue = 6;
3429         int intPref = 0;                        
3430         int intType = 0;
3431         long ListCtrlIndex;
3432         
3433         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3434         
3435         intPrevValue = 5;
3436         
3437         PropertyType PropType = PROPERTY_NONE;
3438                 
3439         // Look for type before continuing.
3440         
3441         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3442         
3443         // Setup the pointers.
3444         
3445         std::map<int, wxString> *RoleList = NULL;
3446         std::map<int, wxString> *RoleListAltID = NULL;
3447         std::map<int, wxString> *RoleListPID = NULL;
3448         std::map<int, wxString> *RoleListType = NULL;
3449         std::map<int, wxString> *RoleListTokens = NULL;
3450         std::map<int, wxString> *RoleListLanguage = NULL;
3451         std::map<int, int> *RoleListPref = NULL;
3452         
3453         // Setup blank lines for later on.
3454         
3455         switch(PropType){
3456                 case PROPERTY_NONE:
3457                         RoleList = &GeneralRoleList;
3458                         RoleListType = &GeneralRoleListType;
3459                         RoleListAltID = &GeneralRoleListAltID;
3460                         RoleListPID = &GeneralRoleListPID;
3461                         RoleListTokens = &GeneralRoleListTokens;
3462                         RoleListLanguage = &GeneralRoleListLanguage;
3463                         RoleListPref = &GeneralRoleListPref;    
3464                         break;
3465                 case PROPERTY_HOME:
3466                         RoleList = &HomeRoleList;
3467                         RoleListType = &HomeRoleListType;
3468                         RoleListAltID = &HomeRoleListAltID;
3469                         RoleListPID = &HomeRoleListPID;
3470                         RoleListTokens = &HomeRoleListTokens;
3471                         RoleListLanguage = &HomeRoleListLanguage;
3472                         RoleListPref = &HomeRoleListPref;       
3473                         break;
3474                 case PROPERTY_WORK:
3475                         RoleList = &BusinessRoleList;
3476                         RoleListType = &BusinessRoleListType;
3477                         RoleListAltID = &BusinessRoleListAltID;
3478                         RoleListPID = &BusinessRoleListPID;
3479                         RoleListTokens = &BusinessRoleListTokens;
3480                         RoleListLanguage = &BusinessRoleListLanguage;   
3481                         RoleListPref = &BusinessRoleListPref;
3482                         break;
3483         }
3485         intPrevValue = 5;
3486                 
3487         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3488         intiter != SplitPoints.end(); ++intiter){
3489         
3490                 SLiter = SplitLength.find(intiter->first);
3491         
3492                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3493                 
3494                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3495                 PropertyName = PropertyElement.GetNextToken();                          
3496                 PropertyValue = PropertyElement.GetNextToken();
3497                 
3498                 intPrevValue = intiter->second;
3499                 
3500                 // Process properties.
3501                 
3502                 size_t intPropertyValueLen = PropertyValue.Len();
3503                 
3504                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3505                         
3506                         PropertyValue.Trim();
3507                         PropertyValue.RemoveLast();
3508                         
3509                 }                               
3510                 
3511                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3512                         
3513                         PropertyValue.Remove(0, 1);
3514                         
3515                 }                               
3516                 
3517                 CaptureString(&PropertyValue, FALSE);
3518                 
3519                 if (PropertyName == wxT("ALTID")){
3520                 
3521                         RoleListAltID->erase(*RoleCount);
3522                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3523                 
3524                 } else if (PropertyName == wxT("PID")){
3526                         RoleListPID->erase(*RoleCount);
3527                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3528                 
3529                 } else if (PropertyName == wxT("PREF")){
3531                         ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3532                                 
3533                 } else if (PropertyName == wxT("LANGUAGE")){
3534                 
3535                         RoleListLanguage->erase(*RoleCount);
3536                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3537                 
3538                 } else {
3539                 
3540                         // Something else we don't know about so append
3541                         // to the tokens variable.
3542                 
3543                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3544                 
3545                                 if (FirstToken == TRUE){
3546                         
3547                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3548                                         FirstToken = FALSE;
3549                         
3550                                 } else {
3551                         
3552                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3553                         
3554                                 }
3555                 
3556                         }
3557                 
3558                 }
3559         
3560         }
3561         
3562         // Add the data to the General/Home/Work address variables.
3563         
3564         CaptureString(&PropertySeg2, FALSE);
3566         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3567         
3568         if (!PropertyTokens.IsEmpty()){
3569         
3570                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3571                         
3572         }
3576 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3578         std::map<int, int> SplitPoints;
3579         std::map<int, int> SplitLength;
3580         std::map<int, int>::iterator SLiter;                    
3581         wxString PropertyData;
3582         wxString PropertyName;
3583         wxString PropertyValue;
3584         wxString PropertyTokens;
3585         bool FirstToken = TRUE;
3586         int intPrevValue = 5;
3587         int intPref = 0;                        
3588         int intType = 0;
3589         long ListCtrlIndex;
3590         
3591         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3592         
3593         intPrevValue = 4;
3594         
3595         PropertyType PropType = PROPERTY_NONE;
3596                 
3597         // Look for type before continuing.
3598         
3599         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3600         
3601         // Setup the pointers.
3602         
3603         std::map<int, wxString> *OrganisationsList = NULL;
3604         std::map<int, wxString> *OrganisationsListAltID = NULL;
3605         std::map<int, wxString> *OrganisationsListPID = NULL;
3606         std::map<int, wxString> *OrganisationsListType = NULL;
3607         std::map<int, wxString> *OrganisationsListTokens = NULL;
3608         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3609         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3610         std::map<int, int> *OrganisationsListPref = NULL;
3611         
3612         // Setup blank lines for later on.
3613         
3614         switch(PropType){
3615                 case PROPERTY_NONE:
3616                         OrganisationsList = &GeneralOrganisationsList;
3617                         OrganisationsListType = &GeneralOrganisationsListType;
3618                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3619                         OrganisationsListPID = &GeneralOrganisationsListPID;
3620                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3621                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3622                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3623                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3624                         break;
3625                 case PROPERTY_HOME:
3626                         OrganisationsList = &HomeOrganisationsList;
3627                         OrganisationsListType = &HomeOrganisationsListType;
3628                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3629                         OrganisationsListPID = &HomeOrganisationsListPID;
3630                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3631                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3632                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3633                         OrganisationsListPref = &HomeOrganisationsListPref;     
3634                         break;
3635                 case PROPERTY_WORK:
3636                         OrganisationsList = &BusinessOrganisationsList;
3637                         OrganisationsListType = &BusinessOrganisationsListType;
3638                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3639                         OrganisationsListPID = &BusinessOrganisationsListPID;
3640                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3641                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3642                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3643                         OrganisationsListPref = &BusinessOrganisationsListPref;
3644                         break;
3645         }
3647         intPrevValue = 4;
3648                 
3649         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3650         intiter != SplitPoints.end(); ++intiter){
3651         
3652                 SLiter = SplitLength.find(intiter->first);
3653         
3654                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3655                 
3656                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3657                 PropertyName = PropertyElement.GetNextToken();                          
3658                 PropertyValue = PropertyElement.GetNextToken();
3659                 
3660                 intPrevValue = intiter->second;
3661                 
3662                 // Process properties.
3663                 
3664                 size_t intPropertyValueLen = PropertyValue.Len();
3665                 
3666                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3667                         
3668                         PropertyValue.Trim();
3669                         PropertyValue.RemoveLast();
3670                         
3671                 }                               
3672                 
3673                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3674                         
3675                         PropertyValue.Remove(0, 1);
3676                         
3677                 }                               
3678                 
3679                 CaptureString(&PropertyValue, FALSE);
3680                 
3681                 if (PropertyName == wxT("ALTID")){
3682                 
3683                         OrganisationsListAltID->erase(*OrganisationCount);
3684                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3685                 
3686                 } else if (PropertyName == wxT("PID")){
3688                         OrganisationsListPID->erase(*OrganisationCount);
3689                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3690                 
3691                 } else if (PropertyName == wxT("SORT-AS")){
3693                         OrganisationsListSortAs->erase(*OrganisationCount);
3694                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3695                 
3696                 } else if (PropertyName == wxT("PREF")){
3698                         ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3699                         
3700                 } else if (PropertyName == wxT("LANGUAGE")){
3701                 
3702                         OrganisationsListLanguage->erase(*OrganisationCount);
3703                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3704                 
3705                 } else {
3706                 
3707                         // Something else we don't know about so append
3708                         // to the tokens variable.
3709                 
3710                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3711                 
3712                                 if (FirstToken == TRUE){
3713                         
3714                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3715                                         FirstToken = FALSE;
3716                         
3717                                 } else {
3718                         
3719                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3720                         
3721                                 }
3722                 
3723                         }
3724                 
3725                 }
3726         
3727         }
3728         
3729         // Add the data to the General/Home/Work address variables.
3730         
3731         CaptureString(&PropertySeg2, FALSE);
3733         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3734         
3735         if (!PropertyTokens.IsEmpty()){
3736         
3737                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3738                         
3739         }
3743 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3745         std::map<int, int> SplitPoints;
3746         std::map<int, int> SplitLength;
3747         std::map<int, int>::iterator SLiter;                    
3748         wxString PropertyData;
3749         wxString PropertyName;
3750         wxString PropertyValue;
3751         wxString PropertyTokens;
3752         bool FirstToken = TRUE;
3753         int intPrevValue = 6;
3754         int intPref = 0;                        
3755         int intType = 0;
3756         long ListCtrlIndex;
3757         
3758         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3759         
3760         intPrevValue = 5;
3761         
3762         PropertyType PropType = PROPERTY_NONE;
3763                 
3764         // Look for type before continuing.
3765         
3766         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3767         
3768         // Setup the pointers.
3769         
3770         std::map<int, wxString> *NoteList = NULL;
3771         std::map<int, wxString> *NoteListAltID = NULL;
3772         std::map<int, wxString> *NoteListPID = NULL;
3773         std::map<int, wxString> *NoteListType = NULL;
3774         std::map<int, wxString> *NoteListTokens = NULL;
3775         std::map<int, wxString> *NoteListLanguage = NULL;
3776         std::map<int, int> *NoteListPref = NULL;
3777         
3778         // Setup blank lines for later on.
3779         
3780         switch(PropType){
3781                 case PROPERTY_NONE:
3782                         NoteList = &GeneralNoteList;
3783                         NoteListType = &GeneralNoteListType;
3784                         NoteListAltID = &GeneralNoteListAltID;
3785                         NoteListPID = &GeneralNoteListPID;
3786                         NoteListTokens = &GeneralNoteListTokens;
3787                         NoteListLanguage = &GeneralNoteListLanguage;
3788                         NoteListPref = &GeneralNoteListPref;    
3789                         break;
3790                 case PROPERTY_HOME:
3791                         NoteList = &HomeNoteList;
3792                         NoteListType = &HomeNoteListType;
3793                         NoteListAltID = &HomeNoteListAltID;
3794                         NoteListPID = &HomeNoteListPID;
3795                         NoteListTokens = &HomeNoteListTokens;
3796                         NoteListLanguage = &HomeNoteListLanguage;
3797                         NoteListPref = &HomeNoteListPref;       
3798                         break;
3799                 case PROPERTY_WORK:
3800                         NoteList = &BusinessNoteList;
3801                         NoteListType = &BusinessNoteListType;
3802                         NoteListAltID = &BusinessNoteListAltID;
3803                         NoteListPID = &BusinessNoteListPID;
3804                         NoteListTokens = &BusinessNoteListTokens;
3805                         NoteListLanguage = &BusinessNoteListLanguage;   
3806                         NoteListPref = &BusinessNoteListPref;
3807                         break;
3808         }
3810         intPrevValue = 5;
3811                 
3812         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3813         intiter != SplitPoints.end(); ++intiter){
3814         
3815                 SLiter = SplitLength.find(intiter->first);
3816         
3817                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3818                 
3819                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3820                 PropertyName = PropertyElement.GetNextToken();                          
3821                 PropertyValue = PropertyElement.GetNextToken();
3822                 
3823                 intPrevValue = intiter->second;
3824                 
3825                 // Process properties.
3826                 
3827                 size_t intPropertyValueLen = PropertyValue.Len();
3828                 
3829                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3830                         
3831                         PropertyValue.Trim();
3832                         PropertyValue.RemoveLast();
3833                         
3834                 }                               
3835                 
3836                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3837                         
3838                         PropertyValue.Remove(0, 1);
3839                         
3840                 }                               
3841                 
3842                 CaptureString(&PropertyValue, FALSE);
3843                 
3844                 if (PropertyName == wxT("ALTID")){
3845                 
3846                         NoteListAltID->erase(*NoteCount);
3847                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3848                 
3849                 } else if (PropertyName == wxT("PID")){
3851                         NoteListPID->erase(*NoteCount);
3852                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3853                 
3854                 } else if (PropertyName == wxT("PREF")){
3856                         ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3857                 
3858                 } else if (PropertyName == wxT("LANGUAGE")){
3859                 
3860                         NoteListLanguage->erase(*NoteCount);
3861                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3862                 
3863                 } else {
3864                 
3865                         // Something else we don't know about so append
3866                         // to the tokens variable.
3867                 
3868                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3869                 
3870                                 if (FirstToken == TRUE){
3871                         
3872                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3873                                         FirstToken = FALSE;
3874                         
3875                                 } else {
3876                         
3877                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3878                         
3879                                 }
3880                 
3881                         }
3882                 
3883                 }
3884         
3885         }
3886         
3887         // Add the data to the General/Home/Work address variables.
3888         
3889         CaptureString(&PropertySeg2, FALSE);
3891         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3892         
3893         if (!PropertyTokens.IsEmpty()){
3894         
3895                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3896                         
3897         }
3901 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3903         std::map<int, int> SplitPoints;
3904         std::map<int, int> SplitLength;
3905         std::map<int, int>::iterator SLiter;                    
3906         wxString PropertyData;
3907         wxString PropertyName;
3908         wxString PropertyValue;
3909         wxString PropertyTokens;
3910         bool FirstToken = TRUE;
3911         int intPrevValue = 12;
3912         int intPref = 0;                        
3913         int intType = 0;
3914         long ListCtrlIndex;
3915         
3916         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3917         
3918         intPrevValue = 11;
3919         
3920         PropertyType PropType = PROPERTY_NONE;
3921                 
3922         // Look for type before continuing.
3923         
3924         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3925         
3926         // Setup blank lines for later on.
3927         
3928         switch(PropType){
3929                 case PROPERTY_NONE:
3930                         break;
3931                 case PROPERTY_HOME:
3932                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3933                         break;
3934                 case PROPERTY_WORK:
3935                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3936                         break;
3937         }
3939         intPrevValue = 11;
3940                 
3941         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3942         intiter != SplitPoints.end(); ++intiter){
3943         
3944                 SLiter = SplitLength.find(intiter->first);
3945         
3946                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3947                 
3948                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3949                 PropertyName = PropertyElement.GetNextToken();                          
3950                 PropertyValue = PropertyElement.GetNextToken();
3951                 
3952                 intPrevValue = intiter->second;
3953                 
3954                 // Process properties.
3955                 
3956                 size_t intPropertyValueLen = PropertyValue.Len();
3957                 
3958                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3959                         
3960                         PropertyValue.Trim();
3961                         PropertyValue.RemoveLast();
3962                         
3963                 }                               
3964                 
3965                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3966                         
3967                         PropertyValue.Remove(0, 1);
3968                         
3969                 }                               
3970                 
3971                 CaptureString(&PropertyValue, FALSE);
3972                 
3973                 if (PropertyName == wxT("ALTID")){
3974                 
3975                         CategoriesListAltID.erase(*CategoryCount);
3976                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3977                 
3978                 } else if (PropertyName == wxT("PID")){
3980                         CategoriesListPID.erase(*CategoryCount);
3981                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3982                 
3983                 } else if (PropertyName == wxT("PREF")){
3985                         ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3986                         
3987                 } else if (PropertyName == wxT("LANGUAGE")){
3988                 
3989                         CategoriesListLanguage.erase(*CategoryCount);
3990                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3991                 
3992                 } else {
3993                 
3994                         // Something else we don't know about so append
3995                         // to the tokens variable.
3996                 
3997                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3998                 
3999                                 if (FirstToken == TRUE){
4000                         
4001                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4002                                         FirstToken = FALSE;
4003                         
4004                                 } else {
4005                         
4006                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4007                         
4008                                 }
4009                 
4010                         }
4011                 
4012                 }
4013         
4014         }
4015         
4016         // Deal with multiple categories.
4017         
4018         int intOrigCatCount = *CategoryCount;
4019         bool FirstCategoryProcessed = TRUE;
4020         bool AfterFirstToken = FALSE;
4021         int intSplitSize = 0;
4022         int intSplitsFound = 0;
4023         int intSplitSeek = 0;
4024         int intPropertyLen = PropertySeg2.Len();
4025         
4026         SplitPoints.clear();
4027         SplitLength.clear();
4028         intPrevValue = 0;
4029         
4030         for (int i = 0; i <= intPropertyLen; i++){
4031         
4032                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4033         
4034                         continue;
4035                 
4036                 }
4037         
4038                 intSplitSize++;
4039         
4040                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4041         
4042                         if (AfterFirstToken == TRUE){
4043                 
4044                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4045                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4046                         
4047                         } else {
4048                         
4049                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4050                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
4051                                 AfterFirstToken = TRUE;
4053                         }
4055                         intSplitsFound++;
4056                         intSplitSeek = i;
4057                         intSplitSize = 0;                               
4058         
4059                 }                       
4060         
4061         }
4062         
4063         if (SplitPoints.size() > 0){
4064         
4065                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4066                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4067         
4068         }
4069         
4070         if (SplitPoints.size() == 0){
4071         
4072                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4073         
4074                 if (!PropertyTokens.IsEmpty()){
4075                 
4076                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4077                 
4078                 }
4079         
4080         }
4081         
4082         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4083         intiter != SplitPoints.end(); ++intiter){
4084         
4085                 SLiter = SplitLength.find(intiter->first);
4086         
4087                 intPrevValue = intiter->second;
4088         
4089                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4090                 
4091                 // Add the data to the General/Home/Work address variables.
4092         
4093                 // Trim any whitespace from the start and end.
4094         
4095                 PropertyData = PropertyData.Trim(FALSE);
4096                 PropertyData = PropertyData.Trim(TRUE); 
4097         
4098                 CaptureString(&PropertyData, FALSE);
4099                 
4100                 if (FirstCategoryProcessed == TRUE){
4101                 
4102                         FirstCategoryProcessed = FALSE;
4103                         
4104                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4105         
4106                         if (!PropertyTokens.IsEmpty()){
4107                 
4108                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4109                 
4110                         }
4111                         
4112                         continue;
4113                 
4114                 } else {
4116                         (*CategoryCount)++;
4117                         
4118                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4119                 
4120                         if (!PropertyTokens.IsEmpty()){
4121                 
4122                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4123                 
4124                         }
4125                 
4126                 }
4127                 
4128                 // Copy the properties to each of the categories (if it exists).
4129                 
4130                 if (!PropertyTokens.IsEmpty()){
4131                 
4132                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4133                 
4134                 }
4135                 
4136                 // Check if ALTID was used.
4137                 
4138                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4139                 
4140                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4141                 
4142                 }
4143                 
4144                 // Check if PID was used.
4145                 
4146                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4147                 
4148                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4149                 
4150                 }
4151         
4152                 // Check if PREF was used.
4153         
4154                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4155                 
4156                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4157                 
4158                 }
4159                 
4160                 // Check if LANGUAGE was used.
4161                 
4162                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4163                 
4164                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4165                 
4166                 }
4167                 
4168                 // Check if TYPE was used.
4169                 
4170                 switch(PropType){
4171                         case PROPERTY_NONE:
4172                                 break;
4173                         case PROPERTY_HOME:
4174                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4175                                 break;
4176                         case PROPERTY_WORK:
4177                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4178                                 break;
4179                 }
4180         
4181         }
4185 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4187         size_t intPropertyLen = PropertySeg1.Len();
4188         std::map<int, int> SplitPoints;
4189         std::map<int, int> SplitLength;
4190         std::map<int, int>::iterator SLiter;                    
4191         wxString PropertyData;
4192         wxString PropertyName;
4193         wxString PropertyValue;
4194         wxString PropertyTokens;
4195         bool FirstToken = TRUE;
4196         int intSplitsFound = 0;
4197         int intSplitSize = 0;
4198         int intPrevValue = 7;
4199         int intPref = 0;                        
4200         int intType = 0;
4201         
4202         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4203         
4204         intPrevValue = 6;
4205         
4206         PropertyType PropType = PROPERTY_NONE;
4207                 
4208         // Look for type before continuing.
4209         
4210         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4212         intPrevValue = 6;
4214         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4215         intiter != SplitPoints.end(); ++intiter){
4216         
4217                 SLiter = SplitLength.find(intiter->first);
4218         
4219                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4220                 
4221                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4222                 PropertyName = PropertyElement.GetNextToken();                          
4223                 PropertyValue = PropertyElement.GetNextToken();
4224                 
4225                 intPrevValue = intiter->second;
4226                 
4227                 // Process properties.
4228                 
4229                 size_t intPropertyValueLen = PropertyValue.Len();
4230                 
4231                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4232                         
4233                         PropertyValue.Trim();
4234                         PropertyValue.RemoveLast();
4235                         
4236                 }                               
4237                 
4238                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4239                         
4240                         PropertyValue.Remove(0, 1);
4241                         
4242                 }
4243                 
4244                 CaptureString(&PropertyValue, FALSE);
4245                 
4246                 if (PropertyName == wxT("ALTID")){
4248                         PicturesListAltID.erase(*PhotoCount);
4249                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4250                 
4251                 } else if (PropertyName == wxT("PID")){
4253                         PicturesListPID.erase(*PhotoCount);
4254                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4255                 
4256                 } else if (PropertyName == wxT("PREF")){
4258                         ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4259                 
4260                 } else if (PropertyName == wxT("MEDIATYPE")){
4261                 
4262                         PicturesListMediatype.erase(*PhotoCount);
4263                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4264                                         
4265                 } else {
4266                 
4267                         // Something else we don't know about so append
4268                         // to the tokens variable.
4269                         
4270                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4271                         
4272                                 if (FirstToken == TRUE){
4273                                 
4274                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4275                                         FirstToken = FALSE;
4276                                 
4277                                 } else {
4278                                 
4279                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4280                                 
4281                                 }
4282                         
4283                         }
4284                 
4285                 }
4286         
4287         }       
4288         
4289         intPropertyLen = PropertySeg2.Len();
4290         SplitPoints.clear();
4291         SplitLength.clear();
4292         intSplitsFound = 0;
4293         intSplitSize = 0;
4294         intPrevValue = 0;                       
4295         
4296         CaptureString(&PropertySeg2, FALSE);
4297         
4298         for (int i = 0; i <= intPropertyLen; i++){
4300                 intSplitSize++;
4301         
4302                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4303         
4304                         intSplitsFound++;
4305                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4306                         
4307                         if (intSplitsFound == 6){ 
4308                         
4309                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4310                                 break; 
4311                                 
4312                         } else {
4313                         
4314                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4315                         
4316                         }
4317                         
4318                         intSplitSize = 0;                                       
4319         
4320                 }
4322         }
4323         
4324         wxString wxSPhotoURI;
4325         wxString wxSPhotoMIME;
4326         wxString wxSPhotoEncoding;
4327         wxString wxSPhotoData;
4328         std::string base64enc;
4329         
4330         if (intSplitsFound == 0){
4331         
4332         } else {
4333         
4334                 std::map<int, int>::iterator striter;
4335         
4336                 striter = SplitLength.find(1);
4337         
4338                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4339         
4340                 while (wSTDataType.HasMoreTokens() == TRUE){
4341                 
4342                         wxSPhotoURI = wSTDataType.GetNextToken();
4343                         wxSPhotoMIME = wSTDataType.GetNextToken();
4344                         break;
4345                 
4346                 }                       
4347         
4348                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4349         
4350                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4351                 
4352                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4353                         wxSPhotoData = wSTDataInfo.GetNextToken();
4354                         base64enc = wxSPhotoData.mb_str();
4355                         break;
4356                 
4357                 }
4358         
4359         }
4360         
4361         // Add the data to the General/Home/Work address variables.
4362         
4363         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4364         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4365         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4366         
4367         switch(PropType){
4368                 case PROPERTY_NONE:
4369                         break;
4370                 case PROPERTY_HOME:
4371                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4372                         break;
4373                 case PROPERTY_WORK:
4374                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4375                         break;
4376         }
4377         
4378         if (!PropertyTokens.IsEmpty()){
4380                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4381         
4382         }
4386 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4388         size_t intPropertyLen = PropertySeg1.Len();
4389         std::map<int, int> SplitPoints;
4390         std::map<int, int> SplitLength;
4391         std::map<int, int>::iterator SLiter;                    
4392         wxString PropertyData;
4393         wxString PropertyName;
4394         wxString PropertyValue;
4395         wxString PropertyTokens;
4396         bool FirstToken = TRUE;
4397         int intSplitsFound = 0;
4398         int intSplitSize = 0;
4399         int intPrevValue = 6;
4400         int intPref = 0;                        
4401         int intType = 0;
4402         
4403         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4404         
4405         intPrevValue = 5;
4406         
4407         PropertyType PropType = PROPERTY_NONE;
4408                 
4409         // Look for type before continuing.
4410         
4411         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4413         intPrevValue = 5;
4415         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4416         intiter != SplitPoints.end(); ++intiter){
4417         
4418                 SLiter = SplitLength.find(intiter->first);
4419         
4420                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4421                 
4422                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4423                 PropertyName = PropertyElement.GetNextToken();                          
4424                 PropertyValue = PropertyElement.GetNextToken();
4425                 
4426                 intPrevValue = intiter->second;
4427                 
4428                 // Process properties.
4429                 
4430                 size_t intPropertyValueLen = PropertyValue.Len();
4431                 
4432                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4433                         
4434                         PropertyValue.Trim();
4435                         PropertyValue.RemoveLast();
4436                         
4437                 }                               
4438                 
4439                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4440                         
4441                         PropertyValue.Remove(0, 1);
4442                         
4443                 }
4444                 
4445                 CaptureString(&PropertyValue, FALSE);
4446                 
4447                 if (PropertyName == wxT("ALTID")){
4449                         LogosListAltID.erase(*LogoCount);
4450                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4451                 
4452                 } else if (PropertyName == wxT("PID")){
4454                         LogosListPID.erase(*LogoCount);
4455                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4456                 
4457                 } else if (PropertyName == wxT("PREF")){
4459                         ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4460                 
4461                 } else if (PropertyName == wxT("MEDIATYPE")){
4462                 
4463                         LogosListMediatype.erase(*LogoCount);
4464                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4465                                         
4466                 } else {
4467                 
4468                         // Something else we don't know about so append
4469                         // to the tokens variable.
4470                         
4471                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4472                         
4473                                 if (FirstToken == TRUE){
4474                                 
4475                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4476                                         FirstToken = FALSE;
4477                                 
4478                                 } else {
4479                                 
4480                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4481                                 
4482                                 }
4483                         
4484                         }
4485                 
4486                 }
4487         
4488         }       
4489         
4490         intPropertyLen = PropertySeg2.Len();
4491         SplitPoints.clear();
4492         SplitLength.clear();
4493         intSplitsFound = 0;
4494         intSplitSize = 0;
4495         intPrevValue = 0;                       
4496         
4497         CaptureString(&PropertySeg2, FALSE);
4498         
4499         for (int i = 0; i <= intPropertyLen; i++){
4501                 intSplitSize++;
4502         
4503                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4504         
4505                         intSplitsFound++;
4506                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4507                         
4508                         if (intSplitsFound == 6){ 
4509                         
4510                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4511                                 break; 
4512                                 
4513                         } else {
4514                         
4515                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4516                         
4517                         }
4518                         
4519                         intSplitSize = 0;                                       
4520         
4521                 }
4523         }
4524         
4525         wxString wxSPhotoURI;
4526         wxString wxSPhotoMIME;
4527         wxString wxSPhotoEncoding;
4528         wxString wxSPhotoData;
4529         std::string base64enc;
4530         
4531         if (intSplitsFound == 0){
4532         
4533         } else {
4534         
4535                 std::map<int, int>::iterator striter;
4536         
4537                 striter = SplitLength.find(1);
4538         
4539                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4540         
4541                 while (wSTDataType.HasMoreTokens() == TRUE){
4542                 
4543                         wxSPhotoURI = wSTDataType.GetNextToken();
4544                         wxSPhotoMIME = wSTDataType.GetNextToken();
4545                         break;
4546                 
4547                 }                       
4548         
4549                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4550         
4551                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4552                 
4553                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4554                         wxSPhotoData = wSTDataInfo.GetNextToken();
4555                         base64enc = wxSPhotoData.mb_str();
4556                         break;
4557                 
4558                 }
4559         
4560         }
4561         
4562         // Add the data to the General/Home/Work address variables.
4563         
4564         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4565         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4566         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4567         
4568         switch(PropType){
4569                 case PROPERTY_NONE:
4570                         break;
4571                 case PROPERTY_HOME:
4572                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4573                         break;
4574                 case PROPERTY_WORK:
4575                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4576                         break;
4577         }
4578         
4579         if (!PropertyTokens.IsEmpty()){
4581                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4582         
4583         }
4587 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4589         size_t intPropertyLen = PropertySeg1.Len();
4590         std::map<int, int> SplitPoints;
4591         std::map<int, int> SplitLength;
4592         std::map<int, int>::iterator SLiter;                    
4593         wxString PropertyData;
4594         wxString PropertyName;
4595         wxString PropertyValue;
4596         wxString PropertyTokens;
4597         bool FirstToken = TRUE;
4598         int intSplitsFound = 0;
4599         int intSplitSize = 0;
4600         int intPrevValue = 7;
4601         int intPref = 0;                        
4602         int intType = 0;
4603         
4604         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4605         
4606         intPrevValue = 6;
4607         
4608         PropertyType PropType = PROPERTY_NONE;
4609         
4610         // Look for type before continuing.                     
4612         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4614         intPrevValue = 6;
4616         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4617         intiter != SplitPoints.end(); ++intiter){
4618         
4619                 SLiter = SplitLength.find(intiter->first);
4620         
4621                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4622                 
4623                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4624                 PropertyName = PropertyElement.GetNextToken();                          
4625                 PropertyValue = PropertyElement.GetNextToken();
4626                 
4627                 intPrevValue = intiter->second;
4628                 
4629                 // Process properties.
4630                 
4631                 size_t intPropertyValueLen = PropertyValue.Len();
4632                 
4633                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4634                         
4635                         PropertyValue.Trim();
4636                         PropertyValue.RemoveLast();
4637                         
4638                 }                               
4639                 
4640                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4641                         
4642                         PropertyValue.Remove(0, 1);
4643                         
4644                 }                       
4645                 
4646                 CaptureString(&PropertyValue, FALSE);
4647                 
4648                 if (PropertyName == wxT("ALTID")){
4650                         SoundsListAltID.erase(*SoundCount);
4651                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4652                 
4653                 } else if (PropertyName == wxT("PID")){
4655                         SoundsListPID.erase(*SoundCount);
4656                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4657                 
4658                 } else if (PropertyName == wxT("PREF")){
4660                         ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4661                 
4662                 } else if (PropertyName == wxT("MEDIATYPE")){
4663                 
4664                         SoundsListMediatype.erase(*SoundCount);
4665                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4667                 } else if (PropertyName == wxT("LANGUAGE")){
4668                 
4669                         SoundsListLanguage.erase(*SoundCount);
4670                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4672                 } else {
4673                 
4674                         // Something else we don't know about so append
4675                         // to the tokens variable.
4676                         
4677                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4678                         
4679                                 if (FirstToken == TRUE){
4680                                 
4681                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4682                                         FirstToken = FALSE;
4683                                 
4684                                 } else {
4685                                 
4686                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4687                                 
4688                                 }
4689                         
4690                         }
4691                 
4692                 }
4693         
4694         }       
4695         
4696         intPropertyLen = PropertySeg2.Len();
4697         SplitPoints.clear();
4698         SplitLength.clear();
4699         intSplitsFound = 0;
4700         intSplitSize = 0;
4701         intPrevValue = 0;
4702         
4703         CaptureString(&PropertySeg2, FALSE);
4704         
4705         for (int i = 0; i <= intPropertyLen; i++){
4707                 intSplitSize++;
4708         
4709                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4710         
4711                         intSplitsFound++;
4712                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4713                         
4714                         if (intSplitsFound == 6){ 
4715                         
4716                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4717                                 break; 
4718                                 
4719                         } else {
4720                         
4721                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4722                         
4723                         }
4724                         
4725                         intSplitSize = 0;                                       
4726         
4727                 }
4729         }
4730         
4731         wxString wxSSoundURI;
4732         wxString wxSSoundMIME;
4733         wxString wxSSoundEncoding;
4734         wxString wxSSoundData;
4735         std::string base64enc;
4736         
4737         if (intSplitsFound == 0){
4738         
4739         } else {
4740         
4741                 std::map<int, int>::iterator striter;
4742         
4743                 striter = SplitLength.find(1);
4744         
4745                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4746         
4747                 while (wSTDataType.HasMoreTokens() == TRUE){
4748                 
4749                         wxSSoundURI = wSTDataType.GetNextToken();
4750                         wxSSoundMIME = wSTDataType.GetNextToken();
4751                         break;
4752                 
4753                 }                       
4754         
4755                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4756         
4757                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4758                 
4759                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4760                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4761                         base64enc = wxSSoundData.mb_str();
4762                         break;
4763                 
4764                 }
4765         
4766         }
4767         
4768         // Add the data to the General/Home/Work address variables.
4769                 
4770         switch(PropType){
4771                 case PROPERTY_NONE:
4772                         break;
4773                 case PROPERTY_HOME:
4774                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4775                         break;
4776                 case PROPERTY_WORK:
4777                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4778                         break;
4779         }
4780         
4781         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4782         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4783         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4784         
4785         if (!PropertyTokens.IsEmpty()){
4786         
4787                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4788         
4789         }
4790         
4793 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4795         size_t intPropertyLen = PropertySeg1.Len();
4796         std::map<int, int> SplitPoints;
4797         std::map<int, int> SplitLength;
4798         std::map<int, int>::iterator SLiter;                    
4799         wxString PropertyData;
4800         wxString PropertyName;
4801         wxString PropertyValue;
4802         wxString PropertyTokens;
4803         bool FirstToken = TRUE;
4804         int intSplitsFound = 0;
4805         int intSplitSize = 0;
4806         int intPrevValue = 8;
4807         int intPref = 0;                        
4808         int intType = 0;
4809         
4810         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4811         
4812         intPrevValue = 7;
4813         
4814         PropertyType PropType = PROPERTY_NONE;
4815         
4816         // Look for type before continuing.                     
4818         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4820         intPrevValue = 7;
4822         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4823         intiter != SplitPoints.end(); ++intiter){
4824         
4825                 SLiter = SplitLength.find(intiter->first);
4826         
4827                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4828                 
4829                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4830                 PropertyName = PropertyElement.GetNextToken();                          
4831                 PropertyValue = PropertyElement.GetNextToken();
4832                 
4833                 intPrevValue = intiter->second;
4834                 
4835                 // Process properties.
4836                 
4837                 size_t intPropertyValueLen = PropertyValue.Len();
4838                 
4839                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4840                         
4841                         PropertyValue.Trim();
4842                         PropertyValue.RemoveLast();
4843                         
4844                 }                               
4845                 
4846                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4847                         
4848                         PropertyValue.Remove(0, 1);
4849                         
4850                 }                       
4851                 
4852                 CaptureString(&PropertyValue, FALSE);
4853                 
4854                 if (PropertyName == wxT("ALTID")){
4856                         CalendarListAltID.erase(*CalURICount);
4857                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4858                 
4859                 } else if (PropertyName == wxT("PID")){
4861                         CalendarListPID.erase(*CalURICount);
4862                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4863                 
4864                 } else if (PropertyName == wxT("PREF")){
4866                         ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4867                 
4868                 } else if (PropertyName == wxT("MEDIATYPE")){
4869                 
4870                         CalendarListMediatype.erase(*CalURICount);
4871                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4873                 } else {
4874                 
4875                         // Something else we don't know about so append
4876                         // to the tokens variable.
4877                         
4878                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4879                         
4880                                 if (FirstToken == TRUE){
4881                                 
4882                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4883                                         FirstToken = FALSE;
4884                                 
4885                                 } else {
4886                                 
4887                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4888                                 
4889                                 }
4890                         
4891                         }
4892                 
4893                 }
4894         
4895         }       
4896         
4897         intPropertyLen = PropertySeg2.Len();
4898         SplitPoints.clear();
4899         SplitLength.clear();
4900         intSplitsFound = 0;
4901         intSplitSize = 0;
4902         intPrevValue = 0;
4903         
4904         CaptureString(&PropertySeg2, FALSE);
4905         
4906         // Add the data to the General/Home/Work address variables.
4907                 
4908         switch(PropType){
4909                 case PROPERTY_NONE:
4910                         break;
4911                 case PROPERTY_HOME:
4912                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4913                         break;
4914                 case PROPERTY_WORK:
4915                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4916                         break;
4917         }
4918         
4919         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4920         
4921         if (!PropertyTokens.IsEmpty()){
4922         
4923                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4924         
4925         }
4929 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4931         size_t intPropertyLen = PropertySeg1.Len();
4932         std::map<int, int> SplitPoints;
4933         std::map<int, int> SplitLength;
4934         std::map<int, int>::iterator SLiter;                    
4935         wxString PropertyData;
4936         wxString PropertyName;
4937         wxString PropertyValue;
4938         wxString PropertyTokens;
4939         bool FirstToken = TRUE;
4940         int intSplitsFound = 0;
4941         int intSplitSize = 0;
4942         int intPrevValue = 8;
4943         int intPref = 0;                        
4944         int intType = 0;
4945         
4946         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4947         
4948         intPrevValue = 7;
4949         
4950         PropertyType PropType = PROPERTY_NONE;
4951         
4952         // Look for type before continuing.                     
4954         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4956         intPrevValue = 7;
4958         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4959         intiter != SplitPoints.end(); ++intiter){
4960         
4961                 SLiter = SplitLength.find(intiter->first);
4962         
4963                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4964                 
4965                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4966                 PropertyName = PropertyElement.GetNextToken();                          
4967                 PropertyValue = PropertyElement.GetNextToken();
4968                 
4969                 intPrevValue = intiter->second;
4970                 
4971                 // Process properties.
4972                 
4973                 size_t intPropertyValueLen = PropertyValue.Len();
4974                 
4975                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4976                         
4977                         PropertyValue.Trim();
4978                         PropertyValue.RemoveLast();
4979                         
4980                 }                               
4981                 
4982                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4983                         
4984                         PropertyValue.Remove(0, 1);
4985                         
4986                 }                       
4987                 
4988                 CaptureString(&PropertyValue, FALSE);
4989                 
4990                 if (PropertyName == wxT("ALTID")){
4992                         CalendarRequestListAltID.erase(*CalAdrURICount);
4993                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4994                 
4995                 } else if (PropertyName == wxT("PID")){
4997                         CalendarRequestListPID.erase(*CalAdrURICount);
4998                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4999                 
5000                 } else if (PropertyName == wxT("PREF")){
5002                         ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
5003                 
5004                 } else if (PropertyName == wxT("MEDIATYPE")){
5005                 
5006                         CalendarRequestListMediatype.erase(*CalAdrURICount);
5007                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5009                 } else {
5010                 
5011                         // Something else we don't know about so append
5012                         // to the tokens variable.
5013                         
5014                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5015                         
5016                                 if (FirstToken == TRUE){
5017                                 
5018                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5019                                         FirstToken = FALSE;
5020                                 
5021                                 } else {
5022                                 
5023                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5024                                 
5025                                 }
5026                         
5027                         }
5028                 
5029                 }
5030         
5031         }       
5032         
5033         intPropertyLen = PropertySeg2.Len();
5034         SplitPoints.clear();
5035         SplitLength.clear();
5036         intSplitsFound = 0;
5037         intSplitSize = 0;
5038         intPrevValue = 0;
5039         
5040         CaptureString(&PropertySeg2, FALSE);
5041         
5042         // Add the data to the General/Home/Work address variables.
5043                 
5044         switch(PropType){
5045                 case PROPERTY_NONE:
5046                         break;
5047                 case PROPERTY_HOME:
5048                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5049                         break;
5050                 case PROPERTY_WORK:
5051                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5052                         break;
5053         }
5054         
5055         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5056         
5057         if (!PropertyTokens.IsEmpty()){
5058         
5059                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5060         
5061         }       
5062         
5065 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5067         size_t intPropertyLen = PropertySeg1.Len();
5068         std::map<int, int> SplitPoints;
5069         std::map<int, int> SplitLength;
5070         std::map<int, int>::iterator SLiter;                    
5071         wxString PropertyData;
5072         wxString PropertyName;
5073         wxString PropertyValue;
5074         wxString PropertyTokens;
5075         bool FirstToken = TRUE;
5076         int intSplitsFound = 0;
5077         int intSplitSize = 0;
5078         int intPrevValue = 7;
5079         int intPref = 0;                        
5080         int intType = 0;
5081         
5082         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5083         
5084         intPrevValue = 6;
5085         
5086         PropertyType PropType = PROPERTY_NONE;
5087         
5088         // Look for type before continuing.                     
5090         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5092         intPrevValue = 6;
5094         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5095         intiter != SplitPoints.end(); ++intiter){
5096         
5097                 SLiter = SplitLength.find(intiter->first);
5098         
5099                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5100                 
5101                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5102                 PropertyName = PropertyElement.GetNextToken();                          
5103                 PropertyValue = PropertyElement.GetNextToken();
5104                 
5105                 intPrevValue = intiter->second;
5106                 
5107                 // Process properties.
5108                 
5109                 size_t intPropertyValueLen = PropertyValue.Len();
5110                 
5111                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5112                         
5113                         PropertyValue.Trim();
5114                         PropertyValue.RemoveLast();
5115                         
5116                 }                               
5117                 
5118                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5119                         
5120                         PropertyValue.Remove(0, 1);
5121                         
5122                 }                       
5123                 
5124                 CaptureString(&PropertyValue, FALSE);
5125                 
5126                 if (PropertyName == wxT("ALTID")){
5128                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5129                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5130                 
5131                 } else if (PropertyName == wxT("PID")){
5133                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5134                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5135                 
5136                 } else if (PropertyName == wxT("PREF")){
5138                         ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5139                 
5140                 } else if (PropertyName == wxT("MEDIATYPE")){
5141                 
5142                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5143                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5145                 } else {
5146                 
5147                         // Something else we don't know about so append
5148                         // to the tokens variable.
5149                         
5150                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5151                         
5152                                 if (FirstToken == TRUE){
5153                                 
5154                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5155                                         FirstToken = FALSE;
5156                                 
5157                                 } else {
5158                                 
5159                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5160                                 
5161                                 }
5162                         
5163                         }
5164                 
5165                 }
5166         
5167         }       
5168         
5169         intPropertyLen = PropertySeg2.Len();
5170         SplitPoints.clear();
5171         SplitLength.clear();
5172         intSplitsFound = 0;
5173         intSplitSize = 0;
5174         intPrevValue = 0;
5175         
5176         CaptureString(&PropertySeg2, FALSE);
5177         
5178         // Add the data to the General/Home/Work address variables.
5179                 
5180         switch(PropType){
5181                 case PROPERTY_NONE:
5182                         break;
5183                 case PROPERTY_HOME:
5184                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5185                         break;
5186                 case PROPERTY_WORK:
5187                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5188                         break;
5189         }
5190         
5191         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5192         
5193         if (!PropertyTokens.IsEmpty()){
5194         
5195                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5196         
5197         }
5201 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5203         size_t intPropertyLen = PropertySeg1.Len();
5204         std::map<int, int> SplitPoints;
5205         std::map<int, int> SplitLength;
5206         std::map<int, int>::iterator SLiter;                    
5207         wxString PropertyData;
5208         wxString PropertyName;
5209         wxString PropertyValue;
5210         wxString PropertyTokens;
5211         bool FirstToken = TRUE;
5212         int intSplitsFound = 0;
5213         int intSplitSize = 0;
5214         int intPrevValue = 5;
5215         int intPref = 0;                        
5216         int intType = 0;
5217         long ListCtrlIndex;
5218         
5219         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5220         
5221         intPrevValue = 4;
5222         
5223         PropertyType PropType = PROPERTY_NONE;
5224         
5225         // Look for type before continuing.
5227         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5229         intPrevValue = 4;
5231         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5232         intiter != SplitPoints.end(); ++intiter){
5233         
5234                 SLiter = SplitLength.find(intiter->first);
5235         
5236                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5237                 
5238                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5239                 PropertyName = PropertyElement.GetNextToken();                          
5240                 PropertyValue = PropertyElement.GetNextToken();
5241                 
5242                 intPrevValue = intiter->second;
5243                 
5244                 // Process properties.
5245                 
5246                 size_t intPropertyValueLen = PropertyValue.Len();
5247                 
5248                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5249                         
5250                         PropertyValue.Trim();
5251                         PropertyValue.RemoveLast();
5252                         
5253                 }                               
5254                 
5255                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5256                         
5257                         PropertyValue.Remove(0, 1);
5258                         
5259                 }                               
5260                 
5261                 if (PropertyName == wxT("ALTID")){
5263                         KeyListAltID.erase(*KeyCount);
5264                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5265                 
5266                 } else if (PropertyName == wxT("PID")){
5268                         KeyListPID.erase(*KeyCount);
5269                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5270                 
5271                 } else if (PropertyName == wxT("PREF")){
5273                         ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5274                 
5275                 } else {
5276                 
5277                         // Something else we don't know about so append
5278                         // to the tokens variable.
5279                         
5280                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5281                         
5282                                 if (FirstToken == TRUE){
5283                                 
5284                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5285                                         FirstToken = FALSE;
5286                                 
5287                                 } else {
5288                                 
5289                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5290                                 
5291                                 }
5292                         
5293                         }
5294                 
5295                 }
5296         
5297         }                               
5298         
5299         intPropertyLen = PropertySeg2.Len();
5300         SplitPoints.clear();
5301         SplitLength.clear();
5302         intSplitsFound = 0;
5303         intSplitSize = 0;
5304         intPrevValue = 0;                       
5305         
5306         for (int i = 0; i <= intPropertyLen; i++){
5308                 intSplitSize++;
5309         
5310                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5311         
5312                         intSplitsFound++;
5313                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5314                         
5315                         if (intSplitsFound == 6){ 
5316                         
5317                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5318                                 break; 
5319                                 
5320                         } else {
5321                         
5322                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5323                         
5324                         }
5325                         
5326                         intSplitSize = 0;                                       
5327         
5328                 }
5330         }
5331         
5332         wxString wxSKeyURI;
5333         wxString wxSKeyMIME;
5334         wxString wxSKeyEncoding;
5335         wxString wxSKeyData;
5336         std::string base64enc;
5337         
5338         if (intSplitsFound == 0){
5339         
5340         } else {
5341         
5342                 std::map<int, int>::iterator striter;
5343         
5344                 striter = SplitLength.find(1);
5345         
5346                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5347         
5348                 while (wSTDataType.HasMoreTokens() == TRUE){
5349                 
5350                         wxSKeyURI = wSTDataType.GetNextToken();
5351                         wxSKeyMIME = wSTDataType.GetNextToken();
5352                         break;
5353                 
5354                 }                       
5355         
5356                 if (wxSKeyURI == wxT("data")){
5357                 
5358                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5359         
5360                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5361                 
5362                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5363                                 wxSKeyData = wSTDataInfo.GetNextToken();
5364                                 break;
5365                 
5366                         }
5367                 
5368                 }
5369         
5370         }
5371         
5372         // Add the data to the General/Home/Work address variables.
5373         
5374         if (wxSKeyURI == wxT("data")){
5375                 
5376                 KeyListDataEncType.erase(*KeyCount);
5377                 KeyListKeyType.erase(*KeyCount);
5378                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5379                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5380                 
5381                 KeyList.erase(*KeyCount);
5382                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5383         
5384         } else {
5385                 
5386                 KeyList.erase(*KeyCount);
5387                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5388         
5389         }
5390         
5391         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5392                 
5393         switch (PropType){
5394                 case PROPERTY_NONE:
5395                         break;
5396                 case PROPERTY_HOME: 
5397                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5398                         break;
5399                 case PROPERTY_WORK: 
5400                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5401                         break;
5402         }
5404         if (!PropertyTokens.IsEmpty()){
5406                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5408         }
5412 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5414         // Split the Vendor three ways.
5415         
5416         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5417         
5418         wxString wxSVNDID;
5419         wxString wxSVNDPropName;
5420         long ListCtrlIndex;                     
5422         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5423         
5424                 wSTVendorDetails.GetNextToken();
5425                 wxSVNDID = wSTVendorDetails.GetNextToken();
5426                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5427                 break;
5428         
5429         }
5430         
5431         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5432         
5433                 // Add the data to the vendor variables.
5434         
5435                 VendorList.erase(*VendorCount);
5436                 VendorListPEN.erase(*VendorCount);
5437                 VendorListElement.erase(*VendorCount);
5438         
5439                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5440                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5441                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5442         
5443         }
5447 void ProcessStringValue(wxString *PropertyName,
5448         wxString PropertyNameMatch,
5449         std::map<int,wxString> *MapPtr,
5450         wxString *PropertyValue,
5451         int *ItemCount,
5452         bool *PropertyMatched){
5453         
5454         if (*PropertyName == PropertyNameMatch){
5455                 MapPtr->erase(*ItemCount);
5456                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5457                 *PropertyMatched = TRUE;
5458         }
5459         
5462 void ProcessIntegerValue(wxString *PropertyName,
5463         wxString PropertyNameMatch,
5464         std::map<int,int> *PrefPtr, 
5465         wxString *PropertyValue, 
5466         int *ItemCount,
5467         bool *PropertyMatched){
5469         if (*PropertyName == PropertyNameMatch){
5470                 *PropertyMatched = TRUE;
5471         } else {
5472                 return;
5473         }
5475         int PriorityNumber = 0; 
5476         bool ValidNumber = TRUE;
5477                         
5478         try{
5479                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5480         }
5481                         
5482         catch(std::invalid_argument &e){
5483                 ValidNumber = FALSE;
5484         }
5486         if (ValidNumber == TRUE){
5488                 PrefPtr->erase(*ItemCount);
5489                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5491         }
5495 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
5496         wxString *PropertyValue, 
5497         int *ItemCount){
5499         int PriorityNumber = 0; 
5500         bool ValidNumber = TRUE;
5501                         
5502         try{
5503                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5504         }
5505                         
5506         catch(std::invalid_argument &e){
5507                 ValidNumber = FALSE;
5508         }
5510         if (ValidNumber == TRUE){
5512                 PrefPtr->erase(*ItemCount);
5513                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5515         }
5519 void SplitValues(wxString *PropertyLine, 
5520         std::map<int,int> *SplitPoints, 
5521         std::map<int,int> *SplitLength, 
5522         int intSize){
5523         
5524         size_t intPropertyLen = PropertyLine->Len();
5525         int intSplitsFound = 0;
5526         int intSplitSize = 0;
5527         int intSplitSeek = 0;
5528         
5529         for (int i = intSize; i <= intPropertyLen; i++){
5531                 intSplitSize++;
5532         
5533                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5534                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5535            
5536                     if (intSplitsFound == 0){
5537             
5538                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5539           
5540                     } else {
5541            
5542                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5543             
5544                     }
5545             
5546                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5547             
5548                     intSplitsFound++;
5549                     intSplitSeek = i;
5550                     intSplitSize = 0;
5551             
5552                 }
5554         }
5556         if (intSplitsFound == 0){
5558                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5559                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5561         } else {
5563                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5564                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5566         }
5570 void CheckType(wxString *PropertySeg1, 
5571         std::map<int,int> *SplitPoints, 
5572         std::map<int,int> *SplitLength, 
5573         int *intPrevValue, 
5574         PropertyType *PropType){
5575         
5576         wxString PropertyData;
5577         wxString PropertyName;
5578         wxString PropertyValue;
5579         std::map<int,int>::iterator SLiter;
5580         
5581         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5582         intiter != SplitPoints->end(); ++intiter){
5583         
5584                 SLiter = SplitLength->find(intiter->first);
5585         
5586                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5587                 
5588                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5589                 PropertyName = PropertyElement.GetNextToken();                          
5590                 PropertyValue = PropertyElement.GetNextToken();
5591                 
5592                 *intPrevValue = intiter->second;
5593                 
5594                 if (PropertyName == wxT("TYPE")){
5595                                 
5596                         if (PropertyValue == wxT("work")){
5597                         
5598                                 *PropType = PROPERTY_WORK;
5599                                                         
5600                         } else if (PropertyValue == wxT("home")){
5602                                 *PropType = PROPERTY_HOME;
5603                                                         
5604                         } else {
5605                         
5606                                 *PropType = PROPERTY_NONE;
5607                         
5608                         }
5609                 
5610                         return;
5611                 
5612                 }
5613         
5614         }
5615         
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