void AdHocCommandServer::ChangeStatusInfo (const QDomElement& sourceElem) { QList<QXmppDataForm::Field> fields; QXmppDataForm::Field field (QXmppDataForm::Field::HiddenField); field.setValue (RcStr); field.setKey ("FORM_TYPE"); fields << field; const GlooxAccountState& state = Conn_->GetLastState (); QList<QPair<State, QString>> rawOpts; rawOpts << qMakePair<State, QString> (SChat, "chat"); rawOpts << qMakePair<State, QString> (SOnline, "online"); rawOpts << qMakePair<State, QString> (SAway, "away"); rawOpts << qMakePair<State, QString> (SXA, "xa"); rawOpts << qMakePair<State, QString> (SDND, "dnd"); rawOpts << qMakePair<State, QString> (SInvisible, "invisible"); rawOpts << qMakePair<State, QString> (SOffline, "offline"); QString option; QList<QPair<QString, QString>> options; QPair<State, QString> pair; IProxyObject *proxy = Core::Instance ().GetPluginProxy (); Q_FOREACH (pair, rawOpts) { options << qMakePair (proxy->StateToString (pair.first), pair.second); if (pair.first == state.State_) option = pair.second; }
void RoomCLEntry::HandleMessage (RoomPublicMessage *msg) { GlooxProtocol *proto = qobject_cast<GlooxProtocol*> (Account_->GetParentProtocol ()); IProxyObject *proxy = qobject_cast<IProxyObject*> (proto->GetProxyObject ()); proxy->PreprocessMessage (msg); AllMessages_ << msg; emit gotMessage (msg); }
void EntryBase::HandleMessage (IrcMessage *msg) { msg->SetOtherPart (this); IrcProtocol *proto = qobject_cast<IrcProtocol*> (Account_-> GetParentProtocol ()); IProxyObject *proxy = qobject_cast<IProxyObject*> (proto->GetProxyObject ()); proxy->PreprocessMessage (msg); AllMessages_ << msg; emit gotMessage (msg); }
void EntryBase::HandleMessage (GlooxMessage *msg) { if (msg->GetMessageType () == IMessage::MTChatMessage) { HasUnreadMsgs_ = true; UnreadMessages_ << msg; } GlooxProtocol *proto = qobject_cast<GlooxProtocol*> (Account_->GetParentProtocol ()); IProxyObject *proxy = qobject_cast<IProxyObject*> (proto->GetProxyObject ()); proxy->PreprocessMessage (msg); AllMessages_ << msg; emit gotMessage (msg); }
void ChatHistoryWidget::handleGotUsersForAccount (const QStringList& users, const QString& id, const QStringList& nameCache) { if (id != Ui_.AccountBox_->itemData (Ui_.AccountBox_->currentIndex ()).toString ()) return; IProxyObject *proxy = Core::Instance ()->GetPluginProxy (); ContactsModel_->clear (); Ui_.HistView_->clear (); QStandardItem *ourFocus = 0; const QString& focusId = EntryToFocus_ ? EntryToFocus_->GetEntryID () : CurrentEntry_; EntryToFocus_ = 0; for (int i = 0; i < users.size (); ++i) { const QString& user = users.at (i); ICLEntry *entry = qobject_cast<ICLEntry*> (proxy->GetEntry (user, id)); const QString& name = entry ? entry->GetEntryName () : (nameCache.value (i).isEmpty () ? user : nameCache.value (i)); EntryID2NameCache_ [user] = name; QStandardItem *item = new QStandardItem (name); item->setData (user, MRIDRole); item->setToolTip (name); item->setEditable (false); ContactsModel_->appendRow (item); if (!ourFocus && user == focusId) ourFocus = item; } if (ourFocus) { ShowLoading (); QModelIndex idx = ContactsModel_->indexFromItem (ourFocus); idx = SortFilter_->mapFromSource (idx); Ui_.Contacts_->selectionModel ()-> setCurrentIndex (idx, QItemSelectionModel::SelectCurrent); } }
QString GlooxAccount::GetPassword (bool authfailure) { IProxyObject *proxy = qobject_cast<IProxyObject*> (ParentProtocol_->GetProxyObject ()); return proxy->GetAccountPassword (this, !authfailure); }
void EntryBase::SetStatus (const EntryStatus& status, const QString& variant, const QXmppPresence& presence) { const bool existed = CurrentStatus_.contains (variant); const bool wasOffline = existed ? CurrentStatus_ [variant].State_ == SOffline : false; if (existed && status == CurrentStatus_ [variant] && presence.priority () == Variant2ClientInfo_.value (variant).value ("priority")) return; CurrentStatus_ [variant] = status; const QStringList& vars = Variants (); if ((!existed || wasOffline) && !vars.isEmpty ()) { const QString& highest = vars.first (); if (Location_.contains (QString ())) Location_ [highest] = Location_.take (QString ()); if (Variant2ClientInfo_.contains (QString ())) { const auto& info = Variant2ClientInfo_ [QString ()]; QStringList toCopy; toCopy << "user_tune" << "user_mood" << "user_activity"; Q_FOREACH (const QString& key, toCopy) if (info.contains (key)) Variant2ClientInfo_ [highest] [key] = info [key]; } } if ((!existed || wasOffline) && status.State_ != SOffline) { auto conn = Account_->GetClientConnection (); if (conn->GetInfoReqPolicyManager ()->IsRequestAllowed (InfoRequest::Version, this) && !variant.isEmpty ()) conn->FetchVersion (GetJID () + '/' + variant); } if (status.State_ != SOffline) { if (const int p = presence.priority ()) Variant2ClientInfo_ [variant] ["priority"] = p; } else { Variant2Version_.remove (variant); Variant2ClientInfo_.remove (variant); } emit statusChanged (status, variant); if (!existed || (existed && status.State_ == SOffline) || wasOffline) emit availableVariantsChanged (vars); GlooxMessage *message = 0; if (GetEntryType () == ETPrivateChat) message = new GlooxMessage (IMessage::MTStatusMessage, IMessage::DIn, qobject_cast<RoomCLEntry*> (GetParentCLEntry ())-> GetRoomHandler ()->GetRoomJID (), GetEntryName (), Account_->GetClientConnection ().get ()); else message = new GlooxMessage (IMessage::MTStatusMessage, IMessage::DIn, GetJID (), variant, Account_->GetClientConnection ().get ()); message->SetMessageSubType (IMessage::MSTParticipantStatusChange); GlooxProtocol *proto = qobject_cast<GlooxProtocol*> (Account_->GetParentProtocol ()); IProxyObject *proxy = qobject_cast<IProxyObject*> (proto->GetProxyObject ()); const QString& state = proxy->StateToString (status.State_); const QString& nick = GetEntryName () + '/' + variant; message->setProperty ("Azoth/Nick", nick); message->setProperty ("Azoth/TargetState", state); message->setProperty ("Azoth/StatusText", status.StatusString_); QString msg = tr ("%1 is now %2 (%3)") .arg (nick) .arg (state) .arg (status.StatusString_); message->SetBody (msg); HandleMessage (message); }