From 8a74e7495ce5ad39de4f5c25121a84d35df90c36 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 May 2018 15:08:48 +0300 Subject: CMPlugin to receive a reference to PLUGININFOEX --- plugins/Msg_Export/src/FileViewer.cpp | 42 +++++++++++++++++------------------ plugins/Msg_Export/src/main.cpp | 34 +++++++++++++++------------- plugins/Msg_Export/src/options.cpp | 18 +++++++-------- plugins/Msg_Export/src/stdafx.h | 6 ++--- plugins/Msg_Export/src/utils.cpp | 38 +++++++++++++++---------------- 5 files changed, 70 insertions(+), 68 deletions(-) (limited to 'plugins/Msg_Export/src') diff --git a/plugins/Msg_Export/src/FileViewer.cpp b/plugins/Msg_Export/src/FileViewer.cpp index 074a89672c..03acddac16 100755 --- a/plugins/Msg_Export/src/FileViewer.cpp +++ b/plugins/Msg_Export/src/FileViewer.cpp @@ -906,13 +906,13 @@ void SetRichEditFont(HWND hRichEdit, bool bUseSyntaxHL) CHARFORMAT ncf = { 0 }; ncf.cbSize = sizeof(CHARFORMAT); ncf.dwMask = CFM_BOLD | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE; - ncf.dwEffects = db_get_dw(NULL, MODULE, szFileViewDB "TEffects", 0); - ncf.yHeight = db_get_dw(NULL, MODULE, szFileViewDB "THeight", 165); - wcsncpy_s(ncf.szFaceName, _DBGetString(NULL, MODULE, szFileViewDB "TFace", L"Courier New").c_str(), _TRUNCATE); + ncf.dwEffects = db_get_dw(NULL, MODULENAME, szFileViewDB "TEffects", 0); + ncf.yHeight = db_get_dw(NULL, MODULENAME, szFileViewDB "THeight", 165); + wcsncpy_s(ncf.szFaceName, _DBGetString(NULL, MODULENAME, szFileViewDB "TFace", L"Courier New").c_str(), _TRUNCATE); if (!bUseSyntaxHL) { ncf.dwMask |= CFM_COLOR; - ncf.crTextColor = db_get_dw(NULL, MODULE, szFileViewDB "TColor", 0); + ncf.crTextColor = db_get_dw(NULL, MODULENAME, szFileViewDB "TColor", 0); } SendMessage(hRichEdit, EM_SETCHARFORMAT, (WPARAM)SCF_ALL, (LPARAM)&ncf); @@ -956,22 +956,22 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, InsertMenu(hSysMenu, 0, MF_STRING | MF_BYPOSITION, ID_FV_SAVE_AS_RTF, LPGENW("Save as RTF")); InsertMenu(hSysMenu, 0, MF_SEPARATOR | MF_BYPOSITION, 0, nullptr); - BYTE bUseCC = (BYTE)db_get_b(NULL, MODULE, szFileViewDB "UseCC", 0); + BYTE bUseCC = (BYTE)db_get_b(NULL, MODULENAME, szFileViewDB "UseCC", 0); InsertMenu(hSysMenu, 0, MF_STRING | MF_BYPOSITION | (bUseCC ? MF_CHECKED : 0), ID_FV_COLOR, LPGENW("Color...")); if (bUseCC) - SendMessage(hRichEdit, EM_SETBKGNDCOLOR, 0, db_get_dw(NULL, MODULE, szFileViewDB "CustomC", RGB(255, 255, 255))); + SendMessage(hRichEdit, EM_SETBKGNDCOLOR, 0, db_get_dw(NULL, MODULENAME, szFileViewDB "CustomC", RGB(255, 255, 255))); InsertMenu(hSysMenu, 0, MF_STRING | MF_BYPOSITION, ID_FV_FONT, LPGENW("Font...")); - bool bUseSyntaxHL = db_get_b(NULL, MODULE, szFileViewDB "UseSyntaxHL", 1) != 0; + bool bUseSyntaxHL = db_get_b(NULL, MODULENAME, szFileViewDB "UseSyntaxHL", 1) != 0; InsertMenu(hSysMenu, 0, MF_STRING | MF_BYPOSITION | (bUseSyntaxHL ? MF_CHECKED : 0), ID_FV_SYNTAX_HL, LPGENW("Syntax highlight")); SetRichEditFont(hRichEdit, bUseSyntaxHL); TranslateDialogDefault(hwndDlg); - Utils_RestoreWindowPosition(hwndDlg, pclDlg->hContact, MODULE, szFileViewDB); + Utils_RestoreWindowPosition(hwndDlg, pclDlg->hContact, MODULENAME, szFileViewDB); pclDlg->sPath = GetFilePathFromUser(pclDlg->hContact); @@ -1016,7 +1016,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, return 0; case WM_DESTROY: - Utils_SaveWindowPosition(hwndDlg, pclDlg->hContact, MODULE, szFileViewDB); + Utils_SaveWindowPosition(hwndDlg, pclDlg->hContact, MODULENAME, szFileViewDB); WindowList_Remove(hInternalWindowList, hwndDlg); return 0; @@ -1030,18 +1030,18 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, LOGFONT lf = { 0 }; lf.lfHeight = 14L; - DWORD dwEffects = db_get_dw(NULL, MODULE, szFileViewDB "TEffects", 0); + DWORD dwEffects = db_get_dw(NULL, MODULENAME, szFileViewDB "TEffects", 0); lf.lfWeight = (dwEffects & CFE_BOLD) ? FW_BOLD : 0; lf.lfUnderline = (dwEffects & CFE_UNDERLINE) != 0; lf.lfStrikeOut = (dwEffects & CFE_STRIKEOUT) != 0; lf.lfItalic = (dwEffects & CFE_ITALIC) != 0; - wcsncpy_s(lf.lfFaceName, _DBGetString(NULL, MODULE, szFileViewDB "TFace", L"Courier New").c_str(), _TRUNCATE); + wcsncpy_s(lf.lfFaceName, _DBGetString(NULL, MODULENAME, szFileViewDB "TFace", L"Courier New").c_str(), _TRUNCATE); CHOOSEFONT cf = { 0 }; cf.lStructSize = sizeof(cf); cf.hwndOwner = hwndDlg; cf.lpLogFont = &lf; - cf.rgbColors = db_get_dw(NULL, MODULE, szFileViewDB "TColor", 0); + cf.rgbColors = db_get_dw(NULL, MODULENAME, szFileViewDB "TColor", 0); cf.Flags = CF_EFFECTS | CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; if (ChooseFont(&cf)) { @@ -1050,27 +1050,27 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, (lf.lfStrikeOut ? CFE_STRIKEOUT : 0) | (lf.lfUnderline ? CFE_UNDERLINE : 0); - db_set_dw(NULL, MODULE, szFileViewDB "TEffects", dwEffects); - db_set_dw(NULL, MODULE, szFileViewDB "THeight", cf.iPointSize * 2); - db_set_dw(NULL, MODULE, szFileViewDB "TColor", cf.rgbColors); - db_set_ws(NULL, MODULE, szFileViewDB "TFace", lf.lfFaceName); + db_set_dw(NULL, MODULENAME, szFileViewDB "TEffects", dwEffects); + db_set_dw(NULL, MODULENAME, szFileViewDB "THeight", cf.iPointSize * 2); + db_set_dw(NULL, MODULENAME, szFileViewDB "TColor", cf.rgbColors); + db_set_ws(NULL, MODULENAME, szFileViewDB "TFace", lf.lfFaceName); SetRichEditFont(hRichEdit, bUseSyntaxHL); } return TRUE; } if ((wParam & 0xFFF0) == ID_FV_COLOR) { - BYTE bUseCC = !db_get_b(NULL, MODULE, szFileViewDB "UseCC", 0); + BYTE bUseCC = !db_get_b(NULL, MODULENAME, szFileViewDB "UseCC", 0); if (bUseCC) { CHOOSECOLOR cc = { 0 }; cc.lStructSize = sizeof(cc); cc.hwndOwner = hwndDlg; - cc.rgbResult = db_get_dw(NULL, MODULE, szFileViewDB "CustomC", RGB(255, 255, 255)); + cc.rgbResult = db_get_dw(NULL, MODULENAME, szFileViewDB "CustomC", RGB(255, 255, 255)); cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT; static COLORREF MyCustColors[16] = { 0xFFFFFFFF }; cc.lpCustColors = MyCustColors; if (ChooseColor(&cc)) { SendMessage(hRichEdit, EM_SETBKGNDCOLOR, 0, cc.rgbResult); - db_set_dw(NULL, MODULE, szFileViewDB "CustomC", cc.rgbResult); + db_set_dw(NULL, MODULENAME, szFileViewDB "CustomC", cc.rgbResult); } else { CommDlgExtendedError(); @@ -1080,7 +1080,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, else SendMessage(hRichEdit, EM_SETBKGNDCOLOR, TRUE, 0); CheckMenuItem(hSysMenu, ID_FV_COLOR, MF_BYCOMMAND | (bUseCC ? MF_CHECKED : 0)); - db_set_b(NULL, MODULE, szFileViewDB "UseCC", bUseCC); + db_set_b(NULL, MODULENAME, szFileViewDB "UseCC", bUseCC); return TRUE; } if ((wParam & 0xFFF0) == ID_FV_SYNTAX_HL) { @@ -1091,7 +1091,7 @@ static INT_PTR CALLBACK DlgProcFileViewer(HWND hwndDlg, UINT msg, WPARAM wParam, bUseSyntaxHL = !bUseSyntaxHL; CheckMenuItem(hSysMenu, ID_FV_SYNTAX_HL, MF_BYCOMMAND | (bUseSyntaxHL ? MF_CHECKED : 0)); - db_set_b(NULL, MODULE, szFileViewDB "UseSyntaxHL", bUseSyntaxHL); + db_set_b(NULL, MODULENAME, szFileViewDB "UseSyntaxHL", bUseSyntaxHL); if (bUseSyntaxHL) bLoadFile(hwndDlg, pclDlg); diff --git a/plugins/Msg_Export/src/main.cpp b/plugins/Msg_Export/src/main.cpp index 393184075b..f8b790e976 100755 --- a/plugins/Msg_Export/src/main.cpp +++ b/plugins/Msg_Export/src/main.cpp @@ -27,7 +27,7 @@ MWindowList hInternalWindowList = nullptr; // Remember to update the Version in the resource !!! ///////////////////////////////////////////////////// -PLUGININFOEX pluginInfo = { +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), @@ -40,9 +40,13 @@ PLUGININFOEX pluginInfo = { { 0x46102b07, 0xc215, 0x4162, { 0x9c, 0x83, 0xd3, 0x77, 0x88, 0x1d, 0xa7, 0xcc } } }; +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - return &pluginInfo; + return &pluginInfoEx; } ///////////////////////////////////////////////////////////////////// @@ -141,29 +145,29 @@ int MainInit(WPARAM /*wparam*/, LPARAM /*lparam*/) extern "C" __declspec(dllexport) int Load() { - mir_getLP(&pluginInfo); + mir_getLP(&pluginInfoEx); HookEvent(ME_SYSTEM_MODULESLOADED, MainInit); - nMaxLineWidth = db_get_w(NULL, MODULE, "MaxLineWidth", nMaxLineWidth); + nMaxLineWidth = db_get_w(NULL, MODULENAME, "MaxLineWidth", nMaxLineWidth); if (nMaxLineWidth > 0 && nMaxLineWidth < 5) nMaxLineWidth = 5; - sExportDir = _DBGetString(NULL, MODULE, "ExportDir", L"%dbpath%\\MsgExport\\"); - sDefaultFile = _DBGetString(NULL, MODULE, "DefaultFile", L"%nick%.txt"); + sExportDir = _DBGetString(NULL, MODULENAME, "ExportDir", L"%dbpath%\\MsgExport\\"); + sDefaultFile = _DBGetString(NULL, MODULENAME, "DefaultFile", L"%nick%.txt"); - sTimeFormat = _DBGetString(NULL, MODULE, "TimeFormat", L"d s"); + sTimeFormat = _DBGetString(NULL, MODULENAME, "TimeFormat", L"d s"); - sFileViewerPrg = _DBGetString(NULL, MODULE, "FileViewerPrg", L""); - bUseInternalViewer(db_get_b(NULL, MODULE, "UseInternalViewer", bUseInternalViewer()) != 0); + sFileViewerPrg = _DBGetString(NULL, MODULENAME, "FileViewerPrg", L""); + bUseInternalViewer(db_get_b(NULL, MODULENAME, "UseInternalViewer", bUseInternalViewer()) != 0); - bReplaceHistory = db_get_b(NULL, MODULE, "ReplaceHistory", bReplaceHistory) != 0; - bAppendNewLine = db_get_b(NULL, MODULE, "AppendNewLine", bAppendNewLine) != 0; - bUseUtf8InNewFiles = db_get_b(NULL, MODULE, "UseUtf8InNewFiles", bUseUtf8InNewFiles) != 0; - bUseLessAndGreaterInExport = db_get_b(NULL, MODULE, "UseLessAndGreaterInExport", bUseLessAndGreaterInExport) != 0; + bReplaceHistory = db_get_b(NULL, MODULENAME, "ReplaceHistory", bReplaceHistory) != 0; + bAppendNewLine = db_get_b(NULL, MODULENAME, "AppendNewLine", bAppendNewLine) != 0; + bUseUtf8InNewFiles = db_get_b(NULL, MODULENAME, "UseUtf8InNewFiles", bUseUtf8InNewFiles) != 0; + bUseLessAndGreaterInExport = db_get_b(NULL, MODULENAME, "UseLessAndGreaterInExport", bUseLessAndGreaterInExport) != 0; - enRenameAction = (ENDialogAction)db_get_b(NULL, MODULE, "RenameAction", enRenameAction); - enDeleteAction = (ENDialogAction)db_get_b(NULL, MODULE, "DeleteAction", enDeleteAction); + enRenameAction = (ENDialogAction)db_get_b(NULL, MODULENAME, "RenameAction", enRenameAction); + enDeleteAction = (ENDialogAction)db_get_b(NULL, MODULENAME, "DeleteAction", enDeleteAction); HANDLE hServiceFunc = nullptr; if (bReplaceHistory) diff --git a/plugins/Msg_Export/src/options.cpp b/plugins/Msg_Export/src/options.cpp index d593c7f2e9..f51b662ab7 100755 --- a/plugins/Msg_Export/src/options.cpp +++ b/plugins/Msg_Export/src/options.cpp @@ -409,14 +409,14 @@ BOOL bApplyChanges(HWND hwndDlg) if (ListView_GetItem(hMapUser, &sItem)) { MCONTACT hUser = (MCONTACT)sItem.lParam; if (mir_wstrlen(szTemp) > 0) - db_set_ws(hUser, MODULE, "FileName", szTemp); + db_set_ws(hUser, MODULENAME, "FileName", szTemp); else - db_unset(hUser, MODULE, "FileName"); + db_unset(hUser, MODULENAME, "FileName"); if (sItem.iImage) - db_unset(hUser, MODULE, "EnableLog"); // default is Enabled !! + db_unset(hUser, MODULENAME, "EnableLog"); // default is Enabled !! else - db_set_b(hUser, MODULE, "EnableLog", 0); + db_set_b(hUser, MODULENAME, "EnableLog", 0); } } UpdateFileToColWidth(); @@ -632,10 +632,10 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts(HWND hwndDlg, UINT msg, WPARAM wPar sItem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; sItem.iItem = nUser++; sItem.iSubItem = 0; - sItem.iImage = db_get_b(hContact, MODULE, "EnableLog", 1); + sItem.iImage = db_get_b(hContact, MODULENAME, "EnableLog", 1); sItem.lParam = hContact; - sTmp = _DBGetString(hContact, MODULE, "FileName", L""); + sTmp = _DBGetString(hContact, MODULENAME, "FileName", L""); sItem.pszText = (wchar_t*)sTmp.c_str(); ListView_InsertItem(hMapUser, &sItem); @@ -1053,9 +1053,9 @@ BOOL bApplyChanges2(HWND hwndDlg) sItem.cchTextMax = (_countof(szTemp) - 15); if (::SendMessage(hMapUser, LVM_GETITEMA, 0, (LPARAM)&sItem)) { if (sItem.iImage) - db_unset(NULL, MODULE, szTemp); // default is Enabled !! + db_unset(NULL, MODULENAME, szTemp); // default is Enabled !! else - db_set_b(NULL, MODULE, szTemp, 0); + db_set_b(NULL, MODULENAME, szTemp, 0); } } SaveSettings(); @@ -1139,7 +1139,7 @@ static INT_PTR CALLBACK DlgProcMsgExportOpts2(HWND hwndDlg, UINT msg, WPARAM wPa for (auto &pa : Accounts()) { mir_snprintf(szTemp, "DisableProt_%s", pa->szModuleName); sItem.pszText = pa->szModuleName; - sItem.iImage = db_get_b(NULL, MODULE, szTemp, 1); + sItem.iImage = db_get_b(NULL, MODULENAME, szTemp, 1); ::SendMessage(hMapUser, LVM_INSERTITEMA, 0, (LPARAM)&sItem); sItem.iItem++; } diff --git a/plugins/Msg_Export/src/stdafx.h b/plugins/Msg_Export/src/stdafx.h index 29ba199b25..9b49eebf9f 100755 --- a/plugins/Msg_Export/src/stdafx.h +++ b/plugins/Msg_Export/src/stdafx.h @@ -48,7 +48,7 @@ using namespace std; #include "resource.h" #include "version.h" -#define MODULE "Msg_Export" +#define MODULENAME "Msg_Export" #define MSG_BOX_TITEL TranslateT("Miranda NG (Message Export Plugin)") #define MS_SHOW_EXPORT_HISTORY "History/ShowExportHistory" #define szFileViewDB "FileV_" @@ -56,9 +56,7 @@ using namespace std; struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(MODULE) - {} + CMPlugin(); }; extern MWindowList hInternalWindowList; diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 6112c82631..1ab91a64c9 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -518,7 +518,7 @@ void ReplaceDBPath(tstring &sRet) tstring GetFilePathFromUser(MCONTACT hContact) { - tstring sFilePath = sExportDir + _DBGetString(hContact, MODULE, "FileName", sDefaultFile.c_str()); + tstring sFilePath = sExportDir + _DBGetString(hContact, MODULENAME, "FileName", sDefaultFile.c_str()); bool bNickUsed = sFilePath.find(L"%nick%") != string::npos; @@ -530,7 +530,7 @@ tstring GetFilePathFromUser(MCONTACT hContact) ReplaceDBPath(sFilePath); // Previous file name check to see if it has changed !! - tstring sPrevFileName = _DBGetString(hContact, MODULE, "PrevFileName", L""); + tstring sPrevFileName = _DBGetString(hContact, MODULENAME, "PrevFileName", L""); if (sNoDBPath != sPrevFileName) { if (!sPrevFileName.empty()) { ReplaceDBPath(sPrevFileName); @@ -596,7 +596,7 @@ tstring GetFilePathFromUser(MCONTACT hContact) } // Store the Filename used so that we can check if it changes. - db_set_ws(hContact, MODULE, "PrevFileName", sNoDBPath.c_str()); + db_set_ws(hContact, MODULENAME, "PrevFileName", sNoDBPath.c_str()); } return sFilePath; @@ -1209,13 +1209,13 @@ HANDLE openCreateFile(tstring sFilePath) bool bIsExportEnabled(MCONTACT hContact) { - if (!db_get_b(hContact, MODULE, "EnableLog", 1)) + if (!db_get_b(hContact, MODULENAME, "EnableLog", 1)) return false; const char *szProto = GetContactProto(hContact); char szTemp[500]; mir_snprintf(szTemp, "DisableProt_%s", szProto); - if (!db_get_b(NULL, MODULE, szTemp, 1)) + if (!db_get_b(NULL, MODULENAME, szTemp, 1)) return false; return true; @@ -1445,20 +1445,20 @@ int nContactDeleted(WPARAM wparam, LPARAM /*lparam*/) void SaveSettings() { - db_set_w(NULL, MODULE, "MaxLineWidth", (WORD)nMaxLineWidth); - db_set_ws(NULL, MODULE, "ExportDir", sExportDir.c_str()); - db_set_ws(NULL, MODULE, "DefaultFile", sDefaultFile.c_str()); - db_set_ws(NULL, MODULE, "TimeFormat", sTimeFormat.c_str()); - - db_set_ws(NULL, MODULE, "FileViewerPrg", sFileViewerPrg.c_str()); - db_set_b(NULL, MODULE, "UseInternalViewer", bUseInternalViewer()); - db_set_b(NULL, MODULE, "ReplaceHistory", bReplaceHistory); - db_set_b(NULL, MODULE, "AppendNewLine", bAppendNewLine); - db_set_b(NULL, MODULE, "UseUtf8InNewFiles", bUseUtf8InNewFiles); - db_set_b(NULL, MODULE, "UseLessAndGreaterInExport", bUseLessAndGreaterInExport); - - db_set_b(NULL, MODULE, "RenameAction", (BYTE)enRenameAction); - db_set_b(NULL, MODULE, "DeleteAction", (BYTE)enDeleteAction); + db_set_w(NULL, MODULENAME, "MaxLineWidth", (WORD)nMaxLineWidth); + db_set_ws(NULL, MODULENAME, "ExportDir", sExportDir.c_str()); + db_set_ws(NULL, MODULENAME, "DefaultFile", sDefaultFile.c_str()); + db_set_ws(NULL, MODULENAME, "TimeFormat", sTimeFormat.c_str()); + + db_set_ws(NULL, MODULENAME, "FileViewerPrg", sFileViewerPrg.c_str()); + db_set_b(NULL, MODULENAME, "UseInternalViewer", bUseInternalViewer()); + db_set_b(NULL, MODULENAME, "ReplaceHistory", bReplaceHistory); + db_set_b(NULL, MODULENAME, "AppendNewLine", bAppendNewLine); + db_set_b(NULL, MODULENAME, "UseUtf8InNewFiles", bUseUtf8InNewFiles); + db_set_b(NULL, MODULENAME, "UseLessAndGreaterInExport", bUseLessAndGreaterInExport); + + db_set_b(NULL, MODULENAME, "RenameAction", (BYTE)enRenameAction); + db_set_b(NULL, MODULENAME, "DeleteAction", (BYTE)enDeleteAction); } ///////////////////////////////////////////////////////////////////// -- cgit v1.2.3