Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced string processing in GEO with ProcessStringValue.
[xestiaab/.git] / source / contacteditor / ContactDataObject.cpp
1 // ContactDataObject.cpp - Client Data Object.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
22         
23         if (!wxFileExists(Filename)){
24         
25                 return CONTACTLOAD_FILEMISSING;
26         
27         }
28         
29         wxFile ContactFile;
30         
31         if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
32         
33                 return CONTACTLOAD_FILEERROR;
34         
35         }
36         
37         // Check that the vCard is a valid vCard 4.0 file.
39         vCard vCard4FormatCheck;
40         
41         vCard4FormatCheck.LoadFile(Filename);
42         
43         if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
44         
45                 return CONTACTLOAD_FILEINVALIDFORMAT;
46         
47         }
49         // Check that the vCard meets the base specification.
50         
51         if (!vCard4FormatCheck.MeetBaseSpecification()){
52         
53                 return CONTACTLOAD_FILEBASESPECFAIL;
54         
55         }
56         
57         wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
58         
59         std::map<int, wxString> ContactFileLines;
61         int ContactLineSeek = 0;
63         while (wSTContactFileLines.HasMoreTokens() == TRUE){
65                 wxString ContactLine = wSTContactFileLines.GetNextToken();
66                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
67                 ContactLineSeek++;              
68         
69         }
70         
71         wxString wxSPropertyNextLine;
72         
73         bool ExtraLineSeek = TRUE;
74         bool QuoteMode = FALSE;
75         bool PropertyFind = TRUE;
76         bool KindProcessed = FALSE;
77         bool NameProcessed = FALSE;
78         bool GenderProcessed = FALSE;
79         bool BirthdayProcessed = FALSE;
80         bool AnniversaryProcessed = FALSE;
81         bool UIDProcessed = FALSE;
82         bool RevisionProcessed = FALSE;
83         int ContactLineLen = 0;
84         int QuoteBreakPoint = 0;
85         int SourceCount = 0;
86         int GroupCount = 0;
87         int FNCount = 0;
88         int NicknameCount = 0;
89         int TimeZoneCount = 0;
90         int AddressCount = 0;
91         int EmailCount = 0;
92         int IMCount = 0;
93         int TelephoneCount = 0;
94         int LanguageCount = 0;
95         int GeographicCount = 0;
96         int RelatedCount = 0;
97         int URLCount = 0;
98         int TitleCount = 0;
99         int RoleCount = 0;
100         int OrganisationCount = 0;
101         int NoteCount = 0;
102         int CategoryCount = 0;
103         int PhotoCount = 0;
104         int LogoCount = 0;
105         int SoundCount = 0;
106         int CalendarCount = 0;
107         int CalendarAddressCount = 0;
108         int FreeBusyAddressCount = 0;
109         int KeyCount = 0;
110         int VendorCount = 0;
111         int XTokenCount = 0;
112         int XMLCount = 0;
113         int ClientPIDCount = 0;
114         wxString ContactLine;
115         wxString PropertyLine;
116         wxString PropertySeg1;
117         wxString PropertySeg2;
118         wxString PropertyNextLine;
119         wxString Property;
120         
121         for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
122          iter != ContactFileLines.end(); ++iter){
124                 ExtraLineSeek = TRUE;
125                 QuoteMode = FALSE;
126                 PropertyFind = TRUE;
127                 ContactLineLen = 0;
128                 QuoteBreakPoint = 0;
129                 ContactLine.Clear();
130                 PropertyLine.Clear();
131                 PropertySeg1.Clear();
132                 PropertySeg2.Clear();
133                 Property.Clear();
134          
135                 ContactLine = iter->second;
136                 
137                 while (ExtraLineSeek == TRUE){
138                 
139                         // Check if there is extra data on the next line 
140                         // (indicated by space or tab at the start) and add data.
141                 
142                         iter++;
143                         
144                         if (iter == ContactFileLines.end()){
145                         
146                                 iter--;
147                                 break;
148                         
149                         }                       
150                 
151                         PropertyNextLine = iter->second;
152                 
153                         if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
154                 
155                                 PropertyNextLine.Remove(0, 1);
156                                 ContactLine.Append(PropertyNextLine);
157                 
158                         } else {
159                         
160                                 iter--;
161                                 ExtraLineSeek = FALSE;
162                         
163                         }
164                 
165                 }
167                 ContactLineLen = ContactLine.Len();
168                 
169                 // Make sure we are not in quotation mode.
170                 // Make sure colon does not have \ or \\ before it.
171                 
172                 for (int i = 0; i <= ContactLineLen; i++){
173                 
174                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
175                         
176                                 PropertyFind = FALSE;
177                         
178                         } else if (PropertyFind == TRUE){
179                         
180                                 Property.Append(ContactLine.Mid(i, 1));
181                         
182                         }               
183                 
184                         if (ContactLine.Mid(i, 1) == wxT("\"")){
185                         
186                                 if (QuoteMode == TRUE){
187                                 
188                                         QuoteMode = FALSE;
189                                 
190                                 } else {
191                         
192                                         QuoteMode = TRUE;
193                                         
194                                 }
195                         
196                         }
197                         
198                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
199                         
200                                 QuoteBreakPoint = i;
201                                 break;
202                         
203                         }
204                 
205                 }
206                 
207                 // Split that line at the point into two variables (ignore the colon).
208                 
209                 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210                 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
211                 
212                  if (Property == wxT("KIND") && KindProcessed == FALSE){
213                                 
214                         ProcessKind(PropertySeg2);
215                 
216                 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
217                 
218                         UIDToken = PropertySeg2;
219                         UIDProcessed = TRUE;
220                 
221                 } else if (Property == wxT("SOURCE")){
222                 
223                         ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
224                         SourceCount++;
225                 
226                 } else if (Property == wxT("XML")){
227                 
228                         ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
229                         XMLCount++;
230                 
231                 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
232                 
233                         ProcessRevision(PropertySeg1, PropertySeg2);
234                         RevisionProcessed = TRUE;
235                 
236                 } else if (Property == wxT("MEMBER")){
238                         ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
239                         GroupCount++;   
240                 
241                 } else if (Property == wxT("FN")){
242                 
243                         ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
244                         FNCount++;
245                 
246                 } else if (Property == wxT("N") && NameProcessed == FALSE){
247                 
248                         ProcessN(PropertySeg1, PropertySeg2);
249                         NameProcessed = TRUE;
250                 
251                 } else if (Property == wxT("CLIENTPIDMAP")){
252                 
253                         ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
254                         ClientPIDCount++;
255                 
256                 } else if (Property == wxT("NICKNAME")){
257                                                 
258                         ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
259                         NicknameCount++;
260                         
261                 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
262                 
263                         ProcessGender(PropertySeg1, PropertySeg2);
264                         GenderProcessed = TRUE;
265                 
266                 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
267                 
268                         ProcessBirthday(PropertySeg1, PropertySeg2);
269                         BirthdayProcessed = TRUE;
270                 
271                 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
272                 
273                         ProcessAnniversary(PropertySeg1, PropertySeg2);
274                         AnniversaryProcessed = TRUE;
275                 
276                 } else if (Property == wxT("TZ")){
277                 
278                         ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
279                         TimeZoneCount++;
280                 
281                 } else if (Property == wxT("ADR")){
282                 
283                         ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
284                         AddressCount++;
285                 
286                 } else if (Property == wxT("EMAIL")){
287                                         
288                         ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);  
289                         EmailCount++;
290                 
291                 } else if (Property == wxT("IMPP")){
292                 
293                         ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
294                         IMCount++;
295                         
296                 } else if (Property == wxT("TEL")){
297                                 
298                         ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
299                         TelephoneCount++;
300                 
301                 } else if (Property == wxT("LANG")){
302                 
303                         // See frmContactEditor-LoadLanguage.cpp
304                         
305                         ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
306                         LanguageCount++;
307                 
308                 } else if (Property == wxT("GEO")){
309                 
310                         // See frmContactEditor-LoadGeo.cpp
311                         
312                         ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);        
313                         GeographicCount++;
314                 
315                 } else if (Property == wxT("RELATED")){
316                         
317                         // See fromContactEditor-LoadRelated.cpp
318                         
319                         ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);              
320                         RelatedCount++;
321                         
322                 } else if (Property == wxT("URL")){
324                         // See frmContactEditor-LoadURL.cpp
325                 
326                         ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
327                         URLCount++;
328                 
329                 } else if (Property == wxT("TITLE")) {
330                 
331                         // See frmContactEditor-LoadTitle.cpp
332                         
333                         ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
334                         TitleCount++;
335                         
336                 } else if (Property == wxT("ROLE")) {
337                 
338                         // See frmContactEditor-LoadTitle.cpp
339                         
340                         ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
341                         RoleCount++;
342                         
343                 } else if (Property == wxT("ORG")) {
344                 
345                         // See frmContactEditor-LoadOrg.cpp
346                         
347                         ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
348                         OrganisationCount++;
349                         
350                 } else if (Property == wxT("NOTE")) {
352                         // See frmContactEditor-LoadNote.cpp
354                         ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
355                         NoteCount++;    
356                         
357                 } else if (Property == wxT("CATEGORIES")) {
358                 
359                         // See frmContactEditor-LoadCategory.cpp
360                 
361                         ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);    
362                         CategoryCount++;
363                         
364                 } else if (Property == wxT("PHOTO")) {
365                 
366                         // See frmContactEditor-LoadPhoto.cpp
367                         
368                         ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
369                         PhotoCount++;
371                 } else if (Property == wxT("LOGO")) {
372                 
373                         // See frmContactEditor-LoadPhoto.cpp
374                         
375                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
376                         LogoCount++;
378                 } else if (Property == wxT("LOGO")) {
379                 
380                         // See frmContactEditor-LoadPhoto.cpp
381                         
382                         ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
383                         LogoCount++;
385                 } else if (Property == wxT("SOUND")) {
386                 
387                         // See frmContactEditor-LoadSound.cpp
388                         
389                         ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
390                         SoundCount++;
391                         
392                 } else if (Property == wxT("CALURI")){
394                         // See frmContactEditor-LoadCalendar.cpp
395                         
396                         ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
397                         CalendarCount++;
398                 
399                 } else if (Property == wxT("CALADRURI")){
400                 
401                         ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402                         CalendarAddressCount++;
403                 
404                 } else if (Property == wxT("FBURL")){
406                         // See frmContactEditor-LoadCalendar.cpp
408                         ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409                         FreeBusyAddressCount++;
411                 } else if (Property == wxT("KEY")){
412                 
413                         // See frmContactEditor-LoadKey.cpp
414                         
415                         ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
416                         KeyCount++;
417                 
418                 } else if (Property.Mid(0, 3) == wxT("VND")){
419                 
420                         ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
421                         VendorCount++;
422                 
423                 } else if (Property.Mid(0, 2) == wxT("X-")){
424                         
425                         XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426                         XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
427                         XTokenCount++;
428                 
429                 }
430                 
431         }
432         
433         return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439         if (KindType == wxT("individual")){
440                         
441                 ContactKind = CONTACTKIND_INDIVIDUAL;
442                         
443         } else if (KindType == wxT("group")){
444                         
445                 ContactKind = CONTACTKIND_GROUP;
446                         
447         } else if (KindType == wxT("org")){
448                         
449                 ContactKind = CONTACTKIND_ORGANISATION;
450                         
451         } else if (KindType == wxT("location")){
452                         
453                 ContactKind = CONTACTKIND_LOCATION;
454                         
455         } else {
456                         
457                 ContactKind = CONTACTKIND_NONE;                 
458         }
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464         size_t intPropertyLen = PropertySeg1.Len();
465         std::map<int, int> SplitPoints;
466         std::map<int, int> SplitLength;
467         std::map<int, int>::iterator SLiter;                    
468         wxString PropertyData;
469         wxString PropertyName;
470         wxString PropertyValue;
471         wxString PropertyTokens;
472         bool FirstToken = TRUE;
473         int intSplitsFound = 0;
474         int intSplitSize = 0;
475         int intPrevValue = 5;
476         int intPref = 0;                        
477         int intType = 0;
478         
479         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
480         
481         intPrevValue = 4;
483         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
484         intiter != SplitPoints.end(); ++intiter){
485         
486                 SLiter = SplitLength.find(intiter->first);
487         
488                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
489                 
490                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
491                 PropertyName = PropertyElement.GetNextToken();                          
492                 PropertyValue = PropertyElement.GetNextToken();
493                 
494                 intPrevValue = intiter->second;
495                 
496                 // Process properties.
497                 
498                 size_t intPropertyValueLen = PropertyValue.Len();
499                 
500                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
501                         
502                         PropertyValue.Trim();
503                         PropertyValue.RemoveLast();
504                         
505                 }                               
506                 
507                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
508                         
509                         PropertyValue.Remove(0, 1);
510                         
511                 }                       
512                 
513                 CaptureString(&PropertyValue, FALSE);
514                                                                 
515                 if (FirstToken == TRUE){
516                                 
517                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
518                         FirstToken = FALSE;
519                                 
520                 } else {
521                                 
522                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
523                                 
524                 }
525         
526         }       
527         
528         CaptureString(&PropertySeg2, FALSE);
529         
530         Revision = PropertySeg2;
531         
532         if (!PropertyTokens.IsEmpty()){
533         
534                 RevisionTokens = PropertyTokens;
535         
536         }
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543         size_t intPropertyLen = PropertySeg1.Len();
544         std::map<int, int> SplitPoints;
545         std::map<int, int> SplitLength;
546         std::map<int, int>::iterator SLiter;                    
547         wxString PropertyData;
548         wxString PropertyName;
549         wxString PropertyValue;
550         wxString PropertyTokens;
551         bool FirstToken = TRUE;
552         bool PropertyMatched = FALSE;
553         int intSplitsFound = 0;
554         int intSplitSize = 0;
555         int intPrevValue = 8;
556         int intPref = 0;                        
557         int intType = 0;
558         
559         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
560         
561         intPrevValue = 7;
562         
563         PropertyType PropType = PROPERTY_NONE;
564         
565         // Look for type before continuing.                     
567         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
569         intPrevValue = 7;
571         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
572         intiter != SplitPoints.end(); ++intiter){
573         
574                 SLiter = SplitLength.find(intiter->first);
575         
576                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
577                 
578                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
579                 PropertyName = PropertyElement.GetNextToken();                          
580                 PropertyValue = PropertyElement.GetNextToken();
581                 
582                 intPrevValue = intiter->second;
583                 
584                 // Process properties.
585                 
586                 size_t intPropertyValueLen = PropertyValue.Len();
587                 
588                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
589                         
590                         PropertyValue.Trim();
591                         PropertyValue.RemoveLast();
592                         
593                 }                               
594                 
595                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
596                         
597                         PropertyValue.Remove(0, 1);
598                         
599                 }                       
600                 
601                 CaptureString(&PropertyValue, FALSE);
602                 
603                 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
604                 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
605                 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
606                 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
607                 
608                 if (PropertyMatched == TRUE){
609                 
610                         PropertyMatched = FALSE;
611                         continue;
612                 
613                 }
614                 
615                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
616                         
617                         if (FirstToken == TRUE){
618                                 
619                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
620                                 FirstToken = FALSE;
621                         
622                         } else {
623                         
624                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
625                         
626                         }
627                 
628                 }
629         
630         }       
631         
632         intPropertyLen = PropertySeg2.Len();
633         SplitPoints.clear();
634         SplitLength.clear();
635         intSplitsFound = 0;
636         intSplitSize = 0;
637         intPrevValue = 0;
638         
639         CaptureString(&PropertySeg2, FALSE);
640         
641         // Add the data to the General/Home/Work address variables.
642                 
643         switch(PropType){
644                 case PROPERTY_NONE:
645                         break;
646                 case PROPERTY_HOME:
647                         SourceListType.insert(std::make_pair(*SourceCount, "home"));
648                         break;
649                 case PROPERTY_WORK:
650                         SourceListType.insert(std::make_pair(*SourceCount, "work"));
651                         break;
652         }
653         
654         SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
655         
656         if (!PropertyTokens.IsEmpty()){
657         
658                 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
659         
660         }
664 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
666         std::map<int, int> SplitPoints;
667         std::map<int, int> SplitLength;
669         int intPrevValue = 5;
670         int intPref = 0;                        
671         int intType = 0;
672         
673         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
675         intPrevValue = 4;
676         
677         wxString PropertyName;
678         wxString PropertyValue;
679         wxString PropertyData;
680         wxString PropertyTokens;
681         std::map<int,int>::iterator SLiter;
682         bool FirstToken = TRUE;
683         bool PropertyMatched = FALSE;
684         
685         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
686         intiter != SplitPoints.end(); ++intiter){
687         
688                 SLiter = SplitLength.find(intiter->first);
689         
690                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
691                 
692                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
693                 PropertyName = PropertyElement.GetNextToken();                          
694                 PropertyValue = PropertyElement.GetNextToken();
695                 
696                 intPrevValue = intiter->second;
697                 
698                 CaptureString(&PropertyValue, FALSE);
699         
700                 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
701                 
702                 if (PropertyMatched == TRUE){
703                 
704                         PropertyMatched = FALSE;
705                         continue;
706                 
707                 }
708                 
709         }
711         XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
715 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
717         std::map<int, int> SplitPoints;
718         std::map<int, int> SplitLength;
720         int intPrevValue = 8;
721         int intPref = 0;                        
722         int intType = 0;
723         
724         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
726         intPrevValue = 7;
727         
728         wxString PropertyName;
729         wxString PropertyValue;
730         wxString PropertyData;
731         wxString PropertyTokens;
732         std::map<int,int>::iterator SLiter;
733         bool FirstToken = TRUE;
734         bool PropertyMatched = FALSE;
735         
736         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
737         intiter != SplitPoints.end(); ++intiter){
738         
739                 SLiter = SplitLength.find(intiter->first);
740         
741                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
742                 
743                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
744                 PropertyName = PropertyElement.GetNextToken();                          
745                 PropertyValue = PropertyElement.GetNextToken();
746                 
747                 intPrevValue = intiter->second;
748                 
749                 CaptureString(&PropertyValue, FALSE);
750         
751                 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
752                 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
753                 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
754                 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
755                 
756                 if (PropertyMatched == TRUE){
757                 
758                         PropertyMatched = FALSE;
759                         continue;
760                 
761                 }
762                 
763                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
764                         
765                         if (FirstToken == TRUE){
766                                 
767                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
768                                 FirstToken = FALSE;
769                                 
770                         } else {
771                         
772                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
773                                 
774                         }
775                         
776                 }
777                 
778         }
780         GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
782         if (!PropertyTokens.IsEmpty()){
783         
784                 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
785         
786         }
791 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
793         std::map<int, int> SplitPoints;
794         std::map<int, int> SplitLength;
796         int intPrevValue = 4;
797         int intPref = 0;                        
798         int intType = 0;
799         
800         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
802         intPrevValue = 3;
803         
804         wxString PropertyName;
805         wxString PropertyValue;
806         wxString PropertyData;
807         wxString PropertyTokens;
808         std::map<int,int>::iterator SLiter;
809         bool FirstToken = TRUE;
810         bool PropertyMatched = FALSE;
811         
812         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
813         intiter != SplitPoints.end(); ++intiter){
814         
815                 SLiter = SplitLength.find(intiter->first);
816         
817                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
818                 
819                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
820                 PropertyName = PropertyElement.GetNextToken();                          
821                 PropertyValue = PropertyElement.GetNextToken();
822                 
823                 intPrevValue = intiter->second;
824                 
825                 CaptureString(&PropertyValue, FALSE);
826                 
827                 if (PropertyName == wxT("TYPE")){
829                         if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
830                                 PropertyValue == wxT("work") ){
832                                 FullNamesListType.erase(*FNCount);
833                                 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
834                 
835                         }
836                         
837                         PropertyMatched = TRUE;
838                 
839                 }
840                 
841                 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
842                 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
843                 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
844                 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
845                 
846                 if (PropertyMatched == TRUE){
847                 
848                         PropertyMatched = FALSE;
849                         continue;
850                 
851                 }
852                 
853                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
854                         
855                         if (FirstToken == TRUE){
856                                 
857                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
858                                 FirstToken = FALSE;
859                                 
860                         } else {
861                         
862                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
863                                 
864                         }
865                         
866                 } 
867         
868         }
870         FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
872         if (!PropertyTokens.IsEmpty()){
873         
874                 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
875         
876         }
880 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
882         std::map<int, int> SplitPoints;
883         std::map<int, int> SplitLength;
885         int intPrevValue = 3;
886         int intPref = 0;                        
887         int intType = 0;
888         
889         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
890         
891         intPrevValue = 2;
892         
893         wxString PropertyName;
894         wxString PropertyValue;
895         wxString PropertyData;
896         wxString PropertyTokens;
897         std::map<int,int>::iterator SLiter;
898         bool FirstToken = TRUE;
899         
900         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
901         intiter != SplitPoints.end(); ++intiter){
902         
903                 SLiter = SplitLength.find(intiter->first);
904         
905                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
906                 
907                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
908                 PropertyName = PropertyElement.GetNextToken();                          
909                 PropertyValue = PropertyElement.GetNextToken();
910                 
911                 intPrevValue = intiter->second;
912                 
913                 CaptureString(&PropertyValue, FALSE);
914                 
915                 if (PropertyName == wxT("ALTID")){
917                         NameAltID = PropertyValue;
918                 
919                 } else if (PropertyName == wxT("LANGUAGE")){
920                 
921                         NameLanguage = PropertyValue;
922                 
923                 } else if (PropertyName == wxT("SORT-AS")){
924                 
925                         if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
926                                 PropertyValue.Len() >= 3){
927                                 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
928                         }
929                 
930                 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
931                         
932                         if (FirstToken == TRUE){
933                                 
934                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
935                                 FirstToken = FALSE;
936                                 
937                         } else {
938                         
939                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
940                                 
941                         }
942                         
943                 }
944         
945         }
946         
947         // Split the name data.
948         
949         int intSplitSeek = 0;           
950         int intSplitsFound = 0;
951         int intSplitSize = 0;
952         int intPropertyLen = PropertySeg2.Len();
953         
954         std::map<int,wxString> NameValues;
955         intPrevValue = 0;                                       
956         
957         for (int i = 0; i <= intPropertyLen; i++){
958         
959                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
960                         
961                         NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
962                         
963                         intSplitSeek = i;
964                         intSplitSeek++;
965                         
966                         if (intSplitsFound == 4){
967                         
968                                 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
969                                 break;
970                         
971                         }
972                         
973                         intSplitSize = 0;
974                         continue;
975         
976                 }
977                 
978                 intSplitSize++;
980         }
981         
982         // Split the data into several parts.
983                         
984         for (std::map<int, wxString>::iterator iter = NameValues.begin(); 
985         iter != NameValues.end(); ++iter){
986         
987                 if (iter->first == 1){
988                 
989                         // Deal with family name.
990                         
991                         NameSurname = iter->second;
992                 
993                 } else if (iter->first == 2){
994                 
995                         // Deal with given names.
996                         
997                         NameForename = iter->second;
998                 
999                 } else if (iter->first == 3){
1000                 
1001                         // Deal with additional names.
1002                         
1003                         NameOtherNames = iter->second;
1004                 
1005                 } else if (iter->first == 4){
1006                 
1007                         // Deal with honorifix prefixes and suffixes.
1009                         NameTitle = iter->second;
1010                 
1011                         iter++;
1012                         
1013                         if (iter == NameValues.end()){
1014                         
1015                                 break;
1016                         
1017                         }
1018                 
1019                         NameSuffix = iter->second;
1020                 
1021                 }
1022         
1023         }
1024         
1025         // Add the name token data.
1026         
1027         if (!PropertyTokens.IsEmpty()){
1028         
1029                 NameTokens = PropertyTokens;
1030         
1031         }
1035 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1037         size_t intPropertyLen = PropertySeg1.Len();
1038         std::map<int, int> SplitPoints;
1039         std::map<int, int> SplitLength;
1040         std::map<int, int>::iterator SLiter;                    
1041         wxString PropertyData;
1042         wxString PropertyName;
1043         wxString PropertyValue;
1044         wxString PropertyTokens;
1045         bool FirstToken = TRUE;
1046         int intSplitsFound = 0;
1047         int intSplitSize = 0;
1048         int intPrevValue = 14;
1049         int intPref = 0;                        
1050         int intType = 0;
1051         
1052         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1053         
1054         intPrevValue = 13;
1056         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1057         intiter != SplitPoints.end(); ++intiter){
1058         
1059                 SLiter = SplitLength.find(intiter->first);
1060         
1061                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1062                 
1063                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1064                 PropertyName = PropertyElement.GetNextToken();                          
1065                 PropertyValue = PropertyElement.GetNextToken();
1066                 
1067                 intPrevValue = intiter->second;
1068                 
1069                 // Process properties.
1070                                 
1071                 CaptureString(&PropertyValue, FALSE);
1072                                         
1073                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1074                                                         
1075                         if (FirstToken == TRUE){
1076                                 
1077                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1078                                 FirstToken = FALSE;
1079                                 
1080                         } else {
1081                                 
1082                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1083                                 
1084                         }
1085                 
1086                 }
1087         
1088         }       
1089         
1090         CaptureString(&PropertySeg2, FALSE);
1091         
1092         ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1093         
1094         if (!PropertyTokens.IsEmpty()){
1095         
1096                 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1097         
1098         }
1102 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1104         std::map<int, int> SplitPoints;
1105         std::map<int, int> SplitLength;
1107         int intPrevValue = 10;
1108         int intPref = 0;                        
1109         
1110         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1111         
1112         intPrevValue = 9;
1113         
1114         PropertyType PropType = PROPERTY_NONE;
1115         
1116         // Look for type before continuing.
1117         
1118         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1119         
1120         intPrevValue = 9;
1121         
1122         std::map<int, wxString> *NicknamesList = NULL;
1123         std::map<int, wxString> *NicknamesListType = NULL;
1124         std::map<int, wxString> *NicknamesListLanguage = NULL;
1125         std::map<int, wxString> *NicknamesListAltID = NULL;
1126         std::map<int, wxString> *NicknamesListPID = NULL;
1127         std::map<int, wxString> *NicknamesListTokens = NULL;            
1128         std::map<int, int> *NicknamesListPref = NULL;
1129         
1130         switch(PropType){
1131                 case PROPERTY_NONE:
1132                         NicknamesList = &GeneralNicknamesList;
1133                         NicknamesListType = &GeneralNicknamesListType;
1134                         NicknamesListLanguage = &GeneralNicknamesListLanguage;
1135                         NicknamesListAltID = &GeneralNicknamesListAltID;
1136                         NicknamesListPID = &GeneralNicknamesListPID;
1137                         NicknamesListTokens = &GeneralNicknamesListTokens;
1138                         NicknamesListPref = &GeneralNicknamesListPref;
1139                         break;
1140                 case PROPERTY_HOME:
1141                         NicknamesList = &HomeNicknamesList;
1142                         NicknamesListType = &HomeNicknamesListType;
1143                         NicknamesListLanguage = &HomeNicknamesListLanguage;
1144                         NicknamesListAltID = &HomeNicknamesListAltID;
1145                         NicknamesListPID = &HomeNicknamesListPID;
1146                         NicknamesListTokens = &HomeNicknamesListTokens;
1147                         NicknamesListPref = &HomeNicknamesListPref;
1148                         break;
1149                 case PROPERTY_WORK:
1150                         NicknamesList = &BusinessNicknamesList;
1151                         NicknamesListType = &BusinessNicknamesListType;
1152                         NicknamesListLanguage = &BusinessNicknamesListLanguage;
1153                         NicknamesListAltID = &BusinessNicknamesListAltID;
1154                         NicknamesListPID = &BusinessNicknamesListPID;
1155                         NicknamesListTokens = &BusinessNicknamesListTokens;
1156                         NicknamesListPref = &BusinessNicknamesListPref;
1157                         break;
1158         }
1159         
1160         std::map<int, int>::iterator SLiter;    
1161         wxString PropertyData;
1162         wxString PropertyName;
1163         wxString PropertyValue;
1164         wxString PropertyTokens;
1165         bool FirstToken = TRUE;
1166         bool PropertyMatched = FALSE;
1167         
1168         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1169         intiter != SplitPoints.end(); ++intiter){
1170         
1171                 SLiter = SplitLength.find(intiter->first);
1172         
1173                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1174                 
1175                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1176                 PropertyName = PropertyElement.GetNextToken();                          
1177                 PropertyValue = PropertyElement.GetNextToken();
1178                 
1179                 intPrevValue = intiter->second;
1180                 
1181                 CaptureString(&PropertyValue, FALSE);
1182                 
1183                 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1184                 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1185                 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1186                 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1187                 
1188                 if (PropertyMatched == TRUE){
1189                 
1190                         PropertyMatched = FALSE;
1191                         continue;
1192                 
1193                 }
1194                 
1195                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1196         
1197                         if (FirstToken == TRUE){
1198                 
1199                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1200                                 FirstToken = FALSE;
1201                 
1202                         } else {
1203                 
1204                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1205                 
1206                         }
1207         
1208                 }
1209                 
1210         }
1211         
1212         NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1213         
1214         // Add the name token data.
1215         
1216         if (!PropertyTokens.IsEmpty()){
1217         
1218                 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1219         
1220         }
1224 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1226         std::map<int, int> SplitPoints;
1227         std::map<int, int> SplitLength;
1228         std::map<int, int>::iterator SLiter;                    
1229         wxString PropertyData;
1230         wxString PropertyName;
1231         wxString PropertyValue;
1232         wxString PropertyTokens;
1233         bool FirstToken = TRUE;
1234         int intPrevValue = 8;
1236         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1238         intPrevValue = 7;                       
1239         
1240         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1241         intiter != SplitPoints.end(); ++intiter){
1242         
1243                 SLiter = SplitLength.find(intiter->first);
1244         
1245                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1246                 
1247                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1248                 PropertyName = PropertyElement.GetNextToken();                          
1249                 PropertyValue = PropertyElement.GetNextToken();
1250                 
1251                 intPrevValue = intiter->second;
1252                 
1253                 // Process properties.
1254                 
1255                 size_t intPropertyValueLen = PropertyValue.Len();
1256                 
1257                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1258                         
1259                         PropertyValue.Trim();
1260                         PropertyValue.RemoveLast();
1261                         
1262                 }                               
1263                 
1264                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1265                         
1266                         PropertyValue.Remove(0, 1);
1267                         
1268                 }                               
1269                 
1270                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1272                         if (FirstToken == TRUE){
1273         
1274                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1275                                 FirstToken = FALSE;
1276         
1277                         } else {
1278         
1279                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1280         
1281                         }
1283                 }
1284         
1285         }       
1287         wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1288         
1289         wxString GenderComponent;
1290         
1291         if (GenderData.CountTokens() >= 2){
1292         
1293                 Gender = GenderData.GetNextToken();
1294                 GenderDetails = GenderData.GetString();
1295         
1296                 CaptureString(&GenderDetails, FALSE);
1297                                                 
1298         } else {
1299         
1300                 Gender = GenderData.GetNextToken();
1301         
1302         }
1303         
1304         if (!PropertyTokens.IsEmpty()){
1305         
1306                 GenderTokens = PropertyTokens;
1307         
1308         }
1312 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1314         // Process date. Preserve the remainder in the string.
1316         std::map<int, int> SplitPoints;
1317         std::map<int, int> SplitLength;
1318         std::map<int, int>::iterator SLiter;                    
1319         wxString PropertyData;
1320         wxString PropertyName;
1321         wxString PropertyValue;
1322         wxString PropertyTokens;
1323         bool BirthdayText = FALSE;
1324         int intPrevValue = 6;
1326         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1328         intPrevValue = 5;
1330         // Look for type before continuing.
1332         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1333         intiter != SplitPoints.end(); ++intiter){
1335                 SLiter = SplitLength.find(intiter->first);
1337                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1338         
1339                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1340                 PropertyName = PropertyElement.GetNextToken();                          
1341                 PropertyValue = PropertyElement.GetNextToken();
1342         
1343                 intPrevValue = intiter->second;
1344         
1345                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1346         
1347                         CaptureString(&PropertySeg2, FALSE);
1348                         Birthday = PropertySeg2;
1349                         BirthdayText = TRUE;
1350         
1351                 }
1353         }
1355         // Setup blank lines for later on.
1356         
1357         intPrevValue = 5;
1358         bool FirstToken = TRUE;
1360         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1361         intiter != SplitPoints.end(); ++intiter){
1363                 SLiter = SplitLength.find(intiter->first);
1365                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1366         
1367                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1368                 PropertyName = PropertyElement.GetNextToken();                          
1369                 PropertyValue = PropertyElement.GetNextToken();
1370         
1371                 intPrevValue = intiter->second;
1372         
1373                 // Process properties.
1374         
1375                 CaptureString(&PropertyValue, FALSE);
1376         
1377                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1378                 
1379                         PropertyValue.Trim();
1380                         PropertyValue.RemoveLast();
1381                 
1382                 }                               
1383         
1384                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1385                 
1386                         PropertyValue.Remove(0, 1);
1387                 
1388                 }                               
1389         
1390                 if (PropertyName == wxT("ALTID")){
1392                         BirthdayAltID = PropertyValue;
1393         
1394                 } else if (PropertyName == wxT("CALSCALE")){
1395         
1396                         BirthdayCalScale = PropertyValue;
1397         
1398                 } else if (PropertyName != wxT("VALUE")) {
1399         
1400                         // Something else we don't know about so append
1401                         // to the tokens variable.
1402                 
1403                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1404                 
1405                                 if (FirstToken == TRUE){
1406         
1407                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1408                                         FirstToken = FALSE;
1409         
1410                                 } else {
1411         
1412                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1413         
1414                                 }
1415                                 
1416                         }
1417                         
1418                 }
1420         }       
1422         // Add the data to the variables and form.
1423         
1424         if (BirthdayText == FALSE){
1425         
1426                 Birthday = PropertySeg2;
1428         }
1429         
1430         if (!PropertyTokens.IsEmpty()){
1431         
1432                 BirthdayTokens = PropertyTokens;
1434         }
1438 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1440         // Process date. Preserve the remainder in the string.
1442         std::map<int, int> SplitPoints;
1443         std::map<int, int> SplitLength;
1444         std::map<int, int>::iterator SLiter;                    
1445         wxString PropertyData;
1446         wxString PropertyName;
1447         wxString PropertyValue;
1448         wxString PropertyTokens;
1449         bool AnniversaryText = FALSE;
1450         int intPrevValue = 13;
1452         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1454         intPrevValue = 12;
1456         // Look for type before continuing.
1458         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1459         intiter != SplitPoints.end(); ++intiter){
1461                 SLiter = SplitLength.find(intiter->first);
1463                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1464         
1465                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1466                 PropertyName = PropertyElement.GetNextToken();                          
1467                 PropertyValue = PropertyElement.GetNextToken();
1468         
1469                 intPrevValue = intiter->second;
1470         
1471                 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1472         
1473                         CaptureString(&PropertySeg2, FALSE);
1474                         Anniversary = PropertySeg2;
1475                         AnniversaryText = TRUE;
1476         
1477                 }
1479         }
1481         // Setup blank lines for later on.
1482         
1483         intPrevValue = 12;
1484         bool FirstToken = TRUE;
1486         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1487         intiter != SplitPoints.end(); ++intiter){
1489                 SLiter = SplitLength.find(intiter->first);
1491                 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1492         
1493                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1494                 PropertyName = PropertyElement.GetNextToken();                          
1495                 PropertyValue = PropertyElement.GetNextToken();
1496         
1497                 intPrevValue = intiter->second;
1498         
1499                 // Process properties.
1500         
1501                 CaptureString(&PropertyValue, FALSE);
1502         
1503                 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1504                 
1505                         PropertyValue.Trim();
1506                         PropertyValue.RemoveLast();
1507                 
1508                 }                               
1509         
1510                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1511                 
1512                         PropertyValue.Remove(0, 1);
1513                 
1514                 }                               
1515         
1516                 if (PropertyName == wxT("ALTID")){
1518                         AnniversaryAltID = PropertyValue;
1519         
1520                 } else if (PropertyName == wxT("CALSCALE")){
1521         
1522                         AnniversaryCalScale = PropertyValue;
1523         
1524                 } else if (PropertyName != wxT("VALUE")) {
1525         
1526                         // Something else we don't know about so append
1527                         // to the tokens variable.
1528                 
1529                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1530                 
1531                                 if (FirstToken == TRUE){
1532         
1533                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1534                                         FirstToken = FALSE;
1535         
1536                                 } else {
1537         
1538                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1539         
1540                                 }
1541                                 
1542                         }
1543                         
1544                 }
1546         }       
1548         // Add the data to the variables and form.
1549         
1550         if (AnniversaryText == FALSE){
1551         
1552                 Anniversary = PropertySeg2;
1554         }
1555         
1556         if (!PropertyTokens.IsEmpty()){
1557         
1558                 AnniversaryTokens = PropertyTokens;
1560         }
1564 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1566         std::map<int, int> SplitPoints;
1567         std::map<int, int> SplitLength;
1569         int intPrevValue = 4;
1570         int intPref = 0;                        
1571         
1572         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1573         
1574         intPrevValue = 3;
1575         
1576         PropertyType PropType = PROPERTY_NONE;
1577         
1578         // Look for type before continuing.
1579         
1580         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1581         
1582         intPrevValue = 3;
1583         
1584         std::map<int, wxString> *TZList = NULL;
1585         std::map<int, wxString> *TZListType = NULL;
1586         std::map<int, wxString> *TZListMediatype = NULL;
1587         std::map<int, wxString> *TZListAltID = NULL;
1588         std::map<int, wxString> *TZListPID = NULL;
1589         std::map<int, wxString> *TZListTokens = NULL;           
1590         std::map<int, int> *TZListPref = NULL;
1591         
1592         switch(PropType){
1593                 case PROPERTY_NONE:
1594                         TZList = &GeneralTZList;
1595                         TZListType = &GeneralTZListType;
1596                         TZListMediatype = &GeneralTZListMediatype;
1597                         TZListAltID = &GeneralTZListAltID;
1598                         TZListPID = &GeneralTZListPID;
1599                         TZListTokens = &GeneralTZListTokens;
1600                         TZListPref = &GeneralTZListPref;
1601                         break;
1602                 case PROPERTY_HOME:
1603                         TZList = &HomeTZList;
1604                         TZListType = &HomeTZListType;
1605                         TZListMediatype = &HomeTZListMediatype;
1606                         TZListAltID = &HomeTZListAltID;
1607                         TZListPID = &HomeTZListPID;
1608                         TZListTokens = &HomeTZListTokens;
1609                         TZListPref = &HomeTZListPref;
1610                         break;
1611                 case PROPERTY_WORK:
1612                         TZList = &BusinessTZList;
1613                         TZListType = &BusinessTZListType;
1614                         TZListMediatype = &BusinessTZListMediatype;
1615                         TZListAltID = &BusinessTZListAltID;
1616                         TZListPID = &BusinessTZListPID;
1617                         TZListTokens = &BusinessTZListTokens;
1618                         TZListPref = &BusinessTZListPref;
1619                         break;
1620         }
1621         
1622         std::map<int, int>::iterator SLiter;    
1623         wxString PropertyData;
1624         wxString PropertyName;
1625         wxString PropertyValue;
1626         wxString PropertyTokens;
1627         bool FirstToken = TRUE;
1628         bool PropertyMatched = FALSE;
1629         
1630         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1631         intiter != SplitPoints.end(); ++intiter){
1632         
1633                 SLiter = SplitLength.find(intiter->first);
1634         
1635                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1636                 
1637                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1638                 PropertyName = PropertyElement.GetNextToken();                          
1639                 PropertyValue = PropertyElement.GetNextToken();
1640                 
1641                 intPrevValue = intiter->second;
1642                 
1643                 CaptureString(&PropertyValue, FALSE);
1645                 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1646                 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1647                 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1648                 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1649                 
1650                 if (PropertyMatched == TRUE){
1651                 
1652                         PropertyMatched = FALSE;
1653                         continue;
1654                 
1655                 }
1657                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1658         
1659                         if (FirstToken == TRUE){
1660                 
1661                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1662                                 FirstToken = FALSE;
1663                 
1664                         } else {
1665                 
1666                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1667                 
1668                         }
1669         
1670                 }
1671                 
1672         }
1673         
1674         TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1675         
1676         // Add the name token data.
1677         
1678         if (!PropertyTokens.IsEmpty()){
1679         
1680                 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1681         
1682         }
1687 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1689         size_t intPropertyLen = PropertySeg1.Len();
1690         std::map<int, int> SplitPoints;
1691         std::map<int, int> SplitLength;
1692         std::map<int, int>::iterator SLiter;                    
1693         wxString PropertyData;
1694         wxString PropertyName;
1695         wxString PropertyValue;
1696         wxString PropertyTokens;
1697         wxString AddressLabel;
1698         wxString AddressLang;
1699         wxString AddressAltID;
1700         wxString AddressPID;
1701         wxString AddressTokens;
1702         wxString AddressGeo;
1703         wxString AddressTimezone;
1704         wxString AddressType;
1705         wxString AddressMediatype;
1706         wxString AddressPOBox;
1707         wxString AddressExtended;
1708         wxString AddressStreet;
1709         wxString AddressLocality;
1710         wxString AddressCity;
1711         wxString AddressRegion;
1712         wxString AddressPostalCode;
1713         wxString AddressCountry;
1714         bool FirstToken = TRUE;                 
1715         int intSplitsFound = 0;
1716         int intSplitSize = 0;
1717         int intPrevValue = 5;
1718         int intPref = 0;                        
1719         int intType = 0;
1720         long ListCtrlIndex;
1721         bool PropertyMatched = FALSE;
1722         
1723         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1724         
1725         intPrevValue = 4;
1726         
1727         PropertyType PropType = PROPERTY_NONE;
1728                 
1729         // Look for type before continuing.
1730         
1731         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1732         
1733         intPrevValue = 4;
1734         
1735         std::map<int, wxString> *AddressList = NULL;
1736         std::map<int, wxString> *AddressListTown = NULL;
1737         std::map<int, wxString> *AddressListCounty = NULL;
1738         std::map<int, wxString> *AddressListPostCode = NULL;
1739         std::map<int, wxString> *AddressListCountry = NULL;
1740         std::map<int, wxString> *AddressListLabel = NULL;
1741         std::map<int, wxString> *AddressListLang = NULL;                
1742         std::map<int, wxString> *AddressListAltID = NULL;
1743         std::map<int, wxString> *AddressListPID = NULL;
1744         std::map<int, wxString> *AddressListTokens = NULL;
1745         std::map<int, wxString> *AddressListGeo = NULL;
1746         std::map<int, wxString> *AddressListTimezone = NULL;            
1747         std::map<int, wxString> *AddressListType = NULL;
1748         std::map<int, wxString> *AddressListMediatype = NULL;
1749         std::map<int, int> *AddressListPref = NULL;
1751         switch(PropType){
1752                 case PROPERTY_NONE:
1753                         AddressList = &GeneralAddressList;
1754                         AddressListTown = &GeneralAddressListTown;
1755                         AddressListCounty = &GeneralAddressListCounty;
1756                         AddressListPostCode = &GeneralAddressListPostCode;
1757                         AddressListCountry = &GeneralAddressListCountry;
1758                         AddressListLabel = &GeneralAddressListLabel;
1759                         AddressListLang = &GeneralAddressListLang;              
1760                         AddressListAltID = &GeneralAddressListAltID;
1761                         AddressListPID = &GeneralAddressListPID;
1762                         AddressListTokens = &GeneralAddressListTokens;
1763                         AddressListGeo = &GeneralAddressListGeo;
1764                         AddressListTimezone = &GeneralAddressListTimezone;
1765                         AddressListType = &GeneralAddressListType;
1766                         AddressListMediatype = &GeneralAddressListMediatype;
1767                         AddressListPref = &GeneralAddressListPref;              
1768                         break;
1769                 case PROPERTY_HOME:
1770                         AddressList = &HomeAddressList;
1771                         AddressListTown = &HomeAddressListTown;
1772                         AddressListCounty = &HomeAddressListCounty;
1773                         AddressListPostCode = &HomeAddressListPostCode;
1774                         AddressListCountry = &HomeAddressListCountry;
1775                         AddressListLabel = &HomeAddressListLabel;
1776                         AddressListLang = &HomeAddressListLang;         
1777                         AddressListAltID = &HomeAddressListAltID;
1778                         AddressListPID = &HomeAddressListPID;
1779                         AddressListTokens = &HomeAddressListTokens;
1780                         AddressListGeo = &HomeAddressListGeo;
1781                         AddressListTimezone = &HomeAddressListTimezone;
1782                         AddressListType = &HomeAddressListType;
1783                         AddressListMediatype = &HomeAddressListMediatype;
1784                         AddressListPref = &HomeAddressListPref;
1785                         break;
1786                 case PROPERTY_WORK:
1787                         AddressList = &BusinessAddressList;
1788                         AddressListTown = &BusinessAddressListTown;
1789                         AddressListCounty = &BusinessAddressListCounty;
1790                         AddressListPostCode = &BusinessAddressListPostCode;
1791                         AddressListCountry = &BusinessAddressListCountry;
1792                         AddressListLabel = &BusinessAddressListLabel;
1793                         AddressListLang = &BusinessAddressListLang;             
1794                         AddressListAltID = &BusinessAddressListAltID;
1795                         AddressListPID = &BusinessAddressListPID;
1796                         AddressListTokens = &BusinessAddressListTokens;
1797                         AddressListGeo = &BusinessAddressListGeo;
1798                         AddressListTimezone = &BusinessAddressListTimezone;
1799                         AddressListType = &BusinessAddressListType;
1800                         AddressListMediatype = &BusinessAddressListMediatype;
1801                         AddressListPref = &BusinessAddressListPref;
1802                         break;
1803         }
1804         
1805         intPrevValue = 4;
1806         
1807         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1808         intiter != SplitPoints.end(); ++intiter){
1809         
1810                 SLiter = SplitLength.find(intiter->first);
1811         
1812                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1813                 
1814                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1815                 PropertyName = PropertyElement.GetNextToken();                          
1816                 PropertyValue = PropertyElement.GetNextToken();
1817                 
1818                 intPrevValue = intiter->second;
1819                 
1820                 CaptureString(&PropertyValue, FALSE);
1821                 
1822                 // Process properties.
1823                 
1824                 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1825                 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1826                 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1827                 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1828                 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1829                 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1830                 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1831                 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1832                 
1833                 if (PropertyMatched == TRUE){
1834                 
1835                         PropertyMatched = FALSE;
1836                         continue;
1837                 
1838                 }
1839                 
1840                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1841                 
1842                         if (FirstToken == TRUE){
1843                         
1844                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1845                                 FirstToken = FALSE;
1846                         
1847                         } else {
1848                         
1849                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1850                         
1851                         }
1852                         
1853                 }
1854         
1855         }                       
1856         
1857         // Split the address. 
1859         //std::map<int, int>::iterator SLiter;
1860         intPropertyLen = PropertySeg2.Len();
1861         SplitPoints.clear();
1862         SplitLength.clear();
1863         intSplitsFound = 0;
1864         intSplitSize = 0;
1865         intPrevValue = 0;
1866         
1867         for (int i = 0; i <= intPropertyLen; i++){
1869                 intSplitSize++;
1870         
1871                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1872         
1873                         intSplitsFound++;
1874                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1875                         
1876                         if (intSplitsFound == 6){ 
1877                         
1878                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1879                                 break; 
1880                                 
1881                         } else {
1882                         
1883                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1884                         
1885                         }
1886                         
1887                         intSplitSize = 0;                                       
1888         
1889                 }
1891         }
1892         
1893         // Split the data into several parts.                   
1894         
1895         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
1896         intiter != SplitPoints.end(); ++intiter){
1897                         
1898                 if (intiter->first == 1){
1899                 
1900                         // Deal with PO Box.
1901                         
1902                         SLiter = SplitLength.find(1);
1903                                                                 
1904                         AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1905                         intPrevValue = intiter->second;
1906                 
1907                 } else if (intiter->first == 2){
1908                 
1909                         // Deal with extended address.
1910                         
1911                         SLiter = SplitLength.find(2);
1912                         
1913                         AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1914                         intPrevValue = intiter->second;
1915                 
1916                 } else if (intiter->first == 3){
1917                 
1918                         // Deal with street address.
1919                         
1920                         SLiter = SplitLength.find(3);
1921                                                                 
1922                         AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1923                         intPrevValue = intiter->second;
1924                 
1925                 } else if (intiter->first == 4){
1926                 
1927                         // Deal with locality
1929                         SLiter = SplitLength.find(4);
1930                         
1931                         AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1932                         intPrevValue = intiter->second;
1933                 
1934                 } else if (intiter->first == 5){
1935                 
1936                         // Deal with region.
1938                         SLiter = SplitLength.find(5);
1939                         
1940                         AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1941                         intPrevValue = intiter->second;
1942                         
1943                 
1944                 } else if (intiter->first == 6){
1945                 
1946                         // Deal with post code.
1948                         SLiter = SplitLength.find(6);
1949                         
1950                         AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1951                         intPrevValue = intiter->second;
1952                         
1953                         // Deal with country.
1954                                                 
1955                         AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1957                         break;
1958                 
1959                 }
1960         
1961         }       
1962         
1963         // Add the data to the General/Home/Work address variables.
1964         
1965         CaptureString(&AddressStreet, FALSE); 
1966         CaptureString(&AddressLocality, FALSE);
1967         CaptureString(&AddressRegion, FALSE);
1968         CaptureString(&AddressPostalCode, FALSE);
1969         CaptureString(&AddressCountry, FALSE);
1970                 
1971         if (!PropertyTokens.IsEmpty()){
1972         
1973                 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1974         
1975         }
1977         AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));      
1978         AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1979         AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1980         AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1981         AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1983         switch(PropType){
1984                 case PROPERTY_NONE:
1985                         AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1986                         break;
1987                 case PROPERTY_HOME:
1988                         AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1989                         break;
1990                 case PROPERTY_WORK:
1991                         AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));    
1992                         break;
1993         }
1994         
1995         AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1999 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2001         std::map<int, int> SplitPoints;
2002         std::map<int, int> SplitLength;
2004         int intPrevValue = 7;
2005         int intPref = 0;                        
2006         
2007         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2008         
2009         intPrevValue = 6;
2010         
2011         PropertyType PropType = PROPERTY_NONE;
2012                 
2013         // Look for type before continuing.
2014         
2015         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2016         
2017         std::map<int, wxString> *EmailList = NULL;
2018         std::map<int, wxString> *EmailListType = NULL;
2019         std::map<int, wxString> *EmailListAltID = NULL;
2020         std::map<int, wxString> *EmailListPID = NULL;
2021         std::map<int, wxString> *EmailListTokens = NULL;                
2022         std::map<int, int> *EmailListPref = NULL;
2024         switch(PropType){
2025                 case PROPERTY_NONE:
2026                         EmailList = &GeneralEmailList;
2027                         EmailListType = &GeneralEmailListType;
2028                         EmailListAltID = &GeneralEmailListAltID;
2029                         EmailListPID = &GeneralEmailListPID;
2030                         EmailListTokens = &GeneralEmailListTokens;              
2031                         EmailListPref = &GeneralEmailListPref;  
2032                         break;
2033                 case PROPERTY_HOME:
2034                         EmailList = &HomeEmailList;
2035                         EmailListType = &HomeEmailListType;
2036                         EmailListAltID = &HomeEmailListAltID;
2037                         EmailListPID = &HomeEmailListPID;
2038                         EmailListTokens = &HomeEmailListTokens;         
2039                         EmailListPref = &HomeEmailListPref;     
2040                         break;
2041                 case PROPERTY_WORK:
2042                         EmailList = &BusinessEmailList;
2043                         EmailListType = &BusinessEmailListType;
2044                         EmailListAltID = &BusinessEmailListAltID;
2045                         EmailListPID = &BusinessEmailListPID;
2046                         EmailListTokens = &BusinessEmailListTokens;             
2047                         EmailListPref = &BusinessEmailListPref; 
2048                         break;
2049         }
2050         
2051         intPrevValue = 6;
2052         
2053         std::map<int,int>::iterator SLiter;
2054         wxString PropertyData;
2055         wxString PropertyName;
2056         wxString PropertyValue;
2057         wxString PropertyTokens;
2058         bool FirstToken = TRUE;
2059         bool PropertyMatched = FALSE;
2060         
2061         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2062         intiter != SplitPoints.end(); ++intiter){
2063         
2064                 SLiter = SplitLength.find(intiter->first);
2065         
2066                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2067                 
2068                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2069                 PropertyName = PropertyElement.GetNextToken();                          
2070                 PropertyValue = PropertyElement.GetNextToken();
2071                 
2072                 intPrevValue = intiter->second;
2073                 
2074                 CaptureString(&PropertyValue, FALSE);
2075                 
2076                 // Process properties.
2077                 
2078                 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
2079                 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
2080                 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
2081                 
2082                 if (PropertyMatched == TRUE){
2083                 
2084                         PropertyMatched = FALSE;
2085                         continue;
2086                 
2087                 }
2088                 
2089                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2090                         
2091                         if (FirstToken == TRUE){
2092                         
2093                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2094                                 FirstToken = FALSE;
2095                         
2096                         } else {
2097                         
2098                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2099                         
2100                         }
2101                         
2102                 }
2103         
2104         }
2105         
2106         EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2107         
2108         // Add the name token data.
2109         
2110         if (!PropertyTokens.IsEmpty()){
2111         
2112                 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2113         
2114         }       
2119 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2121         std::map<int, int> SplitPoints;
2122         std::map<int, int> SplitLength;
2124         int intPrevValue = 6;
2125         int intPref = 0;                        
2126         
2127         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2128         
2129         intPrevValue = 5;
2130         
2131         PropertyType PropType = PROPERTY_NONE;
2132                 
2133         // Look for type before continuing.
2134         
2135         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2136         
2137         std::map<int, wxString> *IMList = NULL;
2138         std::map<int, wxString> *IMListType = NULL;
2139         std::map<int, wxString> *IMListAltID = NULL;
2140         std::map<int, wxString> *IMListPID = NULL;
2141         std::map<int, wxString> *IMListTokens = NULL;
2142         std::map<int, wxString> *IMListMediatype = NULL;        
2143         std::map<int, int> *IMListPref = NULL;
2145         switch(PropType){
2146                 case PROPERTY_NONE:
2147                         IMList = &GeneralIMList;
2148                         IMListType = &GeneralIMListType;
2149                         IMListAltID = &GeneralIMListAltID;
2150                         IMListPID = &GeneralIMListPID;
2151                         IMListTokens = &GeneralIMListTokens;
2152                         IMListMediatype = &GeneralIMListMediatype;
2153                         IMListPref = &GeneralIMListPref;        
2154                         break;
2155                 case PROPERTY_HOME:
2156                         IMList = &HomeIMList;
2157                         IMListType = &HomeIMListType;
2158                         IMListAltID = &HomeIMListAltID;
2159                         IMListPID = &HomeIMListPID;
2160                         IMListTokens = &HomeIMListTokens;
2161                         IMListMediatype = &HomeIMListMediatype;         
2162                         IMListPref = &HomeIMListPref;   
2163                         break;
2164                 case PROPERTY_WORK:
2165                         IMList = &BusinessIMList;
2166                         IMListType = &BusinessIMListType;
2167                         IMListAltID = &BusinessIMListAltID;
2168                         IMListPID = &BusinessIMListPID;
2169                         IMListTokens = &BusinessIMListTokens;   
2170                         IMListMediatype = &BusinessIMListMediatype;     
2171                         IMListPref = &BusinessIMListPref;       
2172                         break;
2173         }
2174         
2175         intPrevValue = 5;
2176         
2177         std::map<int,int>::iterator SLiter;
2178         wxString PropertyData;
2179         wxString PropertyName;
2180         wxString PropertyValue;
2181         wxString PropertyTokens;
2182         bool FirstToken = TRUE;
2183         bool PropertyMatched = FALSE;
2184         
2185         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2186         intiter != SplitPoints.end(); ++intiter){
2187         
2188                 SLiter = SplitLength.find(intiter->first);
2189         
2190                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2191                 
2192                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2193                 PropertyName = PropertyElement.GetNextToken();                          
2194                 PropertyValue = PropertyElement.GetNextToken();
2195                 
2196                 intPrevValue = intiter->second;
2197                 
2198                 CaptureString(&PropertyValue, FALSE);
2199                 
2200                 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
2201                 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
2202                 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
2203                 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
2204                 
2205                 // Process properties.
2206                 
2207                 if (PropertyMatched == TRUE){
2208                         
2209                         PropertyMatched = FALSE;
2210                         continue;
2211                 
2212                 }
2213                 
2214                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2215                 
2216                         if (FirstToken == TRUE){
2217                         
2218                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2219                                 FirstToken = FALSE;
2220                         
2221                         } else {
2222                         
2223                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2224                         
2225                         }
2226                 
2227                 }
2228         
2229         }
2230                 
2231         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2232         
2233         // Add the name token data.
2234         
2235         if (!PropertyTokens.IsEmpty()){
2236         
2237                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2238         
2239         }
2243 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2245         std::map<int, int> SplitPoints;
2246         std::map<int, int> SplitLength;
2247         std::map<int, int>::iterator SLiter;
2248         
2249         int intPref = 0;
2250         
2251         PropertyType PropType = PROPERTY_NONE;
2252                 
2253         // Look for type before continuing.
2254         
2255         wxString TelTypeUI;
2256         wxString TelTypeDetail;
2257         wxString PropertyData;
2258         wxString PropertyName;
2259         wxString PropertyValue;
2260         wxString PropertyTokens;
2261         
2262         std::map<int,int> TypeSplitPoints;
2263         std::map<int,int> TypeSplitLength;
2264         std::map<int,int>::iterator TSLiter;
2265         
2266         int intSplitSize = 0;
2267         int intSplitsFound = 0;
2268         int intSplitPoint = 0;
2269         int intType = 0;
2270         int intPrevValue = 5;
2271                 
2272         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2273         
2274         intPrevValue = 4;
2275         
2276         // Look for type before continuing.
2277         
2278         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2279         intiter != SplitPoints.end(); ++intiter){
2280         
2281                 SLiter = SplitLength.find(intiter->first);
2282         
2283                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2284                 
2285                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2286                 PropertyName = PropertyElement.GetNextToken();                          
2287                 PropertyValue = PropertyElement.GetNextToken();
2288                 
2289                 intPrevValue = intiter->second;
2291                 if (PropertyName == wxT("TYPE")){
2292                 
2293                         // Process each value in type and translate each
2294                         // part.
2295                 
2296                         // Strip out the quotes if they are there.
2297                 
2298                         size_t intPropertyValueLen = PropertyValue.Len();
2299                 
2300                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2301                         
2302                                 PropertyValue.Trim();
2303                                 PropertyValue.RemoveLast();
2304                         
2305                         }                               
2306                 
2307                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2308                         
2309                                 PropertyValue.Remove(0, 1);
2310                         
2311                         }
2312                         
2313                         TelTypeDetail = PropertyValue;
2314                         
2315                         intSplitSize = 0;
2316                         intSplitsFound = 0;
2317                         intSplitPoint = 0;
2318                         
2319                         for (int i = 0; i <= intPropertyValueLen; i++){
2320         
2321                                 intSplitSize++;
2322         
2323                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2324         
2325                                         if (intSplitsFound == 0){
2327                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2328                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2329                         
2330                                         } else {
2331                         
2332                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2333                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2334                         
2335                                         }                       
2337                                         intSplitsFound++;
2338                                         i++;
2339                                         intSplitPoint = i;
2340                                         intSplitSize = 0;
2341         
2342                                 }
2343         
2344                         }
2345                         
2346                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2347                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2348                 
2349                         int intTypeSeek = 0;
2350                 
2351                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2352                         typeiter != TypeSplitPoints.end(); ++typeiter){
2353                         
2354                                 wxString TypePropertyName;
2355                                 
2356                                 TSLiter = TypeSplitLength.find(typeiter->first);
2357                                 
2358                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2359                                 
2360                                 if (intTypeSeek == 0){
2361                                 
2362                                 
2363                                 } else {
2364                                                                                 
2365                                         TelTypeUI.Append(wxT(","));                                                     
2366                                 
2367                                 }
2368                         
2369                                 if (TypePropertyName == wxT("home")){
2370                                 
2371                                         PropType = PROPERTY_HOME;
2372                                 
2373                                 } else if (TypePropertyName == wxT("work")){
2374                                 
2375                                         PropType = PROPERTY_WORK;
2376                                                                         
2377                                 }
2378                                 
2379                                 
2380                                 if (TypePropertyName == wxT("text")){
2381                                 
2382                                         TelTypeUI.Append(_("text"));
2383                                         intTypeSeek++;
2384                                 
2385                                 } else if (TypePropertyName == wxT("voice")){
2386                                 
2387                                         TelTypeUI.Append(_("voice"));
2388                                         intTypeSeek++;
2389                                 
2390                                 } else if (TypePropertyName == wxT("fax")){
2391                                 
2392                                         TelTypeUI.Append(_("fax"));
2393                                         intTypeSeek++;
2394                                 
2395                                 } else if (TypePropertyName == wxT("cell")){
2396                                 
2397                                         TelTypeUI.Append(_("mobile"));
2398                                         intTypeSeek++;
2399                                 
2400                                 } else if (TypePropertyName == wxT("video")){
2401                                 
2402                                         TelTypeUI.Append(_("video"));
2403                                         intTypeSeek++;
2404                                 
2405                                 } else if (TypePropertyName == wxT("pager")){
2406                                 
2407                                         TelTypeUI.Append(_("pager"));
2408                                         intTypeSeek++;
2409                                 
2410                                 } else if (TypePropertyName == wxT("textphone")){
2411                                 
2412                                         TelTypeUI.Append(_("textphone"));
2413                                         intTypeSeek++;
2414                                 
2415                                 }
2416                         
2417                         }
2418                 
2419                 }
2420                 
2421         }
2422         
2423         std::map<int, wxString> *TelephoneList = NULL;
2424         std::map<int, wxString> *TelephoneListType = NULL;
2425         std::map<int, wxString> *TelephoneListAltID = NULL;
2426         std::map<int, wxString> *TelephoneListPID = NULL;
2427         std::map<int, wxString> *TelephoneListTokens = NULL;
2428         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2429         std::map<int, int> *TelephoneListPref = NULL;
2431         switch(PropType){
2432                 case PROPERTY_NONE:
2433                         TelephoneList = &GeneralTelephoneList;
2434                         TelephoneListType = &GeneralTelephoneListType;
2435                         TelephoneListAltID = &GeneralTelephoneListAltID;
2436                         TelephoneListPID = &GeneralTelephoneListPID;
2437                         TelephoneListTokens = &GeneralTelephoneListTokens;
2438                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2439                         TelephoneListPref = &GeneralTelephoneListPref;  
2440                         break;
2441                 case PROPERTY_HOME:
2442                         TelephoneList = &HomeTelephoneList;
2443                         TelephoneListType = &HomeTelephoneListType;
2444                         TelephoneListAltID = &HomeTelephoneListAltID;
2445                         TelephoneListPID = &HomeTelephoneListPID;
2446                         TelephoneListTokens = &HomeTelephoneListTokens;
2447                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2448                         TelephoneListPref = &HomeTelephoneListPref;     
2449                         break;
2450                 case PROPERTY_WORK:
2451                         TelephoneList = &BusinessTelephoneList;
2452                         TelephoneListType = &BusinessTelephoneListType;
2453                         TelephoneListAltID = &BusinessTelephoneListAltID;
2454                         TelephoneListPID = &BusinessTelephoneListPID;
2455                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2456                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2457                         TelephoneListPref = &BusinessTelephoneListPref; 
2458                         break;
2459         }
2460                 
2461         // Process the properties.
2462         
2463         bool FirstToken = TRUE;
2464         
2465         intPrevValue = 5;
2466         SplitPoints.clear();
2467         SplitLength.clear();
2469         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2471         intPrevValue = 4;
2472         
2473         bool PropertyMatched = FALSE;
2474         
2475         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2476         intiter != SplitPoints.end(); ++intiter){
2477         
2478                 SLiter = SplitLength.find(intiter->first);
2479         
2480                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2481                 
2482                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2483                 PropertyName = PropertyElement.GetNextToken();                          
2484                 PropertyValue = PropertyElement.GetNextToken();
2485                 
2486                 intPrevValue = intiter->second;
2487                 
2488                 CaptureString(&PropertyValue, FALSE);
2489                 
2490                 // Process properties.
2491                 
2492                 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2493                 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2494                 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2495                 
2496                 if (PropertyMatched == TRUE){
2497                 
2498                         PropertyMatched = FALSE;
2499                         continue;
2500                 
2501                 }
2503                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2504                 
2505                         if (FirstToken == TRUE){
2506                         
2507                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2508                                 FirstToken = FALSE;
2509                         
2510                         } else {
2511                         
2512                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2513                         
2514                         }
2515                 
2516                 }
2517         
2518         }
2519                 
2520         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2521         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2522         
2523         // Add the name token data.
2524         
2525         if (!PropertyTokens.IsEmpty()){
2526         
2527                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2528         
2529         }
2533 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2535         std::map<int, int> SplitPoints;
2536         std::map<int, int> SplitLength;
2538         int intPrevValue = 6;
2539         int intPref = 0;                        
2540         
2541         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2542         
2543         intPrevValue = 5;
2544         
2545         PropertyType PropType = PROPERTY_NONE;
2546                 
2547         // Look for type before continuing.
2548         
2549         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2550         
2551         std::map<int, wxString> *LanguageList = NULL;
2552         std::map<int, wxString> *LanguageListType = NULL;
2553         std::map<int, wxString> *LanguageListAltID = NULL;
2554         std::map<int, wxString> *LanguageListPID = NULL;
2555         std::map<int, wxString> *LanguageListTokens = NULL;
2556         std::map<int, int> *LanguageListPref = NULL;
2558         switch(PropType){
2559                 case PROPERTY_NONE:
2560                         LanguageList = &GeneralLanguageList;
2561                         LanguageListType = &GeneralLanguageListType;
2562                         LanguageListAltID = &GeneralLanguageListAltID;
2563                         LanguageListPID = &GeneralLanguageListPID;
2564                         LanguageListTokens = &GeneralLanguageListTokens;
2565                         LanguageListPref = &GeneralLanguageListPref;    
2566                         break;
2567                 case PROPERTY_HOME:
2568                         LanguageList = &HomeLanguageList;
2569                         LanguageListType = &HomeLanguageListType;
2570                         LanguageListAltID = &HomeLanguageListAltID;
2571                         LanguageListPID = &HomeLanguageListPID;
2572                         LanguageListTokens = &HomeLanguageListTokens;   
2573                         LanguageListPref = &HomeLanguageListPref;       
2574                         break;
2575                 case PROPERTY_WORK:
2576                         LanguageList = &BusinessLanguageList;
2577                         LanguageListType = &BusinessLanguageListType;
2578                         LanguageListAltID = &BusinessLanguageListAltID;
2579                         LanguageListPID = &BusinessLanguageListPID;
2580                         LanguageListTokens = &BusinessLanguageListTokens;       
2581                         LanguageListPref = &BusinessLanguageListPref;
2582                         break;
2583         }
2584         
2585         intPrevValue = 5;
2586         
2587         std::map<int,int>::iterator SLiter;
2588         wxString PropertyData;
2589         wxString PropertyName;
2590         wxString PropertyValue;
2591         wxString PropertyTokens;
2592         bool FirstToken = TRUE;
2593         bool PropertyMatched = FALSE;
2594         
2595         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2596         intiter != SplitPoints.end(); ++intiter){
2597         
2598                 SLiter = SplitLength.find(intiter->first);
2599         
2600                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2601                 
2602                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2603                 PropertyName = PropertyElement.GetNextToken();                          
2604                 PropertyValue = PropertyElement.GetNextToken();
2605                 
2606                 intPrevValue = intiter->second;
2607                 
2608                 CaptureString(&PropertyValue, FALSE);
2609                 
2610                 // Process properties.
2611                 
2612                 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2613                 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2614                 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2616                 if (PropertyMatched == TRUE){
2617                 
2618                         PropertyMatched = FALSE;
2619                         continue;
2620                 
2621                 }
2622                 
2623                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2624                 
2625                         if (FirstToken == TRUE){
2626                         
2627                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2628                                 FirstToken = FALSE;
2629                         
2630                         } else {
2631                         
2632                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2633                         
2634                         }
2635                 
2636                 }
2637         
2638         }
2639                 
2640         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2641         
2642         // Add the name token data.
2643         
2644         if (!PropertyTokens.IsEmpty()){
2645         
2646                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2647         
2648         }
2652 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2654         std::map<int, int> SplitPoints;
2655         std::map<int, int> SplitLength;
2657         int intPrevValue = 5;
2658         int intPref = 0;                        
2659         
2660         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2661         
2662         intPrevValue = 4;
2663         
2664         PropertyType PropType = PROPERTY_NONE;
2665                 
2666         // Look for type before continuing.
2667         
2668         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2669         
2670         std::map<int, wxString> *GeopositionList = NULL;
2671         std::map<int, wxString> *GeopositionListType = NULL;
2672         std::map<int, wxString> *GeopositionListAltID = NULL;
2673         std::map<int, wxString> *GeopositionListPID = NULL;
2674         std::map<int, wxString> *GeopositionListTokens = NULL;
2675         std::map<int, wxString> *GeopositionListMediatype = NULL;
2676         std::map<int, int> *GeopositionListPref = NULL;
2678         switch(PropType){
2679                 case PROPERTY_NONE:
2680                         GeopositionList = &GeneralGeographyList;
2681                         GeopositionListType = &GeneralGeographyListType;
2682                         GeopositionListAltID = &GeneralGeographyListAltID;
2683                         GeopositionListPID = &GeneralGeographyListPID;
2684                         GeopositionListTokens = &GeneralGeographyListTokens;
2685                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2686                         GeopositionListPref = &GeneralGeographyListPref;        
2687                         break;
2688                 case PROPERTY_HOME:
2689                         GeopositionList = &HomeGeographyList;
2690                         GeopositionListType = &HomeGeographyListType;
2691                         GeopositionListAltID = &HomeGeographyListAltID;
2692                         GeopositionListPID = &HomeGeographyListPID;
2693                         GeopositionListTokens = &HomeGeographyListTokens;
2694                         GeopositionListMediatype = &HomeGeographyListMediatype;
2695                         GeopositionListPref = &HomeGeographyListPref;   
2696                         break;
2697                 case PROPERTY_WORK:
2698                         GeopositionList = &BusinessGeographyList;
2699                         GeopositionListType = &BusinessGeographyListType;
2700                         GeopositionListAltID = &BusinessGeographyListAltID;
2701                         GeopositionListPID = &BusinessGeographyListPID;
2702                         GeopositionListTokens = &BusinessGeographyListTokens;
2703                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2704                         GeopositionListPref = &BusinessGeographyListPref;
2705                         break;
2706         }
2707         
2708         intPrevValue = 4;
2709         
2710         std::map<int,int>::iterator SLiter;
2711         wxString PropertyData;
2712         wxString PropertyName;
2713         wxString PropertyValue;
2714         wxString PropertyTokens;
2715         bool FirstToken = TRUE;
2716         bool PropertyMatched = FALSE;
2717         
2718         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2719         intiter != SplitPoints.end(); ++intiter){
2720         
2721                 SLiter = SplitLength.find(intiter->first);
2722         
2723                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2724                 
2725                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2726                 PropertyName = PropertyElement.GetNextToken();                          
2727                 PropertyValue = PropertyElement.GetNextToken();
2728                 
2729                 intPrevValue = intiter->second;
2730                 
2731                 CaptureString(&PropertyValue, FALSE);
2732                 
2733                 // Process properties.
2734                 
2735                 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2736                 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2737                 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2738                 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2739                 
2740                 if (PropertyMatched == TRUE){
2741                 
2742                         PropertyMatched = FALSE;
2743                         continue;
2744                 
2745                 }
2746                 
2747                 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2748                 
2749                         if (FirstToken == TRUE){
2750                         
2751                                 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2752                                 FirstToken = FALSE;
2753                         
2754                         } else {
2755                         
2756                                 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2757                         
2758                         }
2759                 
2760                 }
2761         
2762         }
2763                 
2764         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2765         
2766         // Add the name token data.
2767         
2768         if (!PropertyTokens.IsEmpty()){
2769         
2770                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2771         
2772         }
2776 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2778         size_t intPropertyLen = PropertySeg1.Len();
2779         std::map<int, int> SplitPoints;
2780         std::map<int, int> SplitLength;
2781         std::map<int, int>::iterator SLiter;                    
2782         wxString PropertyData;
2783         wxString PropertyName;
2784         wxString PropertyValue;
2785         wxString PropertyTokens;
2786         wxString RelatedType;
2787         wxString RelatedTypeOriginal;                   
2788         wxString RelatedName;
2789         bool FirstToken = TRUE;                 
2790         int intSplitsFound = 0;
2791         int intSplitSize = 0;
2792         int intPrevValue = 9;
2793         int intPref = 0;
2794         long ListCtrlIndex;
2795         
2796         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2797         
2798         intPrevValue = 8;
2799         
2800         // Look for type before continuing.
2801         
2802         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2803         intiter != SplitPoints.end(); ++intiter){
2804         
2805                 SLiter = SplitLength.find(intiter->first);
2806         
2807                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2808                 
2809                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2810                 PropertyName = PropertyElement.GetNextToken();                          
2811                 PropertyValue = PropertyElement.GetNextToken();
2812                 
2813                 intPrevValue = intiter->second;
2814                 
2815                 // Process these.
2816                 
2817                 RelatedTypeOriginal = PropertyValue;
2818                 
2819                 if (PropertyName == wxT("TYPE")){
2820                 
2821                         if (PropertyValue == wxT("contact")){
2823                                 RelatedType = _("Contact");
2825                         } else if (PropertyValue == wxT("acquaintance")){
2827                                 RelatedType = _("Acquaintance");
2829                         } else if (PropertyValue == wxT("friend")){
2831                                 RelatedType = _("Friend");
2833                         } else if (PropertyValue == wxT("met")){
2835                                 RelatedType = _("Met");
2837                         } else if (PropertyValue == wxT("co-worker")){
2839                                 RelatedType = _("Co-worker");
2841                         } else if (PropertyValue == wxT("colleague")){
2843                                 RelatedType = _("Colleague");
2845                         } else if (PropertyValue == wxT("co-resident")){
2847                                 RelatedType = _("Co-resident");
2849                         } else if (PropertyValue == wxT("neighbor")){
2851                                 RelatedType = _("Neighbour");
2853                         } else if (PropertyValue == wxT("child")){
2855                                 RelatedType = _("Child");
2857                         } else if (PropertyValue == wxT("parent")){
2859                                 RelatedType = _("Parent");
2861                         } else if (PropertyValue == wxT("sibling")){
2863                                 RelatedType = _("Sibling");
2865                         } else if (PropertyValue == wxT("spouse")){
2867                                 RelatedType = _("Spouse");
2869                         } else if (PropertyValue == wxT("kin")){
2871                                 RelatedType = _("Kin");
2873                         } else if (PropertyValue == wxT("muse")){
2875                                 RelatedType = _("Muse");
2877                         } else if (PropertyValue == wxT("crush")){
2879                                 RelatedType = _("Crush");
2881                         } else if (PropertyValue == wxT("date")){
2883                                 RelatedType = _("Date");
2885                         } else if (PropertyValue == wxT("sweetheart")){
2887                                 RelatedType = _("Sweetheart");
2889                         } else if (PropertyValue == wxT("me")){
2891                                 RelatedType = _("Me");
2893                         } else if (PropertyValue == wxT("agent")){
2895                                 RelatedType = _("Agent");
2897                         } else if (PropertyValue == wxT("emergency")){
2899                                 RelatedType = _("Emergency");
2901                         } else {
2903                                 RelatedType = PropertyValue;
2905                         }
2906                 
2907                 }
2908         
2909         }
2910         
2911         intPrevValue = 8;                       
2912         
2913         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2914         intiter != SplitPoints.end(); ++intiter){
2915         
2916                 SLiter = SplitLength.find(intiter->first);
2917         
2918                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2919                 
2920                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2921                 PropertyName = PropertyElement.GetNextToken();                          
2922                 PropertyValue = PropertyElement.GetNextToken();
2923                 
2924                 intPrevValue = intiter->second;
2925                 
2926                 // Process properties.
2927                 
2928                 size_t intPropertyValueLen = PropertyValue.Len();
2929                 
2930                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2931                         
2932                         PropertyValue.Trim();
2933                         PropertyValue.RemoveLast();
2934                         
2935                 }                               
2936                 
2937                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2938                         
2939                         PropertyValue.Remove(0, 1);
2940                         
2941                 }
2942                 
2943                 CaptureString(&PropertyValue, FALSE);
2944                         
2945                 if (PropertyName == wxT("ALTID")){
2947                         GeneralRelatedListAltID.erase(*RelatedCount);
2948                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2949                 
2950                 } else if (PropertyName == wxT("PID")){
2952                         GeneralRelatedListPID.erase(*RelatedCount);
2953                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2954                 
2955                 } else if (PropertyName == wxT("PREF")){
2956                         
2957                         int PriorityNumber = 0;
2958                         bool ValidNumber = TRUE;
2959                         
2960                         try{
2961                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2962                         }
2963                         
2964                         catch(std::invalid_argument &e){
2965                                 ValidNumber = FALSE;
2966                         }
2968                         if (ValidNumber == TRUE){
2970                                 GeneralRelatedListPref.erase(*RelatedCount);
2971                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2973                         }
2974                 
2975                 } else if (PropertyName == wxT("LANGUAGE")){
2977                         ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
2978                 
2979                 } else if (PropertyName != wxT("TYPE")) {
2980                 
2981                         // Something else we don't know about so append
2982                         // to the tokens variable.
2983                 
2984                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2985                 
2986                                 if (FirstToken == TRUE){
2987                         
2988                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2989                                         FirstToken = FALSE;
2990                         
2991                                 } else {
2992                         
2993                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2994                         
2995                                 }
2996                 
2997                         }
2998                 
2999                 }
3000         
3001         }                                       
3002         
3003         // Add the data to the General/Home/Work address variables.
3004                                 
3005         GeneralRelatedList.erase(*RelatedCount);
3006         GeneralRelatedListRelType.erase(*RelatedCount);
3007         GeneralRelatedListType.erase(*RelatedCount);
3008         GeneralRelatedListTokens.erase(*RelatedCount);
3009         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3010         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3011         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3012         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3016 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3018         std::map<int, int> SplitPoints;
3019         std::map<int, int> SplitLength;
3020         std::map<int, int>::iterator SLiter;                    
3021         wxString PropertyData;
3022         wxString PropertyName;
3023         wxString PropertyValue;
3024         wxString PropertyTokens;
3025         bool FirstToken = TRUE;
3026         int intPrevValue = 5;
3027         int intPref = 0;                        
3028         int intType = 0;
3029         long ListCtrlIndex;
3030         
3031         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3032         
3033         intPrevValue = 4;
3034         
3035         PropertyType PropType = PROPERTY_NONE;
3036                 
3037         // Look for type before continuing.
3038         
3039         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3040         
3041         // Setup the pointers.
3042         
3043         std::map<int, wxString> *WebsiteList = NULL;
3044         std::map<int, wxString> *WebsiteListAltID = NULL;
3045         std::map<int, wxString> *WebsiteListPID = NULL;
3046         std::map<int, wxString> *WebsiteListType = NULL;
3047         std::map<int, wxString> *WebsiteListTokens = NULL;
3048         std::map<int, wxString> *WebsiteListMediatype = NULL;
3049         std::map<int, int> *WebsiteListPref = NULL;
3050         
3051         // Setup blank lines for later on.
3052         
3053         switch(PropType){
3054                 case PROPERTY_NONE:
3055                         WebsiteList = &GeneralWebsiteList;
3056                         WebsiteListType = &GeneralWebsiteListType;
3057                         WebsiteListAltID = &GeneralWebsiteListAltID;
3058                         WebsiteListPID = &GeneralWebsiteListPID;
3059                         WebsiteListTokens = &GeneralWebsiteListTokens;
3060                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3061                         WebsiteListPref = &GeneralWebsiteListPref;      
3062                         break;
3063                 case PROPERTY_HOME:
3064                         WebsiteList = &HomeWebsiteList;
3065                         WebsiteListType = &HomeWebsiteListType;
3066                         WebsiteListAltID = &HomeWebsiteListAltID;
3067                         WebsiteListPID = &HomeWebsiteListPID;
3068                         WebsiteListTokens = &HomeWebsiteListTokens;
3069                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3070                         WebsiteListPref = &HomeWebsiteListPref; 
3071                         break;
3072                 case PROPERTY_WORK:
3073                         WebsiteList = &BusinessWebsiteList;
3074                         WebsiteListType = &BusinessWebsiteListType;
3075                         WebsiteListAltID = &BusinessWebsiteListAltID;
3076                         WebsiteListPID = &BusinessWebsiteListPID;
3077                         WebsiteListTokens = &BusinessWebsiteListTokens;
3078                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3079                         WebsiteListPref = &BusinessWebsiteListPref;
3080                         break;
3081         }
3082         
3083         intPrevValue = 4;
3084         
3085         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3086         intiter != SplitPoints.end(); ++intiter){
3087         
3088                 SLiter = SplitLength.find(intiter->first);
3089         
3090                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3091                 
3092                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3093                 PropertyName = PropertyElement.GetNextToken();                          
3094                 PropertyValue = PropertyElement.GetNextToken();
3095                 
3096                 intPrevValue = intiter->second;
3097                 
3098                 // Process properties.
3099                 
3100                 size_t intPropertyValueLen = PropertyValue.Len();
3101                 
3102                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3103                         
3104                         PropertyValue.Trim();
3105                         PropertyValue.RemoveLast();
3106                         
3107                 }                               
3108                 
3109                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3110                         
3111                         PropertyValue.Remove(0, 1);
3112                         
3113                 }
3114                 
3115                 CaptureString(&PropertyValue, FALSE);
3116                 
3117                 if (PropertyName == wxT("ALTID")){
3119                         WebsiteListAltID->erase(*URLCount);
3120                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3121                 
3122                 } else if (PropertyName == wxT("PID")){
3124                         WebsiteListPID->erase(*URLCount);
3125                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3126                         
3127                 } else if (PropertyName == wxT("PREF")){
3129                         ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3130                                                         
3131                 } else if (PropertyName == wxT("MEDIATYPE")){
3132                 
3133                         WebsiteListMediatype->erase(*URLCount);
3134                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3135                 
3136                 } else {
3137                 
3138                         // Something else we don't know about so append
3139                         // to the tokens variable.
3140                 
3141                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3142                 
3143                                 if (FirstToken == TRUE){
3144                         
3145                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3146                                         FirstToken = FALSE;
3147                         
3148                                 } else {
3149                         
3150                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3151                         
3152                                 }
3153                 
3154                         }
3155                 
3156                 }
3157         
3158         }
3159         
3160         // Add the data to the General/Home/Work address variables.
3161         
3162         CaptureString(&PropertySeg2, FALSE);
3163                         
3164         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3165         
3166         if (!PropertyTokens.IsEmpty()){
3167         
3168                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3169                         
3170         }
3171         
3174 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3176         std::map<int, int> SplitPoints;
3177         std::map<int, int> SplitLength;
3178         std::map<int, int>::iterator SLiter;                    
3179         wxString PropertyData;
3180         wxString PropertyName;
3181         wxString PropertyValue;
3182         wxString PropertyTokens;
3183         bool FirstToken = TRUE;
3184         int intPrevValue = 7;
3185         int intPref = 0;                        
3186         int intType = 0;
3187         long ListCtrlIndex;
3188         
3189         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3190         
3191         intPrevValue = 6;
3192         
3193         PropertyType PropType = PROPERTY_NONE;
3194                 
3195         // Look for type before continuing.
3196         
3197         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3198         
3199         // Setup the pointers.
3200         
3201         std::map<int, wxString> *TitleList = NULL;
3202         std::map<int, wxString> *TitleListAltID = NULL;
3203         std::map<int, wxString> *TitleListPID = NULL;
3204         std::map<int, wxString> *TitleListType = NULL;
3205         std::map<int, wxString> *TitleListTokens = NULL;
3206         std::map<int, wxString> *TitleListLanguage = NULL;
3207         std::map<int, int> *TitleListPref = NULL;
3208         
3209         // Setup blank lines for later on.
3210         
3211         switch(PropType){
3212                 case PROPERTY_NONE:
3213                         TitleList = &GeneralTitleList;
3214                         TitleListType = &GeneralTitleListType;
3215                         TitleListAltID = &GeneralTitleListAltID;
3216                         TitleListPID = &GeneralTitleListPID;
3217                         TitleListTokens = &GeneralTitleListTokens;
3218                         TitleListLanguage = &GeneralTitleListLanguage;
3219                         TitleListPref = &GeneralTitleListPref;  
3220                         break;
3221                 case PROPERTY_HOME:
3222                         TitleList = &HomeTitleList;
3223                         TitleListType = &HomeTitleListType;
3224                         TitleListAltID = &HomeTitleListAltID;
3225                         TitleListPID = &HomeTitleListPID;
3226                         TitleListTokens = &HomeTitleListTokens;
3227                         TitleListLanguage = &HomeTitleListLanguage;
3228                         TitleListPref = &HomeTitleListPref;     
3229                         break;
3230                 case PROPERTY_WORK:
3231                         TitleList = &BusinessTitleList;
3232                         TitleListType = &BusinessTitleListType;
3233                         TitleListAltID = &BusinessTitleListAltID;
3234                         TitleListPID = &BusinessTitleListPID;
3235                         TitleListTokens = &BusinessTitleListTokens;
3236                         TitleListLanguage = &BusinessTitleListLanguage; 
3237                         TitleListPref = &BusinessTitleListPref;
3238                         break;
3239         }
3241         intPrevValue = 6;
3242                 
3243         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3244         intiter != SplitPoints.end(); ++intiter){
3245         
3246                 SLiter = SplitLength.find(intiter->first);
3247         
3248                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3249                 
3250                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3251                 PropertyName = PropertyElement.GetNextToken();                          
3252                 PropertyValue = PropertyElement.GetNextToken();
3253                 
3254                 intPrevValue = intiter->second;
3255                 
3256                 // Process properties.
3257                 
3258                 size_t intPropertyValueLen = PropertyValue.Len();
3259                 
3260                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3261                         
3262                         PropertyValue.Trim();
3263                         PropertyValue.RemoveLast();
3264                         
3265                 }                               
3266                 
3267                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3268                         
3269                         PropertyValue.Remove(0, 1);
3270                         
3271                 }                               
3272                 
3273                 CaptureString(&PropertyValue, FALSE);
3274                 
3275                 if (PropertyName == wxT("ALTID")){
3276                 
3277                         TitleListAltID->erase(*TitleCount);
3278                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3279                 
3280                 } else if (PropertyName == wxT("PID")){
3282                         TitleListPID->erase(*TitleCount);
3283                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3284                 
3285                 } else if (PropertyName == wxT("PREF")){
3287                         ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3288                         
3289                 } else if (PropertyName == wxT("LANGUAGE")){
3290                 
3291                         TitleListLanguage->erase(*TitleCount);
3292                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3293                 
3294                 } else {
3295                 
3296                         // Something else we don't know about so append
3297                         // to the tokens variable.
3298                 
3299                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3300                 
3301                                 if (FirstToken == TRUE){
3302                         
3303                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3304                                         FirstToken = FALSE;
3305                         
3306                                 } else {
3307                         
3308                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3309                         
3310                                 }
3311                 
3312                         }
3313                 
3314                 }
3315         
3316         }
3317         
3318         // Add the data to the General/Home/Work address variables.
3319         
3320         CaptureString(&PropertySeg2, FALSE);
3322         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3323         
3324         if (!PropertyTokens.IsEmpty()){
3325         
3326                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3327                         
3328         }
3332 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3334         std::map<int, int> SplitPoints;
3335         std::map<int, int> SplitLength;
3336         std::map<int, int>::iterator SLiter;                    
3337         wxString PropertyData;
3338         wxString PropertyName;
3339         wxString PropertyValue;
3340         wxString PropertyTokens;
3341         bool FirstToken = TRUE;
3342         int intPrevValue = 6;
3343         int intPref = 0;                        
3344         int intType = 0;
3345         long ListCtrlIndex;
3346         
3347         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3348         
3349         intPrevValue = 5;
3350         
3351         PropertyType PropType = PROPERTY_NONE;
3352                 
3353         // Look for type before continuing.
3354         
3355         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3356         
3357         // Setup the pointers.
3358         
3359         std::map<int, wxString> *RoleList = NULL;
3360         std::map<int, wxString> *RoleListAltID = NULL;
3361         std::map<int, wxString> *RoleListPID = NULL;
3362         std::map<int, wxString> *RoleListType = NULL;
3363         std::map<int, wxString> *RoleListTokens = NULL;
3364         std::map<int, wxString> *RoleListLanguage = NULL;
3365         std::map<int, int> *RoleListPref = NULL;
3366         
3367         // Setup blank lines for later on.
3368         
3369         switch(PropType){
3370                 case PROPERTY_NONE:
3371                         RoleList = &GeneralRoleList;
3372                         RoleListType = &GeneralRoleListType;
3373                         RoleListAltID = &GeneralRoleListAltID;
3374                         RoleListPID = &GeneralRoleListPID;
3375                         RoleListTokens = &GeneralRoleListTokens;
3376                         RoleListLanguage = &GeneralRoleListLanguage;
3377                         RoleListPref = &GeneralRoleListPref;    
3378                         break;
3379                 case PROPERTY_HOME:
3380                         RoleList = &HomeRoleList;
3381                         RoleListType = &HomeRoleListType;
3382                         RoleListAltID = &HomeRoleListAltID;
3383                         RoleListPID = &HomeRoleListPID;
3384                         RoleListTokens = &HomeRoleListTokens;
3385                         RoleListLanguage = &HomeRoleListLanguage;
3386                         RoleListPref = &HomeRoleListPref;       
3387                         break;
3388                 case PROPERTY_WORK:
3389                         RoleList = &BusinessRoleList;
3390                         RoleListType = &BusinessRoleListType;
3391                         RoleListAltID = &BusinessRoleListAltID;
3392                         RoleListPID = &BusinessRoleListPID;
3393                         RoleListTokens = &BusinessRoleListTokens;
3394                         RoleListLanguage = &BusinessRoleListLanguage;   
3395                         RoleListPref = &BusinessRoleListPref;
3396                         break;
3397         }
3399         intPrevValue = 5;
3400                 
3401         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3402         intiter != SplitPoints.end(); ++intiter){
3403         
3404                 SLiter = SplitLength.find(intiter->first);
3405         
3406                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3407                 
3408                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3409                 PropertyName = PropertyElement.GetNextToken();                          
3410                 PropertyValue = PropertyElement.GetNextToken();
3411                 
3412                 intPrevValue = intiter->second;
3413                 
3414                 // Process properties.
3415                 
3416                 size_t intPropertyValueLen = PropertyValue.Len();
3417                 
3418                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3419                         
3420                         PropertyValue.Trim();
3421                         PropertyValue.RemoveLast();
3422                         
3423                 }                               
3424                 
3425                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3426                         
3427                         PropertyValue.Remove(0, 1);
3428                         
3429                 }                               
3430                 
3431                 CaptureString(&PropertyValue, FALSE);
3432                 
3433                 if (PropertyName == wxT("ALTID")){
3434                 
3435                         RoleListAltID->erase(*RoleCount);
3436                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3437                 
3438                 } else if (PropertyName == wxT("PID")){
3440                         RoleListPID->erase(*RoleCount);
3441                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3442                 
3443                 } else if (PropertyName == wxT("PREF")){
3445                         ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3446                                 
3447                 } else if (PropertyName == wxT("LANGUAGE")){
3448                 
3449                         RoleListLanguage->erase(*RoleCount);
3450                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3451                 
3452                 } else {
3453                 
3454                         // Something else we don't know about so append
3455                         // to the tokens variable.
3456                 
3457                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3458                 
3459                                 if (FirstToken == TRUE){
3460                         
3461                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3462                                         FirstToken = FALSE;
3463                         
3464                                 } else {
3465                         
3466                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3467                         
3468                                 }
3469                 
3470                         }
3471                 
3472                 }
3473         
3474         }
3475         
3476         // Add the data to the General/Home/Work address variables.
3477         
3478         CaptureString(&PropertySeg2, FALSE);
3480         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3481         
3482         if (!PropertyTokens.IsEmpty()){
3483         
3484                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3485                         
3486         }
3490 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3492         std::map<int, int> SplitPoints;
3493         std::map<int, int> SplitLength;
3494         std::map<int, int>::iterator SLiter;                    
3495         wxString PropertyData;
3496         wxString PropertyName;
3497         wxString PropertyValue;
3498         wxString PropertyTokens;
3499         bool FirstToken = TRUE;
3500         int intPrevValue = 5;
3501         int intPref = 0;                        
3502         int intType = 0;
3503         long ListCtrlIndex;
3504         
3505         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3506         
3507         intPrevValue = 4;
3508         
3509         PropertyType PropType = PROPERTY_NONE;
3510                 
3511         // Look for type before continuing.
3512         
3513         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3514         
3515         // Setup the pointers.
3516         
3517         std::map<int, wxString> *OrganisationsList = NULL;
3518         std::map<int, wxString> *OrganisationsListAltID = NULL;
3519         std::map<int, wxString> *OrganisationsListPID = NULL;
3520         std::map<int, wxString> *OrganisationsListType = NULL;
3521         std::map<int, wxString> *OrganisationsListTokens = NULL;
3522         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3523         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3524         std::map<int, int> *OrganisationsListPref = NULL;
3525         
3526         // Setup blank lines for later on.
3527         
3528         switch(PropType){
3529                 case PROPERTY_NONE:
3530                         OrganisationsList = &GeneralOrganisationsList;
3531                         OrganisationsListType = &GeneralOrganisationsListType;
3532                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3533                         OrganisationsListPID = &GeneralOrganisationsListPID;
3534                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3535                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3536                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3537                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3538                         break;
3539                 case PROPERTY_HOME:
3540                         OrganisationsList = &HomeOrganisationsList;
3541                         OrganisationsListType = &HomeOrganisationsListType;
3542                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3543                         OrganisationsListPID = &HomeOrganisationsListPID;
3544                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3545                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3546                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3547                         OrganisationsListPref = &HomeOrganisationsListPref;     
3548                         break;
3549                 case PROPERTY_WORK:
3550                         OrganisationsList = &BusinessOrganisationsList;
3551                         OrganisationsListType = &BusinessOrganisationsListType;
3552                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3553                         OrganisationsListPID = &BusinessOrganisationsListPID;
3554                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3555                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3556                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3557                         OrganisationsListPref = &BusinessOrganisationsListPref;
3558                         break;
3559         }
3561         intPrevValue = 4;
3562                 
3563         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3564         intiter != SplitPoints.end(); ++intiter){
3565         
3566                 SLiter = SplitLength.find(intiter->first);
3567         
3568                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3569                 
3570                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3571                 PropertyName = PropertyElement.GetNextToken();                          
3572                 PropertyValue = PropertyElement.GetNextToken();
3573                 
3574                 intPrevValue = intiter->second;
3575                 
3576                 // Process properties.
3577                 
3578                 size_t intPropertyValueLen = PropertyValue.Len();
3579                 
3580                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3581                         
3582                         PropertyValue.Trim();
3583                         PropertyValue.RemoveLast();
3584                         
3585                 }                               
3586                 
3587                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3588                         
3589                         PropertyValue.Remove(0, 1);
3590                         
3591                 }                               
3592                 
3593                 CaptureString(&PropertyValue, FALSE);
3594                 
3595                 if (PropertyName == wxT("ALTID")){
3596                 
3597                         OrganisationsListAltID->erase(*OrganisationCount);
3598                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3599                 
3600                 } else if (PropertyName == wxT("PID")){
3602                         OrganisationsListPID->erase(*OrganisationCount);
3603                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3604                 
3605                 } else if (PropertyName == wxT("SORT-AS")){
3607                         OrganisationsListSortAs->erase(*OrganisationCount);
3608                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3609                 
3610                 } else if (PropertyName == wxT("PREF")){
3612                         ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3613                         
3614                 } else if (PropertyName == wxT("LANGUAGE")){
3615                 
3616                         OrganisationsListLanguage->erase(*OrganisationCount);
3617                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3618                 
3619                 } else {
3620                 
3621                         // Something else we don't know about so append
3622                         // to the tokens variable.
3623                 
3624                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3625                 
3626                                 if (FirstToken == TRUE){
3627                         
3628                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3629                                         FirstToken = FALSE;
3630                         
3631                                 } else {
3632                         
3633                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3634                         
3635                                 }
3636                 
3637                         }
3638                 
3639                 }
3640         
3641         }
3642         
3643         // Add the data to the General/Home/Work address variables.
3644         
3645         CaptureString(&PropertySeg2, FALSE);
3647         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3648         
3649         if (!PropertyTokens.IsEmpty()){
3650         
3651                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3652                         
3653         }
3657 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3659         std::map<int, int> SplitPoints;
3660         std::map<int, int> SplitLength;
3661         std::map<int, int>::iterator SLiter;                    
3662         wxString PropertyData;
3663         wxString PropertyName;
3664         wxString PropertyValue;
3665         wxString PropertyTokens;
3666         bool FirstToken = TRUE;
3667         int intPrevValue = 6;
3668         int intPref = 0;                        
3669         int intType = 0;
3670         long ListCtrlIndex;
3671         
3672         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3673         
3674         intPrevValue = 5;
3675         
3676         PropertyType PropType = PROPERTY_NONE;
3677                 
3678         // Look for type before continuing.
3679         
3680         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3681         
3682         // Setup the pointers.
3683         
3684         std::map<int, wxString> *NoteList = NULL;
3685         std::map<int, wxString> *NoteListAltID = NULL;
3686         std::map<int, wxString> *NoteListPID = NULL;
3687         std::map<int, wxString> *NoteListType = NULL;
3688         std::map<int, wxString> *NoteListTokens = NULL;
3689         std::map<int, wxString> *NoteListLanguage = NULL;
3690         std::map<int, int> *NoteListPref = NULL;
3691         
3692         // Setup blank lines for later on.
3693         
3694         switch(PropType){
3695                 case PROPERTY_NONE:
3696                         NoteList = &GeneralNoteList;
3697                         NoteListType = &GeneralNoteListType;
3698                         NoteListAltID = &GeneralNoteListAltID;
3699                         NoteListPID = &GeneralNoteListPID;
3700                         NoteListTokens = &GeneralNoteListTokens;
3701                         NoteListLanguage = &GeneralNoteListLanguage;
3702                         NoteListPref = &GeneralNoteListPref;    
3703                         break;
3704                 case PROPERTY_HOME:
3705                         NoteList = &HomeNoteList;
3706                         NoteListType = &HomeNoteListType;
3707                         NoteListAltID = &HomeNoteListAltID;
3708                         NoteListPID = &HomeNoteListPID;
3709                         NoteListTokens = &HomeNoteListTokens;
3710                         NoteListLanguage = &HomeNoteListLanguage;
3711                         NoteListPref = &HomeNoteListPref;       
3712                         break;
3713                 case PROPERTY_WORK:
3714                         NoteList = &BusinessNoteList;
3715                         NoteListType = &BusinessNoteListType;
3716                         NoteListAltID = &BusinessNoteListAltID;
3717                         NoteListPID = &BusinessNoteListPID;
3718                         NoteListTokens = &BusinessNoteListTokens;
3719                         NoteListLanguage = &BusinessNoteListLanguage;   
3720                         NoteListPref = &BusinessNoteListPref;
3721                         break;
3722         }
3724         intPrevValue = 5;
3725                 
3726         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3727         intiter != SplitPoints.end(); ++intiter){
3728         
3729                 SLiter = SplitLength.find(intiter->first);
3730         
3731                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3732                 
3733                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3734                 PropertyName = PropertyElement.GetNextToken();                          
3735                 PropertyValue = PropertyElement.GetNextToken();
3736                 
3737                 intPrevValue = intiter->second;
3738                 
3739                 // Process properties.
3740                 
3741                 size_t intPropertyValueLen = PropertyValue.Len();
3742                 
3743                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3744                         
3745                         PropertyValue.Trim();
3746                         PropertyValue.RemoveLast();
3747                         
3748                 }                               
3749                 
3750                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3751                         
3752                         PropertyValue.Remove(0, 1);
3753                         
3754                 }                               
3755                 
3756                 CaptureString(&PropertyValue, FALSE);
3757                 
3758                 if (PropertyName == wxT("ALTID")){
3759                 
3760                         NoteListAltID->erase(*NoteCount);
3761                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3762                 
3763                 } else if (PropertyName == wxT("PID")){
3765                         NoteListPID->erase(*NoteCount);
3766                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3767                 
3768                 } else if (PropertyName == wxT("PREF")){
3770                         ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3771                 
3772                 } else if (PropertyName == wxT("LANGUAGE")){
3773                 
3774                         NoteListLanguage->erase(*NoteCount);
3775                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3776                 
3777                 } else {
3778                 
3779                         // Something else we don't know about so append
3780                         // to the tokens variable.
3781                 
3782                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3783                 
3784                                 if (FirstToken == TRUE){
3785                         
3786                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3787                                         FirstToken = FALSE;
3788                         
3789                                 } else {
3790                         
3791                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3792                         
3793                                 }
3794                 
3795                         }
3796                 
3797                 }
3798         
3799         }
3800         
3801         // Add the data to the General/Home/Work address variables.
3802         
3803         CaptureString(&PropertySeg2, FALSE);
3805         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3806         
3807         if (!PropertyTokens.IsEmpty()){
3808         
3809                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3810                         
3811         }
3815 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3817         std::map<int, int> SplitPoints;
3818         std::map<int, int> SplitLength;
3819         std::map<int, int>::iterator SLiter;                    
3820         wxString PropertyData;
3821         wxString PropertyName;
3822         wxString PropertyValue;
3823         wxString PropertyTokens;
3824         bool FirstToken = TRUE;
3825         int intPrevValue = 12;
3826         int intPref = 0;                        
3827         int intType = 0;
3828         long ListCtrlIndex;
3829         
3830         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3831         
3832         intPrevValue = 11;
3833         
3834         PropertyType PropType = PROPERTY_NONE;
3835                 
3836         // Look for type before continuing.
3837         
3838         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3839         
3840         // Setup blank lines for later on.
3841         
3842         switch(PropType){
3843                 case PROPERTY_NONE:
3844                         break;
3845                 case PROPERTY_HOME:
3846                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3847                         break;
3848                 case PROPERTY_WORK:
3849                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3850                         break;
3851         }
3853         intPrevValue = 11;
3854                 
3855         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3856         intiter != SplitPoints.end(); ++intiter){
3857         
3858                 SLiter = SplitLength.find(intiter->first);
3859         
3860                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3861                 
3862                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3863                 PropertyName = PropertyElement.GetNextToken();                          
3864                 PropertyValue = PropertyElement.GetNextToken();
3865                 
3866                 intPrevValue = intiter->second;
3867                 
3868                 // Process properties.
3869                 
3870                 size_t intPropertyValueLen = PropertyValue.Len();
3871                 
3872                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3873                         
3874                         PropertyValue.Trim();
3875                         PropertyValue.RemoveLast();
3876                         
3877                 }                               
3878                 
3879                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3880                         
3881                         PropertyValue.Remove(0, 1);
3882                         
3883                 }                               
3884                 
3885                 CaptureString(&PropertyValue, FALSE);
3886                 
3887                 if (PropertyName == wxT("ALTID")){
3888                 
3889                         CategoriesListAltID.erase(*CategoryCount);
3890                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3891                 
3892                 } else if (PropertyName == wxT("PID")){
3894                         CategoriesListPID.erase(*CategoryCount);
3895                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3896                 
3897                 } else if (PropertyName == wxT("PREF")){
3899                         ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3900                         
3901                 } else if (PropertyName == wxT("LANGUAGE")){
3902                 
3903                         CategoriesListLanguage.erase(*CategoryCount);
3904                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3905                 
3906                 } else {
3907                 
3908                         // Something else we don't know about so append
3909                         // to the tokens variable.
3910                 
3911                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3912                 
3913                                 if (FirstToken == TRUE){
3914                         
3915                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3916                                         FirstToken = FALSE;
3917                         
3918                                 } else {
3919                         
3920                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3921                         
3922                                 }
3923                 
3924                         }
3925                 
3926                 }
3927         
3928         }
3929         
3930         // Deal with multiple categories.
3931         
3932         int intOrigCatCount = *CategoryCount;
3933         bool FirstCategoryProcessed = TRUE;
3934         bool AfterFirstToken = FALSE;
3935         int intSplitSize = 0;
3936         int intSplitsFound = 0;
3937         int intSplitSeek = 0;
3938         int intPropertyLen = PropertySeg2.Len();
3939         
3940         SplitPoints.clear();
3941         SplitLength.clear();
3942         intPrevValue = 0;
3943         
3944         for (int i = 0; i <= intPropertyLen; i++){
3945         
3946                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3947         
3948                         continue;
3949                 
3950                 }
3951         
3952                 intSplitSize++;
3953         
3954                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3955         
3956                         if (AfterFirstToken == TRUE){
3957                 
3958                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3959                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3960                         
3961                         } else {
3962                         
3963                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3964                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3965                                 AfterFirstToken = TRUE;
3967                         }
3969                         intSplitsFound++;
3970                         intSplitSeek = i;
3971                         intSplitSize = 0;                               
3972         
3973                 }                       
3974         
3975         }
3976         
3977         if (SplitPoints.size() > 0){
3978         
3979                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3980                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3981         
3982         }
3983         
3984         if (SplitPoints.size() == 0){
3985         
3986                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3987         
3988                 if (!PropertyTokens.IsEmpty()){
3989                 
3990                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3991                 
3992                 }
3993         
3994         }
3995         
3996         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3997         intiter != SplitPoints.end(); ++intiter){
3998         
3999                 SLiter = SplitLength.find(intiter->first);
4000         
4001                 intPrevValue = intiter->second;
4002         
4003                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4004                 
4005                 // Add the data to the General/Home/Work address variables.
4006         
4007                 // Trim any whitespace from the start and end.
4008         
4009                 PropertyData = PropertyData.Trim(FALSE);
4010                 PropertyData = PropertyData.Trim(TRUE); 
4011         
4012                 CaptureString(&PropertyData, FALSE);
4013                 
4014                 if (FirstCategoryProcessed == TRUE){
4015                 
4016                         FirstCategoryProcessed = FALSE;
4017                         
4018                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4019         
4020                         if (!PropertyTokens.IsEmpty()){
4021                 
4022                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4023                 
4024                         }
4025                         
4026                         continue;
4027                 
4028                 } else {
4030                         (*CategoryCount)++;
4031                         
4032                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4033                 
4034                         if (!PropertyTokens.IsEmpty()){
4035                 
4036                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4037                 
4038                         }
4039                 
4040                 }
4041                 
4042                 // Copy the properties to each of the categories (if it exists).
4043                 
4044                 if (!PropertyTokens.IsEmpty()){
4045                 
4046                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4047                 
4048                 }
4049                 
4050                 // Check if ALTID was used.
4051                 
4052                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4053                 
4054                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4055                 
4056                 }
4057                 
4058                 // Check if PID was used.
4059                 
4060                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4061                 
4062                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4063                 
4064                 }
4065         
4066                 // Check if PREF was used.
4067         
4068                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4069                 
4070                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4071                 
4072                 }
4073                 
4074                 // Check if LANGUAGE was used.
4075                 
4076                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4077                 
4078                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4079                 
4080                 }
4081                 
4082                 // Check if TYPE was used.
4083                 
4084                 switch(PropType){
4085                         case PROPERTY_NONE:
4086                                 break;
4087                         case PROPERTY_HOME:
4088                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4089                                 break;
4090                         case PROPERTY_WORK:
4091                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4092                                 break;
4093                 }
4094         
4095         }
4099 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4101         size_t intPropertyLen = PropertySeg1.Len();
4102         std::map<int, int> SplitPoints;
4103         std::map<int, int> SplitLength;
4104         std::map<int, int>::iterator SLiter;                    
4105         wxString PropertyData;
4106         wxString PropertyName;
4107         wxString PropertyValue;
4108         wxString PropertyTokens;
4109         bool FirstToken = TRUE;
4110         int intSplitsFound = 0;
4111         int intSplitSize = 0;
4112         int intPrevValue = 7;
4113         int intPref = 0;                        
4114         int intType = 0;
4115         
4116         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4117         
4118         intPrevValue = 6;
4119         
4120         PropertyType PropType = PROPERTY_NONE;
4121                 
4122         // Look for type before continuing.
4123         
4124         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4126         intPrevValue = 6;
4128         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4129         intiter != SplitPoints.end(); ++intiter){
4130         
4131                 SLiter = SplitLength.find(intiter->first);
4132         
4133                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4134                 
4135                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4136                 PropertyName = PropertyElement.GetNextToken();                          
4137                 PropertyValue = PropertyElement.GetNextToken();
4138                 
4139                 intPrevValue = intiter->second;
4140                 
4141                 // Process properties.
4142                 
4143                 size_t intPropertyValueLen = PropertyValue.Len();
4144                 
4145                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4146                         
4147                         PropertyValue.Trim();
4148                         PropertyValue.RemoveLast();
4149                         
4150                 }                               
4151                 
4152                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4153                         
4154                         PropertyValue.Remove(0, 1);
4155                         
4156                 }
4157                 
4158                 CaptureString(&PropertyValue, FALSE);
4159                 
4160                 if (PropertyName == wxT("ALTID")){
4162                         PicturesListAltID.erase(*PhotoCount);
4163                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4164                 
4165                 } else if (PropertyName == wxT("PID")){
4167                         PicturesListPID.erase(*PhotoCount);
4168                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4169                 
4170                 } else if (PropertyName == wxT("PREF")){
4172                         ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4173                 
4174                 } else if (PropertyName == wxT("MEDIATYPE")){
4175                 
4176                         PicturesListMediatype.erase(*PhotoCount);
4177                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4178                                         
4179                 } else {
4180                 
4181                         // Something else we don't know about so append
4182                         // to the tokens variable.
4183                         
4184                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4185                         
4186                                 if (FirstToken == TRUE){
4187                                 
4188                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4189                                         FirstToken = FALSE;
4190                                 
4191                                 } else {
4192                                 
4193                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4194                                 
4195                                 }
4196                         
4197                         }
4198                 
4199                 }
4200         
4201         }       
4202         
4203         intPropertyLen = PropertySeg2.Len();
4204         SplitPoints.clear();
4205         SplitLength.clear();
4206         intSplitsFound = 0;
4207         intSplitSize = 0;
4208         intPrevValue = 0;                       
4209         
4210         CaptureString(&PropertySeg2, FALSE);
4211         
4212         for (int i = 0; i <= intPropertyLen; i++){
4214                 intSplitSize++;
4215         
4216                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4217         
4218                         intSplitsFound++;
4219                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4220                         
4221                         if (intSplitsFound == 6){ 
4222                         
4223                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4224                                 break; 
4225                                 
4226                         } else {
4227                         
4228                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4229                         
4230                         }
4231                         
4232                         intSplitSize = 0;                                       
4233         
4234                 }
4236         }
4237         
4238         wxString wxSPhotoURI;
4239         wxString wxSPhotoMIME;
4240         wxString wxSPhotoEncoding;
4241         wxString wxSPhotoData;
4242         std::string base64enc;
4243         
4244         if (intSplitsFound == 0){
4245         
4246         } else {
4247         
4248                 std::map<int, int>::iterator striter;
4249         
4250                 striter = SplitLength.find(1);
4251         
4252                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4253         
4254                 while (wSTDataType.HasMoreTokens() == TRUE){
4255                 
4256                         wxSPhotoURI = wSTDataType.GetNextToken();
4257                         wxSPhotoMIME = wSTDataType.GetNextToken();
4258                         break;
4259                 
4260                 }                       
4261         
4262                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4263         
4264                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4265                 
4266                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4267                         wxSPhotoData = wSTDataInfo.GetNextToken();
4268                         base64enc = wxSPhotoData.mb_str();
4269                         break;
4270                 
4271                 }
4272         
4273         }
4274         
4275         // Add the data to the General/Home/Work address variables.
4276         
4277         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4278         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4279         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4280         
4281         switch(PropType){
4282                 case PROPERTY_NONE:
4283                         break;
4284                 case PROPERTY_HOME:
4285                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4286                         break;
4287                 case PROPERTY_WORK:
4288                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4289                         break;
4290         }
4291         
4292         if (!PropertyTokens.IsEmpty()){
4294                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4295         
4296         }
4300 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4302         size_t intPropertyLen = PropertySeg1.Len();
4303         std::map<int, int> SplitPoints;
4304         std::map<int, int> SplitLength;
4305         std::map<int, int>::iterator SLiter;                    
4306         wxString PropertyData;
4307         wxString PropertyName;
4308         wxString PropertyValue;
4309         wxString PropertyTokens;
4310         bool FirstToken = TRUE;
4311         int intSplitsFound = 0;
4312         int intSplitSize = 0;
4313         int intPrevValue = 6;
4314         int intPref = 0;                        
4315         int intType = 0;
4316         
4317         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4318         
4319         intPrevValue = 5;
4320         
4321         PropertyType PropType = PROPERTY_NONE;
4322                 
4323         // Look for type before continuing.
4324         
4325         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4327         intPrevValue = 5;
4329         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4330         intiter != SplitPoints.end(); ++intiter){
4331         
4332                 SLiter = SplitLength.find(intiter->first);
4333         
4334                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4335                 
4336                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4337                 PropertyName = PropertyElement.GetNextToken();                          
4338                 PropertyValue = PropertyElement.GetNextToken();
4339                 
4340                 intPrevValue = intiter->second;
4341                 
4342                 // Process properties.
4343                 
4344                 size_t intPropertyValueLen = PropertyValue.Len();
4345                 
4346                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4347                         
4348                         PropertyValue.Trim();
4349                         PropertyValue.RemoveLast();
4350                         
4351                 }                               
4352                 
4353                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4354                         
4355                         PropertyValue.Remove(0, 1);
4356                         
4357                 }
4358                 
4359                 CaptureString(&PropertyValue, FALSE);
4360                 
4361                 if (PropertyName == wxT("ALTID")){
4363                         LogosListAltID.erase(*LogoCount);
4364                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4365                 
4366                 } else if (PropertyName == wxT("PID")){
4368                         LogosListPID.erase(*LogoCount);
4369                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4370                 
4371                 } else if (PropertyName == wxT("PREF")){
4373                         ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4374                 
4375                 } else if (PropertyName == wxT("MEDIATYPE")){
4376                 
4377                         LogosListMediatype.erase(*LogoCount);
4378                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4379                                         
4380                 } else {
4381                 
4382                         // Something else we don't know about so append
4383                         // to the tokens variable.
4384                         
4385                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4386                         
4387                                 if (FirstToken == TRUE){
4388                                 
4389                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4390                                         FirstToken = FALSE;
4391                                 
4392                                 } else {
4393                                 
4394                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4395                                 
4396                                 }
4397                         
4398                         }
4399                 
4400                 }
4401         
4402         }       
4403         
4404         intPropertyLen = PropertySeg2.Len();
4405         SplitPoints.clear();
4406         SplitLength.clear();
4407         intSplitsFound = 0;
4408         intSplitSize = 0;
4409         intPrevValue = 0;                       
4410         
4411         CaptureString(&PropertySeg2, FALSE);
4412         
4413         for (int i = 0; i <= intPropertyLen; i++){
4415                 intSplitSize++;
4416         
4417                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4418         
4419                         intSplitsFound++;
4420                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4421                         
4422                         if (intSplitsFound == 6){ 
4423                         
4424                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4425                                 break; 
4426                                 
4427                         } else {
4428                         
4429                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4430                         
4431                         }
4432                         
4433                         intSplitSize = 0;                                       
4434         
4435                 }
4437         }
4438         
4439         wxString wxSPhotoURI;
4440         wxString wxSPhotoMIME;
4441         wxString wxSPhotoEncoding;
4442         wxString wxSPhotoData;
4443         std::string base64enc;
4444         
4445         if (intSplitsFound == 0){
4446         
4447         } else {
4448         
4449                 std::map<int, int>::iterator striter;
4450         
4451                 striter = SplitLength.find(1);
4452         
4453                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4454         
4455                 while (wSTDataType.HasMoreTokens() == TRUE){
4456                 
4457                         wxSPhotoURI = wSTDataType.GetNextToken();
4458                         wxSPhotoMIME = wSTDataType.GetNextToken();
4459                         break;
4460                 
4461                 }                       
4462         
4463                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4464         
4465                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4466                 
4467                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4468                         wxSPhotoData = wSTDataInfo.GetNextToken();
4469                         base64enc = wxSPhotoData.mb_str();
4470                         break;
4471                 
4472                 }
4473         
4474         }
4475         
4476         // Add the data to the General/Home/Work address variables.
4477         
4478         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4479         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4480         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4481         
4482         switch(PropType){
4483                 case PROPERTY_NONE:
4484                         break;
4485                 case PROPERTY_HOME:
4486                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4487                         break;
4488                 case PROPERTY_WORK:
4489                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4490                         break;
4491         }
4492         
4493         if (!PropertyTokens.IsEmpty()){
4495                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4496         
4497         }
4501 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4503         size_t intPropertyLen = PropertySeg1.Len();
4504         std::map<int, int> SplitPoints;
4505         std::map<int, int> SplitLength;
4506         std::map<int, int>::iterator SLiter;                    
4507         wxString PropertyData;
4508         wxString PropertyName;
4509         wxString PropertyValue;
4510         wxString PropertyTokens;
4511         bool FirstToken = TRUE;
4512         int intSplitsFound = 0;
4513         int intSplitSize = 0;
4514         int intPrevValue = 7;
4515         int intPref = 0;                        
4516         int intType = 0;
4517         
4518         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4519         
4520         intPrevValue = 6;
4521         
4522         PropertyType PropType = PROPERTY_NONE;
4523         
4524         // Look for type before continuing.                     
4526         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4528         intPrevValue = 6;
4530         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4531         intiter != SplitPoints.end(); ++intiter){
4532         
4533                 SLiter = SplitLength.find(intiter->first);
4534         
4535                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4536                 
4537                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4538                 PropertyName = PropertyElement.GetNextToken();                          
4539                 PropertyValue = PropertyElement.GetNextToken();
4540                 
4541                 intPrevValue = intiter->second;
4542                 
4543                 // Process properties.
4544                 
4545                 size_t intPropertyValueLen = PropertyValue.Len();
4546                 
4547                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4548                         
4549                         PropertyValue.Trim();
4550                         PropertyValue.RemoveLast();
4551                         
4552                 }                               
4553                 
4554                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4555                         
4556                         PropertyValue.Remove(0, 1);
4557                         
4558                 }                       
4559                 
4560                 CaptureString(&PropertyValue, FALSE);
4561                 
4562                 if (PropertyName == wxT("ALTID")){
4564                         SoundsListAltID.erase(*SoundCount);
4565                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4566                 
4567                 } else if (PropertyName == wxT("PID")){
4569                         SoundsListPID.erase(*SoundCount);
4570                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4571                 
4572                 } else if (PropertyName == wxT("PREF")){
4574                         ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4575                 
4576                 } else if (PropertyName == wxT("MEDIATYPE")){
4577                 
4578                         SoundsListMediatype.erase(*SoundCount);
4579                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4581                 } else if (PropertyName == wxT("LANGUAGE")){
4582                 
4583                         SoundsListLanguage.erase(*SoundCount);
4584                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4586                 } else {
4587                 
4588                         // Something else we don't know about so append
4589                         // to the tokens variable.
4590                         
4591                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4592                         
4593                                 if (FirstToken == TRUE){
4594                                 
4595                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4596                                         FirstToken = FALSE;
4597                                 
4598                                 } else {
4599                                 
4600                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4601                                 
4602                                 }
4603                         
4604                         }
4605                 
4606                 }
4607         
4608         }       
4609         
4610         intPropertyLen = PropertySeg2.Len();
4611         SplitPoints.clear();
4612         SplitLength.clear();
4613         intSplitsFound = 0;
4614         intSplitSize = 0;
4615         intPrevValue = 0;
4616         
4617         CaptureString(&PropertySeg2, FALSE);
4618         
4619         for (int i = 0; i <= intPropertyLen; i++){
4621                 intSplitSize++;
4622         
4623                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4624         
4625                         intSplitsFound++;
4626                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4627                         
4628                         if (intSplitsFound == 6){ 
4629                         
4630                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4631                                 break; 
4632                                 
4633                         } else {
4634                         
4635                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4636                         
4637                         }
4638                         
4639                         intSplitSize = 0;                                       
4640         
4641                 }
4643         }
4644         
4645         wxString wxSSoundURI;
4646         wxString wxSSoundMIME;
4647         wxString wxSSoundEncoding;
4648         wxString wxSSoundData;
4649         std::string base64enc;
4650         
4651         if (intSplitsFound == 0){
4652         
4653         } else {
4654         
4655                 std::map<int, int>::iterator striter;
4656         
4657                 striter = SplitLength.find(1);
4658         
4659                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4660         
4661                 while (wSTDataType.HasMoreTokens() == TRUE){
4662                 
4663                         wxSSoundURI = wSTDataType.GetNextToken();
4664                         wxSSoundMIME = wSTDataType.GetNextToken();
4665                         break;
4666                 
4667                 }                       
4668         
4669                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4670         
4671                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4672                 
4673                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4674                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4675                         base64enc = wxSSoundData.mb_str();
4676                         break;
4677                 
4678                 }
4679         
4680         }
4681         
4682         // Add the data to the General/Home/Work address variables.
4683                 
4684         switch(PropType){
4685                 case PROPERTY_NONE:
4686                         break;
4687                 case PROPERTY_HOME:
4688                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4689                         break;
4690                 case PROPERTY_WORK:
4691                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4692                         break;
4693         }
4694         
4695         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4696         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4697         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4698         
4699         if (!PropertyTokens.IsEmpty()){
4700         
4701                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4702         
4703         }
4704         
4707 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4709         size_t intPropertyLen = PropertySeg1.Len();
4710         std::map<int, int> SplitPoints;
4711         std::map<int, int> SplitLength;
4712         std::map<int, int>::iterator SLiter;                    
4713         wxString PropertyData;
4714         wxString PropertyName;
4715         wxString PropertyValue;
4716         wxString PropertyTokens;
4717         bool FirstToken = TRUE;
4718         int intSplitsFound = 0;
4719         int intSplitSize = 0;
4720         int intPrevValue = 8;
4721         int intPref = 0;                        
4722         int intType = 0;
4723         
4724         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4725         
4726         intPrevValue = 7;
4727         
4728         PropertyType PropType = PROPERTY_NONE;
4729         
4730         // Look for type before continuing.                     
4732         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4734         intPrevValue = 7;
4736         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4737         intiter != SplitPoints.end(); ++intiter){
4738         
4739                 SLiter = SplitLength.find(intiter->first);
4740         
4741                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4742                 
4743                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4744                 PropertyName = PropertyElement.GetNextToken();                          
4745                 PropertyValue = PropertyElement.GetNextToken();
4746                 
4747                 intPrevValue = intiter->second;
4748                 
4749                 // Process properties.
4750                 
4751                 size_t intPropertyValueLen = PropertyValue.Len();
4752                 
4753                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4754                         
4755                         PropertyValue.Trim();
4756                         PropertyValue.RemoveLast();
4757                         
4758                 }                               
4759                 
4760                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4761                         
4762                         PropertyValue.Remove(0, 1);
4763                         
4764                 }                       
4765                 
4766                 CaptureString(&PropertyValue, FALSE);
4767                 
4768                 if (PropertyName == wxT("ALTID")){
4770                         CalendarListAltID.erase(*CalURICount);
4771                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4772                 
4773                 } else if (PropertyName == wxT("PID")){
4775                         CalendarListPID.erase(*CalURICount);
4776                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4777                 
4778                 } else if (PropertyName == wxT("PREF")){
4780                         ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4781                 
4782                 } else if (PropertyName == wxT("MEDIATYPE")){
4783                 
4784                         CalendarListMediatype.erase(*CalURICount);
4785                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4787                 } else {
4788                 
4789                         // Something else we don't know about so append
4790                         // to the tokens variable.
4791                         
4792                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4793                         
4794                                 if (FirstToken == TRUE){
4795                                 
4796                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4797                                         FirstToken = FALSE;
4798                                 
4799                                 } else {
4800                                 
4801                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4802                                 
4803                                 }
4804                         
4805                         }
4806                 
4807                 }
4808         
4809         }       
4810         
4811         intPropertyLen = PropertySeg2.Len();
4812         SplitPoints.clear();
4813         SplitLength.clear();
4814         intSplitsFound = 0;
4815         intSplitSize = 0;
4816         intPrevValue = 0;
4817         
4818         CaptureString(&PropertySeg2, FALSE);
4819         
4820         // Add the data to the General/Home/Work address variables.
4821                 
4822         switch(PropType){
4823                 case PROPERTY_NONE:
4824                         break;
4825                 case PROPERTY_HOME:
4826                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4827                         break;
4828                 case PROPERTY_WORK:
4829                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4830                         break;
4831         }
4832         
4833         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4834         
4835         if (!PropertyTokens.IsEmpty()){
4836         
4837                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4838         
4839         }
4843 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4845         size_t intPropertyLen = PropertySeg1.Len();
4846         std::map<int, int> SplitPoints;
4847         std::map<int, int> SplitLength;
4848         std::map<int, int>::iterator SLiter;                    
4849         wxString PropertyData;
4850         wxString PropertyName;
4851         wxString PropertyValue;
4852         wxString PropertyTokens;
4853         bool FirstToken = TRUE;
4854         int intSplitsFound = 0;
4855         int intSplitSize = 0;
4856         int intPrevValue = 8;
4857         int intPref = 0;                        
4858         int intType = 0;
4859         
4860         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4861         
4862         intPrevValue = 7;
4863         
4864         PropertyType PropType = PROPERTY_NONE;
4865         
4866         // Look for type before continuing.                     
4868         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4870         intPrevValue = 7;
4872         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4873         intiter != SplitPoints.end(); ++intiter){
4874         
4875                 SLiter = SplitLength.find(intiter->first);
4876         
4877                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4878                 
4879                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4880                 PropertyName = PropertyElement.GetNextToken();                          
4881                 PropertyValue = PropertyElement.GetNextToken();
4882                 
4883                 intPrevValue = intiter->second;
4884                 
4885                 // Process properties.
4886                 
4887                 size_t intPropertyValueLen = PropertyValue.Len();
4888                 
4889                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4890                         
4891                         PropertyValue.Trim();
4892                         PropertyValue.RemoveLast();
4893                         
4894                 }                               
4895                 
4896                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4897                         
4898                         PropertyValue.Remove(0, 1);
4899                         
4900                 }                       
4901                 
4902                 CaptureString(&PropertyValue, FALSE);
4903                 
4904                 if (PropertyName == wxT("ALTID")){
4906                         CalendarRequestListAltID.erase(*CalAdrURICount);
4907                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4908                 
4909                 } else if (PropertyName == wxT("PID")){
4911                         CalendarRequestListPID.erase(*CalAdrURICount);
4912                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4913                 
4914                 } else if (PropertyName == wxT("PREF")){
4916                         ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
4917                 
4918                 } else if (PropertyName == wxT("MEDIATYPE")){
4919                 
4920                         CalendarRequestListMediatype.erase(*CalAdrURICount);
4921                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4923                 } else {
4924                 
4925                         // Something else we don't know about so append
4926                         // to the tokens variable.
4927                         
4928                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4929                         
4930                                 if (FirstToken == TRUE){
4931                                 
4932                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4933                                         FirstToken = FALSE;
4934                                 
4935                                 } else {
4936                                 
4937                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4938                                 
4939                                 }
4940                         
4941                         }
4942                 
4943                 }
4944         
4945         }       
4946         
4947         intPropertyLen = PropertySeg2.Len();
4948         SplitPoints.clear();
4949         SplitLength.clear();
4950         intSplitsFound = 0;
4951         intSplitSize = 0;
4952         intPrevValue = 0;
4953         
4954         CaptureString(&PropertySeg2, FALSE);
4955         
4956         // Add the data to the General/Home/Work address variables.
4957                 
4958         switch(PropType){
4959                 case PROPERTY_NONE:
4960                         break;
4961                 case PROPERTY_HOME:
4962                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4963                         break;
4964                 case PROPERTY_WORK:
4965                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4966                         break;
4967         }
4968         
4969         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4970         
4971         if (!PropertyTokens.IsEmpty()){
4972         
4973                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4974         
4975         }       
4976         
4979 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4981         size_t intPropertyLen = PropertySeg1.Len();
4982         std::map<int, int> SplitPoints;
4983         std::map<int, int> SplitLength;
4984         std::map<int, int>::iterator SLiter;                    
4985         wxString PropertyData;
4986         wxString PropertyName;
4987         wxString PropertyValue;
4988         wxString PropertyTokens;
4989         bool FirstToken = TRUE;
4990         int intSplitsFound = 0;
4991         int intSplitSize = 0;
4992         int intPrevValue = 7;
4993         int intPref = 0;                        
4994         int intType = 0;
4995         
4996         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4997         
4998         intPrevValue = 6;
4999         
5000         PropertyType PropType = PROPERTY_NONE;
5001         
5002         // Look for type before continuing.                     
5004         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5006         intPrevValue = 6;
5008         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5009         intiter != SplitPoints.end(); ++intiter){
5010         
5011                 SLiter = SplitLength.find(intiter->first);
5012         
5013                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5014                 
5015                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5016                 PropertyName = PropertyElement.GetNextToken();                          
5017                 PropertyValue = PropertyElement.GetNextToken();
5018                 
5019                 intPrevValue = intiter->second;
5020                 
5021                 // Process properties.
5022                 
5023                 size_t intPropertyValueLen = PropertyValue.Len();
5024                 
5025                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5026                         
5027                         PropertyValue.Trim();
5028                         PropertyValue.RemoveLast();
5029                         
5030                 }                               
5031                 
5032                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5033                         
5034                         PropertyValue.Remove(0, 1);
5035                         
5036                 }                       
5037                 
5038                 CaptureString(&PropertyValue, FALSE);
5039                 
5040                 if (PropertyName == wxT("ALTID")){
5042                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5043                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5044                 
5045                 } else if (PropertyName == wxT("PID")){
5047                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5048                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5049                 
5050                 } else if (PropertyName == wxT("PREF")){
5052                         ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5053                 
5054                 } else if (PropertyName == wxT("MEDIATYPE")){
5055                 
5056                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5057                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5059                 } else {
5060                 
5061                         // Something else we don't know about so append
5062                         // to the tokens variable.
5063                         
5064                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5065                         
5066                                 if (FirstToken == TRUE){
5067                                 
5068                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5069                                         FirstToken = FALSE;
5070                                 
5071                                 } else {
5072                                 
5073                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5074                                 
5075                                 }
5076                         
5077                         }
5078                 
5079                 }
5080         
5081         }       
5082         
5083         intPropertyLen = PropertySeg2.Len();
5084         SplitPoints.clear();
5085         SplitLength.clear();
5086         intSplitsFound = 0;
5087         intSplitSize = 0;
5088         intPrevValue = 0;
5089         
5090         CaptureString(&PropertySeg2, FALSE);
5091         
5092         // Add the data to the General/Home/Work address variables.
5093                 
5094         switch(PropType){
5095                 case PROPERTY_NONE:
5096                         break;
5097                 case PROPERTY_HOME:
5098                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5099                         break;
5100                 case PROPERTY_WORK:
5101                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5102                         break;
5103         }
5104         
5105         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5106         
5107         if (!PropertyTokens.IsEmpty()){
5108         
5109                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5110         
5111         }
5115 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5117         size_t intPropertyLen = PropertySeg1.Len();
5118         std::map<int, int> SplitPoints;
5119         std::map<int, int> SplitLength;
5120         std::map<int, int>::iterator SLiter;                    
5121         wxString PropertyData;
5122         wxString PropertyName;
5123         wxString PropertyValue;
5124         wxString PropertyTokens;
5125         bool FirstToken = TRUE;
5126         int intSplitsFound = 0;
5127         int intSplitSize = 0;
5128         int intPrevValue = 5;
5129         int intPref = 0;                        
5130         int intType = 0;
5131         long ListCtrlIndex;
5132         
5133         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5134         
5135         intPrevValue = 4;
5136         
5137         PropertyType PropType = PROPERTY_NONE;
5138         
5139         // Look for type before continuing.
5141         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5143         intPrevValue = 4;
5145         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5146         intiter != SplitPoints.end(); ++intiter){
5147         
5148                 SLiter = SplitLength.find(intiter->first);
5149         
5150                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5151                 
5152                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5153                 PropertyName = PropertyElement.GetNextToken();                          
5154                 PropertyValue = PropertyElement.GetNextToken();
5155                 
5156                 intPrevValue = intiter->second;
5157                 
5158                 // Process properties.
5159                 
5160                 size_t intPropertyValueLen = PropertyValue.Len();
5161                 
5162                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5163                         
5164                         PropertyValue.Trim();
5165                         PropertyValue.RemoveLast();
5166                         
5167                 }                               
5168                 
5169                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5170                         
5171                         PropertyValue.Remove(0, 1);
5172                         
5173                 }                               
5174                 
5175                 if (PropertyName == wxT("ALTID")){
5177                         KeyListAltID.erase(*KeyCount);
5178                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5179                 
5180                 } else if (PropertyName == wxT("PID")){
5182                         KeyListPID.erase(*KeyCount);
5183                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5184                 
5185                 } else if (PropertyName == wxT("PREF")){
5187                         ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5188                 
5189                 } else {
5190                 
5191                         // Something else we don't know about so append
5192                         // to the tokens variable.
5193                         
5194                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5195                         
5196                                 if (FirstToken == TRUE){
5197                                 
5198                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5199                                         FirstToken = FALSE;
5200                                 
5201                                 } else {
5202                                 
5203                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5204                                 
5205                                 }
5206                         
5207                         }
5208                 
5209                 }
5210         
5211         }                               
5212         
5213         intPropertyLen = PropertySeg2.Len();
5214         SplitPoints.clear();
5215         SplitLength.clear();
5216         intSplitsFound = 0;
5217         intSplitSize = 0;
5218         intPrevValue = 0;                       
5219         
5220         for (int i = 0; i <= intPropertyLen; i++){
5222                 intSplitSize++;
5223         
5224                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5225         
5226                         intSplitsFound++;
5227                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5228                         
5229                         if (intSplitsFound == 6){ 
5230                         
5231                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5232                                 break; 
5233                                 
5234                         } else {
5235                         
5236                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5237                         
5238                         }
5239                         
5240                         intSplitSize = 0;                                       
5241         
5242                 }
5244         }
5245         
5246         wxString wxSKeyURI;
5247         wxString wxSKeyMIME;
5248         wxString wxSKeyEncoding;
5249         wxString wxSKeyData;
5250         std::string base64enc;
5251         
5252         if (intSplitsFound == 0){
5253         
5254         } else {
5255         
5256                 std::map<int, int>::iterator striter;
5257         
5258                 striter = SplitLength.find(1);
5259         
5260                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5261         
5262                 while (wSTDataType.HasMoreTokens() == TRUE){
5263                 
5264                         wxSKeyURI = wSTDataType.GetNextToken();
5265                         wxSKeyMIME = wSTDataType.GetNextToken();
5266                         break;
5267                 
5268                 }                       
5269         
5270                 if (wxSKeyURI == wxT("data")){
5271                 
5272                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5273         
5274                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5275                 
5276                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5277                                 wxSKeyData = wSTDataInfo.GetNextToken();
5278                                 break;
5279                 
5280                         }
5281                 
5282                 }
5283         
5284         }
5285         
5286         // Add the data to the General/Home/Work address variables.
5287         
5288         if (wxSKeyURI == wxT("data")){
5289                 
5290                 KeyListDataEncType.erase(*KeyCount);
5291                 KeyListKeyType.erase(*KeyCount);
5292                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5293                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5294                 
5295                 KeyList.erase(*KeyCount);
5296                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5297         
5298         } else {
5299                 
5300                 KeyList.erase(*KeyCount);
5301                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5302         
5303         }
5304         
5305         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5306                 
5307         switch (PropType){
5308                 case PROPERTY_NONE:
5309                         break;
5310                 case PROPERTY_HOME: 
5311                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5312                         break;
5313                 case PROPERTY_WORK: 
5314                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5315                         break;
5316         }
5318         if (!PropertyTokens.IsEmpty()){
5320                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5322         }
5326 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5328         // Split the Vendor three ways.
5329         
5330         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5331         
5332         wxString wxSVNDID;
5333         wxString wxSVNDPropName;
5334         long ListCtrlIndex;                     
5336         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5337         
5338                 wSTVendorDetails.GetNextToken();
5339                 wxSVNDID = wSTVendorDetails.GetNextToken();
5340                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5341                 break;
5342         
5343         }
5344         
5345         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5346         
5347                 // Add the data to the vendor variables.
5348         
5349                 VendorList.erase(*VendorCount);
5350                 VendorListPEN.erase(*VendorCount);
5351                 VendorListElement.erase(*VendorCount);
5352         
5353                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5354                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5355                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5356         
5357         }
5361 void ProcessStringValue(wxString *PropertyName,
5362         wxString PropertyNameMatch,
5363         std::map<int,wxString> *MapPtr,
5364         wxString *PropertyValue,
5365         int *ItemCount,
5366         bool *PropertyMatched){
5367         
5368         if (*PropertyName == PropertyNameMatch){
5369                 MapPtr->erase(*ItemCount);
5370                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5371                 *PropertyMatched = TRUE;
5372         }
5373         
5376 void ProcessIntegerValue(wxString *PropertyName,
5377         wxString PropertyNameMatch,
5378         std::map<int,int> *PrefPtr, 
5379         wxString *PropertyValue, 
5380         int *ItemCount,
5381         bool *PropertyMatched){
5383         if (*PropertyName == PropertyNameMatch){
5384                 *PropertyMatched = TRUE;
5385         } else {
5386                 return;
5387         }
5389         int PriorityNumber = 0; 
5390         bool ValidNumber = TRUE;
5391                         
5392         try{
5393                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5394         }
5395                         
5396         catch(std::invalid_argument &e){
5397                 ValidNumber = FALSE;
5398         }
5400         if (ValidNumber == TRUE){
5402                 PrefPtr->erase(*ItemCount);
5403                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5405         }
5409 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
5410         wxString *PropertyValue, 
5411         int *ItemCount){
5413         int PriorityNumber = 0; 
5414         bool ValidNumber = TRUE;
5415                         
5416         try{
5417                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5418         }
5419                         
5420         catch(std::invalid_argument &e){
5421                 ValidNumber = FALSE;
5422         }
5424         if (ValidNumber == TRUE){
5426                 PrefPtr->erase(*ItemCount);
5427                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5429         }
5433 void SplitValues(wxString *PropertyLine, 
5434         std::map<int,int> *SplitPoints, 
5435         std::map<int,int> *SplitLength, 
5436         int intSize){
5437         
5438         size_t intPropertyLen = PropertyLine->Len();
5439         int intSplitsFound = 0;
5440         int intSplitSize = 0;
5441         int intSplitSeek = 0;
5442         
5443         for (int i = intSize; i <= intPropertyLen; i++){
5445                 intSplitSize++;
5446         
5447                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5448                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5449            
5450                     if (intSplitsFound == 0){
5451             
5452                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5453           
5454                     } else {
5455            
5456                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5457             
5458                     }
5459             
5460                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5461             
5462                     intSplitsFound++;
5463                     intSplitSeek = i;
5464                     intSplitSize = 0;
5465             
5466                 }
5468         }
5470         if (intSplitsFound == 0){
5472                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5473                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5475         } else {
5477                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5478                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5480         }
5484 void CheckType(wxString *PropertySeg1, 
5485         std::map<int,int> *SplitPoints, 
5486         std::map<int,int> *SplitLength, 
5487         int *intPrevValue, 
5488         PropertyType *PropType){
5489         
5490         wxString PropertyData;
5491         wxString PropertyName;
5492         wxString PropertyValue;
5493         std::map<int,int>::iterator SLiter;
5494         
5495         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5496         intiter != SplitPoints->end(); ++intiter){
5497         
5498                 SLiter = SplitLength->find(intiter->first);
5499         
5500                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5501                 
5502                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5503                 PropertyName = PropertyElement.GetNextToken();                          
5504                 PropertyValue = PropertyElement.GetNextToken();
5505                 
5506                 *intPrevValue = intiter->second;
5507                 
5508                 if (PropertyName == wxT("TYPE")){
5509                                 
5510                         if (PropertyValue == wxT("work")){
5511                         
5512                                 *PropType = PROPERTY_WORK;
5513                                                         
5514                         } else if (PropertyValue == wxT("home")){
5516                                 *PropType = PROPERTY_HOME;
5517                                                         
5518                         } else {
5519                         
5520                                 *PropType = PROPERTY_NONE;
5521                         
5522                         }
5523                 
5524                         return;
5525                 
5526                 }
5527         
5528         }
5529         
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