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