Sun, 09 Nov 2008 20:55:10 +0000
Added menu items to buddy list context menu to start voice and video sessions
After discussing the matter with Maiku, we decided to have two choises.
"Audio call" which will show up if audio sessions is possible with a buddy and
the other item is either "Audio/Video" or "Video" depending on if the buddy
supports both at the same time or not
| 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18169
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18169
diff
changeset
|
19 | * 02111-1301, USA. |
| 7543 | 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" | |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
36 | #include "debug.h" |
| 7543 | 37 | #include "notify.h" |
| 38 | #include "prefs.h" | |
| 39 | #include "util.h" | |
| 9943 | 40 | #include "version.h" |
| 7543 | 41 | |
| 15577 | 42 | #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
|
43 | |
| 7543 | 44 | /* 1 day */ |
| 45 | #define MIN_CHECK_INTERVAL 60 * 60 * 24 | |
| 46 | ||
| 47 | static void | |
| 15884 | 48 | version_fetch_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
49 | const gchar *response, size_t len, const gchar *error_message) |
| 7543 | 50 | { |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
51 | gchar *cur_ver, *formatted; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
52 | const char *tmp, *changelog; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
53 | char response_code[4]; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
54 | |
| 7543 | 55 | GString *message; |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
56 | int i = 0; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
57 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
58 | if(error_message || !response || !len) |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
59 | return; |
| 7543 | 60 | |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
61 | memset(response_code, '\0', sizeof(response_code)); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
62 | /* Parse the status code - the response should be in the form of "HTTP/?.? 200 ..." */ |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
63 | if ((tmp = strstr(response, " ")) != NULL) { |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
64 | tmp++; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
65 | /* Read the 3 digit status code */ |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
66 | if (len - (tmp - response) > 3) { |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
67 | memcpy(response_code, tmp, 3); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
68 | } |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
69 | } |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
70 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
71 | if (strcmp(response_code, "200") != 0) { |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
72 | purple_debug_error("relnot", "Didn't recieve a HTTP status code of 200.\n"); |
| 7543 | 73 | return; |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
74 | } |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
75 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
76 | /* Go to the start of the data */ |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
77 | if((changelog = strstr(response, "\r\n\r\n")) == NULL) { |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
78 | purple_debug_error("relnot", "Unable to find start of HTTP response data.\n"); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
79 | return; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
80 | } |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
81 | changelog += 4; |
| 7543 | 82 | |
| 83 | while(changelog[i] && changelog[i] != '\n') i++; | |
| 84 | ||
| 14281 | 85 | /* this basically means the version thing wasn't in the format we were |
| 86 | * looking for so sourceforge is probably having web server issues, and | |
| 87 | * we should try again later */ | |
| 88 | if(i == 0) | |
| 89 | return; | |
| 90 | ||
| 7543 | 91 | cur_ver = g_strndup(changelog, i); |
| 92 | changelog += i; | |
| 93 | ||
| 94 | while(*changelog == '\n') changelog++; | |
| 95 | ||
| 96 | 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
|
97 | g_string_append_printf(message, _("You are using %s version %s. The " |
|
17538
a1ae88080722
Two small changes to the release notification plugin:
Mark Doliner <markdoliner@pidgin.im>
parents:
16749
diff
changeset
|
98 | "current version is %s. You can get it from " |
|
18169
2d325551db9e
Remove the use of compiler string concatenation in a translatable string to
Richard Laager <rlaager@pidgin.im>
parents:
17538
diff
changeset
|
99 | "<a href=\"%s\">%s</a><hr>"), |
|
2d325551db9e
Remove the use of compiler string concatenation in a translatable string to
Richard Laager <rlaager@pidgin.im>
parents:
17538
diff
changeset
|
100 | PIDGIN_NAME, purple_core_get_version(), cur_ver, |
|
2d325551db9e
Remove the use of compiler string concatenation in a translatable string to
Richard Laager <rlaager@pidgin.im>
parents:
17538
diff
changeset
|
101 | PURPLE_WEBSITE, PURPLE_WEBSITE); |
| 7543 | 102 | |
| 103 | if(*changelog) { | |
| 15884 | 104 | formatted = purple_strdup_withhtml(changelog); |
|
17538
a1ae88080722
Two small changes to the release notification plugin:
Mark Doliner <markdoliner@pidgin.im>
parents:
16749
diff
changeset
|
105 | g_string_append_printf(message, _("<b>ChangeLog:</b><br>%s"), |
| 7543 | 106 | formatted); |
| 107 | g_free(formatted); | |
| 108 | } | |
| 109 | ||
| 15884 | 110 | purple_notify_formatted(NULL, _("New Version Available"), |
| 7543 | 111 | _("New Version Available"), NULL, message->str, |
| 112 | NULL, NULL); | |
| 113 | ||
| 114 | g_string_free(message, TRUE); | |
| 7599 | 115 | g_free(cur_ver); |
| 7543 | 116 | } |
| 117 | ||
| 118 | static void | |
| 119 | do_check(void) | |
| 120 | { | |
| 15884 | 121 | int last_check = purple_prefs_get_int("/plugins/gtk/relnot/last_check"); |
| 7543 | 122 | if(!last_check || time(NULL) - last_check > MIN_CHECK_INTERVAL) { |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
123 | gchar *url, *request; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
124 | const char *host = "pidgin.im"; |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
125 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
126 | url = g_strdup_printf("http://%s/version.php?version=%s&build=%s", |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
127 | host, |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
128 | purple_core_get_version(), |
| 7543 | 129 | #ifdef _WIN32 |
| 15884 | 130 | "purple-win32" |
| 7543 | 131 | #else |
| 15884 | 132 | "purple" |
| 7543 | 133 | #endif |
| 7546 | 134 | ); |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
135 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
136 | request = g_strdup_printf( |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
137 | "GET %s HTTP/1.0\r\n" |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
138 | "Connection: close\r\n" |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
139 | "Accept: */*\r\n" |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
140 | "Host: %s\r\n\r\n", |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
141 | url, |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
142 | host); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
143 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
144 | purple_util_fetch_url_request_len(url, TRUE, NULL, FALSE, |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
145 | request, TRUE, -1, version_fetch_cb, NULL); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
146 | |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
147 | g_free(request); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
148 | g_free(url); |
|
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
149 | |
| 15884 | 150 | purple_prefs_set_int("/plugins/gtk/relnot/last_check", time(NULL)); |
|
24247
9f640ea2ab9f
Parse the HTTP status code in the release notification plugin and only display
Daniel Atallah <datallah@pidgin.im>
parents:
20288
diff
changeset
|
151 | |
| 7543 | 152 | } |
| 153 | } | |
| 154 | ||
| 155 | static void | |
| 15884 | 156 | signed_on_cb(PurpleConnection *gc, void *data) { |
| 7543 | 157 | do_check(); |
| 158 | } | |
| 159 | ||
| 160 | /************************************************************************** | |
| 161 | * Plugin stuff | |
| 162 | **************************************************************************/ | |
| 163 | static gboolean | |
| 15884 | 164 | plugin_load(PurplePlugin *plugin) |
| 7543 | 165 | { |
| 15884 | 166 | purple_signal_connect(purple_connections_get_handle(), "signed-on", |
| 167 | plugin, PURPLE_CALLBACK(signed_on_cb), NULL); | |
| 7543 | 168 | |
| 169 | /* we don't check if we're offline */ | |
| 15884 | 170 | if(purple_connections_get_all()) |
| 7543 | 171 | do_check(); |
| 172 | ||
| 173 | return TRUE; | |
| 174 | } | |
| 175 | ||
| 15884 | 176 | static PurplePluginInfo info = |
| 7543 | 177 | { |
| 15884 | 178 | PURPLE_PLUGIN_MAGIC, |
| 179 | PURPLE_MAJOR_VERSION, | |
| 180 | PURPLE_MINOR_VERSION, | |
| 181 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 7543 | 182 | NULL, /**< ui_requirement */ |
| 183 | 0, /**< flags */ | |
| 184 | NULL, /**< dependencies */ | |
| 15884 | 185 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 7543 | 186 | |
| 187 | "gtk-relnot", /**< id */ | |
| 188 | N_("Release Notification"), /**< name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
189 | DISPLAY_VERSION, /**< version */ |
| 7543 | 190 | /** summary */ |
| 191 | N_("Checks periodically for new releases."), | |
| 192 | /** description */ | |
| 193 | N_("Checks periodically for new releases and notifies the user " | |
| 194 | "with the ChangeLog."), | |
| 195 | "Nathan Walp <faceprint@faceprint.com>", /**< author */ | |
| 15884 | 196 | PURPLE_WEBSITE, /**< homepage */ |
| 7543 | 197 | |
| 198 | plugin_load, /**< load */ | |
| 199 | NULL, /**< unload */ | |
| 200 | NULL, /**< destroy */ | |
| 201 | ||
| 202 | NULL, /**< ui_info */ | |
| 8993 | 203 | NULL, /**< extra_info */ |
| 204 | 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
|
205 | 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
|
206 | |
|
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
|
207 | /* 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
|
208 | 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
|
209 | 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
|
210 | NULL, |
| 8993 | 211 | NULL |
| 7543 | 212 | }; |
| 213 | ||
| 214 | static void | |
| 15884 | 215 | init_plugin(PurplePlugin *plugin) |
| 7543 | 216 | { |
| 15884 | 217 | purple_prefs_add_none("/plugins/gtk/relnot"); |
| 218 | purple_prefs_add_int("/plugins/gtk/relnot/last_check", 0); | |
| 7543 | 219 | } |
| 220 | ||
| 15884 | 221 | PURPLE_INIT_PLUGIN(relnot, init_plugin, info) |