Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Skip processing BDAY and ANNIVERSARY if there is data for them.
[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.GeneralIMList,
378                 &ContactEditorData.GeneralIMListPref,
379                 &ContactEditorData.GeneralIMListTypeInfo,
380                 lboIM,
381                 &ContactEditorData.HomeIMList,
382                 &ContactEditorData.HomeIMListPref,
383                 &ContactEditorData.HomeIMListTypeInfo,
384                 lboHomeIM,
385                 &ContactEditorData.BusinessIMList,
386                 &ContactEditorData.BusinessIMListPref,
387                 &ContactEditorData.BusinessIMListTypeInfo,
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         size_t intPropertyLen = PropertyLine->Len();
863         int intSplitsFound = 0;
864         int intSplitSize = 0;
865         int intSplitSeek = 0;
866         
867         for (int i = intSize; i <= intPropertyLen; i++){
869                 intSplitSize++;
870         
871                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
872                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
873            
874                     if (intSplitsFound == 0){
875             
876                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
877           
878                     } else {
879            
880                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
881             
882                     }
883             
884                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
885             
886                     intSplitsFound++;
887                     intSplitSeek = i;
888                     intSplitSize = 0;
889             
890                 }
892         }
894         if (intSplitsFound == 0){
896                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
897                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
899         } else {
901                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
902                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
904         }
908 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
909                 std::map<int, int> *GeneralListPref,
910                 wxListCtrl *GeneralListCtrl,
911                 std::map<int, wxString> *HomeList,
912                 std::map<int, int> *HomeListPref,
913                 wxListCtrl *HomeListCtrl,
914                 std::map<int, wxString> *BusinessList,
915                 std::map<int, int> *BusinessListPref,
916                 wxListCtrl *BusinessListCtrl,
917                 int *DataCount){
919         long ListCtrlIndex = -1;
921         // Deal with the general items.
922         
923         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
924                 Iter != GeneralList->end();
925                 Iter++){
926         
927                 wxListItem coldata;
929                 coldata.SetId(*DataCount);
930                 coldata.SetData(*DataCount);
931                 coldata.SetText(Iter->second);
932                 
933                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
935                 if (MapDataExists(DataCount, GeneralListPref)){
936                 
937                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
938                 
939                 }
940         
941                 (*DataCount)++;
942         
943         }
944         
945         // Deal with the home items.
946         
947         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
948                 Iter != HomeList->end();
949                 Iter++){
950         
951                 wxListItem coldata;
953                 coldata.SetId(*DataCount);
954                 coldata.SetData(*DataCount);
955                 coldata.SetText(Iter->second);
956                 
957                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
959                 if (MapDataExists(DataCount, HomeListPref)){
960                 
961                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
962                 
963                 }
964         
965                 (*DataCount)++;
966         
967         }
968         
969         // Deal with the work items.
970         
971         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
972                 Iter != BusinessList->end();
973                 Iter++){
974         
975                 wxListItem coldata;
977                 coldata.SetId(*DataCount);
978                 coldata.SetData(*DataCount);
979                 coldata.SetText(Iter->second);
980                 
981                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
982                                 
983                 if (MapDataExists(DataCount, BusinessListPref)){
984                 
985                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
986                 
987                 }
988         
989                 (*DataCount)++;
990         
991         }
995 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
996                 std::map<int, int> *GeneralListPref,
997                 std::map<int, wxString> *GeneralListType,
998                 wxListCtrl *GeneralListCtrl,
999                 std::map<int, wxString> *HomeList,
1000                 std::map<int, int> *HomeListPref,
1001                 std::map<int, wxString> *HomeListType,
1002                 wxListCtrl *HomeListCtrl,
1003                 std::map<int, wxString> *BusinessList,
1004                 std::map<int, int> *BusinessListPref,
1005                 std::map<int, wxString> *BusinessListType,
1006                 wxListCtrl *BusinessListCtrl,
1007                 int *DataCount){
1009         long ListCtrlIndex = -1;
1011         // Deal with the general items.
1012         
1013         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
1014                 Iter != GeneralList->end();
1015                 Iter++){
1016         
1017                 wxListItem coldata;
1019                 coldata.SetId(*DataCount);
1020                 coldata.SetData(*DataCount);
1021                 coldata.SetText(Iter->second);
1022                 
1023                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
1025                 if (MapDataExists(DataCount, GeneralListPref)){
1026                 
1027                         GeneralListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
1028                 
1029                 }
1030         
1031                 if (MapDataExists(DataCount, GeneralListType)){
1032                 
1033                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, GeneralListType->find(*DataCount)->second);
1034                 
1035                 }
1036         
1037                 (*DataCount)++;
1038         
1039         }
1040         
1041         // Deal with the home items.
1042         
1043         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
1044                 Iter != HomeList->end();
1045                 Iter++){
1046         
1047                 wxListItem coldata;
1049                 coldata.SetId(*DataCount);
1050                 coldata.SetData(*DataCount);
1051                 coldata.SetText(Iter->second);
1052                 
1053                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
1055                 if (MapDataExists(DataCount, HomeListPref)){
1056                 
1057                         HomeListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
1058                 
1059                 }
1060                 
1061                 if (MapDataExists(DataCount, HomeListType)){
1062                 
1063                         HomeListCtrl->SetItem(ListCtrlIndex, 1, HomeListType->find(*DataCount)->second);
1064                 
1065                 }
1066         
1067                 (*DataCount)++;
1068         
1069         }
1070         
1071         // Deal with the work items.
1072         
1073         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
1074                 Iter != BusinessList->end();
1075                 Iter++){
1076         
1077                 wxListItem coldata;
1079                 coldata.SetId(*DataCount);
1080                 coldata.SetData(*DataCount);
1081                 coldata.SetText(Iter->second);
1082                 
1083                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
1084                                 
1085                 if (MapDataExists(DataCount, BusinessListPref)){
1086                 
1087                         BusinessListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
1088                 
1089                 }
1090                 
1091                 if (MapDataExists(DataCount, BusinessListType)){
1092                 
1093                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, BusinessListType->find(*DataCount)->second);
1094                 
1095                 }
1096         
1097                 (*DataCount)++;
1098         
1099         }
1104 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1105                 std::map<int,int> *ItemListPref,
1106                 wxListCtrl *ItemCtrl,
1107                 int *DataCount){
1109         long ListCtrlIndex = -1;
1111         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1112                 Iter != ItemList->end();
1113                 Iter++){
1114         
1115                 wxListItem coldata;
1117                 coldata.SetId(*DataCount);
1118                 coldata.SetData(*DataCount);
1119                 coldata.SetText(Iter->second);
1120                 
1121                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1122                                 
1123                 if (MapDataExists(DataCount, ItemListPref)){
1124                 
1125                         ItemCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1126                 
1127                 }
1128         
1129                 (*DataCount)++;
1130         
1131         }
1135 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1136                 std::map<int,int> *ItemListPref,
1137                 std::map<int,wxString> *ItemListType,
1138                 wxListCtrl *ItemCtrl,
1139                 int *DataCount){
1141         long ListCtrlIndex = -1;
1143         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1144                 Iter != ItemList->end();
1145                 Iter++){
1146         
1147                 wxListItem coldata;
1149                 coldata.SetId(*DataCount);
1150                 coldata.SetData(*DataCount);
1151                 coldata.SetText(Iter->second);
1152                 
1153                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1154                                 
1155                 if (MapDataExists(DataCount, ItemListType)){
1156                 
1157                         ItemCtrl->SetItem(ListCtrlIndex, 1, ItemListType->find(*DataCount)->second);
1158                 
1159                 }
1160                                 
1161                 if (MapDataExists(DataCount, ItemListPref)){
1162                 
1163                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1164                 
1165                 }
1166         
1167                 (*DataCount)++;
1168         
1169         }
1173 void frmContactEditor::LoadData(wxString ItemName,
1174                 std::map<int,wxString> *ItemList,
1175                 std::map<int,int> *ItemListPref,
1176                 std::map<int,wxString> *ItemListType,
1177                 std::map<int,wxString> *ItemListDataType,
1178                 wxListCtrl *ItemCtrl,
1179                 int *DataCount){
1181         long ListCtrlIndex = -1;
1183         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1184                 Iter != ItemList->end();
1185                 Iter++){
1186         
1187                 wxListItem coldata;
1189                 coldata.SetId(*DataCount);
1190                 coldata.SetData(*DataCount);
1191                 coldata.SetText(Iter->second);
1193                 if (ItemName == "KEY"){
1195                         // Get the key type, if any.
1197                         if (MapDataExists(DataCount, ItemListDataType)){
1198                 
1199                                 if (ItemListDataType->find(*DataCount)->second == "application/pgp-keys"){
1200                                 
1201                                         coldata.SetText(_("PGP Key"));
1202                                 
1203                                 }
1204                 
1205                         } else {
1206                         
1207                                 coldata.SetText(_("Key"));
1208                         
1209                         }
1210                 
1211                 
1212                 }
1213                 
1214                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1215                 
1216                 if (MapDataExists(DataCount, ItemListType)){
1217                 
1218                         if (ItemListType->find(*DataCount)->second == "home"){
1219                         
1220                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
1221                         
1222                         } else if (ItemListType->find(*DataCount)->second == "work"){
1223                         
1224                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
1225                         
1226                         }
1227                                 
1228                 }
1229                         
1230                 if (MapDataExists(DataCount, ItemListPref)){
1231                 
1232                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1233                 
1234                 }
1235         
1236                 (*DataCount)++;
1237         
1238         }
1242 void frmContactEditor::LoadPictureData(wxString ItemName, 
1243                 std::map<int,std::string> *ItemList,
1244                 std::map<int,int> *ItemListPref,
1245                 std::map<int,wxString> *ItemListType,
1246                 wxListCtrl *ItemCtrl,
1247                 int *DataCount){
1249         long ListCtrlIndex = -1;
1251         for (std::map<int,std::string>::iterator Iter = ItemList->begin();
1252                 Iter != ItemList->end();
1253                 Iter++){
1254         
1255                 wxListItem coldata;
1257                 coldata.SetId(*DataCount);
1258                 coldata.SetData(*DataCount);
1259                 
1260                 if (ItemName == "PHOTO"){
1261                 
1262                         coldata.SetText("Picture");
1263                 
1264                 } else if (ItemName == "LOGO"){
1266                         coldata.SetText("Logo");
1267                 
1268                 } else if (ItemName == "SOUND"){
1269                 
1270                         coldata.SetText("Sound");               
1271                 
1272                 } else {
1273                 
1274                         coldata.SetText("Object");
1275                 
1276                 }
1277                                 
1278                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1279                                                                 
1280                 if (MapDataExists(DataCount, ItemListType)){
1281                 
1282                         if (ItemListType->find(*DataCount)->second == "home"){
1283                         
1284                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
1285                         
1286                         } else if (ItemListType->find(*DataCount)->second == "work"){
1287                         
1288                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
1289                         
1290                         }
1291                                 
1292                 }
1293                                 
1294                 if (MapDataExists(DataCount, ItemListPref)){
1295                 
1296                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1297                 
1298                 }
1299         
1300                 (*DataCount)++;
1301         
1302         }
1306 void frmContactEditor::LoadVendorData(std::map<int,wxString> *ItemListPEN,
1307                 std::map<int,wxString> *ItemListElement,
1308                 wxListCtrl *ItemCtrl,
1309                 int *DataCount){
1310                 
1311         long ListCtrlIndex = -1;
1312         wxString ItemValue;
1314         for (std::map<int,wxString>::iterator Iter = ItemListPEN->begin();
1315                 Iter != ItemListPEN->end();
1316                 Iter++){
1317                         
1318                 ItemValue.clear();
1319                         
1320                 wxListItem coldata;
1322                 coldata.SetId(*DataCount);
1323                 coldata.SetData(*DataCount);
1324                                                         
1325                 ItemValue.Append(ItemListPEN->find(*DataCount)->second);
1326                 ItemValue.Append("-");
1327                 ItemValue.Append(ItemListElement->find(*DataCount)->second);
1328                                 
1329                 coldata.SetText(ItemValue);
1330                                 
1331                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1332                 
1333                 (*DataCount)++;
1334                 
1335         }
1336                 
1339 void frmContactEditor::LoadXTokenData(std::map<int,wxString> *ItemListTokens,
1340                 wxListCtrl *ItemCtrl,
1341                 int *DataCount){
1342         
1343         long ListCtrlIndex = -1;
1344         wxString ItemValue;
1346         for (std::map<int,wxString>::iterator Iter = ItemListTokens->begin();
1347                 Iter != ItemListTokens->end();
1348                 Iter++){
1349                         
1350                 ItemValue.clear();
1351                         
1352                 wxListItem coldata;
1354                 coldata.SetId(*DataCount);
1355                 coldata.SetData(*DataCount);
1356                                                         
1357                 ItemValue.Append(ItemListTokens->find(*DataCount)->second);
1358                 
1359                 coldata.SetText(ItemValue);
1360                                 
1361                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1362                 
1363                 (*DataCount)++;
1364                 
1365         }
1366                 
1369 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
1370                 wxComboBox *ItemCtrl){
1372         int ItemIndex = 0;
1374         if (MapDataExists(&ItemIndex, ItemList)){
1375         
1376                 cmbDisplayAs->SetValue(ItemList->find(0)->second);
1377         
1378         }
1379                 
1382 void frmContactEditor::LoadRelatedData(std::map<int,wxString> *ItemList,
1383                 std::map<int,int> *ItemListPref,
1384                 std::map<int,wxString> *ItemListType,
1385                 wxListCtrl *ItemCtrl,
1386                 int *DataCount){
1388         long ListCtrlIndex = -1;
1389         wxString RelatedType;
1391         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
1392                 Iter != ItemList->end();
1393                 Iter++){
1394         
1395                 RelatedType.clear();
1396         
1397                 wxListItem coldata;
1399                 coldata.SetId(*DataCount);
1400                 coldata.SetData(*DataCount);
1401         
1402                 if (MapDataExists(DataCount, ItemListType)){
1403                 
1404                         std::map<int,wxString>::iterator TypeIter = ItemListType->find(*DataCount);
1405                 
1406                         if (TypeIter->second == wxT("contact")){
1408                                 RelatedType = _("Contact");
1410                         } else if (TypeIter->second == wxT("acquaintance")){
1412                                 RelatedType = _("Acquaintance");
1414                         } else if (TypeIter->second == wxT("friend")){
1416                                 RelatedType = _("Friend");
1418                         } else if (TypeIter->second == wxT("met")){
1420                                 RelatedType = _("Met");
1422                         } else if (TypeIter->second == wxT("co-worker")){
1424                                 RelatedType = _("Co-worker");
1426                         } else if (TypeIter->second == wxT("colleague")){
1428                                 RelatedType = _("Colleague");
1430                         } else if (TypeIter->second == wxT("co-resident")){
1432                                 RelatedType = _("Co-resident");
1434                         } else if (TypeIter->second == wxT("neighbor")){
1436                                 RelatedType = _("Neighbour");
1438                         } else if (TypeIter->second == wxT("child")){
1440                                 RelatedType = _("Child");
1442                         } else if (TypeIter->second == wxT("parent")){
1444                                 RelatedType = _("Parent");
1446                         } else if (TypeIter->second == wxT("sibling")){
1448                                 RelatedType = _("Sibling");
1450                         } else if (TypeIter->second == wxT("spouse")){
1452                                 RelatedType = _("Spouse");
1454                         } else if (TypeIter->second == wxT("kin")){
1456                                 RelatedType = _("Kin");
1458                         } else if (TypeIter->second == wxT("muse")){
1460                                 RelatedType = _("Muse");
1462                         } else if (TypeIter->second == wxT("crush")){
1464                                 RelatedType = _("Crush");
1466                         } else if (TypeIter->second == wxT("date")){
1468                                 RelatedType = _("Date");
1470                         } else if (TypeIter->second == wxT("sweetheart")){
1472                                 RelatedType = _("Sweetheart");
1474                         } else if (TypeIter->second == wxT("me")){
1476                                 RelatedType = _("Me");
1478                         } else if (TypeIter->second == wxT("agent")){
1480                                 RelatedType = _("Agent");
1482                         } else if (TypeIter->second == wxT("emergency")){
1484                                 RelatedType = _("Emergency");
1486                         } else {
1488                                 RelatedType = TypeIter->second;
1490                         }
1491                 
1492                 }
1493                 
1494                 coldata.SetText(RelatedType);
1495                                 
1496                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1498                 if (MapDataExists(DataCount, ItemList)){
1499                 
1500                         ItemCtrl->SetItem(ListCtrlIndex, 1, ItemList->find(*DataCount)->second);
1501                 
1502                 }
1504                 if (MapDataExists(DataCount, ItemListPref)){
1505                 
1506                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1507                 
1508                 }
1509         
1510                 (*DataCount)++;
1511                 
1512         }
1513                 
1516 void frmContactEditor::LoadKind(ContactKindType *KindType){
1518         switch (*KindType){
1519                 case CONTACTKIND_INDIVIDUAL:
1520                         cmbType->SetSelection(1);
1521                         break;
1522                 case CONTACTKIND_GROUP:
1523                         cmbType->SetSelection(2);
1524                         break;
1525                 case CONTACTKIND_ORGANISATION:
1526                         cmbType->SetSelection(3);
1527                         break;
1528                 case CONTACTKIND_LOCATION:
1529                         cmbType->SetSelection(4);
1530                         break;
1531                 case CONTACTKIND_NONE:
1532                         cmbType->SetSelection(0);
1533                         break;
1534         }
1535                         
1536         wxCommandEvent nullevent;
1537                         
1538         UpdateMembersTab(nullevent);
1542 void frmContactEditor::LoadBirthday(wxString *BirthdayData, bool *BirthdayText){
1544         if (BirthdayData->IsEmpty()){
1545             return;
1546         }
1547   
1548         if (*BirthdayText == FALSE){
1549         
1550                 int DateYear = 0;
1551                 wxDateTime::Month DateMonth;
1552                 unsigned int DateDay;
1553                 
1554                 wxString wxSData;
1555                 
1556                 if (BirthdayData->Mid(0, 2) == wxT("--")){
1557                 
1558                         // Skip year.
1559                 
1560                 } else {
1561                 
1562                         DateYear = wxAtoi(BirthdayData->Mid(0,4));
1563                 
1564                 }
1565                 
1566                 DateMonth = (wxDateTime::Month)(wxAtoi(BirthdayData->Mid(4,2)) - 1);
1567                 DateDay = wxAtoi(BirthdayData->Mid(6,2));
1568         
1569                 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
1570         
1571                 dapBirthday->SetValue(BDayDate);                                
1572         
1573         } else {
1574         
1575                 txtBirthday->SetValue(*BirthdayData);
1576         
1577         }
1581 void frmContactEditor::LoadAnniversary(wxString *AnniversaryData, bool *AnniversaryText){
1583         if (AnniversaryData->IsEmpty()){
1584             return;
1585         }
1586   
1587         if (*AnniversaryText == FALSE){
1588         
1589                 int DateYear = 0;
1590                 wxDateTime::Month DateMonth;
1591                 int DateDay;
1592                 
1593                 wxString wxSData;
1594                 
1595                 if (AnniversaryData->Mid(0, 2) == wxT("--")){
1596                 
1597                         // Skip year.
1598                 
1599                 } else {
1600                 
1601                         DateYear = wxAtoi(AnniversaryData->Mid(0,4));
1602                 
1603                 }
1604                 
1605                 DateMonth = (wxDateTime::Month)(wxAtoi(AnniversaryData->Mid(4,2)) - 1);
1606                 DateDay = wxAtoi(AnniversaryData->Mid(6,2));                                    
1607         
1608                 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
1609         
1610                 dapAnniversary->SetValue(ADayDate);
1611         
1612         } else {
1613         
1614                 txtAnniversary->SetValue(*AnniversaryData);
1615         
1616         }
1620 void frmContactEditor::LoadGender(wxString *GenderComponent, wxString *GenderIdentity){
1622         // Deal with the Gender Component.
1623         
1624         if (*GenderComponent == wxT("M")){
1625                 
1626                 // Gender is Male.
1627                         
1628                 cmbGender->SetSelection(1);
1629                 
1630         } else if (*GenderComponent == wxT("F")){
1631                 
1632                 // Gender is Female.
1633                         
1634                 cmbGender->SetSelection(2);                                     
1635                 
1636         } else if (*GenderComponent == wxT("O")){
1637                 
1638                 // Gender is Other.
1639                         
1640                 cmbGender->SetSelection(3);
1641                 
1642         } else if (*GenderComponent == wxT("N")){
1643                 
1644                 // Gender is None/Not Applicable.
1645                 
1646                 cmbGender->SetSelection(4);                                     
1647                 
1648         } else if (*GenderComponent == wxT("U")){
1649                 
1650                 // Gender is Unknown.
1651                         
1652                 cmbGender->SetSelection(5);                                     
1653                 
1654         }
1655         
1656         // Deal with the Gender Identity.
1658         txtGenderDescription->SetValue(*GenderIdentity);
1662 void frmContactEditor::LoadName(wxString *NameTitle, wxString *NameForename,
1663         wxString *NameSurname, wxString *NameOtherNames, 
1664         wxString *NameSuffix){
1666         txtTitle->SetValue(*NameTitle); 
1667         txtForename->SetValue(*NameForename);
1668         txtSurname->SetValue(*NameSurname);
1669         txtOtherNames->SetValue(*NameOtherNames);
1670         txtSuffix->SetValue(*NameSuffix);
1671         
1674 void frmContactEditor::LoadMember(std::map<int,wxString> *GroupList){
1676         // Go through the list of contacts for the account and find the matching UID.
1677         // If contact with UID doesn't match then say (unknown contact).
1679         XABViewMode XVMData;
1680         if (StartupEditMode == FALSE){
1681                 XVMData = MainPtr->GetViewMode();
1682         }
1683         
1684         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
1686         //wxString vcardfilenamewxs;
1687         wxString vCardFilename;
1688         wxString vCardFilenameFull;
1689         wxString vCardDataString;
1690         //wxStringTokenizer vcardfileline;
1691         wxString lwxs;
1692         wxString setname, setvalue;
1693         wxString MemberData;
1694         bool FoundContact = FALSE;
1695         //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
1696         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
1697         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
1699         wxDir vcardaccdir(AccountDirFinal);
1701         for (std::map<int,wxString>::iterator MemberIter = GroupList->begin();
1702                 MemberIter != GroupList->end();
1703                 MemberIter++){
1704                 
1705                 MemberData = MemberIter->second;
1706                 
1707                 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1708                 while(ProcFiles){
1710                         if (vCardFilename.Right(4) == wxT(".vcf") || 
1711                             vCardFilename.Right(4) == wxT(".VCF") || 
1712                             vCardFilename.Right(5) == wxT(".vcard") || 
1713                             vCardFilename.Right(5) == wxT(".VCARD")){
1715                             vCard Person;
1717                             vCardFilenameFull.Append(AccountDirFinal);
1718                             vCardFilenameFull.Append(wxT("/"));
1719                             vCardFilenameFull.Append(vCardFilename);
1721                             Person.LoadFile(vCardFilenameFull);
1723                             if (MemberData.Left(9) == wxT("urn:uuid:")){
1725                                 wxString NewPropValue;
1726                                 NewPropValue = MemberData.Mid(9, wxString::npos);
1727                                 MemberData = NewPropValue;
1729                             }
1731                             if (Person.MeetBaseSpecification()){
1733                                 wxString KindStatus = Person.Get(wxT("KIND"));
1735                                 if (KindStatus == wxT("group")){
1737                                         vCardFilename.Clear();
1738                                         vCardFilenameFull.Clear();
1739                                         vCardDataString.Clear();
1740                                         ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1741                                         continue;
1743                                 }
1745                                 wxString PersonName = Person.Get(wxT("N"));
1746                                 wxString PersonUID = Person.Get(wxT("UID"));
1747                                 wxString PersonFilename = vCardFilenameFull;
1748                         
1749                                 if (PersonUID != MemberData){
1750                         
1751                                         vCardFilename.Clear();
1752                                         vCardFilenameFull.Clear();
1753                                         vCardDataString.Clear();
1754                                         ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1755                                         continue;
1756                         
1757                                 } else {
1758                                         FoundContact = TRUE;
1759                                 }
1761                                 //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
1762                                 //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
1764                                 if (XVMData.SortMode == 1){
1766                                     // Split the name into sections.
1767         
1768                                     vCardDataString = Person.Get(wxT("N"));
1770                                     vCardName NameData = Person.GetName();
1771     
1772                                     vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
1773     
1774                                 } else if (XVMData.SortMode == 2){
1775     
1776                                     // Split the name into sections.
1777     
1778                                     vCardName NameData = Person.GetName();    
1779     
1780                                     vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
1781     
1782                                 } else if (XVMData.SortMode == 3){
1783     
1784                                     // Check and make sure that the top most nickname is used.
1785     
1786                                     vCardDataString = Person.Get(wxT("NICKNAME"));
1787     
1788                                     if (vCardDataString.IsEmpty()){
1789         
1790                                         vCardDataString = wxT("(no nickname)");
1791         
1792                                     }
1793     
1794                                 } else if (XVMData.SortMode == 4){
1795     
1796                                     vCardDataString = Person.Get(wxT("FN"));
1797     
1798                                 }
1800                                 if (XVMData.AscendingMode == TRUE){
1801                                     vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
1802                                 } else {
1803                                     vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
1804                                 }
1806                             } else {
1808                             }
1812                         }
1814                         vCardFilename.Clear();
1815                         vCardFilenameFull.Clear();
1816                         vCardDataString.Clear();
1817                         ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1819                     }
1820                     
1821                     if (FoundContact == FALSE){
1822                         if (XVMData.AscendingMode == TRUE){
1823                             vCardNamesAsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1824                         } else {
1825                             vCardNamesDsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1826                         }
1827                     }
1829                     if (XVMData.AscendingMode == TRUE){
1831                         for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
1832                         iter != vCardNamesAsc.end(); ++iter){
1834                                 wxListItem ItemData;
1835                         
1836                                 ItemData.SetId(0);
1837                                 ItemData.SetText(iter->first);
1838         
1839                                 lboGroups->InsertItem(ItemData);
1841                         }
1844                     } else {
1846                         for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
1847                         iter != vCardNamesDsc.end(); ++iter){
1849                                 wxListItem ItemData;
1850                         
1851                                 ItemData.SetId(0);
1852                                 ItemData.SetText(iter->first);
1853         
1854                                 lboGroups->InsertItem(ItemData);
1856                     }
1858                 }
1859         
1860         }
1861         
1864 void frmContactEditor::LoadAddress(std::map<int, wxString> *GeneralAddressList,
1865         std::map<int, wxString> *GeneralAddressListTown,
1866         std::map<int, wxString> *GeneralAddressListCounty,
1867         std::map<int, wxString> *GeneralAddressListPostCode,
1868         std::map<int, int> *GeneralAddressListPref,
1869         std::map<int, wxString> *HomeAddressList,
1870         std::map<int, wxString> *HomeAddressListTown,
1871         std::map<int, wxString> *HomeAddressListCounty,
1872         std::map<int, wxString> *HomeAddressListPostCode,
1873         std::map<int, int> *HomeAddressListPref,
1874         std::map<int, wxString> *BusinessAddressList,
1875         std::map<int, wxString> *BusinessAddressListTown,
1876         std::map<int, wxString> *BusinessAddressListCounty,
1877         std::map<int, wxString> *BusinessAddressListPostCode,
1878         std::map<int, int> *BusinessAddressListPref, 
1879         int *AddressCount){
1881         long ListCtrlIndex = -1;
1883         // Deal with the general addresses.
1884         
1885         for (std::map<int,wxString>::iterator Iter = GeneralAddressList->begin();
1886                 Iter != GeneralAddressList->end();
1887                 Iter++){
1888         
1889                 wxListItem coldata;
1891                 coldata.SetId(*AddressCount);
1892                 coldata.SetData(*AddressCount);
1893                 coldata.SetText(Iter->second);
1894                 
1895                 ListCtrlIndex = lboAddresses->InsertItem(coldata);
1896                 
1897                 if (MapDataExists(AddressCount, GeneralAddressListTown)){
1898                 
1899                         lboAddresses->SetItem(ListCtrlIndex, 1, GeneralAddressListTown->find(*AddressCount)->second);
1900                 
1901                 }
1903                 if (MapDataExists(AddressCount, GeneralAddressListCounty)){
1904                 
1905                         lboAddresses->SetItem(ListCtrlIndex, 2, GeneralAddressListCounty->find(*AddressCount)->second);
1906                 
1907                 }
1908                 
1909                 if (MapDataExists(AddressCount, GeneralAddressListPostCode)){
1910                 
1911                         lboAddresses->SetItem(ListCtrlIndex, 3, GeneralAddressListPostCode->find(*AddressCount)->second);
1912                 
1913                 }
1914                 
1915                 if (MapDataExists(AddressCount, GeneralAddressListPref)){
1916                 
1917                         lboAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", GeneralAddressListPref->find(*AddressCount)->second));
1918                 
1919                 }
1920         
1921                 (*AddressCount)++;
1922         
1923         }
1924         
1925         // Deal with the home addresses.
1926         
1927         for (std::map<int,wxString>::iterator Iter = HomeAddressList->begin();
1928                 Iter != HomeAddressList->end();
1929                 Iter++){
1930         
1931                 wxListItem coldata;
1933                 coldata.SetId(*AddressCount);
1934                 coldata.SetData(*AddressCount);
1935                 coldata.SetText(Iter->second);
1936                 
1937                 ListCtrlIndex = lboHomeAddresses->InsertItem(coldata);
1938                 
1939                 if (MapDataExists(AddressCount, HomeAddressListTown)){
1940                 
1941                         lboHomeAddresses->SetItem(ListCtrlIndex, 1, HomeAddressListTown->find(*AddressCount)->second);
1942                 
1943                 }
1945                 if (MapDataExists(AddressCount, HomeAddressListCounty)){
1946                 
1947                         lboHomeAddresses->SetItem(ListCtrlIndex, 2, HomeAddressListCounty->find(*AddressCount)->second);
1948                 
1949                 }
1950                 
1951                 if (MapDataExists(AddressCount, HomeAddressListPostCode)){
1952                 
1953                         lboHomeAddresses->SetItem(ListCtrlIndex, 3, HomeAddressListPostCode->find(*AddressCount)->second);
1954                 
1955                 }
1956                 
1957                 if (MapDataExists(AddressCount, HomeAddressListPref)){
1958                 
1959                         lboHomeAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", HomeAddressListPref->find(*AddressCount)->second));
1960                 
1961                 }
1962         
1963                 (*AddressCount)++;
1964         
1965         }
1966         
1967         // Deal with the work addresses.
1968         
1969         for (std::map<int,wxString>::iterator Iter = BusinessAddressList->begin();
1970                 Iter != BusinessAddressList->end();
1971                 Iter++){
1972         
1973                 wxListItem coldata;
1975                 coldata.SetId(*AddressCount);
1976                 coldata.SetData(*AddressCount);
1977                 coldata.SetText(Iter->second);
1978                 
1979                 ListCtrlIndex = lboBusinessAddresses->InsertItem(coldata);
1980                 
1981                 if (MapDataExists(AddressCount, BusinessAddressListTown)){
1982                 
1983                         lboBusinessAddresses->SetItem(ListCtrlIndex, 1, BusinessAddressListTown->find(*AddressCount)->second);
1984                 
1985                 }
1987                 if (MapDataExists(AddressCount, BusinessAddressListCounty)){
1988                 
1989                         lboBusinessAddresses->SetItem(ListCtrlIndex, 2, BusinessAddressListCounty->find(*AddressCount)->second);
1990                 
1991                 }
1992                 
1993                 if (MapDataExists(AddressCount, BusinessAddressListPostCode)){
1994                 
1995                         lboBusinessAddresses->SetItem(ListCtrlIndex, 3, BusinessAddressListPostCode->find(*AddressCount)->second);
1996                 
1997                 }
1998                 
1999                 if (MapDataExists(AddressCount, BusinessAddressListPref)){
2000                 
2001                         lboBusinessAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", BusinessAddressListPref->find(*AddressCount)->second));
2002                 
2003                 }
2004         
2005                 (*AddressCount)++;
2006         
2007         }
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