From 45a5b1f9b7709f8d93b57abea7ba46b44eac5707 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 10 Oct 2013 15:13:20 +0000 Subject: - MS_CLIST_GETSTATUSMODEDESCRIPTION replaced with the direct clist call - crazy & obsolete constant GSMDF_PREFIXONLINE removed git-svn-id: http://svn.miranda-ng.org/main/trunk@6428 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Gadu-Gadu/src/core.cpp | 11 ++--- protocols/Gadu-Gadu/src/dialogs.cpp | 10 ++--- protocols/IcqOscarJ/src/fam_03buddy.cpp | 73 ++++++++++++++------------------- protocols/IcqOscarJ/src/utilities.cpp | 9 +--- protocols/IcqOscarJ/src/utilities.h | 1 - protocols/MRA/src/Mra.cpp | 2 + protocols/MRA/src/Mra.h | 4 +- protocols/MRA/src/Mra_proto.cpp | 2 +- protocols/MRA/src/Mra_svcs.cpp | 2 +- protocols/Yahoo/src/main.cpp | 2 + protocols/Yahoo/src/proto.cpp | 4 +- protocols/Yahoo/src/services.cpp | 6 +-- 12 files changed, 53 insertions(+), 73 deletions(-) (limited to 'protocols') diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 63b5c14735..b506525aaa 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -647,20 +647,17 @@ retry: TCHAR strFmt1[64]; TCHAR strFmt2[64]; - mir_sntprintf(strFmt2, SIZEOF(strFmt2), _T("%s"), (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status_gg2m(atoi(__status)), GSMDF_TCHAR)); - if (__city) - { + _tcsncpy_s(strFmt2, SIZEOF(strFmt2), pcli->pfnGetStatusModeDescription( status_gg2m(atoi(__status)), 0), _TRUNCATE); + if (__city) { mir_sntprintf(strFmt1, SIZEOF(strFmt1), _T(", %s %s"), TranslateT("City:"), __city); _tcsncat(strFmt2, strFmt1, SIZEOF(strFmt2) - _tcslen(strFmt2)); } - if (__birthyear) - { + if (__birthyear) { time_t t = time(NULL); struct tm *lt = localtime(&t); int br = atoi(__birthyear); - if (br < (lt->tm_year + 1900) && br > 1900) - { + if (br < (lt->tm_year + 1900) && br > 1900) { mir_sntprintf(strFmt1, SIZEOF(strFmt1), _T(", %s %d"), TranslateT("Age:"), (lt->tm_year + 1900) - br); _tcsncat(strFmt2, strFmt1, SIZEOF(strFmt2) - _tcslen(strFmt2)); } diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index a78fc38822..86f422c26a 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -283,11 +283,11 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, EnableWindow(GetDlgItem(hwndDlg, IDC_LEAVESTATUS), IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG)); EnableWindow(GetDlgItem(hwndDlg, IDC_IMGMETHOD), IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE)); SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("")); // 0 - SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_ONLINE,GSMDF_TCHAR)); - SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_AWAY,GSMDF_TCHAR)); - SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_DND,GSMDF_TCHAR)); - SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_FREECHAT,GSMDF_TCHAR)); - SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_INVISIBLE,GSMDF_TCHAR)); + SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_ONLINE, 0)); + SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_AWAY, 0)); + SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_DND, 0)); + SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_FREECHAT, 0)); + SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(ID_STATUS_INVISIBLE, 0)); switch(gg->getWord(GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) { case ID_STATUS_ONLINE: SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 1, 0); diff --git a/protocols/IcqOscarJ/src/fam_03buddy.cpp b/protocols/IcqOscarJ/src/fam_03buddy.cpp index b6baeda2d0..44c285c446 100644 --- a/protocols/IcqOscarJ/src/fam_03buddy.cpp +++ b/protocols/IcqOscarJ/src/fam_03buddy.cpp @@ -400,8 +400,8 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) #endif } - if (capLen) - { // Update the contact's capabilies if present in packet + if (capLen) { + // Update the contact's capabilies if present in packet SetCapabilitiesFromBuffer(hContact, capBuf, capLen, wOldStatus == ID_STATUS_OFFLINE); char *szCurrentClient = wOldStatus == ID_STATUS_OFFLINE ? NULL : getSettingStringUtf(hContact, "MirVer", NULL); @@ -412,8 +412,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) szClient = (const char*)-1; SAFE_FREE(&szCurrentClient); } - else if (wOldStatus == ID_STATUS_OFFLINE) - { + else if (wOldStatus == ID_STATUS_OFFLINE) { // Remove the contact's capabilities if coming from offline ClearAllContactCapabilities(hContact); @@ -422,11 +421,8 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) szClient = detectUserClient(hContact, nIsICQ, wClass, dwOnlineSince, NULL, wVersion, dwFT1, dwFT2, dwFT3, nTCPFlag, dwDirectConnCookie, dwWebPort, NULL, capLen, &bClientId, szStrBuf); } - else - { - // Capabilities not present in update packet, do not touch + else // Capabilities not present in update packet, do not touch szClient = (const char*)-1; // we don't want to client be overwritten - } // handle Xtraz status char *moodData = NULL; @@ -445,8 +441,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) ClearContactCapabilities(hContact, CAPF_STATUS_MESSAGES); #ifdef _DEBUG - if (wOldStatus == ID_STATUS_OFFLINE) - { + if (wOldStatus == ID_STATUS_OFFLINE) { if (CheckContactCapabilities(hContact, CAPF_SRV_RELAY)) NetLog_Server("Supports advanced messages"); else @@ -454,8 +449,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) } #endif - if (!nIsICQ) - { + if (!nIsICQ) { // AIM clients does not advertise these, but do support them SetContactCapabilities(hContact, CAPF_UTF | CAPF_TYPING); // Server relayed messages are only supported by ICQ clients @@ -465,8 +459,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) NetLog_Server("Logged in with AIM client"); } - if (nIsICQ && wVersion < 8) - { + if (nIsICQ && wVersion < 8) { ClearContactCapabilities(hContact, CAPF_SRV_RELAY); if (wOldStatus == ID_STATUS_OFFLINE) NetLog_Server("Forcing simple messages due to compability issues"); @@ -486,8 +479,7 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) disposeChain(&pChain); // Save contacts details in database - if (hContact != NULL) - { + if (hContact != NULL) { setDword(hContact, "LogonTS", dwOnlineSince); setDword(hContact, "AwayTS", dwAwaySince); setDword(hContact, "IdleTS", tIdleTS); @@ -495,39 +487,35 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) if (dwMemberSince) setDword(hContact, "MemberTS", dwMemberSince); - if (nIsICQ) - { // on AIM these are not used + if (nIsICQ) { + // on AIM these are not used setDword(hContact, "DirectCookie", dwDirectConnCookie); setByte(hContact, "DCType", (BYTE)nTCPFlag); setWord(hContact, "UserPort", (WORD)(dwPort & 0xffff)); setWord(hContact, "Version", wVersion); } - else - { + else { delSetting(hContact, "DirectCookie"); delSetting(hContact, "DCType"); delSetting(hContact, "UserPort"); delSetting(hContact, "Version"); } + // if no detection, set uknown if (!szClient) - { - // if no detection, set uknown szClient = (nIsICQ ? "Unknown" : "Unknown AIM"); - } - if (szClient != (char*)-1) - { + + if (szClient != (char*)-1) { db_set_utf(hContact, m_szModuleName, "MirVer", szClient); setByte(hContact, "ClientID", bClientId); } - if (wOldStatus == ID_STATUS_OFFLINE) - { + if (wOldStatus == ID_STATUS_OFFLINE) { setDword(hContact, "IP", dwIP); setDword(hContact, "RealIP", dwRealIP); } - else - { // if not first notification only write significant information + else { + // if not first notification only write significant information if (dwIP) setDword(hContact, "IP", dwIP); if (dwRealIP) @@ -536,34 +524,33 @@ void CIcqProto::handleUserOnline(BYTE *buf, WORD wLen, serverthread_info *info) setWord(hContact, "Status", (WORD)IcqStatusToMiranda(wStatus)); // Update info? - if (dwUIN) - { // check if the local copy of user details is up-to-date + if (dwUIN) { + // check if the local copy of user details is up-to-date if (IsMetaInfoChanged(hContact)) icq_QueueUser(hContact); } } - if (wOldStatus != IcqStatusToMiranda(wStatus)) - { // And a small log notice... if status was changed + LPCTSTR ptszStatus = pcli->pfnGetStatusModeDescription(IcqStatusToMiranda(wStatus), 0); + if (wOldStatus != IcqStatusToMiranda(wStatus)) { + // And a small log notice... if status was changed if (nIsICQ) - NetLog_Server("%u changed status to %s (v%d).", dwUIN, MirandaStatusToString(IcqStatusToMiranda(wStatus)), wVersion); + NetLog_Server("%u changed status to %S (v%d).", dwUIN, ptszStatus, wVersion); else - NetLog_Server("%s changed status to %s.", strUID(dwUIN, szUID), MirandaStatusToString(IcqStatusToMiranda(wStatus))); + NetLog_Server("%s changed status to %S.", strUID(dwUIN, szUID), ptszStatus); } #ifdef _DEBUG - else - { + else { if (nIsICQ) - NetLog_Server("%u has status %s (v%d).", dwUIN, MirandaStatusToString(IcqStatusToMiranda(wStatus)), wVersion); + NetLog_Server("%u has status %s (v%d).", dwUIN, ptszStatus, wVersion); else - NetLog_Server("%s has status %s.", strUID(dwUIN, szUID), MirandaStatusToString(IcqStatusToMiranda(wStatus))); + NetLog_Server("%s has status %s.", strUID(dwUIN, szUID), ptszStatus); } #endif - if (szClient == cliSpamBot) - { - if (getByte("KillSpambots", DEFAULT_KILLSPAM_ENABLED) && db_get_b(hContact, "CList", "NotOnList", 0)) - { // kill spammer + if (szClient == cliSpamBot) { + if (getByte("KillSpambots", DEFAULT_KILLSPAM_ENABLED) && db_get_b(hContact, "CList", "NotOnList", 0)) { + // kill spammer icq_DequeueUser(dwUIN); icq_sendRemoveContact(dwUIN, NULL); AddToSpammerList(dwUIN); diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 9f212cd271..7b6e87cf40 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -210,14 +210,9 @@ default: return nSupportedStatus; } -char *MirandaStatusToString(int mirandaStatus) -{ - return (char*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, mirandaStatus, 0); -} - -char *MirandaStatusToStringUtf(int mirandaStatus) +char* MirandaStatusToStringUtf(int mirandaStatus) { // return miranda status description in utf-8, use unicode service is possible - return tchar_to_utf8((TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, mirandaStatus, GSMDF_TCHAR)); + return tchar_to_utf8( pcli->pfnGetStatusModeDescription(mirandaStatus, 0)); } char** CIcqProto::MirandaStatusToAwayMsg(int nStatus) diff --git a/protocols/IcqOscarJ/src/utilities.h b/protocols/IcqOscarJ/src/utilities.h index de1274081b..336c0e8a8a 100644 --- a/protocols/IcqOscarJ/src/utilities.h +++ b/protocols/IcqOscarJ/src/utilities.h @@ -58,7 +58,6 @@ void icq_ShowMultipleControls(HWND hwndDlg, const UINT* controls, int cControls, int IcqStatusToMiranda(WORD wStatus); WORD MirandaStatusToIcq(int nStatus); int MirandaStatusToSupported(int nMirandaStatus); -char *MirandaStatusToString(int); char *MirandaStatusToStringUtf(int); int AwayMsgTypeToStatus(int nMsgType); diff --git a/protocols/MRA/src/Mra.cpp b/protocols/MRA/src/Mra.cpp index efaddcfd34..ca07b67f0a 100644 --- a/protocols/MRA/src/Mra.cpp +++ b/protocols/MRA/src/Mra.cpp @@ -3,6 +3,7 @@ LIST g_Instances(1, PtrKeySortT); MRA_SETTINGS masMraSettings; +CLIST_INTERFACE *pcli; int hLangpack; PLUGININFOEX pluginInfoEx = { @@ -79,6 +80,7 @@ static int OnPreShutdown(WPARAM, LPARAM) extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfoEx); + mir_getCLI(); IconsLoad(); diff --git a/protocols/MRA/src/Mra.h b/protocols/MRA/src/Mra.h index cf8a474842..b5ef8016e5 100644 --- a/protocols/MRA/src/Mra.h +++ b/protocols/MRA/src/Mra.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -222,9 +223,6 @@ CMStringA MraGetSelfVersionString(); #define GetContactNameA(Contact) (LPSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)Contact, 0) #define GetContactNameW(Contact) (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)Contact, GCDNF_UNICODE) -#define GetStatusModeDescriptionA(Status) (LPSTR)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)Status, 0) -#define GetStatusModeDescriptionW(Status) (LPWSTR)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)Status, GSMDF_UNICODE) - #define SetBit(bytes, bitpos) bytes |= (1<pfnGetStatusModeDescription(m_iDesiredStatus, 0); CMStringA szSelfVersionString = MraGetSelfVersionString(); if ( !mraGetStringA(NULL, "MirVerCustom", szUserAgentFormatted)) diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 48295be603..fa41da557a 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -880,7 +880,7 @@ DWORD CMraProto::MraSendNewStatus(DWORD dwStatusMir, DWORD dwXStatusMir, const C else wszStatusDesc = pwszStatusDesc; } else if (pwszStatusTitle.IsEmpty()) - wszStatusTitle = GetStatusModeDescriptionW(dwStatusMir); + wszStatusTitle = pcli->pfnGetStatusModeDescription(dwStatusMir, 0); MraChangeStatus(dwStatus, lpcszStatusUri[dwXStatus], wszStatusTitle, wszStatusDesc, ((getByte("RTFReceiveEnable", MRA_DEFAULT_RTF_RECEIVE_ENABLE)? FEATURE_FLAG_RTF_MESSAGE:0)|MRA_FEATURE_FLAGS)); return 0; diff --git a/protocols/Yahoo/src/main.cpp b/protocols/Yahoo/src/main.cpp index e7f96840f9..07e8a80b28 100644 --- a/protocols/Yahoo/src/main.cpp +++ b/protocols/Yahoo/src/main.cpp @@ -24,6 +24,7 @@ HINSTANCE hInstance; HANDLE g_hNetlibUser; +CLIST_INTERFACE *pcli; int hLangpack; PLUGININFOEX pluginInfo={ @@ -96,6 +97,7 @@ static int yahooProtoUninit( CYahooProto* ppro ) extern "C" int __declspec(dllexport)Load(void) { mir_getLP( &pluginInfo ); + mir_getCLI(); PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; pd.szName = "YAHOO"; diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 4769e91e22..22dfba71f1 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -420,7 +420,7 @@ int __cdecl CYahooProto::SetApparentMode( HANDLE hContact, int mode ) int __cdecl CYahooProto::SetStatus( int iNewStatus ) { - LOG(("[SetStatus] New status %s", (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iNewStatus, 0))); + LOG(("[SetStatus] New status %S", pcli->pfnGetStatusModeDescription(iNewStatus, 0))); if (iNewStatus == ID_STATUS_OFFLINE) { @@ -609,7 +609,7 @@ int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg ) { char *c = msg && msg[0] ? mir_utf8encodeT(msg) : NULL; - DebugLog("[YahooSetAwayMessage] Status: %s, Msg: %s",(char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, 0), (char*) c); + DebugLog("[YahooSetAwayMessage] Status: %S, Msg: %s", pcli->pfnGetStatusModeDescription(status, 0), (char*)c); if (!m_bLoggedIn) { if (m_iStatus == ID_STATUS_OFFLINE) { diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp index 7cd7556918..397f655ad2 100644 --- a/protocols/Yahoo/src/services.cpp +++ b/protocols/Yahoo/src/services.cpp @@ -71,9 +71,9 @@ void CYahooProto::BroadcastStatus(int s) m_iStatus = ID_STATUS_ONLINE; } - DebugLog("[yahoo_util_broadcaststatus] Old Status: %s (%d), New Status: %s (%d)", - NEWSTR_ALLOCA((char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, oldStatus, 0)), oldStatus, - NEWSTR_ALLOCA((char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, m_iStatus, 0)), m_iStatus); + DebugLog("[yahoo_util_broadcaststatus] Old Status: %S (%d), New Status: %S (%d)", + pcli->pfnGetStatusModeDescription(oldStatus, 0), oldStatus, + pcli->pfnGetStatusModeDescription(m_iStatus, 0), m_iStatus); ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, (LPARAM)m_iStatus); } -- cgit v1.2.3