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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
/*
Miranda NG: the free IM client for Microsoft* Windows*
Copyright 2012 Miranda NG project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\..\core\commonheaders.h"
MIDatabase *currDb = NULL;
DATABASELINK *currDblink = NULL;
MIR_CORE_DLL(void) db_setCurrent(MIDatabase*);
static INT_PTR srvSetSafetyMode(WPARAM wParam, LPARAM)
{
if (!currDb) return 1;
currDb->SetCacheSafetyMode(wParam != 0);
return 0;
}
static INT_PTR srvGetContactCount(WPARAM, LPARAM)
{ return (currDb) ? currDb->GetContactCount() : 0;
}
///////////////////////////////////////////////////////////////////////////////
// Events
static INT_PTR srvFindFirstContact(WPARAM, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindFirstContact((LPCSTR)lParam) : 0;
}
static INT_PTR srvFindNextContact(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindNextContact((HANDLE)wParam, (LPCSTR)lParam) : 0;
}
static INT_PTR srvDeleteContact(WPARAM wParam, LPARAM)
{ return (currDb) ? currDb->DeleteContact((HANDLE)wParam) : 0;
}
static INT_PTR srvAddContact(WPARAM wParam, LPARAM)
{ return (currDb) ? (INT_PTR)currDb->AddContact() : 0;
}
static INT_PTR srvIsDbContact(WPARAM wParam, LPARAM)
{ return (currDb) ? currDb->IsDbContact((HANDLE)wParam) : 0;
}
///////////////////////////////////////////////////////////////////////////////
// Events
static INT_PTR srvGetEventCount(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? currDb->GetEventCount((HANDLE)wParam) : 0;
}
static INT_PTR srvAddEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->AddEvent((HANDLE)wParam, (DBEVENTINFO*)lParam) : 0;
}
static INT_PTR srvDeleteEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? currDb->DeleteEvent((HANDLE)wParam, (HANDLE)lParam) : 0;
}
static INT_PTR srvGetBlobSize(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? currDb->GetBlobSize((HANDLE)wParam) : 0;
}
static INT_PTR srvGetEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->GetEvent((HANDLE)wParam, (DBEVENTINFO*)lParam) : 0;
}
static INT_PTR srvMarkEventRead(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? currDb->MarkEventRead((HANDLE)wParam, (HANDLE)lParam) : 0;
}
static INT_PTR srvGetEventContact(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->GetEventContact((HANDLE)wParam) : 0;
}
static INT_PTR srvFindFirstEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindFirstEvent((HANDLE)wParam) : 0;
}
static INT_PTR srvFindFirstUnreadEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindFirstUnreadEvent((HANDLE)wParam) : 0;
}
static INT_PTR srvFindLastEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindLastEvent((HANDLE)wParam) : 0;
}
static INT_PTR srvFindNextEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindNextEvent((HANDLE)wParam) : 0;
}
static INT_PTR srvFindPrevEvent(WPARAM wParam, LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FindPrevEvent((HANDLE)wParam) : 0;
}
///////////////////////////////////////////////////////////////////////////////
// Module chain
static INT_PTR srvEnumModuleNames(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->EnumModuleNames((DBMODULEENUMPROC)lParam, (void*)wParam) : 0;
}
///////////////////////////////////////////////////////////////////////////////
// Settings
static INT_PTR srvGetContactSetting(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->GetContactSetting((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
}
static INT_PTR srvGetContactSettingStr(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->GetContactSettingStr((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
}
static INT_PTR srvGetContactSettingStatic(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->GetContactSettingStatic((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
}
static INT_PTR srvFreeVariant(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->FreeVariant((DBVARIANT*)lParam) : 0;
}
static INT_PTR srvWriteContactSetting(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->WriteContactSetting((HANDLE)wParam, (DBCONTACTWRITESETTING*)lParam) : 0;
}
static INT_PTR srvDeleteContactSetting(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->DeleteContactSetting((HANDLE)wParam, (DBCONTACTGETSETTING*)lParam) : 0;
}
static INT_PTR srvEnumContactSettings(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->EnumContactSettings((HANDLE)wParam, (DBCONTACTENUMSETTINGS*)lParam) : 0;
}
static INT_PTR srvSetSettingResident(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->SetSettingResident(wParam, (char*)lParam) : 0;
}
static INT_PTR srvEnumResidentSettings(WPARAM wParam,LPARAM lParam)
{ return (currDb) ? (INT_PTR)currDb->EnumResidentSettings((DBMODULEENUMPROC)wParam, (void*)lParam) : 0;
}
///////////////////////////////////////////////////////////////////////////////
// Database list
LIST<DATABASELINK> arDbPlugins(5);
static INT_PTR srvRegisterPlugin(WPARAM wParam,LPARAM lParam)
{
DATABASELINK* pPlug = (DATABASELINK*)lParam;
if (pPlug == NULL)
return 1;
arDbPlugins.insert(pPlug);
return 0;
}
static INT_PTR srvFindPlugin(WPARAM wParam,LPARAM lParam)
{
for (int i=0; i < arDbPlugins.getCount(); i++) {
int error = arDbPlugins[i]->grokHeader((TCHAR*)lParam);
if (error == ERROR_SUCCESS)
return (INT_PTR)arDbPlugins[i];
}
return NULL;
}
static INT_PTR srvGetCurrentDb(WPARAM wParam,LPARAM lParam)
{
return (INT_PTR)currDb;
}
///////////////////////////////////////////////////////////////////////////////
int LoadDbintfModule()
{
CreateServiceFunction(MS_DB_SETSAFETYMODE, srvSetSafetyMode);
CreateServiceFunction(MS_DB_CONTACT_GETCOUNT, srvGetContactCount);
CreateServiceFunction(MS_DB_CONTACT_FINDFIRST, srvFindFirstContact);
CreateServiceFunction(MS_DB_CONTACT_FINDNEXT, srvFindNextContact);
CreateServiceFunction(MS_DB_CONTACT_DELETE, srvDeleteContact);
CreateServiceFunction(MS_DB_CONTACT_ADD, srvAddContact);
CreateServiceFunction(MS_DB_CONTACT_IS, srvIsDbContact);
CreateServiceFunction(MS_DB_EVENT_GETCOUNT, srvGetEventCount);
CreateServiceFunction(MS_DB_EVENT_ADD, srvAddEvent);
CreateServiceFunction(MS_DB_EVENT_DELETE, srvDeleteEvent);
CreateServiceFunction(MS_DB_EVENT_GETBLOBSIZE, srvGetBlobSize);
CreateServiceFunction(MS_DB_EVENT_GET, srvGetEvent);
CreateServiceFunction(MS_DB_EVENT_MARKREAD, srvMarkEventRead);
CreateServiceFunction(MS_DB_EVENT_GETCONTACT, srvGetEventContact);
CreateServiceFunction(MS_DB_EVENT_FINDFIRST, srvFindFirstEvent);
CreateServiceFunction(MS_DB_EVENT_FINDFIRSTUNREAD, srvFindFirstUnreadEvent);
CreateServiceFunction(MS_DB_EVENT_FINDLAST, srvFindLastEvent);
CreateServiceFunction(MS_DB_EVENT_FINDNEXT, srvFindNextEvent);
CreateServiceFunction(MS_DB_EVENT_FINDPREV, srvFindPrevEvent);
CreateServiceFunction(MS_DB_MODULES_ENUM, srvEnumModuleNames);
CreateServiceFunction(MS_DB_CONTACT_GETSETTING, srvGetContactSetting);
CreateServiceFunction(MS_DB_CONTACT_GETSETTING_STR, srvGetContactSettingStr);
CreateServiceFunction(MS_DB_CONTACT_GETSETTINGSTATIC, srvGetContactSettingStatic);
CreateServiceFunction(MS_DB_CONTACT_FREEVARIANT, srvFreeVariant);
CreateServiceFunction(MS_DB_CONTACT_WRITESETTING, srvWriteContactSetting);
CreateServiceFunction(MS_DB_CONTACT_DELETESETTING, srvDeleteContactSetting);
CreateServiceFunction(MS_DB_CONTACT_ENUMSETTINGS, srvEnumContactSettings);
CreateServiceFunction(MS_DB_SETSETTINGRESIDENT, srvSetSettingResident);
CreateServiceFunction("DB/ResidentSettings/Enum", srvEnumResidentSettings);
CreateServiceFunction(MS_DB_REGISTER_PLUGIN, srvRegisterPlugin);
CreateServiceFunction(MS_DB_FIND_PLUGIN, srvFindPlugin);
CreateServiceFunction(MS_DB_GET_CURRENT, srvGetCurrentDb);
return 0;
}
|