summaryrefslogtreecommitdiff
path: root/src/mcd-storage.h
blob: 893a0af34b17697c0c959da963ffa2eb84f0ef4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* Mission Control storage API - interface which provides access to account
 * parameter/attribute storage
 *
 * Copyright © 2010 Nokia Corporation
 * Copyright © 2010 Collabora Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <glib-object.h>
#include <mission-control-plugins/mission-control-plugins.h>

#ifndef MCD_STORAGE_H
#define MCD_STORAGE_H

G_BEGIN_DECLS

typedef struct {
  GObject parent;
  TpDBusDaemon *dbusd;
  /* owned string => owned McdStorageAccount */
  GHashTable *accounts;
} McdStorage;

typedef struct _McdStorageClass McdStorageClass;
typedef struct _McdStoragePrivate McdStoragePrivate;

#define MCD_TYPE_STORAGE (mcd_storage_get_type ())

#define MCD_STORAGE(o) \
  (G_TYPE_CHECK_INSTANCE_CAST ((o), MCD_TYPE_STORAGE, McdStorage))

#define MCD_STORAGE_CLASS(cls) \
  (G_TYPE_CHECK_CLASS_CAST ((cls), MCD_TYPE_STORAGE, McdStorageClass))

#define MCD_IS_STORAGE(o) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((o), MCD_TYPE_STORAGE))

#define MCD_IS_STORAGE_CLASS(cls) \
  (G_TYPE_CHECK_CLASS_TYPE ((cls), MCD_TYPE_STORAGE))

#define MCD_STORAGE_GET_CLASS(o) \
  (G_TYPE_INSTANCE_GET_CLASS ((o), MCD_TYPE_STORAGE, McdStorageClass))

GType mcd_storage_get_type (void);

McdStorage *mcd_storage_new (TpDBusDaemon *dbus_daemon);
void mcd_storage_ready (McdStorage *self);
void mcd_storage_connect_signal (const gchar *signal,
    GCallback func,
    gpointer user_data);

void mcd_storage_load (McdStorage *storage);

GStrv mcd_storage_dup_accounts (McdStorage *storage, gsize *n);

GStrv mcd_storage_dup_attributes (McdStorage *storage,
    const gchar *account,
    gsize *n);

gboolean mcd_storage_set_string (McdStorage *storage,
    const gchar *account,
    const gchar *attribute,
    const gchar *value);

gboolean mcd_storage_set_strv (McdStorage *storage,
    const gchar *account,
    const gchar *attribute,
    const gchar * const *strv);

gboolean mcd_storage_set_attribute (McdStorage *storage,
    const gchar *account,
    const gchar *attribute,
    const GValue *value);

gboolean mcd_storage_set_parameter (McdStorage *storage,
    const gchar *account,
    const gchar *parameter,
    const GValue *value,
    gboolean secret);

gchar *mcd_storage_create_account (McdStorage *storage,
    const gchar *provider,
    const gchar *manager,
    const gchar *protocol,
    GHashTable *params,
    GError **error);

void mcd_storage_delete_account (McdStorage *storage, const gchar *account);

void mcd_storage_commit (McdStorage *storage, const gchar *account);

gchar *mcd_storage_dup_string (McdStorage *storage,
    const gchar *account,
    const gchar *attribute);

gboolean mcd_storage_get_attribute (McdStorage *storage,
    const gchar *account,
    const gchar *attribute,
    GValue *value,
    GError **error);

gboolean mcd_storage_get_parameter (McdStorage *storage,
    const gchar *account,
    const gchar *parameter,
    GValue *value,
    GError **error);

gboolean mcd_storage_get_boolean (McdStorage *storage,
    const gchar *account,
    const gchar *attribute);

gint mcd_storage_get_integer (McdStorage *storage,
    const gchar *account,
    const gchar *attribute);

McpAccountStorage * mcd_storage_get_plugin (McdStorage *storage,
    const gchar *account);

G_GNUC_INTERNAL void _mcd_storage_store_connections (McdStorage *storage);

gboolean mcd_storage_add_account_from_plugin (McdStorage *storage,
    McpAccountStorage *plugin,
    const gchar *account);

gboolean mcd_keyfile_get_value (GKeyFile *keyfile,
    const gchar *group,
    const gchar *key,
    GValue *value,
    GError **error);
gboolean mcd_keyfile_set_value (GKeyFile *keyfile,
    const gchar *name,
    const gchar *key,
    const GValue *value);

gchar *mcd_keyfile_escape_value (const GValue *value);
gboolean mcd_keyfile_unescape_value (const gchar *escaped,
    GValue *value,
    GError **error);

const gchar *mcd_storage_get_attribute_type (const gchar *attribute);
gboolean mcd_storage_init_value_for_attribute (GValue *value,
    const gchar *attribute);

G_END_DECLS

#endif /* MCD_STORAGE_H */