Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Replaced string processing in EMAIL 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         
2184         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2185         intiter != SplitPoints.end(); ++intiter){
2186         
2187                 SLiter = SplitLength.find(intiter->first);
2188         
2189                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2190                 
2191                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2192                 PropertyName = PropertyElement.GetNextToken();                          
2193                 PropertyValue = PropertyElement.GetNextToken();
2194                 
2195                 intPrevValue = intiter->second;
2196                 
2197                 CaptureString(&PropertyValue, FALSE);
2198                 
2199                 // Process properties.
2200                 
2201                 if (PropertyName == wxT("ALTID")){
2203                         IMListAltID->erase(*IMCount);
2204                         IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2205                 
2206                 } else if (PropertyName == wxT("PID")){
2208                         IMListPID->erase(*IMCount);
2209                         IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2210                 
2211                 } else if (PropertyName == wxT("MEDIATYPE")){
2213                         IMListMediatype->erase(*IMCount);
2214                         IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2215                 
2216                 } else if (PropertyName == wxT("PREF")){
2217                         
2218                         ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2219                 
2220                 } else {
2221                 
2222                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2223                         
2224                                 if (FirstToken == TRUE){
2225                                 
2226                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2227                                         FirstToken = FALSE;
2228                                 
2229                                 } else {
2230                                 
2231                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2232                                 
2233                                 }
2234                         
2235                         }
2236                 
2237                 }
2238         
2239         }
2240                 
2241         IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2242         
2243         // Add the name token data.
2244         
2245         if (!PropertyTokens.IsEmpty()){
2246         
2247                 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2248         
2249         }
2253 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2255         std::map<int, int> SplitPoints;
2256         std::map<int, int> SplitLength;
2257         std::map<int, int>::iterator SLiter;
2258         
2259         int intPref = 0;
2260         
2261         PropertyType PropType = PROPERTY_NONE;
2262                 
2263         // Look for type before continuing.
2264         
2265         wxString TelTypeUI;
2266         wxString TelTypeDetail;
2267         wxString PropertyData;
2268         wxString PropertyName;
2269         wxString PropertyValue;
2270         wxString PropertyTokens;
2271         
2272         std::map<int,int> TypeSplitPoints;
2273         std::map<int,int> TypeSplitLength;
2274         std::map<int,int>::iterator TSLiter;
2275         
2276         int intSplitSize = 0;
2277         int intSplitsFound = 0;
2278         int intSplitPoint = 0;
2279         int intType = 0;
2280         int intPrevValue = 5;
2281                 
2282         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2283         
2284         intPrevValue = 4;
2285         
2286         // Look for type before continuing.
2287         
2288         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2289         intiter != SplitPoints.end(); ++intiter){
2290         
2291                 SLiter = SplitLength.find(intiter->first);
2292         
2293                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2294                 
2295                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2296                 PropertyName = PropertyElement.GetNextToken();                          
2297                 PropertyValue = PropertyElement.GetNextToken();
2298                 
2299                 intPrevValue = intiter->second;
2301                 if (PropertyName == wxT("TYPE")){
2302                 
2303                         // Process each value in type and translate each
2304                         // part.
2305                 
2306                         // Strip out the quotes if they are there.
2307                 
2308                         size_t intPropertyValueLen = PropertyValue.Len();
2309                 
2310                         if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2311                         
2312                                 PropertyValue.Trim();
2313                                 PropertyValue.RemoveLast();
2314                         
2315                         }                               
2316                 
2317                         if (PropertyValue.Mid(0, 1) == wxT("\"")){
2318                         
2319                                 PropertyValue.Remove(0, 1);
2320                         
2321                         }
2322                         
2323                         TelTypeDetail = PropertyValue;
2324                         
2325                         intSplitSize = 0;
2326                         intSplitsFound = 0;
2327                         intSplitPoint = 0;
2328                         
2329                         for (int i = 0; i <= intPropertyValueLen; i++){
2330         
2331                                 intSplitSize++;
2332         
2333                                 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2334         
2335                                         if (intSplitsFound == 0){
2337                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2338                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2339                         
2340                                         } else {
2341                         
2342                                                 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2343                                                 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2344                         
2345                                         }                       
2347                                         intSplitsFound++;
2348                                         i++;
2349                                         intSplitPoint = i;
2350                                         intSplitSize = 0;
2351         
2352                                 }
2353         
2354                         }
2355                         
2356                         TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2357                         TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));                                                           
2358                 
2359                         int intTypeSeek = 0;
2360                 
2361                         for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin(); 
2362                         typeiter != TypeSplitPoints.end(); ++typeiter){
2363                         
2364                                 wxString TypePropertyName;
2365                                 
2366                                 TSLiter = TypeSplitLength.find(typeiter->first);
2367                                 
2368                                 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2369                                 
2370                                 if (intTypeSeek == 0){
2371                                 
2372                                 
2373                                 } else {
2374                                                                                 
2375                                         TelTypeUI.Append(wxT(","));                                                     
2376                                 
2377                                 }
2378                         
2379                                 if (TypePropertyName == wxT("home")){
2380                                 
2381                                         PropType = PROPERTY_HOME;
2382                                 
2383                                 } else if (TypePropertyName == wxT("work")){
2384                                 
2385                                         PropType = PROPERTY_WORK;
2386                                                                         
2387                                 }
2388                                 
2389                                 
2390                                 if (TypePropertyName == wxT("text")){
2391                                 
2392                                         TelTypeUI.Append(_("text"));
2393                                         intTypeSeek++;
2394                                 
2395                                 } else if (TypePropertyName == wxT("voice")){
2396                                 
2397                                         TelTypeUI.Append(_("voice"));
2398                                         intTypeSeek++;
2399                                 
2400                                 } else if (TypePropertyName == wxT("fax")){
2401                                 
2402                                         TelTypeUI.Append(_("fax"));
2403                                         intTypeSeek++;
2404                                 
2405                                 } else if (TypePropertyName == wxT("cell")){
2406                                 
2407                                         TelTypeUI.Append(_("mobile"));
2408                                         intTypeSeek++;
2409                                 
2410                                 } else if (TypePropertyName == wxT("video")){
2411                                 
2412                                         TelTypeUI.Append(_("video"));
2413                                         intTypeSeek++;
2414                                 
2415                                 } else if (TypePropertyName == wxT("pager")){
2416                                 
2417                                         TelTypeUI.Append(_("pager"));
2418                                         intTypeSeek++;
2419                                 
2420                                 } else if (TypePropertyName == wxT("textphone")){
2421                                 
2422                                         TelTypeUI.Append(_("textphone"));
2423                                         intTypeSeek++;
2424                                 
2425                                 }
2426                         
2427                         }
2428                 
2429                 }
2430                 
2431         }
2432         
2433         std::map<int, wxString> *TelephoneList = NULL;
2434         std::map<int, wxString> *TelephoneListType = NULL;
2435         std::map<int, wxString> *TelephoneListAltID = NULL;
2436         std::map<int, wxString> *TelephoneListPID = NULL;
2437         std::map<int, wxString> *TelephoneListTokens = NULL;
2438         std::map<int, wxString> *TelephoneListTypeInfo = NULL;  
2439         std::map<int, int> *TelephoneListPref = NULL;
2441         switch(PropType){
2442                 case PROPERTY_NONE:
2443                         TelephoneList = &GeneralTelephoneList;
2444                         TelephoneListType = &GeneralTelephoneListType;
2445                         TelephoneListAltID = &GeneralTelephoneListAltID;
2446                         TelephoneListPID = &GeneralTelephoneListPID;
2447                         TelephoneListTokens = &GeneralTelephoneListTokens;
2448                         TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2449                         TelephoneListPref = &GeneralTelephoneListPref;  
2450                         break;
2451                 case PROPERTY_HOME:
2452                         TelephoneList = &HomeTelephoneList;
2453                         TelephoneListType = &HomeTelephoneListType;
2454                         TelephoneListAltID = &HomeTelephoneListAltID;
2455                         TelephoneListPID = &HomeTelephoneListPID;
2456                         TelephoneListTokens = &HomeTelephoneListTokens;
2457                         TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;     
2458                         TelephoneListPref = &HomeTelephoneListPref;     
2459                         break;
2460                 case PROPERTY_WORK:
2461                         TelephoneList = &BusinessTelephoneList;
2462                         TelephoneListType = &BusinessTelephoneListType;
2463                         TelephoneListAltID = &BusinessTelephoneListAltID;
2464                         TelephoneListPID = &BusinessTelephoneListPID;
2465                         TelephoneListTokens = &BusinessTelephoneListTokens;     
2466                         TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo; 
2467                         TelephoneListPref = &BusinessTelephoneListPref; 
2468                         break;
2469         }
2470                 
2471         // Process the properties.
2472         
2473         bool FirstToken = TRUE;
2474         
2475         intPrevValue = 5;
2476         SplitPoints.clear();
2477         SplitLength.clear();
2479         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2481         intPrevValue = 4;
2482         
2483         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2484         intiter != SplitPoints.end(); ++intiter){
2485         
2486                 SLiter = SplitLength.find(intiter->first);
2487         
2488                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2489                 
2490                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2491                 PropertyName = PropertyElement.GetNextToken();                          
2492                 PropertyValue = PropertyElement.GetNextToken();
2493                 
2494                 intPrevValue = intiter->second;
2495                 
2496                 CaptureString(&PropertyValue, FALSE);
2497                 
2498                 // Process properties.
2499                 
2500                 if (PropertyName == wxT("ALTID")){
2502                         TelephoneListAltID->erase(*TelephoneCount);
2503                         TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2504                 
2505                 } else if (PropertyName == wxT("PID")){
2507                         TelephoneListPID->erase(*TelephoneCount);
2508                         TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2509                 
2510                 } else if (PropertyName == wxT("PREF")){
2512                         ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2513                 
2514                 } else {
2515                 
2516                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2517                         
2518                                 if (FirstToken == TRUE){
2519                                 
2520                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2521                                         FirstToken = FALSE;
2522                                 
2523                                 } else {
2524                                 
2525                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2526                                 
2527                                 }
2528                         
2529                         }
2530                 
2531                 }
2532         
2533         }
2534                 
2535         TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2536         TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2537         
2538         // Add the name token data.
2539         
2540         if (!PropertyTokens.IsEmpty()){
2541         
2542                 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2543         
2544         }
2548 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2550         std::map<int, int> SplitPoints;
2551         std::map<int, int> SplitLength;
2553         int intPrevValue = 6;
2554         int intPref = 0;                        
2555         
2556         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2557         
2558         intPrevValue = 5;
2559         
2560         PropertyType PropType = PROPERTY_NONE;
2561                 
2562         // Look for type before continuing.
2563         
2564         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2565         
2566         std::map<int, wxString> *LanguageList = NULL;
2567         std::map<int, wxString> *LanguageListType = NULL;
2568         std::map<int, wxString> *LanguageListAltID = NULL;
2569         std::map<int, wxString> *LanguageListPID = NULL;
2570         std::map<int, wxString> *LanguageListTokens = NULL;
2571         std::map<int, int> *LanguageListPref = NULL;
2573         switch(PropType){
2574                 case PROPERTY_NONE:
2575                         LanguageList = &GeneralLanguageList;
2576                         LanguageListType = &GeneralLanguageListType;
2577                         LanguageListAltID = &GeneralLanguageListAltID;
2578                         LanguageListPID = &GeneralLanguageListPID;
2579                         LanguageListTokens = &GeneralLanguageListTokens;
2580                         LanguageListPref = &GeneralLanguageListPref;    
2581                         break;
2582                 case PROPERTY_HOME:
2583                         LanguageList = &HomeLanguageList;
2584                         LanguageListType = &HomeLanguageListType;
2585                         LanguageListAltID = &HomeLanguageListAltID;
2586                         LanguageListPID = &HomeLanguageListPID;
2587                         LanguageListTokens = &HomeLanguageListTokens;   
2588                         LanguageListPref = &HomeLanguageListPref;       
2589                         break;
2590                 case PROPERTY_WORK:
2591                         LanguageList = &BusinessLanguageList;
2592                         LanguageListType = &BusinessLanguageListType;
2593                         LanguageListAltID = &BusinessLanguageListAltID;
2594                         LanguageListPID = &BusinessLanguageListPID;
2595                         LanguageListTokens = &BusinessLanguageListTokens;       
2596                         LanguageListPref = &BusinessLanguageListPref;
2597                         break;
2598         }
2599         
2600         intPrevValue = 5;
2601         
2602         std::map<int,int>::iterator SLiter;
2603         wxString PropertyData;
2604         wxString PropertyName;
2605         wxString PropertyValue;
2606         wxString PropertyTokens;
2607         bool FirstToken = TRUE;
2608         
2609         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2610         intiter != SplitPoints.end(); ++intiter){
2611         
2612                 SLiter = SplitLength.find(intiter->first);
2613         
2614                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2615                 
2616                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2617                 PropertyName = PropertyElement.GetNextToken();                          
2618                 PropertyValue = PropertyElement.GetNextToken();
2619                 
2620                 intPrevValue = intiter->second;
2621                 
2622                 CaptureString(&PropertyValue, FALSE);
2623                 
2624                 // Process properties.
2625                 
2626                 if (PropertyName == wxT("ALTID")){
2628                         LanguageListAltID->erase(*LanguageCount);
2629                         LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2630                 
2631                 } else if (PropertyName == wxT("PID")){
2633                         LanguageListPID->erase(*LanguageCount);
2634                         LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2635                 
2636                 } else if (PropertyName == wxT("PREF")){
2637                         
2638                         ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2639                 
2640                 } else {
2641                 
2642                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2643                         
2644                                 if (FirstToken == TRUE){
2645                                 
2646                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2647                                         FirstToken = FALSE;
2648                                 
2649                                 } else {
2650                                 
2651                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2652                                 
2653                                 }
2654                         
2655                         }
2656                 
2657                 }
2658         
2659         }
2660                 
2661         LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2662         
2663         // Add the name token data.
2664         
2665         if (!PropertyTokens.IsEmpty()){
2666         
2667                 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2668         
2669         }
2673 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2675         std::map<int, int> SplitPoints;
2676         std::map<int, int> SplitLength;
2678         int intPrevValue = 5;
2679         int intPref = 0;                        
2680         
2681         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2682         
2683         intPrevValue = 4;
2684         
2685         PropertyType PropType = PROPERTY_NONE;
2686                 
2687         // Look for type before continuing.
2688         
2689         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2690         
2691         std::map<int, wxString> *GeopositionList = NULL;
2692         std::map<int, wxString> *GeopositionListType = NULL;
2693         std::map<int, wxString> *GeopositionListAltID = NULL;
2694         std::map<int, wxString> *GeopositionListPID = NULL;
2695         std::map<int, wxString> *GeopositionListTokens = NULL;
2696         std::map<int, wxString> *GeopositionListMediatype = NULL;
2697         std::map<int, int> *GeopositionListPref = NULL;
2699         switch(PropType){
2700                 case PROPERTY_NONE:
2701                         GeopositionList = &GeneralGeographyList;
2702                         GeopositionListType = &GeneralGeographyListType;
2703                         GeopositionListAltID = &GeneralGeographyListAltID;
2704                         GeopositionListPID = &GeneralGeographyListPID;
2705                         GeopositionListTokens = &GeneralGeographyListTokens;
2706                         GeopositionListMediatype = &GeneralGeographyListMediatype;
2707                         GeopositionListPref = &GeneralGeographyListPref;        
2708                         break;
2709                 case PROPERTY_HOME:
2710                         GeopositionList = &HomeGeographyList;
2711                         GeopositionListType = &HomeGeographyListType;
2712                         GeopositionListAltID = &HomeGeographyListAltID;
2713                         GeopositionListPID = &HomeGeographyListPID;
2714                         GeopositionListTokens = &HomeGeographyListTokens;
2715                         GeopositionListMediatype = &HomeGeographyListMediatype;
2716                         GeopositionListPref = &HomeGeographyListPref;   
2717                         break;
2718                 case PROPERTY_WORK:
2719                         GeopositionList = &BusinessGeographyList;
2720                         GeopositionListType = &BusinessGeographyListType;
2721                         GeopositionListAltID = &BusinessGeographyListAltID;
2722                         GeopositionListPID = &BusinessGeographyListPID;
2723                         GeopositionListTokens = &BusinessGeographyListTokens;
2724                         GeopositionListMediatype = &BusinessGeographyListMediatype;     
2725                         GeopositionListPref = &BusinessGeographyListPref;
2726                         break;
2727         }
2728         
2729         intPrevValue = 4;
2730         
2731         std::map<int,int>::iterator SLiter;
2732         wxString PropertyData;
2733         wxString PropertyName;
2734         wxString PropertyValue;
2735         wxString PropertyTokens;
2736         bool FirstToken = TRUE;
2737         
2738         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2739         intiter != SplitPoints.end(); ++intiter){
2740         
2741                 SLiter = SplitLength.find(intiter->first);
2742         
2743                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2744                 
2745                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2746                 PropertyName = PropertyElement.GetNextToken();                          
2747                 PropertyValue = PropertyElement.GetNextToken();
2748                 
2749                 intPrevValue = intiter->second;
2750                 
2751                 CaptureString(&PropertyValue, FALSE);
2752                 
2753                 // Process properties.
2754                 
2755                 if (PropertyName == wxT("ALTID")){
2757                         GeopositionListAltID->erase(*GeographicCount);
2758                         GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2759                 
2760                 } else if (PropertyName == wxT("PID")){
2762                         GeopositionListPID->erase(*GeographicCount);
2763                         GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2764                 
2765                 } else if (PropertyName == wxT("MEDIATYPE")){
2767                         GeopositionListMediatype->erase(*GeographicCount);
2768                         GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2769                 
2770                 } else if (PropertyName == wxT("PREF")){
2772                         ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2773                 
2774                 } else {
2775                 
2776                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2777                         
2778                                 if (FirstToken == TRUE){
2779                                 
2780                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2781                                         FirstToken = FALSE;
2782                                 
2783                                 } else {
2784                                 
2785                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2786                                 
2787                                 }
2788                         
2789                         }
2790                 
2791                 }
2792         
2793         }
2794                 
2795         GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2796         
2797         // Add the name token data.
2798         
2799         if (!PropertyTokens.IsEmpty()){
2800         
2801                 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2802         
2803         }
2807 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2809         size_t intPropertyLen = PropertySeg1.Len();
2810         std::map<int, int> SplitPoints;
2811         std::map<int, int> SplitLength;
2812         std::map<int, int>::iterator SLiter;                    
2813         wxString PropertyData;
2814         wxString PropertyName;
2815         wxString PropertyValue;
2816         wxString PropertyTokens;
2817         wxString RelatedType;
2818         wxString RelatedTypeOriginal;                   
2819         wxString RelatedName;
2820         bool FirstToken = TRUE;                 
2821         int intSplitsFound = 0;
2822         int intSplitSize = 0;
2823         int intPrevValue = 9;
2824         int intPref = 0;
2825         long ListCtrlIndex;
2826         
2827         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2828         
2829         intPrevValue = 8;
2830         
2831         // Look for type before continuing.
2832         
2833         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2834         intiter != SplitPoints.end(); ++intiter){
2835         
2836                 SLiter = SplitLength.find(intiter->first);
2837         
2838                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2839                 
2840                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2841                 PropertyName = PropertyElement.GetNextToken();                          
2842                 PropertyValue = PropertyElement.GetNextToken();
2843                 
2844                 intPrevValue = intiter->second;
2845                 
2846                 // Process these.
2847                 
2848                 RelatedTypeOriginal = PropertyValue;
2849                 
2850                 if (PropertyName == wxT("TYPE")){
2851                 
2852                         if (PropertyValue == wxT("contact")){
2854                                 RelatedType = _("Contact");
2856                         } else if (PropertyValue == wxT("acquaintance")){
2858                                 RelatedType = _("Acquaintance");
2860                         } else if (PropertyValue == wxT("friend")){
2862                                 RelatedType = _("Friend");
2864                         } else if (PropertyValue == wxT("met")){
2866                                 RelatedType = _("Met");
2868                         } else if (PropertyValue == wxT("co-worker")){
2870                                 RelatedType = _("Co-worker");
2872                         } else if (PropertyValue == wxT("colleague")){
2874                                 RelatedType = _("Colleague");
2876                         } else if (PropertyValue == wxT("co-resident")){
2878                                 RelatedType = _("Co-resident");
2880                         } else if (PropertyValue == wxT("neighbor")){
2882                                 RelatedType = _("Neighbour");
2884                         } else if (PropertyValue == wxT("child")){
2886                                 RelatedType = _("Child");
2888                         } else if (PropertyValue == wxT("parent")){
2890                                 RelatedType = _("Parent");
2892                         } else if (PropertyValue == wxT("sibling")){
2894                                 RelatedType = _("Sibling");
2896                         } else if (PropertyValue == wxT("spouse")){
2898                                 RelatedType = _("Spouse");
2900                         } else if (PropertyValue == wxT("kin")){
2902                                 RelatedType = _("Kin");
2904                         } else if (PropertyValue == wxT("muse")){
2906                                 RelatedType = _("Muse");
2908                         } else if (PropertyValue == wxT("crush")){
2910                                 RelatedType = _("Crush");
2912                         } else if (PropertyValue == wxT("date")){
2914                                 RelatedType = _("Date");
2916                         } else if (PropertyValue == wxT("sweetheart")){
2918                                 RelatedType = _("Sweetheart");
2920                         } else if (PropertyValue == wxT("me")){
2922                                 RelatedType = _("Me");
2924                         } else if (PropertyValue == wxT("agent")){
2926                                 RelatedType = _("Agent");
2928                         } else if (PropertyValue == wxT("emergency")){
2930                                 RelatedType = _("Emergency");
2932                         } else {
2934                                 RelatedType = PropertyValue;
2936                         }
2937                 
2938                 }
2939         
2940         }
2941         
2942         intPrevValue = 8;                       
2943         
2944         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
2945         intiter != SplitPoints.end(); ++intiter){
2946         
2947                 SLiter = SplitLength.find(intiter->first);
2948         
2949                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2950                 
2951                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2952                 PropertyName = PropertyElement.GetNextToken();                          
2953                 PropertyValue = PropertyElement.GetNextToken();
2954                 
2955                 intPrevValue = intiter->second;
2956                 
2957                 // Process properties.
2958                 
2959                 size_t intPropertyValueLen = PropertyValue.Len();
2960                 
2961                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2962                         
2963                         PropertyValue.Trim();
2964                         PropertyValue.RemoveLast();
2965                         
2966                 }                               
2967                 
2968                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2969                         
2970                         PropertyValue.Remove(0, 1);
2971                         
2972                 }
2973                 
2974                 CaptureString(&PropertyValue, FALSE);
2975                         
2976                 if (PropertyName == wxT("ALTID")){
2978                         GeneralRelatedListAltID.erase(*RelatedCount);
2979                         GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2980                 
2981                 } else if (PropertyName == wxT("PID")){
2983                         GeneralRelatedListPID.erase(*RelatedCount);
2984                         GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2985                 
2986                 } else if (PropertyName == wxT("PREF")){
2987                         
2988                         int PriorityNumber = 0;
2989                         bool ValidNumber = TRUE;
2990                         
2991                         try{
2992                                 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2993                         }
2994                         
2995                         catch(std::invalid_argument &e){
2996                                 ValidNumber = FALSE;
2997                         }
2999                         if (ValidNumber == TRUE){
3001                                 GeneralRelatedListPref.erase(*RelatedCount);
3002                                 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3004                         }
3005                 
3006                 } else if (PropertyName == wxT("LANGUAGE")){
3008                         ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3009                 
3010                 } else if (PropertyName != wxT("TYPE")) {
3011                 
3012                         // Something else we don't know about so append
3013                         // to the tokens variable.
3014                 
3015                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3016                 
3017                                 if (FirstToken == TRUE){
3018                         
3019                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3020                                         FirstToken = FALSE;
3021                         
3022                                 } else {
3023                         
3024                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3025                         
3026                                 }
3027                 
3028                         }
3029                 
3030                 }
3031         
3032         }                                       
3033         
3034         // Add the data to the General/Home/Work address variables.
3035                                 
3036         GeneralRelatedList.erase(*RelatedCount);
3037         GeneralRelatedListRelType.erase(*RelatedCount);
3038         GeneralRelatedListType.erase(*RelatedCount);
3039         GeneralRelatedListTokens.erase(*RelatedCount);
3040         GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3041         GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));                   
3042         GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3043         GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3047 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3049         std::map<int, int> SplitPoints;
3050         std::map<int, int> SplitLength;
3051         std::map<int, int>::iterator SLiter;                    
3052         wxString PropertyData;
3053         wxString PropertyName;
3054         wxString PropertyValue;
3055         wxString PropertyTokens;
3056         bool FirstToken = TRUE;
3057         int intPrevValue = 5;
3058         int intPref = 0;                        
3059         int intType = 0;
3060         long ListCtrlIndex;
3061         
3062         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3063         
3064         intPrevValue = 4;
3065         
3066         PropertyType PropType = PROPERTY_NONE;
3067                 
3068         // Look for type before continuing.
3069         
3070         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3071         
3072         // Setup the pointers.
3073         
3074         std::map<int, wxString> *WebsiteList = NULL;
3075         std::map<int, wxString> *WebsiteListAltID = NULL;
3076         std::map<int, wxString> *WebsiteListPID = NULL;
3077         std::map<int, wxString> *WebsiteListType = NULL;
3078         std::map<int, wxString> *WebsiteListTokens = NULL;
3079         std::map<int, wxString> *WebsiteListMediatype = NULL;
3080         std::map<int, int> *WebsiteListPref = NULL;
3081         
3082         // Setup blank lines for later on.
3083         
3084         switch(PropType){
3085                 case PROPERTY_NONE:
3086                         WebsiteList = &GeneralWebsiteList;
3087                         WebsiteListType = &GeneralWebsiteListType;
3088                         WebsiteListAltID = &GeneralWebsiteListAltID;
3089                         WebsiteListPID = &GeneralWebsiteListPID;
3090                         WebsiteListTokens = &GeneralWebsiteListTokens;
3091                         WebsiteListMediatype = &GeneralWebsiteListMediatype;
3092                         WebsiteListPref = &GeneralWebsiteListPref;      
3093                         break;
3094                 case PROPERTY_HOME:
3095                         WebsiteList = &HomeWebsiteList;
3096                         WebsiteListType = &HomeWebsiteListType;
3097                         WebsiteListAltID = &HomeWebsiteListAltID;
3098                         WebsiteListPID = &HomeWebsiteListPID;
3099                         WebsiteListTokens = &HomeWebsiteListTokens;
3100                         WebsiteListMediatype = &HomeWebsiteListMediatype;
3101                         WebsiteListPref = &HomeWebsiteListPref; 
3102                         break;
3103                 case PROPERTY_WORK:
3104                         WebsiteList = &BusinessWebsiteList;
3105                         WebsiteListType = &BusinessWebsiteListType;
3106                         WebsiteListAltID = &BusinessWebsiteListAltID;
3107                         WebsiteListPID = &BusinessWebsiteListPID;
3108                         WebsiteListTokens = &BusinessWebsiteListTokens;
3109                         WebsiteListMediatype = &BusinessWebsiteListMediatype;   
3110                         WebsiteListPref = &BusinessWebsiteListPref;
3111                         break;
3112         }
3113         
3114         intPrevValue = 4;
3115         
3116         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3117         intiter != SplitPoints.end(); ++intiter){
3118         
3119                 SLiter = SplitLength.find(intiter->first);
3120         
3121                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3122                 
3123                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3124                 PropertyName = PropertyElement.GetNextToken();                          
3125                 PropertyValue = PropertyElement.GetNextToken();
3126                 
3127                 intPrevValue = intiter->second;
3128                 
3129                 // Process properties.
3130                 
3131                 size_t intPropertyValueLen = PropertyValue.Len();
3132                 
3133                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3134                         
3135                         PropertyValue.Trim();
3136                         PropertyValue.RemoveLast();
3137                         
3138                 }                               
3139                 
3140                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3141                         
3142                         PropertyValue.Remove(0, 1);
3143                         
3144                 }
3145                 
3146                 CaptureString(&PropertyValue, FALSE);
3147                 
3148                 if (PropertyName == wxT("ALTID")){
3150                         WebsiteListAltID->erase(*URLCount);
3151                         WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3152                 
3153                 } else if (PropertyName == wxT("PID")){
3155                         WebsiteListPID->erase(*URLCount);
3156                         WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3157                         
3158                 } else if (PropertyName == wxT("PREF")){
3160                         ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3161                                                         
3162                 } else if (PropertyName == wxT("MEDIATYPE")){
3163                 
3164                         WebsiteListMediatype->erase(*URLCount);
3165                         WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3166                 
3167                 } else {
3168                 
3169                         // Something else we don't know about so append
3170                         // to the tokens variable.
3171                 
3172                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3173                 
3174                                 if (FirstToken == TRUE){
3175                         
3176                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3177                                         FirstToken = FALSE;
3178                         
3179                                 } else {
3180                         
3181                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3182                         
3183                                 }
3184                 
3185                         }
3186                 
3187                 }
3188         
3189         }
3190         
3191         // Add the data to the General/Home/Work address variables.
3192         
3193         CaptureString(&PropertySeg2, FALSE);
3194                         
3195         WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3196         
3197         if (!PropertyTokens.IsEmpty()){
3198         
3199                 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3200                         
3201         }
3202         
3205 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3207         std::map<int, int> SplitPoints;
3208         std::map<int, int> SplitLength;
3209         std::map<int, int>::iterator SLiter;                    
3210         wxString PropertyData;
3211         wxString PropertyName;
3212         wxString PropertyValue;
3213         wxString PropertyTokens;
3214         bool FirstToken = TRUE;
3215         int intPrevValue = 7;
3216         int intPref = 0;                        
3217         int intType = 0;
3218         long ListCtrlIndex;
3219         
3220         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3221         
3222         intPrevValue = 6;
3223         
3224         PropertyType PropType = PROPERTY_NONE;
3225                 
3226         // Look for type before continuing.
3227         
3228         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3229         
3230         // Setup the pointers.
3231         
3232         std::map<int, wxString> *TitleList = NULL;
3233         std::map<int, wxString> *TitleListAltID = NULL;
3234         std::map<int, wxString> *TitleListPID = NULL;
3235         std::map<int, wxString> *TitleListType = NULL;
3236         std::map<int, wxString> *TitleListTokens = NULL;
3237         std::map<int, wxString> *TitleListLanguage = NULL;
3238         std::map<int, int> *TitleListPref = NULL;
3239         
3240         // Setup blank lines for later on.
3241         
3242         switch(PropType){
3243                 case PROPERTY_NONE:
3244                         TitleList = &GeneralTitleList;
3245                         TitleListType = &GeneralTitleListType;
3246                         TitleListAltID = &GeneralTitleListAltID;
3247                         TitleListPID = &GeneralTitleListPID;
3248                         TitleListTokens = &GeneralTitleListTokens;
3249                         TitleListLanguage = &GeneralTitleListLanguage;
3250                         TitleListPref = &GeneralTitleListPref;  
3251                         break;
3252                 case PROPERTY_HOME:
3253                         TitleList = &HomeTitleList;
3254                         TitleListType = &HomeTitleListType;
3255                         TitleListAltID = &HomeTitleListAltID;
3256                         TitleListPID = &HomeTitleListPID;
3257                         TitleListTokens = &HomeTitleListTokens;
3258                         TitleListLanguage = &HomeTitleListLanguage;
3259                         TitleListPref = &HomeTitleListPref;     
3260                         break;
3261                 case PROPERTY_WORK:
3262                         TitleList = &BusinessTitleList;
3263                         TitleListType = &BusinessTitleListType;
3264                         TitleListAltID = &BusinessTitleListAltID;
3265                         TitleListPID = &BusinessTitleListPID;
3266                         TitleListTokens = &BusinessTitleListTokens;
3267                         TitleListLanguage = &BusinessTitleListLanguage; 
3268                         TitleListPref = &BusinessTitleListPref;
3269                         break;
3270         }
3272         intPrevValue = 6;
3273                 
3274         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3275         intiter != SplitPoints.end(); ++intiter){
3276         
3277                 SLiter = SplitLength.find(intiter->first);
3278         
3279                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3280                 
3281                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3282                 PropertyName = PropertyElement.GetNextToken();                          
3283                 PropertyValue = PropertyElement.GetNextToken();
3284                 
3285                 intPrevValue = intiter->second;
3286                 
3287                 // Process properties.
3288                 
3289                 size_t intPropertyValueLen = PropertyValue.Len();
3290                 
3291                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3292                         
3293                         PropertyValue.Trim();
3294                         PropertyValue.RemoveLast();
3295                         
3296                 }                               
3297                 
3298                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3299                         
3300                         PropertyValue.Remove(0, 1);
3301                         
3302                 }                               
3303                 
3304                 CaptureString(&PropertyValue, FALSE);
3305                 
3306                 if (PropertyName == wxT("ALTID")){
3307                 
3308                         TitleListAltID->erase(*TitleCount);
3309                         TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3310                 
3311                 } else if (PropertyName == wxT("PID")){
3313                         TitleListPID->erase(*TitleCount);
3314                         TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3315                 
3316                 } else if (PropertyName == wxT("PREF")){
3318                         ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3319                         
3320                 } else if (PropertyName == wxT("LANGUAGE")){
3321                 
3322                         TitleListLanguage->erase(*TitleCount);
3323                         TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3324                 
3325                 } else {
3326                 
3327                         // Something else we don't know about so append
3328                         // to the tokens variable.
3329                 
3330                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3331                 
3332                                 if (FirstToken == TRUE){
3333                         
3334                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3335                                         FirstToken = FALSE;
3336                         
3337                                 } else {
3338                         
3339                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3340                         
3341                                 }
3342                 
3343                         }
3344                 
3345                 }
3346         
3347         }
3348         
3349         // Add the data to the General/Home/Work address variables.
3350         
3351         CaptureString(&PropertySeg2, FALSE);
3353         TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3354         
3355         if (!PropertyTokens.IsEmpty()){
3356         
3357                 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3358                         
3359         }
3363 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3365         std::map<int, int> SplitPoints;
3366         std::map<int, int> SplitLength;
3367         std::map<int, int>::iterator SLiter;                    
3368         wxString PropertyData;
3369         wxString PropertyName;
3370         wxString PropertyValue;
3371         wxString PropertyTokens;
3372         bool FirstToken = TRUE;
3373         int intPrevValue = 6;
3374         int intPref = 0;                        
3375         int intType = 0;
3376         long ListCtrlIndex;
3377         
3378         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3379         
3380         intPrevValue = 5;
3381         
3382         PropertyType PropType = PROPERTY_NONE;
3383                 
3384         // Look for type before continuing.
3385         
3386         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3387         
3388         // Setup the pointers.
3389         
3390         std::map<int, wxString> *RoleList = NULL;
3391         std::map<int, wxString> *RoleListAltID = NULL;
3392         std::map<int, wxString> *RoleListPID = NULL;
3393         std::map<int, wxString> *RoleListType = NULL;
3394         std::map<int, wxString> *RoleListTokens = NULL;
3395         std::map<int, wxString> *RoleListLanguage = NULL;
3396         std::map<int, int> *RoleListPref = NULL;
3397         
3398         // Setup blank lines for later on.
3399         
3400         switch(PropType){
3401                 case PROPERTY_NONE:
3402                         RoleList = &GeneralRoleList;
3403                         RoleListType = &GeneralRoleListType;
3404                         RoleListAltID = &GeneralRoleListAltID;
3405                         RoleListPID = &GeneralRoleListPID;
3406                         RoleListTokens = &GeneralRoleListTokens;
3407                         RoleListLanguage = &GeneralRoleListLanguage;
3408                         RoleListPref = &GeneralRoleListPref;    
3409                         break;
3410                 case PROPERTY_HOME:
3411                         RoleList = &HomeRoleList;
3412                         RoleListType = &HomeRoleListType;
3413                         RoleListAltID = &HomeRoleListAltID;
3414                         RoleListPID = &HomeRoleListPID;
3415                         RoleListTokens = &HomeRoleListTokens;
3416                         RoleListLanguage = &HomeRoleListLanguage;
3417                         RoleListPref = &HomeRoleListPref;       
3418                         break;
3419                 case PROPERTY_WORK:
3420                         RoleList = &BusinessRoleList;
3421                         RoleListType = &BusinessRoleListType;
3422                         RoleListAltID = &BusinessRoleListAltID;
3423                         RoleListPID = &BusinessRoleListPID;
3424                         RoleListTokens = &BusinessRoleListTokens;
3425                         RoleListLanguage = &BusinessRoleListLanguage;   
3426                         RoleListPref = &BusinessRoleListPref;
3427                         break;
3428         }
3430         intPrevValue = 5;
3431                 
3432         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3433         intiter != SplitPoints.end(); ++intiter){
3434         
3435                 SLiter = SplitLength.find(intiter->first);
3436         
3437                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3438                 
3439                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3440                 PropertyName = PropertyElement.GetNextToken();                          
3441                 PropertyValue = PropertyElement.GetNextToken();
3442                 
3443                 intPrevValue = intiter->second;
3444                 
3445                 // Process properties.
3446                 
3447                 size_t intPropertyValueLen = PropertyValue.Len();
3448                 
3449                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3450                         
3451                         PropertyValue.Trim();
3452                         PropertyValue.RemoveLast();
3453                         
3454                 }                               
3455                 
3456                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3457                         
3458                         PropertyValue.Remove(0, 1);
3459                         
3460                 }                               
3461                 
3462                 CaptureString(&PropertyValue, FALSE);
3463                 
3464                 if (PropertyName == wxT("ALTID")){
3465                 
3466                         RoleListAltID->erase(*RoleCount);
3467                         RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3468                 
3469                 } else if (PropertyName == wxT("PID")){
3471                         RoleListPID->erase(*RoleCount);
3472                         RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3473                 
3474                 } else if (PropertyName == wxT("PREF")){
3476                         ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3477                                 
3478                 } else if (PropertyName == wxT("LANGUAGE")){
3479                 
3480                         RoleListLanguage->erase(*RoleCount);
3481                         RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3482                 
3483                 } else {
3484                 
3485                         // Something else we don't know about so append
3486                         // to the tokens variable.
3487                 
3488                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3489                 
3490                                 if (FirstToken == TRUE){
3491                         
3492                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3493                                         FirstToken = FALSE;
3494                         
3495                                 } else {
3496                         
3497                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3498                         
3499                                 }
3500                 
3501                         }
3502                 
3503                 }
3504         
3505         }
3506         
3507         // Add the data to the General/Home/Work address variables.
3508         
3509         CaptureString(&PropertySeg2, FALSE);
3511         RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3512         
3513         if (!PropertyTokens.IsEmpty()){
3514         
3515                 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3516                         
3517         }
3521 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3523         std::map<int, int> SplitPoints;
3524         std::map<int, int> SplitLength;
3525         std::map<int, int>::iterator SLiter;                    
3526         wxString PropertyData;
3527         wxString PropertyName;
3528         wxString PropertyValue;
3529         wxString PropertyTokens;
3530         bool FirstToken = TRUE;
3531         int intPrevValue = 5;
3532         int intPref = 0;                        
3533         int intType = 0;
3534         long ListCtrlIndex;
3535         
3536         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3537         
3538         intPrevValue = 4;
3539         
3540         PropertyType PropType = PROPERTY_NONE;
3541                 
3542         // Look for type before continuing.
3543         
3544         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3545         
3546         // Setup the pointers.
3547         
3548         std::map<int, wxString> *OrganisationsList = NULL;
3549         std::map<int, wxString> *OrganisationsListAltID = NULL;
3550         std::map<int, wxString> *OrganisationsListPID = NULL;
3551         std::map<int, wxString> *OrganisationsListType = NULL;
3552         std::map<int, wxString> *OrganisationsListTokens = NULL;
3553         std::map<int, wxString> *OrganisationsListLanguage = NULL;
3554         std::map<int, wxString> *OrganisationsListSortAs = NULL;
3555         std::map<int, int> *OrganisationsListPref = NULL;
3556         
3557         // Setup blank lines for later on.
3558         
3559         switch(PropType){
3560                 case PROPERTY_NONE:
3561                         OrganisationsList = &GeneralOrganisationsList;
3562                         OrganisationsListType = &GeneralOrganisationsListType;
3563                         OrganisationsListAltID = &GeneralOrganisationsListAltID;
3564                         OrganisationsListPID = &GeneralOrganisationsListPID;
3565                         OrganisationsListTokens = &GeneralOrganisationsListTokens;
3566                         OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3567                         OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3568                         OrganisationsListPref = &GeneralOrganisationsListPref;  
3569                         break;
3570                 case PROPERTY_HOME:
3571                         OrganisationsList = &HomeOrganisationsList;
3572                         OrganisationsListType = &HomeOrganisationsListType;
3573                         OrganisationsListAltID = &HomeOrganisationsListAltID;
3574                         OrganisationsListPID = &HomeOrganisationsListPID;
3575                         OrganisationsListTokens = &HomeOrganisationsListTokens;
3576                         OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3577                         OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3578                         OrganisationsListPref = &HomeOrganisationsListPref;     
3579                         break;
3580                 case PROPERTY_WORK:
3581                         OrganisationsList = &BusinessOrganisationsList;
3582                         OrganisationsListType = &BusinessOrganisationsListType;
3583                         OrganisationsListAltID = &BusinessOrganisationsListAltID;
3584                         OrganisationsListPID = &BusinessOrganisationsListPID;
3585                         OrganisationsListTokens = &BusinessOrganisationsListTokens;
3586                         OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3587                         OrganisationsListSortAs = &BusinessOrganisationsListSortAs;     
3588                         OrganisationsListPref = &BusinessOrganisationsListPref;
3589                         break;
3590         }
3592         intPrevValue = 4;
3593                 
3594         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3595         intiter != SplitPoints.end(); ++intiter){
3596         
3597                 SLiter = SplitLength.find(intiter->first);
3598         
3599                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3600                 
3601                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3602                 PropertyName = PropertyElement.GetNextToken();                          
3603                 PropertyValue = PropertyElement.GetNextToken();
3604                 
3605                 intPrevValue = intiter->second;
3606                 
3607                 // Process properties.
3608                 
3609                 size_t intPropertyValueLen = PropertyValue.Len();
3610                 
3611                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3612                         
3613                         PropertyValue.Trim();
3614                         PropertyValue.RemoveLast();
3615                         
3616                 }                               
3617                 
3618                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3619                         
3620                         PropertyValue.Remove(0, 1);
3621                         
3622                 }                               
3623                 
3624                 CaptureString(&PropertyValue, FALSE);
3625                 
3626                 if (PropertyName == wxT("ALTID")){
3627                 
3628                         OrganisationsListAltID->erase(*OrganisationCount);
3629                         OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3630                 
3631                 } else if (PropertyName == wxT("PID")){
3633                         OrganisationsListPID->erase(*OrganisationCount);
3634                         OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3635                 
3636                 } else if (PropertyName == wxT("SORT-AS")){
3638                         OrganisationsListSortAs->erase(*OrganisationCount);
3639                         OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3640                 
3641                 } else if (PropertyName == wxT("PREF")){
3643                         ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3644                         
3645                 } else if (PropertyName == wxT("LANGUAGE")){
3646                 
3647                         OrganisationsListLanguage->erase(*OrganisationCount);
3648                         OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3649                 
3650                 } else {
3651                 
3652                         // Something else we don't know about so append
3653                         // to the tokens variable.
3654                 
3655                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3656                 
3657                                 if (FirstToken == TRUE){
3658                         
3659                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3660                                         FirstToken = FALSE;
3661                         
3662                                 } else {
3663                         
3664                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3665                         
3666                                 }
3667                 
3668                         }
3669                 
3670                 }
3671         
3672         }
3673         
3674         // Add the data to the General/Home/Work address variables.
3675         
3676         CaptureString(&PropertySeg2, FALSE);
3678         OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3679         
3680         if (!PropertyTokens.IsEmpty()){
3681         
3682                 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3683                         
3684         }
3688 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3690         std::map<int, int> SplitPoints;
3691         std::map<int, int> SplitLength;
3692         std::map<int, int>::iterator SLiter;                    
3693         wxString PropertyData;
3694         wxString PropertyName;
3695         wxString PropertyValue;
3696         wxString PropertyTokens;
3697         bool FirstToken = TRUE;
3698         int intPrevValue = 6;
3699         int intPref = 0;                        
3700         int intType = 0;
3701         long ListCtrlIndex;
3702         
3703         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3704         
3705         intPrevValue = 5;
3706         
3707         PropertyType PropType = PROPERTY_NONE;
3708                 
3709         // Look for type before continuing.
3710         
3711         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3712         
3713         // Setup the pointers.
3714         
3715         std::map<int, wxString> *NoteList = NULL;
3716         std::map<int, wxString> *NoteListAltID = NULL;
3717         std::map<int, wxString> *NoteListPID = NULL;
3718         std::map<int, wxString> *NoteListType = NULL;
3719         std::map<int, wxString> *NoteListTokens = NULL;
3720         std::map<int, wxString> *NoteListLanguage = NULL;
3721         std::map<int, int> *NoteListPref = NULL;
3722         
3723         // Setup blank lines for later on.
3724         
3725         switch(PropType){
3726                 case PROPERTY_NONE:
3727                         NoteList = &GeneralNoteList;
3728                         NoteListType = &GeneralNoteListType;
3729                         NoteListAltID = &GeneralNoteListAltID;
3730                         NoteListPID = &GeneralNoteListPID;
3731                         NoteListTokens = &GeneralNoteListTokens;
3732                         NoteListLanguage = &GeneralNoteListLanguage;
3733                         NoteListPref = &GeneralNoteListPref;    
3734                         break;
3735                 case PROPERTY_HOME:
3736                         NoteList = &HomeNoteList;
3737                         NoteListType = &HomeNoteListType;
3738                         NoteListAltID = &HomeNoteListAltID;
3739                         NoteListPID = &HomeNoteListPID;
3740                         NoteListTokens = &HomeNoteListTokens;
3741                         NoteListLanguage = &HomeNoteListLanguage;
3742                         NoteListPref = &HomeNoteListPref;       
3743                         break;
3744                 case PROPERTY_WORK:
3745                         NoteList = &BusinessNoteList;
3746                         NoteListType = &BusinessNoteListType;
3747                         NoteListAltID = &BusinessNoteListAltID;
3748                         NoteListPID = &BusinessNoteListPID;
3749                         NoteListTokens = &BusinessNoteListTokens;
3750                         NoteListLanguage = &BusinessNoteListLanguage;   
3751                         NoteListPref = &BusinessNoteListPref;
3752                         break;
3753         }
3755         intPrevValue = 5;
3756                 
3757         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3758         intiter != SplitPoints.end(); ++intiter){
3759         
3760                 SLiter = SplitLength.find(intiter->first);
3761         
3762                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3763                 
3764                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3765                 PropertyName = PropertyElement.GetNextToken();                          
3766                 PropertyValue = PropertyElement.GetNextToken();
3767                 
3768                 intPrevValue = intiter->second;
3769                 
3770                 // Process properties.
3771                 
3772                 size_t intPropertyValueLen = PropertyValue.Len();
3773                 
3774                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3775                         
3776                         PropertyValue.Trim();
3777                         PropertyValue.RemoveLast();
3778                         
3779                 }                               
3780                 
3781                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3782                         
3783                         PropertyValue.Remove(0, 1);
3784                         
3785                 }                               
3786                 
3787                 CaptureString(&PropertyValue, FALSE);
3788                 
3789                 if (PropertyName == wxT("ALTID")){
3790                 
3791                         NoteListAltID->erase(*NoteCount);
3792                         NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3793                 
3794                 } else if (PropertyName == wxT("PID")){
3796                         NoteListPID->erase(*NoteCount);
3797                         NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3798                 
3799                 } else if (PropertyName == wxT("PREF")){
3801                         ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3802                 
3803                 } else if (PropertyName == wxT("LANGUAGE")){
3804                 
3805                         NoteListLanguage->erase(*NoteCount);
3806                         NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3807                 
3808                 } else {
3809                 
3810                         // Something else we don't know about so append
3811                         // to the tokens variable.
3812                 
3813                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3814                 
3815                                 if (FirstToken == TRUE){
3816                         
3817                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3818                                         FirstToken = FALSE;
3819                         
3820                                 } else {
3821                         
3822                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3823                         
3824                                 }
3825                 
3826                         }
3827                 
3828                 }
3829         
3830         }
3831         
3832         // Add the data to the General/Home/Work address variables.
3833         
3834         CaptureString(&PropertySeg2, FALSE);
3836         NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3837         
3838         if (!PropertyTokens.IsEmpty()){
3839         
3840                 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3841                         
3842         }
3846 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3848         std::map<int, int> SplitPoints;
3849         std::map<int, int> SplitLength;
3850         std::map<int, int>::iterator SLiter;                    
3851         wxString PropertyData;
3852         wxString PropertyName;
3853         wxString PropertyValue;
3854         wxString PropertyTokens;
3855         bool FirstToken = TRUE;
3856         int intPrevValue = 12;
3857         int intPref = 0;                        
3858         int intType = 0;
3859         long ListCtrlIndex;
3860         
3861         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3862         
3863         intPrevValue = 11;
3864         
3865         PropertyType PropType = PROPERTY_NONE;
3866                 
3867         // Look for type before continuing.
3868         
3869         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3870         
3871         // Setup blank lines for later on.
3872         
3873         switch(PropType){
3874                 case PROPERTY_NONE:
3875                         break;
3876                 case PROPERTY_HOME:
3877                         CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3878                         break;
3879                 case PROPERTY_WORK:
3880                         CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3881                         break;
3882         }
3884         intPrevValue = 11;
3885                 
3886         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
3887         intiter != SplitPoints.end(); ++intiter){
3888         
3889                 SLiter = SplitLength.find(intiter->first);
3890         
3891                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3892                 
3893                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3894                 PropertyName = PropertyElement.GetNextToken();                          
3895                 PropertyValue = PropertyElement.GetNextToken();
3896                 
3897                 intPrevValue = intiter->second;
3898                 
3899                 // Process properties.
3900                 
3901                 size_t intPropertyValueLen = PropertyValue.Len();
3902                 
3903                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3904                         
3905                         PropertyValue.Trim();
3906                         PropertyValue.RemoveLast();
3907                         
3908                 }                               
3909                 
3910                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3911                         
3912                         PropertyValue.Remove(0, 1);
3913                         
3914                 }                               
3915                 
3916                 CaptureString(&PropertyValue, FALSE);
3917                 
3918                 if (PropertyName == wxT("ALTID")){
3919                 
3920                         CategoriesListAltID.erase(*CategoryCount);
3921                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3922                 
3923                 } else if (PropertyName == wxT("PID")){
3925                         CategoriesListPID.erase(*CategoryCount);
3926                         CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3927                 
3928                 } else if (PropertyName == wxT("PREF")){
3930                         ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3931                         
3932                 } else if (PropertyName == wxT("LANGUAGE")){
3933                 
3934                         CategoriesListLanguage.erase(*CategoryCount);
3935                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3936                 
3937                 } else {
3938                 
3939                         // Something else we don't know about so append
3940                         // to the tokens variable.
3941                 
3942                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3943                 
3944                                 if (FirstToken == TRUE){
3945                         
3946                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3947                                         FirstToken = FALSE;
3948                         
3949                                 } else {
3950                         
3951                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3952                         
3953                                 }
3954                 
3955                         }
3956                 
3957                 }
3958         
3959         }
3960         
3961         // Deal with multiple categories.
3962         
3963         int intOrigCatCount = *CategoryCount;
3964         bool FirstCategoryProcessed = TRUE;
3965         bool AfterFirstToken = FALSE;
3966         int intSplitSize = 0;
3967         int intSplitsFound = 0;
3968         int intSplitSeek = 0;
3969         int intPropertyLen = PropertySeg2.Len();
3970         
3971         SplitPoints.clear();
3972         SplitLength.clear();
3973         intPrevValue = 0;
3974         
3975         for (int i = 0; i <= intPropertyLen; i++){
3976         
3977                 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3978         
3979                         continue;
3980                 
3981                 }
3982         
3983                 intSplitSize++;
3984         
3985                 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3986         
3987                         if (AfterFirstToken == TRUE){
3988                 
3989                                 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3990                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3991                         
3992                         } else {
3993                         
3994                                 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3995                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));                                 
3996                                 AfterFirstToken = TRUE;
3998                         }
4000                         intSplitsFound++;
4001                         intSplitSeek = i;
4002                         intSplitSize = 0;                               
4003         
4004                 }                       
4005         
4006         }
4007         
4008         if (SplitPoints.size() > 0){
4009         
4010                 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4011                 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4012         
4013         }
4014         
4015         if (SplitPoints.size() == 0){
4016         
4017                 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4018         
4019                 if (!PropertyTokens.IsEmpty()){
4020                 
4021                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4022                 
4023                 }
4024         
4025         }
4026         
4027         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4028         intiter != SplitPoints.end(); ++intiter){
4029         
4030                 SLiter = SplitLength.find(intiter->first);
4031         
4032                 intPrevValue = intiter->second;
4033         
4034                 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4035                 
4036                 // Add the data to the General/Home/Work address variables.
4037         
4038                 // Trim any whitespace from the start and end.
4039         
4040                 PropertyData = PropertyData.Trim(FALSE);
4041                 PropertyData = PropertyData.Trim(TRUE); 
4042         
4043                 CaptureString(&PropertyData, FALSE);
4044                 
4045                 if (FirstCategoryProcessed == TRUE){
4046                 
4047                         FirstCategoryProcessed = FALSE;
4048                         
4049                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4050         
4051                         if (!PropertyTokens.IsEmpty()){
4052                 
4053                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4054                 
4055                         }
4056                         
4057                         continue;
4058                 
4059                 } else {
4061                         (*CategoryCount)++;
4062                         
4063                         CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4064                 
4065                         if (!PropertyTokens.IsEmpty()){
4066                 
4067                                 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4068                 
4069                         }
4070                 
4071                 }
4072                 
4073                 // Copy the properties to each of the categories (if it exists).
4074                 
4075                 if (!PropertyTokens.IsEmpty()){
4076                 
4077                         CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4078                 
4079                 }
4080                 
4081                 // Check if ALTID was used.
4082                 
4083                 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4084                 
4085                         CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4086                 
4087                 }
4088                 
4089                 // Check if PID was used.
4090                 
4091                 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4092                 
4093                         CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4094                 
4095                 }
4096         
4097                 // Check if PREF was used.
4098         
4099                 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4100                 
4101                         CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4102                 
4103                 }
4104                 
4105                 // Check if LANGUAGE was used.
4106                 
4107                 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4108                 
4109                         CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4110                 
4111                 }
4112                 
4113                 // Check if TYPE was used.
4114                 
4115                 switch(PropType){
4116                         case PROPERTY_NONE:
4117                                 break;
4118                         case PROPERTY_HOME:
4119                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4120                                 break;
4121                         case PROPERTY_WORK:
4122                                 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4123                                 break;
4124                 }
4125         
4126         }
4130 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4132         size_t intPropertyLen = PropertySeg1.Len();
4133         std::map<int, int> SplitPoints;
4134         std::map<int, int> SplitLength;
4135         std::map<int, int>::iterator SLiter;                    
4136         wxString PropertyData;
4137         wxString PropertyName;
4138         wxString PropertyValue;
4139         wxString PropertyTokens;
4140         bool FirstToken = TRUE;
4141         int intSplitsFound = 0;
4142         int intSplitSize = 0;
4143         int intPrevValue = 7;
4144         int intPref = 0;                        
4145         int intType = 0;
4146         
4147         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4148         
4149         intPrevValue = 6;
4150         
4151         PropertyType PropType = PROPERTY_NONE;
4152                 
4153         // Look for type before continuing.
4154         
4155         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4157         intPrevValue = 6;
4159         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4160         intiter != SplitPoints.end(); ++intiter){
4161         
4162                 SLiter = SplitLength.find(intiter->first);
4163         
4164                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4165                 
4166                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4167                 PropertyName = PropertyElement.GetNextToken();                          
4168                 PropertyValue = PropertyElement.GetNextToken();
4169                 
4170                 intPrevValue = intiter->second;
4171                 
4172                 // Process properties.
4173                 
4174                 size_t intPropertyValueLen = PropertyValue.Len();
4175                 
4176                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4177                         
4178                         PropertyValue.Trim();
4179                         PropertyValue.RemoveLast();
4180                         
4181                 }                               
4182                 
4183                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4184                         
4185                         PropertyValue.Remove(0, 1);
4186                         
4187                 }
4188                 
4189                 CaptureString(&PropertyValue, FALSE);
4190                 
4191                 if (PropertyName == wxT("ALTID")){
4193                         PicturesListAltID.erase(*PhotoCount);
4194                         PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4195                 
4196                 } else if (PropertyName == wxT("PID")){
4198                         PicturesListPID.erase(*PhotoCount);
4199                         PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4200                 
4201                 } else if (PropertyName == wxT("PREF")){
4203                         ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4204                 
4205                 } else if (PropertyName == wxT("MEDIATYPE")){
4206                 
4207                         PicturesListMediatype.erase(*PhotoCount);
4208                         PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4209                                         
4210                 } else {
4211                 
4212                         // Something else we don't know about so append
4213                         // to the tokens variable.
4214                         
4215                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4216                         
4217                                 if (FirstToken == TRUE){
4218                                 
4219                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4220                                         FirstToken = FALSE;
4221                                 
4222                                 } else {
4223                                 
4224                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4225                                 
4226                                 }
4227                         
4228                         }
4229                 
4230                 }
4231         
4232         }       
4233         
4234         intPropertyLen = PropertySeg2.Len();
4235         SplitPoints.clear();
4236         SplitLength.clear();
4237         intSplitsFound = 0;
4238         intSplitSize = 0;
4239         intPrevValue = 0;                       
4240         
4241         CaptureString(&PropertySeg2, FALSE);
4242         
4243         for (int i = 0; i <= intPropertyLen; i++){
4245                 intSplitSize++;
4246         
4247                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4248         
4249                         intSplitsFound++;
4250                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4251                         
4252                         if (intSplitsFound == 6){ 
4253                         
4254                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4255                                 break; 
4256                                 
4257                         } else {
4258                         
4259                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4260                         
4261                         }
4262                         
4263                         intSplitSize = 0;                                       
4264         
4265                 }
4267         }
4268         
4269         wxString wxSPhotoURI;
4270         wxString wxSPhotoMIME;
4271         wxString wxSPhotoEncoding;
4272         wxString wxSPhotoData;
4273         std::string base64enc;
4274         
4275         if (intSplitsFound == 0){
4276         
4277         } else {
4278         
4279                 std::map<int, int>::iterator striter;
4280         
4281                 striter = SplitLength.find(1);
4282         
4283                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4284         
4285                 while (wSTDataType.HasMoreTokens() == TRUE){
4286                 
4287                         wxSPhotoURI = wSTDataType.GetNextToken();
4288                         wxSPhotoMIME = wSTDataType.GetNextToken();
4289                         break;
4290                 
4291                 }                       
4292         
4293                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4294         
4295                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4296                 
4297                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4298                         wxSPhotoData = wSTDataInfo.GetNextToken();
4299                         base64enc = wxSPhotoData.mb_str();
4300                         break;
4301                 
4302                 }
4303         
4304         }
4305         
4306         // Add the data to the General/Home/Work address variables.
4307         
4308         PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4309         PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4310         PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4311         
4312         switch(PropType){
4313                 case PROPERTY_NONE:
4314                         break;
4315                 case PROPERTY_HOME:
4316                         PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4317                         break;
4318                 case PROPERTY_WORK:
4319                         PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4320                         break;
4321         }
4322         
4323         if (!PropertyTokens.IsEmpty()){
4325                 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4326         
4327         }
4331 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4333         size_t intPropertyLen = PropertySeg1.Len();
4334         std::map<int, int> SplitPoints;
4335         std::map<int, int> SplitLength;
4336         std::map<int, int>::iterator SLiter;                    
4337         wxString PropertyData;
4338         wxString PropertyName;
4339         wxString PropertyValue;
4340         wxString PropertyTokens;
4341         bool FirstToken = TRUE;
4342         int intSplitsFound = 0;
4343         int intSplitSize = 0;
4344         int intPrevValue = 6;
4345         int intPref = 0;                        
4346         int intType = 0;
4347         
4348         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4349         
4350         intPrevValue = 5;
4351         
4352         PropertyType PropType = PROPERTY_NONE;
4353                 
4354         // Look for type before continuing.
4355         
4356         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4358         intPrevValue = 5;
4360         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4361         intiter != SplitPoints.end(); ++intiter){
4362         
4363                 SLiter = SplitLength.find(intiter->first);
4364         
4365                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4366                 
4367                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4368                 PropertyName = PropertyElement.GetNextToken();                          
4369                 PropertyValue = PropertyElement.GetNextToken();
4370                 
4371                 intPrevValue = intiter->second;
4372                 
4373                 // Process properties.
4374                 
4375                 size_t intPropertyValueLen = PropertyValue.Len();
4376                 
4377                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4378                         
4379                         PropertyValue.Trim();
4380                         PropertyValue.RemoveLast();
4381                         
4382                 }                               
4383                 
4384                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4385                         
4386                         PropertyValue.Remove(0, 1);
4387                         
4388                 }
4389                 
4390                 CaptureString(&PropertyValue, FALSE);
4391                 
4392                 if (PropertyName == wxT("ALTID")){
4394                         LogosListAltID.erase(*LogoCount);
4395                         LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4396                 
4397                 } else if (PropertyName == wxT("PID")){
4399                         LogosListPID.erase(*LogoCount);
4400                         LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4401                 
4402                 } else if (PropertyName == wxT("PREF")){
4404                         ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4405                 
4406                 } else if (PropertyName == wxT("MEDIATYPE")){
4407                 
4408                         LogosListMediatype.erase(*LogoCount);
4409                         LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4410                                         
4411                 } else {
4412                 
4413                         // Something else we don't know about so append
4414                         // to the tokens variable.
4415                         
4416                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4417                         
4418                                 if (FirstToken == TRUE){
4419                                 
4420                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4421                                         FirstToken = FALSE;
4422                                 
4423                                 } else {
4424                                 
4425                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4426                                 
4427                                 }
4428                         
4429                         }
4430                 
4431                 }
4432         
4433         }       
4434         
4435         intPropertyLen = PropertySeg2.Len();
4436         SplitPoints.clear();
4437         SplitLength.clear();
4438         intSplitsFound = 0;
4439         intSplitSize = 0;
4440         intPrevValue = 0;                       
4441         
4442         CaptureString(&PropertySeg2, FALSE);
4443         
4444         for (int i = 0; i <= intPropertyLen; i++){
4446                 intSplitSize++;
4447         
4448                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4449         
4450                         intSplitsFound++;
4451                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4452                         
4453                         if (intSplitsFound == 6){ 
4454                         
4455                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4456                                 break; 
4457                                 
4458                         } else {
4459                         
4460                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4461                         
4462                         }
4463                         
4464                         intSplitSize = 0;                                       
4465         
4466                 }
4468         }
4469         
4470         wxString wxSPhotoURI;
4471         wxString wxSPhotoMIME;
4472         wxString wxSPhotoEncoding;
4473         wxString wxSPhotoData;
4474         std::string base64enc;
4475         
4476         if (intSplitsFound == 0){
4477         
4478         } else {
4479         
4480                 std::map<int, int>::iterator striter;
4481         
4482                 striter = SplitLength.find(1);
4483         
4484                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4485         
4486                 while (wSTDataType.HasMoreTokens() == TRUE){
4487                 
4488                         wxSPhotoURI = wSTDataType.GetNextToken();
4489                         wxSPhotoMIME = wSTDataType.GetNextToken();
4490                         break;
4491                 
4492                 }                       
4493         
4494                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4495         
4496                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4497                 
4498                         wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4499                         wxSPhotoData = wSTDataInfo.GetNextToken();
4500                         base64enc = wxSPhotoData.mb_str();
4501                         break;
4502                 
4503                 }
4504         
4505         }
4506         
4507         // Add the data to the General/Home/Work address variables.
4508         
4509         LogosList.insert(std::make_pair(*LogoCount, base64enc));
4510         LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4511         LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4512         
4513         switch(PropType){
4514                 case PROPERTY_NONE:
4515                         break;
4516                 case PROPERTY_HOME:
4517                         LogosListType.insert(std::make_pair(*LogoCount, "home"));
4518                         break;
4519                 case PROPERTY_WORK:
4520                         LogosListType.insert(std::make_pair(*LogoCount, "work"));
4521                         break;
4522         }
4523         
4524         if (!PropertyTokens.IsEmpty()){
4526                 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4527         
4528         }
4532 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4534         size_t intPropertyLen = PropertySeg1.Len();
4535         std::map<int, int> SplitPoints;
4536         std::map<int, int> SplitLength;
4537         std::map<int, int>::iterator SLiter;                    
4538         wxString PropertyData;
4539         wxString PropertyName;
4540         wxString PropertyValue;
4541         wxString PropertyTokens;
4542         bool FirstToken = TRUE;
4543         int intSplitsFound = 0;
4544         int intSplitSize = 0;
4545         int intPrevValue = 7;
4546         int intPref = 0;                        
4547         int intType = 0;
4548         
4549         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4550         
4551         intPrevValue = 6;
4552         
4553         PropertyType PropType = PROPERTY_NONE;
4554         
4555         // Look for type before continuing.                     
4557         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4559         intPrevValue = 6;
4561         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4562         intiter != SplitPoints.end(); ++intiter){
4563         
4564                 SLiter = SplitLength.find(intiter->first);
4565         
4566                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4567                 
4568                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4569                 PropertyName = PropertyElement.GetNextToken();                          
4570                 PropertyValue = PropertyElement.GetNextToken();
4571                 
4572                 intPrevValue = intiter->second;
4573                 
4574                 // Process properties.
4575                 
4576                 size_t intPropertyValueLen = PropertyValue.Len();
4577                 
4578                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4579                         
4580                         PropertyValue.Trim();
4581                         PropertyValue.RemoveLast();
4582                         
4583                 }                               
4584                 
4585                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4586                         
4587                         PropertyValue.Remove(0, 1);
4588                         
4589                 }                       
4590                 
4591                 CaptureString(&PropertyValue, FALSE);
4592                 
4593                 if (PropertyName == wxT("ALTID")){
4595                         SoundsListAltID.erase(*SoundCount);
4596                         SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4597                 
4598                 } else if (PropertyName == wxT("PID")){
4600                         SoundsListPID.erase(*SoundCount);
4601                         SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4602                 
4603                 } else if (PropertyName == wxT("PREF")){
4605                         ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4606                 
4607                 } else if (PropertyName == wxT("MEDIATYPE")){
4608                 
4609                         SoundsListMediatype.erase(*SoundCount);
4610                         SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4612                 } else if (PropertyName == wxT("LANGUAGE")){
4613                 
4614                         SoundsListLanguage.erase(*SoundCount);
4615                         SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4617                 } else {
4618                 
4619                         // Something else we don't know about so append
4620                         // to the tokens variable.
4621                         
4622                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4623                         
4624                                 if (FirstToken == TRUE){
4625                                 
4626                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4627                                         FirstToken = FALSE;
4628                                 
4629                                 } else {
4630                                 
4631                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4632                                 
4633                                 }
4634                         
4635                         }
4636                 
4637                 }
4638         
4639         }       
4640         
4641         intPropertyLen = PropertySeg2.Len();
4642         SplitPoints.clear();
4643         SplitLength.clear();
4644         intSplitsFound = 0;
4645         intSplitSize = 0;
4646         intPrevValue = 0;
4647         
4648         CaptureString(&PropertySeg2, FALSE);
4649         
4650         for (int i = 0; i <= intPropertyLen; i++){
4652                 intSplitSize++;
4653         
4654                 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4655         
4656                         intSplitsFound++;
4657                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4658                         
4659                         if (intSplitsFound == 6){ 
4660                         
4661                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4662                                 break; 
4663                                 
4664                         } else {
4665                         
4666                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4667                         
4668                         }
4669                         
4670                         intSplitSize = 0;                                       
4671         
4672                 }
4674         }
4675         
4676         wxString wxSSoundURI;
4677         wxString wxSSoundMIME;
4678         wxString wxSSoundEncoding;
4679         wxString wxSSoundData;
4680         std::string base64enc;
4681         
4682         if (intSplitsFound == 0){
4683         
4684         } else {
4685         
4686                 std::map<int, int>::iterator striter;
4687         
4688                 striter = SplitLength.find(1);
4689         
4690                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4691         
4692                 while (wSTDataType.HasMoreTokens() == TRUE){
4693                 
4694                         wxSSoundURI = wSTDataType.GetNextToken();
4695                         wxSSoundMIME = wSTDataType.GetNextToken();
4696                         break;
4697                 
4698                 }                       
4699         
4700                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
4701         
4702                 while (wSTDataInfo.HasMoreTokens() == TRUE){
4703                 
4704                         wxSSoundEncoding = wSTDataInfo.GetNextToken();
4705                         wxSSoundData = wSTDataInfo.GetNextToken();                                      
4706                         base64enc = wxSSoundData.mb_str();
4707                         break;
4708                 
4709                 }
4710         
4711         }
4712         
4713         // Add the data to the General/Home/Work address variables.
4714                 
4715         switch(PropType){
4716                 case PROPERTY_NONE:
4717                         break;
4718                 case PROPERTY_HOME:
4719                         SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4720                         break;
4721                 case PROPERTY_WORK:
4722                         SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4723                         break;
4724         }
4725         
4726         SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4727         SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4728         SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4729         
4730         if (!PropertyTokens.IsEmpty()){
4731         
4732                 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4733         
4734         }
4735         
4738 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4740         size_t intPropertyLen = PropertySeg1.Len();
4741         std::map<int, int> SplitPoints;
4742         std::map<int, int> SplitLength;
4743         std::map<int, int>::iterator SLiter;                    
4744         wxString PropertyData;
4745         wxString PropertyName;
4746         wxString PropertyValue;
4747         wxString PropertyTokens;
4748         bool FirstToken = TRUE;
4749         int intSplitsFound = 0;
4750         int intSplitSize = 0;
4751         int intPrevValue = 8;
4752         int intPref = 0;                        
4753         int intType = 0;
4754         
4755         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4756         
4757         intPrevValue = 7;
4758         
4759         PropertyType PropType = PROPERTY_NONE;
4760         
4761         // Look for type before continuing.                     
4763         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4765         intPrevValue = 7;
4767         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4768         intiter != SplitPoints.end(); ++intiter){
4769         
4770                 SLiter = SplitLength.find(intiter->first);
4771         
4772                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4773                 
4774                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4775                 PropertyName = PropertyElement.GetNextToken();                          
4776                 PropertyValue = PropertyElement.GetNextToken();
4777                 
4778                 intPrevValue = intiter->second;
4779                 
4780                 // Process properties.
4781                 
4782                 size_t intPropertyValueLen = PropertyValue.Len();
4783                 
4784                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4785                         
4786                         PropertyValue.Trim();
4787                         PropertyValue.RemoveLast();
4788                         
4789                 }                               
4790                 
4791                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4792                         
4793                         PropertyValue.Remove(0, 1);
4794                         
4795                 }                       
4796                 
4797                 CaptureString(&PropertyValue, FALSE);
4798                 
4799                 if (PropertyName == wxT("ALTID")){
4801                         CalendarListAltID.erase(*CalURICount);
4802                         CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4803                 
4804                 } else if (PropertyName == wxT("PID")){
4806                         CalendarListPID.erase(*CalURICount);
4807                         CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4808                 
4809                 } else if (PropertyName == wxT("PREF")){
4811                         ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4812                 
4813                 } else if (PropertyName == wxT("MEDIATYPE")){
4814                 
4815                         CalendarListMediatype.erase(*CalURICount);
4816                         CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4818                 } else {
4819                 
4820                         // Something else we don't know about so append
4821                         // to the tokens variable.
4822                         
4823                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4824                         
4825                                 if (FirstToken == TRUE){
4826                                 
4827                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4828                                         FirstToken = FALSE;
4829                                 
4830                                 } else {
4831                                 
4832                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4833                                 
4834                                 }
4835                         
4836                         }
4837                 
4838                 }
4839         
4840         }       
4841         
4842         intPropertyLen = PropertySeg2.Len();
4843         SplitPoints.clear();
4844         SplitLength.clear();
4845         intSplitsFound = 0;
4846         intSplitSize = 0;
4847         intPrevValue = 0;
4848         
4849         CaptureString(&PropertySeg2, FALSE);
4850         
4851         // Add the data to the General/Home/Work address variables.
4852                 
4853         switch(PropType){
4854                 case PROPERTY_NONE:
4855                         break;
4856                 case PROPERTY_HOME:
4857                         CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4858                         break;
4859                 case PROPERTY_WORK:
4860                         CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4861                         break;
4862         }
4863         
4864         CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4865         
4866         if (!PropertyTokens.IsEmpty()){
4867         
4868                 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4869         
4870         }
4874 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4876         size_t intPropertyLen = PropertySeg1.Len();
4877         std::map<int, int> SplitPoints;
4878         std::map<int, int> SplitLength;
4879         std::map<int, int>::iterator SLiter;                    
4880         wxString PropertyData;
4881         wxString PropertyName;
4882         wxString PropertyValue;
4883         wxString PropertyTokens;
4884         bool FirstToken = TRUE;
4885         int intSplitsFound = 0;
4886         int intSplitSize = 0;
4887         int intPrevValue = 8;
4888         int intPref = 0;                        
4889         int intType = 0;
4890         
4891         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4892         
4893         intPrevValue = 7;
4894         
4895         PropertyType PropType = PROPERTY_NONE;
4896         
4897         // Look for type before continuing.                     
4899         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4901         intPrevValue = 7;
4903         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
4904         intiter != SplitPoints.end(); ++intiter){
4905         
4906                 SLiter = SplitLength.find(intiter->first);
4907         
4908                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4909                 
4910                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4911                 PropertyName = PropertyElement.GetNextToken();                          
4912                 PropertyValue = PropertyElement.GetNextToken();
4913                 
4914                 intPrevValue = intiter->second;
4915                 
4916                 // Process properties.
4917                 
4918                 size_t intPropertyValueLen = PropertyValue.Len();
4919                 
4920                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4921                         
4922                         PropertyValue.Trim();
4923                         PropertyValue.RemoveLast();
4924                         
4925                 }                               
4926                 
4927                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4928                         
4929                         PropertyValue.Remove(0, 1);
4930                         
4931                 }                       
4932                 
4933                 CaptureString(&PropertyValue, FALSE);
4934                 
4935                 if (PropertyName == wxT("ALTID")){
4937                         CalendarRequestListAltID.erase(*CalAdrURICount);
4938                         CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4939                 
4940                 } else if (PropertyName == wxT("PID")){
4942                         CalendarRequestListPID.erase(*CalAdrURICount);
4943                         CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4944                 
4945                 } else if (PropertyName == wxT("PREF")){
4947                         ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
4948                 
4949                 } else if (PropertyName == wxT("MEDIATYPE")){
4950                 
4951                         CalendarRequestListMediatype.erase(*CalAdrURICount);
4952                         CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4954                 } else {
4955                 
4956                         // Something else we don't know about so append
4957                         // to the tokens variable.
4958                         
4959                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4960                         
4961                                 if (FirstToken == TRUE){
4962                                 
4963                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4964                                         FirstToken = FALSE;
4965                                 
4966                                 } else {
4967                                 
4968                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4969                                 
4970                                 }
4971                         
4972                         }
4973                 
4974                 }
4975         
4976         }       
4977         
4978         intPropertyLen = PropertySeg2.Len();
4979         SplitPoints.clear();
4980         SplitLength.clear();
4981         intSplitsFound = 0;
4982         intSplitSize = 0;
4983         intPrevValue = 0;
4984         
4985         CaptureString(&PropertySeg2, FALSE);
4986         
4987         // Add the data to the General/Home/Work address variables.
4988                 
4989         switch(PropType){
4990                 case PROPERTY_NONE:
4991                         break;
4992                 case PROPERTY_HOME:
4993                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4994                         break;
4995                 case PROPERTY_WORK:
4996                         CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4997                         break;
4998         }
4999         
5000         CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5001         
5002         if (!PropertyTokens.IsEmpty()){
5003         
5004                 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5005         
5006         }       
5007         
5010 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5012         size_t intPropertyLen = PropertySeg1.Len();
5013         std::map<int, int> SplitPoints;
5014         std::map<int, int> SplitLength;
5015         std::map<int, int>::iterator SLiter;                    
5016         wxString PropertyData;
5017         wxString PropertyName;
5018         wxString PropertyValue;
5019         wxString PropertyTokens;
5020         bool FirstToken = TRUE;
5021         int intSplitsFound = 0;
5022         int intSplitSize = 0;
5023         int intPrevValue = 7;
5024         int intPref = 0;                        
5025         int intType = 0;
5026         
5027         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5028         
5029         intPrevValue = 6;
5030         
5031         PropertyType PropType = PROPERTY_NONE;
5032         
5033         // Look for type before continuing.                     
5035         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5037         intPrevValue = 6;
5039         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5040         intiter != SplitPoints.end(); ++intiter){
5041         
5042                 SLiter = SplitLength.find(intiter->first);
5043         
5044                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5045                 
5046                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5047                 PropertyName = PropertyElement.GetNextToken();                          
5048                 PropertyValue = PropertyElement.GetNextToken();
5049                 
5050                 intPrevValue = intiter->second;
5051                 
5052                 // Process properties.
5053                 
5054                 size_t intPropertyValueLen = PropertyValue.Len();
5055                 
5056                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5057                         
5058                         PropertyValue.Trim();
5059                         PropertyValue.RemoveLast();
5060                         
5061                 }                               
5062                 
5063                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5064                         
5065                         PropertyValue.Remove(0, 1);
5066                         
5067                 }                       
5068                 
5069                 CaptureString(&PropertyValue, FALSE);
5070                 
5071                 if (PropertyName == wxT("ALTID")){
5073                         FreeBusyListAltID.erase(*FreeBusyAddressCount);
5074                         FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5075                 
5076                 } else if (PropertyName == wxT("PID")){
5078                         FreeBusyListPID.erase(*FreeBusyAddressCount);
5079                         FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5080                 
5081                 } else if (PropertyName == wxT("PREF")){
5083                         ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5084                 
5085                 } else if (PropertyName == wxT("MEDIATYPE")){
5086                 
5087                         FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5088                         FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5090                 } else {
5091                 
5092                         // Something else we don't know about so append
5093                         // to the tokens variable.
5094                         
5095                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5096                         
5097                                 if (FirstToken == TRUE){
5098                                 
5099                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5100                                         FirstToken = FALSE;
5101                                 
5102                                 } else {
5103                                 
5104                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5105                                 
5106                                 }
5107                         
5108                         }
5109                 
5110                 }
5111         
5112         }       
5113         
5114         intPropertyLen = PropertySeg2.Len();
5115         SplitPoints.clear();
5116         SplitLength.clear();
5117         intSplitsFound = 0;
5118         intSplitSize = 0;
5119         intPrevValue = 0;
5120         
5121         CaptureString(&PropertySeg2, FALSE);
5122         
5123         // Add the data to the General/Home/Work address variables.
5124                 
5125         switch(PropType){
5126                 case PROPERTY_NONE:
5127                         break;
5128                 case PROPERTY_HOME:
5129                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5130                         break;
5131                 case PROPERTY_WORK:
5132                         FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5133                         break;
5134         }
5135         
5136         FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5137         
5138         if (!PropertyTokens.IsEmpty()){
5139         
5140                 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5141         
5142         }
5146 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5148         size_t intPropertyLen = PropertySeg1.Len();
5149         std::map<int, int> SplitPoints;
5150         std::map<int, int> SplitLength;
5151         std::map<int, int>::iterator SLiter;                    
5152         wxString PropertyData;
5153         wxString PropertyName;
5154         wxString PropertyValue;
5155         wxString PropertyTokens;
5156         bool FirstToken = TRUE;
5157         int intSplitsFound = 0;
5158         int intSplitSize = 0;
5159         int intPrevValue = 5;
5160         int intPref = 0;                        
5161         int intType = 0;
5162         long ListCtrlIndex;
5163         
5164         SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5165         
5166         intPrevValue = 4;
5167         
5168         PropertyType PropType = PROPERTY_NONE;
5169         
5170         // Look for type before continuing.
5172         CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5174         intPrevValue = 4;
5176         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
5177         intiter != SplitPoints.end(); ++intiter){
5178         
5179                 SLiter = SplitLength.find(intiter->first);
5180         
5181                 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5182                 
5183                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5184                 PropertyName = PropertyElement.GetNextToken();                          
5185                 PropertyValue = PropertyElement.GetNextToken();
5186                 
5187                 intPrevValue = intiter->second;
5188                 
5189                 // Process properties.
5190                 
5191                 size_t intPropertyValueLen = PropertyValue.Len();
5192                 
5193                 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5194                         
5195                         PropertyValue.Trim();
5196                         PropertyValue.RemoveLast();
5197                         
5198                 }                               
5199                 
5200                 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5201                         
5202                         PropertyValue.Remove(0, 1);
5203                         
5204                 }                               
5205                 
5206                 if (PropertyName == wxT("ALTID")){
5208                         KeyListAltID.erase(*KeyCount);
5209                         KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5210                 
5211                 } else if (PropertyName == wxT("PID")){
5213                         KeyListPID.erase(*KeyCount);
5214                         KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5215                 
5216                 } else if (PropertyName == wxT("PREF")){
5218                         ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5219                 
5220                 } else {
5221                 
5222                         // Something else we don't know about so append
5223                         // to the tokens variable.
5224                         
5225                         if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5226                         
5227                                 if (FirstToken == TRUE){
5228                                 
5229                                         PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5230                                         FirstToken = FALSE;
5231                                 
5232                                 } else {
5233                                 
5234                                         PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5235                                 
5236                                 }
5237                         
5238                         }
5239                 
5240                 }
5241         
5242         }                               
5243         
5244         intPropertyLen = PropertySeg2.Len();
5245         SplitPoints.clear();
5246         SplitLength.clear();
5247         intSplitsFound = 0;
5248         intSplitSize = 0;
5249         intPrevValue = 0;                       
5250         
5251         for (int i = 0; i <= intPropertyLen; i++){
5253                 intSplitSize++;
5254         
5255                 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5256         
5257                         intSplitsFound++;
5258                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5259                         
5260                         if (intSplitsFound == 6){ 
5261                         
5262                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5263                                 break; 
5264                                 
5265                         } else {
5266                         
5267                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5268                         
5269                         }
5270                         
5271                         intSplitSize = 0;                                       
5272         
5273                 }
5275         }
5276         
5277         wxString wxSKeyURI;
5278         wxString wxSKeyMIME;
5279         wxString wxSKeyEncoding;
5280         wxString wxSKeyData;
5281         std::string base64enc;
5282         
5283         if (intSplitsFound == 0){
5284         
5285         } else {
5286         
5287                 std::map<int, int>::iterator striter;
5288         
5289                 striter = SplitLength.find(1);
5290         
5291                 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5292         
5293                 while (wSTDataType.HasMoreTokens() == TRUE){
5294                 
5295                         wxSKeyURI = wSTDataType.GetNextToken();
5296                         wxSKeyMIME = wSTDataType.GetNextToken();
5297                         break;
5298                 
5299                 }                       
5300         
5301                 if (wxSKeyURI == wxT("data")){
5302                 
5303                                 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));                       
5304         
5305                                 while (wSTDataInfo.HasMoreTokens() == TRUE){
5306                 
5307                                 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5308                                 wxSKeyData = wSTDataInfo.GetNextToken();
5309                                 break;
5310                 
5311                         }
5312                 
5313                 }
5314         
5315         }
5316         
5317         // Add the data to the General/Home/Work address variables.
5318         
5319         if (wxSKeyURI == wxT("data")){
5320                 
5321                 KeyListDataEncType.erase(*KeyCount);
5322                 KeyListKeyType.erase(*KeyCount);
5323                 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5324                 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5325                 
5326                 KeyList.erase(*KeyCount);
5327                 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5328         
5329         } else {
5330                 
5331                 KeyList.erase(*KeyCount);
5332                 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5333         
5334         }
5335         
5336         KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5337                 
5338         switch (PropType){
5339                 case PROPERTY_NONE:
5340                         break;
5341                 case PROPERTY_HOME: 
5342                         KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5343                         break;
5344                 case PROPERTY_WORK: 
5345                         KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5346                         break;
5347         }
5349         if (!PropertyTokens.IsEmpty()){
5351                 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5353         }
5357 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5359         // Split the Vendor three ways.
5360         
5361         wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5362         
5363         wxString wxSVNDID;
5364         wxString wxSVNDPropName;
5365         long ListCtrlIndex;                     
5367         while (wSTVendorDetails.HasMoreTokens() == TRUE){
5368         
5369                 wSTVendorDetails.GetNextToken();
5370                 wxSVNDID = wSTVendorDetails.GetNextToken();
5371                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5372                 break;
5373         
5374         }
5375         
5376         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5377         
5378                 // Add the data to the vendor variables.
5379         
5380                 VendorList.erase(*VendorCount);
5381                 VendorListPEN.erase(*VendorCount);
5382                 VendorListElement.erase(*VendorCount);
5383         
5384                 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5385                 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5386                 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5387         
5388         }
5392 void ProcessStringValue(wxString *PropertyName,
5393         wxString PropertyNameMatch,
5394         std::map<int,wxString> *MapPtr,
5395         wxString *PropertyValue,
5396         int *ItemCount,
5397         bool *PropertyMatched){
5398         
5399         if (*PropertyName == PropertyNameMatch){
5400                 MapPtr->erase(*ItemCount);
5401                 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5402                 *PropertyMatched = TRUE;
5403         }
5404         
5407 void ProcessIntegerValue(wxString *PropertyName,
5408         wxString PropertyNameMatch,
5409         std::map<int,int> *PrefPtr, 
5410         wxString *PropertyValue, 
5411         int *ItemCount,
5412         bool *PropertyMatched){
5414         if (*PropertyName == PropertyNameMatch){
5415                 *PropertyMatched = TRUE;
5416         } else {
5417                 return;
5418         }
5420         int PriorityNumber = 0; 
5421         bool ValidNumber = TRUE;
5422                         
5423         try{
5424                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5425         }
5426                         
5427         catch(std::invalid_argument &e){
5428                 ValidNumber = FALSE;
5429         }
5431         if (ValidNumber == TRUE){
5433                 PrefPtr->erase(*ItemCount);
5434                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5436         }
5440 void ProcessIntegerValue(std::map<int,int> *PrefPtr, 
5441         wxString *PropertyValue, 
5442         int *ItemCount){
5444         int PriorityNumber = 0; 
5445         bool ValidNumber = TRUE;
5446                         
5447         try{
5448                 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5449         }
5450                         
5451         catch(std::invalid_argument &e){
5452                 ValidNumber = FALSE;
5453         }
5455         if (ValidNumber == TRUE){
5457                 PrefPtr->erase(*ItemCount);
5458                 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5460         }
5464 void SplitValues(wxString *PropertyLine, 
5465         std::map<int,int> *SplitPoints, 
5466         std::map<int,int> *SplitLength, 
5467         int intSize){
5468         
5469         size_t intPropertyLen = PropertyLine->Len();
5470         int intSplitsFound = 0;
5471         int intSplitSize = 0;
5472         int intSplitSeek = 0;
5473         
5474         for (int i = intSize; i <= intPropertyLen; i++){
5476                 intSplitSize++;
5477         
5478                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5479                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5480            
5481                     if (intSplitsFound == 0){
5482             
5483                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5484           
5485                     } else {
5486            
5487                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5488             
5489                     }
5490             
5491                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5492             
5493                     intSplitsFound++;
5494                     intSplitSeek = i;
5495                     intSplitSize = 0;
5496             
5497                 }
5499         }
5501         if (intSplitsFound == 0){
5503                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5504                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5506         } else {
5508                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5509                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5511         }
5515 void CheckType(wxString *PropertySeg1, 
5516         std::map<int,int> *SplitPoints, 
5517         std::map<int,int> *SplitLength, 
5518         int *intPrevValue, 
5519         PropertyType *PropType){
5520         
5521         wxString PropertyData;
5522         wxString PropertyName;
5523         wxString PropertyValue;
5524         std::map<int,int>::iterator SLiter;
5525         
5526         for (std::map<int, int>::iterator intiter = SplitPoints->begin(); 
5527         intiter != SplitPoints->end(); ++intiter){
5528         
5529                 SLiter = SplitLength->find(intiter->first);
5530         
5531                 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5532                 
5533                 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5534                 PropertyName = PropertyElement.GetNextToken();                          
5535                 PropertyValue = PropertyElement.GetNextToken();
5536                 
5537                 *intPrevValue = intiter->second;
5538                 
5539                 if (PropertyName == wxT("TYPE")){
5540                                 
5541                         if (PropertyValue == wxT("work")){
5542                         
5543                                 *PropType = PROPERTY_WORK;
5544                                                         
5545                         } else if (PropertyValue == wxT("home")){
5547                                 *PropType = PROPERTY_HOME;
5548                                                         
5549                         } else {
5550                         
5551                                 *PropType = PROPERTY_NONE;
5552                         
5553                         }
5554                 
5555                         return;
5556                 
5557                 }
5558         
5559         }
5560         
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