Esempio n. 1
0
void WPAccount::setOnlineStatus(const Kopete::OnlineStatus &status, const QString &reason)
{
	if (myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Online)
		connect( status );
	else if (myself()->onlineStatus().status() != Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Offline)
		disconnect();
	else if (myself()->onlineStatus().status() != Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Away)
		setAway( true, reason );
}
void JabberTransport::setOnlineStatus( const Kopete::OnlineStatus& status  , const QString &reason)
{
#if 0
	if( status.status() == Kopete::OnlineStatus::Offline )
	{
		disconnect( Kopete::Account::Manual );
		return;
	}

	if( isConnecting () )
	{
		errorConnectionInProgress ();
		return;
	}

	XMPP::Status xmppStatus ( "", reason );

	switch ( status.internalStatus () )
	{
		case JabberProtocol::JabberFreeForChat:
			xmppStatus.setShow ( "chat" );
			break;

		case JabberProtocol::JabberOnline:
			xmppStatus.setShow ( "" );
			break;

		case JabberProtocol::JabberAway:
			xmppStatus.setShow ( "away" );
			break;

		case JabberProtocol::JabberXA:
			xmppStatus.setShow ( "xa" );
			break;

		case JabberProtocol::JabberDND:
			xmppStatus.setShow ( "dnd" );
			break;

		case JabberProtocol::JabberInvisible:
			xmppStatus.setIsInvisible ( true );
			break;
	}

	if ( !isConnected () )
	{
		// we are not connected yet, so connect now
		m_initialPresence = xmppStatus;
		connect ();
	}
	else
	{
		setPresence ( xmppStatus );
	}
#endif
}
Esempio n. 3
0
QString KopeteIface::onlineStatus( const QString &metaContactId )
{
    Kopete::MetaContact *m = Kopete::ContactList::self()->metaContact( metaContactId );
    if( m )
    {
        Kopete::OnlineStatus status = m->status();
        return status.description();
    }

    return "Unknown Contact";
}
Esempio n. 4
0
void KopeteSystemTray::slotReevaluateAccountStates()
{
	// If there is a pending message, we don't need to refresh the system tray now.
	// This function will even be called when the animation will stop.
	if ( mBlinkTimer->isActive() )
		return;

	Kopete::OnlineStatus highestStatus;
	foreach ( Kopete::Account *account, Kopete::AccountManager::self()->accounts())
	{
		if ( account->myself() && account->myself()->onlineStatus() > highestStatus )
		{
			highestStatus = account->myself()->onlineStatus();
		}
	}

	switch ( highestStatus.status() )
	{
		case Kopete::OnlineStatus::Unknown:
		case Kopete::OnlineStatus::Offline:
		case Kopete::OnlineStatus::Connecting:
		{
			setIconByName("kopete-offline");
			setOverlayIconByName("user-offline");
			break;
		}
		case Kopete::OnlineStatus::Invisible:
		{
			setIconByName(mKopeteIcon);
			setOverlayIconByName("user-invisible");
			break;
		}
		case Kopete::OnlineStatus::Away:
		{
			setIconByName(mKopeteIcon);
			setOverlayIconByName("user-away");
			break;
		}
		case Kopete::OnlineStatus::Busy:
		{
			setIconByName(mKopeteIcon);
			setOverlayIconByName("user-busy");
			break;
		}
		case Kopete::OnlineStatus::Online:
		{
			setIconByName(mKopeteIcon);
			setOverlayIconByName(QString());
			break;
		}
	}
}
Esempio n. 5
0
void FacebookAccount::setOnlineStatus(const Kopete::OnlineStatus& status, const Kopete::StatusMessage &reason, const OnlineStatusOptions& options)
{
    Q_UNUSED(options);

    if ( status.status() == Kopete::OnlineStatus::Online &&
         myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline )
        slotGoOnline();
    else if (status.status() == Kopete::OnlineStatus::Online &&
             myself()->onlineStatus().status() == Kopete::OnlineStatus::Away )
        setAway( false, reason.message() );
    else if ( status.status() == Kopete::OnlineStatus::Offline )
        slotGoOffline();
    else if ( status.status() == Kopete::OnlineStatus::Away )
        slotGoAway( /* reason */ );    
}
Esempio n. 6
0
void IRCAccount::setOnlineStatus(const Kopete::OnlineStatus& status, const Kopete::StatusMessage &reason, const OnlineStatusOptions& /*options*/)
{
	if ( status.status() == Kopete::OnlineStatus::Online &&
			myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline )
		slotGoOnline();
	else if (status.status() == Kopete::OnlineStatus::Online &&
			(myself()->onlineStatus().status() == Kopete::OnlineStatus::Away || 
				myself()->onlineStatus().status() == Kopete::OnlineStatus::Busy) )
		setAway( false, reason.message() );
	else if ( status.status() == Kopete::OnlineStatus::Offline )
		slotGoOffline();
	else if ( status.status() == Kopete::OnlineStatus::Away )
		slotGoAway( /* reason */ );
	else if ( status.status() == Kopete::OnlineStatus::Busy )
		slotGoBusy( /* reason */ );
}
Esempio n. 7
0
XMPP::Status JabberProtocol::kosToStatus( const Kopete::OnlineStatus & status , const QString & message )
{
	XMPP::Status xmppStatus ( "", message );

	if( status.status() == Kopete::OnlineStatus::Offline )
	{
		xmppStatus.setIsAvailable( false );
	}

	switch ( status.internalStatus () )
	{
		case JabberProtocol::JabberFreeForChat:
			xmppStatus.setShow ( "chat" );
			break;

		case JabberProtocol::JabberOnline:
			xmppStatus.setShow ( "" );
			break;

		case JabberProtocol::JabberAway:
			xmppStatus.setShow ( "away" );
			break;

		case JabberProtocol::JabberXA:
			xmppStatus.setShow ( "xa" );
			break;

		case JabberProtocol::JabberDND:
			xmppStatus.setShow ( "dnd" );
			break;

		case JabberProtocol::JabberInvisible:
			xmppStatus.setIsInvisible ( true );
			break;
	}
	return xmppStatus;
}
void MeanwhileSession::setStatus(Kopete::OnlineStatus status,
        const Kopete::StatusMessage &msg)
{
    HERE;
    mwDebug() << "setStatus: " << status.description() << '('
        << status.internalStatus() << ')' << endl;
    if (status.internalStatus() == 0)
        return;

    struct mwUserStatus stat;
    mwUserStatus_clone(&stat, mwSession_getUserStatus(session));

    free(stat.desc);

    stat.status = (mwStatusType)status.internalStatus();
    if (msg.isEmpty())
        stat.desc = ::strdup(status.description().toUtf8().constData());
    else
        stat.desc = ::strdup(msg.message().toUtf8().constData());

    mwSession_setUserStatus(session, &stat);
    /* will free stat.desc */
    mwUserStatus_clear(&stat);
}
Esempio n. 9
0
void GroupWiseContact::setOnlineStatus( const Kopete::OnlineStatus& status )
{
	setMessageReceivedOffline( false );
	if ( status == protocol()->groupwiseAwayIdle && status != onlineStatus() )
		setIdleTime( 1 );
	else if ( onlineStatus() == protocol()->groupwiseAwayIdle && status != onlineStatus() )
		setIdleTime( 0 );
	
	if ( account()->isContactBlocked( m_dn ) && status.internalStatus() < 15 )
	{
		Kopete::Contact::setOnlineStatus(Kopete::OnlineStatus(status.status(), (status.weight()==0) ? 0 : (status.weight() -1),
			protocol() , status.internalStatus()+15 , QStringList("msn_blocked"),
			i18n("%1|Blocked", status.description() ) ) );
	}
	else
	{
		if(status.internalStatus() >= 15)
		{	//the user is not blocked, but the status is blocked
			switch(status.internalStatus()-15)
			{
				case 0:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseUnknown );
					break;
				case 1:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseOffline );
					break;
				case 2:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseAvailable );
					break;
				case 3:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseBusy );
					break;
				case 4:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseAway );
					break;
				case 5:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseAwayIdle );
					break;
				default:
					Kopete::Contact::setOnlineStatus( GroupWiseProtocol::protocol()->groupwiseUnknown );
					break;
			}
		}
		else
			Kopete::Contact::setOnlineStatus(status);
	}
}
Esempio n. 10
0
void
WlmContact::setOnlineStatus(const Kopete::OnlineStatus& status)
{
#if 0
	bool isBlocked = qobject_cast <WlmAccount *>(account())->isOnBlockList(contactId());
	bool isOnForwardList = qobject_cast <WlmAccount *>(account())->isOnServerSideList(contactId());
	bool isOnReverseList = qobject_cast <WlmAccount *>(account())->isOnReverseList(contactId());
	
	// if this contact is blocked, and currently has a regular status,
	// create a custom status and add wlm_blocked to ovelayIcons
	if(isBlocked || (isOnForwardList && !isOnReverseList))
	{
		QStringList overelayIconsList;
		QString reason;
		if(isOnForwardList && !isOnReverseList)
		{
			overelayIconsList << "wlm_fakefriend";
			reason = i18n("This contact does not have you in his/her list");
		}

		if(isBlocked)
		{
			overelayIconsList << "wlm_blocked";
			if(reason.isEmpty())
				reason = i18n("This contact is blocked");
			else
				reason = i18n("This contact does not have you in his/her list and is blocked");
		}
		// set the new status
		Kopete::Contact::setOnlineStatus(
				Kopete::OnlineStatus(status.status() ,
				(status.weight()==0) ? 0 : (status.weight() -1),
				protocol(),
				status.internalStatus()+15,
				status.overlayIcons() + overelayIconsList,
				reason ) );
		return;
	}

	if (status.internalStatus() >= 15)
	{
		// if this contact was previously blocked, set a regular status again
		switch(status.internalStatus()-15)
		{
			case 1:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmOnline);
				break;
			case 2:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmAway);
				break;
			case 3:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmBusy);
				break;
			case 4:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmBeRightBack);
				break;
			case 5:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmOnThePhone);
				break;
			case 6:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmOutToLunch);
				break;
			case 7:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmInvisible);
				break;
			case 8:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmOffline);
				break;
			case 9:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmIdle);
				break;
			default:
				Kopete::Contact::setOnlineStatus(WlmProtocol::protocol()->wlmUnknown);
				break;
		}

	}
	else
