// frmContact.cpp - Contact information form.
//
// (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 "frmContact.h"
#include "common/getcontactinfo.h"
#include "frmMain.h"
#include
#include
#include
BEGIN_EVENT_TABLE(frmContact, wxFrame)
END_EVENT_TABLE()
frmContact::frmContact( wxWindow* parent )
:
frmContactADT( parent )
{
}
void frmContact::CloseWindowProcessing(){
}
void frmContact::CloseWindow( wxCommandEvent& event ){
this->Close();
}
void frmContact::CloseWindow( wxCloseEvent& event ){
// Off for peppermint tea. Better clean up first or
// we'll be in for it later.
wxFileSystem::AddHandler(new wxMemoryFSHandler);
if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){
} else {
std::map::iterator striter;
for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){
if (SessionID == striter->second){
// Delete the references from the wxMemoryFSHandler
// and the entry from the map.
wxMemoryFSHandler::RemoveFile(striter->first);
break;
}
}
MemoryFSListPtr->erase(striter);
}
WindowData *WData = new WindowData;
WData->DataType = 0;
WData->WindowPointer = this;
WData->WindowID = ContactUID;
wxCommandEvent delevent(WINDOW_CLOSE);
delevent.SetClientData(WData);
wxPostEvent(GetParent(), delevent);
Destroy();
}
bool frmContact::SetupContactData(vCard *vCardObj){
wxFileSystem::AddHandler(new wxMemoryFSHandler);
for (std::map::iterator striter = MemoryFSListPtr->begin();
striter != MemoryFSListPtr->end(); striter++){
if (SessionID == striter->second){
// Delete the references from the wxMemoryFSHandler
// and the entry from the map.
wxMemoryFSHandler::RemoveFile(striter->first);
MemoryFSListPtr->erase(striter);
}
}
OldSessionID = SessionID;
SessionID = wxString::Format(wxT("%i"), rand() % 32768);
LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr);
SetTitle(vCardObj->Get(wxT("FN")));
WindowData *WData = new WindowData;
vCardFilename = vCardObj->GetFilename();
WData->DataType = 0;
WData->WindowPointer = this;
WData->WindowID = ContactUID;
wxCommandEvent editevent(WINDOW_EDIT);
editevent.SetClientData(WData);
wxPostEvent(GetParent(), editevent);
return TRUE;
}
void frmContact::SetupPointers(std::map *MemoryFSListIncPtr){
MemoryFSListPtr = MemoryFSListIncPtr;
}
void frmContact::SetUID(int UID){
ContactUID = UID;
}
wxString frmContact::GetFilename(){
return vCardFilename;
}