mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05:00
Added new notify on connect attempt by the local message system.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5124 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e8b1c08ace
commit
d28ffb9c0d
@ -93,6 +93,7 @@ const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
||||
|
||||
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
||||
|
||||
class RsFeedItem
|
||||
{
|
||||
|
@ -131,43 +131,48 @@ void p3MsgService::processMsg(RsMsgItem *mi)
|
||||
|
||||
std::string mesg;
|
||||
|
||||
RsStackMutex stack(mMsgMtx); /*** STACK LOCKED MTX ***/
|
||||
|
||||
if (mi -> PeerId() == mLinkMgr->getOwnId())
|
||||
{
|
||||
/* from the loopback device */
|
||||
mi -> msgFlags |= RS_MSG_FLAGS_OUTGOING;
|
||||
}
|
||||
else
|
||||
{
|
||||
mi -> msgFlags = RS_MSG_FLAGS_NEW;
|
||||
RsStackMutex stack(mMsgMtx); /*** STACK LOCKED MTX ***/
|
||||
|
||||
/* from a peer */
|
||||
MsgInfoSummary mis;
|
||||
initRsMIS(mi, mis);
|
||||
|
||||
// msgNotifications.push_back(mis);
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
// if (mi -> PeerId() == mLinkMgr->getOwnId())
|
||||
if (mi->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
{
|
||||
std::string title, message;
|
||||
librs::util::ConvertUtf16ToUtf8(mi->subject, title);
|
||||
librs::util::ConvertUtf16ToUtf8(mi->message, message);
|
||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), title, message);
|
||||
|
||||
std::string out;
|
||||
rs_sprintf(out, "%lu", mi->msgId);
|
||||
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
|
||||
/* 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);
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
std::string title, message;
|
||||
librs::util::ConvertUtf16ToUtf8(mi->subject, title);
|
||||
librs::util::ConvertUtf16ToUtf8(mi->message, message);
|
||||
notify->AddPopupMessage(RS_POPUP_MSG, mi->PeerId(), title, message);
|
||||
|
||||
std::string out;
|
||||
rs_sprintf(out, "%lu", mi->msgId);
|
||||
notify->AddFeedItem(RS_FEED_ITEM_MESSAGE, out, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
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! *****/
|
||||
}
|
||||
|
||||
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! *****/
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_ADD);
|
||||
|
||||
/**** STACK UNLOCKED ***/
|
||||
}
|
||||
@ -226,7 +231,10 @@ int p3MsgService::incomingMsgs()
|
||||
++i;
|
||||
|
||||
if(checkAndRebuildPartialMessage(mi)) // only returns true when a msg is complete.
|
||||
{
|
||||
mi->msgFlags = 0;
|
||||
processMsg(mi);
|
||||
}
|
||||
}
|
||||
if(changed)
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
@ -927,12 +935,18 @@ 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);
|
||||
}
|
||||
}
|
||||
@ -942,6 +956,10 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
||||
RsMsgItem *msg = initMIRsMsg(info, *pit);
|
||||
if (msg)
|
||||
{
|
||||
if (*pit == ownId) {
|
||||
processMsg(msg);
|
||||
continue;
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@ -951,16 +969,21 @@ 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, mLinkMgr->getOwnId());
|
||||
RsMsgItem *msg = initMIRsMsg(info, ownId);
|
||||
if (msg)
|
||||
{
|
||||
/* use processMsg to get the new msgId */
|
||||
// sendMessage(msg);
|
||||
msg->msgFlags |= RS_MSG_FLAGS_OUTGOING;
|
||||
processMsg(msg);
|
||||
|
||||
// return new message id
|
||||
@ -1428,14 +1451,13 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
||||
{
|
||||
mis.msgflags = 0;
|
||||
|
||||
/* translate flags, if we sent it... outgoing */
|
||||
if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING)
|
||||
|| (msg->PeerId() == mLinkMgr->getOwnId()))
|
||||
/*|| (msg->PeerId() == mLinkMgr->getOwnId())*/)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_OUTGOING;
|
||||
}
|
||||
@ -1456,7 +1478,7 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_TRASH;
|
||||
}
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER)
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_UNREAD_BY_USER;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "settings/rsharesettings.h"
|
||||
#include "chat/ChatDialog.h"
|
||||
#include "msgs/MessageComposer.h"
|
||||
|
||||
const uint32_t NEWSFEED_PEERLIST = 0x0001;
|
||||
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
|
||||
@ -108,6 +109,9 @@ void NewsFeed::updateFeed()
|
||||
break;
|
||||
|
||||
case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT:
|
||||
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) {
|
||||
MessageComposer::sendConnectAttemptMsg(fi.mId1, QString::fromUtf8(fi.mId3.c_str()));
|
||||
}
|
||||
if (flags & RS_FEED_TYPE_SECURITY)
|
||||
addFeedItemSecurityConnectAttempt(fi);
|
||||
break;
|
||||
|
@ -453,6 +453,50 @@ void MessageComposer::recommendFriend(const std::list <std::string> &sslIds, con
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessageComposer::sendConnectAttemptMsg(const std::string &gpgId, const QString &sslName)
|
||||
{
|
||||
if (gpgId.empty()) {
|
||||
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 */
|
||||
std::list<MsgInfoSummary> msgList;
|
||||
std::list<MsgInfoSummary>::const_iterator it;
|
||||
|
||||
rsMsgs->getMessageSummaries(msgList);
|
||||
for(it = msgList.begin(); it != msgList.end(); it++) {
|
||||
if (it->msgflags & RS_MSG_TRASH) {
|
||||
continue;
|
||||
}
|
||||
if ((it->msgflags & RS_MSG_BOXMASK) != RS_MSG_INBOX) {
|
||||
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();
|
||||
}
|
||||
|
||||
void MessageComposer::closeEvent (QCloseEvent * event)
|
||||
{
|
||||
bool bClose = true;
|
||||
@ -1001,9 +1045,13 @@ void MessageComposer::insertForwardPastedText(QString msg)
|
||||
ui.msgText->document()->setModified(true);
|
||||
}
|
||||
|
||||
void MessageComposer::insertMsgText(const QString &msg)
|
||||
void MessageComposer::insertMsgText(const QString &msg, bool asHtml)
|
||||
{
|
||||
ui.msgText->setText(msg);
|
||||
if (asHtml) {
|
||||
ui.msgText->setHtml(msg);
|
||||
} else {
|
||||
ui.msgText->setText(msg);
|
||||
}
|
||||
|
||||
ui.msgText->setFocus( Qt::OtherFocusReason );
|
||||
|
||||
@ -1066,6 +1114,9 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
|
||||
std::list<std::string> peers;
|
||||
rsPeers->getFriendList(peers);
|
||||
|
||||
/* add own id */
|
||||
peers.push_back(rsPeers->getOwnId());
|
||||
|
||||
int rowCount = ui.recipientWidget->rowCount();
|
||||
int row;
|
||||
|
||||
|
@ -50,6 +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 MessageComposer *newMsg(const std::string &msgId = "");
|
||||
static MessageComposer *replyMsg(const std::string &msgId, bool all);
|
||||
@ -63,7 +64,7 @@ public:
|
||||
void insertPastedText(QString msg) ;
|
||||
void insertForwardPastedText(QString msg);
|
||||
void insertHtmlText(const QString &msg);
|
||||
void insertMsgText(const QString &msg);
|
||||
void insertMsgText(const QString &msg, bool asHtml = false);
|
||||
void addRecipient(enumType type, const std::string &id, bool group);
|
||||
void Create_New_Image_Tag(const QString urlremoteorlocal);
|
||||
|
||||
|
@ -62,6 +62,7 @@ NotifyPage::save(QString &/*errmsg*/)
|
||||
uint traynotifyflags = 0;
|
||||
uint newsflags = 0;
|
||||
uint chatflags = 0;
|
||||
uint messageflags = 0;
|
||||
|
||||
if (ui.popup_Connect->isChecked())
|
||||
notifyflags |= RS_POPUP_CONNECT;
|
||||
@ -124,10 +125,14 @@ NotifyPage::save(QString &/*errmsg*/)
|
||||
if (ui.trayNotify_TransferCombined->isChecked())
|
||||
traynotifyflags |= TRAYNOTIFY_TRANSFERS_COMBINED;
|
||||
|
||||
if (ui.message_ConnectAttempt->isChecked())
|
||||
messageflags |= RS_MESSAGE_CONNECT_ATTEMPT;
|
||||
|
||||
Settings->setNotifyFlags(notifyflags);
|
||||
Settings->setTrayNotifyFlags(traynotifyflags);
|
||||
Settings->setNewsFeedFlags(newsflags);
|
||||
Settings->setChatFlags(chatflags);
|
||||
Settings->setMessageFlags(messageflags);
|
||||
|
||||
Settings->setDisplayTrayGroupChat(ui.systray_GroupChat->isChecked());
|
||||
MainWindow::installGroupChatNotifier();
|
||||
@ -155,6 +160,7 @@ void NotifyPage::load()
|
||||
uint traynotifyflags = Settings->getTrayNotifyFlags();
|
||||
uint newsflags = Settings->getNewsFeedFlags();
|
||||
uint chatflags = Settings->getChatFlags();
|
||||
uint messageflags = Settings->getMessageFlags();
|
||||
|
||||
ui.popup_Connect->setChecked(notifyflags & RS_POPUP_CONNECT);
|
||||
ui.popup_NewMsg->setChecked(notifyflags & RS_POPUP_MSG);
|
||||
@ -177,6 +183,8 @@ void NotifyPage::load()
|
||||
ui.chat_Focus->setChecked(chatflags & RS_CHAT_FOCUS);
|
||||
ui.chat_tabbedWindow->setChecked(chatflags & RS_CHAT_TABBED_WINDOW);
|
||||
|
||||
ui.message_ConnectAttempt->setChecked(messageflags & RS_MESSAGE_CONNECT_ATTEMPT);
|
||||
|
||||
ui.systray_GroupChat->setChecked(Settings->getDisplayTrayGroupChat());
|
||||
|
||||
ui.trayNotify_PrivateChat->setChecked(traynotifyflags & TRAYNOTIFY_PRIVATECHAT);
|
||||
|
@ -665,6 +665,22 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="messageGroupBox">
|
||||
<property name="title">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="message_ConnectAttempt">
|
||||
<property name="text">
|
||||
<string>Connect attempt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -315,6 +315,16 @@ void RshareSettings::setTrayNotifyFlags(uint flags)
|
||||
setValue(SETTING_TRAYNOTIFY_FLAGS, flags);
|
||||
}
|
||||
|
||||
uint RshareSettings::getMessageFlags()
|
||||
{
|
||||
return value("MessageFlags").toUInt();
|
||||
}
|
||||
|
||||
void RshareSettings::setMessageFlags(uint flags)
|
||||
{
|
||||
setValue("MessageFlags", flags);
|
||||
}
|
||||
|
||||
bool RshareSettings::getDisplayTrayGroupChat()
|
||||
{
|
||||
return value("DisplayTrayGroupChat").toBool();
|
||||
|
@ -161,6 +161,9 @@ public:
|
||||
uint getTrayNotifyFlags();
|
||||
void setTrayNotifyFlags(uint flags);
|
||||
|
||||
uint getMessageFlags();
|
||||
void setMessageFlags(uint flags);
|
||||
|
||||
bool getDisplayTrayGroupChat();
|
||||
void setDisplayTrayGroupChat(bool bValue);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user