diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-27 13:50:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-27 13:50:53 +0000 |
commit | 5f8a607f900a42e27bf166b86185001aadf3e9f2 (patch) | |
tree | 6c69f5caebc55e84437ddc23013fada0a69af397 | |
parent | 5e0f2fb896d874f9b7f5c069a90de64305089542 (diff) |
more fun:
- MS_AWAYMSG_GETSTATUSMSGW/T is present in any MIID_SRAWAY plugin, so there's no need to check its existence;
- therefore MS_AWAYMSG_GETSTATUSMSG considered useless, cause it has no references
git-svn-id: http://svn.miranda-ng.org/main/trunk@8293 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/delphi/m_awaymsg.inc | 3 | ||||
-rw-r--r-- | include/m_awaymsg.h | 7 | ||||
-rw-r--r-- | include/m_protocols.h | 2 | ||||
-rw-r--r-- | plugins/BossKeyPlus/src/BossKey.cpp | 13 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/AwaySys.cpp | 1 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Services.cpp | 12 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Services.h | 1 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/src/main.cpp | 13 | ||||
-rw-r--r-- | plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp | 21 | ||||
-rw-r--r-- | plugins/StatusPlugins/commonstatus.cpp | 31 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_rc.cpp | 11 | ||||
-rw-r--r-- | src/core/stdautoaway/autoaway.cpp | 27 | ||||
-rw-r--r-- | src/core/stdaway/sendmsg.cpp | 89 | ||||
-rw-r--r-- | src/modules/protocols/protocols.cpp | 23 |
14 files changed, 80 insertions, 174 deletions
diff --git a/include/delphi/m_awaymsg.inc b/include/delphi/m_awaymsg.inc index 021597c8ca..9f1bf262b7 100644 --- a/include/delphi/m_awaymsg.inc +++ b/include/delphi/m_awaymsg.inc @@ -35,12 +35,11 @@ const MS_AWAYMSG_SHOWAWAYMSG:PAnsiChar = 'SRAway/GetMessage';
{
- returns: the default status message for a status
+ returns: (PWideChar) the default status message for a status
wParam=status
lParam=szProto
notes: returns status msg. Remember to free the return value
}
- MS_AWAYMSG_GETSTATUSMSG :PAnsiChar = 'SRAway/GetStatusMessage';
MS_AWAYMSG_GETSTATUSMSGW:PAnsiChar = 'SRAway/GetStatusMessageW';
{$ENDIF}
diff --git a/include/m_awaymsg.h b/include/m_awaymsg.h index 78db3428c1..981ed6055c 100644 --- a/include/m_awaymsg.h +++ b/include/m_awaymsg.h @@ -32,17 +32,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //returns immediately, without waiting for the message to retrieve
#define MS_AWAYMSG_SHOWAWAYMSG "SRAway/GetMessage"
-//returns the default status message for a status
+//returns (TCHAR*)the default status message for a status
//wParam = (int)status
//lParam = (LPARAM)(char*)szProto
-//returns status msg. Remember to free the return value
-#define MS_AWAYMSG_GETSTATUSMSG "SRAway/GetStatusMessage"
+//returns status msg. Remember to free the return value using mir_free/ptrW
#define MS_AWAYMSG_GETSTATUSMSGW "SRAway/GetStatusMessageW"
#ifdef _UNICODE
#define MS_AWAYMSG_GETSTATUSMSGT MS_AWAYMSG_GETSTATUSMSGW
#else
-#define MS_AWAYMSG_GETSTATUSMSGT MS_AWAYMSG_GETSTATUSMSG
+#define MS_AWAYMSG_GETSTATUSMSGT not implemented
#endif
#endif // M_AWAYMSG_H__
diff --git a/include/m_protocols.h b/include/m_protocols.h index b29fd4583d..67ffd950ff 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -336,7 +336,7 @@ __forceinline PROTOACCOUNT* ProtoGetAccount(const char* accName) //Returns 1 if an account is valid and enabled, 0 otherwise
#define MS_PROTO_ISACCOUNTENABLED "Proto/IsAccountEnabled"
-__forceinline int IsAccountEnabled(const PROTOACCOUNT* pa)
+__forceinline int IsAccountEnabled(const PROTOACCOUNT *pa)
{
return (int)CallService(MS_PROTO_ISACCOUNTENABLED, 0, (LPARAM)pa);
}
diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index 15c0b1b480..188e1ec57f 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -201,16 +201,7 @@ BOOL CALLBACK EnumWindowsProc(HWND hWnd,LPARAM) TCHAR* GetDefStatusMsg(unsigned uStatus, const char* szProto)
{
- INT_PTR res = CallService (MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)uStatus, (LPARAM)szProto );
- if (res == CALLSERVICE_NOTFOUND )
- {
- char* tmp = ( char* )CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)uStatus, (LPARAM)szProto );
- TCHAR *ret = mir_a2t( tmp );
- mir_free( tmp );
- return ret;
- }
- else
- return (TCHAR *) res;
+ return (TCHAR*)CallService (MS_AWAYMSG_GETSTATUSMSGT, uStatus, (LPARAM)szProto);
}
void SetStatus(const char* szProto, unsigned status, TCHAR *tszAwayMsg)
@@ -220,7 +211,7 @@ void SetStatus(const char* szProto, unsigned status, TCHAR *tszAwayMsg) if ( CallProtoService( szProto, PS_SETAWAYMSGT, status, (LPARAM) tszAwayMsg ) == CALLSERVICE_NOTFOUND )
{
char *szAwayMsg = mir_t2a(tszAwayMsg);
- CallProtoService( szProto, PS_SETAWAYMSG, status, (LPARAM) szAwayMsg );
+ CallProtoService( szProto, PS_SETAWAYMSG, status, (LPARAM)szAwayMsg );
mir_free(szAwayMsg);
}
}
diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 2ee9c2832a..bcfd76cecc 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -680,7 +680,6 @@ int MirandaLoaded(WPARAM, LPARAM) CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_ON, srvAutoreplyOn);
CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_OFF, srvAutoreplyOff);
CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_USEDEFAULT, srvAutoreplyUseDefault);
- CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, GetStatusMsg);
CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, GetStatusMsgW);
CreateServiceFunction(MS_NAS_GETSTATEA, GetStateA);
diff --git a/plugins/NewAwaySysMod/src/Services.cpp b/plugins/NewAwaySysMod/src/Services.cpp index bce50f84d3..686ad07cac 100644 --- a/plugins/NewAwaySysMod/src/Services.cpp +++ b/plugins/NewAwaySysMod/src/Services.cpp @@ -50,19 +50,11 @@ __inline void PSSetStatus(char *szProto, WORD Status, int bNoClistSetStatusMode // called by GamerStatus and built-in miranda autoaway module
// wParam = (int)status, lParam = 0
// MS_AWAYMSG_GETSTATUSMSG "SRAway/GetStatusMessage"
-INT_PTR GetStatusMsg(WPARAM wParam, LPARAM)
-{
- LogMessage("MS_AWAYMSG_GETSTATUSMSG called. status=%d", wParam);
- char *szMsg = mir_t2a(GetDynamicStatMsg(INVALID_CONTACT_ID, NULL, 0, wParam));
- LogMessage("returned szMsg:\n%s", szMsg ? szMsg : "NULL");
- return (INT_PTR)szMsg;
-}
-
INT_PTR GetStatusMsgW(WPARAM wParam, LPARAM)
{
- LogMessage("MS_AWAYMSG_GETSTATUSMSG called. status=%d", wParam);
+ LogMessage("MS_AWAYMSG_GETSTATUSMSGW called. status=%d", wParam);
WCHAR *szMsg = mir_t2u(GetDynamicStatMsg(INVALID_CONTACT_ID, NULL, 0, wParam));
- LogMessage("returned szMsg:\n%S", szMsg ? szMsg : L"NULL");
+ LogMessage("returned szMsgW:\n%S", szMsg ? szMsg : L"NULL");
return (INT_PTR)szMsg;
}
diff --git a/plugins/NewAwaySysMod/src/Services.h b/plugins/NewAwaySysMod/src/Services.h index 2aac3c7cc0..ca81be7f75 100644 --- a/plugins/NewAwaySysMod/src/Services.h +++ b/plugins/NewAwaySysMod/src/Services.h @@ -17,7 +17,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-INT_PTR GetStatusMsg(WPARAM wParam, LPARAM lParam);
INT_PTR GetStatusMsgW(WPARAM wParam, LPARAM lParam);
INT_PTR SetStatusMode(WPARAM wParam, LPARAM lParam);
// int IgnoreNextStatusChange(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index f57160395d..530c769fa2 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -58,7 +58,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfo;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SRAWAY, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST };
#ifdef _DEBUG
void log2file(const char *fmt, ...)
@@ -1976,15 +1976,6 @@ static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam) return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL);
}
-
-static INT_PTR sttGetAwayMessage(WPARAM wParam, LPARAM lParam)
-{
- TCHAR* msg = GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL);
- char* res = mir_t2a(msg);
- mir_free(msg);
- return (INT_PTR)res;
-}
-
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
@@ -1997,8 +1988,6 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccListChanged);
-
- CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, sttGetAwayMessage);
CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, sttGetAwayMessageT);
CreateServiceFunction(MS_SIMPLESTATUSMSG_SETSTATUS, SetStatusModeFromExtern);
diff --git a/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp b/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp index 5de614c838..ec254d3203 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp +++ b/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp @@ -122,23 +122,15 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L settings[last]->msg = ( char* )realloc(settings[last]->msg, len+1);
SendDlgItemMessageA(hwndDlg, IDC_STATUSMSG, WM_GETTEXT, (LPARAM)(len+1), (WPARAM)settings[last]->msg);
}
+
if (i != -1) {
if (settings[i]->msg != NULL)
SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, settings[i]->msg);
- else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSGT)) {
- TCHAR *msg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)settings[i]->status, 0);
- if (msg != NULL) {
- SetDlgItemText(hwndDlg, IDC_STATUSMSG, msg);
- mir_free(msg);
- }
- }
- else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) {
- char *msg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)settings[i]->status, 0);
- if (msg != NULL) {
- SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, msg);
- mir_free(msg);
- }
+ else {
+ ptrT msg((TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, settings[i]->status, 0));
+ SetDlgItemText(hwndDlg, IDC_STATUSMSG, (msg != NULL) ? msg : _T(""));
}
+
if (settings[i]->useCustom) {
EnableWindow(GetDlgItem(hwndDlg, IDC_STATUSMSG), TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), TRUE);
@@ -150,7 +142,8 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), FALSE);
CheckDlgButton(hwndDlg, IDC_RADUSEMIRANDA, TRUE);
CheckDlgButton(hwndDlg, IDC_RADUSECUSTOM, FALSE);
- } }
+ }
+ }
last = i;
}
break;
diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index 3f2963748d..74218f4ebf 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -119,34 +119,9 @@ TCHAR* GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus) return mir_tstrdup(ps->szMsg);
}
- if (ServiceExists(MS_AWAYMSG_GETSTATUSMSGT)) {
- TCHAR* tMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, newstatus, (LPARAM)ps->szName);
- log_debugA("CommonStatus: Status message retrieved from general awaysys (TCHAR)");
- return tMsg;
- }
-
- if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) {
- char *tMsg;
- if (ServiceExists(MS_SA_ISSARUNNING) && CallService(MS_SA_ISSARUNNING, 0, 0))
- tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, (LPARAM)ps->szName);
- else
- tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, 0);
-
- log_debugA("CommonStatus: Status message retrieved from general awaysys");
-
- TCHAR* result = mir_a2t(tMsg);
- mir_free(tMsg);
- return result;
- }
-
- /* awaysys doesn't define the service above */
- TCHAR* tMsg = GetDefaultMessage(newstatus);
- if (tMsg != NULL) {
- log_debugA("CommonStatus: Status message retrieved from defaults");
- return mir_tstrdup(tMsg);
- }
-
- return NULL;
+ TCHAR *tMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, newstatus, (LPARAM)ps->szName);
+ log_debugA("CommonStatus: Status message retrieved from general awaysys: %S", tMsg);
+ return tMsg;
}
static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps)
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index b1ae868e3a..3f72827bce 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -323,16 +323,15 @@ int CJabberProto::AdhocSetStatusHandler(HXML, CJabberIqInfo *pInfo, CJabberAdhoc fieldNode = xNode << XCHILD(_T("field")) << XATTR(_T("label"), TranslateT("Change global status"))
<< XATTR(_T("type"), _T("boolean")) << XATTR(_T("var"), _T("status-global"));
- char* szStatusMsg = (char *)CallService(MS_AWAYMSG_GETSTATUSMSG, status, 0);
- if (szStatusMsg) {
- fieldNode << XCHILD(_T("value"), _A2T(szStatusMsg));
- mir_free(szStatusMsg);
- }
+ ptrT tszStatusMsg((TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, status, 0));
+ if (tszStatusMsg)
+ fieldNode << XCHILD(_T("value"), szStatusMsg);
m_ThreadInfo->send(iq);
return JABBER_ADHOC_HANDLER_STATUS_EXECUTING;
}
- else if (pSession->GetStage() == 1) {
+
+ if (pSession->GetStage() == 1) {
// result form here
HXML commandNode = pInfo->GetChildNode();
HXML xNode = xmlGetChildByTag(commandNode, "x", "xmlns", JABBER_FEAT_DATA_FORMS);
diff --git a/src/core/stdautoaway/autoaway.cpp b/src/core/stdautoaway/autoaway.cpp index 94980f4368..f515a26ad8 100644 --- a/src/core/stdautoaway/autoaway.cpp +++ b/src/core/stdautoaway/autoaway.cpp @@ -35,12 +35,12 @@ static int AutoAwaySound(WPARAM, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////
-static bool Proto_IsAccountEnabled(PROTOACCOUNT* pa)
+static bool Proto_IsAccountEnabled(PROTOACCOUNT *pa)
{
return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto);
}
-static bool Proto_IsAccountLocked(PROTOACCOUNT* pa)
+static bool Proto_IsAccountLocked(PROTOACCOUNT *pa)
{
return pa && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0) != 0;
}
@@ -48,18 +48,9 @@ static bool Proto_IsAccountLocked(PROTOACCOUNT* pa) static void Proto_SetStatus(const char* szProto, unsigned status)
{
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
- TCHAR* awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, (WPARAM) status, (LPARAM) szProto);
- if ((INT_PTR)awayMsg == CALLSERVICE_NOTFOUND) {
- char* awayMsgA = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM) status, (LPARAM) szProto);
- if ((INT_PTR)awayMsgA != CALLSERVICE_NOTFOUND) {
- awayMsg = mir_a2t(awayMsgA);
- mir_free(awayMsgA);
- }
- }
- if ((INT_PTR)awayMsg != CALLSERVICE_NOTFOUND) {
- CallProtoService(szProto, PS_SETAWAYMSGT, status, (LPARAM) awayMsg);
- mir_free(awayMsg);
- }
+ TCHAR *awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, status, (LPARAM)szProto);
+ CallProtoService(szProto, PS_SETAWAYMSGT, status, (LPARAM)awayMsg);
+ mir_free(awayMsg);
}
CallProtoService(szProto, PS_SETSTATUS, status, 0);
@@ -81,15 +72,15 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam) PROTOACCOUNT** accounts;
ProtoEnumAccounts(&numAccounts, &accounts);
- for (int i=0; i < numAccounts; i++) {
- PROTOACCOUNT* pa = accounts[i];
- if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa))
+ for (int i = 0; i < numAccounts; i++) {
+ PROTOACCOUNT *pa = accounts[i];
+ if (!Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa))
continue;
int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
int statusbits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
int status = mii.aaStatus;
- if ( !(statusbits & Proto_Status2Flag(status))) {
+ if (!(statusbits & Proto_Status2Flag(status))) {
// the protocol doesnt support the given status
if (statusbits & Proto_Status2Flag(ID_STATUS_AWAY))
status = ID_STATUS_AWAY;
diff --git a/src/core/stdaway/sendmsg.cpp b/src/core/stdaway/sendmsg.cpp index c05a65b822..d3ee3ea38e 100644 --- a/src/core/stdaway/sendmsg.cpp +++ b/src/core/stdaway/sendmsg.cpp @@ -27,12 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static DWORD protoModeMsgFlags;
static HWND hwndStatusMsg;
-static bool Proto_IsAccountEnabled(PROTOACCOUNT* pa)
+static bool Proto_IsAccountEnabled(PROTOACCOUNT *pa)
{
return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto);
}
-static bool Proto_IsAccountLocked(PROTOACCOUNT* pa)
+static bool Proto_IsAccountLocked(PROTOACCOUNT *pa)
{
return pa && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0) != 0;
}
@@ -185,15 +185,15 @@ void ChangeAllProtoMessages(char *szProto, int statusMode, TCHAR *msg) {
if (szProto == NULL) {
int nAccounts;
- PROTOACCOUNT** accounts;
+ PROTOACCOUNT **accounts;
ProtoEnumAccounts(&nAccounts, &accounts);
- for (int i=0; i < nAccounts; i++)
- {
- PROTOACCOUNT* pa = accounts[i];
- if ( !Proto_IsAccountEnabled(pa)) continue;
- if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) &&
- !Proto_IsAccountLocked(pa))
+ for (int i = 0; i < nAccounts; i++) {
+ PROTOACCOUNT *pa = accounts[i];
+ if (!Proto_IsAccountEnabled(pa))
+ continue;
+
+ if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && !Proto_IsAccountLocked(pa))
CallProtoService(pa->szModuleName, PS_SETAWAYMSGT, statusMode, (LPARAM)msg);
}
}
@@ -221,18 +221,18 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa {
SetAwayMsgData* dat = (SetAwayMsgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch(message) {
+ switch (message) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)lParam;
- TranslateDialogDefault(hwndDlg);
dat = (SetAwayMsgData*)mir_alloc(sizeof(SetAwayMsgData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->statusMode = newdat->statusMode;
dat->szProto = newdat->szProto;
mir_free(newdat);
SendDlgItemMessage(hwndDlg, IDC_MSG, EM_LIMITTEXT, 1024, 0);
- mir_subclassWindow( GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc);
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc);
{
TCHAR str[256], format[128];
GetWindowText(hwndDlg, format, SIZEOF(format));
@@ -276,7 +276,7 @@ static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
if (dat->countdown < 0) {
TCHAR str[1024];
@@ -323,17 +323,15 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam) return 0;
// If its a global change check the complete PFLAGNUM_3 flags to see if a popup might be needed
- if ( !szProto)
- {
- if ( !(protoModeMsgFlags & Proto_Status2Flag(statusMode)))
+ if (!szProto) {
+ if (!(protoModeMsgFlags & Proto_Status2Flag(statusMode)))
return 0;
}
- else
- {
+ else {
// If its a single protocol check the PFLAGNUM_3 for the single protocol
- if ( !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) ||
- !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
- return 0;
+ if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) ||
+ !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
+ return 0;
}
BOOL bScreenSaverRunning = IsScreenSaverRunning();
@@ -351,8 +349,7 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam) newdat->statusMode = statusMode;
if (hwndStatusMsg)
DestroyWindow(hwndStatusMsg);
- hwndStatusMsg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETAWAYMSG),
- NULL, SetAwayMsgDlgProc, (LPARAM)newdat);
+ hwndStatusMsg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)newdat);
}
return 0;
}
@@ -389,9 +386,8 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->oldPage = -1;
- for (int i=0; i < SIZEOF(statusModes); i++)
- {
- if ( !(protoModeMsgFlags & Proto_Status2Flag(statusModes[i])))
+ for (int i = 0; i < SIZEOF(statusModes); i++) {
+ if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i])))
continue;
int j;
@@ -428,8 +424,9 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
if (mis->CtlID == IDC_LST_STATUS)
mis->itemHeight = 20;
- break;
}
+ break;
+
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
@@ -439,7 +436,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam TCHAR buf[128];
SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETTEXT, dis->itemID, (LPARAM)buf);
- if (dis->itemState & (ODS_SELECTED|ODS_FOCUS)) {
+ if (dis->itemState & (ODS_SELECTED | ODS_FOCUS)) {
FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
}
@@ -453,10 +450,11 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam rc.left += 25;
SetBkMode(dis->hDC, TRANSPARENT);
DrawText(dis->hDC, buf, -1, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX);
- break;
}
+ break;
+
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_LST_STATUS:
case IDC_STATUS:
if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == LBN_SELCHANGE)) {
@@ -469,14 +467,14 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat->info[dat->oldPage].usePrevious = IsDlgButtonChecked(hwndDlg, IDC_USEPREVIOUS);
GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, SIZEOF(dat->info[dat->oldPage].msg));
}
- CheckDlgButton(hwndDlg, IDC_DONTREPLY, i < 0 ? 0 : dat->info[i].ignore);
- CheckDlgButton(hwndDlg, IDC_NODIALOG, i < 0 ? 0 : dat->info[i].noDialog);
+ CheckDlgButton(hwndDlg, IDC_DONTREPLY, i < 0 ? 0 : dat->info[i].ignore);
+ CheckDlgButton(hwndDlg, IDC_NODIALOG, i < 0 ? 0 : dat->info[i].noDialog);
CheckDlgButton(hwndDlg, IDC_USEPREVIOUS, i < 0 ? 0 : dat->info[i].usePrevious);
CheckDlgButton(hwndDlg, IDC_USESPECIFIC, i < 0 ? 0 : !dat->info[i].usePrevious);
SetDlgItemText(hwndDlg, IDC_MSG, i < 0 ? _T("") : dat->info[i].msg);
- EnableWindow(GetDlgItem(hwndDlg, IDC_NODIALOG), i < 0 ? 0 : !dat->info[i].ignore);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_NODIALOG), i < 0 ? 0 : !dat->info[i].ignore);
EnableWindow(GetDlgItem(hwndDlg, IDC_USEPREVIOUS), i < 0 ? 0 : !dat->info[i].ignore);
EnableWindow(GetDlgItem(hwndDlg, IDC_USESPECIFIC), i < 0 ? 0 : !dat->info[i].ignore);
EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), i < 0 ? 0 : !(dat->info[i].ignore || dat->info[i].usePrevious));
@@ -499,9 +497,9 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
- switch(((LPNMHDR)lParam)->code) {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0);
{
@@ -509,10 +507,10 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam (SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCOUNT, 0, 0) - 1);
for (; i >= 0; i--) {
int status = hLst ?
- SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETITEMDATA, i, 0):
- SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, i, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETITEMDATA, i, 0) :
+ SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, i, 0);
SetStatusModeByte(status, "Ignore", (BYTE)dat->info[i].ignore);
- SetStatusModeByte(status, "NoDlg", (BYTE)dat->info[i].noDialog);
+ SetStatusModeByte(status, "NoDlg", (BYTE)dat->info[i].noDialog);
SetStatusModeByte(status, "UsePrev", (BYTE)dat->info[i].usePrevious);
db_set_ts(NULL, "SRAway", StatusModeToDbSetting(status, "Default"), dat->info[i].msg);
}
@@ -558,7 +556,7 @@ static int AwayMsgSendModernOptInit(WPARAM wParam, LPARAM) MODERNOPT_CTRL_LAST
};
- MODERNOPTOBJECT obj = {0};
+ MODERNOPTOBJECT obj = { 0 };
obj.cbSize = sizeof(obj);
obj.hInstance = hInst;
obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE;
@@ -579,8 +577,8 @@ static int AwayMsgSendAccountsChanged(WPARAM, LPARAM) int nAccounts;
PROTOACCOUNT** accounts;
ProtoEnumAccounts(&nAccounts, &accounts);
- for (int i=0; i < nAccounts; i++) {
- if ( !Proto_IsAccountEnabled(accounts[i]))
+ for (int i = 0; i < nAccounts; i++) {
+ if (!Proto_IsAccountEnabled(accounts[i]))
continue;
protoModeMsgFlags |= CallProtoService(accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
@@ -605,20 +603,11 @@ static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam) return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam);
}
-static INT_PTR sttGetAwayMessage(WPARAM wParam, LPARAM lParam)
-{
- TCHAR* msg = GetAwayMessage((int)wParam, (char*)lParam);
- char* res = mir_t2a(msg);
- mir_free(msg);
- return (INT_PTR)res;
-}
-
int LoadAwayMessageSending(void)
{
HookEvent(ME_SYSTEM_MODULESLOADED, AwayMsgSendModulesLoaded);
HookEvent(ME_PROTO_ACCLISTCHANGED, AwayMsgSendAccountsChanged);
- CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, sttGetAwayMessage);
CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, sttGetAwayMessageT);
return 0;
}
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index c0b0410563..0191d62d7c 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -113,7 +113,7 @@ static INT_PTR Proto_RegisterModule(WPARAM, LPARAM lParam) // let's create a new container
PROTO_INTERFACE* ppi = AddDefaultAccount(pd->szName);
if (ppi) {
- PROTOACCOUNT* pa = Proto_GetAccount(pd->szName);
+ PROTOACCOUNT *pa = Proto_GetAccount(pd->szName);
if (pa == NULL) {
pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
pa->cbSize = sizeof(PROTOACCOUNT);
@@ -247,18 +247,9 @@ static INT_PTR Proto_ContactIsTyping(WPARAM wParam, LPARAM lParam) void Proto_SetStatus(const char *szProto, unsigned status)
{
if (CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
- TCHAR* awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, (WPARAM)status, (LPARAM)szProto);
- if ((INT_PTR)awayMsg == CALLSERVICE_NOTFOUND) {
- char* awayMsgA = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)status, (LPARAM)szProto);
- if ((INT_PTR)awayMsgA != CALLSERVICE_NOTFOUND) {
- awayMsg = mir_a2t(awayMsgA);
- mir_free(awayMsgA);
- }
- }
- if ((INT_PTR)awayMsg != CALLSERVICE_NOTFOUND) {
- CallProtoServiceInt(NULL, szProto, PS_SETAWAYMSGT, status, (LPARAM)awayMsg);
- mir_free(awayMsg);
- }
+ TCHAR *awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, status, (LPARAM)szProto);
+ CallProtoServiceInt(NULL, szProto, PS_SETAWAYMSGT, status, (LPARAM)awayMsg);
+ mir_free(awayMsg);
}
CallProtoServiceInt(NULL, szProto, PS_SETSTATUS, status, 0);
}
@@ -339,7 +330,7 @@ static INT_PTR Proto_EnumAccounts(WPARAM wParam, LPARAM lParam) return 0;
}
-bool __fastcall Proto_IsAccountEnabled(PROTOACCOUNT* pa)
+bool __fastcall Proto_IsAccountEnabled(PROTOACCOUNT *pa)
{
return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto);
}
@@ -349,7 +340,7 @@ static INT_PTR srvProto_IsAccountEnabled(WPARAM, LPARAM lParam) return (INT_PTR)Proto_IsAccountEnabled((PROTOACCOUNT*)lParam);
}
-bool __fastcall Proto_IsAccountLocked(PROTOACCOUNT* pa)
+bool __fastcall Proto_IsAccountLocked(PROTOACCOUNT *pa)
{
return pa && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0) != 0;
}
@@ -374,7 +365,7 @@ INT_PTR CallProtoService(const char* szModule, const char* szService, WPARAM wPa INT_PTR CallProtoServiceInt(MCONTACT hContact, const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam)
{
- PROTOACCOUNT* pa = Proto_GetAccount(szModule);
+ PROTOACCOUNT *pa = Proto_GetAccount(szModule);
if (pa && !pa->bOldProto) {
PROTO_INTERFACE* ppi;
if ((ppi = pa->ppro) == NULL)
|