2018-12-25 15:34:59 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/NotifyQt.h *
|
|
|
|
* *
|
|
|
|
* Copyright (c) 2010 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/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
#ifndef RSIFACE_NOTIFY_TXT_H
|
|
|
|
#define RSIFACE_NOTIFY_TXT_H
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsiface.h>
|
|
|
|
#include <retroshare/rsturtle.h>
|
2014-01-07 17:51:22 -05:00
|
|
|
#include <retroshare/rsnotify.h>
|
2014-12-29 16:41:05 -05:00
|
|
|
#include <retroshare/rsmsgs.h>
|
2009-12-28 17:40:45 -05:00
|
|
|
#include <QObject>
|
2012-05-15 16:25:53 -04:00
|
|
|
#include <QMutex>
|
2012-09-04 16:04:49 -04:00
|
|
|
#include <QPoint>
|
2010-12-07 19:14:12 -05:00
|
|
|
//#include <QMutex>
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
class QTimer;
|
2009-12-28 17:40:45 -05:00
|
|
|
class NetworkDialog;
|
2011-05-17 13:27:47 -04:00
|
|
|
class FriendsDialog;
|
2009-12-28 17:40:45 -05:00
|
|
|
class TransfersDialog;
|
|
|
|
class ChatDialog;
|
|
|
|
class MessagesDialog;
|
|
|
|
class ChannelsDialog;
|
|
|
|
class MessengerWindow;
|
2015-05-26 11:19:57 -04:00
|
|
|
class ToasterItem;
|
|
|
|
class ToasterNotify;
|
2013-03-01 18:00:43 -05:00
|
|
|
class SignatureEventData ;
|
2018-06-06 17:15:29 -04:00
|
|
|
|
2010-09-07 11:49:31 -04:00
|
|
|
struct TurtleFileInfo;
|
2018-06-06 17:15:29 -04:00
|
|
|
struct TurtleGxsInfo;
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2014-01-07 17:51:22 -05:00
|
|
|
class NotifyQt: public QObject, public NotifyClient
|
2009-12-28 17:40:45 -05:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2010-07-18 07:43:39 -04:00
|
|
|
static NotifyQt *Create ();
|
|
|
|
static NotifyQt *getInstance ();
|
2014-05-10 14:32:48 -04:00
|
|
|
static bool isAllDisable();
|
2012-05-15 16:25:53 -04:00
|
|
|
void enable() ;
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
virtual ~NotifyQt() { return; }
|
|
|
|
|
|
|
|
void setNetworkDialog(NetworkDialog *c) { cDialog = c; }
|
|
|
|
|
|
|
|
virtual void notifyListPreChange(int list, int type);
|
|
|
|
virtual void notifyListChange(int list, int type);
|
|
|
|
virtual void notifyErrorMsg(int list, int sev, std::string msg);
|
2016-03-31 16:52:53 -04:00
|
|
|
virtual void notifyChatMessage(const ChatMessage& /* msg */);
|
|
|
|
virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string);
|
|
|
|
virtual void notifyChatCleared(const ChatId &chat_id);
|
2010-09-02 06:15:13 -04:00
|
|
|
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
|
2010-10-09 14:35:34 -04:00
|
|
|
virtual void notifyHashingInfo(uint32_t type, const std::string& fileinfo);
|
2018-08-28 17:57:16 -04:00
|
|
|
virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files);
|
2018-05-31 09:41:54 -04:00
|
|
|
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups);
|
2009-12-28 17:40:45 -05:00
|
|
|
virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
|
|
|
|
virtual void notifyOwnAvatarChanged() ;
|
2016-02-14 05:53:27 -05:00
|
|
|
virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ;
|
2013-03-18 19:19:37 -04:00
|
|
|
virtual void notifyChatLobbyTimeShift(int time_shift) ;
|
2016-10-09 08:32:52 -04:00
|
|
|
void notifyConnectionWithoutCert();
|
2013-03-18 19:19:37 -04:00
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
virtual void notifyOwnStatusMessageChanged() ;
|
2010-05-21 16:49:48 -04:00
|
|
|
virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
|
2010-08-20 14:45:44 -04:00
|
|
|
/* peer has changed the state */
|
|
|
|
virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state);
|
|
|
|
/* one or more peers has changed the states */
|
|
|
|
virtual void notifyPeerStatusChangedSummary();
|
2015-03-20 06:39:17 -04:00
|
|
|
|
|
|
|
virtual void notifyGxsChange(const RsGxsChanges& change);
|
|
|
|
|
2011-09-29 05:20:09 -04:00
|
|
|
virtual void notifyHistoryChanged(uint32_t msgId, int type);
|
2010-10-06 20:17:42 -04:00
|
|
|
|
2010-11-05 18:46:40 -04:00
|
|
|
virtual void notifyDiscInfoChanged() ;
|
2010-11-24 19:20:25 -05:00
|
|
|
virtual void notifyDownloadComplete(const std::string& fileHash);
|
|
|
|
virtual void notifyDownloadCompleteCount(uint32_t count);
|
2016-08-08 19:22:14 -04:00
|
|
|
virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled);
|
2017-07-29 17:12:56 -04:00
|
|
|
virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time);
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2013-03-01 18:00:43 -05:00
|
|
|
// Queues the signature event so that it canhappen in the main GUI thread (to ask for passwd).
|
|
|
|
// To use this function: call is multiple times as soon as it returns true.
|
|
|
|
//
|
|
|
|
// Dont' use a while, if you're in a mutexed part, otherwize it will lock. You need to call the function
|
|
|
|
// and periodically exit the locked code between calls to allow the signature to happen.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// false = the signature is registered, but the result is not there yet. Call again soon.
|
|
|
|
// true = signature done. Data is ready. signature_result takes the following values:
|
|
|
|
// 1: signature success
|
|
|
|
// 2: signature failed. Wrong passwd, user pressed cancel, etc.
|
|
|
|
//
|
2016-08-08 19:22:14 -04:00
|
|
|
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, int& signature_result, std::string reason = "") ;
|
2013-03-01 18:00:43 -05:00
|
|
|
|
2010-09-07 11:49:31 -04:00
|
|
|
/* Notify from GUI */
|
2015-01-08 14:12:47 -05:00
|
|
|
void notifyChatFontChanged();
|
2010-09-07 11:49:31 -04:00
|
|
|
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
|
|
|
|
2015-05-26 11:19:57 -04:00
|
|
|
void testToasters(uint notifyFlags, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
|
|
|
void testToaster(ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
|
|
|
void testToaster(QString tag, ToasterNotify *toasterNotify, /*RshareSettings::enumToasterPosition*/ int position, QPoint margin);
|
2012-09-04 16:04:49 -04:00
|
|
|
|
2013-01-05 21:30:10 -05:00
|
|
|
void notifySettingsChanged();
|
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
signals:
|
|
|
|
// It's beneficial to send info to the GUI using signals, because signals are thread-safe
|
|
|
|
// as they get queued by Qt.
|
|
|
|
//
|
|
|
|
void hashingInfoChanged(const QString&) const ;
|
|
|
|
void filesPreModChanged(bool) const ;
|
|
|
|
void filesPostModChanged(bool) const ;
|
|
|
|
void transfersChanged() const ;
|
|
|
|
void friendsChanged() const ;
|
2012-01-11 19:13:25 -05:00
|
|
|
void lobbyListChanged() const ;
|
2016-02-14 05:53:27 -05:00
|
|
|
void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ;
|
2011-08-21 18:28:19 -04:00
|
|
|
void neighboursChanged() const ;
|
2009-12-28 17:40:45 -05:00
|
|
|
void messagesChanged() const ;
|
2010-08-22 18:12:26 -04:00
|
|
|
void messagesTagsChanged() const;
|
2014-12-29 16:41:05 -05:00
|
|
|
#ifdef REMOVE
|
2010-08-09 17:20:34 -04:00
|
|
|
void forumsChanged() const ; // use connect with Qt::QueuedConnection
|
2010-10-06 20:17:42 -04:00
|
|
|
void channelsChanged(int type) const ; // use connect with Qt::QueuedConnection
|
2014-12-29 16:41:05 -05:00
|
|
|
#endif
|
2009-12-28 17:40:45 -05:00
|
|
|
void configChanged() const ;
|
|
|
|
void logInfoChanged(const QString&) const ;
|
2016-03-31 16:52:53 -04:00
|
|
|
void chatStatusChanged(const ChatId&,const QString&) const ;
|
|
|
|
void chatCleared(const ChatId&) const ;
|
2010-09-02 06:15:13 -04:00
|
|
|
void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ;
|
2009-12-28 17:40:45 -05:00
|
|
|
void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ;
|
|
|
|
void peerHasNewAvatar(const QString& peer_id) const ;
|
|
|
|
void ownAvatarChanged() const ;
|
|
|
|
void ownStatusMessageChanged() const ;
|
2010-02-07 13:10:12 -05:00
|
|
|
void errorOccurred(int,int,const QString&) const ;
|
2010-05-21 16:49:48 -04:00
|
|
|
void diskFull(int,int) const ;
|
2010-08-31 13:13:52 -04:00
|
|
|
void peerStatusChanged(const QString& /* peer_id */, int /* status */);
|
|
|
|
void peerStatusChangedSummary() const;
|
2015-03-20 06:39:17 -04:00
|
|
|
void gxsChange(const RsGxsChanges& /* changes */);
|
2014-12-29 16:41:05 -05:00
|
|
|
#ifdef REMOVE
|
2010-09-01 13:56:15 -04:00
|
|
|
void publicChatChanged(int type) const ;
|
2010-09-20 20:08:06 -04:00
|
|
|
void privateChatChanged(int list, int type) const ;
|
2014-12-29 16:41:05 -05:00
|
|
|
#endif
|
|
|
|
void chatMessageReceived(ChatMessage msg);
|
2010-09-22 18:37:57 -04:00
|
|
|
void groupsChanged(int type) const ;
|
2010-11-05 18:46:40 -04:00
|
|
|
void discInfoChanged() const ;
|
2010-11-24 19:20:25 -05:00
|
|
|
void downloadComplete(const QString& /* fileHash */);
|
|
|
|
void downloadCompleteCountChanged(int /* count */);
|
2014-12-29 16:41:05 -05:00
|
|
|
#ifdef REMOVE
|
2012-02-11 19:58:47 -05:00
|
|
|
void forumMsgReadSatusChanged(const QString& forumId, const QString& msgId, int status);
|
2010-10-06 20:17:42 -04:00
|
|
|
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
2014-12-29 16:41:05 -05:00
|
|
|
#endif
|
2011-09-29 05:20:09 -04:00
|
|
|
void historyChanged(uint msgId, int type);
|
2011-11-28 17:36:13 -05:00
|
|
|
void chatLobbyInviteReceived() ;
|
2013-03-01 18:00:43 -05:00
|
|
|
void deferredSignatureHandlingRequested() ;
|
2013-03-18 19:19:37 -04:00
|
|
|
void chatLobbyTimeShift(int time_shift) ;
|
2016-10-09 08:32:52 -04:00
|
|
|
void connectionWithoutCert();
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2010-09-07 11:49:31 -04:00
|
|
|
/* Notify from GUI */
|
2015-01-08 14:12:47 -05:00
|
|
|
void chatFontChanged();
|
2010-09-07 11:49:31 -04:00
|
|
|
void chatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
2013-01-05 21:30:10 -05:00
|
|
|
void settingsChanged();
|
2014-05-10 14:32:48 -04:00
|
|
|
void disableAllChanged(bool disableAll) const;
|
2010-09-07 11:49:31 -04:00
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
public slots:
|
2012-02-11 19:58:47 -05:00
|
|
|
void UpdateGUI(); /* called by timer */
|
2014-05-10 14:32:48 -04:00
|
|
|
void SetDisableAll(bool bValue);
|
2017-07-29 16:37:14 -04:00
|
|
|
void resetCachedPassphrases() ;
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
private slots:
|
|
|
|
void runningTick();
|
2013-03-01 18:00:43 -05:00
|
|
|
void handleSignatureEvent() ;
|
2013-03-18 19:19:37 -04:00
|
|
|
void handleChatLobbyTimeShift(int) ;
|
2010-12-07 19:14:12 -05:00
|
|
|
|
2009-12-28 17:40:45 -05:00
|
|
|
private:
|
2010-12-07 19:14:12 -05:00
|
|
|
NotifyQt();
|
2010-07-18 07:43:39 -04:00
|
|
|
|
|
|
|
static NotifyQt *_instance;
|
2014-05-10 14:32:48 -04:00
|
|
|
static bool _disableAllToaster;
|
2009-12-28 17:40:45 -05:00
|
|
|
|
2014-01-07 17:51:22 -05:00
|
|
|
/* system notifications */
|
|
|
|
|
2010-12-07 19:14:12 -05:00
|
|
|
void startWaitingToasters();
|
|
|
|
|
|
|
|
// QMutex waitingToasterMutex; // for lock of the waiting toaster list
|
2015-05-26 11:19:57 -04:00
|
|
|
QList<ToasterItem*> waitingToasterList;
|
2010-12-07 19:14:12 -05:00
|
|
|
|
|
|
|
QTimer *runningToasterTimer;
|
2015-05-26 11:19:57 -04:00
|
|
|
QList<ToasterItem*> runningToasterList;
|
2010-12-07 19:14:12 -05:00
|
|
|
|
2012-05-15 16:25:53 -04:00
|
|
|
bool _enabled ;
|
|
|
|
QMutex _mutex ;
|
|
|
|
|
2013-03-01 18:00:43 -05:00
|
|
|
std::map<std::string,SignatureEventData*> _deferred_signature_queue ;
|
2009-12-28 17:40:45 -05:00
|
|
|
|
|
|
|
/* so we can update windows */
|
|
|
|
NetworkDialog *cDialog;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|