Added new message flag for system messages like friend request.

Show "RetroShare" as sender of system messages to myself.
Added new quick view in MessagesDialog to filter system messages.
Changed RetroShare link in friend request message to certificate.
Added new subject image for the system messages (defnax).
Removed not used notify in message service.
Recompile needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5129 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-05-01 09:18:55 +00:00
parent 32ac7efb42
commit c331098203
20 changed files with 271 additions and 172 deletions

View file

@ -1140,7 +1140,7 @@ bool AuthSSLimpl::decrypt(void *&out, int &outlen, const void *in, int inlen)
/********************************************************************************/
/* store for discovery */
bool AuthSSLimpl::FailedCertificate(X509 *x509, const struct sockaddr_in &addr, bool incoming)
bool AuthSSLimpl::FailedCertificate(X509 *x509, const struct sockaddr_in &/*addr*/, bool incoming)
{
std::string peerId = "UnknownSSLID";
if(!getX509id(x509, peerId))
@ -1165,10 +1165,8 @@ bool AuthSSLimpl::FailedCertificate(X509 *x509, const struct sockaddr_in &add
std::cerr << "GpgId: " << gpgid << " SSLcn: " << sslcn << " peerId: " << peerId;
std::cerr << std::endl;
{
// Hacky - adding IpAddress to SSLId.
rs_sprintf(peerId, "/%s:%u", rs_inet_ntoa(addr.sin_addr).c_str(), ntohs(addr.sin_port));
}
// Hacky - adding IpAddress to SSLId.
// rs_sprintf_append(peerId, "/%s:%u", rs_inet_ntoa(addr.sin_addr).c_str(), ntohs(addr.sin_port));
uint32_t notifyType = 0;

View file

@ -54,6 +54,9 @@
#define RS_MSG_REPLIED 0x0080 /* Message is replied */
#define RS_MSG_FORWARDED 0x0100 /* Message is forwarded */
#define RS_MSG_STAR 0x0200 /* Message is marked with a star */
// system message
#define RS_MSG_USER_REQUEST 0x0400 /* user request */
#define RS_MSG_SYSTEM (RS_MSG_USER_REQUEST)
#define RS_CHAT_LOBBY_EVENT_PEER_LEFT 0x01
#define RS_CHAT_LOBBY_EVENT_PEER_STATUS 0x02
@ -209,7 +212,8 @@ virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList) = 0;
virtual bool getMessage(const std::string &mId, MessageInfo &msg) = 0;
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0;
virtual bool MessageSend(MessageInfo &info) = 0;
virtual bool MessageSend(MessageInfo &info) = 0;
virtual bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag) = 0;
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId) = 0;
virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0;
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0;

View file

@ -96,6 +96,11 @@ bool p3Msgs::MessageSend(MessageInfo &info)
return mMsgSrv->MessageSend(info);
}
bool p3Msgs::SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag)
{
return mMsgSrv->SystemMessage(title, message, systemFlag);
}
bool p3Msgs::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
{
return mMsgSrv->MessageToDraft(info, msgParentId);

View file

@ -58,6 +58,7 @@ class p3Msgs: public RsMsgs
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
virtual bool MessageSend(MessageInfo &info);
virtual bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag);
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
virtual bool MessageToTrash(const std::string &mid, bool bTrash);
virtual bool MessageDelete(const std::string &mid);

View file

@ -1145,6 +1145,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
#endif
//let's parse the ssl id
pd.isOnlyGPGdetail = true;
size_t parsePosition = peerInfo.find(CERT_SSL_ID);
std::cerr << "sslid position : " << parsePosition << std::endl;
if (parsePosition != std::string::npos) {
@ -1155,7 +1156,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
std::string ssl_id = subCert.substr(0, parsePosition);
std::cerr << "SSL id : " << ssl_id << std::endl;
pd.id = ssl_id;
pd.isOnlyGPGdetail = false;
pd.isOnlyGPGdetail = pd.id.empty();
}
}

View file

