diff options
author | George Hazan <ghazan@miranda.im> | 2018-11-12 21:44:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-11-12 21:44:56 +0300 |
commit | 53fe3e46177d17b4941610de19f5cc6210700cb4 (patch) | |
tree | b67a6bc208dad141f9db14035cd7e42ff2a51872 /plugins/PluginUpdater | |
parent | 488214ac8af0c4aeb1a5c1d8fd48368daaf4c4c7 (diff) |
db_* functions replaced with g_plugin calls
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r-- | plugins/PluginUpdater/src/DlgListNew.cpp | 2 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/DlgUpdate.cpp | 40 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Events.cpp | 4 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 18 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 82 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/PluginUpdater.cpp | 20 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 36 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/unzipfile.cpp | 2 |
8 files changed, 102 insertions, 102 deletions
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp index e7a289764a..b55d9ba333 100644 --- a/plugins/PluginUpdater/src/DlgListNew.cpp +++ b/plugins/PluginUpdater/src/DlgListNew.cpp @@ -368,7 +368,7 @@ static FILEINFO* ServerEntryToFileInfo(const ServListEntry &hash, const wchar_t* FileInfo->File.CRCsum = hash.m_crc;
// Load list of checked Plugins from database
Netlib_LogfW(hNetlibUser, L"File %s found", FileInfo->tszOldName);
- FileInfo->bEnabled = db_get_b(NULL, DB_MODULE_NEW_FILES, _T2A(FileInfo->tszOldName)) != 0;
+ FileInfo->bEnabled = db_get_b(0, DB_MODULE_NEW_FILES, _T2A(FileInfo->tszOldName)) != 0;
return FileInfo;
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index 1bce60f362..fbdaee7bf2 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -32,7 +32,7 @@ static void SelectAll(HWND hDlg, bool bEnable) for (auto &it : todo) {
ListView_SetCheckState(hwndList, todo.indexOf(&it), bEnable);
- db_set_b(NULL, DB_MODULE_FILES, StrToLower(_T2A(it->tszOldName)), it->bEnabled = bEnable);
+ db_set_b(0, DB_MODULE_FILES, StrToLower(_T2A(it->tszOldName)), it->bEnabled = bEnable);
}
}
@@ -122,7 +122,7 @@ static void ApplyUpdates(void *param) }
Skin_PlaySound("updatecompleted");
- db_set_b(NULL, MODULENAME, DB_SETTING_RESTART_COUNT, 5);
+ g_plugin.setByte(DB_SETTING_RESTART_COUNT, 5);
if (opts.bBackup)
CallService(MS_AB_BACKUP, 0, 0);
@@ -130,28 +130,28 @@ static void ApplyUpdates(void *param) if (opts.bChangePlatform) {
wchar_t mirandaPath[MAX_PATH];
GetModuleFileName(nullptr, mirandaPath, _countof(mirandaPath));
- db_set_ws(NULL, MODULENAME, "OldBin2", mirandaPath);
+ g_plugin.setWString("OldBin2", mirandaPath);
- db_unset(NULL, MODULENAME, DB_SETTING_CHANGEPLATFORM);
+ g_plugin.delSetting(DB_SETTING_CHANGEPLATFORM);
}
else {
- ptrW oldbin(db_get_wsa(NULL, MODULENAME, "OldBin2"));
+ ptrW oldbin(g_plugin.getWStringA("OldBin2"));
if (oldbin) {
SafeDeleteFile(oldbin);
- db_unset(NULL, MODULENAME, "OldBin2");
+ g_plugin.delSetting("OldBin2");
}
}
if (opts.bForceRedownload) {
opts.bForceRedownload = 0;
- db_unset(NULL, MODULENAME, DB_SETTING_REDOWNLOAD);
+ g_plugin.delSetting(DB_SETTING_REDOWNLOAD);
}
// 5) Prepare Restart
int rc = MessageBox(hDlg, TranslateT("Update complete. Press Yes to restart Miranda now or No to postpone a restart until the exit."), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION);
PostMessage(hDlg, WM_CLOSE, 0, 0);
if (rc == IDYES) {
- BOOL bRestartCurrentProfile = db_get_b(NULL, MODULENAME, "RestartCurrentProfile", 1) ? 1 : 0;
+ BOOL bRestartCurrentProfile = g_plugin.getByte("RestartCurrentProfile", 1) ? 1 : 0;
if (opts.bChangePlatform) {
wchar_t mirstartpath[MAX_PATH];
@@ -292,7 +292,7 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM ListView_GetItem(hwndList, &lvI);
FILEINFO *p = (FILEINFO*)lvI.lParam;
- db_set_b(NULL, DB_MODULE_FILES, StrToLower(_T2A(p->tszOldName)), p->bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem));
+ db_set_b(0, DB_MODULE_FILES, StrToLower(_T2A(p->tszOldName)), p->bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem));
// Toggle the Download button
bool enableOk = false;
@@ -366,7 +366,7 @@ static INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM delete (OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
- db_set_dw(NULL, MODULENAME, DB_SETTING_LAST_UPDATE, time(0));
+ g_plugin.setDword(DB_SETTING_LAST_UPDATE, time(0));
mir_forkthread(InitTimer);
break;
@@ -457,19 +457,19 @@ static void DlgUpdateSilent(void *param) Skin_PlaySound("updatecompleted");
opts.bForceRedownload = false;
- db_unset(NULL, MODULENAME, DB_SETTING_REDOWNLOAD);
+ g_plugin.delSetting(DB_SETTING_REDOWNLOAD);
opts.bChangePlatform = false;
- db_unset(NULL, MODULENAME, DB_SETTING_CHANGEPLATFORM);
+ g_plugin.delSetting(DB_SETTING_CHANGEPLATFORM);
- db_set_b(NULL, MODULENAME, DB_SETTING_RESTART_COUNT, 5);
- db_set_b(NULL, MODULENAME, DB_SETTING_NEED_RESTART, 1);
+ g_plugin.setByte(DB_SETTING_RESTART_COUNT, 5);
+ g_plugin.setByte(DB_SETTING_NEED_RESTART, 1);
// 5) Prepare Restart
wchar_t tszTitle[100];
mir_snwprintf(tszTitle, TranslateT("%d component(s) was updated"), count);
- if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1))
+ if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(0, "Popup", "ModuleIsEnabled", 1))
ShowPopup(tszTitle,TranslateT("You need to restart your Miranda to apply installed updates."),POPUP_TYPE_MSG);
else {
if (Clist_TrayNotifyW(MODULEA, tszTitle, TranslateT("You need to restart your Miranda to apply installed updates."), NIIF_INFO, 30000)) {
@@ -478,7 +478,7 @@ static void DlgUpdateSilent(void *param) mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
if (MessageBox(nullptr, tszText, tszTitle, MB_ICONINFORMATION | MB_YESNO) == IDYES)
- CallServiceSync(MS_SYSTEM_RESTART, db_get_b(NULL, MODULENAME, "RestartCurrentProfile", 1) ? 1 : 0, 0);
+ CallServiceSync(MS_SYSTEM_RESTART, g_plugin.getByte("RestartCurrentProfile", 1) ? 1 : 0, 0);
}
}
}
@@ -742,7 +742,7 @@ static int ScanFolder(const wchar_t *tszFolder, size_t cbBaseLen, const wchar_t *p++ = '/';
// remember whether the user has decided not to update this component with this particular new version
- FileInfo->bEnabled = db_get_b(NULL, DB_MODULE_FILES, StrToLower(_T2A(FileInfo->tszOldName)), 1);
+ FileInfo->bEnabled = db_get_b(0, DB_MODULE_FILES, StrToLower(_T2A(FileInfo->tszOldName)), 1);
FileInfo->File.CRCsum = MyCRC;
UpdateFiles->insert(FileInfo);
@@ -807,7 +807,7 @@ static void DoCheck(bool bSilent = true) else {
opts.bSilent = bSilent;
- db_set_dw(NULL, MODULENAME, DB_SETTING_LAST_UPDATE, time(0));
+ g_plugin.setDword(DB_SETTING_LAST_UPDATE, time(0));
hCheckThread = mir_forkthread(CheckUpdates);
}
@@ -845,7 +845,7 @@ void CheckUpdateOnStartup() if (opts.bUpdateOnStartup) {
if (opts.bOnlyOnceADay) {
time_t now = time(0),
- was = db_get_dw(NULL, MODULENAME, DB_SETTING_LAST_UPDATE, 0);
+ was = g_plugin.getDword(DB_SETTING_LAST_UPDATE, 0);
if ((now - was) < 86400)
return;
@@ -892,7 +892,7 @@ void InitTimer(void *type) case 0: // default, plan next check relative to last check
{
time_t now = time(0);
- time_t was = db_get_dw(NULL, MODULENAME, DB_SETTING_LAST_UPDATE, 0);
+ time_t was = g_plugin.getDword(DB_SETTING_LAST_UPDATE, 0);
interval = PeriodToMilliseconds(opts.Period, opts.bPeriodMeasure);
interval -= (now - was) * 1000;
diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index 3fe786d3e1..4cde7317ff 100644 --- a/plugins/PluginUpdater/src/Events.cpp +++ b/plugins/PluginUpdater/src/Events.cpp @@ -55,9 +55,9 @@ int ModulesLoaded(WPARAM, LPARAM) if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE))
AssocMgr_AddNewUrlTypeW("mirpu:", TranslateT("Plugin updater URI scheme"), g_plugin.getInst(), IDI_PLGLIST, MODULENAME "/ParseUri", 0);
- int iRestartCount = db_get_b(NULL, MODULENAME, DB_SETTING_RESTART_COUNT, 2);
+ int iRestartCount = g_plugin.getByte(DB_SETTING_RESTART_COUNT, 2);
if (iRestartCount > 0)
- db_set_b(NULL, MODULENAME, DB_SETTING_RESTART_COUNT, iRestartCount - 1);
+ g_plugin.setByte(DB_SETTING_RESTART_COUNT, iRestartCount - 1);
else
EmptyFolder(); // silently
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index 7a215758d6..a7dec5cc32 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -25,18 +25,18 @@ void InitPopupList() {
int index = 0;
PopupsList[index].ID = index;
- PopupsList[index].colorBack = db_get_dw(NULL, MODULENAME, "Popups0Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODULENAME, "Popups0Tx", COLOR_TX_DEFAULT);
+ PopupsList[index].colorBack = g_plugin.getDword("Popups0Bg", COLOR_BG_FIRSTDEFAULT);
+ PopupsList[index].colorText = g_plugin.getDword("Popups0Tx", COLOR_TX_DEFAULT);
index = 1;
PopupsList[index].ID = index;
- PopupsList[index].colorBack = db_get_dw(NULL, MODULENAME, "Popups1Bg", COLOR_BG_SECONDDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODULENAME, "Popups1Tx", COLOR_TX_DEFAULT);
+ PopupsList[index].colorBack = g_plugin.getDword("Popups1Bg", COLOR_BG_SECONDDEFAULT);
+ PopupsList[index].colorText = g_plugin.getDword("Popups1Tx", COLOR_TX_DEFAULT);
index = 2;
PopupsList[index].ID = index;
- PopupsList[index].colorBack = db_get_dw(NULL, MODULENAME, "Popups2Bg", COLOR_BG_FIRSTDEFAULT);
- PopupsList[index].colorText = db_get_dw(NULL, MODULENAME, "Popups2Tx", COLOR_TX_DEFAULT);
+ PopupsList[index].colorBack = g_plugin.getDword("Popups2Bg", COLOR_BG_FIRSTDEFAULT);
+ PopupsList[index].colorText = g_plugin.getDword("Popups2Tx", COLOR_TX_DEFAULT);
}
void PopupAction(HWND hPopup, BYTE action)
@@ -74,7 +74,7 @@ static void _stdcall RestartPrompt(void *) mir_snwprintf(tszText, L"%s\n\n%s", TranslateT("You need to restart your Miranda to apply installed updates."), TranslateT("Would you like to restart it now?"));
if (MessageBox(nullptr, tszText, TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION | MB_TOPMOST) == IDYES)
- CallService(MS_SYSTEM_RESTART, db_get_b(NULL, MODULENAME, "RestartCurrentProfile", 1) ? 1 : 0, 0);
+ CallService(MS_SYSTEM_RESTART, g_plugin.getByte("RestartCurrentProfile", 1) ? 1 : 0, 0);
}
static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -95,11 +95,11 @@ static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wPara void ShowPopup(LPCTSTR ptszTitle, LPCTSTR ptszText, int Number)
{
- if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1)) {
+ if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(0, "Popup", "ModuleIsEnabled", 1)) {
char setting[100];
mir_snprintf(setting, "Popups%d", Number);
- if (db_get_b(NULL, MODULENAME, setting, DEFAULT_POPUP_ENABLED)) {
+ if (g_plugin.getByte(setting, DEFAULT_POPUP_ENABLED)) {
POPUPDATAT pd = { 0 };
pd.lchContact = NULL;
pd.lchIcon = IcoLib_GetIconByHandle(iconList[0].hIcolib);
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index 337f1b2dd7..092c096073 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -29,14 +29,14 @@ static int GetBits(HWND hwndDlg) static int GetUpdateMode()
{
- int UpdateMode = db_get_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, -1);
+ int UpdateMode = g_plugin.getByte(DB_SETTING_UPDATE_MODE, -1);
// Check if there is url for custom mode
if (UpdateMode == UPDATE_MODE_CUSTOM) {
- ptrW url(db_get_wsa(NULL, MODULENAME, DB_SETTING_UPDATE_URL));
+ ptrW url(g_plugin.getWStringA(DB_SETTING_UPDATE_URL));
if (url == NULL || !wcslen(url)) {
// No url for custom mode, reset that setting so it will be determined automatically
- db_unset(NULL, MODULENAME, DB_SETTING_UPDATE_MODE);
+ g_plugin.delSetting(DB_SETTING_UPDATE_MODE);
UpdateMode = -1;
}
}
@@ -68,7 +68,7 @@ wchar_t* GetDefaultUrl() mir_snwprintf(url, DEFAULT_UPDATE_URL_TRUNK_SYMBOLS, opts.bChangePlatform ? DEFAULT_OPP_BITS : DEFAULT_BITS);
return mir_wstrdup(url);
default:
- return db_get_wsa(NULL, MODULENAME, DB_SETTING_UPDATE_URL);
+ return g_plugin.getWStringA(DB_SETTING_UPDATE_URL);
}
}
@@ -95,7 +95,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), TRUE);
}
CheckDlgButton(hwndDlg, IDC_SILENTMODE, opts.bSilentMode ? BST_CHECKED : BST_UNCHECKED);
- if (db_get_b(NULL, MODULENAME, DB_SETTING_NEED_RESTART, 0))
+ if (g_plugin.getByte(DB_SETTING_NEED_RESTART, 0))
ShowWindow(GetDlgItem(hwndDlg, IDC_NEEDRESTARTLABEL), SW_SHOW);
SendDlgItemMessage(hwndDlg, IDC_PERIODSPIN, UDM_SETRANGE, 0, MAKELONG(99, 1));
@@ -110,12 +110,12 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar Edit_LimitText(GetDlgItem(hwndDlg, IDC_PERIOD), 2);
- if (db_get_b(NULL, MODULENAME, DB_SETTING_DONT_SWITCH_TO_STABLE, 0)) {
+ if (g_plugin.getByte(DB_SETTING_DONT_SWITCH_TO_STABLE, 0)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_STABLE), FALSE);
// Reset setting if needed
- int UpdateMode = db_get_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
+ int UpdateMode = g_plugin.getByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
if (UpdateMode == UPDATE_MODE_STABLE)
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
SetDlgItemText(hwndDlg, IDC_STABLE, LPGENW("Stable version (incompatible with current development version)"));
}
TranslateDialogDefault(hwndDlg);
@@ -150,7 +150,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), FALSE);
- ptrW url(db_get_wsa(NULL, MODULENAME, DB_SETTING_UPDATE_URL));
+ ptrW url(g_plugin.getWStringA(DB_SETTING_UPDATE_URL));
if (url == NULL)
url = GetDefaultUrl();
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url);
@@ -225,7 +225,7 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE_PLATFORM), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
{
- ptrW url(db_get_wsa(NULL, MODULENAME, DB_SETTING_UPDATE_URL));
+ ptrW url(g_plugin.getWStringA(DB_SETTING_UPDATE_URL));
if (url == NULL)
url = GetDefaultUrl();
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, url);
@@ -277,63 +277,63 @@ static INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wPar SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
if (hdr && hdr->code == PSN_APPLY) {
- db_set_b(NULL, MODULENAME, "UpdateOnStartup", opts.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
- db_set_b(NULL, MODULENAME, "OnlyOnceADay", opts.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY));
- db_set_b(NULL, MODULENAME, "UpdateOnPeriod", opts.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD));
- db_set_b(NULL, MODULENAME, "PeriodMeasure", opts.bPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE)));
- db_set_b(NULL, MODULENAME, "SilentMode", opts.bSilentMode = IsDlgButtonChecked(hwndDlg, IDC_SILENTMODE));
- db_set_b(NULL, MODULENAME, "Backup", opts.bBackup = IsDlgButtonChecked(hwndDlg, IDC_BACKUP));
+ g_plugin.setByte("UpdateOnStartup", opts.bUpdateOnStartup = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONSTARTUP));
+ g_plugin.setByte("OnlyOnceADay", opts.bOnlyOnceADay = IsDlgButtonChecked(hwndDlg, IDC_ONLYONCEADAY));
+ g_plugin.setByte("UpdateOnPeriod", opts.bUpdateOnPeriod = IsDlgButtonChecked(hwndDlg, IDC_UPDATEONPERIOD));
+ g_plugin.setByte("PeriodMeasure", opts.bPeriodMeasure = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE)));
+ g_plugin.setByte("SilentMode", opts.bSilentMode = IsDlgButtonChecked(hwndDlg, IDC_SILENTMODE));
+ g_plugin.setByte("Backup", opts.bBackup = IsDlgButtonChecked(hwndDlg, IDC_BACKUP));
wchar_t buffer[3] = { 0 };
Edit_GetText(GetDlgItem(hwndDlg, IDC_PERIOD), buffer, _countof(buffer));
- db_set_dw(NULL, MODULENAME, "Period", opts.Period = _wtoi(buffer));
+ g_plugin.setDword("Period", opts.Period = _wtoi(buffer));
mir_forkthread(InitTimer, (void*)1);
bool bNoSymbols = false;
if (IsDlgButtonChecked(hwndDlg, IDC_STABLE)) {
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
if (!opts.bChangePlatform)
opts.bForceRedownload = 0;
- db_unset(NULL, MODULENAME, DB_SETTING_REDOWNLOAD);
+ g_plugin.delSetting(DB_SETTING_REDOWNLOAD);
bNoSymbols = true;
}
else if (IsDlgButtonChecked(hwndDlg, IDC_STABLE_SYMBOLS)) {
// Only set ForceRedownload if the previous UpdateMode was different
// to redownload all plugin with pdb files
- if (db_get_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE) != UPDATE_MODE_STABLE_SYMBOLS) {
- db_set_b(NULL, MODULENAME, DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1);
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE_SYMBOLS);
+ if (g_plugin.getByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE) != UPDATE_MODE_STABLE_SYMBOLS) {
+ g_plugin.setByte(DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE_SYMBOLS);
}
}
else if (IsDlgButtonChecked(hwndDlg, IDC_TRUNK)) {
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
if (!opts.bChangePlatform)
opts.bForceRedownload = 0;
- db_unset(NULL, MODULENAME, DB_SETTING_REDOWNLOAD);
+ g_plugin.delSetting(DB_SETTING_REDOWNLOAD);
bNoSymbols = true;
}
else if (IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
// Only set ForceRedownload if the previous UpdateMode was different
// to redownload all plugin with pdb files
- if (db_get_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE) != UPDATE_MODE_TRUNK_SYMBOLS) {
- db_set_b(NULL, MODULENAME, DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1);
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK_SYMBOLS);
+ if (g_plugin.getByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE) != UPDATE_MODE_TRUNK_SYMBOLS) {
+ g_plugin.setByte(DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK_SYMBOLS);
}
}
else {
wchar_t tszUrl[100];
GetDlgItemText(hwndDlg, IDC_CUSTOMURL, tszUrl, _countof(tszUrl));
- db_set_ws(NULL, MODULENAME, DB_SETTING_UPDATE_URL, tszUrl);
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_CUSTOM);
+ g_plugin.setWString(DB_SETTING_UPDATE_URL, tszUrl);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_CUSTOM);
opts.bForceRedownload = 0;
- db_unset(NULL, MODULENAME, DB_SETTING_REDOWNLOAD);
+ g_plugin.delSetting(DB_SETTING_REDOWNLOAD);
}
if (IsDlgButtonChecked(hwndDlg, IDC_CHANGE_PLATFORM)) {
- db_set_b(NULL, MODULENAME, DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1);
- db_set_b(NULL, MODULENAME, DB_SETTING_CHANGEPLATFORM, opts.bChangePlatform = 1);
+ g_plugin.setByte(DB_SETTING_REDOWNLOAD, opts.bForceRedownload = 1);
+ g_plugin.setByte(DB_SETTING_CHANGEPLATFORM, opts.bChangePlatform = 1);
}
- else db_set_b(NULL, MODULENAME, DB_SETTING_CHANGEPLATFORM, opts.bChangePlatform = 0);
+ else g_plugin.setByte(DB_SETTING_CHANGEPLATFORM, opts.bChangePlatform = 0);
// if user selected update channel without symbols, remove PDBs
if (bNoSymbols) {
@@ -399,7 +399,7 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM for (int i = 0; i < POPUPS; i++) {
char str[20] = { 0 };
mir_snprintf(str, "Popups%d", i);
- CheckDlgButton(hdlg, (i + 40071), (db_get_b(NULL, MODULENAME, str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, (i + 40071), (g_plugin.getByte(str, DEFAULT_POPUP_ENABLED)) ? BST_CHECKED : BST_UNCHECKED);
}
return TRUE;
@@ -525,26 +525,26 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM ctlColor = SendDlgItemMessage(hdlg, (i + 42071), CPM_GETCOLOUR, 0, 0);
PopupsList[i].colorBack = ctlColor;
mir_snprintf(szSetting, "Popups%iBg", i);
- db_set_dw(NULL, MODULENAME, szSetting, ctlColor);
+ g_plugin.setDword(szSetting, ctlColor);
ctlColor = SendDlgItemMessage(hdlg, (i + 41071), CPM_GETCOLOUR, 0, 0);
PopupsList[i].colorText = ctlColor;
mir_snprintf(szSetting, "Popups%iTx", i);
- db_set_dw(NULL, MODULENAME, szSetting, ctlColor);
+ g_plugin.setDword(szSetting, ctlColor);
}
//Colors
- db_set_b(NULL, MODULENAME, "DefColors", PopupOptions.DefColors);
+ g_plugin.setByte("DefColors", PopupOptions.DefColors);
//Timeout
PopupOptions.Timeout = GetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, nullptr, TRUE);
- db_set_dw(NULL, MODULENAME, "Timeout", PopupOptions.Timeout);
+ g_plugin.setDword("Timeout", PopupOptions.Timeout);
//Left mouse click
- db_set_b(NULL, MODULENAME, "LeftClickAction", PopupOptions.LeftClickAction);
+ g_plugin.setByte("LeftClickAction", PopupOptions.LeftClickAction);
//Right mouse click
- db_set_b(NULL, MODULENAME, "RightClickAction", PopupOptions.RightClickAction);
+ g_plugin.setByte("RightClickAction", PopupOptions.RightClickAction);
//Notified popups
for (int i = 0; i < POPUPS; i++) {
char str[20] = { 0 };
mir_snprintf(str, "Popups%d", i);
- db_set_b(NULL, MODULENAME, str, (BYTE)(IsDlgButtonChecked(hdlg, (i + 40071))));
+ g_plugin.setByte(str, (BYTE)(IsDlgButtonChecked(hdlg, (i + 40071))));
}
return TRUE;
} //case PSN_APPLY
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index 21f680eec1..5a4f6c3d8f 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -48,7 +48,7 @@ int CMPlugin::Load() {
InitServices();
- db_set_b(NULL, MODULENAME, DB_SETTING_NEED_RESTART, 0);
+ g_plugin.setByte(DB_SETTING_NEED_RESTART, 0);
DWORD dwLen = GetTempPath(_countof(g_tszTempPath), g_tszTempPath);
if (g_tszTempPath[dwLen-1] == '\\')
@@ -100,22 +100,22 @@ int CMPlugin::Load() g_plugin.addSound("updatefailed", LPGENW("Plugin Updater"), LPGENW("Update failed"));
// Upgrade old settings
- if (-1 == db_get_b(0, MODULENAME, DB_SETTING_UPDATE_MODE, -1)) {
- ptrW dbvUpdateURL(db_get_wsa(0, MODULENAME, DB_SETTING_UPDATE_URL));
+ if (-1 == g_plugin.getByte(DB_SETTING_UPDATE_MODE, -1)) {
+ ptrW dbvUpdateURL(g_plugin.getWStringA(DB_SETTING_UPDATE_URL));
if (dbvUpdateURL) {
if (!wcscmp(dbvUpdateURL, _A2W(DEFAULT_UPDATE_URL_OLD))) {
- db_set_b(0, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
- db_unset(0, MODULENAME, DB_SETTING_UPDATE_URL);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
+ g_plugin.delSetting(DB_SETTING_UPDATE_URL);
}
else if (!wcscmp(dbvUpdateURL, _A2W(DEFAULT_UPDATE_URL_TRUNK_OLD))) {
- db_set_b(0, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
- db_unset(0, MODULENAME, DB_SETTING_UPDATE_URL);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
+ g_plugin.delSetting(DB_SETTING_UPDATE_URL);
}
else if (!wcscmp(dbvUpdateURL, _A2W(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS_OLD) L"/")) {
- db_set_b(0, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK_SYMBOLS);
- db_unset(0, MODULENAME, DB_SETTING_UPDATE_URL);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK_SYMBOLS);
+ g_plugin.delSetting(DB_SETTING_UPDATE_URL);
}
- else db_set_b(0, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_CUSTOM);
+ else g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_CUSTOM);
}
}
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index e0c47e2680..b57676e6dd 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -25,20 +25,20 @@ HANDLE hPipe = nullptr; /////////////////////////////////////////////////////////////////////////////////////
void LoadOptions()
{
- PopupOptions.DefColors = db_get_b(NULL, MODULENAME, "DefColors", DEFAULT_COLORS);
- PopupOptions.LeftClickAction= db_get_b(NULL, MODULENAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
- PopupOptions.RightClickAction = db_get_b(NULL, MODULENAME, "RightClickAction", DEFAULT_POPUP_RCLICK);
- PopupOptions.Timeout = db_get_dw(NULL, MODULENAME, "Timeout", DEFAULT_TIMEOUT_VALUE);
-
- opts.bUpdateOnStartup = db_get_b(NULL, MODULENAME, "UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
- opts.bOnlyOnceADay = db_get_b(NULL, MODULENAME, "OnlyOnceADay", DEFAULT_ONLYONCEADAY);
- opts.bUpdateOnPeriod = db_get_b(NULL, MODULENAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
- opts.Period = db_get_dw(NULL, MODULENAME, "Period", DEFAULT_PERIOD);
- opts.bPeriodMeasure = db_get_b(NULL, MODULENAME, "PeriodMeasure", DEFAULT_PERIODMEASURE);
- opts.bForceRedownload = db_get_b(NULL, MODULENAME, DB_SETTING_REDOWNLOAD, 0);
- opts.bSilentMode = db_get_b(NULL, MODULENAME, "SilentMode", 0);
- opts.bBackup = db_get_b(NULL, MODULENAME, "Backup", 0);
- opts.bChangePlatform = db_get_b(NULL, MODULENAME, DB_SETTING_CHANGEPLATFORM, 0);
+ PopupOptions.DefColors = g_plugin.getByte("DefColors", DEFAULT_COLORS);
+ PopupOptions.LeftClickAction= g_plugin.getByte("LeftClickAction", DEFAULT_POPUP_LCLICK);
+ PopupOptions.RightClickAction = g_plugin.getByte("RightClickAction", DEFAULT_POPUP_RCLICK);
+ PopupOptions.Timeout = g_plugin.getDword("Timeout", DEFAULT_TIMEOUT_VALUE);
+
+ opts.bUpdateOnStartup = g_plugin.getByte("UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
+ opts.bOnlyOnceADay = g_plugin.getByte("OnlyOnceADay", DEFAULT_ONLYONCEADAY);
+ opts.bUpdateOnPeriod = g_plugin.getByte("UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
+ opts.Period = g_plugin.getDword("Period", DEFAULT_PERIOD);
+ opts.bPeriodMeasure = g_plugin.getByte("PeriodMeasure", DEFAULT_PERIODMEASURE);
+ opts.bForceRedownload = g_plugin.getByte(DB_SETTING_REDOWNLOAD, 0);
+ opts.bSilentMode = g_plugin.getByte("SilentMode", 0);
+ opts.bBackup = g_plugin.getByte("Backup", 0);
+ opts.bChangePlatform = g_plugin.getByte(DB_SETTING_CHANGEPLATFORM, 0);
}
IconItem iconList[] =
@@ -205,14 +205,14 @@ bool ParseHashes(const wchar_t *ptszUrl, ptrW &baseUrl, SERVLIST &arHashes) DeleteFile(tszTmpIni);
if (bDoNotSwitchToStable) {
- db_set_b(NULL, MODULENAME, DB_SETTING_DONT_SWITCH_TO_STABLE, 1);
+ g_plugin.setByte(DB_SETTING_DONT_SWITCH_TO_STABLE, 1);
// Reset setting if needed
- int UpdateMode = db_get_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
+ int UpdateMode = g_plugin.getByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_STABLE);
if (UpdateMode == UPDATE_MODE_STABLE)
- db_set_b(NULL, MODULENAME, DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
+ g_plugin.setByte(DB_SETTING_UPDATE_MODE, UPDATE_MODE_TRUNK);
}
else
- db_set_b(NULL, MODULENAME, DB_SETTING_DONT_SWITCH_TO_STABLE, 0);
+ g_plugin.setByte(DB_SETTING_DONT_SWITCH_TO_STABLE, 0);
return true;
}
diff --git a/plugins/PluginUpdater/src/unzipfile.cpp b/plugins/PluginUpdater/src/unzipfile.cpp index 7e0ddca0e5..92a51887c5 100644 --- a/plugins/PluginUpdater/src/unzipfile.cpp +++ b/plugins/PluginUpdater/src/unzipfile.cpp @@ -49,7 +49,7 @@ bool extractCurrentFile(unzFile uf, wchar_t *ptszDestPath, wchar_t *ptszBackPath // This is because there may be more then one file in a single zip
// So we need to check each file
- if (ch && !db_get_b(NULL, DB_MODULE_FILES, StrToLower(ptrA(mir_strdup(filename))), 1))
+ if (ch && !db_get_b(0, DB_MODULE_FILES, StrToLower(ptrA(mir_strdup(filename))), 1))
return true;
wchar_t tszDestFile[MAX_PATH], tszBackFile[MAX_PATH];
|