void MrimContact::clearComposingState() { bool isComposing = chatState() == ChatUnit::ChatStateComposing; p->incomingComposingTimer.stop(); if (isComposing) setChatState(ChatUnit::ChatStateActive); }
void MrimContact::updateComposingState() { bool isComposing = chatState() == ChatUnit::ChatStateComposing; p->incomingComposingTimer.start(10000, this); if (!isComposing) setChatState(ChatUnit::ChatStateComposing); }
void ChatDlg::hideEvent(QHideEvent* e) { if (isMinimized()) { resetComposing(); setChatState(StateInactive); } TabbableWidget::hideEvent(e); }
void wavrChatWindow::closeEvent(QCloseEvent* pEvent) { setChatState(CS_Inactive); // Call stop() to save history stop(); emit closed(&peerId); QWidget::closeEvent(pEvent); }
void MrimContact::timerEvent(QTimerEvent *event) { if (p->composingTimer.timerId() == event->timerId()) { account()->connection()->messages()->sendComposingNotification(this); return; } else if (p->incomingComposingTimer.timerId() == event->timerId()) { setChatState(ChatUnit::ChatStateActive); p->incomingComposingTimer.stop(); return; } return Contact::timerEvent(event); }
void VContact::setOnline(bool set) { Q_D(VContact); if (d->online != set) { Status previous = status(); d->online = set; Status status = this->status(); setChatState(set ? ChatStateInActive : ChatStateGone); NotificationRequest request(this, status, previous); request.send(); emit statusChanged(status, previous); } }
void ChatDlg::setContactChatState(ChatState state) { contactChatState_ = state; if (state == XMPP::StateGone) { appendSysMsg(tr("%1 ended the conversation").arg(Qt::escape(dispNick_))); } else { // Activate ourselves if (lastChatState_ == XMPP::StateGone) { setChatState(XMPP::StateActive); } } invalidateTab(); }
/** * Runs all the gumph necessary before hiding a chat. * (checking new messages, setting the autodelete, cancelling composing etc) * \return ChatDlg is ready to be hidden. */ bool ChatDlg::readyToHide() { // really lame way of checking if we are encrypting if (!chatEdit()->isEnabled()) { return false; } if (keepOpen_) { QMessageBox mb(QMessageBox::Information, tr("Warning"), tr("A new chat message was just received.\nDo you still want to close the window?"), QMessageBox::Cancel, this); mb.addButton(tr("Close"), QMessageBox::AcceptRole); if (mb.exec() == QMessageBox::Cancel) { return false; } } // destroy the dialog if delChats is dcClose if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "instant") { setAttribute(Qt::WA_DeleteOnClose); } else { if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "hour") { setSelfDestruct(60); } else if (PsiOptions::instance()->getOption("options.ui.chat.delete-contents-after").toString() == "day") { setSelfDestruct(60 * 24); } } // Reset 'contact is composing' & cancel own composing event resetComposing(); setChatState(StateGone); if (contactChatState_ == StateComposing || contactChatState_ == StateInactive) { setContactChatState(StatePaused); } if (pending_ > 0) { pending_ = 0; messagesRead(jid()); invalidateTab(); } doFlash(false); chatEdit()->setFocus(); return true; }
void ChatDlg::updateIsComposing(bool b) { setChatState(b ? XMPP::StateComposing : XMPP::StatePaused); }
void ChatDlg::doSend() { if (!chatEdit()->isEnabled()) { return; } if (chatEdit()->text().isEmpty()) { return; } if (chatEdit()->text() == "/clear") { chatEdit()->clear(); doClear(); return; } if (!account()->loggedIn()) { return; } if (warnSend_) { warnSend_ = false; int n = QMessageBox::information(this, tr("Warning"), tr( "<p>Encryption was recently disabled by the remote contact. " "Are you sure you want to send this message without encryption?</p>" ), tr("&Yes"), tr("&No")); if (n != 0) { return; } } Message m(jid()); m.setType("chat"); m.setBody(chatEdit()->text()); m.setTimeStamp(QDateTime::currentDateTime()); if (isEncryptionEnabled()) { m.setWasEncrypted(true); } m_ = m; // Request events if (PsiOptions::instance()->getOption("options.messages.send-composing-events").toBool()) { // Only request more events when really necessary if (sendComposingEvents_) { m.addEvent(ComposingEvent); } m.setChatState(XMPP::StateActive); } // Update current state setChatState(XMPP::StateActive); if (isEncryptionEnabled()) { chatEdit()->setEnabled(false); transid_ = account()->sendMessageEncrypted(m); if (transid_ == -1) { chatEdit()->setEnabled(true); chatEdit()->setFocus(); return; } } else { aSend(m); doneSend(); } chatEdit()->setFocus(); }