pidgin/plugins/relnot.c

Wed, 21 Sep 2011 06:45:26 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Wed, 21 Sep 2011 06:45:26 +0000
changeset 32575
eb4fc932fae9
parent 32147
f16364a9c7fb
child 32438
dc8991868906
permissions
-rw-r--r--

Apply conversation theme when opening the GTK conversation. All the
parsing stuff was moved out of the theme code and into the conversation
code.

Someone (not me!) needs to check the code I commented out and see if
we really need that stuff (and then port it to WebKit/styling).

We also need to determine where to place Template.html and the rest
of our (not-yet-written) default theme.

7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * Release Notification Plugin
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * License, or (at your option) any later version.
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * General Public License for more details.
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18169
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18169
diff changeset
19 * 02111-1301, USA.
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include <config.h>
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #endif
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
26 #ifndef PURPLE_PLUGINS
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
27 #define PURPLE_PLUGINS
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #endif
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "internal.h"
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include <string.h>
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "connection.h"
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "core.h"
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
36 #include "debug.h"
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
37 #include "gtkblist.h"
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
38 #include "gtkutils.h"
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 #include "notify.h"
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
40 #include "pidginstock.h"
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 #include "prefs.h"
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 #include "util.h"
9943
b54a762f60fa [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 8993
diff changeset
43 #include "version.h"
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
15577
b8129373f65e More pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15498
diff changeset
45 #include "pidgin.h"
15442
2ff7f5308727 I think this is all the instances of 'Gaim' within pidgin/
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
46
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 /* 1 day */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 #define MIN_CHECK_INTERVAL 60 * 60 * 24
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 static void
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
51 release_hide()
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
52 {
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
53 /* No-op. We may use this method in the future to avoid showing
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
54 * the popup twice */
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
55 }
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
56
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
57 static void
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
58 release_show()
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
59 {
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
60 purple_notify_uri(NULL, PURPLE_WEBSITE);
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
61 }
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
62
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
63 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
64 version_fetch_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
65 const gchar *response, size_t len, const gchar *error_message)
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 {
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
67 gchar *cur_ver;
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
68 const char *tmp, *changelog;
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
69 char response_code[4];
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
70 GtkWidget *release_dialog;
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
71
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 GString *message;
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
73 int i = 0;
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
74
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
75 if(error_message || !response || !len)
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
76 return;
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
78 memset(response_code, '\0', sizeof(response_code));
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
79 /* Parse the status code - the response should be in the form of "HTTP/?.? 200 ..." */
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
80 if ((tmp = strstr(response, " ")) != NULL) {
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
81 tmp++;
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
82 /* Read the 3 digit status code */
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
83 if (len - (tmp - response) > 3) {
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
84 memcpy(response_code, tmp, 3);
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
85 }
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
86 }
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
87
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
88 if (strcmp(response_code, "200") != 0) {
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
89 purple_debug_error("relnot", "Didn't recieve a HTTP status code of 200.\n");
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 return;
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
91 }
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
92
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
93 /* Go to the start of the data */
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
94 if((changelog = strstr(response, "\r\n\r\n")) == NULL) {
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
95 purple_debug_error("relnot", "Unable to find start of HTTP response data.\n");
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
96 return;
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
97 }
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
98 changelog += 4;
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 while(changelog[i] && changelog[i] != '\n') i++;
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101
14281
bb395cb6e106 [gaim-migrate @ 16900]
Nathan Walp <nwalp@pidgin.im>
parents: 14253
diff changeset
102 /* this basically means the version thing wasn't in the format we were
bb395cb6e106 [gaim-migrate @ 16900]
Nathan Walp <nwalp@pidgin.im>
parents: 14253
diff changeset
103 * looking for so sourceforge is probably having web server issues, and
bb395cb6e106 [gaim-migrate @ 16900]
Nathan Walp <nwalp@pidgin.im>
parents: 14253
diff changeset
104 * we should try again later */
bb395cb6e106 [gaim-migrate @ 16900]
Nathan Walp <nwalp@pidgin.im>
parents: 14253
diff changeset
105 if(i == 0)
bb395cb6e106 [gaim-migrate @ 16900]
Nathan Walp <nwalp@pidgin.im>
parents: 14253
diff changeset
106 return;
bb395cb6e106 [gaim-migrate @ 16900]
Nathan Walp <nwalp@pidgin.im>
parents: 14253
diff changeset
107
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 cur_ver = g_strndup(changelog, i);
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 message = g_string_new("");
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
111 g_string_append_printf(message, _("You can upgrade to %s %s today."),
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
112 PIDGIN_NAME, cur_ver);
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
114 release_dialog = pidgin_make_mini_dialog(
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
115 NULL, PIDGIN_STOCK_DIALOG_INFO,
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
116 _("New Version Available"),
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
117 message->str,
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
118 NULL,
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
119 _("Later"), PURPLE_CALLBACK(release_hide),
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
120 _("Download Now"), PURPLE_CALLBACK(release_show),
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
121 NULL);
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122
24768
c9d1cfe1d89c A patch from Casey Ho to move the release notification to a mini-dialog in the buddy list. The change log is no longer displayed, but will open a webbrowser to show it.
Casey Ho <caseyho@pidgin.im>
parents: 24247
diff changeset
123 pidgin_blist_add_alert(release_dialog);
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
125 g_string_free(message, TRUE);
7599
37ee21202f1f [gaim-migrate @ 8220]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 7546
diff changeset
126 g_free(cur_ver);
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 }
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 static void
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 do_check(void)
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
132 int last_check = purple_prefs_get_int("/plugins/gtk/relnot/last_check");
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 if(!last_check || time(NULL) - last_check > MIN_CHECK_INTERVAL) {
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
134 gchar *url, *request;
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
135 const char *host = "pidgin.im";
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 24768
diff changeset
136
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
137 url = g_strdup_printf("http://%s/version.php?version=%s&build=%s",
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
138 host,
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
139 purple_core_get_version(),
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 #ifdef _WIN32
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
141 "purple-win32"
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 #else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
143 "purple"
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 #endif
7546
b8f94451a5b0 [gaim-migrate @ 8160]
Nathan Walp <nwalp@pidgin.im>
parents: 7545
diff changeset
145 );
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
146
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
147 request = g_strdup_printf(
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
148 "GET %s HTTP/1.0\r\n"
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
149 "Connection: close\r\n"
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
150 "Accept: */*\r\n"
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
151 "Host: %s\r\n\r\n",
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
152 url,
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
153 host);
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
154
32147
f16364a9c7fb Rename purple_util_fetch_url_request_len_with_account to
Mark Doliner <markdoliner@pidgin.im>
parents: 32146
diff changeset
155 purple_util_fetch_url_request_len(NULL, url, TRUE, NULL, FALSE,
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
156 request, TRUE, -1, version_fetch_cb, NULL);
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
157
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
158 g_free(request);
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
159 g_free(url);
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
160
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
161 purple_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL));
24247
9f640ea2ab9f Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents: 20288
diff changeset
162
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 }
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 }
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
167 signed_on_cb(PurpleConnection *gc, void *data) {
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 do_check();
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 }
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 /**************************************************************************
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172 * Plugin stuff
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 **************************************************************************/
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 static gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
175 plugin_load(PurplePlugin *plugin)
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
177 purple_signal_connect(purple_connections_get_handle(), "signed-on",
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
178 plugin, PURPLE_CALLBACK(signed_on_cb), NULL);
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180 /* we don't check if we're offline */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
181 if(purple_connections_get_all())
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 do_check();
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184 return TRUE;
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
185 }
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
187 static PurplePluginInfo info =
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
188 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
189 PURPLE_PLUGIN_MAGIC,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
190 PURPLE_MAJOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
191 PURPLE_MINOR_VERSION,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
192 PURPLE_PLUGIN_STANDARD, /**< type */
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193 NULL, /**< ui_requirement */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194 0, /**< flags */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 NULL, /**< dependencies */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
196 PURPLE_PRIORITY_DEFAULT, /**< priority */
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198 "gtk-relnot", /**< id */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 N_("Release Notification"), /**< name */
20288
5ca925a094e2 applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19859
diff changeset
200 DISPLAY_VERSION, /**< version */
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 /** summary */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 N_("Checks periodically for new releases."),
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 /** description */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 N_("Checks periodically for new releases and notifies the user "
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 "with the ChangeLog."),
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 "Nathan Walp <faceprint@faceprint.com>", /**< author */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
207 PURPLE_WEBSITE, /**< homepage */
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209 plugin_load, /**< load */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 NULL, /**< unload */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 NULL, /**< destroy */
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 NULL, /**< ui_info */
8993
41f67bceab41 [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
214 NULL, /**< extra_info */
41f67bceab41 [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
215 NULL,
16749
14a3fdc0aed7 Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents: 16073
diff changeset
216 NULL,
14a3fdc0aed7 Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents: 16073
diff changeset
217
14a3fdc0aed7 Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents: 16073
diff changeset
218 /* padding */
14a3fdc0aed7 Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents: 16073
diff changeset
219 NULL,
14a3fdc0aed7 Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents: 16073
diff changeset
220 NULL,
14a3fdc0aed7 Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents: 16073
diff changeset
221 NULL,
8993
41f67bceab41 [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
222 NULL
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223 };
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
226 init_plugin(PurplePlugin *plugin)
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
228 purple_prefs_add_none("/plugins/gtk/relnot");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
229 purple_prefs_add_int("/plugins/gtk/relnot/last_check", 0);
7543
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 }
03c003c76c98 [gaim-migrate @ 8157]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
232 PURPLE_INIT_PLUGIN(relnot, init_plugin, info)

mercurial