summaryrefslogtreecommitdiff
path: root/plugins/CrashDumper
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-12-02 18:19:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-12-02 18:19:49 +0000
commitc4582dd65b444e5dae29ada7cc3f6c9a9c20edf3 (patch)
tree17a8627550b202d62df8e1df76d2585d3d0cdeaa /plugins/CrashDumper
parent5ea5feb7e052ca45af7bc9ed76e4a252bd71950d (diff)
new easy standard way of registering icons: Icon_Register
git-svn-id: http://svn.miranda-ng.org/main/trunk@2601 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CrashDumper')
-rw-r--r--plugins/CrashDumper/src/crshdmp.cpp75
-rw-r--r--plugins/CrashDumper/src/crshdmp_icons.cpp56
-rw-r--r--plugins/CrashDumper/src/ui.cpp19
-rw-r--r--plugins/CrashDumper/src/utils.h8
4 files changed, 50 insertions, 108 deletions
diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp
index 047f93a7ef..b94ad9f0ca 100644
--- a/plugins/CrashDumper/src/crshdmp.cpp
+++ b/plugins/CrashDumper/src/crshdmp.cpp
@@ -72,10 +72,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirVers
// MirandaInterfaces - returns the protocol interface to the core
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_CRASHDUMP, MIID_LAST };
-HANDLE hHooks[5];
-HANDLE hServices[6];
-
-
INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam)
{
CreateDirectoryTree(VersionInfoFolder);
@@ -218,24 +214,24 @@ static int ToolbarModulesLoaded(WPARAM, LPARAM)
tbb.pszService = MS_CRASHDUMPER_STORETOCLIP;
tbb.name = tbb.pszTooltipUp = LPGEN("Version Information To Clipboard");
- tbb.hIconHandleUp = GetIconHandle("storeToClip");
+ tbb.hIconHandleUp = GetIconHandle(IDI_VITOCLIP);
tbb.dwFlags = TTBBF_VISIBLE;
TopToolbar_AddButton(&tbb);
tbb.pszService = MS_CRASHDUMPER_STORETOFILE;
tbb.name = tbb.pszTooltipUp = LPGEN("Version Information To File");
- tbb.hIconHandleUp = GetIconHandle("storeToFile");
+ tbb.hIconHandleUp = GetIconHandle(IDI_VITOFILE);
tbb.dwFlags = 0;
TopToolbar_AddButton(&tbb);
tbb.pszService = MS_CRASHDUMPER_VIEWINFO;
tbb.name = tbb.pszTooltipUp = LPGEN("Show Version Information");
- tbb.hIconHandleUp = GetIconHandle("showInfo");
+ tbb.hIconHandleUp = GetIconHandle(IDI_VISHOW);
TopToolbar_AddButton(&tbb);
tbb.pszService = MS_CRASHDUMPER_UPLOAD;
tbb.name = tbb.pszTooltipUp = LPGEN("Upload Version Information");
- tbb.hIconHandleUp = GetIconHandle("uploadInfo");
+ tbb.hIconHandleUp = GetIconHandle(IDI_VIUPLOAD);
TopToolbar_AddButton(&tbb);
return 0;
}
@@ -262,10 +258,8 @@ static int ModulesLoaded(WPARAM, LPARAM)
FoldersPathChanged(0, 0);
-
-
- hHooks[2] = HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged);
- if (hHooks[3] == NULL) hHooks[3] = HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded);
+ HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged);
+ HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded);
UploadInit();
@@ -273,7 +267,7 @@ static int ModulesLoaded(WPARAM, LPARAM)
mi.popupPosition = 2000089999;
mi.position = 2000089999;
mi.flags = CMIF_ROOTPOPUP | CMIF_ICONFROMICOLIB | CMIF_TCHAR;
- mi.icolibItem = GetIconHandle("versionInfo");
+ mi.icolibItem = GetIconHandle(IDI_VI);
mi.ptszName = LPGENT("Version Information");
mi.pszPopupName = (char *)-1;
HANDLE hMenuRoot = Menu_AddMainMenuItem(&mi);
@@ -284,33 +278,33 @@ static int ModulesLoaded(WPARAM, LPARAM)
mi.position = 2000089995;
mi.ptszName = LPGENT("Copy to clipboard");
- mi.icolibItem = GetIconHandle("storeToClip");
+ mi.icolibItem = GetIconHandle(IDI_VITOCLIP);
mi.pszService = MS_CRASHDUMPER_STORETOCLIP;
Menu_AddMainMenuItem(&mi);
mi.position = 2000089996;
mi.ptszName = LPGENT("Store to file");
- mi.icolibItem = GetIconHandle("storeToFile");
+ mi.icolibItem = GetIconHandle(IDI_VITOFILE);
mi.pszService = MS_CRASHDUMPER_STORETOFILE;
Menu_AddMainMenuItem(&mi);
mi.position = 2000089997;
mi.ptszName = LPGENT("Show");
- mi.icolibItem = GetIconHandle("showInfo");
+ mi.icolibItem = GetIconHandle(IDI_VISHOW);
mi.pszService = MS_CRASHDUMPER_VIEWINFO;
Menu_AddMainMenuItem(&mi);
mi.popupPosition = 1;
mi.position = 2000089998;
mi.ptszName = LPGENT("Show with DLLs");
- mi.icolibItem = GetIconHandle("showInfo");
+ mi.icolibItem = GetIconHandle(IDI_VIUPLOAD);
mi.pszService = MS_CRASHDUMPER_VIEWINFO;
Menu_AddMainMenuItem(&mi);
mi.popupPosition = 0;
mi.position = 2000089999;
mi.ptszName = LPGENT("Upload");
- mi.icolibItem = GetIconHandle("uploadInfo");
+ mi.icolibItem = GetIconHandle(IDI_VIUPLOAD);
mi.pszService = MS_CRASHDUMPER_UPLOAD;
Menu_AddMainMenuItem(&mi);
@@ -341,12 +335,10 @@ static int ModulesLoaded(WPARAM, LPARAM)
hk.pszService = MS_CRASHDUMPER_VIEWINFO;
Hotkey_Register(&hk);
- if (servicemode) ViewVersionInfo(0, 0);
- else
- {
- if (DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false))
- UploadVersionInfo(0, 0xa1);
- }
+ if (servicemode)
+ ViewVersionInfo(0, 0);
+ else if (DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false))
+ UploadVersionInfo(0, 0xa1);
CheckForOtherCrashReportingPlugins();
return 0;
@@ -354,33 +346,22 @@ static int ModulesLoaded(WPARAM, LPARAM)
static int PreShutdown(WPARAM, LPARAM)
{
- unsigned i;
-
DestroyAllWindows();
UploadClose();
-
- for (i=0; i<SIZEOF(hHooks); ++i)
- UnhookEvent(hHooks[i]);
-
- for (i=0; i<SIZEOF(hServices); ++i)
- DestroyServiceFunction(hServices[i]);
-
return 0;
}
extern "C" int __declspec(dllexport) Load(void)
{
-
-
clsdates = DBGetContactSettingByte(NULL, PluginName, "ClassicDates", 1) != 0;
dtsubfldr = DBGetContactSettingByte(NULL, PluginName, "SubFolders", 1) != 0;
mir_getLP(&pluginInfoEx);
- hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- hHooks[1] = HookEvent(ME_OPT_INITIALISE, OptionsInit);
- hHooks[3] = HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded);
- hHooks[4] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ HookEvent(ME_OPT_INITIALISE, OptionsInit);
+ HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
packlcid = (LCID)CallService(MS_LANGPACK_GETLOCALE, 0, 0);
@@ -388,16 +369,12 @@ extern "C" int __declspec(dllexport) Load(void)
InitExceptionHandler();
- hServices[0] = CreateServiceFunction(MS_CRASHDUMPER_STORETOFILE, StoreVersionInfoToFile);
- hServices[1] = CreateServiceFunction(MS_CRASHDUMPER_STORETOCLIP, StoreVersionInfoToClipboard);
- hServices[2] = CreateServiceFunction(MS_CRASHDUMPER_VIEWINFO, ViewVersionInfo);
- hServices[3] = CreateServiceFunction(MS_CRASHDUMPER_UPLOAD, UploadVersionInfo);
- hServices[4] = CreateServiceFunction(MS_CRASHDUMPER_URL, OpenUrl);
- hServices[5] = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeLaunch);
-
- // unsigned *p = (unsigned*)0x15;
- // *p = 324;
-
+ CreateServiceFunction(MS_CRASHDUMPER_STORETOFILE, StoreVersionInfoToFile);
+ CreateServiceFunction(MS_CRASHDUMPER_STORETOCLIP, StoreVersionInfoToClipboard);
+ CreateServiceFunction(MS_CRASHDUMPER_VIEWINFO, ViewVersionInfo);
+ CreateServiceFunction(MS_CRASHDUMPER_UPLOAD, UploadVersionInfo);
+ CreateServiceFunction(MS_CRASHDUMPER_URL, OpenUrl);
+ CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeLaunch);
return 0;
}
diff --git a/plugins/CrashDumper/src/crshdmp_icons.cpp b/plugins/CrashDumper/src/crshdmp_icons.cpp
index 670adae90c..d469c5349d 100644
--- a/plugins/CrashDumper/src/crshdmp_icons.cpp
+++ b/plugins/CrashDumper/src/crshdmp_icons.cpp
@@ -17,15 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "utils.h"
-#include <m_icolib.h>
-struct _tag_iconList
-{
- const char* szDescr;
- const char* szName;
- int defIconID;
-}
-static const iconList[] =
+static IconItem iconList[] =
{
{ "Version Information", "versionInfo", IDI_VI },
{ "Copy To Clipboard", "storeToClip", IDI_VITOCLIP },
@@ -34,52 +27,25 @@ static const iconList[] =
{ "Upload", "uploadInfo", IDI_VIUPLOAD },
};
-static HANDLE hIconLibItem[SIZEOF(iconList)];
-
void InitIcons(void)
{
- char szSettingName[100];
- TCHAR szFile[MAX_PATH];
- GetModuleFileName(hInst, szFile, SIZEOF(szFile));
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.ptszDefaultFile = szFile;
- sid.pszName = szSettingName;
- sid.pszSection = (char*)PluginName;
-
- for (unsigned i = 0; i < SIZEOF(iconList); i++) {
- mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, iconList[i].szName);
-
- sid.pszDescription = (char*)iconList[i].szDescr;
- sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = Skin_AddIcon(&sid);
- }
+ Icon_Register(hInst, PluginName, iconList, SIZEOF(iconList), PluginName);
}
-HICON LoadIconEx(const char* name, bool big)
+HICON LoadIconEx(int iconId, bool big)
{
- char szSettingName[100];
- mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, name);
- return Skin_GetIcon(szSettingName, big);
-}
+ for (int i=0; i < SIZEOF(iconList); i++)
+ if (iconList[i].defIconID == iconId)
+ return Skin_GetIconByHandle(iconList[i].hIcolib);
-HANDLE GetIconHandle(const char* name)
-{
- unsigned i;
- for (i=0; i < SIZEOF(iconList); i++)
- if (strcmp(iconList[i].szName, name) == 0)
- return hIconLibItem[i];
return NULL;
}
-void ReleaseIconEx(const char* name)
+HANDLE GetIconHandle(int iconId)
{
- char szSettingName[100];
- mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, name);
- Skin_ReleaseIcon(szSettingName);
-}
+ for (int i=0; i < SIZEOF(iconList); i++)
+ if (iconList[i].defIconID == iconId)
+ return iconList[i].hIcolib;
-void ReleaseIconEx(HICON hIcon)
-{
- Skin_ReleaseIcon(hIcon);
+ return NULL;
}
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp
index f39a329069..2055554374 100644
--- a/plugins/CrashDumper/src/ui.cpp
+++ b/plugins/CrashDumper/src/ui.cpp
@@ -70,8 +70,8 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
{
hViewWnd = hwndDlg;
TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("versionInfo", true));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx("versionInfo"));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx(IDI_VI, true));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx(IDI_VI));
CHARFORMAT2 chf;
chf.cbSize = sizeof(chf);
@@ -192,8 +192,8 @@ INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
case WM_DESTROY:
hViewWnd = NULL;
- ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
- ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
+ Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
+ Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
Utils_SaveWindowPosition(hwndDlg, NULL, PluginName, "ViewInfo_");
if (servicemode) PostQuitMessage(0);
break;
@@ -273,15 +273,13 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_CONTEXTMENU:
PUDeletePopUp(hWnd);
break;
case WM_COMMAND:
- switch ((int)PUGetPluginData(hWnd))
- {
+ switch ((int)PUGetPluginData(hWnd)) {
case 0:
OpenAuthUrl("http://www.miranda-vi.org/");
break;
@@ -301,7 +299,8 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case UM_FREEPLUGINDATA:
- ReleaseIconEx("versionInfo");
+ Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0));
+ Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0));
break;
}
@@ -321,7 +320,7 @@ void ShowMessage(int type, const TCHAR* format, ...)
if (ServiceExists(MS_POPUP_ADDPOPUPT))
{
_tcscpy(pi.lptzContactName, TEXT(PluginName));
- pi.lchIcon = LoadIconEx("versionInfo");
+ pi.lchIcon = LoadIconEx(IDI_VI);
pi.PluginWindowProc = DlgProcPopup;
pi.PluginData = (void*)type;
diff --git a/plugins/CrashDumper/src/utils.h b/plugins/CrashDumper/src/utils.h
index 9089f57571..e1f4c1919c 100644
--- a/plugins/CrashDumper/src/utils.h
+++ b/plugins/CrashDumper/src/utils.h
@@ -56,6 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <m_hotkeys.h>
#include <m_protocols.h>
#include <m_help.h>
+#include <m_icolib.h>
#include "bkstring.h"
@@ -171,7 +172,6 @@ void OpenAuthUrl(const char* url);
void __cdecl VersionInfoUploadThread(void* arg);
void InitIcons(void);
-HICON LoadIconEx(const char* name, bool big = false);
-HANDLE GetIconHandle(const char* name);
-void ReleaseIconEx(const char* name);
-void ReleaseIconEx(HICON hIcon);
+HICON LoadIconEx(int iconId, bool big = false);
+void ReleaseIconEx(int iconId);
+HANDLE GetIconHandle(int iconId);