From 31d8da1c4c1d30c6e68a37a01da0a4cfbfe593ac Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Wed, 23 May 2012 02:29:30 -0400 Subject: [PATCH] desktop: added concept of configured PST type mask For example, in the Evolution plugin config, it may be difficult for the end user to find the correct config for Memos or Calendar, if the autodetect code doesn't work for them on their system. If the user just doesn't care about syncing that particular object, it should be possible to use an empty string, and then disable the corresponding sync type. By adding the concept of configured sync types to the plugin classes, and ANDing the supported sync types with the configured ones, it is possible to make these configuration possibilities more intuitive and automatic. --- desktop/src/CUI_Evolution.cc | 9 ++++----- desktop/src/EvoCfgDlg.cc | 19 ++++-------------- desktop/src/EvoCfgDlg.h | 1 + desktop/src/osconfig.h | 48 +++++++++++++++++++++++++++++++++++++------- desktop/src/osconv22.cc | 7 +++---- desktop/src/osconv40.cc | 8 ++++---- desktop/src/ostypes.h | 6 +++++- 7 files changed, 62 insertions(+), 36 deletions(-) diff --git a/desktop/src/CUI_Evolution.cc b/desktop/src/CUI_Evolution.cc index 2b73f9ba..a4adef3a 100644 --- a/desktop/src/CUI_Evolution.cc +++ b/desktop/src/CUI_Evolution.cc @@ -315,14 +315,13 @@ bool Evolution::ZapData(wxWindow *parent, wxString msg; if( dynamic_cast(engine) ) { msg = _T( - "Starting Evolution. Delete all contacts and calendar " - "entries manually."); + "Starting Evolution. Delete all contacts and/or calendar " + "entries manually, depending on your sync configuration."); } else { msg = _T( - "Starting Evolution. Delete all contacts and calendar " - "entries manually (as well as memos and tasks if you are " - "syncing them too)." + "Starting Evolution. Delete all objects (contacts, calendar, " + "memos, and tasks, depending on your sync configuration)." ); } int choice = wxMessageBox(msg, _T("Starting Evolution"), diff --git a/desktop/src/EvoCfgDlg.cc b/desktop/src/EvoCfgDlg.cc index 6f2f3284..fb2f732a 100644 --- a/desktop/src/EvoCfgDlg.cc +++ b/desktop/src/EvoCfgDlg.cc @@ -137,21 +137,10 @@ wxString EvoCfgDlg::CheckPath(const wxString &name, wxString EvoCfgDlg::ValidatePaths() const { - if( m_address_path.empty() || m_calendar_path.empty() || m_tasks_path.empty() ) - return _T("Address book, Event, and Tasks must be set."); - - wxString msg; - msg = CheckPath(_T("Address book path"), m_address_path); - if( msg.size() ) - return msg; - msg = CheckPath(_T("Event path"), m_calendar_path); - if( msg.size() ) - return msg; - msg = CheckPath(_T("Tasks path"), m_tasks_path); - if( msg.size() ) - return msg; - msg = CheckPath(_T("Memos path"), m_memos_path); - return msg; + if( m_address_path.empty() && m_calendar_path.empty() && + m_tasks_path.empty() && m_memos_path.empty() ) + return _T("No paths set! If there are no default options available in the drop down lists, please double check that you've initialized your Evolution account first."); + return _T(""); } bool EvoCfgDlg::TransferDataFromWindow() diff --git a/desktop/src/EvoCfgDlg.h b/desktop/src/EvoCfgDlg.h index 6d6007b3..9f14d34f 100644 --- a/desktop/src/EvoCfgDlg.h +++ b/desktop/src/EvoCfgDlg.h @@ -24,6 +24,7 @@ #include #include "EvoSources.h" +#include "ostypes.h" // forward declarations namespace OpenSync { diff --git a/desktop/src/osconfig.h b/desktop/src/osconfig.h index c7f65396..3709cd8b 100644 --- a/desktop/src/osconfig.h +++ b/desktop/src/osconfig.h @@ -107,10 +107,12 @@ public: //{ // return api.GetConverter().IsConfigured(*this); //} + virtual pst_type GetConfiguredSyncTypes() const { return PST_NONE; } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const = 0; // sample implementation: //{ - // return api.GetConverter().GetSupportedSyncTypes(*this); + // return api.GetConverter().GetSupportedSyncTypes(*this) + // && GetConfiguredSyncTypes(); //} /// Support function for Group::Compare(). If plugin is the @@ -163,7 +165,8 @@ public: } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const { - return api.GetConverter().GetSupportedSyncTypes(*this); + return api.GetConverter().GetSupportedSyncTypes(*this) & + GetConfiguredSyncTypes();; } // statics @@ -240,9 +243,14 @@ public: { return api.GetConverter().IsConfigured(*this); } + virtual pst_type GetConfiguredSyncTypes() const + { + return m_pin.Valid() ? PST_ALL : PST_NONE; + } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const { - return api.GetConverter().GetSupportedSyncTypes(*this); + return api.GetConverter().GetSupportedSyncTypes(*this) & + GetConfiguredSyncTypes(); } virtual bool Compare(const Plugin &plugin, bool &sametype, bool &equal) const @@ -323,9 +331,21 @@ public: { return api.GetConverter().IsConfigured(*this); } + virtual pst_type GetConfiguredSyncTypes() const + { + pst_type pst = PST_NONE; + if( m_address_path.size() ) pst |= PST_CONTACTS; + if( m_calendar_path.size() ) pst |= PST_EVENTS; + if( m_tasks_path.size() ) pst |= PST_TODOS; + if( m_memos_path.size() ) pst |= PST_NOTES; + return pst; + } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const { - return api.GetConverter().GetSupportedSyncTypes(*this); + // supported types include what the plugin is capable of, + // ANDed against what has been configured + return api.GetConverter().GetSupportedSyncTypes(*this) & + GetConfiguredSyncTypes(); } virtual bool Compare(const Plugin &plugin, bool &sametype, bool &equal) const @@ -385,7 +405,8 @@ public: } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const { - return api.GetConverter().GetSupportedSyncTypes(*this); + return api.GetConverter().GetSupportedSyncTypes(*this) & + GetConfiguredSyncTypes(); } virtual bool Compare(const Plugin &plugin, bool &sametype, bool &equal) const @@ -471,9 +492,17 @@ public: { return api.GetConverter().IsConfigured(*this); } + virtual pst_type GetConfiguredSyncTypes() const + { + pst_type pst = PST_NONE; + if( m_contacts_enabled ) pst |= PST_CONTACTS; + if( m_calendar_enabled ) pst |= PST_EVENTS; + return pst; + } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const { - return api.GetConverter().GetSupportedSyncTypes(*this); + return api.GetConverter().GetSupportedSyncTypes(*this) & + GetConfiguredSyncTypes(); } virtual bool Compare(const Plugin &plugin, bool &sametype, bool &equal) const @@ -535,9 +564,14 @@ public: { return api.GetConverter().IsConfigured(*this); } + virtual pst_type GetConfiguredSyncTypes() const + { + return PST_ALL; + } virtual pst_type GetSupportedSyncTypes(OpenSync::API &api) const { - return api.GetConverter().GetSupportedSyncTypes(*this); + return api.GetConverter().GetSupportedSyncTypes(*this) & + GetConfiguredSyncTypes(); } virtual bool Compare(const Plugin &plugin, bool &sametype, bool &equal) const diff --git a/desktop/src/osconv22.cc b/desktop/src/osconv22.cc index 37ee62bc..965e862b 100644 --- a/desktop/src/osconv22.cc +++ b/desktop/src/osconv22.cc @@ -130,10 +130,9 @@ bool Converter22::IsConfigured(const Config::Barry &config) const bool Converter22::IsConfigured(const Config::Evolution &config) const { // the 22 barry plugin only supports address and calendar, - // but the evolution plugin seems to like these 3 - return config.GetAddressPath().size() && - config.GetCalendarPath().size() && - config.GetTasksPath().size(); + // and as long as either one is configured, we're good + return config.GetAddressPath().size() || + config.GetCalendarPath().size(); } bool Converter22::IsConfigured(const Config::Evolution3 &config) const diff --git a/desktop/src/osconv40.cc b/desktop/src/osconv40.cc index e9a8b192..6c87246c 100644 --- a/desktop/src/osconv40.cc +++ b/desktop/src/osconv40.cc @@ -135,10 +135,10 @@ bool Converter40::IsConfigured(const Config::Barry &config) const bool Converter40::IsConfigured(const Config::Evolution &config) const { - // the 40 plugin supports all 4, so check all 4 - return config.GetAddressPath().size() && - config.GetCalendarPath().size() && - config.GetTasksPath().size() && + // as long as one is configured, we're good + return config.GetAddressPath().size() || + config.GetCalendarPath().size() || + config.GetTasksPath().size() || config.GetMemosPath().size(); } diff --git a/desktop/src/ostypes.h b/desktop/src/ostypes.h index 68ddde24..8317c7e8 100644 --- a/desktop/src/ostypes.h +++ b/desktop/src/ostypes.h @@ -32,7 +32,11 @@ #define PST_NOTES 0x04 #define PST_TODOS 0x08 #define PST_ALL 0x0f -#define PST_DO_NOT_SET 0x10000000 +#define PST_DO_NOT_SET 0x10000000 // used by the engine to signal + // an attempt to run without + // specifying supported types... + // i.e. just run with default + // efforts namespace OpenSync { namespace Config { -- 2.11.4.GIT