Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditorNickname/Notes: Use list of ISO 639-1 languages
[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         // Close this window.
43         
44         this->Close();
46 }
48 void frmContact::CloseWindow( wxCloseEvent& event ){
50         // Off for peppermint tea. Better clean up first or
51         // we'll be in for it later.
53         wxFileSystem::AddHandler(new wxMemoryFSHandler);
55         // Check if frmContact is the main window, if not
56         // then do some clear up.
57         
58         if (StartupMode == false){
59         
60                 if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){
62                 } else {
64                         std::map<wxString, wxString>::iterator striter;
66                         for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){
68                                 if (SessionID == striter->second){
70                                         // Delete the references from the wxMemoryFSHandler
71                                         // and the entry from the map.
73                                         wxMemoryFSHandler::RemoveFile(striter->first);
75                                         break;
77                                 }
79                         }
81                         MemoryFSListPtr->erase(striter);
83                 }
84         
85                 WindowData *WData = new WindowData;
87                 WData->DataType = 0;
88                 WData->WindowPointer = this;
89                 WData->WindowID = ContactUID;
91                 wxCommandEvent delevent(WINDOW_CLOSE);
92                 delevent.SetClientData(WData);
93                 wxPostEvent(GetParent(), delevent);
94         
95         }
96                 
97         Destroy();
99 }
101 bool frmContact::SetupContactData(vCard *vCardObj){
103         // Setup the contact information.
104         
105         wxFileSystem::AddHandler(new wxMemoryFSHandler);
106         
107         for (std::map<wxString, wxString>::iterator striter = MemoryFSListPtr->begin();
108         striter != MemoryFSListPtr->end(); striter++){
110                 if (SessionID == striter->second){
112                         // Delete the references from the wxMemoryFSHandler
113                         // and the entry from the map.
115                         wxMemoryFSHandler::RemoveFile(striter->first);
116                         MemoryFSListPtr->erase(striter);
118                 }
120         }
122         OldSessionID = SessionID;
123         SessionID = wxString::Format(wxT("%i"), rand() % 32768);
124         LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr);
125         ArrayvCardOutData FNList;
126         FNList = vCardObj->GetByPartial(wxT("FN"));
127         
128         if (FNList.PropCount > 0){
129                 FNList.PropValues[0].Trim();
130                 SetTitle(FNList.PropValues[0]);
131         }
132         
133         if (StartupMode == false){
134         
135                 WindowData *WData = new WindowData;
137                 vCardFilename = vCardObj->GetFilename();
139                 WData->DataType = 0;
140                 WData->WindowPointer = this;
141                 WData->WindowID = ContactUID;
142         
143                 wxCommandEvent editevent(WINDOW_EDIT);
144                 editevent.SetClientData(WData);
145                 wxPostEvent(GetParent(), editevent);
146                 
147         }
149         return TRUE;
152 void frmContact::SetMode(bool StartupModeIn){
154         // Set the mode which frmContact will be operating.
155         
156         StartupMode = StartupModeIn;
157         
160 void frmContact::SetupPointers(std::map<wxString,wxString> *MemoryFSListIncPtr){
162         // Set the pointer for the Memory Filesystem map.
163         
164         MemoryFSListPtr = MemoryFSListIncPtr;
168 void frmContact::SetUID(int UID){
170         // Set the UID of the contact window.
171         
172         ContactUID = UID;
176 wxString frmContact::GetFilename(){
178         // Get the filename of the contact being displayed.
179         
180         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