1 /* 2 SPDX-License-Identifier: GPL-2.0-or-later 3 4 SPDX-FileCopyrightText: 2002 Dario Abatianni <eisfuchs@tigress.com> 5 SPDX-FileCopyrightText: 2005-2008 Eike Hein <hein@kde.org> 6 */ 7 8 #ifndef QUERY_H 9 #define QUERY_H 10 11 #include "chatwindow.h" 12 #include "nickinfo.h" 13 14 #include <config-konversation.h> 15 16 #ifdef HAVE_QCA2 17 #include "cipher.h" 18 #endif 19 20 #include <QString> 21 22 /* TODO: Idle counter to close query after XXX minutes of inactivity */ 23 /* TODO: Use /USERHOST to check if queries are still valid */ 24 25 class AwayLabel; 26 class IRCInput; 27 28 class QLabel; 29 class QSplitter; 30 31 class KSqueezedTextLabel; 32 33 34 class Query : public ChatWindow 35 { 36 Q_OBJECT 37 friend class Server; 38 39 public: 40 explicit Query(QWidget* parent, const QString& _name); 41 void setServer(Server* newServer) override; 42 43 ~Query() override; 44 45 /** This will always be called soon after this object is created. 46 * @param nickInfo A nickinfo that must exist. 47 */ 48 void setNickInfo(const NickInfoPtr & nickInfo); 49 /** It seems that this does _not_ guaranttee to return non null. 50 * The problem is when you open a query to someone, then the go offline. 51 * This should be fixed maybe? I don't know. 52 */ 53 NickInfoPtr getNickInfo() const; 54 bool closeYourself(bool askForConfirmation=true) override; 55 bool canBeFrontView() const override; 56 bool searchView() const override; 57 58 void setChannelEncoding(const QString& encoding) override; 59 QString getChannelEncoding() const override; 60 QString getChannelEncodingDefaultDesc() const override; 61 void emitUpdateInfo() override; 62 63 /** call this when you see a nick quit from the server. 64 * @param reason The quit reason given by that user. 65 */ 66 void quitNick(const QString& reason, const QHash<QString, QString> &messageTags); 67 68 #ifdef HAVE_QCA2 69 Konversation::Cipher* getCipher() const; 70 #endif 71 72 Q_SIGNALS: 73 void sendFile(const QString& recipient); 74 void updateQueryChrome(ChatWindow*, const QString&); 75 76 public Q_SLOTS: 77 void sendText(const QString& text) override; 78 void indicateAway(bool show) override; 79 void setEncryptedOutput(bool); 80 void connectionStateChanged(Server*, Konversation::ConnectionState); 81 82 protected: 83 void setName(const QString& newName) override; 84 void showEvent(QShowEvent* event) override; 85 /** Called from ChatWindow adjustFocus */ 86 void childAdjustFocus() override; 87 88 private Q_SLOTS: 89 void queryTextEntered(); 90 void queryPassthroughCommand(); 91 void sendFileMenu(); 92 void urlsDropped(const QList<QUrl>& urls); 93 // connected to IRCInput::textPasted() - used to handle large/multiline pastes 94 void textPasted(const QString& text); 95 void nickInfoChanged(); 96 void updateNickInfo(Server* server, const NickInfoPtr &nickInfo); 97 98 private: 99 bool awayChanged; 100 bool awayState; 101 102 QString queryName; 103 QString buffer; 104 105 QSplitter* m_headerSplitter; 106 KSqueezedTextLabel* queryHostmask; 107 QLabel* blowfishLabel; 108 AwayLabel* awayLabel; 109 NickInfoPtr m_nickInfo; 110 111 bool m_initialShow; 112 113 #ifdef HAVE_QCA2 114 //FIXME: We might want to put this into the attendee object (i.e. NickInfo). 115 mutable Konversation::Cipher *m_cipher; 116 #endif 117 118 Q_DISABLE_COPY(Query) 119 }; 120 121 #endif 122