Bumped copyright dates for 2013
[barry.git] / desktop / src / GroupCfgDlg.h
blob046a728a7f263ddd94d0e19d9d70a9b8b5a38452
1 ///
2 /// \file GroupCfgDlg.h
3 /// The configuration dialog used when a user double clicks
4 /// on a device in the device list. It lets the user choose
5 /// the app to sync with Barry, as well as the engine to use.
6 ///
8 /*
9 Copyright (C) 2009-2013, Net Direct Inc. (http://www.netdirect.ca/)
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 See the GNU General Public License in the COPYING file at the
21 root directory of this project for more details.
24 #ifndef __BARRYDESKTOP_GROUPCFGDLG_H__
25 #define __BARRYDESKTOP_GROUPCFGDLG_H__
27 #include <wx/wx.h>
28 #include "deviceset.h"
30 class GroupCfgDlg : public wxDialog
32 DECLARE_EVENT_TABLE() // sets to protected:
34 private:
35 typedef OpenSync::Config::Group::plugin_ptr plugin_ptr;
36 typedef OpenSync::Config::pst_type pst_type;
37 typedef std::map<std::string, plugin_ptr> appcfg_map;
38 typedef std::map<OpenSync::API*, appcfg_map> engapp_map;
39 typedef std::map<OpenSync::API*, pst_type> engtypes_map;
41 // external data sources
42 const DeviceEntry &m_device;
43 OpenSync::APISet &m_apiset;
45 // misc flags
46 int m_app_count;
48 // results of the configuration
49 std::string m_device_name;
50 std::string m_group_name;
51 DeviceEntry::group_ptr m_group;
52 DeviceEntry::extras_ptr m_extras;
54 // in-process config results... i.e. the plugin config
55 // is stored here, and can be overwritten as the user
56 // keeps fiddling with the controls... a map of engines
57 // and apps is kept, so that if the user changes engine
58 // or app, and then changes back, his settings are not lost...
59 // this also means that pre-existing configs from outside
60 // the dialog are kept if possible, to help with re-saving
61 // of opensync configs
62 engapp_map m_plugins; // map of engines/apps/plugins
63 engtypes_map m_sync_types; // map of engines/sync types
64 // this is a map only to preserve user selections between
65 // engines, similar to the plugin behaviour above
66 OpenSync::API *m_engine; // current engine
67 OpenSync::Config::Barry m_barry_plugin;
68 std::string m_favour_plugin_name; // an extra
70 // dialog controls
71 wxSizer *m_topsizer, *m_appsizer;
72 wxComboBox *m_engine_combo, *m_app_combo;
73 wxTextCtrl *m_password_edit, *m_name_edit;
74 wxCheckBox *m_debug_check;
75 wxCheckBox *m_sync_contacts_check;
76 wxCheckBox *m_sync_events_check;
77 wxCheckBox *m_sync_notes_check;
78 wxCheckBox *m_sync_todos_check;
79 wxRadioBox *m_favour_radios;
81 protected:
82 void CreateLayout();
83 void AddEngineSizer(wxSizer *sizer);
84 void AddConfigSizer(wxSizer *sizer);
85 void AddBarrySizer(wxSizer *sizer);
86 void AddAppSizer(wxSizer *sizer);
87 void UpdateAppSizer(bool relayout = true); // called if engine changes,
88 // to update the app combo, etc, with available
89 // apps
90 void LoadAppNames(wxArrayString &appnames);
91 void AddSyncTypeSizer(wxSizer *sizer);
92 void AddFavourSizer(wxSizer *sizer);
93 void AddButtonSizer(wxSizer *sizer);
95 void SelectCurrentEngine();
96 void LoadBarryConfig();
97 void SelectApplication(const std::string appname);
98 void SelectSyncTypes();
99 void SelectFavour();
101 // utility functions for interacting with the sync type checkboxes
102 void EnableSyncTypeChecks(pst_type types);
103 void SetSyncTypeChecks(pst_type types);
104 pst_type GetSyncTypeChecks();
106 std::string GetCurrentAppName() const; // returns name of currently
107 // selected app, for the currently
108 // selected engine... if none selected,
109 // returns empty string (size() == 0)
110 plugin_ptr GetCurrentPlugin();
112 public:
113 GroupCfgDlg(wxWindow *parent, const DeviceEntry &device,
114 OpenSync::APISet &apiset);
116 // results
117 std::string GetDeviceName() const { return m_device_name; }
118 DeviceEntry::group_ptr GetGroup() { return m_group; }
119 OpenSync::API* GetEngine() const { return m_engine; }
120 DeviceEntry::extras_ptr GetExtras() { return m_extras; }
122 // event handlers
123 void OnConfigureApp(wxCommandEvent &event);
124 void OnEngineComboChange(wxCommandEvent &event);
125 void OnAppComboChange(wxCommandEvent &event);
126 void OnSyncTypeCheck(wxCommandEvent &event);
128 // overrides
129 virtual bool TransferDataFromWindow();
130 int ShowModal();
133 #endif