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