Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
If StartupMode is true, ignore doing any MemoryFS clean ups.
[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 (StartupMode == false){
54         
55                 if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){
57                 } else {
59                         std::map<wxString, wxString>::iterator striter;
61                         for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){
63                                 if (SessionID == striter->second){
65                                         // Delete the references from the wxMemoryFSHandler
66                                         // and the entry from the map.
68                                         wxMemoryFSHandler::RemoveFile(striter->first);
70                                         break;
72                                 }
74                         }
76                         MemoryFSListPtr->erase(striter);
78                 }
79         
80                 WindowData *WData = new WindowData;
82                 WData->DataType = 0;
83                 WData->WindowPointer = this;
84                 WData->WindowID = ContactUID;
86                 wxCommandEvent delevent(WINDOW_CLOSE);
87                 delevent.SetClientData(WData);
88                 wxPostEvent(GetParent(), delevent);
89         
90         }
91                 
92         Destroy();
94 }
96 bool frmContact::SetupContactData(vCard *vCardObj){
98         wxFileSystem::AddHandler(new wxMemoryFSHandler);
99         
100         for (std::map<wxString, wxString>::iterator striter = MemoryFSListPtr->begin();
101         striter != MemoryFSListPtr->end(); striter++){
103                 if (SessionID == striter->second){
105                         // Delete the references from the wxMemoryFSHandler
106                         // and the entry from the map.
108                         wxMemoryFSHandler::RemoveFile(striter->first);
109                         MemoryFSListPtr->erase(striter);
111                 }
113         }
115         OldSessionID = SessionID;
116         SessionID = wxString::Format(wxT("%i"), rand() % 32768);
117         LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr);
118         ArrayvCardOutData FNList;
119         FNList = vCardObj->GetByPartial(wxT("FN"));
120         
121         if (FNList.PropCount > 0){
122                 FNList.PropValues[0].Trim();
123                 SetTitle(FNList.PropValues[0]);
124         }
125         
126         if (StartupMode == false){
127         
128                 WindowData *WData = new WindowData;
130                 vCardFilename = vCardObj->GetFilename();
132                 WData->DataType = 0;
133                 WData->WindowPointer = this;
134                 WData->WindowID = ContactUID;
135         
136                 wxCommandEvent editevent(WINDOW_EDIT);
137                 editevent.SetClientData(WData);
138                 wxPostEvent(GetParent(), editevent);
139                 
140         }
142         return TRUE;
145 void frmContact::SetMode(bool StartupModeIn){
147         StartupMode = StartupModeIn;
148         
151 void frmContact::SetupPointers(std::map<wxString,wxString> *MemoryFSListIncPtr){
153         MemoryFSListPtr = MemoryFSListIncPtr;
157 void frmContact::SetUID(int UID){
159         ContactUID = UID;
163 wxString frmContact::GetFilename(){
165         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