| 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 |