+// 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 <http://www.gnu.org/licenses/>
+
#include "frmContactEditor.h"
#include "../common/dirs.h"
#include <wx/dir.h>
+void frmContactEditor::LoadKind(ContactKindType *KindType){
+
+ switch (*KindType){
+ case CONTACTKIND_INDIVIDUAL:
+ cmbType->SetSelection(1);
+ break;
+ case CONTACTKIND_GROUP:
+ cmbType->SetSelection(2);
+ break;
+ case CONTACTKIND_ORGANISATION:
+ cmbType->SetSelection(3);
+ break;
+ case CONTACTKIND_LOCATION:
+ cmbType->SetSelection(4);
+ break;
+ case CONTACTKIND_NONE:
+ cmbType->SetSelection(0);
+ break;
+ }
+
+ wxCommandEvent nullevent;
+
+ UpdateMembersTab(nullevent);
+
+}
+
void frmContactEditor::LoadKind(wxString KindType){
if (KindType == wxT("individual")){
}
+void frmContactEditor::LoadMember(std::map<int,wxString> *GroupList){
+
+ // 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;
+ wxString MemberData;
+ bool FoundContact = FALSE;
+ //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
+ std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
+ std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
+
+ wxDir vcardaccdir(AccountDirFinal);
+
+ for (std::map<int,wxString>::iterator MemberIter = GroupList->begin();
+ MemberIter != GroupList->end();
+ MemberIter++){
+
+ MemberData = MemberIter->second;
+
+ 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;
+
+ } else {
+ FoundContact = TRUE;
+ }
+
+ //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 (FoundContact == FALSE){
+ if (XVMData.AscendingMode == TRUE){
+ vCardNamesAsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
+ } else {
+ vCardNamesDsc.insert(std::make_pair(MemberIter->second, MemberIter->second));
+ }
+ }
+
+ if (XVMData.AscendingMode == TRUE){
+
+ for (std::map<wxString,wxString>::iterator iter = vCardNamesAsc.begin();
+ iter != vCardNamesAsc.end(); ++iter){
+
+ wxListItem ItemData;
+
+ ItemData.SetId(0);
+ ItemData.SetText(iter->first);
+
+ lboGroups->InsertItem(ItemData);
+
+ }
+
+
+ } else {
+
+ for (std::map<wxString,wxString>::iterator iter = vCardNamesDsc.begin();
+ iter != vCardNamesDsc.end(); ++iter){
+
+ wxListItem ItemData;
+
+ ItemData.SetId(0);
+ ItemData.SetText(iter->first);
+
+ lboGroups->InsertItem(ItemData);
+
+ }
+
+ }
+
+ }
+
+}
+
void frmContactEditor::LoadMember(wxString MemberData, int *GroupCount){
// Go through the list of contacts for the account and find the matching UID.
GroupsList.insert(std::make_pair(intValueSeek, iter->second));
- }
-
}
+
+ }
GroupCount++;
intValueSeek++;