X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2FfrmContact.cpp;h=5df872893dd1841c8a9cae9f963a656eb5a8d694;hb=cb31afce9cc7f778ed1519c8d3b17cce6f7bc1a3;hp=5d9eeae00c65c34065b046fbdd018373192cd152;hpb=45729fca56479bd9158486e0cda0c4a94b4dd1dc;p=xestiaab%2F.git diff --git a/source/frmContact.cpp b/source/frmContact.cpp index 5d9eeae..5df8728 100644 --- a/source/frmContact.cpp +++ b/source/frmContact.cpp @@ -1,3 +1,21 @@ +// 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" @@ -21,6 +39,8 @@ void frmContact::CloseWindowProcessing(){ void frmContact::CloseWindow( wxCommandEvent& event ){ + // Close this window. + this->Close(); } @@ -32,49 +52,56 @@ void frmContact::CloseWindow( wxCloseEvent& event ){ wxFileSystem::AddHandler(new wxMemoryFSHandler); - if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){ + // Check if frmContact is the main window, if not + // then do some clear up. + + if (StartupMode == false){ + + if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){ + + } else { - } else { + std::map::iterator striter; - std::map::iterator striter; + for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){ - for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){ + if (SessionID == striter->second){ - if (SessionID == striter->second){ + // Delete the references from the wxMemoryFSHandler + // and the entry from the map. - // Delete the references from the wxMemoryFSHandler - // and the entry from the map. + wxMemoryFSHandler::RemoveFile(striter->first); - wxMemoryFSHandler::RemoveFile(striter->first); + break; - break; + } } - } - - MemoryFSListPtr->erase(striter); + MemoryFSListPtr->erase(striter); - } + } - WindowData *WData = new WindowData; + WindowData *WData = new WindowData; - WData->DataType = 0; - WData->WindowPointer = this; - WData->WindowID = ContactUID; + WData->DataType = 0; + WData->WindowPointer = this; + WData->WindowID = ContactUID; - wxCommandEvent delevent(WINDOW_CLOSE); - delevent.SetClientData(WData); - wxPostEvent(GetParent(), delevent); + wxCommandEvent delevent(WINDOW_CLOSE); + delevent.SetClientData(WData); + wxPostEvent(GetParent(), delevent); + } + Destroy(); } - - bool frmContact::SetupContactData(vCard *vCardObj){ + // Setup the contact information. + wxFileSystem::AddHandler(new wxMemoryFSHandler); for (std::map::iterator striter = MemoryFSListPtr->begin(); @@ -95,37 +122,61 @@ bool frmContact::SetupContactData(vCard *vCardObj){ OldSessionID = SessionID; SessionID = wxString::Format(wxT("%i"), rand() % 32768); LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr); - SetTitle(vCardObj->Get(wxT("FN"))); + ArrayvCardOutData FNList; + FNList = vCardObj->GetByPartial(wxT("FN")); + + if (FNList.PropCount > 0){ + FNList.PropValues[0].Trim(); + SetTitle(FNList.PropValues[0]); + } + + if (StartupMode == false){ + + WindowData *WData = new WindowData; - WindowData *WData = new WindowData; + vCardFilename = vCardObj->GetFilename(); - vCardFilename = vCardObj->GetFilename(); + WData->DataType = 0; + WData->WindowPointer = this; + WData->WindowID = ContactUID; + + wxCommandEvent editevent(WINDOW_EDIT); + editevent.SetClientData(WData); + wxPostEvent(GetParent(), editevent); + + } - WData->DataType = 0; - WData->WindowPointer = this; - WData->WindowID = ContactUID; + return TRUE; +} - wxCommandEvent editevent(WINDOW_EDIT); - editevent.SetClientData(WData); - wxPostEvent(GetParent(), editevent); +void frmContact::SetMode(bool StartupModeIn){ - return TRUE; + // Set the mode which frmContact will be operating. + + StartupMode = StartupModeIn; + } void frmContact::SetupPointers(std::map *MemoryFSListIncPtr){ + // Set the pointer for the Memory Filesystem map. + MemoryFSListPtr = MemoryFSListIncPtr; } void frmContact::SetUID(int UID){ + // Set the UID of the contact window. + ContactUID = UID; } wxString frmContact::GetFilename(){ + // Get the filename of the contact being displayed. + return vCardFilename; } \ No newline at end of file