From 53fe3e46177d17b4941610de19f5cc6210700cb4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 12 Nov 2018 21:44:56 +0300 Subject: db_* functions replaced with g_plugin calls --- plugins/AVS/src/acc.cpp | 2 +- plugins/AVS/src/cache.cpp | 4 +-- plugins/AVS/src/image_utils.cpp | 8 ++--- plugins/AVS/src/main.cpp | 2 +- plugins/AVS/src/options.cpp | 65 ++++++++++++++++++++--------------------- plugins/AVS/src/poll.cpp | 4 +-- plugins/AVS/src/services.cpp | 26 ++++++++--------- plugins/AVS/src/stdafx.h | 3 ++ plugins/AVS/src/utils.cpp | 16 +++++----- 9 files changed, 66 insertions(+), 64 deletions(-) (limited to 'plugins/AVS/src') diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp index 5d7bb35503..df91050b65 100644 --- a/plugins/AVS/src/acc.cpp +++ b/plugins/AVS/src/acc.cpp @@ -565,7 +565,7 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP DeleteObject(hbrush); } - if (data->hContact == NULL && data->proto[0] == 0 && db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1)) + if (data->hContact == NULL && data->proto[0] == 0 && g_plugin.getByte("GlobalUserAvatarNotConsistent", 1)) DrawText(hdc, data->hFont, rc, TranslateT("Protocols have different avatars")); // Has an animated gif diff --git a/plugins/AVS/src/cache.cpp b/plugins/AVS/src/cache.cpp index 79ccc1ddbe..d698f42b93 100644 --- a/plugins/AVS/src/cache.cpp +++ b/plugins/AVS/src/cache.cpp @@ -72,7 +72,7 @@ CacheNode* FindAvatarInCache(MCONTACT hContact, bool add, bool findAny) return nullptr; char *szProto = GetContactProto(hContact); - if (szProto == nullptr || !db_get_b(NULL, AVS_MODULE, szProto, 1)) + if (szProto == nullptr || !g_plugin.getByte(szProto, 1)) return nullptr; CacheNode *cc; @@ -222,7 +222,7 @@ void PicLoader(LPVOID) { Thread_SetName("AVS: PicLoader"); - DWORD dwDelay = db_get_dw(NULL, AVS_MODULE, "picloader_sleeptime", 80); + DWORD dwDelay = g_plugin.getDword("picloader_sleeptime", 80); if (dwDelay < 30) dwDelay = 30; diff --git a/plugins/AVS/src/image_utils.cpp b/plugins/AVS/src/image_utils.cpp index d89448e359..9717e5ddb4 100644 --- a/plugins/AVS/src/image_utils.cpp +++ b/plugins/AVS/src/image_utils.cpp @@ -319,7 +319,7 @@ BOOL MakeTransparentBkg(MCONTACT hContact, HBITMAP *hBitmap) GetObject(*hBitmap, sizeof(bmp), &bmp); int width = bmp.bmWidth; int height = bmp.bmHeight; - int colorDiff = db_get_w(hContact, "ContactPhoto", "TranspBkgColorDiff", db_get_w(0, AVS_MODULE, "TranspBkgColorDiff", 10)); + int colorDiff = db_get_w(hContact, "ContactPhoto", "TranspBkgColorDiff", g_plugin.getWord("TranspBkgColorDiff", 10)); // Min 5x5 to easy things in loop if (width <= 4 || height <= 4) @@ -414,7 +414,7 @@ BOOL MakeTransparentBkg(MCONTACT hContact, HBITMAP *hBitmap) if (foundBkg[i]) count++; - if (count < db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5))) { + if (count < db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", g_plugin.getWord("TranspBkgNumPoints", 5))) { if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); @@ -440,7 +440,7 @@ BOOL MakeTransparentBkg(MCONTACT hContact, HBITMAP *hBitmap) } if (maxCount < db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", - db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5))) { + g_plugin.getWord("TranspBkgNumPoints", 5))) { // Not enought corners with the same color if (hBmpTmp != *hBitmap) DeleteObject(hBmpTmp); free(p); @@ -480,7 +480,7 @@ BOOL MakeTransparentBkg(MCONTACT hContact, HBITMAP *hBitmap) } // Set alpha from borders - bool transpProportional = (db_get_b(NULL, AVS_MODULE, "MakeTransparencyProportionalToColorDiff", 0) != 0); + bool transpProportional = (g_plugin.getByte("MakeTransparencyProportionalToColorDiff", 0) != 0); int *stack = (int *)malloc(width * height * 2 * sizeof(int)); if (stack == nullptr) { diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 0d2827a0cb..057f69339c 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -57,7 +57,7 @@ static PLUGININFOEX pluginInfoEx = }; CMPlugin::CMPlugin() : - PLUGIN(AVS_MODULE, pluginInfoEx) + PLUGIN(MODULENAME, pluginInfoEx) {} ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 2558fe9626..057098a607 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -114,7 +114,7 @@ static void SetProtoPic(protoPicCacheEntry *pce) wchar_t szNewPath[MAX_PATH]; PathToRelativeW(FileName, szNewPath, g_szDataPath); - db_set_ws(NULL, PPICT_MODULE, pce->szProtoname, szNewPath); + db_set_ws(0, PPICT_MODULE, pce->szProtoname, szNewPath); switch(pce->cacheType) { case PCE_TYPE_GLOBAL: @@ -171,16 +171,16 @@ static INT_PTR CALLBACK DlgProcOptionsAvatars(HWND hwndDlg, UINT msg, WPARAM wPa case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_SHOWWARNINGS, db_get_b(0, AVS_MODULE, "warnings", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MAKE_GRAYSCALE, db_get_b(0, AVS_MODULE, "MakeGrayscale", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MAKE_TRANSPARENT_BKG, db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_MAKE_TRANSP_PROPORTIONAL, db_get_b(0, AVS_MODULE, "MakeTransparencyProportionalToColorDiff", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SHOWWARNINGS, g_plugin.getByte("warnings", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MAKE_GRAYSCALE, g_plugin.getByte("MakeGrayscale", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MAKE_TRANSPARENT_BKG, g_plugin.getByte("MakeTransparentBkg", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MAKE_TRANSP_PROPORTIONAL, g_plugin.getByte("MakeTransparencyProportionalToColorDiff", 0) ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETRANGE, 0, MAKELONG(8, 2)); - SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5)); + SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETPOS, 0, g_plugin.getWord("TranspBkgNumPoints", 5)); SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETRANGE, 0, MAKELONG(100, 0)); - SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(0, AVS_MODULE, "TranspBkgColorDiff", 10)); + SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETPOS, 0, g_plugin.getWord("TranspBkgColorDiff", 10)); { BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_MAKE_TRANSPARENT_BKG); EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_NUM_POINTS_L), enabled); @@ -195,8 +195,7 @@ static INT_PTR CALLBACK DlgProcOptionsAvatars(HWND hwndDlg, UINT msg, WPARAM wPa return TRUE; case WM_COMMAND: - if ((LOWORD(wParam) == IDC_BKG_NUM_POINTS || LOWORD(wParam) == IDC_BKG_COLOR_DIFFERENCE) - && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) + if ((LOWORD(wParam) == IDC_BKG_NUM_POINTS || LOWORD(wParam) == IDC_BKG_COLOR_DIFFERENCE) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return FALSE; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; @@ -218,12 +217,12 @@ static INT_PTR CALLBACK DlgProcOptionsAvatars(HWND hwndDlg, UINT msg, WPARAM wPa case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - db_set_b(NULL, AVS_MODULE, "warnings", IsDlgButtonChecked(hwndDlg, IDC_SHOWWARNINGS) ? 1 : 0); - db_set_b(NULL, AVS_MODULE, "MakeGrayscale", IsDlgButtonChecked(hwndDlg, IDC_MAKE_GRAYSCALE) ? 1 : 0); - db_set_b(NULL, AVS_MODULE, "MakeTransparentBkg", IsDlgButtonChecked(hwndDlg, IDC_MAKE_TRANSPARENT_BKG) ? 1 : 0); - db_set_b(NULL, AVS_MODULE, "MakeTransparencyProportionalToColorDiff", IsDlgButtonChecked(hwndDlg, IDC_MAKE_TRANSP_PROPORTIONAL) ? 1 : 0); - db_set_w(NULL, AVS_MODULE, "TranspBkgNumPoints", (WORD)SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_GETPOS, 0, 0)); - db_set_w(NULL, AVS_MODULE, "TranspBkgColorDiff", (WORD)SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_GETPOS, 0, 0)); + g_plugin.setByte("warnings", IsDlgButtonChecked(hwndDlg, IDC_SHOWWARNINGS) ? 1 : 0); + g_plugin.setByte("MakeGrayscale", IsDlgButtonChecked(hwndDlg, IDC_MAKE_GRAYSCALE) ? 1 : 0); + g_plugin.setByte("MakeTransparentBkg", IsDlgButtonChecked(hwndDlg, IDC_MAKE_TRANSPARENT_BKG) ? 1 : 0); + g_plugin.setByte("MakeTransparencyProportionalToColorDiff", IsDlgButtonChecked(hwndDlg, IDC_MAKE_TRANSP_PROPORTIONAL) ? 1 : 0); + g_plugin.setWord("TranspBkgNumPoints", (WORD)SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_GETPOS, 0, 0)); + g_plugin.setWord("TranspBkgColorDiff", (WORD)SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_GETPOS, 0, 0)); } } break; @@ -239,8 +238,8 @@ static INT_PTR CALLBACK DlgProcOptionsOwn(HWND hwndDlg, UINT msg, WPARAM, LPARAM case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_MAKE_MY_AVATARS_TRANSP, db_get_b(0, AVS_MODULE, "MakeMyAvatarsTransparent", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SET_MAKE_SQUARE, db_get_b(0, AVS_MODULE, "SetAllwaysMakeSquare", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_MAKE_MY_AVATARS_TRANSP, g_plugin.getByte("MakeMyAvatarsTransparent", 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SET_MAKE_SQUARE, g_plugin.getByte("SetAllwaysMakeSquare", 0) ? BST_CHECKED : BST_UNCHECKED); return TRUE; @@ -253,8 +252,8 @@ static INT_PTR CALLBACK DlgProcOptionsOwn(HWND hwndDlg, UINT msg, WPARAM, LPARAM case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - db_set_b(NULL, AVS_MODULE, "MakeMyAvatarsTransparent", IsDlgButtonChecked(hwndDlg, IDC_MAKE_MY_AVATARS_TRANSP) ? 1 : 0); - db_set_b(NULL, AVS_MODULE, "SetAllwaysMakeSquare", IsDlgButtonChecked(hwndDlg, IDC_SET_MAKE_SQUARE) ? 1 : 0); + g_plugin.setByte("MakeMyAvatarsTransparent", IsDlgButtonChecked(hwndDlg, IDC_MAKE_MY_AVATARS_TRANSP) ? 1 : 0); + g_plugin.setByte("SetAllwaysMakeSquare", IsDlgButtonChecked(hwndDlg, IDC_SET_MAKE_SQUARE) ? 1 : 0); } } break; @@ -313,7 +312,7 @@ static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wPar int newItem = ListView_InsertItem(hwndList, &item); if (newItem >= 0) ListView_SetCheckState(hwndList, newItem, - db_get_b(NULL, AVS_MODULE, p->szProtoname, 1) ? TRUE : FALSE); + g_plugin.getByte(p->szProtoname, 1) ? TRUE : FALSE); } ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE); ListView_Arrange(hwndList, LVA_ALIGNLEFT | LVA_ALIGNTOP); @@ -410,7 +409,7 @@ static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wPar for (int i = 0; i < ListView_GetItemCount(hwndList); i++) { auto *pce = GetProtoFromList(hwndDlg, i); - BOOL oldVal = db_get_b(NULL, AVS_MODULE, pce->szProtoname, 1); + BOOL oldVal = g_plugin.getByte(pce->szProtoname, 1); BOOL newVal = ListView_GetCheckState(hwndList, i); if (oldVal && !newVal) @@ -418,9 +417,9 @@ static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wPar DeleteAvatarFromCache(hContact, TRUE); if (newVal) - db_set_b(NULL, AVS_MODULE, pce->szProtoname, 1); + g_plugin.setByte(pce->szProtoname, 1); else - db_set_b(NULL, AVS_MODULE, pce->szProtoname, 0); + g_plugin.setByte(pce->szProtoname, 0); } } } @@ -433,9 +432,9 @@ static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wPar static void LoadTransparentData(HWND hwndDlg, MCONTACT hContact) { - CheckDlgButton(hwndDlg, IDC_MAKETRANSPBKG, db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0)) ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5))); - SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(hContact, "ContactPhoto", "TranspBkgColorDiff", db_get_w(0, AVS_MODULE, "TranspBkgColorDiff", 10))); + CheckDlgButton(hwndDlg, IDC_MAKETRANSPBKG, db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", g_plugin.getByte("MakeTransparentBkg", 0)) ? BST_CHECKED : BST_UNCHECKED); + SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", g_plugin.getWord("TranspBkgNumPoints", 5))); + SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(hContact, "ContactPhoto", "TranspBkgColorDiff", g_plugin.getWord("TranspBkgColorDiff", 10))); BOOL transp_enabled = IsDlgButtonChecked(hwndDlg, IDC_MAKETRANSPBKG); EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_NUM_POINTS_L), transp_enabled); @@ -449,19 +448,19 @@ static void LoadTransparentData(HWND hwndDlg, MCONTACT hContact) static void SaveTransparentData(HWND hwndDlg, MCONTACT hContact) { BOOL transp = IsDlgButtonChecked(hwndDlg, IDC_MAKETRANSPBKG); - if (db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0) == transp) + if (g_plugin.getByte("MakeTransparentBkg", 0) == transp) db_unset(hContact, "ContactPhoto", "MakeTransparentBkg"); else db_set_b(hContact, "ContactPhoto", "MakeTransparentBkg", transp); WORD tmp = (WORD)SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_GETPOS, 0, 0); - if (db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5) == tmp) + if (g_plugin.getWord("TranspBkgNumPoints", 5) == tmp) db_unset(hContact, "ContactPhoto", "TranspBkgNumPoints"); else db_set_w(hContact, "ContactPhoto", "TranspBkgNumPoints", tmp); tmp = (WORD)SendDlgItemMessage(hwndDlg, IDC_BKG_COLOR_DIFFERENCE_SPIN, UDM_GETPOS, 0, 0); - if (db_get_w(0, AVS_MODULE, "TranspBkgColorDiff", 10) == tmp) + if (g_plugin.getWord("TranspBkgColorDiff", 10) == tmp) db_unset(hContact, "ContactPhoto", "TranspBkgColorDiff"); else db_set_w(hContact, "ContactPhoto", "TranspBkgColorDiff", tmp); @@ -917,7 +916,7 @@ static void EnableDisableControls(HWND hwndDlg, char *proto) else { EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE); - if (db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1)) + if (g_plugin.getByte("GlobalUserAvatarNotConsistent", 1)) EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); else { int width, height; @@ -1025,7 +1024,7 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP ListView_Arrange(hwndList, LVA_ALIGNLEFT | LVA_ALIGNTOP); // Check if should show per protocol avatars - CheckDlgButton(hwndDlg, IDC_PER_PROTO, db_get_b(NULL, AVS_MODULE, "PerProtocolUserAvatars", 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PER_PROTO, g_plugin.getByte("PerProtocolUserAvatars", 1) ? BST_CHECKED : BST_UNCHECKED); EnableDisableProtocols(hwndDlg, TRUE); } break; @@ -1086,7 +1085,7 @@ static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wP break; case IDC_PER_PROTO: - db_set_b(NULL, AVS_MODULE, "PerProtocolUserAvatars", IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO) ? 1 : 0); + g_plugin.setByte("PerProtocolUserAvatars", IsDlgButtonChecked(hwndDlg, IDC_PER_PROTO) ? 1 : 0); EnableDisableProtocols(hwndDlg, FALSE); break; } @@ -1109,7 +1108,7 @@ int OnDetailsInit(WPARAM wParam, LPARAM lParam) } else { char *szProto = GetContactProto(hContact); - if (szProto == nullptr || db_get_b(NULL, AVS_MODULE, szProto, 1)) { + if (szProto == nullptr || g_plugin.getByte(szProto, 1)) { // Contact dialog odp.pfnDlgProc = DlgProcAvatarUserInfo; odp.position = -2000000000; diff --git a/plugins/AVS/src/poll.cpp b/plugins/AVS/src/poll.cpp index c004765f03..90f2e614ce 100644 --- a/plugins/AVS/src/poll.cpp +++ b/plugins/AVS/src/poll.cpp @@ -81,7 +81,7 @@ static BOOL PollProtocolCanHaveAvatar(const char *szProto) // Return true if this protocol has to be checked static BOOL PollCheckProtocol(const char *szProto) { - return db_get_b(NULL, AVS_MODULE, szProto, 1); + return g_plugin.getByte(szProto, 1); } // Return true if this contact can have avatar requested @@ -156,7 +156,7 @@ void ProcessAvatarInfo(MCONTACT hContact, int type, PROTO_AVATAR_INFORMATION *pa else if (type == GAIR_NOAVATAR) { db_unset(hContact, "ContactPhoto", "NeedUpdate"); - if (db_get_b(NULL, AVS_MODULE, "RemoveAvatarWhenContactRemoves", 1)) { + if (g_plugin.getByte("RemoveAvatarWhenContactRemoves", 1)) { // Delete settings db_unset(hContact, "ContactPhoto", "RFile"); if (!db_get_b(hContact, "ContactPhoto", "Locked", 0)) diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp index 7a4b80faf2..b31702457b 100644 --- a/plugins/AVS/src/services.cpp +++ b/plugins/AVS/src/services.cpp @@ -205,9 +205,9 @@ static int InternalRemoveMyAvatar(char *protocol) if (ret == 0) { // Has global avatar? DBVARIANT dbv = { 0 }; - if (!db_get_ws(NULL, AVS_MODULE, "GlobalUserAvatarFile", &dbv)) { + if (!g_plugin.getWString("GlobalUserAvatarFile", &dbv)) { db_free(&dbv); - db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); + g_plugin.setByte("GlobalUserAvatarNotConsistent", 1); DeleteGlobalUserAvatar(); } } @@ -229,9 +229,9 @@ static int InternalRemoveMyAvatar(char *protocol) DeleteGlobalUserAvatar(); if (ret) - db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); + g_plugin.setByte("GlobalUserAvatarNotConsistent", 1); else - db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 0); + g_plugin.setByte("GlobalUserAvatarNotConsistent", 0); } SetIgnoreNotify(protocol, FALSE); @@ -502,7 +502,7 @@ static int InternalSetMyAvatar(char *protocol, wchar_t *szFinalName, SetMyAvatar ret = SetProtoMyAvatar(protocol, hBmp, szFinalName, format, data.square, data.grow); if (ret == 0) { DeleteGlobalUserAvatar(); - db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); + g_plugin.setByte("GlobalUserAvatarNotConsistent", 1); } } else { @@ -521,7 +521,7 @@ static int InternalSetMyAvatar(char *protocol, wchar_t *szFinalName, SetMyAvatar DeleteGlobalUserAvatar(); if (ret) - db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); + g_plugin.setByte("GlobalUserAvatarNotConsistent", 1); else { // Copy avatar file to store as global one wchar_t globalFile[1024]; @@ -558,13 +558,13 @@ static int InternalSetMyAvatar(char *protocol, wchar_t *szFinalName, SetMyAvatar if (saved) { wchar_t relFile[1024]; if (PathToRelativeW(globalFile, relFile, g_szDataPath)) - db_set_ws(NULL, AVS_MODULE, "GlobalUserAvatarFile", relFile); + g_plugin.setWString("GlobalUserAvatarFile", relFile); else - db_set_ws(NULL, AVS_MODULE, "GlobalUserAvatarFile", globalFile); + g_plugin.setWString("GlobalUserAvatarFile", globalFile); - db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 0); + g_plugin.setByte("GlobalUserAvatarNotConsistent", 0); } - else db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); + else g_plugin.setByte("GlobalUserAvatarNotConsistent", 1); } } @@ -614,7 +614,7 @@ INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam) allAcceptSWF = allAcceptSWF && Proto_IsAvatarFormatSupported(it->szModuleName, PA_FORMAT_SWF); } - data.square = db_get_b(0, AVS_MODULE, "SetAllwaysMakeSquare", 0); + data.square = g_plugin.getByte("SetAllwaysMakeSquare", 0); } else { allAcceptXML = Proto_IsAvatarFormatSupported(protocol, PA_FORMAT_XML); @@ -622,7 +622,7 @@ INT_PTR SetMyAvatar(WPARAM wParam, LPARAM lParam) data.protocol = protocol; data.square = (Proto_AvatarImageProportion(protocol) & PIP_SQUARE) - || db_get_b(0, AVS_MODULE, "SetAllwaysMakeSquare", 0); + || g_plugin.getByte("SetAllwaysMakeSquare", 0); } if (tszPath == nullptr) { @@ -710,7 +710,7 @@ INT_PTR DrawAvatarPicture(WPARAM, LPARAM lParam) if (r->szProto == nullptr) return 0; - if (r->szProto[0] == '\0' && db_get_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1)) + if (r->szProto[0] == '\0' && g_plugin.getByte("GlobalUserAvatarNotConsistent", 1)) return -1; ace = (AVATARCACHEENTRY *)GetMyAvatar(0, (LPARAM)r->szProto); diff --git a/plugins/AVS/src/stdafx.h b/plugins/AVS/src/stdafx.h index f9911c6f6a..0caf8837ac 100644 --- a/plugins/AVS/src/stdafx.h +++ b/plugins/AVS/src/stdafx.h @@ -57,6 +57,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SHVIEW_THUMBNAIL 0x702D #endif +#define MODULENAME "AVS_Settings" // db settings module path +#define PPICT_MODULE "AVS_ProtoPics" // protocol pictures are saved here + struct CMPlugin : public PLUGIN { CMPlugin(); diff --git a/plugins/AVS/src/utils.cpp b/plugins/AVS/src/utils.cpp index 2c809a53d0..4e1d9ea226 100644 --- a/plugins/AVS/src/utils.cpp +++ b/plugins/AVS/src/utils.cpp @@ -79,7 +79,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz if (szProto == nullptr) { char *proto = GetContactProto(hContact); - if (proto == nullptr || !db_get_b(NULL, AVS_MODULE, proto, 1)) + if (proto == nullptr || !g_plugin.getByte(proto, 1)) return -1; if (db_get_b(hContact, "ContactPhoto", "Locked", 0) && (tszValue = db_get_wsa(hContact, "ContactPhoto", "Backup"))) @@ -114,7 +114,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz // startup and everytime they are changed. if (szProto[0] == '\0') { // Global avatar - if (tszValue = db_get_wsa(NULL, AVS_MODULE, "GlobalUserAvatarFile")) + if (tszValue = g_plugin.getWStringA("GlobalUserAvatarFile")) MyPathToAbsolute(tszValue, tszFilename); else return -10; @@ -164,7 +164,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz ace->bmHeight = bminfo.bmHeight; ace->bmWidth = bminfo.bmWidth; - BOOL noTransparency = db_get_b(0, AVS_MODULE, "RemoveAllTransparency", 0); + BOOL noTransparency = g_plugin.getByte("RemoveAllTransparency", 0); // Calc image hash if (hContact != 0 && hContact != INVALID_CONTACT_ID) { @@ -179,7 +179,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz } // Make transparent? - if (!noTransparency && !isTransparentImage && db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0))) { + if (!noTransparency && !isTransparentImage && db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", g_plugin.getByte("MakeTransparentBkg", 0))) { if (MakeTransparentBkg(hContact, &ace->hbmPic)) { ace->dwFlags |= AVS_CUSTOMTRANSPBKG | AVS_HASTRANSPARENCY; GetObject(ace->hbmPic, sizeof(bminfo), &bminfo); @@ -188,7 +188,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz } } else if (hContact == INVALID_CONTACT_ID) { // My avatars - if (!noTransparency && !isTransparentImage && db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0) && db_get_b(0, AVS_MODULE, "MakeMyAvatarsTransparent", 0)) { + if (!noTransparency && !isTransparentImage && g_plugin.getByte("MakeTransparentBkg", 0) && g_plugin.getByte("MakeMyAvatarsTransparent", 0)) { if (MakeTransparentBkg(0, &ace->hbmPic)) { ace->dwFlags |= AVS_CUSTOMTRANSPBKG | AVS_HASTRANSPARENCY; GetObject(ace->hbmPic, sizeof(bminfo), &bminfo); @@ -197,7 +197,7 @@ int CreateAvatarInCache(MCONTACT hContact, AVATARCACHEENTRY *ace, const char *sz } } - if (db_get_b(0, AVS_MODULE, "MakeGrayscale", 0)) + if (g_plugin.getByte("MakeGrayscale", 0)) ace->hbmPic = MakeGrayscale(ace->hbmPic); if (noTransparency) { @@ -428,7 +428,7 @@ int ChangeAvatar(MCONTACT hContact, bool fLoad, bool fNotifyHist, int pa_format) void DeleteGlobalUserAvatar() { DBVARIANT dbv = { 0 }; - if (db_get_ws(NULL, AVS_MODULE, "GlobalUserAvatarFile", &dbv)) + if (g_plugin.getWString("GlobalUserAvatarFile", &dbv)) return; wchar_t szFilename[MAX_PATH]; @@ -436,7 +436,7 @@ void DeleteGlobalUserAvatar() db_free(&dbv); DeleteFile(szFilename); - db_unset(NULL, AVS_MODULE, "GlobalUserAvatarFile"); + g_plugin.delSetting("GlobalUserAvatarFile"); } void SetIgnoreNotify(char *protocol, BOOL ignore) -- cgit v1.2.3