diff options
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_icolib.cpp | 121 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 61 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 166 |
4 files changed, 160 insertions, 194 deletions
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index a9f1f5be19..ee83c67a73 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -321,7 +321,7 @@ int CJabberProto::LoadAdvancedIcons(int iID) if ( !hAdvancedStatusIcon)
hAdvancedStatusIcon=(HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST,0,0);
- EnterCriticalSection(&m_csModeMsgMutex);
+ mir_cslock lck(m_csModeMsgMutex);
for (int i=0; i < ID_STATUS_ONTHEPHONE-ID_STATUS_OFFLINE; i++) {
BOOL needFree;
int n = skinStatusToJabberStatus[i];
@@ -330,13 +330,14 @@ int CJabberProto::LoadAdvancedIcons(int iID) HICON hicon = LoadTransportIcon(defFile,-skinIconStatusToResourceId[i],Uname,Group,descr,-(n+ID_STATUS_OFFLINE),&needFree);
int index = (m_transportProtoTableStartIndex[iID] == -1)?-1:m_transportProtoTableStartIndex[iID]+n;
int added = ImageList_ReplaceIcon(hAdvancedStatusIcon,index,hicon?hicon:empty);
- if (first == -1) first = added;
- if (hicon && needFree) DestroyIcon(hicon);
+ if (first == -1)
+ first = added;
+ if (hicon && needFree)
+ DestroyIcon(hicon);
}
if (m_transportProtoTableStartIndex[iID] == -1)
m_transportProtoTableStartIndex[iID] = first;
- LeaveCriticalSection(&m_csModeMsgMutex);
return 0;
}
@@ -405,8 +406,7 @@ INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM wParam, LPARAM) int iID = GetTransportProtoID(dbv.ptszVal);
db_free(&dbv);
if (iID >= 0) {
- WORD Status = ID_STATUS_OFFLINE;
- Status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+ WORD Status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
if (Status < ID_STATUS_OFFLINE)
Status = ID_STATUS_OFFLINE;
else if (Status > ID_STATUS_INVISIBLE)
@@ -438,18 +438,17 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact if (resourcepos != NULL)
*resourcepos = '\0';
- for (int i=0; i < SIZEOF(TransportProtoTable); i++) {
+ for (int i=0; i < SIZEOF(TransportProtoTable); i++)
if (MatchMask(domain, TransportProtoTable[i].mask)) {
GetTransportStatusIconIndex(GetTransportProtoID(domain), ID_STATUS_OFFLINE);
isTransported = TRUE;
break;
- } }
+ }
- if (m_lstTransports.getIndex(domain) == -1) {
- if (isAgent) {
- m_lstTransports.insert(mir_tstrdup(domain));
- setByte(hContact, "IsTransport", 1);
- } }
+ if (m_lstTransports.getIndex(domain) == -1 && isAgent) {
+ m_lstTransports.insert( mir_tstrdup(domain));
+ setByte(hContact, "IsTransport", 1);
+ }
if (isTransported) {
setTString(hContact, "Transport", domain);
@@ -461,11 +460,9 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact void CJabberProto::CheckAllContactsAreTransported()
{
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- DBVARIANT dbv;
- if ( !getTString(hContact, "jid", &dbv)) {
- DBCheckIsTransportedContact(dbv.ptszVal, hContact);
- db_free(&dbv);
- }
+ ptrT jid( getTStringA(hContact, "jid"));
+ if (jid)
+ DBCheckIsTransportedContact(jid, hContact);
}
}
@@ -474,62 +471,62 @@ void CJabberProto::CheckAllContactsAreTransported() static IconItem sharedIconList1[] =
{
- { LPGEN("Privacy Lists"), "privacylists", IDI_PRIVACY_LISTS },
- { LPGEN("Bookmarks"), "bookmarks", IDI_BOOKMARKS },
- { LPGEN("Notes"), "notes", IDI_NOTES },
- { LPGEN("Multi-User Conference"), "group", IDI_GROUP },
- { LPGEN("Agents list"), "Agents", IDI_AGENTS },
- { LPGEN("Transports"), "transport", IDI_TRANSPORT },
- { LPGEN("Registered transports"), "transport_loc", IDI_TRANSPORTL },
- { LPGEN("Change password"), "key", IDI_KEYS },
- { LPGEN("Personal vCard"), "vcard", IDI_VCARD },
- { LPGEN("Convert to room"), "convert", IDI_USER2ROOM },
- { LPGEN("Login/logout"), "trlogonoff", IDI_LOGIN },
- { LPGEN("Resolve nicks"), "trresolve", IDI_REFRESH },
- { LPGEN("Send note"), "sendnote", IDI_SEND_NOTE, },
- { LPGEN("Service Discovery"), "servicediscovery", IDI_SERVICE_DISCOVERY },
- { LPGEN("AdHoc Command"), "adhoc", IDI_COMMAND },
- { LPGEN("XML Console"), "xmlconsole", IDI_CONSOLE },
- { LPGEN("OpenID Request"), "openid", IDI_HTTP_AUTH }
+ { LPGEN("Privacy Lists"), "privacylists", IDI_PRIVACY_LISTS },
+ { LPGEN("Bookmarks"), "bookmarks", IDI_BOOKMARKS },
+ { LPGEN("Notes"), "notes", IDI_NOTES },
+ { LPGEN("Multi-User Conference"), "group", IDI_GROUP },
+ { LPGEN("Agents list"), "Agents", IDI_AGENTS },
+ { LPGEN("Transports"), "transport", IDI_TRANSPORT },
+ { LPGEN("Registered transports"), "transport_loc", IDI_TRANSPORTL },
+ { LPGEN("Change password"), "key", IDI_KEYS },
+ { LPGEN("Personal vCard"), "vcard", IDI_VCARD },
+ { LPGEN("Convert to room"), "convert", IDI_USER2ROOM },
+ { LPGEN("Login/logout"), "trlogonoff", IDI_LOGIN },
+ { LPGEN("Resolve nicks"), "trresolve", IDI_REFRESH },
+ { LPGEN("Send note"), "sendnote", IDI_SEND_NOTE, },
+ { LPGEN("Service Discovery"), "servicediscovery", IDI_SERVICE_DISCOVERY },
+ { LPGEN("AdHoc Command"), "adhoc", IDI_COMMAND },
+ { LPGEN("XML Console"), "xmlconsole", IDI_CONSOLE },
+ { LPGEN("OpenID Request"), "openid", IDI_HTTP_AUTH }
};
static IconItem sharedIconList2[] =
{
- { LPGEN("Discovery succeeded"), "disco_ok", IDI_DISCO_OK },
- { LPGEN("Discovery failed"), "disco_fail", IDI_DISCO_FAIL },
- { LPGEN("Discovery in progress"), "disco_progress", IDI_DISCO_PROGRESS },
- { LPGEN("View as tree"), "sd_view_tree", IDI_VIEW_TREE },
- { LPGEN("View as list"), "sd_view_list", IDI_VIEW_LIST },
- { LPGEN("Apply filter"), "sd_filter_apply", IDI_FILTER_APPLY },
- { LPGEN("Reset filter"), "sd_filter_reset", IDI_FILTER_RESET }
+ { LPGEN("Discovery succeeded"), "disco_ok", IDI_DISCO_OK },
+ { LPGEN("Discovery failed"), "disco_fail", IDI_DISCO_FAIL },
+ { LPGEN("Discovery in progress"), "disco_progress", IDI_DISCO_PROGRESS },
+ { LPGEN("View as tree"), "sd_view_tree", IDI_VIEW_TREE },
+ { LPGEN("View as list"), "sd_view_list", IDI_VIEW_LIST },
+ { LPGEN("Apply filter"), "sd_filter_apply", IDI_FILTER_APPLY },
+ { LPGEN("Reset filter"), "sd_filter_reset", IDI_FILTER_RESET }
};
static IconItem sharedIconList3[] =
{
- { LPGEN("Navigate home"), "sd_nav_home", IDI_NAV_HOME },
- { LPGEN("Refresh node"), "sd_nav_refresh", IDI_NAV_REFRESH },
- { LPGEN("Browse node"), "sd_browse", IDI_BROWSE },
- { LPGEN("RSS service"), "node_rss", IDI_NODE_RSS },
- { LPGEN("Server"), "node_server", IDI_NODE_SERVER },
- { LPGEN("Storage service"), "node_store", IDI_NODE_STORE },
- { LPGEN("Weather service"), "node_weather", IDI_NODE_WEATHER }
+ { LPGEN("Navigate home"), "sd_nav_home", IDI_NAV_HOME },
+ { LPGEN("Refresh node"), "sd_nav_refresh", IDI_NAV_REFRESH },
+ { LPGEN("Browse node"), "sd_browse", IDI_BROWSE },
+ { LPGEN("RSS service"), "node_rss", IDI_NODE_RSS },
+ { LPGEN("Server"), "node_server", IDI_NODE_SERVER },
+ { LPGEN("Storage service"), "node_store", IDI_NODE_STORE },
+ { LPGEN("Weather service"), "node_weather", IDI_NODE_WEATHER }
};
static IconItem sharedIconList4[] =
{
- { LPGEN("Generic privacy list"), "pl_list_any", IDI_PL_LIST_ANY },
- { LPGEN("Active privacy list"), "pl_list_active", IDI_PL_LIST_ACTIVE },
- { LPGEN("Default privacy list"), "pl_list_default", IDI_PL_LIST_DEFAULT },
- { LPGEN("Move up"), "arrow_up", IDI_ARROW_UP },
- { LPGEN("Move down"), "arrow_down", IDI_ARROW_DOWN },
- { LPGEN("Allow Messages"), "pl_msg_allow", IDI_PL_MSG_ALLOW },
- { LPGEN("Allow Presences (in)"), "pl_prin_allow", IDI_PL_PRIN_ALLOW },
- { LPGEN("Allow Presences (out)"), "pl_prout_allow", IDI_PL_PROUT_ALLOW },
- { LPGEN("Allow Queries"), "pl_iq_allow", IDI_PL_QUERY_ALLOW },
- { LPGEN("Deny Messages"), "pl_msg_deny", IDI_PL_MSG_DENY },
- { LPGEN("Deny Presences (in)"), "pl_prin_deny", IDI_PL_PRIN_DENY },
- { LPGEN("Deny Presences (out)"), "pl_prout_deny", IDI_PL_PROUT_DENY },
- { LPGEN("Deny Queries"), "pl_iq_deny", IDI_PL_QUERY_DENY }
+ { LPGEN("Generic privacy list"), "pl_list_any", IDI_PL_LIST_ANY },
+ { LPGEN("Active privacy list"), "pl_list_active", IDI_PL_LIST_ACTIVE },
+ { LPGEN("Default privacy list"), "pl_list_default", IDI_PL_LIST_DEFAULT },
+ { LPGEN("Move up"), "arrow_up", IDI_ARROW_UP },
+ { LPGEN("Move down"), "arrow_down", IDI_ARROW_DOWN },
+ { LPGEN("Allow Messages"), "pl_msg_allow", IDI_PL_MSG_ALLOW },
+ { LPGEN("Allow Presences (in)"), "pl_prin_allow", IDI_PL_PRIN_ALLOW },
+ { LPGEN("Allow Presences (out)"), "pl_prout_allow", IDI_PL_PROUT_ALLOW },
+ { LPGEN("Allow Queries"), "pl_iq_allow", IDI_PL_QUERY_ALLOW },
+ { LPGEN("Deny Messages"), "pl_msg_deny", IDI_PL_MSG_DENY },
+ { LPGEN("Deny Presences (in)"), "pl_prin_deny", IDI_PL_PRIN_DENY },
+ { LPGEN("Deny Presences (out)"), "pl_prout_deny", IDI_PL_PROUT_DENY },
+ { LPGEN("Deny Queries"), "pl_iq_deny", IDI_PL_QUERY_DENY }
};
void g_IconsInit()
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 0ba244248e..55fd4c8e7d 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -714,7 +714,7 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/) if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == NULL)
item = ListGetItemPtr(LIST_ROSTER, jid);
- if ( !item) {
+ if (item == NULL) {
TCHAR szBareJid[JABBER_MAX_JID_LEN];
_tcsncpy(szBareJid, jid, SIZEOF(szBareJid));
TCHAR *pDelimiter = _tcschr(szBareJid, _T('/'));
@@ -735,34 +735,36 @@ int __cdecl CJabberProto::GetInfo(HANDLE hContact, int /*infoType*/) else item = ListAdd(LIST_VCARD_TEMP, jid);
}
- if (item && item->arResources.getCount()) {
- for (int i = 0; i < item->arResources.getCount(); i++) {
- pResourceStatus r(item->arResources[i]);
- TCHAR szp1[JABBER_MAX_JID_LEN], tmp[JABBER_MAX_JID_LEN];
- JabberStripJid(jid, szp1, SIZEOF(szp1));
- mir_sntprintf(tmp, SIZEOF(tmp), _T("%s/%s"), szp1, r->m_tszResourceName);
-
- XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
- iq3 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
- m_ThreadInfo->send(iq3);
-
- if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) {
- XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
- iq5 << XQUERY(JABBER_FEAT_DISCO_INFO);
- m_ThreadInfo->send(iq5);
- }
+ if (item != NULL) {
+ if (item->arResources.getCount()) {
+ for (int i = 0; i < item->arResources.getCount(); i++) {
+ pResourceStatus r(item->arResources[i]);
+ TCHAR szp1[JABBER_MAX_JID_LEN], tmp[JABBER_MAX_JID_LEN];
+ JabberStripJid(jid, szp1, SIZEOF(szp1));
+ mir_sntprintf(tmp, SIZEOF(tmp), _T("%s/%s"), szp1, r->m_tszResourceName);
+
+ XmlNodeIq iq3(m_iqManager.AddHandler(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
+ iq3 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
+ m_ThreadInfo->send(iq3);
+
+ if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) {
+ XmlNodeIq iq5(m_iqManager.AddHandler(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
+ iq5 << XQUERY(JABBER_FEAT_DISCO_INFO);
+ m_ThreadInfo->send(iq5);
+ }
- if ( !r->m_dwVersionRequestTime) {
- XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
- iq4 << XQUERY(JABBER_FEAT_VERSION);
- m_ThreadInfo->send(iq4);
+ if ( !r->m_dwVersionRequestTime) {
+ XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ iq4 << XQUERY(JABBER_FEAT_VERSION);
+ m_ThreadInfo->send(iq4);
+ }
}
}
- }
- else if ( !item->m_pItemResource->m_dwVersionRequestTime) {
- XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
- iq4 << XQUERY(JABBER_FEAT_VERSION);
- m_ThreadInfo->send(iq4);
+ else if (item->m_pItemResource && item->m_pItemResource->m_dwVersionRequestTime == 0) {
+ XmlNodeIq iq4(m_iqManager.AddHandler(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
+ iq4 << XQUERY(JABBER_FEAT_VERSION);
+ m_ThreadInfo->send(iq4);
+ }
}
}
@@ -1377,9 +1379,8 @@ int __cdecl CJabberProto::SetAwayMsg(int status, const TCHAR *msg) {
Log("SetAwayMsg called, wParam=%d lParam=%S", status, msg);
- EnterCriticalSection(&m_csModeMsgMutex);
-
TCHAR **szMsg;
+ mir_cslockfull lck(m_csModeMsgMutex);
switch (status) {
case ID_STATUS_ONLINE:
@@ -1408,7 +1409,6 @@ int __cdecl CJabberProto::SetAwayMsg(int status, const TCHAR *msg) break;
default:
- LeaveCriticalSection(&m_csModeMsgMutex);
return 1;
}
@@ -1418,7 +1418,6 @@ int __cdecl CJabberProto::SetAwayMsg(int status, const TCHAR *msg) (*szMsg != NULL && newModeMsg != NULL && !lstrcmp(*szMsg, newModeMsg))) {
// Message is the same, no update needed
mir_free(newModeMsg);
- LeaveCriticalSection(&m_csModeMsgMutex);
}
else {
// Update with the new mode message
@@ -1426,7 +1425,7 @@ int __cdecl CJabberProto::SetAwayMsg(int status, const TCHAR *msg) mir_free(*szMsg);
*szMsg = newModeMsg;
// Send a presence update if needed
- LeaveCriticalSection(&m_csModeMsgMutex);
+ lck.unlock();
if (status == m_iStatus)
SendPresence(m_iStatus, true);
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index df56450d5b..6c2bdb3d12 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -43,7 +43,7 @@ INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) TCHAR *szStatus = NULL;
INT_PTR nRetVal = 0;
- EnterCriticalSection(&m_csModeMsgMutex);
+ mir_cslock lck(m_csModeMsgMutex);
switch (wParam ? (int)wParam : m_iStatus) {
case ID_STATUS_ONLINE:
szStatus = m_modeMsgs.szOnline;
@@ -63,13 +63,11 @@ INT_PTR __cdecl CJabberProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam) case ID_STATUS_FREECHAT:
szStatus = m_modeMsgs.szFreechat;
break;
- default:
- // Should not reach here
+ default: // Should not reach here
break;
}
if (szStatus)
nRetVal = (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(szStatus) : (INT_PTR)mir_t2a(szStatus);
- LeaveCriticalSection(&m_csModeMsgMutex);
return nRetVal;
}
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 13b058820e..577a71198f 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -619,80 +619,52 @@ void CJabberProto::SendPresenceTo(int status, TCHAR* to, HXML extra, const TCHAR HXML c = p << XCHILDNS(_T("c"), JABBER_FEAT_ENTITY_CAPS) << XATTR(_T("node"), JABBER_CAPS_MIRANDA_NODE)
<< XATTR(_T("ver"), szCoreVersion);
- TCHAR szExtCaps[ 512 ] = _T("");
-
+ LIST<TCHAR> arrExtCaps(5);
if (m_bGoogleTalk)
- _tcscat(szExtCaps, _T(JABBER_EXT_GTALK_PMUC));
+ arrExtCaps.insert( _T(JABBER_EXT_GTALK_PMUC));
- if (bSecureIM) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_SECUREIM));
- }
+ if (bSecureIM)
+ arrExtCaps.insert( _T(JABBER_EXT_SECUREIM));
- if (bMirOTR) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_MIROTR));
- }
+ if (bMirOTR)
+ arrExtCaps.insert( _T(JABBER_EXT_MIROTR));
- if (bNewGPG) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_NEWGPG));
- }
+ if (bNewGPG)
+ arrExtCaps.insert( _T(JABBER_EXT_NEWGPG));
- if (bPlatform) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_PLATFORMX64));
- } else {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_PLATFORMX86));
- }
+ if (bPlatform)
+ arrExtCaps.insert( _T(JABBER_EXT_PLATFORMX64));
+ else
+ arrExtCaps.insert( _T(JABBER_EXT_PLATFORMX86));
- if (m_options.EnableRemoteControl) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_COMMANDS));
- }
+ if (m_options.EnableRemoteControl)
+ arrExtCaps.insert( _T(JABBER_EXT_COMMANDS));
- if (m_options.EnableUserMood) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_USER_MOOD));
- }
+ if (m_options.EnableUserMood)
+ arrExtCaps.insert( _T(JABBER_EXT_USER_MOOD));
- if (m_options.EnableUserTune) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_USER_TUNE));
- }
+ if (m_options.EnableUserTune)
+ arrExtCaps.insert( _T(JABBER_EXT_USER_TUNE));
- if (m_options.EnableUserActivity) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_USER_ACTIVITY));
- }
+ if (m_options.EnableUserActivity)
+ arrExtCaps.insert( _T(JABBER_EXT_USER_ACTIVITY));
- if (m_options.AcceptNotes) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, _T(JABBER_EXT_MIR_NOTES));
- }
+ if (m_options.AcceptNotes)
+ arrExtCaps.insert( _T(JABBER_EXT_MIR_NOTES));
// add features enabled through IJabberNetInterface::AddFeatures()
- for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
- if (m_uEnabledFeatCapsDynamic & m_lstJabberFeatCapPairsDynamic[i]->jcbCap) {
- if (szExtCaps[0])
- _tcscat(szExtCaps, _T(" "));
- _tcscat(szExtCaps, m_lstJabberFeatCapPairsDynamic[i]->szExt);
+ for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
+ if (m_uEnabledFeatCapsDynamic & m_lstJabberFeatCapPairsDynamic[i]->jcbCap)
+ arrExtCaps.insert(m_lstJabberFeatCapPairsDynamic[i]->szExt);
+
+ if (arrExtCaps.getCount()) {
+ CMString szExtCaps = arrExtCaps[0];
+ for (int i=1; i < arrExtCaps.getCount(); i++) {
+ szExtCaps.AppendChar(' ');
+ szExtCaps += arrExtCaps[i];
}
- }
-
- if (szExtCaps[0])
xmlAddAttr(c, _T("ext"), szExtCaps);
+ }
if (m_options.EnableAvatars) {
HXML x = p << XCHILDNS(_T("x"), _T("vcard-temp:x:update"));
@@ -703,46 +675,46 @@ void CJabberProto::SendPresenceTo(int status, TCHAR* to, HXML extra, const TCHAR else
x << XCHILD(_T("photo"));
}
+ {
+ mir_cslock lck(m_csModeMsgMutex);
+ switch (status) {
+ case ID_STATUS_ONLINE:
+ if (!msg) msg = m_modeMsgs.szOnline;
+ break;
+ case ID_STATUS_INVISIBLE:
+ if (!m_bGoogleSharedStatus)
+ p << XATTR(_T("type"), _T("invisible"));
+ break;
+ case ID_STATUS_AWAY:
+ case ID_STATUS_ONTHEPHONE:
+ case ID_STATUS_OUTTOLUNCH:
+ p << XCHILD(_T("show"), _T("away"));
+ if (!msg) msg = m_modeMsgs.szAway;
+ break;
+ case ID_STATUS_NA:
+ p << XCHILD(_T("show"), _T("xa"));
+ if (!msg) msg = m_modeMsgs.szNa;
+ break;
+ case ID_STATUS_DND:
+ case ID_STATUS_OCCUPIED:
+ p << XCHILD(_T("show"), _T("dnd"));
+ if (!msg) msg = m_modeMsgs.szDnd;
+ break;
+ case ID_STATUS_FREECHAT:
+ p << XCHILD(_T("show"), _T("chat"));
+ if (!msg) msg = m_modeMsgs.szFreechat;
+ break;
+ default: // Should not reach here
+ break;
+ }
- EnterCriticalSection(&m_csModeMsgMutex);
- switch (status) {
- case ID_STATUS_ONLINE:
- if ( !msg) msg = m_modeMsgs.szOnline;
- break;
- case ID_STATUS_INVISIBLE:
- if ( !m_bGoogleSharedStatus) p << XATTR(_T("type"), _T("invisible"));
- break;
- case ID_STATUS_AWAY:
- case ID_STATUS_ONTHEPHONE:
- case ID_STATUS_OUTTOLUNCH:
- p << XCHILD(_T("show"), _T("away"));
- if ( !msg) msg = m_modeMsgs.szAway;
- break;
- case ID_STATUS_NA:
- p << XCHILD(_T("show"), _T("xa"));
- if ( !msg) msg = m_modeMsgs.szNa;
- break;
- case ID_STATUS_DND:
- case ID_STATUS_OCCUPIED:
- p << XCHILD(_T("show"), _T("dnd"));
- if ( !msg) msg = m_modeMsgs.szDnd;
- break;
- case ID_STATUS_FREECHAT:
- p << XCHILD(_T("show"), _T("chat"));
- if ( !msg) msg = m_modeMsgs.szFreechat;
- break;
- default:
- // Should not reach here
- break;
- }
-
- if (msg)
- p << XCHILD(_T("status"), msg);
+ if (msg)
+ p << XCHILD(_T("status"), msg);
- if (m_bGoogleSharedStatus && !to)
- SendIqGoogleSharedStatus(status, msg);
+ if (m_bGoogleSharedStatus && !to)
+ SendIqGoogleSharedStatus(status, msg);
+ }
- LeaveCriticalSection(&m_csModeMsgMutex);
m_ThreadInfo->send(p);
}
|