/soc/2013/bhaskar/plugins-window: 5a6b98f8039a: Fixed some build...
Bhaskar Kandiyal
bkandiyal at gmail.com
Sun Sep 22 15:58:57 EDT 2013
Changeset: 5a6b98f8039acd457670a210298720d88ce59e13
Author: Bhaskar Kandiyal <bkandiyal at gmail.com>
Date: 2013-09-23 01:28 +0530
Branch: soc.2013.plugins_window
URL: https://hg.pidgin.im/soc/2013/bhaskar/plugins-window/rev/5a6b98f8039a
Description:
Fixed some build errors due to API change. Made the plugin installation better
diffstat:
pidgin/Makefile.am | 3 ++-
pidgin/gtkplugin-updater.c | 37 +++++++++++++++++++++++++------------
pidgin/gtkplugin-updater.h | 2 +-
pidgin/gtkplugin.c | 41 ++++++++++++++++++++++-------------------
4 files changed, 50 insertions(+), 33 deletions(-)
diffs (225 lines):
diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -183,7 +183,8 @@ pidgin_LDADD = \
$(WEBKIT_LIBS) \
$(GTK_LIBS) \
$(X11_LIBS) \
- $(top_builddir)/libpurple/libpurple.la
+ $(top_builddir)/libpurple/libpurple.la \
+ $(JSON_LIBS)
if USE_INTERNAL_LIBGADU
INTGG_CFLAGS = -DUSE_INTERNAL_LIBGADU
diff --git a/pidgin/gtkplugin-updater.c b/pidgin/gtkplugin-updater.c
--- a/pidgin/gtkplugin-updater.c
+++ b/pidgin/gtkplugin-updater.c
@@ -94,29 +94,37 @@ download_plugin_cb(PurpleHttpConnection
{
gchar *id = (gchar*) user_data;
gssize size;
- const gchar *data, *header;
+ const gchar *data, *header, *type;
gchar *path, *filename, *tmp_dir, *tmp_file;
GRegex *regex;
GMatchInfo *minfo;
+ GList *list;
+ int i;
- if(purple_http_response_is_successfull(response))
+ if(purple_http_response_is_successful(response))
{
data = purple_http_response_get_data(response, &size);
header = purple_http_response_get_header(response, "Content-Disposition");
- regex = g_regex_new("attachment; filename=\"(?<filename>.*)\"", G_REGEX_OPTIMIZE, 0, NULL);
+
+ purple_debug_info("updater", "Location: %s\n", purple_http_response_get_header(response, "Location"));
+ list = purple_http_response_get_all_headers(response);
+ for(i=0; i < g_list_length(list); i++)
+ {
+ purple_debug_info("updater", "%s\n", g_list_nth_data(list, i));
+ }
+
+ regex = g_regex_new("attachment; filename=\"?(?<type>.*)_(?<filename>.*)\"?", G_REGEX_OPTIMIZE, 0, NULL);
if(g_regex_match(regex, header, 0, &minfo))
{
filename = g_match_info_fetch_named(minfo, "filename");
- if(filename == NULL)
+ type = g_match_info_fetch_named(minfo, "type");
+ if(filename == NULL || type == NULL)
{
- purple_debug_info("updater", "Error: Cannot parse filename from header!");
+ purple_debug_info("updater", "Error: Cannot parse filename/type from header!");
return;
}
else
{
- header = purple_http_response_get_header(response, "Purple-Resource-Type");
- purple_debug_info("updater", "Plugin Type: %s", header);
-
/* If we have a zip file then extract it to the appropriate directory */
if(g_str_has_suffix(filename, ".zip"))
{
@@ -137,7 +145,7 @@ download_plugin_cb(PurpleHttpConnection
purple_debug_info("updater", "Error saving downloaded plugin %s\n", id);
}
- path = g_build_filename(purple_user_dir(), header, id, NULL);
+ path = g_build_filename(purple_user_dir(), type, id, NULL);
g_mkdir_with_parents(path, 0755);
purple_debug_info("updater", "Extracting file %s for %s....", tmp_file, id);
@@ -152,7 +160,7 @@ download_plugin_cb(PurpleHttpConnection
}
else
{
- path = g_build_filename(purple_user_dir(), "updates", header, filename, NULL);
+ path = g_build_filename(purple_user_dir(), "updates", type, filename, NULL);
g_mkdir_with_parents(g_path_get_dirname(path), 0755);
purple_debug_info("updater", "Downloading finished, saving to: %s\n", path);
if(!g_file_set_contents(path, data, size, NULL))
@@ -162,6 +170,10 @@ download_plugin_cb(PurpleHttpConnection
}
}
}
+ else
+ {
+ purple_debug_error("updater", "Cannot parse header information for plugin: %s", id);
+ }
g_match_info_free(minfo);
g_regex_unref(regex);
}
@@ -207,7 +219,7 @@ execute_update_queue(gpointer data)
purple_debug_info("updater", "Starting download of: %s\n", url);
- con = purple_http_get(NULL, url, download_plugin_cb, id);
+ con = purple_http_get(NULL, download_plugin_cb, id, url);
while(purple_http_conn_is_running(con)) {
/* We wait for the connection to close */
@@ -390,7 +402,7 @@ check_updates_request_cb(PurpleHttpConne
GtkTreeIter iter;
GtkWidget *msgd;
- if(!purple_http_response_is_successfull(response))
+ if(!purple_http_response_is_successful(response))
{
purple_debug_info("updater", "Error: Cannot check for updates\n");
if(INTERACTIVE)
@@ -399,6 +411,7 @@ check_updates_request_cb(PurpleHttpConne
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("There was a problem checking for updates."));
gtk_dialog_run(GTK_DIALOG(msgd));
gtk_widget_destroy(msgd);
+ gtk_widget_destroy(dlg_progress);
}
return;
}
diff --git a/pidgin/gtkplugin-updater.h b/pidgin/gtkplugin-updater.h
--- a/pidgin/gtkplugin-updater.h
+++ b/pidgin/gtkplugin-updater.h
@@ -30,7 +30,7 @@
#include <glib.h>
/*static const gchar* PIDGIN_PLUGIN_WEBSITE_URI = "http://bhaskar-kandiyal.rhcloud.com";*/
-static const gchar* PIDGIN_PLUGIN_WEBSITE_URI = "http://kandiyal.local"; /* For local debugging only */
+static const gchar* PIDGIN_PLUGIN_WEBSITE_URI = "http://kandiyal.com"; /* For local debugging only */
typedef enum
{
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -910,17 +910,18 @@ webview_download_status(gpointer data)
static gboolean
webview_download_requested_cb(WebKitWebView *webview, GObject *download, gpointer user_data)
{
- gchar *uri, *tmp_dir, *filename, *type, **info, *path;
- SoupMessage *msg;
- SoupMessageHeaders *headers;
+ gchar *uri, *tmp_dir, *filename, *type, *path, *id;
GValue headers_value = G_VALUE_INIT;
GHashTable *hash;
GtkWidget *msgd;
GRegex *re;
+ GMatchInfo *minfo;
PurplePlugin *plug;
GFile *file;
GtkWidget *progress;
+ purple_debug_info("plugins", "Got download request\n");
+
msgd = gtk_message_dialog_new(GTK_WINDOW(plugin_dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
_("Are you sure you wish to install this plugin?"));
@@ -931,14 +932,24 @@ webview_download_requested_cb(WebKitWebV
}
gtk_widget_destroy(msgd);
- msg = webkit_network_response_get_message(webkit_download_get_network_response(WEBKIT_DOWNLOAD(download)));
+ filename = webkit_download_get_suggested_filename(WEBKIT_DOWNLOAD(download));
- g_value_init(&headers_value, SOUP_TYPE_MESSAGE_HEADERS);
- g_object_get_property(G_OBJECT(msg), SOUP_MESSAGE_RESPONSE_HEADERS, &headers_value);
- headers = g_value_get_boxed(&headers_value);
- g_value_unset(&headers_value);
+ re = g_regex_new("^(.*)_(.*)\\.", 0, 0, NULL);
+ if(!g_regex_match(re, filename, G_REGEX_MATCH_PARTIAL, &minfo))
+ {
+ msgd = gtk_message_dialog_new(GTK_WINDOW(plugin_dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Error: Invalid filename: %s"), filename);
+ gtk_dialog_run(GTK_DIALOG(msgd));
+ gtk_widget_destroy(msgd);
+ g_regex_unref(re);
+ return FALSE;
+ }
- type = soup_message_headers_get_one(headers, "Purple-Resource-Type");
+ type = g_match_info_fetch(minfo, 1);
+ id = g_match_info_fetch(minfo, 2);
+
+ g_regex_unref(re);
+ g_match_info_unref(minfo);
/* If no type is defines then assume it's a plugin */
if(type == NULL)
@@ -946,13 +957,6 @@ webview_download_requested_cb(WebKitWebV
type = "plugins";
}
- filename = webkit_download_get_suggested_filename(WEBKIT_DOWNLOAD(download));
-
- re = g_regex_new("\\..*$", 0, 0, NULL);
- info = g_regex_split(re, filename, 0);
-
- g_regex_unref(re);
-
progress = create_progress_dialog();
hash = g_hash_table_new(NULL, NULL);
@@ -965,7 +969,7 @@ webview_download_requested_cb(WebKitWebV
if(g_str_equal("plugins", type))
{
- plug = purple_plugins_find_with_id(*info);
+ plug = purple_plugins_find_with_id(id);
if(purple_plugin_is_loaded(plug))
{
path = g_build_filename(purple_user_dir(), "updates", type, filename, NULL);
@@ -1024,7 +1028,6 @@ webview_download_requested_cb(WebKitWebV
g_free(path);
g_free(uri);
- g_strfreev(info);
return TRUE;
}
@@ -1266,7 +1269,7 @@ void pidgin_plugin_dialog_show()
/* Create the plugin details webview */
- plugin_details = gtk_webview_new();
+ plugin_details = gtk_webview_new(FALSE);
file = g_build_filename(DATADIR, "pidgin", "ui", "plugin_details.html", NULL);
More information about the Commits
mailing list