Exemple #1
0
INT_PTR __cdecl CJabberProto::OnMenuTransportLogin(WPARAM hContact, LPARAM)
{
    if (!getByte(hContact, "IsTransport", 0))
        return 0;

    JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrT(getTStringA(hContact, "jid")));
    if (item != NULL) {
        XmlNode p(_T("presence"));
        XmlAddAttr(p, _T("to"), item->jid);
        if (item->getTemp()->m_iStatus == ID_STATUS_ONLINE)
            XmlAddAttr(p, _T("type"), _T("unavailable"));
        m_ThreadInfo->send(p);
    }
    return 0;
}
Exemple #2
0
bool CJabberProto::ListAddResource(JABBER_LIST list, const TCHAR *jid, int status, const TCHAR *statusMessage, char priority, const TCHAR *nick)
{
	mir_cslockfull lck(m_csLists);
	JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
	if (LI == NULL)
		return false;

	bool bIsNewResource = false;

	const TCHAR *p = _tcschr(jid, '@');
	const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
	if (q) {
		const TCHAR *resource = q+1;
		if (*resource == 0)
			return 0;

		JABBER_RESOURCE_STATUS *r = LI->findResource(resource);
		if (r != NULL) { // Already exists, update status and statusMessage
			r->m_iStatus = status;
			r->m_tszStatusMessage = mir_tstrdup(statusMessage);
			r->m_iPriority = priority;
		}
		else { // Does not exist, add new resource
			bIsNewResource = true;
			r = new JABBER_RESOURCE_STATUS();
			r->m_iStatus = status;
			r->m_affiliation = AFFILIATION_NONE;
			r->m_role = ROLE_NONE;
			r->m_tszResourceName = mir_tstrdup(resource);
			r->m_tszNick = mir_tstrdup(nick);
			if (statusMessage)
				r->m_tszStatusMessage = mir_tstrdup(statusMessage);
			r->m_iPriority = priority;
			LI->arResources.insert(r);
		}
	}
	// No resource, update the main statusMessage
	else {
		JABBER_RESOURCE_STATUS *r = LI->getTemp();
		r->m_iStatus = status;
		r->m_tszStatusMessage = mir_tstrdup(statusMessage);
	}

	lck.unlock();

	MenuUpdateSrmmIcon(LI);
	return bIsNewResource;
}