1 #include "frmContact.h"
2 #include "common/getcontactinfo.h"
5 #include <wx/filesys.h>
8 BEGIN_EVENT_TABLE(frmContact, wxFrame)
11 frmContact::frmContact( wxWindow* parent )
13 frmContactADT( parent )
18 void frmContact::CloseWindowProcessing(){
22 void frmContact::CloseWindow( wxCommandEvent& event ){
28 void frmContact::CloseWindow( wxCloseEvent& event ){
30 // Off for peppermint tea. Better clean up first or
31 // we'll be in for it later.
33 wxFileSystem::AddHandler(new wxMemoryFSHandler);
35 if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){
39 std::map<wxString, wxString>::iterator striter;
41 for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){
43 if (SessionID == striter->second){
45 // Delete the references from the wxMemoryFSHandler
46 // and the entry from the map.
48 wxMemoryFSHandler::RemoveFile(striter->first);
56 MemoryFSListPtr->erase(striter);
60 WindowData *WData = new WindowData;
63 WData->WindowPointer = this;
64 WData->WindowID = ContactUID;
66 wxCommandEvent delevent(WINDOW_CLOSE);
67 delevent.SetClientData(WData);
68 wxPostEvent(GetParent(), delevent);
76 bool frmContact::SetupContactData(vCard *vCardObj){
78 wxFileSystem::AddHandler(new wxMemoryFSHandler);
80 for (std::map<wxString, wxString>::iterator striter = MemoryFSListPtr->begin();
81 striter != MemoryFSListPtr->end(); striter++){
83 if (SessionID == striter->second){
85 // Delete the references from the wxMemoryFSHandler
86 // and the entry from the map.
88 wxMemoryFSHandler::RemoveFile(striter->first);
89 MemoryFSListPtr->erase(striter);
95 OldSessionID = SessionID;
96 SessionID = wxString::Format(wxT("%i"), rand() % 32768);
97 LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr);
98 SetTitle(vCardObj->Get(wxT("FN")));
100 WindowData *WData = new WindowData;
102 vCardFilename = vCardObj->GetFilename();
105 WData->WindowPointer = this;
106 WData->WindowID = ContactUID;
108 wxCommandEvent editevent(WINDOW_EDIT);
109 editevent.SetClientData(WData);
110 wxPostEvent(GetParent(), editevent);
115 void frmContact::SetupPointers(std::map<wxString,wxString> *MemoryFSListIncPtr){
117 MemoryFSListPtr = MemoryFSListIncPtr;
121 void frmContact::SetUID(int UID){
127 wxString frmContact::GetFilename(){
129 return vCardFilename;