gswitchit_plugins r102 - in trunk: . flags



Author: svu
Date: Wed Mar 26 00:03:24 2008
New Revision: 102
URL: http://svn.gnome.org/viewvc/gswitchit_plugins?rev=102&view=rev

Log:
Switching to libsoup 2.4

Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/flags/flags.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Wed Mar 26 00:03:24 2008
@@ -29,7 +29,7 @@
 AC_HEADER_STDC
 AM_PROG_LIBTOOL
 
-PKG_CHECK_MODULES(LINKED_GNOME, gdk-pixbuf-2.0 libglade-2.0 gconf-2.0 gmodule-2.0 libgnomeui-2.0 libgnomekbd >= 2.18.0 libsoup-2.2 cairo librsvg-2.0)
+PKG_CHECK_MODULES(LINKED_GNOME, gdk-pixbuf-2.0 libglade-2.0 gconf-2.0 gmodule-2.0 libgnomeui-2.0 libgnomekbd >= 2.18.0 libsoup-2.4 cairo librsvg-2.0)
 
 AC_SUBST(LINKED_GNOME_CFLAGS)
 AC_SUBST(LINKED_GNOME_LIBS)

Modified: trunk/flags/flags.c
==============================================================================
--- trunk/flags/flags.c	(original)
+++ trunk/flags/flags.c	Wed Mar 26 00:03:24 2008
@@ -29,9 +29,9 @@
 extern gchar GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS[];
 
 #ifdef LOCALURL
-  #define FLAGS_URL "http://localhost/sodipodi-flags-1.6.tar.bz2";
+#define FLAGS_URL "http://localhost/sodipodi-flags-1.6.tar.bz2";
 #else
-  #define FLAGS_URL "http://internap.dl.sourceforge.net/sourceforge/sodipodi/sodipodi-flags-1.6.tar.bz2";
+#define FLAGS_URL "http://internap.dl.sourceforge.net/sourceforge/sodipodi/sodipodi-flags-1.6.tar.bz2";
 #endif
 
 #define SCRIPTER_EXEC "perl"
@@ -53,7 +53,8 @@
 	GError *gerror = NULL;
 	showFlags =
 	    gconf_client_get_bool (container->conf_client,
-				   GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS, &gerror);
+				   GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS,
+				   &gerror);
 	if (gerror != NULL) {
 		if (gerror != NULL) {
 			g_warning ("Error reading configuration:%s\n",
@@ -72,7 +73,9 @@
 
 	cs = gconf_change_set_new ();
 
-	gconf_change_set_set_bool (cs, GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS, showFlags);
+	gconf_change_set_set_bool (cs,
+				   GKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS,
+				   showFlags);
 
 	gconf_client_commit_change_set (container->conf_client, cs, TRUE,
 					&gerror);
@@ -183,7 +186,7 @@
 }
 
 static void
-GotFile (SoupMessage * msg)
+GotFile (SoupSession * session, SoupMessage * msg)
 {
 	gchar *errMsg = NULL;
 
@@ -194,14 +197,15 @@
 	    GPOINTER_TO_INT (g_object_get_data
 			     (G_OBJECT (msg), "totalSize"));
 
-	printf ("Got the file %s of size %d/current %d/total %d\n",
-		soup_message_get_uri (msg)->path, msg->response.length,
+	int responseBodyLength = msg->response_body->length;
+	printf ("Got the file %s, resp body length %d/current size %d/total size %d\n",
+		soup_message_get_uri (msg)->path, responseBodyLength,
 		currentSize, totalSize);
-	printf ("status:%d[%s]\n", msg->status_code,
+	printf ("status: %d [%s]\n", msg->status_code,
 		soup_status_get_phrase (msg->status_code));
 
 	if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
-		if (currentSize == msg->response.length &&
+		if (currentSize == responseBodyLength &&
 		    (totalSize == 0 || totalSize == currentSize)) {
 			/* Only complete files are processed! */
 			gchar *tarname =
@@ -210,8 +214,8 @@
 					      NULL);
 			int fd = mkstemp (tarname);
 			gchar *perlPath;
-			write (fd, msg->response.body,
-			       msg->response.length);
+			write (fd, msg->response_body->data,
+			       responseBodyLength);
 			close (fd);
 			printf ("Copied to [%s]\n", tarname);
 			perlPath = g_find_program_in_path (SCRIPTER_EXEC);
@@ -307,17 +311,17 @@
 static void
 GotHeaders (SoupMessage * msg)
 {
-	GSList *cll = (GSList *)
-	    g_hash_table_lookup (msg->response_headers, "Content-Length");
-	if (cll != NULL) {
-		/* Here I assume that flags archive size fits into int. Bad assumption, isn't it? */
-		int tl = atoi (cll->data);
+	gint cl =
+	    (gint) soup_message_headers_get_content_length (msg->
+							    response_headers);
+	printf ("content length: %d\n", cl);
+	if (cl != 0) {
 		g_object_set_data (G_OBJECT (msg), "totalSize",
-				   GINT_TO_POINTER (tl));
+				   GINT_TO_POINTER (cl));
 		gtk_range_set_range (GTK_RANGE
 				     (glade_xml_get_widget
 				      (data, "downloadProgress")), 0,
-				     (int) (tl / 0.75));
+				     (int) (cl * 3 / 4));
 	} else
 		gtk_range_set_range (GTK_RANGE (glade_xml_get_widget
 						(data,
@@ -325,7 +329,6 @@
 				     2);
 	g_object_set_data (G_OBJECT (msg), "currentSize",
 			   GINT_TO_POINTER (0));
-/*	printf ("val: %d\n", 0);*/
 	gtk_range_set_value (GTK_RANGE (glade_xml_get_widget
 					(data, "downloadProgress")), 0);
 }
@@ -333,15 +336,11 @@
 static void
 GotMsgChunk (SoupMessage * msg)
 {
-	int cs =
-	    GPOINTER_TO_INT (g_object_get_data
-			     (G_OBJECT (msg), "currentSize"));
-	cs += msg->response.length;
+	int cs = msg->response_body->length;
 	g_object_set_data (G_OBJECT (msg), "currentSize",
 			   GINT_TO_POINTER (cs));
 	if (GPOINTER_TO_INT
 	    (g_object_get_data (G_OBJECT (msg), "totalSize"))) {
-/*		printf ("val: %d\n", cs);*/
 		gtk_range_set_value (GTK_RANGE (glade_xml_get_widget
 						(data,
 						 "downloadProgress")), cs);
@@ -351,7 +350,8 @@
 static void
 DoCancelDownloadFlags ()
 {
-	soup_session_cancel_message (soupSession, soupMessage);
+	soup_session_cancel_message (soupSession, soupMessage,
+				     SOUP_STATUS_CANCELLED);
 	EnableDisableDownloadButtons (FALSE);
 }
 
@@ -365,6 +365,7 @@
 		     SOUP_SESSION_PROXY_URI, NULL, NULL);
 	}
 
+	printf ("url: [%s]\n", FLAGS_URL);
 	soupMessage = soup_message_new (SOUP_METHOD_GET, FLAGS_URL);
 
 	g_signal_connect (G_OBJECT (soupMessage), "got_chunk",
@@ -373,7 +374,8 @@
 			  (GCallback) GotHeaders, NULL);
 
 	soup_session_queue_message (soupSession, soupMessage,
-				    (SoupMessageCallbackFn) GotFile, NULL);
+				    (SoupSessionCallback) GotFile, NULL);
+
 	EnableDisableDownloadButtons (TRUE);
 	SetDownloadStatus (dgettext (PACKAGE, "Downloading ..."));
 }



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