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