summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/ExternalAPI/m_flags.h2
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flags.cpp12
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flags.h2
-rw-r--r--plugins/UserInfoEx/src/init.cpp4
-rw-r--r--plugins/UserInfoEx/src/psp_options.cpp269
-rw-r--r--plugins/UserInfoEx/src/psp_options.h9
-rw-r--r--plugins/UserInfoEx/src/stdafx.h3
7 files changed, 87 insertions, 214 deletions
diff --git a/plugins/ExternalAPI/m_flags.h b/plugins/ExternalAPI/m_flags.h
index 663e61ccbd..6a58cf3e13 100644
--- a/plugins/ExternalAPI/m_flags.h
+++ b/plugins/ExternalAPI/m_flags.h
@@ -79,9 +79,7 @@ or 0xFFFF on failure (MS_UTILS_GETCOUNTRYBYNUMBER returns "Unknown" for this).
#define MS_FLAGS_GETCONTACTORIGINCOUNTRY "Flags/GetContactOriginCountry" //for beta version 0.1.1.0
#if !defined(FLAGS_NOSETTINGS)
-#define SETTING_SHOWSTATUSICONFLAG_DEFAULT 1
#define SETTING_SHOWEXTRAIMGFLAG_DEFAULT 1
-#define SETTING_USEUNKNOWNFLAG_DEFAULT 1
#define SETTING_USEIPTOCOUNTRY_DEFAULT 1
#endif
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
index e7054db2cc..590a95d6a3 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp
+++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
@@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define M_ENABLE_SUBCTLS (WM_APP+1)
-bool g_bUseUnknownFlag = false, g_bShowStatusIconFlag = false;
-
/* Misc */
int nCountriesCount;
struct CountryListEntry *countries;
@@ -69,7 +67,7 @@ static void CALLBACK SetExtraImage(LPARAM lParam)
{
/* get contact's country */
int countryNumber = ServiceDetectContactOriginCountry(lParam, 0);
- ExtraIcon_SetIcon(hExtraIconSvc, lParam, (countryNumber != 0xFFFF || g_bUseUnknownFlag) ? LoadFlagHandle(countryNumber) : nullptr);
+ ExtraIcon_SetIcon(hExtraIconSvc, lParam, (countryNumber != 0xFFFF || g_plugin.bUseUnknownFlag) ? LoadFlagHandle(countryNumber) : nullptr);
}
static int OnCListApplyIcons(WPARAM wParam, LPARAM)
@@ -97,7 +95,7 @@ MsgWndData::~MsgWndData()
void MsgWndData::FlagsIconSet()
{
- if (!g_bShowStatusIconFlag || (m_countryID == 0xFFFF && !g_bUseUnknownFlag))
+ if (!g_plugin.bShowStatusIconFlag || (m_countryID == 0xFFFF && !g_plugin.bUseUnknownFlag))
Srmm_SetIconFlags(m_hContact, MODNAMEFLAGS, 0, MBF_HIDDEN);
else {
char *szTooltip = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, m_countryID, 0);
@@ -197,10 +195,6 @@ void SvcFlagsLoadModule()
InitIcons(); /* load in iconlib */
CreateServiceFunction(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY, ServiceDetectContactOriginCountry);
-
- // init settings
- g_bUseUnknownFlag = db_get_b(0, MODNAMEFLAGS, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
- g_bShowStatusIconFlag = db_get_b(0, MODNAMEFLAGS, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
HookEvent(ME_SKIN_ICONSCHANGED, OnStatusIconsChanged);
@@ -227,7 +221,7 @@ void SvcFlagsOnModulesLoaded()
/* Status Icon */
StatusIconData sid = {};
sid.szModule = MODNAMEFLAGS;
- if (!g_bShowStatusIconFlag)
+ if (!g_plugin.bShowStatusIconFlag)
sid.flags = MBF_HIDDEN;
Srmm_AddIcon(&sid, &g_plugin);
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.h b/plugins/UserInfoEx/src/Flags/svc_flags.h
index 8de5096e1f..3bd57648ca 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flags.h
+++ b/plugins/UserInfoEx/src/Flags/svc_flags.h
@@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EXTRAIMAGE_REFRESHDELAY 100 /* time for which setting changes are buffered */
#define STATUSICON_REFRESHDELAY 100 /* time for which setting changes are buffered */
-extern bool g_bUseUnknownFlag, g_bShowStatusIconFlag;
-
struct MsgWndData
{
MCONTACT m_hContact;
diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp
index 4753ffa949..508b062184 100644
--- a/plugins/UserInfoEx/src/init.cpp
+++ b/plugins/UserInfoEx/src/init.cpp
@@ -46,6 +46,10 @@ static PLUGININFOEX pluginInfoEx =
CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ // Common options
+ bUseUnknownFlag(MODULENAME, "UseUnknownFlag", true),
+ bShowStatusIconFlag(MODULENAME, "ShowStatusIconFlag", true),
+
// Advanced options
bCheckVersion(MODULENAME, "CheckIconPackVersion", true),
bMetaScan(MODULENAME, "MetaScan", true),
diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp
index 3ffb988525..7399537e1f 100644
--- a/plugins/UserInfoEx/src/psp_options.cpp
+++ b/plugins/UserInfoEx/src/psp_options.cpp
@@ -23,36 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PSM_ENABLE_TABITEM (WM_USER+106)
-static MenuOptionsList ctrl_Menu[] = {
- { SET_MI_MAIN, CHECK_OPT_MI_MAIN, RADIO_OPT_MI_MAIN_NONE, RADIO_OPT_MI_MAIN_ALL, RADIO_OPT_MI_MAIN_EXIMPORT },
- { SET_MI_CONTACT, CHECK_OPT_MI_CONTACT, RADIO_OPT_MI_CONTACT_NONE, RADIO_OPT_MI_CONTACT_ALL, RADIO_OPT_MI_CONTACT_EXIMPORT },
- { SET_MI_GROUP, CHECK_OPT_MI_GROUP, RADIO_OPT_MI_GROUP_NONE, RADIO_OPT_MI_GROUP_ALL, RADIO_OPT_MI_GROUP_EXIMPORT },
- { SET_MI_SUBGROUP, CHECK_OPT_MI_SUBGROUP, RADIO_OPT_MI_SUBGROUP_NONE, RADIO_OPT_MI_SUBGROUP_ALL, RADIO_OPT_MI_SUBGROUP_EXIMPORT },
- { SET_MI_ACCOUNT, CHECK_OPT_MI_ACCOUNT, RADIO_OPT_MI_ACCOUNT_NONE, RADIO_OPT_MI_ACCOUNT_ALL, RADIO_OPT_MI_ACCOUNT_EXIMPORT },
-};
-
-void __forceinline NotifyParentOfChange(HWND hDlg)
-{
- SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
-}
-
-int __forceinline ComboBox_FindByItemDataPtr(HWND hCombo, LPARAM pData)
-{
- int nItemIndex;
- for (nItemIndex = ComboBox_GetCount(hCombo); (nItemIndex >= 0) && (ComboBox_GetItemData(hCombo, nItemIndex) != pData); nItemIndex--);
- return nItemIndex;
-}
-
-void __forceinline ComboBox_SetCurSelByItemDataPtr(HWND hCombo, LPARAM pData)
-{
- ComboBox_SetCurSel(hCombo, ComboBox_FindByItemDataPtr(hCombo, pData));
-}
-
-void __forceinline ComboBox_AddItemWithData(HWND hCombo, LPTSTR ptszText, LPARAM pData)
-{
- ComboBox_SetItemData(hCombo, ComboBox_AddString(hCombo, TranslateW(ptszText)), pData);
-}
-
/**
* This function enables a dialog item
*
@@ -69,27 +39,6 @@ static uint8_t EnableDlgItem(HWND hDlg, const int idCtrl, uint8_t bEnabled)
}
/**
- * This function enables a list of dialog items, if they were enabled in the resource editor.
- *
- * @param hWnd - the dialog's window handle
- * @param idCtrl - the array of dialog items' identifiers
- * @param countCtrl - the number of items in the array of dialog items
- * @param bEnabled - TRUE if the item should be enabled, FALSE if disabled
- *
- * @return bEnabled
- **/
-static uint8_t InitialEnableControls(HWND hDlg, const int *idCtrl, int countCtrl, uint8_t bEnabled)
-{
- HWND hCtrl;
-
- while (countCtrl-- > 0) {
- hCtrl = GetDlgItem(hDlg, idCtrl[countCtrl]);
- EnableWindow(hCtrl, IsWindowEnabled(hCtrl) && bEnabled);
- }
- return bEnabled;
-}
-
-/**
* This function enables a list of dialog items.
*
* @param hWnd - the dialog's window handle
@@ -123,169 +72,108 @@ static uint8_t DBGetCheckBtn(HWND hDlg, const int idCtrl, LPCSTR pszSetting, uin
return val;
}
-/**
- * This function writes a byte (flag = 1) to database according to the checkstate
- * of the dialog button identified by 'idCtrl'.
- *
- * @param hWnd - the dialog's window handle
- * @param idCtrl - the dialog item's identifier
- * @param pszSetting - the setting to write the button state to
- *
- * @return checkstate
- **/
-static uint8_t DBWriteCheckBtn(HWND hDlg, const int idCtrl, LPCSTR pszSetting)
-{
- uint8_t val = IsDlgButtonChecked(hDlg, idCtrl);
- int Temp = g_plugin.getByte(pszSetting, 0);
- Temp &= ~1;
- g_plugin.setByte(pszSetting, Temp |= val);
- return val;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Common options dialog
-/**
- * This function reads a uint32_t from database and interprets it as an color value
- * to set to the color control.
- *
- * @param hWnd - the dialog's window handle
- * @param idCtrl - the dialog item's identifier
- * @param pszSetting - the setting from the database to use
- * @param bDefault - the default value to use, if no database setting exists
- *
- * @return nothing
- **/
-static void DBGetColor(HWND hDlg, const int idCtrl, LPCSTR pszSetting, uint32_t bDefault)
+struct
{
- SendDlgItemMessage(hDlg, idCtrl, CPM_SETCOLOUR, 0, g_plugin.getDword(pszSetting, bDefault));
+ LPCSTR pszKey;
+ int idCheckbox;
+ int idNONE;
+ int idALL;
+ int idEXIMPORT;
}
+static ctrl_Menu[] = {
+ { SET_MI_MAIN, CHECK_OPT_MI_MAIN, RADIO_OPT_MI_MAIN_NONE, RADIO_OPT_MI_MAIN_ALL, RADIO_OPT_MI_MAIN_EXIMPORT },
+ { SET_MI_CONTACT, CHECK_OPT_MI_CONTACT, RADIO_OPT_MI_CONTACT_NONE, RADIO_OPT_MI_CONTACT_ALL, RADIO_OPT_MI_CONTACT_EXIMPORT },
+ { SET_MI_GROUP, CHECK_OPT_MI_GROUP, RADIO_OPT_MI_GROUP_NONE, RADIO_OPT_MI_GROUP_ALL, RADIO_OPT_MI_GROUP_EXIMPORT },
+ { SET_MI_SUBGROUP, CHECK_OPT_MI_SUBGROUP, RADIO_OPT_MI_SUBGROUP_NONE, RADIO_OPT_MI_SUBGROUP_ALL, RADIO_OPT_MI_SUBGROUP_EXIMPORT },
+ { SET_MI_ACCOUNT, CHECK_OPT_MI_ACCOUNT, RADIO_OPT_MI_ACCOUNT_NONE, RADIO_OPT_MI_ACCOUNT_ALL, RADIO_OPT_MI_ACCOUNT_EXIMPORT },
+};
-/**
- * This function writes a uint32_t to database according to the value
- * of the color control identified by 'idCtrl'.
- *
- * @param hWnd - the dialog's window handle
- * @param idCtrl - the dialog item's identifier
- * @param pszSetting - the setting to write the button state to
- *
- * @return nothing
- **/
-static void DBWriteColor(HWND hDlg, const int idCtrl, LPCSTR pszSetting)
+class CCommonOptsDlg : public CDlgBase
{
- g_plugin.setDword(pszSetting, (uint32_t)SendDlgItemMessage(hDlg, idCtrl, CPM_GETCOLOUR, 0, 0));
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Common options dialog
+ CCtrlCheck chk1, chk2, chk3, chk4, chk5, chkFlagUnknown, chkStatusIcon;
-static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- static uint8_t bInitialized = 0;
+public:
+ CCommonOptsDlg() :
+ CDlgBase(g_plugin, IDD_OPT_COMMON),
+ chk1(this, CHECK_OPT_MI_MAIN),
+ chk2(this, CHECK_OPT_MI_CONTACT),
+ chk3(this, CHECK_OPT_MI_GROUP),
+ chk4(this, CHECK_OPT_MI_SUBGROUP),
+ chk5(this, CHECK_OPT_MI_ACCOUNT),
+ chkStatusIcon(this, CHECK_OPT_FLAGSMSGSTATUS),
+ chkFlagUnknown(this, CHECK_OPT_FLAGSUNKNOWN)
+ {
+ CreateLink(chkStatusIcon, g_plugin.bShowStatusIconFlag);
+ CreateLink(chkFlagUnknown, g_plugin.bUseUnknownFlag);
- switch (uMsg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hDlg);
- bInitialized = 0;
+ chk1.OnChange = chk2.OnChange = chk3.OnChange = chk4.OnChange = chk5.OnChange = Callback(this, &CCommonOptsDlg::onChange_Root);
+ }
+ bool OnInitDialog() override
+ {
// menu item settings
for (auto &it : ctrl_Menu) {
int flag = g_plugin.getByte(it.pszKey, 2);
+
// check button and enable / disable control
- int idEnable[] = { it.idCheckbox + 1, it.idNONE, it.idALL, it.idEXIMPORT };
- EnableControls(hDlg, idEnable, _countof(idEnable), DBGetCheckBtn(hDlg, it.idCheckbox, it.pszKey, 0));
+ DBGetCheckBtn(m_hwnd, it.idCheckbox, it.pszKey, 0);
+
// set radio button state
int id = it.idNONE; //default
if ((flag & 4) == 4)
id = it.idALL;
else if ((flag & 8) == 8)
id = it.idEXIMPORT;
- CheckRadioButton(hDlg, it.idNONE, it.idEXIMPORT, id);
+ CheckRadioButton(m_hwnd, it.idNONE, it.idEXIMPORT, id);
}
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ // menu item settings
+ for (auto &it : ctrl_Menu) {
+ int flag = IsDlgButtonChecked(m_hwnd, it.idCheckbox);
+ flag |= IsDlgButtonChecked(m_hwnd, it.idNONE) ? 2 : 0;
+ flag |= IsDlgButtonChecked(m_hwnd, it.idALL) ? 4 : 0;
+ flag |= IsDlgButtonChecked(m_hwnd, it.idEXIMPORT) ? 8 : 0;
+ g_plugin.setByte(it.pszKey, (uint8_t)flag);
+ }
+
+ RebuildMenu();
// extra icon settings
- CheckDlgButton(hDlg, CHECK_OPT_FLAGSUNKNOWN, g_bUseUnknownFlag ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hDlg, CHECK_OPT_FLAGSMSGSTATUS, g_bShowStatusIconFlag ? BST_CHECKED : BST_UNCHECKED);
-
- bInitialized = 1;
- return TRUE;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- // menu item settings
- for (auto &it : ctrl_Menu) {
- int flag = IsDlgButtonChecked(hDlg, it.idCheckbox);
- flag |= IsDlgButtonChecked(hDlg, it.idNONE) ? 2 : 0;
- flag |= IsDlgButtonChecked(hDlg, it.idALL) ? 4 : 0;
- flag |= IsDlgButtonChecked(hDlg, it.idEXIMPORT) ? 8 : 0;
- g_plugin.setByte(it.pszKey, (uint8_t)flag);
- }
+ bool FlagsClistChange = false, FlagsMsgWndChange = false;
- RebuildMenu();
+ if (chkFlagUnknown.IsChanged()) {
+ FlagsClistChange = true;
+ FlagsMsgWndChange = true;
+ }
- // extra icon settings
- bool FlagsClistChange = false, FlagsMsgWndChange = false;
+ if (chkStatusIcon.IsChanged())
+ FlagsMsgWndChange = true;
- bool valNew = IsDlgButtonChecked(hDlg, CHECK_OPT_FLAGSUNKNOWN) != 0;
- if (g_bUseUnknownFlag != valNew) {
- g_bUseUnknownFlag = valNew;
- db_set_b(0, MODNAMEFLAGS, "UseUnknownFlag", valNew);
- FlagsClistChange = true;
- FlagsMsgWndChange = true;
- }
- valNew = IsDlgButtonChecked(hDlg, CHECK_OPT_FLAGSMSGSTATUS) != 0;
- if (g_bShowStatusIconFlag != valNew) {
- g_bShowStatusIconFlag = valNew;
- db_set_b(0, MODNAMEFLAGS, "ShowStatusIconFlag", valNew);
- FlagsMsgWndChange = true;
- }
+ if (FlagsClistChange)
+ ExtraIcon_SetAll();
+ if (FlagsMsgWndChange)
+ UpdateStatusIcons();
+ return true;
+ }
- if (FlagsClistChange)
- ExtraIcon_SetAll();
- if (FlagsMsgWndChange)
- UpdateStatusIcons();
- }
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case CHECK_OPT_MI_MAIN:
- case CHECK_OPT_MI_CONTACT:
- case CHECK_OPT_MI_GROUP:
- case CHECK_OPT_MI_SUBGROUP:
- case CHECK_OPT_MI_ACCOUNT:
- for (auto &it : ctrl_Menu) {
- if (it.idCheckbox == LOWORD(wParam)) {
- const int idMenuItems[] = { it.idCheckbox + 1, it.idNONE, it.idALL, it.idEXIMPORT };
- EnableControls(hDlg, idMenuItems, _countof(idMenuItems), Button_GetCheck((HWND)lParam));
- break;
- }
+ void onChange_Root(CCtrlCheck *pCheck)
+ {
+ for (auto &it : ctrl_Menu) {
+ if (it.idCheckbox == pCheck->GetCtrlId()) {
+ const int idMenuItems[] = { it.idCheckbox + 1, it.idNONE, it.idALL, it.idEXIMPORT };
+ EnableControls(m_hwnd, idMenuItems, _countof(idMenuItems), pCheck->IsChecked());
+ break;
}
- if (bInitialized)
- NotifyParentOfChange(hDlg);
- break;
-
- case RADIO_OPT_MI_MAIN_ALL:
- case RADIO_OPT_MI_MAIN_NONE:
- case RADIO_OPT_MI_MAIN_EXIMPORT:
- case RADIO_OPT_MI_CONTACT_ALL:
- case RADIO_OPT_MI_CONTACT_NONE:
- case RADIO_OPT_MI_CONTACT_EXIMPORT:
- case RADIO_OPT_MI_GROUP_ALL:
- case RADIO_OPT_MI_GROUP_NONE:
- case RADIO_OPT_MI_GROUP_EXIMPORT:
- case RADIO_OPT_MI_SUBGROUP_ALL:
- case RADIO_OPT_MI_SUBGROUP_NONE:
- case RADIO_OPT_MI_SUBGROUP_EXIMPORT:
- case RADIO_OPT_MI_ACCOUNT_ALL:
- case RADIO_OPT_MI_ACCOUNT_NONE:
- case RADIO_OPT_MI_ACCOUNT_EXIMPORT:
- case CHECK_OPT_FLAGSUNKNOWN:
- case CHECK_OPT_FLAGSMSGSTATUS:
- if (bInitialized)
- NotifyParentOfChange(hDlg);
}
}
- return FALSE;
-}
+};
/////////////////////////////////////////////////////////////////////////////////////////
// Advanced options dialog
@@ -550,8 +438,8 @@ public:
{
// disable if popup plugin dos not sopport buttons inside popop
if (!(db_get_dw(0, "Popup", "Actions", 0) & 1))
- EnableDlgItem(m_hwnd, CHECK_OPT_POPUP_MSGBOX, FALSE);
-
+ chkMsgbox.Disable();
+
// set colortype checkboxes and color controls
switch (g_plugin.iBirthClrType) {
case POPUP_COLOR_DEFAULT:
@@ -715,14 +603,11 @@ int OnInitOptions(WPARAM wParam, LPARAM)
// Common page
odp.szTab.a = LPGEN("Common");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_COMMON);
- odp.pfnDlgProc = DlgProc_CommonOpts;
+ odp.pDialog = new CCommonOptsDlg();
g_plugin.addOptions(wParam, &odp);
// Advanced page
odp.szTab.a = LPGEN("Advanced");
- odp.pszTemplate = 0;
- odp.pfnDlgProc = 0;
odp.pDialog = new CAdvancedOptsDlg();
g_plugin.addOptions(wParam, &odp);
diff --git a/plugins/UserInfoEx/src/psp_options.h b/plugins/UserInfoEx/src/psp_options.h
index 0eed35b99b..ff0690fbe8 100644
--- a/plugins/UserInfoEx/src/psp_options.h
+++ b/plugins/UserInfoEx/src/psp_options.h
@@ -22,15 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _UINFOEX_OPTIONS_H_INCLUDED_
#define _UINFOEX_OPTIONS_H_INCLUDED_
-struct MenuOptionsList
-{
- LPCSTR pszKey;
- int idCheckbox;
- int idNONE;
- int idALL;
- int idEXIMPORT;
-};
-
int OnInitOptions(WPARAM, LPARAM);
#endif /* _UINFOEX_OPTIONS_H_INCLUDED_ */ \ No newline at end of file
diff --git a/plugins/UserInfoEx/src/stdafx.h b/plugins/UserInfoEx/src/stdafx.h
index ccced93f66..8475aca800 100644
--- a/plugins/UserInfoEx/src/stdafx.h
+++ b/plugins/UserInfoEx/src/stdafx.h
@@ -107,6 +107,9 @@ struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin();
+ // Common options
+ CMOption<bool> bUseUnknownFlag, bShowStatusIconFlag;
+
// Advanced options
CMOption<bool> bCheckVersion, bMetaScan, bButtonIcons, bEmailService;