From LIVECHAT Developer Zone Wiki
#pragma once
#include "API.h"
class CPlugin;
// Internal window procedure to handle specified messages from application
static LRESULT APIENTRY PluginWindowProc(HWND hWindow, UINT uiMessage, WPARAM wParam, LPARAM lParam);
#define WM_LIVECHAT_RPC WM_USER + 1
typedef struct LIVECHAT_RPC {
int nSize;
LPCTSTR name;
WPARAM wParam;
LPARAM lParam;
} LIVECHAT_RPC;
#define PLUGIN_MAKE_VERSION(a,b,c,d) (((((DWORD)(a))&0xFF)<<24)|((((DWORD)(b))&0xFF)<<16)|((((DWORD)(c))&0xFF)<<8)|(((DWORD)(d))&0xFF))
#define PLUGINTYPE_PROTOCOL 1
#define PLUGINTYPE_HOOK 2
typedef struct PLUGININFO{
int cbSize;
LPCTSTR name;
LPCTSTR dispname;
DWORD version;
LPCTSTR description;
LPCTSTR author;
LPCTSTR copyright;
int type;
} PLUGININFO;
#define BEGIN_PLUGIN_INFO(theClass) \
PLUGININFO* get_plugin_info() \
{ \
static PLUGININFO pluginInfo = { 0 }; \
if(!pluginInfo.cbSize) \
{ \
pluginInfo.cbSize = sizeof(pluginInfo);
#define PLUGIN_NAME(value) pluginInfo.name = value;
#define PLUGIN_DISPNAME(value) pluginInfo.dispname = value;
#define PLUGIN_VERSION(value) pluginInfo.version = value;
#define PLUGIN_DESCRIPTION(value) pluginInfo.description = value;
#define PLUGIN_AUTHOR(value) pluginInfo.author = value;
#define PLUGIN_COPYRIGHT(value) pluginInfo.copyright = value;
#define PLUGIN_HOMEPAGE(value) pluginInfo.homepage = value;
#define PLUGIN_TYPE(value) pluginInfo.type = value;
#define END_PLUGIN_INFO() \
} \
return &pluginInfo; \
}
// Principal base class. Derive your custom class from CPlugin to implement new add-on.
class CPlugin
{
public:
CPlugin(void);
bool DllMain(HINSTANCE hInst, DWORD reason);
PLUGININFO* plugin_info(DWORD version);
HWND load(HINSTANCE hInstance, HWND hwnd);
int unload();
HINSTANCE instance() const { return mInstance; }
DWORD app_version() const { return mAppVersion; }
HWND hwnd() { return mWindow; }
HWND app_hwnd() { return mAppWindow; }
int call(LPCTSTR name, WPARAM wParam, LPARAM lParam);
int call(LPCTSTR command);
LPCTSTR name();
LPCTSTR dispname();
virtual int on_command(LPCTSTR cmd);
virtual int on_command(LPCTSTR cmd, WPARAM wParam, LPARAM lParam);
virtual int on_load();
virtual int on_unload();
virtual PLUGININFO* get_plugin_info() { return 0; }
bool closed() { return mClosed; }
protected:
int create_window(LPCTSTR name);
int destroy_window();
protected:
HINSTANCE mInstance;
HWND mWindow;
HWND mAppWindow;
DWORD mAppVersion;
bool mClosed;
};