[evolution-rss] fix gecko exclusive lock on cookies db



commit ff1802b192ebfbd72184ecdd5a0f0edbfe6a2e72
Author: Lucian Langa <lucilanga gnome org>
Date:   Wed Jul 1 23:02:09 2009 +0300

    fix gecko exclusive lock on cookies db

 src/network-soup.c       |   39 +++++++++++++++++++++++++++++----------
 src/network-soup.h       |    2 ++
 src/rss-config-factory.c |    4 +++-
 src/rss.c                |   14 +++++++-------
 4 files changed, 41 insertions(+), 18 deletions(-)
---
diff --git a/src/network-soup.c b/src/network-soup.c
index 15cb356..3081d4d 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -239,9 +239,9 @@ proxify_session(EProxy *proxy, SoupSession *session, gchar *uri)
 		if (e_proxy_require_proxy_for_uri (proxy, uri)) {
 			proxy_uri = e_proxy_peek_uri_for (proxy, uri);
 			if (proxy_uri)
-				g_print("proxified %s with %s:%d\n", uri, proxy_uri->host, proxy_uri->port);
+				d(g_print("proxified %s with %s:%d\n", uri, proxy_uri->host, proxy_uri->port));
 		} else 
-			g_print("no PROXY-%s\n", uri);
+			d(g_print("no PROXY-%s\n", uri));
 		g_object_set (G_OBJECT (session), SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
 		break;
 
@@ -716,6 +716,28 @@ abort_all_soup(void)
 }
 
 void
+sync_gecko_cookies(void)
+{
+	//this currently sux as firefox 3.5b will open
+	//cookie database file exclusively, that means import will fail
+	//even fetch will fail - we should copy this file separately for
+	//gecko renderer
+	//symlink(cookie_path, moz_cookie_path);
+	GFile *cookie_file, *moz_cookie_file;
+	gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
+	gchar *cookie_path = g_build_path("/", feed_dir, "rss-cookies.sqlite", NULL);
+	gchar *moz_cookie_path = g_build_path("/", feed_dir, "mozembed-rss", "cookies.sqlite", NULL);
+
+	cookie_file = g_file_new_for_path (cookie_path);
+	moz_cookie_file = g_file_new_for_path (moz_cookie_path);
+	g_file_copy(cookie_file, moz_cookie_file, 
+			G_FILE_COPY_OVERWRITE,
+			NULL, NULL, NULL, NULL);
+	g_free(cookie_path);
+	g_free(moz_cookie_path);
+}
+
+void
 rss_soup_init(void)
 {
 #if LIBSOUP_VERSION > 2026002 && defined(HAVE_LIBSOUP_GNOME) 
@@ -723,18 +745,15 @@ rss_soup_init(void)
 		gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
 		gchar *cookie_path = g_build_path("/", feed_dir, "rss-cookies.sqlite", NULL);
 		gchar *moz_cookie_path = g_build_path("/", feed_dir, "mozembed-rss", "cookies.sqlite", NULL);
-		if (!g_file_test(moz_cookie_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_SYMLINK)) {
-
-			//this currently sux as firefox 3.5b will open
-			//cookie database file exclusively, that means import will fail
-			//even fetch will fail - we should copy this file separately for
-			//gecko renderer
-			symlink(cookie_path, moz_cookie_path);
-		}
 
 		rss_soup_jar = 
 			soup_cookie_jar_sqlite_new (cookie_path, FALSE);
+
+		if (!g_file_test(moz_cookie_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_SYMLINK)) {
+			sync_gecko_cookies();
+		}
 		g_free(cookie_path);
+		g_free(moz_cookie_path);
 	}
 #endif
 }
diff --git a/src/network-soup.h b/src/network-soup.h
index f9405d6..9cc3dfb 100644
--- a/src/network-soup.h
+++ b/src/network-soup.h
@@ -44,3 +44,5 @@ guint del_up(gpointer data);
 void rss_soup_init(void);
 EProxy *proxy_init(void);
 guint read_up(gpointer data);
+void sync_gecko_cookies(void);
+
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index d2c76f9..6946c84 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -1639,7 +1639,7 @@ import_cookies(gchar *file)
 	SoupCookieJar *jar = NULL;
 	gchar header[16];
 	memset(header, 0, 16);
-	g_print("import cookies from %s\n", file);
+	d(g_print("import cookies from %s\n", file));
 	FILE *f = fopen(file, "r");
 	if (f) {
 		fgets(header, 16, f);
@@ -1699,6 +1699,8 @@ process_cookies(SoupCookieJar *jar)
 	//reset cancel signal
 	rf->cancel = 0;
 	gtk_widget_destroy(import_dialog);
+	//copy gecko data over (gecko will open database locked exclusively)
+	sync_gecko_cookies();
 }
 
 static void
diff --git a/src/rss.c b/src/rss.c
index 5008bf9..d04af24 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -584,7 +584,7 @@ create_user_pass_dialog(RSS_AUTH *auth)
         gtk_dialog_set_default_response (
                 GTK_DIALOG (widget), GTK_RESPONSE_OK);
         gtk_window_set_resizable (GTK_WINDOW (widget), FALSE);
-//        gtk_window_set_transient_for (GTK_WINDOW (widget), msg->parent);
+        gtk_window_set_transient_for (GTK_WINDOW (widget), widget->parent);
         gtk_window_set_position (GTK_WINDOW (widget), GTK_WIN_POS_CENTER_ON_PARENT);
         gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
         GtkWidget *password_dialog = GTK_WIDGET (widget);
@@ -752,14 +752,14 @@ web_auth_dialog(gchar *url)
 		else
 			del_up(url);
 	
-        	gtk_widget_destroy (GTK_WIDGET(dialog));
 		resp = 0;
         	break;
     	default:
-        	gtk_widget_destroy (GTK_WIDGET(dialog));
+		g_print("destroy\n");
 		resp = 1;
         	break;
 	}
+       	gtk_widget_destroy (GTK_WIDGET(dialog));
 	g_free(auth_info);
 	return resp;
 }
@@ -2484,7 +2484,6 @@ top:	d(g_print("adding feed->feed_url:%s\n", feed->feed_url));
 		//and later display the actual feed (once rf-> structure is
 		//properly populated
 		chn_name = process_feed(r);
-	g_print("add chn_name:%s\n", chn_name);
 add:
 		//feed name can only come from an import so we rather prefer
 		//resulted channel name instead of supplied one
@@ -2494,9 +2493,9 @@ add:
                 if (chn_name == NULL)
                         chn_name = g_strdup (_(DEFAULT_NO_CHANNEL));
                 //FIXME g_free
-		gchar *tmp = sanitize_folder(chn_name);
 		tmp_chn_name = chn_name;
-		chn_name = tmp;
+		chn_name = sanitize_folder(chn_name);
+		g_free(chn_name);
                	chn_name = generate_safe_chn_name(chn_name);
 		
 		gpointer crc_feed = gen_md5(feed->feed_url);
@@ -2745,6 +2744,7 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 	GString *response = g_string_new_len(msg->body, msg->length);
 
 	g_print("feed %s\n", (gchar *)user_data);
+	goto out;
 
 	while (gtk_events_pending ())
             gtk_main_iteration ();
@@ -2880,7 +2880,7 @@ fetch_feed(gpointer key, gpointer value, gpointer user_data)
 	//exclude feeds that have special update interval or 
 	//no update at all
 	if (GPOINTER_TO_INT(g_hash_table_lookup(rf->hrupdate, lookup_key(key))) >= 2
-	&& !force_update)
+		&& !force_update)
 		return 0;
 
 	return fetch_one_feed(key, value, user_data);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]