Merge branch 'badPacketMessage'

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1168 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2009-05-05 13:35:36 +00:00
parent 16231dea2b
commit 698425ba9e
7 changed files with 75 additions and 1 deletions

View File

@ -55,6 +55,27 @@ bool p3Notify::NotifySysMessage(uint32_t &sysid, uint32_t &type,
return false; 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) 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; 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) bool p3Notify::GetFeedItem(RsFeedItem &item)
{ {

View File

@ -41,6 +41,16 @@ class p3NotifySysMsg
std::string msg; std::string msg;
}; };
class p3NotifyLogMsg
{
public:
uint32_t sysid;
uint32_t type;
std::string title;
std::string msg;
};
class p3NotifyPopupMsg class p3NotifyPopupMsg
{ {
public: public:
@ -62,6 +72,7 @@ virtual ~p3Notify() { return; }
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg); std::string &title, std::string &msg);
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, 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 */ /* Control over Messages */
virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list); virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list);
@ -75,6 +86,7 @@ virtual bool GetFeedItem(RsFeedItem &item);
/* Overloaded from pqiNotify */ /* Overloaded from pqiNotify */
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg); 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 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); virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3);
private: private:
@ -82,6 +94,7 @@ virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::s
RsMutex noteMtx; RsMutex noteMtx;
std::list<p3NotifySysMsg> pendingSysMsgs; std::list<p3NotifySysMsg> pendingSysMsgs;
std::list<p3NotifyLogMsg> pendingLogMsgs;
std::list<p3NotifyPopupMsg> pendingPopupMsgs; std::list<p3NotifyPopupMsg> pendingPopupMsgs;
std::list<RsFeedItem> pendingNewsFeed; std::list<RsFeedItem> pendingNewsFeed;
}; };

View File

@ -42,6 +42,7 @@ virtual ~pqiNotify() { return; }
/* Input from libretroshare */ /* Input from libretroshare */
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg) = 0; 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 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; virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3) = 0;
}; };

View File

@ -628,7 +628,7 @@ continue_packet:
msgout << "\n"; msgout << "\n";
std::string msg = msgout.str(); std::string msg = msgout.str();
notify->AddSysMessage(0, RS_SYS_WARNING, title, msg); notify->AddLogMessage(0, RS_SYS_WARNING, title, msg);
} }
bio->close(); bio->close();
reading_state = reading_state_initial ; // restart at state 1. reading_state = reading_state_initial ; // restart at state 1.

View File

@ -106,6 +106,8 @@ virtual ~RsNotify() { return; }
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg) = 0; std::string &title, std::string &msg) = 0;
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, 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 */ /* Control over Messages */
virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list) = 0; virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list) = 0;

View File

@ -267,6 +267,24 @@ void NotifyQt::UpdateGUI()
break; 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;
}
}
} }
} }

View File

@ -106,6 +106,8 @@ virtual ~RsNotify() { return; }
virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type, virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg) = 0; std::string &title, std::string &msg) = 0;
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, 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 */ /* Control over Messages */
virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list) = 0; virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list) = 0;