diff options
Diffstat (limited to 'plugins')
38 files changed, 821 insertions, 845 deletions
diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp index 092bc18f5e..e224226ad1 100644 --- a/plugins/CSList/src/cslist.cpp +++ b/plugins/CSList/src/cslist.cpp @@ -28,8 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "strpos.h" CLIST_INTERFACE *pcli; +CMPlugin g_plugin; int hLangpack; -HINSTANCE g_hInst; static LIST<CSWindow> arWindows(3, HandleKeySortT); @@ -47,14 +47,6 @@ PLUGININFOEX pluginInfoEx = { 0xc8cc7414, 0x6507, 0x4af6, { 0x92, 0x5a, 0x83, 0xc1, 0xd2, 0xf7, 0xbe, 0x8c } } }; -// ====[ MAIN ]=============================================================== - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - g_hInst = hinstDLL; - return TRUE; -} - // ====[ PLUGIN INFO ]======================================================== extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) @@ -81,7 +73,7 @@ static int OnInitOptions(WPARAM wparam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.position = 955000000; - odp.hInstance = g_hInst; + odp.hInstance = g_plugin.getInst(); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.pfnDlgProc = CSOptionsProc; odp.szGroup.w = L"Status"; @@ -120,7 +112,7 @@ extern "C" __declspec(dllexport) int Load() // init icons wchar_t tszFile[MAX_PATH]; - GetModuleFileName(g_hInst, tszFile, MAX_PATH); + GetModuleFileName(g_plugin.getInst(), tszFile, MAX_PATH); SKINICONDESC sid = {}; sid.defaultFile.w = tszFile; @@ -212,7 +204,7 @@ INT_PTR showList(WPARAM, LPARAM, LPARAM param) } } - CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_CSLIST), nullptr, CSWindowProc, (LPARAM)new CSWindow(szProto)); + CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CSLIST), nullptr, CSWindowProc, (LPARAM)new CSWindow(szProto)); return 0; } @@ -232,7 +224,7 @@ void addProtoStatusMenuItem(char *protoName) CreateServiceFunctionParam(buf, showList, (LPARAM)protoName); CMenuItem mi; - mi.flags = CMIF_UNICODE; + mi.flags = CMIF_UNICODE; mi.hIcolibItem = forms[0].hIcoLibItem; mi.name.w = MODULENAME; mi.position = 2000040000; @@ -458,7 +450,7 @@ CSAMWindow::~CSAMWindow() void CSAMWindow::exec() { - DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ADDMODIFY), nullptr, CSAMWindowProc, (LPARAM)this); + DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ADDMODIFY), nullptr, CSAMWindowProc, (LPARAM)this); } @@ -1002,15 +994,15 @@ INT_PTR CALLBACK CSOptionsProc(HWND hwnd, UINT message, WPARAM, LPARAM lparam) TranslateDialogDefault(hwnd); CheckDlgButton(hwnd, IDC_CONFIRM_DELETION, getByte("ConfirmDeletion", DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION) ? - BST_CHECKED : BST_UNCHECKED); + BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_DELETE_AFTER_IMPORT, getByte("DeleteAfterImport", DEFAULT_PLUGIN_DELETE_AFTER_IMPORT) ? - BST_CHECKED : BST_UNCHECKED); + BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_REMEMBER_POSITION, getByte("RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION) ? - BST_CHECKED : BST_UNCHECKED); + BST_CHECKED : BST_UNCHECKED); return TRUE; case WM_NOTIFY: diff --git a/plugins/CSList/src/stdafx.h b/plugins/CSList/src/stdafx.h index 6dbe1bfcbd..810409e9fa 100644 --- a/plugins/CSList/src/stdafx.h +++ b/plugins/CSList/src/stdafx.h @@ -35,8 +35,6 @@ Offers List of your Custom Statuses. #include <windows.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_database.h>
#include <m_system.h>
@@ -59,6 +57,13 @@ Offers List of your Custom Statuses. #define MODULENAME LPGENW("Custom Status List")
#define MODNAME "CSList"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODNAME)
+ {}
+};
+
// ====[ LIMITS ]=============================================================
#define EXTRASTATUS_TITLE_LIMIT 64 // limit of chars for extra status title
@@ -396,7 +401,6 @@ INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM); void addProtoStatusMenuItem(char *protoName);
// other functions
-void IitIcoLib();
void RegisterHotkeys(char buf[200], wchar_t* accName, int Number);
void SetStatus(WORD code, StatusItem* item, char *protoName);
@@ -404,7 +408,6 @@ void SetStatus(WORD code, StatusItem* item, char *protoName); INT_PTR CALLBACK CSWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
INT_PTR CALLBACK CSAMWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
-INT_PTR CALLBACK CSRNWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
INT_PTR CALLBACK CSOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
#endif /* __CSLIST_H */
diff --git a/plugins/CountryFlags/src/icons.cpp b/plugins/CountryFlags/src/icons.cpp index e0d145dfe7..c295ddebb1 100644 --- a/plugins/CountryFlags/src/icons.cpp +++ b/plugins/CountryFlags/src/icons.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static HANDLE *phIconHandles;
/* country number indices (same order as in flags.bmp) */
-const int BitmapIndexMap[232]={
+const int BitmapIndexMap[232] = {
0, 1, 7, 20, 27, 30, 31, 32, 33, 34, 36, 39, 40, 41, 43, 44, 45, 46, 47, 48,
49, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 81, 82, 84, 86,
90, 91, 92, 93, 94, 95, 98, 101, 102, 103, 104, 105, 106, 107, 178, 108, 109, 110, 111, 112,
@@ -42,7 +42,7 @@ const int BitmapIndexMap[232]={ static int __fastcall CountryNumberToBitmapIndex(int countryNumber)
{
/* shared flags by multiple countries */
- switch(countryNumber) {
+ switch (countryNumber) {
case 262: /* Reunion Island */
case 594: /* French Guiana */
case 5901: /* French Antilles */
@@ -70,17 +70,17 @@ static int __fastcall CountryNumberToBitmapIndex(int countryNumber) }
/* binary search in index array */
- int low = 0, i, high = _countof(BitmapIndexMap)-1;
+ int low = 0, i, high = _countof(BitmapIndexMap) - 1;
if (countryNumber <= BitmapIndexMap[high])
while (low <= high) {
- i = low+((high-low)/2);
+ i = low + ((high - low) / 2);
if (BitmapIndexMap[i] == countryNumber)
return i;
- if (countryNumber >BitmapIndexMap[i])
- low=i+1;
+ if (countryNumber > BitmapIndexMap[i])
+ low = i + 1;
else
- high=i-1;
+ high = i - 1;
}
/* Other,Unknown,Unspecified */
@@ -89,43 +89,43 @@ static int __fastcall CountryNumberToBitmapIndex(int countryNumber) // return value needs to be released using DestroyIcon()
// only operates on color icons, which isn't a problem here
-static HICON __fastcall ResizeIconCentered(HICON hIcon,int cx,int cy)
+static HICON __fastcall ResizeIconCentered(HICON hIcon, int cx, int cy)
{
HICON hResIcon = nullptr;
HDC hdc = CreateCompatibleDC(nullptr);
if (hdc != nullptr) {
ICONINFO icoi;
- if ( GetIconInfo(hIcon,&icoi)) {
+ if (GetIconInfo(hIcon, &icoi)) {
BITMAP bm;
- if (GetObject(icoi.hbmColor,sizeof(bm),&bm) && bm.bmWidth<=cx && bm.bmHeight<=cy) {
+ if (GetObject(icoi.hbmColor, sizeof(bm), &bm) && bm.bmWidth <= cx && bm.bmHeight <= cy) {
POINT pt;
- pt.x = (cx-bm.bmWidth)/2;
- pt.y = (cy-bm.bmHeight)/2;
+ pt.x = (cx - bm.bmWidth) / 2;
+ pt.y = (cy - bm.bmHeight) / 2;
HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, icoi.hbmColor);
if (hbmPrev != nullptr) { /* error on select? */
HBITMAP hbm = icoi.hbmColor;
- icoi.hbmColor = CreateCompatibleBitmap(hdc,cx,cy);
+ icoi.hbmColor = CreateCompatibleBitmap(hdc, cx, cy);
if (icoi.hbmColor != nullptr)
- if (SelectObject(hdc,icoi.hbmColor) != nullptr) { /* error on select? */
+ if (SelectObject(hdc, icoi.hbmColor) != nullptr) { /* error on select? */
DeleteObject(hbm); /* delete prev color (XOR) */
- if (BitBlt(hdc,0,0,cx,cy,nullptr,0,0,BLACKNESS)) /* transparency: AND=0, XOR=1 */
- if (DrawIconEx(hdc,pt.x,pt.y,hIcon,bm.bmWidth,bm.bmHeight,0,nullptr,DI_IMAGE|DI_NOMIRROR)) {
- if (SelectObject(hdc,icoi.hbmMask) != nullptr) { /* error on select? */
+ if (BitBlt(hdc, 0, 0, cx, cy, nullptr, 0, 0, BLACKNESS)) /* transparency: AND=0, XOR=1 */
+ if (DrawIconEx(hdc, pt.x, pt.y, hIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_IMAGE | DI_NOMIRROR)) {
+ if (SelectObject(hdc, icoi.hbmMask) != nullptr) { /* error on select? */
hbm = icoi.hbmMask;
- icoi.hbmMask = CreateBitmap(cx,cy,1,1,nullptr); /* mono */
+ icoi.hbmMask = CreateBitmap(cx, cy, 1, 1, nullptr); /* mono */
if (icoi.hbmMask != nullptr)
- if (SelectObject(hdc,icoi.hbmMask) != nullptr) { /* error on select? */
+ if (SelectObject(hdc, icoi.hbmMask) != nullptr) { /* error on select? */
DeleteObject(hbm); /* delete prev mask (AND) */
- if (BitBlt(hdc,0,0,cx,cy,nullptr,0,0,WHITENESS)) /* transparency: AND=0, XOR=1 */
- if (DrawIconEx(hdc,pt.x,pt.y,hIcon,0,0,0,nullptr,DI_MASK|DI_NOMIRROR)) {
- SelectObject(hdc,hbmPrev);
+ if (BitBlt(hdc, 0, 0, cx, cy, nullptr, 0, 0, WHITENESS)) /* transparency: AND=0, XOR=1 */
+ if (DrawIconEx(hdc, pt.x, pt.y, hIcon, 0, 0, 0, nullptr, DI_MASK | DI_NOMIRROR)) {
+ SelectObject(hdc, hbmPrev);
hResIcon = CreateIconIndirect(&icoi); /* bitmaps must not be selected */
}
}
}
}
}
- SelectObject(hdc,hbmPrev);
+ SelectObject(hdc, hbmPrev);
}
}
DeleteObject(icoi.hbmColor);
@@ -152,8 +152,8 @@ HICON __fastcall LoadFlagIcon(int countryNumber) int __fastcall CountryNumberToIndex(int countryNumber)
{
- int nf=0;
- for(int i=0; i < nCountriesCount; ++i) {
+ int nf = 0;
+ for (int i = 0; i < nCountriesCount; ++i) {
if (countries[i].id == countryNumber)
return i;
if (countries[i].id == 0xFFFF)
@@ -164,7 +164,7 @@ int __fastcall CountryNumberToIndex(int countryNumber) /************************* Services *******************************/
-static INT_PTR ServiceLoadFlagIcon(WPARAM wParam,LPARAM lParam)
+static INT_PTR ServiceLoadFlagIcon(WPARAM wParam, LPARAM lParam)
{
/* return handle */
if ((BOOL)lParam) {
@@ -177,15 +177,15 @@ static INT_PTR ServiceLoadFlagIcon(WPARAM wParam,LPARAM lParam) return (INT_PTR)LoadFlagIcon(wParam);
}
-static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam)
+static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam, LPARAM lParam)
{
HICON hIcon = nullptr;
/* load both icons */
- HICON hLowerIcon = (HICON)ServiceLoadFlagIcon((WPARAM)lParam,0);
+ HICON hLowerIcon = (HICON)ServiceLoadFlagIcon((WPARAM)lParam, 0);
if (hLowerIcon == nullptr)
return 0;
- HICON hUpperIcon = (HICON)ServiceLoadFlagIcon(wParam,0);
+ HICON hUpperIcon = (HICON)ServiceLoadFlagIcon(wParam, 0);
/* merge them */
ICONINFO icoi;
@@ -195,18 +195,18 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) HDC hdc = CreateCompatibleDC(nullptr);
if (hdc != nullptr) {
POINT aptTriangle[3] = { 0 };
- aptTriangle[1].y = bm.bmHeight-1;
- aptTriangle[2].x = bm.bmWidth-1;
- HRGN hrgn = CreatePolygonRgn(aptTriangle,_countof(aptTriangle),WINDING);
+ aptTriangle[1].y = bm.bmHeight - 1;
+ aptTriangle[2].x = bm.bmWidth - 1;
+ HRGN hrgn = CreatePolygonRgn(aptTriangle, _countof(aptTriangle), WINDING);
if (hrgn != nullptr) {
- SelectClipRgn(hdc,hrgn);
+ SelectClipRgn(hdc, hrgn);
DeleteObject(hrgn);
HBITMAP hbmPrev = (HBITMAP)SelectObject(hdc, icoi.hbmColor);
if (hbmPrev != nullptr) { /* error on select? */
- if ( DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,nullptr,DI_NOMIRROR|DI_IMAGE))
- if ( SelectObject(hdc,icoi.hbmMask) != nullptr) /* error on select? */
- DrawIconEx(hdc,0,0,hUpperIcon,bm.bmWidth,bm.bmHeight,0,nullptr,DI_NOMIRROR|DI_MASK);
- SelectObject(hdc,hbmPrev);
+ if (DrawIconEx(hdc, 0, 0, hUpperIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_NOMIRROR | DI_IMAGE))
+ if (SelectObject(hdc, icoi.hbmMask) != nullptr) /* error on select? */
+ DrawIconEx(hdc, 0, 0, hUpperIcon, bm.bmWidth, bm.bmHeight, 0, nullptr, DI_NOMIRROR | DI_MASK);
+ SelectObject(hdc, hbmPrev);
}
}
DeleteDC(hdc);
@@ -236,20 +236,20 @@ void InitIcons(void) /* all those flag icons do not need any transparency mask (flags are always opaque),
* storing them in a large bitmap to reduce file size */
- HIMAGELIST himl = ImageList_LoadImage(hInst,MAKEINTRESOURCE(IDB_FLAGS),sid.cx,0,CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION);
+ HIMAGELIST himl = ImageList_LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDB_FLAGS), sid.cx, 0, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION);
if (himl != nullptr) {
- phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
+ phIconHandles = (HANDLE*)mir_alloc(nCountriesCount * sizeof(HANDLE));
if (phIconHandles != nullptr) {
- for (int i=0; i < nCountriesCount; ++i) {
+ for (int i = 0; i < nCountriesCount; ++i) {
sid.description.a = (char*)countries[i].szName;
/* create identifier */
- mir_snprintf(szId, (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i","flags_", countries[i].id); /* buffer safe */
+ mir_snprintf(szId, (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countries[i].id); /* buffer safe */
int index = CountryNumberToBitmapIndex(countries[i].id);
/* create icon */
- HICON hIcon = ImageList_GetIcon(himl,index,ILD_NORMAL);
+ HICON hIcon = ImageList_GetIcon(himl, index, ILD_NORMAL);
if (hIcon) {
- sid.hDefaultIcon = ResizeIconCentered(hIcon,sid.cx,sid.cy);
+ sid.hDefaultIcon = ResizeIconCentered(hIcon, sid.cx, sid.cy);
DestroyIcon(hIcon);
}
else sid.hDefaultIcon = nullptr;
diff --git a/plugins/CountryFlags/src/ip2country.cpp b/plugins/CountryFlags/src/ip2country.cpp index ce4c45e020..2e8bae93db 100644 --- a/plugins/CountryFlags/src/ip2country.cpp +++ b/plugins/CountryFlags/src/ip2country.cpp @@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-extern HINSTANCE hInst;
extern int nCountriesCount;
extern struct CountryListEntry *countries;
@@ -28,24 +27,24 @@ extern struct CountryListEntry *countries; #define DATARECORD_SIZE (sizeof(DWORD)+sizeof(DWORD)+sizeof(WORD))
// mir_free() the return value
-static BYTE* GetDataHeader(BYTE *data,DWORD cbDataSize,DWORD *pnDataRecordCount)
+static BYTE* GetDataHeader(BYTE *data, DWORD cbDataSize, DWORD *pnDataRecordCount)
{
BYTE *recordData;
/* uncompressed size stored in first DWORD */
- *pnDataRecordCount=(*(DWORD*)data)/DATARECORD_SIZE;
- recordData=(BYTE*)mir_alloc(*(DWORD*)data);
+ *pnDataRecordCount = (*(DWORD*)data) / DATARECORD_SIZE;
+ recordData = (BYTE*)mir_alloc(*(DWORD*)data);
if (recordData != nullptr)
- Huffman_Uncompress(data+sizeof(DWORD),recordData,cbDataSize-sizeof(DWORD),*(DWORD*)data);
+ Huffman_Uncompress(data + sizeof(DWORD), recordData, cbDataSize - sizeof(DWORD), *(DWORD*)data);
return recordData;
}
-static int GetDataRecord(BYTE *data,DWORD index,DWORD *pdwFrom,DWORD *pdwTo)
+static int GetDataRecord(BYTE *data, DWORD index, DWORD *pdwFrom, DWORD *pdwTo)
{
- data+=index*DATARECORD_SIZE;
- *pdwFrom=*(DWORD*)data;
- data+=sizeof(DWORD);
- if (pdwTo != nullptr) *pdwTo=*(DWORD*)data;
- data+=sizeof(DWORD);
+ data += index * DATARECORD_SIZE;
+ *pdwFrom = *(DWORD*)data;
+ data += sizeof(DWORD);
+ if (pdwTo != nullptr) *pdwTo = *(DWORD*)data;
+ data += sizeof(DWORD);
return (int)*(WORD*)data;
}
@@ -61,36 +60,36 @@ static void CALLBACK UnloadRecordCache(LPARAM) {
mir_cslock lck(csRecordCache);
mir_free(dataRecords);
- dataRecords=nullptr;
+ dataRecords = nullptr;
}
// function assumes it has got the csRecordCache mutex
-static BOOL EnsureRecordCacheLoaded(BYTE **pdata,DWORD *pcount)
+static BOOL EnsureRecordCacheLoaded(BYTE **pdata, DWORD *pcount)
{
HRSRC hrsrc;
DWORD cb;
mir_cslock lck(csRecordCache);
if (dataRecords == nullptr) {
/* load record data list from resources */
- hrsrc=FindResource(hInst,MAKEINTRESOURCE(IDR_IPTOCOUNTRY),L"BIN");
- cb=SizeofResource(hInst,hrsrc);
- dataRecords=(BYTE*)LockResource(LoadResource(hInst,hrsrc));
- if (cb<=sizeof(DWORD) || dataRecords == nullptr)
+ hrsrc = FindResource(g_plugin.getInst(), MAKEINTRESOURCE(IDR_IPTOCOUNTRY), L"BIN");
+ cb = SizeofResource(g_plugin.getInst(), hrsrc);
+ dataRecords = (BYTE*)LockResource(LoadResource(g_plugin.getInst(), hrsrc));
+ if (cb <= sizeof(DWORD) || dataRecords == nullptr)
return FALSE;
/* uncompress record data */
- dataRecords=GetDataHeader(dataRecords,cb,&nDataRecordsCount);
+ dataRecords = GetDataHeader(dataRecords, cb, &nDataRecordsCount);
if (dataRecords == nullptr || !nDataRecordsCount)
return FALSE;
}
- *pdata=dataRecords;
- *pcount=nDataRecordsCount;
+ *pdata = dataRecords;
+ *pcount = nDataRecordsCount;
return TRUE;
}
static void LeaveRecordCache(void)
{
/* mark for unload */
- CallFunctionBuffered(UnloadRecordCache,0,FALSE,UNLOADDELAY);
+ CallFunctionBuffered(UnloadRecordCache, 0, FALSE, UNLOADDELAY);
}
/************************* Services *******************************/
@@ -99,21 +98,21 @@ static void LeaveRecordCache(void) INT_PTR ServiceIpToCountry(WPARAM wParam, LPARAM)
{
BYTE *data;
- DWORD dwFrom,dwTo;
- DWORD low=0,i,high;
+ DWORD dwFrom, dwTo;
+ DWORD low = 0, i, high;
int id;
- if (EnsureRecordCacheLoaded(&data,&high)) {
+ if (EnsureRecordCacheLoaded(&data, &high)) {
/* binary search in record data */
- GetDataRecord(data,low,&dwFrom,nullptr);
+ GetDataRecord(data, low, &dwFrom, nullptr);
--high;
- if (wParam>=dwFrom) /* only search if wParam valid */
- while (low<=high) {
- i=low+((high-low)/2);
- /* analyze record */
- id=GetDataRecord(data,i,&dwFrom,&dwTo);
- if (dwFrom<=wParam && dwTo>=wParam) { LeaveRecordCache(); return id; }
- if (wParam>dwTo) low=i+1;
- else high=i-1;
+ if (wParam >= dwFrom) /* only search if wParam valid */
+ while (low <= high) {
+ i = low + ((high - low) / 2);
+ /* analyze record */
+ id = GetDataRecord(data, i, &dwFrom, &dwTo);
+ if (dwFrom <= wParam && dwTo >= wParam) { LeaveRecordCache(); return id; }
+ if (wParam > dwTo) low = i + 1;
+ else high = i - 1;
}
LeaveRecordCache();
}
@@ -129,7 +128,7 @@ INT_PTR ServiceIpToCountry(WPARAM wParam, LPARAM) struct {
const char *szMir;
const char *szCSV;
-} static const differentCountryNames[]={
+} static const differentCountryNames[] = {
{"British Virgin Islands","VIRGIN ISLANDS, BRITISH"},
{"Brunei","BRUNEI DARUSSALAM"},
{"Cape Verde Islands","CAPE VERDE"},
@@ -164,82 +163,82 @@ struct { struct ResizableByteBuffer {
BYTE *buf;
- DWORD cbLength,cbAlloced;
+ DWORD cbLength, cbAlloced;
};
-static void AppendToByteBuffer(struct ResizableByteBuffer *buffer,const void *append,DWORD cbAppendSize)
+static void AppendToByteBuffer(struct ResizableByteBuffer *buffer, const void *append, DWORD cbAppendSize)
{
- if (buffer->cbAlloced<=buffer->cbLength+cbAppendSize) {
- BYTE* buf=(BYTE*)mir_realloc(buffer->buf,buffer->cbAlloced+ALLOC_STEP+cbAppendSize);
+ if (buffer->cbAlloced <= buffer->cbLength + cbAppendSize) {
+ BYTE* buf = (BYTE*)mir_realloc(buffer->buf, buffer->cbAlloced + ALLOC_STEP + cbAppendSize);
if (buf == NULL) return;
- buffer->buf=buf;
- buffer->cbAlloced+=ALLOC_STEP+cbAppendSize;
+ buffer->buf = buf;
+ buffer->cbAlloced += ALLOC_STEP + cbAppendSize;
OutputDebugStringA("reallocating memory...\n"); /* all ascii */
}
- memcpy(&buffer->buf[buffer->cbLength],append,cbAppendSize);
- buffer->cbLength+=cbAppendSize;
+ memcpy(&buffer->buf[buffer->cbLength], append, cbAppendSize);
+ buffer->cbLength += cbAppendSize;
}
-static int EnumIpDataLines(const char *pszFileCSV,const char *pszFileOut)
+static int EnumIpDataLines(const char *pszFileCSV, const char *pszFileOut)
{
FILE *fp;
- char line[1024],out[512],*pszFrom,*pszTo,*pszTwo,*pszCountry,*buf;
- int i,j;
+ char line[1024], out[512], *pszFrom, *pszTo, *pszTwo, *pszCountry, *buf;
+ int i, j;
DWORD dwOut;
WORD wOut;
struct ResizableByteBuffer buffer;
memset(&buffer, 0, sizeof(buffer));
- fp=fopen(pszFileCSV,"rt");
+ fp = fopen(pszFileCSV, "rt");
if (fp != NULL) {
OutputDebugStringA("Running IP data convert...\n"); /* all ascii */
while (!feof(fp)) {
- if (fgets(line,sizeof(line),fp) == NULL) break;
+ if (fgets(line, sizeof(line), fp) == NULL) break;
/* get line data */
- pszFrom=line+1;
- pszTo=strchr(pszFrom,',');
- *(pszTo-1)='\0'; pszTo+=2;
- pszTwo=strchr(pszTo,',');
- *(pszTwo-1)='\0'; pszTwo+=2;
- pszCountry=strchr(pszTwo,',')+1;
- pszCountry=strchr(pszCountry,',')+2;
- buf=strchr(pszCountry,'"');
- *buf=pszTwo[2]='\0';
+ pszFrom = line + 1;
+ pszTo = strchr(pszFrom, ',');
+ *(pszTo - 1) = '\0'; pszTo += 2;
+ pszTwo = strchr(pszTo, ',');
+ *(pszTwo - 1) = '\0'; pszTwo += 2;
+ pszCountry = strchr(pszTwo, ',') + 1;
+ pszCountry = strchr(pszCountry, ',') + 2;
+ buf = strchr(pszCountry, '"');
+ *buf = pszTwo[2] = '\0';
/* corrections */
- if (!mir_wstrcmpi(pszCountry,"ANTARCTICA")) continue;
- if (!mir_wstrcmpi(pszCountry,"TIMOR-LESTE")) continue;
- if (!mir_wstrcmpi(pszCountry,"PALESTINIAN TERRITORY, OCCUPIED"))
- mir_wstrcpy(pszCountry,"ISRAEL");
- else if (!mir_wstrcmpi(pszCountry,"UNITED STATES MINOR OUTLYING ISLANDS"))
- mir_wstrcpy(pszCountry,"UNITED STATES");
- else if (!mir_wstrcmpi(pszCountry,"SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"))
- mir_wstrcpy(pszCountry,"UNITED KINGDOM");
- else if (!mir_wstrcmpi(pszTwo,"JE")) /* map error */
- mir_wstrcpy(pszCountry,"UNITED KINGDOM");
- else if (!mir_wstrcmpi(pszTwo,"AX")) /* Еland Island belongs to Finland */
- mir_wstrcpy(pszCountry,"FINLAND");
- else if (!mir_wstrcmpi(pszTwo,"ME"))
- mir_wstrcpy(pszCountry,"MONTENEGRO");
- else if (!mir_wstrcmpi(pszTwo,"RS") || !mir_wstrcmpi(pszTwo,"CS"))
- mir_wstrcpy(pszCountry,"SERBIA");
+ if (!mir_wstrcmpi(pszCountry, "ANTARCTICA")) continue;
+ if (!mir_wstrcmpi(pszCountry, "TIMOR-LESTE")) continue;
+ if (!mir_wstrcmpi(pszCountry, "PALESTINIAN TERRITORY, OCCUPIED"))
+ mir_wstrcpy(pszCountry, "ISRAEL");
+ else if (!mir_wstrcmpi(pszCountry, "UNITED STATES MINOR OUTLYING ISLANDS"))
+ mir_wstrcpy(pszCountry, "UNITED STATES");
+ else if (!mir_wstrcmpi(pszCountry, "SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"))
+ mir_wstrcpy(pszCountry, "UNITED KINGDOM");
+ else if (!mir_wstrcmpi(pszTwo, "JE")) /* map error */
+ mir_wstrcpy(pszCountry, "UNITED KINGDOM");
+ else if (!mir_wstrcmpi(pszTwo, "AX")) /* Еland Island belongs to Finland */
+ mir_wstrcpy(pszCountry, "FINLAND");
+ else if (!mir_wstrcmpi(pszTwo, "ME"))
+ mir_wstrcpy(pszCountry, "MONTENEGRO");
+ else if (!mir_wstrcmpi(pszTwo, "RS") || !mir_wstrcmpi(pszTwo, "CS"))
+ mir_wstrcpy(pszCountry, "SERBIA");
/* convert */
- for(i=0;i<nCountriesCount;i++) {
+ for (i = 0; i < nCountriesCount; i++) {
/* map different writings */
- for(j=0;j<_countof(differentCountryNames);j++)
- if (!mir_wstrcmpi(countries[i].szName,differentCountryNames[j].szMir)) {
- buf=(char*)differentCountryNames[j].szCSV;
+ for (j = 0; j < _countof(differentCountryNames); j++)
+ if (!mir_wstrcmpi(countries[i].szName, differentCountryNames[j].szMir)) {
+ buf = (char*)differentCountryNames[j].szCSV;
break;
}
if (j == _countof(differentCountryNames))
- buf=(char*)countries[i].szName;
+ buf = (char*)countries[i].szName;
/* check country */
- if (!mir_strcmpi(pszCountry,buf)) {
- dwOut=(DWORD)atoi(pszFrom);
- AppendToByteBuffer(&buffer,(void*)&dwOut,sizeof(DWORD));
- dwOut=(DWORD)atoi(pszTo);
- AppendToByteBuffer(&buffer,(void*)&dwOut,sizeof(DWORD));
- wOut=(WORD)countries[i].id;
- AppendToByteBuffer(&buffer,(void*)&wOut,sizeof(WORD));
+ if (!mir_strcmpi(pszCountry, buf)) {
+ dwOut = (DWORD)atoi(pszFrom);
+ AppendToByteBuffer(&buffer, (void*)&dwOut, sizeof(DWORD));
+ dwOut = (DWORD)atoi(pszTo);
+ AppendToByteBuffer(&buffer, (void*)&dwOut, sizeof(DWORD));
+ wOut = (WORD)countries[i].id;
+ AppendToByteBuffer(&buffer, (void*)&wOut, sizeof(WORD));
break;
}
}
@@ -253,23 +252,23 @@ static int EnumIpDataLines(const char *pszFileCSV,const char *pszFileOut) OutputDebugStringA("Done!\n"); /* all ascii */
if (buffer.buf != NULL) {
HANDLE hFileOut;
- DWORD cbWritten=0;
+ DWORD cbWritten = 0;
BYTE *compressed;
DWORD cbCompressed;
/* compress whole data */
OutputDebugStringA("Compressing...\n"); /* all ascii */
- compressed=(BYTE*)mir_alloc(buffer.cbAlloced+384);
+ compressed = (BYTE*)mir_alloc(buffer.cbAlloced + 384);
if (compressed != NULL) {
- cbCompressed=Huffman_Compress(buffer.buf,compressed,buffer.cbLength);
+ cbCompressed = Huffman_Compress(buffer.buf, compressed, buffer.cbLength);
OutputDebugStringA("Done!\n"); /* all ascii */
OutputDebugStringA("Writing to file...\n"); /* all ascii */
- hFileOut=CreateFile(pszFileOut,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
+ hFileOut = CreateFile(pszFileOut, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFileOut != INVALID_HANDLE_VALUE) {
/* store data length count at beginning */
- dwOut=buffer.cbLength;
- WriteFile(hFileOut,&dwOut,sizeof(DWORD),&cbWritten,NULL);
+ dwOut = buffer.cbLength;
+ WriteFile(hFileOut, &dwOut, sizeof(DWORD), &cbWritten, NULL);
/* store compressed data records */
- WriteFile(hFileOut,compressed,cbCompressed,&cbWritten,NULL);
+ WriteFile(hFileOut, compressed, cbCompressed, &cbWritten, NULL);
CloseHandle(hFileOut);
}
OutputDebugStringA("Done!\n"); /* all ascii */
@@ -285,12 +284,12 @@ static int EnumIpDataLines(const char *pszFileCSV,const char *pszFileOut) static void BinConvThread(void *unused)
{
/* debug version only */
- if (MessageBox(NULL,_T("Looking for 'ip-to-country.csv' in current directory.\n"
+ if (MessageBox(NULL, _T("Looking for 'ip-to-country.csv' in current directory.\n"
"It will be converted into 'ip-to-country.bin'.\n"
"See debug output for more details.\n"
- "This process may take very long."),L"Bin Converter",MB_OKCANCEL|MB_ICONINFORMATION|MB_SETFOREGROUND|MB_TOPMOST|MB_TASKMODAL) == IDOK) {
- EnumIpDataLines("ip-to-country.csv","ip-to-country.bin");
- MessageBox(NULL,L"Done!\n'ip-to-country.bin' has been created in current directory.",L"Bin Converter",MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND|MB_TOPMOST|MB_TASKMODAL);
+ "This process may take very long."), L"Bin Converter", MB_OKCANCEL | MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL) == IDOK) {
+ EnumIpDataLines("ip-to-country.csv", "ip-to-country.bin");
+ MessageBox(NULL, L"Done!\n'ip-to-country.bin' has been created in current directory.", L"Bin Converter", MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST | MB_TASKMODAL);
}
}
@@ -300,10 +299,10 @@ static void BinConvThread(void *unused) void InitIpToCountry(void)
{
- nDataRecordsCount=0;
- dataRecords=nullptr;
+ nDataRecordsCount = 0;
+ dataRecords = nullptr;
/* Services */
- CreateServiceFunction(MS_FLAGS_IPTOCOUNTRY,ServiceIpToCountry);
+ CreateServiceFunction(MS_FLAGS_IPTOCOUNTRY, ServiceIpToCountry);
#ifdef BINCONV
mir_forkthread(BinConvThread);
#endif
diff --git a/plugins/CountryFlags/src/main.cpp b/plugins/CountryFlags/src/main.cpp index e34ff660be..78525158be 100644 --- a/plugins/CountryFlags/src/main.cpp +++ b/plugins/CountryFlags/src/main.cpp @@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int nCountriesCount;
CountryListEntry *countries;
-HINSTANCE hInst;
+CMPlugin g_plugin;
int hLangpack;
-static PLUGININFOEX pluginInfo={
+static PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -38,12 +38,6 @@ static PLUGININFOEX pluginInfo={ {0x68c36842, 0x3d95, 0x4f4a, {0xab, 0x81, 0x1, 0x4d, 0x65, 0x93, 0x86, 0x3b}}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
@@ -54,12 +48,12 @@ extern "C" __declspec(dllexport) int Load(void) mir_getLP(&pluginInfo);
PrepareBufferedFunctions();
- if ( CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&nCountriesCount, (LPARAM)&countries))
+ if (CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&nCountriesCount, (LPARAM)&countries))
nCountriesCount = 0;
bShowStatusIcon = db_get_b(NULL, MODULENAME, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
- bShowExtraIcon = db_get_b(NULL, MODULENAME, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT) != 0;
- bUseUnknown = db_get_b(NULL, MODULENAME, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
+ bShowExtraIcon = db_get_b(NULL, MODULENAME, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT) != 0;
+ bUseUnknown = db_get_b(NULL, MODULENAME, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
bUseIpToCountry = db_get_b(NULL, MODULENAME, "UseIpToCountry", SETTING_USEIPTOCOUNTRY_DEFAULT) != 0;
InitIcons();
diff --git a/plugins/CountryFlags/src/options.cpp b/plugins/CountryFlags/src/options.cpp index 01b0e31a5c..d47bf75963 100644 --- a/plugins/CountryFlags/src/options.cpp +++ b/plugins/CountryFlags/src/options.cpp @@ -23,38 +23,38 @@ bool bUseUnknown, bShowStatusIcon, bShowExtraIcon, bUseIpToCountry; #define M_ENABLE_SUBCTLS (WM_APP+1)
-static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM,LPARAM lParam)
+static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
CheckDlgButton(hwndDlg, IDC_CHECK_SHOWSTATUSICONFLAG, bShowStatusIcon ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SHOWEXTRAIMGFLAG, bShowExtraIcon ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_USEUNKNOWNFLAG, bUseUnknown ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg,IDC_CHECK_USEIPTOCOUNTRY, bUseIpToCountry ? BST_CHECKED : BST_UNCHECKED);
-
- SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ CheckDlgButton(hwndDlg, IDC_CHECK_USEIPTOCOUNTRY, bUseIpToCountry ? BST_CHECKED : BST_UNCHECKED);
+
+ SendMessage(hwndDlg, M_ENABLE_SUBCTLS, 0, 0);
return TRUE; /* default focus */
case M_ENABLE_SUBCTLS:
- {
- BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWEXTRAIMGFLAG);
- EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT_EXTRAIMGFLAGCOLUMN), checked);
- if (!checked)
- checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWSTATUSICONFLAG);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_USEUNKNOWNFLAG), checked);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_USEIPTOCOUNTRY), checked);
- }
- return TRUE;
+ {
+ BOOL checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWEXTRAIMGFLAG);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TEXT_EXTRAIMGFLAGCOLUMN), checked);
+ if (!checked)
+ checked = IsDlgButtonChecked(hwndDlg, IDC_CHECK_SHOWSTATUSICONFLAG);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_USEUNKNOWNFLAG), checked);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK_USEIPTOCOUNTRY), checked);
+ }
+ return TRUE;
case WM_COMMAND:
- PostMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
- PostMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); /* enable apply */
+ PostMessage(hwndDlg, M_ENABLE_SUBCTLS, 0, 0);
+ PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); /* enable apply */
return FALSE;
case WM_NOTIFY:
- switch(((NMHDR*)lParam)->code) {
+ switch (((NMHDR*)lParam)->code) {
case PSN_APPLY: /* setting change hook will pick these up */
bool bChanged = false, bTemp;
@@ -83,7 +83,7 @@ static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM,LPARAM l int OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_EXTRAIMG);
odp.position = 900000002;
odp.szGroup.a = LPGEN("Icons"); /* autotranslated */
diff --git a/plugins/CountryFlags/src/stdafx.h b/plugins/CountryFlags/src/stdafx.h index 5ca2c565f3..894510b513 100644 --- a/plugins/CountryFlags/src/stdafx.h +++ b/plugins/CountryFlags/src/stdafx.h @@ -26,7 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <win2k.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_langpack.h>
#include <m_icolib.h>
@@ -44,7 +43,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "resource.h"
#include "version.h"
-extern HINSTANCE hInst;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
extern int nCountriesCount;
extern CountryListEntry *countries;
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 64d10f56f6..ae4450d937 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
+CMPlugin g_plugin;
int hLangpack;
-HINSTANCE hInst;
DWORD mirandaVersion;
LCID packlcid;
//HANDLE hCrashLogFolder, hVerInfoFolder;
@@ -119,7 +119,7 @@ INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM) }
else {
DWORD dwFlags = wParam ? (VI_FLAG_PRNVAR | VI_FLAG_PRNDLL) : VI_FLAG_PRNVAR;
- hViewWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_VIEWVERSION), nullptr, DlgProcView, dwFlags);
+ hViewWnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_VIEWVERSION), nullptr, DlgProcView, dwFlags);
}
return 0;
@@ -200,7 +200,7 @@ int OptionsInit(WPARAM wParam, LPARAM) {
OPTIONSDIALOGPAGE odp = {};
odp.position = -790000000;
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szTitle.a = PluginName;
odp.szGroup.a = LPGEN("Services");
@@ -404,9 +404,3 @@ extern "C" int __declspec(dllexport) Unload(void) FreeLibrary(hMsftedit);
return 0;
}
-
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
diff --git a/plugins/CrashDumper/src/crshdmp_icons.cpp b/plugins/CrashDumper/src/crshdmp_icons.cpp index cbefe71020..eec6791409 100644 --- a/plugins/CrashDumper/src/crshdmp_icons.cpp +++ b/plugins/CrashDumper/src/crshdmp_icons.cpp @@ -30,7 +30,7 @@ static IconItem iconList[] = void InitIcons(void)
{
- Icon_Register(hInst, LPGEN("Crash Dumper"), iconList, _countof(iconList), PluginName);
+ Icon_Register(g_plugin.getInst(), LPGEN("Crash Dumper"), iconList, _countof(iconList), PluginName);
}
HICON LoadIconEx(int iconId, bool big)
diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h index ff651e6839..ac343409e7 100644 --- a/plugins/CrashDumper/src/stdafx.h +++ b/plugins/CrashDumper/src/stdafx.h @@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <delayimp.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_utils.h>
#include <m_langpack.h>
@@ -80,6 +78,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define PluginName "Crash Dumper"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(PluginName)
+ {}
+};
+
#define VI_FLAG_FORMAT 1
#define VI_FLAG_PRNVAR 2
#define VI_FLAG_PRNDLL 4
@@ -91,7 +96,6 @@ struct VerTrnsfr bool autot;
};
-extern HMODULE hInst;
extern DWORD mirandaVersion;
extern LCID packlcid;
extern bool servicemode, clsdates, dtsubfldr, catchcrashes, needrestart;
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index d09ac5b809..d270b7438b 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
HWND hViewWnd;
-extern HINSTANCE hInst;
HDWP MyResizeWindow(HDWP hDwp, HWND hwndDlg, HWND hwndCtrl, int nHorizontalOffset, int nVerticalOffset, int nWidthOffset, int nHeightOffset)
{
@@ -132,7 +131,7 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara if (PtInRect(&rc, pt)) {
static const CHARRANGE all = { 0, -1 };
- HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT));
HMENU hSubMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hSubMenu);
diff --git a/plugins/CryptoPP/src/GPGw/gpg_main.cpp b/plugins/CryptoPP/src/GPGw/gpg_main.cpp index 311d7daa7c..f0b96bcf47 100644 --- a/plugins/CryptoPP/src/GPGw/gpg_main.cpp +++ b/plugins/CryptoPP/src/GPGw/gpg_main.cpp @@ -10,8 +10,8 @@ char logfile[fullfilenamesize]; char *txtbeginpgppublickeyblock="-----BEGIN PGP PUBLIC KEY BLOCK-----";
char *txtendpgppublickeyblock="-----END PGP PUBLIC KEY BLOCK-----";
*/
-char *txtbeginpgpmessage="-----BEGIN PGP MESSAGE-----";
-char *txtendpgpmessage="-----END PGP MESSAGE-----";
+char *txtbeginpgpmessage = "-----BEGIN PGP MESSAGE-----";
+char *txtendpgpmessage = "-----END PGP MESSAGE-----";
void __cdecl ErrorMessage(const char *alevel, const char *atext, const char *ahint)
{
@@ -28,10 +28,10 @@ void __cdecl LogMessage(const char *astart, const char *atext, const char *aend) {
FILE *log;
- if(logfile[0]=='\0') return;
+ if (logfile[0] == '\0') return;
- log=fopen(logfile, "a");
- if(log!=NULL)
+ log = fopen(logfile, "a");
+ if (log != NULL)
{
fputs(astart, log);
fputs(atext, log);
@@ -42,8 +42,8 @@ void __cdecl LogMessage(const char *astart, const char *atext, const char *aend) int __cdecl _gpg_init()
{
- GetTempPath(sizeof(temporarydirectory),temporarydirectory);
- logfile[0]='\0';
+ GetTempPath(sizeof(temporarydirectory), temporarydirectory);
+ logfile[0] = '\0';
initPassphrases();
initKeyUserIDs(publickeyuserid);
initKeyUserIDs(secretkeyuserid);
@@ -62,13 +62,13 @@ int __cdecl _gpg_done() int __cdecl _gpg_open_keyrings(LPSTR ExecPath, LPSTR HomePath)
{
- if ( !ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath)) ) {
+ if (!ExecPath || (!*ExecPath && !ShowSelectExecDlg(ExecPath))) {
return 0;
}
- if ( !HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath)) ) {
+ if (!HomePath || (!*HomePath && !ShowSelectHomeDlg(HomePath))) {
return 0;
}
- if ( !existsFile(ExecPath) ) {
+ if (!existsFile(ExecPath)) {
// ErrorMessage(txtwarning, txtinvalidexecutable, txtverifyoptions);
return 0;
}
@@ -94,15 +94,15 @@ LPSTR __cdecl _gpg_get_error() void __cdecl _gpg_set_log(LPCSTR LogPath)
{
- if(LogPath) strncpy(logfile,LogPath,sizeof(logfile));
- else logfile[0]='\0';
+ if (LogPath) strncpy(logfile, LogPath, sizeof(logfile));
+ else logfile[0] = '\0';
}
void __cdecl _gpg_set_tmp(LPCSTR TmpPath)
{
- if(TmpPath) strncpy(temporarydirectory,TmpPath,sizeof(temporarydirectory));
- else GetTempPath(sizeof(temporarydirectory),temporarydirectory);
+ if (TmpPath) strncpy(temporarydirectory, TmpPath, sizeof(temporarydirectory));
+ else GetTempPath(sizeof(temporarydirectory), temporarydirectory);
}
@@ -110,21 +110,21 @@ LPSTR __cdecl _gpg_get_passphrases() {
size_t i; char *b, x;
- b = (char *) LocalAlloc(LPTR,(keyuseridsize+passphrasesize)*passphrasecount+1); *b = '\0';
+ b = (char *)LocalAlloc(LPTR, (keyuseridsize + passphrasesize)*passphrasecount + 1); *b = '\0';
- for(i=0; i<(size_t)passphrasecount; i++) {
- strcat(b,passphrases[i].keyuserid); strcat(b,"\x01");
- strcat(b,passphrases[i].passphrase); strcat(b,"\x02");
+ for (i = 0; i < (size_t)passphrasecount; i++) {
+ strcat(b, passphrases[i].keyuserid); strcat(b, "\x01");
+ strcat(b, passphrases[i].passphrase); strcat(b, "\x02");
}
// encrypt
- for(i=0; i<strlen(b); i++)
- if ( b[i]>2 ) {
- x = b[i] ^ ( (i&0x7f) ^ 13);
- if ( x>2 ) b[i]=x;
+ for (i = 0; i < strlen(b); i++)
+ if (b[i] > 2) {
+ x = b[i] ^ ((i & 0x7f) ^ 13);
+ if (x > 2) b[i] = x;
}
- return b;
+ return b;
}
@@ -132,25 +132,25 @@ void __cdecl _gpg_set_passphrases(LPCSTR buffer) {
size_t i, l = strlen(buffer); char *t, *p, *b, x;
- if ( !l ) return;
+ if (!l) return;
- b = (char *) LocalAlloc(LPTR,l+1);
+ b = (char *)LocalAlloc(LPTR, l + 1);
strcpy(b, buffer);
// decrypt
- for(i=0; i<strlen(b); i++)
- if ( b[i]>2 ) {
- x = b[i] ^ ( (i&0x7f) ^ 13);
- if ( x>2 ) b[i]=x;
+ for (i = 0; i < strlen(b); i++)
+ if (b[i] > 2) {
+ x = b[i] ^ ((i & 0x7f) ^ 13);
+ if (x > 2) b[i] = x;
}
- while(*b) {
+ while (*b) {
t = strchr(b, '\x02');
- if(t) {
+ if (t) {
*t = '\0';
p = strchr(b, '\x01');
*p = '\0';
- addPassphrase(b, p+1);
+ addPassphrase(b, p + 1);
t++;
}
b = t;
@@ -165,16 +165,16 @@ LPSTR __cdecl _gpg_encrypt(LPCSTR message, LPCSTR keyid) char *encmessage = 0;
gpgResult gpgresult;
- if(strlen(keyid))
+ if (strlen(keyid))
{
memset(buffer, 0, sizeof(buffer));
- gpgresult=gpgEncrypt(buffer, keyid, message);
+ gpgresult = gpgEncrypt(buffer, keyid, message);
- if(gpgresult!=gpgSuccess)
+ if (gpgresult != gpgSuccess)
return 0;
- size_t encmessagelen = strlen(buffer)+1;
- encmessage = (char *) LocalAlloc(LPTR,encmessagelen);
+ size_t encmessagelen = strlen(buffer) + 1;
+ encmessage = (char *)LocalAlloc(LPTR, encmessagelen);
memcpy(encmessage, buffer, encmessagelen);
}
@@ -196,64 +196,64 @@ LPSTR __cdecl _gpg_decrypt(LPCSTR message) const char *begin = strstr(message, txtbeginpgpmessage);
const char *end = strstr(message, txtendpgpmessage);
- if ((begin!=NULL)&&(end!=NULL))
+ if ((begin != NULL) && (end != NULL))
{
strcpy(buffer, "");
- strncat(buffer, begin, end-begin+strlen(txtendpgpmessage));
+ strncat(buffer, begin, end - begin + strlen(txtendpgpmessage));
replace(buffer, "\r", "");
replace(buffer, "\n", txtcrlf);
memset(keyuserid, 0, sizeof(keyuserid));
- gpgresult=gpgDetectUserID(keyuserid, buffer);
- storedpassphrase=NULL;
+ gpgresult = gpgDetectUserID(keyuserid, buffer);
+ storedpassphrase = NULL;
- if(gpgresult!=gpgSuccess)
+ if (gpgresult != gpgSuccess)
{
// ErrorMessage(txtwarning, txtdetectuseridfailed, txtverifyoptions);
strcpy(keyuserid, txtunknownuserid);
- useridvalid=FALSE;
+ useridvalid = FALSE;
}
else
{
- storedpassphrase=getPassphrase(keyuserid);
- useridvalid=TRUE;
+ storedpassphrase = getPassphrase(keyuserid);
+ useridvalid = TRUE;
}
- if(storedpassphrase!=NULL)
+ if (storedpassphrase != NULL)
{
strcpy(passphrase, storedpassphrase);
memset(plaintext, 0, sizeof(plaintext));
- gpgresult=gpgDecrypt(plaintext, buffer, passphrase);
+ gpgresult = gpgDecrypt(plaintext, buffer, passphrase);
}
- else gpgresult=gpgUnknownError;
+ else gpgresult = gpgUnknownError;
- dlgresult=IDOK;
- while((gpgresult!=gpgSuccess)&&(dlgresult!=IDCANCEL))
+ dlgresult = IDOK;
+ while ((gpgresult != gpgSuccess) && (dlgresult != IDCANCEL))
{
- dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, PassphraseDialogProcedure, (LPARAM)keyuserid);
+ dlgresult = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PASSPHRASE), NULL, PassphraseDialogProcedure, (LPARAM)keyuserid);
- if(dlgresult==IDOK)
+ if (dlgresult == IDOK)
{
strcpy(passphrase, dlgpassphrase);
memset(dlgpassphrase, 0, passphrasesize);
strcat(passphrase, txtcrlf);
memset(plaintext, 0, sizeof(plaintext));
- gpgresult=gpgDecrypt(plaintext, buffer, passphrase);
+ gpgresult = gpgDecrypt(plaintext, buffer, passphrase);
}
}
- if(gpgresult==gpgSuccess)
+ if (gpgresult == gpgSuccess)
{
strcpy(buffer, plaintext);
}
- if ( gpgresult==gpgSuccess && useridvalid==TRUE)
+ if (gpgresult == gpgSuccess && useridvalid == TRUE)
addPassphrase(keyuserid, passphrase);
SecureZeroMemory(passphrase, sizeof(passphrase));
- size_t decmessagelen = strlen(buffer)+1;
- decmessage = (char *) LocalAlloc(LPTR,decmessagelen);
+ size_t decmessagelen = strlen(buffer) + 1;
+ decmessage = (char *)LocalAlloc(LPTR, decmessagelen);
memcpy(decmessage, buffer, decmessagelen);
}
@@ -272,32 +272,32 @@ int __cdecl _gpg_select_keyid(HWND hdlg, LPSTR keyid) int dlgresult;
memset(keyid, 0, keyidsize);
- dlgresult=DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_SELECTKEY), hdlg, UserIdDialogProcedure, (LPARAM)keyid);
+ dlgresult = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_SELECTKEY), hdlg, UserIdDialogProcedure, (LPARAM)keyid);
- if(dlgresult!=IDOK)
+ if (dlgresult != IDOK)
memset(keyid, 0, keyidsize);
- return (dlgresult==IDOK);
+ return (dlgresult == IDOK);
}
void noBackslash(LPSTR path)
{
LPSTR ptr = path + strlen(path) - 1;
- if ( *ptr=='\\' ) *ptr = '\0';
+ if (*ptr == '\\') *ptr = '\0';
}
static char buf[MAX_PATH];
-LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName)
+LPSTR GetRegValue(HKEY hKey, LPCSTR szPath, LPCSTR szName)
{
- DWORD len=MAX_PATH,type;
- LPSTR ret=0;
+ DWORD len = MAX_PATH, type;
+ LPSTR ret = 0;
- RegOpenKey(hKey,szPath,&hKey);
- if ( RegQueryValueEx(hKey,szName,NULL,&type,(LPBYTE)&buf,&len)==ERROR_SUCCESS ) {
+ RegOpenKey(hKey, szPath, &hKey);
+ if (RegQueryValueEx(hKey, szName, NULL, &type, (LPBYTE)&buf, &len) == ERROR_SUCCESS) {
noBackslash((LPSTR)&buf);
ret = (LPSTR)&buf;
}
@@ -309,9 +309,9 @@ LPSTR GetRegValue(HKEY hKey , LPCSTR szPath, LPCSTR szName) LPSTR GetEnvValue(LPCSTR szName)
{
- LPSTR ret=0;
+ LPSTR ret = 0;
- if ( GetEnvironmentVariable(szName, buf, MAX_PATH) > 0 ) {
+ if (GetEnvironmentVariable(szName, buf, MAX_PATH) > 0) {
noBackslash((LPSTR)&buf);
ret = (LPSTR)&buf;
}
@@ -325,15 +325,15 @@ BOOL ShowSelectExecDlg(LPSTR path) OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
- ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","gpgProgram");
- if ( ofn.lpstrFile && existsFile(ofn.lpstrFile) ) {
+ ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", "gpgProgram");
+ if (ofn.lpstrFile && existsFile(ofn.lpstrFile)) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
- ofn.lpstrFile = GetRegValue(HKEY_LOCAL_MACHINE,"Software\\GNU\\GnuPG","Install Directory");
- if ( ofn.lpstrFile ) {
- strcat(ofn.lpstrFile,"\\gpg.exe");
- if ( existsFile(ofn.lpstrFile) ) {
+ ofn.lpstrFile = GetRegValue(HKEY_LOCAL_MACHINE, "Software\\GNU\\GnuPG", "Install Directory");
+ if (ofn.lpstrFile) {
+ strcat(ofn.lpstrFile, "\\gpg.exe");
+ if (existsFile(ofn.lpstrFile)) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
@@ -357,19 +357,19 @@ BOOL ShowSelectHomeDlg(LPSTR path) OPENFILENAME ofn;
ofn.lpstrFile = GetEnvValue("GNUPGHOME");
- if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
+ if (ofn.lpstrFile && existsPath(ofn.lpstrFile)) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
- ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER,"Software\\GNU\\GnuPG","HomeDir");
- if ( ofn.lpstrFile && existsPath(ofn.lpstrFile) ) {
+ ofn.lpstrFile = GetRegValue(HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", "HomeDir");
+ if (ofn.lpstrFile && existsPath(ofn.lpstrFile)) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
ofn.lpstrFile = GetEnvValue("APPDATA");
- if ( ofn.lpstrFile ) {
- strcat(ofn.lpstrFile,"\\gnupg");
- if ( existsPath(ofn.lpstrFile) ) {
+ if (ofn.lpstrFile) {
+ strcat(ofn.lpstrFile, "\\gnupg");
+ if (existsPath(ofn.lpstrFile)) {
strcpy(path, ofn.lpstrFile);
return TRUE;
}
@@ -385,7 +385,7 @@ BOOL ShowSelectHomeDlg(LPSTR path) if (!GetOpenFileName(&ofn)) return FALSE;
int i;
- for(i = (int)strlen(path);i && path[i]!='\\';i--);
+ for (i = (int)strlen(path); i && path[i] != '\\'; i--);
path[i] = 0;
return TRUE;
diff --git a/plugins/CryptoPP/src/GPGw/gpgw.h b/plugins/CryptoPP/src/GPGw/gpgw.h index 041c79abc5..aefa913d04 100644 --- a/plugins/CryptoPP/src/GPGw/gpgw.h +++ b/plugins/CryptoPP/src/GPGw/gpgw.h @@ -39,7 +39,6 @@ extern char *txtendpgpmessage; extern LPCSTR szModuleName;
extern LPCSTR szVersionStr;
-extern HINSTANCE g_hInst;
#define DLLEXPORT __declspec(dllexport)
diff --git a/plugins/CryptoPP/src/commonheaders.h b/plugins/CryptoPP/src/commonheaders.h index e959912d38..0925c0881f 100644 --- a/plugins/CryptoPP/src/commonheaders.h +++ b/plugins/CryptoPP/src/commonheaders.h @@ -5,13 +5,13 @@ #define CRYPTOPP_DEFAULT_NO_DLL
#ifdef _MSC_VER
- #pragma once
- #define _CRT_SECURE_NO_WARNINGS
- #define _SCL_SECURE_NO_WARNINGS
- #define NOMINMAX
- #ifndef _WIN64
- #define _USE_32BIT_TIME_T
- #endif
+#pragma once
+#define _CRT_SECURE_NO_WARNINGS
+#define _SCL_SECURE_NO_WARNINGS
+#define NOMINMAX
+#ifndef _WIN64
+#define _USE_32BIT_TIME_T
+#endif
#endif
#include <limits>
@@ -32,7 +32,6 @@ #define M_API_H__
// Miranda API
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
#include <m_system.h>
#include <m_utils.h>
@@ -55,11 +54,17 @@ #define MODULENAME "Crypto++"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME)
+ {}
+};
+
extern LPCSTR szModuleName;
extern LPCSTR szVersionStr;
// shared vars
-extern HINSTANCE g_hInst;
extern PLUGININFOEX pluginInfoEx;
extern HANDLE hPGPPRIV;
@@ -67,7 +72,7 @@ extern HANDLE hRSA4096; extern mir_cs localQueueMutex;
-void ExtractFile(char*,int,int);
+void ExtractFile(char*, int, int);
size_t rtrim(LPCSTR);
std::string base64encode(const std::string&);
@@ -78,14 +83,14 @@ std::string base64decode(const char *); extern HNETLIBUSER hNetlibUser;
void InitNetlib();
void DeinitNetlib();
-int Sent_NetLog(const char *,...);
+int Sent_NetLog(const char *, ...);
#endif
#define DLLEXPORT __declspec(dllexport)
PBYTE cpp_alloc_pdata(pCNTX);
-extern "C"
+extern "C"
{
DLLEXPORT HANDLE __cdecl cpp_create_context(int); // create crypt-context
DLLEXPORT void __cdecl cpp_delete_context(HANDLE); // delete crypt-context
diff --git a/plugins/CryptoPP/src/cpp_gpgw.cpp b/plugins/CryptoPP/src/cpp_gpgw.cpp index bda82d6e6f..6141ee8796 100644 --- a/plugins/CryptoPP/src/cpp_gpgw.cpp +++ b/plugins/CryptoPP/src/cpp_gpgw.cpp @@ -7,21 +7,21 @@ PBYTE pRS_gpg; int __cdecl _gpg_init(void);
int __cdecl _gpg_done(void);
-int __cdecl _gpg_open_keyrings(LPSTR,LPSTR);
+int __cdecl _gpg_open_keyrings(LPSTR, LPSTR);
int __cdecl _gpg_close_keyrings(void);
void __cdecl _gpg_set_log(LPCSTR);
void __cdecl _gpg_set_tmp(LPCSTR);
LPSTR __cdecl _gpg_get_error(void);
int __cdecl _gpg_size_keyid(void);
-int __cdecl _gpg_select_keyid(HWND,LPSTR);
-LPSTR __cdecl _gpg_encrypt(LPCSTR,LPCSTR);
+int __cdecl _gpg_select_keyid(HWND, LPSTR);
+LPSTR __cdecl _gpg_encrypt(LPCSTR, LPCSTR);
LPSTR __cdecl _gpg_decrypt(LPCSTR);
LPSTR __cdecl _gpg_get_passphrases();
void __cdecl _gpg_set_passphrases(LPCSTR);
int __cdecl gpg_init()
{
- hgpg = g_hInst;
+ hgpg = g_plugin.getInst();
return _gpg_init();
}
@@ -71,7 +71,7 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg) return ptr->tmp = nullptr;
}
else {
- ptr->tmp = mir_strdup(szEncMsg);
+ ptr->tmp = mir_strdup(szEncMsg);
LocalFree((LPVOID)szEncMsg);
return ptr->tmp;
}
diff --git a/plugins/CryptoPP/src/cpp_pgpw.cpp b/plugins/CryptoPP/src/cpp_pgpw.cpp index d574c2f236..4c148cffec 100644 --- a/plugins/CryptoPP/src/cpp_pgpw.cpp +++ b/plugins/CryptoPP/src/cpp_pgpw.cpp @@ -8,31 +8,31 @@ PBYTE pRS_pgp; int __cdecl _pgp_init(void);
int __cdecl _pgp_done(void);
-int __cdecl _pgp_open_keyrings(LPSTR,LPSTR);
+int __cdecl _pgp_open_keyrings(LPSTR, LPSTR);
int __cdecl _pgp_close_keyrings(void);
int __cdecl _pgp_get_version(void);
LPSTR __cdecl _pgp_get_error(void);
int __cdecl _pgp_size_keyid(void);
-PVOID __cdecl _pgp_select_keyid(HWND,LPSTR);
-LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR,PVOID);
+PVOID __cdecl _pgp_select_keyid(HWND, LPSTR);
+LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR, PVOID);
LPSTR __cdecl _pgp_decrypt_keydb(LPCSTR);
//int __cdecl _pgp_check_key(LPCSTR);
-LPSTR __cdecl _pgp_encrypt_key(LPCSTR,LPCSTR);
-LPSTR __cdecl _pgp_decrypt_key(LPCSTR,LPCSTR);
-
-int (__cdecl *p_pgp_init)(void);
-int (__cdecl *p_pgp_done)(void);
-int (__cdecl *p_pgp_open_keyrings)(LPSTR,LPSTR);
-int (__cdecl *p_pgp_close_keyrings)(void);
-int (__cdecl *p_pgp_get_version)(void);
-LPSTR (__cdecl *p_pgp_get_error)(void);
-int (__cdecl *p_pgp_size_keyid)(void);
-PVOID (__cdecl *p_pgp_select_keyid)(HWND,LPSTR);
-LPSTR (__cdecl *p_pgp_encrypt_keydb)(LPCSTR,PVOID);
-LPSTR (__cdecl *p_pgp_decrypt_keydb)(LPCSTR);
+LPSTR __cdecl _pgp_encrypt_key(LPCSTR, LPCSTR);
+LPSTR __cdecl _pgp_decrypt_key(LPCSTR, LPCSTR);
+
+int(__cdecl *p_pgp_init)(void);
+int(__cdecl *p_pgp_done)(void);
+int(__cdecl *p_pgp_open_keyrings)(LPSTR, LPSTR);
+int(__cdecl *p_pgp_close_keyrings)(void);
+int(__cdecl *p_pgp_get_version)(void);
+LPSTR(__cdecl *p_pgp_get_error)(void);
+int(__cdecl *p_pgp_size_keyid)(void);
+PVOID(__cdecl *p_pgp_select_keyid)(HWND, LPSTR);
+LPSTR(__cdecl *p_pgp_encrypt_keydb)(LPCSTR, PVOID);
+LPSTR(__cdecl *p_pgp_decrypt_keydb)(LPCSTR);
//int (__cdecl *p_pgp_check_key)(LPCSTR);
-LPSTR (__cdecl *p_pgp_encrypt_key)(LPCSTR,LPCSTR);
-LPSTR (__cdecl *p_pgp_decrypt_key)(LPCSTR,LPCSTR);
+LPSTR(__cdecl *p_pgp_encrypt_key)(LPCSTR, LPCSTR);
+LPSTR(__cdecl *p_pgp_decrypt_key)(LPCSTR, LPCSTR);
#define GPA(x) \
{ \
@@ -97,7 +97,7 @@ int __cdecl pgp_init() memset(tmp->pdata, 0, sizeof(PGPDATA));
}
- hpgpsdk = g_hInst;
+ hpgpsdk = g_plugin.getInst();
return 0;
}
diff --git a/plugins/CryptoPP/src/cryptopp.h b/plugins/CryptoPP/src/cryptopp.h index a13337f20e..a98b6204f5 100644 --- a/plugins/CryptoPP/src/cryptopp.h +++ b/plugins/CryptoPP/src/cryptopp.h @@ -107,7 +107,7 @@ typedef RSAPRIV* pRSAPRIV; typedef deque<string, allocator<string> > STRINGDEQUE;
-typedef queue<string,STRINGDEQUE> STRINGQUEUE;
+typedef queue<string, STRINGDEQUE> STRINGQUEUE;
typedef struct __RSADATA {
@@ -120,7 +120,7 @@ typedef struct __RSADATA { string aes_v; // aes iv
HANDLE thread; // thread handle
BOOL thread_exit;
- HANDLE event; // thread event
+ HANDLE event; // thread event
STRINGQUEUE *queue; // thread queue
} RSADATA;
typedef RSADATA* pRSADATA;
@@ -151,48 +151,47 @@ typedef RSADATA* pRSADATA; extern LPCSTR szModuleName;
extern LPCSTR szVersionStr;
-extern HINSTANCE g_hInst;
pCNTX get_context_on_id(int);
pCNTX get_context_on_id(HANDLE);
void cpp_free_keys(pCNTX);
-BYTE *cpp_gzip(BYTE*,size_t,size_t&);
-BYTE *cpp_gunzip(BYTE*,size_t,size_t&);
+BYTE *cpp_gzip(BYTE*, size_t, size_t&);
+BYTE *cpp_gunzip(BYTE*, size_t, size_t&);
string cpp_zlibc(string&);
string cpp_zlibd(string&);
typedef struct {
- int (__cdecl *rsa_gen_keypair)(short); // генерит RSA-ключи для указанной длины (либо тока 2048, либо 2048 и 4096)
- int (__cdecl *rsa_get_keypair)(short,PBYTE,int*,PBYTE,int*); // возвращает пару ключей для указанной длины
- int (__cdecl *rsa_get_keyhash)(short,PBYTE,int*,PBYTE,int*); // возвращает hash пары ключей для указанной длины
- int (__cdecl *rsa_set_keypair)(short,PBYTE,int); // устанавливает ключи, указанной длины
- int (__cdecl *rsa_get_pubkey)(HANDLE,PBYTE,int*); // возвращает паблик ключ из указанного контекста
- int (__cdecl *rsa_set_pubkey)(HANDLE,PBYTE,int); // загружает паблик ключ для указанного контекста
- void (__cdecl *rsa_set_timeout)(int); // установить таймаут для установки секюрного соединения
- int (__cdecl *rsa_get_state)(HANDLE); // получить статус указанного контекста
- int (__cdecl *rsa_get_hash)(PBYTE,int,PBYTE,int*); // вычисляет SHA1(key)
- int (__cdecl *rsa_connect)(HANDLE); // запускает процесс установки содинения с указанным контекстом
- int (__cdecl *rsa_disconnect)(HANDLE); // разрывает соединение с указанным контекстом
- int (__cdecl *rsa_disabled)(HANDLE); // разрывает соединение по причине "disabled"
- LPSTR (__cdecl *rsa_recv)(HANDLE,LPCSTR); // необходимо передавать сюда все входящие протокольные сообщения
- int (__cdecl *rsa_send)(HANDLE,LPCSTR); // вызываем для отправки сообщения клиенту
- int (__cdecl *rsa_encrypt_file)(HANDLE,LPCSTR,LPCSTR);
- int (__cdecl *rsa_decrypt_file)(HANDLE,LPCSTR,LPCSTR);
- LPSTR (__cdecl *utf8encode)(LPCWSTR);
- LPWSTR (__cdecl *utf8decode)(LPCSTR);
- int (__cdecl *is_7bit_string)(LPCSTR);
- int (__cdecl *is_utf8_string)(LPCSTR);
- int (__cdecl *rsa_export_keypair)(short,LPSTR,LPSTR,LPSTR); // export private key
- int (__cdecl *rsa_import_keypair)(short,LPSTR,LPSTR); // import & activate private key
- int (__cdecl *rsa_export_pubkey)(HANDLE,LPSTR); // export public key from context
- int (__cdecl *rsa_import_pubkey)(HANDLE,LPSTR); // import public key into context
+ int(__cdecl *rsa_gen_keypair)(short); // генерит RSA-ключи для указанной длины (либо тока 2048, либо 2048 и 4096)
+ int(__cdecl *rsa_get_keypair)(short, PBYTE, int*, PBYTE, int*); // возвращает пару ключей для указанной длины
+ int(__cdecl *rsa_get_keyhash)(short, PBYTE, int*, PBYTE, int*); // возвращает hash пары ключей для указанной длины
+ int(__cdecl *rsa_set_keypair)(short, PBYTE, int); // устанавливает ключи, указанной длины
+ int(__cdecl *rsa_get_pubkey)(HANDLE, PBYTE, int*); // возвращает паблик ключ из указанного контекста
+ int(__cdecl *rsa_set_pubkey)(HANDLE, PBYTE, int); // загружает паблик ключ для указанного контекста
+ void(__cdecl *rsa_set_timeout)(int); // установить таймаут для установки секюрного соединения
+ int(__cdecl *rsa_get_state)(HANDLE); // получить статус указанного контекста
+ int(__cdecl *rsa_get_hash)(PBYTE, int, PBYTE, int*); // вычисляет SHA1(key)
+ int(__cdecl *rsa_connect)(HANDLE); // запускает процесс установки содинения с указанным контекстом
+ int(__cdecl *rsa_disconnect)(HANDLE); // разрывает соединение с указанным контекстом
+ int(__cdecl *rsa_disabled)(HANDLE); // разрывает соединение по причине "disabled"
+ LPSTR(__cdecl *rsa_recv)(HANDLE, LPCSTR); // необходимо передавать сюда все входящие протокольные сообщения
+ int(__cdecl *rsa_send)(HANDLE, LPCSTR); // вызываем для отправки сообщения клиенту
+ int(__cdecl *rsa_encrypt_file)(HANDLE, LPCSTR, LPCSTR);
+ int(__cdecl *rsa_decrypt_file)(HANDLE, LPCSTR, LPCSTR);
+ LPSTR(__cdecl *utf8encode)(LPCWSTR);
+ LPWSTR(__cdecl *utf8decode)(LPCSTR);
+ int(__cdecl *is_7bit_string)(LPCSTR);
+ int(__cdecl *is_utf8_string)(LPCSTR);
+ int(__cdecl *rsa_export_keypair)(short, LPSTR, LPSTR, LPSTR); // export private key
+ int(__cdecl *rsa_import_keypair)(short, LPSTR, LPSTR); // import & activate private key
+ int(__cdecl *rsa_export_pubkey)(HANDLE, LPSTR); // export public key from context
+ int(__cdecl *rsa_import_pubkey)(HANDLE, LPSTR); // import public key into context
} RSA_EXPORT;
typedef RSA_EXPORT* pRSA_EXPORT;
typedef struct {
- int (__cdecl *rsa_inject)(HANDLE,LPCSTR); // вставляет сообщение в очередь на отправку
- int (__cdecl *rsa_check_pub)(HANDLE,PBYTE,int,PBYTE,int); // проверяет интерактивно SHA и сохраняет ключ, если все нормально
- void (__cdecl *rsa_notify)(HANDLE,int); // нотификация о смене состояния
+ int(__cdecl *rsa_inject)(HANDLE, LPCSTR); // вставляет сообщение в очередь на отправку
+ int(__cdecl *rsa_check_pub)(HANDLE, PBYTE, int, PBYTE, int); // проверяет интерактивно SHA и сохраняет ключ, если все нормально
+ void(__cdecl *rsa_notify)(HANDLE, int); // нотификация о смене состояния
} RSA_IMPORT;
typedef RSA_IMPORT* pRSA_IMPORT;
diff --git a/plugins/CryptoPP/src/main.cpp b/plugins/CryptoPP/src/main.cpp index 922ca181ce..6c735ccbbd 100644 --- a/plugins/CryptoPP/src/main.cpp +++ b/plugins/CryptoPP/src/main.cpp @@ -1,9 +1,9 @@ #include "commonheaders.h"
+CMPlugin g_plugin;
int hLangpack;
LPCSTR szModuleName = MODULENAME;
LPCSTR szVersionStr = MODULENAME" DLL (" __VERSION_STRING_DOTS ")";
-HINSTANCE g_hInst;
HANDLE hPGPPRIV = nullptr;
HANDLE hRSA4096 = nullptr;
@@ -24,12 +24,6 @@ PLUGININFOEX pluginInfoEx = { {0x3613F2D9, 0xC040, 0x4361, {0xA4, 0x4F, 0xDF, 0x7B, 0x5A, 0xAA, 0xCF, 0x6E}}
};
-BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID)
-{
- g_hInst = hInst;
- return TRUE;
-}
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfoEx;
@@ -46,7 +40,7 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam) extern "C" __declspec(dllexport) int Load()
{
- DisableThreadLibraryCalls(g_hInst);
+ DisableThreadLibraryCalls(g_plugin.getInst());
// get memoryManagerInterface address
mir_getLP(&pluginInfoEx);
@@ -66,15 +60,15 @@ extern "C" __declspec(dllexport) int Unload() BOOL ExtractFileFromResource(HANDLE FH, int ResType, int ResId, DWORD* Size)
{
- HRSRC RH = FindResource(g_hInst, MAKEINTRESOURCE(ResId), MAKEINTRESOURCE(ResType));
+ HRSRC RH = FindResource(g_plugin.getInst(), MAKEINTRESOURCE(ResId), MAKEINTRESOURCE(ResType));
if (RH == nullptr)
return FALSE;
- PBYTE RP = (PBYTE)LoadResource(g_hInst, RH);
+ PBYTE RP = (PBYTE)LoadResource(g_plugin.getInst(), RH);
if (RP == nullptr)
return FALSE;
- DWORD x, s = SizeofResource(g_hInst, RH);
+ DWORD x, s = SizeofResource(g_plugin.getInst(), RH);
if (!WriteFile(FH, RP, s, &x, nullptr)) return FALSE;
if (x != s) return FALSE;
if (Size) *Size = s;
diff --git a/plugins/CyrTranslit/src/main.cpp b/plugins/CyrTranslit/src/main.cpp index e78a6732d1..13cb87d0a3 100644 --- a/plugins/CyrTranslit/src/main.cpp +++ b/plugins/CyrTranslit/src/main.cpp @@ -19,7 +19,7 @@ #include "stdafx.h"
-HINSTANCE hInst;
+CMPlugin g_plugin;
int hLangpack = 0;
PLUGININFOEX pluginInfoEx={
@@ -36,14 +36,6 @@ PLUGININFOEX pluginInfoEx={ //------------------------------------------------------------------------------
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
-//------------------------------------------------------------------------------
-
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
diff --git a/plugins/CyrTranslit/src/stdafx.h b/plugins/CyrTranslit/src/stdafx.h index 9b8a6c9a2a..027a5f0907 100644 --- a/plugins/CyrTranslit/src/stdafx.h +++ b/plugins/CyrTranslit/src/stdafx.h @@ -22,8 +22,6 @@ #include <windows.h>
#include <map>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_database.h>
#include <m_protosvc.h>
@@ -34,3 +32,10 @@ #include "MirandaContact.h"
#include "TransliterationMap.h"
#include "TransliterationProtocol.h"
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>("CyrTranslit")
+ {}
+};
diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp index 052b6fd8d5..e0adfe2812 100644 --- a/plugins/DbEditorPP/src/copymodule.cpp +++ b/plugins/DbEditorPP/src/copymodule.cpp @@ -85,7 +85,7 @@ void copyModuleMenuItem(MCONTACT hContact, const char *module) mac->hContact = hContact;
mir_strncpy(mac->module, module, sizeof(mac->module));
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, copyModDlgProc, (LPARAM)mac);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, copyModDlgProc, (LPARAM)mac);
}
diff --git a/plugins/DbEditorPP/src/deletemodule.cpp b/plugins/DbEditorPP/src/deletemodule.cpp index 2c08c762e4..dd2758f3e5 100644 --- a/plugins/DbEditorPP/src/deletemodule.cpp +++ b/plugins/DbEditorPP/src/deletemodule.cpp @@ -121,7 +121,7 @@ INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) void deleteModuleDlg()
{
if (!hwnd2Delete)
- hwnd2Delete = CreateDialog(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, DeleteModuleDlgProc);
+ hwnd2Delete = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, DeleteModuleDlgProc);
else
SetForegroundWindow(hwnd2Delete);
}
diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index 425abae95a..8241c13ed5 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -440,7 +440,7 @@ INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT));
if (length) {
- wchar_t *data = (wchar_t*)mir_alloc((length + 1)*sizeof(wchar_t));
+ wchar_t *data = (wchar_t*)mir_alloc((length + 1) * sizeof(wchar_t));
GetDlgItemText(hwnd, IDC_TEXT, data, length + 1);
importSettings(hContact, T2Utf(data));
mir_free(data);
@@ -454,7 +454,7 @@ INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara void ImportSettingsMenuItem(MCONTACT hContact)
{
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_IMPORT), hwnd2mainWindow, ImportDlgProc, hContact);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_IMPORT), hwnd2mainWindow, ImportDlgProc, hContact);
}
int Openfile2Import(wchar_t *outputFiles, int maxlen)
diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp index ca09d1750c..508a9fe727 100644 --- a/plugins/DbEditorPP/src/findwindow.cpp +++ b/plugins/DbEditorPP/src/findwindow.cpp @@ -3,16 +3,16 @@ #ifdef _UNICODE
- #define FindMatchT(a,b,c) FindMatchW(a,b,c)
+#define FindMatchT(a,b,c) FindMatchW(a,b,c)
#else
- #define FindMatchT(a,b,c) FindMatchA(a,b,c)
+#define FindMatchT(a,b,c) FindMatchA(a,b,c)
#endif
#ifdef _UNICODE
- #define multiReplaceT(a,b,c,d) multiReplaceW(a,b,c,d)
+#define multiReplaceT(a,b,c,d) multiReplaceW(a,b,c,d)
#else
- #define multiReplaceT(a,b,c,d) multiReplaceA(a,b,c,d)
+#define multiReplaceT(a,b,c,d) multiReplaceA(a,b,c,d)
#endif
@@ -78,7 +78,7 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP CheckDlgButton(hwnd, IDC_SETTINGNAME, BST_CHECKED);
CheckDlgButton(hwnd, IDC_SETTINGVALUE, BST_CHECKED);
CheckDlgButton(hwnd, IDC_FOUND, BST_CHECKED);
- SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)));
+ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT)));
SetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA, 0);
SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0);
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW); // taskbar icon
@@ -96,11 +96,11 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0);
else {
wchar_t text[FLD_SIZE];
- wchar_t replace[FLD_SIZE] = {0};
+ wchar_t replace[FLD_SIZE] = { 0 };
if (!GetDlgItemText(hwnd, IDC_TEXT, text, _countof(text)) && !IsDlgButtonChecked(hwnd, IDC_EXACT)) break;
- // empty replace is done only for exact match or entire replace
+ // empty replace is done only for exact match or entire replace
if (LOWORD(wParam) == IDOK &&
!GetDlgItemText(hwnd, IDC_REPLACE, replace, _countof(replace)) &&
(!IsDlgButtonChecked(hwnd, IDC_ENTIRELY) && !IsDlgButtonChecked(hwnd, IDC_EXACT)))
@@ -154,61 +154,61 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP }
break;
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO*)lParam;
- mmi->ptMinTrackSize.x = 610;
- mmi->ptMinTrackSize.y = 300;
- }
- return 0;
+ {
+ MINMAXINFO *mmi = (MINMAXINFO*)lParam;
+ mmi->ptMinTrackSize.x = 610;
+ mmi->ptMinTrackSize.y = 300;
+ }
+ return 0;
case WM_SIZE:
- Utils_ResizeDialog(hwnd, hInst, MAKEINTRESOURCEA(IDD_FIND), FindDialogResize);
+ Utils_ResizeDialog(hwnd, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_FIND), FindDialogResize);
break;
case WM_NOTIFY:
if (LOWORD(wParam) != IDC_LIST) break;
- switch (((NMHDR*)lParam)->code) {
- case NM_DBLCLK:
- {
- LVHITTESTINFO hti;
- LVITEM lvi;
- HWND hwndResults = GetDlgItem(hwnd, IDC_LIST);
- hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
- if (ListView_SubItemHitTest(hwndResults, &hti) > -1) {
- if (hti.flags&LVHT_ONITEM)
+ switch (((NMHDR*)lParam)->code) {
+ case NM_DBLCLK:
+ {
+ LVHITTESTINFO hti;
+ LVITEM lvi;
+ HWND hwndResults = GetDlgItem(hwnd, IDC_LIST);
+ hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
+ if (ListView_SubItemHitTest(hwndResults, &hti) > -1) {
+ if (hti.flags&LVHT_ONITEM)
+ {
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hti.iItem;
+ lvi.iSubItem = 0;
+ if (ListView_GetItem(hwndResults, &lvi))
{
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hti.iItem;
- lvi.iSubItem = 0;
- if (ListView_GetItem(hwndResults, &lvi))
- {
- ItemInfo ii = {0};
- ii.hContact = (MCONTACT)lvi.lParam;
- ListView_GetItemTextA(hwndResults, hti.iItem, 2, ii.module, _countof(ii.module));
- ListView_GetItemTextA(hwndResults, hti.iItem, 3, ii.setting, _countof(ii.setting));
- if (ii.setting[0])
- ii.type = FW_SETTINGNAME;
- else if (ii.module[0])
- ii.type = FW_MODULE;
-
- SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0);
- }
+ ItemInfo ii = { 0 };
+ ii.hContact = (MCONTACT)lvi.lParam;
+ ListView_GetItemTextA(hwndResults, hti.iItem, 2, ii.module, _countof(ii.module));
+ ListView_GetItemTextA(hwndResults, hti.iItem, 3, ii.setting, _countof(ii.setting));
+ if (ii.setting[0])
+ ii.type = FW_SETTINGNAME;
+ else if (ii.module[0])
+ ii.type = FW_MODULE;
+
+ SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0);
}
}
- break;
}
+ break;
+ }
case LVN_COLUMNCLICK:
- {
- LPNMLISTVIEW lv = (LPNMLISTVIEW)lParam;
- ColumnsSortParams params;
- params.hList = GetDlgItem(hwnd, IDC_LIST);
- params.column = lv->iSubItem;
- params.last = lastColumn;
- ListView_SortItemsEx(params.hList, ColumnsCompare, (LPARAM)¶ms);
- lastColumn = (params.column == lastColumn) ? -1 : params.column;
- break;
- }
+ {
+ LPNMLISTVIEW lv = (LPNMLISTVIEW)lParam;
+ ColumnsSortParams params;
+ params.hList = GetDlgItem(hwnd, IDC_LIST);
+ params.column = lv->iSubItem;
+ params.last = lastColumn;
+ ListView_SortItemsEx(params.hList, ColumnsCompare, (LPARAM)¶ms);
+ lastColumn = (params.column == lastColumn) ? -1 : params.column;
+ break;
+ }
} // switch
break;
case WM_DESTROY:
@@ -222,7 +222,7 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP void newFindWindow() {
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd2mainWindow, FindWindowDlgProc);
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIND), hwnd2mainWindow, FindWindowDlgProc);
}
void ItemFound(HWND hwnd, MCONTACT hContact, const char *module, const char *setting, wchar_t* value, int type)
@@ -236,10 +236,10 @@ void ItemFound(HWND hwnd, MCONTACT hContact, const char *module, const char *set mode = TranslateT("Deleted");
else
mode = TranslateT("Found");
-
+
GetContactName(hContact, nullptr, name, _countof(name));
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM;
lvi.lParam = (LPARAM)hContact;
@@ -266,20 +266,20 @@ char* multiReplaceA(const char *value, const char *search, const char *replace, int vlen = (int)mir_strlen(value);
int ci = slen ? cs : 1; // on empty string strstr() returns full string while StrStrI() returns NULL
// let's try to calculate maximum length for result string
- int newlen = (!slen) ? rlen + 1 : ( ( rlen <= slen ) ? vlen + 1 : vlen * rlen / slen + 1 );
-
+ int newlen = (!slen) ? rlen + 1 : ((rlen <= slen) ? vlen + 1 : vlen * rlen / slen + 1);
+
char *head;
char *in = (char*)value;
char *out = (char*)mir_alloc(newlen * sizeof(char));
out[0] = 0;
-
+
while (head = ci ? strstr(in, search) : StrStrIA(in, search)) {
if (head != in)
mir_strncat(out, in, head - in + 1);
in = head + slen;
mir_strcat(out, replace);
}
-
+
mir_strcat(out, in);
return out;
}
@@ -291,8 +291,8 @@ WCHAR* multiReplaceW(const WCHAR *value, const WCHAR *search, const WCHAR *repla int vlen = (int)mir_wstrlen(value);
int ci = slen ? cs : 1; // on empty string strstr() returns full string while StrStrI() returns NULL
// let's try to calculate maximum length for result string
- int newlen = (!slen) ? rlen + 1 : ( ( rlen <= slen ) ? vlen + 1 : vlen * rlen / slen + 1 );
-
+ int newlen = (!slen) ? rlen + 1 : ((rlen <= slen) ? vlen + 1 : vlen * rlen / slen + 1);
+
WCHAR *head;
WCHAR *in = (WCHAR*)value;
WCHAR *out = (WCHAR*)mir_alloc(newlen * sizeof(WCHAR));
@@ -304,7 +304,7 @@ WCHAR* multiReplaceW(const WCHAR *value, const WCHAR *search, const WCHAR *repla in = head + slen;
mir_wstrcat(out, replace);
}
-
+
mir_wstrcat(out, in);
return out;
}
@@ -317,7 +317,7 @@ int FindMatchA(const char *text, char *search, int options) if (options & F_EXACT)
return (options & F_CASE) ? !strcmp(text, search) : !stricmp(text, search);
-
+
// on empty string strstr() returns full string while StrStrI() returns NULL
return (options & F_CASE) ? (INT_PTR)strstr(text, search) : (INT_PTR)StrStrIA(text, search);
}
@@ -355,7 +355,7 @@ void __cdecl FindSettings(LPVOID param) MCONTACT hContact;
DBVARIANT dbv = { 0 };
- int foundCount = 0, replaceCount = 0, deleteCount = 0;
+ int foundCount = 0, replaceCount = 0, deleteCount = 0;
DWORD numsearch = 0, numreplace = 0;
int NULLContactDone = 0;
@@ -368,13 +368,13 @@ void __cdecl FindSettings(LPVOID param) _T2A search(fi->search);
_T2A replace(fi->replace);
- // skip modules and setting names on unicode search or replace
- if (IsRealUnicode(fi->search) || IsRealUnicode(fi->replace)) {
- fi->options &= ~(F_SETNAME | F_MODNAME);
- fi->options |= F_UNICODE;
- }
+ // skip modules and setting names on unicode search or replace
+ if (IsRealUnicode(fi->search) || IsRealUnicode(fi->replace)) {
+ fi->options &= ~(F_SETNAME | F_MODNAME);
+ fi->options |= F_UNICODE;
+ }
- if (!(fi->options & F_UNICODE) && (fi->options & F_SETVAL)) {
+ if (!(fi->options & F_UNICODE) && (fi->options & F_SETVAL)) {
char val[16];
numsearch = strtoul(search, nullptr, 10);
_ultoa(numsearch, val, 10);
@@ -397,7 +397,7 @@ void __cdecl FindSettings(LPVOID param) while (GetWindowLongPtr(GetDlgItem(hwndParent, IDC_SEARCH), GWLP_USERDATA)) {
if (!hContact) {
- if (NULLContactDone)
+ if (NULLContactDone)
break;
else {
NULLContactDone = 1;
@@ -430,27 +430,27 @@ void __cdecl FindSettings(LPVOID param) wchar_t *value = nullptr;
- switch(dbv.type) {
+ switch (dbv.type) {
- case DBVT_BYTE:
- case DBVT_WORD:
+ case DBVT_BYTE:
+ case DBVT_WORD:
case DBVT_DWORD:
if ((fi->options & F_NUMSRCH) && numsearch == getNumericValue(&dbv)) {
wchar_t *val = fi->search;
int flag = F_SETVAL;
if (fi->options & F_NUMREPL) {
- if (replace[0]) {
+ if (replace[0]) {
db_unset(hContact, module->name, setting->name);
flag |= F_DELETED;
deleteCount++;
- }
- else
- if (setNumericValue(hContact, module->name, setting->name, numreplace, dbv.type)) {
- val = fi->replace;
- flag |= F_REPLACED;
- replaceCount++;
}
+ else
+ if (setNumericValue(hContact, module->name, setting->name, numreplace, dbv.type)) {
+ val = fi->replace;
+ flag |= F_REPLACED;
+ replaceCount++;
+ }
}
ItemFound(fi->hwnd, hContact, module->name, setting->name, val, flag);
@@ -478,14 +478,15 @@ void __cdecl FindSettings(LPVOID param) flag |= F_DELETED;
newValue = value;
deleteCount++;
- } else {
+ }
+ else {
#ifdef _UNICODE
- // save as unicode if needed
+ // save as unicode if needed
if (dbv.type != DBVT_ASCIIZ || IsRealUnicode(newValue))
db_set_ws(hContact, module->name, setting->name, newValue);
- else
+ else
#endif
- db_set_s(hContact, module->name, setting->name, _T2A(newValue));
+ db_set_s(hContact, module->name, setting->name, _T2A(newValue));
flag |= F_REPLACED;
replaceCount++;
}
@@ -513,15 +514,16 @@ void __cdecl FindSettings(LPVOID param) flag |= F_DELETED;
newSetting = setting->name;
deleteCount++;
- } else {
+ }
+ else {
DBVARIANT dbv2;
// skip if exist
- if (!db_get_s(hContact, module->name, newSetting, &dbv2, 0))
+ if (!db_get_s(hContact, module->name, newSetting, &dbv2, 0))
db_free(&dbv2);
else if (!db_set(hContact, module->name, newSetting, &dbv)) {
db_unset(hContact, module->name, setting->name);
flag |= F_REPLACED;
- replaceCount++;
+ replaceCount++;
}
}
}
@@ -545,16 +547,16 @@ void __cdecl FindSettings(LPVOID param) if (replace) {
newModule = (fi->options & F_ENTIRE) ? replace : ptr = multiReplaceA(module->name, search, replace, fi->options & F_CASE);
-
+
if (!newModule[0]) {
deleteModule(hContact, module->name, 0);
replaceTreeItem(hContact, module->name, nullptr);
flag |= F_DELETED;
newModule = module->name;
deleteCount++;
- }
+ }
else if (renameModule(hContact, module->name, newModule)) {
- replaceTreeItem(hContact, module->name, nullptr);
+ replaceTreeItem(hContact, module->name, nullptr);
flag |= F_REPLACED;
replaceCount++;
}
@@ -566,7 +568,7 @@ void __cdecl FindSettings(LPVOID param) } // for(module)
}
- wchar_t msg[MSG_SIZE];
+ wchar_t msg[MSG_SIZE];
mir_snwprintf(msg, TranslateT("Finished. Items found: %d / replaced: %d / deleted: %d"), foundCount, replaceCount, deleteCount);
SendDlgItemMessage(hwndParent, IDC_SBAR, SB_SETTEXT, 0, (LPARAM)msg);
diff --git a/plugins/DbEditorPP/src/icons.cpp b/plugins/DbEditorPP/src/icons.cpp index a80958d752..7d5a0ec0bf 100644 --- a/plugins/DbEditorPP/src/icons.cpp +++ b/plugins/DbEditorPP/src/icons.cpp @@ -50,7 +50,7 @@ HANDLE GetIcoLibHandle(int icon) void IcoLibRegister(void)
{
- Icon_Register(hInst, modFullname, iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), modFullname, iconList, _countof(iconList));
}
HICON LoadSkinnedDBEIcon(int icon)
@@ -59,7 +59,7 @@ HICON LoadSkinnedDBEIcon(int icon) if (it.defIconID == icon)
return IcoLib_GetIconByHandle(it.hIcolib);
- return LoadIcon(hInst, MAKEINTRESOURCE(icon));
+ return LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(icon));
}
HIMAGELIST LoadIcons()
diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index e54b484de5..70a77edb7b 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -1,13 +1,12 @@ #include "stdafx.h"
-HINSTANCE hInst = nullptr;
-
MIDatabase *g_db;
HANDLE hTTBButt = nullptr;
bool g_bServiceMode = false;
bool g_bUsePopups;
+CMPlugin g_plugin;
int hLangpack;
BYTE nameOrder[NAMEORDERCOUNT];
HGENMENU hUserMenu;
@@ -43,16 +42,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) // we implement service mode interface
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_LAST };
-//========================
-// WINAPI DllMain
-//========================
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
-{
- hInst = hinstDLL;
- return TRUE;
-}
-
-
int DBSettingChanged(WPARAM hContact, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
@@ -169,7 +158,7 @@ INT_PTR ServiceMode(WPARAM, LPARAM) IcoLibRegister();
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChanged);
-
+
return SERVICE_ONLYDB; // load database and then call us
}
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 318a1fc8e1..cb5c21a393 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -60,12 +60,12 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return HTCLIENT;
case WM_SETCURSOR:
- {
- RECT rc;
- GetClientRect(hwnd, &rc);
- SetCursor(rc.right > rc.bottom ? LoadCursor(nullptr, IDC_SIZENS) : LoadCursor(nullptr, IDC_SIZEWE));
- }
- return TRUE;
+ {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ SetCursor(rc.right > rc.bottom ? LoadCursor(nullptr, IDC_SIZENS) : LoadCursor(nullptr, IDC_SIZEWE));
+ }
+ return TRUE;
case WM_LBUTTONDOWN:
SetCapture(hwnd);
@@ -91,18 +91,18 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR {
switch (msg) {
case WM_RBUTTONDOWN:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(hwnd, &hti.pt);
-
- if (TreeView_HitTest(hwnd, &hti)) {
- if (hti.flags&TVHT_ONITEM)
- TreeView_SelectItem(hwnd, hti.hItem);
- }
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(hwnd, &hti.pt);
+
+ if (TreeView_HitTest(hwnd, &hti)) {
+ if (hti.flags&TVHT_ONITEM)
+ TreeView_SelectItem(hwnd, hti.hItem);
}
- break;
+ }
+ break;
case WM_CHAR:
if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6)
@@ -209,7 +209,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) hImg = LoadIcons();
// do the icon
- SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)));
+ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT)));
SetWindowText(hwnd, TranslateT("Database Editor++"));
// setup the splitter
@@ -265,42 +265,42 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return TRUE;
case GC_SPLITTERMOVED:
- {
- int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
-
- RECT rc2;
- GetWindowRect(hwnd, &rc2);
-
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) {
- RECT rc;
- GetClientRect(hwnd, &rc);
- POINT pt = { (LONG)wParam, 0 };
- ScreenToClient(hwnd, &pt);
-
- splitterPos = rc.left + pt.x + 1;
- if (splitterPos < 150)
- splitterPos = 150;
- if (splitterPos > rc2.right - rc2.left - 150)
- splitterPos = rc2.right - rc2.left - 150;
- SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
- db_set_w(NULL, modname, "Splitter", (WORD)splitterPos);
- }
- PostMessage(hwnd, WM_SIZE, 0, 0);
+ {
+ int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
+
+ RECT rc2;
+ GetWindowRect(hwnd, &rc2);
+
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ POINT pt = { (LONG)wParam, 0 };
+ ScreenToClient(hwnd, &pt);
+
+ splitterPos = rc.left + pt.x + 1;
+ if (splitterPos < 150)
+ splitterPos = 150;
+ if (splitterPos > rc2.right - rc2.left - 150)
+ splitterPos = rc2.right - rc2.left - 150;
+ SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
+ db_set_w(NULL, modname, "Splitter", (WORD)splitterPos);
}
- break;
+ PostMessage(hwnd, WM_SIZE, 0, 0);
+ }
+ break;
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO *)lParam;
- int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
- mmi->ptMinTrackSize.x = splitterPos + 150;
- mmi->ptMinTrackSize.y = 300;
- }
- return 0;
+ {
+ MINMAXINFO *mmi = (MINMAXINFO *)lParam;
+ int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
+ mmi->ptMinTrackSize.x = splitterPos + 150;
+ mmi->ptMinTrackSize.y = 300;
+ }
+ return 0;
case WM_MOVE:
case WM_SIZE:
- Utils_ResizeDialog(hwnd, hInst, MAKEINTRESOURCEA(IDD_MAIN), DialogResize, GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA));
+ Utils_ResizeDialog(hwnd, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_MAIN), DialogResize, GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA));
break;
case WM_DESTROY: // free our shit!
@@ -359,7 +359,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ShowWindow(hwnd, SW_SHOWNOACTIVATE);
}
else db_set_b(NULL, modname, "Maximized", 0);
-
+
Utils_SaveWindowPosition(hwnd, NULL, modname, "Main_");
ShowWindow(hwnd, SW_HIDE);
}
@@ -408,7 +408,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
break;
- // watches
+ // watches
case MENU_VIEW_WATCHES:
openWatchedVarWindow();
break;
@@ -490,12 +490,12 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
break;
case MENU_SAVE_POSITION:
- {
- BOOL save = !db_get_b(NULL, modname, "RestoreOnOpen", 1);
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED));
- db_set_b(NULL, modname, "RestoreOnOpen", (byte)save);
- }
- break;
+ {
+ BOOL save = !db_get_b(NULL, modname, "RestoreOnOpen", 1);
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED));
+ db_set_b(NULL, modname, "RestoreOnOpen", (byte)save);
+ }
+ break;
case MENU_INLINE_EDIT:
g_Inline = !g_Inline;
CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
@@ -523,7 +523,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return TRUE; // case WM_NOTIFY
case WM_FINDITEM:
- ItemInfo *ii = (ItemInfo *)wParam;
+ ItemInfo * ii = (ItemInfo *)wParam;
HTREEITEM hItem = findItemInTree(ii->hContact, ii->module);
if (hItem) {
TreeView_SelectItem(hwnd2Tree, hItem);
@@ -539,5 +539,5 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) void openMainWindow()
{
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), nullptr, MainDlgProc);
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_MAIN), nullptr, MainDlgProc);
}
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index 5502e5c62e..b9dde4ac32 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -42,7 +42,7 @@ int doContacts(HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelec tvi.hInsertAfter = TVI_SORT;
tvi.item.cChildren = 1;
-
+
char szProto[FLD_SIZE];
wchar_t name[NAME_SIZE];
@@ -80,7 +80,7 @@ int doContacts(HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelec for (ModSetLinkLinkItem *module = modlist->first; module && hwnd2mainWindow; module = module->next) {
if (!module->name[0] || IsModuleEmpty(hContact, module->name))
continue;
- insertItem(hContact, module->name, contact);
+ insertItem(hContact, module->name, contact);
}
hItem = findItemInTree(hSelectedContact, selectedModule);
@@ -400,7 +400,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID param) for (ModSetLinkLinkItem *module = modlist.first; module && hwnd2mainWindow; module = module->next) {
if (!module->name[0] || IsModuleEmpty(hContact, module->name))
continue;
- insertItem(hContact, module->name, contact);
+ insertItem(hContact, module->name, contact);
}
if (db_get_b(NULL, modname, "ExpandSettingsOnOpen", 0))
@@ -494,34 +494,34 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)// hwnd h break;
case TVN_SELCHANGED:
- {
- LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
- TVITEM tvi = { 0 };
- wchar_t text[FLD_SIZE];
- MCONTACT hContact;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
- tvi.hItem = pnmtv->itemNew.hItem;
- tvi.pszText = text;
- tvi.cchTextMax = _countof(text);
- TreeView_GetItem(pnmtv->hdr.hwndFrom, &tvi);
-
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
+ {
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
+ TVITEM tvi = { 0 };
+ wchar_t text[FLD_SIZE];
+ MCONTACT hContact;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
+ tvi.hItem = pnmtv->itemNew.hItem;
+ tvi.pszText = text;
+ tvi.cchTextMax = _countof(text);
+ TreeView_GetItem(pnmtv->hdr.hwndFrom, &tvi);
- if (mtis) {
-
- hContact = mtis->hContact;
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
- if (mtis->type == STUB)
- break;
+ if (mtis) {
- if (populating)
- Select = 0;
+ hContact = mtis->hContact;
- if (mtis->type == MODULE) {
- _T2A module(text);
- PopulateSettings(hContact, module);
- }
- else
+ if (mtis->type == STUB)
+ break;
+
+ if (populating)
+ Select = 0;
+
+ if (mtis->type == MODULE) {
+ _T2A module(text);
+ PopulateSettings(hContact, module);
+ }
+ else
if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) {
int multi = 0;
@@ -550,11 +550,11 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)// hwnd h }
else
ClearListView();
- }
- else
- ClearListView();
}
- break; //TVN_SELCHANGED:
+ else
+ ClearListView();
+ }
+ break; //TVN_SELCHANGED:
case NM_RCLICK:
if (((NMHDR *)lParam)->code == NM_RCLICK)
@@ -562,18 +562,18 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)// hwnd h break;
case TVN_BEGINLABELEDIT: // subclass it..
- {
- LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
- ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam;
- HWND hwnd2Edit = TreeView_GetEditControl(hwnd2Tree);
- if (!mtis->type || (mtis->type == CONTACT)) {
- SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
- break;
- }
- mir_subclassWindow(hwnd2Edit, ModuleTreeLabelEditSubClassProc);
- SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
+ {
+ LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
+ ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam;
+ HWND hwnd2Edit = TreeView_GetEditControl(hwnd2Tree);
+ if (!mtis->type || (mtis->type == CONTACT)) {
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
+ break;
}
- break;
+ mir_subclassWindow(hwnd2Edit, ModuleTreeLabelEditSubClassProc);
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
+ }
+ break;
case TVN_ENDLABELEDIT:
LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
@@ -615,7 +615,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t hti.pt.y = (short)HIWORD(GetMessagePos());
ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (!TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || !(hti.flags & TVHT_ONITEM)) return;
+ if (!TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || !(hti.flags & TVHT_ONITEM)) return;
TVITEM tvi = { 0 };
HMENU hMenu, hSubMenu;
@@ -636,7 +636,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t MCONTACT hContact = mtis->hContact;
GetCursorPos(&hti.pt);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU));
+ hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXTMENU));
TranslateMenu(hMenu);
if (mtis->type == CONTACT && hContact)
@@ -660,7 +660,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t {
// check if the setting is being watched and if it is then check the menu item
int watchIdx = WatchedArrayIndex(hContact, module, nullptr, 1);
- if (watchIdx >= 0)
+ if (watchIdx >= 0)
CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND);
switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, nullptr)) {
@@ -689,7 +689,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t break;
case MENU_REFRESH:
- refreshTree(1);
+ refreshTree(1);
break;
case MENU_EXPORTMODULE:
@@ -739,7 +739,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t break;
case MENU_REFRESH:
- refreshTree(1);
+ refreshTree(1);
break;
}
@@ -760,7 +760,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t ImportSettingsFromFileMenuItem(NULL, nullptr);
break;
case MENU_REFRESH:
- refreshTree(1);
+ refreshTree(1);
break;
}
break;
@@ -777,7 +777,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t ImportSettingsFromFileMenuItem(NULL, nullptr);
break;
case MENU_REFRESH:
- refreshTree(1);
+ refreshTree(1);
break;
}
break;
diff --git a/plugins/DbEditorPP/src/options.cpp b/plugins/DbEditorPP/src/options.cpp index 12a60c0693..29e45ad00f 100644 --- a/plugins/DbEditorPP/src/options.cpp +++ b/plugins/DbEditorPP/src/options.cpp @@ -57,7 +57,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l INT OptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_plugin.getInst();
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.szGroup.a = LPGEN("Database");
odp.szTitle.a = modFullname;
diff --git a/plugins/DbEditorPP/src/renamemodule.cpp b/plugins/DbEditorPP/src/renamemodule.cpp index 89122b9b39..488f881460 100644 --- a/plugins/DbEditorPP/src/renamemodule.cpp +++ b/plugins/DbEditorPP/src/renamemodule.cpp @@ -63,5 +63,5 @@ static INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA void addModuleDlg(MCONTACT hContact)
{
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd2mainWindow, AddModDlgProc, hContact);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd2mainWindow, AddModDlgProc, hContact);
}
diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index aaa8591c8b..6043abc02c 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -1,7 +1,7 @@ #include "stdafx.h"
-SettingListInfo info = {0};
+SettingListInfo info = { 0 };
HWND hwnd2List = nullptr;
@@ -451,139 +451,139 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- DBVARIANT dbv = { 0 };
- int len = GetWindowTextLength(hwnd) + 1;
+ {
+ DBVARIANT dbv = { 0 };
+ int len = GetWindowTextLength(hwnd) + 1;
- if ((!info.subitem && len <= 1) || db_get_s(info.hContact, info.module, info.setting, &dbv, 0)) {
- SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
- }
+ if ((!info.subitem && len <= 1) || db_get_s(info.hContact, info.module, info.setting, &dbv, 0)) {
+ SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
+ return 0;
+ }
- wchar_t *value = (wchar_t*)mir_alloc(len*sizeof(wchar_t));
+ wchar_t *value = (wchar_t*)mir_alloc(len * sizeof(wchar_t));
- GetWindowText(hwnd, value, len);
+ GetWindowText(hwnd, value, len);
- _T2A szValue(value);
+ _T2A szValue(value);
- int res = 0;
+ int res = 0;
- switch (info.subitem) {
- case 0: // setting name
- if (!mir_strcmp(info.setting, szValue) || mir_strlen(szValue) > 0xFE) {
- db_free(&dbv);
- mir_free(value);
- SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
- }
- if (db_set(info.hContact, info.module, szValue, &dbv))
- break;
- res = 1;
- db_unset(info.hContact, info.module, info.setting);
- deleteListItem(info.setting);
+ switch (info.subitem) {
+ case 0: // setting name
+ if (!mir_strcmp(info.setting, szValue) || mir_strlen(szValue) > 0xFE) {
+ db_free(&dbv);
+ mir_free(value);
+ SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
+ return 0;
+ }
+ if (db_set(info.hContact, info.module, szValue, &dbv))
break;
+ res = 1;
+ db_unset(info.hContact, info.module, info.setting);
+ deleteListItem(info.setting);
+ break;
- case 1: // value
- DWORD val;
- int i = 0;
+ case 1: // value
+ DWORD val;
+ int i = 0;
- if (dbv.type == DBVT_BLOB) {
- res = WriteBlobFromString(info.hContact, info.module, info.setting, szValue, (int)mir_strlen(szValue));
- break;
- }
+ if (dbv.type == DBVT_BLOB) {
+ res = WriteBlobFromString(info.hContact, info.module, info.setting, szValue, (int)mir_strlen(szValue));
+ break;
+ }
- switch (value[0]) {
- case 'b':
- case 'B':
- val = wcstoul(&value[1], nullptr, 0);
- if (!val || value[1] == '0') {
- res = !db_set_b(info.hContact, info.module, info.setting, (BYTE)val);
- }
- else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
- case 'w':
- case 'W':
- val = wcstoul(&value[1], nullptr, 0);
- if (!val || value[1] == '0')
- res = !db_set_w(info.hContact, info.module, info.setting, (WORD)val);
- else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
- case 'd':
- case 'D':
- val = wcstoul(&value[1], nullptr, 0);
- if (!val || value[1] == '0')
- res = !db_set_dw(info.hContact, info.module, info.setting, val);
- else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
+ switch (value[0]) {
+ case 'b':
+ case 'B':
+ val = wcstoul(&value[1], nullptr, 0);
+ if (!val || value[1] == '0') {
+ res = !db_set_b(info.hContact, info.module, info.setting, (BYTE)val);
+ }
+ else
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
+ case 'w':
+ case 'W':
+ val = wcstoul(&value[1], nullptr, 0);
+ if (!val || value[1] == '0')
+ res = !db_set_w(info.hContact, info.module, info.setting, (WORD)val);
+ else
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
+ case 'd':
+ case 'D':
+ val = wcstoul(&value[1], nullptr, 0);
+ if (!val || value[1] == '0')
+ res = !db_set_dw(info.hContact, info.module, info.setting, val);
+ else
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
- case '0':
- i = 1;
- __fallthrough;
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- case 'x':
- case 'X':
- if (value[i] == 'x' || value[i] == 'X')
- val = wcstoul(&value[i + 1], nullptr, 16);
- else
- val = wcstoul(value, nullptr, 10);
-
- switch (dbv.type) {
- case DBVT_BYTE:
- case DBVT_WORD:
- case DBVT_DWORD:
- res = setNumericValue(info.hContact, info.module, info.setting, val, dbv.type);
- break;
- case DBVT_ASCIIZ:
- case DBVT_WCHAR:
- case DBVT_UTF8:
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
- }
- break;
- case '\"':
- case '\'':
- {
- size_t nlen = mir_wstrlen(value);
- int sh = 0;
- if (nlen > 3) {
- if (value[nlen - 1] == value[0]) {
- value[nlen - 1] = 0;
- sh = 1;
- }
- }
- res = setTextValue(info.hContact, info.module, info.setting, &value[sh], dbv.type);
- }
+ case '0':
+ i = 1;
+ __fallthrough;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ case 'x':
+ case 'X':
+ if (value[i] == 'x' || value[i] == 'X')
+ val = wcstoul(&value[i + 1], nullptr, 16);
+ else
+ val = wcstoul(value, nullptr, 10);
+
+ switch (dbv.type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ res = setNumericValue(info.hContact, info.module, info.setting, val, dbv.type);
break;
-
- default:
+ case DBVT_ASCIIZ:
+ case DBVT_WCHAR:
+ case DBVT_UTF8:
res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
break;
}
break;
+ case '\"':
+ case '\'':
+ {
+ size_t nlen = mir_wstrlen(value);
+ int sh = 0;
+ if (nlen > 3) {
+ if (value[nlen - 1] == value[0]) {
+ value[nlen - 1] = 0;
+ sh = 1;
+ }
+ }
+ res = setTextValue(info.hContact, info.module, info.setting, &value[sh], dbv.type);
}
+ break;
- mir_free(value);
- db_free(&dbv);
-
- if (!res) {
- msg(TranslateT("Unable to store value in this data type!"));
+ default:
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
break;
}
+ break;
+ }
+
+ mir_free(value);
+ db_free(&dbv);
+
+ if (!res) {
+ msg(TranslateT("Unable to store value in this data type!"));
+ break;
}
- __fallthrough;
+ }
+ __fallthrough;
case IDCANCEL:
DestroyWindow(hwnd);
@@ -622,7 +622,7 @@ void EditLabel(int item, int subitem) info.subitem = subitem;
if (!subitem)
- info.hwnd2Edit = CreateWindow(L"EDIT", _A2T(setting), WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), hwnd2List, nullptr, hInst, nullptr);
+ info.hwnd2Edit = CreateWindow(L"EDIT", _A2T(setting), WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), hwnd2List, nullptr, g_plugin.getInst(), nullptr);
else {
wchar_t *str = nullptr, value[16] = { 0 };
@@ -656,11 +656,11 @@ void EditLabel(int item, int subitem) GetClientRect(hwnd2List, &rclist);
if (rc.top + height > rclist.bottom && rclist.bottom - rclist.top > height)
rc.top = rc.bottom - height;
- info.hwnd2Edit = CreateWindow(L"EDIT", str, WS_BORDER | WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL, rc.left, rc.top, rc.right - rc.left, height, hwnd2List, nullptr, hInst, nullptr);
+ info.hwnd2Edit = CreateWindow(L"EDIT", str, WS_BORDER | WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL, rc.left, rc.top, rc.right - rc.left, height, hwnd2List, nullptr, g_plugin.getInst(), nullptr);
mir_free(str);
}
else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD)
- info.hwnd2Edit = CreateWindow(L"EDIT", value, WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), hwnd2List, nullptr, hInst, nullptr);
+ info.hwnd2Edit = CreateWindow(L"EDIT", value, WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), hwnd2List, nullptr, g_plugin.getInst(), nullptr);
}
db_free(&dbv);
@@ -740,7 +740,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to if (ListView_SubItemHitTest(hwnd2List, &hti) == -1) {
// nowhere.. new item menu
GetCursorPos(&pt);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU));
+ hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXTMENU));
hSubMenu = GetSubMenu(hMenu, 6);
TranslateMenu(hSubMenu);
@@ -783,7 +783,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to // on item
GetCursorPos(&pt);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU));
+ hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXTMENU));
hSubMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hSubMenu);
diff --git a/plugins/DbEditorPP/src/settingsdlg.cpp b/plugins/DbEditorPP/src/settingsdlg.cpp index 10201f6965..8c0f0d78a9 100644 --- a/plugins/DbEditorPP/src/settingsdlg.cpp +++ b/plugins/DbEditorPP/src/settingsdlg.cpp @@ -100,18 +100,18 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l break;
case DBVT_UTF8:
- {
- ptrW tmp(mir_utf8decodeW(dbsetting->dbv.pszVal));
- SetDlgItemTextW(hwnd, IDC_STRING, tmp);
- break;
- }
+ {
+ ptrW tmp(mir_utf8decodeW(dbsetting->dbv.pszVal));
+ SetDlgItemTextW(hwnd, IDC_STRING, tmp);
+ break;
+ }
case DBVT_BLOB:
- {
- ptrA tmp(StringFromBlob(dbsetting->dbv.pbVal, dbsetting->dbv.cpbVal));
- SetDlgItemTextA(hwnd, IDC_BLOB, tmp);
- break;
- }
+ {
+ ptrA tmp(StringFromBlob(dbsetting->dbv.pbVal, dbsetting->dbv.cpbVal));
+ SetDlgItemTextA(hwnd, IDC_BLOB, tmp);
+ break;
+ }
}
}
@@ -176,79 +176,79 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l break;
case IDOK:
- {
- struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
-
- wchar_t settingname[FLD_SIZE];
- GetDlgItemText(hwnd, IDC_SETTINGNAME, settingname, _countof(settingname));
-
- if (settingname[0]) {
- int valueID = 0;
-
- switch (dbsetting->dbv.type) {
- case DBVT_BYTE:
- case DBVT_WORD:
- case DBVT_DWORD:
- case DBVT_DELETED:
- valueID = IDC_SETTINGVALUE;
- break;
-
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- case DBVT_WCHAR:
- valueID = IDC_STRING;
- break;
-
- case DBVT_BLOB:
- valueID = IDC_BLOB;
- break;
- default:
- break;
- }
+ {
+ struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!valueID)
- break;
-
- int len = GetWindowTextLength(GetDlgItem(hwnd, valueID)) + 1;
- wchar_t *value = (wchar_t*)mir_alloc(len * sizeof(wchar_t));
-
- GetDlgItemText(hwnd, valueID, value, len);
- _T2A setting(settingname);
-
- int type = saveAsType(hwnd, dbsetting->dbv.type);
- int res = 0;
-
- // write the setting
- switch (type) {
- case DBVT_BYTE:
- case DBVT_WORD:
- case DBVT_DWORD:
- res = setNumericValue(dbsetting->hContact, dbsetting->module, setting, wcstoul(value, nullptr, IsDlgButtonChecked(hwnd, CHK_HEX) ? 16 : 10), type);
- break;
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- case DBVT_WCHAR:
- res = setTextValue(dbsetting->hContact, dbsetting->module, setting, value, type);
- break;
- case DBVT_BLOB:
- res = WriteBlobFromString(dbsetting->hContact, dbsetting->module, setting, _T2A(value), len);
- break;
- }
+ wchar_t settingname[FLD_SIZE];
+ GetDlgItemText(hwnd, IDC_SETTINGNAME, settingname, _countof(settingname));
- mir_free(value);
+ if (settingname[0]) {
+ int valueID = 0;
- if (!res) {
- msg(TranslateT("Unable to store value in this data type!"));
- break;
- }
+ switch (dbsetting->dbv.type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ case DBVT_DELETED:
+ valueID = IDC_SETTINGVALUE;
+ break;
+
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ case DBVT_WCHAR:
+ valueID = IDC_STRING;
+ break;
+
+ case DBVT_BLOB:
+ valueID = IDC_BLOB;
+ break;
+ default:
+ break;
+ }
+
+ if (!valueID)
+ break;
+
+ int len = GetWindowTextLength(GetDlgItem(hwnd, valueID)) + 1;
+ wchar_t *value = (wchar_t*)mir_alloc(len * sizeof(wchar_t));
+
+ GetDlgItemText(hwnd, valueID, value, len);
+ _T2A setting(settingname);
+
+ int type = saveAsType(hwnd, dbsetting->dbv.type);
+ int res = 0;
+
+ // write the setting
+ switch (type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ res = setNumericValue(dbsetting->hContact, dbsetting->module, setting, wcstoul(value, nullptr, IsDlgButtonChecked(hwnd, CHK_HEX) ? 16 : 10), type);
+ break;
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ case DBVT_WCHAR:
+ res = setTextValue(dbsetting->hContact, dbsetting->module, setting, value, type);
+ break;
+ case DBVT_BLOB:
+ res = WriteBlobFromString(dbsetting->hContact, dbsetting->module, setting, _T2A(value), len);
+ break;
+ }
+
+ mir_free(value);
- // delete old setting
- if (dbsetting->setting && mir_strcmp(setting, dbsetting->setting))
- db_unset(dbsetting->hContact, dbsetting->module, dbsetting->setting);
+ if (!res) {
+ msg(TranslateT("Unable to store value in this data type!"));
+ break;
}
+ // delete old setting
+ if (dbsetting->setting && mir_strcmp(setting, dbsetting->setting))
+ db_unset(dbsetting->hContact, dbsetting->module, dbsetting->setting);
}
- __fallthrough;
+
+ }
+ __fallthrough;
case IDCANCEL:
struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
@@ -275,7 +275,7 @@ void editSetting(MCONTACT hContact, const char *module, const char *setting) dbsetting->module = mir_strdup(module);
dbsetting->setting = mir_strdup(setting);
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
}
}
@@ -298,7 +298,7 @@ void copySetting(MCONTACT hContact, const char *module, const char *setting) dbsetting->hContact = hContact;
dbsetting->module = mir_strdup(module);
dbsetting->setting = mir_strdup(tmp);
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
return;
}
}
@@ -313,5 +313,5 @@ void newSetting(MCONTACT hContact, const char *module, int type) dbsetting->hContact = hContact;
dbsetting->module = mir_strdup(module);
dbsetting->setting = nullptr;
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
}
diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h index f661911b8c..3e3c0c9e6b 100644 --- a/plugins/DbEditorPP/src/stdafx.h +++ b/plugins/DbEditorPP/src/stdafx.h @@ -16,8 +16,6 @@ #include <win2k.h>
#include <malloc.h>
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_utils.h>
#include <m_clist.h>
@@ -49,6 +47,13 @@ #define modname "DBEditorpp"
#define modFullname "Database Editor++"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(modname)
+ {}
+};
+
#define msg(a) MessageBox(hwnd2mainWindow,a,_A2T(modFullname),MB_OK)
#define dlg(a,b) MessageBox(hwnd2mainWindow,a,_A2T(modFullname),b)
@@ -64,7 +69,7 @@ this gets dumped as the lparam for each module tree item
************************/
-// types
+ // types
#define CONTACT_ROOT_ITEM 0
#define CONTACT 1
#define MODULE 2
@@ -149,7 +154,7 @@ struct ColumnsSortParams { enum ICONS {
- IMAGE_EMPTY,
+ IMAGE_EMPTY,
IMAGE_BINARY,
IMAGE_BYTE,
IMAGE_WORD,
@@ -169,8 +174,6 @@ enum ICONS { //=======================================================
// Variables
//=======================================================
-extern HINSTANCE hInst;
-
extern HWND hwnd2mainWindow;
extern int g_Mode;
@@ -196,9 +199,9 @@ extern bool g_bUsePopups; #define HEX_DWORD 4
#ifdef _UNICODE
- #define GetValue(a,b,c,d,e) GetValueW(a,b,c,d,e)
+#define GetValue(a,b,c,d,e) GetValueW(a,b,c,d,e)
#else
- #define GetValue(a,b,c,d,e) GetValueA(a,b,c,d,e)
+#define GetValue(a,b,c,d,e) GetValueA(a,b,c,d,e)
#endif
//main
@@ -250,7 +253,7 @@ void settingChanged(MCONTACT hContact, const char *module, const char *setting, void editSetting(MCONTACT hContact, const char *module, const char *setting);
void copySetting(MCONTACT hContact, const char *module, const char *setting);
void newSetting(MCONTACT hContact, const char *module, int type);
-
+
// exportimport
void exportDB(MCONTACT hContact, const char *module); // hContact == -1 export entire db. module == NULL export entire contact
void ImportSettingsMenuItem(MCONTACT hContact);
diff --git a/plugins/DbEditorPP/src/watchedvars.cpp b/plugins/DbEditorPP/src/watchedvars.cpp index f438f3dba6..5d894c2c5a 100644 --- a/plugins/DbEditorPP/src/watchedvars.cpp +++ b/plugins/DbEditorPP/src/watchedvars.cpp @@ -22,7 +22,7 @@ int WatchedArrayIndex(MCONTACT hContact, const char *module, const char *setting if (hContact == WatchListArray.item[i].hContact)
if (!mir_strcmp(module, WatchListArray.item[i].module))
// empty setting = module watching
- if ((!strict && !WatchListArray.item[i].setting) || !mir_strcmp(setting, WatchListArray.item[i].setting))
+ if ((!strict && !WatchListArray.item[i].setting) || !mir_strcmp(setting, WatchListArray.item[i].setting))
return i;
}
return -1;
@@ -36,7 +36,7 @@ int addSettingToWatchList(MCONTACT hContact, const char *module, const char *set WatchListArray.size += 32;
WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size);
}
- if (!WatchListArray.item)
+ if (!WatchListArray.item)
return 0;
db_get_s(hContact, module, setting, &(WatchListArray.item[WatchListArray.count].dbv), 0);
@@ -44,7 +44,7 @@ int addSettingToWatchList(MCONTACT hContact, const char *module, const char *set WatchListArray.item[WatchListArray.count].hContact = hContact;
WatchListArray.item[WatchListArray.count].module = mir_strdup(module);
- if (setting)
+ if (setting)
WatchListArray.item[WatchListArray.count].setting = mir_strdup(setting);
else
WatchListArray.item[WatchListArray.count].setting = nullptr;
@@ -56,14 +56,14 @@ int addSettingToWatchList(MCONTACT hContact, const char *module, const char *set void freeWatchListItem(int item)
{
- if (item < 0 || item >= WatchListArray.count) return;
-
- if (WatchListArray.item[item].module)
+ if (item < 0 || item >= WatchListArray.count) return;
+
+ if (WatchListArray.item[item].module)
mir_free(WatchListArray.item[item].module);
WatchListArray.item[item].module = nullptr;
- if (WatchListArray.item[item].setting)
+ if (WatchListArray.item[item].setting)
mir_free(WatchListArray.item[item].setting);
WatchListArray.item[item].setting = nullptr;
@@ -77,7 +77,7 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam) DBVARIANT *dbv = &(lParam->dbv);
if (!lParam->module) return;
-
+
LVITEM lvItem;
lvItem.lParam = (LPARAM)lParam->hContact;
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
@@ -90,20 +90,20 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam) if (IsModuleEmpty(lParam->hContact, lParam->module) || !EnumSettings(lParam->hContact, lParam->module, &settinglist))
return;
- struct DBsetting dummy = {0};
+ struct DBsetting dummy = { 0 };
dummy.hContact = lParam->hContact;
dummy.module = lParam->module;
-
+
for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next)
{
dummy.setting = setting->name;
addwatchtolist(hwnd, &dummy);
-
+
}
FreeModuleSettingLL(&settinglist);
return;
}
-
+
db_free(&(lParam->dbv));
if (db_get_s(lParam->hContact, lParam->module, lParam->setting, &(lParam->dbv), 0))
@@ -172,8 +172,8 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam) void PopulateWatchedWindow()
{
- if (!hwnd2watchedVarsWindow) return;
- HWND hwnd = GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS);
+ if (!hwnd2watchedVarsWindow) return;
+ HWND hwnd = GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS);
ListView_DeleteAllItems(hwnd);
for (int i = 0; i < WatchListArray.count; i++) {
addwatchtolist(hwnd, &(WatchListArray.item[i]));
@@ -237,7 +237,7 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG:
hwnd2watchedVarsWindow = hwnd;
// do the icon
- SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)));
+ SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT)));
TranslateMenu(GetMenu(hwnd));
TranslateMenu(GetSubMenu(GetMenu(hwnd), 0));
TranslateDialogDefault(hwnd);
@@ -254,17 +254,17 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) PopulateWatchedWindow();
return TRUE;
- // for the resize
+ // for the resize
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO*)lParam;
- mmi->ptMinTrackSize.x = 500;
- mmi->ptMinTrackSize.y = 300;
- }
- return 0;
+ {
+ MINMAXINFO *mmi = (MINMAXINFO*)lParam;
+ mmi->ptMinTrackSize.x = 500;
+ mmi->ptMinTrackSize.y = 300;
+ }
+ return 0;
case WM_SIZE:
- Utils_ResizeDialog(hwnd, hInst, MAKEINTRESOURCEA(IDD_WATCH_DIAG), WatchDialogResize);
+ Utils_ResizeDialog(hwnd, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_WATCH_DIAG), WatchDialogResize);
break;
case WM_COMMAND:
@@ -339,8 +339,8 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) void openWatchedVarWindow()
{
- if (!hwnd2watchedVarsWindow)
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), nullptr, WatchDlgProc);
+ if (!hwnd2watchedVarsWindow)
+ CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WATCH_DIAG), nullptr, WatchDlgProc);
else
SetForegroundWindow(hwnd2watchedVarsWindow);
}
@@ -361,7 +361,7 @@ void popupWatchedVar(MCONTACT hContact, const char *module, const char *setting) POPUPDATAT ppd = { 0 };
ppd.lchContact = (MCONTACT)hContact;
- ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT));
+ ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT));
mir_wstrncpy(ppd.lptzContactName, name, _countof(ppd.lptzContactName));
mir_wstrncpy(ppd.lptzText, text, _countof(ppd.lptzText));
ppd.colorBack = colorBack;
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index cb43a50d68..75e9f26a28 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -217,7 +217,7 @@ int Backup(wchar_t *backup_filename) ShowPopup(dbname, TranslateT("Backup in progress"), nullptr);
if (!options.disable_progress)
- progress_dialog = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_COPYPROGRESS), nullptr, DlgProcProgress);
+ progress_dialog = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_COPYPROGRESS), nullptr, DlgProcProgress);
SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Copying database file..."));
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index 561e31dfeb..ceb612aac9 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -1,7 +1,7 @@ #include "stdafx.h"
+CMPlugin g_plugin;
int hLangpack;
-HINSTANCE g_hInstance;
HANDLE hFolder;
char g_szMirVer[100];
@@ -18,12 +18,6 @@ PLUGININFOEX pluginInfo = { { 0x81c220a6, 0x226, 0x4ad6, { 0xbf, 0xca, 0x21, 0x7b, 0x17, 0xa1, 0x60, 0x53 } }
};
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
-{
- g_hInstance = hInstance;
- return TRUE;
-}
-
static INT_PTR ABService(WPARAM, LPARAM)
{
BackupStart(nullptr);
@@ -122,7 +116,7 @@ extern "C" __declspec(dllexport) int Load(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoad);
- Icon_Register(g_hInstance, LPGEN("Database") "/" LPGEN("Database backups"), iconList, _countof(iconList));
+ Icon_Register(g_plugin.getInst(), LPGEN("Database") "/" LPGEN("Database backups"), iconList, _countof(iconList));
CreateServiceFunction(MS_AB_BACKUP, ABService);
CreateServiceFunction(MS_AB_SAVEAS, DBSaveAs);
diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp index 7a7e9d8fd0..1ef4066053 100644 --- a/plugins/Db_autobackups/src/options.cpp +++ b/plugins/Db_autobackups/src/options.cpp @@ -17,7 +17,7 @@ Options::Options() : Options options;
COptionsDlg::COptionsDlg()
- : CPluginDlgBase(g_hInstance, IDD_OPTIONS, MODULE),
+ : CPluginDlgBase(g_plugin.getInst(), IDD_OPTIONS, MODULE),
m_disable(this, IDC_RAD_DISABLED), m_backupOnStart(this, IDC_RAD_START),
m_backupOnExit(this, IDC_RAD_EXIT), m_backupPeriodic(this, IDC_RAD_PERIODIC),
m_backup(this, IDC_BUT_NOW), m_backupProfile(this, IDC_BACKUPPROFILE),
@@ -277,7 +277,7 @@ void COptionsDlg::CreateToolTip(LPTSTR ptszText, LPTSTR ptszTitle) (WS_POPUP | TTS_NOPREFIX),
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
- hwndFolder, nullptr, g_hInstance, nullptr);
+ hwndFolder, nullptr, g_plugin.getInst(), nullptr);
if (m_hPathTip == nullptr) {
return;
@@ -289,7 +289,7 @@ void COptionsDlg::CreateToolTip(LPTSTR ptszText, LPTSTR ptszTitle) ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP;
ti.hwnd = hwndFolder;
- ti.hinst = g_hInstance;
+ ti.hinst = g_plugin.getInst();
ti.lpszText = ptszText;
GetClientRect(hwndFolder, &ti.rect);
ti.rect.left = -80;
diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h index 6ad8c6628b..5152963200 100644 --- a/plugins/Db_autobackups/src/stdafx.h +++ b/plugins/Db_autobackups/src/stdafx.h @@ -12,8 +12,6 @@ namespace fs = std::experimental::filesystem;
-#define __NO_CMPLUGIN_NEEDED
-
#include <newpluginapi.h>
#include <m_clist.h>
#include <m_database.h>
@@ -29,6 +27,13 @@ namespace fs = std::experimental::filesystem; #define MODULE "AutoBackups"
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(MODULE)
+ {}
+};
+
#include "options.h"
#include "resource.h"
#include "version.h"
@@ -52,7 +57,6 @@ struct ZipFile int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std::function<bool(size_t)> &fnCallback);
-extern HINSTANCE g_hInstance;
extern char g_szMirVer[];
static IconItem iconList[] = {
|