Beispiel #1
0
void CJabberProto::GroupchatJoinRoom( const TCHAR* server, const TCHAR* room, const TCHAR* nick, const TCHAR* password, bool autojoin )
{
	JabberGcRecentInfo info( this );

	int i = 0;
	bool found = false;
	for (i = 0 ; i < 5; ++i)
	{
		if (!info.loadRecent(i))
			continue;

		if (info.equals(room, server, nick, password))
		{
			found = true;
			break;
		}
	}

	if (!found)
	{
		for (int i = 4; i--; )
		{
			if (info.loadRecent(i))
				info.saveRecent(i + 1);
		}

		info.fillData(room, server, nick, password);
		info.saveRecent(0);
	}

	TCHAR jid[512];
	mir_sntprintf( jid, SIZEOF(jid), _T("%s@%s/%s"), room, server, nick );

	JABBER_LIST_ITEM* item = ListAdd( LIST_CHATROOM, jid );
	item->bAutoJoin = autojoin;
	replaceStr( item->nick, nick );
	replaceStr( item->password, info.password );

	int status = ( m_iStatus == ID_STATUS_INVISIBLE ) ? ID_STATUS_ONLINE : m_iStatus;
	XmlNode x( _T("x")); x << XATTR( _T("xmlns"), _T(JABBER_FEAT_MUC));
	if ( info.password && info.password[0] )
		x << XCHILD( _T("password"), info.password );

	if (m_options.GcLogChatHistory) {
		HANDLE hContact = ChatRoomHContactFromJID(jid);
		time_t lasteventtime = JGetDword(hContact, "muc_lastevent", 0);
		if (hContact && lasteventtime) {
			TCHAR lasteventdate[40];
			tmi.printTimeStamp(UTC_TIME_HANDLE, lasteventtime, _T("I"), lasteventdate, SIZEOF(lasteventdate), 0);
			x << XCHILD( _T("history") ) << XATTR( _T("since"), lasteventdate);
		}	
	}

	SendPresenceTo( status, jid, x );
}
Beispiel #2
0
JABBER_LIST_ITEM *CJabberProto::ListAdd( JABBER_LIST list, const TCHAR* jid )
{
	JABBER_LIST_ITEM* item;
	BOOL bUseResource=FALSE;
	EnterCriticalSection( &m_csLists );
	if (( item = ListGetItemPtr( list, jid )) != NULL ) {
		LeaveCriticalSection( &m_csLists );
		return item;
	}

	TCHAR *s = mir_tstrdup( jid );
	TCHAR *q = NULL;
	// strip resource name if any
	//fyr
	if ( !((list== LIST_ROSTER )  && ListExist(LIST_CHATROOM, jid))) { // but only if it is not chat room contact	
		if ( list != LIST_VCARD_TEMP ) {
			TCHAR *p;
			if (( p = _tcschr( s, '@' )) != NULL )
				if (( q = _tcschr( p, '/' )) != NULL )
					*q = '\0';
		}
	} else {
		bUseResource=TRUE;
	}
	
	if ( !bUseResource && list== LIST_ROSTER )
	{
		//if it is a chat room keep resource and made it resource sensitive
		if ( ChatRoomHContactFromJID( s ) )
		{
			if (q != NULL)	*q='/';
			bUseResource=TRUE;
		}
	}
	item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM ));
	ZeroMemory( item, sizeof( JABBER_LIST_ITEM ));
	item->list = list;
	item->jid = s;
	item->itemResource.status = ID_STATUS_OFFLINE;
	item->resource = NULL;
	item->resourceMode = RSMODE_LASTSEEN;
	item->lastSeenResource = -1;
	item->manualResource = -1;
	item->bUseResource = bUseResource;

	m_lstRoster.insert( item );
	LeaveCriticalSection( &m_csLists );

	MenuUpdateSrmmIcon(item);
	return item;
}
Beispiel #3
0
JABBER_LIST_ITEM *CJabberProto::ListAdd(JABBER_LIST list, const TCHAR *jid)
{
	bool bUseResource = false;
	mir_cslockfull lck(m_csLists);

	JABBER_LIST_ITEM *item = ListGetItemPtr(list, jid);
	if (item != NULL)
		return item;

	TCHAR *s = mir_tstrdup(jid);
	TCHAR *q = NULL;
	// strip resource name if any
	//fyr
	if (!((list== LIST_ROSTER)  && ListGetItemPtr(LIST_CHATROOM, jid))) { // but only if it is not chat room contact
		if (list != LIST_VCARD_TEMP) {
			TCHAR *p;
			if ((p = _tcschr(s, '@')) != NULL)
				if ((q = _tcschr(p, '/')) != NULL)
					*q = '\0';
		}
	}
	else bUseResource = true;

	if (!bUseResource && list == LIST_ROSTER) {
		//if it is a chat room keep resource and made it resource sensitive
		if (ChatRoomHContactFromJID(s)) {
			if (q != NULL)
				*q='/';
			bUseResource = true;
		}
	}

	item = new JABBER_LIST_ITEM();
	item->list = list;
	item->jid = s;
	item->resourceMode = RSMODE_LASTSEEN;
	item->bUseResource = bUseResource;
	m_lstRoster.insert(item);
	lck.unlock();

	MenuUpdateSrmmIcon(item);
	return item;
}