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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/* Replace "dll.h" with the name of your header */
#include "common.h"
#include "version.h"
#include "resource.h"
#include "options.h"
#include "proto.h"
#include "net.h"
#include "menu.h"
#include "arc4.h"
#include "notifications.h"
#include "srmm_icon.h"
#include "links.h"
///////////////////////////////////////////////
// Common Plugin Stuff
///////////////////////////////////////////////
HINSTANCE hInst;
PLUGINLINK *pluginLink;
HANDLE mainThread;
int code_page;
char MODULE[256];
MM_INTERFACE mmi;
char mir_ver[256];
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESC,
__AUTHOR,
__AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
0,
{ 0xA0D1D7B2, 0x6B1, 0x437D, { 0x84, 0x91, 0xA7, 0x46, 0x58, 0xB9, 0x63, 0x70 } }
};
extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) {
hInst=hinstDLL;
return TRUE;
}
extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) {
if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 7, 0, 32))
return 0;
return &pluginInfo;
}
static const MUUID interfaces[] = {MIID_PROTOCOL, MIID_LAST};
extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
{
return interfaces;
}
int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
if(ServiceExists(MS_UPDATE_REGISTER)) {
// register with updater
Update update = {0};
char szVersion[16];
update.cbSize = sizeof(Update);
update.szComponentName = pluginInfo.shortName;
update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
update.cpbVersion = strlen((char *)update.pbVersion);
update.szBetaChangelogURL = "https://server.scottellis.com.au/wsvn/mim_plugs/MySpace/?op=log&rev=0&sc=0&isdir=1";
update.szUpdateURL = UPDATER_AUTOREGISTER;
// these are the three lines that matter - the archive, the page containing the version string, and the text (or data)
// before the version that we use to locate it on the page
// (note that if the update URL and the version URL point to standard file listing entries, the backend xml
// data will be used to check for updates rather than the actual web page - this is not true for beta urls)
#ifdef _UNICODE
update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/MySpace.zip";
update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_MySpace.html";
#else
update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/MySpace_ansi.zip";
update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_MySpace_ansi.html";
#endif
update.pbBetaVersionPrefix = (BYTE *)"MySpace version ";
update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
}
InitNetlib();
InitMenu();
InitNotifications();
InitSRMMIcon();
return 0;
}
void SetAllOffline() {
char *proto;
HANDLE hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
while ( hContact != NULL )
{
proto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 );
if ( proto && !strcmp( MODULE, proto)) {
DBWriteContactSettingWord(hContact, MODULE, "Status", ID_STATUS_OFFLINE);
DBWriteContactSettingDword(hContact, MODULE, "IdleTS", 0);
}
hContact = ( HANDLE )CallService( MS_DB_CONTACT_FINDNEXT,( WPARAM )hContact, 0 );
}
}
HANDLE hModulesLoaded;
extern "C" __declspec (dllexport) int Load(PLUGINLINK *link) {
DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, 0, FALSE, DUPLICATE_SAME_ACCESS );
pluginLink=link;
code_page = (int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
mir_getMMI(&mmi);
// Get module name from DLL file name
{
char* str1;
char str2[MAX_PATH];
GetModuleFileNameA(hInst, str2, MAX_PATH);
str1 = strrchr(str2, '\\');
if (str1 != NULL && strlen(str1+1) > 4) {
strncpy(MODULE, str1+1, strlen(str1+1)-4);
MODULE[strlen(str1+1)-3] = 0;
}
CharUpperA(MODULE);
}
char temp[256];
CallService(MS_SYSTEM_GETVERSIONTEXT, 256, (LPARAM)temp);
mir_snprintf(mir_ver, 256, "Miranda IM %s (MySpace %d.%d.%d.%d)", temp, __FILEVERSION_STRING);
if(ServiceExists(MS_DB_SETSETTINGRESIDENT)) { // 0.6+
char buff[256];
mir_snprintf(buff, 256, "%s/%s", MODULE, "Status");
CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)buff);
mir_snprintf(buff, 256, "%s/%s", MODULE, "StatusMsg");
CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)buff);
mir_snprintf(buff, 256, "%s/%s", MODULE, "IdleTS");
CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)buff);
}
InitARC4Module();
InitOptions();
/////////////
////// init protocol
RegisterProto();
CreateProtoServices();
SetAllOffline();
myspace_links_init();
// hook modules loaded
hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
return 0;
}
extern "C" __declspec (dllexport) int Unload(void) {
UnhookEvent(hModulesLoaded);
DeinitSRMMIcon();
DeinitMenu();
DeinitNetlib();
DeinitProto();
myspace_links_destroy();
DeinitOptions();
DeinitNotifications();
DeinitARC4Module();
return 0;
}
|