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));
}
// 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
@ -210,6 +213,7 @@ 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 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,7 +56,7 @@ 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());
@ -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

View File

@ -44,6 +44,7 @@
#define IMAGE_MESSAGEREMOVE ":/images/message-mail-imapdelete.png"
#define IMAGE_STAR_ON ":/images/star-on-16.png"
#define IMAGE_STAR_OFF ":/images/star-off-16.png"
#define IMAGE_SYSTEM ":/images/user/user_request6.png"
#define COLUMN_COUNT 8
#define COLUMN_STAR 0
@ -72,6 +73,7 @@
#define QUICKVIEW_TYPE_TAG 2
#define QUICKVIEW_STATIC_ID_STARRED 1
#define QUICKVIEW_STATIC_ID_SYSTEM 2
#define ROW_INBOX 0
#define ROW_OUTBOX 1
@ -85,15 +87,15 @@ MessagesDialog::LockUpdate::LockUpdate (MessagesDialog *pDialog, bool bUpdate)
m_pDialog = pDialog;
m_bUpdate = bUpdate;
m_pDialog->m_nLockUpdate++;
m_pDialog->lockUpdate++;
}
MessagesDialog::LockUpdate::~LockUpdate ()
{
if(--m_pDialog->m_nLockUpdate < 0)
m_pDialog->m_nLockUpdate = 0;
if(--m_pDialog->lockUpdate < 0)
m_pDialog->lockUpdate = 0;
if (m_bUpdate && m_pDialog->m_nLockUpdate == 0) {
if (m_bUpdate && m_pDialog->lockUpdate == 0) {
m_pDialog->insertMessages();
}
}
@ -150,9 +152,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
m_bProcessSettings = false;
inProcessSettings = false;
inChange = false;
m_nLockUpdate = 0;
lockUpdate = 0;
connect(ui.messagestreeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(messageslistWidgetCostumPopupMenu(QPoint)));
connect(ui.listWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(folderlistWidgetCostumPopupMenu(QPoint)));
@ -181,7 +183,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connectActions();
m_eListMode = LIST_NOTHING;
listMode = LIST_NOTHING;
mCurrMsgId = "";
@ -317,7 +319,7 @@ void MessagesDialog::processSettings(bool load)
{
int messageTreeVersion = 2; // version number for the settings to solve problems when modifying the column count
m_bProcessSettings = true;
inProcessSettings = true;
QHeaderView *msgwheader = ui.messagestreeView->header () ;
@ -372,7 +374,7 @@ void MessagesDialog::processSettings(bool load)
msgWidget->processSettings("MessageDialog", load);
}
m_bProcessSettings = false;
inProcessSettings = false;
}
bool MessagesDialog::eventFilter(QObject *obj, QEvent *event)
@ -404,11 +406,11 @@ void MessagesDialog::fillQuickView()
// save current selection
QListWidgetItem *item = ui.quickViewWidget->currentItem();
int nSelectedType = 0;
uint32_t nSelectedId = 0;
int selectedType = 0;
uint32_t selectedId = 0;
if (item) {
nSelectedType = item->data(ROLE_QUICKVIEW_TYPE).toInt();
nSelectedId = item->data(ROLE_QUICKVIEW_ID).toInt();
selectedType = item->data(ROLE_QUICKVIEW_TYPE).toInt();
selectedId = item->data(ROLE_QUICKVIEW_ID).toInt();
}
QListWidgetItem *itemToSelect = NULL;
@ -423,7 +425,17 @@ void MessagesDialog::fillQuickView()
item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_STARRED);
item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList
if (nSelectedType == QUICKVIEW_TYPE_STATIC && nSelectedId == QUICKVIEW_STATIC_ID_STARRED) {
if (selectedType == QUICKVIEW_TYPE_STATIC && selectedId == QUICKVIEW_STATIC_ID_STARRED) {
itemToSelect = item;
}
item = new QListWidgetItem(tr("System"), ui.quickViewWidget);
item->setIcon(QIcon(IMAGE_SYSTEM));
item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC);
item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_SYSTEM);
item->setData(ROLE_QUICKVIEW_TEXT, item->text()); // for updateMessageSummaryList
if (selectedType == QUICKVIEW_TYPE_STATIC && selectedId == QUICKVIEW_STATIC_ID_SYSTEM) {
itemToSelect = item;
}
@ -437,7 +449,7 @@ void MessagesDialog::fillQuickView()
item->setData(ROLE_QUICKVIEW_ID, tag->first);
item->setData(ROLE_QUICKVIEW_TEXT, text); // for updateMessageSummaryList
if (nSelectedType == QUICKVIEW_TYPE_TAG && tag->first == nSelectedId) {
if (selectedType == QUICKVIEW_TYPE_TAG && tag->first == selectedId) {
itemToSelect = item;
}
}
@ -707,7 +719,7 @@ void MessagesDialog::changeBox(int)
MessagesModel->removeRows (0, MessagesModel->rowCount());
ui.quickViewWidget->setCurrentItem(NULL);
m_eListMode = LIST_BOX;
listMode = LIST_BOX;
insertMessages();
insertMsgTxtAndFiles();
@ -729,7 +741,7 @@ void MessagesDialog::changeQuickView(int newrow)
MessagesModel->removeRows (0, MessagesModel->rowCount());
ui.listWidget->setCurrentItem(NULL);
m_eListMode = LIST_QUICKVIEW;
listMode = LIST_QUICKVIEW;
insertMessages();
insertMsgTxtAndFiles();
@ -739,7 +751,7 @@ void MessagesDialog::changeQuickView(int newrow)
void MessagesDialog::messagesTagsChanged()
{
if (m_nLockUpdate) {
if (lockUpdate) {
return;
}
@ -755,7 +767,9 @@ static void InitIconAndFont(QStandardItem *item[COLUMN_COUNT])
if (msgFlags & RS_MSG_NEW) {
item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-state-new.png"));
} else {
if (msgFlags & RS_MSG_UNREAD_BY_USER) {
if (msgFlags & RS_MSG_USER_REQUEST) {
item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/user/user_request6.png"));
} else if (msgFlags & RS_MSG_UNREAD_BY_USER) {
if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_REPLIED) {
item[COLUMN_SUBJECT]->setIcon(QIcon(":/images/message-mail-replied.png"));
} else if ((msgFlags & (RS_MSG_REPLIED | RS_MSG_FORWARDED)) == RS_MSG_FORWARDED) {
@ -813,7 +827,7 @@ static void InitIconAndFont(QStandardItem *item[COLUMN_COUNT])
void MessagesDialog::insertMessages()
{
if (m_nLockUpdate) {
if (lockUpdate) {
return;
}
@ -822,14 +836,16 @@ void MessagesDialog::insertMessages()
std::list<MsgInfoSummary> msgList;
std::list<MsgInfoSummary>::const_iterator it;
MessageInfo msgInfo;
bool bGotInfo;
bool gotInfo;
QString text;
std::string ownId = rsPeers->getOwnId();
rsMsgs -> getMessageSummaries(msgList);
std::cerr << "MessagesDialog::insertMessages()" << std::endl;
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
/* check the mode we are in */
unsigned int msgbox = 0;
@ -841,7 +857,7 @@ void MessagesDialog::insertMessages()
QIcon boxIcon;
QString placeholderText;
switch (m_eListMode) {
switch (listMode) {
case LIST_NOTHING:
doFill = false;
break;
@ -901,6 +917,9 @@ void MessagesDialog::insertMessages()
case QUICKVIEW_STATIC_ID_STARRED:
placeholderText = tr("No starred messages available. Stars let you give messages a special status to make them easier to find. To star a message, click on the light grey star beside any message.");
break;
case QUICKVIEW_STATIC_ID_SYSTEM:
placeholderText = tr("No system messages available.");
break;
}
break;
case QUICKVIEW_TYPE_TAG:
@ -935,7 +954,7 @@ void MessagesDialog::insertMessages()
/* search messages */
std::list<MsgInfoSummary> msgToShow;
for(it = msgList.begin(); it != msgList.end(); it++) {
if (m_eListMode == LIST_BOX) {
if (listMode == LIST_BOX) {
if (isTrash) {
if ((it->msgflags & RS_MSG_TRASH) == 0) {
continue;
@ -948,14 +967,17 @@ void MessagesDialog::insertMessages()
continue;
}
}
} else if (m_eListMode == LIST_QUICKVIEW && quickViewType == QUICKVIEW_TYPE_TAG) {
} else if (listMode == LIST_QUICKVIEW && quickViewType == QUICKVIEW_TYPE_TAG) {
MsgTagInfo tagInfo;
rsMsgs->getMessageTag(it->msgId, tagInfo);
if (std::find(tagInfo.tagIds.begin(), tagInfo.tagIds.end(), quickViewId) == tagInfo.tagIds.end()) {
continue;
}
} else if (m_eListMode == LIST_QUICKVIEW && quickViewType == QUICKVIEW_TYPE_STATIC) {
if ((it->msgflags & RS_MSG_STAR) == 0) {
} else if (listMode == LIST_QUICKVIEW && quickViewType == QUICKVIEW_TYPE_STATIC) {
if (quickViewId == QUICKVIEW_STATIC_ID_STARRED && (it->msgflags & RS_MSG_STAR) == 0) {
continue;
}
if (quickViewId == QUICKVIEW_STATIC_ID_SYSTEM && (it->msgflags & RS_MSG_SYSTEM) == 0) {
continue;
}
} else {
@ -1004,7 +1026,7 @@ void MessagesDialog::insertMessages()
*
*/
bGotInfo = false;
gotInfo = false;
msgInfo = MessageInfo(); // clear
// search exisisting items
@ -1076,10 +1098,14 @@ void MessagesDialog::insertMessages()
// From ....
{
if (msgbox == RS_MSG_INBOX || msgbox == RS_MSG_OUTBOX) {
text = QString::fromUtf8(rsPeers->getPeerName(it->srcId).c_str());
if ((it->msgflags & RS_MSG_SYSTEM) && it->srcId == ownId) {
text = "RetroShare";
} else {
if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
bGotInfo = true;
text = QString::fromUtf8(rsPeers->getPeerName(it->srcId).c_str());
}
} else {
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
gotInfo = true;
text.clear();
@ -1164,10 +1190,10 @@ void MessagesDialog::insertMessages()
item[COLUMN_ATTACHEMENTS] -> setTextAlignment(Qt::AlignHCenter);
}
if (nFilterColumn == COLUMN_CONTENT) {
if (filterColumn == COLUMN_CONTENT) {
// need content for filter
if (bGotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
bGotInfo = true;
if (gotInfo || rsMsgs->getMessage(it->msgId, msgInfo)) {
gotInfo = true;
QTextDocument doc;
doc.setHtml(QString::fromStdWString(msgInfo.msg));
item[COLUMN_CONTENT]->setText(doc.toPlainText().replace(QString("\n"), QString(" ")));
@ -1571,7 +1597,7 @@ void MessagesDialog::filterChanged(const QString& text)
void MessagesDialog::filterColumnChanged()
{
if (m_bProcessSettings) {
if (inProcessSettings) {
return;
}
@ -1595,6 +1621,7 @@ void MessagesDialog::updateMessageSummaryList()
unsigned int inboxCount = 0;
unsigned int trashboxCount = 0;
unsigned int starredCount = 0;
unsigned int systemCount = 0;
/* calculating the new messages */
// rsMsgs->getMessageCount (&inboxCount, &newInboxCount, &newOutboxCount, &newDraftCount, &newSentboxCount);
@ -1621,6 +1648,10 @@ void MessagesDialog::updateMessageSummaryList()
starredCount++;
}
if (it->msgflags & RS_MSG_SYSTEM) {
systemCount++;
}
/* calculate box */
if (it->msgflags & RS_MSG_TRASH) {
trashboxCount++;
@ -1777,6 +1808,9 @@ void MessagesDialog::updateMessageSummaryList()
case QUICKVIEW_STATIC_ID_STARRED:
text += " (" + QString::number(starredCount) + ")";
break;
case QUICKVIEW_STATIC_ID_SYSTEM:
text += " (" + QString::number(systemCount) + ")";
break;
}
item->setText(text);

View File

@ -126,11 +126,11 @@ private:
void closeTab(const std::string &msgId);
bool m_bProcessSettings;
bool inProcessSettings;
bool inChange;
int m_nLockUpdate; // use with LockUpdate
int lockUpdate; // use with LockUpdate
enum { LIST_NOTHING, LIST_BOX, LIST_QUICKVIEW } m_eListMode;
enum { LIST_NOTHING, LIST_BOX, LIST_QUICKVIEW } listMode;
std::string mCurrMsgId;

View File

@ -110,7 +110,7 @@ void NewsFeed::updateFeed()
case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT:
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) {
MessageComposer::sendConnectAttemptMsg(fi.mId1, QString::fromUtf8(fi.mId3.c_str()));
MessageComposer::sendConnectAttemptMsg(fi.mId1, fi.mId2, QString::fromUtf8(fi.mId3.c_str()));
}
if (flags & RS_FEED_TYPE_SECURITY)
addFeedItemSecurityConnectAttempt(fi);

View File

@ -281,19 +281,19 @@ bool RetroShareLink::createPerson(const std::string& id)
return valid();
}
bool RetroShareLink::createCertificate(const std::string& ssl_id)
bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id)
{
std::string invite = rsPeers->GetRetroshareInvite(ssl_id,false) ;
std::string invite = rsPeers->GetRetroshareInvite(ssl_or_gpg_id, false) ;
if(invite == "")
{
std::cerr << "RetroShareLink::createPerson() Couldn't get retroshare invite for ssl id: " << ssl_id << std::endl;
std::cerr << "RetroShareLink::createPerson() Couldn't get retroshare invite for ssl id: " << ssl_or_gpg_id << std::endl;
return false;
}
RsPeerDetails detail;
if (rsPeers->getPeerDetails(ssl_id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl;
if (rsPeers->getPeerDetails(ssl_or_gpg_id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_or_gpg_id << std::endl;
return false;
}
@ -306,14 +306,20 @@ bool RetroShareLink::createCertificate(const std::string& ssl_id)
_type = TYPE_CERTIFICATE;
_GPGid = QString::fromStdString(detail.gpg_id).right(8);
_SSLid = QString::fromStdString(ssl_id) ;
_GPGBase64String = gpg_base_64.replace("\n","") ;
if (detail.isOnlyGPGdetail) {
_SSLid.clear();
_location.clear();
_ext_ip_port.clear();
_loc_ip_port.clear();
} else {
_SSLid = QString::fromStdString(ssl_or_gpg_id) ;
_location = QString::fromUtf8(detail.location.c_str()) ;
_name = QString::fromUtf8(detail.name.c_str()) ;
_ext_ip_port = QString::fromStdString(invite).section("--EXT--",1,1) ;
QString lst = QString::fromStdString(invite).section("--EXT--",0,0) ;
_loc_ip_port = lst.section("--LOCAL--",1,1) ;
}
_GPGBase64String = gpg_base_64.replace("\n","") ;
_name = QString::fromUtf8(detail.name.c_str()) ;
std::cerr << "Found gpg base 64 string = " << _GPGBase64String.toStdString() << std::endl;
std::cerr << "Found gpg base 64 checksum = " << _GPGBase64CheckSum.toStdString() << std::endl;
@ -326,6 +332,35 @@ bool RetroShareLink::createCertificate(const std::string& ssl_id)
return true;
}
bool RetroShareLink::createUnknwonSslCertificate(const std::string& sslId, const std::string& gpgId)
{
// first try ssl id
if (createCertificate(sslId)) {
if (gpgId.empty() || _GPGid.toStdString() == gpgId) {
return true;
}
// wrong gpg id
return false;
}
// then gpg id
if (createCertificate(gpgId)) {
if (!_SSLid.isEmpty()) {
return false;
}
if (sslId.empty()) {
return true;
}
_SSLid = QString::fromStdString(sslId);
if (_location.isEmpty()) {
_location = _name;
}
return true;
}
return false;
}
bool RetroShareLink::createForum(const std::string& id, const std::string& msgId)
{
clear();
@ -602,14 +637,22 @@ QString RetroShareLink::toString() const
QUrl url ;
url.setScheme(RSLINK_SCHEME);
url.setHost(HOST_CERTIFICATE) ;
if (!_SSLid.isEmpty()) {
url.addQueryItem(CERTIFICATE_SSLID, _SSLid);
}
url.addQueryItem(CERTIFICATE_GPG_ID, _GPGid);
url.addQueryItem(CERTIFICATE_GPG_BASE64, _GPGBase64String);
url.addQueryItem(CERTIFICATE_GPG_CHECKSUM, _GPGBase64CheckSum);
if (!_location.isEmpty()) {
url.addQueryItem(CERTIFICATE_LOCATION, encodeItem(_location));
}
url.addQueryItem(CERTIFICATE_NAME, encodeItem(_name));
if (!_loc_ip_port.isEmpty()) {
url.addQueryItem(CERTIFICATE_LOC_IPPORT, encodeItem(_loc_ip_port));
}
if (!_ext_ip_port.isEmpty()) {
url.addQueryItem(CERTIFICATE_EXT_IPPORT, encodeItem(_ext_ip_port));
}
return url.toString();
}
@ -624,8 +667,12 @@ QString RetroShareLink::niceName() const
return PeerDefs::rsid(name().toUtf8().constData(), hash().toStdString());
}
if(type() == TYPE_CERTIFICATE)
if(type() == TYPE_CERTIFICATE) {
if (_location.isEmpty()) {
return QString("RetroShare Certificate (%1)").arg(_name);
}
return QString("RetroShare Certificate (%1, @%2)").arg(_name, _location); // should add SSL id there
}
return name();
}

View File

@ -61,7 +61,8 @@ class RetroShareLink
bool createChannel(const std::string& id, const std::string& msgId);
bool createSearch(const QString& keywords);
bool createMessage(const std::string& peerId, const QString& subject);
bool createCertificate(const std::string& peerId) ;
bool createCertificate(const std::string& ssl_or_gpg_id) ;
bool createUnknwonSslCertificate(const std::string& sslId, const std::string& gpgId = "") ;
enumType type() const {return _type; }
uint64_t size() const { return _size ; }

View File

@ -84,7 +84,12 @@ void MsgItem::updateItemStatic()
avatar->setId(mPeerId, false);
QString title;
QString srcName = QString::fromUtf8(rsPeers->getPeerName(mi.srcId).c_str());
QString srcName;
if ((mi.msgflags & RS_MSG_SYSTEM) && mi.srcId == rsPeers->getOwnId()) {
srcName = "RetroShare";
} else {
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.srcId).c_str());
}
{
QDateTime qtime;

View File

@ -468,6 +468,7 @@
<file>images/user/agt_forum128.png</file>
<file>images/user/group16.png</file>
<file>images/user/group24.png</file>
<file>images/user/user_request6.png</file>
<file>images/user/user_request48.png</file>
<file>images/user/user_request_unknown48.png</file>
<file>images/up.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

View File

@ -114,6 +114,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
ui.setupUi(this);
m_msgType = NORMAL;
// needed to send system flags with reply
//systemFlags = 0;
setupFileActions();
setupEditActions();
@ -453,12 +455,17 @@ void MessageComposer::recommendFriend(const std::list <std::string> &sslIds, con
/* window will destroy itself! */
}
void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const QString &sslName)
void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const std::string &sslId, const QString &sslName)
{
if (gpgId.empty()) {
return;
}
RetroShareLink link;
if (link.createUnknwonSslCertificate(sslId, gpgId) == false) {
return;
}
QString title = QString("%1 %2").arg(sslName, tr("wants to be friend with you on RetroShare"));
/* search for an exisiting message in the inbox */
@ -473,28 +480,17 @@ void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const QStr
if ((it->msgflags & RS_MSG_BOXMASK) != RS_MSG_INBOX) {
continue;
}
if ((it->msgflags & RS_MSG_USER_REQUEST) == 0) {
continue;
}
if (it->title == title.toStdWString()) {
return;
}
}
/* create a message */
MessageComposer *msgDialog = MessageComposer::newMsg();
msgDialog->insertTitleText(title);
msgDialog->addRecipient(TO, rsPeers->getOwnId(), false);
RetroShareLink link;
link.createPerson(gpgId);
QString msgText = tr("Hi %1,<br>%2 wants to be friend with you on RetroShare.<br><br>Respond now<br>%3<br><br>Thanks.<br>The RetroShare Team").arg(QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str()), sslName, link.toHtml());
msgDialog->insertMsgText(msgText, true);
if (msgDialog->sendMessage_internal(false)) {
msgDialog->close();
return;
}
msgDialog->ui.msgText->document()->setModified(false);
msgDialog->close();
rsMsgs->SystemMessage(title.toStdWString(), msgText.toStdWString(), RS_MSG_USER_REQUEST);
}
void MessageComposer::closeEvent (QCloseEvent * event)
@ -861,6 +857,9 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
}
}
// needed to send system flags with reply
//msgComposer->systemFlags = (msgInfo.msgflags & RS_MSG_SYSTEM);
msgComposer->insertTitleText(QString::fromStdWString(msgInfo.title));
msgComposer->insertMsgText(QString::fromStdWString(msgInfo.msg));
@ -950,6 +949,9 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all)
}
}
// needed to send system flags with reply
//msgComposer->systemFlags = (msgInfo.msgflags & RS_MSG_SYSTEM);
msgComposer->calculateTitle();
/* window will destroy itself! */
@ -981,6 +983,9 @@ MessageComposer *MessageComposer::forwardMsg(const std::string &msgId)
msgComposer->insertFileList(files_info);
// needed to send system flags with reply
//msgComposer->systemFlags = (msgInfo.msgflags & RS_MSG_SYSTEM);
msgComposer->calculateTitle();
/* window will destroy itself! */
@ -1083,6 +1088,9 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
mi.title = misc::removeNewLine(ui.titleEdit->text()).toStdWString();
mi.msg = ui.msgText->toHtml().toStdWString();
// needed to send system flags with reply
//mi.msgflags = systemFlags;
mi.msgflags = 0;
QString text;
RsHtml::optimizeHtml(ui.msgText, text);

View File

@ -50,7 +50,7 @@ public:
static void msgFriend(const std::string &id, bool group);
static QString recommendMessage();
static void recommendFriend(const std::list <std::string> &sslIds, const std::string &to = "", const QString &msg = "", bool autoSend = false);
static void sendConnectAttemptMsg(const std::string &gpgId, const QString &sslName);
static void sendConnectAttemptMsg(const std::string &gpgId, const std::string &sslId, const QString &sslName);
static MessageComposer *newMsg(const std::string &msgId = "");
static MessageComposer *replyMsg(const std::string &msgId, bool all);
@ -207,6 +207,9 @@ private:
std::list<uint32_t> m_tagIds;
QList<QLabel*> tagLabels;
// needed to send system flags with reply
//unsigned systemFlags;
RSTreeWidgetItemCompareRole *m_compareRole;
QCompleter *m_completer;

View File

@ -503,17 +503,23 @@ void MessageWidget::fill(const std::string &msgId)
ui.dateText->setText(timestamp);
}
std::string ownId = rsPeers->getOwnId();
std::string srcId;
if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) {
// outgoing message are from me
srcId = rsPeers->getOwnId();
srcId = ownId;
} else {
srcId = msgInfo.srcId;
}
link.createMessage(srcId, "");
if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.srcId == ownId) {
ui.fromText->setText("RetroShare");
} else {
ui.fromText->setText(link.toHtml());
ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId));
}
ui.subjectText->setText(QString::fromStdWString(msgInfo.title));

View File

@ -166,7 +166,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>80</x>
<y>30</y>
<width>201</width>
<width>211</width>
<height>20</height>
</rect>
</property>