Sat, 19 May 2007 21:38:47 +0000
merge of '1442df274a24edc9a31194327bd00dfbcf478720'
and 'ce02548a6b6a545d97fb3f371506bcf1b5cc5131'
| 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 | ||
| 15884 | 26 | #ifndef PURPLE_PLUGINS |
| 27 | #define PURPLE_PLUGINS | |
| 7543 | 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" | |
| 9943 | 39 | #include "version.h" |
| 7543 | 40 | |
| 15577 | 41 | #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
|
42 | |
| 7543 | 43 | /* 1 day */ |
| 44 | #define MIN_CHECK_INTERVAL 60 * 60 * 24 | |
| 45 | ||
| 46 | static void | |
| 15884 | 47 | version_fetch_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14281
diff
changeset
|
48 | const gchar *changelog, size_t len, const gchar *error_message) |
| 7543 | 49 | { |
| 50 | char *cur_ver, *formatted; | |
| 51 | GString *message; | |
| 52 | int i=0; | |
| 53 | ||
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14281
diff
changeset
|
54 | if(error_message || !changelog || !len) |
| 7543 | 55 | return; |
| 56 | ||
| 57 | while(changelog[i] && changelog[i] != '\n') i++; | |
| 58 | ||
| 14281 | 59 | /* this basically means the version thing wasn't in the format we were |
| 60 | * looking for so sourceforge is probably having web server issues, and | |
| 61 | * we should try again later */ | |
| 62 | if(i == 0) | |
| 63 | return; | |
| 64 | ||
| 7543 | 65 | cur_ver = g_strndup(changelog, i); |
| 66 | changelog += i; | |
| 67 | ||
| 68 | while(*changelog == '\n') changelog++; | |
| 69 | ||
| 70 | message = g_string_new(""); | |
|
16073
e70e589dde54
more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents:
15928
diff
changeset
|
71 | g_string_append_printf(message, _("You are using %s version %s. The " |
| 7543 | 72 | "current version is %s.<hr>"), |
|
16073
e70e589dde54
more help for translators (I removed a few PIDGIN_NAME references
Nathan Walp <nwalp@pidgin.im>
parents:
15928
diff
changeset
|
73 | PIDGIN_NAME, purple_core_get_version(), cur_ver); |
| 7543 | 74 | |
| 75 | if(*changelog) { | |
| 15884 | 76 | formatted = purple_strdup_withhtml(changelog); |
| 7543 | 77 | g_string_append_printf(message, _("<b>ChangeLog:</b>\n%s<br><br>"), |
| 78 | formatted); | |
| 79 | g_free(formatted); | |
| 80 | } | |
| 81 | ||
| 82 | g_string_append_printf(message, _("You can get version %s from:<br>" | |
|
15498
2ee3112b6f24
This should be the last of the string changes
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
83 | "<a href=\"http://pidgin.im/\">" |
|
2ee3112b6f24
This should be the last of the string changes
Sean Egan <seanegan@pidgin.im>
parents:
15442
diff
changeset
|
84 | "http://pidgin.im</a>."), cur_ver); |
| 7543 | 85 | |
| 15884 | 86 | purple_notify_formatted(NULL, _("New Version Available"), |
| 7543 | 87 | _("New Version Available"), NULL, message->str, |
| 88 | NULL, NULL); | |
| 89 | ||
| 90 | g_string_free(message, TRUE); | |
| 7599 | 91 | g_free(cur_ver); |
| 7543 | 92 | } |
| 93 | ||
| 94 | static void | |
| 95 | do_check(void) | |
| 96 | { | |
| 15884 | 97 | int last_check = purple_prefs_get_int("/plugins/gtk/relnot/last_check"); |
| 7543 | 98 | if(!last_check || time(NULL) - last_check > MIN_CHECK_INTERVAL) { |
|
15928
7a44b142ee55
More s/purple.sourceforge.net/pidgin.im/, this time for the release notification plugin.
Richard Laager <rlaager@pidgin.im>
parents:
15926
diff
changeset
|
99 | char *url = g_strdup_printf("http://pidgin.im/version.php?version=%s&build=%s", purple_core_get_version(), |
| 7543 | 100 | #ifdef _WIN32 |
| 15884 | 101 | "purple-win32" |
| 7543 | 102 | #else |
| 15884 | 103 | "purple" |
| 7543 | 104 | #endif |
| 7546 | 105 | ); |
| 15884 | 106 | purple_util_fetch_url(url, TRUE, NULL, FALSE, version_fetch_cb, NULL); |
| 107 | purple_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL)); | |
| 7545 | 108 | g_free(url); |
| 7543 | 109 | } |
| 110 | } | |
| 111 | ||
| 112 | static void | |
| 15884 | 113 | signed_on_cb(PurpleConnection *gc, void *data) { |
| 7543 | 114 | do_check(); |
| 115 | } | |
| 116 | ||
| 117 | /************************************************************************** | |
| 118 | * Plugin stuff | |
| 119 | **************************************************************************/ | |
| 120 | static gboolean | |
| 15884 | 121 | plugin_load(PurplePlugin *plugin) |
| 7543 | 122 | { |
| 15884 | 123 | purple_signal_connect(purple_connections_get_handle(), "signed-on", |
| 124 | plugin, PURPLE_CALLBACK(signed_on_cb), NULL); | |
| 7543 | 125 | |
| 126 | /* we don't check if we're offline */ | |
| 15884 | 127 | if(purple_connections_get_all()) |
| 7543 | 128 | do_check(); |
| 129 | ||
| 130 | return TRUE; | |
| 131 | } | |
| 132 | ||
| 15884 | 133 | static PurplePluginInfo info = |
| 7543 | 134 | { |
| 15884 | 135 | PURPLE_PLUGIN_MAGIC, |
| 136 | PURPLE_MAJOR_VERSION, | |
| 137 | PURPLE_MINOR_VERSION, | |
| 138 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 7543 | 139 | NULL, /**< ui_requirement */ |
| 140 | 0, /**< flags */ | |
| 141 | NULL, /**< dependencies */ | |
| 15884 | 142 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 7543 | 143 | |
| 144 | "gtk-relnot", /**< id */ | |
| 145 | N_("Release Notification"), /**< name */ | |
| 146 | VERSION, /**< version */ | |
| 147 | /** summary */ | |
| 148 | N_("Checks periodically for new releases."), | |
| 149 | /** description */ | |
| 150 | N_("Checks periodically for new releases and notifies the user " | |
| 151 | "with the ChangeLog."), | |
| 152 | "Nathan Walp <faceprint@faceprint.com>", /**< author */ | |
| 15884 | 153 | PURPLE_WEBSITE, /**< homepage */ |
| 7543 | 154 | |
| 155 | plugin_load, /**< load */ | |
| 156 | NULL, /**< unload */ | |
| 157 | NULL, /**< destroy */ | |
| 158 | ||
| 159 | NULL, /**< ui_info */ | |
| 8993 | 160 | NULL, /**< extra_info */ |
| 161 | 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
|
162 | 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
|
163 | |
|
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
|
164 | /* 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
|
165 | 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
|
166 | 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
|
167 | NULL, |
| 8993 | 168 | NULL |
| 7543 | 169 | }; |
| 170 | ||
| 171 | static void | |
| 15884 | 172 | init_plugin(PurplePlugin *plugin) |
| 7543 | 173 | { |
| 15884 | 174 | purple_prefs_add_none("/plugins/gtk/relnot"); |
| 175 | purple_prefs_add_int("/plugins/gtk/relnot/last_check", 0); | |
| 7543 | 176 | } |
| 177 | ||
| 15884 | 178 | PURPLE_INIT_PLUGIN(relnot, init_plugin, info) |