X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2FfrmMain.cpp;h=155d500ddbcf0e0f81defdf8e4db91d7c280db59;hb=4ea07d6964c0f73c858e83513e14a28000054256;hp=8e6ec600739a0d9c73d3e87193d754e39ba4f981;hpb=b6cfc76dade74fbf1b72d53701638b85ce8a121e;p=xestiaab%2F.git
diff --git a/source/frmMain.cpp b/source/frmMain.cpp
index 8e6ec60..155d500 100644
--- a/source/frmMain.cpp
+++ b/source/frmMain.cpp
@@ -1,3 +1,21 @@
+// frmMain.cpp - Main window 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
#include
#include
@@ -13,7 +31,7 @@
#include
#include
#include
-//#include
+#include
// Include the forms.
@@ -21,13 +39,14 @@
#include "frmAbout.h"
#include "frmPreferences.h"
#include "frmNewAccount.h"
-#include "frmActivityMgr.h"
+#include "actmgr/frmActivityMgr.h"
#include "frmContact.h"
#include "frmConflictResolution.h"
#include "frmInvalidSSLCertificate.h"
-#include "frmSearch.h"
+#include "search/frmSearch.h"
#include "frmSSLCertificate.h"
#include "frmUpdate.h"
+#include "import/frmImportResults.h"
#include "bitmaps.h"
#include "common/preferences.h"
@@ -39,6 +58,7 @@
#include "contacteditor/frmContactEditor.h"
#include "import/import.h"
#include "export/export.h"
+#include "widgets/XABContactMenu.h"
#include "widgets/XABAccountView.h"
#include "version.h"
@@ -52,7 +72,10 @@ DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
DEFINE_EVENT_TYPE(CE_OPENCONTACT);
+DEFINE_EVENT_TYPE(CE_OPENCONTACTLIST);
+DEFINE_EVENT_TYPE(CE_NEWCONTACT);
DEFINE_EVENT_TYPE(CE_EDITCONTACT);
+DEFINE_EVENT_TYPE(CE_DELETECONTACT);
DEFINE_EVENT_TYPE(CE_REVEALCONTACT);
DEFINE_EVENT_TYPE(CE_REMOVECONTACT);
DEFINE_EVENT_TYPE(CE_REMOVESEARCH);
@@ -62,12 +85,14 @@ DEFINE_EVENT_TYPE(ACTMGR_SHUFFLE);
DEFINE_EVENT_TYPE(ACTMGR_STOP);
DEFINE_EVENT_TYPE(WINDOW_ADD);
DEFINE_EVENT_TYPE(WINDOW_EDIT);
-//DEFINE_EVENT_TYPE(WINDOW_DELETE);
DEFINE_EVENT_TYPE(WINDOW_CLOSE);
DEFINE_EVENT_TYPE(CONNSTAT_UPDATE);
DEFINE_EVENT_TYPE(INVALIDSSLCERT);
DEFINE_EVENT_TYPE(GETSELECTEDLIST);
DEFINE_EVENT_TYPE(SYNCACCOUNT);
+DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW);
+DEFINE_EVENT_TYPE(RELOADCONTACTLIST);
+DEFINE_EVENT_TYPE(REFRESHADDRESSBOOK);
BEGIN_EVENT_TABLE(frmMain, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
@@ -75,7 +100,10 @@ EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
+EVT_COMMAND(wxID_ANY, CE_OPENCONTACTLIST, frmMain::OpenContactInfoList)
+EVT_COMMAND(wxID_ANY, CE_NEWCONTACT, frmMain::ShowContactEditorNew)
EVT_COMMAND(wxID_ANY, CE_EDITCONTACT, frmMain::ShowContactEditorEdit)
+EVT_COMMAND(wxID_ANY, CE_DELETECONTACT, frmMain::DeleteContact)
EVT_COMMAND(wxID_ANY, CE_REVEALCONTACT, frmMain::RevealContact)
EVT_COMMAND(wxID_ANY, CE_REMOVESEARCH, frmMain::RemoveContactsWindowPointer)
EVT_COMMAND(wxID_ANY, SYNC_EMPTYSERVER, frmMain::EmptyServerDialog)
@@ -89,6 +117,9 @@ EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus)
EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate)
EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList)
EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
+EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults)
+EVT_COMMAND(wxID_ANY, RELOADCONTACTLIST, frmMain::ReloadContactList)
+EVT_COMMAND(wxID_ANY, REFRESHADDRESSBOOK, frmMain::RefreshAddressBook)
END_EVENT_TABLE()
frmMain::frmMain( wxWindow* parent )
@@ -322,13 +353,34 @@ frmMainADT( parent )
}
+void frmMain::QuitApp( wxCloseEvent& event )
+{
+
+ QuitApp();
+
+}
+
void frmMain::QuitApp( wxCommandEvent& event )
+{
+
+ QuitApp();
+
+}
+
+void frmMain::QuitApp()
{
//-------------------------------------------------------------------
// frmMain::QuitApp: Quits the application by simply closing this
// window which causes the exit as frmMain is the main window.
//
// wxCommandEvent Accepts a referenced event command.
+ //-------------------------------------------------------------------
+
+ //-------------------------------------------------------------------
+ // frmMain::QuitApp: Quits the application by simply closing this
+ // window which causes the exit as frmMain is the main window.
+ //
+ // wxCommandEvent Accepts a referenced event command.
//-------------------------------------------------------------------
//Go through the windows and close each one (be it search
@@ -393,17 +445,6 @@ void frmMain::QuitApp( wxCommandEvent& event )
std::exit(0);
-}
-
-void frmMain::QuitApp()
-{
- //-------------------------------------------------------------------
- // frmMain::QuitApp: Quits the application by simply closing this
- // window which causes the exit as frmMain is the main window.
- //
- // wxCommandEvent Accepts a referenced event command.
- //-------------------------------------------------------------------
-
Close();
}
@@ -757,7 +798,6 @@ void frmMain::LoadContactList( wxTreeEvent& event )
vCard Person;
vCardFilenameFull.Append(AccountDirFinal);
- vCardFilenameFull.Append(wxT("/"));
vCardFilenameFull.Append(vCardFilename);
Person.LoadFile(vCardFilenameFull);
@@ -1210,20 +1250,31 @@ void frmMain::ShowContactEditorEdit( wxCommandEvent& event )
}
void frmMain::RefreshAddressBook( wxCommandEvent& event ){
-
- // TODO: Check Account Type.
+
+ // Check if ActiveAccount is empty. If not then check if
+ // account type is not local otherwise continue.
if (!ActiveAccount.IsEmpty()){
-
- frmActivityMgr *frameActMgr = static_cast(ActMgrPtr);
- frameActMgr->AddTask(3, wxT(""), ActiveAccount,
- wxT(""), wxT(""), wxT(""), wxT(""));
-
+
+ if (ActiveAccountType != wxT("Local")){
+
+ // Account type is not local.
+
+ frmActivityMgr *frameActMgr = static_cast(ActMgrPtr);
+ frameActMgr->AddTask(3, wxT(""), ActiveAccount,
+ wxT(""), wxT(""), wxT(""), wxT(""));
+
+ } else {
+
+ wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported for this type of account"));
+
+ }
+
}
}
-void frmMain::OpenContactInfo( wxListEvent& event )
+void frmMain::OpenContactInfoList( wxListEvent& event )
{
wxStringTokenizer vcardfileline;
@@ -1280,6 +1331,13 @@ void frmMain::OpenContactInfo( wxListEvent& event )
}
+void frmMain::OpenContactInfoList( wxCommandEvent& event ){
+
+ wxListEvent pevent;
+ OpenContactInfoList(pevent);
+
+}
+
void frmMain::OpenContactInfo( wxCommandEvent& event )
{
@@ -1870,15 +1928,17 @@ void frmMain::RevealContact(wxCommandEvent& event){
// If they match then select it.
if (ContactsFileIndex[intSelectedData] == uc->ContactFilename){
-
+
// Select.
lstContacts->SetItemState(longSelected, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
lstContacts->EnsureVisible(longSelected);
- break;
-
- }
+ } else {
+
+ lstContacts->SetItemState(longSelected, 0, wxLIST_STATE_SELECTED);
+
+ }
}
@@ -2746,10 +2806,10 @@ void frmMain::GetSelectedList( wxCommandEvent& event ){
void frmMain::SyncAccount( wxCommandEvent& event ){
- wxString *AccNameInc = (wxString*)event.GetClientData();
+ wxString AccNameInc = event.GetString();
frmActivityMgr *frameActMgr = static_cast(ActMgrPtr);
- frameActMgr->AddTask(3, wxT(""), *AccNameInc,
+ frameActMgr->AddTask(3, wxT(""), AccNameInc,
wxT(""), wxT(""), wxT(""), wxT(""));
}
@@ -2797,4 +2857,50 @@ void frmMain::ShowHelp( wxCommandEvent& event ){
#endif
+}
+
+void frmMain::ShowImportResults( wxCommandEvent &event ){
+
+ std::map *ResultData = (std::map*)event.GetClientData();
+
+ frmImportResults *frmIR = new frmImportResults(this);
+ frmIR->LoadData(ResultData, event.GetInt(), (int)event.GetExtraLong());
+ frmIR->ShowModal();
+
+ delete frmIR;
+ frmIR = NULL;
+
+ delete ResultData;
+ ResultData = NULL;
+
+}
+
+void frmMain::ReloadContactList( wxCommandEvent &event ){
+
+ // Check if the account name given is the current
+ // account selected.
+
+ if (ActiveAccount == event.GetString()){
+
+ wxTreeEvent NullEvent;
+ LoadContactList(NullEvent);
+
+ }
+
+}
+
+void frmMain::ShowContactMenu( wxMouseEvent& event ){
+
+ bool EnableRefresh = FALSE;
+
+ if (!ActiveAccount.IsEmpty()){
+
+ EnableRefresh = TRUE;
+
+ }
+
+ ContactMenu->SetupPointers(this, lstContacts, EnableRefresh);
+
+ this->PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);
+
}
\ No newline at end of file