/* * 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 * */ #ifdef __cplusplus extern "C" { #endif #define INITGUID #include #include #include #include #include #include #include #define NUM_ELEMENTS(x) (sizeof((x)) / sizeof((x)[0])) inline const BSTR _mb2wchar (const char* a) { static WCHAR b[64]; MultiByteToWideChar (0, 0, a, -1, b, 64); return b; } static const char* add_curly_braces_to_uuid (const char* string_uuid) { static char curly_braced_uuid_string[64]; unsigned i; if (!string_uuid) return NULL; curly_braced_uuid_string[0]='{'; for (i=0; iput_SubscriptionID (_mb2wchar (add_curly_braces_to_uuid ((char*)subids[i]))))) { RpcStringFree (&subids[i]); break; } RpcStringFree (&subids[i]); if ((res=pIEventSubscription->put_SubscriptionName (_mb2wchar (names[i])))) break; if ((res=pIEventSubscription->put_MethodName (_mb2wchar (methods[i])))) break; if ((res=pIEventSubscription->put_EventClassID (_mb2wchar (eventclassid)))) break; if ((res=pIEventSubscription->put_SubscriberInterface ((IUnknown*)pISensNetwork))) 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. */ if ((res=pIEventSubscription->put_PerUser (TRUE))) break; if ((res=pIEventSystem->Store ((BSTR)PROGID_EventSubscription, (IUnknown*)pIEventSubscription))) break; pIEventSubscription->Release (); pIEventSubscription=0; } } if (pIEventSubscription) pIEventSubscription->Release(); } /* 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); IsNetworkAlive_t pIsNetworkAlive = NULL; HMODULE hDLL=LoadLibrary ("sensapi.dll"); BOOL alive = TRUE; if ((pIsNetworkAlive=(IsNetworkAlive_t) GetProcAddress (hDLL, "IsNetworkAlive"))) { DWORD Network; alive=pIsNetworkAlive (&Network); } FreeLibrary(hDLL); EShell *shell = windows_sens_get_shell (extension); e_shell_set_network_available (shell, alive); } } 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) { } #ifdef __cplusplus } #endif