Sat, 03 Feb 2007 08:19:27 +0000
GAIM_UNSEEN to PIDGIN_UNSEEN
| 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" | |
| 9943 | 39 | #include "version.h" |
| 7543 | 40 | |
|
15442
2ff7f5308727
I think this is all the instances of 'Gaim' within pidgin/
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
41 | #include "gtkgaim.h" |
|
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 | |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14281
diff
changeset
|
47 | version_fetch_cb(GaimUtilFetchUrlData *url_data, gpointer user_data, |
|
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(""); | |
|
15442
2ff7f5308727
I think this is all the instances of 'Gaim' within pidgin/
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
71 | g_string_append_printf(message, _("You are using " PIDGIN_NAME " version %s. The " |
| 7543 | 72 | "current version is %s.<hr>"), |
| 73 | gaim_core_get_version(), cur_ver); | |
| 74 | ||
| 75 | if(*changelog) { | |
| 76 | formatted = gaim_strdup_withhtml(changelog); | |
| 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 | |
| 86 | gaim_notify_formatted(NULL, _("New Version Available"), | |
| 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 | { | |
| 97 | int last_check = gaim_prefs_get_int("/plugins/gtk/relnot/last_check"); | |
| 98 | if(!last_check || time(NULL) - last_check > MIN_CHECK_INTERVAL) { | |
| 7546 | 99 | char *url = g_strdup_printf("http://gaim.sourceforge.net/version.php?version=%s&build=%s", gaim_core_get_version(), |
| 7543 | 100 | #ifdef _WIN32 |
| 7546 | 101 | "gaim-win32" |
| 7543 | 102 | #else |
| 7546 | 103 | "gaim" |
| 7543 | 104 | #endif |
| 7546 | 105 | ); |
|
14416
c95ffd983a39
[gaim-migrate @ 17060]
Mark Doliner <markdoliner@pidgin.im>
parents:
14281
diff
changeset
|
106 | gaim_util_fetch_url(url, TRUE, NULL, FALSE, version_fetch_cb, NULL); |
| 7543 | 107 | gaim_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL)); |
| 7545 | 108 | g_free(url); |
| 7543 | 109 | } |
| 110 | } | |
| 111 | ||
| 112 | static void | |
| 113 | signed_on_cb(GaimConnection *gc, void *data) { | |
| 114 | do_check(); | |
| 115 | } | |
| 116 | ||
| 117 | /************************************************************************** | |
| 118 | * Plugin stuff | |
| 119 | **************************************************************************/ | |
| 120 | static gboolean | |
| 121 | plugin_load(GaimPlugin *plugin) | |
| 122 | { | |
| 123 | gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
| 124 | plugin, GAIM_CALLBACK(signed_on_cb), NULL); | |
| 125 | ||
| 126 | /* we don't check if we're offline */ | |
| 127 | if(gaim_connections_get_all()) | |
| 128 | do_check(); | |
| 129 | ||
| 130 | return TRUE; | |
| 131 | } | |
| 132 | ||
| 133 | static GaimPluginInfo info = | |
| 134 | { | |
| 9943 | 135 | GAIM_PLUGIN_MAGIC, |
| 136 | GAIM_MAJOR_VERSION, | |
| 137 | GAIM_MINOR_VERSION, | |
| 7543 | 138 | GAIM_PLUGIN_STANDARD, /**< type */ |
| 139 | NULL, /**< ui_requirement */ | |
| 140 | 0, /**< flags */ | |
| 141 | NULL, /**< dependencies */ | |
| 142 | GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 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 */ | |
| 153 | GAIM_WEBSITE, /**< homepage */ | |
| 154 | ||
| 155 | plugin_load, /**< load */ | |
| 156 | NULL, /**< unload */ | |
| 157 | NULL, /**< destroy */ | |
| 158 | ||
| 159 | NULL, /**< ui_info */ | |
| 8993 | 160 | NULL, /**< extra_info */ |
| 161 | NULL, | |
| 162 | NULL | |
| 7543 | 163 | }; |
| 164 | ||
| 165 | static void | |
| 166 | init_plugin(GaimPlugin *plugin) | |
| 167 | { | |
| 168 | gaim_prefs_add_none("/plugins/gtk/relnot"); | |
| 169 | gaim_prefs_add_int("/plugins/gtk/relnot/last_check", 0); | |
| 170 | } | |
| 171 | ||
| 7769 | 172 | GAIM_INIT_PLUGIN(relnot, init_plugin, info) |