# HG changeset patch # User Daniel Atallah # Date 1283194604 0 # Node ID 80affba7ea0d40c2b84ffa5f3328fed91dff4fa4 # Parent c8d6a2cc3bfe22aa044f3217acf0fb6bb31da24b Kill the win32 idle tracking code that works on old windows versions and move the W2K+ only version into pidgin/win32/gtkwin32dep.[ch]. This ends up removing API that should only have ever been used internally. If you're unhappy about that, let me know. diff -r c8d6a2cc3bfe -r 80affba7ea0d libpurple/win32/global.mak --- a/libpurple/win32/global.mak Sun Aug 29 23:28:46 2010 +0000 +++ b/libpurple/win32/global.mak Mon Aug 30 18:56:44 2010 +0000 @@ -37,7 +37,6 @@ PURPLE_PLUGINS_TOP := $(PURPLE_TOP)/plugins PURPLE_PERL_TOP := $(PURPLE_PLUGINS_TOP)/perl PIDGIN_TOP := $(PIDGIN_TREE_TOP)/pidgin -PIDGIN_IDLETRACK_TOP := $(PIDGIN_TOP)/win32/IdleTracker PIDGIN_PIXMAPS_TOP := $(PIDGIN_TOP)/pixmaps PIDGIN_PLUGINS_TOP := $(PIDGIN_TOP)/plugins PURPLE_PO_TOP := $(PIDGIN_TREE_TOP)/po @@ -48,7 +47,6 @@ PURPLE_CONFIG_H := $(PIDGIN_TREE_TOP)/config.h PIDGIN_REVISION_H := $(PIDGIN_TREE_TOP)/package_revision.h PIDGIN_REVISION_RAW_TXT := $(PIDGIN_TREE_TOP)/package_revision_raw.txt -PIDGIN_IDLETRACK_DLL := $(PIDGIN_IDLETRACK_TOP)/idletrack.dll PURPLE_PURPLE_H := $(PURPLE_TOP)/purple.h PURPLE_VERSION_H := $(PURPLE_TOP)/version.h PURPLE_DLL := $(PURPLE_TOP)/libpurple.dll diff -r c8d6a2cc3bfe -r 80affba7ea0d libpurple/win32/targets.mak --- a/libpurple/win32/targets.mak Sun Aug 29 23:28:46 2010 +0000 +++ b/libpurple/win32/targets.mak Mon Aug 30 18:56:44 2010 +0000 @@ -36,9 +36,6 @@ $(PIDGIN_DLL) $(PIDGIN_DLL).a: $(MAKE) -C $(PIDGIN_TOP) -f $(MINGW_MAKEFILE) pidgin.dll -$(PIDGIN_IDLETRACK_DLL) $(PIDGIN_IDLETRACK_DLL).a: - $(MAKE) -C $(PIDGIN_IDLETRACK_TOP) -f $(MINGW_MAKEFILE) idletrack.dll - $(PIDGIN_EXE): $(MAKE) -C $(PIDGIN_TOP) -f $(MINGW_MAKEFILE) pidgin.exe diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/Makefile.mingw --- a/pidgin/Makefile.mingw Sun Aug 29 23:28:46 2010 +0000 +++ b/pidgin/Makefile.mingw Mon Aug 30 18:56:44 2010 +0000 @@ -33,7 +33,6 @@ INCLUDE_PATHS += \ $(PURPLE_INCLUDE_PATHS) \ - -I$(PIDGIN_IDLETRACK_TOP) \ -I$(PIDGIN_TOP) \ -I$(PIDGIN_TOP)/win32 \ -I$(GTK_TOP)/include/gtk-2.0 \ @@ -45,8 +44,7 @@ LIB_PATHS += -L$(GTK_TOP)/lib \ -L$(PURPLE_TOP) \ - -L$(PIDGIN_TOP) \ - -L$(PIDGIN_IDLETRACK_TOP) + -L$(PIDGIN_TOP) ## ## SOURCES, OBJECTS @@ -121,7 +119,6 @@ -lgthread-2.0 \ -lpurple \ -lz \ - -lidletrack \ -lgtk-win32-2.0 \ -latk-1.0 \ -lpango-1.0 \ @@ -151,7 +148,6 @@ install: install_shallow all $(MAKE) -C $(PIDGIN_PLUGINS_TOP) -f $(MINGW_MAKEFILE) install $(MAKE) -C $(PIDGIN_PIXMAPS_TOP) -f $(MINGW_MAKEFILE) install - $(MAKE) -C $(PIDGIN_IDLETRACK_TOP) -f $(MINGW_MAKEFILE) install win32/pidgin_dll_rc.rc: win32/pidgin_dll_rc.rc.in $(PIDGIN_TREE_TOP)/VERSION sed -e 's/@PIDGIN_VERSION@/$(PIDGIN_VERSION)/g' \ @@ -159,7 +155,7 @@ $(EXE_OBJECTS) $(PIDGIN_OBJECTS): $(PIDGIN_CONFIG_H) -$(PIDGIN_TARGET).dll $(PIDGIN_TARGET).dll.a: $(PURPLE_DLL).a $(PIDGIN_IDLETRACK_DLL).a $(PIDGIN_OBJECTS) +$(PIDGIN_TARGET).dll $(PIDGIN_TARGET).dll.a: $(PURPLE_DLL).a $(PIDGIN_OBJECTS) $(CC) -shared $(PIDGIN_OBJECTS) $(LIB_PATHS) $(PIDGIN_LIBS) $(DLL_LD_FLAGS) -Wl,--output-def,$(PIDGIN_TARGET).def,--out-implib,$(PIDGIN_TARGET).dll.a -o $(PIDGIN_TARGET).dll $(EXE_TARGET).exe: $(PIDGIN_CONFIG_H) $(PIDGIN_DLL).a $(EXE_OBJECTS) $(PIDGIN_TARGET).dll @@ -169,7 +165,6 @@ ## CLEAN RULES ## clean: - $(MAKE) -C $(PIDGIN_IDLETRACK_TOP) -f $(MINGW_MAKEFILE) clean $(MAKE) -C $(PIDGIN_PLUGINS_TOP) -f $(MINGW_MAKEFILE) clean $(MAKE) -C $(PIDGIN_PIXMAPS_TOP) -f $(MINGW_MAKEFILE) clean rm -f $(PIDGIN_OBJECTS) $(PIDGIN_RC_SRC) $(EXE_OBJECTS) $(EXE_RC_SRC) diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/gtkidle.c --- a/pidgin/gtkidle.c Sun Aug 29 23:28:46 2010 +0000 +++ b/pidgin/gtkidle.c Mon Aug 30 18:56:44 2010 +0000 @@ -29,7 +29,7 @@ #else # ifdef USE_SCREENSAVER # ifdef _WIN32 -# include "idletrack.h" +# include "gtkwin32dep.h" # else /* We're on X11 and not MacOS X with IOKit. */ # include diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/win32/IdleTracker/Makefile.mingw --- a/pidgin/win32/IdleTracker/Makefile.mingw Sun Aug 29 23:28:46 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -# -# Makefile.mingw -# -# Description: Makefile for idletrack -# - -PIDGIN_TREE_TOP := ../../.. -include $(PIDGIN_TREE_TOP)/libpurple/win32/global.mak - -TARGET = idletrack - -## -## SOURCES, OBJECTS -## - -C_SRC = idletrack.c - -OBJECTS = $(C_SRC:%.c=%.o) - -include $(PIDGIN_COMMON_RULES) - -## -## TARGET DEFINITIONS -## - -.PHONY: all install clean - -all: $(TARGET).dll - -install: $(PIDGIN_INSTALL_DIR) - cp $(TARGET).dll $(PIDGIN_INSTALL_DIR) - -## -## BUILD DLL -## - -$(TARGET).dll $(TARGET).dll.a: $(OBJECTS) - $(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS) -Wl,--out-implib,$(TARGET).dll.a -o $(TARGET).dll - -## -## CLEAN RULES -## - -clean: - rm -f $(OBJECTS) $(TARGET).dll $(TARGET).dll.a - -include $(PIDGIN_COMMON_TARGETS) diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/win32/IdleTracker/idletrack.c --- a/pidgin/win32/IdleTracker/idletrack.c Sun Aug 29 23:28:46 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* - * idletrack.c - * - * Authors: mrgentry @ http://www.experts-exchange.com - * Herman Bloggs - * Date: February, 2003 - * Description: Track user inactivity. - * - * Andrew Whewell - 25th June 2004. Added - * support for GetLastInputInfo under Windows 2000 and above. This avoids having - * IDLETRACK.DLL hook itself into every process on the machine, which makes - * upgrades easier. The hook mechanism is also used by key loggers, so not - * using hooks doesn't put the willys up programs that keep an eye out for - * loggers. - * - * Windows 9x doesn't have GetLastInputInfo - when Purple runs on these machines - * the code silently falls back onto the old hooking scheme. - */ -#define _WIN32_WINNT 0x0500 -#include "idletrack.h" - -#define EXPORT __declspec(dllexport) - -static HANDLE hMapObject = NULL; -static DWORD *lastTime = NULL; -static HHOOK keyHook = NULL; -static HHOOK mouseHook = NULL; -static HINSTANCE g_hInstance = NULL; -static POINT g_point; - -/* GetLastInputInfo address and module - if g_GetLastInputInfo == NULL then - * we fall back on the old "hook the world" method. GetLastInputInfo was brought - * in with Windows 2000 so Windows 9x will still hook everything. - */ -typedef BOOL (WINAPI *GETLASTINPUTINFO)(LASTINPUTINFO *); -static HMODULE g_user32 = NULL; -static GETLASTINPUTINFO g_GetLastInputInfo = NULL; - -static DWORD* setup_shared_mem() { - BOOL fInit; - - /* Set up the shared memory. */ - hMapObject = CreateFileMapping((HANDLE) 0xFFFFFFFF, /* use paging file */ - NULL, /* no security attributes */ - PAGE_READWRITE, /* read/write access */ - 0, /* size: high 32-bits */ - sizeof(DWORD), /* size: low 32-bits */ - "timermem"); /* name of map object */ - - if(hMapObject == NULL) - return NULL; - - /* The first process to attach initializes memory. */ - fInit = (GetLastError() != ERROR_ALREADY_EXISTS); - - /* Get a pointer to the file-mapped shared memory. */ - lastTime = (DWORD*) MapViewOfFile(hMapObject, /* object to map view of */ - FILE_MAP_WRITE, /* read/write access */ - 0, /* high offset: map from */ - 0, /* low offset: beginning */ - 0); /* default: map entire file */ - - if(lastTime == NULL) - return NULL; - - *lastTime = GetTickCount(); - - return lastTime; -} - - -static LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam) { - if(!(code < 0)) { - if(lastTime == NULL) - lastTime = setup_shared_mem(); - - if(lastTime) - *lastTime = GetTickCount(); - } - return CallNextHookEx(keyHook, code, wParam, lParam); -} - - -static LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam) { - /* We need to verify that the Mouse pointer has actually moved. */ - if(!(code < 0) && - !((g_point.x == ((MOUSEHOOKSTRUCT*) lParam)->pt.x) && - (g_point.y == ((MOUSEHOOKSTRUCT*) lParam)->pt.y))) { - g_point.x = ((MOUSEHOOKSTRUCT*) lParam)->pt.x; - g_point.y = ((MOUSEHOOKSTRUCT*) lParam)->pt.y; - - if(lastTime == NULL) - lastTime = setup_shared_mem(); - - if(lastTime) - *lastTime = GetTickCount(); - } - return CallNextHookEx(mouseHook, code, wParam, lParam); -} - - -EXPORT DWORD winpidgin_get_lastactive() { - DWORD result = 0; - - /* If we have GetLastInputInfo then use it, otherwise use the hooks*/ - if(g_GetLastInputInfo != NULL) { - LASTINPUTINFO lii; - memset(&lii, 0, sizeof(lii)); - lii.cbSize = sizeof(lii); - if(g_GetLastInputInfo(&lii)) { - result = lii.dwTime; - } - } else { - if(lastTime == NULL) - lastTime = setup_shared_mem(); - - if(lastTime) - result = *lastTime; - } - - return result; -} - - -EXPORT BOOL winpidgin_set_idlehooks() { - /* Is GetLastInputInfo available?*/ - g_user32 = LoadLibrary("user32.dll"); - if(g_user32) { - g_GetLastInputInfo = (GETLASTINPUTINFO) GetProcAddress(g_user32, "GetLastInputInfo"); - } - - /* If we couldn't find GetLastInputInfo then fall back onto the hooking scheme*/ - if(g_GetLastInputInfo == NULL) { - /* Set up the shared memory.*/ - lastTime = setup_shared_mem(); - if(lastTime == NULL) - return FALSE; - *lastTime = GetTickCount(); - - /* Set up the keyboard hook.*/ - keyHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, 0); - if(keyHook == NULL) { - UnmapViewOfFile(lastTime); - CloseHandle(hMapObject); - return FALSE; - } - - /* Set up the mouse hook.*/ - mouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, g_hInstance, 0); - if(mouseHook == NULL) { - UnhookWindowsHookEx(keyHook); - UnmapViewOfFile(lastTime); - CloseHandle(hMapObject); - return FALSE; - } - } - - return TRUE; -} - - -EXPORT void winpidgin_remove_idlehooks() { - if(g_user32 != NULL) - FreeLibrary(g_user32); - if(keyHook) - UnhookWindowsHookEx(keyHook); - if(mouseHook) - UnhookWindowsHookEx(mouseHook); - if(lastTime) - UnmapViewOfFile(lastTime); - if(hMapObject) - CloseHandle(hMapObject); -} - -/* suppress gcc "no previous prototype" warning */ -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved); -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { - switch(dwReason) { - case DLL_PROCESS_ATTACH: - g_hInstance = hInstance; - g_point.x = 0; - g_point.y = 0; - break; - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/win32/IdleTracker/idletrack.h --- a/pidgin/win32/IdleTracker/idletrack.h Sun Aug 29 23:28:46 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -/* - * idletrack.h - */ -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -DWORD winpidgin_get_lastactive(void); -BOOL winpidgin_set_idlehooks(void); -void winpidgin_remove_idlehooks(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/win32/gtkwin32dep.c --- a/pidgin/win32/gtkwin32dep.c Sun Aug 29 23:28:46 2010 +0000 +++ b/pidgin/win32/gtkwin32dep.c Mon Aug 30 18:56:44 2010 +0000 @@ -43,7 +43,6 @@ #include "network.h" #include "resource.h" -#include "idletrack.h" #include "zlib.h" #include "untar.h" @@ -385,7 +384,7 @@ proc = wpurple_find_and_loadproc("exchndl.dll", "SetLogFile"); if (proc) { gchar *debug_dir, *locale_debug_dir; - + debug_dir = g_build_filename(purple_user_dir(), "pidgin.RPT", NULL); locale_debug_dir = g_locale_from_utf8(debug_dir, -1, NULL, NULL, NULL); @@ -397,10 +396,6 @@ g_free(locale_debug_dir); } - /* IdleTracker Initialization */ - if(!winpidgin_set_idlehooks()) - purple_debug_error("winpidgin", "Failed to initialize idle tracker\n"); - winpidgin_spell_init(); purple_debug_info("winpidgin", "GTK+ :%u.%u.%u\n", gtk_major_version, gtk_minor_version, gtk_micro_version); @@ -429,9 +424,6 @@ if(messagewin_hwnd) DestroyWindow(messagewin_hwnd); - /* Idle tracker cleanup */ - winpidgin_remove_idlehooks(); - } /* DLL initializer */ @@ -535,5 +527,18 @@ (winR.right - winR.left), (winR.bottom - winR.top), TRUE); } + } +DWORD winpidgin_get_lastactive() { + DWORD result = 0; + + LASTINPUTINFO lii; + memset(&lii, 0, sizeof(lii)); + lii.cbSize = sizeof(lii); + if (GetLastInputInfo(&lii)) + result = lii.dwTime; + + return result; +} + diff -r c8d6a2cc3bfe -r 80affba7ea0d pidgin/win32/gtkwin32dep.h --- a/pidgin/win32/gtkwin32dep.h Sun Aug 29 23:28:46 2010 +0000 +++ b/pidgin/win32/gtkwin32dep.h Mon Aug 30 18:56:44 2010 +0000 @@ -39,6 +39,7 @@ void winpidgin_ensure_onscreen(GtkWidget *win); void winpidgin_conv_blink(PurpleConversation *conv, PurpleMessageFlags flags); void winpidgin_window_flash(GtkWindow *window, gboolean flash); +DWORD winpidgin_get_lastactive(void); /* init / cleanup */ void winpidgin_init(HINSTANCE);