diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-04-23 08:16:58 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-04-23 08:16:58 +0000 |
commit | 36ac355b3009665069258c76f9ce8b7f7229ece9 (patch) | |
tree | 0d7f059ab35c0901b29bcdfb8a9417dc73a89192 /plugins/SimpleAR | |
parent | 5b5cdb2ff09867ac166b8bc451432608859e68d5 (diff) |
fixed #322
git-svn-id: http://svn.miranda-ng.org/main/trunk@4510 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SimpleAR')
-rw-r--r-- | plugins/SimpleAR/src/Common.h | 6 | ||||
-rw-r--r-- | plugins/SimpleAR/src/Main.cpp | 39 | ||||
-rw-r--r-- | plugins/SimpleAR/src/Options.cpp | 34 |
3 files changed, 42 insertions, 37 deletions
diff --git a/plugins/SimpleAR/src/Common.h b/plugins/SimpleAR/src/Common.h index 80c18c0d60..7eb0b069d7 100644 --- a/plugins/SimpleAR/src/Common.h +++ b/plugins/SimpleAR/src/Common.h @@ -23,8 +23,8 @@ //General
extern HINSTANCE hinstance;
-extern BOOL fEnabled;
extern INT interval;
-extern TCHAR* ptszDefaultMsg[6];
+extern TCHAR *ptszDefaultMsg[6];
+extern HGENMENU hEnableMenu;
-extern INT OptInit(WPARAM wParam,LPARAM lParam);
+extern INT OptInit(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index 94032d97d8..c92b2aeabb 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -20,7 +20,7 @@ HINSTANCE hinstance; HANDLE hPreBuildHook = NULL, hAddEventHook = NULL, hOptHook = NULL, hCheckDefHook = NULL, hOnPreShutdown = NULL, hToggleEnable = NULL, hToggleAutoanswer = NULL;
HGENMENU hToggle, hEnableMenu;
-BOOL fEnabled, gbVarsServiceExist = FALSE;
+BOOL gbVarsServiceExist = FALSE;
INT interval;
int hLangpack;
@@ -60,17 +60,13 @@ BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) INT_PTR ToggleEnable(WPARAM wParam, LPARAM lParam)
{
+ BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1);
+ db_set_b(NULL, protocolname, KEY_ENABLED, !fEnabled);
+
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_NAME|CMIM_ICON|CMIF_TCHAR;
- fEnabled = !fEnabled;
- if (fEnabled) {
- mi.ptszName = LPGENT("Disable Auto&reply");
- mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON));
- }
- else {
- mi.ptszName = LPGENT("Enable Auto&reply");
- mi.hIcon = LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF));
- }
+ mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR;
+ mi.ptszName = !fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply");
+ mi.hIcon = !fEnabled ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON));
Menu_ModifyItem(hEnableMenu, &mi);
return 0;
}
@@ -78,13 +74,12 @@ INT_PTR ToggleEnable(WPARAM wParam, LPARAM lParam) INT_PTR Toggle(WPARAM w, LPARAM l)
{
HANDLE hContact = (HANDLE)w;
- BOOL on = 0;
- on = !db_get_b(hContact, protocolname, "TurnedOn", 0);
- db_set_b(hContact, protocolname, "TurnedOn", on ? 1 : 0);
- on = on?0:1;
+ BOOL on = !db_get_b(hContact, protocolname, "TurnedOn", 0);
+ db_set_b(hContact, protocolname, "TurnedOn", on);
+ on = !on;
CLISTMENUITEM mi = { sizeof(mi) };
- mi.flags = CMIM_NAME |CMIM_ICON | CMIF_TCHAR;
+ mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR;
mi.ptszName = on ? LPGENT("Turn off Autoanswer") : LPGENT("Turn on Autoanswer");
mi.hIcon = on ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON));
Menu_ModifyItem(hToggle, &mi);
@@ -99,7 +94,7 @@ INT OnPreBuildContactMenu(WPARAM w, LPARAM l) mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR;
BOOL on = !db_get_b(hContact, protocolname, "TurnedOn", 0);
mi.ptszName = on ? LPGENT("Turn off Autoanswer") : LPGENT("Turn on Autoanswer");
- mi.hIcon = on?LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)):LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON));
+ mi.hIcon = on ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON));
Menu_ModifyItem(hToggle, &mi);
return 0;
}
@@ -112,7 +107,6 @@ INT CheckDefaults(WPARAM, LPARAM) UnhookEvent(hCheckDefHook);
- fEnabled=!db_get_b(NULL,protocolname,KEY_ENABLED,1)==1;
interval=db_get_w(NULL,protocolname,KEY_REPEATINTERVAL,300);
if (db_get_ts(NULL,protocolname,KEY_HEADING,&dbv))
@@ -146,7 +140,13 @@ INT CheckDefaults(WPARAM, LPARAM) if (ServiceExists(MS_VARS_FORMATSTRING))
gbVarsServiceExist = TRUE;
- ToggleEnable(0,0);
+ BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1);
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR;
+ mi.ptszName = fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply");
+ mi.hIcon = fEnabled ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON));
+ Menu_ModifyItem(hEnableMenu, &mi);
+
return 0;
}
@@ -188,6 +188,7 @@ INT addEvent(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam;
HANDLE hDBEvent = (HANDLE)lParam;
+ BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1);
if (!fEnabled || !hContact || !hDBEvent)
return FALSE; /// unspecifyed error
diff --git a/plugins/SimpleAR/src/Options.cpp b/plugins/SimpleAR/src/Options.cpp index 41a0a5f1f0..59aa4587df 100644 --- a/plugins/SimpleAR/src/Options.cpp +++ b/plugins/SimpleAR/src/Options.cpp @@ -87,18 +87,21 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara {
case PSN_APPLY:
{
- INT size;
TCHAR ptszText[1024];
- char szStatus[6]={0};
BOOL translated;
- fEnabled=IsDlgButtonChecked(hwndDlg,IDC_ENABLEREPLIER)==1;
- db_set_b(NULL,protocolname,KEY_ENABLED,(BYTE)fEnabled);
+ BOOL fEnabled = IsDlgButtonChecked(hwndDlg, IDC_ENABLEREPLIER) == 1;
+ db_set_b(NULL, protocolname, KEY_ENABLED, (BYTE)fEnabled);
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_NAME | CMIM_ICON | CMIF_TCHAR;
+ mi.ptszName = fEnabled ? LPGENT("Disable Auto&reply") : LPGENT("Enable Auto&reply");
+ mi.hIcon = fEnabled ? LoadIcon(hinstance, MAKEINTRESOURCE(IDI_ON)) : LoadIcon(hinstance, MAKEINTRESOURCE(IDI_OFF));
+ Menu_ModifyItem(hEnableMenu, &mi);
- GetDlgItemText(hwndDlg,IDC_HEADING,ptszText,SIZEOF(ptszText));
- db_set_ts(NULL,protocolname,KEY_HEADING,ptszText);
+ GetDlgItemText(hwndDlg, IDC_HEADING, ptszText, SIZEOF(ptszText));
+ db_set_ts(NULL, protocolname, KEY_HEADING, ptszText);
- size=GetDlgItemInt(hwndDlg,IDC_INTERVAL,&translated,FALSE);
+ INT size = GetDlgItemInt(hwndDlg, IDC_INTERVAL, &translated, FALSE);
if (translated)
interval=size*60;
db_set_w(NULL,protocolname,KEY_REPEATINTERVAL,interval);
@@ -112,14 +115,15 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara continue;
else
{
- mir_snprintf(szStatus,SIZEOF(szStatus),"%d",c);
-
- if (c<40077 && ptszMessage[c-ID_STATUS_ONLINE-1])
- db_set_ts(NULL,protocolname,szStatus,ptszMessage[c-ID_STATUS_ONLINE-1]);
- else if (c>40078 && ptszMessage[c-ID_STATUS_ONLINE-3])
- db_set_ts(NULL,protocolname,szStatus,ptszMessage[c-ID_STATUS_ONLINE-3]);
- else
- db_unset(NULL,protocolname,szStatus);
+ char szStatus[6] = {0};
+ mir_snprintf(szStatus, SIZEOF(szStatus), "%d", c);
+
+ if (c<40077 && ptszMessage[c-ID_STATUS_ONLINE-1])
+ db_set_ts(NULL,protocolname,szStatus,ptszMessage[c-ID_STATUS_ONLINE-1]);
+ else if (c>40078 && ptszMessage[c-ID_STATUS_ONLINE-3])
+ db_set_ts(NULL,protocolname,szStatus,ptszMessage[c-ID_STATUS_ONLINE-3]);
+ else
+ db_unset(NULL,protocolname,szStatus);
}
}
return TRUE;
|