Bumped copyright dates for 2013
[barry.git] / desktop / src / os40.h
blob507056b0262b78053054673473e9642bb718393c
1 ///
2 /// \file os40.h
3 /// Wrapper class for opensync 0.4x syncing behaviour
4 ///
6 /*
7 Copyright (C) 2009-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRYDESKTOP_OS40_H__
23 #define __BARRYDESKTOP_OS40_H__
25 #include "dlopen.h"
26 #include "osbase.h"
27 #include <memory>
29 namespace OpenSync {
31 class OpenSync40Private;
32 class OS40PluginConfigPrivate;
33 class OS40ConfigResourcePrivate;
35 class OS40PluginConfig;
36 class OpenSync40;
38 class OS40ConfigResource
40 friend class OS40PluginConfig;
42 private:
43 OS40ConfigResourcePrivate *m_priv;
44 bool m_exists; // true if this resources exists
45 // in the plugin config.
46 // AddResource() sets this to true
48 private:
49 OS40ConfigResource(const OS40PluginConfig &parent, void *resource,
50 bool existing_resource);
51 OS40ConfigResource(const OS40ConfigResource &other);//disabled copy
52 OS40ConfigResource& operator=(const OS40ConfigResource &other);
54 public:
55 ~OS40ConfigResource();
57 /// Returns true if this instance represents an existing
58 /// resource in the config. If this is false, then
59 /// AddResource() must be called, otherwise any changes
60 /// will not be saved to the config object.
61 bool IsExistingResource() const;
62 void AddResource(); // safe to call multiple times
64 bool IsEnabled() const;
65 OS40ConfigResource& Enable(bool enabled = true);
67 // searches for the objformat, and fills in config with its config
68 // value if it exists and returns true... otherwise returns false
69 bool FindObjFormat(const std::string &objformat, std::string &config);
70 OS40ConfigResource& SetObjFormat(const std::string &objformat,
71 const std::string &config = "");
73 std::string GetName() const;
74 OS40ConfigResource& SetName(const std::string &name);
76 std::string GetPreferredFormat() const;
77 OS40ConfigResource& SetPreferredFormat(const std::string &format);
79 std::string GetMime() const;
80 OS40ConfigResource& SetMime(const std::string &mime);
82 std::string GetObjType() const;
83 private:OS40ConfigResource& SetObjType(const std::string &objtype); // objtype is set
84 // automatically when this object is created with GetResource()
86 public:
87 std::string GetPath() const;
88 OS40ConfigResource& SetPath(const std::string &path);
90 std::string GetUrl() const;
91 OS40ConfigResource& SetUrl(const std::string &url);
94 class OS40PluginConfig
96 friend class OS40ConfigResource;
97 friend class OpenSync40;
99 public:
100 typedef std::auto_ptr<OS40ConfigResource> OS40ConfigResourcePtr;
102 enum {
103 NONE_TYPE,
104 BOOL_TYPE,
105 CHAR_TYPE,
106 DOUBLE_TYPE,
107 INT_TYPE,
108 LONG_TYPE,
109 LONGLONG_TYPE,
110 UINT_TYPE,
111 ULONG_TYPE,
112 ULONGLONG_TYPE,
113 STRING_TYPE
116 private:
117 OpenSync40Private *m_privapi; // external pointer to OpenSync40
118 std::tr1::shared_ptr<OS40PluginConfigPrivate> m_priv;
120 private:
121 OS40PluginConfig(OpenSync40Private *privapi, void *member, void *config);
123 public:
124 std::string GetAdvanced(const std::string &name);
125 void SetAdvanced(const std::string &name,
126 const std::string &display_name, const std::string &val);
127 void SetAdvanced(const std::string &name,
128 const std::string &display_name,
129 int val_type, const std::string &val);
131 OS40ConfigResourcePtr GetResource(const std::string &objtype);
133 std::string GetUsername() const;
134 void SetUsername(const std::string &username);
136 std::string GetPassword() const;
137 void SetPassword(const std::string &password);
139 void Save();
142 class OpenSync40 : public DlOpen, public OpenSync::API
144 public:
146 private:
147 // private opensync 0.40 function pointers and data
148 OpenSync40Private *m_priv;
150 protected:
151 void SetupEnvironment(OpenSync40Private *p);
153 public:
154 OpenSync40();
155 ~OpenSync40();
158 // Virtual API overrides
161 // Functional abilities information... this does not come from
162 // the engine itself, but is information the osbase library
163 // determines useful for applications to know
164 bool IsSlowSyncSupported() const { return true; } // FIXME - is this right?
166 // General engine information
167 const char* GetVersion() const;
168 const char* GetEngineName() const;
169 void GetPluginNames(string_list_type &plugins);
170 void GetFormats(format_list_type &formats);
172 // Information about configured groups
173 void GetGroupNames(string_list_type &groups);
174 void GetMembers(const std::string &group_name,
175 member_list_type &members);
177 // Group configuration
178 void AddGroup(const std::string &group_name);
179 void DeleteGroup(const std::string &group_name);
181 // Plugin configuration helper
182 Converter& GetConverter();
184 // Member configuration
185 long AddMember(const std::string &group_name,
186 const std::string &plugin_name,
187 const std::string &member_name);
188 void DeleteMember(const std::string &group_name, long member_id);
189 void DeleteMember(const std::string &group_name,
190 const std::string &plugin_name);
191 bool IsConfigurable(const std::string &group_name,
192 long member_id);
193 std::string GetConfiguration(const std::string &group_name,
194 long member_id);
195 OS40PluginConfig GetConfigurationObj(const std::string &group_name,
196 long member_id);
197 void SetConfiguration(const std::string &group_name,
198 long member_id, const std::string &config_data);
199 void Discover(const std::string &group_name);
201 // Syncing
202 void Sync(const std::string &group_name, SyncStatus &status_callback,
203 Config::pst_type sync_types/* = PST_DO_NOT_SET*/);
206 } // namespace OpenSync
208 #endif