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