summaryrefslogtreecommitdiff
path: root/src/mcd-storage.h
blob: 5a0915599eea829af4b6c0abef55062f5ed666af (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
/* Mission Control storage API - interface which provides access to account
 * parameter/setting 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;
  GKeyFile *keyfile;
  GKeyFile *secrets;
} 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 (void);
void mcd_storage_set_dbus_daemon (McdStorage *self,
    TpDBusDaemon *dbusd);
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_settings (McdStorage *storage,
    const gchar *account,
    gsize *n);

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

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

gboolean mcd_storage_set_value (McdStorage *storage,
    const gchar *account,
    const gchar *key,
    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 *key);

gboolean mcd_storage_has_value (McdStorage *storage,
    const gchar *account,
    const gchar *key);

GValue *mcd_storage_dup_value (McdStorage *storage,
    const gchar *account,
    const gchar *key,
    GType type,
    GError **error);

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

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

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

G_GNUC_INTERNAL void _mcd_storage_store_connections (McdStorage *storage);

G_END_DECLS

#endif /* MCD_STORAGE_H */