diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-04-01 01:51:50 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-04-01 03:48:01 +0800 |
commit | bfb1d53650e81405792091827dd937182367cd6c (patch) | |
tree | 3526b00222ad9dfee5b47a395ef7e2357a5ab2a4 /modules | |
parent | 4eec255877f060bf907704488397459f7612be86 (diff) | |
download | gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.tar gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.tar.gz gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.tar.bz2 gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.tar.lz gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.tar.xz gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.tar.zst gsoc2013-evolution-bfb1d53650e81405792091827dd937182367cd6c.zip |
Drop the ConnMan/NetworkManager/WindowsSENS modules.
We rely on GNetworkMonitor for network availability now.
Not our problem anymore. \o/
Diffstat (limited to 'modules')
-rw-r--r-- | modules/Makefile.am | 17 | ||||
-rw-r--r-- | modules/connman/Makefile.am | 22 | ||||
-rw-r--r-- | modules/connman/evolution-connman.c | 250 | ||||
-rw-r--r-- | modules/network-manager/Makefile.am | 24 | ||||
-rw-r--r-- | modules/network-manager/evolution-network-manager.c | 282 | ||||
-rw-r--r-- | modules/windows-sens/Makefile.am | 22 | ||||
-rw-r--r-- | modules/windows-sens/evolution-windows-sens.c | 626 |
7 files changed, 1 insertions, 1242 deletions
diff --git a/modules/Makefile.am b/modules/Makefile.am index 671215b952..ce6c0aa94a 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -10,18 +10,6 @@ if ENABLE_ONLINE_ACCOUNTS ONLINE_ACCOUNTS_DIR = online-accounts endif -if ENABLE_NETWORK_MANAGER -NETWORK_MANAGER_DIR = network-manager -endif - -if ENABLE_CONNMAN -CONNMAN_DIR = connman -endif - -if ENABLE_WINDOWS_SENS -WINDOWS_SENS_DIR = windows-sens -endif - SUBDIRS = \ addressbook \ bogofilter \ @@ -38,9 +26,6 @@ SUBDIRS = \ web-inspector \ $(MONO_DIR) \ $(PYTHON_DIR) \ - $(ONLINE_ACCOUNTS_DIR) \ - $(NETWORK_MANAGER_DIR) \ - $(WINDOWS_SENS_DIR) \ - $(CONNMAN_DIR) + $(ONLINE_ACCOUNTS_DIR) -include $(top_srcdir)/git.mk diff --git a/modules/connman/Makefile.am b/modules/connman/Makefile.am deleted file mode 100644 index d01a8f0daa..0000000000 --- a/modules/connman/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -module_LTLIBRARIES = libevolution-module-connman.la - -libevolution_module_connman_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - -DG_LOG_DOMAIN=\"evolution-connman\" \ - $(EVOLUTION_DATA_SERVER_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) - -libevolution_module_connman_la_SOURCES = \ - evolution-connman.c - -libevolution_module_connman_la_LIBADD = \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/shell/libeshell.la \ - $(EVOLUTION_DATA_SERVER_LIBS) \ - $(GNOME_PLATFORM_LIBS) - -libevolution_module_connman_la_LDFLAGS = \ - -module -avoid-version $(NO_UNDEFINED) - --include $(top_srcdir)/git.mk diff --git a/modules/connman/evolution-connman.c b/modules/connman/evolution-connman.c deleted file mode 100644 index 2c35c2412e..0000000000 --- a/modules/connman/evolution-connman.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * evolution-connman.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gio/gio.h> -#include <libebackend/e-extension.h> - -#include <shell/e-shell.h> - -#define CM_DBUS_SERVICE "net.connman" -#define CM_DBUS_INTERFACE "net.connman.Manager" -#define CM_DBUS_PATH "/" - -/* Standard GObject macros */ -#define E_TYPE_CONNMAN \ - (e_connman_get_type ()) -#define E_CONNMAN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_CONNMAN, EConnMan)) - -typedef struct { - EExtension parent; - GDBusConnection *connection; -} EConnMan; -typedef EExtensionClass EConnManClass; - -/* Module Entry Points */ -void e_module_load (GTypeModule *type_module); -void e_module_unload (GTypeModule *type_module); - -/* Forward Declarations */ -GType e_connman_get_type (void); -static gboolean connman_connect (EConnMan *extension); - -G_DEFINE_DYNAMIC_TYPE (EConnMan, e_connman, E_TYPE_EXTENSION) - -static void -extension_set_state (EConnMan *extension, - const gchar *state) -{ - EExtensible *extensible; - gboolean network_available; - - extensible = e_extension_get_extensible (E_EXTENSION (extension)); - g_return_if_fail (E_IS_SHELL (extensible)); - - network_available = (g_strcmp0 (state, "online") == 0); - e_shell_set_network_available (E_SHELL (extensible), network_available); -} - -static void -connman_connection_closed_cb (GDBusConnection *connection, - gboolean remote_peer_vanished, - GError *error, - EConnMan *extension) -{ - gboolean try_again; - - g_object_unref (extension->connection); - extension->connection = NULL; - - /* Try connecting to the session bus immediately, and then - * keep trying at 3 second intervals until we're back on. */ - - try_again = connman_connect (extension); - - if (try_again) - g_timeout_add_seconds ( - 3, (GSourceFunc) connman_connect, extension); -} - -static void -conn_manager_signal_cb (GDBusConnection *connection, - const gchar *sender_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *signal_name, - GVariant *parameters, - gpointer user_data) -{ - EConnMan *extension = user_data; - gchar *state = NULL; - - if (g_strcmp0 (interface_name, CM_DBUS_INTERFACE) != 0 - || g_strcmp0 (object_path, CM_DBUS_PATH) != 0 - || g_strcmp0 (signal_name, "StateChanged") != 0) - return; - - g_variant_get (parameters, "(s)", &state); - extension_set_state (extension, state); - g_free (state); -} - -static void -connman_check_initial_state (EConnMan *extension) -{ - GDBusMessage *message = NULL; - GDBusMessage *response = NULL; - GVariant *body; - gchar *state = NULL; - GError *error = NULL; - - message = g_dbus_message_new_method_call ( - CM_DBUS_SERVICE, CM_DBUS_PATH, CM_DBUS_INTERFACE, "GetState"); - - /* XXX Assuming this should be safe to call synchronously. */ - response = g_dbus_connection_send_message_with_reply_sync ( - extension->connection, message, - G_DBUS_SEND_MESSAGE_FLAGS_NONE, 100, NULL, NULL, &error); - - if (response != NULL) { - if (g_dbus_message_to_gerror (response, &error)) { - g_object_unref (response); - response = NULL; - } - } - - g_object_unref (message); - - if (error != NULL) { - g_warning ("%s: %s", G_STRFUNC, error->message); - g_error_free (error); - return; - } - - g_return_if_fail (G_IS_DBUS_MESSAGE (response)); - - body = g_dbus_message_get_body (response); - g_variant_get (body, "(s)", &state); - extension_set_state (extension, state); - g_free (state); - - g_object_unref (response); -} - -static gboolean -connman_connect (EConnMan *extension) -{ - GError *error = NULL; - - /* This is a timeout callback, so the return value denotes - * whether to reschedule, not whether we're successful. */ - - if (extension->connection != NULL) - return FALSE; - - extension->connection = - g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); - - if (error != NULL) { - g_warning ("%s: %s", G_STRFUNC, error->message); - g_error_free (error); - return TRUE; - } - - g_return_val_if_fail ( - G_IS_DBUS_CONNECTION (extension->connection), FALSE); - - g_dbus_connection_set_exit_on_close (extension->connection, FALSE); - - if (!g_dbus_connection_signal_subscribe ( - extension->connection, - CM_DBUS_SERVICE, - CM_DBUS_INTERFACE, - NULL, - CM_DBUS_PATH, - NULL, - G_DBUS_SIGNAL_FLAGS_NONE, - conn_manager_signal_cb, - extension, - NULL)) { - g_warning ("%s: Failed to subscribe for a signal", G_STRFUNC); - goto fail; - } - - g_signal_connect ( - extension->connection, "closed", - G_CALLBACK (connman_connection_closed_cb), extension); - - connman_check_initial_state (extension); - - return FALSE; - -fail: - g_object_unref (extension->connection); - extension->connection = NULL; - - return TRUE; -} - -static void -connman_constructed (GObject *object) -{ - connman_connect (E_CONNMAN (object)); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_connman_parent_class)->constructed (object); -} - -static void -e_connman_class_init (EConnManClass *class) -{ - GObjectClass *object_class; - EExtensionClass *extension_class; - - object_class = G_OBJECT_CLASS (class); - object_class->constructed = connman_constructed; - - extension_class = E_EXTENSION_CLASS (class); - extension_class->extensible_type = E_TYPE_SHELL; -} - -static void -e_connman_class_finalize (EConnManClass *class) -{ -} - -static void -e_connman_init (EConnMan *extension) -{ -} - -G_MODULE_EXPORT void -e_module_load (GTypeModule *type_module) -{ - e_connman_register_type (type_module); -} - -G_MODULE_EXPORT void -e_module_unload (GTypeModule *type_module) -{ -} diff --git a/modules/network-manager/Makefile.am b/modules/network-manager/Makefile.am deleted file mode 100644 index 2d87b22acf..0000000000 --- a/modules/network-manager/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -module_LTLIBRARIES = libevolution-module-network-manager.la - -libevolution_module_network_manager_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - -DG_LOG_DOMAIN=\"evolution-network-manager\" \ - $(EVOLUTION_DATA_SERVER_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) \ - $(SHELL_CFLAGS) \ - $(NM_CFLAGS) - -libevolution_module_network_manager_la_SOURCES = \ - evolution-network-manager.c - -libevolution_module_network_manager_la_LIBADD = \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/shell/libeshell.la \ - $(EVOLUTION_DATA_SERVER_LIBS) \ - $(GNOME_PLATFORM_LIBS) - -libevolution_module_network_manager_la_LDFLAGS = \ - -module -avoid-version $(NO_UNDEFINED) - --include $(top_srcdir)/git.mk diff --git a/modules/network-manager/evolution-network-manager.c b/modules/network-manager/evolution-network-manager.c deleted file mode 100644 index bb83ba8104..0000000000 --- a/modules/network-manager/evolution-network-manager.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * evolution-network-manager.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gio/gio.h> -#include <libebackend/e-extension.h> -#include <NetworkManager/NetworkManager.h> - -#if !defined(NM_CHECK_VERSION) -#define NM_CHECK_VERSION(x,y,z) 0 -#endif - -#include <shell/e-shell.h> - -/* Standard GObject macros */ -#define E_TYPE_NETWORK_MANAGER \ - (e_network_manager_get_type ()) -#define E_NETWORK_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_NETWORK_MANAGER, ENetworkManager)) - -typedef struct _ENetworkManager ENetworkManager; -typedef struct _ENetworkManagerClass ENetworkManagerClass; - -struct _ENetworkManager { - EExtension parent; - GDBusConnection *connection; -}; - -struct _ENetworkManagerClass { - EExtensionClass parent_class; -}; - -/* Module Entry Points */ -void e_module_load (GTypeModule *type_module); -void e_module_unload (GTypeModule *type_module); - -/* Forward Declarations */ -GType e_network_manager_get_type (void); -static gboolean network_manager_connect (ENetworkManager *extension); - -G_DEFINE_DYNAMIC_TYPE (ENetworkManager, e_network_manager, E_TYPE_EXTENSION) - -static EShell * -network_manager_get_shell (ENetworkManager *extension) -{ - EExtensible *extensible; - - extensible = e_extension_get_extensible (E_EXTENSION (extension)); - - return E_SHELL (extensible); -} - -static void -nm_connection_closed_cb (GDBusConnection *connection, - gboolean remote_peer_vanished, - GError *error, - ENetworkManager *extension) -{ - gboolean try_again; - - g_object_unref (extension->connection); - extension->connection = NULL; - - /* Try connecting to the session bus immediately, and then - * keep trying at 3 second intervals until we're back on. */ - - try_again = network_manager_connect (extension); - - if (try_again) - g_timeout_add_seconds ( - 3, (GSourceFunc) network_manager_connect, extension); -} - -static void -network_manager_handle_state (EShell *shell, - guint32 state) -{ - switch (state) { -#if NM_CHECK_VERSION(0,8,992) - case NM_STATE_CONNECTED_LOCAL: - case NM_STATE_CONNECTED_SITE: - case NM_STATE_CONNECTED_GLOBAL: -#else - case NM_STATE_CONNECTED: -#endif - e_shell_set_network_available (shell, TRUE); - break; - case NM_STATE_ASLEEP: - case NM_STATE_DISCONNECTED: -#if NM_CHECK_VERSION(0,8,992) - case NM_STATE_DISCONNECTING: -#endif - e_shell_set_network_available (shell, FALSE); - break; - default: - break; - } -} - -static void -network_manager_signal_cb (GDBusConnection *connection, - const gchar *sender_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *signal_name, - GVariant *parameters, - gpointer user_data) -{ - ENetworkManager *extension = user_data; - EShell *shell; - guint32 state; - - shell = network_manager_get_shell (extension); - - if (g_strcmp0 (interface_name, NM_DBUS_INTERFACE) != 0 - || g_strcmp0 (signal_name, "StateChanged") != 0) - return; - - g_variant_get (parameters, "(u)", &state); - network_manager_handle_state (shell, state); -} - -static void -network_manager_query_state (ENetworkManager *extension) -{ - EShell *shell; - GDBusMessage *message = NULL; - GDBusMessage *response = NULL; - GVariant *body; - guint32 state = -1; - GError *error = NULL; - - shell = network_manager_get_shell (extension); - - message = g_dbus_message_new_method_call ( - NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "state"); - - /* XXX Assuming this should be safe to call synchronously. */ - response = g_dbus_connection_send_message_with_reply_sync ( - extension->connection, message, - G_DBUS_SEND_MESSAGE_FLAGS_NONE, 100, NULL, NULL, &error); - - if (response != NULL) { - if (g_dbus_message_to_gerror (response, &error)) { - g_object_unref (response); - response = NULL; - } - } - - g_object_unref (message); - - if (error != NULL) { - g_warning ("%s: %s", G_STRFUNC, error->message); - g_error_free (error); - return; - } - - g_return_if_fail (G_IS_DBUS_MESSAGE (response)); - - body = g_dbus_message_get_body (response); - g_variant_get (body, "(u)", &state); - network_manager_handle_state (shell, state); - - g_object_unref (response); -} - -static gboolean -network_manager_connect (ENetworkManager *extension) -{ - GError *error = NULL; - - /* This is a timeout callback, so the return value denotes - * whether to reschedule, not whether we're successful. */ - - if (extension->connection != NULL) - return FALSE; - - extension->connection = - g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); - - if (error != NULL) { - g_warning ("%s: %s", G_STRFUNC, error->message); - g_error_free (error); - return TRUE; - } - - g_return_val_if_fail ( - G_IS_DBUS_CONNECTION (extension->connection), FALSE); - - g_dbus_connection_set_exit_on_close (extension->connection, FALSE); - - if (!g_dbus_connection_signal_subscribe ( - extension->connection, - NM_DBUS_SERVICE, - NM_DBUS_INTERFACE, - NULL, - NM_DBUS_PATH, - NULL, - G_DBUS_SIGNAL_FLAGS_NONE, - network_manager_signal_cb, - extension, - NULL)) { - g_warning ("%s: Failed to subscribe for a signal", G_STRFUNC); - goto fail; - } - - g_signal_connect ( - extension->connection, "closed", - G_CALLBACK (nm_connection_closed_cb), extension); - - network_manager_query_state (extension); - - return FALSE; - -fail: - g_object_unref (extension->connection); - extension->connection = NULL; - - return TRUE; -} - -static void -network_manager_constructed (GObject *object) -{ - network_manager_connect (E_NETWORK_MANAGER (object)); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_network_manager_parent_class)->constructed (object); -} - -static void -e_network_manager_class_init (ENetworkManagerClass *class) -{ - GObjectClass *object_class; - EExtensionClass *extension_class; - - object_class = G_OBJECT_CLASS (class); - object_class->constructed = network_manager_constructed; - - extension_class = E_EXTENSION_CLASS (class); - extension_class->extensible_type = E_TYPE_SHELL; -} - -static void -e_network_manager_class_finalize (ENetworkManagerClass *class) -{ -} - -static void -e_network_manager_init (ENetworkManager *extension) -{ -} - -G_MODULE_EXPORT void -e_module_load (GTypeModule *type_module) -{ - e_network_manager_register_type (type_module); -} - -G_MODULE_EXPORT void -e_module_unload (GTypeModule *type_module) -{ -} diff --git a/modules/windows-sens/Makefile.am b/modules/windows-sens/Makefile.am deleted file mode 100644 index a9b9d31865..0000000000 --- a/modules/windows-sens/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -module_LTLIBRARIES = libevolution-module-windows-sens.la - -libevolution_module_windows_sens_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - -DG_LOG_DOMAIN=\"evolution-windows-sens\" \ - $(EVOLUTION_DATA_SERVER_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) - -libevolution_module_windows_sens_la_SOURCES = \ - evolution-windows-sens.c - -libevolution_module_windows_sens_la_LIBADD = \ - $(top_builddir)/shell/libeshell.la \ - $(EVOLUTION_DATA_SERVER_LIBS) \ - $(GNOME_PLATFORM_LIBS) \ - $(SENS_LIBS) - -libevolution_module_windows_sens_la_LDFLAGS = \ - -module -avoid-version $(NO_UNDEFINED) - --include $(top_srcdir)/git.mk diff --git a/modules/windows-sens/evolution-windows-sens.c b/modules/windows-sens/evolution-windows-sens.c deleted file mode 100644 index f3110b2fcc..0000000000 --- a/modules/windows-sens/evolution-windows-sens.c +++ /dev/null @@ -1,626 +0,0 @@ -/* - * evolution-windows-sens.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - */ - -#ifdef __cplusplus -#error This file cannot be built with C++ compiler -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define INITGUID -#include <windows.h> -#include <rpc.h> - -#ifdef HAVE_EVENTSYS_H -#include <eventsys.h> -#else - -#include <libebackend/e-extension.h> - -/* Extract relevant typedefs from mingw-w64 headers */ - -typedef struct IEnumEventObject IEnumEventObject; - -const IID IID_IEnumEventObject; -typedef struct IEnumEventObjectVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(IEnumEventObject *This,REFIID riid,PVOID *ppvObject); - ULONG (WINAPI *AddRef)(IEnumEventObject *This); - ULONG (WINAPI *Release)(IEnumEventObject *This); - HRESULT (WINAPI *Clone)(IEnumEventObject *This,IEnumEventObject **ppInterface); - HRESULT (WINAPI *Next)(IEnumEventObject *This,ULONG cReqElem,IUnknown **ppInterface,ULONG *cRetElem); - HRESULT (WINAPI *Reset)(IEnumEventObject *This); - HRESULT (WINAPI *Skip)(IEnumEventObject *This,ULONG cSkipElem); - END_INTERFACE -} IEnumEventObjectVtbl; -struct IEnumEventObject { - CONST_VTBL struct IEnumEventObjectVtbl *lpVtbl; -}; - -typedef struct IEventObjectCollection IEventObjectCollection; - -const IID IID_IEventObjectCollection; -typedef struct IEventObjectCollectionVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(IEventObjectCollection *This,REFIID riid,PVOID *ppvObject); - ULONG (WINAPI *AddRef)(IEventObjectCollection *This); - ULONG (WINAPI *Release)(IEventObjectCollection *This); - HRESULT (WINAPI *GetTypeInfoCount)(IEventObjectCollection *This,UINT *pctinfo); - HRESULT (WINAPI *GetTypeInfo)(IEventObjectCollection *This,UINT iTInfo,LCID lcid,ITypeInfo **ppTInfo); - HRESULT (WINAPI *GetIDsOfNames)(IEventObjectCollection *This,REFIID riid,LPOLESTR *rgszNames,UINT cNames,LCID lcid,DISPID *rgDispId); - HRESULT (WINAPI *Invoke)(IEventObjectCollection *This,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS *pDispParams,VARIANT *pVarResult,EXCEPINFO *pExcepInfo,UINT *puArgErr); - HRESULT (WINAPI *get__NewEnum)(IEventObjectCollection *This,IUnknown **ppUnkEnum); - HRESULT (WINAPI *get_Item)(IEventObjectCollection *This,BSTR objectID,VARIANT *pItem); - HRESULT (WINAPI *get_NewEnum)(IEventObjectCollection *This,IEnumEventObject **ppEnum); - HRESULT (WINAPI *get_Count)(IEventObjectCollection *This,long *pCount); - HRESULT (WINAPI *Add)(IEventObjectCollection *This,VARIANT *item,BSTR objectID); - HRESULT (WINAPI *Remove)(IEventObjectCollection *This,BSTR objectID); - END_INTERFACE -} IEventObjectCollectionVtbl; -struct IEventObjectCollection { - CONST_VTBL struct IEventObjectCollectionVtbl *lpVtbl; -}; - -typedef struct IEventSystem IEventSystem; - -const IID IID_IEventSystem; -typedef struct IEventSystemVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(IEventSystem *This,REFIID riid,PVOID *ppvObject); - ULONG (WINAPI *AddRef)(IEventSystem *This); - ULONG (WINAPI *Release)(IEventSystem *This); - HRESULT (WINAPI *GetTypeInfoCount)(IEventSystem *This,UINT *pctinfo); - HRESULT (WINAPI *GetTypeInfo)(IEventSystem *This,UINT iTInfo,LCID lcid,ITypeInfo **ppTInfo); - HRESULT (WINAPI *GetIDsOfNames)(IEventSystem *This,REFIID riid,LPOLESTR *rgszNames,UINT cNames,LCID lcid,DISPID *rgDispId); - HRESULT (WINAPI *Invoke)(IEventSystem *This,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS *pDispParams,VARIANT *pVarResult,EXCEPINFO *pExcepInfo,UINT *puArgErr); - HRESULT (WINAPI *Query)(IEventSystem *This,BSTR progID,BSTR queryCriteria,int *errorIndex,IUnknown **ppInterface); - HRESULT (WINAPI *Store)(IEventSystem *This,BSTR ProgID,IUnknown *pInterface); - HRESULT (WINAPI *Remove)(IEventSystem *This,BSTR progID,BSTR queryCriteria,int *errorIndex); - HRESULT (WINAPI *get_EventObjectChangeEventClassID)(IEventSystem *This,BSTR *pbstrEventClassID); - HRESULT (WINAPI *QueryS)(IEventSystem *This,BSTR progID,BSTR queryCriteria,IUnknown **ppInterface); - HRESULT (WINAPI *RemoveS)(IEventSystem *This,BSTR progID,BSTR queryCriteria); - END_INTERFACE -} IEventSystemVtbl; -struct IEventSystem { - CONST_VTBL struct IEventSystemVtbl *lpVtbl; -}; - -typedef struct IEventSubscription IEventSubscription; - -const IID IID_IEventSubscription; -typedef struct IEventSubscriptionVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(IEventSubscription *This,REFIID riid,PVOID *ppvObject); - ULONG (WINAPI *AddRef)(IEventSubscription *This); - ULONG (WINAPI *Release)(IEventSubscription *This); - HRESULT (WINAPI *GetTypeInfoCount)(IEventSubscription *This,UINT *pctinfo); - HRESULT (WINAPI *GetTypeInfo)(IEventSubscription *This,UINT iTInfo,LCID lcid,ITypeInfo **ppTInfo); - HRESULT (WINAPI *GetIDsOfNames)(IEventSubscription *This,REFIID riid,LPOLESTR *rgszNames,UINT cNames,LCID lcid,DISPID *rgDispId); - HRESULT (WINAPI *Invoke)(IEventSubscription *This,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS *pDispParams,VARIANT *pVarResult,EXCEPINFO *pExcepInfo,UINT *puArgErr); - HRESULT (WINAPI *get_SubscriptionID)(IEventSubscription *This,BSTR *pbstrSubscriptionID); - HRESULT (WINAPI *put_SubscriptionID)(IEventSubscription *This,BSTR bstrSubscriptionID); - HRESULT (WINAPI *get_SubscriptionName)(IEventSubscription *This,BSTR *pbstrSubscriptionName); - HRESULT (WINAPI *put_SubscriptionName)(IEventSubscription *This,BSTR bstrSubscriptionName); - HRESULT (WINAPI *get_PublisherID)(IEventSubscription *This,BSTR *pbstrPublisherID); - HRESULT (WINAPI *put_PublisherID)(IEventSubscription *This,BSTR bstrPublisherID); - HRESULT (WINAPI *get_EventClassID)(IEventSubscription *This,BSTR *pbstrEventClassID); - HRESULT (WINAPI *put_EventClassID)(IEventSubscription *This,BSTR bstrEventClassID); - HRESULT (WINAPI *get_MethodName)(IEventSubscription *This,BSTR *pbstrMethodName); - HRESULT (WINAPI *put_MethodName)(IEventSubscription *This,BSTR bstrMethodName); - HRESULT (WINAPI *get_SubscriberCLSID)(IEventSubscription *This,BSTR *pbstrSubscriberCLSID); - HRESULT (WINAPI *put_SubscriberCLSID)(IEventSubscription *This,BSTR bstrSubscriberCLSID); - HRESULT (WINAPI *get_SubscriberInterface)(IEventSubscription *This,IUnknown **ppSubscriberInterface); - HRESULT (WINAPI *put_SubscriberInterface)(IEventSubscription *This,IUnknown *pSubscriberInterface); - HRESULT (WINAPI *get_PerUser)(IEventSubscription *This,WINBOOL *pfPerUser); - HRESULT (WINAPI *put_PerUser)(IEventSubscription *This,WINBOOL fPerUser); - HRESULT (WINAPI *get_OwnerSID)(IEventSubscription *This,BSTR *pbstrOwnerSID); - HRESULT (WINAPI *put_OwnerSID)(IEventSubscription *This,BSTR bstrOwnerSID); - HRESULT (WINAPI *get_Enabled)(IEventSubscription *This,WINBOOL *pfEnabled); - HRESULT (WINAPI *put_Enabled)(IEventSubscription *This,WINBOOL fEnabled); - HRESULT (WINAPI *get_Description)(IEventSubscription *This,BSTR *pbstrDescription); - HRESULT (WINAPI *put_Description)(IEventSubscription *This,BSTR bstrDescription); - HRESULT (WINAPI *get_MachineName)(IEventSubscription *This,BSTR *pbstrMachineName); - HRESULT (WINAPI *put_MachineName)(IEventSubscription *This,BSTR bstrMachineName); - HRESULT (WINAPI *GetPublisherProperty)(IEventSubscription *This,BSTR bstrPropertyName,VARIANT *propertyValue); - HRESULT (WINAPI *PutPublisherProperty)(IEventSubscription *This,BSTR bstrPropertyName,VARIANT *propertyValue); - HRESULT (WINAPI *RemovePublisherProperty)(IEventSubscription *This,BSTR bstrPropertyName); - HRESULT (WINAPI *GetPublisherPropertyCollection)(IEventSubscription *This,IEventObjectCollection **collection); - HRESULT (WINAPI *GetSubscriberProperty)(IEventSubscription *This,BSTR bstrPropertyName,VARIANT *propertyValue); - HRESULT (WINAPI *PutSubscriberProperty)(IEventSubscription *This,BSTR bstrPropertyName,VARIANT *propertyValue); - HRESULT (WINAPI *RemoveSubscriberProperty)(IEventSubscription *This,BSTR bstrPropertyName); - HRESULT (WINAPI *GetSubscriberPropertyCollection)(IEventSubscription *This,IEventObjectCollection **collection); - HRESULT (WINAPI *get_InterfaceID)(IEventSubscription *This,BSTR *pbstrInterfaceID); - HRESULT (WINAPI *put_InterfaceID)(IEventSubscription *This,BSTR bstrInterfaceID); - END_INTERFACE -} IEventSubscriptionVtbl; -struct IEventSubscription { - CONST_VTBL struct IEventSubscriptionVtbl *lpVtbl; -}; - -#define PROGID_EventSubscription OLESTR("EventSystem.EventSubscription") - -#endif - -#ifdef HAVE_SENSEVTS_H -#include <sensevts.h> -#else - -/* Extract relevant typedefs from mingw-w64 headers */ - -typedef struct { - DWORD dwSize; - DWORD dwFlags; - DWORD dwOutSpeed; - DWORD dwInSpeed; -} *LPSENS_QOCINFO; - -typedef struct ISensNetwork ISensNetwork; - -const IID IID_ISensNetwork; -typedef struct ISensNetworkVtbl { - BEGIN_INTERFACE - HRESULT (WINAPI *QueryInterface)(ISensNetwork *This,REFIID riid,PVOID *ppvObject); - ULONG (WINAPI *AddRef)(ISensNetwork *This); - ULONG (WINAPI *Release)(ISensNetwork *This); - HRESULT (WINAPI *GetTypeInfoCount)(ISensNetwork *This,UINT *pctinfo); - HRESULT (WINAPI *GetTypeInfo)(ISensNetwork *This,UINT iTInfo,LCID lcid,ITypeInfo **ppTInfo); - HRESULT (WINAPI *GetIDsOfNames)(ISensNetwork *This,REFIID riid,LPOLESTR *rgszNames,UINT cNames,LCID lcid,DISPID *rgDispId); - HRESULT (WINAPI *Invoke)(ISensNetwork *This,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS *pDispParams,VARIANT *pVarResult,EXCEPINFO *pExcepInfo,UINT *puArgErr); - HRESULT (WINAPI *ConnectionMade)(ISensNetwork *This,BSTR bstrConnection,ULONG ulType,LPSENS_QOCINFO lpQOCInfo); - HRESULT (WINAPI *ConnectionMadeNoQOCInfo)(ISensNetwork *This,BSTR bstrConnection,ULONG ulType); - HRESULT (WINAPI *ConnectionLost)(ISensNetwork *This,BSTR bstrConnection,ULONG ulType); - HRESULT (WINAPI *DestinationReachable)(ISensNetwork *This,BSTR bstrDestination,BSTR bstrConnection,ULONG ulType,LPSENS_QOCINFO lpQOCInfo); - HRESULT (WINAPI *DestinationReachableNoQOCInfo)(ISensNetwork *This,BSTR bstrDestination,BSTR bstrConnection,ULONG ulType); - END_INTERFACE -} ISensNetworkVtbl; -struct ISensNetwork { - CONST_VTBL struct ISensNetworkVtbl *lpVtbl; -}; - -#endif - -#include <shell/e-shell.h> - -/* 4E14FB9F-2E22-11D1-9964-00C04FBBB345 */ -DEFINE_GUID (IID_IEventSystem, 0x4E14FB9F, 0x2E22, 0x11D1, 0x99, 0x64, 0x00, 0xC0, 0x4F, 0xBB, 0xB3, 0x45); - -/* 4A6B0E15-2E38-11D1-9965-00C04FBBB345 */ -DEFINE_GUID (IID_IEventSubscription, 0x4A6B0E15, 0x2E38, 0x11D1, 0x99, 0x65, 0x00, 0xC0, 0x4F, 0xBB, 0xB3, 0x45); - -/* d597bab1-5b9f-11d1-8dd2-00aa004abd5e */ -DEFINE_GUID (IID_ISensNetwork, 0xd597bab1, 0x5b9f, 0x11d1, 0x8d, 0xd2, 0x00, 0xaa, 0x00, 0x4a, 0xbd, 0x5e); - -/* 4E14FBA2-2E22-11D1-9964-00C04FBBB345 */ -DEFINE_GUID (CLSID_CEventSystem, 0x4E14FBA2, 0x2E22, 0x11D1, 0x99, 0x64, 0x00, 0xC0, 0x4F, 0xBB, 0xB3, 0x45); - -/* 7542e960-79c7-11d1-88f9-0080c7d771bf */ -DEFINE_GUID (CLSID_CEventSubscription, 0x7542e960, 0x79c7, 0x11d1, 0x88, 0xf9, 0x00, 0x80, 0xc7, 0xd7, 0x71, 0xbf); - -/* Standard GObject macros */ -#define E_TYPE_WINDOWS_SENS \ - (e_windows_sens_get_type ()) -#define E_WINDOWS_SENS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_WINDOWS_SENS, EWindowsSENS)) - -typedef struct _EWindowsSENS EWindowsSENS; -typedef struct _EWindowsSENSClass EWindowsSENSClass; - -struct _EWindowsSENS { - EExtension parent; -}; - -struct _EWindowsSENSClass { - EExtensionClass parent_class; -}; - -/* Module Entry Points */ -void e_module_load (GTypeModule *type_module); -void e_module_unload (GTypeModule *type_module); - -/* Forward Declarations */ -GType e_windows_sens_get_type (void); - -G_DEFINE_DYNAMIC_TYPE (EWindowsSENS, e_windows_sens, E_TYPE_EXTENSION) - -static EShell * -windows_sens_get_shell (EWindowsSENS *extension) -{ - EExtensible *extensible; - - extensible = e_extension_get_extensible (E_EXTENSION (extension)); - - return E_SHELL (extensible); -} - -/* Object to receive the ISensNetwork events */ - -typedef struct ESensNetworkListener { - ISensNetworkVtbl *lpVtbl; - long ref; - EWindowsSENS *ews_ptr; -} ESensNetworkListener; - -static void e_sens_network_listener_init (ESensNetworkListener **,EWindowsSENS *); - -/* Functions to implement ISensNetwork interface */ - -static HRESULT WINAPI e_sens_network_listener_queryinterface (ISensNetwork *,REFIID,PVOID *); -static ULONG WINAPI e_sens_network_listener_addref (ISensNetwork *); -static ULONG WINAPI e_sens_network_listener_release (ISensNetwork *); -static HRESULT WINAPI e_sens_network_listener_gettypeinfocount (ISensNetwork *, UINT *); -static HRESULT WINAPI e_sens_network_listener_gettypeinfo (ISensNetwork *,UINT,LCID,ITypeInfo **); -static HRESULT WINAPI e_sens_network_listener_getidsofnames (ISensNetwork *,REFIID,LPOLESTR *,UINT,LCID, DISPID *); -static HRESULT WINAPI e_sens_network_listener_invoke (ISensNetwork *,DISPID,REFIID,LCID,WORD,DISPPARAMS *,VARIANT *,EXCEPINFO *,UINT *); -static HRESULT WINAPI e_sens_network_listener_connectionmade (ISensNetwork *,BSTR,ULONG,LPSENS_QOCINFO); -static HRESULT WINAPI e_sens_network_listener_connectionmadenoqocinfo (ISensNetwork *,BSTR,ULONG); -static HRESULT WINAPI e_sens_network_listener_connectionlost (ISensNetwork *,BSTR,ULONG); -static HRESULT WINAPI e_sens_network_listener_destinationreachable (ISensNetwork *,BSTR,BSTR,ULONG,LPSENS_QOCINFO); -static HRESULT WINAPI e_sens_network_listener_destinationreachablenoqocinfo (ISensNetwork *,BSTR,BSTR,ULONG); - -/* Initializing the VTable of our ESensNetworkListener object */ - -static ISensNetworkVtbl ESensNetworkListenerVtbl = { - e_sens_network_listener_queryinterface, - e_sens_network_listener_addref, - e_sens_network_listener_release, - e_sens_network_listener_gettypeinfocount, - e_sens_network_listener_gettypeinfo, - e_sens_network_listener_getidsofnames, - e_sens_network_listener_invoke, - e_sens_network_listener_connectionmade, - e_sens_network_listener_connectionmadenoqocinfo, - e_sens_network_listener_connectionlost, - e_sens_network_listener_destinationreachable, - e_sens_network_listener_destinationreachablenoqocinfo -}; - -static HRESULT WINAPI -e_sens_network_listener_queryinterface (ISensNetwork *This, - REFIID iid, - gpointer *ppv) -{ - if (IsEqualIID (iid, &IID_IUnknown) || IsEqualIID (iid, &IID_IDispatch) || IsEqualIID (iid, &IID_ISensNetwork)) { - *ppv = This; - ((LPUNKNOWN) * ppv)->lpVtbl->AddRef ((LPUNKNOWN) * ppv); - return S_OK; - } - *ppv = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI -e_sens_network_listener_addref (ISensNetwork *This) -{ - ESensNetworkListener *esnl_ptr = (ESensNetworkListener *) This; - return InterlockedIncrement (&(esnl_ptr->ref)); -} - -static ULONG WINAPI -e_sens_network_listener_release (ISensNetwork *This) -{ - ESensNetworkListener *esnl_ptr = (ESensNetworkListener *) This; - ULONG tmp = InterlockedDecrement (&(esnl_ptr->ref)); - return tmp; -} - -static HRESULT WINAPI -e_sens_network_listener_gettypeinfocount (ISensNetwork *This, - UINT *pctinfo) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI -e_sens_network_listener_gettypeinfo (ISensNetwork *This, - UINT iTInfo, - LCID lcid, - ITypeInfo **ppTInfo) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI -e_sens_network_listener_getidsofnames (ISensNetwork *This, - REFIID riid, - LPOLESTR *rgszNames, - UINT cNames, - LCID lcid, - DISPID *rgDispId) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI -e_sens_network_listener_invoke (ISensNetwork *This, - DISPID dispIdMember, - REFIID riid, - LCID lcid, - WORD wFlags, - DISPPARAMS *pDispParams, - VARIANT *pVarResult, - EXCEPINFO *pExcepInfo, - UINT *puArgErr) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI -e_sens_network_listener_connectionmade (ISensNetwork *This, - BSTR bstrConnection, - ULONG ulType, - LPSENS_QOCINFO lpQOCInfo) -{ - if (ulType) { - ESensNetworkListener *esnl_ptr = (ESensNetworkListener *) This; - EShell *shell = windows_sens_get_shell (esnl_ptr->ews_ptr); - /* Wait a second so that the connection stabilizes */ - g_usleep (G_USEC_PER_SEC); - e_shell_set_network_available (shell, TRUE); - } - return S_OK; -} - -static HRESULT WINAPI -e_sens_network_listener_connectionmadenoqocinfo (ISensNetwork *This, - BSTR bstrConnection, - ULONG ulType) -{ - return S_OK; -} - -static HRESULT WINAPI -e_sens_network_listener_connectionlost (ISensNetwork *This, - BSTR bstrConnection, - ULONG ulType) -{ - if (ulType) { - ESensNetworkListener *esnl_ptr = (ESensNetworkListener *) This; - EShell *shell = windows_sens_get_shell (esnl_ptr->ews_ptr); - e_shell_set_network_available (shell, FALSE); - } - return S_OK; -} - -static HRESULT WINAPI -e_sens_network_listener_destinationreachable (ISensNetwork *This, - BSTR bstrDestination, - BSTR bstrConnection, - ULONG ulType, - LPSENS_QOCINFO lpQOCInfo) -{ - if (ulType) { - ESensNetworkListener *esnl_ptr = (ESensNetworkListener *) This; - EShell *shell = windows_sens_get_shell (esnl_ptr->ews_ptr); - /* Wait a second so that the connection stabilizes */ - g_usleep (G_USEC_PER_SEC); - e_shell_set_network_available (shell, TRUE); - } - return S_OK; -} - -static HRESULT WINAPI -e_sens_network_listener_destinationreachablenoqocinfo (ISensNetwork *This, - BSTR bstrDestination, - BSTR bstrConnection, - ULONG ulType) -{ - return S_OK; -} - -static void -e_sens_network_listener_init (ESensNetworkListener **esnl_ptr, - EWindowsSENS *ews) -{ - (*esnl_ptr) = g_new0 (ESensNetworkListener,1); - (*esnl_ptr)->lpVtbl = &ESensNetworkListenerVtbl; - (*esnl_ptr)->ews_ptr = ews; - (*esnl_ptr)->ref = 1; -} - -static BSTR -_mb2wchar (const gchar *a) -{ - static WCHAR b[64]; - MultiByteToWideChar (0, 0, a, -1, b, 64); - return b; -} - -static const gchar * add_curly_braces_to_uuid (const gchar * string_uuid) -{ - static gchar curly_braced_uuid_string[64]; - gint i; - if (!string_uuid) - return NULL; - lstrcpy(curly_braced_uuid_string,"{"); - i = strlen (curly_braced_uuid_string); - lstrcat (curly_braced_uuid_string + i,string_uuid); - i = strlen (curly_braced_uuid_string); - lstrcat(curly_braced_uuid_string+i,"}"); - return curly_braced_uuid_string; -} - -#define SENSAPI_DLL "sensapi.dll" - -static void -windows_sens_constructed (GObject *object) -{ - HRESULT res; - static IEventSystem *pEventSystem =0; - static IEventSubscription * pEventSubscription = 0; - static ESensNetworkListener *pESensNetworkListener = 0; - static const gchar * eventclassid="{D5978620-5B9F-11D1-8DD2-00AA004ABD5E}"; - static const gchar * methods[]={ - "ConnectionMade", - "ConnectionMadeNoQOCInfo", - "ConnectionLost", - "DestinationReachable", - "DestinationReachableNoQOCInfo" - }; - static const gchar * names[]={ - "EWS_ConnectionMade", - "EWS_ConnectionMadeNoQOCInfo", - "EWS_ConnectionLost", - "EWS_DestinationReachable", - "EWS_DestinationReachableNoQOCInfo" - }; - guchar * subids[] = { 0, 0, 0, 0, 0 }; - - EWindowsSENS *extension = (E_WINDOWS_SENS (object)); - e_sens_network_listener_init (&pESensNetworkListener, extension); - - CoInitialize (0); - - res = CoCreateInstance (&CLSID_CEventSystem, 0,CLSCTX_SERVER,&IID_IEventSystem,(LPVOID *) &pEventSystem); - - if (res == S_OK && pEventSystem) { - - guint i; - - for (i = 0; i < G_N_ELEMENTS (methods); i++) { - - res = CoCreateInstance (&CLSID_CEventSubscription, 0, CLSCTX_SERVER, &IID_IEventSubscription, (LPVOID *) &pEventSubscription); - - if (res == S_OK && pEventSubscription) { - UUID tmp_uuid; - UuidCreate (&tmp_uuid); - UuidToString (&tmp_uuid, &subids[i]); - res = pEventSubscription->lpVtbl->put_SubscriptionID (pEventSubscription, _mb2wchar (add_curly_braces_to_uuid ((gchar *) subids[i]))); - if (res) { - RpcStringFree (&subids[i]); - break; - } - RpcStringFree (&subids[i]); - res = pEventSubscription->lpVtbl->put_SubscriptionName (pEventSubscription, _mb2wchar (names[i])); - if (res) - break; - res = pEventSubscription->lpVtbl->put_MethodName (pEventSubscription, _mb2wchar (methods[i])); - if (res) - break; - res = pEventSubscription->lpVtbl->put_EventClassID (pEventSubscription, _mb2wchar (eventclassid)); - if (res) - break; - res = pEventSubscription->lpVtbl->put_SubscriberInterface (pEventSubscription, (IUnknown *) pESensNetworkListener); - if (res) - break; - /* Make the subscription receive the event only if the owner of the subscription - * is logged on to the same computer as the publisher. This makes this module - * work with normal user account without administrative privileges. - */ - res = pEventSubscription->lpVtbl->put_PerUser (pEventSubscription, TRUE); - if (res) - break; - - res = pEventSystem->lpVtbl->Store (pEventSystem, (BSTR) PROGID_EventSubscription, (IUnknown *) pEventSubscription); - if (res) - break; - pEventSubscription->lpVtbl->Release (pEventSubscription); - pEventSubscription = 0; - } - } - if (pEventSubscription) - pEventSubscription->lpVtbl->Release (pEventSubscription); - } - - /* Do not try to get initial state when we are sure we will not get system events. - * Like that we don't get stuck with Disconnected status if we were disconnected - * on start. - */ - if (res == S_OK) { - - typedef BOOL (WINAPI * IsNetworkAlive_t) (LPDWORD); - BOOL alive = TRUE; - EShell *shell = windows_sens_get_shell (extension); - - IsNetworkAlive_t pIsNetworkAlive = NULL; - - gchar *buf = NULL; - gchar dummy; - gint n, k; - HMODULE hDLL = NULL; - - n = GetSystemDirectory (&dummy, 0); - - if (n <= 0) - goto cleanup; - - buf = g_malloc (n + 1 + strlen (SENSAPI_DLL)); - k = GetSystemDirectory (buf, n); - - if (k == 0 || k > n) - goto cleanup; - - if (!G_IS_DIR_SEPARATOR (buf[strlen (buf) -1])) - strcat (buf, G_DIR_SEPARATOR_S); - strcat (buf, SENSAPI_DLL); - - hDLL = LoadLibrary (buf); - - if ((pIsNetworkAlive=(IsNetworkAlive_t) GetProcAddress (hDLL, "IsNetworkAlive"))) { - DWORD Network; - alive = pIsNetworkAlive (&Network); - } - - FreeLibrary (hDLL); - - e_shell_set_network_available (shell, alive); - -cleanup: - g_free (buf); - } - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (e_windows_sens_parent_class)->constructed (object); -} - -static void -e_windows_sens_class_init (EWindowsSENSClass *_class) -{ - GObjectClass *object_class; - EExtensionClass *extension_class; - - object_class = G_OBJECT_CLASS (_class); - object_class->constructed = windows_sens_constructed; - - extension_class = E_EXTENSION_CLASS (_class); - extension_class->extensible_type = E_TYPE_SHELL; -} - -static void -e_windows_sens_class_finalize (EWindowsSENSClass *_class) -{ -} - -static void -e_windows_sens_init (EWindowsSENS *extension) -{ -} - -G_MODULE_EXPORT void -e_module_load (GTypeModule *type_module) -{ - e_windows_sens_register_type (type_module); -} - -G_MODULE_EXPORT void -e_module_unload (GTypeModule *type_module) -{ -} - |