Exemplo n.º 1
0
void CJabberProto::ListRemoveResource(JABBER_LIST list, const TCHAR *jid)
{
	mir_cslockfull lck(m_csLists);
	JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
	if (LI == NULL)
		return;

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

	pResourceStatus r( LI->findResource(q+1));
	if (r == NULL)
		return;

	// Found last seen resource ID to be removed
	if (LI->m_pLastSeenResource == r)
		LI->m_pLastSeenResource = NULL;

	// update manually selected resource ID
	if (LI->resourceMode == RSMODE_MANUAL && LI->m_pManualResource == r) {
		LI->resourceMode = RSMODE_LASTSEEN;
		LI->m_pManualResource = NULL;
	}

	// Update MirVer due to possible resource changes
	UpdateMirVer(LI);

	LI->arResources.remove(r);
	r->Release();
	lck.unlock();

	MenuUpdateSrmmIcon(LI);
}
Exemplo n.º 2
0
pResourceStatus CJabberProto::ListFindResource(JABBER_LIST list, const TCHAR *jid)
{
	mir_cslock lck(m_csLists);
	JABBER_LIST_ITEM *LI = ListGetItemPtr(list, jid);
	if (LI == NULL)
		return NULL;

	const TCHAR *p = _tcschr(jid, '@');
	const TCHAR *q = _tcschr((p == NULL) ? jid : p, '/');
	return (q == NULL) ? NULL : LI->findResource(q+1);
}
Exemplo n.º 3
0
INT_PTR __cdecl CJabberProto::JabberGCGetToolTipText(WPARAM wParam, LPARAM lParam)
{
	if (!wParam || !lParam)
		return 0; //room global tooltip not supported yet

	JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_CHATROOM, (TCHAR*)wParam);
	if (item == NULL)
		return 0;  //no room found

	pResourceStatus info( item->findResource((TCHAR*)lParam));
	if (info == NULL)
		return 0; //no info found

	// ok process info output will be:
	// JID:			real@jid/resource or
	// Nick:		Nickname
	// Status:		StatusText
	// Role:		Moderator
	// Affiliation:  Affiliation

	TCHAR outBuf[2048];
	outBuf[0]=0;

	bool bIsTipper = db_get_b(NULL, "Tab_SRMsg", "adv_TipperTooltip", 0) && ServiceExists("mToolTip/HideTip");

	//JID:
	if (_tcschr(info->m_tszResourceName, _T('@')) != NULL)
		appendString(bIsTipper, LPGENT("JID:"), info->m_tszResourceName, outBuf, SIZEOF(outBuf));
	else if (lParam) //or simple nick
		appendString(bIsTipper, LPGENT("Nick:"), (TCHAR*)lParam, outBuf, SIZEOF(outBuf));

	// status
	if (info->m_iStatus >= ID_STATUS_OFFLINE && info->m_iStatus <= ID_STATUS_IDLE )
		appendString(bIsTipper, LPGENT("Status:"), pcli->pfnGetStatusModeDescription(info->m_iStatus, 0), outBuf, SIZEOF(outBuf));

	// status text
	if (info->m_tszStatusMessage)
		appendString(bIsTipper, LPGENT("Status text:"), info->m_tszStatusMessage, outBuf, SIZEOF(outBuf));

	// Role
	appendString(bIsTipper, LPGENT("Role:"), TranslateTS(JabberEnum2RoleStr[info->m_role]), outBuf, SIZEOF(outBuf));

	// Affiliation
	appendString(bIsTipper, LPGENT("Affiliation:"), TranslateTS(JabberEnum2AffilationStr[info->m_affiliation]), outBuf, SIZEOF(outBuf));

	// real jid
	if (info->m_tszRealJid)
		appendString(bIsTipper, LPGENT("Real JID:"), info->m_tszRealJid, outBuf, SIZEOF(outBuf));

	return (outBuf[0] == 0 ? NULL : (INT_PTR) mir_tstrdup(outBuf));
}
Exemplo n.º 4
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;
}
Exemplo n.º 5
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;
}
Exemplo n.º 6
0
TCHAR* CJabberProto::ListGetBestClientResourceNamePtr(const TCHAR *jid)
{
	mir_cslock lck(m_csLists);
	JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
	if (LI == NULL)
		return NULL;

	pResourceStatus r( LI->getBestResource());
	if (r != NULL)
		return r->m_tszResourceName;

	int status = ID_STATUS_OFFLINE;
	TCHAR *res = NULL;
	for (int i=0; i < LI->arResources.getCount(); i++) {
		r = LI->arResources[i];
		bool foundBetter = false;
		switch (r->m_iStatus) {
		case ID_STATUS_FREECHAT:
			foundBetter = true;
			break;
		case ID_STATUS_ONLINE:
			if (status != ID_STATUS_FREECHAT)
				foundBetter = true;
			break;
		case ID_STATUS_DND:
			if (status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE)
				foundBetter = true;
			break;
		case ID_STATUS_AWAY:
			if (status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE && status != ID_STATUS_DND)
				foundBetter = true;
			break;
		case ID_STATUS_NA:
			if (status != ID_STATUS_FREECHAT && status != ID_STATUS_ONLINE && status != ID_STATUS_DND && status != ID_STATUS_AWAY)
				foundBetter = true;
			break;
		}
		if (foundBetter) {
			res = r->m_tszResourceName;
			status = r->m_iStatus;
		}
	}

	return res;
}