pidgin/win32/IdleTracker/idletrack.c

Sat, 27 Jun 2009 17:56:04 +0000

author
John Bailey <rekkanoryo@rekkanoryo.org>
date
Sat, 27 Jun 2009 17:56:04 +0000
branch
release-2.5.8
changeset 25790
1533d33dee9a
parent 15884
4de1981757fc
child 16238
33bf2fd32108
child 18068
b6554e3c8224
child 20478
46933dc62880
permissions
-rw-r--r--

We're releasing Pidgin 2.5.8 today, not yesterday.

4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
1 /*
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
2 * idletrack.c
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
3 *
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
4 * Authors: mrgentry @ http://www.experts-exchange.com
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
5 * Herman Bloggs <hermanator12002@yahoo.com>
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
6 * Date: February, 2003
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
7 * Description: Track user inactivity.
9417
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
8 *
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
9 * Andrew Whewell <awhewell@users.sourceforge.net> - 25th June 2004. Added
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
10 * support for GetLastInputInfo under Windows 2000 and above. This avoids having
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
11 * IDLETRACK.DLL hook itself into every process on the machine, which makes
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
12 * upgrades easier. The hook mechanism is also used by key loggers, so not
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
13 * using hooks doesn't put the willys up programs that keep an eye out for
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
14 * loggers.
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
15 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15697
diff changeset
16 * Windows 9x doesn't have GetLastInputInfo - when Purple runs on these machines
9417
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
17 * the code silently falls back onto the old hooking scheme.
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
18 */
9417
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
19 #define _WIN32_WINNT 0x0500
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
20 #include "idletrack.h"
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
21
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
22 #define EXPORT __declspec(dllexport)
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
23
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
24 static HANDLE hMapObject = NULL;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
25 static DWORD *lastTime = NULL;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
26 static HHOOK keyHook = NULL;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
27 static HHOOK mouseHook = NULL;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
28 static HINSTANCE g_hInstance = NULL;
4548
f89a7e6e9508 [gaim-migrate @ 4827]
Herman Bloggs <herman@bluedigits.com>
parents: 4533
diff changeset
29 static POINT g_point;
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
30
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
31 /* GetLastInputInfo address and module - if g_GetLastInputInfo == NULL then
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
32 * we fall back on the old "hook the world" method. GetLastInputInfo was brought
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
33 * in with Windows 2000 so Windows 9x will still hook everything.
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
34 */
9417
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
35 typedef BOOL (WINAPI *GETLASTINPUTINFO)(LASTINPUTINFO *);
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
36 static HMODULE g_user32 = NULL;
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
37 static GETLASTINPUTINFO g_GetLastInputInfo = NULL;
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
38
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
39 static DWORD* setup_shared_mem() {
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
40 BOOL fInit;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
41
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
42 /* Set up the shared memory. */
11828
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
43 hMapObject = CreateFileMapping((HANDLE) 0xFFFFFFFF, /* use paging file */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
44 NULL, /* no security attributes */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
45 PAGE_READWRITE, /* read/write access */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
46 0, /* size: high 32-bits */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
47 sizeof(DWORD), /* size: low 32-bits */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
48 "timermem"); /* name of map object */
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
49
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
50 if(hMapObject == NULL)
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
51 return NULL;
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
52
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
53 /* The first process to attach initializes memory. */
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
54 fInit = (GetLastError() != ERROR_ALREADY_EXISTS);
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
55
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
56 /* Get a pointer to the file-mapped shared memory. */
11828
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
57 lastTime = (DWORD*) MapViewOfFile(hMapObject, /* object to map view of */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
58 FILE_MAP_WRITE, /* read/write access */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
59 0, /* high offset: map from */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
60 0, /* low offset: beginning */
a4bf634fc3d4 [gaim-migrate @ 14119]
Richard Laager <rlaager@pidgin.im>
parents: 9865
diff changeset
61 0); /* default: map entire file */
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
62
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
63 if(lastTime == NULL)
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
64 return NULL;
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
65
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
66 *lastTime = GetTickCount();
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
67
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
68 return lastTime;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
69 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
70
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
71
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
72 static LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
73 if(!(code < 0)) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
74 if(lastTime == NULL)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
75 lastTime = setup_shared_mem();
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
76
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
77 if(lastTime)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
78 *lastTime = GetTickCount();
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
79 }
5336
722c9bb36994 [gaim-migrate @ 5712]
Jason Brisch of blueboxshell.org
parents: 4548
diff changeset
80 return CallNextHookEx(keyHook, code, wParam, lParam);
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
81 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
82
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
83
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
84 static LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam) {
4548
f89a7e6e9508 [gaim-migrate @ 4827]
Herman Bloggs <herman@bluedigits.com>
parents: 4533
diff changeset
85 /* We need to verify that the Mouse pointer has actually moved. */
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
86 if(!(code < 0) &&
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
87 !((g_point.x == ((MOUSEHOOKSTRUCT*) lParam)->pt.x) &&
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
88 (g_point.y == ((MOUSEHOOKSTRUCT*) lParam)->pt.y))) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
89 g_point.x = ((MOUSEHOOKSTRUCT*) lParam)->pt.x;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
90 g_point.y = ((MOUSEHOOKSTRUCT*) lParam)->pt.y;
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
91
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
92 if(lastTime == NULL)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
93 lastTime = setup_shared_mem();
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
94
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
95 if(lastTime)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
96 *lastTime = GetTickCount();
6561
88ff258f78dd [gaim-migrate @ 7083]
Herman Bloggs <herman@bluedigits.com>
parents: 5336
diff changeset
97 }
5336
722c9bb36994 [gaim-migrate @ 5712]
Jason Brisch of blueboxshell.org
parents: 4548
diff changeset
98 return CallNextHookEx(mouseHook, code, wParam, lParam);
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
99 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
100
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
101
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
102 EXPORT DWORD winpidgin_get_lastactive() {
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
103 DWORD result = 0;
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
104
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
105 /* If we have GetLastInputInfo then use it, otherwise use the hooks*/
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
106 if(g_GetLastInputInfo != NULL) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
107 LASTINPUTINFO lii;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
108 memset(&lii, 0, sizeof(lii));
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
109 lii.cbSize = sizeof(lii);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
110 if(g_GetLastInputInfo(&lii)) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
111 result = lii.dwTime;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
112 }
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
113 } else {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
114 if(lastTime == NULL)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
115 lastTime = setup_shared_mem();
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
116
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
117 if(lastTime)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
118 result = *lastTime;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
119 }
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
120
9417
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
121 return result;
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
122 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
123
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
124
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
125 EXPORT BOOL winpidgin_set_idlehooks() {
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
126 /* Is GetLastInputInfo available?*/
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
127 g_user32 = LoadLibrary("user32.dll");
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
128 if(g_user32) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
129 g_GetLastInputInfo = (GETLASTINPUTINFO) GetProcAddress(g_user32, "GetLastInputInfo");
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
130 }
9417
13d5e9fdda1a [gaim-migrate @ 10232]
Andrew Whewell
parents: 7242
diff changeset
131
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
132 /* If we couldn't find GetLastInputInfo then fall back onto the hooking scheme*/
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
133 if(g_GetLastInputInfo == NULL) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
134 /* Set up the shared memory.*/
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
135 lastTime = setup_shared_mem();
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
136 if(lastTime == NULL)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
137 return FALSE;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
138 *lastTime = GetTickCount();
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
139
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
140 /* Set up the keyboard hook.*/
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
141 keyHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, 0);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
142 if(keyHook == NULL) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
143 UnmapViewOfFile(lastTime);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
144 CloseHandle(hMapObject);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
145 return FALSE;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
146 }
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
147
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
148 /* Set up the mouse hook.*/
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
149 mouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, g_hInstance, 0);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
150 if(mouseHook == NULL) {
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
151 UnhookWindowsHookEx(keyHook);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
152 UnmapViewOfFile(lastTime);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
153 CloseHandle(hMapObject);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
154 return FALSE;
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
155 }
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
156 }
9418
b7c8a5fe5067 [gaim-migrate @ 10233]
Luke Schierer <lschiere@pidgin.im>
parents: 9417
diff changeset
157
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
158 return TRUE;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
159 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
160
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
161
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15435
diff changeset
162 EXPORT void winpidgin_remove_idlehooks() {
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
163 if(g_user32 != NULL)
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
164 FreeLibrary(g_user32);
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
165 if(keyHook)
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
166 UnhookWindowsHookEx(keyHook);
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
167 if(mouseHook)
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
168 UnhookWindowsHookEx(mouseHook);
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
169 if(lastTime)
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
170 UnmapViewOfFile(lastTime);
13431
1f446d4ac433 [gaim-migrate @ 15805]
Daniel Atallah <datallah@pidgin.im>
parents: 11828
diff changeset
171 if(hMapObject)
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
172 CloseHandle(hMapObject);
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
173 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
174
15697
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
175 /* suppress gcc "no previous prototype" warning */
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
176 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
78ddac185d80 winpidgin warning fixes
Daniel Atallah <datallah@pidgin.im>
parents: 15574
diff changeset
177 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
178 switch(dwReason) {
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
179 case DLL_PROCESS_ATTACH:
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
180 g_hInstance = hInstance;
4548
f89a7e6e9508 [gaim-migrate @ 4827]
Herman Bloggs <herman@bluedigits.com>
parents: 4533
diff changeset
181 g_point.x = 0;
f89a7e6e9508 [gaim-migrate @ 4827]
Herman Bloggs <herman@bluedigits.com>
parents: 4533
diff changeset
182 g_point.y = 0;
4533
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
183 break;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
184 case DLL_PROCESS_DETACH:
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
185 break;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
186 }
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
187 return TRUE;
5dc66200ccd9 [gaim-migrate @ 4812]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
188 }

mercurial