Example #1
0
void FileDescStatusChanger::changeStatus(UserStatus &status)
{
	if (status.isOffline())
		return;
	if (!disabled)
		status.setDescription(title);
}
Example #2
0
UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
    UserStatus *result = nullptr;
    switch (constructor) {
        case 0x8c703f:
            result = new TL_userStatusOffline();
            break;
        case 0x7bf09fc:
            result = new TL_userStatusLastWeek();
            break;
        case 0x9d05049:
            result = new TL_userStatusEmpty();
            break;
        case 0x77ebc742:
            result = new TL_userStatusLastMonth();
            break;
        case 0xedb93949:
            result = new TL_userStatusOnline();
            break;
        case 0xe26f42f1:
            result = new TL_userStatusRecently();
            break;
        default:
            error = true;
            DEBUG_E("can't parse magic %x in UserStatus", constructor);
            return nullptr;
    }
    result->readParams(stream, instanceNum, error);
    return result;
}
Example #3
0
void PowerStatusChanger::changeStatus(UserStatus &status)
{
    kdebugf();
    switch(state)
    {
    case STATUS_ONLINE:
        status.setOnline(description);
        break;

    case STATUS_BUSY:
        status.setBusy(description);
        break;

    case STATUS_INVISIBLE:
        status.setInvisible(description);
        break;

    case STATUS_OFFLINE:
        status.setOffline(description);
        break;

    case STATUS_BY_INDEX:
        status.setIndex(index, description);

    default:
        kdebugm(KDEBUG_INFO, "Status state not specified\n");
        break;
    }
    state = STATUS_NOT_SPECIFIED;
    kdebugf2();
}
int QOCIUserStatusOperation::UpdateRecord(DBModel *dataModel, const QString &connName)
{
    UserStatus *userStatusInfo = dynamic_cast<UserStatus *>(dataModel);
    if(userStatusInfo)
    {
        QSqlDatabase db = QPSqlConnection::getDBbyName(connName);
        QSqlQuery query(db);
        if(userStatusInfo->inTime().isNull())
        {
            query.prepare("UPDATE T_USERSTATUS SET STATUS_ID=:STATUS_ID,LOGOUT_TIME=:LOGOUT_TIME where USERSTATUS_ID=:USERSTATUS_ID");
            query.bindValue(":USERSTATUS_ID",userStatusInfo->id());
            query.bindValue(":STATUS_ID",userStatusInfo->statusID());
            query.bindValue(":LOGOUT_TIME", userStatusInfo->outTime());
        }
        else
        {
            query.prepare("UPDATE T_USERSTATUS SET STATUS_ID=:STATUS_ID,LOGIN_TIME=:LOGIN_TIME,LOGOUT_TIME=:LOGOUT_TIME where USERSTATUS_ID=:USERSTATUS_ID");
            query.bindValue(":USERSTATUS_ID",userStatusInfo->id());
            query.bindValue(":STATUS_ID",userStatusInfo->statusID());
            query.bindValue(":LOGIN_TIME",userStatusInfo->inTime());
            query.bindValue(":LOGOUT_TIME", userStatusInfo->outTime());
        }
        return ExecuteQSqlQuery(query);
    }
    else
    {
        QPErrorInfoQueue *queue = QPErrorInfoQueue::getInstance();
        queue->addErrorInfo(SqlError::errNo_PointIsNULL, SqlError::errStr_PointIsNull);
        return SqlError::retInsertRecordError;
    }
}
Example #5
0
void ServerEvents::OnUserStatus( const wxString& nick, UserStatus status )
{
    wxLogDebugFunc( _T("") );
    try
    {
        wxLogMessage( _T("calling m_serv.GetUser( nick ) ") );
        User& user = m_serv.GetUser( nick );
        wxLogMessage( _T("calling user.SetStatus( status ) ") );

        UserStatus oldStatus = user.GetStatus();
        user.SetStatus( status );
        if ( useractions().DoActionOnUser( UserActions::ActNotifStatus, nick ) )
        {
            wxString diffString = status.GetDiffString( oldStatus ) ;
            if ( diffString != wxEmptyString )
                actNotifBox( SL_MAIN_ICON, nick + _(" is now ") + diffString );
        }

        wxLogMessage( _T("calling ui().OnUserStatusChanged( user ) ") );
        ui().OnUserStatusChanged( user );
        wxLogMessage( _T("updating battles ") );

        if ( user.GetBattle() != 0 )
        {
            Battle& battle = *user.GetBattle();
            try
            {
            if ( battle.GetFounder().GetNick() == user.GetNick() )
            {
                if ( status.in_game != battle.GetInGame() )
                {
                    battle.SetInGame( status.in_game );
                    if ( status.in_game ) battle.StartSpring();
					else
						BattleEvents::GetBattleEventSender( BattleEvents::BattleInfoUpdate ).SendEvent( std::make_pair(user.GetBattle(),wxString()) );
                }
            }
            }catch(...){}
        }
    }
    catch (...)
    {
        wxLogWarning( _("OnUserStatus() failed ! (exception)") );
    }
}
void ServerEvents::OnUserStatus(const std::string& nick, UserStatus status)
{
	slLogDebugFunc("");
	try {
		User& user = m_serv.GetUser(nick);

		UserStatus oldStatus = user.GetStatus();
		user.SetStatus(status);
		if (useractions().DoActionOnUser(UserActions::ActNotifStatus, TowxString(nick))) {
			wxString diffString = TowxString(status.GetDiffString(oldStatus));
			if (diffString != wxEmptyString)
				actNotifBox(SL_MAIN_ICON, TowxString(nick) + _(" is now ") + diffString);
		}

		if (m_serv.IsOnline()) { //login info isn't complete yet
			ui().OnUserStatusChanged(user);
		}

		if (user.GetBattle() != 0) {
			IBattle& battle = *user.GetBattle();
			try {
				if (battle.GetFounder().GetNick() == user.GetNick()) {
					if (status.in_game != battle.GetInGame()) {
						battle.SetInGame(status.in_game);
						if (m_serv.IsOnline()) {
							if (status.in_game) {
								battle.StartSpring();
							} else {
								ui().OnBattleInfoUpdated(battle, wxEmptyString);
							}
						}
					}
				}
			} catch (...) {
			}
		}
	} catch (...) {
		wxLogWarning(_("OnUserStatus() failed ! (exception)"));
	}
}