1 #include "frmContactEditor.h"
2 #include "../common/dirs.h"
5 void frmContactEditor::LoadKind(wxString KindType){
7 if (KindType == wxT("individual")){
9 cmbType->SetSelection(1);
11 } else if (KindType == wxT("group")){
13 cmbType->SetSelection(2);
16 } else if (KindType == wxT("org")){
18 cmbType->SetSelection(3);
20 } else if (KindType == wxT("location")){
22 cmbType->SetSelection(4);
26 cmbType->SetSelection(0);
30 wxCommandEvent nullevent;
32 UpdateMembersTab(nullevent);
36 void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
38 // Go through the list of contacts for the account and find the matching UID.
39 // If contact with UID doesn't match then say (unknown contact).
42 if (StartupEditMode == FALSE){
43 XVMData = MainPtr->GetViewMode();
46 wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
48 //wxString vcardfilenamewxs;
49 wxString vCardFilename;
50 wxString vCardFilenameFull;
51 wxString vCardDataString;
52 //wxStringTokenizer vcardfileline;
54 wxString setname, setvalue;
55 //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
56 std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
57 std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
59 wxDir vcardaccdir(AccountDirFinal);
61 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
64 if (vCardFilename.Right(4) == wxT(".vcf") ||
65 vCardFilename.Right(4) == wxT(".VCF") ||
66 vCardFilename.Right(5) == wxT(".vcard") ||
67 vCardFilename.Right(5) == wxT(".VCARD")){
71 vCardFilenameFull.Append(AccountDirFinal);
72 vCardFilenameFull.Append(wxT("/"));
73 vCardFilenameFull.Append(vCardFilename);
75 Person.LoadFile(vCardFilenameFull);
77 if (MemberData.Left(9) == wxT("urn:uuid:")){
79 wxString NewPropValue;
80 NewPropValue = MemberData.Mid(9, wxString::npos);
81 MemberData = NewPropValue;
85 if (Person.MeetBaseSpecification()){
87 wxString KindStatus = Person.Get(wxT("KIND"));
89 if (KindStatus == wxT("group")){
91 vCardFilename.Clear();
92 vCardFilenameFull.Clear();
93 vCardDataString.Clear();
94 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
99 wxString PersonName = Person.Get(wxT("N"));
100 wxString PersonUID = Person.Get(wxT("UID"));
101 wxString PersonFilename = vCardFilenameFull;
103 if (PersonUID != MemberData){
105 vCardFilename.Clear();
106 vCardFilenameFull.Clear();
107 vCardDataString.Clear();
108 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
113 //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
114 //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
116 if (XVMData.SortMode == 1){
118 // Split the name into sections.
120 vCardDataString = Person.Get(wxT("N"));
122 vCardName NameData = Person.GetName();
124 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
126 } else if (XVMData.SortMode == 2){
128 // Split the name into sections.
130 vCardName NameData = Person.GetName();
132 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
134 } else if (XVMData.SortMode == 3){
136 // Check and make sure that the top most nickname is used.
138 vCardDataString = Person.Get(wxT("NICKNAME"));
140 if (vCardDataString.IsEmpty()){
142 vCardDataString = wxT("(no nickname)");
146 } else if (XVMData.SortMode == 4){
148 vCardDataString = Person.Get(wxT("FN"));
152 if (XVMData.AscendingMode == TRUE){
153 vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
155 vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
166 vCardFilename.Clear();
167 vCardFilenameFull.Clear();
168 vCardDataString.Clear();
169 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
173 if (XVMData.AscendingMode == TRUE){
175 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin();
176 iter != vCardNamesAsc.end(); ++iter){
181 ItemData.SetText(iter->first);
183 lboGroups->InsertItem(ItemData);
185 GroupsList.insert(std::make_pair(intValueSeek, iter->second));
192 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin();
193 iter != vCardNamesDsc.end(); ++iter){
198 ItemData.SetText(iter->first);
200 lboGroups->InsertItem(ItemData);
202 GroupsList.insert(std::make_pair(intValueSeek, iter->second));