diff --git a/libretroshare/src/pqi/p3notify.cc b/libretroshare/src/pqi/p3notify.cc index a2bb54376..ef5308d53 100644 --- a/libretroshare/src/pqi/p3notify.cc +++ b/libretroshare/src/pqi/p3notify.cc @@ -55,6 +55,27 @@ bool p3Notify::NotifySysMessage(uint32_t &sysid, uint32_t &type, return false; } + /* Output for retroshare-gui */ +bool p3Notify::NotifyLogMessage(uint32_t &sysid, uint32_t &type, + std::string &title, std::string &msg) +{ + RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/ + if (pendingLogMsgs.size() > 0) + { + p3NotifyLogMsg smsg = pendingLogMsgs.front(); + pendingLogMsgs.pop_front(); + + sysid = smsg.sysid; + type = smsg.type; + title = smsg.title; + msg = smsg.msg; + + return true; + } + + return false; +} + bool p3Notify::NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg) { @@ -132,6 +153,23 @@ bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type, return true; } +bool p3Notify::AddLogMessage(uint32_t sysid, uint32_t type, + std::string title, std::string msg) +{ + RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/ + + p3NotifyLogMsg smsg; + + smsg.sysid = sysid; + smsg.type = type; + smsg.title = title; + smsg.msg = msg; + + pendingLogMsgs.push_back(smsg); + + return true; +} + bool p3Notify::GetFeedItem(RsFeedItem &item) { diff --git a/libretroshare/src/pqi/p3notify.h b/libretroshare/src/pqi/p3notify.h index 8d360bbf0..69c3d7e6f 100644 --- a/libretroshare/src/pqi/p3notify.h +++ b/libretroshare/src/pqi/p3notify.h @@ -41,6 +41,16 @@ class p3NotifySysMsg std::string msg; }; +class p3NotifyLogMsg +{ + public: + + uint32_t sysid; + uint32_t type; + std::string title; + std::string msg; +}; + class p3NotifyPopupMsg { public: @@ -62,6 +72,7 @@ virtual ~p3Notify() { return; } virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg); virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg); +virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg); /* Control over Messages */ virtual bool GetSysMessageList(std::map &list); @@ -75,6 +86,7 @@ virtual bool GetFeedItem(RsFeedItem &item); /* Overloaded from pqiNotify */ virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg); virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg); +virtual bool AddLogMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg); virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3); private: @@ -82,6 +94,7 @@ virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::s RsMutex noteMtx; std::list pendingSysMsgs; + std::list pendingLogMsgs; std::list pendingPopupMsgs; std::list pendingNewsFeed; }; diff --git a/libretroshare/src/pqi/pqinotify.h b/libretroshare/src/pqi/pqinotify.h index 06af3baa7..2660822c2 100644 --- a/libretroshare/src/pqi/pqinotify.h +++ b/libretroshare/src/pqi/pqinotify.h @@ -42,6 +42,7 @@ virtual ~pqiNotify() { return; } /* Input from libretroshare */ virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg) = 0; virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg) = 0; +virtual bool AddLogMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg) = 0; virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3) = 0; }; diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index d9feb875e..23b14c355 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -628,7 +628,7 @@ continue_packet: msgout << "\n"; std::string msg = msgout.str(); - notify->AddSysMessage(0, RS_SYS_WARNING, title, msg); + notify->AddLogMessage(0, RS_SYS_WARNING, title, msg); } bio->close(); reading_state = reading_state_initial ; // restart at state 1. diff --git a/libretroshare/src/rsiface/rsnotify.h b/libretroshare/src/rsiface/rsnotify.h index 95e1d0464..55ef4678f 100644 --- a/libretroshare/src/rsiface/rsnotify.h +++ b/libretroshare/src/rsiface/rsnotify.h @@ -106,6 +106,8 @@ virtual ~RsNotify() { return; } virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg) = 0; virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg) = 0; +virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, + std::string &title, std::string &msg) = 0; /* Control over Messages */ virtual bool GetSysMessageList(std::map &list) = 0; diff --git a/retroshare-gui/src/rsiface/notifyqt.cpp b/retroshare-gui/src/rsiface/notifyqt.cpp index 7ae3ad57a..abad0c587 100644 --- a/retroshare-gui/src/rsiface/notifyqt.cpp +++ b/retroshare-gui/src/rsiface/notifyqt.cpp @@ -267,6 +267,24 @@ void NotifyQt::UpdateGUI() break; } } + if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) + { + /* make a log message */ + std::string logMesString = title + " " + msg; + switch(type) + { + case RS_SYS_ERROR: + cDialog->setLogInfo(QString(logMesString.c_str())); + break; + case RS_SYS_WARNING: + cDialog->setLogInfo(QString(logMesString.c_str())); + break; + default: + case RS_SYS_INFO: + cDialog->setLogInfo(QString(logMesString.c_str())); + break; + } + } } } diff --git a/retroshare-gui/src/rsiface/rsnotify.h b/retroshare-gui/src/rsiface/rsnotify.h index 95e1d0464..bf121c69e 100644 --- a/retroshare-gui/src/rsiface/rsnotify.h +++ b/retroshare-gui/src/rsiface/rsnotify.h @@ -106,6 +106,8 @@ virtual ~RsNotify() { return; } virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, std::string &title, std::string &msg) = 0; virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg) = 0; +virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type, + std::string &title, std::string &msg) = 0; /* Control over Messages */ virtual bool GetSysMessageList(std::map &list) = 0;