diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index b3c39066c..24f8b7a12 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -40,6 +40,7 @@ #include "common/PeerDefs.h" #include "common/RSItemDelegate.h" #include "common/Emoticons.h" +#include "RetroShareLink.h" #include #include @@ -249,10 +250,6 @@ MessagesDialog::MessagesDialog(QWidget *parent) connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged())); - connect(ui.toText, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString))); - connect(ui.ccText, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString))); - connect(ui.bccText, SIGNAL(linkActivated(QString)), this, SLOT(linkActivated(QString))); - m_eListMode = LIST_NOTHING; mCurrCertId = ""; @@ -1671,13 +1668,14 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead) /* iterate through the sources */ std::list::const_iterator pit; + RetroShareLink link; QString text; - QString name; - QString rsid; + for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) { - rsid = PeerDefs::rsidFromId(*pit, &name); - text += " " + name + "" + " "; + if (link.createMessage(*pit, "")) { + text += link.toHtml() + " "; + } } ui.toText->setText(text); @@ -1688,8 +1686,9 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead) text.clear(); for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) { - rsid = PeerDefs::rsidFromId(*pit, &name); - text += " " + name + "" + " "; + if (link.createMessage(*pit, "")) { + text += link.toHtml() + " "; + } } ui.ccText->setText(text); } else { @@ -1705,8 +1704,9 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead) text.clear(); for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++) { - rsid = PeerDefs::rsidFromId(*pit, &name); - text += " " + name + "" + " "; + if (link.createMessage(*pit, "")) { + text += link.toHtml() + " "; + } } ui.bccText->setText(text); } else { @@ -1722,18 +1722,17 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead) ui.dateText-> setText(timestamp); } - std::string sSrcId; + std::string srcId; if ((msgInfo.msgflags & RS_MSG_BOXMASK) == RS_MSG_OUTBOX) { // outgoing message are from me - sSrcId = rsPeers->getOwnId(); + srcId = rsPeers->getOwnId(); } else { - sSrcId = msgInfo.srcId; + srcId = msgInfo.srcId; } - rsid = PeerDefs::rsidFromId(sSrcId, &name); - text += " " + name + "" + " "; + link.createMessage(srcId, ""); - ui.fromText->setText(" " + name +""); - ui.fromText->setToolTip(rsid); + ui.fromText->setText(link.toHtml()); + ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId)); ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); @@ -2262,18 +2261,6 @@ void MessagesDialog::tagTriggered(QAction *pAction) // LockUpdate -> insertMessages(); } -void MessagesDialog::linkActivated(QString link) -{ - if (link.isEmpty() == false) { - std::string id = PeerDefs::idFromRsid(link, false); - - RsPeerDetails detail; - if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection) { - MessageComposer::msgFriend(detail.id, false); - } - } -} - void MessagesDialog::emptyTrash() { LockUpdate Lock (this, true); diff --git a/retroshare-gui/src/gui/MessagesDialog.h b/retroshare-gui/src/gui/MessagesDialog.h index 7fd7478d0..674f984c4 100644 --- a/retroshare-gui/src/gui/MessagesDialog.h +++ b/retroshare-gui/src/gui/MessagesDialog.h @@ -57,7 +57,6 @@ public slots: private slots: /** Create the context popup menu and it's submenus */ - void linkActivated(QString link); void messageslistWidgetCostumPopupMenu( QPoint point ); void msgfilelistWidgetCostumPopupMenu(QPoint); void folderlistWidgetCostumPopupMenu(QPoint); diff --git a/retroshare-gui/src/gui/MessagesDialog.ui b/retroshare-gui/src/gui/MessagesDialog.ui index 194e1452d..1e3bd4bd4 100644 --- a/retroshare-gui/src/gui/MessagesDialog.ui +++ b/retroshare-gui/src/gui/MessagesDialog.ui @@ -1591,6 +1591,9 @@ p, li { white-space: pre-wrap; } true + + true + @@ -1654,6 +1657,9 @@ p, li { white-space: pre-wrap; } true + + true + @@ -1734,6 +1740,9 @@ p, li { white-space: pre-wrap; } true + + true + @@ -1741,6 +1750,9 @@ p, li { white-space: pre-wrap; } true + + true + diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 8a2aa736a..c5a92a00d 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -33,6 +33,7 @@ #include "ForumsDialog.h" #include "ChannelFeed.h" #include "SearchDialog.h" +#include "msgs/MessageComposer.h" #include "util/misc.h" #include "common/PeerDefs.h" @@ -47,7 +48,8 @@ #define HOST_PERSON "person" #define HOST_FORUM "forum" #define HOST_CHANNEL "channel" -#define HOST_REGEXP "file|person|forum|channel|search" +#define HOST_MESSAGE "message" +#define HOST_REGEXP "file|person|forum|channel|search|message" #define FILE_NAME "name" #define FILE_SIZE "size" @@ -64,6 +66,9 @@ #define CHANNEL_ID "id" #define CHANNEL_MSGID "msgid" +#define MESSAGE_ID "id" +#define MESSAGE_SUBJECT "subject" + #define HOST_SEARCH "search" #define SEARCH_KEYWORDS "keywords" @@ -194,6 +199,13 @@ void RetroShareLink::fromUrl(const QUrl& url) return; } + if (url.host() == HOST_MESSAGE) { + _type = TYPE_MESSAGE; + std::string id = url.queryItemValue(MESSAGE_ID).toStdString(); + createMessage(id, url.queryItemValue(MESSAGE_SUBJECT)); + return; + } + // bad link #ifdef DEBUG_RSLINK @@ -280,6 +292,21 @@ bool RetroShareLink::createSearch(const QString& keywords) return valid(); } +bool RetroShareLink::createMessage(const std::string& peerId, const QString& subject) +{ + clear(); + + _hash = QString::fromStdString(peerId); + PeerDefs::rsidFromId(peerId, &_name); + _subject = subject; + + _type = TYPE_MESSAGE; + + check(); + + return valid(); +} + void RetroShareLink::clear() { _valid = false; @@ -291,71 +318,74 @@ void RetroShareLink::clear() void RetroShareLink::check() { - _valid = true; + _valid = true; - switch (_type) { - case TYPE_UNKNOWN: - _valid = false; - break; - case TYPE_FILE: - if(_size > (((uint64_t)1)<<40)) // 1TB. Who has such large files? - _valid = false; + switch (_type) { + case TYPE_UNKNOWN: + _valid = false; + break; + case TYPE_FILE: + if(_size > (((uint64_t)1)<<40)) // 1TB. Who has such large files? + _valid = false; - if(!checkName(_name)) - _valid = false; + if(!checkName(_name)) + _valid = false; - if(!checkHash(_hash)) - _valid = false; - break; - case TYPE_PERSON: - if(_size != 0) - _valid = false; + if(!checkHash(_hash)) + _valid = false; + break; + case TYPE_PERSON: + if(_size != 0) + _valid = false; - if(_name.isEmpty()) - _valid = false; + if(_name.isEmpty()) + _valid = false; - if(_hash.isEmpty()) - _valid = false; - break; - case TYPE_FORUM: - if(_size != 0) - _valid = false; + if(_hash.isEmpty()) + _valid = false; + break; + case TYPE_FORUM: + if(_size != 0) + _valid = false; - if(_name.isEmpty()) - _valid = false; + if(_name.isEmpty()) + _valid = false; - if(_hash.isEmpty()) - _valid = false; - break; - case TYPE_CHANNEL: - if(_size != 0) - _valid = false; + if(_hash.isEmpty()) + _valid = false; + break; + case TYPE_CHANNEL: + if(_size != 0) + _valid = false; - if(_name.isEmpty()) - _valid = false; + if(_name.isEmpty()) + _valid = false; - if(_hash.isEmpty()) - _valid = false; - break; - case TYPE_SEARCH: - if(_size != 0) - _valid = false; + if(_hash.isEmpty()) + _valid = false; + break; + case TYPE_SEARCH: + if(_size != 0) + _valid = false; - if(_name.isEmpty()) - _valid = false; + if(_name.isEmpty()) + _valid = false; - if(!_hash.isEmpty()) - _valid = false; - break; - } + if(!_hash.isEmpty()) + _valid = false; + break; + case TYPE_MESSAGE: + if(_size != 0) + _valid = false; - if(!_valid) // we should throw an exception instead of this crap, but drbob doesn't like exceptions. Why ??? - { - _type = TYPE_UNKNOWN; - _hash = "" ; - _name = "" ; - _size = 0 ; - } + if(_hash.isEmpty()) + _valid = false; + break; + } + + if (!_valid) { + clear(); + } } QString RetroShareLink::title() const @@ -374,6 +404,8 @@ QString RetroShareLink::title() const case TYPE_CHANNEL: case TYPE_SEARCH: break; + case TYPE_MESSAGE: + return PeerDefs::rsidFromId(hash().toStdString()); } return ""; @@ -458,6 +490,22 @@ QString RetroShareLink::toString(bool encoded /*= true*/) const return url.toEncoded(); } + return url.toString(); + } + case TYPE_MESSAGE: + { + QUrl url; + url.setScheme(RSLINK_SCHEME); + url.setHost(HOST_MESSAGE); + url.addQueryItem(MESSAGE_ID, _hash); + if (_subject.isEmpty() == false) { + url.addQueryItem(MESSAGE_SUBJECT, _subject); + } + + if (encoded) { + return url.toEncoded(); + } + return url.toString(); } } @@ -545,198 +593,232 @@ bool RetroShareLink::checkHash(const QString& hash) bool RetroShareLink::process(int flag) { - if (valid() == false) { - std::cerr << " RetroShareLink::process invalid request" << std::endl; - return false; - } + if (valid() == false) { + std::cerr << " RetroShareLink::process invalid request" << std::endl; + return false; + } - switch (type()) { - case TYPE_UNKNOWN: - break; + switch (type()) { + case TYPE_UNKNOWN: + break; - case TYPE_FILE: - { + case TYPE_FILE: + { #ifdef DEBUG_RSLINK - std::cerr << " RetroShareLink::process FileRequest : fileName : " << name().toUtf8().constData() << ". fileHash : " << hash().toStdString() << ". fileSize : " << size() << std::endl; + std::cerr << " RetroShareLink::process FileRequest : fileName : " << name().toUtf8().constData() << ". fileHash : " << hash().toStdString() << ". fileSize : " << size() << std::endl; #endif - // Get a list of available direct sources, in case the file is browsable only. - std::list srcIds; - FileInfo finfo ; - rsFiles->FileDetails(hash().toStdString(), RS_FILE_HINTS_REMOTE,finfo) ; + // Get a list of available direct sources, in case the file is browsable only. + std::list srcIds; + FileInfo finfo ; + rsFiles->FileDetails(hash().toStdString(), RS_FILE_HINTS_REMOTE,finfo) ; - for(std::list::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it) - { + for(std::list::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it) + { #ifdef DEBUG_RSLINK - std::cerr << " adding peerid " << (*it).peerId << std::endl ; + std::cerr << " adding peerid " << (*it).peerId << std::endl ; #endif - srcIds.push_back((*it).peerId) ; - } + srcIds.push_back((*it).peerId) ; + } - if (rsFiles->FileRequest(name().toUtf8().constData(), hash().toStdString(), size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) { - if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { - QMessageBox mb(QObject::tr("File Request Confirmation"), QObject::tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return true; - } + if (rsFiles->FileRequest(name().toUtf8().constData(), hash().toStdString(), size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) { + if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { + QMessageBox mb(QObject::tr("File Request Confirmation"), QObject::tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return true; + } - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("File Request canceled"), QObject::tr("The file has not been added to your download list, because you already have it."),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("File Request canceled"), QObject::tr("The file has not been added to your download list, because you already have it."),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } - case TYPE_PERSON: - { + case TYPE_PERSON: + { #ifdef DEBUG_RSLINK - std::cerr << " RetroShareLink::process FriendRequest : name : " << name().toStdString() << ". id : " << hash().toStdString() << std::endl; + std::cerr << " RetroShareLink::process FriendRequest : name : " << name().toStdString() << ". id : " << hash().toStdString() << std::endl; #endif - RsPeerDetails detail; - if (rsPeers->getPeerDetails(hash().toStdString(), detail)) { - if (detail.gpg_id == rsPeers->getGPGOwnId()) { - // it's me, do nothing - return true; - } + RsPeerDetails detail; + if (rsPeers->getPeerDetails(hash().toStdString(), detail)) { + if (detail.gpg_id == rsPeers->getGPGOwnId()) { + // it's me, do nothing + return true; + } - if (detail.accept_connection) { - // peer connection is already accepted - if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { - QMessageBox mb(QObject::tr("Friend Request Confirmation"), QObject::tr("The friend is already in your list."),QMessageBox::Information,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return true; - } + if (detail.accept_connection) { + // peer connection is already accepted + if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { + QMessageBox mb(QObject::tr("Friend Request Confirmation"), QObject::tr("The friend is already in your list."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return true; + } - if (rsPeers->setAcceptToConnectGPGCertificate(hash().toStdString(), true)) { - if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { - QMessageBox mb(QObject::tr("Friend Request Confirmation"), QObject::tr("The friend has been added to your list."),QMessageBox::Information,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return true; - } + if (rsPeers->setAcceptToConnectGPGCertificate(hash().toStdString(), true)) { + if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { + QMessageBox mb(QObject::tr("Friend Request Confirmation"), QObject::tr("The friend has been added to your list."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return true; + } - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("Friend Request canceled"), QObject::tr("The friend could not be added to your list."),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Friend Request canceled"), QObject::tr("The friend could not be added to your list."),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("Friend Request canceled"), QObject::tr("The friend could not be found."),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Friend Request canceled"), QObject::tr("The friend could not be found."),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } - case TYPE_FORUM: - { + case TYPE_FORUM: + { #ifdef DEBUG_RSLINK - std::cerr << " RetroShareLink::process ForumRequest : name : " << name().toStdString() << ". id : " << hash().toStdString() << ". msgId : " << msgId().toStdString() << std::endl; + std::cerr << " RetroShareLink::process ForumRequest : name : " << name().toStdString() << ". id : " << hash().toStdString() << ". msgId : " << msgId().toStdString() << std::endl; #endif - ForumInfo fi; - if (!rsForums->getForumInfo(id().toStdString(), fi)) { - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("Forum Request canceled"), QObject::tr("The forum \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } + ForumInfo fi; + if (!rsForums->getForumInfo(id().toStdString(), fi)) { + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Forum Request canceled"), QObject::tr("The forum \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } - ForumMsgInfo msg; - if (!msgId().isEmpty()) { - if (!rsForums->getForumMessage(fi.forumId, msgId().toStdString(), msg)) { - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("Forum Request canceled"), QObject::tr("The forum message in forum \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } - } + ForumMsgInfo msg; + if (!msgId().isEmpty()) { + if (!rsForums->getForumMessage(fi.forumId, msgId().toStdString(), msg)) { + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Forum Request canceled"), QObject::tr("The forum message in forum \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } + } - MainWindow::showWindow(MainWindow::Forums); - ForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); - if (!forumsDialog) { - return false; - } + MainWindow::showWindow(MainWindow::Forums); + ForumsDialog *forumsDialog = dynamic_cast(MainWindow::getPage(MainWindow::Forums)); + if (!forumsDialog) { + return false; + } - return forumsDialog->navigate(fi.forumId, msg.msgId); - } + return forumsDialog->navigate(fi.forumId, msg.msgId); + } - case TYPE_CHANNEL: - { + case TYPE_CHANNEL: + { #ifdef DEBUG_RSLINK - std::cerr << " RetroShareLink::process ChannelRequest : name : " << name().toStdString() << ". id : " << hash().toStdString() << ". msgId : " << msgId().toStdString() << std::endl; + std::cerr << " RetroShareLink::process ChannelRequest : name : " << name().toStdString() << ". id : " << hash().toStdString() << ". msgId : " << msgId().toStdString() << std::endl; #endif - ChannelInfo ci; - if (!rsChannels->getChannelInfo(id().toStdString(), ci)) { - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("Channel Request canceled"), QObject::tr("The channel \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } + ChannelInfo ci; + if (!rsChannels->getChannelInfo(id().toStdString(), ci)) { + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Channel Request canceled"), QObject::tr("The channel \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } - ChannelMsgInfo msg; - if (!msgId().isEmpty()) { - if (!rsChannels->getChannelMessage(ci.channelId, msgId().toStdString(), msg)) { - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("Channel Request canceled"), QObject::tr("The channel message in channel \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; - } - } + ChannelMsgInfo msg; + if (!msgId().isEmpty()) { + if (!rsChannels->getChannelMessage(ci.channelId, msgId().toStdString(), msg)) { + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Channel Request canceled"), QObject::tr("The channel message in channel \"%1\" could not be found.").arg(name()),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; + } + } - MainWindow::showWindow(MainWindow::Channels); - ChannelFeed *channelFeed = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); - if (!channelFeed) { - return false; - } + MainWindow::showWindow(MainWindow::Channels); + ChannelFeed *channelFeed = dynamic_cast(MainWindow::getPage(MainWindow::Channels)); + if (!channelFeed) { + return false; + } - return channelFeed->navigate(ci.channelId, msg.msgId); - } + return channelFeed->navigate(ci.channelId, msg.msgId); + } - case TYPE_SEARCH: - { + case TYPE_SEARCH: + { #ifdef DEBUG_RSLINK - std::cerr << " RetroShareLink::process SearchRequest : string : " << name().toStdString() << std::endl; + std::cerr << " RetroShareLink::process SearchRequest : string : " << name().toStdString() << std::endl; #endif - MainWindow::showWindow(MainWindow::Search); - SearchDialog *searchDialog = dynamic_cast(MainWindow::getPage(MainWindow::Search)); - if (!searchDialog) { - return false; - } + MainWindow::showWindow(MainWindow::Search); + SearchDialog *searchDialog = dynamic_cast(MainWindow::getPage(MainWindow::Search)); + if (!searchDialog) { + return false; + } - searchDialog->searchKeywords(name()); - return true; - } - } + searchDialog->searchKeywords(name()); + return true; + } - std::cerr << " RetroShareLink::process unknown type: " << type() << std::endl; + case TYPE_MESSAGE: + { +#ifdef DEBUG_RSLINK + std::cerr << " RetroShareLink::process MessageRequest : id : " << _hash.toStdString() << ", subject : " << name().toStdString() << std::endl; +#endif + RsPeerDetails detail; + if (rsPeers->getPeerDetails(hash().toStdString(), detail)) { + if (detail.accept_connection || detail.id == rsPeers->getOwnId()) { + MessageComposer *msg = MessageComposer::newMsg(); + msg->addRecipient(MessageComposer::TO, detail.id, false); + if (subject().isEmpty() == false) { + msg->insertTitleText(subject()); + } + msg->show(); - if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { - QMessageBox mb(QObject::tr("File Request Error"), QObject::tr("The file link is malformed."),QMessageBox::Critical,QMessageBox::Ok,0,0); - mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); - mb.exec(); - } - return false; + return true; + } else { + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Message Request canceled"), QObject::tr("Cannot send a message to a not accepted receipient \"%1\".").arg(hash()), QMessageBox::Critical, QMessageBox::Ok, 0, 0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + } + } else { + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("Message Request canceled"), QObject::tr("The receipient of the message is unknown."), QMessageBox::Critical, QMessageBox::Ok, 0, 0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + } + + return false; + } + } + + std::cerr << " RetroShareLink::process unknown type: " << type() << std::endl; + + if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { + QMessageBox mb(QObject::tr("File Request Error"), QObject::tr("The file link is malformed."),QMessageBox::Critical,QMessageBox::Ok,0,0); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + } + return false; } void RSLinkClipboard::copyLinks(const std::vector& links) diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index 4cd8e39b2..e0ad42cd3 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -47,7 +47,7 @@ class RetroShareLink { public: - enum enumType { TYPE_UNKNOWN, TYPE_FILE, TYPE_PERSON, TYPE_FORUM, TYPE_CHANNEL, TYPE_SEARCH }; + enum enumType { TYPE_UNKNOWN, TYPE_FILE, TYPE_PERSON, TYPE_FORUM, TYPE_CHANNEL, TYPE_SEARCH, TYPE_MESSAGE }; public: RetroShareLink(); @@ -59,6 +59,7 @@ class RetroShareLink bool createForum(const QString& name, const QString& id, const QString& msgId); bool createChannel(const QString& name, const QString& id, const QString& msgId); bool createSearch(const QString& keywords); + bool createMessage(const std::string& peerId, const QString& subject); enumType type() const {return _type; } uint64_t size() const { return _size ; } @@ -66,6 +67,7 @@ class RetroShareLink const QString& hash() const { return _hash ; } const QString& id() const { return _hash ; } const QString& msgId() const { return _msgId ; } + const QString& subject() const { return _subject ; } QString title() const; // get nice name for anchor @@ -103,8 +105,9 @@ class RetroShareLink enumType _type; QString _name; uint64_t _size; - QString _hash; // or id (forum, channel) + QString _hash; // or id (forum, channel, message) QString _msgId; // id of the message (forum, channel) + QString _subject; }; /// This class handles the copy/paste of links. Every member is static to ensure unicity. diff --git a/retroshare-gui/src/gui/common/PeerDefs.cpp b/retroshare-gui/src/gui/common/PeerDefs.cpp index 9f26a6ce1..b8ca4d3b9 100644 --- a/retroshare-gui/src/gui/common/PeerDefs.cpp +++ b/retroshare-gui/src/gui/common/PeerDefs.cpp @@ -26,9 +26,9 @@ const QString PeerDefs::nameWithLocation(const RsPeerDetails &details) { - QString name = QString::fromStdString(details.name); + QString name = QString::fromUtf8(details.name.c_str()); if (details.location.empty() == false) { - name += " (" + QString::fromStdString(details.location) + ")"; + name += " (" + QString::fromUtf8(details.location.c_str()) + ")"; } return name; @@ -40,7 +40,7 @@ const QString PeerDefs::rsid(const std::string &name, const std::string &id) return qApp->translate("PeerDefs", "Unknown") + "@" + QString::fromStdString(id); } - return QString::fromStdString(name) + "@" + QString::fromStdString(id); + return QString::fromUtf8(name.c_str()) + "@" + QString::fromStdString(id); } const QString PeerDefs::rsid(const RsPeerDetails &details) @@ -63,7 +63,7 @@ const QString PeerDefs::rsidFromId(const std::string &id, QString *name /*= NULL rsid = PeerDefs::rsid(peerName, id); if (name) { - *name = QString::fromStdString(peerName); + *name = QString::fromUtf8(peerName.c_str()); } } diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp index 9ca2e673f..9f2d570fa 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.cpp @@ -58,7 +58,7 @@ ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::strin connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) ); connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyToPost ( void ) ) ); connect( sendButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) ); - + connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); small(); @@ -144,7 +144,9 @@ void ForumMsgItem::updateItemStatic() if (rsPeers->getPeerName(msg.srcId) !="") { - namelabel->setText(QString::fromStdString(rsPeers->getPeerName(msg.srcId))); + RetroShareLink linkMessage; + linkMessage.createMessage(msg.srcId, ""); + namelabel->setText(linkMessage.toHtml()); } else { @@ -157,7 +159,7 @@ void ForumMsgItem::updateItemStatic() QDateTime qtime; qtime.setTime_t(msg.ts); QString timestamp = qtime.toString("dd.MM.yyyy hh:mm:ss"); - timestamplabel->setText(timestamp); + timestamplabel->setText(timestamp); nextFrame->hide(); } @@ -167,7 +169,9 @@ void ForumMsgItem::updateItemStatic() if (rsPeers->getPeerName(msg.srcId) !="") { - nextnamelabel->setText(QString::fromStdString(rsPeers->getPeerName(msg.srcId))); + RetroShareLink linkMessage; + linkMessage.createMessage(msg.srcId, ""); + nextnamelabel->setText(linkMessage.toHtml()); } else { @@ -196,7 +200,9 @@ void ForumMsgItem::updateItemStatic() if (rsPeers->getPeerName(msgParent.srcId) !="") { - namelabel->setText(QString::fromStdString(rsPeers->getPeerName(msgParent.srcId))); + RetroShareLink linkMessage; + linkMessage.createMessage(msgParent.srcId, ""); + namelabel->setText(linkMessage.toHtml()); } else { diff --git a/retroshare-gui/src/gui/feeds/ForumMsgItem.ui b/retroshare-gui/src/gui/feeds/ForumMsgItem.ui index d655fe736..16fe745ac 100644 --- a/retroshare-gui/src/gui/feeds/ForumMsgItem.ui +++ b/retroshare-gui/src/gui/feeds/ForumMsgItem.ui @@ -358,6 +358,9 @@ border-radius: 10px} Friend Name + + true + @@ -522,6 +525,9 @@ border-radius: 10px} Next Name + + true + diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index b0f8a1434..973328ea0 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1509,31 +1509,52 @@ void MessageComposer::editingRecipientFinished() void MessageComposer::addRecipient(enumType type, const std::string &id, bool group) { - // search existing or empty row - int rowCount = ui.recipientWidget->rowCount(); - int row; - for (row = 0; row < rowCount; row++) { - enumType rowType; - std::string rowId; - bool rowGroup; + std::list sslIds; + if (group) { + sslIds.push_back(id); + } else { + // check for gpg id or ssl id + RsPeerDetails detail; + if (!rsPeers->getPeerDetails(id, detail)) { + return; + } - if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true) { - if (rowId.empty()) { + if (detail.isOnlyGPGdetail) { + if (!rsPeers->getSSLChildListOfGPGId(id, sslIds)) { + return; + } + } else { + sslIds.push_back(id); + } + } + std::list::const_iterator sslIt; + for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { + // search existing or empty row + int rowCount = ui.recipientWidget->rowCount(); + int row; + for (row = 0; row < rowCount; row++) { + enumType rowType; + std::string rowId; + bool rowGroup; + + if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true) { + if (rowId.empty()) { + // use row + break; + } + + if (rowId == *sslIt && rowType == type && group == rowGroup) { + // existing row + break; + } + } else { // use row break; } - - if (rowId == id && rowType == type && group == rowGroup) { - // existing row - break; - } - } else { - // use row - break; } - } - setRecipientToRow(row, type, id, group); + setRecipientToRow(row, type, *sslIt, group); + } } void MessageComposer::setupFileActions() diff --git a/retroshare-gui/src/lang/retroshare_de.qm b/retroshare-gui/src/lang/retroshare_de.qm index 2b935250b..ee2e02eaa 100644 Binary files a/retroshare-gui/src/lang/retroshare_de.qm and b/retroshare-gui/src/lang/retroshare_de.qm differ diff --git a/retroshare-gui/src/lang/retroshare_de.ts b/retroshare-gui/src/lang/retroshare_de.ts index f4d94f9c1..aef558f58 100644 --- a/retroshare-gui/src/lang/retroshare_de.ts +++ b/retroshare-gui/src/lang/retroshare_de.ts @@ -3562,8 +3562,8 @@ p, li { white-space: pre-wrap; } - - + + Subject: Betreff: @@ -3572,7 +3572,7 @@ p, li { white-space: pre-wrap; } Gehe zum Forumbeitrag - + Unsubscribe To Forum Forum abbestellen @@ -3582,7 +3582,7 @@ p, li { white-space: pre-wrap; } Antwort - + Send Senden @@ -3602,19 +3602,19 @@ p, li { white-space: pre-wrap; } Unbekannter Forumbeitrag - - - + + + Anonymous Anonym - + In Reply to Als Antwort auf - + Please give a Text Message Bitte Nachricht eingeben @@ -5881,12 +5881,12 @@ Bitte gib etwas Speicher frei und drücke OK. - + Save Message Nachricht speichern - + Message has not been Sent. Do you want to save message to draft box? Nachricht wurde noch nicht gesendet. @@ -5935,7 +5935,7 @@ Möchtest Du die Nachricht in den Entwürfen speichern? Unbekannter Freund - + &File &Datei @@ -6104,7 +6104,7 @@ Willst Du die Nachricht speichern ? Datei nicht gefunden oder Dateiname nicht akzeptiert. - + Friend Recommendation(s) Freundempfehlung(en) @@ -6189,7 +6189,7 @@ Willst Du die Nachricht speichern ? MessagesDialog - + New Message Neue Nachricht @@ -6217,12 +6217,12 @@ Willst Du die Nachricht speichern ? Von - + Size Grösse - + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Arial'; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;"> @@ -6297,15 +6297,15 @@ p, li { white-space: pre-wrap; } - + Inbox Posteingang - - + + Outbox Postausgang @@ -6317,12 +6317,12 @@ p, li { white-space: pre-wrap; } - + Sent Gesendet - + Cc: Cc: @@ -6332,7 +6332,7 @@ p, li { white-space: pre-wrap; } Bcc: - + Tags: Schlagwörter: @@ -6379,13 +6379,13 @@ p, li { white-space: pre-wrap; } Speichern unter... - + Print Document Dokument drucken - - + + Subject Betreff @@ -6400,12 +6400,12 @@ p, li { white-space: pre-wrap; } Von: - + To: An: - + File Name Dateiname @@ -6415,7 +6415,7 @@ p, li { white-space: pre-wrap; } Prüfsumme - + Print Drucken @@ -6450,7 +6450,7 @@ p, li { white-space: pre-wrap; } Empfohlene Dateien einblenden - + File Datei @@ -6470,7 +6470,7 @@ p, li { white-space: pre-wrap; } HTML-Dateien (*.htm *.html);;Alle Dateien (*) - + Reply to All Allen antworten @@ -6510,7 +6510,7 @@ p, li { white-space: pre-wrap; } - + Trash Papierkorb @@ -6526,7 +6526,7 @@ p, li { white-space: pre-wrap; } Ordner - + Remove All Tags Alle Schlagwörter entfernen @@ -6557,13 +6557,13 @@ p, li { white-space: pre-wrap; } - + Drafts Entwürfe - + To An @@ -6573,7 +6573,7 @@ p, li { white-space: pre-wrap; } Editieren... - + @@ -8958,7 +8958,7 @@ Lockdatei: Vielleicht ist das Passwort falsch - + File Request Confirmation Bestätigung der Dateianforderung @@ -8968,7 +8968,7 @@ Lockdatei: Die Datei wurde zur Downloadliste hinzugefügt. - + File Request canceled Dateianforderung abgebrochen @@ -9038,12 +9038,17 @@ Lockdatei: The channel message in channel "%1" could not be found. Der Kanalbeitrag im Kanal "%1" konnte nicht gefunden werden. + + + The receipient of the message is unknown. + Der Empfänger der Nachricht ist unbekannt. + The forum message could not be found. Der Forumbeitrag "%1" konnte nicht gefunden werden. - + Channel Request canceled Kanalanfrage abgebrochen @@ -9054,7 +9059,22 @@ Lockdatei: Der Kanal "%1" konnte nicht gefunden werden. - + + Cannot send a message to a not accepted receipient "%1". + Nachricht kann nicht an den nicht akzeptierten Empfänger "%1" senden. + + + + + Message Request canceled + Nachrichtenanfrage abgebrochen + + + The receipient of the message "%1" is unknown. + Der Empfänger der Nachricht "%1" ist unbekannt. + + + File Request Error Fehler bei der Dateianforderung @@ -9671,12 +9691,12 @@ p, li { white-space: pre-wrap; } - + Download Herunterladen - + Enter a keyword here (at least 3 char long) Gib einen Suchbegriff ein (min. 3 Zeichen) @@ -9697,7 +9717,7 @@ p, li { white-space: pre-wrap; } Freunden empfehlen - + Copy RetroShare Link Kopiere RetroShare Link