[geany/geany-plugins] 697f54: Merge pull request #166 from eht16/updatechecker-improvements
Frank Lanitz
git-noreply at xxxxx
Sun Oct 19 16:28:49 UTC 2014
Branch: refs/heads/master
Author: Frank Lanitz <frank at frank.uvena.de>
Committer: Frank Lanitz <frank at frank.uvena.de>
Date: Sun, 19 Oct 2014 16:28:49 UTC
Commit: 697f549ba6add25ecd5b096e937b596b6bf29a33
https://github.com/geany/geany-plugins/commit/697f549ba6add25ecd5b096e937b596b6bf29a33
Log Message:
-----------
Merge pull request #166 from eht16/updatechecker-improvements
Updatechecker improvements - more notifications and setting a timeout
Modified Paths:
--------------
updatechecker/src/updatechecker.c
Modified: updatechecker/src/updatechecker.c
52 lines changed, 33 insertions(+), 19 deletions(-)
===================================================================
@@ -48,6 +48,8 @@ enum {
UPDATECHECK_STARTUP
};
+#define UPDATE_CHECK_URL "http://geany.org/service/version.php"
+
static GtkWidget *main_menu_item = NULL;
static void update_check_result_cb(SoupSession *session,
SoupMessage *msg, gpointer user_data);
@@ -81,13 +83,15 @@ static void update_check(gint type)
gchar *user_agent = g_strconcat("Updatechecker ", VERSION, " at Geany ",
GEANY_VERSION, NULL);
- g_message("Checking for updates");
- soup = soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT,
- user_agent, NULL);
+ g_message("Checking for updates (querying URL \"%s\")", UPDATE_CHECK_URL);
+ soup = soup_session_async_new_with_options(
+ SOUP_SESSION_USER_AGENT, user_agent,
+ SOUP_SESSION_TIMEOUT, 10,
+ NULL);
g_free(user_agent);
- msg = soup_message_new ("GET", "http://geany.org/service/version.php");
+ msg = soup_message_new ("GET", UPDATE_CHECK_URL);
soup_session_queue_message (soup, msg, update_check_result_cb, GINT_TO_POINTER(type));
}
@@ -184,35 +188,45 @@ static void update_check_result_cb(SoupSession *session,
/* Checking whether we did get a valid (200) result */
if (msg->status_code == 200)
{
- if (version_compare(msg->response_body->data) == TRUE)
+ const gchar *remote_version = msg->response_body->data;
+ if (version_compare(remote_version) == TRUE)
{
- dialogs_show_msgbox(GTK_MESSAGE_INFO,
- _("There is a more recent version of Geany available"));
- g_message(_("There is a more recent version of Geany available"));
+ gchar *update_msg = g_strdup_printf(
+ _("There is a more recent version of Geany available: %s"),
+ remote_version);
+ dialogs_show_msgbox(GTK_MESSAGE_INFO, "%s", update_msg);
+ g_message("%s", update_msg);
+ g_free(update_msg);
}
else
{
+ const gchar *no_update_msg = _("No newer Geany version available");
if (type == UPDATECHECK_MANUAL)
{
- dialogs_show_msgbox(GTK_MESSAGE_INFO,
- _("No update available"));
+ dialogs_show_msgbox(GTK_MESSAGE_INFO, "%s", no_update_msg);
}
-
- g_message("No update available");
-
+ else
+ {
+ msgwin_status_add("%s", no_update_msg);
+ }
+ g_message("%s", no_update_msg);
}
}
else
{
+ gchar *error_message = g_strdup_printf(
+ _("Unable to perform version check.\nError code: %d \nError message: »%s«"),
+ msg->status_code, msg->reason_phrase);
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);
+ dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", error_message);
}
- g_warning("Connection error. Code: %d; Message: %s",
- msg->status_code, msg->reason_phrase);
+ else
+ {
+ msgwin_status_add("%s", error_message);
+ }
+ g_warning("Connection error: Code: %d; Message: %s", msg->status_code, msg->reason_phrase);
+ g_free(error_message);
}
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list