[geany/geany-plugins] fe7b3a: Improve logging and notifications of update check results

Enrico Tröger git-noreply at xxxxx
Sun Oct 19 14:48:08 UTC 2014


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 19 Oct 2014 14:48:08 UTC
Commit:      fe7b3a17f38803da03e9b0973ad573842dfd93d9
             https://github.com/geany/geany-plugins/commit/fe7b3a17f38803da03e9b0973ad573842dfd93d9

Log Message:
-----------
Improve logging and notifications of update check results

When checking for updates on program start, also log the results to the
status messages to make the result more visible to the user.
While at it, changed the wording of a few messages and made the
version check URL a constant.


Modified Paths:
--------------
    updatechecker/src/updatechecker.c

Modified: updatechecker/src/updatechecker.c
46 lines changed, 29 insertions(+), 17 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,13 @@ static void update_check(gint type)
     gchar *user_agent = g_strconcat("Updatechecker ", VERSION, " at Geany ",
                                      GEANY_VERSION, NULL);
 
-    g_message("Checking for updates");
+    g_message("Checking for updates (querying URL \"%s\")", UPDATE_CHECK_URL);
     soup = soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT,
             user_agent, 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 +186,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