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