summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin10/lib/mir_core.libbin37816 -> 39270 bytes
-rw-r--r--bin10/lib/mir_core64.libbin34498 -> 35812 bytes
-rw-r--r--bin11/lib/mir_core.libbin37816 -> 39270 bytes
-rw-r--r--bin11/lib/mir_core64.libbin34498 -> 35812 bytes
-rw-r--r--include/m_core.h16
-rw-r--r--include/m_protoint.h32
-rw-r--r--plugins/AssocMgr/src/reg.cpp2
-rw-r--r--plugins/HTTPServer/src/IndexXML.cpp2
-rw-r--r--plugins/HTTPServer/src/MimeHandling.cpp7
-rw-r--r--plugins/HTTPServer/src/main.cpp10
-rw-r--r--plugins/New_GPG/src/utilities.h10
-rw-r--r--plugins/TabSRMM/src/chat/services.cpp2
-rw-r--r--protocols/AimOscar/src/chat.cpp4
-rw-r--r--protocols/AimOscar/src/proto.cpp38
-rw-r--r--protocols/AimOscar/src/proto.h14
-rw-r--r--protocols/AimOscar/src/theme.cpp14
-rw-r--r--protocols/AimOscar/src/utility.cpp21
-rw-r--r--protocols/FacebookRM/src/avatars.cpp11
-rw-r--r--protocols/FacebookRM/src/chat.cpp6
-rw-r--r--protocols/FacebookRM/src/communication.cpp29
-rw-r--r--protocols/FacebookRM/src/connection.cpp19
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp6
-rw-r--r--protocols/FacebookRM/src/events.cpp2
-rw-r--r--protocols/FacebookRM/src/messages.cpp6
-rw-r--r--protocols/FacebookRM/src/process.cpp3
-rw-r--r--protocols/FacebookRM/src/proto.cpp72
-rw-r--r--protocols/FacebookRM/src/proto.h42
-rw-r--r--protocols/FacebookRM/src/theme.cpp12
-rw-r--r--protocols/FacebookRM/src/utils.h29
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp12
-rw-r--r--protocols/Gadu-Gadu/src/filetransfer.cpp8
-rw-r--r--protocols/Gadu-Gadu/src/gg.cpp8
-rw-r--r--protocols/Gadu-Gadu/src/gg.h16
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp74
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h16
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp16
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp16
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp20
-rw-r--r--protocols/Gadu-Gadu/src/ownerinfo.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/services.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/sessions.cpp6
-rw-r--r--protocols/Gadu-Gadu/src/userutils.cpp40
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp4
-rw-r--r--protocols/IRCG/src/irc.h17
-rw-r--r--protocols/IRCG/src/irclib.cpp2
-rw-r--r--protocols/IRCG/src/ircproto.cpp65
-rw-r--r--protocols/IRCG/src/options.cpp2
-rw-r--r--protocols/IRCG/src/services.cpp8
-rw-r--r--protocols/IRCG/src/tools.cpp24
-rw-r--r--protocols/IcqOscarJ/src/chan_05ping.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_avatar.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_direct.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_infoupdate.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp68
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.h22
-rw-r--r--protocols/IcqOscarJ/src/icq_rates.cpp2
-rw-r--r--protocols/IcqOscarJ/src/icq_server.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_xstatus.cpp2
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.cpp4
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp46
-rw-r--r--protocols/JabberG/src/jabber_console.cpp2
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp8
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp2
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp2
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp2
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp28
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp2
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp6
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp89
-rw-r--r--protocols/JabberG/src/jabber_proto.h15
-rw-r--r--protocols/JabberG/src/jabber_std.cpp41
-rw-r--r--protocols/MRA/src/Mra.h14
-rw-r--r--protocols/MRA/src/MraAvatars.cpp2
-rw-r--r--protocols/MRA/src/MraFilesQueue.cpp4
-rw-r--r--protocols/MRA/src/MraIcons.cpp2
-rw-r--r--protocols/MRA/src/MraProto.cpp70
-rw-r--r--protocols/MRA/src/MraProto.h17
-rw-r--r--protocols/MRA/src/Mra_proto.cpp2
-rw-r--r--protocols/MRA/src/Mra_svcs.cpp3
-rw-r--r--protocols/MSN/src/msn_chat.cpp4
-rw-r--r--protocols/MSN/src/msn_commands.cpp4
-rw-r--r--protocols/MSN/src/msn_contact.cpp4
-rw-r--r--protocols/MSN/src/msn_errors.cpp2
-rw-r--r--protocols/MSN/src/msn_global.h2
-rw-r--r--protocols/MSN/src/msn_menu.cpp12
-rw-r--r--protocols/MSN/src/msn_misc.cpp6
-rw-r--r--protocols/MSN/src/msn_msgqueue.cpp4
-rw-r--r--protocols/MSN/src/msn_opts.cpp14
-rw-r--r--protocols/MSN/src/msn_p2p.cpp2
-rw-r--r--protocols/MSN/src/msn_proto.cpp61
-rw-r--r--protocols/MSN/src/msn_proto.h14
-rw-r--r--protocols/MSN/src/msn_soapab.cpp6
-rw-r--r--protocols/MSN/src/msn_srv.cpp10
-rw-r--r--protocols/MSN/src/msn_std.cpp42
-rw-r--r--protocols/MSN/src/msn_svcs.cpp8
-rw-r--r--protocols/Omegle/src/chat.cpp18
-rw-r--r--protocols/Omegle/src/communication.cpp5
-rw-r--r--protocols/Omegle/src/proto.cpp19
-rw-r--r--protocols/Omegle/src/proto.h12
-rw-r--r--protocols/Omegle/src/utils.h29
-rw-r--r--protocols/Skype/src/skype_hooks.cpp5
-rw-r--r--protocols/Skype/src/skype_menus.cpp4
-rw-r--r--protocols/Skype/src/skype_proto.cpp5
-rw-r--r--protocols/Skype/src/skype_proto.h15
-rw-r--r--protocols/Skype/src/skype_services.cpp18
-rw-r--r--protocols/Skype/src/skype_utils.cpp44
-rw-r--r--protocols/Tlen/src/jabber.h5
-rw-r--r--protocols/Tlen/src/jabber_svc.cpp8
-rw-r--r--protocols/Twitter/src/chat.cpp8
-rw-r--r--protocols/Twitter/src/connection.cpp4
-rw-r--r--protocols/Twitter/src/contacts.cpp10
-rw-r--r--protocols/Twitter/src/proto.cpp45
-rw-r--r--protocols/Twitter/src/proto.h26
-rw-r--r--protocols/Twitter/src/theme.cpp2
-rw-r--r--protocols/Twitter/src/ui.cpp2
-rw-r--r--protocols/Twitter/src/utility.h29
-rw-r--r--protocols/Yahoo/src/avatar.cpp4
-rw-r--r--protocols/Yahoo/src/chat.cpp4
-rw-r--r--protocols/Yahoo/src/file_transfer.cpp6
-rw-r--r--protocols/Yahoo/src/im.cpp10
-rw-r--r--protocols/Yahoo/src/proto.cpp17
-rw-r--r--protocols/Yahoo/src/proto.h27
-rw-r--r--protocols/Yahoo/src/search.cpp4
-rw-r--r--protocols/Yahoo/src/services.cpp36
-rw-r--r--protocols/Yahoo/src/util.cpp27
-rw-r--r--src/mir_core/mir_core.def6
-rw-r--r--src/mir_core/protos.cpp45
-rw-r--r--src/modules/extraicons/options_ei.cpp10
129 files changed, 724 insertions, 1224 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
index 8393ea9f71..5c8c38a530 100644
--- a/bin10/lib/mir_core.lib
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
index 4c3efeee52..18f70c1c88 100644
--- a/bin10/lib/mir_core64.lib
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib
index db7baf3c24..ec9c957f49 100644
--- a/bin11/lib/mir_core.lib
+++ b/bin11/lib/mir_core.lib
Binary files differ
diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib
index 210f725cfb..10a9ea603c 100644
--- a/bin11/lib/mir_core64.lib
+++ b/bin11/lib/mir_core64.lib
Binary files differ
diff --git a/include/m_core.h b/include/m_core.h
index 4467168395..3a8da096cd 100644
--- a/include/m_core.h
+++ b/include/m_core.h
@@ -605,6 +605,22 @@ MIR_CORE_DLL(void) ProtoConstructor(struct PROTO_INTERFACE *pThis, const char *p
// Call it in the very end of your proto's destructor
MIR_CORE_DLL(void) ProtoDestructor(struct PROTO_INTERFACE *pThis);
+#if defined( __cplusplus )
+typedef void (__cdecl PROTO_INTERFACE::*ProtoThreadFunc)(void*);
+MIR_CORE_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param);
+MIR_CORE_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc, void *param, UINT* threadID);
+
+typedef int (__cdecl PROTO_INTERFACE::*ProtoEventFunc)(WPARAM, LPARAM);
+MIR_CORE_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szName, ProtoEventFunc pFunc);
+MIR_CORE_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szService);
+
+typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFunc)(WPARAM, LPARAM);
+MIR_CORE_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc);
+
+typedef INT_PTR (__cdecl PROTO_INTERFACE::*ProtoServiceFuncParam)(WPARAM, LPARAM, LPARAM);
+MIR_CORE_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam, LPARAM);
+#endif
+
///////////////////////////////////////////////////////////////////////////////
// sha1 functions
diff --git a/include/m_protoint.h b/include/m_protoint.h
index ac700dfbad..336a5eecba 100644
--- a/include/m_protoint.h
+++ b/include/m_protoint.h
@@ -106,4 +106,36 @@ struct PROTO_INTERFACE : public MZeroedObject
virtual int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam) = 0;
};
+template<class T> class PROTO : public PROTO_INTERFACE
+{
+
+public:
+ __forceinline PROTO(const char *szProto, const TCHAR *tszUserName)
+ {
+ ::ProtoConstructor(this, szProto, tszUserName);
+ }
+
+ __forceinline ~PROTO()
+ {
+ ::ProtoDestructor(this);
+ }
+
+ typedef int (__cdecl T::*MyEventFunc)(WPARAM, LPARAM);
+ void __forceinline HookEvent(const char* name, MyEventFunc pFunc)
+ { ::ProtoHookEvent(this, name, (ProtoEventFunc)pFunc); }
+
+ typedef void (__cdecl T::*MyThreadFunc)(void*);
+ void __forceinline ForkThread(MyThreadFunc pFunc, void *param)
+ { ::ProtoForkThread(this, (ProtoThreadFunc)pFunc, param); }
+ HANDLE __forceinline ForkThreadEx(MyThreadFunc pFunc, void *param, UINT *pThreadId)
+ { return ::ProtoForkThreadEx(this, (ProtoThreadFunc)pFunc, param, pThreadId); }
+
+ typedef INT_PTR (__cdecl T::*MyServiceFunc)(WPARAM, LPARAM);
+ void __forceinline CreateService(const char *name, MyServiceFunc pFunc)
+ { ::ProtoCreateService(this, name, (ProtoServiceFunc)pFunc); }
+
+ typedef INT_PTR (__cdecl T::*MyServiceFuncParam)(WPARAM, LPARAM, LPARAM);
+ void __forceinline CreateServiceParam(const char *name, MyServiceFuncParam pFunc, LPARAM param)
+ { ::ProtoCreateServiceParam(this, name, (ProtoServiceFuncParam)pFunc, param); }
+};
#endif // M_PROTOINT_H__
diff --git a/plugins/AssocMgr/src/reg.cpp b/plugins/AssocMgr/src/reg.cpp
index d792a69566..fc5803d7e1 100644
--- a/plugins/AssocMgr/src/reg.cpp
+++ b/plugins/AssocMgr/src/reg.cpp
@@ -346,7 +346,7 @@ static void WriteDbBackupData(const char *pszSetting,DWORD dwType,BYTE *pData,DW
if (buf) {
*(DWORD*)buf = dwType;
CopyMemory(buf+sizeof(DWORD), pData, cbData);
- db_set_blob(NULL, "AssocMgr", pszSetting, buf, cbLen);
+ db_set_blob(NULL, "AssocMgr", pszSetting, buf, (unsigned)cbLen);
mir_free(buf);
}
}
diff --git a/plugins/HTTPServer/src/IndexXML.cpp b/plugins/HTTPServer/src/IndexXML.cpp
index 15c86c5c40..0297a1f038 100644
--- a/plugins/HTTPServer/src/IndexXML.cpp
+++ b/plugins/HTTPServer/src/IndexXML.cpp
@@ -116,7 +116,7 @@ bool bCreateIndexXML(const char * pszRealPath, const char * pszIndexPath,
strcpy(szBuffer, "index.xsl");
}
- WriteFile(hFile, szBuffer, strlen(szBuffer), &dwBytesWritten, NULL);
+ WriteFile(hFile, szBuffer, (DWORD)strlen(szBuffer), &dwBytesWritten, NULL);
WriteFile(hFile, szXmlHeader2, sizeof(szXmlHeader2) - 1, &dwBytesWritten, NULL);
diff --git a/plugins/HTTPServer/src/MimeHandling.cpp b/plugins/HTTPServer/src/MimeHandling.cpp
index 42964bfeb3..9656753056 100644
--- a/plugins/HTTPServer/src/MimeHandling.cpp
+++ b/plugins/HTTPServer/src/MimeHandling.cpp
@@ -9,7 +9,6 @@ int bInitMimeHandling() {
FILE *mimeDB;
char line[LINE_MAX_SIZE];
char *tok = NULL;
- int lenght;
ContentType *pDBCell = NULL;
ContentTypeDB pDB = NULL;
ExtensionList extListCur = NULL;
@@ -32,10 +31,10 @@ int bInitMimeHandling() {
*tok = '\0';
}
/* remove trailing \n */
- lenght = strlen(line);
- if (lenght > 0 && line[lenght - 1] == '\n') {
+ int lenght = (int)strlen(line);
+ if (lenght > 0 && line[lenght - 1] == '\n')
line[lenght - 1] = '\0';
- }
+
/* first token = mime type */
tok = (char*)strtok(line, " \t");
/*create and fill a cell*/
diff --git a/plugins/HTTPServer/src/main.cpp b/plugins/HTTPServer/src/main.cpp
index f6bd92563a..b59587737e 100644
--- a/plugins/HTTPServer/src/main.cpp
+++ b/plugins/HTTPServer/src/main.cpp
@@ -127,7 +127,7 @@ bool bOpenLogFile() {
bool bWriteToFile(HANDLE hFile, const char * pszSrc, int nLen = -1) {
if (nLen < 0)
- nLen = strlen(pszSrc);
+ nLen = (int)strlen(pszSrc);
DWORD dwBytesWritten;
return WriteFile(hFile, pszSrc, nLen, &dwBytesWritten, NULL) && (dwBytesWritten == (DWORD)nLen);
}
@@ -162,9 +162,9 @@ void LogEvent(const TCHAR * pszTitle, const char * pszLog) {
char szTmp[128];
time_t now;
time(&now);
- int nLen = strftime(szTmp, sizeof(szTmp), "%d-%m-%Y %H:%M:%S -- ", localtime(&now));
+ int nLen = (int)strftime(szTmp, sizeof(szTmp), "%d-%m-%Y %H:%M:%S -- ", localtime(&now));
- int nLogLen = strlen(pszLog);
+ int nLogLen = (int)strlen(pszLog);
while (nLogLen > 0 && (pszLog[nLogLen-1] == '\r' || pszLog[nLogLen-1] == '\n'))
nLogLen--;
@@ -242,7 +242,7 @@ bool bReadConfigurationFile() {
// move rest of buffer to front
if (pszCurPos && pszCurPos != szBuf) {
- dwBytesInBuffer = sizeof(szBuf) - (pszCurPos - szBuf);
+ dwBytesInBuffer = DWORD(sizeof(szBuf) - (pszCurPos - szBuf));
memmove(szBuf, pszCurPos, dwBytesInBuffer);
}
@@ -915,7 +915,7 @@ int nSystemShutdown(WPARAM /*wparam*/, LPARAM /*lparam*/) {
return 1;
}
- nPluginPathLen = strlen(szPluginPath);
+ nPluginPathLen = (int)strlen(szPluginPath);
sLogFilePath = szPluginPath;
sLogFilePath += "HTTPServer.log";
diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h
index eaa7ef71b5..ef3fbced23 100644
--- a/plugins/New_GPG/src/utilities.h
+++ b/plugins/New_GPG/src/utilities.h
@@ -46,12 +46,12 @@ public:
timestamp = time(0);
szModule = 0;
cbSize = 0;
- cbBlob = strlen(msg)+1;
+ cbBlob = DWORD(strlen(msg)+1);
pBlob = (PBYTE)msg;
}
db_event(char* msg, DWORD time)
{
- cbBlob = strlen(msg)+1;
+ cbBlob = DWORD(strlen(msg)+1);
pBlob = (PBYTE)msg;
eventType = EVENTTYPE_MESSAGE;
flags = 0;
@@ -61,7 +61,7 @@ public:
}
db_event(char* msg, DWORD time, int type)
{
- cbBlob = strlen(msg)+1;
+ cbBlob = DWORD(strlen(msg)+1);
pBlob = (PBYTE)msg;
if(type)
eventType = type;
@@ -74,7 +74,7 @@ public:
}
db_event(char* msg, int type)
{
- cbBlob = strlen(msg)+1;
+ cbBlob = DWORD(strlen(msg)+1);
pBlob = (PBYTE)msg;
flags = 0;
if(type)
@@ -87,7 +87,7 @@ public:
}
db_event(char* msg, DWORD time, int type, DWORD _flags)
{
- cbBlob = strlen(msg)+1;
+ cbBlob = DWORD(strlen(msg)+1);
pBlob = (PBYTE)msg;
if(type)
eventType = type;
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp
index e421518e24..231f466da9 100644
--- a/plugins/TabSRMM/src/chat/services.cpp
+++ b/plugins/TabSRMM/src/chat/services.cpp
@@ -159,7 +159,7 @@ INT_PTR Service_Register(WPARAM wParam, LPARAM lParam)
mi = MM_AddModule(gcr->pszModule);
if (mi) {
mi->ptszModDispName = a2tf( gcr->ptszModuleDispName, gcr->dwFlags);
- mi->bBold = gcr->dwFlags & GC_BOLD;
+ mi->bBold = (gcr->dwFlags & GC_BOLD) != 0;
mi->bUnderline = (gcr->dwFlags & GC_UNDERLINE) != 0;
mi->bItalics = (gcr->dwFlags & GC_ITALICS) != 0;
mi->bColor = (gcr->dwFlags & GC_COLOR) != 0;
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp
index 1c9f329486..033643f915 100644
--- a/protocols/AimOscar/src/chat.cpp
+++ b/protocols/AimOscar/src/chat.cpp
@@ -31,8 +31,8 @@ void CAimProto::chat_register(void)
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
- HookProtoEvent(ME_GC_EVENT, &CAimProto::OnGCEvent);
- HookProtoEvent(ME_GC_BUILDMENU, &CAimProto::OnGCMenuHook );
+ HookEvent(ME_GC_EVENT, &CAimProto::OnGCEvent);
+ HookEvent(ME_GC_BUILDMENU, &CAimProto::OnGCMenuHook );
}
void CAimProto::chat_start(const char* id, unsigned short exchange)
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp
index 6f9815a8a7..2d13a60e8b 100644
--- a/protocols/AimOscar/src/proto.cpp
+++ b/protocols/AimOscar/src/proto.cpp
@@ -17,35 +17,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "aim.h"
-CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName)
- : chat_rooms(5)
+CAimProto::CAimProto(const char* aProtoName, const TCHAR* aUserName) :
+ PROTO<CAimProto>(aProtoName, aUserName),
+ chat_rooms(5)
{
- ProtoConstructor(this, aProtoName, aUserName);
LOG("Setting protocol/module name to '%s'", m_szModuleName);
//create some events
hAvatarEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
hChatNavEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- hAdminEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ hAdminEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
InitializeCriticalSection(&SendingMutex);
InitializeCriticalSection(&connMutex);
- CreateProtoService(PS_CREATEACCMGRUI, &CAimProto::SvcCreateAccMgrUI);
+ CreateService(PS_CREATEACCMGRUI, &CAimProto::SvcCreateAccMgrUI);
- CreateProtoService(PS_GETMYAWAYMSG, &CAimProto::GetMyAwayMsg);
+ CreateService(PS_GETMYAWAYMSG, &CAimProto::GetMyAwayMsg);
- CreateProtoService(PS_GETAVATARINFOT, &CAimProto::GetAvatarInfo);
- CreateProtoService(PS_GETMYAVATART, &CAimProto::GetAvatar);
- CreateProtoService(PS_SETMYAVATART, &CAimProto::SetAvatar);
- CreateProtoService(PS_GETAVATARCAPS, &CAimProto::GetAvatarCaps);
+ CreateService(PS_GETAVATARINFOT, &CAimProto::GetAvatarInfo);
+ CreateService(PS_GETMYAVATART, &CAimProto::GetAvatar);
+ CreateService(PS_SETMYAVATART, &CAimProto::SetAvatar);
+ CreateService(PS_GETAVATARCAPS, &CAimProto::GetAvatarCaps);
- CreateProtoService(PS_JOINCHAT, &CAimProto::OnJoinChat);
- CreateProtoService(PS_LEAVECHAT, &CAimProto::OnLeaveChat);
+ CreateService(PS_JOINCHAT, &CAimProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &CAimProto::OnLeaveChat);
- HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CAimProto::OnPreBuildContactMenu);
- HookProtoEvent(ME_CLIST_GROUPCHANGE, &CAimProto::OnGroupChange);
- HookProtoEvent(ME_OPT_INITIALISE, &CAimProto::OnOptionsInit);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CAimProto::OnPreBuildContactMenu);
+ HookEvent(ME_CLIST_GROUPCHANGE, &CAimProto::OnGroupChange);
+ HookEvent(ME_OPT_INITIALISE, &CAimProto::OnOptionsInit);
init_custom_folders();
offline_contacts();
@@ -109,8 +109,6 @@ CAimProto::~CAimProto()
mir_free(CHATNAV_COOKIE);
mir_free(ADMIN_COOKIE);
mir_free(username);
-
- ProtoDestructor(this);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -118,9 +116,9 @@ CAimProto::~CAimProto()
int CAimProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- HookProtoEvent(ME_USERINFO_INITIALISE, &CAimProto::OnUserInfoInit);
- HookProtoEvent(ME_IDLE_CHANGED, &CAimProto::OnIdleChanged);
- HookProtoEvent(ME_MSG_WINDOWEVENT, &CAimProto::OnWindowEvent);
+ HookEvent(ME_USERINFO_INITIALISE, &CAimProto::OnUserInfoInit);
+ HookEvent(ME_IDLE_CHANGED, &CAimProto::OnIdleChanged);
+ HookEvent(ME_MSG_WINDOWEVENT, &CAimProto::OnWindowEvent);
chat_register();
InitContactMenus();
diff --git a/protocols/AimOscar/src/proto.h b/protocols/AimOscar/src/proto.h
index 5c8aa0bde9..3cb22c28d2 100644
--- a/protocols/AimOscar/src/proto.h
+++ b/protocols/AimOscar/src/proto.h
@@ -19,15 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _AIM_PROTO_H_
#define _AIM_PROTO_H_
-struct CAimProto;
-typedef void ( __cdecl CAimProto::*AimThreadFunc )( void* );
-typedef int ( __cdecl CAimProto::*AimEventFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CAimProto::*AimServiceFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CAimProto::*AimServiceFuncParam )( WPARAM, LPARAM, LPARAM );
-
-struct CAimProto : public PROTO_INTERFACE
+struct CAimProto : public PROTO<CAimProto>
{
- CAimProto( const char*, const TCHAR* );
+ CAimProto(const char*, const TCHAR*);
~CAimProto();
//====================================================================================
@@ -461,10 +455,6 @@ struct CAimProto : public PROTO_INTERFACE
//////////////////////////////////////////////////////////////////////////////////////
HANDLE CreateProtoEvent(const char* szEvent);
- void CreateProtoService(const char* szService, AimServiceFunc serviceProc);
- void CreateProtoServiceParam(const char* szService, AimServiceFuncParam serviceProc, LPARAM lParam);
- void HookProtoEvent(const char* szEvent, AimEventFunc pFunc);
- void ForkThread(AimThreadFunc, void*);
int deleteSetting(HANDLE hContact, const char* setting);
diff --git a/protocols/AimOscar/src/theme.cpp b/protocols/AimOscar/src/theme.cpp
index 5f595d2cc6..02e1f652bd 100644
--- a/protocols/AimOscar/src/theme.cpp
+++ b/protocols/AimOscar/src/theme.cpp
@@ -270,21 +270,21 @@ void CAimProto::InitMainMenus(void)
mi.flags = CMIF_CHILDPOPUP;
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/ManageAccount");
- CreateProtoService("/ManageAccount", &CAimProto::ManageAccount);
+ CreateService("/ManageAccount", &CAimProto::ManageAccount);
mi.position = 201001;
mi.icolibItem = GetIconHandle("aim");
mi.pszName = LPGEN("Manage Account");
hMainMenu[0] = Menu_AddProtoMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/InstantIdle");
- CreateProtoService("/InstantIdle",&CAimProto::InstantIdle);
+ CreateService("/InstantIdle",&CAimProto::InstantIdle);
mi.position = 201002;
mi.icolibItem = GetIconHandle("idle");
mi.pszName = LPGEN("Instant Idle");
hMainMenu[1] = Menu_AddProtoMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/JoinChatRoom");
- CreateProtoService("/JoinChatRoom", &CAimProto::JoinChatUI);
+ CreateService("/JoinChatRoom", &CAimProto::JoinChatUI);
mi.position = 201003;
mi.icolibItem = GetIconHandle("aol");
mi.pszName = LPGEN( "Join Chat Room" );
@@ -301,7 +301,7 @@ void CAimProto::InitContactMenus(void)
mi.pszContactOwner = m_szModuleName;
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/GetHTMLAwayMsg");
- CreateProtoService("/GetHTMLAwayMsg",&CAimProto::GetHTMLAwayMsg);
+ CreateService("/GetHTMLAwayMsg",&CAimProto::GetHTMLAwayMsg);
mi.position = -2000006000;
mi.icolibItem = GetIconHandle("away");
mi.pszName = LPGEN("Read &HTML Away Message");
@@ -309,7 +309,7 @@ void CAimProto::InitContactMenus(void)
hHTMLAwayContextMenuItem = Menu_AddContactMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/GetProfile");
- CreateProtoService("/GetProfile", &CAimProto::GetProfile);
+ CreateService("/GetProfile", &CAimProto::GetProfile);
mi.position = -2000005090;
mi.icolibItem = GetIconHandle("profile");
mi.pszName = LPGEN("Read Profile");
@@ -317,7 +317,7 @@ void CAimProto::InitContactMenus(void)
hReadProfileMenuItem = Menu_AddContactMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/AddToServerList");
- CreateProtoService("/AddToServerList", &CAimProto::AddToServerList);
+ CreateService("/AddToServerList", &CAimProto::AddToServerList);
mi.position = -2000005080;
mi.icolibItem = GetIconHandle("add");
mi.pszName = LPGEN("Add To Server List");
@@ -325,7 +325,7 @@ void CAimProto::InitContactMenus(void)
hAddToServerListContextMenuItem = Menu_AddContactMenuItem(&mi);
mir_snprintf(service_name, sizeof(service_name), "%s%s", m_szModuleName, "/BlockCommand");
- CreateProtoService("/BlockCommand", &CAimProto::BlockBuddy);
+ CreateService("/BlockCommand", &CAimProto::BlockBuddy);
mi.position = -2000005060;
mi.icolibItem = GetIconHandle("block");
mi.pszName = LPGEN("&Block");
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp
index f43e88aa63..be6ac0b388 100644
--- a/protocols/AimOscar/src/utility.cpp
+++ b/protocols/AimOscar/src/utility.cpp
@@ -804,24 +804,3 @@ void CAimProto::setWord(const char* name, WORD value)
void CAimProto::setWord(HANDLE hContact, const char* name, WORD value)
{ db_set_w(hContact, m_szModuleName, name, value);
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CAimProto::CreateProtoService(const char* szService, AimServiceFunc serviceProc)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp, sizeof(temp), "%s%s", m_szModuleName, szService);
- CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
-
-void CAimProto::HookProtoEvent(const char* szEvent, AimEventFunc pFunc)
-{
- ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&pFunc, this);
-}
-
-void CAimProto::ForkThread(AimThreadFunc pFunc, void* param)
-{
- UINT threadID;
- CloseHandle((HANDLE)mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, this, param, &threadID));
-}
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp
index 11c812fd0d..77802300f0 100644
--- a/protocols/FacebookRM/src/avatars.cpp
+++ b/protocols/FacebookRM/src/avatars.cpp
@@ -140,7 +140,7 @@ std::tstring FacebookProto::GetAvatarFolder()
return path;
}
-int FacebookProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
{
int res = 0;
@@ -177,7 +177,7 @@ int FacebookProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
return res;
}
-int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
{
if (!lParam)
return GAIR_NOAVATAR;
@@ -203,7 +203,7 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
bool is_empty = avatar_queue.empty();
avatar_queue.push_back(AI->hContact);
if (is_empty)
- ForkThread(&FacebookProto::UpdateAvatarWorker, this, NULL);
+ ForkThread(&FacebookProto::UpdateAvatarWorker, NULL);
}
return GAIR_WAITFOR;
}
@@ -214,7 +214,7 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
return GAIR_NOAVATAR;
}
-int FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
LOG("***** GetMyAvatar");
@@ -225,8 +225,7 @@ int FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
int size = (int)lParam;
PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
- switch (GetAvatarInfo(0, (LPARAM)&ai))
- {
+ switch (GetAvatarInfo(0, (LPARAM)&ai)) {
case GAIR_SUCCESS:
_tcsncpy(buf, ai.filename, size);
buf[size-1] = 0;
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 01279a9df9..bd7ad7d553 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -71,7 +71,7 @@ int FacebookProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
if (isOnline()) {
LOG("**Chat - Outgoing message: %s", text);
- ForkThread(&FacebookProto::SendChatMsgWorker, this, new send_chat(chat_id, msg));
+ ForkThread(&FacebookProto::SendChatMsgWorker, new send_chat(chat_id, msg));
}
break;
@@ -228,7 +228,7 @@ void FacebookProto::AddChat(const char *id, const char *name)
}
*/
-int FacebookProto::OnJoinChat(WPARAM,LPARAM suppress)
+INT_PTR FacebookProto::OnJoinChat(WPARAM,LPARAM suppress)
{
/* GCSESSION gcw = {sizeof(gcw)};
@@ -268,7 +268,7 @@ int FacebookProto::OnJoinChat(WPARAM,LPARAM suppress)
return 0;
}
-int FacebookProto::OnLeaveChat(WPARAM,LPARAM)
+INT_PTR FacebookProto::OnLeaveChat(WPARAM,LPARAM)
{
GCDEST gcd = { m_szModuleName };
gcd.ptszID = NULL;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 619f082a45..2a79fa8e87 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -950,14 +950,10 @@ bool facebook_client::buddy_list()
// Process result data
validate_response(&resp);
- switch (resp.code)
- {
+ switch (resp.code) {
case HTTP_CODE_OK:
- {
- std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessBuddyList, this->parent, (void*)response_data);
+ parent->ForkThread(&FacebookProto::ProcessBuddyList, new std::string(resp.data));
return handle_success("buddy_list");
- }
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
@@ -976,14 +972,11 @@ bool facebook_client::load_friends()
// Process result data
validate_response(&resp);
- switch (resp.code)
- {
+ switch (resp.code) {
case HTTP_CODE_OK:
- {
- std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessFriendList, this->parent, (void*)response_data);
+ parent->ForkThread(&FacebookProto::ProcessFriendList, new std::string(resp.data));
return handle_success("load_friends");
- }
+
case HTTP_CODE_FAKE_ERROR:
case HTTP_CODE_FAKE_DISCONNECTED:
default:
@@ -1001,13 +994,11 @@ bool facebook_client::feeds()
// Process result data
validate_response(&resp);
- switch (resp.code)
- {
+ switch (resp.code) {
case HTTP_CODE_OK:
- if (resp.data.find("\"num_stories\":0") == std::string::npos) {
- std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessFeeds, this->parent, (void*)response_data);
- }
+ if (resp.data.find("\"num_stories\":0") == std::string::npos)
+ parent->ForkThread(&FacebookProto::ProcessFeeds, new std::string(resp.data));
+
return handle_success("feeds");
case HTTP_CODE_FAKE_ERROR:
@@ -1062,7 +1053,7 @@ bool facebook_client::channel()
} else {
// Something has been received, throw to new thread to process
std::string* response_data = new std::string(resp.data);
- ForkThread(&FacebookProto::ProcessMessages, this->parent, (void*)response_data);
+ parent->ForkThread(&FacebookProto::ProcessMessages, response_data);
// Increment sequence number
this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index 27908aa019..c1692a6cca 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.cpp
@@ -84,23 +84,22 @@ void FacebookProto::ChangeStatus(void*)
facy.load_friends();
// Process Friends requests
- ForkThread(&FacebookProto::ProcessFriendRequests, this, NULL);
+ ForkThread(&FacebookProto::ProcessFriendRequests, NULL);
// Get unread messages
- ForkThread(&FacebookProto::ProcessUnreadMessages, this);
+ ForkThread(&FacebookProto::ProcessUnreadMessages, NULL);
// Get notifications
- ForkThread(&FacebookProto::ProcessNotifications, this);
+ ForkThread(&FacebookProto::ProcessNotifications, NULL);
setDword("LogonTS", (DWORD)time(NULL));
- ForkThread(&FacebookProto::UpdateLoop, this);
- ForkThread(&FacebookProto::MessageLoop, this);
+ ForkThread(&FacebookProto::UpdateLoop, NULL);
+ ForkThread(&FacebookProto::MessageLoop, NULL);
if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
- {
- ForkThread(&FacebookProto::SetAwayMsgWorker, this, NULL);
- }
- } else {
+ ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
+ }
+ else {
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)old_status, m_iStatus);
if (facy.hFcbCon)
@@ -212,7 +211,7 @@ void FacebookProto::UpdateLoop(void *)
break;
if (i == 49)
- ForkThread(&FacebookProto::ProcessFriendRequests, this, NULL);
+ ForkThread(&FacebookProto::ProcessFriendRequests, NULL);
LOG("***** FacebookProto::UpdateLoop[%d] going to sleep...", tim);
if (WaitForSingleObjectEx(update_loop_lock_, GetPollRate() * 1000, true) != WAIT_TIMEOUT)
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 9d8dfaae53..166c0c3f12 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -182,7 +182,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
utils::mem::detract(narrow);
//char *narrow = mir_t2a_cp(mindMessage,CP_UTF8);
- ForkThread(&FacebookProto::SetAwayMsgWorker, proto, NULL);
+ proto->ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
EndDialog(hwnd, wparam);
return TRUE;
@@ -368,9 +368,7 @@ INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, L
{
db_set_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_SET_MIRANDA_STATUS, setStatus);
if (setStatus && proto->isOnline())
- {
- ForkThread(&FacebookProto::SetAwayMsgWorker, proto, NULL);
- }
+ proto->ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
}
return TRUE;
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp
index 14596477d7..bbab7df928 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -53,7 +53,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
popup_data *data = (popup_data *)PUGetPluginData(hwnd);
if (data != NULL) {
if (!data->notification_id.empty())
- ForkThread(&FacebookProto::ReadNotificationWorker, data->proto, new std::string(data->notification_id));
+ data->proto->ForkThread(&FacebookProto::ReadNotificationWorker, new std::string(data->notification_id));
if (message == WM_COMMAND && !data->url.empty())
data->proto->OpenUrl(data->url);
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index 1c31312263..d801fefe35 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int FacebookProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre)
{
- ForkThread(&FacebookProto::ReadMessageWorker, this, hContact);
+ ForkThread(&FacebookProto::ReadMessageWorker, hContact);
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
return Proto_RecvMessage(hContact, pre);
@@ -112,14 +112,14 @@ int FacebookProto::SendMsg(HANDLE hContact, int flags, const char *msg)
msg = mir_utf8encode(msg);
facy.msgid_ = (facy.msgid_ % 1024)+1;
- ForkThread(&FacebookProto::SendMsgWorker, this, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
+ ForkThread(&FacebookProto::SendMsgWorker, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
return facy.msgid_;
}
int FacebookProto::UserIsTyping(HANDLE hContact,int type)
{
if (hContact && isOnline())
- ForkThread(&FacebookProto::SendTypingWorker, this, new send_typing(hContact, type));
+ ForkThread(&FacebookProto::SendTypingWorker, new send_typing(hContact, type));
return 0;
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index ab77ddb50d..fa13cc2b86 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -293,8 +293,7 @@ void FacebookProto::ProcessUnreadMessages(void*)
if (tid.empty())
continue;
- std::string* data = new std::string(tid);
- ForkThread(&FacebookProto::ProcessUnreadMessage, this, (void*)data);
+ ForkThread(&FacebookProto::ProcessUnreadMessage, new std::string(tid));
}
page = utils::text::source_get_value(&items, 3, "id=\"see_older_threads\"", "page=", "&");
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index ab0f3a6e3d..7a7e02608b 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -22,10 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
-FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username)
+FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
+ PROTO<FacebookProto>(proto_name, username)
{
- ProtoConstructor(this, proto_name, username);
-
facy.parent = this;
signon_lock_ = CreateMutex(NULL, FALSE, NULL);
@@ -36,22 +35,22 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username)
facy.send_message_lock_ = CreateMutex(NULL, FALSE, NULL);
facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL);
- CreateProtoService(m_szModuleName, PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI, this);
- CreateProtoService(m_szModuleName, PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg, this);
- CreateProtoService(m_szModuleName, PS_GETMYAVATART, &FacebookProto::GetMyAvatar, this);
- CreateProtoService(m_szModuleName, PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo, this);
- CreateProtoService(m_szModuleName, PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps, this);
+ CreateService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI);
+ CreateService(PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg);
+ CreateService(PS_GETMYAVATART, &FacebookProto::GetMyAvatar);
+ CreateService(PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo);
+ CreateService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps);
- CreateProtoService(m_szModuleName, PS_JOINCHAT, &FacebookProto::OnJoinChat, this);
- CreateProtoService(m_szModuleName, PS_LEAVECHAT, &FacebookProto::OnLeaveChat, this);
+ CreateService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
- CreateProtoService(m_szModuleName, "/Mind", &FacebookProto::OnMind, this);
+ CreateService("/Mind", &FacebookProto::OnMind);
- HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu, this);
- HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit, this);
- HookProtoEvent(ME_GC_EVENT, &FacebookProto::OnChatOutgoing, this);
- HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged, this);
- HookProtoEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit, this);
+ HookEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu);
+ HookEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit);
+ HookEvent(ME_GC_EVENT, &FacebookProto::OnChatOutgoing);
+ HookEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged);
+ HookEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit);
char module[512];
mir_snprintf(module, sizeof(module), "%s/Mind", m_szModuleName);
@@ -201,7 +200,7 @@ int FacebookProto::SetAwayMsg(int status, const PROTOCHAR *msg)
utils::mem::detract(narrow);
if (isOnline() && getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
- ForkThread(&FacebookProto::SetAwayMsgWorker, this, NULL);
+ ForkThread(&FacebookProto::SetAwayMsgWorker, NULL);
return 0;
}
@@ -218,8 +217,7 @@ HANDLE FacebookProto::SearchBasic(const PROTOCHAR* id)
return 0;
TCHAR* email = mir_tstrdup(id);
- ForkThread(&FacebookProto::SearchAckThread, this, (void*)email);
-
+ ForkThread(&FacebookProto::SearchAckThread, email);
return email;
}
@@ -303,7 +301,7 @@ int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason)
//////////////////////////////////////////////////////////////////////////////
// SERVICES
-int FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv = { DBVT_TCHAR };
if (!getTString("StatusMsg", &dbv) && lstrlen(dbv.ptszVal) != 0)
@@ -363,7 +361,7 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
// EVENTS
-int FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
(HWND)lParam, FBAccountProc, (LPARAM)this);
@@ -438,7 +436,7 @@ int FacebookProto::OnToolbarInit(WPARAM, LPARAM)
return 0;
}
-int FacebookProto::OnMind(WPARAM, LPARAM)
+INT_PTR FacebookProto::OnMind(WPARAM, LPARAM)
{
if (isOnline()) {
HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(this));
@@ -448,7 +446,7 @@ int FacebookProto::OnMind(WPARAM, LPARAM)
return 0;
}
-int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
+INT_PTR FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
{
if (!isOffline()) {
facy.client_notify(TranslateT("Loading newsfeeds..."));
@@ -457,7 +455,7 @@ int FacebookProto::CheckNewsfeeds(WPARAM, LPARAM)
return 0;
}
-int FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
+INT_PTR FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
{
if (!isOffline()) {
facy.client_notify(TranslateT("Checking friend requests..."));
@@ -466,7 +464,7 @@ int FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
return 0;
}
-int FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
+INT_PTR FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
{
if (!isOffline()) {
facy.client_notify(TranslateT("Refreshing buddy list..."));
@@ -476,7 +474,7 @@ int FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
}
-int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -501,7 +499,7 @@ int FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
return 0;
}
-int FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -518,7 +516,7 @@ int FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
-int FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -529,11 +527,11 @@ int FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
if (id == NULL)
return 1;
- ForkThread(&FacebookProto::SendPokeWorker, this, new std::string(id));
+ ForkThread(&FacebookProto::SendPokeWorker, new std::string(id));
return 0;
}
-int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -567,13 +565,13 @@ int FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
fbu->handle = NULL;
}
- ForkThread(&FacebookProto::DeleteContactFromServer, this, (void*)val);
+ ForkThread(&FacebookProto::DeleteContactFromServer, val);
}
return 0;
}
-int FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -584,29 +582,29 @@ int FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
if (id == NULL)
return 1;
- ForkThread(&FacebookProto::AddContactToServer, this, new std::string(id));
+ ForkThread(&FacebookProto::AddContactToServer, new std::string(id));
return 0;
}
-int FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
- ForkThread(&FacebookProto::ApproveContactToServer, this, (void*)hContact);
+ ForkThread(&FacebookProto::ApproveContactToServer, hContact);
return 0;
}
-int FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
HANDLE *hContact = new HANDLE(reinterpret_cast<HANDLE>(wParam));
- ForkThread(&FacebookProto::CancelFriendsRequest, this, (void*)hContact);
+ ForkThread(&FacebookProto::CancelFriendsRequest, hContact);
return 0;
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 1fe140a966..e36af93199 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-class FacebookProto : public PROTO_INTERFACE
+class FacebookProto : public PROTO<FacebookProto>
{
public:
FacebookProto(const char *proto_name, const TCHAR *username);
@@ -101,22 +101,27 @@ public:
////////////////////////
// Services
- int __cdecl GetMyAwayMsg(WPARAM, LPARAM);
- int __cdecl SetMyAwayMsg(WPARAM, LPARAM);
- int __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
- int __cdecl GetMyAvatar(WPARAM, LPARAM);
- int __cdecl GetAvatarInfo(WPARAM, LPARAM);
- int __cdecl GetAvatarCaps(WPARAM, LPARAM);
- int __cdecl VisitProfile(WPARAM, LPARAM);
- int __cdecl VisitFriendship(WPARAM, LPARAM);
- int __cdecl Poke(WPARAM, LPARAM);
- int __cdecl CancelFriendship(WPARAM, LPARAM);
- int __cdecl RequestFriendship(WPARAM, LPARAM);
- int __cdecl ApproveFriendship(WPARAM, LPARAM);
- int __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM);
- int __cdecl CheckNewsfeeds(WPARAM, LPARAM);
- int __cdecl CheckFriendRequests(WPARAM, LPARAM);
- int __cdecl RefreshBuddyList(WPARAM, LPARAM);
+ INT_PTR __cdecl GetMyAwayMsg(WPARAM, LPARAM);
+ INT_PTR __cdecl SetMyAwayMsg(WPARAM, LPARAM);
+ INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
+ INT_PTR __cdecl GetMyAvatar(WPARAM, LPARAM);
+ INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM);
+ INT_PTR __cdecl GetAvatarCaps(WPARAM, LPARAM);
+ INT_PTR __cdecl VisitProfile(WPARAM, LPARAM);
+ INT_PTR __cdecl VisitFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl Poke(WPARAM, LPARAM);
+ INT_PTR __cdecl CancelFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl RequestFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl ApproveFriendship(WPARAM, LPARAM);
+ INT_PTR __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM);
+ INT_PTR __cdecl CheckNewsfeeds(WPARAM, LPARAM);
+ INT_PTR __cdecl CheckFriendRequests(WPARAM, LPARAM);
+ INT_PTR __cdecl RefreshBuddyList(WPARAM, LPARAM);
+
+ INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
+ INT_PTR __cdecl OnLeaveChat(WPARAM,LPARAM);
+
+ INT_PTR __cdecl OnMind(WPARAM,LPARAM);
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
@@ -124,13 +129,10 @@ public:
int __cdecl OnToolbarInit(WPARAM, LPARAM);
int __cdecl OnBuildStatusMenu(WPARAM,LPARAM);
int __cdecl OnContactDeleted(WPARAM,LPARAM);
- int __cdecl OnMind(WPARAM,LPARAM);
int __cdecl OnPreShutdown(WPARAM,LPARAM);
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
int __cdecl OnIdleChanged(WPARAM,LPARAM);
int __cdecl OnChatOutgoing(WPARAM,LPARAM);
- int __cdecl OnJoinChat(WPARAM,LPARAM);
- int __cdecl OnLeaveChat(WPARAM,LPARAM);
// Loops
bool NegotiateConnection();
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index f01dcd616e..c67474a25a 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -66,7 +66,7 @@ static FacebookProto * GetInstanceByHContact(HANDLE hContact)
return 0;
}
-template<int (__cdecl FacebookProto::*Fcn)(WPARAM,LPARAM)>
+template<INT_PTR (__cdecl FacebookProto::*Fcn)(WPARAM,LPARAM)>
INT_PTR GlobalService(WPARAM wParam,LPARAM lParam)
{
FacebookProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
@@ -193,14 +193,14 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.flags = CMIF_CHILDPOPUP | (this->isOnline() ? 0 : CMIF_GRAYED);
mi.position = 201001;
- //CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
+ //CreateService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
strcpy(tDest,"/Mind");
mi.hParentMenu = hRoot;
mi.pszName = LPGEN("Mind...");
mi.icolibItem = GetIconHandle("mind");
m_hStatusMind = Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/VisitProfile",&FacebookProto::VisitProfile,this);
+ CreateService("/VisitProfile",&FacebookProto::VisitProfile);
strcpy(tDest,"/VisitProfile");
mi.flags = CMIF_CHILDPOPUP;
mi.pszName = LPGEN("Visit profile");
@@ -215,7 +215,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.icolibItem = NULL;
m_hMenuServicesRoot = Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/RefreshBuddyList",&FacebookProto::RefreshBuddyList,this);
+ CreateService("/RefreshBuddyList",&FacebookProto::RefreshBuddyList);
strcpy(tDest,"/RefreshBuddyList");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Refresh Buddy List");
@@ -224,7 +224,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.hParentMenu = m_hMenuServicesRoot;
Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/CheckFriendRequests",&FacebookProto::CheckFriendRequests,this);
+ CreateService("/CheckFriendRequests",&FacebookProto::CheckFriendRequests);
strcpy(tDest,"/CheckFriendRequests");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Check Friends Requests");
@@ -232,7 +232,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.hParentMenu = m_hMenuServicesRoot;
Menu_AddProtoMenuItem(&mi);
- CreateProtoService(m_szModuleName,"/CheckNewsfeeds",&FacebookProto::CheckNewsfeeds,this);
+ CreateService("/CheckNewsfeeds",&FacebookProto::CheckNewsfeeds);
strcpy(tDest,"/CheckNewsfeeds");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Check Newsfeeds");
diff --git a/protocols/FacebookRM/src/utils.h b/protocols/FacebookRM/src/utils.h
index eef3907004..c0c8e680d3 100644
--- a/protocols/FacebookRM/src/utils.h
+++ b/protocols/FacebookRM/src/utils.h
@@ -31,35 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// miscellaneous
#define UTILS_CONV_TIME_T 0x0040 // 1234567890
-template<typename T>
-void CreateProtoService(const char *module,const char *service,
- int (__cdecl T::*serviceProc)(WPARAM,LPARAM),T *self)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp,sizeof(temp),"%s%s",module,service);
- CreateServiceFunctionObj(temp,(MIRANDASERVICEOBJ)*(void**)&serviceProc, self);
-}
-
-template<typename T>
-void HookProtoEvent(const char* evt, int (__cdecl T::*eventProc)(WPARAM,LPARAM), T *self)
-{
- ::HookEventObj(evt,(MIRANDAHOOKOBJ)*(void**)&eventProc,self);
-}
-
-template<typename T>
-HANDLE ForkThreadEx(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- return reinterpret_cast<HANDLE>(mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&thread,self,data,0));
-}
-
-template<typename T>
-void ForkThread(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- CloseHandle(ForkThreadEx(thread,self,data));
-}
-
namespace utils
{
namespace url
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index 307d0de7ae..2bc6dc0aab 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -309,9 +309,9 @@ void GGPROTO::initavatarrequestthread()
avatar_requests.destroy();
avatar_transfers.destroy();
#ifdef DEBUGMODE
- netlog("initavatarrequestthread(): forkthreadex 1 GGPROTO::avatarrequestthread");
+ netlog("initavatarrequestthread(): ForkThreadEx 1 GGPROTO::avatarrequestthread");
#endif
- pth_avatar.hThread = forkthreadex(&GGPROTO::avatarrequestthread, NULL, &pth_avatar.dwThreadId);
+ pth_avatar.hThread = ForkThreadEx(&GGPROTO::avatarrequestthread, NULL, &pth_avatar.dwThreadId);
}
}
@@ -345,9 +345,9 @@ void GGPROTO::getOwnAvatar()
if (db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)
&& db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)){
#ifdef DEBUGMODE
- netlog("getOwnAvatar(): forkthread 2 GGPROTO::getOwnAvatarThread");
+ netlog("getOwnAvatar(): ForkThread 2 GGPROTO::getOwnAvatarThread");
#endif
- forkthread(&GGPROTO::getOwnAvatarThread, NULL);
+ ForkThread(&GGPROTO::getOwnAvatarThread, NULL);
}
}
@@ -502,7 +502,7 @@ void __cdecl GGPROTO::setavatarthread(void *param)
void GGPROTO::setAvatar(const TCHAR *szFilename)
{
#ifdef DEBUGMODE
- netlog("setAvatar(): forkthread 3 GGPROTO::setavatarthread");
+ netlog("setAvatar(): ForkThread 3 GGPROTO::setavatarthread");
#endif
- forkthread(&GGPROTO::setavatarthread, mir_tstrdup(szFilename));
+ ForkThread(&GGPROTO::setavatarthread, mir_tstrdup(szFilename));
}
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp
index 345537d9be..bfd23dbd06 100644
--- a/protocols/Gadu-Gadu/src/filetransfer.cpp
+++ b/protocols/Gadu-Gadu/src/filetransfer.cpp
@@ -52,9 +52,9 @@ void GGPROTO::dccstart()
// Start thread
#ifdef DEBUGMODE
- netlog("dccstart(): forkthreadex 4 GGPROTO::dccmainthread");
+ netlog("dccstart(): ForkThreadEx 4 GGPROTO::dccmainthread");
#endif
- pth_dcc.hThread = forkthreadex(&GGPROTO::dccmainthread, NULL, &pth_dcc.dwThreadId);
+ pth_dcc.hThread = ForkThreadEx(&GGPROTO::dccmainthread, NULL, &pth_dcc.dwThreadId);
}
void GGPROTO::dccconnect(uin_t uin)
@@ -113,9 +113,9 @@ HANDLE ftfail(GGPROTO *gg, HANDLE hContact)
ft->hProcess = (HANDLE)rand();
ft->hContact = hContact;
#ifdef DEBUGMODE
- gg->netlog("ftfail(): forkthread 5 GGPROTO::ftfailthread");
+ gg->netlog("ftfail(): ForkThread 5 GGPROTO::ftfailthread");
#endif
- gg->forkthread(&GGPROTO::ftfailthread, ft);
+ gg->ForkThread(&GGPROTO::ftfailthread, ft);
return ft->hProcess;
}
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp
index 4aa782a6b4..3bd7b199a6 100644
--- a/protocols/Gadu-Gadu/src/gg.cpp
+++ b/protocols/Gadu-Gadu/src/gg.cpp
@@ -256,12 +256,12 @@ INT_PTR GGPROTO::blockuser(WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////
// Contact blocking initialization
-#define GGS_BLOCKUSER "%s/BlockUser"
+#define GGS_BLOCKUSER "/BlockUser"
void GGPROTO::block_init()
{
char service[64];
- mir_snprintf(service, sizeof(service), GGS_BLOCKUSER, m_szModuleName);
- createObjService(service, &GGPROTO::blockuser);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_BLOCKUSER);
+ CreateService(GGS_BLOCKUSER, &GGPROTO::blockuser);
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_TCHAR;
@@ -272,7 +272,7 @@ void GGPROTO::block_init()
mi.pszContactOwner = m_szModuleName;
hBlockMenuItem = Menu_AddContactMenuItem(&mi);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, gg_prebuildcontactmenu);
+ ::HookEvent(ME_CLIST_PREBUILDCONTACTMENU, gg_prebuildcontactmenu);
}
//////////////////////////////////////////////////////////
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h
index ea98b0bc72..c6ca392ece 100644
--- a/protocols/Gadu-Gadu/src/gg.h
+++ b/protocols/Gadu-Gadu/src/gg.h
@@ -156,14 +156,14 @@ struct GGGETAVATARDATA
#define GG_SEQ_CHINFO 400
// Services
-#define GGS_IMPORT_SERVER "%s/ImportFromServer"
-#define GGS_REMOVE_SERVER "%s/RemoveFromServer"
-#define GGS_IMPORT_TEXT "%s/ImportFromText"
-#define GGS_EXPORT_SERVER "%s/ExportFromServer"
-#define GGS_EXPORT_TEXT "%s/ExportFromText"
-
-#define GGS_SENDIMAGE "%s/SendImage"
-#define GGS_RECVIMAGE "%s/RecvImage"
+#define GGS_IMPORT_SERVER "/ImportFromServer"
+#define GGS_REMOVE_SERVER "/RemoveFromServer"
+#define GGS_IMPORT_TEXT "/ImportFromText"
+#define GGS_EXPORT_SERVER "/ExportFromServer"
+#define GGS_EXPORT_TEXT "/ExportFromText"
+
+#define GGS_SENDIMAGE "/SendImage"
+#define GGS_RECVIMAGE "/RecvImage"
// Keys
#define GG_PLUGINVERSION "Version" // Plugin version.. user for cleanup from previous versions
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index 22b2a5e57d..6642e2bb61 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -22,11 +22,10 @@
#include "gg.h"
GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) :
+ PROTO<GGPROTO>(pszProtoName, tszUserName),
avatar_requests(1, HandleKeySortT),
avatar_transfers(1, HandleKeySortT)
{
- ProtoConstructor(this, pszProtoName, tszUserName);
-
#ifdef DEBUGMODE
extendedLogging = 0;
#endif
@@ -52,16 +51,16 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) :
netlib = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
// Register services
- createProtoService(PS_GETAVATARCAPS, &GGPROTO::getavatarcaps);
- createProtoService(PS_GETAVATARINFOT, &GGPROTO::getavatarinfo);
- createProtoService(PS_GETMYAVATART, &GGPROTO::getmyavatar);
- createProtoService(PS_SETMYAVATART, &GGPROTO::setmyavatar);
+ CreateService(PS_GETAVATARCAPS, &GGPROTO::getavatarcaps);
+ CreateService(PS_GETAVATARINFOT, &GGPROTO::getavatarinfo);
+ CreateService(PS_GETMYAVATART, &GGPROTO::getmyavatar);
+ CreateService(PS_SETMYAVATART, &GGPROTO::setmyavatar);
- createProtoService(PS_GETMYAWAYMSG, &GGPROTO::getmyawaymsg);
- createProtoService(PS_SETAWAYMSGT, (GGServiceFunc)&GGPROTO::SetAwayMsg);
- createProtoService(PS_CREATEACCMGRUI, &GGPROTO::get_acc_mgr_gui);
+ CreateService(PS_GETMYAWAYMSG, &GGPROTO::getmyawaymsg);
+ CreateService(PS_SETAWAYMSGT, (MyServiceFunc)&GGPROTO::SetAwayMsg);
+ CreateService(PS_CREATEACCMGRUI, &GGPROTO::get_acc_mgr_gui);
- createProtoService(PS_LEAVECHAT, &GGPROTO::leavechat);
+ CreateService(PS_LEAVECHAT, &GGPROTO::leavechat);
// Offline contacts and clear logon time
setalloffline();
@@ -82,7 +81,6 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) :
links_instance_init();
initavatarrequestthread();
-
}
GGPROTO::~GGPROTO()
@@ -124,8 +122,6 @@ GGPROTO::~GGPROTO()
if (modemsg.freechat) mir_free(modemsg.freechat);
if (modemsg.invisible) mir_free(modemsg.invisible);
if (modemsg.offline) mir_free(modemsg.offline);
-
- ProtoDestructor(this);
}
//////////////////////////////////////////////////////////
@@ -212,9 +208,9 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType)
if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)))
{
#ifdef DEBUGMODE
- netlog("GetInfo(): forkthread 6 GGPROTO::cmdgetinfothread");
+ netlog("GetInfo(): ForkThread 6 GGPROTO::cmdgetinfothread");
#endif
- forkthread(&GGPROTO::cmdgetinfothread, hContact);
+ ForkThread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
@@ -230,9 +226,9 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType)
{
gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 1, "sess_mutex", 1);
#ifdef DEBUGMODE
- netlog("GetInfo(): forkthread 7 GGPROTO::cmdgetinfothread");
+ netlog("GetInfo(): ForkThread 7 GGPROTO::cmdgetinfothread");
#endif
- forkthread(&GGPROTO::cmdgetinfothread, hContact);
+ ForkThread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 2, "sess_mutex", 1);
@@ -244,9 +240,9 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType)
if (!(req = gg_pubdir50_new(GG_PUBDIR50_READ)))
{
#ifdef DEBUGMODE
- netlog("GetInfo(): forkthread 8 GGPROTO::cmdgetinfothread");
+ netlog("GetInfo(): ForkThread 8 GGPROTO::cmdgetinfothread");
#endif
- forkthread(&GGPROTO::cmdgetinfothread, hContact);
+ ForkThread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
@@ -261,9 +257,9 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType)
{
gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 49, 1, "sess_mutex", 1);
#ifdef DEBUGMODE
- netlog("GetInfo(): forkthread 9 GGPROTO::cmdgetinfothread");
+ netlog("GetInfo(): ForkThread 9 GGPROTO::cmdgetinfothread");
#endif
- forkthread(&GGPROTO::cmdgetinfothread, hContact);
+ ForkThread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 49, 2, "sess_mutex", 1);
@@ -296,9 +292,9 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id)
gg_pubdir50_t req;
if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH))) {
#ifdef DEBUGMODE
- netlog("SearchBasic(): forkthread 10 GGPROTO::searchthread");
+ netlog("SearchBasic(): ForkThread 10 GGPROTO::searchthread");
#endif
- forkthread(&GGPROTO::searchthread, NULL);
+ ForkThread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
@@ -315,9 +311,9 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id)
{
gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 1, "sess_mutex", 1);
#ifdef DEBUGMODE
- netlog("SearchBasic(): forkthread 11 GGPROTO::searchthread");
+ netlog("SearchBasic(): ForkThread 11 GGPROTO::searchthread");
#endif
- forkthread(&GGPROTO::searchthread, NULL);
+ ForkThread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 2, "sess_mutex", 1);
@@ -346,9 +342,9 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName,
if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)))
{
#ifdef DEBUGMODE
- netlog("SearchByName(): forkthread 12 GGPROTO::searchthread");
+ netlog("SearchByName(): ForkThread 12 GGPROTO::searchthread");
#endif
- forkthread(&GGPROTO::searchthread, NULL);
+ ForkThread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
@@ -394,9 +390,9 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName,
{
gg_LeaveCriticalSection(&sess_mutex, "SearchByName", 51, 1, "sess_mutex", 1);
#ifdef DEBUGMODE
- netlog("SearchByName(): forkthread 13 GGPROTO::searchthread");
+ netlog("SearchByName(): ForkThread 13 GGPROTO::searchthread");
#endif
- forkthread(&GGPROTO::searchthread, NULL);
+ ForkThread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
gg_LeaveCriticalSection(&sess_mutex, "SearchByName", 51, 2, "sess_mutex", 1);
@@ -422,9 +418,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)))
{
#ifdef DEBUGMODE
- netlog("SearchAdvanced(): forkthread 14 GGPROTO::searchthread");
+ netlog("SearchAdvanced(): ForkThread 14 GGPROTO::searchthread");
#endif
- forkthread(&GGPROTO::searchthread, NULL);
+ ForkThread(&GGPROTO::searchthread, NULL);
return (HWND)1;
}
@@ -540,9 +536,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg)
{
gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 1, "sess_mutex", 1);
#ifdef DEBUGMODE
- netlog("SearchAdvanced(): forkthread 15 GGPROTO::searchthread");
+ netlog("SearchAdvanced(): ForkThread 15 GGPROTO::searchthread");
#endif
- forkthread(&GGPROTO::searchthread, NULL);
+ ForkThread(&GGPROTO::searchthread, NULL);
return (HWND)1;
}
gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 2, "sess_mutex", 1);
@@ -637,9 +633,9 @@ int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg)
ack->seq = seq;
ack->hContact = hContact;
#ifdef DEBUGMODE
- netlog("SendMsg(): forkthread 16 GGPROTO::sendackthread");
+ netlog("SendMsg(): ForkThread 16 GGPROTO::sendackthread");
#endif
- forkthread(&GGPROTO::sendackthread, ack);
+ ForkThread(&GGPROTO::sendackthread, ack);
}
}
mir_free(msg_utf8);
@@ -700,9 +696,9 @@ void __cdecl GGPROTO::getawaymsgthread(void *hContact)
HANDLE GGPROTO::GetAwayMsg(HANDLE hContact)
{
#ifdef DEBUGMODE
- netlog("GetAwayMsg(): forkthread 17 GGPROTO::getawaymsgthread");
+ netlog("GetAwayMsg(): ForkThread 17 GGPROTO::getawaymsgthread");
#endif
- forkthread(&GGPROTO::getawaymsgthread, hContact);
+ ForkThread(&GGPROTO::getawaymsgthread, hContact);
return (HANDLE)1;
}
@@ -796,8 +792,8 @@ int GGPROTO::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
switch( eventType ) {
case EV_PROTO_ONLOAD:
{
- hookProtoEvent(ME_OPT_INITIALISE, &GGPROTO::options_init);
- hookProtoEvent(ME_USERINFO_INITIALISE, &GGPROTO::details_init);
+ HookEvent(ME_OPT_INITIALISE, &GGPROTO::options_init);
+ HookEvent(ME_USERINFO_INITIALISE, &GGPROTO::details_init);
// Init misc stuff
gg_icolib_init();
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index 5660ce1713..e6389f7266 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -22,12 +22,7 @@
#ifndef GGPROTO_H
#define GGPROTO_H
-struct GGPROTO;
-typedef void ( __cdecl GGPROTO::*GGThreadFunc )( void* );
-typedef int ( __cdecl GGPROTO::*GGEventFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl GGPROTO::*GGServiceFunc )( WPARAM, LPARAM );
-
-struct GGPROTO : public PROTO_INTERFACE
+struct GGPROTO : public PROTO<GGPROTO>
{
GGPROTO( const char*, const TCHAR* );
~GGPROTO();
@@ -106,8 +101,6 @@ struct GGPROTO : public PROTO_INTERFACE
void checknewuser(uin_t uin, const char* passwd);
/* Thread functions */
- void forkthread(GGThreadFunc pFunc, void *param);
- HANDLE forkthreadex(GGThreadFunc pFunc, void *param, UINT *threadId);
void threadwait(GGTHREAD *thread);
#ifdef DEBUGMODE
@@ -237,13 +230,6 @@ struct GGPROTO : public PROTO_INTERFACE
BOOL sessions_closedlg();
void sessions_menus_init(HGENMENU hRoot);
- /* Event helpers */
- void createObjService(const char* szService, GGServiceFunc serviceProc);
- void createProtoService(const char* szService, GGServiceFunc serviceProc);
- HANDLE hookProtoEvent(const char*, GGEventFunc);
- void forkThread(GGThreadFunc, void* );
- HANDLE forkThreadEx(GGThreadFunc, void*, UINT* threadID = NULL);
-
// Debug functions
int netlog(const char *fmt, ...);
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index b619ae97ac..542d35adc5 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -21,9 +21,9 @@
#include "gg.h"
#include "m_metacontacts.h"
-#define GG_GC_GETCHAT "%s/GCGetChat"
-#define GGS_OPEN_CONF "%s/OpenConf"
-#define GGS_CLEAR_IGNORED "%s/ClearIgnored"
+#define GG_GC_GETCHAT "/GCGetChat"
+#define GGS_OPEN_CONF "/OpenConf"
+#define GGS_CLEAR_IGNORED "/ClearIgnored"
////////////////////////////////////////////////////////////////////////////////
// Inits Gadu-Gadu groupchat module using chat.dll
@@ -44,7 +44,7 @@ int GGPROTO::gc_init()
gcr.ptszModuleDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
- hookProtoEvent(ME_GC_EVENT, &GGPROTO::gc_event);
+ HookEvent(ME_GC_EVENT, &GGPROTO::gc_event);
gc_enabled = TRUE;
// create & hook event
mir_snprintf(service, 64, GG_GC_GETCHAT, m_szModuleName);
@@ -69,8 +69,8 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot)
mi.hParentMenu = hRoot;
// Conferencing
- mir_snprintf(service, sizeof(service), GGS_OPEN_CONF, m_szModuleName);
- createObjService(service, &GGPROTO::gc_openconf);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_OPEN_CONF);
+ CreateService(GGS_OPEN_CONF, &GGPROTO::gc_openconf);
mi.position = 2000050001;
mi.icolibItem = iconList[14].hIcolib;
mi.ptszName = LPGENT("Open &conference...");
@@ -78,8 +78,8 @@ void GGPROTO::gc_menus_init(HGENMENU hRoot)
hMainMenu[0] = Menu_AddProtoMenuItem(&mi);
// Clear ignored conferences
- mir_snprintf(service, sizeof(service), GGS_CLEAR_IGNORED, m_szModuleName);
- createObjService(service, &GGPROTO::gc_clearignored);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_CLEAR_IGNORED);
+ CreateService(GGS_CLEAR_IGNORED, &GGPROTO::gc_clearignored);
mi.position = 2000050002;
mi.icolibItem = iconList[15].hIcolib;
mi.ptszName = LPGENT("&Clear ignored conferences");
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index 5a6b38d9b6..f970b9eb87 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -69,8 +69,8 @@ int gg_img_remove(GGIMAGEDLGDATA *dat);
int GGPROTO::img_init()
{
char service[64];
- mir_snprintf(service, sizeof(service), GGS_SENDIMAGE, m_szModuleName);
- createObjService(service, &GGPROTO::img_sendimg);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_SENDIMAGE);
+ CreateService(GGS_SENDIMAGE, &GGPROTO::img_sendimg);
// Send image contact menu item
CLISTMENUITEM mi = { sizeof(mi) };
@@ -83,9 +83,7 @@ int GGPROTO::img_init()
hImageMenuItem = Menu_AddContactMenuItem(&mi);
// Receive image
- mir_snprintf(service, sizeof(service), GGS_RECVIMAGE, m_szModuleName);
- createObjService(service, &GGPROTO::img_recvimage);
-
+ CreateService(GGS_RECVIMAGE, &GGPROTO::img_recvimage);
return FALSE;
}
@@ -744,9 +742,9 @@ GGIMAGEDLGDATA *gg_img_recvdlg(GGPROTO *gg, HANDLE hContact)
dat->gg = gg;
ResetEvent(dat->hEvent);
#ifdef DEBUGMODE
- gg->netlog("gg_img_recvdlg(): forkthread 18 GGPROTO::img_dlgcallthread");
+ gg->netlog("gg_img_recvdlg(): ForkThread 18 GGPROTO::img_dlgcallthread");
#endif
- gg->forkthread(&GGPROTO::img_dlgcallthread, dat);
+ gg->ForkThread(&GGPROTO::img_dlgcallthread, dat);
return dat;
}
@@ -1198,9 +1196,9 @@ INT_PTR GGPROTO::img_sendimg(WPARAM wParam, LPARAM lParam)
// Create new dialog
#ifdef DEBUGMODE
- netlog("img_sendimg(): forkthread 19 GGPROTO::img_dlgcallthread");
+ netlog("img_sendimg(): ForkThread 19 GGPROTO::img_dlgcallthread");
#endif
- forkthread(&GGPROTO::img_dlgcallthread, dat);
+ ForkThread(&GGPROTO::img_dlgcallthread, dat);
while (WaitForSingleObjectEx(dat->hEvent, INFINITE, TRUE) != WAIT_OBJECT_0);
CloseHandle(dat->hEvent);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 1e899588db..53623916ae 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -612,8 +612,8 @@ void GGPROTO::import_init(HGENMENU hRoot)
{
// Import from server item
char service[64];
- mir_snprintf(service, sizeof(service), GGS_IMPORT_SERVER, m_szModuleName);
- createObjService(service, &GGPROTO::import_server);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_IMPORT_SERVER);
+ CreateService(GGS_IMPORT_SERVER, &GGPROTO::import_server);
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
@@ -625,8 +625,8 @@ void GGPROTO::import_init(HGENMENU hRoot)
hMainMenu[2] = Menu_AddProtoMenuItem(&mi);
// Import from textfile
- mir_snprintf(service, sizeof(service), GGS_IMPORT_TEXT, m_szModuleName);
- createObjService(service, &GGPROTO::import_text);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_IMPORT_TEXT);
+ CreateService(GGS_IMPORT_TEXT, &GGPROTO::import_text);
mi.position = 2000500002;
mi.icolibItem = iconList[2].hIcolib;
@@ -635,8 +635,8 @@ void GGPROTO::import_init(HGENMENU hRoot)
hMainMenu[3] = Menu_AddProtoMenuItem(&mi);
// Remove from server
- mir_snprintf(service, sizeof(service), GGS_REMOVE_SERVER, m_szModuleName);
- createObjService(service, &GGPROTO::remove_server);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_REMOVE_SERVER);
+ CreateService(GGS_REMOVE_SERVER, &GGPROTO::remove_server);
mi.position = 2000500003;
mi.icolibItem = iconList[3].hIcolib;
@@ -645,8 +645,8 @@ void GGPROTO::import_init(HGENMENU hRoot)
hMainMenu[4] = Menu_AddProtoMenuItem(&mi);
// Export to server
- mir_snprintf(service, sizeof(service), GGS_EXPORT_SERVER, m_szModuleName);
- createObjService(service, &GGPROTO::export_server);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_EXPORT_SERVER);
+ CreateService(GGS_EXPORT_SERVER, &GGPROTO::export_server);
mi.position = 2005000001;
mi.icolibItem = iconList[4].hIcolib;
@@ -655,8 +655,8 @@ void GGPROTO::import_init(HGENMENU hRoot)
hMainMenu[5] = Menu_AddProtoMenuItem(&mi);
// Export to textfile
- mir_snprintf(service, sizeof(service), GGS_EXPORT_TEXT, m_szModuleName);
- createObjService(service, &GGPROTO::export_text);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_EXPORT_TEXT);
+ CreateService(GGS_EXPORT_TEXT, &GGPROTO::export_text);
mi.position = 2005000002;
mi.icolibItem = iconList[5].hIcolib;
diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp
index 4acf245682..908cc842c3 100644
--- a/protocols/Gadu-Gadu/src/ownerinfo.cpp
+++ b/protocols/Gadu-Gadu/src/ownerinfo.cpp
@@ -81,7 +81,7 @@ void GGPROTO::remindpassword(uin_t uin, const char *email)
rp->uin = uin;
rp->email = email;
#ifdef DEBUGMODE
- netlog("remindpassword(): forkthreadex 20 GGPROTO::remindpasswordthread");
+ netlog("remindpassword(): ForkThreadEx 20 GGPROTO::remindpasswordthread");
#endif
- forkthread(&GGPROTO::remindpasswordthread, rp);
+ ForkThread(&GGPROTO::remindpasswordthread, rp);
}
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp
index a22dbb69e2..e2560c557f 100644
--- a/protocols/Gadu-Gadu/src/services.cpp
+++ b/protocols/Gadu-Gadu/src/services.cpp
@@ -94,9 +94,9 @@ int GGPROTO::refreshstatus(int status)
threadwait(&pth_sess);
#ifdef DEBUGMODE
netlog("refreshstatus(): Waiting pth_sess thread - OK");
- netlog("refreshstatus(): forkthreadex 21 GGPROTO::mainthread");
+ netlog("refreshstatus(): ForkThreadEx 21 GGPROTO::mainthread");
#endif
- pth_sess.hThread = forkthreadex(&GGPROTO::mainthread, NULL, &pth_sess.dwThreadId);
+ pth_sess.hThread = ForkThreadEx(&GGPROTO::mainthread, NULL, &pth_sess.dwThreadId);
}
else
{
diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp
index 04836b80d4..7268d9fafc 100644
--- a/protocols/Gadu-Gadu/src/sessions.cpp
+++ b/protocols/Gadu-Gadu/src/sessions.cpp
@@ -20,7 +20,7 @@
#include "gg.h"
-#define GGS_CONCUR_SESS "%s/ConcurSess"
+#define GGS_CONCUR_SESS "/ConcurSess"
static void gg_clearsessionslist(HWND hwndDlg)
{
@@ -426,8 +426,8 @@ BOOL GGPROTO::sessions_closedlg()
void GGPROTO::sessions_menus_init(HGENMENU hRoot)
{
char service[64];
- mir_snprintf(service, sizeof(service), GGS_CONCUR_SESS, m_szModuleName);
- createObjService(service, &GGPROTO::sessions_view);
+ mir_snprintf(service, sizeof(service), "%s%s", m_szModuleName, GGS_CONCUR_SESS);
+ CreateService(service, &GGPROTO::sessions_view);
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp
index c00d615ad1..de73cb5e52 100644
--- a/protocols/Gadu-Gadu/src/userutils.cpp
+++ b/protocols/Gadu-Gadu/src/userutils.cpp
@@ -277,46 +277,6 @@ INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
//////////////////////////////////////////////////////////
-// Hooks protocol event
-
-HANDLE GGPROTO::hookProtoEvent(const char* szEvent, GGEventFunc handler)
-{
- return ::HookEventObj(szEvent, ( MIRANDAHOOKOBJ )*( void** )&handler, this);
-}
-
-//////////////////////////////////////////////////////////
-// Adds a new protocol specific service function
-
-void GGPROTO::createObjService(const char* szService, GGServiceFunc serviceProc)
-{
- CreateServiceFunctionObj(szService, (MIRANDASERVICEOBJ)*( void** )&serviceProc, this);
-}
-
-void GGPROTO::createProtoService(const char* szService, GGServiceFunc serviceProc)
-{
- char str[MAXMODULELABELLENGTH];
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*( void** )&serviceProc, this);
-}
-
-//////////////////////////////////////////////////////////
-// Forks a thread
-
-void GGPROTO::forkthread(GGThreadFunc pFunc, void *param)
-{
- UINT threadId;
- CloseHandle( mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, this, param, &threadId));
-}
-
-//////////////////////////////////////////////////////////
-// Forks a thread and returns a pseudo handle for it
-
-HANDLE GGPROTO::forkthreadex(GGThreadFunc pFunc, void *param, UINT *threadId)
-{
- return mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, this, param, threadId);
-}
-
-//////////////////////////////////////////////////////////
// Wait for thread to stop
void GGPROTO::threadwait(GGTHREAD *thread)
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index f5d73cfe71..345a0ff0e8 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -276,7 +276,7 @@ bool CIrcProto::OnIrc_WELCOME(const CIrcMessage* pmsg)
lstrcpyn( host, word.c_str(), SIZEOF(host));
TCHAR* p1 = _tcschr( host, '@' );
if ( p1 )
- ircFork( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(p1+1), IP_AUTO ));
+ ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(p1+1), IP_AUTO ));
}
word = GetWord(pmsg->parameters[1].c_str(), ++i);
@@ -2039,7 +2039,7 @@ bool CIrcProto::OnIrc_WHO_REPLY(const CIrcMessage* pmsg)
if ( lstrcmpi( pmsg->parameters[5].c_str(), m_info.sNick.c_str()) == 0 ) {
TCHAR host[1024];
lstrcpyn( host, pmsg->parameters[3].c_str(), 1024 );
- ircFork( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(host), IP_AUTO ));
+ ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( _T2A(host), IP_AUTO ));
} }
if ( command[0] == 'U' )
diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h
index d82b394a70..a7ba4ab3bf 100644
--- a/protocols/IRCG/src/irc.h
+++ b/protocols/IRCG/src/irc.h
@@ -195,12 +195,6 @@ using namespace irc;
/////////////////////////////////////////////////////////////////////////////////////////
-struct CIrcProto;
-typedef void ( __cdecl CIrcProto::*IrcThreadFunc )( void* param );
-typedef int ( __cdecl CIrcProto::*IrcEventFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CIrcProto::*IrcServiceFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CIrcProto::*IrcServiceFuncParam )( WPARAM, LPARAM, LPARAM );
-
typedef bool (CIrcProto::*PfnIrcMessageHandler)(const CIrcMessage* pmsg);
struct CIrcHandler
@@ -214,9 +208,9 @@ struct CIrcHandler
PfnIrcMessageHandler m_handler;
};
-struct CIrcProto : public PROTO_INTERFACE
+struct CIrcProto : public PROTO<CIrcProto>
{
- CIrcProto( const char*, const TCHAR* );
+ CIrcProto(const char*, const TCHAR*);
~CIrcProto();
// Protocol interface
@@ -483,12 +477,8 @@ struct CIrcProto : public PROTO_INTERFACE
void ConnectToServer(void);
void DisconnectFromServer(void);
void DoNetlibLog( const char* fmt, ... );
- void IrcHookEvent( const char*, IrcEventFunc );
void InitMainMenus(void);
- void ircFork( IrcThreadFunc, void* arg );
- HANDLE ircForkEx( IrcThreadFunc, void* arg );
-
UINT_PTR RetryTimer;
void __cdecl ConnectServerThread( void* );
@@ -498,11 +488,10 @@ struct CIrcProto : public PROTO_INTERFACE
void AddToJTemp(TCHAR op, CMString& sCommand);
bool AddWindowItemData(CMString window, const TCHAR* pszLimit, const TCHAR* pszMode, const TCHAR* pszPassword, const TCHAR* pszTopic);
INT_PTR CallChatEvent(WPARAM wParam, LPARAM lParam);
- void CreateProtoService( const char* serviceName, IrcServiceFunc pFunc );
INT_PTR DoEvent(int iEvent, const TCHAR* pszWindow, const TCHAR* pszNick, const TCHAR* pszText, const TCHAR* pszStatus, const TCHAR* pszUserInfo, DWORD_PTR dwItemData, bool bAddToLog, bool bIsMe,time_t timestamp = 1);
void FindLocalIP(HANDLE con);
bool FreeWindowItemData(CMString window, CHANNELINFO* wis);
- bool IsChannel(const char* sName);
+ bool IsChannel(const char* sName);
bool IsChannel(const TCHAR* sName);
void KillChatTimer(UINT_PTR &nIDEvent);
CMString MakeWndID(const TCHAR* sWindow);
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp
index 7314d726cf..78f30e729c 100644
--- a/protocols/IRCG/src/irclib.cpp
+++ b/protocols/IRCG/src/irclib.cpp
@@ -221,7 +221,7 @@ bool CIrcProto::Connect(const CIrcSessionInfo& info)
m_info = info;
// start receiving messages from host
- ircFork( &CIrcProto::ThreadProc, NULL );
+ ForkThread( &CIrcProto::ThreadProc, NULL );
Sleep( 100 );
if ( info.sPassword.GetLength())
NLSend( "PASS %s\r\n", info.sPassword.c_str());
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp
index de23f16b83..24028adc45 100644
--- a/protocols/IRCG/src/ircproto.cpp
+++ b/protocols/IRCG/src/ircproto.cpp
@@ -32,40 +32,39 @@ static int CompareSessions( const CDccSession* p1, const CDccSession* p2 )
}
CIrcProto::CIrcProto(const char* szModuleName, const TCHAR* tszUserName) :
+ PROTO<CIrcProto>(szModuleName, tszUserName),
m_dcc_chats( 10, CompareSessions ),
m_dcc_xfers( 10, CompareSessions ),
m_ignoreItems( 10 ),
vUserhostReasons( 10 ),
vWhoInProgress( 10 )
{
- ProtoConstructor(this, szModuleName, tszUserName);
-
InitializeCriticalSection(&cs);
InitializeCriticalSection(&m_gchook);
m_evWndCreate = ::CreateEvent( NULL, FALSE, FALSE, NULL );
- CreateProtoService( PS_GETMYAWAYMSG, &CIrcProto::GetMyAwayMsg );
-
- CreateProtoService( PS_CREATEACCMGRUI, &CIrcProto::SvcCreateAccMgrUI );
- CreateProtoService( PS_JOINCHAT, &CIrcProto::OnJoinChat );
- CreateProtoService( PS_LEAVECHAT, &CIrcProto::OnLeaveChat );
-
- CreateProtoService( IRC_JOINCHANNEL, &CIrcProto::OnJoinMenuCommand );
- CreateProtoService( IRC_QUICKCONNECT, &CIrcProto::OnQuickConnectMenuCommand);
- CreateProtoService( IRC_CHANGENICK, &CIrcProto::OnChangeNickMenuCommand );
- CreateProtoService( IRC_SHOWLIST, &CIrcProto::OnShowListMenuCommand );
- CreateProtoService( IRC_SHOWSERVER, &CIrcProto::OnShowServerMenuCommand );
- CreateProtoService( IRC_UM_CHANSETTINGS, &CIrcProto::OnMenuChanSettings );
- CreateProtoService( IRC_UM_WHOIS, &CIrcProto::OnMenuWhois );
- CreateProtoService( IRC_UM_DISCONNECT, &CIrcProto::OnMenuDisconnect );
- CreateProtoService( IRC_UM_IGNORE, &CIrcProto::OnMenuIgnore );
-
- CreateProtoService( "/DblClickEvent", &CIrcProto::OnDoubleclicked );
- CreateProtoService( "/InsertRawIn", &CIrcProto::Scripting_InsertRawIn );
- CreateProtoService( "/InsertRawOut", &CIrcProto::Scripting_InsertRawOut );
- CreateProtoService( "/InsertGuiIn", &CIrcProto::Scripting_InsertGuiIn );
- CreateProtoService( "/InsertGuiOut", &CIrcProto::Scripting_InsertGuiOut);
- CreateProtoService( "/GetIrcData", &CIrcProto::Scripting_GetIrcData);
+ CreateService( PS_GETMYAWAYMSG, &CIrcProto::GetMyAwayMsg );
+
+ CreateService( PS_CREATEACCMGRUI, &CIrcProto::SvcCreateAccMgrUI );
+ CreateService( PS_JOINCHAT, &CIrcProto::OnJoinChat );
+ CreateService( PS_LEAVECHAT, &CIrcProto::OnLeaveChat );
+
+ CreateService( IRC_JOINCHANNEL, &CIrcProto::OnJoinMenuCommand );
+ CreateService( IRC_QUICKCONNECT, &CIrcProto::OnQuickConnectMenuCommand);
+ CreateService( IRC_CHANGENICK, &CIrcProto::OnChangeNickMenuCommand );
+ CreateService( IRC_SHOWLIST, &CIrcProto::OnShowListMenuCommand );
+ CreateService( IRC_SHOWSERVER, &CIrcProto::OnShowServerMenuCommand );
+ CreateService( IRC_UM_CHANSETTINGS, &CIrcProto::OnMenuChanSettings );
+ CreateService( IRC_UM_WHOIS, &CIrcProto::OnMenuWhois );
+ CreateService( IRC_UM_DISCONNECT, &CIrcProto::OnMenuDisconnect );
+ CreateService( IRC_UM_IGNORE, &CIrcProto::OnMenuIgnore );
+
+ CreateService( "/DblClickEvent", &CIrcProto::OnDoubleclicked );
+ CreateService( "/InsertRawIn", &CIrcProto::Scripting_InsertRawIn );
+ CreateService( "/InsertRawOut", &CIrcProto::Scripting_InsertRawOut );
+ CreateService( "/InsertGuiIn", &CIrcProto::Scripting_InsertGuiIn );
+ CreateService( "/InsertGuiOut", &CIrcProto::Scripting_InsertGuiOut);
+ CreateService( "/GetIrcData", &CIrcProto::Scripting_GetIrcData);
codepage = CP_ACP;
InitializeCriticalSection(&m_resolve);
@@ -169,8 +168,6 @@ CIrcProto::~CIrcProto()
DeleteCriticalSection(&m_dcc);
KillChatTimer(OnlineNotifTimer);
KillChatTimer(OnlineNotifTimer3);
-
- ProtoDestructor(this);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -232,8 +229,8 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM )
gcr.ptszModuleDispName = m_tszUserName;
gcr.pszModule = m_szModuleName;
CallServiceSync( MS_GC_REGISTER, NULL, (LPARAM)&gcr );
- IrcHookEvent( ME_GC_EVENT, &CIrcProto::GCEventHook );
- IrcHookEvent( ME_GC_BUILDMENU, &CIrcProto::GCMenuHook );
+ HookEvent( ME_GC_EVENT, &CIrcProto::GCEventHook );
+ HookEvent( ME_GC_BUILDMENU, &CIrcProto::GCMenuHook );
GCSESSION gcw = { sizeof(GCSESSION) };
gcw.dwFlags = GC_TCHAR;
@@ -312,8 +309,8 @@ int CIrcProto::OnModulesLoaded( WPARAM, LPARAM )
InitIgnore();
- IrcHookEvent( ME_USERINFO_INITIALISE, &CIrcProto::OnInitUserInfo );
- IrcHookEvent( ME_OPT_INITIALISE, &CIrcProto::OnInitOptionsPages );
+ HookEvent( ME_USERINFO_INITIALISE, &CIrcProto::OnInitUserInfo );
+ HookEvent( ME_OPT_INITIALISE, &CIrcProto::OnInitOptionsPages );
if (m_nick[0]) {
TCHAR szBuf[ 40 ];
@@ -579,7 +576,7 @@ HANDLE __cdecl CIrcProto::SearchBasic( const PROTOCHAR* szId )
szId && szId[0] && !IsChannel(szId)) {
AckBasicSearchParam* param = new AckBasicSearchParam;
lstrcpyn( param->buf, szId, 50 );
- ircFork( &CIrcProto::AckBasicSearch, param );
+ ForkThread( &CIrcProto::AckBasicSearch, param );
return ( HANDLE )1;
} }
@@ -825,11 +822,11 @@ int __cdecl CIrcProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
BYTE bDcc = getByte(hContact, "DCC", 0);
WORD wStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
if (bDcc && wStatus != ID_STATUS_ONLINE) {
- ircFork(&CIrcProto::AckMessageFailDcc, hContact);
+ ForkThread(&CIrcProto::AckMessageFailDcc, hContact);
return 0;
}
if (!bDcc && (m_iStatus == ID_STATUS_OFFLINE || m_iStatus == ID_STATUS_CONNECTING)) {
- ircFork(&CIrcProto::AckMessageFail, hContact);
+ ForkThread(&CIrcProto::AckMessageFail, hContact);
return 0;
}
@@ -854,7 +851,7 @@ int __cdecl CIrcProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
mir_free(result);
int seq = InterlockedIncrement(&g_msgid);
- ircFork(&CIrcProto::AckMessageSuccess, new TFakeAckParam(hContact, seq));
+ ForkThread(&CIrcProto::AckMessageSuccess, new TFakeAckParam(hContact, seq));
return seq;
}
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index 3d200f4811..dc0f491e5e 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -955,7 +955,7 @@ void CCtcpPrefsDlg::OnApply()
m_ip.GetTextA( szTemp, sizeof( szTemp ));
lstrcpynA(m_proto->m_mySpecifiedHost, GetWord(szTemp, 0).c_str(), 499);
if ( lstrlenA( m_proto->m_mySpecifiedHost ))
- m_proto->ircFork( &CIrcProto::ResolveIPThread, new IPRESOLVE( m_proto->m_mySpecifiedHost, IP_MANUAL ));
+ m_proto->ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( m_proto->m_mySpecifiedHost, IP_MANUAL ));
}
else m_proto->m_mySpecifiedHost[0] = 0;
diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp
index 3bf3f885b0..7755fa84fb 100644
--- a/protocols/IRCG/src/services.cpp
+++ b/protocols/IRCG/src/services.cpp
@@ -1091,7 +1091,7 @@ void __cdecl CIrcProto::ConnectServerThread( void* )
KillChatTimer( RetryTimer );
if ( m_mySpecifiedHost[0] )
- ircFork( &CIrcProto::ResolveIPThread, new IPRESOLVE( m_mySpecifiedHost, IP_MANUAL ));
+ ForkThread( &CIrcProto::ResolveIPThread, new IPRESOLVE( m_mySpecifiedHost, IP_MANUAL ));
DoEvent(GC_EVENT_CHANGESESSIONAME, SERVERWINDOW, NULL, m_info.sNetwork.c_str(), NULL, NULL, NULL, FALSE, TRUE);
}
@@ -1151,7 +1151,7 @@ void CIrcProto::ConnectToServer(void)
sChannelModes = "btnimklps";
if (!m_bConnectThreadRunning)
- ircFork( &CIrcProto::ConnectServerThread, 0 );
+ ForkThread( &CIrcProto::ConnectServerThread, 0 );
else if (m_bConnectRequested < 1)
InterlockedIncrement((long *) &m_bConnectRequested);
@@ -1176,7 +1176,7 @@ void CIrcProto::DisconnectFromServer(void)
gce.pDest = &gcd;
CallChatEvent( SESSION_TERMINATE, (LPARAM)&gce);
- ircFork( &CIrcProto::DisconnectServerThread, 0 );
+ ForkThread( &CIrcProto::DisconnectServerThread, 0 );
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1214,7 +1214,7 @@ VOID CALLBACK RetryTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
ppro->DoEvent(GC_EVENT_INFORMATION, SERVERWINDOW, NULL, szTemp, NULL, NULL, NULL, true, false);
if ( !ppro->m_bConnectThreadRunning )
- ppro->ircFork( &CIrcProto::ConnectServerThread, 0 );
+ ppro->ForkThread( &CIrcProto::ConnectServerThread, 0 );
else
ppro->m_bConnectRequested = true;
diff --git a/protocols/IRCG/src/tools.cpp b/protocols/IRCG/src/tools.cpp
index b93d4ea498..0d12162854 100644
--- a/protocols/IRCG/src/tools.cpp
+++ b/protocols/IRCG/src/tools.cpp
@@ -132,23 +132,6 @@ void CIrcProto::AddToJTemp(TCHAR op, CMString& sCommand)
setTString("JTemp", res.c_str());
}
-void CIrcProto::ircFork( IrcThreadFunc pFunc, void* arg )
-{
- unsigned threadID;
- CloseHandle(( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner )( *( void** )&pFunc ), this, arg, &threadID ));
-}
-
-HANDLE CIrcProto::ircForkEx( IrcThreadFunc pFunc, void* arg )
-{
- unsigned threadID;
- return (HANDLE)::mir_forkthreadowner(( pThreadFuncOwner )( *( void** )&pFunc ), this, arg, &threadID );
-}
-
-void CIrcProto::IrcHookEvent( const char* szEvent, IrcEventFunc pFunc )
-{
- ::HookEventObj( szEvent, ( MIRANDAHOOKOBJ )*( void** )&pFunc, this );
-}
-
CMString __stdcall GetWord(const TCHAR* text, int index)
{
if ( text && *text ) {
@@ -791,13 +774,6 @@ bool CIrcProto::AddWindowItemData(CMString window, const TCHAR* pszLimit, const
return false;
}
-void CIrcProto::CreateProtoService( const char* serviceName, IrcServiceFunc pFunc )
-{
- char temp[MAXMODULELABELLENGTH];
- mir_snprintf( temp, sizeof(temp), "%s%s", m_szModuleName, serviceName );
- CreateServiceFunctionObj( temp, ( MIRANDASERVICEOBJ )*( void** )&pFunc, this );
-}
-
void CIrcProto::FindLocalIP(HANDLE con) // inspiration from jabber
{
// Determine local IP
diff --git a/protocols/IcqOscarJ/src/chan_05ping.cpp b/protocols/IcqOscarJ/src/chan_05ping.cpp
index 2a2b843509..cc28e5c185 100644
--- a/protocols/IcqOscarJ/src/chan_05ping.cpp
+++ b/protocols/IcqOscarJ/src/chan_05ping.cpp
@@ -78,7 +78,7 @@ void CIcqProto::StartKeepAlive(serverthread_info *info)
return;
if (getSettingByte(NULL, "KeepAlive", DEFAULT_KEEPALIVE_ENABLED))
- CloseHandle( ForkThreadEx(&CIcqProto::KeepAliveThread, info));
+ CloseHandle( ForkThreadEx(&CIcqProto::KeepAliveThread, info, 0));
}
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp
index 31581e8fdb..b323030be3 100644
--- a/protocols/IcqOscarJ/src/icq_avatar.cpp
+++ b/protocols/IcqOscarJ/src/icq_avatar.cpp
@@ -999,7 +999,7 @@ isLoggedIn(FALSE), stopThread(FALSE), isActive(FALSE)
m_ratesMutex = new icq_critical_section();
// Create connection thread
- ppro->ForkThread(( IcqThreadFunc )&CIcqProto::AvatarThread, this);
+ ppro->ForkThread((CIcqProto::MyThreadFunc)&CIcqProto::AvatarThread, this);
}
diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp
index ac016ba935..cfe357bc58 100644
--- a/protocols/IcqOscarJ/src/icq_direct.cpp
+++ b/protocols/IcqOscarJ/src/icq_direct.cpp
@@ -178,7 +178,7 @@ void icq_newConnectionReceived(HANDLE hNewConnection, DWORD dwRemoteIP, void *pE
{
// Start a new thread for the incomming connection
CIcqProto* ppro = (CIcqProto*)pExtra;
- ppro->ForkThread(( IcqThreadFunc )&CIcqProto::icq_directThread, CreateDTSI(NULL, hNewConnection, -1));
+ ppro->ForkThread((CIcqProto::MyThreadFunc)&CIcqProto::icq_directThread, CreateDTSI(NULL, hNewConnection, -1));
}
// Opens direct connection of specified type to specified contact
@@ -187,7 +187,7 @@ void CIcqProto::OpenDirectConnection(HANDLE hContact, int type, void* pvExtra)
// Create a new connection
directthreadstartinfo* dtsi = CreateDTSI(hContact, NULL, type);
dtsi->pvExtra = pvExtra;
- ForkThread(( IcqThreadFunc )&CIcqProto::icq_directThread, dtsi);
+ ForkThread((MyThreadFunc)&CIcqProto::icq_directThread, dtsi);
}
// Safely close NetLib connection - do not corrupt direct connection list
diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
index 257256fd1f..cf61c3ea3d 100644
--- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp
+++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
@@ -46,7 +46,7 @@ void CIcqProto::icq_InitInfoUpdate(void)
m_infoUpdateList[i].queued = 0;
}
- CloseHandle( ForkThreadEx( &CIcqProto::InfoUpdateThread, NULL));
+ ForkThread(&CIcqProto::InfoUpdateThread, 0);
}
bInfoPendingUsers = 0;
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp
index f25d21827a..cb5ee9948e 100644
--- a/protocols/IcqOscarJ/src/icq_proto.cpp
+++ b/protocols/IcqOscarJ/src/icq_proto.cpp
@@ -71,14 +71,13 @@ static int CompareContactsCache(const icq_contacts_cache *p1, const icq_contacts
}
CIcqProto::CIcqProto( const char* aProtoName, const TCHAR* aUserName ) :
+ PROTO<CIcqProto>(aProtoName, aUserName),
cookies(10, CompareCookies),
directConns(10, CompareConns),
expectedFileRecvs(10, CompareFT),
contactsCache(10, CompareContactsCache),
- cheekySearchId( -1 )
+ cheekySearchId(-1)
{
- ProtoConstructor(this, aProtoName, aUserName);
-
NetLog_Server( "Setting protocol/module name to '%s'", m_szModuleName );
oftMutex = new icq_critical_section();
@@ -90,7 +89,7 @@ CIcqProto::CIcqProto( const char* aProtoName, const TCHAR* aUserName ) :
// Initialize server lists
servlistMutex = new icq_critical_section();
servlistQueueMutex = new icq_critical_section();
- HookProtoEvent(ME_CLIST_GROUPCHANGE, &CIcqProto::ServListCListGroupChange);
+ HookEvent(ME_CLIST_GROUPCHANGE, &CIcqProto::ServListCListGroupChange);
// Initialize status message struct
ZeroMemory(&m_modeMsgs, sizeof(icq_mode_messages));
@@ -98,7 +97,7 @@ CIcqProto::CIcqProto( const char* aProtoName, const TCHAR* aUserName ) :
connectionHandleMutex = new icq_critical_section();
localSeqMutex = new icq_critical_section();
- m_modeMsgsEvent = CreateProtoEvent(ME_ICQ_STATUSMSGREQ);
+ m_modeMsgsEvent = CreateHookableEvent(ME_ICQ_STATUSMSGREQ);
// Initialize cookies
cookieMutex = new icq_critical_section();
@@ -123,42 +122,42 @@ CIcqProto::CIcqProto( const char* aProtoName, const TCHAR* aUserName ) :
db_set_resident(m_szModuleName, DBSETTING_STATUS_MOOD);
// Setup services
- CreateProtoService(PS_CREATEACCMGRUI, &CIcqProto::OnCreateAccMgrUI );
- CreateProtoService(MS_ICQ_SENDSMS, &CIcqProto::SendSms);
- CreateProtoService(PS_SET_NICKNAME, &CIcqProto::SetNickName);
+ CreateService(PS_CREATEACCMGRUI, &CIcqProto::OnCreateAccMgrUI );
+ CreateService(MS_ICQ_SENDSMS, &CIcqProto::SendSms);
+ CreateService(PS_SET_NICKNAME, &CIcqProto::SetNickName);
- CreateProtoService(PS_GETMYAWAYMSG, &CIcqProto::GetMyAwayMsg);
+ CreateService(PS_GETMYAWAYMSG, &CIcqProto::GetMyAwayMsg);
- CreateProtoService(PS_GETINFOSETTING, &CIcqProto::GetInfoSetting);
+ CreateService(PS_GETINFOSETTING, &CIcqProto::GetInfoSetting);
- CreateProtoService(PSS_ADDED, &CIcqProto::SendYouWereAdded);
+ CreateService(PSS_ADDED, &CIcqProto::SendYouWereAdded);
// Session password API
- CreateProtoService(PS_ICQ_SETPASSWORD, &CIcqProto::SetPassword);
+ CreateService(PS_ICQ_SETPASSWORD, &CIcqProto::SetPassword);
// ChangeInfo API
- CreateProtoService(PS_CHANGEINFOEX, &CIcqProto::ChangeInfoEx);
+ CreateService(PS_CHANGEINFOEX, &CIcqProto::ChangeInfoEx);
// Avatar API
- CreateProtoService(PS_GETAVATARINFOT, &CIcqProto::GetAvatarInfo);
- CreateProtoService(PS_GETAVATARCAPS, &CIcqProto::GetAvatarCaps);
- CreateProtoService(PS_GETMYAVATART, &CIcqProto::GetMyAvatar);
- CreateProtoService(PS_SETMYAVATART, &CIcqProto::SetMyAvatar);
+ CreateService(PS_GETAVATARINFOT, &CIcqProto::GetAvatarInfo);
+ CreateService(PS_GETAVATARCAPS, &CIcqProto::GetAvatarCaps);
+ CreateService(PS_GETMYAVATART, &CIcqProto::GetMyAvatar);
+ CreateService(PS_SETMYAVATART, &CIcqProto::SetMyAvatar);
// Custom Status API
- CreateProtoService(PS_SETCUSTOMSTATUSEX, &CIcqProto::SetXStatusEx);
- CreateProtoService(PS_GETCUSTOMSTATUSEX, &CIcqProto::GetXStatusEx);
- CreateProtoService(PS_GETCUSTOMSTATUSICON, &CIcqProto::GetXStatusIcon);
- CreateProtoService(PS_GETADVANCEDSTATUSICON, &CIcqProto::RequestAdvStatusIconIdx);
- CreateProtoService(PS_ICQ_REQUESTCUSTOMSTATUS, &CIcqProto::RequestXStatusDetails);
+ CreateService(PS_SETCUSTOMSTATUSEX, &CIcqProto::SetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSEX, &CIcqProto::GetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSICON, &CIcqProto::GetXStatusIcon);
+ CreateService(PS_GETADVANCEDSTATUSICON, &CIcqProto::RequestAdvStatusIconIdx);
+ CreateService(PS_ICQ_REQUESTCUSTOMSTATUS, &CIcqProto::RequestXStatusDetails);
- CreateProtoService(MS_ICQ_ADDSERVCONTACT, &CIcqProto::AddServerContact);
+ CreateService(MS_ICQ_ADDSERVCONTACT, &CIcqProto::AddServerContact);
- CreateProtoService(MS_REQ_AUTH, &CIcqProto::RequestAuthorization);
- CreateProtoService(MS_GRANT_AUTH, &CIcqProto::GrantAuthorization);
- CreateProtoService(MS_REVOKE_AUTH, &CIcqProto::RevokeAuthorization);
+ CreateService(MS_REQ_AUTH, &CIcqProto::RequestAuthorization);
+ CreateService(MS_GRANT_AUTH, &CIcqProto::GrantAuthorization);
+ CreateService(MS_REVOKE_AUTH, &CIcqProto::RevokeAuthorization);
- CreateProtoService(MS_XSTATUS_SHOWDETAILS, &CIcqProto::ShowXStatusDetails);
+ CreateService(MS_XSTATUS_SHOWDETAILS, &CIcqProto::ShowXStatusDetails);
// Custom caps
- CreateProtoService(PS_ICQ_ADDCAPABILITY, &CIcqProto::IcqAddCapability);
- CreateProtoService(PS_ICQ_CHECKCAPABILITY, &CIcqProto::IcqCheckCapability);
+ CreateService(PS_ICQ_ADDCAPABILITY, &CIcqProto::IcqAddCapability);
+ CreateService(PS_ICQ_CHECKCAPABILITY, &CIcqProto::IcqCheckCapability);
// Reset a bunch of session specific settings
UpdateGlobalSettings();
@@ -170,7 +169,7 @@ CIcqProto::CIcqProto( const char* aProtoName, const TCHAR* aUserName ) :
// Startup Auto Info-Update thread
icq_InitInfoUpdate();
- HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &CIcqProto::OnPreBuildStatusMenu);
+ HookEvent(ME_CLIST_PREBUILDSTATUSMENU, &CIcqProto::OnPreBuildStatusMenu);
// Register netlib users
NETLIBUSER nlu = {0};
@@ -265,14 +264,11 @@ CIcqProto::~CIcqProto()
SAFE_FREE(&m_modeMsgs.szFfc);
NetLog_Server("%s: Protocol instance '%s' destroyed.", ICQ_PROTOCOL_NAME, m_szModuleName);
- ProtoDestructor(this);
}
-
////////////////////////////////////////////////////////////////////////////////////////
// OnModulesLoadedEx - performs hook registration
-
int CIcqProto::OnModulesLoaded( WPARAM wParam, LPARAM lParam )
{
char pszP2PName[MAX_PATH];
@@ -289,9 +285,9 @@ int CIcqProto::OnModulesLoaded( WPARAM wParam, LPARAM lParam )
modules[3] = pszSrvGroupsName;
CallService("DBEditorpp/RegisterModule",(WPARAM)modules,(LPARAM)4);
- HookProtoEvent(ME_OPT_INITIALISE, &CIcqProto::OnOptionsInit);
- HookProtoEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit);
- HookProtoEvent(ME_IDLE_CHANGED, &CIcqProto::OnIdleChanged);
+ HookEvent(ME_OPT_INITIALISE, &CIcqProto::OnOptionsInit);
+ HookEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit);
+ HookEvent(ME_IDLE_CHANGED, &CIcqProto::OnIdleChanged);
InitAvatars();
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h
index 5b322f929d..81a4c5755e 100644
--- a/protocols/IcqOscarJ/src/icq_proto.h
+++ b/protocols/IcqOscarJ/src/icq_proto.h
@@ -37,23 +37,17 @@
#define XSTATUS_COUNT 86
-struct CIcqProto;
-typedef void ( __cdecl CIcqProto::*IcqThreadFunc )( void* );
-typedef int ( __cdecl CIcqProto::*IcqEventFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CIcqProto::*IcqServiceFunc )( WPARAM, LPARAM );
-typedef INT_PTR ( __cdecl CIcqProto::*IcqServiceFuncParam )( WPARAM, LPARAM, LPARAM );
-
// for InfoUpdate
struct userinfo
{
- DWORD dwUin;
+ DWORD dwUin;
HANDLE hContact;
- time_t queued;
+ time_t queued;
};
-struct CIcqProto : public PROTO_INTERFACE
+struct CIcqProto : public PROTO<CIcqProto>
{
- CIcqProto( const char*, const TCHAR* );
+ CIcqProto(const char*, const TCHAR*);
~CIcqProto();
//====================================================================================
@@ -898,17 +892,9 @@ struct CIcqProto : public PROTO_INTERFACE
DWORD ReportGenericSendError(HANDLE hContact, int nType, const char* szErrorMsg);
void SetCurrentStatus(int nStatus);
- void ForkThread( IcqThreadFunc pFunc, void* arg );
- HANDLE ForkThreadEx( IcqThreadFunc pFunc, void* arg, UINT* threadID = NULL );
-
void __cdecl ProtocolAckThread(icq_ack_args* pArguments);
void SendProtoAck(HANDLE hContact, DWORD dwCookie, int nAckResult, int nAckType, char* pszMessage);
- HANDLE CreateProtoEvent(const char* szEvent);
- void CreateProtoService(const char* szService, IcqServiceFunc serviceProc);
- void CreateProtoServiceParam(const char* szService, IcqServiceFuncParam serviceProc, LPARAM lParam);
- HANDLE HookProtoEvent(const char* szEvent, IcqEventFunc pFunc);
-
int NetLog_Server(const char *fmt,...);
int NetLog_Direct(const char *fmt,...);
int NetLog_Uni(BOOL bDC, const char *fmt,...);
diff --git a/protocols/IcqOscarJ/src/icq_rates.cpp b/protocols/IcqOscarJ/src/icq_rates.cpp
index 55ac226d31..e2c5734049 100644
--- a/protocols/IcqOscarJ/src/icq_rates.cpp
+++ b/protocols/IcqOscarJ/src/icq_rates.cpp
@@ -365,7 +365,7 @@ void rates_queue::initDelay(int nDelay, IcqRateFunc delaycode)
pArgs->nDelay = nDelay;
pArgs->delaycode = delaycode;
- ppro->ForkThread((IcqThreadFunc)&CIcqProto::rateDelayThread, pArgs);
+ ppro->ForkThread((CIcqProto::MyThreadFunc)&CIcqProto::rateDelayThread, pArgs);
}
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp
index 1b4e48e804..cb02eec4ad 100644
--- a/protocols/IcqOscarJ/src/icq_server.cpp
+++ b/protocols/IcqOscarJ/src/icq_server.cpp
@@ -385,7 +385,7 @@ void CIcqProto::sendServPacketAsync(icq_packet *packet)
pPacket = (icq_packet*)SAFE_MALLOC(sizeof(icq_packet)); // This will be freed in the new thread
memcpy(pPacket, packet, sizeof(icq_packet));
- ForkThread(( IcqThreadFunc )&CIcqProto::SendPacketAsyncThread, pPacket);
+ ForkThread((MyThreadFunc)&CIcqProto::SendPacketAsyncThread, pPacket);
}
@@ -438,5 +438,5 @@ void CIcqProto::icq_login(const char* szPassword)
// Initialize members
m_avatarsConnectionPending = TRUE;
- serverThreadHandle = ForkThreadEx(( IcqThreadFunc )&CIcqProto::ServerThread, stsi, &serverThreadId);
+ serverThreadHandle = ForkThreadEx((MyThreadFunc)&CIcqProto::ServerThread, stsi, &serverThreadId);
}
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp
index ac9667618e..19f029f6ff 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.cpp
+++ b/protocols/IcqOscarJ/src/icq_servlist.cpp
@@ -334,7 +334,7 @@ void CIcqProto::servlistQueueAddGroupItem(servlistgroupitem* pGroupItem, int dwT
if (!servlistQueueThreadHandle)
{
// create new board thread
- servlistQueueThreadHandle = ForkThreadEx( &CIcqProto::servlistQueueThread, &servlistQueueState );
+ servlistQueueThreadHandle = ForkThreadEx(&CIcqProto::servlistQueueThread, &servlistQueueState, 0);
}
else // signal thread, that queue was changed during sleep
servlistQueueState = TRUE;
@@ -444,7 +444,7 @@ void CIcqProto::servlistProcessLogin()
// if the server-list queue contains items and thread is not running, start it
if (servlistQueueCount && !servlistQueueThreadHandle)
- servlistQueueThreadHandle = ForkThreadEx( &CIcqProto::servlistQueueThread, &servlistQueueState );
+ servlistQueueThreadHandle = ForkThreadEx(&CIcqProto::servlistQueueThread, &servlistQueueState, 0);
}
// HERE ENDS SERVER-LIST UPDATE BOARD IMPLEMENTATION //
diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp
index 4453ab2884..59da80a08d 100644
--- a/protocols/IcqOscarJ/src/icq_xstatus.cpp
+++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp
@@ -871,7 +871,7 @@ void CIcqProto::InitXStatusItems(BOOL bAllowStatus)
bXStatusMenuBuilt = ServiceExists(srvFce);
if (!bXStatusMenuBuilt)
- CreateProtoServiceParam(srvFce+len, &CIcqProto::menuXStatus, i);
+ CreateServiceParam(srvFce+len, &CIcqProto::menuXStatus, i);
mi.flags = (bXStatus == i ? CMIF_CHECKED : 0);
mi.icolibItem = i ? hXStatusIcons[i-1] : NULL;
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
index 479002e2ab..b0f42a826d 100644
--- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
@@ -809,7 +809,7 @@ static void oft_newConnectionReceived(HANDLE hNewConnection, DWORD dwRemoteIP, v
otsi->listener = listener;
// Start a new thread for the incomming connection
- listener->ppro->ForkThread(( IcqThreadFunc )&CIcqProto::oft_connectionThread, otsi );
+ listener->ppro->ForkThread((CIcqProto::MyThreadFunc)&CIcqProto::oft_connectionThread, otsi );
}
@@ -1241,7 +1241,7 @@ void CIcqProto::OpenOscarConnection(HANDLE hContact, oscar_filetransfer *ft, int
otsi->type = type;
otsi->ft = ft;
- ForkThread(( IcqThreadFunc )&CIcqProto::oft_connectionThread, otsi );
+ ForkThread((MyThreadFunc)&CIcqProto::oft_connectionThread, otsi );
}
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index 593fa6408c..99d9b690dc 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -1082,7 +1082,7 @@ void CIcqProto::SendProtoAck(HANDLE hContact, DWORD dwCookie, int nAckResult, in
pArgs->nAckType = nAckType;
pArgs->pszMessage = (LPARAM)null_strdup(pszMessage);
- ForkThread(( IcqThreadFunc )&CIcqProto::ProtocolAckThread, pArgs );
+ ForkThread((MyThreadFunc)&CIcqProto::ProtocolAckThread, pArgs );
}
void CIcqProto::SetCurrentStatus(int nStatus)
@@ -1829,17 +1829,6 @@ char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsiz
return buf;
}
-void CIcqProto::ForkThread( IcqThreadFunc pFunc, void* arg )
-{
- CloseHandle(( HANDLE )mir_forkthreadowner(( pThreadFuncOwner )*( void** )&pFunc, this, arg, NULL ));
-}
-
-HANDLE CIcqProto::ForkThreadEx( IcqThreadFunc pFunc, void* arg, UINT* threadID )
-{
- return ( HANDLE )mir_forkthreadowner(( pThreadFuncOwner )*( void** )&pFunc, this, arg, threadID );
-}
-
-
char* CIcqProto::GetUserStoredPassword(char *szBuffer, int cbSize)
{
if (!getSettingStringStatic(NULL, "Password", szBuffer, cbSize))
@@ -2117,36 +2106,3 @@ DWORD CIcqProto::ReportGenericSendError(HANDLE hContact, int nType, const char*
SendProtoAck(hContact, dwCookie, ACKRESULT_FAILED, nType, Translate(szErrorMsg));
return dwCookie;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CIcqProto::CreateProtoService(const char* szService, IcqServiceFunc serviceProc)
-{
- char temp[MAX_PATH*2];
-
- null_snprintf(temp, sizeof(temp), "%s%s", m_szModuleName, szService);
- CreateServiceFunctionObj( temp, ( MIRANDASERVICEOBJ )*( void** )&serviceProc, this );
-}
-
-void CIcqProto::CreateProtoServiceParam(const char* szService, IcqServiceFuncParam serviceProc, LPARAM lParam)
-{
- char temp[MAX_PATH*2];
-
- null_snprintf(temp, sizeof(temp), "%s%s", m_szModuleName, szService);
- CreateServiceFunctionObjParam( temp, ( MIRANDASERVICEOBJPARAM )*( void** )&serviceProc, this, lParam );
-}
-
-
-HANDLE CIcqProto::HookProtoEvent(const char* szEvent, IcqEventFunc pFunc)
-{
- return ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&pFunc, this);
-}
-
-
-HANDLE CIcqProto::CreateProtoEvent(const char* szEvent)
-{
- char str[MAX_PATH + 32];
- strcpy(str, m_szModuleName);
- strcat(str, szEvent);
- return CreateHookableEvent(str);
-}
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp
index fa7174a4ec..75b650b068 100644
--- a/protocols/JabberG/src/jabber_console.cpp
+++ b/protocols/JabberG/src/jabber_console.cpp
@@ -687,7 +687,7 @@ void CJabberProto::ConsoleInit()
{
LoadLibraryA("riched20.dll");
InitializeCriticalSection(&m_filterInfo.csPatternLock);
- m_hThreadConsole = JForkThreadEx(&CJabberProto::ConsoleThread, 0, &m_dwConsoleThreadId);
+ m_hThreadConsole = ForkThreadEx(&CJabberProto::ConsoleThread, 0, &m_dwConsoleThreadId);
}
void CJabberProto::ConsoleUninit()
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index b6075c4867..9f32f62e2b 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -155,7 +155,7 @@ void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo* pInfo)
jbt->ft = ft;
ft->type = FT_BYTESTREAM;
ft->jbt = jbt;
- JForkThread((JThreadFunc)&CJabberProto::ByteSendThread, jbt);
+ ForkThread((MyThreadFunc)&CJabberProto::ByteSendThread, jbt);
} else if ( !_tcscmp(xmlGetText(valueNode), _T(JABBER_FEAT_IBB))) {
JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *) mir_alloc(sizeof (JABBER_IBB_TRANSFER));
ZeroMemory(jibb, sizeof(JABBER_IBB_TRANSFER));
@@ -167,7 +167,7 @@ void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo* pInfo)
jibb->ft = ft;
ft->type = FT_IBB;
ft->jibb = jibb;
- JForkThread((JThreadFunc)&CJabberProto::IbbSendThread, jibb);
+ ForkThread((MyThreadFunc)&CJabberProto::IbbSendThread, jibb);
} } } } } } }
else {
Log("File transfer stream initiation request denied or failed");
@@ -443,7 +443,7 @@ BOOL CJabberProto::FtHandleBytestreamRequest(HXML iqNode, CJabberIqInfo* pInfo)
jbt->pfnFinal = &CJabberProto::FtReceiveFinal;
jbt->ft = item->ft;
item->ft->jbt = jbt;
- JForkThread((JThreadFunc)&CJabberProto::ByteReceiveThread, jbt);
+ ForkThread((MyThreadFunc)&CJabberProto::ByteReceiveThread, jbt);
ListRemove(LIST_FTRECV, sid);
return TRUE;
}
@@ -490,7 +490,7 @@ BOOL CJabberProto::FtHandleIbbRequest(HXML iqNode, BOOL bOpen)
jibb->ft = item->ft;
item->ft->jibb = jibb;
item->jibb = jibb;
- JForkThread((JThreadFunc)&CJabberProto::IbbReceiveThread, jibb);
+ ForkThread((MyThreadFunc)&CJabberProto::IbbReceiveThread, jibb);
m_ThreadInfo->send( XmlNodeIq(_T("result"), id, from));
return TRUE;
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 2255c2bcc0..beea8f4e69 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -1345,7 +1345,7 @@ void CJabberProto::GroupchatProcessInvite(const TCHAR *roomJid, const TCHAR *fro
inviteInfo->from = mir_tstrdup(from);
inviteInfo->reason = mir_tstrdup(reason);
inviteInfo->password = mir_tstrdup(password);
- JForkThread((JThreadFunc)&CJabberProto::GroupchatInviteAcceptThread, inviteInfo);
+ ForkThread((MyThreadFunc)&CJabberProto::GroupchatInviteAcceptThread, inviteInfo);
}
else {
TCHAR* myNick = JabberNickFromJID(m_szJabberJID);
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index 6be5980c54..bfe570201e 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -183,7 +183,7 @@ BOOL CJabberIqManager::Start()
if (m_hExpirerThread || m_bExpirerThreadShutdownRequest)
return FALSE;
- m_hExpirerThread = ppro->JForkThreadEx(&CJabberProto::ExpirerThread, this);
+ m_hExpirerThread = ppro->ForkThreadEx(&CJabberProto::ExpirerThread, this, 0);
if ( !m_hExpirerThread)
return FALSE;
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 85eda703ff..e81d74ea2a 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -525,7 +525,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
}
if (httpavatars->getCount())
- JForkThread(&CJabberProto::LoadHttpAvatars, httpavatars);
+ ForkThread(&CJabberProto::LoadHttpAvatars, httpavatars);
else
delete httpavatars;
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 5ae47f809b..5f4cb29764 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -448,7 +448,7 @@ int CJabberProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
for (int i = 0; i < nMenuResourceItemsNew; i++) {
mir_snprintf(tDest, SIZEOF(text) - nModuleNameLength, "/UseResource_%d", i);
if (i >= m_nMenuResourceItems) {
- JCreateServiceParam(tDest, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES+i);
+ CreateServiceParam(tDest, &CJabberProto::OnMenuHandleResource, MENUITEM_RESOURCES+i);
mi.pszName = "";
mi.position = i;
mi.hParentMenu = g_hMenuResourcesRoot;
@@ -680,7 +680,7 @@ void CJabberProto::MenuInit()
}
// "Bookmarks..."
- JCreateService("/Bookmarks", &CJabberProto::OnMenuHandleBookmarks);
+ CreateService("/Bookmarks", &CJabberProto::OnMenuHandleBookmarks);
strcpy(tDest, "/Bookmarks");
mi.flags = CMIF_CHILDPOPUP;
mi.hParentMenu = hJabberRoot;
@@ -690,7 +690,7 @@ void CJabberProto::MenuInit()
m_hMenuBookmarks = Menu_AddProtoMenuItem(&mi);
// "Options..."
- JCreateService("/Options", &CJabberProto::OnMenuOptions);
+ CreateService("/Options", &CJabberProto::OnMenuOptions);
strcpy(tDest, "/Options");
mi.pszName = LPGEN("Options...");
mi.position = 200002;
@@ -705,7 +705,7 @@ void CJabberProto::MenuInit()
HGENMENU hMenuServicesRoot = Menu_AddProtoMenuItem(&mi);
// "Service Discovery..."
- JCreateService("/ServiceDiscovery", &CJabberProto::OnMenuHandleServiceDiscovery);
+ CreateService("/ServiceDiscovery", &CJabberProto::OnMenuHandleServiceDiscovery);
strcpy(tDest, "/ServiceDiscovery");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Service Discovery");
@@ -714,28 +714,28 @@ void CJabberProto::MenuInit()
mi.hParentMenu = hMenuServicesRoot;
m_hMenuServiceDiscovery = Menu_AddProtoMenuItem(&mi);
- JCreateService("/SD/MyTransports", &CJabberProto::OnMenuHandleServiceDiscoveryMyTransports);
+ CreateService("/SD/MyTransports", &CJabberProto::OnMenuHandleServiceDiscoveryMyTransports);
strcpy(tDest, "/SD/MyTransports");
mi.pszName = LPGEN("Registered Transports");
mi.position = 2000050003;
mi.icolibItem = GetIconHandle(IDI_TRANSPORTL);
m_hMenuSDMyTransports = Menu_AddProtoMenuItem(&mi);
- JCreateService("/SD/Transports", &CJabberProto::OnMenuHandleServiceDiscoveryTransports);
+ CreateService("/SD/Transports", &CJabberProto::OnMenuHandleServiceDiscoveryTransports);
strcpy(tDest, "/SD/Transports");
mi.pszName = LPGEN("Local Server Transports");
mi.position = 2000050004;
mi.icolibItem = GetIconHandle(IDI_TRANSPORT);
m_hMenuSDTransports = Menu_AddProtoMenuItem(&mi);
- JCreateService("/SD/Conferences", &CJabberProto::OnMenuHandleServiceDiscoveryConferences);
+ CreateService("/SD/Conferences", &CJabberProto::OnMenuHandleServiceDiscoveryConferences);
strcpy(tDest, "/SD/Conferences");
mi.pszName = LPGEN("Browse Chatrooms");
mi.position = 2000050005;
mi.icolibItem = GetIconHandle(IDI_GROUP);
m_hMenuSDConferences = Menu_AddProtoMenuItem(&mi);
- JCreateService("/Groupchat", &CJabberProto::OnMenuHandleJoinGroupchat);
+ CreateService("/Groupchat", &CJabberProto::OnMenuHandleJoinGroupchat);
strcpy(tDest, "/Groupchat");
mi.pszName = LPGEN("Create/Join groupchat");
mi.position = 2000050006;
@@ -743,7 +743,7 @@ void CJabberProto::MenuInit()
m_hMenuGroupchat = Menu_AddProtoMenuItem(&mi);
// "Change Password..."
- JCreateService("/ChangePassword", &CJabberProto::OnMenuHandleChangePassword);
+ CreateService("/ChangePassword", &CJabberProto::OnMenuHandleChangePassword);
strcpy(tDest, "/ChangePassword");
mi.pszName = LPGEN("Change Password");
mi.position = 2000050007;
@@ -751,7 +751,7 @@ void CJabberProto::MenuInit()
m_hMenuChangePassword = Menu_AddProtoMenuItem(&mi);
// "Roster editor"
- JCreateService("/RosterEditor", &CJabberProto::OnMenuHandleRosterControl);
+ CreateService("/RosterEditor", &CJabberProto::OnMenuHandleRosterControl);
strcpy(tDest, "/RosterEditor");
mi.pszName = LPGEN("Roster editor");
mi.position = 2000050009;
@@ -759,14 +759,14 @@ void CJabberProto::MenuInit()
m_hMenuRosterControl = Menu_AddProtoMenuItem(&mi);
// "XML Console"
- JCreateService("/XMLConsole", &CJabberProto::OnMenuHandleConsole);
+ CreateService("/XMLConsole", &CJabberProto::OnMenuHandleConsole);
strcpy(tDest, "/XMLConsole");
mi.pszName = LPGEN("XML Console");
mi.position = 2000050010;
mi.icolibItem = GetIconHandle(IDI_CONSOLE);
Menu_AddProtoMenuItem(&mi);
- JCreateService("/Notes", &CJabberProto::OnMenuHandleNotes);
+ CreateService("/Notes", &CJabberProto::OnMenuHandleNotes);
strcpy(tDest, "/Notes");
mi.pszName = LPGEN("Notes");
mi.position = 2000050011;
@@ -800,7 +800,7 @@ void CJabberProto::MenuInit()
mir_snprintf(srvFce, sizeof(srvFce), "%s/menuSetPriority/0", m_szModuleName);
bool needServices = !ServiceExists(srvFce);
if (needServices)
- JCreateServiceParam(svcName, &CJabberProto::OnMenuSetPriority, 0);
+ CreateServiceParam(svcName, &CJabberProto::OnMenuSetPriority, 0);
int steps[] = { 10, 5, 1, 0, -1, -5, -10 };
for (int i = 0; i < SIZEOF(steps); i++) {
@@ -815,7 +815,7 @@ void CJabberProto::MenuInit()
mir_snprintf(szName, sizeof(szName), (steps[i] > 0) ? "Increase priority by %d" : "Decrease priority by %d", abs(steps[i]));
if (needServices)
- JCreateServiceParam(svcName, &CJabberProto::OnMenuSetPriority, (LPARAM)steps[i]);
+ CreateServiceParam(svcName, &CJabberProto::OnMenuSetPriority, (LPARAM)steps[i]);
mi.position++;
Menu_AddProtoMenuItem(&mi);
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index b481f8fe28..df48e8c672 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -292,7 +292,7 @@ private:
thread->port = m_regInfo->port;
thread->useSSL = m_regInfo->useSSL;
thread->reg_hwndDlg= m_hwnd;
- m_proto->JForkThread((JThreadFunc)&CJabberProto::ServerThread, thread);
+ m_proto->ForkThread((CJabberProto::MyThreadFunc)&CJabberProto::ServerThread, thread);
m_btnOk.SetText(TranslateT("Cancel"));
m_bProcessStarted = true;
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index 76679e5517..465d1a87ea 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -2228,7 +2228,7 @@ void CJabberProto::BuildPrivacyMenu()
mi.hParentMenu = MO_GetProtoRootMenu(m_szModuleName);
m_hPrivacyMenuRoot = Menu_AddProtoMenuItem(&mi);
- JCreateService("/PrivacyLists", &CJabberProto::OnMenuHandlePrivacyLists);
+ CreateService("/PrivacyLists", &CJabberProto::OnMenuHandlePrivacyLists);
char srvFce[MAX_PATH + 64];
mir_snprintf(srvFce, SIZEOF(srvFce), "%s/PrivacyLists", m_szModuleName);
mi.pszService = srvFce;
@@ -2261,7 +2261,7 @@ void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld)
mir_snprintf(srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i);
if (i > m_privacyMenuServiceAllocated) {
- JCreateServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
+ CreateServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
m_privacyMenuServiceAllocated = i;
}
mi.position++;
@@ -2277,7 +2277,7 @@ void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld)
mir_snprintf(srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i);
if (i > m_privacyMenuServiceAllocated) {
- JCreateServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
+ CreateServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
m_privacyMenuServiceAllocated = i;
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index e03cf896ae..b6ca54517c 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -64,6 +64,7 @@ static int compareListItems(const JABBER_LIST_ITEM *p1, const JABBER_LIST_ITEM *
}
CJabberProto::CJabberProto(const char* aProtoName, const TCHAR *aUserName) :
+ PROTO<CJabberProto>(aProtoName, aUserName),
m_options(this),
m_lstTransports(50, compareTransports),
m_lstRoster(50, compareListItems),
@@ -83,8 +84,6 @@ CJabberProto::CJabberProto(const char* aProtoName, const TCHAR *aUserName) :
m_lstJabberFeatCapPairsDynamic(2),
m_uEnabledFeatCapsDynamic(0)
{
- ProtoConstructor(this, aProtoName, aUserName);
-
InitializeCriticalSection(&m_csModeMsgMutex);
InitializeCriticalSection(&m_csLists);
InitializeCriticalSection(&m_csLastResourceMap);
@@ -102,50 +101,50 @@ CJabberProto::CJabberProto(const char* aProtoName, const TCHAR *aUserName) :
m_windowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
// Protocol services and events...
- m_hEventNudge = JCreateHookableEvent(JE_NUDGE);
- m_hEventXStatusIconChanged = JCreateHookableEvent(JE_CUSTOMSTATUS_EXTRAICON_CHANGED);
- m_hEventXStatusChanged = JCreateHookableEvent(JE_CUSTOMSTATUS_CHANGED);
+ m_hEventNudge = CreateHookableEvent(JE_NUDGE);
+ m_hEventXStatusIconChanged = CreateHookableEvent(JE_CUSTOMSTATUS_EXTRAICON_CHANGED);
+ m_hEventXStatusChanged = CreateHookableEvent(JE_CUSTOMSTATUS_CHANGED);
- JCreateService(PS_CREATEACCMGRUI, &CJabberProto::SvcCreateAccMgrUI);
+ CreateService(PS_CREATEACCMGRUI, &CJabberProto::SvcCreateAccMgrUI);
- JCreateService(PS_GETAVATARINFOT, &CJabberProto::JabberGetAvatarInfo);
- JCreateService(PS_GETMYAWAYMSG, &CJabberProto::GetMyAwayMsg);
- JCreateService(PS_SET_LISTENINGTO, &CJabberProto::OnSetListeningTo);
+ CreateService(PS_GETAVATARINFOT, &CJabberProto::JabberGetAvatarInfo);
+ CreateService(PS_GETMYAWAYMSG, &CJabberProto::GetMyAwayMsg);
+ CreateService(PS_SET_LISTENINGTO, &CJabberProto::OnSetListeningTo);
- JCreateService(PS_JOINCHAT, &CJabberProto::OnJoinChat);
- JCreateService(PS_LEAVECHAT, &CJabberProto::OnLeaveChat);
+ CreateService(PS_JOINCHAT, &CJabberProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &CJabberProto::OnLeaveChat);
- JCreateService(PS_GETCUSTOMSTATUSEX, &CJabberProto::OnGetXStatusEx);
- JCreateService(PS_SETCUSTOMSTATUSEX, &CJabberProto::OnSetXStatusEx);
- JCreateService(PS_GETCUSTOMSTATUSICON, &CJabberProto::OnGetXStatusIcon);
- JCreateService(PS_GETADVANCEDSTATUSICON, &CJabberProto::JGetAdvancedStatusIcon);
+ CreateService(PS_GETCUSTOMSTATUSEX, &CJabberProto::OnGetXStatusEx);
+ CreateService(PS_SETCUSTOMSTATUSEX, &CJabberProto::OnSetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSICON, &CJabberProto::OnGetXStatusIcon);
+ CreateService(PS_GETADVANCEDSTATUSICON, &CJabberProto::JGetAdvancedStatusIcon);
- JCreateService(JS_HTTP_AUTH, &CJabberProto::OnHttpAuthRequest);
- JCreateService(JS_INCOMING_NOTE_EVENT, &CJabberProto::OnIncomingNoteEvent);
+ CreateService(JS_HTTP_AUTH, &CJabberProto::OnHttpAuthRequest);
+ CreateService(JS_INCOMING_NOTE_EVENT, &CJabberProto::OnIncomingNoteEvent);
- JCreateService(JS_SENDXML, &CJabberProto::ServiceSendXML);
- JCreateService(PS_GETMYAVATART, &CJabberProto::JabberGetAvatar);
- JCreateService(PS_GETAVATARCAPS, &CJabberProto::JabberGetAvatarCaps);
- JCreateService(PS_SETMYAVATART, &CJabberProto::JabberSetAvatar);
- JCreateService(PS_SETMYNICKNAME, &CJabberProto::JabberSetNickname);
+ CreateService(JS_SENDXML, &CJabberProto::ServiceSendXML);
+ CreateService(PS_GETMYAVATART, &CJabberProto::JabberGetAvatar);
+ CreateService(PS_GETAVATARCAPS, &CJabberProto::JabberGetAvatarCaps);
+ CreateService(PS_SETMYAVATART, &CJabberProto::JabberSetAvatar);
+ CreateService(PS_SETMYNICKNAME, &CJabberProto::JabberSetNickname);
- JCreateService(JS_DB_GETEVENTTEXT_CHATSTATES, &CJabberProto::OnGetEventTextChatStates);
- JCreateService(JS_DB_GETEVENTTEXT_PRESENCE, &CJabberProto::OnGetEventTextPresence);
+ CreateService(JS_DB_GETEVENTTEXT_CHATSTATES, &CJabberProto::OnGetEventTextChatStates);
+ CreateService(JS_DB_GETEVENTTEXT_PRESENCE, &CJabberProto::OnGetEventTextPresence);
- JCreateService(JS_GETJABBERAPI, &CJabberProto::JabberGetApi);
+ CreateService(JS_GETJABBERAPI, &CJabberProto::JabberGetApi);
// XEP-0224 support (Attention/Nudge)
- JCreateService(JS_SEND_NUDGE, &CJabberProto::JabberSendNudge);
+ CreateService(JS_SEND_NUDGE, &CJabberProto::JabberSendNudge);
// service to get from protocol chat buddy info
- JCreateService(MS_GC_PROTO_GETTOOLTIPTEXT, &CJabberProto::JabberGCGetToolTipText);
+ CreateService(MS_GC_PROTO_GETTOOLTIPTEXT, &CJabberProto::JabberGCGetToolTipText);
// XMPP URI parser service for "File Association Manager" plugin
- JCreateService(JS_PARSE_XMPP_URI, &CJabberProto::JabberServiceParseXmppURI);
+ CreateService(JS_PARSE_XMPP_URI, &CJabberProto::JabberServiceParseXmppURI);
- JHookEvent(ME_MODERNOPT_INITIALIZE, &CJabberProto::OnModernOptInit);
- JHookEvent(ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit);
- JHookEvent(ME_SKIN2_ICONSCHANGED, &CJabberProto::OnReloadIcons);
+ HookEvent(ME_MODERNOPT_INITIALIZE, &CJabberProto::OnModernOptInit);
+ HookEvent(ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit);
+ HookEvent(ME_SKIN2_ICONSCHANGED, &CJabberProto::OnReloadIcons);
m_iqManager.FillPermanentHandlers();
m_iqManager.Start();
@@ -251,8 +250,6 @@ CJabberProto::~CJabberProto()
}
m_lstJabberFeatCapPairsDynamic.destroy();
m_hPrivacyMenuItems.destroy();
-
- ProtoDestructor(this);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -262,7 +259,7 @@ static COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
{
- JHookEvent(ME_USERINFO_INITIALISE, &CJabberProto::OnUserInfoInit);
+ HookEvent(ME_USERINFO_INITIALISE, &CJabberProto::OnUserInfoInit);
XStatusInit();
m_pepServices.InitGui();
@@ -281,8 +278,8 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, NULL, (LPARAM)&gcr);
- JHookEvent(ME_GC_EVENT, &CJabberProto::JabberGcEventHook);
- JHookEvent(ME_GC_BUILDMENU, &CJabberProto::JabberGcMenuHook);
+ HookEvent(ME_GC_EVENT, &CJabberProto::JabberGcEventHook);
+ HookEvent(ME_GC_BUILDMENU, &CJabberProto::JabberGcMenuHook);
}
HICON hIcon = LoadIconEx("main");
@@ -294,8 +291,8 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
Srmm_AddIcon(&sid);
Skin_ReleaseIcon(hIcon);
- JHookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
- JHookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
+ HookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
+ HookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
dbEventType.module = m_szModuleName;
@@ -307,7 +304,7 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
dbEventType.descr = "Presence notifications";
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
- JHookEvent(ME_IDLE_CHANGED, &CJabberProto::OnIdleChanged);
+ HookEvent(ME_IDLE_CHANGED, &CJabberProto::OnIdleChanged);
CheckAllContactsAreTransported();
@@ -593,7 +590,7 @@ HANDLE __cdecl CJabberProto::FileAllow(HANDLE /*hContact*/, HANDLE hTransfer, co
switch (ft->type) {
case FT_OOB:
- JForkThread((JThreadFunc)&CJabberProto::FileReceiveThread, ft);
+ ForkThread((MyThreadFunc)&CJabberProto::FileReceiveThread, ft);
break;
case FT_BYTESTREAM:
FtAcceptSiRequest(ft);
@@ -869,7 +866,7 @@ HANDLE __cdecl CJabberProto::SearchBasic(const TCHAR *szJid)
Log("Adding '%s' without validation", jsb->jid);
jsb->hSearch = SerialNext();
- JForkThread((JThreadFunc)&CJabberProto::BasicSearchThread, jsb);
+ ForkThread((MyThreadFunc)&CJabberProto::BasicSearchThread, jsb);
return (HANDLE)jsb->hSearch;
}
@@ -1108,7 +1105,7 @@ HANDLE __cdecl CJabberProto::SendFile(HANDLE hContact, const TCHAR *szDescriptio
if (jcb & JABBER_CAPS_SI_FT)
FtInitiate(item->jid, ft);
else if (jcb & JABBER_CAPS_OOB)
- JForkThread((JThreadFunc)&CJabberProto::FileServerThread, ft);
+ ForkThread((MyThreadFunc)&CJabberProto::FileServerThread, ft);
return ft;
}
@@ -1146,7 +1143,7 @@ int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc
ptrT ptszJid( db_get_tsa(hContact, m_szModuleName, "jid"));
if ( !m_bJabberOnline || ptszJid == NULL) {
TFakeAckParams *param = new TFakeAckParams(hContact, Translate("Protocol is offline or no jid"));
- JForkThread(&CJabberProto::SendMessageAckThread, param);
+ ForkThread(&CJabberProto::SendMessageAckThread, param);
return 1;
}
@@ -1223,7 +1220,7 @@ int __cdecl CJabberProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc
}
m_ThreadInfo->send(m);
- JForkThread(&CJabberProto::SendMessageAckThread, new TFakeAckParams(hContact, 0, id));
+ ForkThread(&CJabberProto::SendMessageAckThread, new TFakeAckParams(hContact, 0, id));
}
else {
xmlAddAttr(m, _T("to"), szClientJid); xmlAddAttrID(m, id);
@@ -1326,7 +1323,7 @@ int __cdecl CJabberProto::SetStatus(int iNewStatus)
m_iStatus = ID_STATUS_CONNECTING;
ThreadData* thread = new ThreadData(this, JABBER_SESSION_NORMAL);
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
- thread->hThread = JForkThreadEx((JThreadFunc)&CJabberProto::ServerThread, thread);
+ thread->hThread = ForkThreadEx((MyThreadFunc)&CJabberProto::ServerThread, thread, 0);
RebuildInfoFrame();
}
@@ -1394,7 +1391,7 @@ HANDLE __cdecl CJabberProto::GetAwayMsg(HANDLE hContact)
{
Log("GetAwayMsg called, hContact=%08X", hContact);
- JForkThread(&CJabberProto::GetAwayMsgThread, hContact);
+ ForkThread(&CJabberProto::GetAwayMsgThread, hContact);
return (HANDLE)1;
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index c07c79dd1e..848381579d 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -38,10 +38,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_send_manager.h"
struct CJabberProto;
-typedef void (__cdecl CJabberProto::*JThreadFunc)(void*);
-typedef int (__cdecl CJabberProto::*JEventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CJabberProto::*JServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CJabberProto::*JServiceFuncParam)(WPARAM, LPARAM, LPARAM);
enum TJabberGcLogInfoType { INFO_BAN, INFO_STATUS, INFO_CONFIG, INFO_AFFILIATION, INFO_ROLE };
@@ -147,10 +143,8 @@ struct CJabberInterface: public IJabberInterface
CJabberProto *m_psProto;
};
-struct CJabberProto : public PROTO_INTERFACE
+struct CJabberProto : public PROTO<CJabberProto>
{
- typedef PROTO_INTERFACE CSuper;
-
CJabberProto(const char*, const TCHAR*);
~CJabberProto();
@@ -789,12 +783,6 @@ struct CJabberProto : public PROTO_INTERFACE
//---- jabber_std.cpp ----------------------------------------------
- void JCreateService(const char* szService, JServiceFunc serviceProc);
- void JCreateServiceParam(const char* szService, JServiceFuncParam serviceProc, LPARAM lParam);
- HANDLE JCreateHookableEvent(const char* szService);
- void JForkThread(JThreadFunc, void*);
- HANDLE JForkThreadEx(JThreadFunc, void*, UINT* threadID = NULL);
-
void JDeleteSetting(HANDLE hContact, const char* valueName);
DWORD JGetByte(HANDLE hContact, const char* valueName, int parDefltValue);
DWORD JGetDword(HANDLE hContact, const char* valueName, DWORD parDefltValue);
@@ -805,7 +793,6 @@ struct CJabberProto : public PROTO_INTERFACE
TCHAR *JGetStringT(HANDLE hContact, char* valueName, TCHAR *&out);
TCHAR *JGetStringT(HANDLE hContact, char* valueName, TCHAR *buf, int size);
WORD JGetWord(HANDLE hContact, const char* valueName, int parDefltValue);
- void JHookEvent(const char*, JEventFunc);
void JLoginFailed(int errorCode);
DWORD JSetByte(HANDLE hContact, const char* valueName, int parValue);
DWORD JSetDword(HANDLE hContact, const char* valueName, DWORD parValue);
diff --git a/protocols/JabberG/src/jabber_std.cpp b/protocols/JabberG/src/jabber_std.cpp
index 559950cace..4eff7b90c9 100644
--- a/protocols/JabberG/src/jabber_std.cpp
+++ b/protocols/JabberG/src/jabber_std.cpp
@@ -23,47 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber.h"
-void CJabberProto::JCreateService(const char* szService, JServiceFunc serviceProc)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy(str, m_szModuleName);
- strcat(str, szService);
- ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
-
-void CJabberProto::JCreateServiceParam(const char* szService, JServiceFuncParam serviceProc, LPARAM lParam)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy(str, m_szModuleName);
- strcat(str, szService);
- ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
-}
-
-void CJabberProto::JHookEvent(const char* szEvent, JEventFunc handler)
-{
- ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&handler, this);
-}
-
-HANDLE CJabberProto::JCreateHookableEvent(const char* szService)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy(str, m_szModuleName);
- strcat(str, szService);
- return CreateHookableEvent(str);
-}
-
-void CJabberProto::JForkThread(JThreadFunc pFunc, void *param)
-{
- UINT threadID;
- CloseHandle((HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, this, param, &threadID));
-}
-
-HANDLE CJabberProto::JForkThreadEx(JThreadFunc pFunc, void *param, UINT* threadID)
-{
- UINT lthreadID;
- return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, this, param, threadID ? threadID : &lthreadID);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
void CJabberProto::JDeleteSetting(HANDLE hContact, const char* valueName)
diff --git a/protocols/MRA/src/Mra.h b/protocols/MRA/src/Mra.h
index 253dbfc9b3..1d6df272b0 100644
--- a/protocols/MRA/src/Mra.h
+++ b/protocols/MRA/src/Mra.h
@@ -120,18 +120,18 @@ struct MRA_ADDR_LIST
// ñòðóêòóðà ñîäåðæàùàÿ èíôîðìàöèþ ïî ïîñòðîåíèþ ìåíþ èëè ðàñøèðåíûõ èêîíîê
struct GUI_DISPLAY_ITEM
{
- LPSTR lpszName; // èìÿ ñåðâèñà, îíî æå èìÿ â èêîëèáå
- LPWSTR lpwszDescr; // òåêñòîâîå îïèñàíèå îòîáðàæàåìîå þçåðó
- LONG defIcon; // èêîíêà èç ðåñóðñîâ
- ServiceFunc lpFunc; // ôóíêöèÿ âûçûâàåìàÿ ìåíþ
- HANDLE hIconHandle;
+ LPSTR lpszName; // èìÿ ñåðâèñà, îíî æå èìÿ â èêîëèáå
+ LPWSTR lpwszDescr; // òåêñòîâîå îïèñàíèå îòîáðàæàåìîå þçåðó
+ LONG defIcon; // èêîíêà èç ðåñóðñîâ
+ CMraProto::MyServiceFunc lpFunc; // ôóíêöèÿ âûçûâàåìàÿ ìåíþ
+ HANDLE hIconHandle;
};
// ñòðóêòóðà ñîäåðæàùàÿ èíôîðìàöèþ î ñåðâèñàõ/ôóíêöèÿõ
struct SERVICE_ITEM
{
- LPSTR lpszName; // èìÿ ñåðâèñà, îíî æå èìÿ â èêîëèáå
- ServiceFunc lpFunc; // ôóíêöèÿ âûçûâàåìàÿ
+ LPSTR lpszName; // èìÿ ñåðâèñà, îíî æå èìÿ â èêîëèáå
+ CMraProto::MyServiceFunc lpFunc; // ôóíêöèÿ âûçûâàåìàÿ
};
extern GUI_DISPLAY_ITEM gdiMenuItems[];
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp
index 85f49b4d4d..077489bed1 100644
--- a/protocols/MRA/src/MraAvatars.cpp
+++ b/protocols/MRA/src/MraAvatars.cpp
@@ -100,7 +100,7 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle)
if (pmraaqAvatarsQueue->iThreadsCount > MAXIMUM_WAIT_OBJECTS)
pmraaqAvatarsQueue->iThreadsCount = MAXIMUM_WAIT_OBJECTS;
for (int i=0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
- pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue);
+ pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue, 0);
*phAvatarsQueueHandle = (HANDLE)pmraaqAvatarsQueue;
}
diff --git a/protocols/MRA/src/MraFilesQueue.cpp b/protocols/MRA/src/MraFilesQueue.cpp
index 8ab83d4a6c..21d853f511 100644
--- a/protocols/MRA/src/MraFilesQueue.cpp
+++ b/protocols/MRA/src/MraFilesQueue.cpp
@@ -292,7 +292,7 @@ DWORD CMraProto::MraFilesQueueAccept(HANDLE hFilesQueueHandle, DWORD dwIDRequest
pmftpp->hFilesQueueHandle = hFilesQueueHandle;
pmftpp->dat = dat;
- dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueRecvThreadProc, pmftpp);
+ dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueRecvThreadProc, pmftpp, 0);
}
return dwRetErrorCode;
}
@@ -1002,7 +1002,7 @@ DWORD CMraProto::MraFilesQueueAddSend(HANDLE hFilesQueueHandle, DWORD dwFlags, H
MRA_FILES_THREADPROC_PARAMS *pmftpp = (MRA_FILES_THREADPROC_PARAMS*)mir_calloc(sizeof(MRA_FILES_THREADPROC_PARAMS));
pmftpp->hFilesQueueHandle = hFilesQueueHandle;
pmftpp->dat = dat;
- dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueSendThreadProc, pmftpp);
+ dat->hThread = ForkThreadEx(&CMraProto::MraFilesQueueSendThreadProc, pmftpp, 0);
return NO_ERROR;
}
diff --git a/protocols/MRA/src/MraIcons.cpp b/protocols/MRA/src/MraIcons.cpp
index f82ba302c7..0bb4de9214 100644
--- a/protocols/MRA/src/MraIcons.cpp
+++ b/protocols/MRA/src/MraIcons.cpp
@@ -191,7 +191,7 @@ void CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, HICON hMain
for (size_t i = 0; i < dwCount; i++) {
memmove(pszServiceFunctionName, pgdiItems[i].lpszName, lstrlenA(pgdiItems[i].lpszName)+1);
if (pgdiItems[i].lpFunc)
- CreateObjectSvc(pgdiItems[i].lpszName, pgdiItems[i].lpFunc);
+ CreateService(pgdiItems[i].lpszName, pgdiItems[i].lpFunc);
mi.position = int(lPosition + i);
mi.icolibItem = pgdiItems[i].hIconHandle;
mi.ptszName = pgdiItems[i].lpwszDescr;
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp
index 5aa836733f..37321e64e4 100644
--- a/protocols/MRA/src/MraProto.cpp
+++ b/protocols/MRA/src/MraProto.cpp
@@ -8,29 +8,28 @@ static int MraExtraIconsApplyAll(WPARAM, LPARAM)
}
CMraProto::CMraProto(const char* _module, const TCHAR* _displayName) :
+ PROTO<CMraProto>(_module, _displayName),
m_bLoggedIn(false)
{
- ProtoConstructor(this, _module, _displayName);
-
InitializeCriticalSectionAndSpinCount(&csCriticalSectionSend, 0);
MraSendQueueInitialize(0, &hSendQueueHandle);
MraFilesQueueInitialize(0, &hFilesQueueHandle);
MraMPopSessionQueueInitialize(&hMPopSessionQueue);
MraAvatarsQueueInitialize(&hAvatarsQueueHandle);
- CreateObjectSvc(PS_SETCUSTOMSTATUSEX, &CMraProto::MraSetXStatusEx);
- CreateObjectSvc(PS_GETCUSTOMSTATUSEX, &CMraProto::MraGetXStatusEx);
- CreateObjectSvc(PS_GETCUSTOMSTATUSICON, &CMraProto::MraGetXStatusIcon);
+ CreateService(PS_SETCUSTOMSTATUSEX, &CMraProto::MraSetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSEX, &CMraProto::MraGetXStatusEx);
+ CreateService(PS_GETCUSTOMSTATUSICON, &CMraProto::MraGetXStatusIcon);
- CreateObjectSvc(PS_SET_LISTENINGTO, &CMraProto::MraSetListeningTo);
+ CreateService(PS_SET_LISTENINGTO, &CMraProto::MraSetListeningTo);
- CreateObjectSvc(PS_CREATEACCMGRUI, &CMraProto::MraCreateAccMgrUI);
- CreateObjectSvc(PS_GETAVATARCAPS, &CMraProto::MraGetAvatarCaps);
- CreateObjectSvc(PS_GETAVATARINFOT, &CMraProto::MraGetAvatarInfo);
- CreateObjectSvc(PS_GETMYAVATART, &CMraProto::MraGetMyAvatar);
+ CreateService(PS_CREATEACCMGRUI, &CMraProto::MraCreateAccMgrUI);
+ CreateService(PS_GETAVATARCAPS, &CMraProto::MraGetAvatarCaps);
+ CreateService(PS_GETAVATARINFOT, &CMraProto::MraGetAvatarInfo);
+ CreateService(PS_GETMYAVATART, &CMraProto::MraGetMyAvatar);
- CreateObjectSvc(MS_ICQ_SENDSMS, &CMraProto::MraSendSMS);
- CreateObjectSvc(MRA_SEND_NUDGE, &CMraProto::MraSendNudge);
+ CreateService(MS_ICQ_SENDSMS, &CMraProto::MraSendSMS);
+ CreateService(MRA_SEND_NUDGE, &CMraProto::MraSendNudge);
if ( ServiceExists(MS_NUDGE_SEND))
heNudgeReceived = CreateHookableEvent(MS_NUDGE);
@@ -52,7 +51,7 @@ CMraProto::CMraProto(const char* _module, const TCHAR* _displayName) :
for (size_t i = 0; i < MRA_XSTATUS_COUNT; i++) {
char szServiceName[100];
mir_snprintf(szServiceName, SIZEOF(szServiceName), "/menuXStatus%ld", i);
- CreateObjectSvcParam(szServiceName, &CMraProto::MraXStatusMenu, i);
+ CreateServiceParam(szServiceName, &CMraProto::MraXStatusMenu, i);
}
mir_snprintf(szNewMailSound, SIZEOF(szNewMailSound), "%s: %s", m_szModuleName, MRA_SOUND_NEW_EMAIL);
@@ -94,7 +93,7 @@ INT_PTR CMraProto::MraCreateAccMgrUI(WPARAM wParam,LPARAM lParam)
int CMraProto::OnModulesLoaded(WPARAM, LPARAM)
{
- hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, &CMraProto::MraExtraIconsApply);
+ HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, &CMraProto::MraExtraIconsApply);
HookEvent(ME_OPT_INITIALISE, &CMraProto::OnOptionsInit);
HookEvent(ME_DB_CONTACT_DELETED, &CMraProto::MraContactDeleted);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, &CMraProto::MraDbSettingChanged);
@@ -145,49 +144,6 @@ int CMraProto::OnPreShutdown(WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-void CMraProto::CreateObjectSvc(const char *szService, ServiceFunc serviceProc)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObj( str, ( MIRANDASERVICEOBJ )*( void** )&serviceProc, this );
-}
-
-void CMraProto::CreateObjectSvcParam( const char *szService, ServiceFuncParam serviceProc, LPARAM lParam )
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObjParam( str, ( MIRANDASERVICEOBJPARAM )*( void** )&serviceProc, this, lParam );
-}
-
-HANDLE CMraProto::HookEvent(const char* szEvent, EventFunc handler)
-{
- return ::HookEventObj( szEvent, ( MIRANDAHOOKOBJ )*( void** )&handler, this );
-}
-
-HANDLE CMraProto::CreateHookableEvent(const char *szService)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- return ::CreateHookableEvent( str );
-}
-
-void CMraProto::ForkThread(ThreadFunc pFunc, void *param)
-{
- UINT threadID;
- CloseHandle(( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, &threadID ));
-}
-
-HANDLE CMraProto::ForkThreadEx(ThreadFunc pFunc, void *param, UINT* threadID)
-{
- UINT lthreadID;
- return ( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, threadID ? threadID : &lthreadID);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
HANDLE CMraProto::AddToListByEmail(LPCTSTR plpsEMail, LPCTSTR plpsNick, LPCTSTR plpsFirstName, LPCTSTR plpsLastName, DWORD dwFlags)
{
if (!plpsEMail)
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h
index 019401c90d..0037dcb81c 100644
--- a/protocols/MRA/src/MraProto.h
+++ b/protocols/MRA/src/MraProto.h
@@ -18,12 +18,6 @@
struct MRA_FILES_QUEUE_ITEM;
-struct CMraProto;
-typedef void (__cdecl CMraProto::*ThreadFunc)(void*);
-typedef int (__cdecl CMraProto::*EventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CMraProto::*ServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CMraProto::*ServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-
BOOL DB_GetStaticStringA(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
BOOL DB_GetStaticStringW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPWSTR lpszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
@@ -32,7 +26,7 @@ BOOL DB_SetStringExW(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, L
BOOL DB_GetContactSettingBlob(HANDLE hContact, LPCSTR lpszModule, LPCSTR lpszValueName, LPVOID lpRet, size_t dwRetBuffSize, size_t *pdwRetBuffSize);
-struct CMraProto : public PROTO_INTERFACE
+struct CMraProto : public PROTO<CMraProto>
{
CMraProto(const char*, const TCHAR*);
~CMraProto();
@@ -87,13 +81,6 @@ struct CMraProto : public PROTO_INTERFACE
virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam);
- void CreateObjectSvc(const char* szService, ServiceFunc serviceProc);
- void CreateObjectSvcParam(const char* szService, ServiceFuncParam serviceProc, LPARAM lParam);
- HANDLE CreateHookableEvent(const char* szService);
- void ForkThread(ThreadFunc, void*);
- HANDLE ForkThreadEx(ThreadFunc, void*, UINT* threadID = NULL);
- HANDLE HookEvent(const char*, EventFunc);
-
void ShowFormattedErrorMessage(LPWSTR lpwszErrText, DWORD dwErrorCode);
void MraPopupShowW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWSTR lpszTitle, LPWSTR lpszMessage);
void MraPopupShowFromContactW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWSTR lpszMessage);
@@ -200,7 +187,7 @@ struct CMraProto : public PROTO_INTERFACE
HANDLE hSendQueueHandle, hFilesQueueHandle, hMPopSessionQueue;
- HANDLE hNetlibUser, heNudgeReceived, hHookExtraIconsApply;
+ HANDLE hNetlibUser, heNudgeReceived;
HANDLE hThreadWorker;
HANDLE hConnection;
DWORD dwThreadWorkerLastPingTime;
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index 4f79848d52..8b4a9318ed 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -22,7 +22,7 @@ DWORD CMraProto::StartConnect()
if (dwEMailSize > 5 && GetPassDB(szPass, sizeof(szPass), &dwPasswordSize)) {
InterlockedExchange((volatile LONG*)&dwThreadWorkerLastPingTime, GetTickCount());
- hThreadWorker = ForkThreadEx(&CMraProto::MraThreadProc, NULL);
+ hThreadWorker = ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0);
if (hThreadWorker == NULL) {
DWORD dwRetErrorCode = GetLastError();
InterlockedExchange((volatile LONG*)&dwThreadWorkerRunning, FALSE);
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp
index 001a526d2a..83ea9a9544 100644
--- a/protocols/MRA/src/Mra_svcs.cpp
+++ b/protocols/MRA/src/Mra_svcs.cpp
@@ -123,9 +123,6 @@ const LPWSTR lpcszXStatusNameDef[] =
void CMraProto::SetExtraIcons(HANDLE hContact)
{
- if (!hHookExtraIconsApply)
- return;
-
DWORD dwID, dwGroupID, dwContactSeverFlags;
if ( GetContactBasicInfoW(hContact, &dwID, &dwGroupID, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL))
return;
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp
index 1c78c2af7d..ca49d3d11f 100644
--- a/protocols/MSN/src/msn_chat.cpp
+++ b/protocols/MSN/src/msn_chat.cpp
@@ -35,7 +35,7 @@ HANDLE CMsnProto::MSN_GetChatInernalHandle(HANDLE hContact)
if (getString(hContact, "ChatRoomID", &dbv) == 0)
{
result = (HANDLE)(-atol(dbv.pszVal));
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
return result;
@@ -368,7 +368,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam)
mir_free((void*)gce.ptszUID);
if (!bError)
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
break;
diff --git a/protocols/MSN/src/msn_commands.cpp b/protocols/MSN/src/msn_commands.cpp
index 8b4091c313..d696d0d709 100644
--- a/protocols/MSN/src/msn_commands.cpp
+++ b/protocols/MSN/src/msn_commands.cpp
@@ -1378,7 +1378,7 @@ LBL_InvalidCommand:
if (lastStatus == ID_STATUS_OFFLINE) {
DBVARIANT dbv;
bool always = getString(hContact, "MirVer", &dbv) != 0;
- if (!always) MSN_FreeVariant(&dbv);
+ if (!always) db_free(&dbv);
sttSetMirVer(hContact, cont->cap1, always);
}
@@ -1602,7 +1602,7 @@ remove:
if (info->mJoinedContactsWLID.getCount() > 0 && MyOptions.SlowSend)
ProtoBroadcastAck(info->getContactHandle(),
ACKTYPE_MESSAGE, ACKRESULT_FAILED,
- (HANDLE)trid, (LPARAM)MSN_Translate("Message delivery failed"));
+ (HANDLE)trid, (LPARAM)Translate("Message delivery failed"));
MSN_DebugLog("Message send failed (trid=%d)", trid);
break;
diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp
index f1848a738e..93bad80d1e 100644
--- a/protocols/MSN/src/msn_contact.cpp
+++ b/protocols/MSN/src/msn_contact.cpp
@@ -188,7 +188,7 @@ bool CMsnProto::MSN_AddUser(HANDLE hContact, const char* email, int netId, int f
if (!db_get_utf(hContact, "CList", "Group", &dbv))
{
MSN_MoveContactToGroup(hContact, dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
char szContactID[100];
@@ -205,7 +205,7 @@ bool CMsnProto::MSN_AddUser(HANDLE hContact, const char* email, int netId, int f
if (netId == 1 && strstr(email, "@yahoo.com") != 0)
MSN_FindYahooUser(email);
}
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
else if (flags == LIST_LL)
diff --git a/protocols/MSN/src/msn_errors.cpp b/protocols/MSN/src/msn_errors.cpp
index fae9fd65f7..9a4acbe0c8 100644
--- a/protocols/MSN/src/msn_errors.cpp
+++ b/protocols/MSN/src/msn_errors.cpp
@@ -64,7 +64,7 @@ int CMsnProto::MSN_HandleErrors(ThreadData* info, char* cmdString)
case ERR_NOT_ONLINE:
if (info->mInitialContactWLID)
ProtoBroadcastAck(MSN_HContactFromEmail(info->mInitialContactWLID), ACKTYPE_MESSAGE, ACKRESULT_FAILED,
- (HANDLE)999999, (LPARAM)MSN_Translate("User not online"));
+ (HANDLE)999999, (LPARAM)Translate("User not online"));
else
MSN_ShowError("User not online");
diff --git a/protocols/MSN/src/msn_global.h b/protocols/MSN/src/msn_global.h
index aa7ed0f001..33dc271cfc 100644
--- a/protocols/MSN/src/msn_global.h
+++ b/protocols/MSN/src/msn_global.h
@@ -179,8 +179,6 @@ bool MSN_MsgWndExist(HANDLE hContact);
#define MSN_SendNickname(a) MSN_SendNicknameUtf(UTF8(a))
-void MSN_FreeVariant(DBVARIANT* dbv);
-char* MSN_Translate(const char* str);
unsigned MSN_GenRandom(void);
void MSN_InitContactMenu(void);
diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp
index a42aa7016e..eb0bf372b2 100644
--- a/protocols/MSN/src/msn_menu.cpp
+++ b/protocols/MSN/src/msn_menu.cpp
@@ -230,7 +230,7 @@ static INT_PTR CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam
DBVARIANT dbv;
if (!proto->getTString("Nick", &dbv)) {
SetDlgItemText(hwndDlg, IDC_NICKNAME, dbv.ptszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
return TRUE;
}
@@ -307,35 +307,35 @@ void CMsnProto::MsnInitMainMenu(void)
mi.pszService = servicefunction;
strcpy(tDest, MS_SET_NICKNAME_UI);
- CreateProtoService(MS_SET_NICKNAME_UI, &CMsnProto::SetNicknameUI);
+ CreateService(MS_SET_NICKNAME_UI, &CMsnProto::SetNicknameUI);
mi.position = 201001;
mi.icolibItem = GetIconHandle(IDI_MSN);
mi.pszName = LPGEN("Set &Nickname");
menuItemsMain[0] = Menu_AddProtoMenuItem(&mi);
strcpy(tDest, MSN_INVITE);
- CreateProtoService(MSN_INVITE, &CMsnProto::MsnInviteCommand);
+ CreateService(MSN_INVITE, &CMsnProto::MsnInviteCommand);
mi.position = 201002;
mi.icolibItem = GetIconHandle(IDI_INVITE);
mi.pszName = LPGEN("Create &Chat");
menuItemsMain[0] = Menu_AddProtoMenuItem(&mi);
strcpy(tDest, MS_GOTO_INBOX);
- CreateProtoService(MS_GOTO_INBOX, &CMsnProto::MsnGotoInbox);
+ CreateService(MS_GOTO_INBOX, &CMsnProto::MsnGotoInbox);
mi.position = 201003;
mi.icolibItem = GetIconHandle(IDI_INBOX);
mi.pszName = LPGEN("Display &Hotmail Inbox");
menuItemsMain[1] = Menu_AddProtoMenuItem(&mi);
strcpy(tDest, MS_EDIT_PROFILE);
- CreateProtoService(MS_EDIT_PROFILE, &CMsnProto::MsnEditProfile);
+ CreateService(MS_EDIT_PROFILE, &CMsnProto::MsnEditProfile);
mi.position = 201004;
mi.icolibItem = GetIconHandle(IDI_PROFILE);
mi.pszName = LPGEN("View &Profile");
menuItemsMain[2] = Menu_AddProtoMenuItem(&mi);
strcpy(tDest, MS_EDIT_ALERTS);
- CreateProtoService(MS_EDIT_ALERTS, &CMsnProto::MsnSetupAlerts);
+ CreateService(MS_EDIT_ALERTS, &CMsnProto::MsnSetupAlerts);
mi.position = 201004;
mi.icolibItem = GetIconHandle(IDI_PROFILE);
mi.pszName = LPGEN("Setup Live &Alerts");
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index 12c8d24064..183f50c6c0 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -235,7 +235,7 @@ void CMsnProto::MSN_GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t c
deleteSetting(hContact, "PictContext");
if (cbLen) pszDest[0] = 0;
}
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else if (cbLen)
pszDest[0] = 0;
@@ -517,7 +517,7 @@ int ThreadData::sendMessage(int msgType, const char* email, int netId, const cha
if (*p == 0) {
UrlEncode(dbv.pszVal, tFontName, sizeof(tFontName));
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
@@ -806,7 +806,7 @@ void CMsnProto::MSN_SetServerStatus(int newStatus)
if (!getStringUtf("Nick", &dbv)) {
if (dbv.pszVal[0])
MSN_SetNicknameUtf(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
diff --git a/protocols/MSN/src/msn_msgqueue.cpp b/protocols/MSN/src/msn_msgqueue.cpp
index 3bc2eb25c4..a82cad6a49 100644
--- a/protocols/MSN/src/msn_msgqueue.cpp
+++ b/protocols/MSN/src/msn_msgqueue.cpp
@@ -158,7 +158,7 @@ void CMsnProto::MsgQueue_Clear(const char* wlid, bool msg)
{
HANDLE hContact = MSN_HContactFromEmail(E.wlid);
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED,
- (HANDLE)E.seq, (LPARAM)MSN_Translate("Message delivery failed"));
+ (HANDLE)E.seq, (LPARAM)Translate("Message delivery failed"));
}
mir_free(E.message);
mir_free(E.wlid);
@@ -189,7 +189,7 @@ void CMsnProto::MsgQueue_Clear(const char* wlid, bool msg)
LeaveCriticalSection(&csMsgQueue);
HANDLE hContact = MSN_HContactFromEmail(wlid);
ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)seq,
- (LPARAM)MSN_Translate("Message delivery failed"));
+ (LPARAM)Translate("Message delivery failed"));
i = 0;
EnterCriticalSection(&csMsgQueue);
}
diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp
index 37c9ec9db6..934e996c43 100644
--- a/protocols/MSN/src/msn_opts.cpp
+++ b/protocols/MSN/src/msn_opts.cpp
@@ -105,7 +105,7 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (!proto->getTString("Nick", &dbv))
{
SetWindowText(wnd, dbv.ptszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
EnableWindow(wnd, proto->msnLoggedIn);
EnableWindow(GetDlgItem(hwndDlg, IDC_MOBILESEND), proto->msnLoggedIn &&
@@ -260,7 +260,7 @@ LBL_Continue:
reconnectRequired = true;
proto->setString("Password", password);
}
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else
{
@@ -273,7 +273,7 @@ LBL_Continue:
{
if (_tcscmp(dbv.ptszVal, screenStr))
proto->MSN_SendNickname(screenStr);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else
{
@@ -333,7 +333,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam
if (!proto->getString(NULL, "DirectServer", &dbv))
{
SetDlgItemTextA(hwndDlg, IDC_DIRECTSERVER, dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else
SetDlgItemTextA(hwndDlg, IDC_DIRECTSERVER, MSN_DEFAULT_LOGIN_SERVER);
@@ -341,7 +341,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam
if (!proto->getString(NULL, "GatewayServer", &dbv))
{
SetDlgItemTextA(hwndDlg, IDC_GATEWAYSERVER, dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else
SetDlgItemTextA(hwndDlg, IDC_GATEWAYSERVER, MSN_DEFAULT_GATEWAY);
@@ -585,7 +585,7 @@ static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, L
if (!proto->getTString("Place", &dbv))
{
SetDlgItemText(hwndDlg, IDC_PLACE, dbv.ptszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
return TRUE;
}
@@ -628,7 +628,7 @@ static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, L
{
if (strcmp(password, dbv.pszVal))
proto->setString("Password", password);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else
proto->setString("Password", password);
diff --git a/protocols/MSN/src/msn_p2p.cpp b/protocols/MSN/src/msn_p2p.cpp
index 353b4d1a95..b87455d070 100644
--- a/protocols/MSN/src/msn_p2p.cpp
+++ b/protocols/MSN/src/msn_p2p.cpp
@@ -1260,7 +1260,7 @@ void CMsnProto::p2p_InitFileTransfer(
ezxml_free(xmlcon);
ezxml_free(xmldb);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
if (pictmatch)
{
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 3834980ec7..188533496d 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -34,6 +34,7 @@ static int CompareLists(const MsnContact* p1, const MsnContact* p2)
}
CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
+ PROTO<CMsnProto>(aProtoName, aUserName),
contList(10, CompareLists),
grpList(10, CompareId),
sttThreads(10, PtrKeySortT),
@@ -43,8 +44,6 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
lsAvatarQueue(1),
msgCache(5, CompareId)
{
- ProtoConstructor(this, aProtoName, aUserName);
-
db_set_resident(m_szModuleName, "Status");
db_set_resident(m_szModuleName, "IdleTS");
db_set_resident(m_szModuleName, "p2pMsgId");
@@ -52,32 +51,32 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
db_set_resident(m_szModuleName, "MobileAllowed");
// Protocol services and events...
- hMSNNudge = CreateProtoEvent("/Nudge");
+ hMSNNudge = CreateHookableEvent("/Nudge");
- CreateProtoService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI);
+ CreateService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI);
- CreateProtoService(PS_GETAVATARINFOT, &CMsnProto::GetAvatarInfo);
- CreateProtoService(PS_GETMYAWAYMSG, &CMsnProto::GetMyAwayMsg);
+ CreateService(PS_GETAVATARINFOT, &CMsnProto::GetAvatarInfo);
+ CreateService(PS_GETMYAWAYMSG, &CMsnProto::GetMyAwayMsg);
- CreateProtoService(PS_LEAVECHAT, &CMsnProto::OnLeaveChat);
+ CreateService(PS_LEAVECHAT, &CMsnProto::OnLeaveChat);
- CreateProtoService(PS_GETMYAVATART, &CMsnProto::GetAvatar);
- CreateProtoService(PS_SETMYAVATART, &CMsnProto::SetAvatar);
- CreateProtoService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps);
+ CreateService(PS_GETMYAVATART, &CMsnProto::GetAvatar);
+ CreateService(PS_SETMYAVATART, &CMsnProto::SetAvatar);
+ CreateService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps);
- CreateProtoService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia);
- CreateProtoService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia);
+ CreateService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia);
+ CreateService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia);
- CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName);
- CreateProtoService(MSN_SEND_NUDGE, &CMsnProto::SendNudge);
+ CreateService(PS_SETMYNICKNAME, &CMsnProto::SetNickName);
+ CreateService(MSN_SEND_NUDGE, &CMsnProto::SendNudge);
- CreateProtoService(MSN_GETUNREAD_EMAILCOUNT, &CMsnProto::GetUnreadEmailCount);
+ CreateService(MSN_GETUNREAD_EMAILCOUNT, &CMsnProto::GetUnreadEmailCount);
// event hooks
- HookProtoEvent(ME_MSG_WINDOWPOPUP, &CMsnProto::OnWindowPopup);
- HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange);
- HookProtoEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit);
- HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked);
+ HookEvent(ME_MSG_WINDOWPOPUP, &CMsnProto::OnWindowPopup);
+ HookEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange);
+ HookEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit);
+ HookEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked);
LoadOptions();
@@ -178,10 +177,8 @@ CMsnProto::~CMsnProto()
mir_free(storageCacheKey);
FreeAuthTokens();
- ProtoDestructor(this);
}
-
int CMsnProto::OnModulesLoaded(WPARAM, LPARAM)
{
if (msnHaveChatDll) {
@@ -195,11 +192,11 @@ int CMsnProto::OnModulesLoaded(WPARAM, LPARAM)
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
- HookProtoEvent(ME_GC_EVENT, &CMsnProto::MSN_GCEventHook);
- HookProtoEvent(ME_GC_BUILDMENU, &CMsnProto::MSN_GCMenuHook);
+ HookEvent(ME_GC_EVENT, &CMsnProto::MSN_GCEventHook);
+ HookEvent(ME_GC_BUILDMENU, &CMsnProto::MSN_GCMenuHook);
}
- HookProtoEvent(ME_IDLE_CHANGED, &CMsnProto::OnIdleChanged);
+ HookEvent(ME_IDLE_CHANGED, &CMsnProto::OnIdleChanged);
InitPopups();
return 0;
}
@@ -666,7 +663,7 @@ void __cdecl CMsnProto::MsnGetAwayMsgThread(void* arg)
DBVARIANT dbv;
if (!db_get_ts(inf->hContact, "CList", "StatusMsg", &dbv)) {
ProtoBroadcastAck(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, (LPARAM)dbv.ptszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else ProtoBroadcastAck(inf->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)inf->id, 0);
@@ -708,7 +705,7 @@ DWORD_PTR __cdecl CMsnProto::GetCaps(int type, HANDLE hContact)
return PF2_ONTHEPHONE;
case PFLAG_UNIQUEIDTEXT:
- return (UINT_PTR)MSN_Translate("Live ID");
+ return (UINT_PTR)Translate("Live ID");
case PFLAG_UNIQUEIDSETTING:
return (UINT_PTR)"e-mail";
@@ -862,7 +859,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
if (!msnLoggedIn)
{
- errMsg = MSN_Translate("Protocol is offline");
+ errMsg = Translate("Protocol is offline");
ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this));
return 999999;
}
@@ -870,7 +867,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
char tEmail[MSN_MAX_EMAIL_LEN];
if (MSN_IsMeByContact(hContact, tEmail))
{
- errMsg = MSN_Translate("You cannot send message to yourself");
+ errMsg = Translate("You cannot send message to yourself");
ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, 999999, errMsg, this));
return 999999;
}
@@ -901,7 +898,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
case NETID_MOB:
if (strlen(msg) > 133)
{
- errMsg = MSN_Translate("Message is too long: SMS page limited to 133 UTF8 chars");
+ errMsg = Translate("Message is too long: SMS page limited to 133 UTF8 chars");
seq = 999997;
}
else
@@ -916,7 +913,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
if (strlen(msg) > 1202)
{
seq = 999996;
- errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
+ errMsg = Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
}
else
@@ -930,7 +927,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
if (strlen(msg) > 1202)
{
seq = 999996;
- errMsg = MSN_Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
+ errMsg = Translate("Message is too long: MSN messages are limited by 1202 UTF8 chars");
ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
}
else
@@ -950,7 +947,7 @@ int __cdecl CMsnProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc)
else
{
seq = 999993;
- errMsg = MSN_Translate("Offline messaging is not allowed for LCS contacts");
+ errMsg = Translate("Offline messaging is not allowed for LCS contacts");
ForkThread(&CMsnProto::MsnFakeAck, new TFakeAckParams(hContact, seq, errMsg, this));
}
}
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h
index 1f729be394..d3362fbd40 100644
--- a/protocols/MSN/src/msn_proto.h
+++ b/protocols/MSN/src/msn_proto.h
@@ -23,13 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <m_protoint.h>
-struct CMsnProto;
-typedef void (__cdecl CMsnProto::*MsnThreadFunc)(void*);
-typedef int (__cdecl CMsnProto::*MsnEventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CMsnProto::*MsnServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CMsnProto::*MsnServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-
-struct CMsnProto : public PROTO_INTERFACE
+struct CMsnProto : public PROTO<CMsnProto>
{
CMsnProto(const char*, const TCHAR*);
~CMsnProto();
@@ -570,12 +564,6 @@ struct CMsnProto : public PROTO_INTERFACE
//////////////////////////////////////////////////////////////////////////////////////
- HANDLE CreateProtoEvent(const char* szEvent);
- void CreateProtoService(const char* szService, MsnServiceFunc serviceProc);
- void CreateProtoServiceParam(const char* szService, MsnServiceFuncParam serviceProc, LPARAM lParam);
- void HookProtoEvent(const char* szEvent, MsnEventFunc pFunc);
- void ForkThread(MsnThreadFunc pFunc, void* param);
-
TCHAR* GetContactNameT(HANDLE hContact);
void deleteSetting(HANDLE hContact, const char* valueName);
diff --git a/protocols/MSN/src/msn_soapab.cpp b/protocols/MSN/src/msn_soapab.cpp
index 2010a9b6dd..9dce4dbdae 100644
--- a/protocols/MSN/src/msn_soapab.cpp
+++ b/protocols/MSN/src/msn_soapab.cpp
@@ -266,7 +266,7 @@ bool CMsnProto::MSN_SharingFindMembership(bool deltas, bool allowRecurse)
if (!getString("SharingLastChange", &dbv) && dbv.pszVal[0])
{
szLastChange = NEWSTR_ALLOCA(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
deltas &= (szLastChange != NULL);
}
@@ -630,7 +630,7 @@ bool CMsnProto::MSN_ABFind(const char* szMethod, const char* szGuid, bool deltas
if (!getString("ABFullLastChange", &dbv) && dbv.pszVal[0])
{
szLastChange = NEWSTR_ALLOCA(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
deltas &= (szLastChange != NULL);
}
@@ -641,7 +641,7 @@ bool CMsnProto::MSN_ABFind(const char* szMethod, const char* szGuid, bool deltas
if (!getString("ABFullDynLastChange", &dbv) && dbv.pszVal[0])
{
szDynLastChange = NEWSTR_ALLOCA(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
deltas &= (szDynLastChange != NULL);
}
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp
index 55d46c4c80..a3fc024b1b 100644
--- a/protocols/MSN/src/msn_srv.cpp
+++ b/protocols/MSN/src/msn_srv.cpp
@@ -246,7 +246,7 @@ void CMsnProto::MSN_UploadServerGroups(char* group)
{
MSN_MoveContactToGroup(msc->hContact, dbv.pszVal);
}
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
}
@@ -267,17 +267,17 @@ void CMsnProto::MSN_SyncContactToServerGroup(HANDLE hContact, const char* szCont
{
if (strcmp(dbv.pszVal, "MetaContacts Hidden Group") == 0)
{
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
if (!db_get_utf(hContact, "MetaContacts", "OldCListGroup", &dbv))
{
szGrpName = NEWSTR_ALLOCA(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
else
{
szGrpName = NEWSTR_ALLOCA(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
@@ -401,5 +401,5 @@ void CMsnProto::msn_storeProfileThread(void* param)
// MSN_ABUpdateNick(nickname, NULL);
}
- if (needFree) MSN_FreeVariant(&dbv);
+ if (needFree) db_free(&dbv);
}
diff --git a/protocols/MSN/src/msn_std.cpp b/protocols/MSN/src/msn_std.cpp
index 2ca835621b..da31858fd9 100644
--- a/protocols/MSN/src/msn_std.cpp
+++ b/protocols/MSN/src/msn_std.cpp
@@ -141,38 +141,6 @@ void CMsnProto::setWord(HANDLE hContact, const char* name, WORD value)
/////////////////////////////////////////////////////////////////////////////////////////
-void CMsnProto::CreateProtoService(const char* szService, MsnServiceFunc serviceProc)
-{
- char str[MAXMODULELABELLENGTH];
-
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
-
-void CMsnProto::CreateProtoServiceParam(const char* szService, MsnServiceFuncParam serviceProc, LPARAM lParam)
-{
- char str[MAXMODULELABELLENGTH];
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
-}
-
-HANDLE CMsnProto::CreateProtoEvent(const char* szService)
-{
- char str[MAXMODULELABELLENGTH];
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- return ::CreateHookableEvent(str);
-}
-
-void CMsnProto::HookProtoEvent(const char* szEvent, MsnEventFunc pFunc)
-{ ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&pFunc, this);
-}
-
-void CMsnProto::ForkThread(MsnThreadFunc pFunc, void* param)
-{
- UINT threadID;
- CloseHandle((HANDLE)mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, this, param, &threadID));
-}
-
TCHAR* CMsnProto::GetContactNameT(HANDLE hContact)
{
if (hContact)
@@ -190,16 +158,6 @@ TCHAR* CMsnProto::GetContactNameT(HANDLE hContact)
}
}
-void MSN_FreeVariant(DBVARIANT* dbv)
-{
- db_free(dbv);
-}
-
-char* MSN_Translate(const char* str)
-{
- return Translate(str);
-}
-
unsigned MSN_GenRandom(void)
{
unsigned rndnum;
diff --git a/protocols/MSN/src/msn_svcs.cpp b/protocols/MSN/src/msn_svcs.cpp
index e8c6b80a12..40dc63464f 100644
--- a/protocols/MSN/src/msn_svcs.cpp
+++ b/protocols/MSN/src/msn_svcs.cpp
@@ -87,7 +87,7 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
DBVARIANT dbv;
if ( getString(AI->hContact, AI->hContact ? "PictContext" : "PictObject", &dbv) == 0) {
szContext = (char*)NEWSTR_ALLOCA(dbv.pszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
else return GAIR_NOAVATAR;
@@ -98,7 +98,7 @@ INT_PTR CMsnProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
bool needupdate = true;
if (getString(AI->hContact, "PictSavedContext", &dbv) == 0) {
needupdate = strcmp(dbv.pszVal, szContext) != 0;
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
if (needupdate) {
@@ -392,7 +392,7 @@ int CMsnProto::OnContactDeleted(WPARAM wParam, LPARAM lParam)
DBVARIANT dbv;
if (!getTString(hContact, "ChatRoomID", &dbv)) {
MSN_KillChatSession(dbv.ptszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
else
@@ -630,7 +630,7 @@ INT_PTR CMsnProto::OnLeaveChat(WPARAM wParam,LPARAM lParam)
if (getTString(hContact, "ChatRoomID", &dbv) == 0)
{
MSN_KillChatSession(dbv.ptszVal);
- MSN_FreeVariant(&dbv);
+ db_free(&dbv);
}
}
return 0;
diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp
index 62a00d5174..c6681c051f 100644
--- a/protocols/Omegle/src/chat.cpp
+++ b/protocols/Omegle/src/chat.cpp
@@ -85,12 +85,12 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam)
facy.spy_mode_ = false;
facy.question_ = "";
- ForkThread(&OmegleProto::NewChatWorker, this, NULL);
+ ForkThread(&OmegleProto::NewChatWorker, NULL);
break;
}
else if (!stricmp(command.c_str(), "quit"))
{
- ForkThread(&OmegleProto::StopChatWorker, this, NULL);
+ ForkThread(&OmegleProto::StopChatWorker, NULL);
break;
}
else if (!stricmp(command.c_str(), "spy"))
@@ -98,7 +98,7 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam)
facy.spy_mode_ = true;
facy.question_ = "";
- ForkThread(&OmegleProto::NewChatWorker, this, NULL);
+ ForkThread(&OmegleProto::NewChatWorker, NULL);
break;
}
else if (!stricmp(command.c_str(), "ask"))
@@ -131,7 +131,7 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam)
facy.spy_mode_ = true;
facy.question_ = params;
- ForkThread(&OmegleProto::NewChatWorker, this, NULL);
+ ForkThread(&OmegleProto::NewChatWorker, NULL);
break;
}
else if (!stricmp(command.c_str(), "asl"))
@@ -177,7 +177,7 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam)
case STATE_ACTIVE:
LOG("**Chat - Outgoing message: %s", text.c_str());
- ForkThread(&OmegleProto::SendMsgWorker, this, (void*)new std::string(text));
+ ForkThread(&OmegleProto::SendMsgWorker, new std::string(text));
break;
case STATE_INACTIVE:
@@ -199,13 +199,13 @@ int OmegleProto::OnChatEvent(WPARAM wParam,LPARAM lParam)
case GC_USER_TYPNOTIFY:
if ( facy.state_ == STATE_ACTIVE )
- ForkThread(&OmegleProto::SendTypingWorker, this, (void*)mir_tstrdup(hook->ptszText));
+ ForkThread(&OmegleProto::SendTypingWorker, mir_tstrdup(hook->ptszText));
break;
case GC_USER_LEAVE:
case GC_SESSION_TERMINATE:
mir_free( facy.nick_ );
- ForkThread(&OmegleProto::StopChatWorker, this, NULL);
+ ForkThread(&OmegleProto::StopChatWorker, NULL);
break;
}
@@ -271,7 +271,7 @@ void OmegleProto::DeleteChatContact(const TCHAR *name)
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
}
-int OmegleProto::OnJoinChat(WPARAM,LPARAM suppress)
+INT_PTR OmegleProto::OnJoinChat(WPARAM,LPARAM suppress)
{
GCSESSION gcw = {sizeof(gcw)};
@@ -330,7 +330,7 @@ void OmegleProto::SetTopic(const TCHAR *topic)
CallServiceSync(MS_GC_EVENT,0, reinterpret_cast<LPARAM>(&gce));
}
-int OmegleProto::OnLeaveChat(WPARAM,LPARAM)
+INT_PTR OmegleProto::OnLeaveChat(WPARAM,LPARAM)
{
GCDEST gcd = { m_szModuleName };
gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp
index d06a260966..bfad43d05d 100644
--- a/protocols/Omegle/src/communication.cpp
+++ b/protocols/Omegle/src/communication.cpp
@@ -701,10 +701,9 @@ bool Omegle_client::events( )
db_free(&dbv);
parent->Log("**Chat - saying Hi! message");
- ForkThread(&OmegleProto::SendMsgWorker, parent, (void*)message);
- } else {
- parent->Log("**Chat - Hi message is enabled but not used");
+ parent->ForkThread(&OmegleProto::SendMsgWorker, message);
}
+ else parent->Log("**Chat - Hi message is enabled but not used");
}
}
diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp
index 09f330a111..e3c1fd6d1b 100644
--- a/protocols/Omegle/src/proto.cpp
+++ b/protocols/Omegle/src/proto.cpp
@@ -22,10 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
-OmegleProto::OmegleProto(const char* proto_name, const TCHAR* username)
+OmegleProto::OmegleProto(const char* proto_name, const TCHAR* username) :
+ PROTO<OmegleProto>(proto_name, username)
{
- ProtoConstructor(this, proto_name, username);
-
this->facy.parent = this;
this->signon_lock_ = CreateMutex( NULL, FALSE, NULL );
@@ -34,13 +33,13 @@ OmegleProto::OmegleProto(const char* proto_name, const TCHAR* username)
this->facy.connection_lock_ = CreateMutex( NULL, FALSE, NULL );
// Group chats
- CreateProtoService(m_szModuleName, PS_JOINCHAT, &OmegleProto::OnJoinChat, this);
- CreateProtoService(m_szModuleName, PS_LEAVECHAT, &OmegleProto::OnLeaveChat, this);
+ CreateService(PS_JOINCHAT, &OmegleProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &OmegleProto::OnLeaveChat);
- CreateProtoService(m_szModuleName, PS_CREATEACCMGRUI, &OmegleProto::SvcCreateAccMgrUI, this);
+ CreateService(PS_CREATEACCMGRUI, &OmegleProto::SvcCreateAccMgrUI);
- HookProtoEvent(ME_OPT_INITIALISE, &OmegleProto::OnOptionsInit, this);
- HookProtoEvent(ME_GC_EVENT, &OmegleProto::OnChatEvent, this);
+ HookEvent(ME_OPT_INITIALISE, &OmegleProto::OnOptionsInit);
+ HookEvent(ME_GC_EVENT, &OmegleProto::OnChatEvent);
// Create standard network connection
TCHAR descr[512];
@@ -169,9 +168,9 @@ int OmegleProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
// EVENTS
-int OmegleProto::SvcCreateAccMgrUI(WPARAM wParam,LPARAM lParam)
+INT_PTR OmegleProto::SvcCreateAccMgrUI(WPARAM wParam,LPARAM lParam)
{
- return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_OmegleACCOUNT),
+ return (INT_PTR)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_OmegleACCOUNT),
(HWND)lParam, OmegleAccountProc, (LPARAM)this );
}
diff --git a/protocols/Omegle/src/proto.h b/protocols/Omegle/src/proto.h
index 6af449a453..0d37301648 100644
--- a/protocols/Omegle/src/proto.h
+++ b/protocols/Omegle/src/proto.h
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-class OmegleProto : public PROTO_INTERFACE
+class OmegleProto : public PROTO<OmegleProto>
{
public:
OmegleProto( const char *proto_name, const TCHAR *username );
@@ -91,7 +91,7 @@ public:
virtual int __cdecl OnEvent( PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam );
// Services
- int __cdecl SvcCreateAccMgrUI( WPARAM, LPARAM );
+ INT_PTR __cdecl SvcCreateAccMgrUI( WPARAM, LPARAM );
// Events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
@@ -101,10 +101,10 @@ public:
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
// Chat handling
- int __cdecl OnChatEvent(WPARAM,LPARAM);
- int __cdecl OnJoinChat(WPARAM,LPARAM);
- int __cdecl OnLeaveChat(WPARAM,LPARAM);
-
+ int __cdecl OnChatEvent(WPARAM,LPARAM);
+ INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
+ INT_PTR __cdecl OnLeaveChat(WPARAM,LPARAM);
+
// Loops
void __cdecl EventsLoop(void*);
diff --git a/protocols/Omegle/src/utils.h b/protocols/Omegle/src/utils.h
index d6b8e560eb..67a071d00c 100644
--- a/protocols/Omegle/src/utils.h
+++ b/protocols/Omegle/src/utils.h
@@ -22,35 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-template<typename T>
-void CreateProtoService(const char *module,const char *service,
- int (__cdecl T::*serviceProc)(WPARAM,LPARAM),T *self)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp,sizeof(temp),"%s%s",module,service);
- CreateServiceFunctionObj(temp,( MIRANDASERVICEOBJ )*(void**)&serviceProc, self );
-}
-
-template<typename T>
-void HookProtoEvent(const char* evt, int (__cdecl T::*eventProc)(WPARAM,LPARAM), T *self)
-{
- ::HookEventObj(evt,(MIRANDAHOOKOBJ)*(void**)&eventProc,self);
-}
-
-template<typename T>
-HANDLE ForkThreadEx(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- return reinterpret_cast<HANDLE>( mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&thread,self,data,0));
-}
-
-template<typename T>
-void ForkThread(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- CloseHandle(ForkThreadEx(thread,self,data));
-}
-
namespace utils
{
namespace url
diff --git a/protocols/Skype/src/skype_hooks.cpp b/protocols/Skype/src/skype_hooks.cpp
index a1184cc325..9e8f189863 100644
--- a/protocols/Skype/src/skype_hooks.cpp
+++ b/protocols/Skype/src/skype_hooks.cpp
@@ -6,11 +6,6 @@ void CSkypeProto::InitHookList()
::HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSkypeProto::PrebuildContactMenu);
}
-HANDLE CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler)
-{
- return ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
-}
-
void CSkypeProto::InitInstanceHookList()
{
this->HookEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp
index d1ca420913..e9d5846fd6 100644
--- a/protocols/Skype/src/skype_menus.cpp
+++ b/protocols/Skype/src/skype_menus.cpp
@@ -256,7 +256,7 @@ void CSkypeProto::OnInitStatusMenu()
// Invite Command
::strcpy(tDest, "/CreateChatRoom");
- this->CreateServiceObj(tDest, &CSkypeProto::CreateChatRoomCommand);
+ this->CreateService(tDest, &CSkypeProto::CreateChatRoomCommand);
mi.ptszName = LPGENT("Create conference");
mi.position = 200000 + SMI_CHAT_CREATE;
mi.icolibItem = CSkypeProto::GetSkinIconHandle("conference");
@@ -264,7 +264,7 @@ void CSkypeProto::OnInitStatusMenu()
// Invite Command
::strcpy(tDest, "/BlockedeList");
- this->CreateServiceObj(tDest, &CSkypeProto::OpenBlockedListCommand);
+ this->CreateService(tDest, &CSkypeProto::OpenBlockedListCommand);
mi.ptszName = LPGENT("Blocked contacts");
mi.position = 200000 + SMI_IGNORE_LIST;
mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 5bb995029d..746e72a473 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -1,11 +1,10 @@
#include "skype.h"
-CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) :
+CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) :
+ PROTO<CSkypeProto>(protoName, userName),
Skype(1),
skypeKitPort(8963)
{
- ::ProtoConstructor(this, protoName, userName);
-
this->rememberPassword = false;
::InitializeCriticalSection(&this->contact_search_lock);
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 8629f5b63f..c576d68bbe 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -1,10 +1,5 @@
#pragma once
-typedef void (__cdecl CSkypeProto::* SkypeThreadFunc) (void*);
-typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-
struct _tag_iconList
{
wchar_t* Description;
@@ -127,7 +122,7 @@ struct PasswordChangeBoxParam
class ChatMember;
class ChatRoom;
-struct CSkypeProto : public PROTO_INTERFACE, private Skype
+struct CSkypeProto : public PROTO<CSkypeProto>, private Skype
{
friend class ChatRoom;
friend class CAccount;
@@ -445,14 +440,8 @@ protected:
int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
- void CreateServiceObj(const char* szService, SkypeServiceFunc serviceProc);
- void CreateServiceObjParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
-
HANDLE CreateEvent(const char* szService);
- void ForkThread(SkypeThreadFunc, void*);
- HANDLE ForkThreadEx(SkypeThreadFunc, void*, UINT* threadID = NULL);
-
// netlib
HANDLE hNetLibUser;
@@ -465,8 +454,6 @@ protected:
void InitInstanceServiceList();
// hooks
- HANDLE HookEvent(const char*, SkypeEventFunc);
-
void InitInstanceHookList();
// icons
diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp
index 01e598727e..e6bdf123c0 100644
--- a/protocols/Skype/src/skype_services.cpp
+++ b/protocols/Skype/src/skype_services.cpp
@@ -9,17 +9,17 @@ void CSkypeProto::InitServiceList()
void CSkypeProto::InitInstanceServiceList()
{
// Message API
- this->CreateServiceObj(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
+ this->CreateService(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
// Chat API
- this->CreateServiceObj(PS_JOINCHAT, &CSkypeProto::OnJoinChat);
- this->CreateServiceObj(PS_LEAVECHAT, &CSkypeProto::OnLeaveChat);
+ this->CreateService(PS_JOINCHAT, &CSkypeProto::OnJoinChat);
+ this->CreateService(PS_LEAVECHAT, &CSkypeProto::OnLeaveChat);
// Own info
- this->CreateServiceObj(PS_SETMYNICKNAME, &CSkypeProto::SetMyNickName);
+ this->CreateService(PS_SETMYNICKNAME, &CSkypeProto::SetMyNickName);
// Avatar API
- this->CreateServiceObj(PS_GETAVATARINFOT, &CSkypeProto::GetAvatarInfo);
- this->CreateServiceObj(PS_GETAVATARCAPS, &CSkypeProto::GetAvatarCaps);
- this->CreateServiceObj(PS_GETMYAVATART, &CSkypeProto::GetMyAvatar);
- this->CreateServiceObj(PS_SETMYAVATART, &CSkypeProto::SetMyAvatar);
+ this->CreateService(PS_GETAVATARINFOT, &CSkypeProto::GetAvatarInfo);
+ this->CreateService(PS_GETAVATARCAPS, &CSkypeProto::GetAvatarCaps);
+ this->CreateService(PS_GETMYAVATART, &CSkypeProto::GetMyAvatar);
+ this->CreateService(PS_SETMYAVATART, &CSkypeProto::SetMyAvatar);
// service to get from protocol chat buddy info
- this->CreateServiceObj(MS_GC_PROTO_GETTOOLTIPTEXT, &CSkypeProto::SkypeGCGetToolTipText);
+ this->CreateService(MS_GC_PROTO_GETTOOLTIPTEXT, &CSkypeProto::SkypeGCGetToolTipText);
}
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index a84804ba59..82fd39404c 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -255,30 +255,6 @@ void CSkypeProto::InitCustomFolders()
// ---
-void CSkypeProto::CreateServiceObj(const char* szService, SkypeServiceFunc serviceProc)
-{
- char moduleName[MAXMODULELABELLENGTH];
-
- ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- ::CreateServiceFunctionObj(moduleName, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
-
-void CSkypeProto::CreateServiceObjParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam)
-{
- char moduleName[MAXMODULELABELLENGTH];
-
- ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- ::CreateServiceFunctionObjParam(moduleName, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
-}
-
-HANDLE CSkypeProto::CreateEvent(const char* szService)
-{
- char moduleName[MAXMODULELABELLENGTH];
-
- ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- return ::CreateHookableEvent(moduleName);
-}
-
int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
return ::ProtoBroadcastAck(this->m_szModuleName, hContact, type, result, hProcess, lParam);
@@ -289,26 +265,6 @@ int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lPa
return this->SendBroadcast(NULL, type, result, hProcess, lParam);
}
-void CSkypeProto::ForkThread(SkypeThreadFunc pFunc, void *param)
-{
- UINT threadID;
- ::CloseHandle((HANDLE)::mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&pFunc,
- this,
- param,
- &threadID));
-}
-
-HANDLE CSkypeProto::ForkThreadEx(SkypeThreadFunc pFunc, void *param, UINT* threadID)
-{
- UINT lthreadID;
- return (HANDLE)::mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&pFunc,
- this,
- param,
- threadID ? threadID : &lthreadID);
-}
-
//
int CSkypeProto::SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason)
diff --git a/protocols/Tlen/src/jabber.h b/protocols/Tlen/src/jabber.h
index cb06e7e34e..7727eb799b 100644
--- a/protocols/Tlen/src/jabber.h
+++ b/protocols/Tlen/src/jabber.h
@@ -210,11 +210,8 @@ struct JABBER_IQ_FUNC_STRUCT;
struct JABBER_LIST_ITEM_STRUCT;
struct TLEN_VOICE_CONTROL_STRUCT;
-
-struct TlenProtocol : public PROTO_INTERFACE
+struct TlenProtocol : public PROTO<TlenProtocol>
{
- typedef PROTO_INTERFACE CSuper;
-
TlenProtocol( const char*, const TCHAR* );
~TlenProtocol();
diff --git a/protocols/Tlen/src/jabber_svc.cpp b/protocols/Tlen/src/jabber_svc.cpp
index 8214b33483..bade2c8869 100644
--- a/protocols/Tlen/src/jabber_svc.cpp
+++ b/protocols/Tlen/src/jabber_svc.cpp
@@ -1264,10 +1264,9 @@ void TlenInitServicesVTbl(TlenProtocol *proto) {
}
-TlenProtocol::TlenProtocol( const char* aProtoName, const TCHAR* aUserName )
+TlenProtocol::TlenProtocol( const char *aProtoName, const TCHAR *aUserName) :
+ PROTO<TlenProtocol>(aProtoName, aUserName)
{
- ProtoConstructor(this, aProtoName, aUserName);
-
TlenInitServicesVTbl(this);
InitializeCriticalSection(&modeMsgMutex);
@@ -1304,7 +1303,6 @@ TlenProtocol::TlenProtocol( const char* aProtoName, const TCHAR* aUserName )
JabberSerialInit(this);
JabberIqInit(this);
JabberListInit(this);
-
}
TlenProtocol::~TlenProtocol()
@@ -1330,6 +1328,4 @@ TlenProtocol::~TlenProtocol()
mir_free(modeMsgs.szDnd);
mir_free(modeMsgs.szFreechat);
mir_free(modeMsgs.szInvisible);
-
- ProtoDestructor(this);
}
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index dd2219e6f7..96ad8af6da 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -75,7 +75,7 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam)
replaceAll(tweet, "%%", "%"); // the chat plugin will turn "%" into "%%", so we have to change it back :/
char *varTweet = mir_strdup( tweet.c_str());
- ForkThread(&TwitterProto::SendTweetWorker, this, varTweet);
+ ForkThread(&TwitterProto::SendTweetWorker, varTweet);
}
break;
@@ -128,7 +128,7 @@ void TwitterProto::DeleteChatContact(const char *name)
mir_free(const_cast<TCHAR*>(gce.ptszNick));
}
-int TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
+INT_PTR TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
{
GCSESSION gcw = {sizeof(gcw)};
@@ -156,7 +156,7 @@ int TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
// ***** Hook events
- HookProtoEvent(ME_GC_EVENT,&TwitterProto::OnChatOutgoing,this);
+ HookEvent(ME_GC_EVENT, &TwitterProto::OnChatOutgoing);
// Note: Initialization will finish up in SetChatStatus, called separately
if(!suppress)
@@ -166,7 +166,7 @@ int TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
return 0;
}
-int TwitterProto::OnLeaveChat(WPARAM,LPARAM)
+INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM)
{
in_chat_ = false;
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp
index 77ed802696..d9a7dc704b 100644
--- a/protocols/Twitter/src/connection.cpp
+++ b/protocols/Twitter/src/connection.cpp
@@ -68,7 +68,7 @@ void TwitterProto::SignOn(void*)
OnJoinChat(0,true);
SetAllContactStatuses(ID_STATUS_ONLINE);
- hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop,this);
+ hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop, NULL, 0);
}
ReleaseMutex(signon_lock_);
@@ -474,7 +474,7 @@ void TwitterProto::UpdateAvatar(HANDLE hContact,const std::string &url,bool forc
}
else
{
- ForkThread(&TwitterProto::UpdateAvatarWorker, this,new update_avatar(hContact,url));
+ ForkThread(&TwitterProto::UpdateAvatarWorker, new update_avatar(hContact,url));
}
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index 00dd6c66a8..da9ce0d79c 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -48,7 +48,7 @@ HANDLE TwitterProto::AddToList(int flags,PROTOSEARCHRESULT *result)
if(m_iStatus != ID_STATUS_ONLINE)
return 0;
- ForkThread(&TwitterProto::AddToListWorker,this,mir_utf8encodeT(result->nick));
+ ForkThread(&TwitterProto::AddToListWorker, mir_utf8encodeT(result->nick));
return AddToClientList( _T2A(result->nick),"");
}
@@ -87,7 +87,7 @@ int TwitterProto::GetInfo(HANDLE hContact,int info_type)
if(info_type == 0) // From clicking "Update" in the Userinfo dialog
{
- ForkThread(&TwitterProto::UpdateInfoWorker,this,hContact);
+ ForkThread(&TwitterProto::UpdateInfoWorker, hContact);
return 0;
}
@@ -152,13 +152,13 @@ void TwitterProto::DoSearch(void *p)
HANDLE TwitterProto::SearchBasic(const TCHAR *username)
{
- ForkThread(&TwitterProto::DoSearch,this,new search_query(username,false));
+ ForkThread(&TwitterProto::DoSearch, new search_query(username,false));
return (HANDLE)1;
}
HANDLE TwitterProto::SearchByEmail(const TCHAR *email)
{
- ForkThread(&TwitterProto::DoSearch,this,new search_query(email,true));
+ ForkThread(&TwitterProto::DoSearch, new search_query(email,true));
return (HANDLE)1;
}
@@ -179,7 +179,7 @@ void TwitterProto::GetAwayMsgWorker(void *hContact)
HANDLE TwitterProto::GetAwayMsg(HANDLE hContact)
{
- ForkThread(&TwitterProto::GetAwayMsgWorker, this,hContact);
+ ForkThread(&TwitterProto::GetAwayMsgWorker, hContact);
return (HANDLE)1;
}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index d39ba23371..46655d8ba8 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -31,23 +31,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static volatile LONG g_msgid = 1;
-TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username)
+TwitterProto::TwitterProto(const char *proto_name,const TCHAR *username) :
+ PROTO<TwitterProto>(proto_name, username)
{
- ProtoConstructor(this, proto_name, username);
+ CreateService(PS_CREATEACCMGRUI, &TwitterProto::SvcCreateAccMgrUI);
+ CreateService(PS_GETNAME, &TwitterProto::GetName);
+ CreateService(PS_GETSTATUS, &TwitterProto::GetStatus);
- CreateProtoService(m_szModuleName,PS_CREATEACCMGRUI, &TwitterProto::SvcCreateAccMgrUI,this);
- CreateProtoService(m_szModuleName,PS_GETNAME, &TwitterProto::GetName, this);
- CreateProtoService(m_szModuleName,PS_GETSTATUS,&TwitterProto::GetStatus, this);
+ CreateService(PS_JOINCHAT, &TwitterProto::OnJoinChat);
+ CreateService(PS_LEAVECHAT, &TwitterProto::OnLeaveChat);
- CreateProtoService(m_szModuleName,PS_JOINCHAT, &TwitterProto::OnJoinChat, this);
- CreateProtoService(m_szModuleName,PS_LEAVECHAT,&TwitterProto::OnLeaveChat,this);
+ CreateService(PS_GETMYAVATAR, &TwitterProto::GetAvatar);
+ CreateService(PS_SETMYAVATAR, &TwitterProto::SetAvatar);
- CreateProtoService(m_szModuleName,PS_GETMYAVATAR,&TwitterProto::GetAvatar,this);
- CreateProtoService(m_szModuleName,PS_SETMYAVATAR,&TwitterProto::SetAvatar,this);
-
- HookProtoEvent(ME_DB_CONTACT_DELETED, &TwitterProto::OnContactDeleted, this);
- HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &TwitterProto::OnBuildStatusMenu, this);
- HookProtoEvent(ME_OPT_INITIALISE, &TwitterProto::OnOptionsInit, this);
+ HookEvent(ME_DB_CONTACT_DELETED, &TwitterProto::OnContactDeleted);
+ HookEvent(ME_CLIST_PREBUILDSTATUSMENU, &TwitterProto::OnBuildStatusMenu);
+ HookEvent(ME_OPT_INITIALISE, &TwitterProto::OnOptionsInit);
tstring defFolder = std::tstring( _T("%miranda_avatarcache%\\")) + m_tszUserName;
hAvatarFolder_ = FoldersRegisterCustomPathT(LPGEN("Avatars"), m_szModuleName, defFolder.c_str(), m_tszUserName);
@@ -173,7 +172,7 @@ int TwitterProto::SendMsg(HANDLE hContact,int flags,const char *msg)
tszMsg = mir_a2t( msg );
int seq = InterlockedIncrement(&g_msgid);
- ForkThread(&TwitterProto::SendSuccess, this,new send_direct(hContact, msg, seq));
+ ForkThread(&TwitterProto::SendSuccess, new send_direct(hContact, msg, seq));
return seq;
}
@@ -235,23 +234,23 @@ int TwitterProto::OnEvent(PROTOEVENTTYPE event,WPARAM wParam,LPARAM lParam)
// *************************
-int TwitterProto::SvcCreateAccMgrUI(WPARAM,LPARAM lParam)
+INT_PTR TwitterProto::SvcCreateAccMgrUI(WPARAM,LPARAM lParam)
{
return (int)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_TWITTERACCOUNT),(HWND)lParam, first_run_dialog, (LPARAM)this );
}
-int TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
+INT_PTR TwitterProto::GetName(WPARAM wParam,LPARAM lParam)
{
lstrcpynA(reinterpret_cast<char*>(lParam), m_szModuleName, (int)wParam);
return 0;
}
-int TwitterProto::GetStatus(WPARAM,LPARAM)
+INT_PTR TwitterProto::GetStatus(WPARAM,LPARAM)
{
return m_iStatus;
}
-int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
+INT_PTR TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
{
// TODO: support replying to tweets instead of just users
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -270,7 +269,7 @@ int TwitterProto::ReplyToTweet(WPARAM wParam,LPARAM)
return 0;
}
-int TwitterProto::VisitHomepage(WPARAM wParam,LPARAM)
+INT_PTR TwitterProto::VisitHomepage(WPARAM wParam,LPARAM)
{
HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
@@ -311,7 +310,7 @@ int TwitterProto::OnBuildStatusMenu(WPARAM,LPARAM)
// TODO: Disable this menu item when offline
// "Send Tweet..."
- CreateProtoService(m_szModuleName,"/Tweet",&TwitterProto::OnTweet,this);
+ CreateService("/Tweet", &TwitterProto::OnTweet);
strcpy(tDest,"/Tweet");
mi.ptszName = LPGENT("Send Tweet...");
mi.popupPosition = 200001;
@@ -346,7 +345,7 @@ int TwitterProto::OnOptionsInit(WPARAM wParam,LPARAM)
return 0;
}
-int TwitterProto::OnTweet(WPARAM,LPARAM)
+INT_PTR TwitterProto::OnTweet(WPARAM,LPARAM)
{
if(m_iStatus != ID_STATUS_ONLINE)
return 1;
@@ -520,12 +519,12 @@ std::tstring TwitterProto::GetAvatarFolder()
return path;
}
-int TwitterProto::GetAvatar(WPARAM,LPARAM)
+INT_PTR TwitterProto::GetAvatar(WPARAM,LPARAM)
{
return 0;
}
-int TwitterProto::SetAvatar(WPARAM,LPARAM)
+INT_PTR TwitterProto::SetAvatar(WPARAM,LPARAM)
{
return 0;
} \ No newline at end of file
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index 9287ff3636..84a1b1b439 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -25,10 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <m_protoint.h>
-class TwitterProto : public PROTO_INTERFACE
+class TwitterProto : public PROTO<TwitterProto>
{
public:
- TwitterProto(const char *,const TCHAR *);
+ TwitterProto(const char*,const TCHAR*);
~TwitterProto();
inline const char * ModuleName() const
@@ -87,25 +87,27 @@ public:
void UpdateSettings();
// Services
- int __cdecl SvcCreateAccMgrUI(WPARAM,LPARAM);
- int __cdecl GetName(WPARAM,LPARAM);
- int __cdecl GetStatus(WPARAM,LPARAM);
- int __cdecl ReplyToTweet(WPARAM,LPARAM);
- int __cdecl VisitHomepage(WPARAM,LPARAM);
- int __cdecl GetAvatar(WPARAM,LPARAM);
- int __cdecl SetAvatar(WPARAM,LPARAM);
+ INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM,LPARAM);
+ INT_PTR __cdecl GetName(WPARAM,LPARAM);
+ INT_PTR __cdecl GetStatus(WPARAM,LPARAM);
+ INT_PTR __cdecl ReplyToTweet(WPARAM,LPARAM);
+ INT_PTR __cdecl VisitHomepage(WPARAM,LPARAM);
+ INT_PTR __cdecl GetAvatar(WPARAM,LPARAM);
+ INT_PTR __cdecl SetAvatar(WPARAM,LPARAM);
+
+ INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
+ INT_PTR __cdecl OnLeaveChat(WPARAM,LPARAM);
+
+ INT_PTR __cdecl OnTweet(WPARAM,LPARAM);
// Events
int __cdecl OnContactDeleted(WPARAM,LPARAM);
int __cdecl OnBuildStatusMenu(WPARAM,LPARAM);
int __cdecl OnOptionsInit(WPARAM,LPARAM);
- int __cdecl OnTweet(WPARAM,LPARAM);
int __cdecl OnModulesLoaded(WPARAM,LPARAM);
int __cdecl OnPreShutdown(WPARAM,LPARAM);
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
int __cdecl OnChatOutgoing(WPARAM,LPARAM);
- int __cdecl OnJoinChat(WPARAM,LPARAM);
- int __cdecl OnLeaveChat(WPARAM,LPARAM);
void __cdecl SendTweetWorker(void *);
private:
diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp
index b3f886722a..196905b5aa 100644
--- a/protocols/Twitter/src/theme.cpp
+++ b/protocols/Twitter/src/theme.cpp
@@ -65,7 +65,7 @@ static TwitterProto * GetInstanceByHContact(HANDLE hContact)
return 0;
}
-template<int (__cdecl TwitterProto::*Fcn)(WPARAM,LPARAM)>
+template<INT_PTR (__cdecl TwitterProto::*Fcn)(WPARAM,LPARAM)>
INT_PTR GlobalService(WPARAM wParam,LPARAM lParam)
{
TwitterProto *proto = GetInstanceByHContact(reinterpret_cast<HANDLE>(wParam));
diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp
index 4843d8c6e0..97441b186f 100644
--- a/protocols/Twitter/src/ui.cpp
+++ b/protocols/Twitter/src/ui.cpp
@@ -162,7 +162,7 @@ INT_PTR CALLBACK tweet_proc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
ShowWindow(hwndDlg,SW_HIDE);
char *narrow = mir_t2a_cp(msg,CP_UTF8);
- ForkThread(&TwitterProto::SendTweetWorker, proto,narrow);
+ proto->ForkThread(&TwitterProto::SendTweetWorker, narrow);
EndDialog(hwndDlg, wParam);
return true;
diff --git a/protocols/Twitter/src/utility.h b/protocols/Twitter/src/utility.h
index bc94561274..17aa1cb649 100644
--- a/protocols/Twitter/src/utility.h
+++ b/protocols/Twitter/src/utility.h
@@ -21,35 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "http.h"
#include "twitter.h"
-template<typename T>
-void CreateProtoService(const char *module,const char *service,
- int (__cdecl T::*serviceProc)(WPARAM,LPARAM),T *self)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp,sizeof(temp),"%s%s",module,service);
- CreateServiceFunctionObj(temp,( MIRANDASERVICEOBJ )*(void**)&serviceProc, self );
-}
-
-template<typename T>
-void HookProtoEvent(const char* evt, int (__cdecl T::*eventProc)(WPARAM,LPARAM), T *self)
-{
- ::HookEventObj(evt,(MIRANDAHOOKOBJ)*(void**)&eventProc,self);
-}
-
-template<typename T>
-HANDLE ForkThreadEx(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- return reinterpret_cast<HANDLE>( mir_forkthreadowner(
- (pThreadFuncOwner)*(void**)&thread,self,data,0));
-}
-
-template<typename T>
-void ForkThread(void (__cdecl T::*thread)(void*),T *self,void *data = 0)
-{
- CloseHandle(ForkThreadEx(thread,self,data));
-}
-
std::string b64encode(const std::string &s);
class mir_twitter : public twitter
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp
index bfd8743ebe..5aa80eb389 100644
--- a/protocols/Yahoo/src/avatar.cpp
+++ b/protocols/Yahoo/src/avatar.cpp
@@ -141,7 +141,7 @@ void CYahooProto::SendAvatar(const TCHAR *szFile)
DebugLog("[Uploading avatar] filename: %s size: %ld", sf->filename, sf->filesize);
- YForkThread(&CYahooProto::send_avt_thread, sf);
+ ForkThread(&CYahooProto::send_avt_thread, sf);
}
struct avatar_info{
@@ -365,7 +365,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
avt->pic_url = strdup(pic_url);
avt->cksum = cksum;
- YForkThread(&CYahooProto::recv_avatarthread, avt);
+ ForkThread(&CYahooProto::recv_avatarthread, avt);
}
}
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp
index 03bfa66d5a..638d669de7 100644
--- a/protocols/Yahoo/src/chat.cpp
+++ b/protocols/Yahoo/src/chat.cpp
@@ -190,8 +190,8 @@ void CYahooProto::ChatRegister(void)
gcr.pszModule = m_szModuleName;
CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
- YHookEvent(ME_GC_EVENT, &CYahooProto::OnGCEventHook);
- YHookEvent(ME_GC_BUILDMENU, &CYahooProto::OnGCMenuHook);
+ HookEvent(ME_GC_EVENT, &CYahooProto::OnGCEventHook);
+ HookEvent(ME_GC_BUILDMENU, &CYahooProto::OnGCMenuHook);
}
void CYahooProto::ChatStart(const char* room)
diff --git a/protocols/Yahoo/src/file_transfer.cpp b/protocols/Yahoo/src/file_transfer.cpp
index 552eed7a96..b1cdd00da8 100644
--- a/protocols/Yahoo/src/file_transfer.cpp
+++ b/protocols/Yahoo/src/file_transfer.cpp
@@ -603,7 +603,7 @@ void CYahooProto::ext_got_file7info(const char *me, const char *who, const char
ft->url = strdup(url);
- YForkThread(&CYahooProto::recv_filethread, ft);
+ ForkThread(&CYahooProto::recv_filethread, ft);
}
void ext_yahoo_send_file7info(int id, const char *me, const char *who, const char *ft_token)
@@ -670,7 +670,7 @@ void CYahooProto::ext_ft7_send_file(const char *me, const char *who, const char
s->token = strdup(token);
s->sf = sf;
- YForkThread(&CYahooProto::send_filethread, s);
+ ForkThread(&CYahooProto::send_filethread, s);
}
/**************** Send File ********************/
@@ -799,7 +799,7 @@ HANDLE __cdecl CYahooProto::FileAllow( HANDLE /*hContact*/, HANDLE hTransfer, co
return hTransfer;
}
- YForkThread(&CYahooProto::recv_filethread, ft);
+ ForkThread(&CYahooProto::recv_filethread, ft);
return hTransfer;
}
diff --git a/protocols/Yahoo/src/im.cpp b/protocols/Yahoo/src/im.cpp
index 44bd39be16..65232c733a 100644
--- a/protocols/Yahoo/src/im.cpp
+++ b/protocols/Yahoo/src/im.cpp
@@ -176,7 +176,7 @@ void __cdecl CYahooProto::im_sendackfail_longmsg(HANDLE hContact)
int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc )
{
if (!m_bLoggedIn) {/* don't send message if we not connected! */
- YForkThread( &CYahooProto::im_sendackfail, hContact );
+ ForkThread( &CYahooProto::im_sendackfail, hContact );
return 1;
}
@@ -189,7 +189,7 @@ int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc
msg = mir_utf8encode(pszSrc);
if (lstrlenA(msg) > 800) {
- YForkThread( &CYahooProto::im_sendackfail_longmsg, hContact );
+ ForkThread( &CYahooProto::im_sendackfail_longmsg, hContact );
return 1;
}
@@ -197,7 +197,7 @@ int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc
if (!GetString( hContact, YAHOO_LOGINID, &dbv)) {
send_msg(dbv.pszVal, GetWord( hContact, "yprotoid", 0), msg, 1);
- YForkThread( &CYahooProto::im_sendacksuccess, hContact );
+ ForkThread( &CYahooProto::im_sendacksuccess, hContact );
db_free(&dbv);
return 1;
@@ -234,7 +234,7 @@ INT_PTR __cdecl CYahooProto::SendNudge(WPARAM wParam, LPARAM lParam)
DebugLog("[YAHOO_SENDNUDGE]");
if (!m_bLoggedIn) {/* don't send nudge if we not connected! */
- YForkThread( &CYahooProto::im_sendackfail, hContact );
+ ForkThread( &CYahooProto::im_sendackfail, hContact );
return 1;
}
@@ -243,7 +243,7 @@ INT_PTR __cdecl CYahooProto::SendNudge(WPARAM wParam, LPARAM lParam)
send_msg(dbv.pszVal, GetWord(hContact, "yprotoid", 0), "<ding>", 0);
db_free(&dbv);
- YForkThread( &CYahooProto::im_sendacksuccess, hContact );
+ ForkThread( &CYahooProto::im_sendacksuccess, hContact );
return 1;
}
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp
index 4ab4dfe26d..35444e3486 100644
--- a/protocols/Yahoo/src/proto.cpp
+++ b/protocols/Yahoo/src/proto.cpp
@@ -27,12 +27,11 @@
#endif
CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) :
+ PROTO<CYahooProto>(aProtoName, aUserName),
m_bLoggedIn( FALSE ),
poll_loop( 0),
m_chatrooms(3, ChatRoom::compare)
{
- ProtoConstructor(this, aProtoName, aUserName);
-
m_connections = NULL;
m_connection_tags = 0;
@@ -62,8 +61,6 @@ CYahooProto::~CYahooProto()
FREE(m_pw_token);
Netlib_CloseHandle( m_hNetlibUser );
-
- ProtoDestructor(this);
}
////////////////////////////////////////////////////////////////////////////////////////
@@ -71,9 +68,9 @@ CYahooProto::~CYahooProto()
int CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM )
{
- YHookEvent( ME_USERINFO_INITIALISE, &CYahooProto::OnUserInfoInit );
- YHookEvent( ME_IDLE_CHANGED, &CYahooProto::OnIdleEvent);
- YHookEvent( ME_CLIST_PREBUILDCONTACTMENU, &CYahooProto::OnPrebuildContactMenu );
+ HookEvent( ME_USERINFO_INITIALISE, &CYahooProto::OnUserInfoInit );
+ HookEvent( ME_IDLE_CHANGED, &CYahooProto::OnIdleEvent);
+ HookEvent( ME_CLIST_PREBUILDCONTACTMENU, &CYahooProto::OnPrebuildContactMenu );
TCHAR tModuleDescr[ 100 ];
mir_sntprintf(tModuleDescr, SIZEOF(tModuleDescr), TranslateT("%s plugin connections"), m_tszUserName);
@@ -345,7 +342,7 @@ void __cdecl CYahooProto::get_info_thread(HANDLE hContact)
int __cdecl CYahooProto::GetInfo( HANDLE hContact, int /*infoType*/ )
{
- YForkThread(&CYahooProto::get_info_thread, hContact);
+ ForkThread(&CYahooProto::get_info_thread, hContact);
return 0;
}
@@ -505,7 +502,7 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus )
BroadcastStatus(ID_STATUS_CONNECTING);
iNewStatus = (iNewStatus == ID_STATUS_INVISIBLE) ? YAHOO_STATUS_INVISIBLE: YAHOO_STATUS_AVAILABLE;
- YForkThread(&CYahooProto::server_main, (void *)iNewStatus);
+ ForkThread(&CYahooProto::server_main, (void *)iNewStatus);
}
else if (iNewStatus == ID_STATUS_INVISIBLE) { /* other normal away statuses are set via setaway */
BroadcastStatus(iNewStatus);
@@ -594,7 +591,7 @@ HANDLE __cdecl CYahooProto::GetAwayMsg( HANDLE hContact )
if (GetWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
return 0; /* user offline, what Status message? */
- YForkThread(&CYahooProto::get_status_thread, hContact);
+ ForkThread(&CYahooProto::get_status_thread, hContact);
return (HANDLE)1; //Success
}
diff --git a/protocols/Yahoo/src/proto.h b/protocols/Yahoo/src/proto.h
index 4aa8ddc86f..c7f139743b 100644
--- a/protocols/Yahoo/src/proto.h
+++ b/protocols/Yahoo/src/proto.h
@@ -16,26 +16,9 @@
#include <m_protoint.h>
-struct CYahooProto;
-
-#ifdef __GNUC__
-extern "C"
+struct CYahooProto : public PROTO<CYahooProto>
{
- typedef void ( CYahooProto::*YThreadFunc )( void* );
- typedef INT_PTR ( CYahooProto::*YEventFunc )( WPARAM, LPARAM );
- typedef INT_PTR ( CYahooProto::*YServiceFunc )( WPARAM, LPARAM );
- typedef INT_PTR ( CYahooProto::*YServiceFuncParam )( WPARAM, LPARAM, LPARAM );
-}
-#else
- typedef void ( __cdecl CYahooProto::*YThreadFunc )( void* );
- typedef int ( __cdecl CYahooProto::*YEventFunc )( WPARAM, LPARAM );
- typedef INT_PTR ( __cdecl CYahooProto::*YServiceFunc )( WPARAM, LPARAM );
- typedef INT_PTR ( __cdecl CYahooProto::*YServiceFuncParam )( WPARAM, LPARAM, LPARAM );
-#endif
-
-struct CYahooProto : public PROTO_INTERFACE
-{
- CYahooProto( const char*, const TCHAR* );
+ CYahooProto(const char*, const TCHAR*);
virtual ~CYahooProto();
//====================================================================================
@@ -339,12 +322,6 @@ private:
HANDLE hYahooAvatarsFolder;
bool InitCstFldRan;
void InitCustomFolders(void);
-
- void YCreateService( const char* szService, YServiceFunc serviceProc );
- void YCreateServiceParam( const char* szService, YServiceFuncParam serviceProc, LPARAM lParam );
- HANDLE YCreateHookableEvent( const char* szService );
- void YForkThread( YThreadFunc pFunc, void *param );
- void YHookEvent( const char* szEvent, YEventFunc handler );
};
extern LIST<CYahooProto> g_instances;
diff --git a/protocols/Yahoo/src/search.cpp b/protocols/Yahoo/src/search.cpp
index 9d9b53b892..d809bf496f 100644
--- a/protocols/Yahoo/src/search.cpp
+++ b/protocols/Yahoo/src/search.cpp
@@ -53,7 +53,7 @@ HANDLE __cdecl CYahooProto::SearchBasic( const TCHAR* nick )
if ( !m_bLoggedIn )
return 0;
- YForkThread(&CYahooProto::search_simplethread, _tcsdup( nick ));
+ ForkThread(&CYahooProto::search_simplethread, _tcsdup( nick ));
return ( HANDLE )1;
}
@@ -202,6 +202,6 @@ HWND __cdecl CYahooProto::SearchAdvanced( HWND owner )
if ( !m_bLoggedIn )
return 0;
- YForkThread( &CYahooProto::searchadv_thread, owner );
+ ForkThread( &CYahooProto::searchadv_thread, owner );
return ( HWND )1;
}
diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp
index af4f300282..5c6f90433c 100644
--- a/protocols/Yahoo/src/services.cpp
+++ b/protocols/Yahoo/src/services.cpp
@@ -393,7 +393,7 @@ void CYahooProto::MenuMainInit( void )
// Show custom status menu
lstrcpyA( tDest, YAHOO_SET_CUST_STAT );
- YCreateService( YAHOO_SET_CUST_STAT, &CYahooProto::SetCustomStatCommand );
+ CreateService( YAHOO_SET_CUST_STAT, &CYahooProto::SetCustomStatCommand );
mi.position = 290000;
mi.icolibItem = GetIconHandle( IDI_SET_STATUS );
@@ -403,7 +403,7 @@ void CYahooProto::MenuMainInit( void )
// Edit My profile
lstrcpyA( tDest, YAHOO_EDIT_MY_PROFILE );
- YCreateService( YAHOO_EDIT_MY_PROFILE, &CYahooProto::OnEditMyProfile );
+ CreateService( YAHOO_EDIT_MY_PROFILE, &CYahooProto::OnEditMyProfile );
mi.position = 290005;
mi.icolibItem = GetIconHandle( IDI_PROFILE );
@@ -412,7 +412,7 @@ void CYahooProto::MenuMainInit( void )
// Show My profile
lstrcpyA( tDest, YAHOO_SHOW_MY_PROFILE );
- YCreateService( YAHOO_SHOW_MY_PROFILE, &CYahooProto::OnShowMyProfileCommand );
+ CreateService( YAHOO_SHOW_MY_PROFILE, &CYahooProto::OnShowMyProfileCommand );
mi.position = 290006;
mi.icolibItem = GetIconHandle( IDI_PROFILE );
@@ -421,7 +421,7 @@ void CYahooProto::MenuMainInit( void )
// Show Yahoo mail
strcpy( tDest, YAHOO_YAHOO_MAIL );
- YCreateService( YAHOO_YAHOO_MAIL, &CYahooProto::OnGotoMailboxCommand );
+ CreateService( YAHOO_YAHOO_MAIL, &CYahooProto::OnGotoMailboxCommand );
mi.position = 290010;
mi.icolibItem = GetIconHandle( IDI_INBOX );
@@ -430,7 +430,7 @@ void CYahooProto::MenuMainInit( void )
// Show Address Book
strcpy( tDest, YAHOO_AB );
- YCreateService( YAHOO_AB, &CYahooProto::OnABCommand );
+ CreateService( YAHOO_AB, &CYahooProto::OnABCommand );
mi.position = 290015;
mi.icolibItem = GetIconHandle( IDI_YAB );
@@ -439,14 +439,14 @@ void CYahooProto::MenuMainInit( void )
// Show Calendar
strcpy( tDest, YAHOO_CALENDAR );
- YCreateService( YAHOO_CALENDAR, &CYahooProto::OnCalendarCommand );
+ CreateService( YAHOO_CALENDAR, &CYahooProto::OnCalendarCommand );
mi.position = 290017;
mi.icolibItem = GetIconHandle( IDI_CALENDAR );
mi.pszName = LPGEN("&Calendar");
menuItemsAll[5] = Menu_AddProtoMenuItem(&mi);
strcpy( tDest, "/JoinChatRoom");
- YCreateService("/JoinChatRoom", &CYahooProto::CreateConference);
+ CreateService("/JoinChatRoom", &CYahooProto::CreateConference);
mi.position = 290018;
mi.icolibItem = GetIconHandle(IDI_YAHOO);
@@ -456,7 +456,7 @@ void CYahooProto::MenuMainInit( void )
// Show Refresh
/*strcpy( tDest, YAHOO_REFRESH );
- YCreateService( YAHOO_REFRESH, &CYahooProto::OnRefreshCommand );
+ CreateService( YAHOO_REFRESH, &CYahooProto::OnRefreshCommand );
mi.position = 500090015;
mi.icolibItem = GetIconHandle( IDI_REFRESH );
@@ -477,7 +477,7 @@ void CYahooProto::MenuContactInit( void )
// Show Profile
strcpy( tDest, YAHOO_SHOW_PROFILE );
- YCreateService( YAHOO_SHOW_PROFILE, &CYahooProto::OnShowProfileCommand );
+ CreateService( YAHOO_SHOW_PROFILE, &CYahooProto::OnShowProfileCommand );
mi.position = -2000006000;
mi.icolibItem = GetIconHandle( IDI_PROFILE );
@@ -515,24 +515,24 @@ void CYahooProto::LoadYahooServices( void )
char path[MAX_PATH];
//----| Events hooking |--------------------------------------------------------------
- YHookEvent( ME_OPT_INITIALISE, &CYahooProto::OnOptionsInit );
+ HookEvent( ME_OPT_INITIALISE, &CYahooProto::OnOptionsInit );
//----| Create nudge event |----------------------------------------------------------
mir_snprintf(path, SIZEOF(path), "%s/Nudge", m_szModuleName);
hYahooNudge = CreateHookableEvent( path );
//----| Service creation |------------------------------------------------------------
- YCreateService( PS_CREATEACCMGRUI, &CYahooProto::SvcCreateAccMgrUI);
+ CreateService( PS_CREATEACCMGRUI, &CYahooProto::SvcCreateAccMgrUI);
- YCreateService( PS_GETAVATARINFOT, &CYahooProto::GetAvatarInfo );
- YCreateService( PS_GETMYAVATART, &CYahooProto::GetMyAvatar );
- YCreateService( PS_SETMYAVATART, &CYahooProto::SetMyAvatar );
- YCreateService( PS_GETAVATARCAPS, &CYahooProto::GetAvatarCaps );
+ CreateService( PS_GETAVATARINFOT, &CYahooProto::GetAvatarInfo );
+ CreateService( PS_GETMYAVATART, &CYahooProto::GetMyAvatar );
+ CreateService( PS_SETMYAVATART, &CYahooProto::SetMyAvatar );
+ CreateService( PS_GETAVATARCAPS, &CYahooProto::GetAvatarCaps );
- YCreateService( PS_GETMYAWAYMSG, &CYahooProto::GetMyAwayMsg);
- YCreateService( YAHOO_SEND_NUDGE, &CYahooProto::SendNudge );
+ CreateService( PS_GETMYAWAYMSG, &CYahooProto::GetMyAwayMsg);
+ CreateService( YAHOO_SEND_NUDGE, &CYahooProto::SendNudge );
- YCreateService( YAHOO_GETUNREAD_EMAILCOUNT, &CYahooProto::GetUnreadEmailCount);
+ CreateService( YAHOO_GETUNREAD_EMAILCOUNT, &CYahooProto::GetUnreadEmailCount);
//----| Set resident variables |------------------------------------------------------
diff --git a/protocols/Yahoo/src/util.cpp b/protocols/Yahoo/src/util.cpp
index e4e4511cd4..9813d2c825 100644
--- a/protocols/Yahoo/src/util.cpp
+++ b/protocols/Yahoo/src/util.cpp
@@ -22,33 +22,6 @@
#include "resource.h"
-void CYahooProto::YCreateService( const char* szService, YServiceFunc serviceProc )
-{
- char str[ 255 ];
- unsigned int len;
-
- len = snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
-
- if (len >= sizeof(str)) {
- DebugLog("[YCreateService] Failed Registering Service: %s. Reason: buffer too small?", szService);
- return;
- }
-
- ::CreateServiceFunctionObj( str, ( MIRANDASERVICEOBJ )*( void** )&serviceProc, this );
-}
-
-void CYahooProto::YForkThread( YThreadFunc pFunc, void *param )
-{
- UINT lthreadID;
-
- CloseHandle(( HANDLE )::mir_forkthreadowner(( pThreadFuncOwner ) *( void** )&pFunc, this, param, &lthreadID));
-}
-
-void CYahooProto::YHookEvent( const char* szEvent, YEventFunc handler )
-{
- ::HookEventObj( szEvent, ( MIRANDAHOOKOBJ )*( void** )&handler, this );
-}
-
int CYahooProto::DebugLog( const char *fmt, ... )
{
char str[ 4096 ];
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def
index 0e4103229a..a601d34b0b 100644
--- a/src/mir_core/mir_core.def
+++ b/src/mir_core/mir_core.def
@@ -168,3 +168,9 @@ db_set_resident @165
db_set @166
ProtoConstructor @167
ProtoDestructor @168
+ProtoCreateService @169
+ProtoCreateServiceParam @170
+ProtoHookEvent @171
+ProtoCreateHookableEvent @172
+ProtoForkThread @173
+ProtoForkThreadEx @174
diff --git a/src/mir_core/protos.cpp b/src/mir_core/protos.cpp
index 291b7a0fa4..098bf280d4 100644
--- a/src/mir_core/protos.cpp
+++ b/src/mir_core/protos.cpp
@@ -79,8 +79,8 @@ MIR_CORE_DLL(int) ProtoServiceExists(const char *szModule, const char *szService
return false;
char str[MAXMODULELABELLENGTH * 2];
- strncpy_s(str,szModule,strlen(szModule));
- strncat_s(str,szService,strlen(szService));
+ strncpy_s(str, szModule, strlen(szModule));
+ strncat_s(str, szService, strlen(szService));
return ServiceExists(str);
}
@@ -100,3 +100,44 @@ MIR_CORE_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis)
mir_free(pThis->m_szModuleName);
mir_free(pThis->m_tszUserName);
}
+
+MIR_CORE_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc serviceProc)
+{
+ char str[MAXMODULELABELLENGTH * 2];
+ strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
+ strncat_s(str, szService, strlen(szService));
+ ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, pThis);
+}
+
+MIR_CORE_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFuncParam serviceProc, LPARAM lParam)
+{
+ char str[MAXMODULELABELLENGTH * 2];
+ strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
+ strncat_s(str, szService, strlen(szService));
+ ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, pThis, lParam);
+}
+
+MIR_CORE_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szEvent, ProtoEventFunc handler)
+{
+ ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&handler, pThis);
+}
+
+MIR_CORE_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* szName)
+{
+ char str[MAXMODULELABELLENGTH * 2];
+ strncpy_s(str, pThis->m_szModuleName, strlen(pThis->m_szModuleName));
+ strncat_s(str, szName, strlen(szName));
+ return CreateHookableEvent(str);
+}
+
+MIR_CORE_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param)
+{
+ UINT threadID;
+ CloseHandle((HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, pThis, param, &threadID));
+}
+
+MIR_CORE_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param, UINT* threadID)
+{
+ UINT lthreadID;
+ return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner) *(void**)&pFunc, pThis, param, threadID ? threadID : &lthreadID);
+}
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp
index 48a763dc83..81d5a3f7bf 100644
--- a/src/modules/extraicons/options_ei.cpp
+++ b/src/modules/extraicons/options_ei.cpp
@@ -546,14 +546,14 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
CallService(MS_DB_MODULE_DELETE, 0, (LPARAM) MODULE_NAME "Groups");
db_set_w(NULL, MODULE_NAME "Groups", "Count", (WORD)groups.size());
- for (i = 0; i < groups.size(); i++) {
- ExtraIconGroup *group = groups[i];
+ for (unsigned k = 0; k < groups.size(); k++) {
+ ExtraIconGroup *group = groups[k];
char setting[512];
mir_snprintf(setting, SIZEOF(setting), "%d_count", i);
db_set_w(NULL, MODULE_NAME "Groups", setting, (WORD)group->items.size());
- for (unsigned int j = 0; j < group->items.size(); j++) {
+ for (unsigned j = 0; j < group->items.size(); j++) {
BaseExtraIcon *extra = group->items[j];
mir_snprintf(setting, SIZEOF(setting), "%d_%d", i, j);
@@ -567,8 +567,8 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
// Apply icons to new slots
RebuildListsBasedOnGroups(groups);
- for (i = 0; i < extraIconsBySlot.size(); i++) {
- ExtraIcon *extra = extraIconsBySlot[i];
+ for (unsigned n = 0; n < extraIconsBySlot.size(); n++) {
+ ExtraIcon *extra = extraIconsBySlot[n];
if (extra->getType() != EXTRAICON_TYPE_GROUP)
if (oldSlots[((BaseExtraIcon *) extra)->getID() - 1] == extra->getSlot())