1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#include "commonheaders.h"
//=====================================================
// Name : timerProc
// Parameters: none
// Returns : void
// Description : called when the timer interval occurs
//=====================================================
void __cdecl timerFunc(LPVOID di)
{
HANDLE hContact;
char text[512], fn[16], szFileName[MAX_PATH], temp[MAX_PATH];
int i, timer;
int timerCount = DBGetContactSettingWord(NULL, modname, "timerCount",1)+1;
// killTimer();
if (LCStatus == ID_STATUS_OFFLINE)
{
killTimer();
return;
}
DBWriteContactSettingWord(NULL, modname, "timerCount", (WORD)timerCount);
/* update the web pages*/
for (i=0; ;i++)
{
sprintf(fn, "fn%d", i);
if (!DBGetContactSettingString(NULL, modname, fn, text))
break;
if (!strncmp("http://", text, strlen("http://")))
{
strcat(fn, "_timer");
timer = DBGetContactSettingWord(NULL,modname, fn, 60);
if (timer && !(timerCount % timer))
{
if (!InternetDownloadFile(text))
{
wsprintf(szFileName,"%s\\plugins\\fn%d.html",getMimDir(temp), i);
savehtml(szFileName);
}
}
}
}
/* update all the contacts */
hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
while(hContact)
{
if(!lstrcmp(modname,(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0)) )
{
timer = DBGetContactSettingWord(hContact, modname, "Timer", 15);
if (timer && !(timerCount % timer))
{
if (DBGetContactSettingString(hContact, modname, "Name", text))
replaceAllStrings(hContact);
}
}
hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
}
// startTimer(TIMER);
}
void CALLBACK timerProc()
{
// new thread for the timer...
forkthread(timerFunc, 0, 0);
// timerFunc(0);
}
//=====================================================
// Name : startTimer
// Parameters: int interval
// Returns : int
// Description : starts the timer
//=====================================================
int startTimer(int interval)
{
timerId = SetTimer(NULL, 0, interval, timerProc);
return 0;
}
//=====================================================
// Name : killTimer
// Parameters: none
// Returns : int
// Description : stops the timer
//=====================================================
int killTimer()
{
DBWriteContactSettingWord(NULL, modname, "timerCount",0);
KillTimer(NULL,timerId);
return 0;
}
|