// frmContactEditor-LoadGroup.cpp - frmContactEditor load group subroutines. // // (c) 2012-2015 Xestia Software Development. // // This file is part of Xestia Address Book. // // Xestia Address Book is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, version 3 of the license. // // Xestia Address Book is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with Xestia Address Book. If not, see #include "frmContactEditor.h" #include "../common/dirs.h" #include void frmContactEditor::LoadKind(wxString KindType){ if (KindType == wxT("individual")){ cmbType->SetSelection(1); } else if (KindType == wxT("group")){ cmbType->SetSelection(2); IsGroup = TRUE; } else if (KindType == wxT("org")){ cmbType->SetSelection(3); } else if (KindType == wxT("location")){ cmbType->SetSelection(4); } else { cmbType->SetSelection(0); } wxCommandEvent nullevent; UpdateMembersTab(nullevent); } void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){ // Go through the list of contacts for the account and find the matching UID. // If contact with UID doesn't match then say (unknown contact). XABViewMode XVMData; if (StartupEditMode == FALSE){ XVMData = MainPtr->GetViewMode(); } wxString AccountDirFinal = GetAccountDir(wxSContactAccount, FALSE); //wxString vcardfilenamewxs; wxString vCardFilename; wxString vCardFilenameFull; wxString vCardDataString; //wxStringTokenizer vcardfileline; wxString lwxs; wxString setname, setvalue; //vCardNames = new std::map>; std::multimap> vCardNamesAsc; std::multimap> vCardNamesDsc; wxDir vcardaccdir(AccountDirFinal); bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES); while(ProcFiles){ if (vCardFilename.Right(4) == wxT(".vcf") || vCardFilename.Right(4) == wxT(".VCF") || vCardFilename.Right(5) == wxT(".vcard") || vCardFilename.Right(5) == wxT(".VCARD")){ vCard Person; vCardFilenameFull.Append(AccountDirFinal); vCardFilenameFull.Append(wxT("/")); vCardFilenameFull.Append(vCardFilename); Person.LoadFile(vCardFilenameFull); if (MemberData.Left(9) == wxT("urn:uuid:")){ wxString NewPropValue; NewPropValue = MemberData.Mid(9, wxString::npos); MemberData = NewPropValue; } if (Person.MeetBaseSpecification()){ wxString KindStatus = Person.Get(wxT("KIND")); if (KindStatus == wxT("group")){ vCardFilename.Clear(); vCardFilenameFull.Clear(); vCardDataString.Clear(); ProcFiles = vcardaccdir.GetNext(&vCardFilename); continue; } wxString PersonName = Person.Get(wxT("N")); wxString PersonUID = Person.Get(wxT("UID")); wxString PersonFilename = vCardFilenameFull; if (PersonUID != MemberData){ vCardFilename.Clear(); vCardFilenameFull.Clear(); vCardDataString.Clear(); ProcFiles = vcardaccdir.GetNext(&vCardFilename); continue; } //ContactsNames.insert(std::make_pair(PersonName, ContactIndex)); //ContactsUIDs.insert(std::make_pair(ContactIndex, PersonUID)); if (XVMData.SortMode == 1){ // Split the name into sections. vCardDataString = Person.Get(wxT("N")); vCardName NameData = Person.GetName(); vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname; } else if (XVMData.SortMode == 2){ // Split the name into sections. vCardName NameData = Person.GetName(); vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename; } else if (XVMData.SortMode == 3){ // Check and make sure that the top most nickname is used. vCardDataString = Person.Get(wxT("NICKNAME")); if (vCardDataString.IsEmpty()){ vCardDataString = wxT("(no nickname)"); } } else if (XVMData.SortMode == 4){ vCardDataString = Person.Get(wxT("FN")); } if (XVMData.AscendingMode == TRUE){ vCardNamesAsc.insert(std::make_pair(vCardDataString, PersonUID)); } else { vCardNamesDsc.insert(std::make_pair(vCardDataString, PersonUID)); } } else { } } vCardFilename.Clear(); vCardFilenameFull.Clear(); vCardDataString.Clear(); ProcFiles = vcardaccdir.GetNext(&vCardFilename); } if (XVMData.AscendingMode == TRUE){ for (std::map::iterator iter = vCardNamesAsc.begin(); iter != vCardNamesAsc.end(); ++iter){ wxListItem ItemData; ItemData.SetId(0); ItemData.SetText(iter->first); lboGroups->InsertItem(ItemData); GroupsList.insert(std::make_pair(intValueSeek, iter->second)); } } else { for (std::map::iterator iter = vCardNamesDsc.begin(); iter != vCardNamesDsc.end(); ++iter){ wxListItem ItemData; ItemData.SetId(0); ItemData.SetText(iter->first); lboGroups->InsertItem(ItemData); GroupsList.insert(std::make_pair(intValueSeek, iter->second)); } } GroupCount++; intValueSeek++; }