pidgin: 068508c3: Kill the win32 idle tracking code that w...

datallah at pidgin.im datallah at pidgin.im
Mon Aug 30 15:02:13 EDT 2010


----------------------------------------------------------------------
Revision: 068508c3194762c657418464c3cf66eb5eb5b348
Parent:   cece16657e35bbb1f4e5b1654fd66e358ca907fd
Author:   datallah at pidgin.im
Date:     08/30/10 14:56:44
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/068508c3194762c657418464c3cf66eb5eb5b348

Changelog: 

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.

Changes against parent cece16657e35bbb1f4e5b1654fd66e358ca907fd

  dropped  pidgin/win32/IdleTracker
  dropped  pidgin/win32/IdleTracker/Makefile.mingw
  dropped  pidgin/win32/IdleTracker/idletrack.c
  dropped  pidgin/win32/IdleTracker/idletrack.h
  patched  libpurple/win32/global.mak
  patched  libpurple/win32/targets.mak
  patched  pidgin/Makefile.mingw
  patched  pidgin/gtkidle.c
  patched  pidgin/win32/gtkwin32dep.c
  patched  pidgin/win32/gtkwin32dep.h

-------------- next part --------------
============================================================
--- libpurple/win32/global.mak	60a49a76352ce3f93ec60b400b9536fd3c2f41d5
+++ libpurple/win32/global.mak	ac8976b86788f9b1e5f54b90334769367e04dd5a
@@ -37,7 +37,6 @@ PIDGIN_TOP := $(PIDGIN_TREE_TOP)/pidgin
 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 @@ PIDGIN_REVISION_RAW_TXT := $(PIDGIN_TREE
 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
============================================================
--- pidgin/win32/IdleTracker/Makefile.mingw	828856208f9fee18a21401a03ab9887148511216
+++ /dev/null	
@@ -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)
============================================================
--- pidgin/win32/IdleTracker/idletrack.c	ff0e9c22c2323e04604ee3baa127be1495954e16
+++ /dev/null	
@@ -1,188 +0,0 @@
-/*
- *  idletrack.c
- *
- *  Authors: mrgentry @ http://www.experts-exchange.com
- *           Herman Bloggs <hermanator12002 at yahoo.com>
- *  Date: February, 2003
- *  Description: Track user inactivity.
- *
- *  Andrew Whewell <awhewell at users.sourceforge.net> - 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;
-}
============================================================
--- pidgin/win32/IdleTracker/idletrack.h	6c9c11c984d44c93d92d639937ff3e8f31f33ae0
+++ /dev/null	
@@ -1,16 +0,0 @@
-/*
- * idletrack.h
- */
-#include <windows.h>
-
-#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 */
============================================================
--- pidgin/gtkidle.c	5a3dc14b3605fc65bb4b6db0f9a56a72446d596f
+++ pidgin/gtkidle.c	8f436aa490c8df706803e22c1febea860c42b314
@@ -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 <X11/Xlib.h>
============================================================
--- pidgin/Makefile.mingw	34e85ef9875bfd3f292e7400a169b3a36bee6640
+++ pidgin/Makefile.mingw	acfa9f555323353d34b84da929a552ddf98803dc
@@ -33,7 +33,6 @@ INCLUDE_PATHS +=	\
 
 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 \
 
 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 @@ PIDGIN_LIBS =	\
 		-lgthread-2.0 \
 		-lpurple \
 		-lz \
-		-lidletrack \
 		-lgtk-win32-2.0 \
 		-latk-1.0 \
 		-lpango-1.0 \
@@ -151,7 +148,6 @@ install: install_shallow all
 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): $(PIDG
 
 $(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:
 ## 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)
============================================================
--- pidgin/win32/gtkwin32dep.c	4ca2cedf02c4167f9959552570a1af5c8a409614
+++ pidgin/win32/gtkwin32dep.c	0c232fb8d2dc575958de9e9722a33816d45ab1c3
@@ -43,7 +43,6 @@
 #include "network.h"
 
 #include "resource.h"
-#include "idletrack.h"
 #include "zlib.h"
 #include "untar.h"
 
@@ -385,7 +384,7 @@ void winpidgin_init(HINSTANCE hint) {
 	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 @@ void winpidgin_init(HINSTANCE hint) {
 		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 @@ void winpidgin_cleanup(void) {
 	if(messagewin_hwnd)
 		DestroyWindow(messagewin_hwnd);
 
-	/* Idle tracker cleanup */
-	winpidgin_remove_idlehooks();
-
 }
 
 /* DLL initializer */
@@ -535,5 +527,18 @@ void winpidgin_ensure_onscreen(GtkWidget
 				   (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;
+}
+
============================================================
--- pidgin/win32/gtkwin32dep.h	7dd09cb4b3f7e03073c99bf5267d1b9a88472722
+++ pidgin/win32/gtkwin32dep.h	39319af22d0da87cd9ba14c8f2001e40c23c4d15
@@ -39,6 +39,7 @@ void winpidgin_window_flash(GtkWindow *w
 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);
============================================================
--- libpurple/win32/targets.mak	7cff707c2b39ce335a246a4cddf81b74de1dd19e
+++ libpurple/win32/targets.mak	6b7129a4c9fc0c54c48448fc503b13dd1530ace0
@@ -36,9 +36,6 @@ $(PIDGIN_DLL) $(PIDGIN_DLL).a:
 $(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
 


More information about the Commits mailing list