Mercurial > pidgin
annotate plugins/relnot.c @ 9722:25866d09063d
[gaim-migrate @ 10583]
Nathan said it looked like I may have been using something without
initializing it. It doesn't seem like it to me, but I thought I'd
ask other people. This is my way of asking :-)
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 08 Aug 2004 16:56:34 +0000 |
parents | 294ae6548d4e |
children | f8e395a054e2 |
rev | line source |
---|---|
7543 | 1 /* |
2 * Release Notification Plugin | |
3 * | |
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation; either version 2 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 * 02111-1307, USA. | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 #include <config.h> | |
24 #endif | |
25 | |
26 #ifndef GAIM_PLUGINS | |
27 #define GAIM_PLUGINS | |
28 #endif | |
29 | |
30 #include "internal.h" | |
31 | |
32 #include <string.h> | |
33 | |
34 #include "connection.h" | |
35 #include "core.h" | |
36 #include "notify.h" | |
37 #include "prefs.h" | |
38 #include "util.h" | |
39 | |
40 /* 1 day */ | |
41 #define MIN_CHECK_INTERVAL 60 * 60 * 24 | |
42 | |
43 static void | |
44 version_fetch_cb(void *ud, const char *data, size_t len) | |
45 { | |
46 const char *changelog = data; | |
47 char *cur_ver, *formatted; | |
48 GString *message; | |
49 int i=0; | |
50 | |
51 if(!changelog || !len) | |
52 return; | |
53 | |
54 while(changelog[i] && changelog[i] != '\n') i++; | |
55 | |
56 cur_ver = g_strndup(changelog, i); | |
57 changelog += i; | |
58 | |
59 while(*changelog == '\n') changelog++; | |
60 | |
61 message = g_string_new(""); | |
62 g_string_append_printf(message, _("You are using Gaim version %s. The " | |
63 "current version is %s.<hr>"), | |
64 gaim_core_get_version(), cur_ver); | |
65 | |
66 if(*changelog) { | |
67 formatted = gaim_strdup_withhtml(changelog); | |
68 g_string_append_printf(message, _("<b>ChangeLog:</b>\n%s<br><br>"), | |
69 formatted); | |
70 g_free(formatted); | |
71 } | |
72 | |
73 g_string_append_printf(message, _("You can get version %s from:<br>" | |
74 "<a href=\"http://gaim.sourceforge.net/\">" | |
75 "http://gaim.sourceforge.net</a>."), cur_ver); | |
76 | |
77 gaim_notify_formatted(NULL, _("New Version Available"), | |
78 _("New Version Available"), NULL, message->str, | |
79 NULL, NULL); | |
80 | |
81 g_string_free(message, TRUE); | |
7599 | 82 g_free(cur_ver); |
7543 | 83 } |
84 | |
85 static void | |
86 do_check(void) | |
87 { | |
88 int last_check = gaim_prefs_get_int("/plugins/gtk/relnot/last_check"); | |
89 if(!last_check || time(NULL) - last_check > MIN_CHECK_INTERVAL) { | |
7546 | 90 char *url = g_strdup_printf("http://gaim.sourceforge.net/version.php?version=%s&build=%s", gaim_core_get_version(), |
7543 | 91 #ifdef _WIN32 |
7546 | 92 "gaim-win32" |
7543 | 93 #else |
7546 | 94 "gaim" |
7543 | 95 #endif |
7546 | 96 ); |
7543 | 97 gaim_url_fetch(url, TRUE, NULL, FALSE, version_fetch_cb, NULL); |
98 gaim_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL)); | |
7545 | 99 g_free(url); |
7543 | 100 } |
101 } | |
102 | |
103 static void | |
104 signed_on_cb(GaimConnection *gc, void *data) { | |
105 do_check(); | |
106 } | |
107 | |
108 /************************************************************************** | |
109 * Plugin stuff | |
110 **************************************************************************/ | |
111 static gboolean | |
112 plugin_load(GaimPlugin *plugin) | |
113 { | |
114 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
115 plugin, GAIM_CALLBACK(signed_on_cb), NULL); | |
116 | |
117 /* we don't check if we're offline */ | |
118 if(gaim_connections_get_all()) | |
119 do_check(); | |
120 | |
121 return TRUE; | |
122 } | |
123 | |
124 static GaimPluginInfo info = | |
125 { | |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
7769
diff
changeset
|
126 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
7543 | 127 GAIM_PLUGIN_STANDARD, /**< type */ |
128 NULL, /**< ui_requirement */ | |
129 0, /**< flags */ | |
130 NULL, /**< dependencies */ | |
131 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
132 | |
133 "gtk-relnot", /**< id */ | |
134 N_("Release Notification"), /**< name */ | |
135 VERSION, /**< version */ | |
136 /** summary */ | |
137 N_("Checks periodically for new releases."), | |
138 /** description */ | |
139 N_("Checks periodically for new releases and notifies the user " | |
140 "with the ChangeLog."), | |
141 "Nathan Walp <faceprint@faceprint.com>", /**< author */ | |
142 GAIM_WEBSITE, /**< homepage */ | |
143 | |
144 plugin_load, /**< load */ | |
145 NULL, /**< unload */ | |
146 NULL, /**< destroy */ | |
147 | |
148 NULL, /**< ui_info */ | |
8993 | 149 NULL, /**< extra_info */ |
150 NULL, | |
151 NULL | |
7543 | 152 }; |
153 | |
154 static void | |
155 init_plugin(GaimPlugin *plugin) | |
156 { | |
157 gaim_prefs_add_none("/plugins/gtk/relnot"); | |
158 gaim_prefs_add_int("/plugins/gtk/relnot/last_check", 0); | |
159 } | |
160 | |
7769 | 161 GAIM_INIT_PLUGIN(relnot, init_plugin, info) |