void MainWidget::handleChangeStatusRequested () { QAction *action = qobject_cast<QAction*> (sender ()); if (!action) { qWarning () << Q_FUNC_INFO << sender () << "is not an action"; return; } QVariant stateVar = action->property ("Azoth/TargetState"); EntryStatus status; if (!stateVar.isNull ()) { const auto state = stateVar.value<State> (); status = EntryStatus (state, AccountActsMgr_->GetStatusText (action, state)); } else { SetStatusDialog ssd ("global", this); if (ssd.exec () != QDialog::Accepted) return; status = EntryStatus (ssd.GetState (), ssd.GetStatusText ()); } for (IAccount *acc : Core::Instance ().GetAccounts ()) if (acc->IsShownInRoster ()) acc->ChangeState (status); updateFastStatusButton (status.State_); }
EntryStatus GlooxCLEntry::GetStatus (const QString& variant) const { if (ODS_) return EntryStatus (); if (AuthRequested_) return EntryStatus (SOnline, QString ()); QXmppRosterManager& rm = Account_-> GetClientConnection ()->GetClient ()->rosterManager (); if (!rm.isRosterReceived ()) return EntryBase::GetStatus (variant); const QMap<QString, QXmppPresence>& press = rm.getAllPresencesForBareJid (GetJID ()); if (!press.size ()) return EntryBase::GetStatus (variant); QXmppPresence max = press.begin ().value (); Q_FOREACH (const QString& resource, press.keys ()) { if (!variant.isEmpty () && variant == resource) { max = press [resource]; break; } const QXmppPresence& pres = press [resource]; if (pres.priority () > max.priority ()) max = pres; } return EntryStatus (static_cast<State> (max.availableStatusType () + 1), max.statusText ()); }
void IrcAccount::FillSettings (IrcAccountConfigurationWidget *widget) { State lastState = IrcAccountState_; if (lastState != SOffline && (RealName_ != widget->GetRealName () || UserName_ != widget->GetUserName () || NickNames_ != widget->GetNickNames ())) { ChangeState (EntryStatus (SOffline, QString ())); } RealName_ = widget->GetRealName (); UserName_ = widget->GetUserName (); NickNames_ = widget->GetNickNames (); DefaultServer_ = widget->GetDefaultServer (); DefaultPort_ = widget->GetDefaultPort (); DefaultEncoding_ = widget->GetDefaultEncoding (); DefaultChannel_ = widget->GetDefaultChannel (); if (lastState != SOffline) ChangeState (EntryStatus (lastState, QString ())); emit accountSettingsChanged (); }
void ChannelHandler::UpdateEntry (const WhoMessage& message) { if (Nick2Entry_.contains (message.Nick_)) { ChannelParticipantEntry_ptr entry = Nick2Entry_ [message.Nick_]; entry->SetUserName (message.UserName_); entry->SetHostName (message.Host_); entry->SetRealName (message.RealName_); entry->SetStatus (message.IsAway_ ? EntryStatus (SAway, QString ()) : EntryStatus (SOnline, QString ())); } }
void Plugin::handleIdle (int seconds) { IdleSeconds_ = seconds; if (seconds && seconds % 60) return; if (!XmlSettingsManager::Instance ().property ("EnableAutoidler").toBool ()) return; const int mins = seconds / 60; if (!mins && !OldStatuses_.isEmpty ()) { for (QObject *accObj : AzothProxy_->GetAllAccounts ()) { if (!OldStatuses_.contains (accObj)) continue; IAccount *acc = qobject_cast<IAccount*> (accObj); acc->ChangeState (OldStatuses_ [accObj]); } OldStatuses_.clear (); } if (!mins) return; EntryStatus status; if (mins == XmlSettingsManager::Instance ().property ("AwayTimeout").toInt ()) status = EntryStatus (SAway, XmlSettingsManager::Instance ().property ("AwayText").toString ()); else if (mins == XmlSettingsManager::Instance ().property ("NATimeout").toInt ()) status = EntryStatus (SXA, XmlSettingsManager::Instance ().property ("NAText").toString ()); else return; for (QObject *accObj : AzothProxy_->GetAllAccounts ()) { auto acc = qobject_cast<IAccount*> (accObj); const auto& accState = acc->GetState (); if (accState.State_ == State::SOffline) continue; if (!OldStatuses_.contains (accObj)) OldStatuses_ [accObj] = accState; acc->ChangeState (status); } }
EntryStatus GlooxAccount::GetState () const { const auto& state = ClientConnection_ ? ClientConnection_->GetLastState () : GlooxAccountState (); return EntryStatus (state.State_, state.Status_); }
void ChannelHandler::SetChannelUser (const QString& nick, const QString& user, const QString& host) { QString nickName = nick; bool hasRole = false; QChar roleSign; if (CM_->GetISupport ().contains ("PREFIX")) { const QStringList& prefixList = CM_->GetISupport () ["PREFIX"].split (')'); int id = prefixList.value (1).indexOf (nick [0]); if (id != -1) { hasRole = true; nickName = nickName.mid (1); roleSign = prefixList.at (0) [id + 1]; } } CM_->ClosePrivateChat (nickName); const auto existed = Nick2Entry_.contains (nickName); ChannelParticipantEntry_ptr entry (GetParticipantEntry (nickName, false)); entry->SetUserName (user); entry->SetHostName (host); ChannelRole role; if (hasRole) switch (roleSign.toAscii ()) { case 'v': role = ChannelRole::Voiced; break; case 'h': role = ChannelRole::HalfOperator; break; case 'o': role = ChannelRole::Operator; break; case 'a': role = ChannelRole::Admin; break; case 'q': role = ChannelRole::Owner; break; default: role = ChannelRole::Participant; } else role = ChannelRole::Participant; entry->SetRole (role); entry->SetStatus (EntryStatus (SOnline, QString ())); if (!existed) CM_->GetAccount ()->handleGotRosterItems ({ entry.get () }); MakeJoinMessage (nickName); }
void SelfContact::RemoveVariant (const QString& resource) { Prio2Status_.remove (Prio2Status_.key (resource)); CurrentStatus_.remove (resource); EntryBase::SetStatus (EntryStatus (SOffline, QString ()), resource, QXmppPresence (QXmppPresence::Unavailable)); }
EntryStatus FromPurpleStatus (PurpleAccount *account, PurpleStatus *status) { const auto id = purple_status_get_id (status); const auto statusType = purple_account_get_status_type (account, id); const auto message = purple_status_get_attr_string (status, "message"); return EntryStatus (FromPurpleState (purple_status_type_get_primitive (statusType)), message ? QString::fromUtf8 (message) : QString ()); }
void AccountsListWidget::handleItemChanged (QStandardItem *item) { const auto type = item->data (Roles::RItemType).toInt (); if (type != ItemTypes::ShowInRoster) return; IAccount *acc = item->data (Roles::RAccObj).value<IAccount*> (); acc->SetShownInRoster (item->checkState () == Qt::Checked); if (!acc->IsShownInRoster () && acc->GetState ().State_ != SOffline) acc->ChangeState (EntryStatus (SOffline, QString ())); emit accountVisibilityChanged (acc); }
void SelfContact::RemoveVariant (const QString& resource, bool thisInstance) { if (thisInstance) for (const auto& otherResource : Status2Prio_.keys ()) if (otherResource != resource) RemoveVariant (otherResource, false); Status2Prio_.remove (resource); CurrentStatus_.remove (resource); EntryBase::SetStatus (EntryStatus (SOffline, QString ()), resource, QXmppPresence (QXmppPresence::Unavailable)); }
void AccountActionsManager::handleChangeStatusRequested () { auto action = qobject_cast<QAction*> (sender ()); const auto acc = GetAccountFromSender (sender (), Q_FUNC_INFO); QVariant stateVar = action->property ("Azoth/TargetState"); EntryStatus status; if (!stateVar.isNull ()) { const auto state = stateVar.value<State> (); status = EntryStatus (state, GetStatusText (action, state)); } else { SetStatusDialog ssd (acc->GetAccountID ()); if (ssd.exec () != QDialog::Accepted) return; status = EntryStatus (ssd.GetState (), ssd.GetStatusText ()); } acc->ChangeState (status); }
void RoomHandler::handleParticipantRemoved (const QString& jid) { const QXmppPresence& pres = Room_->participantPresence (jid); QString nick; ClientConnection::Split (jid, 0, &nick); const bool us = Room_->nickName () == nick; RoomParticipantEntry_ptr entry = GetParticipantEntry (nick); const QXmppMucItem& item = pres.mucItem (); if (!item.nick ().isEmpty () && item.nick () != nick) { entry->SetEntryName (item.nick ()); Nick2Entry_ [item.nick ()] = Nick2Entry_ [nick]; MakeNickChangeMessage (nick, item.nick ()); Nick2Entry_.remove (nick); PendingNickChanges_ << item.nick (); return; } else if (pres.mucStatusCodes ().contains (301)) !us ? MakeBanMessage (nick, item.reason ()) : static_cast<void> (QMetaObject::invokeMethod (CLEntry_, "beenBanned", Qt::QueuedConnection, Q_ARG (QString, item.reason ()))); else if (pres.mucStatusCodes ().contains (307)) !us ? MakeKickMessage (nick, item.reason ()) : static_cast<void> (QMetaObject::invokeMethod (CLEntry_, "beenKicked", Qt::QueuedConnection, Q_ARG (QString, item.reason ()))); else MakeLeaveMessage (pres, nick); if (us) { Leave (QString (), false); return; } if (entry->HasUnreadMsgs ()) entry->SetStatus (EntryStatus (SOffline, item.reason ()), QString ()); else RemoveEntry (entry.get ()); }
EntryStatus MetaAccount::GetState () const { return EntryStatus (SOnline, QString ()); }
EntryStatus ChannelCLEntry::GetStatus (const QString&) const { return EntryStatus (SOnline, QString ()); }
EntryStatus Status2Azoth (const Tp::Presence& p) { return EntryStatus (StateTelepathy2Azoth (p.type ()), p.statusMessage ()); }