mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-20 23:10:39 -04: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
9 changed files with 154 additions and 38 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue