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).
41 XABViewMode XVMData = MainPtr->GetViewMode();
43 wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE);
45 //wxString vcardfilenamewxs;
46 wxString vCardFilename;
47 wxString vCardFilenameFull;
48 wxString vCardDataString;
49 //wxStringTokenizer vcardfileline;
51 wxString setname, setvalue;
52 //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
53 std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
54 std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
56 wxDir vcardaccdir(AccountDirFinal);
58 bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
61 if (vCardFilename.Right(4) == wxT(".vcf") ||
62 vCardFilename.Right(4) == wxT(".VCF") ||
63 vCardFilename.Right(5) == wxT(".vcard") ||
64 vCardFilename.Right(5) == wxT(".VCARD")){
68 vCardFilenameFull.Append(AccountDirFinal);
69 vCardFilenameFull.Append(wxT("/"));
70 vCardFilenameFull.Append(vCardFilename);
72 Person.LoadFile(vCardFilenameFull);
74 if (MemberData.Left(9) == wxT("urn:uuid:")){
76 wxString NewPropValue;
77 NewPropValue = MemberData.Mid(9, wxString::npos);
78 MemberData = NewPropValue;
82 if (Person.MeetBaseSpecification()){
84 wxString KindStatus = Person.Get(wxT("KIND"));
86 if (KindStatus == wxT("group")){
88 vCardFilename.Clear();
89 vCardFilenameFull.Clear();
90 vCardDataString.Clear();
91 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
96 wxString PersonName = Person.Get(wxT("N"));
97 wxString PersonUID = Person.Get(wxT("UID"));
98 wxString PersonFilename = vCardFilenameFull;
100 if (PersonUID != MemberData){
102 vCardFilename.Clear();
103 vCardFilenameFull.Clear();
104 vCardDataString.Clear();
105 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
110 //ContactsNames.insert(std::make_pair(PersonName, ContactIndex));
111 //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID));
113 if (XVMData.SortMode == 1){
115 // Split the name into sections.
117 vCardDataString = Person.Get(wxT("N"));
119 vCardName NameData = Person.GetName();
121 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
123 } else if (XVMData.SortMode == 2){
125 // Split the name into sections.
127 vCardName NameData = Person.GetName();
129 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
131 } else if (XVMData.SortMode == 3){
133 // Check and make sure that the top most nickname is used.
135 vCardDataString = Person.Get(wxT("NICKNAME"));
137 if (vCardDataString.IsEmpty()){
139 vCardDataString = wxT("(no nickname)");
143 } else if (XVMData.SortMode == 4){
145 vCardDataString = Person.Get(wxT("FN"));
149 if (XVMData.AscendingMode == TRUE){
150 vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID));
152 vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID));
163 vCardFilename.Clear();
164 vCardFilenameFull.Clear();
165 vCardDataString.Clear();
166 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
170 if (XVMData.AscendingMode == TRUE){
172 for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin();
173 iter != vCardNamesAsc.end(); ++iter){
178 ItemData.SetText(iter->first);
180 lboGroups->InsertItem(ItemData);
182 GroupsList.insert(std::make_pair(intValueSeek, iter->second));
189 for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin();
190 iter != vCardNamesDsc.end(); ++iter){
195 ItemData.SetText(iter->first);
197 lboGroups->InsertItem(ItemData);
199 GroupsList.insert(std::make_pair(intValueSeek, iter->second));