summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-18 18:14:33 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-18 18:14:33 +0300
commitb172c4bbc75cdad0e8ccd22292aa671ba43cac45 (patch)
tree4677a04a47f3987c88f3fb44c6b70d2642b1f8a3 /protocols/Gadu-Gadu/src
parent524d1c7186eca3f0a4da08548eeb919785227101 (diff)
PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside
Diffstat (limited to 'protocols/Gadu-Gadu/src')
-rw-r--r--protocols/Gadu-Gadu/src/dialogs.cpp14
-rw-r--r--protocols/Gadu-Gadu/src/gg.cpp18
-rw-r--r--protocols/Gadu-Gadu/src/gg.h2
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h3
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/icolib.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp10
-rw-r--r--protocols/Gadu-Gadu/src/links.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/services.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/sessions.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/token.cpp2
12 files changed, 27 insertions, 36 deletions
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp
index 28a69f80c9..5ebdb40815 100644
--- a/protocols/Gadu-Gadu/src/dialogs.cpp
+++ b/protocols/Gadu-Gadu/src/dialogs.cpp
@@ -357,19 +357,19 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
dat.gg = gg;
if (LOWORD(wParam) == IDC_CREATEACCOUNT) {
dat.mode = GG_USERUTIL_CREATE;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
}
else if (LOWORD(wParam) == IDC_CHPASS) {
dat.mode = GG_USERUTIL_PASS;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
}
else if (LOWORD(wParam) == IDC_CHEMAIL) {
dat.mode = GG_USERUTIL_EMAIL;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
}
else {
dat.mode = GG_USERUTIL_REMOVE;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
}
if (ret == IDOK) {
@@ -759,7 +759,7 @@ int GaduProto::options_init(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.flags = ODPF_UNICODE;
odp.position = 1003000;
- odp.hInstance = hInstance;
+ odp.hInstance = g_hInstance;
odp.szGroup.w = LPGENW("Network");
odp.szTitle.w = m_tszUserName;
odp.dwInitParam = (LPARAM)this;
@@ -809,7 +809,7 @@ int GaduProto::details_init(WPARAM wParam, LPARAM lParam)
OPTIONSDIALOGPAGE odp = { 0 };
odp.flags = ODPF_DONTTRANSLATE | ODPF_UNICODE;
- odp.hInstance = hInstance;
+ odp.hInstance = g_hInstance;
odp.pfnDlgProc = gg_detailsdlgproc;
odp.position = -1900000000;
odp.pszTemplate = pszTemplate;
@@ -867,7 +867,7 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
dat.email = email;
dat.gg = gg;
dat.mode = GG_USERUTIL_CREATE;
- int ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ int ret = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
if (ret == IDOK) {
DBVARIANT dbv;
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp
index 8aeffc1391..bec809277c 100644
--- a/protocols/Gadu-Gadu/src/gg.cpp
+++ b/protocols/Gadu-Gadu/src/gg.cpp
@@ -39,7 +39,7 @@ PLUGININFOEX pluginInfo = {
// Other variables
CMPlugin g_plugin;
-HINSTANCE hInstance;
+HINSTANCE g_hInstance;
SSL_API sslApi;
CLIST_INTERFACE *pcli;
@@ -47,6 +47,8 @@ int hLangpack;
static unsigned long crc_table[256];
+extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain;
+
//////////////////////////////////////////////////////////
// Extra winsock function for error description
//
@@ -407,17 +409,3 @@ void gg_debughandler(int level, const char *format, va_list ap)
free(szFormat);
}
#endif
-
-//////////////////////////////////////////////////////////
-// main DLL function
-//
-BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD, LPVOID)
-{
- crc_gentable();
- hInstance = hInst;
-#ifdef DEBUGMODE
- gg_debug_level = GG_DEBUG_FUNCTION;
- gg_debug_handler = gg_debughandler;
-#endif
- return TRUE;
-}
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h
index da4cc74c01..f96f613fdd 100644
--- a/protocols/Gadu-Gadu/src/gg.h
+++ b/protocols/Gadu-Gadu/src/gg.h
@@ -258,7 +258,7 @@ struct GGGETAVATARDATA
struct GaduProto;
-extern HINSTANCE hInstance;
+extern HINSTANCE g_hInstance;
extern CLIST_INTERFACE *pcli;
extern PLUGININFOEX pluginInfo;
extern IconItem iconList[];
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index a54e6100da..2b2c9eefc5 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -507,7 +507,7 @@ static INT_PTR CALLBACK gg_advancedsearchdlgproc(HWND hwndDlg, UINT message, WPA
HWND GaduProto::CreateExtendedSearchUI(HWND owner)
{
- return CreateDialogParam(hInstance,
+ return CreateDialogParam(g_hInstance,
MAKEINTRESOURCE(IDD_GGADVANCEDSEARCH), owner, gg_advancedsearchdlgproc, (LPARAM)this);
}
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index ddeaa82cb9..87555b9d06 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -303,11 +303,14 @@ inline void GaduProto::gg_sleep(DWORD miliseconds, BOOL alterable, char* calling
#endif
}
+void crc_gentable(void);
+
struct CMPlugin : public ACCPROTOPLUGIN<GaduProto>
{
CMPlugin() :
ACCPROTOPLUGIN<GaduProto>(GGDEF_PROTO)
{
+ crc_gentable();
SetUniqueId(GG_KEY_UIN);
}
};
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index e8db07c499..1ea195a83b 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -600,7 +600,7 @@ INT_PTR GaduProto::gc_openconf(WPARAM, LPARAM)
return 0;
}
- CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_CONFERENCE), nullptr, gg_gc_openconfdlg, (LPARAM)this);
+ CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CONFERENCE), nullptr, gg_gc_openconfdlg, (LPARAM)this);
return 1;
}
diff --git a/protocols/Gadu-Gadu/src/icolib.cpp b/protocols/Gadu-Gadu/src/icolib.cpp
index 040583299c..7ee2a5e5fd 100644
--- a/protocols/Gadu-Gadu/src/icolib.cpp
+++ b/protocols/Gadu-Gadu/src/icolib.cpp
@@ -43,7 +43,7 @@ extern IconItem iconList[] =
void gg_icolib_init()
{
- Icon_Register(hInstance, "Protocols/" GGDEF_PROTO, iconList, _countof(iconList), GGDEF_PROTO);
+ Icon_Register(g_hInstance, "Protocols/" GGDEF_PROTO, iconList, _countof(iconList), GGDEF_PROTO);
}
HICON LoadIconEx(const char* name, bool big)
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index 8d86ada520..909ee5c078 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -256,7 +256,7 @@ int gg_img_saveimage(HWND hwnd, GGIMAGEENTRY *dat)
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwnd;
- ofn.hInstance = hInstance;
+ ofn.hInstance = g_hInstance;
ofn.lpstrFile = szFileName;
ofn.lpstrFilter = szFilter;
ofn.nMaxFile = MAX_PATH;
@@ -439,7 +439,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return TRUE;
case WM_SIZE:
- Utils_ResizeDialog(hwndDlg, hInstance, dat->bReceiving ? MAKEINTRESOURCEA(IDD_IMAGE_RECV) : MAKEINTRESOURCEA(IDD_IMAGE_SEND), sttImageDlgResizer);
+ Utils_ResizeDialog(hwndDlg, g_hInstance, dat->bReceiving ? MAKEINTRESOURCEA(IDD_IMAGE_RECV) : MAKEINTRESOURCEA(IDD_IMAGE_SEND), sttImageDlgResizer);
if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)
InvalidateRect(hwndDlg, nullptr, FALSE);
return 0;
@@ -669,7 +669,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
*szFileName = 0;
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
- ofn.hInstance = hInstance;
+ ofn.hInstance = g_hInstance;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
@@ -708,7 +708,7 @@ void __cdecl GaduProto::img_dlgcallthread(void *param)
HWND hMIWnd = nullptr;
GGIMAGEDLGDATA *dat = (GGIMAGEDLGDATA *)param;
- DialogBoxParam(hInstance, dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND),
+ DialogBoxParam(g_hInstance, dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND),
hMIWnd, gg_img_dlgproc, (LPARAM)dat);
#ifdef DEBUGMODE
@@ -747,7 +747,7 @@ int gg_img_isexists(wchar_t *szPath, GGIMAGEENTRY *dat)
if (_wstat(szPath, &st) != 0)
return 0;
- if ((long)st.st_size == dat->nSize)
+ if (st.st_size == (long)dat->nSize)
{
FILE *fp = _wfopen(szPath, L"rb");
if (!fp) return 0;
diff --git a/protocols/Gadu-Gadu/src/links.cpp b/protocols/Gadu-Gadu/src/links.cpp
index 523be087a9..7ef2ec6cf6 100644
--- a/protocols/Gadu-Gadu/src/links.cpp
+++ b/protocols/Gadu-Gadu/src/links.cpp
@@ -108,7 +108,7 @@ void gg_links_init()
{
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
CreateServiceFunction(GGS_PARSELINK, gg_parselink);
- AssocMgr_AddNewUrlTypeW("gg:", TranslateT("Gadu-Gadu Link Protocol"), hInstance, IDI_GG, GGS_PARSELINK, 0);
+ AssocMgr_AddNewUrlTypeW("gg:", TranslateT("Gadu-Gadu Link Protocol"), g_hInstance, IDI_GG, GGS_PARSELINK, 0);
}
}
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp
index b127f19852..425eb044a2 100644
--- a/protocols/Gadu-Gadu/src/services.cpp
+++ b/protocols/Gadu-Gadu/src/services.cpp
@@ -379,7 +379,7 @@ extern INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwnd, UINT msg, WPARAM wParam
//
INT_PTR GaduProto::get_acc_mgr_gui(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this);
+ return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, gg_acc_mgr_guidlgproc, (LPARAM)this);
}
//////////////////////////////////////////////////////////
diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp
index 2c4f80318c..63ba37d099 100644
--- a/protocols/Gadu-Gadu/src/sessions.cpp
+++ b/protocols/Gadu-Gadu/src/sessions.cpp
@@ -360,7 +360,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w
return 0;
case WM_SIZE:
- Utils_ResizeDialog(hwndDlg, hInstance, MAKEINTRESOURCEA(IDD_SESSIONS), sttSessionsDlgResizer);
+ Utils_ResizeDialog(hwndDlg, g_hInstance, MAKEINTRESOURCEA(IDD_SESSIONS), sttSessionsDlgResizer);
return 0;
case WM_SETCURSOR:
@@ -397,7 +397,7 @@ INT_PTR GaduProto::sessions_view(WPARAM, LPARAM)
SetFocus(hwndSessionsDlg);
}
else
- CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_SESSIONS), nullptr, gg_sessions_viewdlg, (LPARAM)this);
+ CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SESSIONS), nullptr, gg_sessions_viewdlg, (LPARAM)this);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/token.cpp b/protocols/Gadu-Gadu/src/token.cpp
index ebb9535726..9f7f80b87c 100644
--- a/protocols/Gadu-Gadu/src/token.cpp
+++ b/protocols/Gadu-Gadu/src/token.cpp
@@ -145,7 +145,7 @@ int GaduProto::gettoken(GGTOKEN *token)
}
// Load token dialog
- if (DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_TOKEN), nullptr, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL)
+ if (DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_TOKEN), nullptr, gg_tokendlgproc, (LPARAM)&dat) == IDCANCEL)
return FALSE;
// Fillup patterns