2 * Release Notification Plugin
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA
30 #include "connection.h"
34 #include "gtkplugin.h"
38 #include "pidginicon.h"
46 #define MIN_CHECK_INTERVAL 60 * 60 * 24
51 /* No-op. We may use this method in the future to avoid showing
58 purple_notify_uri(NULL
, PURPLE_WEBSITE
);
61 static void version_fetch_cb(PurpleHttpConnection
*hc
,
62 PurpleHttpResponse
*response
, gpointer user_data
)
65 const char *changelog
;
66 GtkWidget
*release_dialog
;
71 if(!purple_http_response_is_successful(response
))
74 changelog
= purple_http_response_get_data(response
, NULL
);
76 while(changelog
[i
] && changelog
[i
] != '\n') i
++;
78 /* this basically means the version thing wasn't in the format we were
79 * looking for so sourceforge is probably having web server issues, and
80 * we should try again later */
84 cur_ver
= g_strndup(changelog
, i
);
86 message
= g_string_new("");
87 g_string_append_printf(message
, _("You can upgrade to %s %s today."),
88 PIDGIN_NAME
, cur_ver
);
90 release_dialog
= pidgin_make_mini_dialog(
91 NULL
, "dialog-information",
92 _("New Version Available"),
95 _("Later"), PURPLE_CALLBACK(release_hide
),
96 _("Download Now"), PURPLE_CALLBACK(release_show
),
99 pidgin_blist_add_alert(release_dialog
);
101 g_string_free(message
, TRUE
);
108 int last_check
= purple_prefs_get_int("/plugins/gtk/relnot/last_check");
109 if(!last_check
|| time(NULL
) - last_check
> MIN_CHECK_INTERVAL
) {
111 const char *host
= "pidgin.im";
113 url
= g_strdup_printf("https://%s/version.php?version=%s&build=%s",
115 purple_core_get_version(),
123 purple_http_get(NULL
, version_fetch_cb
, NULL
, url
);
127 purple_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL
));
133 signed_on_cb(PurpleConnection
*gc
, void *data
) {
137 /**************************************************************************
139 **************************************************************************/
140 static PidginPluginInfo
*
141 plugin_query(GError
**error
)
143 const gchar
* const authors
[] = {
144 "Nathan Walp <faceprint@faceprint.com>",
148 return pidgin_plugin_info_new(
150 "name", N_("Release Notification"),
151 "version", DISPLAY_VERSION
,
152 "category", N_("Notification"),
153 "summary", N_("Checks periodically for new releases."),
154 "description", N_("Checks periodically for new releases and notifies "
155 "the user with the ChangeLog."),
157 "website", PURPLE_WEBSITE
,
158 "abi-version", PURPLE_ABI_VERSION
,
164 plugin_load(PurplePlugin
*plugin
, GError
**error
)
166 purple_prefs_add_none("/plugins/gtk/relnot");
167 purple_prefs_add_int("/plugins/gtk/relnot/last_check", 0);
169 purple_signal_connect(purple_connections_get_handle(), "signed-on",
170 plugin
, PURPLE_CALLBACK(signed_on_cb
), NULL
);
172 /* we don't check if we're offline */
173 if(purple_connections_get_all())
180 plugin_unload(PurplePlugin
*plugin
, GError
**error
)
185 PURPLE_PLUGIN_INIT(relnot
, plugin_query
, plugin_load
, plugin_unload
);