Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced string processing in TEL 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         
2594         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2595         intiter != SplitPoints.end(); ++intiter){
2596         
2597                 SLiter = SplitLength.find(intiter->first);
2598         
2599                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2600                 
2601                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2602                 PropertyName = PropertyElement.GetNextToken();                          
2603                 PropertyValue = PropertyElement.GetNextToken();
2604                 
2605                 intPrevValue = intiter->second;
2606                 
2607                 CaptureString(&PropertyValue, FALSE);
2608                 
2609                 // Process properties.
2610                 
2611                 if (PropertyName == wxT("ALTID")){
2613                         LanguageListAltID->erase(*LanguageCount);
2614                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2615                 
2616                 } else if (PropertyName == wxT("PID")){
2618                         LanguageListPID->erase(*LanguageCount);
2619                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2620                 
2621                 } else if (PropertyName == wxT("PREF")){
2622                         
2623                         ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2624                 
2625                 } else {
2626                 
2627                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2628                         
2629                                 if (FirstToken == TRUE){
2630                                 
2631                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2632                                         FirstToken = FALSE;
2633                                 
2634                                 } else {
2635                                 
2636                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2637                                 
2638                                 }
2639                         
2640                         }
2641                 
2642                 }
2643         
2644         }
2645                 
2646         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2647         
2648         // Add the name token data.
2649         
2650         if (!PropertyTokens.IsEmpty()){
2651         
2652                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2653         
2654         }
2658 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2660         std::map<int, int> SplitPoints;
2661         std::map<int, int> SplitLength;
2663         int intPrevValue = 5;
2664         int intPref = 0;                        
2665         
2666         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2667         
2668         intPrevValue = 4;
2669         
2670         PropertyType PropType = PROPERTY_NONE;
2671                 
2672         // Look for type before continuing.
2673         
2674         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2675         
2676         std::map<int, wxString> *GeopositionList = NULL;
2677         std::map<int, wxString> *GeopositionListType = NULL;
2678         std::map<int, wxString> *GeopositionListAltID = NULL;
2679         std::map<int, wxString> *GeopositionListPID = NULL;
2680         std::map<int, wxString> *GeopositionListTokens = NULL;
2681         std::map<int, wxString> *GeopositionListMediatype = NULL;
2682         std::map<int, int> *GeopositionListPref = NULL;
2684         switch(PropType){
2685                 case PROPERTY_NONE:
2686                         GeopositionList = &GeneralGeographyList;
2687                         GeopositionListType = &GeneralGeographyListType;
2688                         GeopositionListAltID = &GeneralGeographyListAltID;
2689                         GeopositionListPID = &GeneralGeographyListPID;
2690                         GeopositionListTokens = &GeneralGeographyListTokens;
2691                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2692                         GeopositionListPref = &GeneralGeographyListPref;        
2693                         break;
2694                 case PROPERTY_HOME:
2695                         GeopositionList = &HomeGeographyList;
2696                         GeopositionListType = &HomeGeographyListType;
2697                         GeopositionListAltID = &HomeGeographyListAltID;
2698                         GeopositionListPID = &HomeGeographyListPID;
2699                         GeopositionListTokens = &HomeGeographyListTokens;
2700                         GeopositionListMediatype = &HomeGeographyListMediatype;
2701                         GeopositionListPref = &HomeGeographyListPref;   
2702                         break;
2703                 case PROPERTY_WORK:
2704                         GeopositionList = &BusinessGeographyList;
2705                         GeopositionListType = &BusinessGeographyListType;
2706                         GeopositionListAltID = &BusinessGeographyListAltID;
2707                         GeopositionListPID = &BusinessGeographyListPID;
2708                         GeopositionListTokens = &BusinessGeographyListTokens;
2709                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2710                         GeopositionListPref = &BusinessGeographyListPref;
2711                         break;
2712         }
2713         
2714         intPrevValue = 4;
2715         
2716         std::map<int,int>::iterator SLiter;
2717         wxString PropertyData;
2718         wxString PropertyName;
2719         wxString PropertyValue;
2720         wxString PropertyTokens;
2721         bool FirstToken = TRUE;
2722         
2723         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2724         intiter != SplitPoints.end(); ++intiter){
2725         
2726                 SLiter = SplitLength.find(intiter->first);
2727         
2728                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2729                 
2730                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2731                 PropertyName = PropertyElement.GetNextToken();                          
2732                 PropertyValue = PropertyElement.GetNextToken();
2733                 
2734                 intPrevValue = intiter->second;
2735                 
2736                 CaptureString(&PropertyValue, FALSE);
2737                 
2738                 // Process properties.
2739                 
2740                 if (PropertyName == wxT("ALTID")){
2742                         GeopositionListAltID->erase(*GeographicCount);
2743                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2744                 
2745                 } else if (PropertyName == wxT("PID")){
2747                         GeopositionListPID->erase(*GeographicCount);
2748                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2749                 
2750                 } else if (PropertyName == wxT("MEDIATYPE")){
2752                         GeopositionListMediatype->erase(*GeographicCount);
2753                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2754                 
2755                 } else if (PropertyName == wxT("PREF")){
2757                         ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2758                 
2759                 } else {
2760                 
2761                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2762                         
2763                                 if (FirstToken == TRUE){
2764                                 
2765                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2766                                         FirstToken = FALSE;
2767                                 
2768                                 } else {
2769                                 
2770                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2771                                 
2772                                 }
2773                         
2774                         }
2775                 
2776                 }
2777         
2778         }
2779                 
2780         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2781         
2782         // Add the name token data.
2783         
2784         if (!PropertyTokens.IsEmpty()){
2785         
2786                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2787         
2788         }
2792 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2794         size_t intPropertyLen = PropertySeg1.Len();
2795         std::map<int, int> SplitPoints;
2796         std::map<int, int> SplitLength;
2797         std::map<int, int>::iterator SLiter;                    
2798         wxString PropertyData;
2799         wxString PropertyName;
2800         wxString PropertyValue;
2801         wxString PropertyTokens;
2802         wxString RelatedType;
2803         wxString RelatedTypeOriginal;                   
2804         wxString RelatedName;
2805         bool FirstToken = TRUE;                 
2806         int intSplitsFound = 0;
2807         int intSplitSize = 0;
2808         int intPrevValue = 9;
2809         int intPref = 0;
2810         long ListCtrlIndex;
2811         
2812         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2813         
2814         intPrevValue = 8;
2815         
2816         // Look for type before continuing.
2817         
2818         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2819         intiter != SplitPoints.end(); ++intiter){
2820         
2821                 SLiter = SplitLength.find(intiter->first);
2822         
2823                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2824                 
2825                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2826                 PropertyName = PropertyElement.GetNextToken();                          
2827                 PropertyValue = PropertyElement.GetNextToken();
2828                 
2829                 intPrevValue = intiter->second;
2830                 
2831                 // Process these.
2832                 
2833                 RelatedTypeOriginal = PropertyValue;
2834                 
2835                 if (PropertyName == wxT("TYPE")){
2836                 
2837                         if (PropertyValue == wxT("contact")){
2839                                 RelatedType = _("Contact");
2841                         } else if (PropertyValue == wxT("acquaintance")){
2843                                 RelatedType = _("Acquaintance");
2845                         } else if (PropertyValue == wxT("friend")){
2847                                 RelatedType = _("Friend");
2849                         } else if (PropertyValue == wxT("met")){
2851                                 RelatedType = _("Met");
2853                         } else if (PropertyValue == wxT("co-worker")){
2855                                 RelatedType = _("Co-worker");
2857                         } else if (PropertyValue == wxT("colleague")){
2859                                 RelatedType = _("Colleague");
2861                         } else if (PropertyValue == wxT("co-resident")){
2863                                 RelatedType = _("Co-resident");
2865                         } else if (PropertyValue == wxT("neighbor")){
2867                                 RelatedType = _("Neighbour");
2869                         } else if (PropertyValue == wxT("child")){
2871                                 RelatedType = _("Child");
2873                         } else if (PropertyValue == wxT("parent")){
2875                                 RelatedType = _("Parent");
2877                         } else if (PropertyValue == wxT("sibling")){
2879                                 RelatedType = _("Sibling");
2881                         } else if (PropertyValue == wxT("spouse")){
2883                                 RelatedType = _("Spouse");
2885                         } else if (PropertyValue == wxT("kin")){
2887                                 RelatedType = _("Kin");
2889                         } else if (PropertyValue == wxT("muse")){
2891                                 RelatedType = _("Muse");
2893                         } else if (PropertyValue == wxT("crush")){
2895                                 RelatedType = _("Crush");
2897                         } else if (PropertyValue == wxT("date")){
2899                                 RelatedType = _("Date");
2901                         } else if (PropertyValue == wxT("sweetheart")){
2903                                 RelatedType = _("Sweetheart");
2905                         } else if (PropertyValue == wxT("me")){
2907                                 RelatedType = _("Me");
2909                         } else if (PropertyValue == wxT("agent")){
2911                                 RelatedType = _("Agent");
2913                         } else if (PropertyValue == wxT("emergency")){
2915                                 RelatedType = _("Emergency");
2917                         } else {
2919                                 RelatedType = PropertyValue;
2921                         }
2922                 
2923                 }
2924         
2925         }
2926         
2927         intPrevValue = 8;                       
2928         
2929         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2930         intiter != SplitPoints.end(); ++intiter){
2931         
2932                 SLiter = SplitLength.find(intiter->first);
2933         
2934                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2935                 
2936                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2937                 PropertyName = PropertyElement.GetNextToken();                          
2938                 PropertyValue = PropertyElement.GetNextToken();
2939                 
2940                 intPrevValue = intiter->second;
2941                 
2942                 // Process properties.
2943                 
2944                 size_t intPropertyValueLen = PropertyValue.Len();
2945                 
2946                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2947                         
2948                         PropertyValue.Trim();
2949                         PropertyValue.RemoveLast();
2950                         
2951                 }                               
2952                 
2953                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2954                         
2955                         PropertyValue.Remove(0, 1);
2956                         
2957                 }
2958                 
2959                 CaptureString(&PropertyValue, FALSE);
2960                         
2961                 if (PropertyName == wxT("ALTID")){
2963                         GeneralRelatedListAltID.erase(*RelatedCount);
2964                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2965                 
2966                 } else if (PropertyName == wxT("PID")){
2968                         GeneralRelatedListPID.erase(*RelatedCount);
2969                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2970                 
2971                 } else if (PropertyName == wxT("PREF")){
2972                         
2973                         int PriorityNumber = 0;
2974                         bool ValidNumber = TRUE;
2975                         
2976                         try{
2977                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2978                         }
2979                         
2980                         catch(std::invalid_argument &e){
2981                                 ValidNumber = FALSE;
2982                         }
2984                         if (ValidNumber == TRUE){
2986                                 GeneralRelatedListPref.erase(*RelatedCount);
2987                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2989                         }
2990                 
2991                 } else if (PropertyName == wxT("LANGUAGE")){
2993                         ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
2994                 
2995                 } else if (PropertyName != wxT("TYPE")) {
2996                 
2997                         // Something else we don't know about so append
2998                         // to the tokens variable.
2999                 
3000                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3001                 
3002                                 if (FirstToken == TRUE){
3003                         
3004                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3005                                         FirstToken = FALSE;
3006                         
3007                                 } else {
3008                         
3009                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3010                         
3011                                 }
3012                 
3013                         }
3014                 
3015                 }
3016         
3017         }                                       
3018         
3019         // Add the data to the General/Home/Work address variables.
3020                                 
3021         GeneralRelatedList.erase(*RelatedCount);
3022         GeneralRelatedListRelType.erase(*RelatedCount);
3023         GeneralRelatedListType.erase(*RelatedCount);
3024         GeneralRelatedListTokens.erase(*RelatedCount);
3025         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3026         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3027         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3028         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3032 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3034         std::map<int, int> SplitPoints;
3035         std::map<int, int> SplitLength;
3036         std::map<int, int>::iterator SLiter;                    
3037         wxString PropertyData;
3038         wxString PropertyName;
3039         wxString PropertyValue;
3040         wxString PropertyTokens;
3041         bool FirstToken = TRUE;
3042         int intPrevValue = 5;
3043         int intPref = 0;                        
3044         int intType = 0;
3045         long ListCtrlIndex;
3046         
3047         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3048         
3049         intPrevValue = 4;
3050         
3051         PropertyType PropType = PROPERTY_NONE;
3052                 
3053         // Look for type before continuing.
3054         
3055         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3056         
3057         // Setup the pointers.
3058         
3059         std::map<int, wxString> *WebsiteList = NULL;
3060         std::map<int, wxString> *WebsiteListAltID = NULL;
3061         std::map<int, wxString> *WebsiteListPID = NULL;
3062         std::map<int, wxString> *WebsiteListType = NULL;
3063         std::map<int, wxString> *WebsiteListTokens = NULL;
3064         std::map<int, wxString> *WebsiteListMediatype = NULL;
3065         std::map<int, int> *WebsiteListPref = NULL;
3066         
3067         // Setup blank lines for later on.
3068         
3069         switch(PropType){
3070                 case PROPERTY_NONE:
3071                         WebsiteList = &GeneralWebsiteList;
3072                         WebsiteListType = &GeneralWebsiteListType;
3073                         WebsiteListAltID = &GeneralWebsiteListAltID;
3074                         WebsiteListPID = &GeneralWebsiteListPID;
3075                         WebsiteListTokens = &GeneralWebsiteListTokens;
3076                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3077                         WebsiteListPref = &GeneralWebsiteListPref;      
3078                         break;
3079                 case PROPERTY_HOME:
3080                         WebsiteList = &HomeWebsiteList;
3081                         WebsiteListType = &HomeWebsiteListType;
3082                         WebsiteListAltID = &HomeWebsiteListAltID;
3083                         WebsiteListPID = &HomeWebsiteListPID;
3084                         WebsiteListTokens = &HomeWebsiteListTokens;
3085                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3086                         WebsiteListPref = &HomeWebsiteListPref; 
3087                         break;
3088                 case PROPERTY_WORK:
3089                         WebsiteList = &BusinessWebsiteList;
3090                         WebsiteListType = &BusinessWebsiteListType;
3091                         WebsiteListAltID = &BusinessWebsiteListAltID;
3092                         WebsiteListPID = &BusinessWebsiteListPID;
3093                         WebsiteListTokens = &BusinessWebsiteListTokens;
3094                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3095                         WebsiteListPref = &BusinessWebsiteListPref;
3096                         break;
3097         }
3098         
3099         intPrevValue = 4;
3100         
3101         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3102         intiter != SplitPoints.end(); ++intiter){
3103         
3104                 SLiter = SplitLength.find(intiter->first);
3105         
3106                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3107                 
3108                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3109                 PropertyName = PropertyElement.GetNextToken();                          
3110                 PropertyValue = PropertyElement.GetNextToken();
3111                 
3112                 intPrevValue = intiter->second;
3113                 
3114                 // Process properties.
3115                 
3116                 size_t intPropertyValueLen = PropertyValue.Len();
3117                 
3118                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3119                         
3120                         PropertyValue.Trim();
3121                         PropertyValue.RemoveLast();
3122                         
3123                 }                               
3124                 
3125                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3126                         
3127                         PropertyValue.Remove(0, 1);
3128                         
3129                 }
3130                 
3131                 CaptureString(&PropertyValue, FALSE);
3132                 
3133                 if (PropertyName == wxT("ALTID")){
3135                         WebsiteListAltID->erase(*URLCount);
3136                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3137                 
3138                 } else if (PropertyName == wxT("PID")){
3140                         WebsiteListPID->erase(*URLCount);
3141                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3142                         
3143                 } else if (PropertyName == wxT("PREF")){
3145                         ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3146                                                         
3147                 } else if (PropertyName == wxT("MEDIATYPE")){
3148                 
3149                         WebsiteListMediatype->erase(*URLCount);
3150                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3151                 
3152                 } else {
3153                 
3154                         // Something else we don't know about so append
3155                         // to the tokens variable.
3156                 
3157                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3158                 
3159                                 if (FirstToken == TRUE){
3160                         
3161                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3162                                         FirstToken = FALSE;
3163                         
3164                                 } else {
3165                         
3166                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3167                         
3168                                 }
3169                 
3170                         }
3171                 
3172                 }
3173         
3174         }
3175         
3176         // Add the data to the General/Home/Work address variables.
3177         
3178         CaptureString(&PropertySeg2, FALSE);
3179                         
3180         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3181         
3182         if (!PropertyTokens.IsEmpty()){
3183         
3184                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3185                         
3186         }
3187         
3190 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3192         std::map<int, int> SplitPoints;
3193         std::map<int, int> SplitLength;
3194         std::map<int, int>::iterator SLiter;                    
3195         wxString PropertyData;
3196         wxString PropertyName;
3197         wxString PropertyValue;
3198         wxString PropertyTokens;
3199         bool FirstToken = TRUE;
3200         int intPrevValue = 7;
3201         int intPref = 0;                        
3202         int intType = 0;
3203         long ListCtrlIndex;
3204         
3205         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3206         
3207         intPrevValue = 6;
3208         
3209         PropertyType PropType = PROPERTY_NONE;
3210                 
3211         // Look for type before continuing.
3212         
3213         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3214         
3215         // Setup the pointers.
3216         
3217         std::map<int, wxString> *TitleList = NULL;
3218         std::map<int, wxString> *TitleListAltID = NULL;
3219         std::map<int, wxString> *TitleListPID = NULL;
3220         std::map<int, wxString> *TitleListType = NULL;
3221         std::map<int, wxString> *TitleListTokens = NULL;
3222         std::map<int, wxString> *TitleListLanguage = NULL;
3223         std::map<int, int> *TitleListPref = NULL;
3224         
3225         // Setup blank lines for later on.
3226         
3227         switch(PropType){
3228                 case PROPERTY_NONE:
3229                         TitleList = &GeneralTitleList;
3230                         TitleListType = &GeneralTitleListType;
3231                         TitleListAltID = &GeneralTitleListAltID;
3232                         TitleListPID = &GeneralTitleListPID;
3233                         TitleListTokens = &GeneralTitleListTokens;
3234                         TitleListLanguage = &GeneralTitleListLanguage;
3235                         TitleListPref = &GeneralTitleListPref;  
3236                         break;
3237                 case PROPERTY_HOME:
3238                         TitleList = &HomeTitleList;
3239                         TitleListType = &HomeTitleListType;
3240                         TitleListAltID = &HomeTitleListAltID;
3241                         TitleListPID = &HomeTitleListPID;
3242                         TitleListTokens = &HomeTitleListTokens;
3243                         TitleListLanguage = &HomeTitleListLanguage;
3244                         TitleListPref = &HomeTitleListPref;     
3245                         break;
3246                 case PROPERTY_WORK:
3247                         TitleList = &BusinessTitleList;
3248                         TitleListType = &BusinessTitleListType;
3249                         TitleListAltID = &BusinessTitleListAltID;
3250                         TitleListPID = &BusinessTitleListPID;
3251                         TitleListTokens = &BusinessTitleListTokens;
3252                         TitleListLanguage = &BusinessTitleListLanguage; 
3253                         TitleListPref = &BusinessTitleListPref;
3254                         break;
3255         }
3257         intPrevValue = 6;
3258                 
3259         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3260         intiter != SplitPoints.end(); ++intiter){
3261         
3262                 SLiter = SplitLength.find(intiter->first);
3263         
3264                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3265                 
3266                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3267                 PropertyName = PropertyElement.GetNextToken();                          
3268                 PropertyValue = PropertyElement.GetNextToken();
3269                 
3270                 intPrevValue = intiter->second;
3271                 
3272                 // Process properties.
3273                 
3274                 size_t intPropertyValueLen = PropertyValue.Len();
3275                 
3276                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3277                         
3278                         PropertyValue.Trim();
3279                         PropertyValue.RemoveLast();
3280                         
3281                 }                               
3282                 
3283                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3284                         
3285                         PropertyValue.Remove(0, 1);
3286                         
3287                 }                               
3288                 
3289                 CaptureString(&PropertyValue, FALSE);
3290                 
3291                 if (PropertyName == wxT("ALTID")){
3292                 
3293                         TitleListAltID->erase(*TitleCount);
3294                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3295                 
3296                 } else if (PropertyName == wxT("PID")){
3298                         TitleListPID->erase(*TitleCount);
3299                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3300                 
3301                 } else if (PropertyName == wxT("PREF")){
3303                         ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3304                         
3305                 } else if (PropertyName == wxT("LANGUAGE")){
3306                 
3307                         TitleListLanguage->erase(*TitleCount);
3308                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3309                 
3310                 } else {
3311                 
3312                         // Something else we don't know about so append
3313                         // to the tokens variable.
3314                 
3315                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3316                 
3317                                 if (FirstToken == TRUE){
3318                         
3319                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3320                                         FirstToken = FALSE;
3321                         
3322                                 } else {
3323                         
3324                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3325                         
3326                                 }
3327                 
3328                         }
3329                 
3330                 }
3331         
3332         }
3333         
3334         // Add the data to the General/Home/Work address variables.
3335         
3336         CaptureString(&PropertySeg2, FALSE);
3338         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3339         
3340         if (!PropertyTokens.IsEmpty()){
3341         
3342                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3343                         
3344         }
3348 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3350         std::map<int, int> SplitPoints;
3351         std::map<int, int> SplitLength;
3352         std::map<int, int>::iterator SLiter;                    
3353         wxString PropertyData;
3354         wxString PropertyName;
3355         wxString PropertyValue;
3356         wxString PropertyTokens;
3357         bool FirstToken = TRUE;
3358         int intPrevValue = 6;
3359         int intPref = 0;                        
3360         int intType = 0;
3361         long ListCtrlIndex;
3362         
3363         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3364         
3365         intPrevValue = 5;
3366         
3367         PropertyType PropType = PROPERTY_NONE;
3368                 
3369         // Look for type before continuing.
3370         
3371         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3372         
3373         // Setup the pointers.
3374         
3375         std::map<int, wxString> *RoleList = NULL;
3376         std::map<int, wxString> *RoleListAltID = NULL;
3377         std::map<int, wxString> *RoleListPID = NULL;
3378         std::map<int, wxString> *RoleListType = NULL;
3379         std::map<int, wxString> *RoleListTokens = NULL;
3380         std::map<int, wxString> *RoleListLanguage = NULL;
3381         std::map<int, int> *RoleListPref = NULL;
3382         
3383         // Setup blank lines for later on.
3384         
3385         switch(PropType){
3386                 case PROPERTY_NONE:
3387                         RoleList = &GeneralRoleList;
3388                         RoleListType = &GeneralRoleListType;
3389                         RoleListAltID = &GeneralRoleListAltID;
3390                         RoleListPID = &GeneralRoleListPID;
3391                         RoleListTokens = &GeneralRoleListTokens;
3392                         RoleListLanguage = &GeneralRoleListLanguage;
3393                         RoleListPref = &GeneralRoleListPref;    
3394                         break;
3395                 case PROPERTY_HOME:
3396                         RoleList = &HomeRoleList;
3397                         RoleListType = &HomeRoleListType;
3398                         RoleListAltID = &HomeRoleListAltID;
3399                         RoleListPID = &HomeRoleListPID;
3400                         RoleListTokens = &HomeRoleListTokens;
3401                         RoleListLanguage = &HomeRoleListLanguage;
3402                         RoleListPref = &HomeRoleListPref;       
3403                         break;
3404                 case PROPERTY_WORK:
3405                         RoleList = &BusinessRoleList;
3406                         RoleListType = &BusinessRoleListType;
3407                         RoleListAltID = &BusinessRoleListAltID;
3408                         RoleListPID = &BusinessRoleListPID;
3409                         RoleListTokens = &BusinessRoleListTokens;
3410                         RoleListLanguage = &BusinessRoleListLanguage;   
3411                         RoleListPref = &BusinessRoleListPref;
3412                         break;
3413         }
3415         intPrevValue = 5;
3416                 
3417         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3418         intiter != SplitPoints.end(); ++intiter){
3419         
3420                 SLiter = SplitLength.find(intiter->first);
3421         
3422                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3423                 
3424                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3425                 PropertyName = PropertyElement.GetNextToken();                          
3426                 PropertyValue = PropertyElement.GetNextToken();
3427                 
3428                 intPrevValue = intiter->second;
3429                 
3430                 // Process properties.
3431                 
3432                 size_t intPropertyValueLen = PropertyValue.Len();
3433                 
3434                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3435                         
3436                         PropertyValue.Trim();
3437                         PropertyValue.RemoveLast();
3438                         
3439                 }                               
3440                 
3441                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3442                         
3443                         PropertyValue.Remove(0, 1);
3444                         
3445                 }                               
3446                 
3447                 CaptureString(&PropertyValue, FALSE);
3448                 
3449                 if (PropertyName == wxT("ALTID")){
3450                 
3451                         RoleListAltID->erase(*RoleCount);
3452                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3453                 
3454                 } else if (PropertyName == wxT("PID")){
3456                         RoleListPID->erase(*RoleCount);
3457                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3458                 
3459                 } else if (PropertyName == wxT("PREF")){
3461                         ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3462                                 
3463                 } else if (PropertyName == wxT("LANGUAGE")){
3464                 
3465                         RoleListLanguage->erase(*RoleCount);
3466                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3467                 
3468                 } else {
3469                 
3470                         // Something else we don't know about so append
3471                         // to the tokens variable.
3472                 
3473                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3474                 
3475                                 if (FirstToken == TRUE){
3476                         
3477                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3478                                         FirstToken = FALSE;
3479                         
3480                                 } else {
3481                         
3482                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3483                         
3484                                 }
3485                 
3486                         }
3487                 
3488                 }
3489         
3490         }
3491         
3492         // Add the data to the General/Home/Work address variables.
3493         
3494         CaptureString(&PropertySeg2, FALSE);
3496         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3497         
3498         if (!PropertyTokens.IsEmpty()){
3499         
3500                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3501                         
3502         }
3506 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3508         std::map<int, int> SplitPoints;
3509         std::map<int, int> SplitLength;
3510         std::map<int, int>::iterator SLiter;                    
3511         wxString PropertyData;
3512         wxString PropertyName;
3513         wxString PropertyValue;
3514         wxString PropertyTokens;
3515         bool FirstToken = TRUE;
3516         int intPrevValue = 5;
3517         int intPref = 0;                        
3518         int intType = 0;
3519         long ListCtrlIndex;
3520         
3521         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3522         
3523         intPrevValue = 4;
3524         
3525         PropertyType PropType = PROPERTY_NONE;
3526                 
3527         // Look for type before continuing.
3528         
3529         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3530         
3531         // Setup the pointers.
3532         
3533         std::map<int, wxString> *OrganisationsList = NULL;
3534         std::map<int, wxString> *OrganisationsListAltID = NULL;
3535         std::map<int, wxString> *OrganisationsListPID = NULL;
3536         std::map<int, wxString> *OrganisationsListType = NULL;
3537         std::map<int, wxString> *OrganisationsListTokens = NULL;
3538         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3539         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3540         std::map<int, int> *OrganisationsListPref = NULL;
3541         
3542         // Setup blank lines for later on.
3543         
3544         switch(PropType){
3545                 case PROPERTY_NONE:
3546                         OrganisationsList = &GeneralOrganisationsList;
3547                         OrganisationsListType = &GeneralOrganisationsListType;
3548                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3549                         OrganisationsListPID = &GeneralOrganisationsListPID;
3550                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3551                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3552                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3553                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3554                         break;
3555                 case PROPERTY_HOME:
3556                         OrganisationsList = &HomeOrganisationsList;
3557                         OrganisationsListType = &HomeOrganisationsListType;
3558                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3559                         OrganisationsListPID = &HomeOrganisationsListPID;
3560                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3561                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3562                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3563                         OrganisationsListPref = &HomeOrganisationsListPref;     
3564                         break;
3565                 case PROPERTY_WORK:
3566                         OrganisationsList = &BusinessOrganisationsList;
3567                         OrganisationsListType = &BusinessOrganisationsListType;
3568                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3569                         OrganisationsListPID = &BusinessOrganisationsListPID;
3570                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3571                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3572                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3573                         OrganisationsListPref = &BusinessOrganisationsListPref;
3574                         break;
3575         }
3577         intPrevValue = 4;
3578                 
3579         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3580         intiter != SplitPoints.end(); ++intiter){
3581         
3582                 SLiter = SplitLength.find(intiter->first);
3583         
3584                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3585                 
3586                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3587                 PropertyName = PropertyElement.GetNextToken();                          
3588                 PropertyValue = PropertyElement.GetNextToken();
3589                 
3590                 intPrevValue = intiter->second;
3591                 
3592                 // Process properties.
3593                 
3594                 size_t intPropertyValueLen = PropertyValue.Len();
3595                 
3596                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3597                         
3598                         PropertyValue.Trim();
3599                         PropertyValue.RemoveLast();
3600                         
3601                 }                               
3602                 
3603                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3604                         
3605                         PropertyValue.Remove(0, 1);
3606                         
3607                 }                               
3608                 
3609                 CaptureString(&PropertyValue, FALSE);
3610                 
3611                 if (PropertyName == wxT("ALTID")){
3612                 
3613                         OrganisationsListAltID->erase(*OrganisationCount);
3614                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3615                 
3616                 } else if (PropertyName == wxT("PID")){
3618                         OrganisationsListPID->erase(*OrganisationCount);
3619                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3620                 
3621                 } else if (PropertyName == wxT("SORT-AS")){
3623                         OrganisationsListSortAs->erase(*OrganisationCount);
3624                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3625                 
3626                 } else if (PropertyName == wxT("PREF")){
3628                         ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3629                         
3630                 } else if (PropertyName == wxT("LANGUAGE")){
3631                 
3632                         OrganisationsListLanguage->erase(*OrganisationCount);
3633                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3634                 
3635                 } else {
3636                 
3637                         // Something else we don't know about so append
3638                         // to the tokens variable.
3639                 
3640                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3641                 
3642                                 if (FirstToken == TRUE){
3643                         
3644                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3645                                         FirstToken = FALSE;
3646                         
3647                                 } else {
3648                         
3649                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3650                         
3651                                 }
3652                 
3653                         }
3654                 
3655                 }
3656         
3657         }
3658         
3659         // Add the data to the General/Home/Work address variables.
3660         
3661         CaptureString(&PropertySeg2, FALSE);
3663         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3664         
3665         if (!PropertyTokens.IsEmpty()){
3666         
3667                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3668                         
3669         }
3673 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3675         std::map<int, int> SplitPoints;
3676         std::map<int, int> SplitLength;
3677         std::map<int, int>::iterator SLiter;                    
3678         wxString PropertyData;
3679         wxString PropertyName;
3680         wxString PropertyValue;
3681         wxString PropertyTokens;
3682         bool FirstToken = TRUE;
3683         int intPrevValue = 6;
3684         int intPref = 0;                        
3685         int intType = 0;
3686         long ListCtrlIndex;
3687         
3688         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3689         
3690         intPrevValue = 5;
3691         
3692         PropertyType PropType = PROPERTY_NONE;
3693                 
3694         // Look for type before continuing.
3695         
3696         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3697         
3698         // Setup the pointers.
3699         
3700         std::map<int, wxString> *NoteList = NULL;
3701         std::map<int, wxString> *NoteListAltID = NULL;
3702         std::map<int, wxString> *NoteListPID = NULL;
3703         std::map<int, wxString> *NoteListType = NULL;
3704         std::map<int, wxString> *NoteListTokens = NULL;
3705         std::map<int, wxString> *NoteListLanguage = NULL;
3706         std::map<int, int> *NoteListPref = NULL;
3707         
3708         // Setup blank lines for later on.
3709         
3710         switch(PropType){
3711                 case PROPERTY_NONE:
3712                         NoteList = &GeneralNoteList;
3713                         NoteListType = &GeneralNoteListType;
3714                         NoteListAltID = &GeneralNoteListAltID;
3715                         NoteListPID = &GeneralNoteListPID;
3716                         NoteListTokens = &GeneralNoteListTokens;
3717                         NoteListLanguage = &GeneralNoteListLanguage;
3718                         NoteListPref = &GeneralNoteListPref;    
3719                         break;
3720                 case PROPERTY_HOME:
3721                         NoteList = &HomeNoteList;
3722                         NoteListType = &HomeNoteListType;
3723                         NoteListAltID = &HomeNoteListAltID;
3724                         NoteListPID = &HomeNoteListPID;
3725                         NoteListTokens = &HomeNoteListTokens;
3726                         NoteListLanguage = &HomeNoteListLanguage;
3727                         NoteListPref = &HomeNoteListPref;       
3728                         break;
3729                 case PROPERTY_WORK:
3730                         NoteList = &BusinessNoteList;
3731                         NoteListType = &BusinessNoteListType;
3732                         NoteListAltID = &BusinessNoteListAltID;
3733                         NoteListPID = &BusinessNoteListPID;
3734                         NoteListTokens = &BusinessNoteListTokens;
3735                         NoteListLanguage = &BusinessNoteListLanguage;   
3736                         NoteListPref = &BusinessNoteListPref;
3737                         break;
3738         }
3740         intPrevValue = 5;
3741                 
3742         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3743         intiter != SplitPoints.end(); ++intiter){
3744         
3745                 SLiter = SplitLength.find(intiter->first);
3746         
3747                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3748                 
3749                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3750                 PropertyName = PropertyElement.GetNextToken();                          
3751                 PropertyValue = PropertyElement.GetNextToken();
3752                 
3753                 intPrevValue = intiter->second;
3754                 
3755                 // Process properties.
3756                 
3757                 size_t intPropertyValueLen = PropertyValue.Len();
3758                 
3759                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3760                         
3761                         PropertyValue.Trim();
3762                         PropertyValue.RemoveLast();
3763                         
3764                 }                               
3765                 
3766                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3767                         
3768                         PropertyValue.Remove(0, 1);
3769                         
3770                 }                               
3771                 
3772                 CaptureString(&PropertyValue, FALSE);
3773                 
3774                 if (PropertyName == wxT("ALTID")){
3775                 
3776                         NoteListAltID->erase(*NoteCount);
3777                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3778                 
3779                 } else if (PropertyName == wxT("PID")){
3781                         NoteListPID->erase(*NoteCount);
3782                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3783                 
3784                 } else if (PropertyName == wxT("PREF")){
3786                         ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3787                 
3788                 } else if (PropertyName == wxT("LANGUAGE")){
3789                 
3790                         NoteListLanguage->erase(*NoteCount);
3791                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3792                 
3793                 } else {
3794                 
3795                         // Something else we don't know about so append
3796                         // to the tokens variable.
3797                 
3798                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3799                 
3800                                 if (FirstToken == TRUE){
3801                         
3802                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3803                                         FirstToken = FALSE;
3804                         
3805                                 } else {
3806                         
3807                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3808                         
3809                                 }
3810                 
3811                         }
3812                 
3813                 }
3814         
3815         }
3816         
3817         // Add the data to the General/Home/Work address variables.
3818         
3819         CaptureString(&PropertySeg2, FALSE);
3821         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3822         
3823         if (!PropertyTokens.IsEmpty()){
3824         
3825                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3826                         
3827         }
3831 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3833         std::map<int, int> SplitPoints;
3834         std::map<int, int> SplitLength;
3835         std::map<int, int>::iterator SLiter;                    
3836         wxString PropertyData;
3837         wxString PropertyName;
3838         wxString PropertyValue;
3839         wxString PropertyTokens;
3840         bool FirstToken = TRUE;
3841         int intPrevValue = 12;
3842         int intPref = 0;                        
3843         int intType = 0;
3844         long ListCtrlIndex;
3845         
3846         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3847         
3848         intPrevValue = 11;
3849         
3850         PropertyType PropType = PROPERTY_NONE;
3851                 
3852         // Look for type before continuing.
3853         
3854         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3855         
3856         // Setup blank lines for later on.
3857         
3858         switch(PropType){
3859                 case PROPERTY_NONE:
3860                         break;
3861                 case PROPERTY_HOME:
3862                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3863                         break;
3864                 case PROPERTY_WORK:
3865                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3866                         break;
3867         }
3869         intPrevValue = 11;
3870                 
3871         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3872         intiter != SplitPoints.end(); ++intiter){
3873         
3874                 SLiter = SplitLength.find(intiter->first);
3875         
3876                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3877                 
3878                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3879                 PropertyName = PropertyElement.GetNextToken();                          
3880                 PropertyValue = PropertyElement.GetNextToken();
3881                 
3882                 intPrevValue = intiter->second;
3883                 
3884                 // Process properties.
3885                 
3886                 size_t intPropertyValueLen = PropertyValue.Len();
3887                 
3888                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3889                         
3890                         PropertyValue.Trim();
3891                         PropertyValue.RemoveLast();
3892                         
3893                 }                               
3894                 
3895                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3896                         
3897                         PropertyValue.Remove(0, 1);
3898                         
3899                 }                               
3900                 
3901                 CaptureString(&PropertyValue, FALSE);
3902                 
3903                 if (PropertyName == wxT("ALTID")){
3904                 
3905                         CategoriesListAltID.erase(*CategoryCount);
3906                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3907                 
3908                 } else if (PropertyName == wxT("PID")){
3910                         CategoriesListPID.erase(*CategoryCount);
3911                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3912                 
3913                 } else if (PropertyName == wxT("PREF")){
3915                         ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3916                         
3917                 } else if (PropertyName == wxT("LANGUAGE")){
3918                 
3919                         CategoriesListLanguage.erase(*CategoryCount);
3920                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3921                 
3922                 } else {
3923                 
3924                         // Something else we don't know about so append
3925                         // to the tokens variable.
3926                 
3927                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3928                 
3929                                 if (FirstToken == TRUE){
3930                         
3931                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3932                                         FirstToken = FALSE;
3933                         
3934                                 } else {
3935                         
3936                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3937                         
3938                                 }
3939                 
3940                         }
3941                 
3942                 }
3943         
3944         }
3945         
3946         // Deal with multiple categories.
3947         
3948         int intOrigCatCount = *CategoryCount;
3949         bool FirstCategoryProcessed = TRUE;
3950         bool AfterFirstToken = FALSE;
3951         int intSplitSize = 0;
3952         int intSplitsFound = 0;
3953         int intSplitSeek = 0;
3954         int intPropertyLen = PropertySeg2.Len();
3955         
3956         SplitPoints.clear();
3957         SplitLength.clear();
3958         intPrevValue = 0;
3959         
3960         for (int i = 0; i <= intPropertyLen; i++){
3961         
3962                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3963         
3964                         continue;
3965                 
3966                 }
3967         
3968                 intSplitSize++;
3969         
3970                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3971         
3972                         if (AfterFirstToken == TRUE){
3973                 
3974                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3975                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3976                         
3977                         } else {
3978                         
3979                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3980                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3981                                 AfterFirstToken = TRUE;
3983                         }
3985                         intSplitsFound++;
3986                         intSplitSeek = i;
3987                         intSplitSize = 0;                               
3988         
3989                 }                       
3990         
3991         }
3992         
3993         if (SplitPoints.size() > 0){
3994         
3995                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3996                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3997         
3998         }
3999         
4000         if (SplitPoints.size() == 0){
4001         
4002                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4003         
4004                 if (!PropertyTokens.IsEmpty()){
4005                 
4006                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4007                 
4008                 }
4009         
4010         }
4011         
4012         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4013         intiter != SplitPoints.end(); ++intiter){
4014         
4015                 SLiter = SplitLength.find(intiter->first);
4016         
4017                 intPrevValue = intiter->second;
4018         
4019                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4020                 
4021                 // Add the data to the General/Home/Work address variables.
4022         
4023                 // Trim any whitespace from the start and end.
4024         
4025                 PropertyData = PropertyData.Trim(FALSE);
4026                 PropertyData = PropertyData.Trim(TRUE); 
4027         
4028                 CaptureString(&PropertyData, FALSE);
4029                 
4030                 if (FirstCategoryProcessed == TRUE){
4031                 
4032                         FirstCategoryProcessed = FALSE;
4033                         
4034                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4035         
4036                         if (!PropertyTokens.IsEmpty()){
4037                 
4038                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4039                 
4040                         }
4041                         
4042                         continue;
4043                 
4044                 } else {
4046                         (*CategoryCount)++;
4047                         
4048                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4049                 
4050                         if (!PropertyTokens.IsEmpty()){
4051                 
4052                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4053                 
4054                         }
4055                 
4056                 }
4057                 
4058                 // Copy the properties to each of the categories (if it exists).
4059                 
4060                 if (!PropertyTokens.IsEmpty()){
4061                 
4062                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4063                 
4064                 }
4065                 
4066                 // Check if ALTID was used.
4067                 
4068                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4069                 
4070                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4071                 
4072                 }
4073                 
4074                 // Check if PID was used.
4075                 
4076                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4077                 
4078                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4079                 
4080                 }
4081         
4082                 // Check if PREF was used.
4083         
4084                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4085                 
4086                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4087                 
4088                 }
4089                 
4090                 // Check if LANGUAGE was used.
4091                 
4092                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4093                 
4094                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4095                 
4096                 }
4097                 
4098                 // Check if TYPE was used.
4099                 
4100                 switch(PropType){
4101                         case PROPERTY_NONE:
4102                                 break;
4103                         case PROPERTY_HOME:
4104                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4105                                 break;
4106                         case PROPERTY_WORK:
4107                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4108                                 break;
4109                 }
4110         
4111         }
4115 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4117         size_t intPropertyLen = PropertySeg1.Len();
4118         std::map<int, int> SplitPoints;
4119         std::map<int, int> SplitLength;
4120         std::map<int, int>::iterator SLiter;                    
4121         wxString PropertyData;
4122         wxString PropertyName;
4123         wxString PropertyValue;
4124         wxString PropertyTokens;
4125         bool FirstToken = TRUE;
4126         int intSplitsFound = 0;
4127         int intSplitSize = 0;
4128         int intPrevValue = 7;
4129         int intPref = 0;                        
4130         int intType = 0;
4131         
4132         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4133         
4134         intPrevValue = 6;
4135         
4136         PropertyType PropType = PROPERTY_NONE;
4137                 
4138         // Look for type before continuing.
4139         
4140         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4142         intPrevValue = 6;
4144         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4145         intiter != SplitPoints.end(); ++intiter){
4146         
4147                 SLiter = SplitLength.find(intiter->first);
4148         
4149                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4150                 
4151                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4152                 PropertyName = PropertyElement.GetNextToken();                          
4153                 PropertyValue = PropertyElement.GetNextToken();
4154                 
4155                 intPrevValue = intiter->second;
4156                 
4157                 // Process properties.
4158                 
4159                 size_t intPropertyValueLen = PropertyValue.Len();
4160                 
4161                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4162                         
4163                         PropertyValue.Trim();
4164                         PropertyValue.RemoveLast();
4165                         
4166                 }                               
4167                 
4168                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4169                         
4170                         PropertyValue.Remove(0, 1);
4171                         
4172                 }
4173                 
4174                 CaptureString(&PropertyValue, FALSE);
4175                 
4176                 if (PropertyName == wxT("ALTID")){
4178                         PicturesListAltID.erase(*PhotoCount);
4179                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4180                 
4181                 } else if (PropertyName == wxT("PID")){
4183                         PicturesListPID.erase(*PhotoCount);
4184                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4185                 
4186                 } else if (PropertyName == wxT("PREF")){
4188                         ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4189                 
4190                 } else if (PropertyName == wxT("MEDIATYPE")){
4191                 
4192                         PicturesListMediatype.erase(*PhotoCount);
4193                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4194                                         
4195                 } else {
4196                 
4197                         // Something else we don't know about so append
4198                         // to the tokens variable.
4199                         
4200                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4201                         
4202                                 if (FirstToken == TRUE){
4203                                 
4204                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4205                                         FirstToken = FALSE;
4206                                 
4207                                 } else {
4208                                 
4209                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4210                                 
4211                                 }
4212                         
4213                         }
4214                 
4215                 }
4216         
4217         }       
4218         
4219         intPropertyLen = PropertySeg2.Len();
4220         SplitPoints.clear();
4221         SplitLength.clear();
4222         intSplitsFound = 0;
4223         intSplitSize = 0;
4224         intPrevValue = 0;                       
4225         
4226         CaptureString(&PropertySeg2, FALSE);
4227         
4228         for (int i = 0; i <= intPropertyLen; i++){
4230                 intSplitSize++;
4231         
4232                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4233         
4234                         intSplitsFound++;
4235                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4236                         
4237                         if (intSplitsFound == 6){ 
4238                         
4239                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4240                                 break; 
4241                                 
4242                         } else {
4243                         
4244                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4245                         
4246                         }
4247                         
4248                         intSplitSize = 0;                                       
4249         
4250                 }
4252         }
4253         
4254         wxString wxSPhotoURI;
4255         wxString wxSPhotoMIME;
4256         wxString wxSPhotoEncoding;
4257         wxString wxSPhotoData;
4258         std::string base64enc;
4259         
4260         if (intSplitsFound == 0){
4261         
4262         } else {
4263         
4264                 std::map<int, int>::iterator striter;
4265         
4266                 striter = SplitLength.find(1);
4267         
4268                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4269         
4270                 while (wSTDataType.HasMoreTokens() == TRUE){
4271                 
4272                         wxSPhotoURI = wSTDataType.GetNextToken();
4273                         wxSPhotoMIME = wSTDataType.GetNextToken();
4274                         break;
4275                 
4276                 }                       
4277         
4278                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4279         
4280                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4281                 
4282                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4283                         wxSPhotoData = wSTDataInfo.GetNextToken();
4284                         base64enc = wxSPhotoData.mb_str();
4285                         break;
4286                 
4287                 }
4288         
4289         }
4290         
4291         // Add the data to the General/Home/Work address variables.
4292         
4293         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4294         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4295         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4296         
4297         switch(PropType){
4298                 case PROPERTY_NONE:
4299                         break;
4300                 case PROPERTY_HOME:
4301                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4302                         break;
4303                 case PROPERTY_WORK:
4304                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4305                         break;
4306         }
4307         
4308         if (!PropertyTokens.IsEmpty()){
4310                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4311         
4312         }
4316 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4318         size_t intPropertyLen = PropertySeg1.Len();
4319         std::map<int, int> SplitPoints;
4320         std::map<int, int> SplitLength;
4321         std::map<int, int>::iterator SLiter;                    
4322         wxString PropertyData;
4323         wxString PropertyName;
4324         wxString PropertyValue;
4325         wxString PropertyTokens;
4326         bool FirstToken = TRUE;
4327         int intSplitsFound = 0;
4328         int intSplitSize = 0;
4329         int intPrevValue = 6;
4330         int intPref = 0;                        
4331         int intType = 0;
4332         
4333         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4334         
4335         intPrevValue = 5;
4336         
4337         PropertyType PropType = PROPERTY_NONE;
4338                 
4339         // Look for type before continuing.
4340         
4341         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4343         intPrevValue = 5;
4345         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4346         intiter != SplitPoints.end(); ++intiter){
4347         
4348                 SLiter = SplitLength.find(intiter->first);
4349         
4350                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4351                 
4352                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4353                 PropertyName = PropertyElement.GetNextToken();                          
4354                 PropertyValue = PropertyElement.GetNextToken();
4355                 
4356                 intPrevValue = intiter->second;
4357                 
4358                 // Process properties.
4359                 
4360                 size_t intPropertyValueLen = PropertyValue.Len();
4361                 
4362                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4363                         
4364                         PropertyValue.Trim();
4365                         PropertyValue.RemoveLast();
4366                         
4367                 }                               
4368                 
4369                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4370                         
4371                         PropertyValue.Remove(0, 1);
4372                         
4373                 }
4374                 
4375                 CaptureString(&PropertyValue, FALSE);
4376                 
4377                 if (PropertyName == wxT("ALTID")){
4379                         LogosListAltID.erase(*LogoCount);
4380                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4381                 
4382                 } else if (PropertyName == wxT("PID")){
4384                         LogosListPID.erase(*LogoCount);
4385                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4386                 
4387                 } else if (PropertyName == wxT("PREF")){
4389                         ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4390                 
4391                 } else if (PropertyName == wxT("MEDIATYPE")){
4392                 
4393                         LogosListMediatype.erase(*LogoCount);
4394                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4395                                         
4396                 } else {
4397                 
4398                         // Something else we don't know about so append
4399                         // to the tokens variable.
4400                         
4401                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4402                         
4403                                 if (FirstToken == TRUE){
4404                                 
4405                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4406                                         FirstToken = FALSE;
4407                                 
4408                                 } else {
4409                                 
4410                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4411                                 
4412                                 }
4413                         
4414                         }
4415                 
4416                 }
4417         
4418         }       
4419         
4420         intPropertyLen = PropertySeg2.Len();
4421         SplitPoints.clear();
4422         SplitLength.clear();
4423         intSplitsFound = 0;
4424         intSplitSize = 0;
4425         intPrevValue = 0;                       
4426         
4427         CaptureString(&PropertySeg2, FALSE);
4428         
4429         for (int i = 0; i <= intPropertyLen; i++){
4431                 intSplitSize++;
4432         
4433                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4434         
4435                         intSplitsFound++;
4436                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4437                         
4438                         if (intSplitsFound == 6){ 
4439                         
4440                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4441                                 break; 
4442                                 
4443                         } else {
4444                         
4445                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4446                         
4447                         }
4448                         
4449                         intSplitSize = 0;                                       
4450         
4451                 }
4453         }
4454         
4455         wxString wxSPhotoURI;
4456         wxString wxSPhotoMIME;
4457         wxString wxSPhotoEncoding;
4458         wxString wxSPhotoData;
4459         std::string base64enc;
4460         
4461         if (intSplitsFound == 0){
4462         
4463         } else {
4464         
4465                 std::map<int, int>::iterator striter;
4466         
4467                 striter = SplitLength.find(1);
4468         
4469                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4470         
4471                 while (wSTDataType.HasMoreTokens() == TRUE){
4472                 
4473                         wxSPhotoURI = wSTDataType.GetNextToken();
4474                         wxSPhotoMIME = wSTDataType.GetNextToken();
4475                         break;
4476                 
4477                 }                       
4478         
4479                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4480         
4481                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4482                 
4483                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4484                         wxSPhotoData = wSTDataInfo.GetNextToken();
4485                         base64enc = wxSPhotoData.mb_str();
4486                         break;
4487                 
4488                 }
4489         
4490         }
4491         
4492         // Add the data to the General/Home/Work address variables.
4493         
4494         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4495         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4496         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4497         
4498         switch(PropType){
4499                 case PROPERTY_NONE:
4500                         break;
4501                 case PROPERTY_HOME:
4502                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4503                         break;
4504                 case PROPERTY_WORK:
4505                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4506                         break;
4507         }
4508         
4509         if (!PropertyTokens.IsEmpty()){
4511                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4512         
4513         }
4517 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4519         size_t intPropertyLen = PropertySeg1.Len();
4520         std::map<int, int> SplitPoints;
4521         std::map<int, int> SplitLength;
4522         std::map<int, int>::iterator SLiter;                    
4523         wxString PropertyData;
4524         wxString PropertyName;
4525         wxString PropertyValue;
4526         wxString PropertyTokens;
4527         bool FirstToken = TRUE;
4528         int intSplitsFound = 0;
4529         int intSplitSize = 0;
4530         int intPrevValue = 7;
4531         int intPref = 0;                        
4532         int intType = 0;
4533         
4534         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4535         
4536         intPrevValue = 6;
4537         
4538         PropertyType PropType = PROPERTY_NONE;
4539         
4540         // Look for type before continuing.                     
4542         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4544         intPrevValue = 6;
4546         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4547         intiter != SplitPoints.end(); ++intiter){
4548         
4549                 SLiter = SplitLength.find(intiter->first);
4550         
4551                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4552                 
4553                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4554                 PropertyName = PropertyElement.GetNextToken();                          
4555                 PropertyValue = PropertyElement.GetNextToken();
4556                 
4557                 intPrevValue = intiter->second;
4558                 
4559                 // Process properties.
4560                 
4561                 size_t intPropertyValueLen = PropertyValue.Len();
4562                 
4563                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4564                         
4565                         PropertyValue.Trim();
4566                         PropertyValue.RemoveLast();
4567                         
4568                 }                               
4569                 
4570                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4571                         
4572                         PropertyValue.Remove(0, 1);
4573                         
4574                 }                       
4575                 
4576                 CaptureString(&PropertyValue, FALSE);
4577                 
4578                 if (PropertyName == wxT("ALTID")){
4580                         SoundsListAltID.erase(*SoundCount);
4581                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4582                 
4583                 } else if (PropertyName == wxT("PID")){
4585                         SoundsListPID.erase(*SoundCount);
4586                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4587                 
4588                 } else if (PropertyName == wxT("PREF")){
4590                         ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4591                 
4592                 } else if (PropertyName == wxT("MEDIATYPE")){
4593                 
4594                         SoundsListMediatype.erase(*SoundCount);
4595                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4597                 } else if (PropertyName == wxT("LANGUAGE")){
4598                 
4599                         SoundsListLanguage.erase(*SoundCount);
4600                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4602                 } else {
4603                 
4604                         // Something else we don't know about so append
4605                         // to the tokens variable.
4606                         
4607                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4608                         
4609                                 if (FirstToken == TRUE){
4610                                 
4611                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4612                                         FirstToken = FALSE;
4613                                 
4614                                 } else {
4615                                 
4616                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4617                                 
4618                                 }
4619                         
4620                         }
4621                 
4622                 }
4623         
4624         }       
4625         
4626         intPropertyLen = PropertySeg2.Len();
4627         SplitPoints.clear();
4628         SplitLength.clear();
4629         intSplitsFound = 0;
4630         intSplitSize = 0;
4631         intPrevValue = 0;
4632         
4633         CaptureString(&PropertySeg2, FALSE);
4634         
4635         for (int i = 0; i <= intPropertyLen; i++){
4637                 intSplitSize++;
4638         
4639                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4640         
4641                         intSplitsFound++;
4642                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4643                         
4644                         if (intSplitsFound == 6){ 
4645                         
4646                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4647                                 break; 
4648                                 
4649                         } else {
4650                         
4651                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4652                         
4653                         }
4654                         
4655                         intSplitSize = 0;                                       
4656         
4657                 }
4659         }
4660         
4661         wxString wxSSoundURI;
4662         wxString wxSSoundMIME;
4663         wxString wxSSoundEncoding;
4664         wxString wxSSoundData;
4665         std::string base64enc;
4666         
4667         if (intSplitsFound == 0){
4668         
4669         } else {
4670         
4671                 std::map<int, int>::iterator striter;
4672         
4673                 striter = SplitLength.find(1);
4674         
4675                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4676         
4677                 while (wSTDataType.HasMoreTokens() == TRUE){
4678                 
4679                         wxSSoundURI = wSTDataType.GetNextToken();
4680                         wxSSoundMIME = wSTDataType.GetNextToken();
4681                         break;
4682                 
4683                 }                       
4684         
4685                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4686         
4687                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4688                 
4689                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4690                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4691                         base64enc = wxSSoundData.mb_str();
4692                         break;
4693                 
4694                 }
4695         
4696         }
4697         
4698         // Add the data to the General/Home/Work address variables.
4699                 
4700         switch(PropType){
4701                 case PROPERTY_NONE:
4702                         break;
4703                 case PROPERTY_HOME:
4704                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4705                         break;
4706                 case PROPERTY_WORK:
4707                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4708                         break;
4709         }
4710         
4711         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4712         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4713         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4714         
4715         if (!PropertyTokens.IsEmpty()){
4716         
4717                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4718         
4719         }
4720         
4723 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4725         size_t intPropertyLen = PropertySeg1.Len();
4726         std::map<int, int> SplitPoints;
4727         std::map<int, int> SplitLength;
4728         std::map<int, int>::iterator SLiter;                    
4729         wxString PropertyData;
4730         wxString PropertyName;
4731         wxString PropertyValue;
4732         wxString PropertyTokens;
4733         bool FirstToken = TRUE;
4734         int intSplitsFound = 0;
4735         int intSplitSize = 0;
4736         int intPrevValue = 8;
4737         int intPref = 0;                        
4738         int intType = 0;
4739         
4740         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4741         
4742         intPrevValue = 7;
4743         
4744         PropertyType PropType = PROPERTY_NONE;
4745         
4746         // Look for type before continuing.                     
4748         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4750         intPrevValue = 7;
4752         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4753         intiter != SplitPoints.end(); ++intiter){
4754         
4755                 SLiter = SplitLength.find(intiter->first);
4756         
4757                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4758                 
4759                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4760                 PropertyName = PropertyElement.GetNextToken();                          
4761                 PropertyValue = PropertyElement.GetNextToken();
4762                 
4763                 intPrevValue = intiter->second;
4764                 
4765                 // Process properties.
4766                 
4767                 size_t intPropertyValueLen = PropertyValue.Len();
4768                 
4769                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4770                         
4771                         PropertyValue.Trim();
4772                         PropertyValue.RemoveLast();
4773                         
4774                 }                               
4775                 
4776                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4777                         
4778                         PropertyValue.Remove(0, 1);
4779                         
4780                 }                       
4781                 
4782                 CaptureString(&PropertyValue, FALSE);
4783                 
4784                 if (PropertyName == wxT("ALTID")){
4786                         CalendarListAltID.erase(*CalURICount);
4787                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4788                 
4789                 } else if (PropertyName == wxT("PID")){
4791                         CalendarListPID.erase(*CalURICount);
4792                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4793                 
4794                 } else if (PropertyName == wxT("PREF")){
4796                         ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4797                 
4798                 } else if (PropertyName == wxT("MEDIATYPE")){
4799                 
4800                         CalendarListMediatype.erase(*CalURICount);
4801                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4803                 } else {
4804                 
4805                         // Something else we don't know about so append
4806                         // to the tokens variable.
4807                         
4808                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4809                         
4810                                 if (FirstToken == TRUE){
4811                                 
4812                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4813                                         FirstToken = FALSE;
4814                                 
4815                                 } else {
4816                                 
4817                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4818                                 
4819                                 }
4820                         
4821                         }
4822                 
4823                 }
4824         
4825         }       
4826         
4827         intPropertyLen = PropertySeg2.Len();
4828         SplitPoints.clear();
4829         SplitLength.clear();
4830         intSplitsFound = 0;
4831         intSplitSize = 0;
4832         intPrevValue = 0;
4833         
4834         CaptureString(&PropertySeg2, FALSE);
4835         
4836         // Add the data to the General/Home/Work address variables.
4837                 
4838         switch(PropType){
4839                 case PROPERTY_NONE:
4840                         break;
4841                 case PROPERTY_HOME:
4842                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4843                         break;
4844                 case PROPERTY_WORK:
4845                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4846                         break;
4847         }
4848         
4849         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4850         
4851         if (!PropertyTokens.IsEmpty()){
4852         
4853                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4854         
4855         }
4859 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4861         size_t intPropertyLen = PropertySeg1.Len();
4862         std::map<int, int> SplitPoints;
4863         std::map<int, int> SplitLength;
4864         std::map<int, int>::iterator SLiter;                    
4865         wxString PropertyData;
4866         wxString PropertyName;
4867         wxString PropertyValue;
4868         wxString PropertyTokens;
4869         bool FirstToken = TRUE;
4870         int intSplitsFound = 0;
4871         int intSplitSize = 0;
4872         int intPrevValue = 8;
4873         int intPref = 0;                        
4874         int intType = 0;
4875         
4876         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4877         
4878         intPrevValue = 7;
4879         
4880         PropertyType PropType = PROPERTY_NONE;
4881         
4882         // Look for type before continuing.                     
4884         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4886         intPrevValue = 7;
4888         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4889         intiter != SplitPoints.end(); ++intiter){
4890         
4891                 SLiter = SplitLength.find(intiter->first);
4892         
4893                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4894                 
4895                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4896                 PropertyName = PropertyElement.GetNextToken();                          
4897                 PropertyValue = PropertyElement.GetNextToken();
4898                 
4899                 intPrevValue = intiter->second;
4900                 
4901                 // Process properties.
4902                 
4903                 size_t intPropertyValueLen = PropertyValue.Len();
4904                 
4905                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4906                         
4907                         PropertyValue.Trim();
4908                         PropertyValue.RemoveLast();
4909                         
4910                 }                               
4911                 
4912                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4913                         
4914                         PropertyValue.Remove(0, 1);
4915                         
4916                 }                       
4917                 
4918                 CaptureString(&PropertyValue, FALSE);
4919                 
4920                 if (PropertyName == wxT("ALTID")){
4922                         CalendarRequestListAltID.erase(*CalAdrURICount);
4923                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4924                 
4925                 } else if (PropertyName == wxT("PID")){
4927                         CalendarRequestListPID.erase(*CalAdrURICount);
4928                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4929                 
4930                 } else if (PropertyName == wxT("PREF")){
4932                         ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
4933                 
4934                 } else if (PropertyName == wxT("MEDIATYPE")){
4935                 
4936                         CalendarRequestListMediatype.erase(*CalAdrURICount);
4937                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4939                 } else {
4940                 
4941                         // Something else we don't know about so append
4942                         // to the tokens variable.
4943                         
4944                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4945                         
4946                                 if (FirstToken == TRUE){
4947                                 
4948                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4949                                         FirstToken = FALSE;
4950                                 
4951                                 } else {
4952                                 
4953                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4954                                 
4955                                 }
4956                         
4957                         }
4958                 
4959                 }
4960         
4961         }       
4962         
4963         intPropertyLen = PropertySeg2.Len();
4964         SplitPoints.clear();
4965         SplitLength.clear();
4966         intSplitsFound = 0;
4967         intSplitSize = 0;
4968         intPrevValue = 0;
4969         
4970         CaptureString(&PropertySeg2, FALSE);
4971         
4972         // Add the data to the General/Home/Work address variables.
4973                 
4974         switch(PropType){
4975                 case PROPERTY_NONE:
4976                         break;
4977                 case PROPERTY_HOME:
4978                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4979                         break;
4980                 case PROPERTY_WORK:
4981                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4982                         break;
4983         }
4984         
4985         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4986         
4987         if (!PropertyTokens.IsEmpty()){
4988         
4989                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4990         
4991         }       
4992         
4995 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4997         size_t intPropertyLen = PropertySeg1.Len();
4998         std::map<int, int> SplitPoints;
4999         std::map<int, int> SplitLength;
5000         std::map<int, int>::iterator SLiter;                    
5001         wxString PropertyData;
5002         wxString PropertyName;
5003         wxString PropertyValue;
5004         wxString PropertyTokens;
5005         bool FirstToken = TRUE;
5006         int intSplitsFound = 0;
5007         int intSplitSize = 0;
5008         int intPrevValue = 7;
5009         int intPref = 0;                        
5010         int intType = 0;
5011         
5012         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5013         
5014         intPrevValue = 6;
5015         
5016         PropertyType PropType = PROPERTY_NONE;
5017         
5018         // Look for type before continuing.                     
5020         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5022         intPrevValue = 6;
5024         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5025         intiter != SplitPoints.end(); ++intiter){
5026         
5027                 SLiter = SplitLength.find(intiter->first);
5028         
5029                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5030                 
5031                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5032                 PropertyName = PropertyElement.GetNextToken();                          
5033                 PropertyValue = PropertyElement.GetNextToken();
5034                 
5035                 intPrevValue = intiter->second;
5036                 
5037                 // Process properties.
5038                 
5039                 size_t intPropertyValueLen = PropertyValue.Len();
5040                 
5041                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5042                         
5043                         PropertyValue.Trim();
5044                         PropertyValue.RemoveLast();
5045                         
5046                 }                               
5047                 
5048                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5049                         
5050                         PropertyValue.Remove(0, 1);
5051                         
5052                 }                       
5053                 
5054                 CaptureString(&PropertyValue, FALSE);
5055                 
5056                 if (PropertyName == wxT("ALTID")){
5058                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5059                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5060                 
5061                 } else if (PropertyName == wxT("PID")){
5063                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5064                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5065                 
5066                 } else if (PropertyName == wxT("PREF")){
5068                         ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5069                 
5070                 } else if (PropertyName == wxT("MEDIATYPE")){
5071                 
5072                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5073                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5075                 } else {
5076                 
5077                         // Something else we don't know about so append
5078                         // to the tokens variable.
5079                         
5080                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5081                         
5082                                 if (FirstToken == TRUE){
5083                                 
5084                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5085                                         FirstToken = FALSE;
5086                                 
5087                                 } else {
5088                                 
5089                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5090                                 
5091                                 }
5092                         
5093                         }
5094                 
5095                 }
5096         
5097         }       
5098         
5099         intPropertyLen = PropertySeg2.Len();
5100         SplitPoints.clear();
5101         SplitLength.clear();
5102         intSplitsFound = 0;
5103         intSplitSize = 0;
5104         intPrevValue = 0;
5105         
5106         CaptureString(&PropertySeg2, FALSE);
5107         
5108         // Add the data to the General/Home/Work address variables.
5109                 
5110         switch(PropType){
5111                 case PROPERTY_NONE:
5112                         break;
5113                 case PROPERTY_HOME:
5114                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5115                         break;
5116                 case PROPERTY_WORK:
5117                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5118                         break;
5119         }
5120         
5121         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5122         
5123         if (!PropertyTokens.IsEmpty()){
5124         
5125                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5126         
5127         }
5131 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5133         size_t intPropertyLen = PropertySeg1.Len();
5134         std::map<int, int> SplitPoints;
5135         std::map<int, int> SplitLength;
5136         std::map<int, int>::iterator SLiter;                    
5137         wxString PropertyData;
5138         wxString PropertyName;
5139         wxString PropertyValue;
5140         wxString PropertyTokens;
5141         bool FirstToken = TRUE;
5142         int intSplitsFound = 0;
5143         int intSplitSize = 0;
5144         int intPrevValue = 5;
5145         int intPref = 0;                        
5146         int intType = 0;
5147         long ListCtrlIndex;
5148         
5149         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5150         
5151         intPrevValue = 4;
5152         
5153         PropertyType PropType = PROPERTY_NONE;
5154         
5155         // Look for type before continuing.
5157         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5159         intPrevValue = 4;
5161         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5162         intiter != SplitPoints.end(); ++intiter){
5163         
5164                 SLiter = SplitLength.find(intiter->first);
5165         
5166                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5167                 
5168                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5169                 PropertyName = PropertyElement.GetNextToken();                          
5170                 PropertyValue = PropertyElement.GetNextToken();
5171                 
5172                 intPrevValue = intiter->second;
5173                 
5174                 // Process properties.
5175                 
5176                 size_t intPropertyValueLen = PropertyValue.Len();
5177                 
5178                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5179                         
5180                         PropertyValue.Trim();
5181                         PropertyValue.RemoveLast();
5182                         
5183                 }                               
5184                 
5185                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5186                         
5187                         PropertyValue.Remove(0, 1);
5188                         
5189                 }                               
5190                 
5191                 if (PropertyName == wxT("ALTID")){
5193                         KeyListAltID.erase(*KeyCount);
5194                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5195                 
5196                 } else if (PropertyName == wxT("PID")){
5198                         KeyListPID.erase(*KeyCount);
5199                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5200                 
5201                 } else if (PropertyName == wxT("PREF")){
5203                         ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5204                 
5205                 } else {
5206                 
5207                         // Something else we don't know about so append
5208                         // to the tokens variable.
5209                         
5210                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5211                         
5212                                 if (FirstToken == TRUE){
5213                                 
5214                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5215                                         FirstToken = FALSE;
5216                                 
5217                                 } else {
5218                                 
5219                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5220                                 
5221                                 }
5222                         
5223                         }
5224                 
5225                 }
5226         
5227         }                               
5228         
5229         intPropertyLen = PropertySeg2.Len();
5230         SplitPoints.clear();
5231         SplitLength.clear();
5232         intSplitsFound = 0;
5233         intSplitSize = 0;
5234         intPrevValue = 0;                       
5235         
5236         for (int i = 0; i <= intPropertyLen; i++){
5238                 intSplitSize++;
5239         
5240                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5241         
5242                         intSplitsFound++;
5243                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5244                         
5245                         if (intSplitsFound == 6){ 
5246                         
5247                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5248                                 break; 
5249                                 
5250                         } else {
5251                         
5252                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5253                         
5254                         }
5255                         
5256                         intSplitSize = 0;                                       
5257         
5258                 }
5260         }
5261         
5262         wxString wxSKeyURI;
5263         wxString wxSKeyMIME;
5264         wxString wxSKeyEncoding;
5265         wxString wxSKeyData;
5266         std::string base64enc;
5267         
5268         if (intSplitsFound == 0){
5269         
5270         } else {
5271         
5272                 std::map<int, int>::iterator striter;
5273         
5274                 striter = SplitLength.find(1);
5275         
5276                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5277         
5278                 while (wSTDataType.HasMoreTokens() == TRUE){
5279                 
5280                         wxSKeyURI = wSTDataType.GetNextToken();
5281                         wxSKeyMIME = wSTDataType.GetNextToken();
5282                         break;
5283                 
5284                 }                       
5285         
5286                 if (wxSKeyURI == wxT("data")){
5287                 
5288                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5289         
5290                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5291                 
5292                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5293                                 wxSKeyData = wSTDataInfo.GetNextToken();
5294                                 break;
5295                 
5296                         }
5297                 
5298                 }
5299         
5300         }
5301         
5302         // Add the data to the General/Home/Work address variables.
5303         
5304         if (wxSKeyURI == wxT("data")){
5305                 
5306                 KeyListDataEncType.erase(*KeyCount);
5307                 KeyListKeyType.erase(*KeyCount);
5308                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5309                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5310                 
5311                 KeyList.erase(*KeyCount);
5312                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5313         
5314         } else {
5315                 
5316                 KeyList.erase(*KeyCount);
5317                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5318         
5319         }
5320         
5321         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5322                 
5323         switch (PropType){
5324                 case PROPERTY_NONE:
5325                         break;
5326                 case PROPERTY_HOME: 
5327                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5328                         break;
5329                 case PROPERTY_WORK: 
5330                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5331                         break;
5332         }
5334         if (!PropertyTokens.IsEmpty()){
5336                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5338         }
5342 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5344         // Split the Vendor three ways.
5345         
5346         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5347         
5348         wxString wxSVNDID;
5349         wxString wxSVNDPropName;
5350         long ListCtrlIndex;                     
5352         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5353         
5354                 wSTVendorDetails.GetNextToken();
5355                 wxSVNDID = wSTVendorDetails.GetNextToken();
5356                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5357                 break;
5358         
5359         }
5360         
5361         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5362         
5363                 // Add the data to the vendor variables.
5364         
5365                 VendorList.erase(*VendorCount);
5366                 VendorListPEN.erase(*VendorCount);
5367                 VendorListElement.erase(*VendorCount);
5368         
5369                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5370                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5371                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5372         
5373         }
5377 void ProcessStringValue(wxString *PropertyName,
5378         wxString PropertyNameMatch,
5379         std::map<int,wxString> *MapPtr,
5380         wxString *PropertyValue,
5381         int *ItemCount,
5382         bool *PropertyMatched){
5383         
5384         if (*PropertyName == PropertyNameMatch){
5385                 MapPtr->erase(*ItemCount);
5386                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5387                 *PropertyMatched = TRUE;
5388         }
5389         
5392 void ProcessIntegerValue(wxString *PropertyName,
5393         wxString PropertyNameMatch,
5394         std::map<int,int> *PrefPtr, 
5395         wxString *PropertyValue, 
5396         int *ItemCount,
5397         bool *PropertyMatched){
5399         if (*PropertyName == PropertyNameMatch){
5400                 *PropertyMatched = TRUE;
5401         } else {
5402                 return;
5403         }
5405         int PriorityNumber = 0; 
5406         bool ValidNumber = TRUE;
5407                         
5408         try{
5409                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5410         }
5411                         
5412         catch(std::invalid_argument &e){
5413                 ValidNumber = FALSE;
5414         }
5416         if (ValidNumber == TRUE){
5418                 PrefPtr->erase(*ItemCount);
5419                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5421         }
5425 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
5426         wxString *PropertyValue, 
5427         int *ItemCount){
5429         int PriorityNumber = 0; 
5430         bool ValidNumber = TRUE;
5431                         
5432         try{
5433                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5434         }
5435                         
5436         catch(std::invalid_argument &e){
5437                 ValidNumber = FALSE;
5438         }
5440         if (ValidNumber == TRUE){
5442                 PrefPtr->erase(*ItemCount);
5443                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5445         }
5449 void SplitValues(wxString *PropertyLine, 
5450         std::map<int,int> *SplitPoints, 
5451         std::map<int,int> *SplitLength, 
5452         int intSize){
5453         
5454         size_t intPropertyLen = PropertyLine->Len();
5455         int intSplitsFound = 0;
5456         int intSplitSize = 0;
5457         int intSplitSeek = 0;
5458         
5459         for (int i = intSize; i <= intPropertyLen; i++){
5461                 intSplitSize++;
5462         
5463                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5464                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5465            
5466                     if (intSplitsFound == 0){
5467             
5468                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5469           
5470                     } else {
5471            
5472                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5473             
5474                     }
5475             
5476                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5477             
5478                     intSplitsFound++;
5479                     intSplitSeek = i;
5480                     intSplitSize = 0;
5481             
5482                 }
5484         }
5486         if (intSplitsFound == 0){
5488                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5489                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5491         } else {
5493                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5494                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5496         }
5500 void CheckType(wxString *PropertySeg1, 
5501         std::map<int,int> *SplitPoints, 
5502         std::map<int,int> *SplitLength, 
5503         int *intPrevValue, 
5504         PropertyType *PropType){
5505         
5506         wxString PropertyData;
5507         wxString PropertyName;
5508         wxString PropertyValue;
5509         std::map<int,int>::iterator SLiter;
5510         
5511         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5512         intiter != SplitPoints->end(); ++intiter){
5513         
5514                 SLiter = SplitLength->find(intiter->first);
5515         
5516                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5517                 
5518                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5519                 PropertyName = PropertyElement.GetNextToken();                          
5520                 PropertyValue = PropertyElement.GetNextToken();
5521                 
5522                 *intPrevValue = intiter->second;
5523                 
5524                 if (PropertyName == wxT("TYPE")){
5525                                 
5526                         if (PropertyValue == wxT("work")){
5527                         
5528                                 *PropType = PROPERTY_WORK;
5529                                                         
5530                         } else if (PropertyValue == wxT("home")){
5532                                 *PropType = PROPERTY_HOME;
5533                                                         
5534                         } else {
5535                         
5536                                 *PropType = PROPERTY_NONE;
5537                         
5538                         }
5539                 
5540                         return;
5541                 
5542                 }
5543         
5544         }
5545         
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