diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-18 23:04:26 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-18 23:04:26 +0300 |
commit | abf8cd813bb0ac4f4f5451d2af929279d816abac (patch) | |
tree | 4fb7451f2f99fac23a9f891c1aa9dc9fe6e0f8c6 | |
parent | 9ffe3c7ba4eb7011279e14ff1c5b5357bf874114 (diff) |
core changes:
- PROTOCOLDESCRIPTOR's implementation hidden inside mir_app;
- Proto_RegisterModule now doesn't need a PROTOCOLDESCRIPTOR structure;
- PROTOTYPE_PROTOWITHACCS type added for protos that work with accounts
72 files changed, 380 insertions, 495 deletions
diff --git a/include/delphi/m_clistint.inc b/include/delphi/m_clistint.inc index 724ad30bf7..3ec038b04d 100644 --- a/include/delphi/m_clistint.inc +++ b/include/delphi/m_clistint.inc @@ -23,24 +23,6 @@ {$IFNDEF M_CLISTINT}
{$DEFINE M_CLISTINT}
-{Type
- P_menuProto = ^_menuProto;
- PClcCacheEntryBase = ^ClcCacheEntryBase;
- PClcContact = ^ClcContact;
- PClcData = ^ClcData;
- PClcFontInfo = ^ClcFontInfo;
- PClcGroup = ^ClcGroup;
- PClcProtoStatus = ^ClcProtoStatus;
- PCLIST_INTERFACE = ^CLIST_INTERFACE;
- PCListEvent = ^CListEvent;
- PCLCCacheEntry = ^CLCCacheEntry;
- PContactList = ^ContactList;
- PEventList = ^EventList;
- PMenuProto = ^MenuProto;
- PMIRANDASYSTRAYNOTIFY = ^MIRANDASYSTRAYNOTIFY;
- PPROTOCOLDESCRIPTOR = ^PROTOCOLDESCRIPTOR;
- PtrayIconInfo_t = ^trayIconInfo_t;
-}
const
HCONTACT_ISGROUP = $80000000;
HCONTACT_ISINFO = $FFFF0000;
diff --git a/include/delphi/m_protocols.inc b/include/delphi/m_protocols.inc index 713bbb031a..d7bf082421 100644 --- a/include/delphi/m_protocols.inc +++ b/include/delphi/m_protocols.inc @@ -157,7 +157,6 @@ type PPROTOCOLDESCRIPTOR = ^TPROTOCOLDESCRIPTOR;
PPPROTOCOLDESCRIPTOR = ^PPROTOCOLDESCRIPTOR;
TPROTOCOLDESCRIPTOR = record
- cbSize : size_t;
szName : PAnsiChar; // unique name of the module
_type : int; // module type, see PROTOTYPE_ constants
end;
diff --git a/include/delphi/m_protomod.inc b/include/delphi/m_protomod.inc index 416d5758e5..df9d30f2aa 100644 --- a/include/delphi/m_protomod.inc +++ b/include/delphi/m_protomod.inc @@ -39,8 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. be done for PROTOTYPE_PROTOCOL.
}
-function Proto_RegisterModule(descr:pPROTOCOLDESCRIPTOR) : int; stdcall;
- external AppDLL name 'Proto_RegisterModule';
+function Proto_RegisterModule(iType:int; name:PAnsiChar) : int; stdcall; external AppDLL;
{
Affect : Add the given protocol module to the chain for a contact, see notes
@@ -49,16 +48,14 @@ function Proto_RegisterModule(descr:pPROTOCOLDESCRIPTOR) : int; stdcall; registered type.
}
-function Proto_AddToContact(hContact:TMCONTACT; proto:PAnsiChar) : int; stdcall;
- external AppDLL name 'Proto_AddToContact';
+function Proto_AddToContact(hContact:TMCONTACT; proto:PAnsiChar) : int; stdcall; external AppDLL;
{
Affect : Remove the given protocol name from the chain for the given contact
Returns: 0 on success, [non zero] on failure
}
-function Proto_RemoveFromContact(hContact:TMCONTACT; proto:PAnsiChar) : int; stdcall;
- external AppDLL name 'Proto_RemoveFromContact';
+function Proto_RemoveFromContact(hContact:TMCONTACT; proto:PAnsiChar) : int; stdcall; external AppDLL;
{
Affect : Call the next service in the chain for the send operation, see notes
@@ -69,8 +66,7 @@ function Proto_RemoveFromContact(hContact:TMCONTACT; proto:PAnsiChar) : int; std typically your service should return ASAP.
}
-function Proto_ChainSend(order:int; ccs:pCCSDATA) : INT_PTR; stdcall;
- external AppDLL name 'Proto_ChainSend';
+function Proto_ChainSend(order:int; ccs:pCCSDATA) : INT_PTR; stdcall; external AppDLL;
{
Affect : Call the next service in the chain in this receive operation, see notes
@@ -84,7 +80,6 @@ function Proto_ChainSend(order:int; ccs:pCCSDATA) : INT_PTR; stdcall; are translated to the main thread and passed from there.
}
-function Proto_ChainRecv(order:int; ccs:pCCSDATA) : INT_PTR; stdcall;
- external AppDLL name 'Proto_ChainRecv';
+function Proto_ChainRecv(order:int; ccs:pCCSDATA) : INT_PTR; stdcall; external AppDLL;
{$ENDIF}
diff --git a/include/m_plugin.h b/include/m_plugin.h deleted file mode 100644 index 340b3100fe..0000000000 --- a/include/m_plugin.h +++ /dev/null @@ -1,258 +0,0 @@ -#pragma once - -#include <m_core.h> -#include <m_database.h> -#include <m_protocols.h> - -class MIR_APP_EXPORT CMPluginBase -{ - void tryOpenLog(); - -protected: - const char *m_szModuleName; - HANDLE m_hLogger = nullptr; - HINSTANCE m_hInst; - - CMPluginBase(const char *moduleName); - ~CMPluginBase(); - - // pass one of PROTOTYPE_* constants as type - void RegisterProtocol(int type, pfnInitProto = nullptr, pfnUninitProto = nullptr); - __forceinline void SetUniqueId(const char *pszUniqueId) - { - ::Proto_SetUniqueId(m_szModuleName, pszUniqueId); - } - -public: - void debugLogA(LPCSTR szFormat, ...); - void debugLogW(LPCWSTR wszFormat, ...); - - __forceinline HINSTANCE getInst() const { return m_hInst; } - __forceinline void setInst(HINSTANCE hInst) { m_hInst = hInst; } - - __forceinline INT_PTR delSetting(const char *name) - { - return db_unset(0, m_szModuleName, name); - } - __forceinline INT_PTR delSetting(MCONTACT hContact, const char *name) - { - return db_unset(hContact, m_szModuleName, name); - } - - __forceinline bool getBool(const char *name, bool defaultValue = false) - { - return db_get_b(0, m_szModuleName, name, defaultValue) != 0; - } - __forceinline bool getBool(MCONTACT hContact, const char *name, bool defaultValue = false) - { - return db_get_b(hContact, m_szModuleName, name, defaultValue) != 0; - } - - __forceinline int getByte(const char *name, BYTE defaultValue = 0) - { - return db_get_b(0, m_szModuleName, name, defaultValue); - } - __forceinline int getByte(MCONTACT hContact, const char *name, BYTE defaultValue = 0) - { - return db_get_b(hContact, m_szModuleName, name, defaultValue); - } - - __forceinline int getWord(const char *name, WORD defaultValue = 0) - { - return db_get_w(0, m_szModuleName, name, defaultValue); - } - __forceinline int getWord(MCONTACT hContact, const char *name, WORD defaultValue = 0) - { - return db_get_w(hContact, m_szModuleName, name, defaultValue); - } - - __forceinline DWORD getDword(const char *name, DWORD defaultValue = 0) - { - return db_get_dw(0, m_szModuleName, name, defaultValue); - } - __forceinline DWORD getDword(MCONTACT hContact, const char *name, DWORD defaultValue = 0) - { - return db_get_dw(hContact, m_szModuleName, name, defaultValue); - } - - __forceinline INT_PTR getString(const char *name, DBVARIANT *result) - { - return db_get_s(0, m_szModuleName, name, result); - } - __forceinline INT_PTR getString(MCONTACT hContact, const char *name, DBVARIANT *result) - { - return db_get_s(hContact, m_szModuleName, name, result); - } - - __forceinline INT_PTR getWString(const char *name, DBVARIANT *result) - { - return db_get_ws(0, m_szModuleName, name, result); - } - __forceinline INT_PTR getWString(MCONTACT hContact, const char *name, DBVARIANT *result) - { - return db_get_ws(hContact, m_szModuleName, name, result); - } - - __forceinline char* getStringA(const char *name) - { - return db_get_sa(0, m_szModuleName, name); - } - __forceinline char* getStringA(MCONTACT hContact, const char *name) - { - return db_get_sa(hContact, m_szModuleName, name); - } - - __forceinline wchar_t* getWStringA(const char *name) - { - return db_get_wsa(0, m_szModuleName, name); - } - __forceinline wchar_t* getWStringA(MCONTACT hContact, const char *name) - { - return db_get_wsa(hContact, m_szModuleName, name); - } - - __forceinline void setByte(const char *name, BYTE value) - { - db_set_b(0, m_szModuleName, name, value); - } - __forceinline void setByte(MCONTACT hContact, const char *name, BYTE value) - { - db_set_b(hContact, m_szModuleName, name, value); - } - - __forceinline void setWord(const char *name, WORD value) - { - db_set_w(0, m_szModuleName, name, value); - } - __forceinline void setWord(MCONTACT hContact, const char *name, WORD value) - { - db_set_w(hContact, m_szModuleName, name, value); - } - - __forceinline void setDword(const char *name, DWORD value) - { - db_set_dw(0, m_szModuleName, name, value); - } - __forceinline void setDword(MCONTACT hContact, const char *name, DWORD value) - { - db_set_dw(hContact, m_szModuleName, name, value); - } - - __forceinline void setString(const char *name, const char* value) - { - db_set_s(0, m_szModuleName, name, value); - } - __forceinline void setString(MCONTACT hContact, const char *name, const char* value) - { - db_set_s(hContact, m_szModuleName, name, value); - } - - __forceinline void setWString(const char *name, const wchar_t* value) - { - db_set_ws(0, m_szModuleName, name, value); - } - __forceinline void setWString(MCONTACT hContact, const char *name, const wchar_t* value) - { - db_set_ws(hContact, m_szModuleName, name, value); - } -}; - -extern struct CMPlugin g_plugin; - -///////////////////////////////////////////////////////////////////////////////////////// -// Basic class for plugins (not protocols) written in C++ - -typedef BOOL(WINAPI * const _pfnCrtInit)(HINSTANCE, DWORD, LPVOID); - -template<class T> class PLUGIN : public CMPluginBase -{ - typedef CMPluginBase CSuper; - -public: - static BOOL WINAPI RawDllMain(HINSTANCE hInstance, DWORD, LPVOID) - { - g_plugin.setInst(hInstance); - return TRUE; - } - -protected: - PLUGIN(const char *moduleName) - : CSuper(moduleName) - {} - - __forceinline HANDLE CreatePluginEvent(const char *name) - { - CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name); - return CreateHookableEvent(str); - } - - typedef int(__cdecl T::*MyEventFunc)(WPARAM, LPARAM); - __forceinline void HookPluginEvent(const char *name, MyEventFunc pFunc) - { - HookEventObj(name, (MIRANDAHOOKOBJ)*(void**)&pFunc, this); - } - - typedef INT_PTR(__cdecl T::*MyServiceFunc)(WPARAM, LPARAM); - __forceinline void CreatePluginService(const char *name, MyServiceFunc pFunc) - { - CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name); - CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&pFunc, this); - } - - typedef INT_PTR(__cdecl T::*MyServiceFuncParam)(WPARAM, LPARAM, LPARAM); - __forceinline void CreatePluginServiceParam(const char *name, MyServiceFuncParam pFunc, LPARAM param) - { - CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name); - CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&pFunc, this, param); - } -}; - -///////////////////////////////////////////////////////////////////////////////////////// -// Basic class for protocols with accounts - -struct CMPlugin; - -template<class P> class ACCPROTOPLUGIN : public PLUGIN<CMPlugin> -{ - typedef PLUGIN<CMPlugin> CSuper; - -protected: - ACCPROTOPLUGIN(const char *moduleName) : - CSuper(moduleName) - { - CMPluginBase::RegisterProtocol(PROTOTYPE_PROTOCOL, &fnInit, &fnUninit); - } - - static PROTO_INTERFACE* fnInit(const char *szModuleName, const wchar_t *wszAccountName) - { - P *ppro = new P(szModuleName, wszAccountName); - g_arInstances.insert(ppro); - return ppro; - } - - static int fnUninit(PROTO_INTERFACE *ppro) - { - g_arInstances.remove((P*)ppro); - return 0; - } - -public: - static OBJLIST<P> g_arInstances; - - static P* getInstance(const char *szProto) - { - for (auto &it : g_arInstances) - if (mir_strcmp(szProto, it->m_szModuleName) == 0) - return it; - - return nullptr; - } - - static P* getInstance(MCONTACT hContact) - { - return getInstance(::GetContactProto(hContact)); - } -}; - -template<class P> -OBJLIST<P> ACCPROTOPLUGIN<P>::g_arInstances(1, PtrKeySortT); diff --git a/include/m_protocols.h b/include/m_protocols.h index db32e1f94a..ff364d3e7e 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -126,8 +126,6 @@ struct PROTOFILETRANSFERSTATUS uint64_t currentFileTime; // as seconds since 1970
};
-#define PROTOCOLDESCRIPTOR_V3_SIZE (sizeof(size_t)+sizeof(INT_PTR)+sizeof(char*))
-
/////////////////////////////////////////////////////////////////////////////////////////
// For recv, it will go from lower to higher, so in this case:
// check ignore, decrypt (encryption), translate
@@ -137,30 +135,19 @@ struct PROTOFILETRANSFERSTATUS // The DB will store higher numbers here, LOWER in the protocol chain, and lower numbers
// here HIGHER in the protocol chain
-#define PROTOTYPE_IGNORE 50 // added during v0.3.3
-#define PROTOTYPE_PROTOCOL 1000
-#define PROTOTYPE_VIRTUAL 1001 // virtual protocol (has no accounts)
-#define PROTOTYPE_ENCRYPTION 2000
-#define PROTOTYPE_FILTER 3000
-#define PROTOTYPE_TRANSLATION 4000
-#define PROTOTYPE_OTHER 10000 // avoid using this if at all possible
-
- // initializes an empty account
-typedef struct PROTO_INTERFACE* (*pfnInitProto)(const char* szModuleName, const wchar_t* szUserName);
-
-// deallocates an account instance
-typedef int (*pfnUninitProto)(PROTO_INTERFACE*);
+#define PROTOTYPE_IGNORE 50 // added during v0.3.3
+#define PROTOTYPE_PROTOCOL 1000 // old style protocol
+#define PROTOTYPE_VIRTUAL 1001 // virtual protocol (has no accounts)
+#define PROTOTYPE_PROTOWITHACCS 1002 // new style protocol
+#define PROTOTYPE_ENCRYPTION 2000
+#define PROTOTYPE_FILTER 3000
+#define PROTOTYPE_TRANSLATION 4000
+#define PROTOTYPE_OTHER 10000 // avoid using this if at all possible
struct PROTOCOLDESCRIPTOR
{
- size_t cbSize;
char *szName; // unique name of the module
int type; // module type, see PROTOTYPE_ constants
-
- // these fields should be filled only for protos with accounts
- pfnInitProto fnInit; // initializes an empty account
- pfnUninitProto fnUninit; // deallocates an account instance
- HINSTANCE hInst; // module to which that proto belongs to
};
/////////////////////////////////////////////////////////////////////////////////////////
@@ -428,7 +415,7 @@ typedef struct { // PROTOTYPE_PROTOCOL modules must not do this. The value must be exact.
// See MS_PROTO_ENUMPROTOCOLS for more notes.
-EXTERN_C MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR*);
+EXTERN_C MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_RegisterModule(int type, const char *szName);
/////////////////////////////////////////////////////////////////////////////////////////
// adds the specified protocol module to the chain for a contact
diff --git a/include/newpluginapi.h b/include/newpluginapi.h index 6ced312160..85d0b94007 100644 --- a/include/newpluginapi.h +++ b/include/newpluginapi.h @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define M_NEWPLUGINAPI_H__
#include <m_core.h>
+#include <m_database.h>
#define PLUGIN_MAKE_VERSION(a, b, c, d) (((((DWORD)(a))&0xFF)<<24)|((((DWORD)(b))&0xFF)<<16)|((((DWORD)(c))&0xFF)<<8)|(((DWORD)(d))&0xFF))
#define MAXMODULELABELLENGTH 64
@@ -142,4 +143,263 @@ struct PLUGININFOEX EXTERN_C MIR_CORE_DLL(void) mir_getLP(const PLUGININFOEX *pInfo, int *_hLang = &hLangpack);
+/////////////////////////////////////////////////////////////////////////////////////////
+// plugin's class
+
+// initializes an empty account
+typedef struct PROTO_INTERFACE* (*pfnInitProto)(const char* szModuleName, const wchar_t* szUserName);
+
+// deallocates an account instance
+typedef int(*pfnUninitProto)(PROTO_INTERFACE*);
+
+class MIR_APP_EXPORT CMPluginBase
+{
+ void tryOpenLog();
+
+protected:
+ const char *m_szModuleName;
+ HANDLE m_hLogger = nullptr;
+ HINSTANCE m_hInst;
+
+ CMPluginBase(const char *moduleName);
+ ~CMPluginBase();
+
+ // pass one of PROTOTYPE_* constants as type
+ void RegisterProtocol(int type, pfnInitProto = nullptr, pfnUninitProto = nullptr);
+ void SetUniqueId(const char *pszUniqueId);
+
+public:
+ void debugLogA(LPCSTR szFormat, ...);
+ void debugLogW(LPCWSTR wszFormat, ...);
+
+ __forceinline HINSTANCE getInst() const { return m_hInst; }
+ __forceinline void setInst(HINSTANCE hInst) { m_hInst = hInst; }
+
+ __forceinline INT_PTR delSetting(const char *name)
+ {
+ return db_unset(0, m_szModuleName, name);
+ }
+ __forceinline INT_PTR delSetting(MCONTACT hContact, const char *name)
+ {
+ return db_unset(hContact, m_szModuleName, name);
+ }
+
+ __forceinline bool getBool(const char *name, bool defaultValue = false)
+ {
+ return db_get_b(0, m_szModuleName, name, defaultValue) != 0;
+ }
+ __forceinline bool getBool(MCONTACT hContact, const char *name, bool defaultValue = false)
+ {
+ return db_get_b(hContact, m_szModuleName, name, defaultValue) != 0;
+ }
+
+ __forceinline int getByte(const char *name, BYTE defaultValue = 0)
+ {
+ return db_get_b(0, m_szModuleName, name, defaultValue);
+ }
+ __forceinline int getByte(MCONTACT hContact, const char *name, BYTE defaultValue = 0)
+ {
+ return db_get_b(hContact, m_szModuleName, name, defaultValue);
+ }
+
+ __forceinline int getWord(const char *name, WORD defaultValue = 0)
+ {
+ return db_get_w(0, m_szModuleName, name, defaultValue);
+ }
+ __forceinline int getWord(MCONTACT hContact, const char *name, WORD defaultValue = 0)
+ {
+ return db_get_w(hContact, m_szModuleName, name, defaultValue);
+ }
+
+ __forceinline DWORD getDword(const char *name, DWORD defaultValue = 0)
+ {
+ return db_get_dw(0, m_szModuleName, name, defaultValue);
+ }
+ __forceinline DWORD getDword(MCONTACT hContact, const char *name, DWORD defaultValue = 0)
+ {
+ return db_get_dw(hContact, m_szModuleName, name, defaultValue);
+ }
+
+ __forceinline INT_PTR getString(const char *name, DBVARIANT *result)
+ {
+ return db_get_s(0, m_szModuleName, name, result);
+ }
+ __forceinline INT_PTR getString(MCONTACT hContact, const char *name, DBVARIANT *result)
+ {
+ return db_get_s(hContact, m_szModuleName, name, result);
+ }
+
+ __forceinline INT_PTR getWString(const char *name, DBVARIANT *result)
+ {
+ return db_get_ws(0, m_szModuleName, name, result);
+ }
+ __forceinline INT_PTR getWString(MCONTACT hContact, const char *name, DBVARIANT *result)
+ {
+ return db_get_ws(hContact, m_szModuleName, name, result);
+ }
+
+ __forceinline char* getStringA(const char *name)
+ {
+ return db_get_sa(0, m_szModuleName, name);
+ }
+ __forceinline char* getStringA(MCONTACT hContact, const char *name)
+ {
+ return db_get_sa(hContact, m_szModuleName, name);
+ }
+
+ __forceinline wchar_t* getWStringA(const char *name)
+ {
+ return db_get_wsa(0, m_szModuleName, name);
+ }
+ __forceinline wchar_t* getWStringA(MCONTACT hContact, const char *name)
+ {
+ return db_get_wsa(hContact, m_szModuleName, name);
+ }
+
+ __forceinline void setByte(const char *name, BYTE value)
+ {
+ db_set_b(0, m_szModuleName, name, value);
+ }
+ __forceinline void setByte(MCONTACT hContact, const char *name, BYTE value)
+ {
+ db_set_b(hContact, m_szModuleName, name, value);
+ }
+
+ __forceinline void setWord(const char *name, WORD value)
+ {
+ db_set_w(0, m_szModuleName, name, value);
+ }
+ __forceinline void setWord(MCONTACT hContact, const char *name, WORD value)
+ {
+ db_set_w(hContact, m_szModuleName, name, value);
+ }
+
+ __forceinline void setDword(const char *name, DWORD value)
+ {
+ db_set_dw(0, m_szModuleName, name, value);
+ }
+ __forceinline void setDword(MCONTACT hContact, const char *name, DWORD value)
+ {
+ db_set_dw(hContact, m_szModuleName, name, value);
+ }
+
+ __forceinline void setString(const char *name, const char* value)
+ {
+ db_set_s(0, m_szModuleName, name, value);
+ }
+ __forceinline void setString(MCONTACT hContact, const char *name, const char* value)
+ {
+ db_set_s(hContact, m_szModuleName, name, value);
+ }
+
+ __forceinline void setWString(const char *name, const wchar_t* value)
+ {
+ db_set_ws(0, m_szModuleName, name, value);
+ }
+ __forceinline void setWString(MCONTACT hContact, const char *name, const wchar_t* value)
+ {
+ db_set_ws(hContact, m_szModuleName, name, value);
+ }
+};
+
+extern struct CMPlugin g_plugin;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Basic class for plugins (not protocols) written in C++
+
+typedef BOOL(WINAPI * const _pfnCrtInit)(HINSTANCE, DWORD, LPVOID);
+
+template<class T> class PLUGIN : public CMPluginBase
+{
+ typedef CMPluginBase CSuper;
+
+public:
+ static BOOL WINAPI RawDllMain(HINSTANCE hInstance, DWORD, LPVOID)
+ {
+ g_plugin.setInst(hInstance);
+ return TRUE;
+ }
+
+protected:
+ PLUGIN(const char *moduleName)
+ : CSuper(moduleName)
+ {}
+
+ __forceinline HANDLE CreatePluginEvent(const char *name)
+ {
+ CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name);
+ return CreateHookableEvent(str);
+ }
+
+ typedef int(__cdecl T::*MyEventFunc)(WPARAM, LPARAM);
+ __forceinline void HookPluginEvent(const char *name, MyEventFunc pFunc)
+ {
+ HookEventObj(name, (MIRANDAHOOKOBJ)*(void**)&pFunc, this);
+ }
+
+ typedef INT_PTR(__cdecl T::*MyServiceFunc)(WPARAM, LPARAM);
+ __forceinline void CreatePluginService(const char *name, MyServiceFunc pFunc)
+ {
+ CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name);
+ CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&pFunc, this);
+ }
+
+ typedef INT_PTR(__cdecl T::*MyServiceFuncParam)(WPARAM, LPARAM, LPARAM);
+ __forceinline void CreatePluginServiceParam(const char *name, MyServiceFuncParam pFunc, LPARAM param)
+ {
+ CMStringA str(FORMAT, "%s\\%s", m_szModuleName, name);
+ CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&pFunc, this, param);
+ }
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Basic class for protocols with accounts
+
+struct CMPlugin;
+
+template<class P> class ACCPROTOPLUGIN : public PLUGIN<CMPlugin>
+{
+ typedef PLUGIN<CMPlugin> CSuper;
+
+protected:
+ ACCPROTOPLUGIN(const char *moduleName) :
+ CSuper(moduleName)
+ {
+ CMPluginBase::RegisterProtocol(1002, &fnInit, &fnUninit);
+ }
+
+ static PROTO_INTERFACE* fnInit(const char *szModuleName, const wchar_t *wszAccountName)
+ {
+ P *ppro = new P(szModuleName, wszAccountName);
+ g_arInstances.insert(ppro);
+ return ppro;
+ }
+
+ static int fnUninit(PROTO_INTERFACE *ppro)
+ {
+ g_arInstances.remove((P*)ppro);
+ return 0;
+ }
+
+public:
+ static OBJLIST<P> g_arInstances;
+
+ static P* getInstance(const char *szProto)
+ {
+ for (auto &it : g_arInstances)
+ if (mir_strcmp(szProto, it->m_szModuleName) == 0)
+ return it;
+
+ return nullptr;
+ }
+
+ static P* getInstance(MCONTACT hContact)
+ {
+ return getInstance(::GetContactProto(hContact));
+ }
+};
+
+template<class P>
+OBJLIST<P> ACCPROTOPLUGIN<P>::g_arInstances(1, PtrKeySortT);
+
#endif // M_NEWPLUGINAPI_H__
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 7f0eefa35b..b61f8a8b11 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index d36bac1e4e..58edd6b794 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -129,7 +129,7 @@ static void LoadDefaultInfo() static void LoadProtoInfo(PROTOCOLDESCRIPTOR *proto)
{
- if (proto->type != PROTOTYPE_PROTOCOL || proto->cbSize != sizeof(*proto))
+ if (proto->type != PROTOTYPE_PROTOWITHACCS)
return;
char protoName[MAX_PATH];
diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp index a738bbe09b..528cb8e386 100644 --- a/plugins/CloudFile/src/Services/dropbox_service.cpp +++ b/plugins/CloudFile/src/Services/dropbox_service.cpp @@ -315,7 +315,7 @@ struct CMPluginDropbox : public PLUGIN<CMPluginDropbox> { m_hInst = g_plugin.getInst(); - RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CDropboxService::Init, (pfnUninitProto)CDropboxService::UnInit); + RegisterProtocol(PROTOTYPE_PROTOWITHACCS, (pfnInitProto)CDropboxService::Init, (pfnUninitProto)CDropboxService::UnInit); } } g_pluginDropbox; diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp index e3a7a95d15..05befd78f7 100644 --- a/plugins/CloudFile/src/Services/google_service.cpp +++ b/plugins/CloudFile/src/Services/google_service.cpp @@ -299,7 +299,7 @@ struct CMPluginGoogle : public CMPluginBase { m_hInst = g_plugin.getInst(); - RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CGDriveService::Init, (pfnUninitProto)CGDriveService::UnInit); + RegisterProtocol(PROTOTYPE_PROTOWITHACCS, (pfnInitProto)CGDriveService::Init, (pfnUninitProto)CGDriveService::UnInit); } } g_pluginGoogle; diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp index c4ec053eaa..1de8e52ee9 100644 --- a/plugins/CloudFile/src/Services/microsoft_service.cpp +++ b/plugins/CloudFile/src/Services/microsoft_service.cpp @@ -284,7 +284,7 @@ struct CMPluginOnedrive : public CMPluginBase { m_hInst = g_plugin.getInst(); - RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)COneDriveService::Init, (pfnUninitProto)COneDriveService::UnInit); + RegisterProtocol(PROTOTYPE_PROTOWITHACCS, (pfnInitProto)COneDriveService::Init, (pfnUninitProto)COneDriveService::UnInit); } } g_pluginOnedrive; diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp index e05f216698..3e5e63440b 100644 --- a/plugins/CloudFile/src/Services/yandex_service.cpp +++ b/plugins/CloudFile/src/Services/yandex_service.cpp @@ -294,7 +294,7 @@ struct CMPluginYandex : public CMPluginBase { m_hInst = g_plugin.getInst(); - RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CYandexService::Init, (pfnUninitProto)CYandexService::UnInit); + RegisterProtocol(PROTOTYPE_PROTOWITHACCS, (pfnInitProto)CYandexService::Init, (pfnUninitProto)CYandexService::UnInit); } } g_pluginYandex; diff --git a/plugins/CloudFile/src/services.cpp b/plugins/CloudFile/src/services.cpp index 28cda47967..edaad32901 100644 --- a/plugins/CloudFile/src/services.cpp +++ b/plugins/CloudFile/src/services.cpp @@ -95,10 +95,7 @@ INT_PTR Upload(WPARAM wParam, LPARAM lParam) void InitializeServices() { - PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; - pd.type = PROTOTYPE_FILTER; - pd.szName = MODULE; - Proto_RegisterModule(&pd); + Proto_RegisterModule(PROTOTYPE_FILTER, MODULE); CreateServiceFunction(MODULE PSS_FILE, SendFileInterceptor); diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h index d475b54c11..5cfc53b59a 100644 --- a/plugins/CloudFile/src/stdafx.h +++ b/plugins/CloudFile/src/stdafx.h @@ -30,7 +30,6 @@ #include <m_metacontacts.h> #include <m_protoint.h> #include <m_protosvc.h> -#include <m_plugin.h> #include <m_cloudfile.h> diff --git a/plugins/ConnectionNotify/src/stdafx.h b/plugins/ConnectionNotify/src/stdafx.h index fda6ae7b09..659fac668b 100644 --- a/plugins/ConnectionNotify/src/stdafx.h +++ b/plugins/ConnectionNotify/src/stdafx.h @@ -16,7 +16,6 @@ #include <m_utils.h>
#include <m_protosvc.h>
#include <m_system.h>
-#include <m_plugin.h>
#ifdef _DEBUG
#include "debug.h"
diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp index f3c32a4037..1eb4113e24 100644 --- a/plugins/CrashDumper/src/dumper.cpp +++ b/plugins/CrashDumper/src/dumper.cpp @@ -283,8 +283,11 @@ static void GetProtocolStrings(CMStringW &buffer) char **protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*));
for (int i = 0; i < protoCount; i++)
- if (protoList[i]->type == PROTOTYPE_PROTOCOL)
+ switch (protoList[i]->type) {
+ case PROTOTYPE_PROTOCOL:
+ case PROTOTYPE_PROTOWITHACCS:
protoListMy[protoCountMy++] = protoList[i]->szName;
+ }
for (int j = 0; j < accCount; j++) {
int i;
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index 72c1dc1e2e..922ca181ce 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -52,11 +52,7 @@ extern "C" __declspec(dllexport) int Load() mir_getLP(&pluginInfoEx);
// register plugin module
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = (char*)szModuleName;
- pd.type = PROTOTYPE_ENCRYPTION;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_ENCRYPTION, szModuleName);
// hook events
HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded);
diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp index 52eb90b6ef..53382af667 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp +++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp @@ -28,11 +28,7 @@ char *TransliterationProtocol::MODULE_NAME = "ProtoCyrTranslitByIKR"; void TransliterationProtocol::initialize()
{
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = MODULE_NAME;
- pd.type = PROTOTYPE_TRANSLATION;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_TRANSLATION, MODULE_NAME);
CreateProtoServiceFunction(MODULE_NAME, PSS_MESSAGE, sendMessage);
}
diff --git a/plugins/Exchange/src/stdafx.h b/plugins/Exchange/src/stdafx.h index 1358ddbb07..075d19ddd9 100644 --- a/plugins/Exchange/src/stdafx.h +++ b/plugins/Exchange/src/stdafx.h @@ -40,7 +40,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_clist.h>
#include <m_langpack.h>
#include <m_utils.h>
-#include <m_plugin.h>
#include "resource.h"
#include "version.h"
diff --git a/plugins/FileAsMessage/src/main.cpp b/plugins/FileAsMessage/src/main.cpp index 092e6cc6f0..abb3068398 100644 --- a/plugins/FileAsMessage/src/main.cpp +++ b/plugins/FileAsMessage/src/main.cpp @@ -202,11 +202,7 @@ extern "C" __declspec(dllexport) int Load(void) CreateServiceFunction(SERVICE_NAME "/FESendFile", OnSendFile);
CreateServiceFunction(SERVICE_NAME "/FERecvFile", OnRecvFile);
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = SERVICE_NAME;
- pd.type = PROTOTYPE_FILTER;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_FILTER, SERVICE_NAME);
HookEvent(ME_OPT_INITIALISE, OnOptInitialise);
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp index 945ab5984d..c3add00af0 100644 --- a/plugins/GmailNotifier/src/main.cpp +++ b/plugins/GmailNotifier/src/main.cpp @@ -11,7 +11,6 @@ There is no warranty. #include "version.h"
CLIST_INTERFACE *pcli;
-HINSTANCE g_hInstance;
int hLangpack;
UINT hTimer;
HANDLE hMirandaStarted, hOptionsInitial;
@@ -37,6 +36,19 @@ static PLUGININFOEX pluginInfoEx = { 0x243955e0, 0x75d9, 0x4cc3, { 0x9b, 0x28, 0x6f, 0x9c, 0x5a, 0xf4, 0x53, 0x2d } }
};
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfoEx;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMPlugin g_plugin;
+
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR GetCaps(WPARAM wParam, LPARAM)
{
if (wParam == PFLAGNUM_2 && opt.ShowCustomIcon)
@@ -75,11 +87,6 @@ static int OnMirandaStart(WPARAM, LPARAM) return 0;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
-{
- return &pluginInfoEx;
-}
-
extern "C" int __declspec(dllexport) Load()
{
mir_getLP(&pluginInfoEx);
@@ -146,6 +153,8 @@ extern "C" int __declspec(dllexport) Load() return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
extern "C" int __declspec(dllexport) Unload(void)
{
if (hTimer)
@@ -161,17 +170,3 @@ extern "C" int __declspec(dllexport) Unload(void) UnhookEvent(hOptionsInitial);
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-struct CMPlugin : public PLUGIN<CMPlugin>
-{
- CMPlugin() :
- PLUGIN<CMPlugin>(MODULE_NAME)
- {
- RegisterProtocol(PROTOTYPE_VIRTUAL);
- }
-}
- g_plugin;
-
-extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp index 4aafb314f6..9d15fbe1ac 100644 --- a/plugins/GmailNotifier/src/options.cpp +++ b/plugins/GmailNotifier/src/options.cpp @@ -272,7 +272,7 @@ int OptInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = { 0 };
odp.position = -790000000;
- odp.hInstance = g_hInstance;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
odp.szTitle.a = LPGEN("GmailNotifier");
odp.szGroup.a = LPGEN("Network");
diff --git a/plugins/GmailNotifier/src/stdafx.h b/plugins/GmailNotifier/src/stdafx.h index c098816cef..f5cedab022 100644 --- a/plugins/GmailNotifier/src/stdafx.h +++ b/plugins/GmailNotifier/src/stdafx.h @@ -20,7 +20,6 @@ #include "m_clc.h"
#include "m_popup.h"
#include "m_netlib.h"
-#include <m_plugin.h>
#define WM_SHELLNOTIFY WM_USER+5
#define IDI_TRAY WM_USER+6
@@ -73,7 +72,6 @@ struct optionSettings extern OBJLIST<Account> g_accs;
extern optionSettings opt;
-extern HINSTANCE g_hInstance;
extern HNETLIBUSER hNetlibUser;
extern UINT hTimer;
extern short ID_STATUS_NONEW;
@@ -93,3 +91,12 @@ void DeleteResults(resultLink *); void BuildList(void);
Account* GetAccountByContact(MCONTACT hContact);
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE_NAME)
+ {
+ RegisterProtocol(PROTOTYPE_VIRTUAL);
+ }
+};
diff --git a/plugins/LotusNotify/src/stdafx.h b/plugins/LotusNotify/src/stdafx.h index 9a95f7a7f8..aba429fb15 100644 --- a/plugins/LotusNotify/src/stdafx.h +++ b/plugins/LotusNotify/src/stdafx.h @@ -22,7 +22,6 @@ #include <m_protosvc.h>
#include <m_system.h>
#include <m_netlib.h>
-#include <m_plugin.h>
// Notesapi headers
#define W32
diff --git a/plugins/MirLua/src/main.cpp b/plugins/MirLua/src/main.cpp index d316b47cd0..cee700e68b 100644 --- a/plugins/MirLua/src/main.cpp +++ b/plugins/MirLua/src/main.cpp @@ -74,11 +74,7 @@ extern "C" int __declspec(dllexport) Load(void) nlu.szSettingsModule = MODULE;
hNetlib = Netlib_RegisterUser(&nlu);
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = MODULE;
- pd.type = PROTOTYPE_FILTER;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_FILTER, MODULE);
hRecvMessage = CreateHookableEvent(MODULE PSR_MESSAGE);
CreateProtoServiceFunction(MODULE, PSR_MESSAGE, FilterRecvMessage);
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index 3b5d8ffb6d..98b45c6a4a 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -26,7 +26,6 @@ #include <m_toptoolbar.h>
#include <m_json.h>
#include <m_gui.h>
-#include <m_plugin.h>
#include <m_lua.h>
#include <mirlua.h>
diff --git a/plugins/MirOTR/src/dllmain.cpp b/plugins/MirOTR/src/dllmain.cpp index 16ff5afaa8..e548c017dc 100644 --- a/plugins/MirOTR/src/dllmain.cpp +++ b/plugins/MirOTR/src/dllmain.cpp @@ -72,11 +72,7 @@ extern "C" __declspec(dllexport) int Load(void) ////////////////////////////////////////////////////////////////////////////
// init plugin
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = MODULENAME;
- pd.type = PROTOTYPE_ENCRYPTION;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_ENCRYPTION, MODULENAME);
// remove us as a filter to all contacts - fix filter type problem
if(db_get_b(0, MODULENAME, "FilterOrderFix", 0) != 2) {
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index e83731181b..148555015d 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -136,11 +136,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) HookEvent(ME_MSG_WINDOWEVENT, onWindowEvent); HookEvent(ME_MSG_ICONPRESSED, onIconPressed); - PROTOCOLDESCRIPTOR pd = { 0 }; - pd.cbSize = sizeof(pd); - pd.szName = szGPGModuleName; - pd.type = PROTOTYPE_ENCRYPTION; - Proto_RegisterModule(&pd); + Proto_RegisterModule(PROTOTYPE_ENCRYPTION, szGPGModuleName); CreateProtoServiceFunction(szGPGModuleName, PSR_MESSAGE, RecvMsgSvc); CreateProtoServiceFunction(szGPGModuleName, PSS_MESSAGE, SendMsgSvc); diff --git a/plugins/NewsAggregator/Src/stdafx.h b/plugins/NewsAggregator/Src/stdafx.h index f0f8cd793e..834e47b174 100644 --- a/plugins/NewsAggregator/Src/stdafx.h +++ b/plugins/NewsAggregator/Src/stdafx.h @@ -45,7 +45,6 @@ Boston, MA 02111-1307, USA. #include <m_avatars.h>
#include <m_hotkeys.h>
#include <m_gui.h>
-#include <m_plugin.h>
#include <m_folders.h>
#include <m_toptoolbar.h>
diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index c8f6738916..1497c970df 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -44,7 +44,6 @@ struct DLGTEMPLATEEX #include <m_utils.h>
#include <m_ignore.h>
#include <m_netlib.h>
-#include <m_plugin.h>
#include <m_string.h>
#include <win2k.h>
diff --git a/plugins/Quotes/src/stdafx.h b/plugins/Quotes/src/stdafx.h index 5f9f29486d..ea4fed341e 100644 --- a/plugins/Quotes/src/stdafx.h +++ b/plugins/Quotes/src/stdafx.h @@ -29,7 +29,6 @@ #include <m_netlib.h>
#include <m_popup.h>
#include <m_userinfo.h>
-#include <m_plugin.h>
#include <m_variables.h>
#include <m_Quotes.h>
diff --git a/plugins/Rate/src/stdafx.h b/plugins/Rate/src/stdafx.h index be91171499..e04a7de369 100644 --- a/plugins/Rate/src/stdafx.h +++ b/plugins/Rate/src/stdafx.h @@ -28,7 +28,6 @@ #include <m_database.h>
#include <m_langpack.h>
#include <m_extraicons.h>
-#include <m_plugin.h>
#include "resource.h"
#include "version.h"
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 87a021d713..4cfa2d69b2 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -326,11 +326,7 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) }
// register plugin module
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = (char*)MODULENAME;
- pd.type = PROTOTYPE_ENCRYPTION;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_ENCRYPTION, MODULENAME);
// hook events
HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded);
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index d4c4fdf5d0..73a303a393 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -832,7 +832,7 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void) for (int i = 0; i < protoCount; i++) {
PROTOCOLDESCRIPTOR *pd = proto[i];
- if (pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof(*pd))
+ if (pd->type == PROTOTYPE_PROTOWITHACCS)
AddProtoAsCategory(pd->szName, defaultFile);
}
diff --git a/plugins/StartPosition/src/stdafx.h b/plugins/StartPosition/src/stdafx.h index a4995fad9b..c6a7682aef 100644 --- a/plugins/StartPosition/src/stdafx.h +++ b/plugins/StartPosition/src/stdafx.h @@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_gui.h>
#include <m_langpack.h>
#include <m_options.h>
-#include <m_plugin.h>
#include "resource.h"
#include "version.h"
diff --git a/plugins/Watrack/proto/proto.pas b/plugins/Watrack/proto/proto.pas index 33098c7f42..3025ab76f3 100644 --- a/plugins/Watrack/proto/proto.pas +++ b/plugins/Watrack/proto/proto.pas @@ -318,13 +318,8 @@ begin end;
procedure SetProtocol;
-var
- desc:TPROTOCOLDESCRIPTOR;
begin
- desc.cbSize:=SizeOf(desc);
- desc.szName:=PluginShort;
- desc._type :=PROTOTYPE_TRANSLATION;
- Proto_RegisterModule(@desc);
+ Proto_RegisterModule(PROTOTYPE_TRANSLATION,PluginShort);
hSRM:=CreateProtoServiceFunction(PluginShort,PSR_MESSAGE ,@ReceiveMessageProcW);
end;
diff --git a/plugins/Weather/src/stdafx.h b/plugins/Weather/src/stdafx.h index 26c46861ea..9d0c550575 100644 --- a/plugins/Weather/src/stdafx.h +++ b/plugins/Weather/src/stdafx.h @@ -54,7 +54,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_popup.h>
#include <win2k.h>
#include <m_acc.h>
-#include <m_plugin.h>
#include <m_weather.h>
#include <m_toptoolbar.h>
diff --git a/plugins/WebView/src/stdafx.h b/plugins/WebView/src/stdafx.h index 64808dddad..3ce8c77b06 100644 --- a/plugins/WebView/src/stdafx.h +++ b/plugins/WebView/src/stdafx.h @@ -31,7 +31,6 @@ #include <m_netlib.h>
#include <m_langpack.h>
#include <m_findadd.h>
-#include <m_plugin.h>
#include "resource.h"
#include "version.h"
diff --git a/plugins/YAMN/src/stdafx.h b/plugins/YAMN/src/stdafx.h index eb842b2efa..b5612aa639 100644 --- a/plugins/YAMN/src/stdafx.h +++ b/plugins/YAMN/src/stdafx.h @@ -29,7 +29,6 @@ #include <m_yamn.h>
#include <m_protoplugin.h>
#include <m_folders.h>
-#include <m_plugin.h>
#include "main.h"
#include "mails/decode.h"
diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr index a61dae29c5..d7cb1dade7 100644 --- a/plugins/mRadio/mradio.dpr +++ b/plugins/mRadio/mradio.dpr @@ -201,16 +201,9 @@ exports Load, Unload,
MirandaPluginInfoEx;
-var
- desc:TPROTOCOLDESCRIPTOR;
-
begin
// register protocol
- desc.cbSize:=SizeOf(desc);
- desc.szName:=PluginName;
- desc._type :=PROTOTYPE_VIRTUAL;
- Proto_RegisterModule(@desc);
-
+ Proto_RegisterModule(PROTOTYPE_VIRTUAL,PluginName);
Proto_SetUniqueId(PluginName,optStationURL);
DisableThreadLibraryCalls(hInstance);
diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h index 76a0d44862..91c99ee7f7 100644 --- a/protocols/Discord/src/stdafx.h +++ b/protocols/Discord/src/stdafx.h @@ -38,7 +38,6 @@ #include <m_hotkeys.h> #include <m_json.h> #include <m_avatars.h> -#include <m_plugin.h> #include <win2k.h> #include "../../libs/zlib/src/zlib.h" diff --git a/protocols/Dummy/src/stdafx.h b/protocols/Dummy/src/stdafx.h index 1ebadd033c..26ecb0a4bf 100644 --- a/protocols/Dummy/src/stdafx.h +++ b/protocols/Dummy/src/stdafx.h @@ -54,7 +54,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_userinfo.h> #include <m_utils.h> #include <m_proto_listeningto.h> -#include <m_plugin.h> #include <m_folders.h> diff --git a/protocols/EmLanProto/src/stdafx.h b/protocols/EmLanProto/src/stdafx.h index f3156dd280..1fc82252ce 100644 --- a/protocols/EmLanProto/src/stdafx.h +++ b/protocols/EmLanProto/src/stdafx.h @@ -16,7 +16,6 @@ #include <m_protosvc.h>
#include <m_database.h>
#include <m_langpack.h>
-#include <m_plugin.h>
#include "resource.h"
#include "version.h"
diff --git a/protocols/FacebookRM/src/stdafx.h b/protocols/FacebookRM/src/stdafx.h index f41eb6c7f1..1016b54eb8 100644 --- a/protocols/FacebookRM/src/stdafx.h +++ b/protocols/FacebookRM/src/stdafx.h @@ -62,7 +62,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_http.h>
#include <m_messagestate.h>
#include <m_gui.h>
-#include <m_plugin.h>
class FacebookProto;
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index f02dc0be26..be94b8cfb9 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -69,7 +69,6 @@ #include <win2k.h>
#include <m_folders.h>
#include <m_gui.h>
-#include <m_plugin.h>
// libgadu headers
#include "libgadu.h"
diff --git a/protocols/ICQCorp/src/corp.cpp b/protocols/ICQCorp/src/corp.cpp index 38355f466b..523917cb3e 100644 --- a/protocols/ICQCorp/src/corp.cpp +++ b/protocols/ICQCorp/src/corp.cpp @@ -62,11 +62,7 @@ BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID) findData.cFileName[strlen(findData.cFileName) - 4] = 0;
strncpy_s(protoName, findData.cFileName, _TRUNCATE);
- PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
- pd.szName = protoName;
- pd.type = PROTOTYPE_PROTOCOL;
- Proto_RegisterModule(&pd);
-
+ Proto_RegisterModule(PROTOTYPE_PROTOCOL, protoName);
Proto_SetUniqueId(protoName, "UIN");
DisableThreadLibraryCalls(hModule);
diff --git a/protocols/ICQCorp/src/stdafx.h b/protocols/ICQCorp/src/stdafx.h index 99837f6a28..747f1805bf 100644 --- a/protocols/ICQCorp/src/stdafx.h +++ b/protocols/ICQCorp/src/stdafx.h @@ -37,7 +37,6 @@ #include <m_clist.h> #include <m_userinfo.h> #include <m_timezones.h> -#include <m_plugin.h> #include <m_netlib.h> #include "user.h" diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index fff9477127..37343328b9 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -66,7 +66,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_string.h"
#include "win2k.h"
#include "m_gui.h"
-#include <m_plugin.h>
#include "resource.h"
diff --git a/protocols/IcqOscarJ/src/stdafx.h b/protocols/IcqOscarJ/src/stdafx.h index 303c6f363e..9aefe64717 100644 --- a/protocols/IcqOscarJ/src/stdafx.h +++ b/protocols/IcqOscarJ/src/stdafx.h @@ -80,7 +80,6 @@ #include <m_timezones.h>
#include <win2k.h>
#include <m_gui.h>
-#include <m_plugin.h>
// Project resources
#include "resource.h"
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 72833d8381..36b8b8c8bd 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -87,7 +87,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <win2k.h>
#include <m_imgsrvc.h>
#include <m_clc.h>
-#include <m_plugin.h>
#include <m_folders.h>
#include <m_fingerprint.h>
diff --git a/protocols/MRA/src/stdafx.h b/protocols/MRA/src/stdafx.h index bd34263f9b..6ee9201b4c 100644 --- a/protocols/MRA/src/stdafx.h +++ b/protocols/MRA/src/stdafx.h @@ -50,7 +50,6 @@ #include <m_xstatus.h>
#include <m_nudge.h>
#include <m_proto_listeningto.h>
-#include <m_plugin.h>
#define PROTO_VERSION_MAJOR 1
#define PROTO_VERSION_MINOR 21
diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index f996fcdecc..dc4567fc45 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -63,7 +63,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_nudge.h>
#include <m_string.h>
#include <m_json.h>
-#include <m_plugin.h>
#include "m_proto_listeningto.h"
#include "m_folders.h"
diff --git a/protocols/MinecraftDynmap/src/stdafx.h b/protocols/MinecraftDynmap/src/stdafx.h index 7613c4181d..d47e51733c 100644 --- a/protocols/MinecraftDynmap/src/stdafx.h +++ b/protocols/MinecraftDynmap/src/stdafx.h @@ -57,7 +57,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_message.h> #include <m_json.h> #include <m_http.h> -#include <m_plugin.h> #include "version.h" diff --git a/protocols/Omegle/src/stdafx.h b/protocols/Omegle/src/stdafx.h index b6aec36b82..cb38f78ec1 100644 --- a/protocols/Omegle/src/stdafx.h +++ b/protocols/Omegle/src/stdafx.h @@ -58,7 +58,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_message.h>
#include <m_http.h>
#include <m_json.h>
-#include <m_plugin.h>
#include "version.h"
diff --git a/protocols/Sametime/src/StdAfx.h b/protocols/Sametime/src/StdAfx.h index 9f8fe88525..5fa7d2b4d3 100644 --- a/protocols/Sametime/src/StdAfx.h +++ b/protocols/Sametime/src/StdAfx.h @@ -75,4 +75,3 @@ extern "C" { #include <m_genmenu.h>
#include <m_icolib.h>
#include <m_string.h>
-#include <m_plugin.h>
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index 0be6ba5730..a9e15f715c 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -54,7 +54,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_xml.h>
#include <m_assocmgr.h>
#include <m_file.h>
-#include <m_plugin.h>
struct CSkypeProto;
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h index 4a70cb0159..1f48146cb7 100644 --- a/protocols/Steam/src/stdafx.h +++ b/protocols/Steam/src/stdafx.h @@ -35,7 +35,6 @@ #include <m_gui.h>
#include <m_http.h>
#include <m_system.h>
-#include <m_plugin.h>
#include "resource.h"
#include "version.h"
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index be29bd7edb..124fc96b0b 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -36,7 +36,6 @@ #include <m_assocmgr.h>
#include <m_json.h>
#include <m_http.h>
-#include <m_plugin.h>
#include <tox.h>
#include <toxencryptsave.h>
diff --git a/protocols/Twitter/src/stdafx.h b/protocols/Twitter/src/stdafx.h index eaae38768d..3eb1d93a87 100644 --- a/protocols/Twitter/src/stdafx.h +++ b/protocols/Twitter/src/stdafx.h @@ -58,7 +58,6 @@ typedef std::basic_string<wchar_t> wstring; #include <m_icolib.h>
#include <m_utils.h>
#include <m_hotkeys.h>
-#include <m_plugin.h>
#include <m_json.h>
#include <win2k.h>
#pragma warning(pop)
diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index 5695d1bbf1..d039a13d52 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -48,7 +48,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_userinfo.h>
#include <m_proto_listeningto.h>
#include <m_gui.h>
-#include <m_plugin.h>
#include <m_messagestate.h>
#include <m_popup.h>
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index 55b557c0cc..e30fdb3320 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -68,12 +68,18 @@ void CMPluginBase::debugLogW(LPCWSTR wszFormat, ...) void CMPluginBase::RegisterProtocol(int type, pfnInitProto fnInit, pfnUninitProto fnUninit) { - PROTOCOLDESCRIPTOR pd = {}; - pd.cbSize = (fnInit == nullptr) ? PROTOCOLDESCRIPTOR_V3_SIZE : sizeof(pd); - pd.szName = (char*)m_szModuleName; - pd.type = type; - pd.fnInit = fnInit; - pd.fnUninit = fnUninit; - pd.hInst = m_hInst; - Proto_RegisterModule(&pd); + if (type == PROTOTYPE_PROTOCOL && fnInit != nullptr) + type = PROTOTYPE_PROTOWITHACCS; + + MBaseProto *pd = (MBaseProto*)Proto_RegisterModule(type, m_szModuleName); + if (pd) { + pd->fnInit = fnInit; + pd->fnUninit = fnUninit; + pd->hInst = m_hInst; + } +} + +void CMPluginBase::SetUniqueId(const char *pszUniqueId) +{ + ::Proto_SetUniqueId(m_szModuleName, pszUniqueId); } diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 37d5471e88..bf7e23e659 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -418,11 +418,7 @@ static int IgnoreAddedNotify(WPARAM, LPARAM lParam) int LoadIgnoreModule(void)
{
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = "Ignore";
- pd.type = PROTOTYPE_IGNORE;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_IGNORE, "Ignore");
CreateProtoServiceFunction("Ignore", PSR_MESSAGE, IgnoreRecvMessage);
CreateProtoServiceFunction("Ignore", PSR_URL, IgnoreRecvUrl);
diff --git a/src/mir_app/src/meta_main.cpp b/src/mir_app/src/meta_main.cpp index 9746d605c4..e753ac4e57 100644 --- a/src/mir_app/src/meta_main.cpp +++ b/src/mir_app/src/meta_main.cpp @@ -57,15 +57,8 @@ void UnloadMetacontacts(void) static int RegisterMeta(WPARAM, LPARAM)
{
- PROTOCOLDESCRIPTOR pd = { 0 };
- pd.cbSize = sizeof(pd);
- pd.szName = META_FILTER;
- pd.type = PROTOTYPE_FILTER;
- Proto_RegisterModule(&pd);
-
- pd.szName = META_PROTO;
- pd.type = PROTOTYPE_VIRTUAL;
- Proto_RegisterModule(&pd);
+ Proto_RegisterModule(PROTOTYPE_FILTER, META_FILTER);
+ Proto_RegisterModule(PROTOTYPE_VIRTUAL, META_PROTO);
return 0;
}
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 81360cc8fb..ad3370ff48 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -145,6 +145,10 @@ extern LIST<PROTOACCOUNT> accounts; struct MBaseProto : public PROTOCOLDESCRIPTOR
{
+ pfnInitProto fnInit;
+ pfnUninitProto fnUninit;
+
+ HINSTANCE hInst;
char *szUniqueId; // name of the unique setting that identifies a contact
};
@@ -179,6 +183,7 @@ void HotkeyToName(wchar_t *buf, int size, BYTE shift, BYTE key); WORD GetHotkeyValue(INT_PTR idHotkey);
HBITMAP ConvertIconToBitmap(HIMAGELIST hIml, int iconId);
+MBaseProto* Proto_GetProto(const char *szProtoName);
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 8e05ba2c48..0bc5621fb8 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -288,7 +288,7 @@ static HANDLE CreateProtoServiceEx(const char* szModule, const char* szService, bool ActivateAccount(PROTOACCOUNT *pa, bool bIsDynamic)
{
- PROTOCOLDESCRIPTOR* ppd = Proto_IsProtocolLoaded(pa->szProtoName);
+ MBaseProto *ppd = Proto_GetProto(pa->szProtoName);
if (ppd == nullptr)
return false;
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index adefcd9fd4..f295886181 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -187,7 +187,7 @@ MIR_APP_DLL(int) Proto_AddToContact(MCONTACT hContact, const char *szProto) return 1;
}
- if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL)
+ if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL || pd->type == PROTOTYPE_PROTOWITHACCS)
db_set_s(hContact, "Protocol", "p", szProto);
return 0;
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index 70fdd82876..c0b561d3a1 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -599,7 +599,7 @@ public: m_accList.ResetContent();
for (auto &p : accounts) {
PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(p->szProtoName);
- if (pd != nullptr && pd->type != PROTOTYPE_PROTOCOL)
+ if (pd != nullptr && pd->type != PROTOTYPE_PROTOWITHACCS && pd->type != PROTOTYPE_PROTOCOL)
continue;
int iItem = m_accList.AddString(p->tszAccountName);
@@ -823,7 +823,7 @@ void CAccountFormDlg::OnInitDialog() {
int cnt = 0;
for (auto &it : g_arProtos)
- if (it->type == PROTOTYPE_PROTOCOL && it->cbSize == sizeof(PROTOCOLDESCRIPTOR)) {
+ if (it->type == PROTOTYPE_PROTOWITHACCS) {
m_prototype.AddStringA(it->szName);
++cnt;
}
diff --git a/src/mir_app/src/proto_order.cpp b/src/mir_app/src/proto_order.cpp index afa44d91cf..4eefd4c359 100644 --- a/src/mir_app/src/proto_order.cpp +++ b/src/mir_app/src/proto_order.cpp @@ -102,7 +102,7 @@ static bool ProtoToInclude(PROTOACCOUNT *pa) return false;
PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(pa->szProtoName);
- return (pd != nullptr && pd->type == PROTOTYPE_PROTOCOL);
+ return (pd != nullptr && pd->type == PROTOTYPE_PROTOWITHACCS);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/proto_ui.cpp b/src/mir_app/src/proto_ui.cpp index ba10aeb279..4740148f13 100644 --- a/src/mir_app/src/proto_ui.cpp +++ b/src/mir_app/src/proto_ui.cpp @@ -29,7 +29,7 @@ HINSTANCE ProtoGetInstance(const char *szModuleName) if (pa == nullptr)
return nullptr;
- PROTOCOLDESCRIPTOR *p = Proto_IsProtocolLoaded(pa->szProtoName);
+ MBaseProto *p = Proto_GetProto(pa->szProtoName);
return (p == nullptr) ? nullptr : GetInstByAddress(p->fnInit);
}
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 932d8e6e7f..399943562c 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -34,14 +34,20 @@ extern HANDLE hAckEvent; /////////////////////////////////////////////////////////////////////////////////////////
+MBaseProto* Proto_GetProto(const char *szProtoName)
+{
+ if (szProtoName == nullptr)
+ return nullptr;
+
+ return g_arProtos.find((MBaseProto*)&szProtoName);
+}
+
MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_IsProtocolLoaded(const char *szProtoName)
{
if (szProtoName == nullptr)
return nullptr;
- MBaseProto tmp;
- tmp.szName = (char*)szProtoName;
- return g_arProtos.find(&tmp);
+ return g_arProtos.find((MBaseProto*)&szProtoName);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 7e0b49cdfc..14f679ea9b 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -98,44 +98,33 @@ static PROTO_INTERFACE* defInitProto(const char *szModule, const wchar_t*) return AddDefaultAccount(szModule);
}
-MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR *pd)
+MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_RegisterModule(int type, const char *szName)
{
- if (pd == nullptr)
- return 1;
-
- if (pd->cbSize != sizeof(PROTOCOLDESCRIPTOR) && pd->cbSize != PROTOCOLDESCRIPTOR_V3_SIZE)
- return 1;
+ if (szName == nullptr)
+ return nullptr;
bool bTryActivate = false;
- MBaseProto tmp;
- tmp.szName = (char*)pd->szName;
- MBaseProto *p = g_arProtos.find(&tmp);
- if (p == nullptr) {
- p = (MBaseProto*)mir_calloc(sizeof(MBaseProto));
- p->cbSize = pd->cbSize;
- p->szName = mir_strdup(pd->szName);
- g_arProtos.insert(p);
+ MBaseProto *pd = Proto_GetProto(szName);
+ if (pd == nullptr) {
+ pd = (MBaseProto*)mir_calloc(sizeof(MBaseProto));
+ pd->szName = mir_strdup(szName);
+ g_arProtos.insert(pd);
}
else bTryActivate = true;
- p->type = pd->type;
- p->hInst = pd->hInst;
- if (pd->cbSize == sizeof(PROTOCOLDESCRIPTOR)) {
- p->fnInit = pd->fnInit;
- p->fnUninit = pd->fnUninit;
- }
+ pd->type = type;
- if (p->fnInit == nullptr && (p->type == PROTOTYPE_PROTOCOL || p->type == PROTOTYPE_VIRTUAL)) {
+ if (pd->type == PROTOTYPE_PROTOCOL || pd->type == PROTOTYPE_VIRTUAL) {
// let's create a new container
- PROTO_INTERFACE *ppi = AddDefaultAccount(pd->szName);
+ PROTO_INTERFACE *ppi = AddDefaultAccount(szName);
if (ppi) {
- ppi->m_iVersion = (pd->cbSize == PROTOCOLDESCRIPTOR_V3_SIZE) ? 1 : 2;
+ ppi->m_iVersion = 1;
PROTOACCOUNT *pa = Proto_GetAccount(pd->szName);
if (pa == nullptr) {
pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
- pa->szModuleName = mir_strdup(pd->szName);
- pa->szProtoName = mir_strdup(pd->szName);
- pa->tszAccountName = mir_a2u(pd->szName);
+ pa->szModuleName = mir_strdup(szName);
+ pa->szProtoName = mir_strdup(szName);
+ pa->tszAccountName = mir_a2u(szName);
pa->bIsVisible = pa->bIsEnabled = true;
pa->iOrder = accounts.getCount();
pa->iIconBase = -1;
@@ -143,16 +132,16 @@ MIR_APP_DLL(int) Proto_RegisterModule(PROTOCOLDESCRIPTOR *pd) accounts.insert(pa);
}
pa->bOldProto = true;
- pa->bIsVirtual = (p->type == PROTOTYPE_VIRTUAL);
+ pa->bIsVirtual = (pd->type == PROTOTYPE_VIRTUAL);
pa->ppro = ppi;
- p->fnInit = defInitProto;
- p->fnUninit = FreeDefaultAccount;
+ pd->fnInit = defInitProto;
+ pd->fnUninit = FreeDefaultAccount;
}
}
- if (p->type != PROTOTYPE_PROTOCOL && p->type != PROTOTYPE_VIRTUAL)
- g_arFilters.insert(p);
- return 0;
+ if (pd->type != PROTOTYPE_PROTOCOL && pd->type != PROTOTYPE_VIRTUAL && pd->type != PROTOTYPE_PROTOWITHACCS)
+ g_arFilters.insert(pd);
+ return pd;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -360,7 +349,7 @@ bool PROTOACCOUNT::IsVisible() const {
if (this != nullptr && bIsVisible && IsEnabled() && ppro) {
PROTOCOLDESCRIPTOR *pd = Proto_IsProtocolLoaded(szProtoName);
- if (pd == nullptr || pd->type != PROTOTYPE_PROTOCOL)
+ if (pd == nullptr || (pd->type != PROTOTYPE_PROTOCOL && pd->type != PROTOTYPE_PROTOWITHACCS))
return false;
return (ppro->GetCaps(PFLAGNUM_2, 0) & ~ppro->GetCaps(PFLAGNUM_5, 0));
@@ -520,6 +509,6 @@ void UnloadProtocolsModule() pfnUninitProto GetProtocolDestructor(char *szProto)
{
- PROTOCOLDESCRIPTOR *p = Proto_IsProtocolLoaded(szProto);
+ MBaseProto *p = Proto_GetProto(szProto);
return (p == nullptr) ? nullptr : p->fnUninit;
}
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h index 8163839d31..edc880de52 100644 --- a/src/mir_app/src/stdafx.h +++ b/src/mir_app/src/stdafx.h @@ -92,7 +92,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_gui.h>
#include <m_srmm_int.h>
#include <m_imgsrvc.h>
-#include <m_plugin.h>
#include "miranda.h"
|