summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-08-07 15:11:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-08-07 15:11:21 +0300
commit58cb6e6f41c9773b96e1cf9f0cce58c4078b3b46 (patch)
tree69795a2702b6f41d93aa3d89ceb3330b81d3211f
parent933b2a7a59948d3195aafc604d4d5711fa4a6345 (diff)
code cleaning
-rw-r--r--include/m_db_int.h2
-rw-r--r--plugins/DbChecker/src/main.cpp3
-rw-r--r--plugins/DbChecker/src/selectdb.cpp4
-rw-r--r--plugins/DbChecker/src/worker.cpp11
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.cpp2
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.h2
6 files changed, 11 insertions, 13 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
index e8a1dfc5d8..1ce03e2342 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -47,7 +47,7 @@ struct DBCHeckCallback
interface MIDatabaseChecker
{
STDMETHOD_(BOOL, Start)(DBCHeckCallback *callback) PURE;
- STDMETHOD_(BOOL, CheckDb)(int phase, int firstTime) PURE;
+ STDMETHOD_(BOOL, CheckDb)(int phase) PURE;
STDMETHOD_(VOID, Destroy)() PURE;
};
diff --git a/plugins/DbChecker/src/main.cpp b/plugins/DbChecker/src/main.cpp
index 18ee5cc29b..89b5633957 100644
--- a/plugins/DbChecker/src/main.cpp
+++ b/plugins/DbChecker/src/main.cpp
@@ -64,13 +64,14 @@ static INT_PTR ServiceMode(WPARAM, LPARAM)
bServiceMode = true;
opts.db = db_get_current();
+ db_setCurrent(nullptr);
wcsncpy_s(opts.filename, VARSW(L"%miranda_userdata%\\%miranda_profilename%.dat"), _TRUNCATE);
opts.dbChecker = opts.db->GetChecker();
if (opts.dbChecker == nullptr)
return SERVICE_FAILED;
- DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, ProgressDlgProc);
+ DialogBox(g_plugin.getInst(), MAKEINTRESOURCE(IDD_WIZARD), nullptr, WizardDlgProc);
return (bLaunchMiranda) ? SERVICE_CONTINUE : SERVICE_FAILED;
}
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp
index 66df5f7480..162a49af7c 100644
--- a/plugins/DbChecker/src/selectdb.cpp
+++ b/plugins/DbChecker/src/selectdb.cpp
@@ -166,6 +166,10 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM
switch (message) {
case WM_INITDIALOG:
TranslateDialogDefault(hdlg);
+ if (bServiceMode) {
+ OpenDatabase(hdlg);
+ return TRUE;
+ }
{
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 3, 3);
ImageList_AddIcon(hIml, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_PROFILEGREEN)));
diff --git a/plugins/DbChecker/src/worker.cpp b/plugins/DbChecker/src/worker.cpp
index 7911691107..379a702613 100644
--- a/plugins/DbChecker/src/worker.cpp
+++ b/plugins/DbChecker/src/worker.cpp
@@ -29,19 +29,17 @@ static void Finalize()
void __cdecl WorkerThread(void *)
{
- int task, firstTime;
time_t ts = time(nullptr);
AddToStatus(STATUS_MESSAGE, TranslateT("Database worker thread activated"));
DWORD sp = 0;
- firstTime = 0;
DBCHeckCallback callback;
callback.pfnAddLogMessage = AddToStatus;
opts.dbChecker->Start(&callback);
- for (task = 0;;) {
+ for (int task = 0;; task++) {
if (callback.spaceProcessed / (callback.spaceUsed / 1000 + 1) > sp) {
sp = callback.spaceProcessed / (callback.spaceUsed / 1000 + 1);
SetProgressBar(sp);
@@ -52,8 +50,7 @@ void __cdecl WorkerThread(void *)
break;
}
- int ret = opts.dbChecker->CheckDb(task, firstTime);
- firstTime = 0;
+ int ret = opts.dbChecker->CheckDb(task);
if (ret == ERROR_OUT_OF_PAPER) {
Finalize();
AddToStatus(STATUS_MESSAGE, TranslateT("Elapsed time: %d sec"), time(nullptr) - ts);
@@ -63,10 +60,6 @@ void __cdecl WorkerThread(void *)
AddToStatus(STATUS_SUCCESS, TranslateT("All tasks completed successfully"));
break;
}
- else if (ret == ERROR_NO_MORE_ITEMS) {
- task++;
- firstTime = 1;
- }
else if (ret != ERROR_SUCCESS)
break;
}
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp
index 8a28dfe589..6803f2d322 100644
--- a/plugins/Dbx_mdbx/src/dbintf.cpp
+++ b/plugins/Dbx_mdbx/src/dbintf.cpp
@@ -308,7 +308,7 @@ static CheckWorker Workers[] =
&CDbxMDBX::CheckEvents1
};
-int CDbxMDBX::CheckDb(int phase, int)
+int CDbxMDBX::CheckDb(int phase)
{
if (phase >= _countof(Workers))
return ERROR_OUT_OF_PAPER;
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h
index a16b7f85ee..7a563f68d8 100644
--- a/plugins/Dbx_mdbx/src/dbintf.h
+++ b/plugins/Dbx_mdbx/src/dbintf.h
@@ -309,7 +309,7 @@ protected:
}
STDMETHODIMP_(BOOL) Start(DBCHeckCallback *callback);
- STDMETHODIMP_(BOOL) CheckDb(int phase, int firstTime);
+ STDMETHODIMP_(BOOL) CheckDb(int phase);
STDMETHODIMP_(VOID) Destroy();
DBCHeckCallback *cb;