about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/release.c76
-rw-r--r--src/release.h25
-rw-r--r--src/windows.c32
3 files changed, 130 insertions, 3 deletions
diff --git a/src/release.c b/src/release.c
new file mode 100644
index 00000000..fb08b8ba
--- /dev/null
+++ b/src/release.c
@@ -0,0 +1,76 @@
+/*
+ * release.c
+ *
+ * Copyright (C) 2012 James Booth <boothj5@gmail.com>
+ *
+ * This file is part of Profanity.
+ *
+ * Profanity is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Profanity is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Profanity.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib.h>
+#include <curl/curl.h>
+#include <curl/easy.h>
+
+struct curl_data_t
+{
+    char *buffer;
+    size_t size;
+};
+
+static size_t _data_callback(void *ptr, size_t size, size_t nmemb, void *data);
+
+char *
+release_get_latest()
+{
+    char *url = "http://www.boothj5.com/profanity_version.txt";
+
+    CURL *handle = curl_easy_init();
+    struct curl_data_t output;
+    output.buffer = NULL;
+    output.size = 0;
+
+    curl_easy_setopt(handle, CURLOPT_URL, url);
+    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, _data_callback);
+    curl_easy_setopt(handle, CURLOPT_TIMEOUT, 2);
+    curl_easy_setopt(handle, CURLOPT_WRITEDATA, (void *)&output);
+
+    curl_easy_perform(handle);
+    curl_easy_cleanup(handle);
+
+    output.buffer[output.size++] = '\0';
+
+    return output.buffer;
+}
+
+static size_t
+_data_callback(void *ptr, size_t size, size_t nmemb, void *data)
+{
+    size_t realsize = size * nmemb;
+    struct curl_data_t *mem = (struct curl_data_t *) data;
+    mem->buffer = realloc(mem->buffer, mem->size + realsize + 1);
+
+    if ( mem->buffer )
+    {
+        memcpy( &( mem->buffer[ mem->size ] ), ptr, realsize );
+        mem->size += realsize;
+        mem->buffer[ mem->size ] = 0;
+    }
+
+    return realsize;
+}
diff --git a/src/release.h b/src/release.h
new file mode 100644
index 00000000..c106d622
--- /dev/null
+++ b/src/release.h
@@ -0,0 +1,25 @@
+/*
+ * release.h
+ *
+ * Copyright (C) 2012 James Booth <boothj5@gmail.com>
+ *
+ * This file is part of Profanity.
+ *
+ * Profanity is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Profanity is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Profanity.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <glib.h>
+
+char * release_get_latest(void);
diff --git a/src/windows.c b/src/windows.c
index 3183222f..97d85192 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -42,6 +42,7 @@
 #include "contact_list.h"
 #include "log.h"
 #include "preferences.h"
+#include "release.h"
 #include "ui.h"
 
 #define CONS_WIN_TITLE "_cons"
@@ -819,7 +820,12 @@ cons_about(void)
         _cons_splash_logo();
     } else {
         _win_show_time(_cons_win);
-        wprintw(_cons_win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION);
+
+        if (strcmp(PACKAGE_STATUS, "dev") == 0) {
+            wprintw(_cons_win, "Welcome to Profanity, version %sdev\n", PACKAGE_VERSION);
+        } else {
+            wprintw(_cons_win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION);
+        }
     }
 
     _win_show_time(_cons_win);
@@ -839,6 +845,23 @@ cons_about(void)
     _win_show_time(_cons_win);
     wprintw(_cons_win, "\n");
 
+    // check for new version if this is a release build
+    if (strcmp(PACKAGE_STATUS, "release") == 0) {
+        char *latest_release = release_get_latest();
+
+        if (latest_release != NULL) {
+            gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0);
+
+            if (relase_valid) {
+                _win_show_time(_cons_win);
+                wprintw(_cons_win, "RELEASE: %s", latest_release);
+                free(latest_release);
+                _win_show_time(_cons_win);
+                wprintw(_cons_win, "\n");
+            }
+        }
+    }
+
     prefresh(_cons_win, 0, 0, 1, 0, rows-3, cols-1);
 
     dirty = TRUE;
@@ -850,7 +873,6 @@ _cons_splash_logo(void)
     _win_show_time(_cons_win);
     wprintw(_cons_win, "Welcome to\n");
 
-
     _win_show_time(_cons_win);
     wattron(_cons_win, COLOUR_OFFLINE);
     wprintw(_cons_win, "                   ___            _           \n");
@@ -889,7 +911,11 @@ _cons_splash_logo(void)
     _win_show_time(_cons_win);
     wprintw(_cons_win, "\n");
     _win_show_time(_cons_win);
-    wprintw(_cons_win, "Version %s\n", PACKAGE_VERSION);
+    if (strcmp(PACKAGE_STATUS, "dev") == 0) {
+        wprintw(_cons_win, "Version %sdev\n", PACKAGE_VERSION);
+    } else {
+        wprintw(_cons_win, "Version %s\n", PACKAGE_VERSION);
+    }
 }
 
 static int