Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Updated commands needed for building the unit testing application.
[xestiaab/.git] / source / frmContact.cpp
1 // frmContact.cpp - Contact information form.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContact.h"
20 #include "common/getcontactinfo.h"
21 #include "frmMain.h"
22 #include <wx/fs_mem.h>
23 #include <wx/filesys.h>
24 #include <wx/app.h>
26 BEGIN_EVENT_TABLE(frmContact, wxFrame)
27 END_EVENT_TABLE()
29 frmContact::frmContact( wxWindow* parent )
30 :
31 frmContactADT( parent )
32 {
34 }
36 void frmContact::CloseWindowProcessing(){
38 }
40 void frmContact::CloseWindow( wxCommandEvent& event ){
41                 
42         this->Close();
44 }
46 void frmContact::CloseWindow( wxCloseEvent& event ){
48         // Off for peppermint tea. Better clean up first or
49         // we'll be in for it later.
51         wxFileSystem::AddHandler(new wxMemoryFSHandler);
53         if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){
55         } else {
57                 std::map<wxString, wxString>::iterator striter;
59                 for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){
61                         if (SessionID == striter->second){
63                                 // Delete the references from the wxMemoryFSHandler
64                                 // and the entry from the map.
66                                 wxMemoryFSHandler::RemoveFile(striter->first);
68                                 break;
70                         }
72                 }
74                 MemoryFSListPtr->erase(striter);
76         }
77         
78         WindowData *WData = new WindowData;
80         WData->DataType = 0;
81         WData->WindowPointer = this;
82         WData->WindowID = ContactUID;
84         wxCommandEvent delevent(WINDOW_CLOSE);
85         delevent.SetClientData(WData);
86         wxPostEvent(GetParent(), delevent);
87         
88         Destroy();
90 }
94 bool frmContact::SetupContactData(vCard *vCardObj){
96         wxFileSystem::AddHandler(new wxMemoryFSHandler);
97         
98         for (std::map<wxString, wxString>::iterator striter = MemoryFSListPtr->begin();
99         striter != MemoryFSListPtr->end(); striter++){
101                 if (SessionID == striter->second){
103                         // Delete the references from the wxMemoryFSHandler
104                         // and the entry from the map.
106                         wxMemoryFSHandler::RemoveFile(striter->first);
107                         MemoryFSListPtr->erase(striter);
109                 }
111         }
113         OldSessionID = SessionID;
114         SessionID = wxString::Format(wxT("%i"), rand() % 32768);
115         LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr);
116         SetTitle(vCardObj->Get(wxT("FN")));
118         WindowData *WData = new WindowData;
120         vCardFilename = vCardObj->GetFilename();
122         WData->DataType = 0;
123         WData->WindowPointer = this;
124         WData->WindowID = ContactUID;
126         wxCommandEvent editevent(WINDOW_EDIT);
127         editevent.SetClientData(WData);
128         wxPostEvent(GetParent(), editevent);
130         return TRUE;
133 void frmContact::SetupPointers(std::map<wxString,wxString> *MemoryFSListIncPtr){
135         MemoryFSListPtr = MemoryFSListIncPtr;
139 void frmContact::SetUID(int UID){
141         ContactUID = UID;
145 wxString frmContact::GetFilename(){
147         return vCardFilename;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy