Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Indented code properly contacteditor/frmContactEditor-Load.cpp
[xestiaab/.git] / source / contacteditor / frmContactEditor-Load.cpp
1 // frmContactEditor-Load.cpp - frmContactEditor load contact subroutines.
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 <map>
21 #include <wx/ffile.h>
22 #include <wx/tokenzr.h>
23 #include <wx/datetime.h>
24 #include <wx/dir.h>
26 #include "frmContactEditor.h"
28 #include "../enums.h"
29 #include "../version.h"
30 #include "../vcard/vcard.h"
31 #include "../common/textprocessing.h"
32 #include "../common/dirs.h"
33 #include "cdo/ContactDataObject.h"
35 bool frmContactEditor::LoadContact(wxString Filename){
37         // Load the contact into the contact editor.
38         
39         wxFFile ContactFile;
40         wxString wxSContactString;
41         wxString ContactLine;
42         vCard ContactData;
43         XABViewMode XVMData;
44         if (StartupEditMode == FALSE){
45                 XVMData = MainPtr->GetViewMode();
46         }
47         
48         wxSContactFilename = Filename;
49         
50         // Check if we are using wxWidgets version 2.8 or less and
51         // execute the required command accordingly.
52 /*      
53 #if wxABI_VERSION < 20900
54         ContactFile.Open(Filename.c_str(), wxT("r"));
55 #else
56         ContactFile.Open(Filename, wxT("r"));
57 #endif  
58         
59         if (ContactFile.IsOpened() == FALSE){
60         
61                 return FALSE;
62         
63         }
64         
65         ContactEditorData.LoadFile(Filename);
66         
67         ContactFile.ReadAll(&wxSContactString, wxConvAuto());
69         // Split the lines.
70         
71         std::map<int, wxString> ContactFileLines;
72         std::map<int, wxString>::iterator striter;
73         
74         wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
76         int ContactLineSeek = 0;
78         while (wSTContactFileLines.HasMoreTokens() == TRUE){
80                 ContactLine = wSTContactFileLines.GetNextToken();
81                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
82                 ContactLineSeek++;              
83         
84         }
85 */      
87         ContactLoadStatus LoadResult = ContactEditorData.LoadFile(Filename);
89         switch(LoadResult){
90         
91                 case CONTACTLOAD_OK:
92                         break;
93                 case CONTACTLOAD_FILEMISSING:
94                         wxMessageBox(_("The file with the filename given does not exist."),
95                                 _("Contact not found"), wxICON_ERROR);
96                         this->Close();
97                         return FALSE;
98                         break;
99                 case CONTACTLOAD_FILEERROR:
100                         wxMessageBox(_("The file with the filename given cannot be opened due to an error while trying open it."),
101                                 _("Error loading contact"), wxICON_ERROR);
102                         this->Close();
103                         return FALSE;
104                         break;
105                 case CONTACTLOAD_FILEINVALIDFORMAT:
106                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
107                                         _("Contact not supported"), wxICON_ERROR);
108                         this->Close();
109                         return FALSE;
110                         break;
111                 case CONTACTLOAD_FILEBASESPECFAIL:
112                         wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
113                                 _("Contact not supported"), wxICON_ERROR);
114                         this->Close();
115                         return FALSE;
116                         break;
117         
118         };
119         
120         // Get the line.
122         bool QuoteMode = FALSE;
123         bool PropertyFind = TRUE;
124         bool HasExtraNicknames = FALSE;
125         bool IgnoreGender = FALSE;
126         bool ExtraLineSeek = TRUE;
127         //bool BirthdayProcessed = FALSE;
128         //bool AnniversaryProcessed = FALSE;
129         bool FNProcessed = FALSE;
130         bool GenderProcessed = FALSE;
131         bool NameProcessed = FALSE;
132         //bool UIDProcessed = FALSE;
133         //bool KindProcessed = FALSE;
134         bool ETagFound = FALSE;
135         bool ETagOrigFound = FALSE;
136         bool VersionProcessed = FALSE;
137         int intExtraNickname = 0;
138         wxString wxSProperty;
139         wxString wxSPropertySeg1;
140         wxString wxSPropertySeg2;
141         wxString wxSPropertyNextLine;
142         size_t ContactLineLen = 0;
143         int QuoteBreakPoint = 0;
144         int FNCount = 0;
145         int NameCount = 0;
146         int NicknameCount = 0;
147         int ADRCount = 0;
148         int EmailCount = 0;
149         int IMPPCount = 0;
150         int TelCount = 0;
151         int LangCount = 0;
152         int TZCount = 0;
153         int GeoCount = 0;
154         int URLCount = 0;
155         int RelatedCount = 0;
156         int TitleCount = 0;
157         int RoleCount = 0;
158         int OrgCount = 0;
159         int NoteCount = 0;
160         int CategoryCount = 0;
161         int GroupCount = 0;
162         int PhotoCount = 0;
163         int LogoCount = 0;
164         int SoundCount = 0;
165         int CalAdrCount = 0;
166         int CalReqAdrCount = 0;
167         int FreeBusyCount = 0;
168         int KeyCount = 0;
169         int VendorCount = 0;
170         int XTokenCount = 0;
171         //int intValueSeek = 1;
173         // Process the unique ID (UID)
174         
175         // Do nothing at the moment.
176         
177         // Process the contact type (KIND) (frmContactEditor-LoadGroup.cpp)
179         LoadKind(&ContactEditorData.ContactKind);
181         // Process the Birthday (BDAY) (frmContactEditor-LoadBADays.cpp)
182         
183         LoadBirthday(&ContactEditorData.Birthday, &ContactEditorData.BirthdayText);
185         // Process the Anniversary (ANNIVERSARY) (frmContactEditor-LoadBADays.cpp)
186         
187         LoadAnniversary(&ContactEditorData.Anniversary, &ContactEditorData.AnniversaryText);
189         // Process the Gender (GENDER) (frmContactEditor-LoadGender.cpp)
190         
191         LoadGender(&ContactEditorData.Gender, &ContactEditorData.GenderDetails);
192         
193         // Process the Name (N) (frmContactEditor-LoadName.cpp)
194         
195         LoadName(&ContactEditorData.NameTitle, &ContactEditorData.NameForename,
196                 &ContactEditorData.NameSurname, &ContactEditorData.NameOtherNames,
197                 &ContactEditorData.NameSuffix);
198                 
199         // Process the group members (MEMBER) (frmContactEditor-LoadGroup.cpp)
200                 
201         LoadMember(&ContactEditorData.GroupsList);
203         // Process the addresses (ADR) (frmContactEditor-LoadAddress.cpp)
204         
205         LoadAddress(&ContactEditorData.GeneralAddressList,
206                 &ContactEditorData.GeneralAddressListTown,
207                 &ContactEditorData.GeneralAddressListCounty,
208                 &ContactEditorData.GeneralAddressListPostCode,
209                 &ContactEditorData.GeneralAddressListPref,
210                 &ContactEditorData.HomeAddressList,
211                 &ContactEditorData.HomeAddressListTown,
212                 &ContactEditorData.HomeAddressListCounty,
213                 &ContactEditorData.HomeAddressListPostCode,
214                 &ContactEditorData.HomeAddressListPref,
215                 &ContactEditorData.BusinessAddressList,
216                 &ContactEditorData.BusinessAddressListTown,
217                 &ContactEditorData.BusinessAddressListCounty,
218                 &ContactEditorData.BusinessAddressListPostCode,
219                 &ContactEditorData.BusinessAddressListPref,
220                 &ADRCount);
222         // Process the timezones (TZ).
223         
224         LoadData(&ContactEditorData.GeneralTZList,
225                 &ContactEditorData.GeneralTZListPref,
226                 lboTimezones,
227                 &ContactEditorData.HomeTZList,
228                 &ContactEditorData.HomeTZListPref,
229                 lboHomeTimezones,
230                 &ContactEditorData.BusinessTZList,
231                 &ContactEditorData.BusinessTZListPref,
232                 lboBusinessTimezones,
233                 &TZCount);
234                 
235         // Process the emails (EMAIL).
236         
237         LoadData(&ContactEditorData.GeneralEmailList,
238                 &ContactEditorData.GeneralEmailListPref,
239                 lboEmails,
240                 &ContactEditorData.HomeEmailList,
241                 &ContactEditorData.HomeEmailListPref,
242                 lboHomeEmails,
243                 &ContactEditorData.BusinessEmailList,
244                 &ContactEditorData.BusinessEmailListPref,
245                 lboBusinessEmail,
246                 &EmailCount);
248         // Process the nicknames (NICKNAME).
249         
250         LoadData(&ContactEditorData.GeneralNicknamesList,
251                 &ContactEditorData.GeneralNicknamesListPref,
252                 lboNicknames,
253                 &ContactEditorData.HomeNicknamesList,
254                 &ContactEditorData.HomeNicknamesListPref,
255                 lboHomeNicknames,
256                 &ContactEditorData.BusinessNicknamesList,
257                 &ContactEditorData.BusinessNicknamesListPref,
258                 lboBusinessNicknames,
259                 &NicknameCount);
260                 
261         // Process the languages (LANG).
262         
263         LoadData(&ContactEditorData.GeneralLanguageList,
264                 &ContactEditorData.GeneralLanguageListPref,
265                 lboLanguages,
266                 &ContactEditorData.HomeLanguageList,
267                 &ContactEditorData.HomeLanguageListPref,
268                 lboHomeLanguages,
269                 &ContactEditorData.BusinessLanguageList,
270                 &ContactEditorData.BusinessLanguageListPref,
271                 lboBusinessLanguages,
272                 &LangCount);
273                 
274         // Process the geopositiosn (GEO).
275         
276         LoadData(&ContactEditorData.GeneralGeographyList,
277                 &ContactEditorData.GeneralGeographyListPref,
278                 lboGeoposition,
279                 &ContactEditorData.HomeGeographyList,
280                 &ContactEditorData.HomeGeographyListPref,
281                 lboHomeGeoposition,
282                 &ContactEditorData.BusinessGeographyList,
283                 &ContactEditorData.BusinessGeographyListPref,
284                 lboBusinessGeoposition,
285                 &GeoCount);
286                 
287         // Process the websites (URL).
288         
289         LoadData(&ContactEditorData.GeneralWebsiteList,
290                 &ContactEditorData.GeneralWebsiteListPref,
291                 lboWebsites,
292                 &ContactEditorData.HomeWebsiteList,
293                 &ContactEditorData.HomeWebsiteListPref,
294                 lboHomeWebsites,
295                 &ContactEditorData.BusinessWebsiteList,
296                 &ContactEditorData.BusinessWebsiteListPref,
297                 lboBusinessWebsites,
298                 &URLCount);
300         // Process the titles (TITLE).
301         
302         LoadData(&ContactEditorData.GeneralTitleList,
303                 &ContactEditorData.GeneralTitleListPref,
304                 lboTitles,
305                 &ContactEditorData.HomeTitleList,
306                 &ContactEditorData.HomeTitleListPref,
307                 lboHomeTitles,
308                 &ContactEditorData.BusinessTitleList,
309                 &ContactEditorData.BusinessTitleListPref,
310                 lboBusinessTitles,
311                 &TitleCount);
312                 
313         // Process the roles (ROLE).
314         
315         LoadData(&ContactEditorData.GeneralRoleList,
316                 &ContactEditorData.GeneralRoleListPref,
317                 lboRoles,
318                 &ContactEditorData.HomeRoleList,
319                 &ContactEditorData.HomeRoleListPref,
320                 lboHomeRoles,
321                 &ContactEditorData.BusinessRoleList,
322                 &ContactEditorData.BusinessRoleListPref,
323                 lboBusinessRoles,
324                 &RoleCount);
326         // Process the roles (ORG).
327         
328         LoadData(&ContactEditorData.GeneralOrganisationsList,
329                 &ContactEditorData.GeneralOrganisationsListPref,
330                 lboOrganisations,
331                 &ContactEditorData.HomeOrganisationsList,
332                 &ContactEditorData.HomeOrganisationsListPref,
333                 lboHomeOrganisations,
334                 &ContactEditorData.BusinessOrganisationsList,
335                 &ContactEditorData.BusinessOrganisationsListPref,
336                 lboBusinessOrganisations,
337                 &OrgCount);
338                 
339         // Process the notes (NOTE).
340                 
341         LoadData(&ContactEditorData.GeneralNoteList,
342                 &ContactEditorData.GeneralNoteListPref,
343                 lboNotes,
344                 &ContactEditorData.HomeNoteList,
345                 &ContactEditorData.HomeNoteListPref,
346                 lboHomeNotes,
347                 &ContactEditorData.BusinessNoteList,
348                 &ContactEditorData.BusinessNoteListPref,
349                 lboBusinessNotes,
350                 &NoteCount);
351                 
352         // Process the categories (CATEGORIES).
354         LoadData(&ContactEditorData.CategoriesList,
355                 &ContactEditorData.CategoriesListPref,
356                 lboCategories,
357                 &CategoryCount);
358                 
359         // Process the telephone numbers (TEL).
360         
361         LoadData(&ContactEditorData.GeneralTelephoneList,
362                 &ContactEditorData.GeneralTelephoneListPref,
363                 &ContactEditorData.GeneralTelephoneListTypeInfo,
364                 lboTelephone,
365                 &ContactEditorData.HomeTelephoneList,
366                 &ContactEditorData.HomeTelephoneListPref,
367                 &ContactEditorData.HomeTelephoneListTypeInfo,
368                 lboHomeTelephone,
369                 &ContactEditorData.BusinessTelephoneList,
370                 &ContactEditorData.BusinessTelephoneListPref,
371                 &ContactEditorData.BusinessTelephoneListTypeInfo,
372                 lboBusinessTelephone,
373                 &TelCount);
375         // Process the instant messaging (IMPP).
376         
377         LoadData(&ContactEditorData.GeneralIMListTypeInfo,
378                 &ContactEditorData.GeneralIMListPref,
379                 &ContactEditorData.GeneralIMList,
380                 lboIM,
381                 &ContactEditorData.HomeIMListTypeInfo,
382                 &ContactEditorData.HomeIMListPref,
383                 &ContactEditorData.HomeIMList,
384                 lboHomeIM,
385                 &ContactEditorData.BusinessIMListTypeInfo,
386                 &ContactEditorData.BusinessIMListPref,
387                 &ContactEditorData.BusinessIMList,
388                 lboBusinessIM,
389                 &IMPPCount);
391         // Process the photos (PHOTO).
392         
393         LoadPictureData("PHOTO", 
394                 &ContactEditorData.PicturesList,
395                 &ContactEditorData.PicturesListPref,
396                 &ContactEditorData.PicturesListType,
397                 lboPictures,
398                 &PhotoCount);
399                 
400         // Process the logos (LOGO).
401         
402         LoadPictureData("LOGO", 
403                 &ContactEditorData.LogosList,
404                 &ContactEditorData.LogosListPref,
405                 &ContactEditorData.LogosListType,
406                 lboLogos,
407                 &LogoCount);
408                 
409         // Process the sounds (SOUND).
410         
411         LoadPictureData("SOUND", 
412                 &ContactEditorData.SoundsList,
413                 &ContactEditorData.SoundsListPref,
414                 &ContactEditorData.SoundsListType,
415                 lboSounds,
416                 &SoundCount);
418         // Process the calendar addresses (CALURI).
419         
420         LoadData("CALURI", 
421                 &ContactEditorData.CalendarList,
422                 &ContactEditorData.CalendarListPref,
423                 &ContactEditorData.CalendarListType,
424                 NULL,
425                 lboCalendarAddresses,
426                 &CalAdrCount);
427                 
428         // Process the calendar request addresses (CALADRURI).
429         
430         LoadData("CALADRURI", 
431                 &ContactEditorData.CalendarRequestList,
432                 &ContactEditorData.CalendarRequestListPref,
433                 &ContactEditorData.CalendarRequestListType,
434                 NULL,
435                 lboCalendarRequestAddress,
436                 &CalReqAdrCount);
438         // Process the free busy addresses (FBURL).
439         
440         LoadData("FBURL", 
441                 &ContactEditorData.FreeBusyList,
442                 &ContactEditorData.FreeBusyListPref,
443                 &ContactEditorData.FreeBusyListType,
444                 NULL,
445                 lboFreeBusyAddresses,
446                 &FreeBusyCount);
447                 
448         // Process the keys. (KEY)
449         
450         LoadData("KEY",
451                 &ContactEditorData.KeyList,
452                 &ContactEditorData.KeyListPref,
453                 &ContactEditorData.KeyListType,
454                 &ContactEditorData.KeyListDataType,
455                 lboKeys,
456                 &KeyCount);
457                 
458         // Process the vendor specific information (VND-*).
459         
460         LoadVendorData(&ContactEditorData.VendorListPEN,
461                 &ContactEditorData.VendorListElement,
462                 lboVendorNamespace,
463                 &VendorCount);
464         
465         // Process the X-Tokens (X-*).
467         LoadXTokenData(&ContactEditorData.XTokenListTokens,
468                 lboXToken,
469                 &XTokenCount);
470         
471         // Process the related people (RELATED).
472         
473         LoadRelatedData(&ContactEditorData.GeneralRelatedList,
474                 &ContactEditorData.GeneralRelatedListPref,
475                 &ContactEditorData.GeneralRelatedListType,
476                 lboRelated,
477                 &RelatedCount);
478                 
479         // Process the full name (FN).
480         
481         LoadData(&ContactEditorData.FullNamesList,
482                 cmbDisplayAs);
484         /*for (std::map<int,wxString>::iterator iter = ContactFileLines.begin(); 
485          iter != ContactFileLines.end(); ++iter){
486         
487                 // Find the colon which splits the start bit from the data part.
488                 
489                 ContactLine = iter->second;
490                 
491                 while (ExtraLineSeek == TRUE){
492                 
493                         // Check if there is extra data on the next line 
494                         // (indicated by space or tab at the start) and add data.
495                 
496                         iter++;
497                         
498                         if (iter == ContactFileLines.end()){
499                         
500                                 iter--;
501                                 break;
502                         
503                         }                       
504                 
505                         wxSPropertyNextLine = iter->second;
506                         
507                 
508                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
509                 
510                                 wxSPropertyNextLine.Remove(0, 1);
511                                 //wxSPropertyNextLine.Trim(FALSE);
512                                 //ContactLine.Trim();
513                                 ContactLine.Append(wxSPropertyNextLine);
514                 
515                         } else {
516                         
517                                 iter--;
518                                 ExtraLineSeek = FALSE;
519                         
520                         }
521                 
522                 }
524                 ContactLineLen = ContactLine.Len();
525                 
526                 // Make sure we are not in quotation mode.
527                 // Make sure colon does not have \ or \\ before it.
528                 
529                 for (int i = 0; i <= ContactLineLen; i++){
530                 
531                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
532                         
533                                 PropertyFind = FALSE;
534                         
535                         } else if (PropertyFind == TRUE){
536                         
537                                 wxSProperty.Append(ContactLine.Mid(i, 1));
538                         
539                         }               
540                 
541                         if (ContactLine.Mid(i, 1) == wxT("\"")){
542                         
543                                 if (QuoteMode == TRUE){
544                                 
545                                         QuoteMode = FALSE;
546                                 
547                                 } else {
548                         
549                                         QuoteMode = TRUE;
550                                         
551                                 }
552                         
553                         }
554                         
555                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
556                         
557                                 QuoteBreakPoint = i;
558                                 break;
559                         
560                         }
561                 
562                 }
563                 
564                 // Split that line at the point into two variables (ignore the colon).
565                 
566                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
567                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
568                 
569                 // Add the data into the contact editor depending on what it is.                                
570                 
571                 if (wxSProperty == wxT("VERSION") && VersionProcessed == FALSE){
572                 
573                         // Check if version is 4.0, otherwise don't
574                         // load.
575                         
576                         if (wxSPropertySeg2 != wxT("4.0")){
577                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
578                                         _("Contact not supported"), wxICON_ERROR);
579                                 this->Close();
580                                 return FALSE;
581                         }
582                         
583                         VersionProcessed = TRUE;
584                 
585                 }/* if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
586                 
587                         // See frmContactEditor-LoadGroup.cpp
588                 
589                         LoadKind(wxSPropertySeg2);
590                 
591                 }/* else if (wxSProperty == wxT("MEMBER")){
593                         // See frmContactEditor-LoadGroup.cpp
595                         LoadMember(wxSPropertySeg2, &GroupCount);               
596                 
597                 } else if (wxSProperty == wxT("FN")){
598                 
599                         // See frmContactEditor-LoadName.cpp
600                 
601                         LoadFN(wxSPropertySeg1, wxSPropertySeg2, &FNCount, &FNProcessed, &ContactData);
602                 
603                 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
604                 
605                         // See frmContactEditor-LoadName.cpp
606                 
607                         LoadN(wxSPropertySeg1, wxSPropertySeg2, &NameProcessed, &ContactData);
608                 
609                 } else if (wxSProperty == wxT("NICKNAME")){
610                         
611                         // See frmContactEditor-LoadNickname.cpp
612                         
613                         LoadNickname(wxSPropertySeg1, wxSPropertySeg2, &NicknameCount, &ContactData);
614                         
615                 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
616                 
617                         // See frmContactEditor-LoadGender.cpp
618                 
619                         LoadGender(wxSPropertySeg1, wxSPropertySeg2, &GenderProcessed, &ContactData);
620                 
621                 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
623                         // See frmContactEditor-LoadBADays.cpp
625                         LoadBDay(wxSPropertySeg1, wxSPropertySeg2, &BirthdayProcessed);
626                 
627                 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
628                         
629                         // See frmContactEditor-LoadBADays.cpp
630                         
631                         LoadAnniversary(wxSPropertySeg1, wxSPropertySeg2, &AnniversaryProcessed);
632                 
633                 } else if (wxSProperty == wxT("TZ")){
634                 
635                         // See frmContactEditor-LoadTimeZone.cpp
636                 
637                         LoadTimeZone(wxSPropertySeg1, wxSPropertySeg2, &TZCount);       
638                 
639                 }  else if (wxSProperty == wxT("ADR")){
640                         
641                         // See frmContactEditor-LoadAddress.cpp
642                 
643                         LoadADR(wxSPropertySeg1, wxSPropertySeg2, &ADRCount);
644                 
645                 } else if (wxSProperty == wxT("EMAIL")){
646                 
647                         // See frmContactEditor-LoadEmail.cpp
648                         
649                         LoadEmail(wxSPropertySeg1, wxSPropertySeg2, &EmailCount);       
650                 
651                 } else if (wxSProperty == wxT("IMPP")){
652                 
653                         // See frmContactEditor-LoadIM.cpp
654                 
655                         LoadIM(wxSPropertySeg1, wxSPropertySeg2, &IMPPCount);
656                 
657                 }/* else if (wxSProperty == wxT("TEL")){
658                 
659                         // See frmContactEditor-LoadTelephone.cpp
660                 
661                         LoadTelephone(wxSPropertySeg1, wxSPropertySeg2, &TelCount);
662                 
663                 } else if (wxSProperty == wxT("LANG")){
664                 
665                         // See frmContactEditor-LoadLanguage.cpp
666                         
667                         LoadLanguage(wxSPropertySeg1, wxSPropertySeg2, &LangCount);
668                 
669                 } else if (wxSProperty == wxT("GEO")){
670                 
671                         // See frmContactEditor-LoadGeo.cpp
672                         
673                         LoadGeo(wxSPropertySeg1, wxSPropertySeg2, &GeoCount);   
674                 
675                 } else if (wxSProperty == wxT("RELATED")){
676                         
677                         // See fromContactEditor-LoadRelated.cpp
678                         
679                         LoadRelated(wxSPropertySeg1, wxSPropertySeg2, &RelatedCount);           
680                 
681                 } else if (wxSProperty == wxT("URL")){
683                         // See frmContactEditor-LoadURL.cpp
684                 
685                         LoadURL(wxSPropertySeg1, wxSPropertySeg2, &URLCount);
686                 
687                 } else if (wxSProperty == wxT("TITLE")) {
688                 
689                         // See frmContactEditor-LoadTitle.cpp
690                         
691                         LoadTitle(wxSPropertySeg1, wxSPropertySeg2, &TitleCount);
692                         
693                 } else if (wxSProperty == wxT("ROLE")) {
695                         // See frmContactEditor-LoadRole.cpp
696                 
697                         LoadRole(wxSPropertySeg1, wxSPropertySeg2, &RoleCount);
698                         
699                 } else if (wxSProperty == wxT("ORG")) {
700                 
701                         // See frmContactEditor-LoadOrg.cpp
702                         
703                         LoadOrg(wxSPropertySeg1, wxSPropertySeg2, &OrgCount);
704                         
705                 } else if (wxSProperty == wxT("NOTE")) {
707                         // See frmContactEditor-LoadNote.cpp
709                         LoadNote(wxSPropertySeg1, wxSPropertySeg2, &NoteCount); 
710                         
711                 } else if (wxSProperty == wxT("CATEGORIES")) {
712                 
713                         // See frmContactEditor-LoadCategory.cpp
714                 
715                         LoadCategory(wxSPropertySeg1, wxSPropertySeg2, &CategoryCount); 
716                         
717                 } else if (wxSProperty == wxT("PHOTO")) {
718                 
719                         // See frmContactEditor-LoadPhoto.cpp
720                         
721                         LoadPhoto(wxSPropertySeg1, wxSPropertySeg2, &PhotoCount);
723                 } else if (wxSProperty == wxT("LOGO")) {
724                 
725                         // See frmContactEditor-LoadLogo.cpp
726                 
727                         LoadLogo(wxSPropertySeg1, wxSPropertySeg2, &LogoCount);
728                         
729                 } else if (wxSProperty == wxT("SOUND")) {
730                 
731                         // See frmContactEditor-LoadSound.cpp
732                         
733                         LoadSound(wxSPropertySeg1, wxSPropertySeg2, &SoundCount);
734                         
735                 } else if (wxSProperty == wxT("CALURI")){
737                         // See frmContactEditor-LoadCalendar.cpp
738                         
739                         LoadCalURI(wxSPropertySeg1, wxSPropertySeg2, &CalAdrCount);
740                 
741                 } else if (wxSProperty == wxT("CALADRURI")){
743                         // See frmContactEditor-LoadCalendar.cpp
744                         
745                         LoadCalAdrURI(wxSPropertySeg1, wxSPropertySeg2, &CalReqAdrCount);
746                 
747                 } else if (wxSProperty == wxT("FBURL")){
749                         // See frmContactEditor-LoadCalendar.cpp
751                         LoadCalFreeBusy(wxSPropertySeg1, wxSPropertySeg2, &FreeBusyCount);
753                 } else if (wxSProperty == wxT("KEY")){
754                 
755                         // See frmContactEditor-LoadKey.cpp
756                         
757                         LoadKey(wxSPropertySeg1, wxSPropertySeg2, &KeyCount);
758                 
759                 } else if (wxSProperty == wxT("UID") && UIDProcessed == FALSE){
760                 
761                         UIDToken = wxSPropertySeg2;
762                         UIDProcessed = TRUE;
763                 
764                 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
765                 
766                         // Split the Vendor three ways.
767                         
768                         wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
769                         
770                         wxString wxSVNDID;
771                         wxString wxSVNDPropName;
772                         long ListCtrlIndex;                     
774                         while (wSTVendorDetails.HasMoreTokens() == TRUE){
775                         
776                                 wSTVendorDetails.GetNextToken();
777                                 wxSVNDID = wSTVendorDetails.GetNextToken();
778                                 wxSVNDPropName = wSTVendorDetails.GetNextToken();
779                                 break;
780                         
781                         }
782                         
783                         if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
784                         
785                                 // Setup the values for later processing.
786                         
787                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
788                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
789                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));
790                         
791                                 // Add the data to the vendor variables.
792                         
793                                 wxListItem coldata;
794                 
795                                 coldata.SetId(intValueSeek);
796                                 coldata.SetData(intValueSeek);
797                                 coldata.SetText(wxSVNDID + wxT("-") + wxSVNDPropName);
799                                 ListCtrlIndex = lboVendorNamespace->InsertItem(coldata);
800                                 
801                                 VendorList.erase(intValueSeek);
802                                 VendorListPEN.erase(intValueSeek);
803                                 VendorListElement.erase(intValueSeek);
804                         
805                                 VendorList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
806                                 VendorListPEN.insert(std::make_pair(intValueSeek, wxSVNDID));
807                                 VendorListElement.insert(std::make_pair(intValueSeek, wxSVNDPropName));                         
808                         
809                                 VendorCount++;
810                                 intValueSeek++;
811                         
812                         }       
813                 
814                 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
815                 
816                         long ListCtrlIndex;
817                         
818                         XTokenList.insert(std::make_pair(intValueSeek, wxSPropertySeg2));
819                         XTokenListTokens.insert(std::make_pair(intValueSeek, wxSPropertySeg1.Mid(2)));
820                         
821                         // Add to the form.
822                         
823                         wxListItem coldata;
824                 
825                         coldata.SetId(intValueSeek);
826                         coldata.SetData(intValueSeek);
827                         coldata.SetText(wxSPropertySeg1.Mid(2));
829                         ListCtrlIndex = lboXToken->InsertItem(coldata);
830                         
831                         XTokenCount++;
832                         intValueSeek++;
833                         
834                 
835                 }
836                 
837                 // Reset the variables.
838                 
839                 QuoteMode = FALSE;
840                 PropertyFind = TRUE;
841                 ExtraLineSeek = TRUE;
842                 ContactLineLen = 0;
843                 QuoteBreakPoint = 0;
844                 ContactLine.Clear();
845                 wxSProperty.Clear();    
846         
847         }*/
848         
849         FMTimer.SetFilename(Filename);
850         FMTimer.Start(10000, FALSE);
851         
852         EditMode = TRUE;
853         
854         return TRUE;
857 void frmContactEditor::SplitValues(wxString *PropertyLine, 
858         std::map<int,int> *SplitPoints, 
859         std::map<int,int> *SplitLength, 
860         int intSize){
861         
862         // Split the values.
863                 
864         size_t intPropertyLen = PropertyLine->Len();
865         int intSplitsFound = 0;
866         int intSplitSize = 0;
867         int intSplitSeek = 0;
868         
869         for (int i = intSize; i <= intPropertyLen; i++){
871                 intSplitSize++;
872         
873                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
874                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
875            
876                     if (intSplitsFound == 0){
877             
878                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
879           
880                     } else {
881            
882                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
883             
884                     }
885             
886                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
887             
888                     intSplitsFound++;
889                     intSplitSeek = i;
890                     intSplitSize = 0;
891             
892                 }
894         }
896         if (intSplitsFound == 0){
898                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
899                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
901         } else {
903                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
904                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
906         }
910 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
911                 std::map<int, int> *GeneralListPref,
912                 wxListCtrl *GeneralListCtrl,
913                 std::map<int, wxString> *HomeList,
914                 std::map<int, int> *HomeListPref,
915                 wxListCtrl *HomeListCtrl,
916                 std::map<int, wxString> *BusinessList,
917                 std::map<int, int> *BusinessListPref,
918                 wxListCtrl *BusinessListCtrl,
919                 int *DataCount){
921         // Load data into the controls (first section of data and preference
922         // only).
923                         
924         long ListCtrlIndex = -1;
926         // Deal with the general items.
927         
928         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
929                 Iter != GeneralList->end();
930                 Iter++){
931         
932                 wxListItem coldata;
934                 coldata.SetId(*DataCount);
935                 coldata.SetData(*DataCount);
936                 coldata.SetText(Iter->second);
937                 
938                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
940                 if (MapDataExists(DataCount, GeneralListPref)){
941                 
942                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
943                 
944                 }
945         
946                 (*DataCount)++;
947         
948         }
949         
950         // Deal with the home items.
951         
952         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
953                 Iter != HomeList->end();
954                 Iter++){
955         
956                 wxListItem coldata;
958                 coldata.SetId(*DataCount);
959                 coldata.SetData(*DataCount);
960                 coldata.SetText(Iter->second);
961                 
962                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
964                 if (MapDataExists(DataCount, HomeListPref)){
965                 
966                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
967                 
968                 }
969         
970                 (*DataCount)++;
971         
972         }
973         
974         // Deal with the work items.
975         
976         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
977                 Iter != BusinessList->end();
978                 Iter++){
979         
980                 wxListItem coldata;
982                 coldata.SetId(*DataCount);
983                 coldata.SetData(*DataCount);
984                 coldata.SetText(Iter->second);
985                 
986                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
987                                 
988                 if (MapDataExists(DataCount, BusinessListPref)){
989                 
990                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
991                 
992                 }
993         
994                 (*DataCount)++;
995         
996         }
1000 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
1001                 std::map<int, int> *GeneralListPref,
1002                 std::map<int, wxString> *GeneralListType,
1003                 wxListCtrl *GeneralListCtrl,
1004                 std::map<int, wxString> *HomeList,
1005                 std::map<int, int> *HomeListPref,
1006                 std::map<int, wxString> *HomeListType,
1007                 wxListCtrl *HomeListCtrl,
1008                 std::map<int, wxString> *BusinessList,
1009                 std::map<int, int> *BusinessListPref,
1010                 std::map<int, wxString> *BusinessListType,
1011                 wxListCtrl *BusinessListCtrl,
1012                 int *DataCount){
1014         // Load data into the controls (first section of data, 
1015         // type and preference).
1016                         
1017         long ListCtrlIndex = -1;
1019         // Deal with the general items.
1020         
1021         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
1022                 Iter != GeneralList->end();
1023                 Iter++){
1024         
1025                 wxListItem coldata;
1027                 coldata.SetId(*DataCount);
1028                 coldata.SetData(*DataCount);
1029                 coldata.SetText(Iter->second);
1030                 
1031                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
1033                 if (MapDataExists(DataCount, GeneralListPref)){
1034                 
1035                         GeneralListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
1036                 
1037                 }
1038         
1039                 if (MapDataExists(DataCount, GeneralListType)){
1040                 
1041                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, GeneralListType->find(*DataCount)->second);
1042                 
1043                 }
1044         
1045                 (*DataCount)++;
1046         
1047         }
1048         
1049         // Deal with the home items.
1050         
1051         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
1052                 Iter != HomeList->end();
1053                 Iter++){
1054         
1055                 wxListItem coldata;
1057                 coldata.SetId(*DataCount);
1058                 coldata.SetData(*DataCount);
1059                 coldata.SetText(Iter->second);
1060                 
1061                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
1063                 if (MapDataExists(DataCount, HomeListPref)){
1064                 
1065                         HomeListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
1066                 
1067                 }
1068                 
1069                 if (MapDataExists(DataCount, HomeListType)){
1070                 
1071                         HomeListCtrl->SetItem(ListCtrlIndex, 1, HomeListType->find(*DataCount)->second);
1072                 
1073                 }
1074         
1075                 (*DataCount)++;
1076         
1077         }
1078         
1079         // Deal with the work items.
1080         
1081         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
1082                 Iter != BusinessList->end();
1083                 Iter++){
1084         
1085                 wxListItem coldata;
1087                 coldata.SetId(*DataCount);
1088                 coldata.SetData(*DataCount);
1089                 coldata.SetText(Iter->second);
1090                 
1091                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
1092                                 
1093                 if (MapDataExists(DataCount, BusinessListPref)){
1094                 
1095                         BusinessListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
1096                 
1097                 }
1098                 
1099                 if (MapDataExists(DataCount, BusinessListType)){
1100                 
1101                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, BusinessListType->find(*DataCount)->second);
1102                 
1103                 }
1104         
1105                 (*DataCount)++;
1106         
1107         }
1112 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1113                 std::map<int,int> *ItemListPref,
1114                 wxListCtrl *ItemCtrl,
1115                 int *DataCount){
1117         // Load the data (name and preference only).
1118                         
1119         long ListCtrlIndex = -1;
1121         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1122                 Iter != ItemList->end();
1123                 Iter++){
1124         
1125                 wxListItem coldata;
1127                 coldata.SetId(*DataCount);
1128                 coldata.SetData(*DataCount);
1129                 coldata.SetText(Iter->second);
1130                 
1131                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1132                                 
1133                 if (MapDataExists(DataCount, ItemListPref)){
1134                 
1135                         ItemCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1136                 
1137                 }
1138         
1139                 (*DataCount)++;
1140         
1141         }
1145 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1146                 std::map<int,int> *ItemListPref,
1147                 std::map<int,wxString> *ItemListType,
1148                 wxListCtrl *ItemCtrl,
1149                 int *DataCount){
1151         // Load the data (name, preference and type).
1152                         
1153         long ListCtrlIndex = -1;
1155         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1156                 Iter != ItemList->end();
1157                 Iter++){
1158         
1159                 wxListItem coldata;
1161                 coldata.SetId(*DataCount);
1162                 coldata.SetData(*DataCount);
1163                 coldata.SetText(Iter->second);
1164                 
1165                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1166                                 
1167                 if (MapDataExists(DataCount, ItemListType)){
1168                 
1169                         ItemCtrl->SetItem(ListCtrlIndex, 1, ItemListType->find(*DataCount)->second);
1170                 
1171                 }
1172                                 
1173                 if (MapDataExists(DataCount, ItemListPref)){
1174                 
1175                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1176                 
1177                 }
1178         
1179                 (*DataCount)++;
1180         
1181         }
1185 void frmContactEditor::LoadData(wxString ItemName,
1186                 std::map<int,wxString> *ItemList,
1187                 std::map<int,int> *ItemListPref,
1188                 std::map<int,wxString> *ItemListType,
1189                 std::map<int,wxString> *ItemListDataType,
1190                 wxListCtrl *ItemCtrl,
1191                 int *DataCount){
1193         // Load data (name, preference, type and data type).
1194                         
1195         long ListCtrlIndex = -1;
1197         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1198                 Iter != ItemList->end();
1199                 Iter++){
1200         
1201                 wxListItem coldata;
1203                 coldata.SetId(*DataCount);
1204                 coldata.SetData(*DataCount);
1205                 coldata.SetText(Iter->second);
1207                 if (ItemName == "KEY"){
1209                         // Get the key type, if any.
1211                         if (MapDataExists(DataCount, ItemListDataType)){
1212                 
1213                                 if (ItemListDataType->find(*DataCount)->second == "application/pgp-keys"){
1214                                 
1215                                         coldata.SetText(_("PGP Key"));
1216                                 
1217                                 }
1218                 
1219                         } else {
1220                         
1221                                 coldata.SetText(_("Key"));
1222                         
1223                         }
1224                 
1225                 
1226                 }
1227                 
1228                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1229                 
1230                 if (MapDataExists(DataCount, ItemListType)){
1231                 
1232                         if (ItemListType->find(*DataCount)->second == "home"){
1233                         
1234                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
1235                         
1236                         } else if (ItemListType->find(*DataCount)->second == "work"){
1237                         
1238                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
1239                         
1240                         }
1241                                 
1242                 }
1243                         
1244                 if (MapDataExists(DataCount, ItemListPref)){
1245                 
1246                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1247                 
1248                 }
1249         
1250                 (*DataCount)++;
1251         
1252         }
1256 void frmContactEditor::LoadPictureData(wxString ItemName, 
1257                 std::map<int,std::string> *ItemList,
1258                 std::map<int,int> *ItemListPref,
1259                 std::map<int,wxString> *ItemListType,
1260                 wxListCtrl *ItemCtrl,
1261                 int *DataCount){
1263         // Load the picture data.
1264                         
1265         long ListCtrlIndex = -1;
1267         for (std::map<int,std::string>::iterator Iter = ItemList->begin();
1268                 Iter != ItemList->end();
1269                 Iter++){
1270         
1271                 wxListItem coldata;
1273                 coldata.SetId(*DataCount);
1274                 coldata.SetData(*DataCount);
1275                 
1276                 if (ItemName == "PHOTO"){
1277                 
1278                         coldata.SetText("Picture");
1279                 
1280                 } else if (ItemName == "LOGO"){
1282                         coldata.SetText("Logo");
1283                 
1284                 } else if (ItemName == "SOUND"){
1285                 
1286                         coldata.SetText("Sound");               
1287                 
1288                 } else {
1289                 
1290                         coldata.SetText("Object");
1291                 
1292                 }
1293                                 
1294                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1295                                                                 
1296                 if (MapDataExists(DataCount, ItemListType)){
1297                 
1298                         if (ItemListType->find(*DataCount)->second == "home"){
1299                         
1300                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
1301                         
1302                         } else if (ItemListType->find(*DataCount)->second == "work"){
1303                         
1304                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
1305                         
1306                         }
1307                                 
1308                 }
1309                                 
1310                 if (MapDataExists(DataCount, ItemListPref)){
1311                 
1312                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1313                 
1314                 }
1315         
1316                 (*DataCount)++;
1317         
1318         }
1322 void frmContactEditor::LoadVendorData(std::map<int,wxString> *ItemListPEN,
1323                 std::map<int,wxString> *ItemListElement,
1324                 wxListCtrl *ItemCtrl,
1325                 int *DataCount){
1326         
1327         // Load the vendor data.
1328                         
1329         long ListCtrlIndex = -1;
1330         wxString ItemValue;
1332         for (std::map<int,wxString>::iterator Iter = ItemListPEN->begin();
1333                 Iter != ItemListPEN->end();
1334                 Iter++){
1335                         
1336                 ItemValue.clear();
1337                         
1338                 wxListItem coldata;
1340                 coldata.SetId(*DataCount);
1341                 coldata.SetData(*DataCount);
1342                                                         
1343                 ItemValue.Append(ItemListPEN->find(*DataCount)->second);
1344                 ItemValue.Append("-");
1345                 ItemValue.Append(ItemListElement->find(*DataCount)->second);
1346                                 
1347                 coldata.SetText(ItemValue);
1348                                 
1349                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1350                 
1351                 (*DataCount)++;
1352                 
1353         }
1354                 
1357 void frmContactEditor::LoadXTokenData(std::map<int,wxString> *ItemListTokens,
1358                 wxListCtrl *ItemCtrl,
1359                 int *DataCount){
1360         
1361         // Load the X-Token data.
1362                         
1363         long ListCtrlIndex = -1;
1364         wxString ItemValue;
1366         for (std::map<int,wxString>::iterator Iter = ItemListTokens->begin();
1367                 Iter != ItemListTokens->end();
1368                 Iter++){
1369                         
1370                 ItemValue.clear();
1371                         
1372                 wxListItem coldata;
1374                 coldata.SetId(*DataCount);
1375                 coldata.SetData(*DataCount);
1376                                                         
1377                 ItemValue.Append(ItemListTokens->find(*DataCount)->second);
1378                 
1379                 coldata.SetText(ItemValue);
1380                                 
1381                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1382                 
1383                 (*DataCount)++;
1384                 
1385         }
1386                 
1389 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1390                 wxComboBox *ItemCtrl){
1392         // Load data into a wxComboBox.
1393                         
1394         int ItemIndex = 0;
1396         if (MapDataExists(&ItemIndex, ItemList)){
1397         
1398                 cmbDisplayAs->SetValue(ItemList->find(0)->second);
1399         
1400         }
1401                 
1404 void frmContactEditor::LoadRelatedData(std::map<int,wxString> *ItemList,
1405                 std::map<int,int> *ItemListPref,
1406                 std::map<int,wxString> *ItemListType,
1407                 wxListCtrl *ItemCtrl,
1408                 int *DataCount){
1410         // Load related data (name, preference and type).
1411                         
1412         long ListCtrlIndex = -1;
1413         wxString RelatedType;
1415         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1416                 Iter != ItemList->end();
1417                 Iter++){
1418         
1419                 RelatedType.clear();
1420         
1421                 wxListItem coldata;
1423                 coldata.SetId(*DataCount);
1424                 coldata.SetData(*DataCount);
1425         
1426                 if (MapDataExists(DataCount, ItemListType)){
1427                 
1428                         std::map<int,wxString>::iterator TypeIter = ItemListType->find(*DataCount);
1429                 
1430                         if (TypeIter->second == wxT("contact")){
1432                                 RelatedType = _("Contact");
1434                         } else if (TypeIter->second == wxT("acquaintance")){
1436                                 RelatedType = _("Acquaintance");
1438                         } else if (TypeIter->second == wxT("friend")){
1440                                 RelatedType = _("Friend");
1442                         } else if (TypeIter->second == wxT("met")){
1444                                 RelatedType = _("Met");
1446                         } else if (TypeIter->second == wxT("co-worker")){
1448                                 RelatedType = _("Co-worker");
1450                         } else if (TypeIter->second == wxT("colleague")){
1452                                 RelatedType = _("Colleague");
1454                         } else if (TypeIter->second == wxT("co-resident")){
1456                                 RelatedType = _("Co-resident");
1458                         } else if (TypeIter->second == wxT("neighbor")){
1460                                 RelatedType = _("Neighbour");
1462                         } else if (TypeIter->second == wxT("child")){
1464                                 RelatedType = _("Child");
1466                         } else if (TypeIter->second == wxT("parent")){
1468                                 RelatedType = _("Parent");
1470                         } else if (TypeIter->second == wxT("sibling")){
1472                                 RelatedType = _("Sibling");
1474                         } else if (TypeIter->second == wxT("spouse")){
1476                                 RelatedType = _("Spouse");
1478                         } else if (TypeIter->second == wxT("kin")){
1480                                 RelatedType = _("Kin");
1482                         } else if (TypeIter->second == wxT("muse")){
1484                                 RelatedType = _("Muse");
1486                         } else if (TypeIter->second == wxT("crush")){
1488                                 RelatedType = _("Crush");
1490                         } else if (TypeIter->second == wxT("date")){
1492                                 RelatedType = _("Date");
1494                         } else if (TypeIter->second == wxT("sweetheart")){
1496                                 RelatedType = _("Sweetheart");
1498                         } else if (TypeIter->second == wxT("me")){
1500                                 RelatedType = _("Me");
1502                         } else if (TypeIter->second == wxT("agent")){
1504                                 RelatedType = _("Agent");
1506                         } else if (TypeIter->second == wxT("emergency")){
1508                                 RelatedType = _("Emergency");
1510                         } else {
1512                                 RelatedType = TypeIter->second;
1514                         }
1515                 
1516                 }
1517                 
1518                 coldata.SetText(RelatedType);
1519                                 
1520                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1522                 if (MapDataExists(DataCount, ItemList)){
1523                 
1524                         ItemCtrl->SetItem(ListCtrlIndex, 1, ItemList->find(*DataCount)->second);
1525                 
1526                 }
1528                 if (MapDataExists(DataCount, ItemListPref)){
1529                 
1530                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1531                 
1532                 }
1533         
1534                 (*DataCount)++;
1535                 
1536         }
1537                 
1540 void frmContactEditor::LoadKind(ContactKindType *KindType){
1542         // Load contact kind.
1543         
1544         switch (*KindType){
1545                 case CONTACTKIND_INDIVIDUAL:
1546                         cmbType->SetSelection(1);
1547                         break;
1548                 case CONTACTKIND_GROUP:
1549                         cmbType->SetSelection(2);
1550                         break;
1551                 case CONTACTKIND_ORGANISATION:
1552                         cmbType->SetSelection(3);
1553                         break;
1554                 case CONTACTKIND_LOCATION:
1555                         cmbType->SetSelection(4);
1556                         break;
1557                 case CONTACTKIND_NONE:
1558                         cmbType->SetSelection(0);
1559                         break;
1560         }
1561                         
1562         wxCommandEvent nullevent;
1563                         
1564         UpdateMembersTab(nullevent);
1568 void frmContactEditor::LoadBirthday(wxString *BirthdayData, bool *BirthdayText){
1570         // Load Birthday.
1571         
1572         if (BirthdayData->IsEmpty()){
1573             return;
1574         }
1575   
1576         if (*BirthdayText == FALSE){
1577         
1578                 int DateYear = 0;
1579                 wxDateTime::Month DateMonth;
1580                 unsigned int DateDay;
1581                 
1582                 wxString wxSData;
1583                 
1584                 if (BirthdayData->Mid(0, 2) == wxT("--")){
1585                 
1586                         // Skip year.
1587                 
1588                 } else {
1589                 
1590                         DateYear = wxAtoi(BirthdayData->Mid(0,4));
1591                 
1592                 }
1593                 
1594                 DateMonth = (wxDateTime::Month)(wxAtoi(BirthdayData->Mid(4,2)) - 1);
1595                 DateDay = wxAtoi(BirthdayData->Mid(6,2));
1596         
1597                 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
1598         
1599                 dapBirthday->SetValue(BDayDate);                                
1600         
1601         } else {
1602         
1603                 txtBirthday->SetValue(*BirthdayData);
1604         
1605         }
1609 void frmContactEditor::LoadAnniversary(wxString *AnniversaryData, bool *AnniversaryText){
1611         // Load Anniversary.
1612         
1613         if (AnniversaryData->IsEmpty()){
1614             return;
1615         }
1616   
1617         if (*AnniversaryText == FALSE){
1618         
1619                 int DateYear = 0;
1620                 wxDateTime::Month DateMonth;
1621                 int DateDay;
1622                 
1623                 wxString wxSData;
1624                 
1625                 if (AnniversaryData->Mid(0, 2) == wxT("--")){
1626                 
1627                         // Skip year.
1628                 
1629                 } else {
1630                 
1631                         DateYear = wxAtoi(AnniversaryData->Mid(0,4));
1632                 
1633                 }
1634                 
1635                 DateMonth = (wxDateTime::Month)(wxAtoi(AnniversaryData->Mid(4,2)) - 1);
1636                 DateDay = wxAtoi(AnniversaryData->Mid(6,2));                                    
1637         
1638                 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
1639         
1640                 dapAnniversary->SetValue(ADayDate);
1641         
1642         } else {
1643         
1644                 txtAnniversary->SetValue(*AnniversaryData);
1645         
1646         }
1650 void frmContactEditor::LoadGender(wxString *GenderComponent, wxString *GenderIdentity){
1652         // Load Gender.
1653         
1654         // Deal with the Gender Component.
1655         
1656         if (*GenderComponent == wxT("M")){
1657                 
1658                 // Gender is Male.
1659                         
1660                 cmbGender->SetSelection(1);
1661                 
1662         } else if (*GenderComponent == wxT("F")){
1663                 
1664                 // Gender is Female.
1665                         
1666                 cmbGender->SetSelection(2);                                     
1667                 
1668         } else if (*GenderComponent == wxT("O")){
1669                 
1670                 // Gender is Other.
1671                         
1672                 cmbGender->SetSelection(3);
1673                 
1674         } else if (*GenderComponent == wxT("N")){
1675                 
1676                 // Gender is None/Not Applicable.
1677                 
1678                 cmbGender->SetSelection(4);                                     
1679                 
1680         } else if (*GenderComponent == wxT("U")){
1681                 
1682                 // Gender is Unknown.
1683                         
1684                 cmbGender->SetSelection(5);                                     
1685                 
1686         }
1687         
1688         // Deal with the Gender Identity.
1690         txtGenderDescription->SetValue(*GenderIdentity);
1694 void frmContactEditor::LoadName(wxString *NameTitle, wxString *NameForename,
1695         wxString *NameSurname, wxString *NameOtherNames, 
1696         wxString *NameSuffix){
1698         // Load Name.
1699                 
1700         txtTitle->SetValue(*NameTitle); 
1701         txtForename->SetValue(*NameForename);
1702         txtSurname->SetValue(*NameSurname);
1703         txtOtherNames->SetValue(*NameOtherNames);
1704         txtSuffix->SetValue(*NameSuffix);
1705         
1708 void frmContactEditor::LoadMember(std::map<int,wxString> *GroupList){
1710         // Load group data.
1711         
1712         // Go through the list of contacts for the account and find the matching UID.
1713         // If contact with UID doesn't match then say (unknown contact).
1715         XABViewMode XVMData;
1716         if (StartupEditMode == FALSE){
1717                 XVMData = MainPtr->GetViewMode();
1718         }
1719         
1720         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
1722         //wxString vcardfilenamewxs;
1723         wxString vCardFilename;
1724         wxString vCardFilenameFull;
1725         wxString vCardDataString;
1726         //wxStringTokenizer vcardfileline;
1727         wxString lwxs;
1728         wxString setname, setvalue;
1729         wxString MemberData;
1730         bool FoundContact = FALSE;
1731         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
1732         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
1733         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
1735         wxDir vcardaccdir(AccountDirFinal);
1737         for (std::map<int,wxString>::iterator MemberIter = GroupList->begin();
1738                 MemberIter != GroupList->end();
1739                 MemberIter++){
1740                 
1741                 MemberData = MemberIter->second;
1742                 
1743                 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1744                 while(ProcFiles){
1746                         if (vCardFilename.Right(4) == wxT(".vcf") || 
1747                             vCardFilename.Right(4) == wxT(".VCF") || 
1748                             vCardFilename.Right(5) == wxT(".vcard") || 
1749                             vCardFilename.Right(5) == wxT(".VCARD")){
1751                                 vCard Person;
1753                                 vCardFilenameFull.Append(AccountDirFinal);
1754                                 vCardFilenameFull.Append(wxT("/"));
1755                                 vCardFilenameFull.Append(vCardFilename);
1757                                 Person.LoadFile(vCardFilenameFull);
1759                                 if (MemberData.Left(9) == wxT("urn:uuid:")){
1761                                         wxString NewPropValue;
1762                                         NewPropValue = MemberData.Mid(9, wxString::npos);
1763                                         MemberData = NewPropValue;
1765                                 }
1767                                 if (Person.MeetBaseSpecification()){
1769                                         wxString KindStatus = Person.Get(wxT("KIND"));
1771                                         if (KindStatus == wxT("group")){
1773                                                 vCardFilename.Clear();
1774                                                 vCardFilenameFull.Clear();
1775                                                 vCardDataString.Clear();
1776                                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1777                                                 continue;
1779                                         }
1781                                         wxString PersonName = Person.Get(wxT("N"));
1782                                         wxString PersonUID = Person.Get(wxT("UID"));
1783                                         wxString PersonFilename = vCardFilenameFull;
1784                                 
1785                                         if (PersonUID != MemberData){
1786                         
1787                                                 vCardFilename.Clear();
1788                                                 vCardFilenameFull.Clear();
1789                                                 vCardDataString.Clear();
1790                                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1791                                                 continue;
1792                         
1793                                         } else {
1794                                                 
1795                                                 FoundContact = TRUE;
1796                                                 
1797                                         }
1799                                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
1800                                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
1802                                         if (XVMData.SortMode == 1){
1804                                                 // Split the name into sections.
1805         
1806                                                 vCardDataString = Person.Get(wxT("N"));
1808                                                 vCardName NameData = Person.GetName();
1809     
1810                                                 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
1811     
1812                                         } else if (XVMData.SortMode == 2){
1813     
1814                                                 // Split the name into sections.
1815     
1816                                                 vCardName NameData = Person.GetName();    
1817     
1818                                                 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
1819     
1820                                         } else if (XVMData.SortMode == 3){
1821     
1822                                                 // Check and make sure that the top most nickname is used.
1823     
1824                                                 vCardDataString = Person.Get(wxT("NICKNAME"));
1825     
1826                                                 if (vCardDataString.IsEmpty()){
1827         
1828                                                         vCardDataString = wxT("(no nickname)");
1829         
1830                                                 }
1831     
1832                                         } else if (XVMData.SortMode == 4){
1833     
1834                                                 vCardDataString = Person.Get(wxT("FN"));
1835     
1836                                         }
1838                                         if (XVMData.AscendingMode == TRUE){
1839                                                 
1840                                                 vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
1841                                                 
1842                                         } else {
1843                                                 
1844                                                 vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
1845                                                 
1846                                         }
1848                                 } else {
1850                                 }
1852                         }
1854                         vCardFilename.Clear();
1855                         vCardFilenameFull.Clear();
1856                         vCardDataString.Clear();
1857                         ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1859                 }
1860                     
1861                 if (FoundContact == FALSE){
1862                                 
1863                         if (XVMData.AscendingMode == TRUE){
1864                                         
1865                                 vCardNamesAsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1866                                         
1867                         } else {
1868                                 
1869                         vCardNamesDsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1870                                 
1871                         }
1873                 }
1875                 if (XVMData.AscendingMode == TRUE){
1877                         for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
1878                                 iter != vCardNamesAsc.end(); ++iter){
1880                                 wxListItem ItemData;
1881                         
1882                                 ItemData.SetId(0);
1883                                 ItemData.SetText(iter->first);
1884                                 lboGroups->InsertItem(ItemData);
1886                         }
1888                 } else {
1890                         for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
1891                                 iter != vCardNamesDsc.end(); ++iter){
1893                                 wxListItem ItemData;
1894                         
1895                                 ItemData.SetId(0);
1896                                 ItemData.SetText(iter->first);
1898                                 lboGroups->InsertItem(ItemData);
1900                         }
1902                 }
1903         
1904         }
1905         
1908 void frmContactEditor::LoadAddress(std::map<int, wxString> *GeneralAddressList,
1909         std::map<int, wxString> *GeneralAddressListTown,
1910         std::map<int, wxString> *GeneralAddressListCounty,
1911         std::map<int, wxString> *GeneralAddressListPostCode,
1912         std::map<int, int> *GeneralAddressListPref,
1913         std::map<int, wxString> *HomeAddressList,
1914         std::map<int, wxString> *HomeAddressListTown,
1915         std::map<int, wxString> *HomeAddressListCounty,
1916         std::map<int, wxString> *HomeAddressListPostCode,
1917         std::map<int, int> *HomeAddressListPref,
1918         std::map<int, wxString> *BusinessAddressList,
1919         std::map<int, wxString> *BusinessAddressListTown,
1920         std::map<int, wxString> *BusinessAddressListCounty,
1921         std::map<int, wxString> *BusinessAddressListPostCode,
1922         std::map<int, int> *BusinessAddressListPref, 
1923         int *AddressCount){
1925         // Load address.
1926                 
1927         long ListCtrlIndex = -1;
1929         // Deal with the general addresses.
1930         
1931         for (std::map<int,wxString>::iterator Iter = GeneralAddressList->begin();
1932                 Iter != GeneralAddressList->end();
1933                 Iter++){
1934         
1935                 wxListItem coldata;
1937                 coldata.SetId(*AddressCount);
1938                 coldata.SetData(*AddressCount);
1939                 coldata.SetText(Iter->second);
1940                 
1941                 ListCtrlIndex = lboAddresses->InsertItem(coldata);
1942                 
1943                 if (MapDataExists(AddressCount, GeneralAddressListTown)){
1944                 
1945                         lboAddresses->SetItem(ListCtrlIndex, 1, GeneralAddressListTown->find(*AddressCount)->second);
1946                 
1947                 }
1949                 if (MapDataExists(AddressCount, GeneralAddressListCounty)){
1950                 
1951                         lboAddresses->SetItem(ListCtrlIndex, 2, GeneralAddressListCounty->find(*AddressCount)->second);
1952                 
1953                 }
1954                 
1955                 if (MapDataExists(AddressCount, GeneralAddressListPostCode)){
1956                 
1957                         lboAddresses->SetItem(ListCtrlIndex, 3, GeneralAddressListPostCode->find(*AddressCount)->second);
1958                 
1959                 }
1960                 
1961                 if (MapDataExists(AddressCount, GeneralAddressListPref)){
1962                 
1963                         lboAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", GeneralAddressListPref->find(*AddressCount)->second));
1964                 
1965                 }
1966         
1967                 (*AddressCount)++;
1968         
1969         }
1970         
1971         // Deal with the home addresses.
1972         
1973         for (std::map<int,wxString>::iterator Iter = HomeAddressList->begin();
1974                 Iter != HomeAddressList->end();
1975                 Iter++){
1976         
1977                 wxListItem coldata;
1979                 coldata.SetId(*AddressCount);
1980                 coldata.SetData(*AddressCount);
1981                 coldata.SetText(Iter->second);
1982                 
1983                 ListCtrlIndex = lboHomeAddresses->InsertItem(coldata);
1984                 
1985                 if (MapDataExists(AddressCount, HomeAddressListTown)){
1986                 
1987                         lboHomeAddresses->SetItem(ListCtrlIndex, 1, HomeAddressListTown->find(*AddressCount)->second);
1988                 
1989                 }
1991                 if (MapDataExists(AddressCount, HomeAddressListCounty)){
1992                 
1993                         lboHomeAddresses->SetItem(ListCtrlIndex, 2, HomeAddressListCounty->find(*AddressCount)->second);
1994                 
1995                 }
1996                 
1997                 if (MapDataExists(AddressCount, HomeAddressListPostCode)){
1998                 
1999                         lboHomeAddresses->SetItem(ListCtrlIndex, 3, HomeAddressListPostCode->find(*AddressCount)->second);
2000                 
2001                 }
2002                 
2003                 if (MapDataExists(AddressCount, HomeAddressListPref)){
2004                 
2005                         lboHomeAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", HomeAddressListPref->find(*AddressCount)->second));
2006                 
2007                 }
2008         
2009                 (*AddressCount)++;
2010         
2011         }
2012         
2013         // Deal with the work addresses.
2014         
2015         for (std::map<int,wxString>::iterator Iter = BusinessAddressList->begin();
2016                 Iter != BusinessAddressList->end();
2017                 Iter++){
2018         
2019                 wxListItem coldata;
2021                 coldata.SetId(*AddressCount);
2022                 coldata.SetData(*AddressCount);
2023                 coldata.SetText(Iter->second);
2024                 
2025                 ListCtrlIndex = lboBusinessAddresses->InsertItem(coldata);
2026                 
2027                 if (MapDataExists(AddressCount, BusinessAddressListTown)){
2028                 
2029                         lboBusinessAddresses->SetItem(ListCtrlIndex, 1, BusinessAddressListTown->find(*AddressCount)->second);
2030                 
2031                 }
2033                 if (MapDataExists(AddressCount, BusinessAddressListCounty)){
2034                 
2035                         lboBusinessAddresses->SetItem(ListCtrlIndex, 2, BusinessAddressListCounty->find(*AddressCount)->second);
2036                 
2037                 }
2038                 
2039                 if (MapDataExists(AddressCount, BusinessAddressListPostCode)){
2040                 
2041                         lboBusinessAddresses->SetItem(ListCtrlIndex, 3, BusinessAddressListPostCode->find(*AddressCount)->second);
2042                 
2043                 }
2044                 
2045                 if (MapDataExists(AddressCount, BusinessAddressListPref)){
2046                 
2047                         lboBusinessAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", BusinessAddressListPref->find(*AddressCount)->second));
2048                 
2049                 }
2050         
2051                 (*AddressCount)++;
2052         
2053         }
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