Mercurial > pidgin
comparison plugins/relnot.c @ 7543:6373f8060d90
[gaim-migrate @ 8157]
my apolgies to the translators, but i'd rather have this in untranslated
than not at all, because it's uber-cool.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 17 Nov 2003 22:34:29 +0000 |
parents | |
children | c81c18d63a09 |
comparison
equal
deleted
inserted
replaced
7542:ebccd555323b | 7543:6373f8060d90 |
---|---|
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); | |
82 } | |
83 | |
84 static void | |
85 do_check(void) | |
86 { | |
87 int last_check = gaim_prefs_get_int("/plugins/gtk/relnot/last_check"); | |
88 if(!last_check || time(NULL) - last_check > MIN_CHECK_INTERVAL) { | |
89 char *url = g_strdup_printf("http://gaim.sourceforge.net/version.php?version=%s&build=%s", gaim_core_get_version(), | |
90 #ifdef _WIN32 | |
91 "gaim-win32" | |
92 #else | |
93 "gaim" | |
94 #endif | |
95 ); | |
96 gaim_url_fetch(url, TRUE, NULL, FALSE, version_fetch_cb, NULL); | |
97 gaim_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL)); | |
98 } | |
99 } | |
100 | |
101 static void | |
102 signed_on_cb(GaimConnection *gc, void *data) { | |
103 do_check(); | |
104 } | |
105 | |
106 /************************************************************************** | |
107 * Plugin stuff | |
108 **************************************************************************/ | |
109 static gboolean | |
110 plugin_load(GaimPlugin *plugin) | |
111 { | |
112 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
113 plugin, GAIM_CALLBACK(signed_on_cb), NULL); | |
114 | |
115 /* we don't check if we're offline */ | |
116 if(gaim_connections_get_all()) | |
117 do_check(); | |
118 | |
119 return TRUE; | |
120 } | |
121 | |
122 static GaimPluginInfo info = | |
123 { | |
124 2, /**< api_version */ | |
125 GAIM_PLUGIN_STANDARD, /**< type */ | |
126 NULL, /**< ui_requirement */ | |
127 0, /**< flags */ | |
128 NULL, /**< dependencies */ | |
129 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
130 | |
131 "gtk-relnot", /**< id */ | |
132 N_("Release Notification"), /**< name */ | |
133 VERSION, /**< version */ | |
134 /** summary */ | |
135 N_("Checks periodically for new releases."), | |
136 /** description */ | |
137 N_("Checks periodically for new releases and notifies the user " | |
138 "with the ChangeLog."), | |
139 "Nathan Walp <faceprint@faceprint.com>", /**< author */ | |
140 GAIM_WEBSITE, /**< homepage */ | |
141 | |
142 plugin_load, /**< load */ | |
143 NULL, /**< unload */ | |
144 NULL, /**< destroy */ | |
145 | |
146 NULL, /**< ui_info */ | |
147 NULL /**< extra_info */ | |
148 }; | |
149 | |
150 static void | |
151 init_plugin(GaimPlugin *plugin) | |
152 { | |
153 gaim_prefs_add_none("/plugins/gtk/relnot"); | |
154 gaim_prefs_add_int("/plugins/gtk/relnot/last_check", 0); | |
155 } | |
156 | |
157 GAIM_INIT_PLUGIN(signalstest, init_plugin, info) |