@ -361,6 +361,9 @@ const uint32_t RS_MSG_FLAGS_REPLIED = 0x0080;
const uint32_t RS_MSG_FLAGS_FORWARDED = 0x0100;
const uint32_t RS_MSG_FLAGS_STAR = 0x0200;
const uint32_t RS_MSG_FLAGS_PARTIAL = 0x0400;
// system message
const uint32_t RS_MSG_FLAGS_USER_REQUEST = 0x0800;
const uint32_t RS_MSG_FLAGS_SYSTEM = RS_MSG_FLAGS_USER_REQUEST;
class RsMsgItem: public RsItem
{

View file

@ -56,13 +56,13 @@ const int msgservicezone = 54319;
p3MsgService::p3MsgService(p3LinkMgr *lm)
:p3Service(RS_SERVICE_TYPE_MSG), p3Config(CONFIG_TYPE_MSGS),
mLinkMgr(lm), mMsgMtx("p3MsgService"), msgChanged(1), mMsgUniqueId(time(NULL))
mLinkMgr(lm), mMsgMtx("p3MsgService"), mMsgUniqueId(time(NULL))
{
addSerialType(new RsMsgSerialiser());
/* Initialize standard tag types */
if(lm)
initStandardTagTypes();
/* Initialize standard tag types */
if(lm)
initStandardTagTypes();
}
uint32_t p3MsgService::getNewUniqueMsgId()
@ -71,35 +71,6 @@ uint32_t p3MsgService::getNewUniqueMsgId()
return mMsgUniqueId++;
}
/****** Mods/Notifications ****/
bool p3MsgService::MsgsChanged()
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
bool m1 = msgChanged.Changed();
return (m1);
}
bool p3MsgService::MsgNotifications()
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
return (msgNotifications.size() > 0);
}
bool p3MsgService::getMessageNotifications(std::list<MsgInfoSummary> &noteList)
{
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
noteList = msgNotifications;
msgNotifications.clear();
return (noteList.size() > 0);
}
int p3MsgService::tick()
{
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
@ -124,31 +95,21 @@ int p3MsgService::status()
return 1;
}
void p3MsgService::processMsg(RsMsgItem *mi)
void p3MsgService::processMsg(RsMsgItem *mi, bool incoming)
{
mi -> recvTime = time(NULL);
mi -> msgId = getNewUniqueMsgId();
std::string mesg;
{
RsStackMutex stack(mMsgMtx); /*** STACK LOCKED MTX ***/
// if (mi -> PeerId() == mLinkMgr->getOwnId())
if (mi->msgFlags & RS_MSG_FLAGS_OUTGOING)
if (incoming)
{
/* from the loopback device */
// mi -> msgFlags |= RS_MSG_FLAGS_OUTGOING;
}
else
{
mi -> msgFlags = RS_MSG_FLAGS_NEW;
/* from a peer */
MsgInfoSummary mis;
initRsMIS(mi, mis);
// msgNotifications.push_back(mis);
mi->msgFlags &= RS_MSG_FLAGS_SYSTEM; // remove flags
mi->msgFlags |= RS_MSG_FLAGS_NEW;
pqiNotify *notify = getPqiNotify();
if (notify)
{
@ -162,13 +123,16 @@ void p3MsgService::processMsg(RsMsgItem *mi)
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
}
}
else
{
mi->msgFlags |= RS_MSG_OUTGOING;
}
imsg[mi->msgId] = mi;
RsMsgSrcId* msi = new RsMsgSrcId();
msi->msgId = mi->msgId;
msi->srcId = mi->PeerId();
mSrcIds.insert(std::pair<uint32_t, RsMsgSrcId*>(msi->msgId, msi));
msgChanged.IndicateChanged();
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
}
@ -232,8 +196,7 @@ int p3MsgService::incomingMsgs()
if(checkAndRebuildPartialMessage(mi)) // only returns true when a msg is complete.
{
mi->msgFlags = 0;
processMsg(mi);
processMsg(mi, true);
}
}
if(changed)
@ -360,9 +323,6 @@ int p3MsgService::checkOutgoingMessages()
return 0;
}
bool p3MsgService::saveList(bool& cleanup, std::list<RsItem*>& itemList)
{
@ -576,7 +536,6 @@ bool p3MsgService::loadList(std::list<RsItem*>& load)
return true;
}
void p3MsgService::loadWelcomeMsg()
{
/* Load Welcome Message */
@ -638,7 +597,6 @@ bool p3MsgService::getMessageSummaries(std::list<MsgInfoSummary> &msgList)
return true;
}
bool p3MsgService::getMessage(const std::string &mId, MessageInfo &msg)
{
std::map<uint32_t, RsMsgItem *>::iterator mit;
@ -935,18 +893,12 @@ int p3MsgService::sendMessage(RsMsgItem *item)
bool p3MsgService::MessageSend(MessageInfo &info)
{
std::string ownId = mLinkMgr->getOwnId();
std::list<std::string>::const_iterator pit;
for(pit = info.msgto.begin(); pit != info.msgto.end(); pit++)
{
RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg)
{
if (*pit == ownId) {
processMsg(msg);
continue;
}
sendMessage(msg);
}
}
@ -956,10 +908,6 @@ bool p3MsgService::MessageSend(MessageInfo &info)
RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg)
{
if (*pit == ownId) {
processMsg(msg);
continue;
}
sendMessage(msg);
}
}
@ -969,22 +917,17 @@ bool p3MsgService::MessageSend(MessageInfo &info)
RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg)
{
if (*pit == ownId) {
processMsg(msg);
continue;
}
sendMessage(msg);
}
}
/* send to ourselves as well */
RsMsgItem *msg = initMIRsMsg(info, ownId);
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
if (msg)
{
/* use processMsg to get the new msgId */
// sendMessage(msg);
msg->msgFlags |= RS_MSG_FLAGS_OUTGOING;
processMsg(msg);
processMsg(msg, false);
// return new message id
rs_sprintf(info.msgId, "%lu", msg->msgId);
@ -993,6 +936,39 @@ bool p3MsgService::MessageSend(MessageInfo &info)
return true;
}
bool p3MsgService::SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag)
{
if ((systemFlag & RS_MSG_SYSTEM) == 0) {
/* no flag specified */
return false;
}
std::string ownId = mLinkMgr->getOwnId();
RsMsgItem *msg = new RsMsgItem();
msg->PeerId(ownId);
msg->msgFlags = 0;
if (systemFlag & RS_MSG_USER_REQUEST) {
msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST;
}
msg->msgId = 0;
msg->sendTime = time(NULL);
msg->recvTime = 0;
msg->subject = title;
msg->message = message;
msg->msgto.ids.push_back(ownId);
processMsg(msg, true);
return true;
}
bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
{
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
@ -1361,7 +1337,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
/* translate flags, if we sent it... outgoing */
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|| (msg->PeerId() == mLinkMgr->getOwnId()))
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
{
mi.msgflags |= RS_MSG_OUTGOING;
}
@ -1398,6 +1374,10 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{
mi.msgflags |= RS_MSG_STAR;
}
if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST)
{
mi.msgflags |= RS_MSG_USER_REQUEST;
}
mi.ts = msg->sendTime;
mi.srcId = msg->PeerId();
@ -1494,6 +1474,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{
mis.msgflags |= RS_MSG_STAR;
}
if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST)
{
mis.msgflags |= RS_MSG_USER_REQUEST;
}
mis.srcId = msg->PeerId();
{
@ -1506,7 +1490,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
mis.ts = msg->sendTime;
}
RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const std::string &to)
{
RsMsgItem *msg = new RsMsgItem();
@ -1553,6 +1537,12 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, std::string to)
msg -> attachment.items.push_back(mfi);
}
/* translate flags from outside */
if (info.msgflags & RS_MSG_USER_REQUEST)
{
msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST;
}
//std::cerr << "p3MsgService::initMIRsMsg()" << std::endl;
//msg->print(std::cerr);
return msg;

