2012-01-17 15:36:36 -05:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011, RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#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 16:41:05 -05:00
|
|
|
static ChatDialog *getExistingChat(ChatId id);
|
|
|
|
static ChatDialog *getChat(ChatId id, uint chatflags = 0);
|
2012-01-17 15:36:36 -05:00
|
|
|
static void cleanupChat();
|
2014-12-29 16:41:05 -05:00
|
|
|
static void chatFriend(const ChatId &peerId, bool forceFocus = true);
|
2014-10-25 08:26:09 -04:00
|
|
|
static void chatFriend(const RsPgpId &gpgId, bool forceFocus = true);
|
2014-12-29 16:41:05 -05:00
|
|
|
static void closeChat(const ChatId &chat_id);
|
|
|
|
static void chatMessageReceived(ChatMessage msg);
|
2012-01-17 15:36:36 -05:00
|
|
|
|
2012-02-17 05:03:38 -05:00
|
|
|
virtual void showDialog(uint /*chatflags*/) {}
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
virtual ChatWidget *getChatWidget() = 0;
|
|
|
|
virtual bool hasPeerStatus() = 0;
|
2012-10-27 11:59:12 -04:00
|
|
|
virtual bool notifyBlink() = 0;
|
2012-01-17 15:36:36 -05: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 17:58:26 -04:00
|
|
|
void setPeerStatus(uint32_t state);
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
void focusDialog();
|
|
|
|
|
2014-12-29 16:41:05 -05:00
|
|
|
ChatId getChatId(){ return mChatId; }
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
signals:
|
|
|
|
void infoChanged(ChatDialog *dialog);
|
|
|
|
void newMessage(ChatDialog *dialog);
|
2012-01-27 09:49:48 -05:00
|
|
|
void dialogClose(ChatDialog *dialog);
|
2012-01-17 15:36:36 -05:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void chatInfoChanged(ChatWidget*);
|
|
|
|
void chatNewMessage(ChatWidget*);
|
|
|
|
|
|
|
|
protected:
|
2013-10-18 17:10:33 -04:00
|
|
|
explicit ChatDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
2012-01-17 15:36:36 -05:00
|
|
|
virtual ~ChatDialog();
|
|
|
|
|
2012-01-27 09:49:48 -05:00
|
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
virtual bool canClose() { return true; }
|
|
|
|
|
2014-12-29 16:41:05 -05:00
|
|
|
virtual QString getPeerName(const ChatId &sslid) const ; // can be overloaded for chat dialogs that have specific peers
|
|
|
|
virtual QString getOwnName() const;
|
2012-01-17 15:36:36 -05:00
|
|
|
|
2017-03-18 06:56:11 -04:00
|
|
|
virtual void init(const ChatId &id, const QString &title);
|
2014-12-29 16:41:05 -05:00
|
|
|
virtual void addChatMsg(const ChatMessage& msg) = 0;
|
2012-01-17 15:36:36 -05:00
|
|
|
|
2014-12-29 16:41:05 -05:00
|
|
|
ChatId mChatId;
|
2012-01-17 15:36:36 -05:00
|
|
|
};
|
|
|
|
|
2015-05-29 10:01:33 -04: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 15:36:36 -05:00
|
|
|
#endif // CHATDIALOG_H
|