Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditor: Stop XAB crashing when pressing Modify/Delete
[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         ContactLoadStatus LoadResult = ContactEditorData.LoadFile(Filename);
52         switch(LoadResult){
53         
54                 case CONTACTLOAD_OK:
55                         break;
56                 case CONTACTLOAD_FILEMISSING:
57                         wxMessageBox(_("The file with the filename given does not exist."),
58                                 _("Contact not found"), wxICON_ERROR);
59                         this->Close();
60                         return FALSE;
61                         break;
62                 case CONTACTLOAD_FILEERROR:
63                         wxMessageBox(_("The file with the filename given cannot be opened due to an error while trying open it."),
64                                 _("Error loading contact"), wxICON_ERROR);
65                         this->Close();
66                         return FALSE;
67                         break;
68                 case CONTACTLOAD_FILEINVALIDFORMAT:
69                                 wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
70                                         _("Contact not supported"), wxICON_ERROR);
71                         this->Close();
72                         return FALSE;
73                         break;
74                 case CONTACTLOAD_FILEBASESPECFAIL:
75                         wxMessageBox(_("This file is not a vCard 4.0 contact and is not supported under Xestia Address Book."),
76                                 _("Contact not supported"), wxICON_ERROR);
77                         this->Close();
78                         return FALSE;
79                         break;
80         
81         };
82         
83         // Get the line.
85         wxString wxSProperty;
86         wxString wxSPropertySeg1;
87         wxString wxSPropertySeg2;
88         wxString wxSPropertyNextLine;
89         int NicknameCount = 0;
90         int ADRCount = 0;
91         int EmailCount = 0;
92         int IMPPCount = 0;
93         int TelCount = 0;
94         int LangCount = 0;
95         int TZCount = 0;
96         int GeoCount = 0;
97         int URLCount = 0;
98         int RelatedCount = 0;
99         int TitleCount = 0;
100         int RoleCount = 0;
101         int OrgCount = 0;
102         int NoteCount = 0;
103         int CategoryCount = 0;
104         int PhotoCount = 0;
105         int LogoCount = 0;
106         int SoundCount = 0;
107         int CalAdrCount = 0;
108         int CalReqAdrCount = 0;
109         int FreeBusyCount = 0;
110         int KeyCount = 0;
111         int VendorCount = 0;
112         int XTokenCount = 0;
114         // Process the unique ID (UID)
115         
116         // Do nothing at the moment.
117         
118         // Process the contact type (KIND) (frmContactEditor-LoadGroup.cpp)
120         LoadKind(&ContactEditorData.ContactKind);
122         // Process the Birthday (BDAY) (frmContactEditor-LoadBADays.cpp)
123         
124         LoadBirthday(&ContactEditorData.Birthday, &ContactEditorData.BirthdayText);
126         // Process the Anniversary (ANNIVERSARY) (frmContactEditor-LoadBADays.cpp)
127         
128         LoadAnniversary(&ContactEditorData.Anniversary, &ContactEditorData.AnniversaryText);
130         // Process the Gender (GENDER) (frmContactEditor-LoadGender.cpp)
131         
132         LoadGender(&ContactEditorData.Gender, &ContactEditorData.GenderDetails);
133         
134         // Process the Name (N) (frmContactEditor-LoadName.cpp)
135         
136         LoadName(&ContactEditorData.NameTitle, &ContactEditorData.NameForename,
137                 &ContactEditorData.NameSurname, &ContactEditorData.NameOtherNames,
138                 &ContactEditorData.NameSuffix);
139                 
140         // Process the group members (MEMBER) (frmContactEditor-LoadGroup.cpp)
141                 
142         LoadMember(&ContactEditorData.GroupsList);
144         // Process the addresses (ADR) (frmContactEditor-LoadAddress.cpp)
145         
146         LoadAddress(&ContactEditorData.GeneralAddressList,
147                 &ContactEditorData.GeneralAddressListTown,
148                 &ContactEditorData.GeneralAddressListCounty,
149                 &ContactEditorData.GeneralAddressListPostCode,
150                 &ContactEditorData.GeneralAddressListPref,
151                 &ContactEditorData.HomeAddressList,
152                 &ContactEditorData.HomeAddressListTown,
153                 &ContactEditorData.HomeAddressListCounty,
154                 &ContactEditorData.HomeAddressListPostCode,
155                 &ContactEditorData.HomeAddressListPref,
156                 &ContactEditorData.BusinessAddressList,
157                 &ContactEditorData.BusinessAddressListTown,
158                 &ContactEditorData.BusinessAddressListCounty,
159                 &ContactEditorData.BusinessAddressListPostCode,
160                 &ContactEditorData.BusinessAddressListPref,
161                 &ADRCount);
163         // Process the timezones (TZ).
164         
165         LoadData(&ContactEditorData.GeneralTZList,
166                 &ContactEditorData.GeneralTZListPref,
167                 lboTimezones,
168                 &ContactEditorData.HomeTZList,
169                 &ContactEditorData.HomeTZListPref,
170                 lboHomeTimezones,
171                 &ContactEditorData.BusinessTZList,
172                 &ContactEditorData.BusinessTZListPref,
173                 lboBusinessTimezones,
174                 &TZCount);
175                 
176         // Process the emails (EMAIL).
177         
178         LoadData(&ContactEditorData.GeneralEmailList,
179                 &ContactEditorData.GeneralEmailListPref,
180                 lboEmails,
181                 &ContactEditorData.HomeEmailList,
182                 &ContactEditorData.HomeEmailListPref,
183                 lboHomeEmails,
184                 &ContactEditorData.BusinessEmailList,
185                 &ContactEditorData.BusinessEmailListPref,
186                 lboBusinessEmail,
187                 &EmailCount);
189         // Process the nicknames (NICKNAME).
190         
191         LoadData(&ContactEditorData.GeneralNicknamesList,
192                 &ContactEditorData.GeneralNicknamesListPref,
193                 lboNicknames,
194                 &ContactEditorData.HomeNicknamesList,
195                 &ContactEditorData.HomeNicknamesListPref,
196                 lboHomeNicknames,
197                 &ContactEditorData.BusinessNicknamesList,
198                 &ContactEditorData.BusinessNicknamesListPref,
199                 lboBusinessNicknames,
200                 &NicknameCount);
201                 
202         // Process the languages (LANG).
203         
204         LoadData(&ContactEditorData.GeneralLanguageList,
205                 &ContactEditorData.GeneralLanguageListPref,
206                 lboLanguages,
207                 &ContactEditorData.HomeLanguageList,
208                 &ContactEditorData.HomeLanguageListPref,
209                 lboHomeLanguages,
210                 &ContactEditorData.BusinessLanguageList,
211                 &ContactEditorData.BusinessLanguageListPref,
212                 lboBusinessLanguages,
213                 &LangCount);
214                 
215         // Process the geopositiosn (GEO).
216         
217         LoadData(&ContactEditorData.GeneralGeographyList,
218                 &ContactEditorData.GeneralGeographyListPref,
219                 lboGeoposition,
220                 &ContactEditorData.HomeGeographyList,
221                 &ContactEditorData.HomeGeographyListPref,
222                 lboHomeGeoposition,
223                 &ContactEditorData.BusinessGeographyList,
224                 &ContactEditorData.BusinessGeographyListPref,
225                 lboBusinessGeoposition,
226                 &GeoCount);
227                 
228         // Process the websites (URL).
229         
230         LoadData(&ContactEditorData.GeneralWebsiteList,
231                 &ContactEditorData.GeneralWebsiteListPref,
232                 lboWebsites,
233                 &ContactEditorData.HomeWebsiteList,
234                 &ContactEditorData.HomeWebsiteListPref,
235                 lboHomeWebsites,
236                 &ContactEditorData.BusinessWebsiteList,
237                 &ContactEditorData.BusinessWebsiteListPref,
238                 lboBusinessWebsites,
239                 &URLCount);
241         // Process the titles (TITLE).
242         
243         LoadData(&ContactEditorData.GeneralTitleList,
244                 &ContactEditorData.GeneralTitleListPref,
245                 lboTitles,
246                 &ContactEditorData.HomeTitleList,
247                 &ContactEditorData.HomeTitleListPref,
248                 lboHomeTitles,
249                 &ContactEditorData.BusinessTitleList,
250                 &ContactEditorData.BusinessTitleListPref,
251                 lboBusinessTitles,
252                 &TitleCount);
253                 
254         // Process the roles (ROLE).
255         
256         LoadData(&ContactEditorData.GeneralRoleList,
257                 &ContactEditorData.GeneralRoleListPref,
258                 lboRoles,
259                 &ContactEditorData.HomeRoleList,
260                 &ContactEditorData.HomeRoleListPref,
261                 lboHomeRoles,
262                 &ContactEditorData.BusinessRoleList,
263                 &ContactEditorData.BusinessRoleListPref,
264                 lboBusinessRoles,
265                 &RoleCount);
267         // Process the roles (ORG).
268         
269         LoadData(&ContactEditorData.GeneralOrganisationsList,
270                 &ContactEditorData.GeneralOrganisationsListPref,
271                 lboOrganisations,
272                 &ContactEditorData.HomeOrganisationsList,
273                 &ContactEditorData.HomeOrganisationsListPref,
274                 lboHomeOrganisations,
275                 &ContactEditorData.BusinessOrganisationsList,
276                 &ContactEditorData.BusinessOrganisationsListPref,
277                 lboBusinessOrganisations,
278                 &OrgCount);
279                 
280         // Process the notes (NOTE).
281                 
282         LoadData(&ContactEditorData.GeneralNoteList,
283                 &ContactEditorData.GeneralNoteListPref,
284                 lboNotes,
285                 &ContactEditorData.HomeNoteList,
286                 &ContactEditorData.HomeNoteListPref,
287                 lboHomeNotes,
288                 &ContactEditorData.BusinessNoteList,
289                 &ContactEditorData.BusinessNoteListPref,
290                 lboBusinessNotes,
291                 &NoteCount);
292                 
293         // Process the categories (CATEGORIES).
295         LoadData(&ContactEditorData.CategoriesList,
296                 &ContactEditorData.CategoriesListPref,
297                 lboCategories,
298                 &CategoryCount);
299                 
300         // Process the telephone numbers (TEL).
301         
302         LoadData(&ContactEditorData.GeneralTelephoneList,
303                 &ContactEditorData.GeneralTelephoneListPref,
304                 &ContactEditorData.GeneralTelephoneListTypeInfo,
305                 lboTelephone,
306                 &ContactEditorData.HomeTelephoneList,
307                 &ContactEditorData.HomeTelephoneListPref,
308                 &ContactEditorData.HomeTelephoneListTypeInfo,
309                 lboHomeTelephone,
310                 &ContactEditorData.BusinessTelephoneList,
311                 &ContactEditorData.BusinessTelephoneListPref,
312                 &ContactEditorData.BusinessTelephoneListTypeInfo,
313                 lboBusinessTelephone,
314                 &TelCount);
316         // Process the instant messaging (IMPP).
317         
318         LoadData(&ContactEditorData.GeneralIMListTypeInfo,
319                 &ContactEditorData.GeneralIMListPref,
320                 &ContactEditorData.GeneralIMList,
321                 lboIM,
322                 &ContactEditorData.HomeIMListTypeInfo,
323                 &ContactEditorData.HomeIMListPref,
324                 &ContactEditorData.HomeIMList,
325                 lboHomeIM,
326                 &ContactEditorData.BusinessIMListTypeInfo,
327                 &ContactEditorData.BusinessIMListPref,
328                 &ContactEditorData.BusinessIMList,
329                 lboBusinessIM,
330                 &IMPPCount);
332         // Process the photos (PHOTO).
333         
334         LoadPictureData("PHOTO", 
335                 &ContactEditorData.PicturesList,
336                 &ContactEditorData.PicturesListPref,
337                 &ContactEditorData.PicturesListType,
338                 lboPictures,
339                 &PhotoCount);
340                 
341         // Process the logos (LOGO).
342         
343         LoadPictureData("LOGO", 
344                 &ContactEditorData.LogosList,
345                 &ContactEditorData.LogosListPref,
346                 &ContactEditorData.LogosListType,
347                 lboLogos,
348                 &LogoCount);
349                 
350         // Process the sounds (SOUND).
351         
352         LoadPictureData("SOUND", 
353                 &ContactEditorData.SoundsList,
354                 &ContactEditorData.SoundsListPref,
355                 &ContactEditorData.SoundsListType,
356                 lboSounds,
357                 &SoundCount);
359         // Process the calendar addresses (CALURI).
360         
361         LoadData("CALURI", 
362                 &ContactEditorData.CalendarList,
363                 &ContactEditorData.CalendarListPref,
364                 &ContactEditorData.CalendarListType,
365                 NULL,
366                 lboCalendarAddresses,
367                 &CalAdrCount);
368                 
369         // Process the calendar request addresses (CALADRURI).
370         
371         LoadData("CALADRURI", 
372                 &ContactEditorData.CalendarRequestList,
373                 &ContactEditorData.CalendarRequestListPref,
374                 &ContactEditorData.CalendarRequestListType,
375                 NULL,
376                 lboCalendarRequestAddress,
377                 &CalReqAdrCount);
379         // Process the free busy addresses (FBURL).
380         
381         LoadData("FBURL", 
382                 &ContactEditorData.FreeBusyList,
383                 &ContactEditorData.FreeBusyListPref,
384                 &ContactEditorData.FreeBusyListType,
385                 NULL,
386                 lboFreeBusyAddresses,
387                 &FreeBusyCount);
388                 
389         // Process the keys. (KEY)
390         
391         LoadData("KEY",
392                 &ContactEditorData.KeyList,
393                 &ContactEditorData.KeyListPref,
394                 &ContactEditorData.KeyListType,
395                 &ContactEditorData.KeyListDataType,
396                 lboKeys,
397                 &KeyCount);
398                 
399         // Process the vendor specific information (VND-*).
400         
401         LoadVendorData(&ContactEditorData.VendorListPEN,
402                 &ContactEditorData.VendorListElement,
403                 lboVendorNamespace,
404                 &VendorCount);
405         
406         // Process the X-Tokens (X-*).
408         LoadXTokenData(&ContactEditorData.XTokenListTokens,
409                 lboXToken,
410                 &XTokenCount);
411         
412         // Process the related people (RELATED).
413         
414         LoadRelatedData(&ContactEditorData.GeneralRelatedList,
415                 &ContactEditorData.GeneralRelatedListPref,
416                 &ContactEditorData.GeneralRelatedListType,
417                 lboRelated,
418                 &RelatedCount);
419                 
420         // Process the full name (FN).
421         
422         LoadData(&ContactEditorData.FullNamesList,
423                 cmbDisplayAs);
424         
425         FMTimer.SetFilename(Filename);
426         FMTimer.Start(10000, FALSE);
427         
428         EditMode = TRUE;
429         
430         return TRUE;
433 void frmContactEditor::SplitValues(wxString *PropertyLine, 
434         std::map<int,int> *SplitPoints, 
435         std::map<int,int> *SplitLength, 
436         int intSize){
437         
438         // Split the values.
439                 
440         size_t intPropertyLen = PropertyLine->Len();
441         int intSplitsFound = 0;
442         int intSplitSize = 0;
443         int intSplitSeek = 0;
444         
445         for (int i = intSize; i <= intPropertyLen; i++){
447                 intSplitSize++;
448         
449                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
450                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
451            
452                         if (intSplitsFound == 0){
453             
454                                 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
455           
456                         } else {
457            
458                                 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
459             
460                         }
461             
462                         SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
463             
464                         intSplitsFound++;
465                         intSplitSeek = i;
466                         intSplitSize = 0;
467                 
468                 }
470         }
472         if (intSplitsFound == 0){
474                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
475                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
477         } else {
479                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
480                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
482         }
486 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
487                 std::map<int, int> *GeneralListPref,
488                 wxListCtrl *GeneralListCtrl,
489                 std::map<int, wxString> *HomeList,
490                 std::map<int, int> *HomeListPref,
491                 wxListCtrl *HomeListCtrl,
492                 std::map<int, wxString> *BusinessList,
493                 std::map<int, int> *BusinessListPref,
494                 wxListCtrl *BusinessListCtrl,
495                 int *DataCount){
497         // Load data into the controls (first section of data and preference
498         // only).
499                         
500         long ListCtrlIndex = -1;
502         // Deal with the general items.
503         
504         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
505                 Iter != GeneralList->end();
506                 Iter++){
507         
508                 wxListItem coldata;
510                 coldata.SetId(*DataCount);
511                 coldata.SetData(*DataCount);
512                 coldata.SetText(Iter->second);
513                 
514                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
516                 if (MapDataExists(DataCount, GeneralListPref)){
517                 
518                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
519                 
520                 }
521         
522                 (*DataCount)++;
523         
524         }
525         
526         // Deal with the home items.
527         
528         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
529                 Iter != HomeList->end();
530                 Iter++){
531         
532                 wxListItem coldata;
534                 coldata.SetId(*DataCount);
535                 coldata.SetData(*DataCount);
536                 coldata.SetText(Iter->second);
537                 
538                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
540                 if (MapDataExists(DataCount, HomeListPref)){
541                 
542                         HomeListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
543                 
544                 }
545         
546                 (*DataCount)++;
547         
548         }
549         
550         // Deal with the work items.
551         
552         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
553                 Iter != BusinessList->end();
554                 Iter++){
555         
556                 wxListItem coldata;
558                 coldata.SetId(*DataCount);
559                 coldata.SetData(*DataCount);
560                 coldata.SetText(Iter->second);
561                 
562                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
563                                 
564                 if (MapDataExists(DataCount, BusinessListPref)){
565                 
566                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
567                 
568                 }
569         
570                 (*DataCount)++;
571         
572         }
576 void frmContactEditor::LoadData(std::map<int, wxString> *GeneralList,
577                 std::map<int, int> *GeneralListPref,
578                 std::map<int, wxString> *GeneralListType,
579                 wxListCtrl *GeneralListCtrl,
580                 std::map<int, wxString> *HomeList,
581                 std::map<int, int> *HomeListPref,
582                 std::map<int, wxString> *HomeListType,
583                 wxListCtrl *HomeListCtrl,
584                 std::map<int, wxString> *BusinessList,
585                 std::map<int, int> *BusinessListPref,
586                 std::map<int, wxString> *BusinessListType,
587                 wxListCtrl *BusinessListCtrl,
588                 int *DataCount){
590         // Load data into the controls (first section of data, 
591         // type and preference).
592                         
593         long ListCtrlIndex = -1;
595         // Deal with the general items.
596         
597         for (std::map<int,wxString>::iterator Iter = GeneralList->begin();
598                 Iter != GeneralList->end();
599                 Iter++){
600         
601                 wxListItem coldata;
603                 coldata.SetId(*DataCount);
604                 coldata.SetData(*DataCount);
605                 coldata.SetText(Iter->second);
606                 
607                 ListCtrlIndex = GeneralListCtrl->InsertItem(coldata);
609                 if (MapDataExists(DataCount, GeneralListPref)){
610                 
611                         GeneralListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", GeneralListPref->find(*DataCount)->second));
612                 
613                 }
614         
615                 if (MapDataExists(DataCount, GeneralListType)){
616                 
617                         GeneralListCtrl->SetItem(ListCtrlIndex, 1, GeneralListType->find(*DataCount)->second);
618                 
619                 }
620         
621                 (*DataCount)++;
622         
623         }
624         
625         // Deal with the home items.
626         
627         for (std::map<int,wxString>::iterator Iter = HomeList->begin();
628                 Iter != HomeList->end();
629                 Iter++){
630         
631                 wxListItem coldata;
633                 coldata.SetId(*DataCount);
634                 coldata.SetData(*DataCount);
635                 coldata.SetText(Iter->second);
636                 
637                 ListCtrlIndex = HomeListCtrl->InsertItem(coldata);
639                 if (MapDataExists(DataCount, HomeListPref)){
640                 
641                         HomeListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", HomeListPref->find(*DataCount)->second));
642                 
643                 }
644                 
645                 if (MapDataExists(DataCount, HomeListType)){
646                 
647                         HomeListCtrl->SetItem(ListCtrlIndex, 1, HomeListType->find(*DataCount)->second);
648                 
649                 }
650         
651                 (*DataCount)++;
652         
653         }
654         
655         // Deal with the work items.
656         
657         for (std::map<int,wxString>::iterator Iter = BusinessList->begin();
658                 Iter != BusinessList->end();
659                 Iter++){
660         
661                 wxListItem coldata;
663                 coldata.SetId(*DataCount);
664                 coldata.SetData(*DataCount);
665                 coldata.SetText(Iter->second);
666                 
667                 ListCtrlIndex = BusinessListCtrl->InsertItem(coldata);
668                                 
669                 if (MapDataExists(DataCount, BusinessListPref)){
670                 
671                         BusinessListCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", BusinessListPref->find(*DataCount)->second));
672                 
673                 }
674                 
675                 if (MapDataExists(DataCount, BusinessListType)){
676                 
677                         BusinessListCtrl->SetItem(ListCtrlIndex, 1, BusinessListType->find(*DataCount)->second);
678                 
679                 }
680         
681                 (*DataCount)++;
682         
683         }
688 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
689                 std::map<int,int> *ItemListPref,
690                 wxListCtrl *ItemCtrl,
691                 int *DataCount){
693         // Load the data (name and preference only).
694                         
695         long ListCtrlIndex = -1;
697         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
698                 Iter != ItemList->end();
699                 Iter++){
700         
701                 wxListItem coldata;
703                 coldata.SetId(*DataCount);
704                 coldata.SetData(*DataCount);
705                 coldata.SetText(Iter->second);
706                 
707                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
708                                 
709                 if (MapDataExists(DataCount, ItemListPref)){
710                 
711                         ItemCtrl->SetItem(ListCtrlIndex, 1, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
712                 
713                 }
714         
715                 (*DataCount)++;
716         
717         }
721 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
722                 std::map<int,int> *ItemListPref,
723                 std::map<int,wxString> *ItemListType,
724                 wxListCtrl *ItemCtrl,
725                 int *DataCount){
727         // Load the data (name, preference and type).
728                         
729         long ListCtrlIndex = -1;
731         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
732                 Iter != ItemList->end();
733                 Iter++){
734         
735                 wxListItem coldata;
737                 coldata.SetId(*DataCount);
738                 coldata.SetData(*DataCount);
739                 coldata.SetText(Iter->second);
740                 
741                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
742                                 
743                 if (MapDataExists(DataCount, ItemListType)){
744                 
745                         ItemCtrl->SetItem(ListCtrlIndex, 1, ItemListType->find(*DataCount)->second);
746                 
747                 }
748                                 
749                 if (MapDataExists(DataCount, ItemListPref)){
750                 
751                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
752                 
753                 }
754         
755                 (*DataCount)++;
756         
757         }
761 void frmContactEditor::LoadData(wxString ItemName,
762                 std::map<int,wxString> *ItemList,
763                 std::map<int,int> *ItemListPref,
764                 std::map<int,wxString> *ItemListType,
765                 std::map<int,wxString> *ItemListDataType,
766                 wxListCtrl *ItemCtrl,
767                 int *DataCount){
769         // Load data (name, preference, type and data type).
770                         
771         long ListCtrlIndex = -1;
773         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
774                 Iter != ItemList->end();
775                 Iter++){
776         
777                 wxListItem coldata;
779                 coldata.SetId(*DataCount);
780                 coldata.SetData(*DataCount);
781                 coldata.SetText(Iter->second);
783                 if (ItemName == "KEY"){
785                         // Get the key type, if any.
787                         if (MapDataExists(DataCount, ItemListDataType)){
788                 
789                                 if (ItemListDataType->find(*DataCount)->second == "application/pgp-keys"){
790                                 
791                                         coldata.SetText(_("PGP Key"));
792                                 
793                                 }
794                 
795                         } else {
796                         
797                                 coldata.SetText(_("Key"));
798                         
799                         }
800                 
801                 
802                 }
803                 
804                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
805                 
806                 if (MapDataExists(DataCount, ItemListType)){
807                 
808                         if (ItemListType->find(*DataCount)->second == "home"){
809                         
810                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
811                         
812                         } else if (ItemListType->find(*DataCount)->second == "work"){
813                         
814                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
815                         
816                         }
817                                 
818                 }
819                         
820                 if (MapDataExists(DataCount, ItemListPref)){
821                 
822                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
823                 
824                 }
825         
826                 (*DataCount)++;
827         
828         }
832 void frmContactEditor::LoadPictureData(wxString ItemName, 
833                 std::map<int,std::string> *ItemList,
834                 std::map<int,int> *ItemListPref,
835                 std::map<int,wxString> *ItemListType,
836                 wxListCtrl *ItemCtrl,
837                 int *DataCount){
839         // Load the picture data.
840                         
841         long ListCtrlIndex = -1;
843         for (std::map<int,std::string>::iterator Iter = ItemList->begin();
844                 Iter != ItemList->end();
845                 Iter++){
846         
847                 wxListItem coldata;
849                 coldata.SetId(*DataCount);
850                 coldata.SetData(*DataCount);
851                 
852                 if (ItemName == "PHOTO"){
853                 
854                         coldata.SetText("Picture");
855                 
856                 } else if (ItemName == "LOGO"){
858                         coldata.SetText("Logo");
859                 
860                 } else if (ItemName == "SOUND"){
861                 
862                         coldata.SetText("Sound");               
863                 
864                 } else {
865                 
866                         coldata.SetText("Object");
867                 
868                 }
869                                 
870                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
871                                                                 
872                 if (MapDataExists(DataCount, ItemListType)){
873                 
874                         if (ItemListType->find(*DataCount)->second == "home"){
875                         
876                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Home"));
877                         
878                         } else if (ItemListType->find(*DataCount)->second == "work"){
879                         
880                                 ItemCtrl->SetItem(ListCtrlIndex, 1, _("Work"));
881                         
882                         }
883                                 
884                 }
885                                 
886                 if (MapDataExists(DataCount, ItemListPref)){
887                 
888                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
889                 
890                 }
891         
892                 (*DataCount)++;
893         
894         }
898 void frmContactEditor::LoadVendorData(std::map<int,wxString> *ItemListPEN,
899                 std::map<int,wxString> *ItemListElement,
900                 wxListCtrl *ItemCtrl,
901                 int *DataCount){
902         
903         // Load the vendor data.
904                         
905         long ListCtrlIndex = -1;
906         wxString ItemValue;
908         for (std::map<int,wxString>::iterator Iter = ItemListPEN->begin();
909                 Iter != ItemListPEN->end();
910                 Iter++){
911                         
912                 ItemValue.clear();
913                         
914                 wxListItem coldata;
916                 coldata.SetId(*DataCount);
917                 coldata.SetData(*DataCount);
918                                                         
919                 ItemValue.Append(ItemListPEN->find(*DataCount)->second);
920                 ItemValue.Append("-");
921                 ItemValue.Append(ItemListElement->find(*DataCount)->second);
922                                 
923                 coldata.SetText(ItemValue);
924                                 
925                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
926                 
927                 (*DataCount)++;
928                 
929         }
930                 
933 void frmContactEditor::LoadXTokenData(std::map<int,wxString> *ItemListTokens,
934                 wxListCtrl *ItemCtrl,
935                 int *DataCount){
936         
937         // Load the X-Token data.
938                         
939         long ListCtrlIndex = -1;
940         wxString ItemValue;
942         for (std::map<int,wxString>::iterator Iter = ItemListTokens->begin();
943                 Iter != ItemListTokens->end();
944                 Iter++){
945                         
946                 ItemValue.clear();
947                         
948                 wxListItem coldata;
950                 coldata.SetId(*DataCount);
951                 coldata.SetData(*DataCount);
952                                                         
953                 ItemValue.Append(ItemListTokens->find(*DataCount)->second);
954                 
955                 coldata.SetText(ItemValue);
956                                 
957                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
958                 
959                 (*DataCount)++;
960                 
961         }
962                 
965 void frmContactEditor::LoadData(std::map<int,wxString> *ItemList,
966                 wxComboBox *ItemCtrl){
968         // Load data into a wxComboBox.
969                         
970         int ItemIndex = 0;
972         if (MapDataExists(&ItemIndex, ItemList)){
973         
974                 cmbDisplayAs->SetValue(ItemList->find(0)->second);
975         
976         }
977                 
980 void frmContactEditor::LoadRelatedData(std::map<int,wxString> *ItemList,
981                 std::map<int,int> *ItemListPref,
982                 std::map<int,wxString> *ItemListType,
983                 wxListCtrl *ItemCtrl,
984                 int *DataCount){
986         // Load related data (name, preference and type).
987                         
988         long ListCtrlIndex = -1;
989         wxString RelatedType;
991         for (std::map<int,wxString>::iterator Iter = ItemList->begin();
992                 Iter != ItemList->end();
993                 Iter++){
994         
995                 RelatedType.clear();
996         
997                 wxListItem coldata;
999                 coldata.SetId(*DataCount);
1000                 coldata.SetData(*DataCount);
1001         
1002                 if (MapDataExists(DataCount, ItemListType)){
1003                 
1004                         std::map<int,wxString>::iterator TypeIter = ItemListType->find(*DataCount);
1005                 
1006                         if (TypeIter->second == wxT("contact")){
1008                                 RelatedType = _("Contact");
1010                         } else if (TypeIter->second == wxT("acquaintance")){
1012                                 RelatedType = _("Acquaintance");
1014                         } else if (TypeIter->second == wxT("friend")){
1016                                 RelatedType = _("Friend");
1018                         } else if (TypeIter->second == wxT("met")){
1020                                 RelatedType = _("Met");
1022                         } else if (TypeIter->second == wxT("co-worker")){
1024                                 RelatedType = _("Co-worker");
1026                         } else if (TypeIter->second == wxT("colleague")){
1028                                 RelatedType = _("Colleague");
1030                         } else if (TypeIter->second == wxT("co-resident")){
1032                                 RelatedType = _("Co-resident");
1034                         } else if (TypeIter->second == wxT("neighbor")){
1036                                 RelatedType = _("Neighbour");
1038                         } else if (TypeIter->second == wxT("child")){
1040                                 RelatedType = _("Child");
1042                         } else if (TypeIter->second == wxT("parent")){
1044                                 RelatedType = _("Parent");
1046                         } else if (TypeIter->second == wxT("sibling")){
1048                                 RelatedType = _("Sibling");
1050                         } else if (TypeIter->second == wxT("spouse")){
1052                                 RelatedType = _("Spouse");
1054                         } else if (TypeIter->second == wxT("kin")){
1056                                 RelatedType = _("Kin");
1058                         } else if (TypeIter->second == wxT("muse")){
1060                                 RelatedType = _("Muse");
1062                         } else if (TypeIter->second == wxT("crush")){
1064                                 RelatedType = _("Crush");
1066                         } else if (TypeIter->second == wxT("date")){
1068                                 RelatedType = _("Date");
1070                         } else if (TypeIter->second == wxT("sweetheart")){
1072                                 RelatedType = _("Sweetheart");
1074                         } else if (TypeIter->second == wxT("me")){
1076                                 RelatedType = _("Me");
1078                         } else if (TypeIter->second == wxT("agent")){
1080                                 RelatedType = _("Agent");
1082                         } else if (TypeIter->second == wxT("emergency")){
1084                                 RelatedType = _("Emergency");
1086                         } else {
1088                                 RelatedType = TypeIter->second;
1090                         }
1091                 
1092                 }
1093                 
1094                 coldata.SetText(RelatedType);
1095                                 
1096                 ListCtrlIndex = ItemCtrl->InsertItem(coldata);
1098                 if (MapDataExists(DataCount, ItemList)){
1099                 
1100                         ItemCtrl->SetItem(ListCtrlIndex, 1, ItemList->find(*DataCount)->second);
1101                 
1102                 }
1104                 if (MapDataExists(DataCount, ItemListPref)){
1105                 
1106                         ItemCtrl->SetItem(ListCtrlIndex, 2, wxString::Format("%i", ItemListPref->find(*DataCount)->second));
1107                 
1108                 }
1109         
1110                 (*DataCount)++;
1111                 
1112         }
1113                 
1116 void frmContactEditor::LoadKind(ContactKindType *KindType){
1118         // Load contact kind.
1119         
1120         switch (*KindType){
1121                 case CONTACTKIND_INDIVIDUAL:
1122                         cmbType->SetSelection(1);
1123                         break;
1124                 case CONTACTKIND_GROUP:
1125                         cmbType->SetSelection(2);
1126                         break;
1127                 case CONTACTKIND_ORGANISATION:
1128                         cmbType->SetSelection(3);
1129                         break;
1130                 case CONTACTKIND_LOCATION:
1131                         cmbType->SetSelection(4);
1132                         break;
1133                 case CONTACTKIND_NONE:
1134                         cmbType->SetSelection(0);
1135                         break;
1136         }
1137                         
1138         wxCommandEvent nullevent;
1139                         
1140         UpdateMembersTab(nullevent);
1144 void frmContactEditor::LoadBirthday(wxString *BirthdayData, bool *BirthdayText){
1146         // Load Birthday.
1147         
1148         if (BirthdayData->IsEmpty()){
1149             return;
1150         }
1151   
1152         if (*BirthdayText == FALSE){
1153         
1154                 int DateYear = 0;
1155                 wxDateTime::Month DateMonth;
1156                 unsigned int DateDay;
1157                 
1158                 wxString wxSData;
1159                 
1160                 if (BirthdayData->Mid(0, 2) == wxT("--")){
1161                 
1162                         // Skip year.
1163                 
1164                 } else {
1165                 
1166                         DateYear = wxAtoi(BirthdayData->Mid(0,4));
1167                 
1168                 }
1169                 
1170                 DateMonth = (wxDateTime::Month)(wxAtoi(BirthdayData->Mid(4,2)) - 1);
1171                 DateDay = wxAtoi(BirthdayData->Mid(6,2));
1172         
1173                 wxDateTime BDayDate(DateDay,DateMonth,DateYear);
1174         
1175                 dapBirthday->SetValue(BDayDate);                                
1176         
1177         } else {
1178         
1179                 txtBirthday->SetValue(*BirthdayData);
1180         
1181         }
1185 void frmContactEditor::LoadAnniversary(wxString *AnniversaryData, bool *AnniversaryText){
1187         // Load Anniversary.
1188         
1189         if (AnniversaryData->IsEmpty()){
1190             return;
1191         }
1192   
1193         if (*AnniversaryText == FALSE){
1194         
1195                 int DateYear = 0;
1196                 wxDateTime::Month DateMonth;
1197                 int DateDay;
1198                 
1199                 wxString wxSData;
1200                 
1201                 if (AnniversaryData->Mid(0, 2) == wxT("--")){
1202                 
1203                         // Skip year.
1204                 
1205                 } else {
1206                 
1207                         DateYear = wxAtoi(AnniversaryData->Mid(0,4));
1208                 
1209                 }
1210                 
1211                 DateMonth = (wxDateTime::Month)(wxAtoi(AnniversaryData->Mid(4,2)) - 1);
1212                 DateDay = wxAtoi(AnniversaryData->Mid(6,2));                                    
1213         
1214                 wxDateTime ADayDate(DateDay,DateMonth,DateYear);
1215         
1216                 dapAnniversary->SetValue(ADayDate);
1217         
1218         } else {
1219         
1220                 txtAnniversary->SetValue(*AnniversaryData);
1221         
1222         }
1226 void frmContactEditor::LoadGender(wxString *GenderComponent, wxString *GenderIdentity){
1228         // Load Gender.
1229         
1230         // Deal with the Gender Component.
1231         
1232         if (*GenderComponent == wxT("M")){
1233                 
1234                 // Gender is Male.
1235                         
1236                 cmbGender->SetSelection(1);
1237                 
1238         } else if (*GenderComponent == wxT("F")){
1239                 
1240                 // Gender is Female.
1241                         
1242                 cmbGender->SetSelection(2);                                     
1243                 
1244         } else if (*GenderComponent == wxT("O")){
1245                 
1246                 // Gender is Other.
1247                         
1248                 cmbGender->SetSelection(3);
1249                 
1250         } else if (*GenderComponent == wxT("N")){
1251                 
1252                 // Gender is None/Not Applicable.
1253                 
1254                 cmbGender->SetSelection(4);                                     
1255                 
1256         } else if (*GenderComponent == wxT("U")){
1257                 
1258                 // Gender is Unknown.
1259                         
1260                 cmbGender->SetSelection(5);                                     
1261                 
1262         }
1263         
1264         // Deal with the Gender Identity.
1266         txtGenderDescription->SetValue(*GenderIdentity);
1270 void frmContactEditor::LoadName(wxString *NameTitle, wxString *NameForename,
1271         wxString *NameSurname, wxString *NameOtherNames, 
1272         wxString *NameSuffix){
1274         // Load Name.
1275                 
1276         txtTitle->SetValue(*NameTitle); 
1277         txtForename->SetValue(*NameForename);
1278         txtSurname->SetValue(*NameSurname);
1279         txtOtherNames->SetValue(*NameOtherNames);
1280         txtSuffix->SetValue(*NameSuffix);
1281         
1284 void frmContactEditor::LoadMember(std::map<int,wxString> *GroupList){
1286         // Load group data.
1287         
1288         // Go through the list of contacts for the account and find the matching UID.
1289         // If contact with UID doesn't match then say (unknown contact).
1291         XABViewMode XVMData;
1292         if (StartupEditMode == FALSE){
1293                 XVMData = MainPtr->GetViewMode();
1294         }
1295         
1296         wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
1298         wxString vCardFilename;
1299         wxString vCardFilenameFull;
1300         wxString vCardDataString;
1301         wxString lwxs;
1302         wxString setname, setvalue;
1303         wxString MemberData;
1304         bool FoundContact = FALSE;
1305         std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
1306         std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
1308         wxDir vcardaccdir(AccountDirFinal);
1310         for (std::map<int,wxString>::iterator MemberIter = GroupList->begin();
1311                 MemberIter != GroupList->end();
1312                 MemberIter++){
1313                 
1314                 MemberData = MemberIter->second;
1315                 
1316                 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1317                 while(ProcFiles){
1319                         if (vCardFilename.Right(4) == wxT(".vcf") || 
1320                             vCardFilename.Right(4) == wxT(".VCF") || 
1321                             vCardFilename.Right(5) == wxT(".vcard") || 
1322                             vCardFilename.Right(5) == wxT(".VCARD")){
1324                                 vCard Person;
1326                                 vCardFilenameFull.Append(AccountDirFinal);
1327                                 vCardFilenameFull.Append(wxT("/"));
1328                                 vCardFilenameFull.Append(vCardFilename);
1330                                 Person.LoadFile(vCardFilenameFull);
1332                                 if (MemberData.Left(9) == wxT("urn:uuid:")){
1334                                         wxString NewPropValue;
1335                                         NewPropValue = MemberData.Mid(9, wxString::npos);
1336                                         MemberData = NewPropValue;
1338                                 }
1340                                 if (Person.MeetBaseSpecification()){
1342                                         wxString KindStatus = Person.Get(wxT("KIND"));
1344                                         if (KindStatus == wxT("group")){
1346                                                 vCardFilename.Clear();
1347                                                 vCardFilenameFull.Clear();
1348                                                 vCardDataString.Clear();
1349                                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1350                                                 continue;
1352                                         }
1354                                         wxString PersonName = Person.Get(wxT("N"));
1355                                         wxString PersonUID = Person.Get(wxT("UID"));
1356                                         wxString PersonFilename = vCardFilenameFull;
1357                                 
1358                                         if (PersonUID != MemberData){
1359                         
1360                                                 vCardFilename.Clear();
1361                                                 vCardFilenameFull.Clear();
1362                                                 vCardDataString.Clear();
1363                                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1364                                                 continue;
1365                         
1366                                         } else {
1367                                                 
1368                                                 FoundContact = TRUE;
1369                                                 
1370                                         }
1372                                         //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
1373                                         //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
1375                                         if (XVMData.SortMode == 1){
1377                                                 // Split the name into sections.
1378         
1379                                                 vCardDataString = Person.Get(wxT("N"));
1381                                                 vCardName NameData = Person.GetName();
1382     
1383                                                 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
1384     
1385                                         } else if (XVMData.SortMode == 2){
1386     
1387                                                 // Split the name into sections.
1388     
1389                                                 vCardName NameData = Person.GetName();    
1390     
1391                                                 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
1392     
1393                                         } else if (XVMData.SortMode == 3){
1394     
1395                                                 // Check and make sure that the top most nickname is used.
1396     
1397                                                 vCardDataString = Person.Get(wxT("NICKNAME"));
1398     
1399                                                 if (vCardDataString.IsEmpty()){
1400         
1401                                                         vCardDataString = wxT("(no nickname)");
1402         
1403                                                 }
1404     
1405                                         } else if (XVMData.SortMode == 4){
1406     
1407                                                 vCardDataString = Person.Get(wxT("FN"));
1408     
1409                                         }
1411                                         if (XVMData.AscendingMode == TRUE){
1412                                                 
1413                                                 vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
1414                                                 
1415                                         } else {
1416                                                 
1417                                                 vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
1418                                                 
1419                                         }
1421                                 } else {
1423                                 }
1425                         }
1427                         vCardFilename.Clear();
1428                         vCardFilenameFull.Clear();
1429                         vCardDataString.Clear();
1430                         ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1432                 }
1433                     
1434                 if (FoundContact == FALSE){
1435                                 
1436                         if (XVMData.AscendingMode == TRUE){
1437                                         
1438                                 vCardNamesAsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1439                                         
1440                         } else {
1441                                 
1442                         vCardNamesDsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
1443                                 
1444                         }
1446                 }
1448                 if (XVMData.AscendingMode == TRUE){
1450                         for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin(); 
1451                                 iter != vCardNamesAsc.end(); ++iter){
1453                                 wxListItem ItemData;
1454                         
1455                                 ItemData.SetId(0);
1456                                 ItemData.SetText(iter->first);
1457                                 lboGroups->InsertItem(ItemData);
1459                         }
1461                 } else {
1463                         for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin(); 
1464                                 iter != vCardNamesDsc.end(); ++iter){
1466                                 wxListItem ItemData;
1467                         
1468                                 ItemData.SetId(0);
1469                                 ItemData.SetText(iter->first);
1471                                 lboGroups->InsertItem(ItemData);
1473                         }
1475                 }
1476         
1477         }
1478         
1481 void frmContactEditor::LoadAddress(std::map<int, wxString> *GeneralAddressList,
1482         std::map<int, wxString> *GeneralAddressListTown,
1483         std::map<int, wxString> *GeneralAddressListCounty,
1484         std::map<int, wxString> *GeneralAddressListPostCode,
1485         std::map<int, int> *GeneralAddressListPref,
1486         std::map<int, wxString> *HomeAddressList,
1487         std::map<int, wxString> *HomeAddressListTown,
1488         std::map<int, wxString> *HomeAddressListCounty,
1489         std::map<int, wxString> *HomeAddressListPostCode,
1490         std::map<int, int> *HomeAddressListPref,
1491         std::map<int, wxString> *BusinessAddressList,
1492         std::map<int, wxString> *BusinessAddressListTown,
1493         std::map<int, wxString> *BusinessAddressListCounty,
1494         std::map<int, wxString> *BusinessAddressListPostCode,
1495         std::map<int, int> *BusinessAddressListPref, 
1496         int *AddressCount){
1498         // Load address.
1499                 
1500         long ListCtrlIndex = -1;
1502         // Deal with the general addresses.
1503         
1504         for (std::map<int,wxString>::iterator Iter = GeneralAddressList->begin();
1505                 Iter != GeneralAddressList->end();
1506                 Iter++){
1507         
1508                 wxListItem coldata;
1510                 coldata.SetId(*AddressCount);
1511                 coldata.SetData(*AddressCount);
1512                 coldata.SetText(Iter->second);
1513                 
1514                 ListCtrlIndex = lboAddresses->InsertItem(coldata);
1515                 
1516                 if (MapDataExists(AddressCount, GeneralAddressListTown)){
1517                 
1518                         lboAddresses->SetItem(ListCtrlIndex, 1, GeneralAddressListTown->find(*AddressCount)->second);
1519                 
1520                 }
1522                 if (MapDataExists(AddressCount, GeneralAddressListCounty)){
1523                 
1524                         lboAddresses->SetItem(ListCtrlIndex, 2, GeneralAddressListCounty->find(*AddressCount)->second);
1525                 
1526                 }
1527                 
1528                 if (MapDataExists(AddressCount, GeneralAddressListPostCode)){
1529                 
1530                         lboAddresses->SetItem(ListCtrlIndex, 3, GeneralAddressListPostCode->find(*AddressCount)->second);
1531                 
1532                 }
1533                 
1534                 if (MapDataExists(AddressCount, GeneralAddressListPref)){
1535                 
1536                         lboAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", GeneralAddressListPref->find(*AddressCount)->second));
1537                 
1538                 }
1539         
1540                 (*AddressCount)++;
1541         
1542         }
1543         
1544         // Deal with the home addresses.
1545         
1546         for (std::map<int,wxString>::iterator Iter = HomeAddressList->begin();
1547                 Iter != HomeAddressList->end();
1548                 Iter++){
1549         
1550                 wxListItem coldata;
1552                 coldata.SetId(*AddressCount);
1553                 coldata.SetData(*AddressCount);
1554                 coldata.SetText(Iter->second);
1555                 
1556                 ListCtrlIndex = lboHomeAddresses->InsertItem(coldata);
1557                 
1558                 if (MapDataExists(AddressCount, HomeAddressListTown)){
1559                 
1560                         lboHomeAddresses->SetItem(ListCtrlIndex, 1, HomeAddressListTown->find(*AddressCount)->second);
1561                 
1562                 }
1564                 if (MapDataExists(AddressCount, HomeAddressListCounty)){
1565                 
1566                         lboHomeAddresses->SetItem(ListCtrlIndex, 2, HomeAddressListCounty->find(*AddressCount)->second);
1567                 
1568                 }
1569                 
1570                 if (MapDataExists(AddressCount, HomeAddressListPostCode)){
1571                 
1572                         lboHomeAddresses->SetItem(ListCtrlIndex, 3, HomeAddressListPostCode->find(*AddressCount)->second);
1573                 
1574                 }
1575                 
1576                 if (MapDataExists(AddressCount, HomeAddressListPref)){
1577                 
1578                         lboHomeAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", HomeAddressListPref->find(*AddressCount)->second));
1579                 
1580                 }
1581         
1582                 (*AddressCount)++;
1583         
1584         }
1585         
1586         // Deal with the work addresses.
1587         
1588         for (std::map<int,wxString>::iterator Iter = BusinessAddressList->begin();
1589                 Iter != BusinessAddressList->end();
1590                 Iter++){
1591         
1592                 wxListItem coldata;
1594                 coldata.SetId(*AddressCount);
1595                 coldata.SetData(*AddressCount);
1596                 coldata.SetText(Iter->second);
1597                 
1598                 ListCtrlIndex = lboBusinessAddresses->InsertItem(coldata);
1599                 
1600                 if (MapDataExists(AddressCount, BusinessAddressListTown)){
1601                 
1602                         lboBusinessAddresses->SetItem(ListCtrlIndex, 1, BusinessAddressListTown->find(*AddressCount)->second);
1603                 
1604                 }
1606                 if (MapDataExists(AddressCount, BusinessAddressListCounty)){
1607                 
1608                         lboBusinessAddresses->SetItem(ListCtrlIndex, 2, BusinessAddressListCounty->find(*AddressCount)->second);
1609                 
1610                 }
1611                 
1612                 if (MapDataExists(AddressCount, BusinessAddressListPostCode)){
1613                 
1614                         lboBusinessAddresses->SetItem(ListCtrlIndex, 3, BusinessAddressListPostCode->find(*AddressCount)->second);
1615                 
1616                 }
1617                 
1618                 if (MapDataExists(AddressCount, BusinessAddressListPref)){
1619                 
1620                         lboBusinessAddresses->SetItem(ListCtrlIndex, 4, wxString::Format("%i", BusinessAddressListPref->find(*AddressCount)->second));
1621                 
1622                 }
1623         
1624                 (*AddressCount)++;
1625         
1626         }
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