#endif
		Kopete::Contact::setOnlineStatus(status);
}
Esempio n. 11
0
void IRCUserContact::updateStatus()
{
	//kdDebug(14120) << k_funcinfo << endl;

        Kopete::OnlineStatus newStatus;

	switch (kircEngine()->status())
	{
		case KIRC::Engine::Idle:
			newStatus = m_protocol->m_UserStatusOffline;
			break;

		case KIRC::Engine::Connecting:
		case KIRC::Engine::Authentifying:
			if (this == ircAccount()->mySelf())
				newStatus = m_protocol->m_UserStatusConnecting;
			else
				newStatus = m_protocol->m_UserStatusOffline;
			break;

		case KIRC::Engine::Connected:
		case KIRC::Engine::Closing:
			if (mInfo.away)
				newStatus = m_protocol->m_UserStatusAway;
			else if (mInfo.online)
				newStatus = m_protocol->m_UserStatusOnline;
			break;

		default:
			newStatus = m_protocol->m_StatusUnknown;
	}

	// Try hard not to emit several onlineStatusChanged() signals.
	bool onlineStatusChanged = false;


	/* The away status is global, so if the user goes away, we must set
	 * the new status on all channels.
	 */


	// This may not be created yet ( for myself() on startup )
	if( ircAccount()->contactManager() )
	{
		QValueList<IRCChannelContact*> channels = ircAccount()->contactManager()->findChannelsByMember(this);

		for( QValueList<IRCChannelContact*>::iterator it = channels.begin(); it != channels.end(); ++it )
		{
			IRCChannelContact *channel = *it;
			Kopete::OnlineStatus currentStatus = channel->manager()->contactOnlineStatus(this);

			//kdDebug(14120) << k_funcinfo << "iterating channel " << channel->nickName() << " internal status: " << currentStatus.internalStatus() << endl;

			if( currentStatus.internalStatus() >= IRCProtocol::Online )
			{
				onlineStatusChanged = true;

				if( !(currentStatus.internalStatus() & IRCProtocol::Away) && newStatus == m_protocol->m_UserStatusAway )
				{
					setOnlineStatus( newStatus );
					//kdDebug(14120) << k_funcinfo << "was NOT away, but is now, channel " << channel->nickName() << endl;
					adjustInternalOnlineStatusBits(channel, IRCProtocol::Away, AddBits);
				}
				else if( (currentStatus.internalStatus() & IRCProtocol::Away) && newStatus == m_protocol->m_UserStatusOnline )
				{
					setOnlineStatus( newStatus );
					//kdDebug(14120) << k_funcinfo << "was away, but not anymore, channel " << channel->nickName() << endl;
					adjustInternalOnlineStatusBits(channel, IRCProtocol::Away, RemoveBits);

				}
				else if( newStatus.internalStatus() < IRCProtocol::Away )
				{
					//kdDebug(14120) << k_funcinfo << "offline or connecting?" << endl;
					channel->manager()->setContactOnlineStatus( this, newStatus );
				}
			}
		}
	}

	if (!onlineStatusChanged) {
		//kdDebug(14120) << k_funcinfo << "setting status at last" << endl;
		setOnlineStatus( newStatus );
	}
}