~ubuntuone-control-tower/ubuntuone-client/trunk

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Diego Sarmentero, Rodney Dawes
  • Date: 2014-04-11 14:23:37 UTC
  • mfrom: (1403.1.8 ubuntuone-client)
  • Revision ID: tarmac-20140411142337-vg6lk4a6a5au0jag
- Show a message when the client is started indicating that the service will be suspended on June 1st.
- After June 1st, don't contact the server.

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-2012 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
 
 * In addition, as a special exception, the copyright holders give
21
 
 * permission to link the code of portions of this program with the
22
 
 * OpenSSL library under certain conditions as described in each
23
 
 * individual source file, and distribute linked combinations
24
 
 * including the two.
25
 
 * You must obey the GNU General Public License in all respects
26
 
 * for all of the code used other than OpenSSL.  If you modify
27
 
 * file(s) with this exception, you may extend this exception to your
28
 
 * version of the file(s), but you are not obligated to do so.  If you
29
 
 * do not wish to do so, delete this exception statement from your
30
 
 * version.  If you delete this exception statement from all source
31
 
 * files in the program, then also delete it here.
32
 
 *
33
 
 */
34
 
 
35
 
#include "syncdaemon-folder-info.h"
36
 
 
37
 
G_DEFINE_TYPE(SyncdaemonFolderInfo, syncdaemon_folder_info, G_TYPE_OBJECT)
38
 
 
39
 
struct _SyncdaemonFolderInfoPrivate {
40
 
        gchar *path;
41
 
        gboolean subscribed;
42
 
        gchar *volume_id;
43
 
};
44
 
 
45
 
static void
46
 
syncdaemon_folder_info_finalize (GObject *object)
47
 
{
48
 
        SyncdaemonFolderInfo *finfo = SYNCDAEMON_FOLDER_INFO (object);
49
 
 
50
 
        if (finfo->priv != NULL) {
51
 
                if (finfo->priv->path != NULL)
52
 
                        g_free (finfo->priv->path);
53
 
 
54
 
                if (finfo->priv->volume_id != NULL)
55
 
                        g_free (finfo->priv->volume_id);
56
 
 
57
 
                g_free (finfo->priv);
58
 
        }
59
 
 
60
 
        G_OBJECT_CLASS (syncdaemon_folder_info_parent_class)->finalize (object);
61
 
}
62
 
 
63
 
static void
64
 
syncdaemon_folder_info_class_init (SyncdaemonFolderInfoClass *klass)
65
 
{
66
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
67
 
 
68
 
        object_class->finalize = syncdaemon_folder_info_finalize;
69
 
}
70
 
 
71
 
static void
72
 
syncdaemon_folder_info_init (SyncdaemonFolderInfo *finfo)
73
 
{
74
 
        finfo->priv = g_new0 (SyncdaemonFolderInfoPrivate, 1);
75
 
}
76
 
 
77
 
/**
78
 
 * syncdaemon_folder_info_new:
79
 
 */
80
 
SyncdaemonFolderInfo *
81
 
syncdaemon_folder_info_new (void)
82
 
{
83
 
        return g_object_new (SYNCDAEMON_TYPE_FOLDER_INFO, NULL);
84
 
}
85
 
 
86
 
/**
87
 
 * syncdaemon_folder_info_new_from_hash_table:
88
 
 */
89
 
SyncdaemonFolderInfo *
90
 
syncdaemon_folder_info_new_from_hash_table (GHashTable *hash)
91
 
{
92
 
        SyncdaemonFolderInfo *finfo;
93
 
 
94
 
        finfo = g_object_new (SYNCDAEMON_TYPE_FOLDER_INFO, NULL);
95
 
        if (hash != NULL) {
96
 
                syncdaemon_folder_info_set_path (finfo, g_hash_table_lookup (hash, "path"));
97
 
                syncdaemon_folder_info_set_subscribed (
98
 
                        finfo,
99
 
                        g_strcmp0 (g_hash_table_lookup (hash, "subscribed"), "True") == 0);
100
 
                syncdaemon_folder_info_set_volume_id (finfo, g_hash_table_lookup (hash, "volume_id"));
101
 
        }
102
 
 
103
 
        return finfo;
104
 
}
105
 
 
106
 
/**
107
 
 * syncdaemon_folder_info_get_path:
108
 
 */
109
 
const gchar *
110
 
syncdaemon_folder_info_get_path (SyncdaemonFolderInfo *finfo)
111
 
{
112
 
        g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), NULL);
113
 
 
114
 
        return (const gchar *) finfo->priv->path;
115
 
}
116
 
 
117
 
/**
118
 
 * syncdaemon_folder_info_set_path:
119
 
 */
120
 
void
121
 
syncdaemon_folder_info_set_path (SyncdaemonFolderInfo *finfo, const gchar *path)
122
 
{
123
 
        g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
124
 
 
125
 
        if (finfo->priv->path != NULL)
126
 
                g_free (finfo->priv->path);
127
 
 
128
 
        finfo->priv->path = g_strdup (path);
129
 
}
130
 
 
131
 
/**
132
 
 * syncdaemon_folder_info_get_subscribed:
133
 
 */
134
 
gboolean
135
 
syncdaemon_folder_info_get_subscribed (SyncdaemonFolderInfo *finfo)
136
 
{
137
 
        g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), FALSE);
138
 
 
139
 
        return finfo->priv->subscribed;
140
 
}
141
 
 
142
 
/**
143
 
 * syncdaemon_folder_info_set_subscribed:
144
 
 */
145
 
void
146
 
syncdaemon_folder_info_set_subscribed (SyncdaemonFolderInfo *finfo, gboolean subscribed)
147
 
{
148
 
        g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
149
 
 
150
 
        finfo->priv->subscribed = subscribed;
151
 
}
152
 
 
153
 
/**
154
 
 * syncdaemon_folder_info_get_volume_id:
155
 
 */
156
 
const gchar *
157
 
syncdaemon_folder_info_get_volume_id (SyncdaemonFolderInfo *finfo)
158
 
{
159
 
        g_return_val_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo), NULL);
160
 
 
161
 
        return (const gchar *) finfo->priv->volume_id;
162
 
}
163
 
 
164
 
/**
165
 
 * syncdaemon_folder_info_set_volume_id:
166
 
 */
167
 
void
168
 
syncdaemon_folder_info_set_volume_id (SyncdaemonFolderInfo *finfo, const gchar *volume_id)
169
 
{
170
 
        g_return_if_fail (SYNCDAEMON_IS_FOLDER_INFO (finfo));
171
 
 
172
 
        if (finfo->priv->volume_id != NULL)
173
 
                g_free (finfo->priv->volume_id);
174
 
 
175
 
        finfo->priv->volume_id = g_strdup (volume_id);
176
 
}