summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-22 20:06:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-22 20:06:54 +0000
commitb02e4589fbe33a2f623f044c2056a831f47bbe37 (patch)
tree3307971f0da39f44dca3c7c4099a9a2e5a241e49 /plugins/UserInfoEx
parent4c940062ccbf560f057b22a9a5dabe72f17a1222 (diff)
- options setting fix;
- even that cycle is useless; git-svn-id: http://svn.miranda-ng.org/main/trunk@7344 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flags.cpp73
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flags.h13
-rw-r--r--plugins/UserInfoEx/src/init.cpp7
-rw-r--r--plugins/UserInfoEx/src/psp_options.cpp34
-rw-r--r--plugins/UserInfoEx/src/svc_email.cpp5
-rw-r--r--plugins/UserInfoEx/src/svc_gender.cpp2
-rw-r--r--plugins/UserInfoEx/src/svc_phone.cpp2
7 files changed, 66 insertions, 70 deletions
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
index 907d201e38..ed8772fdac 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp
+++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define M_ENABLE_SUBCTLS (WM_APP+1)
-FLAGSOPTIONS gFlagsOpts;
+bool g_bShowExtraImgFlag = false, g_bUseUnknownFlag = false, g_bShowStatusIconFlag = false;
/* Misc */
int nCountriesCount;
@@ -168,7 +168,7 @@ static void CALLBACK SetExtraImage(LPARAM lParam)
{
/* get contact's country */
int countryNumber = ServiceDetectContactOriginCountry(lParam, 0);
- ExtraIcon_SetIcon(hExtraIconSvc, (HANDLE)lParam, (countryNumber != 0xFFFF || gFlagsOpts.bUseUnknownFlag) ? LoadFlagHandle(countryNumber) : NULL);
+ ExtraIcon_SetIcon(hExtraIconSvc, (HANDLE)lParam, (countryNumber != 0xFFFF || g_bUseUnknownFlag) ? LoadFlagHandle(countryNumber) : NULL);
}
static int OnCListApplyIcons(WPARAM wParam, LPARAM)
@@ -177,14 +177,15 @@ static int OnCListApplyIcons(WPARAM wParam, LPARAM)
return 0;
}
-void SvcFlagsEnableExtraIcons(BYTE bColumn, BYTE bUpdateDB)
+void SvcFlagsEnableExtraIcons(bool bEnable, bool bUpdateDB)
{
- gFlagsOpts.bShowExtraImgFlag = (bColumn != ((BYTE)-1));
+ g_bShowExtraImgFlag = bEnable;
+
if (bUpdateDB)
- db_set_b(NULL, MODNAMEFLAGS, "ShowExtraImgFlag", bColumn != (BYTE)-1);
+ db_set_b(NULL, MODNAMEFLAGS, "ShowExtraImgFlag", bEnable);
// Flags is on
- if (gFlagsOpts.bShowExtraImgFlag) {
+ if (g_bShowExtraImgFlag) {
if (hExtraIconSvc == INVALID_HANDLE_VALUE) {
// get local langID for descIcon (try to use user local Flag as icon)
DWORD langid = 0;
@@ -232,7 +233,7 @@ MsgWndData::~MsgWndData()
void MsgWndData::FlagsIconSet()
{
/* ensure status icon is registered */
- if (m_countryID != 0xFFFF || gFlagsOpts.bUseUnknownFlag) {
+ if (m_countryID != 0xFFFF || g_bUseUnknownFlag) {
StatusIconData sid = { sizeof(sid) };
sid.szModule = MODNAMEFLAGS;
sid.hIconDisabled = sid.hIcon = LoadFlagIcon(m_countryID);
@@ -350,7 +351,7 @@ static int OnMsgWndEvent(WPARAM wParam, LPARAM lParam)
//hookProc ME_SKIN2_ICONSCHANGED
static int OnStatusIconsChanged(WPARAM wParam, LPARAM lParam)
{
- if (gFlagsOpts.bShowStatusIconFlag)
+ if (g_bShowStatusIconFlag)
CallFunctionBuffered(UpdateStatusIcons, 0, FALSE, STATUSICON_REFRESHDELAY);
return 0;
}
@@ -388,12 +389,13 @@ static int OnContactSettingChanged(WPARAM wParam, LPARAM lParam)
***********************************************************************************************************/
/**
- * This function initially loads all required stuff for Flags.
- *
- * @param none
- *
- * @return nothing
- **/
+* This function initially loads all required stuff for Flags.
+*
+* @param none
+*
+* @return nothing
+**/
+
void SvcFlagsLoadModule()
{
PrepareBufferedFunctions();
@@ -401,44 +403,44 @@ void SvcFlagsLoadModule()
nCountriesCount = 0;
InitIcons(); /* load in iconlib */
- //InitIpToCountry(); /* not implementet */
CreateServiceFunction(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY, ServiceDetectContactOriginCountry);
- //init settings
- gFlagsOpts.bUseUnknownFlag = db_get_b(NULL, MODNAMEFLAGS, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT);
- gFlagsOpts.bShowExtraImgFlag = db_get_b(NULL, MODNAMEFLAGS, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT);
- gFlagsOpts.bShowStatusIconFlag = db_get_b(NULL, MODNAMEFLAGS, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT);
+ // init settings
+ g_bUseUnknownFlag = db_get_b(NULL, MODNAMEFLAGS, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
+ g_bShowExtraImgFlag = db_get_b(NULL, MODNAMEFLAGS, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT) != 0;
+ g_bShowStatusIconFlag = db_get_b(NULL, MODNAMEFLAGS, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
HookEvent(ME_SKIN2_ICONSCHANGED, OnStatusIconsChanged);
}
/**
- * This function is called by Miranda just after loading all system modules.
- *
- * @param none
- *
- * @return nothing
- **/
+* This function is called by Miranda just after loading all system modules.
+*
+* @param none
+*
+* @return nothing
+**/
+
void SvcFlagsOnModulesLoaded()
{
- SvcFlagsEnableExtraIcons(1, FALSE);
+ SvcFlagsEnableExtraIcons(true, false);
/* Status Icon */
HookEvent(ME_MSG_WINDOWEVENT, OnMsgWndEvent);
}
/**
- * This function unloads the module.
- *
- * @param none
- *
- * @return nothing
- **/
+* This function unloads the module.
+*
+* @param none
+*
+* @return nothing
+**/
+
void SvcFlagsUnloadModule()
{
KillBufferedFunctions();
- //Uninit ExtraImg
- UnhookEvent(hApplyIconHook);
+
//Uninit message winsow
for (int i = 0; i < gMsgWndList.getCount(); i++) {
//this should not happen
@@ -448,7 +450,8 @@ void SvcFlagsUnloadModule()
gMsgWndList.destroy();
gIListMW.destroy();
- //Uninit misc
+ // Uninit misc
+ UnhookEvent(hApplyIconHook);
UnhookEvent(hSettingChangedHook);
UninitIcons();
}
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.h b/plugins/UserInfoEx/src/Flags/svc_flags.h
index 64ed5a2244..3776096479 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flags.h
+++ b/plugins/UserInfoEx/src/Flags/svc_flags.h
@@ -28,14 +28,7 @@ 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 */
-struct FLAGSOPTIONS
-{
- BYTE bShowExtraImgFlag;
- BYTE bUseUnknownFlag;
- BYTE bShowStatusIconFlag;
-};
-
-extern FLAGSOPTIONS gFlagsOpts;
+extern bool g_bShowExtraImgFlag, g_bUseUnknownFlag, g_bShowStatusIconFlag;
extern bool g_eiGender, g_eiHome, g_eiEmail, g_eiPhone;
struct MsgWndData
@@ -51,7 +44,7 @@ struct MsgWndData
void FlagsIconUnset();
void FlagsIconUpdate()
{
- gFlagsOpts.bShowStatusIconFlag ? FlagsIconSet() : FlagsIconUnset();
+ g_bShowStatusIconFlag ? FlagsIconSet() : FlagsIconUnset();
}
void ContryIDchange(int ID)
{
@@ -73,7 +66,7 @@ struct IconList
typedef void (CALLBACK *BUFFEREDPROC)(LPARAM lParam);
void CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumulateSameParam, UINT uElapse);
-void SvcFlagsEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB);
+void SvcFlagsEnableExtraIcons(bool bEnable, bool bUpdateDB);
void CALLBACK UpdateStatusIcons(LPARAM lParam);
void SvcFlagsLoadModule();
diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp
index 394e2da982..b2bb2f2708 100644
--- a/plugins/UserInfoEx/src/init.cpp
+++ b/plugins/UserInfoEx/src/init.cpp
@@ -85,9 +85,6 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
SvcHomepageLoadModule();
SvcFlagsOnModulesLoaded();
- if (SvcEMailEnableExtraIcons() || SvcPhoneEnableExtraIcons() || SvcGenderEnableExtraIcons() || SvcHomepageEnableExtraIcons())
- pcli->pfnSetAllExtraIcons(0);
-
// build contact's menuitems
RebuildMenu();
HookEvent( ME_CLIST_PREBUILDSTATUSMENU, (MIRANDAHOOK)RebuildAccount);
@@ -204,6 +201,10 @@ extern "C" int __declspec(dllexport) Load(void)
SvcEMailLoadModule();
SvcRefreshContactInfoLoadModule();
+ SvcPhoneEnableExtraIcons();
+ SvcGenderEnableExtraIcons();
+ SvcHomepageEnableExtraIcons();
+
CtrlContactLoadModule();
// load my button class
CtrlButtonLoadModule();
diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp
index a79e2ea8be..b4267d85f0 100644
--- a/plugins/UserInfoEx/src/psp_options.cpp
+++ b/plugins/UserInfoEx/src/psp_options.cpp
@@ -322,8 +322,8 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam,
CheckDlgButton(hDlg, CHECK_OPT_EMAILICON, g_eiEmail);
CheckDlgButton(hDlg, CHECK_OPT_PHONEICON, g_eiPhone);
CheckDlgButton(hDlg, CHECK_OPT_HOMEPAGEICON, g_eiHome);
- CheckDlgButton(hDlg, CHECK_OPT_FLAGSUNKNOWN, gFlagsOpts.bUseUnknownFlag);
- CheckDlgButton(hDlg, CHECK_OPT_FLAGSMSGSTATUS, gFlagsOpts.bShowStatusIconFlag);
+ CheckDlgButton(hDlg, CHECK_OPT_FLAGSUNKNOWN, g_bUseUnknownFlag);
+ CheckDlgButton(hDlg, CHECK_OPT_FLAGSMSGSTATUS, g_bShowStatusIconFlag);
// misc
DBGetCheckBtn(hDlg, CHECK_OPT_ZODIACAVATAR, SET_ZODIAC_AVATARS, FALSE);
@@ -344,28 +344,26 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam,
RebuildMenu();
// extra icon settings
- BOOL FlagsClistChange = 0;
- BOOL FlagsMsgWndChange = 0;
+ bool FlagsClistChange = false, FlagsMsgWndChange = false;
- BYTE valNew = IsDlgButtonChecked(hDlg, CHECK_OPT_FLAGSUNKNOWN);
- if (gFlagsOpts.bUseUnknownFlag != valNew) {
- gFlagsOpts.bUseUnknownFlag = valNew;
+ bool valNew = IsDlgButtonChecked(hDlg, CHECK_OPT_FLAGSUNKNOWN) != 0;
+ if (g_bUseUnknownFlag != valNew) {
+ g_bUseUnknownFlag = valNew;
db_set_b(NULL, MODNAMEFLAGS, "UseUnknownFlag", valNew);
- FlagsClistChange++;
- FlagsMsgWndChange++;
+ FlagsClistChange = true;
+ FlagsMsgWndChange = true;
}
- valNew = IsDlgButtonChecked(hDlg, CHECK_OPT_FLAGSMSGSTATUS);
- if (gFlagsOpts.bShowStatusIconFlag != valNew) {
- gFlagsOpts.bShowStatusIconFlag = valNew;
+ valNew = IsDlgButtonChecked(hDlg, CHECK_OPT_FLAGSMSGSTATUS) != 0;
+ if (g_bShowStatusIconFlag != valNew) {
+ g_bShowStatusIconFlag = valNew;
db_set_b(NULL, MODNAMEFLAGS, "ShowStatusIconFlag", valNew);
- FlagsMsgWndChange++;
+ FlagsMsgWndChange = true;
}
- if (SvcHomepageEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_HOMEPAGEICON), true) ||
- SvcEMailEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_EMAILICON), true) ||
- SvcPhoneEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_PHONEICON), true) ||
- SvcGenderEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_GENDER), true))
- FlagsClistChange = true;
+ FlagsClistChange |= SvcHomepageEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_HOMEPAGEICON), true);
+ FlagsClistChange |= SvcEMailEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_EMAILICON), true);
+ FlagsClistChange |= SvcPhoneEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_PHONEICON), true);
+ FlagsClistChange |= SvcGenderEnableExtraIcons(0 != IsDlgButtonChecked(hDlg, CHECK_OPT_GENDER), true);
if (FlagsClistChange) pcli->pfnSetAllExtraIcons(NULL);
if (FlagsMsgWndChange) UpdateStatusIcons(NULL);
diff --git a/plugins/UserInfoEx/src/svc_email.cpp b/plugins/UserInfoEx/src/svc_email.cpp
index 08306415be..334b60bb49 100644
--- a/plugins/UserInfoEx/src/svc_email.cpp
+++ b/plugins/UserInfoEx/src/svc_email.cpp
@@ -215,11 +215,11 @@ bool SvcEMailEnableExtraIcons(bool bEnable, bool bUpdateDB)
if (bUpdateDB) {
bChanged = g_eiEmail != bEnable;
- db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_EMAIL, bEnable);
+ db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_EMAIL, g_eiEmail = bEnable);
}
else bChanged = g_eiEmail = db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_EMAIL, DEFVAL_CLIST_EXTRAICON_EMAIL) != 0;
- if (bEnable) { // E-mail checked
+ if (g_eiEmail) { // E-mail checked
// hook events
if (hChangedHook == NULL)
hChangedHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, (MIRANDAHOOK)OnContactSettingChanged);
@@ -250,6 +250,7 @@ bool SvcEMailEnableExtraIcons(bool bEnable, bool bUpdateDB)
void SvcEMailLoadModule()
{
+ SvcEMailEnableExtraIcons();
if (db_get_b(NULL, MODNAME, SET_EXTENDED_EMAILSERVICE, TRUE)) {
// create own email send command
if (!myDestroyServiceFunction(MS_EMAIL_SENDEMAIL))
diff --git a/plugins/UserInfoEx/src/svc_gender.cpp b/plugins/UserInfoEx/src/svc_gender.cpp
index 6e2af9cf99..75ddfdf09f 100644
--- a/plugins/UserInfoEx/src/svc_gender.cpp
+++ b/plugins/UserInfoEx/src/svc_gender.cpp
@@ -111,7 +111,7 @@ bool SvcGenderEnableExtraIcons(bool bEnable, bool bUpdateDB)
if (bUpdateDB) {
bChanged = g_eiGender != bEnable;
- db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_GENDER2, bEnable);
+ db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_GENDER2, g_eiGender = bEnable);
}
else bChanged = g_eiGender = db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_GENDER2, 0) != 0;
diff --git a/plugins/UserInfoEx/src/svc_phone.cpp b/plugins/UserInfoEx/src/svc_phone.cpp
index 5678ec946f..258cde98c1 100644
--- a/plugins/UserInfoEx/src/svc_phone.cpp
+++ b/plugins/UserInfoEx/src/svc_phone.cpp
@@ -132,7 +132,7 @@ bool SvcPhoneEnableExtraIcons(bool bEnable, bool bUpdateDB)
if (bUpdateDB) {
bChanged = g_eiPhone != bEnable;
- db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_PHONE, bEnable);
+ db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_PHONE, g_eiPhone = bEnable);
}
else bChanged = g_eiPhone = db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_PHONE, DEFVAL_CLIST_EXTRAICON_PHONE) != 0;