diff options
author | George Hazan <ghazan@miranda.im> | 2021-01-19 15:50:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-01-19 15:50:20 +0300 |
commit | e0377024f5048273f409b4844c2b44e3e7bb5d7d (patch) | |
tree | 0a69ab34bed57dcf95f86451aeeda62132f4fb6a /src | |
parent | e1198a334af374479e7f98d41220e85116217db3 (diff) |
fixes #2702 (Dbx_sqlite: missing "Compact" menu item)
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/database.cpp | 37 | ||||
-rw-r--r-- | src/mir_app/src/profilemanager.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/profilemanager.h | 1 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 906358520d..d3ee8296e6 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -29,7 +29,7 @@ bool g_bDbCreated; wchar_t g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_shortProfileName[MAX_PATH];
wchar_t* g_defaultProfile;
-bool fileExist(const wchar_t *fname)
+static bool fileExist(const wchar_t *fname)
{
if (*fname == 0)
return false;
@@ -445,6 +445,38 @@ static BOOL CALLBACK EnumMirandaWindows(HWND hwnd, LPARAM lParam) }
/////////////////////////////////////////////////////////////////////////////////////////
+// Default menu items
+
+static INT_PTR CompactMe(void* obj, WPARAM, LPARAM)
+{
+ auto *db = (MDatabaseCommon *)obj;
+ if (!db->Compact())
+ MessageBox(0, TranslateT("Database was compacted successfully"), TranslateT("Database"), MB_OK | MB_ICONINFORMATION);
+ else
+ MessageBox(0, TranslateT("Database compaction failed"), TranslateT("Database"), MB_OK | MB_ICONERROR);
+ return 0;
+}
+
+static int OnModulesLoaded(WPARAM, LPARAM)
+{
+ auto *pDb = db_get_current();
+ if (pDb->GetDriver()->capabilities & MDB_CAPS_COMPACT) {
+ CMenuItem mi(&g_plugin);
+ mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Database"), 500000000, 0);
+
+ SET_UID(mi, 0x98c0caf3, 0xBfe5, 0x4e31, 0xac, 0xf0, 0xab, 0x95, 0xb2, 0x9b, 0x9f, 0x73);
+ mi.position++;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_DATABASE);
+ mi.name.a = LPGEN("Compact");
+ mi.pszService = "DB/UI/Compact";
+ Menu_AddMainMenuItem(&mi);
+
+ CreateServiceFunctionObj(mi.pszService, CompactMe, pDb);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
static wchar_t tszNoDrivers[] = LPGENW("Miranda is unable to open '%s' because you do not have any profile plugins installed.\nYou need to install dbx_mdbx.dll");
static wchar_t tszUnknownFormat[] = LPGENW("Miranda was unable to open '%s', it's in an unknown format.");
@@ -510,5 +542,8 @@ int LoadDatabaseModule(void) }
while (retry);
+ if (rc == 0)
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+
return rc;
}
diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index 398bf6419c..628bc8856d 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WM_INPUTCHANGED (WM_USER + 0x3000) #define WM_FOCUSTEXTBOX (WM_USER + 0x3001) -typedef BOOL (__cdecl *ENUMPROFILECALLBACK) (wchar_t *tszFullPath, wchar_t *profile, LPARAM lParam); +typedef BOOL (__cdecl *ENUMPROFILECALLBACK)(wchar_t *tszFullPath, wchar_t *profile, LPARAM lParam); ///////////////////////////////////////////////////////////////////////////////////////// // Profile creator diff --git a/src/mir_app/src/profilemanager.h b/src/mir_app/src/profilemanager.h index e4a5f89b62..a895474918 100644 --- a/src/mir_app/src/profilemanager.h +++ b/src/mir_app/src/profilemanager.h @@ -40,7 +40,6 @@ int touchDatabase(const wchar_t *tszProfile, DATABASELINK **pDblink); int getProfileManager(PROFILEMANAGERDATA *pd);
int getProfilePath(wchar_t *buf, size_t cch);
int isValidProfileName(const wchar_t *name);
-bool fileExist(const wchar_t *fname);
bool shouldAutoCreate(wchar_t *szProfile);
extern wchar_t g_profileDir[MAX_PATH], g_profileName[MAX_PATH], g_shortProfileName[MAX_PATH];
|