2018-07-20 19:48:29 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/chat/ChatDialog.h *
|
|
|
|
* *
|
|
|
|
* LibResAPI: API for local socket server *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2011 RetroShare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-01-17 20:36:36 +00:00
|
|
|
|
|
|
|
#ifndef CHATDIALOG_H
|
|
|
|
#define CHATDIALOG_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <retroshare/rsmsgs.h>
|
|
|
|
|
|
|
|
class ChatWidget;
|
|
|
|
class RSStyle;
|
|
|
|
|
|
|
|
class ChatDialog : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2014-12-29 21:41:05 +00:00
|
|
|
static ChatDialog *getExistingChat(ChatId id);
|
|
|
|
static ChatDialog *getChat(ChatId id, uint chatflags = 0);
|
2012-01-17 20:36:36 +00:00
|
|
|
static void cleanupChat();
|
2014-12-29 21:41:05 +00:00
|
|
|
static void chatFriend(const ChatId &peerId, bool forceFocus = true);
|
2014-10-25 12:26:09 +00:00
|
|
|
static void chatFriend(const RsPgpId &gpgId, bool forceFocus = true);
|
2014-12-29 21:41:05 +00:00
|
|
|
static void closeChat(const ChatId &chat_id);
|
|
|
|
static void chatMessageReceived(ChatMessage msg);
|
2012-01-17 20:36:36 +00:00
|
|
|
|
2012-02-17 10:03:38 +00:00
|
|
|
virtual void showDialog(uint /*chatflags*/) {}
|
2012-01-17 20:36:36 +00:00
|
|
|
|
|
|
|
virtual ChatWidget *getChatWidget() = 0;
|
|
|
|
virtual bool hasPeerStatus() = 0;
|
2012-10-27 15:59:12 +00:00
|
|
|
virtual bool notifyBlink() = 0;
|
2012-01-17 20:36:36 +00:00
|
|
|
|
|
|
|
void addToParent(QWidget *newParent);
|
|
|
|
void removeFromParent(QWidget *oldParent);
|
|
|
|
|
|
|
|
QString getTitle();
|
|
|
|
bool hasNewMessages();
|
|
|
|
bool isTyping();
|
|
|
|
|
|
|
|
bool setStyle();
|
|
|
|
const RSStyle *getStyle();
|
|
|
|
|
|
|
|
int getPeerStatus();
|
2013-06-17 21:58:26 +00:00
|
|
|
void setPeerStatus(uint32_t state);
|
2012-01-17 20:36:36 +00:00
|
|
|
|
|
|
|
void focusDialog();
|
|
|
|
|
2014-12-29 21:41:05 +00:00
|
|
|
ChatId getChatId(){ return mChatId; }
|
|
|
|
|
2012-01-17 20:36:36 +00:00
|
|
|
signals:
|
|
|
|
void infoChanged(ChatDialog *dialog);
|
|
|
|
void newMessage(ChatDialog *dialog);
|
2012-01-27 14:49:48 +00:00
|
|
|
void dialogClose(ChatDialog *dialog);
|
2012-01-17 20:36:36 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void chatInfoChanged(ChatWidget*);
|
|
|
|
void chatNewMessage(ChatWidget*);
|
|
|
|
|
|
|
|
protected:
|
2013-10-18 21:10:33 +00:00
|
|
|
explicit ChatDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
2012-01-17 20:36:36 +00:00
|
|
|
virtual ~ChatDialog();
|
|
|
|
|
2012-01-27 14:49:48 +00:00
|
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
virtual bool canClose() { return true; }
|
|
|
|
|
2018-09-24 20:55:27 +02:00
|
|
|
virtual QString getPeerName(const ChatId &sslid,QString& additional_info) const ; // can be overloaded for chat dialogs that have specific peers
|
2014-12-29 21:41:05 +00:00
|
|
|
virtual QString getOwnName() const;
|
2012-01-17 20:36:36 +00:00
|
|
|
|
2017-03-18 11:56:11 +01:00
|
|
|
virtual void init(const ChatId &id, const QString &title);
|
2014-12-29 21:41:05 +00:00
|
|
|
virtual void addChatMsg(const ChatMessage& msg) = 0;
|
2012-01-17 20:36:36 +00:00
|
|
|
|
2014-12-29 21:41:05 +00:00
|
|
|
ChatId mChatId;
|
2012-01-17 20:36:36 +00:00
|
|
|
};
|
|
|
|
|
2015-05-29 14:01:33 +00:00
|
|
|
class ChatFriendMethod: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ChatFriendMethod(QObject* parent, RsPeerId peerId): QObject(parent), mPeerId(peerId){}
|
|
|
|
public slots:
|
|
|
|
void chatFriend(){ChatDialog::chatFriend(ChatId(mPeerId));}
|
|
|
|
private:
|
|
|
|
RsPeerId mPeerId;
|
|
|
|
};
|
|
|
|
|
2012-01-17 20:36:36 +00:00
|
|
|
#endif // CHATDIALOG_H
|