pidgin/plugins/relnot.c

changeset 24768
c9d1cfe1d89c
parent 24247
9f640ea2ab9f
child 31294
73607ab89c6f
equal deleted inserted replaced
24767:5c8dc430f692 24768:c9d1cfe1d89c
32 #include <string.h> 32 #include <string.h>
33 33
34 #include "connection.h" 34 #include "connection.h"
35 #include "core.h" 35 #include "core.h"
36 #include "debug.h" 36 #include "debug.h"
37 #include "gtkblist.h"
38 #include "gtkutils.h"
37 #include "notify.h" 39 #include "notify.h"
40 #include "pidginstock.h"
38 #include "prefs.h" 41 #include "prefs.h"
39 #include "util.h" 42 #include "util.h"
40 #include "version.h" 43 #include "version.h"
41 44
42 #include "pidgin.h" 45 #include "pidgin.h"
43 46
44 /* 1 day */ 47 /* 1 day */
45 #define MIN_CHECK_INTERVAL 60 * 60 * 24 48 #define MIN_CHECK_INTERVAL 60 * 60 * 24
46 49
47 static void 50 static void
51 release_hide()
52 {
53 /* No-op. We may use this method in the future to avoid showing
54 * the popup twice */
55 }
56
57 static void
58 release_show()
59 {
60 purple_notify_uri(NULL, PURPLE_WEBSITE);
61 }
62
63 static void
48 version_fetch_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, 64 version_fetch_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
49 const gchar *response, size_t len, const gchar *error_message) 65 const gchar *response, size_t len, const gchar *error_message)
50 { 66 {
51 gchar *cur_ver, *formatted; 67 gchar *cur_ver;
52 const char *tmp, *changelog; 68 const char *tmp, *changelog;
53 char response_code[4]; 69 char response_code[4];
70 GtkWidget *release_dialog;
54 71
55 GString *message; 72 GString *message;
56 int i = 0; 73 int i = 0;
57 74
58 if(error_message || !response || !len) 75 if(error_message || !response || !len)
87 * we should try again later */ 104 * we should try again later */
88 if(i == 0) 105 if(i == 0)
89 return; 106 return;
90 107
91 cur_ver = g_strndup(changelog, i); 108 cur_ver = g_strndup(changelog, i);
92 changelog += i;
93
94 while(*changelog == '\n') changelog++;
95 109
96 message = g_string_new(""); 110 message = g_string_new("");
97 g_string_append_printf(message, _("You are using %s version %s. The " 111 g_string_append_printf(message, _("You can upgrade to %s %s today."),
98 "current version is %s. You can get it from " 112 PIDGIN_NAME, cur_ver);
99 "<a href=\"%s\">%s</a><hr>"), 113
100 PIDGIN_NAME, purple_core_get_version(), cur_ver, 114 release_dialog = pidgin_make_mini_dialog(
101 PURPLE_WEBSITE, PURPLE_WEBSITE); 115 NULL, PIDGIN_STOCK_DIALOG_INFO,
102 116 _("New Version Available"),
103 if(*changelog) { 117 message->str,
104 formatted = purple_strdup_withhtml(changelog); 118 NULL,
105 g_string_append_printf(message, _("<b>ChangeLog:</b><br>%s"), 119 _("Later"), PURPLE_CALLBACK(release_hide),
106 formatted); 120 _("Download Now"), PURPLE_CALLBACK(release_show),
107 g_free(formatted); 121 NULL);
108 } 122
109 123 pidgin_blist_add_alert(release_dialog);
110 purple_notify_formatted(NULL, _("New Version Available"),
111 _("New Version Available"), NULL, message->str,
112 NULL, NULL);
113 124
114 g_string_free(message, TRUE); 125 g_string_free(message, TRUE);
115 g_free(cur_ver); 126 g_free(cur_ver);
116 } 127 }
117 128

mercurial