diff options
author | Chenthill Palanisamy <pchen@src.gnome.org> | 2006-01-25 15:29:18 +0800 |
---|---|---|
committer | Chenthill Palanisamy <pchen@src.gnome.org> | 2006-01-25 15:29:18 +0800 |
commit | dbfb80ad80a6cdbf624582a8f154a12227b3459b (patch) | |
tree | 9399a52e57e9fa60810dbe733c3737de68541db5 | |
parent | 49477d1708a89e9fc2d939b54b894d69624e8d0f (diff) | |
download | gsoc2013-evolution-dbfb80ad80a6cdbf624582a8f154a12227b3459b.tar.gz gsoc2013-evolution-dbfb80ad80a6cdbf624582a8f154a12227b3459b.tar.zst gsoc2013-evolution-dbfb80ad80a6cdbf624582a8f154a12227b3459b.zip |
Fixes #328224, 328408, 328389
svn path=/trunk/; revision=31303
-rw-r--r-- | plugins/publish-calendar/ChangeLog | 12 | ||||
-rw-r--r-- | plugins/publish-calendar/publish-calendar.c | 81 | ||||
-rw-r--r-- | plugins/publish-calendar/publish-location.c | 15 |
3 files changed, 81 insertions, 27 deletions
diff --git a/plugins/publish-calendar/ChangeLog b/plugins/publish-calendar/ChangeLog index 5166555a80..2435eebe1e 100644 --- a/plugins/publish-calendar/ChangeLog +++ b/plugins/publish-calendar/ChangeLog @@ -1,3 +1,15 @@ +2006-01-23 Chenthill Palanisamy <pchenthill@novell.com> + + Fixes #328224, 328408, 328389 + * publish-calendar.c: (publish_uri_async), (url_add_clicked), + (url_edit_clicked), , + (publish_uris_set_timeout), (e_plugin_lib_enable): Publish + the calendar in a seperate thread so that the gui remains + responsive. + (publish_calendar_locations): Clear the items gtk store. + * publish-location.c: (migrateURI), (e_publish_uri_from_xml): + If the uri is NULL return back. + 2006-01-11 Chenthill Palanisamy <pchenthill@novell.com> Fixes #325926 diff --git a/plugins/publish-calendar/publish-calendar.c b/plugins/publish-calendar/publish-calendar.c index 8e2962da4c..9ca1713ea2 100644 --- a/plugins/publish-calendar/publish-calendar.c +++ b/plugins/publish-calendar/publish-calendar.c @@ -47,6 +47,20 @@ void online_state_changed (EPlugin *ep, ESEventTargetState *target); void publish_calendar_context_activate (EPlugin *ep, ECalPopupTargetSource *target); GtkWidget *publish_calendar_locations (EPlugin *epl, EConfigHookItemFactoryData *data); static void update_timestamp (EPublishUri *uri); +static void publish (EPublishUri *uri); + +static void +publish_uri_async (EPublishUri *uri) +{ + GThread *thread = NULL; + GError *error = NULL; + + thread = g_thread_create ((GThreadFunc) publish, uri, FALSE, &error); + if (!thread) { + g_warning (G_STRLOC ": %s", error->message); + g_error_free (error); + } +} static void publish (EPublishUri *uri) @@ -304,7 +318,7 @@ url_add_clicked (GtkButton *button, PublishUIData *ui) url_list_changed (ui); publish_uris = g_slist_prepend (publish_uris, uri); add_timeout (uri); - publish (uri); + publish_uri_async (uri); } else { g_free (uri); } @@ -338,7 +352,7 @@ url_edit_clicked (GtkButton *button, PublishUIData *ui) g_source_remove (id); add_timeout (uri); url_list_changed (ui); - publish (uri); + publish_uri_async (uri); } } @@ -450,6 +464,9 @@ publish_calendar_locations (EPlugin *epl, EConfigHookItemFactoryData *data) ui->treeview = glade_xml_get_widget (xml, "url list"); if (store == NULL) store = gtk_list_store_new (URL_LIST_N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); + else + gtk_list_store_clear (store); + gtk_tree_view_set_model (GTK_TREE_VIEW (ui->treeview), GTK_TREE_MODEL (store)); renderer = gtk_cell_renderer_toggle_new (); @@ -530,39 +547,53 @@ action_publish (EPlugin *ep, ECalMenuTargetSelect *t) } -int -e_plugin_lib_enable (EPlugin *ep, int enable) +static void +publish_uris_set_timeout (GSList *uris) { - GSList *uris, *l; - GConfClient *client; + GSList *l; - if (enable) { - client = gconf_client_get_default (); - uris = gconf_client_get_list (client, "/apps/evolution/calendar/publish/uris", GCONF_VALUE_STRING, NULL); + uri_timeouts = g_hash_table_new (g_direct_hash, g_direct_equal); + l = uris; - uri_timeouts = g_hash_table_new (g_direct_hash, g_direct_equal); + while (l) { + gchar *xml = l->data; - l = uris; - while (l) { - gchar *xml = l->data; + EPublishUri *uri = e_publish_uri_from_xml (xml); - EPublishUri *uri = e_publish_uri_from_xml (xml); + if (!uri->location) { + g_free (uri); + continue; + } - if (!uri->location) { - g_free (uri); - continue; - } + publish_uris = g_slist_prepend (publish_uris, uri); - publish_uris = g_slist_prepend (publish_uris, uri); + /* Add a timeout based on the last publish time */ + add_offset_timeout (uri); - /* Add a timeout based on the last publish time */ - add_offset_timeout (uri); + l = g_slist_next (l); + } + g_slist_foreach (uris, (GFunc) g_free, NULL); + g_slist_free (uris); +} + +int +e_plugin_lib_enable (EPlugin *ep, int enable) +{ + GSList *uris; + GConfClient *client; + + if (enable) { + GThread *thread = NULL; + GError *error = NULL; - l = g_slist_next (l); - } - g_slist_foreach (uris, (GFunc) g_free, NULL); - g_slist_free (uris); + client = gconf_client_get_default (); + uris = gconf_client_get_list (client, "/apps/evolution/calendar/publish/uris", GCONF_VALUE_STRING, NULL); + thread = g_thread_create ((GThreadFunc) publish_uris_set_timeout, uris, FALSE, &error); + if (!thread) { + g_warning ("Could create thread to set timeout for publishing uris : %s", error->message); + g_error_free (error); + } g_object_unref (client); } diff --git a/plugins/publish-calendar/publish-location.c b/plugins/publish-calendar/publish-location.c index 4c2b36780b..fef67e7a08 100644 --- a/plugins/publish-calendar/publish-location.c +++ b/plugins/publish-calendar/publish-location.c @@ -60,6 +60,12 @@ migrateURI (const gchar *xml, xmlDocPtr doc) username = xmlGetProp (root, "username"); vfs_uri = gnome_vfs_uri_new (location); + + if (!vfs_uri) { + g_warning ("Could not form the uri for %s \n", location); + goto cleanup; + } + gnome_vfs_uri_set_user_name (vfs_uri, username); temp = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD | GNOME_VFS_URI_HIDE_PASSWORD); uri->location = g_strdup_printf ("dav://%s", temp); @@ -95,9 +101,11 @@ migrateURI (const gchar *xml, xmlDocPtr doc) g_slist_free (uris); g_object_unref (client); +cleanup: xmlFree (location); xmlFree (enabled); xmlFree (frequency); + xmlFree (username); xmlFreeDoc (doc); return uri; @@ -109,7 +117,7 @@ e_publish_uri_from_xml (const gchar *xml) xmlDocPtr doc; xmlNodePtr root, p; xmlChar *location, *enabled, *frequency; - xmlChar *publish_time, *format; + xmlChar *publish_time, *format, *username = NULL; GSList *events = NULL; EPublishUri *uri; @@ -121,8 +129,11 @@ e_publish_uri_from_xml (const gchar *xml) if (strcmp (root->name, "uri") != 0) return NULL; - if (xmlGetProp (root, "username")) + if ((username = xmlGetProp (root, "username"))) { + xmlFree (username); return migrateURI (xml, doc); + + } uri = g_new0 (EPublishUri, 1); |