~rodrigo-moya/ubuntuone-client/no-enabling-on-special-udfs

« back to all changes in this revision

Viewing changes to libsyncdaemon/syncdaemon-status-info.c

  • Committer: Tarmac
  • Author(s): Rodrigo Moya
  • Date: 2010-07-06 22:54:29 UTC
  • mfrom: (554.4.5 direct-dbus-is-no-more)
  • Revision ID: rodrigo@megeve-20100706225429-i9teuxkq5lyga87m
Do all Syncdaemon access via DBus from libsyncdaemon, no more direct DBus calls in the Nautilus plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Syncdaemon API
 
3
 *
 
4
 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
 
5
 *
 
6
 * Copyright 2010 Canonical Ltd.
 
7
 *
 
8
 * This program is free software: you can redistribute it and/or modify it
 
9
 * under the terms of the GNU General Public License version 3, as published
 
10
 * by the Free Software Foundation.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
 * PURPOSE.  See the GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along
 
18
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 */
 
21
 
 
22
#include "syncdaemon-status-info.h"
 
23
 
 
24
G_DEFINE_TYPE(SyncdaemonStatusInfo, syncdaemon_status_info, G_TYPE_OBJECT)
 
25
 
 
26
struct _SyncdaemonStatusInfoPrivate {
 
27
        gchar *description;
 
28
        gboolean is_connected;
 
29
        gboolean is_online;
 
30
        gchar *name;
 
31
        gchar *queues;
 
32
};
 
33
 
 
34
static void
 
35
syncdaemon_status_info_finalize (GObject *object)
 
36
{
 
37
        SyncdaemonStatusInfo *sinfo = SYNCDAEMON_STATUS_INFO (object);
 
38
 
 
39
        if (sinfo->priv != NULL) {
 
40
                g_free (sinfo->priv);
 
41
        }
 
42
 
 
43
        G_OBJECT_CLASS (syncdaemon_status_info_parent_class)->finalize (object);
 
44
}
 
45
 
 
46
static void
 
47
syncdaemon_status_info_class_init (SyncdaemonStatusInfoClass *klass)
 
48
{
 
49
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
50
 
 
51
        object_class->finalize = syncdaemon_status_info_finalize;
 
52
}
 
53
 
 
54
static void
 
55
syncdaemon_status_info_init (SyncdaemonStatusInfo *sinfo)
 
56
{
 
57
        sinfo->priv = g_new0 (SyncdaemonStatusInfoPrivate, 1);
 
58
}
 
59
 
 
60
/**
 
61
 * syncdaemon_status_info_new:
 
62
 */
 
63
SyncdaemonStatusInfo *
 
64
syncdaemon_status_info_new (void)
 
65
{
 
66
        return g_object_new (SYNCDAEMON_TYPE_STATUS_INFO, NULL);
 
67
}
 
68
 
 
69
/**
 
70
 * syncdaemon_status_info_new_from_hash_table:
 
71
 */
 
72
SyncdaemonStatusInfo *
 
73
syncdaemon_status_info_new_from_hash_table (GHashTable *hash)
 
74
{
 
75
        SyncdaemonStatusInfo *sinfo;
 
76
 
 
77
        sinfo = g_object_new (SYNCDAEMON_TYPE_STATUS_INFO, NULL);
 
78
        if (hash != NULL) {
 
79
                syncdaemon_status_info_set_description (sinfo, g_hash_table_lookup (hash, "description"));
 
80
                syncdaemon_status_info_set_connected (
 
81
                        sinfo,
 
82
                        g_strcmp0 (g_hash_table_lookup (hash, "is_connected"), "True") == 0);
 
83
                syncdaemon_status_info_set_online (
 
84
                        sinfo,
 
85
                        g_strcmp0 (g_hash_table_lookup (hash, "is_online"), "True") == 0);
 
86
                syncdaemon_status_info_set_name (sinfo, g_hash_table_lookup (hash, "name"));
 
87
                syncdaemon_status_info_set_queues (sinfo, g_hash_table_lookup (hash, "queues"));
 
88
        }
 
89
 
 
90
        return sinfo;
 
91
}
 
