From abc92c3d526f13c6f9b4ad80414761709ace8df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 15 Jan 2013 15:10:26 +0000 Subject: ICQ: - partially fixed mood icons when enabled xstatus support - set xstatus support enabled by default - clear xstatus on login git-svn-id: http://svn.miranda-ng.org/main/trunk@3111 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/icq_constants.h | 2 +- protocols/IcqOscarJ/src/icq_proto.cpp | 3 ++ protocols/IcqOscarJ/src/icq_xstatus.cpp | 69 +++++++++++++++++---------------- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/protocols/IcqOscarJ/src/icq_constants.h b/protocols/IcqOscarJ/src/icq_constants.h index 4da90f1bc0..41460e029b 100644 --- a/protocols/IcqOscarJ/src/icq_constants.h +++ b/protocols/IcqOscarJ/src/icq_constants.h @@ -74,7 +74,7 @@ #define DEFAULT_LOAD_AVATARS 1 #define DEFAULT_BIGGER_AVATARS 0 #define DEFAULT_AVATARS_CHECK 1 -#define DEFAULT_XSTATUS_ENABLED 0 +#define DEFAULT_XSTATUS_ENABLED 1 #define DEFAULT_XSTATUS_AUTO 1 #define DEFAULT_XSTATUS_RESET 0 #define DEFAULT_MOODS_ENABLED 1 diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index 50771cb011..76a7fd2d90 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -2001,6 +2001,9 @@ int __cdecl CIcqProto::SetStatus(int iNewStatus) // Read password from database char *pszPwd = GetUserPassword(FALSE); + // Clear xstatus + setXStatusEx(0, 0); + if (pszPwd) icq_login(pszPwd); else diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index 4d52aa6ab4..11a9f782ad 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -415,16 +415,25 @@ void CIcqProto::handleXStatusCaps(DWORD dwUIN, char *szUID, HANDLE hContact, BYT } int nOldXStatusID = getContactXStatus(hContact); - if (m_bXStatusEnabled) { - // detect custom status capabilities - if (caps) { - if (capsize > 0) + if (m_bMoodsEnabled) { + // process custom statuses (moods) from ICQ6 + if (moods) { + if (moodsize > 0) + if (moodsize >= 32) + moods[32] = '\0'; + for (int i = 0; i < XSTATUS_COUNT; i++) { - if (MatchCapability(caps, capsize, (const capstr*)capXStatus[i], BINARY_CAP_SIZE)) { + char szMoodId[32], szMoodData[32]; + + null_strcpy(szMoodData, moods, moodsize); + + if (moodXStatus[i] == -1) continue; + null_snprintf(szMoodId, SIZEOF(szMoodId), "0icqmood%d", moodXStatus[i]); + if ( !strcmpnull(szMoodId, szMoodData)) { BYTE bXStatusId = (BYTE)(i+1); char str[MAX_PATH]; - SetContactCapabilities(hContact, CAPF_XSTATUS); + SetContactCapabilities(hContact, CAPF_STATUS_MOOD); // only write default name when it is really needed, i.e. on Custom Status change if (nOldXStatusID != bXStatusId) { @@ -432,64 +441,58 @@ void CIcqProto::handleXStatusCaps(DWORD dwUIN, char *szUID, HANDLE hContact, BYT setSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, ICQTranslateUtfStatic(nameXStatus[i], str, MAX_PATH)); deleteSetting(hContact, DBSETTING_XSTATUS_MSG); - NetLog_Server("%s changed custom status to %s.", strUID(dwUIN, szUID), ICQTranslateUtfStatic(nameXStatus[i], str, MAX_PATH)); + NetLog_Server("%s changed mood to %s.", strUID(dwUIN, szUID), ICQTranslateUtfStatic(nameXStatus[i], str, MAX_PATH)); bChanged = TRUE; } - if (getSettingByte(NULL, "XStatusAuto", DEFAULT_XSTATUS_AUTO)) - requestXStatusDetails(hContact, TRUE); + // cannot retrieve mood details here - need to be processed with new user details + nMoodID = bXStatusId; - nCustomStatusID = bXStatusId; break; } } - if (nCustomStatusID == 0) - ClearContactCapabilities(hContact, CAPF_XSTATUS); + if (nMoodID == 0 && moods) + ClearContactCapabilities(hContact, CAPF_STATUS_MOOD); } } - if (m_bMoodsEnabled) { - // process custom statuses (moods) from ICQ6 - if (moods && moodsize < 32) { - if (moodsize > 0) + if (m_bXStatusEnabled) { + // detect custom status capabilities + if (caps) { + if (capsize > 0) for (int i = 0; i < XSTATUS_COUNT; i++) { - char szMoodId[32], szMoodData[32]; - - null_strcpy(szMoodData, moods, moodsize); - - if (moodXStatus[i] == -1) continue; - null_snprintf(szMoodId, SIZEOF(szMoodId), "0icqmood%d", moodXStatus[i]); - if ( !strcmpnull(szMoodId, szMoodData)) { + if (MatchCapability(caps, capsize, (const capstr*)capXStatus[i], BINARY_CAP_SIZE)) { BYTE bXStatusId = (BYTE)(i+1); char str[MAX_PATH]; - SetContactCapabilities(hContact, CAPF_STATUS_MOOD); + SetContactCapabilities(hContact, CAPF_XSTATUS); // only write default name when it is really needed, i.e. on Custom Status change - if (nCustomStatusID == 0 && nOldXStatusID != bXStatusId) { + if (nMoodID == 0 && nOldXStatusID != bXStatusId) { setSettingByte(hContact, DBSETTING_XSTATUS_ID, bXStatusId); setSettingStringUtf(hContact, DBSETTING_XSTATUS_NAME, ICQTranslateUtfStatic(nameXStatus[i], str, MAX_PATH)); deleteSetting(hContact, DBSETTING_XSTATUS_MSG); - NetLog_Server("%s changed mood to %s.", strUID(dwUIN, szUID), ICQTranslateUtfStatic(nameXStatus[i], str, MAX_PATH)); + NetLog_Server("%s changed custom status to %s.", strUID(dwUIN, szUID), ICQTranslateUtfStatic(nameXStatus[i], str, MAX_PATH)); bChanged = TRUE; } - // cannot retrieve mood details here - need to be processed with new user details - nMoodID = bXStatusId; + if (getSettingByte(NULL, "XStatusAuto", DEFAULT_XSTATUS_AUTO)) + requestXStatusDetails(hContact, TRUE); + nCustomStatusID = bXStatusId; break; } - } + } - if (nMoodID == 0 && moods) - ClearContactCapabilities(hContact, CAPF_STATUS_MOOD); + if (nCustomStatusID == 0) + ClearContactCapabilities(hContact, CAPF_XSTATUS); } } if (nCustomStatusID != 0 && nMoodID != 0 && nCustomStatusID != nMoodID) - NetLog_Server("Warning: Diverse custom statuses detected, using custom status."); + NetLog_Server("Warning: Diverse custom statuses detected, using mood status."); if ((nCustomStatusID == 0 && (caps || !m_bXStatusEnabled)) && (nMoodID == 0 && (moods || !m_bMoodsEnabled))) { if (getSettingByte(hContact, DBSETTING_XSTATUS_ID, -1) != -1) @@ -500,7 +503,7 @@ void CIcqProto::handleXStatusCaps(DWORD dwUIN, char *szUID, HANDLE hContact, BYT } if (m_bXStatusEnabled != 10 && m_bMoodsEnabled != 10) - setContactExtraIcon(hContact, nCustomStatusID ? nCustomStatusID : (nMoodID ? nMoodID : (moods ? 0 : nOldXStatusID))); + setContactExtraIcon(hContact, nMoodID ? nMoodID : (moods ? 0 : (nCustomStatusID ? nCustomStatusID : nOldXStatusID))); } -- cgit v1.2.3