View file

@ -51,10 +51,6 @@ class p3MsgService: public p3Service, public p3Config, public pqiMonitor
p3MsgService(p3LinkMgr *lm);
/* External Interface */
bool MsgsChanged(); /* should update display */
bool MsgNotifications(); /* popup - messages */
bool getMessageNotifications(std::list<MsgInfoSummary> &noteList);
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
bool getMessage(const std::string &mid, MessageInfo &msg);
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
@ -67,6 +63,7 @@ bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
bool MessageSend(MessageInfo &info);
bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag);
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
bool MessageToTrash(const std::string &mid, bool bTrash);
@ -107,12 +104,12 @@ int sendMessage(RsMsgItem *item);
void checkSizeAndSendMessage(RsMsgItem *msg);
int incomingMsgs();
void processMsg(RsMsgItem *mi);
void processMsg(RsMsgItem *mi, bool incoming);
bool checkAndRebuildPartialMessage(RsMsgItem*) ;
void initRsMI(RsMsgItem *msg, MessageInfo &mi);
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
RsMsgItem *initMIRsMsg(MessageInfo &info, std::string to);
RsMsgItem *initMIRsMsg(MessageInfo &info, const std::string &to);
void initStandardTagTypes();
@ -129,16 +126,11 @@ void initStandardTagTypes();
std::map<std::string, RsMsgItem *> _pendingPartialMessages ;
/* List of notifications to post via Toaster */
std::list<MsgInfoSummary> msgNotifications;
/* maps for tags types and msg tags */
std::map<uint32_t, RsMsgTagType*> mTags;
std::map<uint32_t, RsMsgTags*> mMsgTags;
Indicator msgChanged;
uint32_t mMsgUniqueId;
// used delete msgSrcIds after config save