From 68061831c125f588689a28344fa052ac8364797b Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 26 Apr 2007 01:53:47 +0000 Subject: win32: disable autocheck timer while suspending to prevent network error on resume. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1669 ee746299-78ed-0310-b773-934348b2243d --- src/main.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 95debba6..201d05da 100644 --- a/src/main.c +++ b/src/main.c @@ -91,6 +91,7 @@ #ifdef G_OS_WIN32 # include +# include # include #endif @@ -125,6 +126,9 @@ static void parse_gtkrc_files (void); static void setup_rc_dir (void); static void check_gpg (void); static void set_log_handlers (gboolean enable); +#ifdef G_OS_WIN32 +static void process_win32_message (void); +#endif static gchar *get_socket_name (void); static gint prohibit_duplicate_launch (void); @@ -287,6 +291,10 @@ int main(int argc, char *argv[]) set_log_handlers(TRUE); +#ifdef G_OS_WIN32 + process_win32_message(); +#endif + account_read_config_all(); account_set_menu(); main_window_reflect_prefs_all(); @@ -891,6 +899,52 @@ static void set_log_handlers(gboolean enable) #endif } +#ifdef G_OS_WIN32 +static LRESULT CALLBACK +wndproc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) +{ + if (message == WM_POWERBROADCAST) { + debug_print("WM_POWERBROADCAST received: wparam = %d\n", + wparam); + if (wparam == PBT_APMSUSPEND || wparam == PBT_APMSTANDBY) { + debug_print("suspend now\n"); + inc_autocheck_timer_remove(); + } else if (wparam == PBT_APMRESUMESUSPEND || + wparam == PBT_APMRESUMESTANDBY) { + debug_print("resume now\n"); + inc_autocheck_timer_set(); + } + } + + return DefWindowProc(hwnd, message, wparam, lparam); +} + +static void process_win32_message(void) +{ + WNDCLASS wclass; + static HWND hwnd = NULL; + ATOM klass; + HINSTANCE hmodule = GetModuleHandle(NULL); + + if (hwnd) + return; + + memset(&wclass, 0, sizeof(WNDCLASS)); + wclass.lpszClassName = "sylpheed-observer"; + wclass.lpfnWndProc = wndproc; + wclass.hInstance = hmodule; + + klass = RegisterClass(&wclass); + if (!klass) + return; + + hwnd = CreateWindow(MAKEINTRESOURCE(klass), NULL, WS_POPUP, + 0, 0, 1, 1, NULL, NULL, hmodule, NULL); + if (!hwnd) + UnregisterClass(MAKEINTRESOURCE(klass), hmodule); +} +#endif + static gchar *get_socket_name(void) { static gchar *filename = NULL; -- cgit v1.2.3