~didrocks/ubuntuone-client/dont-suffer-zg-crash

« back to all changes in this revision

Viewing changes to gsd-plugin/gsd-ubuntuone.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes, Chris Coulson
  • Date: 2011-04-10 21:24:30 UTC
  • mfrom: (1.1.49 upstream)
  • Revision ID: james.westby@ubuntu.com-20110410212430-u9txrycw32fbt0x2
Tags: 1.6.0-0ubuntu1
* New upstream release.
  - Avoid conflict when same file already exists locally (LP: #711389)
  - Must move fils to trash on deletion (LP: #690673)
  - Support disconnection during initial connect attempt (LP: #711211)
  - Log version number on startup (LP: #715455)
  - Memory usage too high (LP: #721483)
  - Unsubscribed folders show as synced, if they exist (LP: #741835)
  - gnome-settings-daemon crash in g_str_hash (LP: #744383)
  - Should not re-queue uploads directly (LP: #744608)
  - No feedback when creating folder from symlink fails (LP: #747299)
  - [FFE] Use API to set urgency from background process (LP: #747677)
  - Open control panel to volumes when quota exceeded (LP: #702176)
  - Set the launcher to urgent when quota exceeded (LP: #702183)
  - nautilus crash in g_str_hash (LP: #724882)
  - Disable/enable file sync is buggy (LP: #744980)

[Chris Coulson]
* gnome-settings-daemon crash in g_return_fail_if_warning (LP: #744980)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
G_DEFINE_TYPE (GsdUbuntuOne, gsd_ubuntuone, G_TYPE_OBJECT);
36
36
#endif
37
37
 
38
 
#define NO_SPACE _("Your Ubuntu One storage is full. Follow the link below to upgrade your subscription.")
39
 
#define NO_SPACE_SHARE _("There is no available space on the folder:\n\"%s\" shared by %s")
40
 
#define NO_SPACE_TITLE _("Out of space")
41
 
#define UPGRADE_SUBSCRIPTION_TEXT _("Upgrade Subscription")
42
 
#define UPGRADE_SUBSCRIPTION_URI "http://one.ubuntu.com/plans/"
43
38
#define CHECKED_BOOKMARK_FILE_KEY "/apps/gnome_settings_daemon/plugins/ubuntuone/checked_bookmark_file"
44
39
 
45
 
#define DAY_IN_SECONDS (60 * 60 * 24)
46
 
 
47
 
/* For passing data into a GSourceFunc */
48
 
typedef struct _GsdUbuntuOneData GsdUbuntuOneData;
49
 
 
50
 
struct _GsdUbuntuOneData
51
 
{
52
 
        GtkWidget *dialog;
53
 
        guint timeout_id;
54
 
        guint last_shown;
55
 
 
56
 
        gchar * message;
57
 
        gboolean show_upgrade_link;
58
 
};
59
 
 
60
 
static void
61
 
gsd_ubuntuone_data_free (GsdUbuntuOneData *data)
62
 
{
63
 
        if (data->dialog) {
64
 
                gtk_widget_destroy (data->dialog);
65
 
                data->dialog = NULL;
66
 
        }
67
 
 
68
 
        if (data->timeout_id) {
69
 
                g_source_remove (data->timeout_id);
70
 
                data->timeout_id = 0;
71
 
        }
72
 
 
73
 
        if (data->message)
74
 
                g_free (data->message);
75
 
 
76
 
        g_free (data);
77
 
}
78
 
 
79
 
 
80
 
static void
81
 
dialog_closed_callback (GtkDialog *dialog,
82
 
                        gint response_id,
83
 
                        gpointer user_data)
84
 
{
85
 
        GsdUbuntuOneData *data = (GsdUbuntuOneData *) (user_data);
86
 
 
87
 
        gtk_widget_destroy (GTK_WIDGET (data->dialog));
88
 
        data->dialog = NULL;
89
 
}
90
 
 
91
 
static gboolean
92
 
show_out_of_space_dialog (GsdUbuntuOneData *data)
93
 
{
94
 
        if ((time (NULL) - DAY_IN_SECONDS) < data->last_shown) {
95
 
                return FALSE;
96
 
        }
97
 
 
98
 
        if (data->dialog != NULL) {
99
 
                gtk_widget_show (GTK_WIDGET (data->dialog));
100
 
                return FALSE;
101
 
        }
102
 
 
103
 
        data->dialog = gtk_message_dialog_new (NULL,
104
 
                                               0,
105
 
                                               GTK_MESSAGE_WARNING,
106
 
                                               GTK_BUTTONS_CLOSE,
107
 
                                               "%s",
108
 
                                               data->message);
109
 
 
110
 
        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (data->dialog), FALSE);
111
 
        gtk_window_set_title (GTK_WINDOW (data->dialog), NO_SPACE_TITLE);
112
 
        gtk_window_set_icon_name (GTK_WINDOW (data->dialog), "ubuntuone");
113
 
        gtk_window_set_position (GTK_WINDOW (data->dialog), GTK_WIN_POS_CENTER);
114
 
 
115
 
        if (data->show_upgrade_link) {
116
 
                GtkWidget *upgrade_link;
117
 
 
118
 
                upgrade_link = gtk_link_button_new_with_label (UPGRADE_SUBSCRIPTION_URI,
119
 
                                                               UPGRADE_SUBSCRIPTION_TEXT);
120
 
                gtk_widget_show (GTK_WIDGET (upgrade_link));
121
 
                gtk_dialog_add_action_widget (GTK_DIALOG (data->dialog),
122
 
                                              upgrade_link, 0);
123
 
        }
124
 
 
125
 
        g_signal_connect (G_OBJECT (data->dialog), "response",
126
 
                          G_CALLBACK (dialog_closed_callback), data);
127
 
        gtk_widget_show (data->dialog);
128
 
 
129
 
        data->last_shown = time (NULL);
130
 
 
131
 
        return FALSE;
132
 
}
133
 
 
134
 
 
135
 
static void
136
 
quota_exceeded_callback (SyncdaemonDaemon *daemon,
137
 
                         GHashTable *file_info,
138
 
                         gpointer user_data)
139
 
{
140
 
        gchar *volume_type, *owner_id;
141
 
        GsdUbuntuOne *plugin = GSD_UBUNTUONE (user_data);
142
 
        GsdUbuntuOneData *data;
143
 
 
144
 
        volume_type = g_hash_table_lookup (file_info, "type");
145
 
        owner_id = g_hash_table_lookup (file_info, "owner_id");
146
 
        data = g_hash_table_lookup (plugin->map_quota_dialogs, owner_id);
147
 
 
148
 
        if (data == NULL) {
149
 
                data = g_new0 (GsdUbuntuOneData, 1);
150
 
 
151
 
                /* Set up the data to use in the dialog */
152
 
                if (g_strcmp0 (volume_type, "Share") == 0) {
153
 
                        gchar * other_visible_name, * path;
154
 
                        other_visible_name = g_hash_table_lookup (file_info, "other_visible_name");
155
 
                        path = g_hash_table_lookup (file_info, "path");
156
 
                        data->message = g_strdup_printf (NO_SPACE_SHARE, path, other_visible_name);
157
 
                        data->show_upgrade_link = FALSE;
158
 
                } else {
159
 
                        data->message = g_strdup (NO_SPACE);
160
 
                        data->show_upgrade_link = TRUE;
161
 
                }
162
 
                g_hash_table_replace (plugin->map_quota_dialogs, g_strdup (owner_id), data);
163
 
        }
164
 
 
165
 
        /* Set up the timeout for letting lots of signals queue */
166
 
        if (data->timeout_id != 0) {
167
 
                g_source_remove (data->timeout_id);
168
 
                data->timeout_id = 0;
169
 
        }
170
 
        data->timeout_id = g_timeout_add_seconds (10, (GSourceFunc) show_out_of_space_dialog, data);
171
 
}
172
 
 
173
40
static void
174
41
bookmark_file_loaded (GObject *source, GAsyncResult *res, gpointer user_data)
175
42
{
276
143
        plugin = GSD_UBUNTUONE (data);
277
144
 
278
145
        plugin->syncdaemon = syncdaemon_daemon_new ();
279
 
        g_signal_connect (G_OBJECT (plugin->syncdaemon), "quota_exceeded",
280
 
                          G_CALLBACK (quota_exceeded_callback), plugin);
281
146
 
282
147
        /* Check for authentication */
283
148
        auth = syncdaemon_daemon_get_authentication (plugin->syncdaemon);
290
155
static void
291
156
gsd_ubuntuone_init (GsdUbuntuOne *plugin)
292
157
{
293
 
        plugin->map_quota_dialogs = g_hash_table_new_full (g_str_hash,
294
 
                                                           g_str_equal,
295
 
                                                           g_free,
296
 
                                                           (GDestroyNotify) gsd_ubuntuone_data_free);
297
158
}
298
159
 
299
160
void
308
169
gsd_ubuntuone_dispose (GObject *object)
309
170
{
310
171
        GsdUbuntuOne *plugin = GSD_UBUNTUONE (object);
311
 
        GsdUbuntuOneClass *klass = GSD_UBUNTUONE_GET_CLASS (object);
312
 
        GObjectClass *parent_class = G_OBJECT_CLASS (klass);
313
172
 
314
173
        if (plugin->syncdaemon != NULL)
315
174
                g_object_unref (plugin->syncdaemon);
316
175
 
317
 
        if (plugin->map_quota_dialogs != NULL)
318
 
                g_hash_table_destroy (plugin->map_quota_dialogs);
319
 
 
320
 
        parent_class->dispose (object);
 
176
        G_OBJECT_CLASS (gsd_ubuntuone_parent_class)->dispose (object);
321
177
}
322
178
 
323
179
static void