Пример #1
0
void Client::importRosterItem(const RosterItem &item)
{
	QString substr;
	switch(item.subscription().type()) {
		case Subscription::Both:
			substr = "<-->";  break;
		case Subscription::From:
			substr = "  ->";  break;
		case Subscription::To:
			substr = "<-  ";  break;
		case Subscription::Remove:
			substr = "xxxx";  break;
		case Subscription::None:
		default:
			substr = "----";  break;
	}

	QString dstr, str;
	str.sprintf("  %s %-32s", substr.latin1(), item.jid().full().latin1());
	if(!item.name().isEmpty())
		str += QString(" [") + item.name() + "]";
	str += '\n';

	// Remove
	if(item.subscription().type() == Subscription::Remove) {
		LiveRoster::Iterator it = d->roster.find(item.jid());
		if(it != d->roster.end()) {
			rosterItemRemoved(*it);
			d->roster.remove(it);
		}
		dstr = "Client: (Removed) ";
	}
	// Add/Update
	else {
		LiveRoster::Iterator it = d->roster.find(item.jid());
		if(it != d->roster.end()) {
			LiveRosterItem &i = *it;
			i.setFlagForDelete(false);
			i.setRosterItem(item);
			rosterItemUpdated(i);
			dstr = "Client: (Updated) ";
                }
		else {
			LiveRosterItem i(item);
			d->roster += i;

			// signal it
			rosterItemAdded(i);
			dstr = "Client: (Added)   ";
		}
	}

	debug(dstr + str);
}
Пример #2
0
void LiveRosterItem::setRosterItem(const RosterItem &i)
{
	setJid(i.jid());
	setName(i.name());
	setGroups(i.groups());
	setSubscription(i.subscription());
	setAsk(i.ask());
	setIsPush(i.isPush());
}
Пример #3
0
void CMainFrame::handleRosterPresence( const RosterItem& item, const std::string& resource,
									  Presence::PresenceType presence, const std::string& msg ) 

{
	if(m_pBuddyList)
	{
		CBuddyListItem* buddy= m_pBuddyList->FindBuddyItem(item.jid());
		if(buddy)
		{
			bool online=buddy->IsOnline();
			buddy->SetPresence(presence);
			buddy->SetSignature(utf8dec(msg));
			if(online!=buddy->IsOnline())
			{
				buddy->SetHeader(GetContext()->GetHeaderManager().GetHeader(item.jid(),buddy->IsOnline()));
			}
		}
	}
}
Пример #4
0
	void handleRosterPresence( const RosterItem& item, const std::string& resource, Presence presence, const std::string& msg ) {

		jsval fval;
		if ( !JS_GetProperty(_cx, _obj, "onRosterPresence", &fval) || fval.isUndefined() )
			return;
		if ( !JL_ValueIsCallable(_cx, fval) ) {

			JS_ReportError(_cx, "onRosterPresence is not a function.");
			return;
		}

		jsval fromVal, presenceVal, msgVal, tmp;
		JidToJsval(_cx, &JID(item.jid()), &fromVal);
		JL_NativeToJsval(_cx, presence, &presenceVal);
		JL_NativeToJsval(_cx, msg.c_str(), &msgVal);

		jsval argv[] = { fromVal, presenceVal, msgVal };
		JS_CallFunctionValue(_cx, _obj, fval, COUNTOF(argv), argv, &tmp); // errors will be managed later by JL_IsExceptionPending(cx)
	}
Пример #5
0
void Core::handleRosterPresence(const RosterItem &item, const std::string &resource, Presence::PresenceType presence, const std::string &msg){
		write_string("You have received a status update of: " + item.jid() + " (" + msg + ")");
		// some bugs with item.jid(), check caracters issues
		update_roster_choice();
}		
Пример #6
0
 virtual void handleSelfPresence( const RosterItem& item, const std::string& resource,
                                    Presence presence, const std::string& /*msg*/ )
 {
   printf( "self presence received: %s/%s -- %d\n", item.jid().c_str(), resource.c_str(), presence );
 }
Пример #7
0
 virtual void presenceUpdated( const RosterItem& item, int /*status*/, const std::string& /*msg*/ )
 {
   printf( "item changed: %s\n", item.jid().c_str() );
 }
Пример #8
0
 virtual void itemUnavailable( const RosterItem& item, const std::string& /*msg*/ )
 {
   printf( "item offline: %s\n", item.jid().c_str() );
 };