~ubuntu-branches/ubuntu/oneiric/ubuntuone-client/oneiric

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Moya
  • Date: 2010-06-23 23:08:15 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20100623230815-4m3ugh10u9x9xzw5
Tags: upstream-1.3.2
ImportĀ upstreamĀ versionĀ 1.3.2

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-folder-info.h"
 
23
 
 
24
G_DEFINE_TYPE(SyncdaemonFolderInfo, syncdaemon_folder_info, G_TYPE_OBJECT)
 
25
 
 
26
struct _SyncdaemonFolderInfoPrivate {
 
27
        gchar *path;
 
28
        gboolean subscribed;
 
29
        gchar *volume_id;
 
30
};
 
31
 
 
32
static void
 
33
syncdaemon_folder_info_finalize (GObject *object)
 
34
{
 
35
        SyncdaemonFolderInfo *finfo = SYNCDAEMON_FOLDER_INFO (object);
 
36
 
 
37
        if (finfo->priv != NULL) {
 
38
                if (finfo->priv->path != NULL)
 
39
                        g_free (finfo->priv->path);
 
40
 
 
41
                if (finfo->priv->volume_id != NULL)
 
42
                        g_free (finfo->priv->volume_id);
 
43
 
 
44
                g_free (finfo->priv);
 
45
        }
 
46
 
 
47
        G_OBJECT_CLASS (syncdaemon_folder_info_parent_class)->finalize (object);
 
48
}
 
49
 
 
50
static void
 
51
syncdaemon_folder_info_class_init (SyncdaemonFolderInfoClass *klass)
 
52
{
 
53
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
54
 
 
55
        object_class->finalize = syncdaemon_folder_info_finalize;
 
56
}
 
57
 
 
58
static void
 
59
syncdaemon_folder_info_init (SyncdaemonFolderInfo *finfo)
 
60
{
 
61
        finfo->priv = g_new0 (SyncdaemonFolderInfoPrivate, 1);
 
62
}
 
63
 
 
64
/**
 
65
 * syncdaemon_folder_info_new:
 
66
 */
 
67
SyncdaemonFolderInfo *
 
68
syncdaemon_folder_info_new (void)
 
69
{
 
70
        return g_object_new (SYNCDAEMON_TYPE_FOLDER_INFO, NULL);
 
71
}
 
72
 
 
73
/**
 
74
 * syncdaemon_folder_info_new_from_hash_table:
 
75
 */
 
76
SyncdaemonFolderInfo *
 
77
syncdaemon_folder_info_new_from_hash_table (GHashTable *hash)
 
78
{
 
79
        SyncdaemonFolderInfo *finfo;
 
80
 
 
81
        finfo = g_object_new (SYNCDAEMON_TYPE_FOLDER_INFO, NULL);
 
82
        if (hash != NULL) {
 
83
                syncdaemon_folder_info_set_path (finfo, g_hash_table_lookup (hash, "path"));
 
84
                syncdaemon_folder_info_set_subscribed (
 
85
                        finfo,
 
86
                        g_strcmp0 (g_hash_table_lookup (hash, "subscribed"), "True") == 0);
 
87
                syncdaemon_folder_info_set_volume_id (finfo, g_hash_table_lookup (hash, "volume_id"));
 
88
        }
 
89
 
 
90
        return finfo;
 
91
}
 
92
 
 
93
/**
 
94
 * syncdaemon_folder_info_get_path:
 
95
 */
 
96
const gchar *
 
97
syncdaemon_folder_info_get_path (SyncdaemonFolderInfo *finfo)
 
98
{
 
99
        g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), NULL);
 
100
 
 
101
        return (const gchar *) finfo->priv->path;
 
102
}
 
103
 
 
104
/**
 
105
 * syncdaemon_folder_info_set_path:
 
106
 */
 
107
void
 
108
syncdaemon_folder_info_set_path (SyncdaemonFolderInfo *finfo, const gchar *path)
 
109
{
 
110
        g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
 
111
 
 
112
        if (finfo->priv->path != NULL)
 
113
                g_free (finfo->priv->path);
 
114
 
 
115
        finfo->priv->path = g_strdup (path);
 
116
}
 
117
 
 
118
/**
 
119
 * syncdaemon_folder_info_get_subscribed:
 
120
 */
 
121
gboolean
 
122
syncdaemon_folder_info_get_subscribed (SyncdaemonFolderInfo *finfo)
 
123
{
 
124
        g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), FALSE);
 
125
 
 
126
        return finfo->priv->subscribed;
 
127
}
 
128
 
 
129
/**
 
130
 * syncdaemon_folder_info_set_subscribed:
 
131
 */
 
132
void
 
133
syncdaemon_folder_info_set_subscribed (SyncdaemonFolderInfo *finfo, gboolean subscribed)
 
134
{
 
135
        g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
 
136
 
 
137
        finfo->priv->subscribed = subscribed;
 
138
}
 
139
 
 
140
/**
 
141
 * syncdaemon_folder_info_get_volume_id:
 
142
 */
 
143
const gchar *
 
144
syncdaemon_folder_info_get_volume_id (SyncdaemonFolderInfo *finfo)
 
145
{
 
146
        g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), NULL);
 
147
 
 
148
        return (const gchar *) finfo->priv->volume_id;
 
149
}
 
150
 
 
151
/**
 
152
 * syncdaemon_folder_info_set_volume_id:
 
153
 */
 
154
void
 
155
syncdaemon_folder_info_set_volume_id (SyncdaemonFolderInfo *finfo, const gchar *volume_id)
 
156
{
 
157
        g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
 
158
 
 
159
        if (finfo->priv->volume_id != NULL)
 
160
                g_free (finfo->priv->volume_id);
 
161
 
 
162
        finfo->priv->volume_id = g_strdup (volume_id);
 
163
}