diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-01 23:07:21 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-01 23:07:21 +0300 |
commit | 32814854d5eec107221424656dca122887e3de3f (patch) | |
tree | 6834c44d3f62920de508c676ab59f88f5b57dc40 /src/mir_app | |
parent | b65a92e65f9010a0166f7dcd954b0ce58f2b6cc4 (diff) |
tabSRMM: old perversion removed
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/pluginopts.cpp | 116 | ||||
-rw-r--r-- | src/mir_app/src/resource.h | 4 | ||||
-rw-r--r-- | src/mir_app/src/skinicons.cpp | 11 |
3 files changed, 34 insertions, 97 deletions
diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index b3eac035e1..973a5094e5 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -37,6 +37,7 @@ struct PluginListItemData wchar_t fileName[MAX_PATH];
HINSTANCE hInst;
int flags, stdPlugin;
+ bool bRequiresRestart, bWasLoaded;
wchar_t *author, *description, *copyright, *homepage;
MUUID uuid;
@@ -101,18 +102,18 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM }
else ppb = &GetPluginByInstance(hInst);
- PluginListItemData *dat = (PluginListItemData*)mir_alloc(sizeof(PluginListItemData));
+ PluginListItemData *dat = (PluginListItemData*)mir_calloc(sizeof(PluginListItemData));
dat->hInst = hInst;
dat->flags = ppb->getInfo().flags;
+ dat->bWasLoaded = hInst != nullptr;
- dat->stdPlugin = 0;
if (pIds != nullptr)
dat->importIds(pIds);
else {
typedef MUUID* (__cdecl * Miranda_Plugin_Interfaces)(void);
Miranda_Plugin_Interfaces pFunc = (Miranda_Plugin_Interfaces)GetProcAddress(ppb->getInst(), "MirandaPluginInterfaces");
if (pFunc) {
- MUUID* pPascalIds = pFunc();
+ MUUID *pPascalIds = pFunc();
if (pPascalIds != nullptr)
dat->importIds(pPascalIds);
}
@@ -122,14 +123,15 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM wcsncpy_s(dat->fileName, fd->cFileName, _TRUNCATE);
HWND hwndList = (HWND)lParam;
-
- LVITEM it = { 0 };
- // column 1: Checkbox + Enable/disabled icons
- it.mask = LVIF_PARAM | LVIF_IMAGE;
- it.iImage = (hInst != nullptr) ? 2 : 3;
bool bNoCheckbox = (dat->flags & STATIC_PLUGIN) != 0;
if (bNoCheckbox || hasMuuid(pIds, MIID_CLIST) || hasMuuid(pIds, MIID_SSL))
- it.iImage += 2;
+ dat->bRequiresRestart = true;
+
+ LVITEM it = { 0 };
+ // column 1: Checkbox + Unicode/ANSI icon + filename
+ it.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
+ it.iImage = (dat->flags & UNICODE_AWARE) ? 0 : 1;
+ it.pszText = fd->cFileName;
it.lParam = (LPARAM)dat;
int iRow = ListView_InsertItem(hwndList, &it);
@@ -137,14 +139,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM ListView_SetItemState(hwndList, iRow, bNoCheckbox ? 0x3000 : 0x2000, LVIS_STATEIMAGEMASK);
if (iRow != -1) {
- // column 2: Unicode/ANSI icon + filename
- it.mask = LVIF_IMAGE | LVIF_TEXT;
- it.iItem = iRow;
- it.iSubItem = 1;
- it.iImage = (dat->flags & UNICODE_AWARE) ? 0 : 1;
- it.pszText = fd->cFileName;
- ListView_SetItem(hwndList, &it);
-
+ // column 2: plugin short name
const PLUGININFOEX &ppi = ppb->getInfo();
dat->author = sttUtf8auto(ppi.author);
dat->copyright = sttUtf8auto(ppi.copyright);
@@ -156,13 +151,12 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM memset(&dat->uuid, 0, sizeof(dat->uuid));
wchar_t *shortNameT = mir_a2u(ppi.shortName);
- // column 3: plugin short name
if (shortNameT) {
- ListView_SetItemText(hwndList, iRow, 2, shortNameT);
+ ListView_SetItemText(hwndList, iRow, 1, shortNameT);
mir_free(shortNameT);
}
- // column4: version number
+ // column 3: version number
DWORD unused, verInfoSize = GetFileVersionInfoSize(buf, &unused);
if (verInfoSize != 0) {
UINT blockSize;
@@ -175,7 +169,7 @@ static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, wchar_t *path, WPARAM, LPARAM }
else mir_snwprintf(buf, L"%d.%d.%d.%d", HIBYTE(HIWORD(ppi.version)), LOBYTE(HIWORD(ppi.version)), HIBYTE(LOWORD(ppi.version)), LOBYTE(LOWORD(ppi.version)));
- ListView_SetItemText(hwndList, iRow, 3, buf);
+ ListView_SetItemText(hwndList, iRow, 2, buf);
arPluginList.insert(dat);
}
else mir_free(dat);
@@ -282,7 +276,6 @@ public: m_timer.OnEvent = Callback(this, &CPluginOptDlg::onTimer);
m_plugList.OnItemChanged = Callback(this, &CPluginOptDlg::list_ItemChanged);
- m_plugList.OnClick = Callback(this, &CPluginOptDlg::list_OnClick);
m_plugList.OnKeyDown = Callback(this, &CPluginOptDlg::list_OnKeyDown);
}
@@ -291,18 +284,10 @@ public: HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0);
ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE);
ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY);
- ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY);
m_plugList.SetImageList(hIml, LVSIL_SMALL);
LVCOLUMN col;
col.mask = LVCF_TEXT | LVCF_WIDTH;
- col.pszText = L"";
- col.cx = 40;
- m_plugList.InsertColumn(0, &col);
-
col.pszText = TranslateT("Plugin");
col.cx = 180;
m_plugList.InsertColumn(1, &col);
@@ -312,7 +297,7 @@ public: m_plugList.InsertColumn(2, &col);
col.pszText = TranslateT("Version");
- col.cx = 75;
+ col.cx = 115;
m_plugList.InsertColumn(3, &col);
m_plugList.SetExtendedListViewStyleEx(0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
@@ -336,9 +321,6 @@ public: m_plugList.SetColumnWidth(2, max);
m_plugList.SortItems(SortPlugins, (LPARAM)m_hwnd);
-
- m_hEvent1 = HookEventMessage(ME_SYSTEM_MODULELOAD, m_hwnd, WM_USER + 1);
- m_hEvent2 = HookEventMessage(ME_SYSTEM_MODULEUNLOAD, m_hwnd, WM_USER + 2);
return true;
}
@@ -349,7 +331,7 @@ public: for (int iRow = 0; iRow != -1;) {
wchar_t buf[1024];
- m_plugList.GetItemText(iRow, 1, buf, _countof(buf));
+ m_plugList.GetItemText(iRow, 0, buf, _countof(buf));
int iState = m_plugList.GetItemState(iRow, LVIS_STATEIMAGEMASK);
SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0);
@@ -363,22 +345,24 @@ public: lvi.mask = LVIF_IMAGE;
PluginListItemData *dat = (PluginListItemData*)lvi.lParam;
- if (iState == 0x2000) {
- // enabling plugin
- if (lvi.iImage == 3 || lvi.iImage == 5) {
- if (lvi.iImage == 3)
+ if (iState == 0x2000) { // enabling plugin
+ if (!dat->bWasLoaded) {
+ if (!dat->bRequiresRestart) {
LoadPluginDynamically(dat);
+ dat->bWasLoaded = true;
+ }
else {
bufRestart.AppendFormat(L" - %s\n", buf);
needRestart = true;
}
}
}
- else {
- // disabling plugin
- if (lvi.iImage == 2 || lvi.iImage == 4) {
- if (lvi.iImage == 2)
+ else { // disabling plugin
+ if (dat->bWasLoaded) {
+ if (!dat->bRequiresRestart) {
UnloadPluginDynamically(dat);
+ dat->bWasLoaded = false;
+ }
else {
bufRestart.AppendFormat(L" - %s\n", buf);
needRestart = true;
@@ -421,52 +405,6 @@ public: }
}
- INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override
- {
- if (uMsg == WM_USER + 1 || uMsg == WM_USER + 2) {
- LVITEM lvi;
- lvi.mask = LVIF_PARAM | LVIF_IMAGE;
- lvi.iSubItem = 0;
- for (lvi.iItem = 0; m_plugList.GetItem(&lvi); lvi.iItem++) {
- PluginListItemData *dat = (PluginListItemData*)lvi.lParam;
- if (dat->hInst == (HINSTANCE)lParam) {
- lvi.iImage = uMsg - WM_USER + 1;
- m_plugList.SetItem(&lvi);
- break;
- }
- }
- }
-
- return CDlgBase::DlgProc(uMsg, wParam, lParam);
- }
-
- void list_OnClick(CCtrlListView::TEventInfo *evt)
- {
- auto hdr = evt->nmlv;
-
- LVHITTESTINFO hi;
- hi.pt.x = hdr->ptAction.x;
- hi.pt.y = hdr->ptAction.y;
- m_plugList.SubItemHitTest(&hi);
- // Dynamically load/unload a plugin
- if (hi.iSubItem == 0 && (hi.flags & LVHT_ONITEMICON)) {
- LVITEM lvi = { 0 };
- lvi.mask = LVIF_IMAGE | LVIF_PARAM;
- lvi.stateMask = -1;
- lvi.iItem = hi.iItem;
- lvi.iSubItem = 0;
- if (m_plugList.GetItem(&lvi)) {
- PluginListItemData *dat = (PluginListItemData*)lvi.lParam;
- if (lvi.iImage == 3)
- LoadPluginDynamically(dat); // load plugin
- else if (lvi.iImage == 2)
- UnloadPluginDynamically(dat); // unload plugin
-
- LoadStdPlugins();
- }
- }
- }
-
void onTimer(CTimer*)
{
m_timer.Stop();
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h index 3b30327ac1..e1a6047fa0 100644 --- a/src/mir_app/src/resource.h +++ b/src/mir_app/src/resource.h @@ -18,8 +18,6 @@ #define IDD_OPT_PROTOCOLORDER 109
#define IDD_OPT_ICOLIB 110
#define IDD_ICOLIB_IMPORT 111
-#define IDI_LOADED_GRAY 113
-#define IDI_NOTLOADED_GRAY 114
#define IDD_ADDED 115
#define IDD_ENTER_STRING 116
#define IDI_ADDGROUP 117
@@ -102,10 +100,8 @@ #define IDI_UNICODE 218
#define IDI_ANSI 219
#define IDD_INFO_SUMMARY 220
-#define IDI_LOADED 220
#define IDD_INFO_CONTACT 221
#define IDR_CREDITS 221
-#define IDI_NOTLOADED 221
#define IDD_INFO_BACKGROUND 222
#define IDD_INFO_NOTES 223
#define IDD_ADDEMAIL 226
diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp index 4cb9361e23..24a4d6b5e5 100644 --- a/src/mir_app/src/skinicons.cpp +++ b/src/mir_app/src/skinicons.cpp @@ -67,8 +67,8 @@ static struct StandardIconDescription mainIcons[] = { SKINICON_OTHER_EMPTYBLOB, LPGEN("Empty blob"), -IDI_EMPTYBLOB, 0, nullptr }, // 26
{ SKINICON_OTHER_UNICODE, LPGEN("Unicode plugin"), -IDI_UNICODE, 0, nullptr }, // 27
{ SKINICON_OTHER_ANSI, LPGEN("ANSI plugin"), -IDI_ANSI, 0, nullptr }, // 28
- { SKINICON_OTHER_LOADED, LPGEN("Running plugin"), -IDI_LOADED, 0, nullptr }, // 29
- { SKINICON_OTHER_NOTLOADED, LPGEN("Unloaded plugin"), -IDI_NOTLOADED, 0, nullptr }, // 30
+ { -1, LPGEN("Unused"), 0, 0, nullptr }, // 29
+ { -1, LPGEN("Unused"), 0, 0, nullptr }, // 30
{ SKINICON_OTHER_UNDO, LPGEN("Undo"), -IDI_UNDO, 0, nullptr }, // 31
{ SKINICON_OTHER_WINDOW, LPGEN("Window"), -IDI_WINDOW, 0, nullptr }, // 32
{ SKINICON_OTHER_WINDOWS, LPGEN("System"), -IDI_WINDOWS, 0, nullptr }, // 33
@@ -82,8 +82,8 @@ static struct StandardIconDescription mainIcons[] = { SKINICON_OTHER_GROUP, LPGEN("Move to group"), -IDI_MOVETOGROUP, 0, nullptr }, // 41
{ SKINICON_OTHER_ON, LPGEN("On"), -IDI_ON, 0, nullptr }, // 42
{ SKINICON_OTHER_OFF, LPGEN("Off"), -IDI_OFF, 0, nullptr }, // 43
- { SKINICON_OTHER_LOADEDGRAY, LPGEN("Running core plugin"), -IDI_LOADED_GRAY, 0, nullptr }, // 44
- { SKINICON_OTHER_NOTLOADEDGRAY, LPGEN("Non-loadable plugin"), -IDI_NOTLOADED_GRAY, 0, nullptr }, // 45
+ { -1, LPGEN("Unused"), 0, 0, nullptr }, // 44
+ { -1, LPGEN("Unused"), 0, 0, nullptr }, // 45
{ SKINICON_OTHER_FRAME, LPGEN("Frames"), -IDI_FRAME, 0, nullptr }, // 46
{ SKINICON_OTHER_GROUPADD, LPGEN("Add group"), -IDI_ADDGROUP, 0, nullptr }, // 47
{ SKINICON_AUTH_ADD, LPGEN("Add to list"), -IDI_AUTH_ADD, 0, nullptr }, // 48
@@ -392,6 +392,9 @@ int LoadSkinIcons(void) // Add main icons to list
for (int i = 0; i < _countof(mainIcons); i++) {
+ if (mainIcons[i].id == -1)
+ continue;
+
mir_snprintf(iconName, "%s%d", mainIconsFmt, i);
sid.section.a = mainIcons[i].section == nullptr ? (char*)LPGEN("Main icons") : (char*)mainIcons[i].section;
sid.description.a = (char*)mainIcons[i].description;
|