1 /* Mission Control plugin API - Account storage hook. 2 * 3 * Copyright © 2010 Nokia Corporation 4 * Copyright © 2010 Collabora Ltd. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef MCP_ACCOUNT_STORAGE_H 22 #define MCP_ACCOUNT_STORAGE_H 23 24 #ifndef _MCP_IN_MISSION_CONTROL_PLUGINS_H 25 #error Use <mission-control-plugins/mission-control-plugins.h> instead 26 #endif 27 28 G_BEGIN_DECLS 29 30 #define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_READONLY -1 31 #define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_DEFAULT 0 32 #define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_NORMAL 100 33 #define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_KEYRING 10000 34 35 /* API for plugins to implement */ 36 typedef struct _McpAccountStorage McpAccountStorage; 37 typedef struct _McpAccountStorageIface McpAccountStorageIface; 38 39 #ifdef _i_used_gtk_doc_but_all_i_got_was_this_heap_of_workarounds 40 /* Without this, gtk-doc doesn't generate documentation for 41 * #McpAccountStorage. There is actually no such struct: do not attempt 42 * to use it. */ 43 struct _McpAccountStorage { }; 44 #endif 45 46 #define MCP_TYPE_ACCOUNT_STORAGE (mcp_account_storage_get_type ()) 47 48 #define MCP_ACCOUNT_STORAGE(o) \ 49 (G_TYPE_CHECK_INSTANCE_CAST ((o), MCP_TYPE_ACCOUNT_STORAGE, \ 50 McpAccountStorage)) 51 52 #define MCP_IS_ACCOUNT_STORAGE(o) \ 53 (G_TYPE_CHECK_INSTANCE_TYPE ((o), MCP_TYPE_ACCOUNT_STORAGE)) 54 55 #define MCP_ACCOUNT_STORAGE_GET_IFACE(o) \ 56 (G_TYPE_INSTANCE_GET_INTERFACE ((o), MCP_TYPE_ACCOUNT_STORAGE, \ 57 McpAccountStorageIface)) 58 59 GType mcp_account_storage_get_type (void); 60 61 /* Virtual method implementation signatures */ 62 typedef gboolean (*McpAccountStorageGetFunc) ( 63 const McpAccountStorage *storage, 64 const McpAccountManager *am, 65 const gchar *account, 66 const gchar *key); 67 typedef gboolean (*McpAccountStorageSetFunc) ( 68 const McpAccountStorage *storage, 69 const McpAccountManager *am, 70 const gchar *account, 71 const gchar *key, 72 const gchar *val); 73 typedef gchar * (*McpAccountStorageCreate) ( 74 const McpAccountStorage *storage, 75 const McpAccountManager *am, 76 const gchar *manager, 77 const gchar *protocol, 78 GHashTable *params, 79 GError **error); 80 typedef gboolean (*McpAccountStorageDeleteFunc) ( 81 const McpAccountStorage *storage, 82 const McpAccountManager *am, 83 const gchar *account, 84 const gchar *key); 85 typedef GList * (*McpAccountStorageListFunc) ( 86 const McpAccountStorage *storage, 87 const McpAccountManager *am); 88 typedef gboolean (*McpAccountStorageCommitFunc) ( 89 const McpAccountStorage *storage, 90 const McpAccountManager *am); 91 typedef gboolean (*McpAccountStorageCommitOneFunc) ( 92 const McpAccountStorage *storage, 93 const McpAccountManager *am, 94 const gchar *account); 95 typedef void (*McpAccountStorageReadyFunc) ( 96 const McpAccountStorage *storage, 97 const McpAccountManager *am); 98 typedef void (*McpAccountStorageGetIdentifierFunc) ( 99 const McpAccountStorage *storage, 100 const gchar *account, 101 GValue *identifier); 102 typedef GHashTable * (*McpAccountStorageGetAdditionalInfoFunc) ( 103 const McpAccountStorage *storage, 104 const gchar *account); 105 /* FIXME: when breaking API, make this return TpStorageRestrictionFlags */ 106 typedef guint (*McpAccountStorageGetRestrictionsFunc) ( 107 const McpAccountStorage *storage, 108 const gchar *account); 109 110 struct _McpAccountStorageIface 111 { 112 GTypeInterface parent; 113 114 gint priority; 115 const gchar *name; 116 const gchar *desc; 117 const gchar *provider; 118 119 McpAccountStorageSetFunc set; 120 McpAccountStorageGetFunc get; 121 McpAccountStorageDeleteFunc delete; 122 McpAccountStorageCommitFunc commit; 123 McpAccountStorageListFunc list; 124 McpAccountStorageReadyFunc ready; 125 McpAccountStorageCommitOneFunc commit_one; 126 McpAccountStorageGetIdentifierFunc get_identifier; 127 McpAccountStorageGetAdditionalInfoFunc get_additional_info; 128 McpAccountStorageGetRestrictionsFunc get_restrictions; 129 McpAccountStorageCreate create; 130 131 /* Since 5.15.0 */ 132 gboolean (*owns) (McpAccountStorage *storage, 133 McpAccountManager *am, 134 const gchar *account); 135 gboolean (*set_attribute) (McpAccountStorage *storage, 136 McpAccountManager *am, 137 const gchar *account, 138 const gchar *attribute, 139 GVariant *val, 140 McpAttributeFlags flags); 141 gboolean (*set_parameter) (McpAccountStorage *storage, 142 McpAccountManager *am, 143 const gchar *account, 144 const gchar *parameter, 145 GVariant *val, 146 McpParameterFlags flags); 147 }; 148 149 #ifndef __GTK_DOC_IGNORE__ 150 #ifndef MC_DISABLE_DEPRECATED 151 152 /* functions with which to fill in the vtable */ 153 G_DEPRECATED_FOR (iface->priority = prio) 154 void mcp_account_storage_iface_set_priority (McpAccountStorageIface *iface, 155 guint prio); 156 157 G_DEPRECATED_FOR (iface->name = name) 158 void mcp_account_storage_iface_set_name (McpAccountStorageIface *iface, 159 const gchar *name); 160 161 G_DEPRECATED_FOR (iface->desc = desc) 162 void mcp_account_storage_iface_set_desc (McpAccountStorageIface *iface, 163 const gchar *desc); 164 165 G_DEPRECATED_FOR (iface->provider = provider) 166 void mcp_account_storage_iface_set_provider (McpAccountStorageIface *iface, 167 const gchar *provider); 168 169 G_DEPRECATED_FOR (iface->get = method) 170 void mcp_account_storage_iface_implement_get (McpAccountStorageIface *iface, 171 McpAccountStorageGetFunc method); 172 G_DEPRECATED_FOR (iface->set = method) 173 void mcp_account_storage_iface_implement_set (McpAccountStorageIface *iface, 174 McpAccountStorageSetFunc method); 175 G_DEPRECATED_FOR (iface->create = method) 176 void mcp_account_storage_iface_implement_create ( 177 McpAccountStorageIface *iface, 178 McpAccountStorageCreate method); 179 G_DEPRECATED_FOR (iface->delete = method) 180 void mcp_account_storage_iface_implement_delete (McpAccountStorageIface *iface, 181 McpAccountStorageDeleteFunc method); 182 G_DEPRECATED_FOR (iface->list = method) 183 void mcp_account_storage_iface_implement_list (McpAccountStorageIface *iface, 184 McpAccountStorageListFunc method); 185 G_DEPRECATED_FOR (iface->commit = method) 186 void mcp_account_storage_iface_implement_commit (McpAccountStorageIface *iface, 187 McpAccountStorageCommitFunc method); 188 G_DEPRECATED_FOR (iface->commit_one = method) 189 void mcp_account_storage_iface_implement_commit_one ( 190 McpAccountStorageIface *iface, 191 McpAccountStorageCommitOneFunc method); 192 G_DEPRECATED_FOR (iface->ready = method) 193 void mcp_account_storage_iface_implement_ready (McpAccountStorageIface *iface, 194 McpAccountStorageReadyFunc method); 195 G_DEPRECATED_FOR (iface->get_identifier = method) 196 void mcp_account_storage_iface_implement_get_identifier ( 197 McpAccountStorageIface *iface, 198 McpAccountStorageGetIdentifierFunc method); 199 G_DEPRECATED_FOR (iface->get_additional_info = method) 200 void mcp_account_storage_iface_implement_get_additional_info ( 201 McpAccountStorageIface *iface, 202 McpAccountStorageGetAdditionalInfoFunc method); 203 G_DEPRECATED_FOR (iface->get_restrictions = method) 204 void mcp_account_storage_iface_implement_get_restrictions ( 205 McpAccountStorageIface *iface, 206 McpAccountStorageGetRestrictionsFunc method); 207 208 #endif /* !defined(MC_DISABLE_DEPRECATED) */ 209 #endif /* !defined(__GTK_DOC_IGNORE__) */ 210 211 /* virtual methods */ 212 gint mcp_account_storage_priority (const McpAccountStorage *storage); 213 214 gboolean mcp_account_storage_get (const McpAccountStorage *storage, 215 McpAccountManager *am, 216 const gchar *account, 217 const gchar *key); 218 219 gboolean mcp_account_storage_set (const McpAccountStorage *storage, 220 const McpAccountManager *am, 221 const gchar *account, 222 const gchar *key, 223 const gchar *value); 224 225 gchar * mcp_account_storage_create (const McpAccountStorage *storage, 226 const McpAccountManager *am, 227 const gchar *manager, 228 const gchar *protocol, 229 GHashTable *params, 230 GError **error); 231 232 gboolean mcp_account_storage_delete (const McpAccountStorage *storage, 233 const McpAccountManager *am, 234 const gchar *account, 235 const gchar *key); 236 237 void mcp_account_storage_ready (const McpAccountStorage *storage, 238 const McpAccountManager *am); 239 240 gboolean 241 mcp_account_storage_commit (const McpAccountStorage *storage, 242 const McpAccountManager *am); 243 244 gboolean 245 mcp_account_storage_commit_one (const McpAccountStorage *storage, 246 const McpAccountManager *am, 247 const gchar *account); 248 249 GList *mcp_account_storage_list (const McpAccountStorage *storage, 250 const McpAccountManager *am); 251 252 void mcp_account_storage_get_identifier (const McpAccountStorage *storage, 253 const gchar *account, 254 GValue *identifier); 255 256 GHashTable *mcp_account_storage_get_additional_info ( 257 const McpAccountStorage *storage, 258 const gchar *account); 259 260 guint mcp_account_storage_get_restrictions (const McpAccountStorage *storage, 261 const gchar *account); 262 263 const gchar *mcp_account_storage_name (const McpAccountStorage *storage); 264 265 const gchar *mcp_account_storage_description (const McpAccountStorage *storage); 266 const gchar *mcp_account_storage_provider (const McpAccountStorage *storage); 267 268 gboolean mcp_account_storage_owns (McpAccountStorage *storage, 269 McpAccountManager *am, 270 const gchar *account); 271 272 gboolean mcp_account_storage_set_attribute (McpAccountStorage *storage, 273 McpAccountManager *am, 274 const gchar *account, 275 const gchar *attribute, 276 GVariant *value, 277 McpAttributeFlags flags); 278 gboolean mcp_account_storage_set_parameter (McpAccountStorage *storage, 279 McpAccountManager *am, 280 const gchar *account, 281 const gchar *parameter, 282 GVariant *value, 283 McpParameterFlags flags); 284 285 void mcp_account_storage_emit_created (McpAccountStorage *storage, 286 const gchar *account); 287 G_DEPRECATED_FOR (something that is actually implemented) 288 void mcp_account_storage_emit_altered (McpAccountStorage *storage, 289 const gchar *account); 290 void mcp_account_storage_emit_altered_one (McpAccountStorage *storage, 291 const gchar *account, 292 const gchar *key); 293 void mcp_account_storage_emit_deleted (McpAccountStorage *storage, 294 const gchar *account); 295 void mcp_account_storage_emit_toggled (McpAccountStorage *storage, 296 const gchar *account, 297 gboolean enabled); 298 void mcp_account_storage_emit_reconnect (McpAccountStorage *storage, 299 const gchar *account); 300 301 G_END_DECLS 302 303 #endif 304