From d57b6799dac75f3c428393666d079fe59361c4b5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 31 May 2015 16:50:53 +0000 Subject: fixes for PS_SETAWAYMSG calls git-svn-id: http://svn.miranda-ng.org/main/trunk@13939 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_protosvc.h | 30 +++++++------- plugins/CmdLine/src/mimcmd_handlers.cpp | 3 +- plugins/MirFox/src/MirandaUtils.cpp | 2 +- plugins/NewAwaySysMod/src/AwaySys.cpp | 8 ++-- plugins/NewAwaySysMod/src/Client.cpp | 6 +-- plugins/NewAwaySysMod/src/Common.h | 6 +-- protocols/Gadu-Gadu/src/gg_proto.cpp | 1 - protocols/ICQCorp/src/services.cpp | 70 ++++++++++++++++----------------- protocols/Xfire/src/all_statusmsg.cpp | 13 +++--- src/modules/protocols/protoint.cpp | 2 +- 10 files changed, 71 insertions(+), 70 deletions(-) diff --git a/include/m_protosvc.h b/include/m_protosvc.h index 49f3aa57d4..b65d83eb95 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -2,7 +2,7 @@ Miranda NG: the free IM client for Microsoft* Windows* -Copyright (ñ) 2012-15 Miranda NG project (http:// miranda-ng.org) +Copyright (ñ) 2012-15 Miranda NG project (http://miranda-ng.org) Copyright (c) 2000-09 Miranda ICQ/IM project, all portions of this codebase are copyrighted to the people listed in contributors.txt. @@ -96,7 +96,7 @@ convert Unicode to ANSI and call the appropriate service. /////////////////////////////////////////////////////////////////////////////// // the status modes that the protocol supports -#define PFLAGNUM_2 2 +#define PFLAGNUM_2 2 #define PF2_ONLINE 0x00000001 // an unadorned online mode #define PF2_INVISIBLE 0x00000002 @@ -139,7 +139,7 @@ static __inline unsigned long Proto_Status2Flag(int status) /////////////////////////////////////////////////////////////////////////////// // another bunch of flags -#define PFLAGNUM_4 4 +#define PFLAGNUM_4 4 #define PF4_FORCEAUTH 0x00000001 // forces auth requests to be sent when adding users #define PF4_FORCEADDED 0x00000002 // forces "you were added" requests to be sent @@ -160,21 +160,21 @@ static __inline unsigned long Proto_Status2Flag(int status) #define PFLAG_MAXLENOFMESSAGE 400 // return the maximum length of an instant message, lParam = (LPARAM)hContact /////////////////////////////////////////////////////////////////////////////// -// A protocol might not support this cap, it allows a protocol to say that -// PFLAGNUM_2 is for statuses contacts supports, and that PFLAGNUM_5 is for -// statuses a protocol can SET TO ITSELF, if this is not replied to, then -// PFLAGNUM_2 is alone in telling you which statuses a protocol can set to and +// A protocol might not support this cap, it allows a protocol to say that +// PFLAGNUM_2 is for statuses contacts supports, and that PFLAGNUM_5 is for +// statuses a protocol can SET TO ITSELF, if this is not replied to, then +// PFLAGNUM_2 is alone in telling you which statuses a protocol can set to and // what statuses a contact can set to as well. // -// E.g. A protocol might report 'wireless' users but a login of the protocol -// from Miranda can not set itself to 'wireless' so PFLAGNUM_2 would return -// PF2_ONTHEPHONE and PFLAGNUM_5 would return PF2_ONTHEPHONE as well, this -// means "I will get contacts who are on the phone but you can not set on the +// E.g. A protocol might report 'wireless' users but a login of the protocol +// from Miranda can not set itself to 'wireless' so PFLAGNUM_2 would return +// PF2_ONTHEPHONE and PFLAGNUM_5 would return PF2_ONTHEPHONE as well, this +// means "I will get contacts who are on the phone but you can not set on the // phone" and so on. // -// Do note that the reply here is a NEGATION of bitflags reported for -// PFLAGNUM_2, e.g. returning PF2_ONTHEPHONE for PFLAGNUM_2 and returning the -// same for PFLAGNUM_5 says that you DO NOT SUPPORT PF2_ONTHEPHONE for the user +// Do note that the reply here is a NEGATION of bitflags reported for +// PFLAGNUM_2, e.g. returning PF2_ONTHEPHONE for PFLAGNUM_2 and returning the +// same for PFLAGNUM_5 says that you DO NOT SUPPORT PF2_ONTHEPHONE for the user // to PS_SETSTATUS to, but you will expect other contacts to have that status, // e.g. you can get onthephone for users but can't go online with onthephone. // @@ -873,7 +873,7 @@ __forceinline INT_PTR Proto_RecvFile(MCONTACT hContact, PROTORECVFILET *pcre) // ASCIIZ userId // } // userNick should be a human-readable description of the user. It need not -// be the nick, or even confined to displaying just one type of information. +// be the nick, or even confined to displaying just one type of information. // The dbe.flags can contain DBEF_UTF defining userNick as utf-8 encoded. // // userId should be a machine-readable representation of the unique diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 5e91e041eb..e26b134d7e 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -369,7 +369,8 @@ void HandleAwayMsgCommand(PCommand command, TArgument *argv, int argc, PReply re if ((CallProtoService(protocol, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) != 0) //if the protocol supports away messages { status = CallProtoService(protocol, PS_GETSTATUS, 0, 0); - res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM) awayMsg); + ptrW wszAwayMsg(mir_a2u(awayMsg)); + res = CallProtoService(protocol, PS_SETAWAYMSG, status, (LPARAM)wszAwayMsg); PrettyStatusMode(status, pn, sizeof(pn)); if (res) szReply.AppendFormat(Translate("Failed to set '%S' status message to '%s' (status is '%s')."), accounts[i]->tszAccountName , awayMsg, pn); diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index e13f507caa..8feae7a960 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -371,7 +371,7 @@ void MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args) INT_PTR result = -1; if (!(CallProtoService(args->accountSzModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_INDIVMODEMSG)) - result = CallProtoService(args->accountSzModuleName, PS_SETAWAYMSG, (WPARAM)status, (LPARAM)args->userActionSelection); + result = CallProtoService(args->accountSzModuleName, PS_SETAWAYMSG, status, (LPARAM)args->userActionSelection); MirandaAccount* mirandaAccount = args->mirfoxDataPtr->getMirandaAccountPtrBySzModuleName(args->accountSzModuleName); TCHAR* tszAccountName = NULL; diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 7649a3f68a..4343b9878d 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -143,13 +143,13 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) return 0; } if (CContactSettings(iMode, hContactForSettings).Ignore) { - CallAllowedPS_SETAWAYMSG(szProto, iMode, ""); // currently NULL makes ICQ to ignore _any_ further status message requests until the next PS_SETAWAYMSG, so i can't use it here.. + CallAllowedPS_SETAWAYMSG(szProto, iMode, _T("")); // currently NULL makes ICQ to ignore _any_ further status message requests until the next PS_SETAWAYMSG, so i can't use it here.. return 0; // move along, sir } - if (iMode) { // if it's not an xstatus message request - CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(GetDynamicStatMsg(hFoundContact, szProto, lParam))); - } + if (iMode) // if it's not an xstatus message request + CallAllowedPS_SETAWAYMSG(szProto, iMode, GetDynamicStatMsg(hFoundContact, szProto, lParam)); + // COptPage PopupNotifyData(g_PopupOptPage); // PopupNotifyData.DBToMem(); VarParseData.szProto = szProto; diff --git a/plugins/NewAwaySysMod/src/Client.cpp b/plugins/NewAwaySysMod/src/Client.cpp index 74244b3d60..22ff666fe5 100644 --- a/plugins/NewAwaySysMod/src/Client.cpp +++ b/plugins/NewAwaySysMod/src/Client.cpp @@ -47,7 +47,7 @@ void __cdecl UpdateMsgsThreadProc(void *) TCString CurMsg(GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName)); if ((TCString)g_ProtoStates[p->szModuleName].CurStatusMsg != (const TCHAR*)CurMsg) { // if the message has changed g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg; - CallAllowedPS_SETAWAYMSG(p->szModuleName, Status, (char*)_T2A(CurMsg)); + CallAllowedPS_SETAWAYMSG(p->szModuleName, Status, CurMsg); } } } @@ -86,7 +86,7 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) if (Msg == NULL) CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, szProto); - CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(CurMsg)); + CallAllowedPS_SETAWAYMSG(szProto, iMode, CurMsg); g_ProtoStates[szProto].CurStatusMsg = CurMsg; } else { // change message of all protocols @@ -99,7 +99,7 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) if (Msg == NULL) CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName); - CallAllowedPS_SETAWAYMSG(p->szModuleName, iMode, (char*)_T2A(CurMsg)); + CallAllowedPS_SETAWAYMSG(p->szModuleName, iMode, CurMsg); g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg; } } diff --git a/plugins/NewAwaySysMod/src/Common.h b/plugins/NewAwaySysMod/src/Common.h index cb8af145fa..c8a99eef6d 100644 --- a/plugins/NewAwaySysMod/src/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -327,10 +327,10 @@ static __inline int LogMessage(const char *Format, ...) return CallService(MS_NETLIB_LOG, NULL, (LPARAM)szText); } -__inline int CallAllowedPS_SETAWAYMSG(const char *szProto, int iMode, const char *szMsg) +__inline int CallAllowedPS_SETAWAYMSG(const char *szProto, int iMode, const TCHAR *szMsg) { // we must use this function everywhere we want to call PS_SETAWAYMSG, otherwise NAS won't allow to change the message! - LogMessage("PS_SETAWAYMSG called by NAS. szProto=%s, Status=%d, Msg:\n%s", szProto, iMode, szMsg ? szMsg : "NULL"); - return CallProtoService(szProto, PS_SETAWAYMSG, (WPARAM)iMode, (LPARAM)szMsg); + LogMessage("PS_SETAWAYMSG called by NAS. szProto=%s, Status=%d, Msg:\n%S", szProto, iMode, szMsg ? szMsg : _T("NULL")); + return CallProtoService(szProto, PS_SETAWAYMSG, iMode, (LPARAM)szMsg); } static __inline int my_variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags = 0, char *szSubjectDesc = NULL, char *szExtraDesc = NULL) diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 3c9380a83c..2d0dfd6702 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -57,7 +57,6 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) : CreateProtoService(PS_SETMYAVATART, &GGPROTO::setmyavatar); CreateProtoService(PS_GETMYAWAYMSG, &GGPROTO::getmyawaymsg); - CreateProtoService(PS_SETAWAYMSG, (MyServiceFunc)&GGPROTO::SetAwayMsg); CreateProtoService(PS_CREATEACCMGRUI, &GGPROTO::get_acc_mgr_gui); CreateProtoService(PS_LEAVECHAT, &GGPROTO::leavechat); diff --git a/protocols/ICQCorp/src/services.cpp b/protocols/ICQCorp/src/services.cpp index d4c8379d75..ee34dc062f 100644 --- a/protocols/ICQCorp/src/services.cpp +++ b/protocols/ICQCorp/src/services.cpp @@ -536,54 +536,52 @@ char *CreateServiceName(char *serviceName, char *functionName) int LoadServices() { - char serviceName[MAX_PATH + 30]; + char serviceName[MAX_PATH + 30]; - if (!icq.load()) return 1; + if (!icq.load()) return 1; HookEvent(ME_DB_CONTACT_DELETED, icqContactDeleted); - HookEvent(ME_OPT_INITIALISE, icqOptionsInitialise); - HookEvent(ME_SYSTEM_MODULESLOADED, icqModulesLoaded); - - CreateServiceFunction(CreateServiceName(serviceName, PS_GETCAPS), icqGetCaps); - CreateServiceFunction(CreateServiceName(serviceName, PS_GETNAME), icqGetName); - CreateServiceFunction(CreateServiceName(serviceName, PS_LOADICON), icqLoadIcon); - CreateServiceFunction(CreateServiceName(serviceName, PS_SETSTATUS), icqSetStatus); - CreateServiceFunction(CreateServiceName(serviceName, PS_GETSTATUS), icqGetStatus); - CreateServiceFunction(CreateServiceName(serviceName, PS_SETAWAYMSG), icqSetAwayMsg); - CreateServiceFunction(CreateServiceName(serviceName, PS_AUTHALLOW), icqAuthAllow); - CreateServiceFunction(CreateServiceName(serviceName, PS_AUTHDENY), icqAuthDeny); - CreateServiceFunction(CreateServiceName(serviceName, PS_BASICSEARCH), icqBasicSearch); - CreateServiceFunction(CreateServiceName(serviceName, PS_SEARCHBYEMAIL), icqSearchByEmail); - CreateServiceFunction(CreateServiceName(serviceName, PS_SEARCHBYNAME), icqSearchByName); -// CreateServiceFunction(MS_ICQ_SEARCHBYDETAILS, icqSearchByDetails); - CreateServiceFunction(CreateServiceName(serviceName, PS_ADDTOLIST), icqAddToList); -// CreateServiceFunction(CreateServiceName(serviceName, PS_ADDTOLISTBYEVENT), icqAddToListByEvent); - CreateServiceFunction(CreateServiceName(serviceName, PS_FILERESUME), icqFileResume); - - CreateServiceFunction(CreateServiceName(serviceName, PSS_GETINFO), icqGetInfo); - CreateServiceFunction(CreateServiceName(serviceName, PSS_MESSAGE), icqSendMessage); - CreateServiceFunction(CreateServiceName(serviceName, PSS_URL), icqSendUrl); - CreateServiceFunction(CreateServiceName(serviceName, PSS_GETAWAYMSG), icqGetAwayMsg); - CreateServiceFunction(CreateServiceName(serviceName, PSS_FILE), icqSendFile); - CreateServiceFunction(CreateServiceName(serviceName, PSS_FILEALLOW), icqFileAllow); - CreateServiceFunction(CreateServiceName(serviceName, PSS_FILEDENY), icqFileDeny); - CreateServiceFunction(CreateServiceName(serviceName, PSS_FILECANCEL), icqFileCancel); - CreateServiceFunction(CreateServiceName(serviceName, PSS_SETAPPARENTMODE), icqSetApparentMode); - - CreateServiceFunction(CreateServiceName(serviceName, PSR_MESSAGE), icqRecvMessage); - CreateServiceFunction(CreateServiceName(serviceName, PSR_URL), icqRecvUrl); + HookEvent(ME_OPT_INITIALISE, icqOptionsInitialise); + HookEvent(ME_SYSTEM_MODULESLOADED, icqModulesLoaded); + + CreateServiceFunction(CreateServiceName(serviceName, PS_GETCAPS), icqGetCaps); + CreateServiceFunction(CreateServiceName(serviceName, PS_GETNAME), icqGetName); + CreateServiceFunction(CreateServiceName(serviceName, PS_LOADICON), icqLoadIcon); + CreateServiceFunction(CreateServiceName(serviceName, PS_SETSTATUS), icqSetStatus); + CreateServiceFunction(CreateServiceName(serviceName, PS_GETSTATUS), icqGetStatus); + CreateServiceFunction(CreateServiceName(serviceName, PS_SETAWAYMSG), icqSetAwayMsg); + CreateServiceFunction(CreateServiceName(serviceName, PS_AUTHALLOW), icqAuthAllow); + CreateServiceFunction(CreateServiceName(serviceName, PS_AUTHDENY), icqAuthDeny); + CreateServiceFunction(CreateServiceName(serviceName, PS_BASICSEARCH), icqBasicSearch); + CreateServiceFunction(CreateServiceName(serviceName, PS_SEARCHBYEMAIL), icqSearchByEmail); + CreateServiceFunction(CreateServiceName(serviceName, PS_SEARCHBYNAME), icqSearchByName); + CreateServiceFunction(CreateServiceName(serviceName, PS_ADDTOLIST), icqAddToList); + CreateServiceFunction(CreateServiceName(serviceName, PS_FILERESUME), icqFileResume); + + CreateServiceFunction(CreateServiceName(serviceName, PSS_GETINFO), icqGetInfo); + CreateServiceFunction(CreateServiceName(serviceName, PSS_MESSAGE), icqSendMessage); + CreateServiceFunction(CreateServiceName(serviceName, PSS_URL), icqSendUrl); + CreateServiceFunction(CreateServiceName(serviceName, PSS_GETAWAYMSG), icqGetAwayMsg); + CreateServiceFunction(CreateServiceName(serviceName, PSS_FILE), icqSendFile); + CreateServiceFunction(CreateServiceName(serviceName, PSS_FILEALLOW), icqFileAllow); + CreateServiceFunction(CreateServiceName(serviceName, PSS_FILEDENY), icqFileDeny); + CreateServiceFunction(CreateServiceName(serviceName, PSS_FILECANCEL), icqFileCancel); + CreateServiceFunction(CreateServiceName(serviceName, PSS_SETAPPARENTMODE), icqSetApparentMode); + + CreateServiceFunction(CreateServiceName(serviceName, PSR_MESSAGE), icqRecvMessage); + CreateServiceFunction(CreateServiceName(serviceName, PSR_URL), icqRecvUrl); CreateServiceFunction(CreateServiceName(serviceName, PSR_AWAYMSG), icqRecvAwayMsg); CreateServiceFunction(CreateServiceName(serviceName, PSR_FILE), icqRecvFile); - return 0; + return 0; } /////////////////////////////////////////////////////////////////////////////// int UnloadServices() { - icq.unload(); - return 0; + icq.unload(); + return 0; } /////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Xfire/src/all_statusmsg.cpp b/protocols/Xfire/src/all_statusmsg.cpp index d08db0920f..6387f5a798 100644 --- a/protocols/Xfire/src/all_statusmsg.cpp +++ b/protocols/Xfire/src/all_statusmsg.cpp @@ -259,14 +259,15 @@ BOOL SetGameStatusMsg() XFireLog("-> SetStatusMsg of %s with Miranda with occupied status.", protoname->at(i).c_str()); //statusmsg für beschäftigt setzen - CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, oltostatus->at(i), (LPARAM)statusMsg); + ptrW wszStatus(mir_a2u(statusMsg)); + CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, oltostatus->at(i), wszStatus); //status auf beschäftigt wechseln CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, oltostatus->at(i), 0); //statusmsg für beschäftigt setzen if (CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0) != oltostatus->at(i)) { XFireLog("Set StatusMsg again, Status was not succesfully set."); - CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, oltostatus->at(i), (LPARAM)statusMsg); + CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, oltostatus->at(i), wszStatus); } } } @@ -274,7 +275,8 @@ BOOL SetGameStatusMsg() { XFireLog("-> SetStatusMsg of %s.", protoname->at(i).c_str()); - CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), (LPARAM)statusMsg); + ptrW wszStatus(mir_a2u(statusMsg)); + CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), wszStatus); } } } @@ -293,18 +295,19 @@ BOOL SetOldStatusMsg() { if (olstatus->at(i) != -1) { + ptrW wszStatus(mir_a2u(olstatusmsg->at(i).c_str())); if (statustype) { //alten status setzen CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, olstatus->at(i), 0); //status wurde nicht gewechselt, dann statusmsg nachträglich setzen if (CallProtoService(temp[i]->szModuleName, PS_GETSTATUS, 0, 0) != olstatus->at(i)) - CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), (LPARAM)olstatusmsg->at(i).c_str()); + CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), wszStatus); } else { CallProtoService(temp[i]->szModuleName, PS_SETSTATUS, olstatus->at(i), 0); - CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), (LPARAM)olstatusmsg->at(i).c_str()); + CallProtoService(temp[i]->szModuleName, PS_SETAWAYMSG, olstatus->at(i), wszStatus); } } } diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp index 2252877ce4..809d78b0cc 100644 --- a/src/modules/protocols/protoint.cpp +++ b/src/modules/protocols/protoint.cpp @@ -251,7 +251,7 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return (int)ProtoCallService(m_szModuleName, PSR_AWAYMSG, 0, (LPARAM)&ccs); } - int __cdecl SetAwayMsg(int iStatus, const TCHAR* msg) + int __cdecl SetAwayMsg(int iStatus, const TCHAR *msg) { if (m_iVersion > 1) return (int)ProtoCallService(m_szModuleName, PS_SETAWAYMSG, iStatus, (LPARAM)msg); -- cgit v1.2.3