diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-28 18:29:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-28 18:29:52 +0000 |
commit | be3185a374d39a8ee0f12a4e985ecca279633fff (patch) | |
tree | 14ba64a79d7dd62d95797db402950702a24667fe /src/modules | |
parent | 61be34f18c2d61c075a7e268aa9aab89b78ec17a (diff) |
- MS_DB_CHECKPROFILE - service for checking databases
- added menu item "Check" to a context menu in profile manager
git-svn-id: http://svn.miranda-ng.org/main/trunk@1228 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/database/profilemanager.cpp | 56 | ||||
-rw-r--r-- | src/modules/plugins/newplugins.cpp | 19 |
2 files changed, 57 insertions, 18 deletions
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 2d9b003e9a..3238f14e87 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "profilemanager.h"
#include <sys/stat.h>
+void EnsureCheckerLoaded(void);
+
#define WM_INPUTCHANGED (WM_USER + 0x3000)
#define WM_FOCUSTEXTBOX (WM_USER + 0x3001)
@@ -286,7 +288,25 @@ BOOL EnumProfilesForList(TCHAR *fullpath, TCHAR *profile, LPARAM lParam) return TRUE;
}
-void DeleteProfile(HWND hwndList, int iItem, DlgProfData* dat)
+void CheckProfile(HWND hwndList, int iItem, DlgProfData *dat)
+{
+ if (iItem < 0)
+ return;
+
+ TCHAR profile[MAX_PATH], fullName[MAX_PATH];
+ LVITEM item = {0};
+ item.mask = LVIF_TEXT;
+ item.iItem = iItem;
+ item.pszText = profile;
+ item.cchTextMax = SIZEOF(profile);
+ if ( !ListView_GetItem(hwndList, &item))
+ return;
+
+ mir_sntprintf(fullName, SIZEOF(fullName), _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, profile, profile);
+ CallService(MS_DB_CHECKPROFILE, (WPARAM)fullName, 0);
+}
+
+void DeleteProfile(HWND hwndList, int iItem, DlgProfData *dat)
{
if (iItem < 0)
return;
@@ -318,21 +338,19 @@ void DeleteProfile(HWND hwndList, int iItem, DlgProfData* dat) static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- DlgProfData* dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ DlgProfData *dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
HWND hwndList = GetDlgItem(hwndDlg, IDC_PROFILELIST);
switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ EnsureCheckerLoaded();
{
- HIMAGELIST hImgList;
- LVCOLUMN col;
-
- TranslateDialogDefault(hwndDlg);
-
dat = (DlgProfData*) lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
// set columns
+ LVCOLUMN col;
col.mask = LVCF_TEXT | LVCF_WIDTH;
col.pszText = TranslateT("Profile");
col.cx = 122;
@@ -355,7 +373,7 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, ListView_InsertColumn(hwndList, 4, &col);
// icons
- hImgList = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 2, 1);
+ HIMAGELIST hImgList = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 2, 1);
ImageList_AddIcon_NotShared(hImgList, MAKEINTRESOURCE(IDI_USERDETAILS));
ImageList_AddIcon_NotShared(hImgList, MAKEINTRESOURCE(IDI_DELETE));
@@ -410,14 +428,19 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, lvht.pt.x = GET_X_LPARAM(lParam);
lvht.pt.y = GET_Y_LPARAM(lParam);
ScreenToClient(hwndList, &lvht.pt);
- if (ListView_HitTest(hwndList, &lvht) < 0) break;
+ if (ListView_HitTest(hwndList, &lvht) < 0)
+ break;
lvht.pt.x = GET_X_LPARAM(lParam);
lvht.pt.y = GET_Y_LPARAM(lParam);
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1, TranslateT("Run"));
- AppendMenu(hMenu, MF_SEPARATOR, 2, NULL);
+ AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
+ if (ServiceExists(MS_DB_CHECKPROFILE)) {
+ AppendMenu(hMenu, MF_STRING, 2, TranslateT("Check"));
+ AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
+ }
AppendMenu(hMenu, MF_STRING, 3, TranslateT("Delete"));
int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, lvht.pt.x, lvht.pt.y, 0, hwndDlg, NULL);
switch (index) {
@@ -425,6 +448,10 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, SendMessage(GetParent(hwndDlg), WM_COMMAND, IDOK, 0);
break;
+ case 2:
+ CheckProfile(hwndList, lvht.iItem, dat);
+ break;
+
case 3:
DeleteProfile(hwndList, lvht.iItem, dat);
break;
@@ -445,12 +472,9 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(dat->hwndOK, ListView_GetSelectedCount(hwndList) == 1);
case NM_DBLCLK:
- {
- LVITEM item = {0};
+ if (dat != NULL) {
TCHAR profile[MAX_PATH];
-
- if (dat == NULL) break;
-
+ LVITEM item = {0};
item.mask = LVIF_TEXT;
item.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED | LVNI_ALL);
item.pszText = profile;
@@ -468,8 +492,8 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, CloseHandle(hFile);
if (hdr->code == NM_DBLCLK) EndDialog(GetParent(hwndDlg), 1);
}
- return TRUE;
}
+ return TRUE;
case LVN_KEYDOWN:
{
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index b52e917dd0..7bdd1d87b1 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -421,7 +421,6 @@ pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path) return p;
}
-
void SetPluginOnWhiteList(const TCHAR* pluginname, int allow)
{
char plugName[MAX_PATH];
@@ -589,7 +588,6 @@ static int LaunchServicePlugin(pluginEntry* p) // plugin load failed - terminating Miranda
if ( !( p->pclass & PCLASS_LOADED)) {
if (p->bpi.Load() != ERROR_SUCCESS) {
- p->pclass |= PCLASS_FAILED;
Plugin_Uninit(p);
return SERVICE_FAILED;
}
@@ -630,6 +628,23 @@ int LoadServiceModePlugin() return (serviceModePlugin == NULL) ? SERVICE_CONTINUE : LaunchServicePlugin(serviceModePlugin);
}
+void EnsureCheckerLoaded(void)
+{
+ for (int i=0; i < servicePlugins.getCount(); i++) {
+ pluginEntry* p = servicePlugins[i];
+ if ( _tcsicmp(p->pluginname, _T("dbchecker.dll")))
+ continue;
+
+ if ( !(p->pclass & PCLASS_LOADED)) {
+ if (p->bpi.Load() != ERROR_SUCCESS)
+ Plugin_Uninit(p);
+ else
+ p->pclass |= PCLASS_LOADED;
+ }
+ break;
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// Event hook to unload all non-core plugins
// hooked very late, after all the internal plugins, blah
|