diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-nm.c | 35 | ||||
-rw-r--r-- | shell/main.c | 28 |
2 files changed, 63 insertions, 0 deletions
diff --git a/shell/e-shell-nm.c b/shell/e-shell-nm.c index 581e505111..c520600769 100644 --- a/shell/e-shell-nm.c +++ b/shell/e-shell-nm.c @@ -96,6 +96,39 @@ e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED, return DBUS_HANDLER_RESULT_HANDLED; } +static void +check_initial_state (EShell *shell) +{ + DBusMessage *message = NULL, *response = NULL; + guint32 state = -1; + DBusError error = DBUS_ERROR_INIT; + + message = dbus_message_new_method_call ( + NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "state"); + + /* assuming this should be safe to call syncronously */ + response = dbus_connection_send_with_reply_and_block ( + dbus_connection, message, 100, &error); + + if (response) + dbus_message_get_args ( + response, &error, DBUS_TYPE_UINT32, + &state, DBUS_TYPE_INVALID); + else { + g_warning ("%s", error.message); + dbus_error_free (&error); + return; + } + + /* Update the state only in the absence of a network connection, + * otherwise let the old state prevail. */ + if (state == NM_STATE_DISCONNECTED) + e_shell_set_network_available (shell, FALSE); + + dbus_message_unref (message); + dbus_message_unref (response); +} + gboolean e_shell_dbus_initialize (EShell *shell) { @@ -119,6 +152,8 @@ e_shell_dbus_initialize (EShell *shell) if (!dbus_connection_add_filter (dbus_connection, e_shell_network_monitor, shell, NULL)) goto exception; + check_initial_state (shell); + dbus_bus_add_match (dbus_connection, "type='signal'," "interface='" NM_DBUS_INTERFACE "'," diff --git a/shell/main.c b/shell/main.c index 7a04cee149..b921dd87ec 100644 --- a/shell/main.c +++ b/shell/main.c @@ -28,6 +28,12 @@ #ifdef G_OS_WIN32 #define WIN32_LEAN_AND_MEAN +#ifdef DATADIR +#undef DATADIR +#endif +#include <io.h> +#include <conio.h> +#define _WIN32_WINNT 0x0500 #include <windows.h> #endif @@ -640,6 +646,28 @@ gint main (gint argc, gchar **argv) { #ifdef G_OS_WIN32 + if (fileno (stdout) != -1 && + _get_osfhandle (fileno (stdout)) != -1) + { + /* stdout is fine, presumably redirected to a file or pipe */ + } + else + { + typedef BOOL (* WINAPI AttachConsole_t) (DWORD); + + AttachConsole_t p_AttachConsole = + (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); + + if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) + { + freopen ("CONOUT$", "w", stdout); + dup2 (fileno (stdout), 1); + freopen ("CONOUT$", "w", stderr); + dup2 (fileno (stderr), 2); + + } + } + extern void link_shutdown (void); #endif |