92
 
 
93
/**
 
94
 * syncdaemon_status_info_get_connected:
 
95
 */
 
96
gboolean
 
97
syncdaemon_status_info_get_connected (SyncdaemonStatusInfo *sinfo)
 
98
{
 
99
        g_return_val_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo), FALSE);
 
100
 
 
101
        return sinfo->priv->is_connected;
 
102
}
 
103
 
 
104
/**
 
105
 * syncdaemon_status_info_set_connected:
 
106
 */
 
107
void
 
108
syncdaemon_status_info_set_connected (SyncdaemonStatusInfo *sinfo, gboolean connected)
 
109
{
 
110
        g_return_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo));
 
111
 
 
112
        sinfo->priv->is_connected = connected;
 
113
}
 
114
 
 
115
/**
 
116
 * syncdaemon_status_info_get_description:
 
117
 */
 
118
const gchar *
 
119
syncdaemon_status_info_get_description (SyncdaemonStatusInfo *sinfo)
 
120
{
 
121
        g_return_val_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo), NULL);
 
122
 
 
123
        return (const gchar *) sinfo->priv->description;
 
124
}
 
125
 
 
126
/**
 
127
 * syncdaemon_status_info_set_description:
 
128
 */
 
129
void
 
130
syncdaemon_status_info_set_description (SyncdaemonStatusInfo *sinfo, const gchar *description)
 
131
{
 
132
        g_return_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo));
 
133
 
 
134
        if (sinfo->priv->description != NULL)
 
135
                g_free (sinfo->priv->description);
 
136
 
 
137
        sinfo->priv->description = g_strdup (description);
 
138
}
 
139
 
 
140
/**
 
141
 * syncdaemon_status_info_get_name:
 
142
 */
 
143
const gchar *
 
144
syncdaemon_status_info_get_name (SyncdaemonStatusInfo *sinfo)
 
145
{
 
146
        g_return_val_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo), NULL);
 
147
 
 
148
        return (const gchar *) sinfo->priv->name;
 
149
}
 
150
 
 
151
/**
 
152
 * syncdaemon_status_info_set_name:
 
153
 */
 
154
void
 
155
syncdaemon_status_info_set_name (SyncdaemonStatusInfo *sinfo, const gchar *name)
 
156
{
 
157
        g_return_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo));
 
158
 
 
159
        if (sinfo->priv->name != NULL)
 
160
                g_free (sinfo->priv->name);
 
161
 
 
162
        sinfo->priv->name = g_strdup (name);
 
163
}
 
164
 
 
165
/**
 
166
 * syncdaemon_status_info_get_online:
 
167
 */
 
168
gboolean
 
169
syncdaemon_status_info_get_online (SyncdaemonStatusInfo *sinfo)
 
170
{
 
171
        g_return_val_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo), FALSE);
 
172
 
 
173
        return sinfo->priv->is_online;
 
174
}
 
175
 
 
176
/**
 
177
 * syncdaemon_status_info_set_online:
 
178
 */
 
179
void
 
180
syncdaemon_status_info_set_online (SyncdaemonStatusInfo *sinfo, gboolean online)
 
181
{
 
182
        g_return_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo));
 
183
 
 
184
        sinfo->priv->is_online = online;
 
185
}
 
186
 
 
187
/**
 
188
 * syncdaemon_status_info_get_queues:
 
189
 */
 
190
const gchar *
 
191
syncdaemon_status_info_get_queues (SyncdaemonStatusInfo *sinfo)
 
192
{
 
193
        g_return_val_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo), NULL);
 
194
 
 
195
        return (const gchar *) sinfo->priv->queues;
 
196
}
 
197
 
 
198
/**
 
199
 * syncdaemon_status_info_set_queues:
 
200
 */
 
201
void
 
202
syncdaemon_status_info_set_queues (SyncdaemonStatusInfo *sinfo, const gchar *queues)
 
203
{
 
204
        g_return_if_fail (SYNCDAEMON_IS_STATUS_INFO (sinfo));
 
205
 
 
206
        if (sinfo->priv->queues != NULL)
 
207
                g_free (sinfo->priv->queues);
 
208
 
 
209
        sinfo->priv->queues = g_strdup (queues);
 
210
}