pidgin/win32/gtkwin32dep.c

changeset 21943
8a938e6ea033
parent 21613
0893e74c800b
child 24053
4ef3a40e1d9e
equal deleted inserted replaced
21942:8ee08ef6b2a3 21943:8a938e6ea033
38 38
39 #include "internal.h" 39 #include "internal.h"
40 40
41 #include "debug.h" 41 #include "debug.h"
42 #include "notify.h" 42 #include "notify.h"
43 #include "network.h"
43 44
44 #include "resource.h" 45 #include "resource.h"
45 #include "idletrack.h" 46 #include "idletrack.h"
46 #include "zlib.h" 47 #include "zlib.h"
47 #include "untar.h" 48 #include "untar.h"
49 #include <libintl.h> 50 #include <libintl.h>
50 51
51 #include "gtkwin32dep.h" 52 #include "gtkwin32dep.h"
52 #include "win32dep.h" 53 #include "win32dep.h"
53 #include "gtkconv.h" 54 #include "gtkconv.h"
55 #include "gtkconn.h"
54 #include "util.h" 56 #include "util.h"
55 #include "wspell.h" 57 #include "wspell.h"
56 58
57 /* 59 /*
58 * GLOBALS 60 * GLOBALS
62 HWND messagewin_hwnd; 64 HWND messagewin_hwnd;
63 static int gtkwin32_handle; 65 static int gtkwin32_handle;
64 66
65 typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); 67 typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO);
66 static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; 68 static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL;
69 static gboolean pwm_handles_connections = TRUE;
67 70
68 71
69 /* 72 /*
70 * PUBLIC CODE 73 * PUBLIC CODE
71 */ 74 */
200 } 203 }
201 204
202 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13) 205 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
203 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14) 206 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
204 207
208 static void*
209 winpidgin_netconfig_changed_cb(void *data)
210 {
211 pwm_handles_connections = FALSE;
212
213 return NULL;
214 }
215
216 static void*
217 winpidgin_get_handle(void)
218 {
219 static int handle;
220
221 return &handle;
222 }
223
224 static gboolean
225 winpidgin_pwm_reconnect()
226 {
227 purple_signal_disconnect(purple_network_get_handle(), "network-configuration-changed",
228 winpidgin_get_handle(), PURPLE_CALLBACK(winpidgin_netconfig_changed_cb));
229
230 if (pwm_handles_connections == TRUE) {
231 PurpleConnectionUiOps *ui_ops = pidgin_connections_get_ui_ops();
232
233 purple_debug_info("winpidgin", "Resumed from standby, reconnecting accounts.\n");
234
235 if (ui_ops != NULL && ui_ops->network_connected != NULL)
236 ui_ops->network_connected();
237 } else {
238 purple_debug_info("winpidgin", "Resumed from standby, gtkconn will handle reconnecting.\n");
239 pwm_handles_connections = TRUE;
240 }
241
242 return FALSE;
243 }
244
205 static LRESULT CALLBACK message_window_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { 245 static LRESULT CALLBACK message_window_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
206 246
207 if (msg == PIDGIN_WM_FOCUS_REQUEST) { 247 if (msg == PIDGIN_WM_FOCUS_REQUEST) {
208 purple_debug_info("winpidgin", "Got external Buddy List focus request."); 248 purple_debug_info("winpidgin", "Got external Buddy List focus request.");
209 purple_blist_set_visible(TRUE); 249 purple_blist_set_visible(TRUE);
211 } else if (msg == PIDGIN_WM_PROTOCOL_HANDLE) { 251 } else if (msg == PIDGIN_WM_PROTOCOL_HANDLE) {
212 char *proto_msg = (char *) lparam; 252 char *proto_msg = (char *) lparam;
213 purple_debug_info("winpidgin", "Got protocol handler request: %s\n", proto_msg ? proto_msg : ""); 253 purple_debug_info("winpidgin", "Got protocol handler request: %s\n", proto_msg ? proto_msg : "");
214 purple_got_protocol_handler_uri(proto_msg); 254 purple_got_protocol_handler_uri(proto_msg);
215 return TRUE; 255 return TRUE;
256 } else if (msg == WM_POWERBROADCAST) {
257 if (wparam == PBT_APMQUERYSUSPEND) {
258 purple_debug_info("winpidgin", "Windows requesting permission to suspend.\n");
259 return TRUE;
260 } else if (wparam == PBT_APMSUSPEND) {
261 PurpleConnectionUiOps *ui_ops = pidgin_connections_get_ui_ops();
262
263 purple_debug_info("winpidgin", "Entering system standby, disconnecting accounts.\n");
264
265 if (ui_ops != NULL && ui_ops->network_disconnected != NULL)
266 ui_ops->network_disconnected();
267
268 purple_signal_connect(purple_network_get_handle(), "network-configuration-changed", winpidgin_get_handle(),
269 PURPLE_CALLBACK(winpidgin_netconfig_changed_cb), NULL);
270
271 return TRUE;
272 } else if (wparam == PBT_APMRESUMESUSPEND) {
273 purple_debug_info("winpidgin", "Resuming from system standby.\n");
274 /* TODO: It seems like it'd be wise to use the NLA message, if possible, instead of this. */
275 purple_timeout_add_seconds(1, winpidgin_pwm_reconnect, NULL);
276 return TRUE;
277 }
216 } 278 }
217 279
218 return DefWindowProc(hwnd, msg, wparam, lparam); 280 return DefWindowProc(hwnd, msg, wparam, lparam);
219 } 281 }
220 282
240 302
241 RegisterClassEx(&wcx); 303 RegisterClassEx(&wcx);
242 304
243 /* Create the window */ 305 /* Create the window */
244 if(!(win_hwnd = CreateWindow(wname, TEXT("WinpidginMsgWin"), 0, 0, 0, 0, 0, 306 if(!(win_hwnd = CreateWindow(wname, TEXT("WinpidginMsgWin"), 0, 0, 0, 0, 0,
245 HWND_MESSAGE, NULL, winpidgin_exe_hinstance(), 0))) { 307 NULL, NULL, winpidgin_exe_hinstance(), 0))) {
246 purple_debug_error("winpidgin", 308 purple_debug_error("winpidgin",
247 "Unable to create message window.\n"); 309 "Unable to create message window.\n");
248 return NULL; 310 return NULL;
249 } 311 }
250 312

mercurial