Revision: 1531 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1531&view=re... Author: frlan Date: 2010-08-25 23:19:16 +0000 (Wed, 25 Aug 2010)
Log Message: ----------- Updatechecker: Remove duplicated code
Modified Paths: -------------- trunk/geany-plugins/updatechecker/src/updatechecker.c
Modified: trunk/geany-plugins/updatechecker/src/updatechecker.c =================================================================== --- trunk/geany-plugins/updatechecker/src/updatechecker.c 2010-08-25 23:18:50 UTC (rev 1530) +++ trunk/geany-plugins/updatechecker/src/updatechecker.c 2010-08-25 23:19:16 UTC (rev 1531) @@ -46,8 +46,6 @@ static GtkWidget *main_menu_item = NULL; static void update_check_result_cb(SoupSession *session, SoupMessage *msg, gpointer user_data); -static void update_check_result_quiet_cb(SoupSession *session, - SoupMessage *msg, gpointer user_data);
static gboolean check_on_startup = FALSE;
@@ -80,11 +78,7 @@ soup = soup_session_async_new (); msg = soup_message_new ("GET", "http://geany.org/service/version.php");
- if (type == UPDATECHECK_STARTUP) - soup_session_queue_message (soup, msg, update_check_result_quiet_cb, NULL); - if (type == UPDATECHECK_MANUAL) - soup_session_queue_message (soup, msg, update_check_result_cb, NULL); - + soup_session_queue_message (soup, msg, update_check_result_cb, GINT_TO_POINTER(type)); }
@@ -171,57 +165,45 @@ }
-static void update_check_result_quiet_cb(SoupSession *session, +static void update_check_result_cb(SoupSession *session, SoupMessage *msg, gpointer user_data) { + gint type = GPOINTER_TO_INT(user_data); + /* Checking whether we did get a valid (200) result */ if (msg->status_code == 200) { if (version_compare(msg->response_body->data) == TRUE) { - g_message("There is a more recent version available"); dialogs_show_msgbox(GTK_MESSAGE_INFO, - _("There is a more recent version availble. Please check " - "http://www.geany.org for updates.")); + _("There is a more recent version availble")); + g_message("There is a more recent version availble"); } else { + if (type == UPDATECHECK_MANUAL) + { + dialogs_show_msgbox(GTK_MESSAGE_INFO, + _("No update available")); + } + g_message("No update available"); + } } else { + if (type == UPDATECHECK_MANUAL) + { + dialogs_show_msgbox(GTK_MESSAGE_ERROR, + _("Wasn't able to catch some version information.\n" + "Error code: %d \n" + "Error message: »%s«"), msg->status_code, msg->reason_phrase); + } g_warning("Connection error. Code: %d; Message: %s", msg->status_code, msg->reason_phrase); } }
- -static void update_check_result_cb(SoupSession *session, - SoupMessage *msg, gpointer user_data) -{ - /* Checking whether we did get a valid (200) result */ - if (msg->status_code == 200) - { - if (version_compare(msg->response_body->data) == TRUE) - { - dialogs_show_msgbox(GTK_MESSAGE_INFO, - _("There is a more recent version availble")); - } - else - { - dialogs_show_msgbox(GTK_MESSAGE_INFO, - _("No update available")); - } - } - else - { - dialogs_show_msgbox(GTK_MESSAGE_ERROR, - _("Wasn't able to catch some version information.\n" - "Error code: %d \n" - "Error message: »%s«"), msg->status_code, msg->reason_phrase); - } -} - static void manual_check_activated_cb(GtkMenuItem *menuitem, gpointer gdata) { update_check(UPDATECHECK_MANUAL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.