Added new RetroShare link format to write a message

retroshare://message?id=...[&subject=...]
Added clickable links in ForumMsgItem for the signer of the message to start the MessageComposer.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4190 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-05-07 23:14:09 +00:00
parent e34505c1d2
commit 70c3c9678d
11 changed files with 447 additions and 311 deletions

View File

@ -40,6 +40,7 @@
#include "common/PeerDefs.h"
#include "common/RSItemDelegate.h"
#include "common/Emoticons.h"
#include "RetroShareLink.h"
#include <retroshare/rsinit.h>
#include <retroshare/rspeers.h>
@ -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<std::string>::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 += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
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 += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
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 += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
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 += "<a style='color: black;'href='" + rsid + "'> " + name + "</a>" + " ";
link.createMessage(srcId, "");
ui.fromText->setText("<a style='color: blue;' href='" + rsid + "'> " + name +"</a>");
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);

View File

@ -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);

View File

@ -1591,6 +1591,9 @@ p, li { white-space: pre-wrap; }
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
@ -1654,6 +1657,9 @@ p, li { white-space: pre-wrap; }
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
@ -1734,6 +1740,9 @@ p, li { white-space: pre-wrap; }
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
@ -1741,6 +1750,9 @@ p, li { white-space: pre-wrap; }
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">

View File

@ -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<std::string> 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<std::string> srcIds;
FileInfo finfo ;
rsFiles->FileDetails(hash().toStdString(), RS_FILE_HINTS_REMOTE,finfo) ;
for(std::list<TransferInfo>::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it)
{
for(std::list<TransferInfo>::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<ForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
if (!forumsDialog) {
return false;
}
MainWindow::showWindow(MainWindow::Forums);
ForumsDialog *forumsDialog = dynamic_cast<ForumsDialog*>(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<ChannelFeed*>(MainWindow::getPage(MainWindow::Channels));
if (!channelFeed) {
return false;
}
MainWindow::showWindow(MainWindow::Channels);
ChannelFeed *channelFeed = dynamic_cast<ChannelFeed*>(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<SearchDialog*>(MainWindow::getPage(MainWindow::Search));
if (!searchDialog) {
return false;
}
MainWindow::showWindow(MainWindow::Search);
SearchDialog *searchDialog = dynamic_cast<SearchDialog*>(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<RetroShareLink>& links)

View File

@ -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.

View File

@ -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());
}
}

View File

@ -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
{

View File

@ -358,6 +358,9 @@ border-radius: 10px}</string>
<property name="text">
<string notr="true">Friend Name</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" rowspan="2">
@ -522,6 +525,9 @@ border-radius: 10px}</string>
<property name="text">
<string notr="true">Next Name</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">

View File

@ -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<std::string> 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<std::string>::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()

View File

@ -3562,8 +3562,8 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+57"/>
<location line="+179"/>
<location line="+164"/>
<location line="+182"/>
<location line="+167"/>
<source>Subject: </source>
<translation>Betreff:</translation>
</message>
@ -3572,7 +3572,7 @@ p, li { white-space: pre-wrap; }
<translation type="obsolete">Gehe zum Forumbeitrag</translation>
</message>
<message>
<location line="-281"/>
<location line="-287"/>
<source>Unsubscribe To Forum</source>
<translation>Forum abbestellen</translation>
</message>
@ -3582,7 +3582,7 @@ p, li { white-space: pre-wrap; }
<translation>Antwort</translation>
</message>
<message>
<location line="+337"/>
<location line="+343"/>
<source>Send</source>
<translation>Senden</translation>
</message>
@ -3602,19 +3602,19 @@ p, li { white-space: pre-wrap; }
<translation>Unbekannter Forumbeitrag</translation>
</message>
<message>
<location line="+35"/>
<location line="+23"/>
<location line="+29"/>
<location line="+37"/>
<location line="+25"/>
<location line="+31"/>
<source>Anonymous</source>
<translation>Anonym</translation>
</message>
<message>
<location line="-18"/>
<location line="-20"/>
<source>In Reply to</source>
<translation>Als Antwort auf</translation>
</message>
<message>
<location line="+166"/>
<location line="+168"/>
<source>Please give a Text Message</source>
<translation>Bitte Nachricht eingeben</translation>
</message>
@ -5881,12 +5881,12 @@ Bitte gib etwas Speicher frei und drücke OK.</translation>
</message>
<message>
<location line="+213"/>
<location line="+1584"/>
<location line="+1605"/>
<source>Save Message</source>
<translation>Nachricht speichern</translation>
</message>
<message>
<location line="-1583"/>
<location line="-1604"/>
<source>Message has not been Sent.
Do you want to save message to draft box?</source>
<translation>Nachricht wurde noch nicht gesendet.
@ -5935,7 +5935,7 @@ Möchtest Du die Nachricht in den Entwürfen speichern?</translation>
<translation>Unbekannter Freund</translation>
</message>
<message>
<location line="+165"/>
<location line="+186"/>
<source>&amp;File</source>
<translation>&amp;Datei</translation>
</message>
@ -6104,7 +6104,7 @@ Willst Du die Nachricht speichern ?</translation>
<translation>Datei nicht gefunden oder Dateiname nicht akzeptiert.</translation>
</message>
<message>
<location line="-2022"/>
<location line="-2043"/>
<source>Friend Recommendation(s)</source>
<translation>Freundempfehlung(en)</translation>
</message>
@ -6189,7 +6189,7 @@ Willst Du die Nachricht speichern ?</translation>
<name>MessagesDialog</name>
<message>
<location filename="../gui/MessagesDialog.ui" line="+576"/>
<location filename="../gui/MessagesDialog.cpp" line="+687"/>
<location filename="../gui/MessagesDialog.cpp" line="+684"/>
<source>New Message</source>
<translation>Neue Nachricht</translation>
</message>
@ -6217,12 +6217,12 @@ Willst Du die Nachricht speichern ?</translation>
<translation>Von</translation>
</message>
<message>
<location line="+837"/>
<location line="+849"/>
<source>Size</source>
<translation>Grösse</translation>
</message>
<message>
<location line="-440"/>
<location line="-452"/>
<source>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Arial&apos;; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;&quot;&gt;
@ -6297,15 +6297,15 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+180"/>
<location filename="../gui/MessagesDialog.cpp" line="-44"/>
<location line="+984"/>
<location line="+986"/>
<location line="+10"/>
<source>Inbox</source>
<translation>Posteingang</translation>
</message>
<message>
<location line="+9"/>
<location filename="../gui/MessagesDialog.cpp" line="-989"/>
<location line="+1002"/>
<location filename="../gui/MessagesDialog.cpp" line="-991"/>
<location line="+1004"/>
<location line="+8"/>
<source>Outbox</source>
<translation>Postausgang</translation>
@ -6317,12 +6317,12 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+9"/>
<location filename="../gui/MessagesDialog.cpp" line="-1000"/>
<location filename="../gui/MessagesDialog.cpp" line="-1002"/>
<source>Sent</source>
<translation>Gesendet</translation>
</message>
<message>
<location line="+526"/>
<location line="+532"/>
<source>Cc:</source>
<translation>Cc:</translation>
</message>
@ -6332,7 +6332,7 @@ p, li { white-space: pre-wrap; }
<translation>Bcc:</translation>
</message>
<message>
<location line="+37"/>
<location line="+43"/>
<source>Tags:</source>
<translation>Schlagwörter:</translation>
</message>
@ -6379,13 +6379,13 @@ p, li { white-space: pre-wrap; }
<translation>Speichern unter...</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="+756"/>
<location filename="../gui/MessagesDialog.cpp" line="+758"/>
<source>Print Document</source>
<translation>Dokument drucken</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.ui" line="-898"/>
<location filename="../gui/MessagesDialog.cpp" line="-1583"/>
<location filename="../gui/MessagesDialog.ui" line="-910"/>
<location filename="../gui/MessagesDialog.cpp" line="-1585"/>
<source>Subject</source>
<translation>Betreff</translation>
</message>
@ -6400,12 +6400,12 @@ p, li { white-space: pre-wrap; }
<translation>Von:</translation>
</message>
<message>
<location line="+65"/>
<location line="+68"/>
<source>To:</source>
<translation>An:</translation>
</message>
<message>
<location line="+172"/>
<location line="+181"/>
<source>File Name</source>
<translation>Dateiname</translation>
</message>
@ -6415,7 +6415,7 @@ p, li { white-space: pre-wrap; }
<translation>Prüfsumme</translation>
</message>
<message>
<location line="-987"/>
<location line="-999"/>
<source>Print</source>
<translation>Drucken</translation>
</message>
@ -6450,7 +6450,7 @@ p, li { white-space: pre-wrap; }
<translation>Empfohlene Dateien einblenden</translation>
</message>
<message>
<location line="+892"/>
<location line="+894"/>
<source>File</source>
<translation>Datei</translation>
</message>
@ -6470,7 +6470,7 @@ p, li { white-space: pre-wrap; }
<translation>HTML-Dateien (*.htm *.html);;Alle Dateien (*)</translation>
</message>
<message>
<location line="-1560"/>
<location line="-1562"/>
<location line="+294"/>
<source>Reply to All</source>
<translation>Allen antworten</translation>
@ -6510,7 +6510,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+177"/>
<location filename="../gui/MessagesDialog.cpp" line="+628"/>
<location line="+1026"/>
<location line="+1028"/>
<location line="+5"/>
<source>Trash</source>
<translation>Papierkorb</translation>
@ -6526,7 +6526,7 @@ p, li { white-space: pre-wrap; }
<translation>Ordner</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="-1648"/>
<location filename="../gui/MessagesDialog.cpp" line="-1650"/>
<source>Remove All Tags</source>
<translation>Alle Schlagwörter entfernen</translation>
</message>
@ -6557,13 +6557,13 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+358"/>
<location line="+1017"/>
<location line="+1019"/>
<location line="+8"/>
<source>Drafts</source>
<translation>Entwürfe</translation>
</message>
<message>
<location line="-989"/>
<location line="-991"/>
<source>To</source>
<translation>An</translation>
</message>
@ -6573,7 +6573,7 @@ p, li { white-space: pre-wrap; }
<translation>Editieren...</translation>
</message>
<message>
<location line="+1404"/>
<location line="+1406"/>
<location line="+4"/>
<location line="+4"/>
<location line="+4"/>
@ -8958,7 +8958,7 @@ Lockdatei:
<translation>Vielleicht ist das Passwort falsch</translation>
</message>
<message>
<location filename="../gui/RetroShareLink.cpp" line="+578"/>
<location filename="../gui/RetroShareLink.cpp" line="+626"/>
<source>File Request Confirmation</source>
<translation>Bestätigung der Dateianforderung</translation>
</message>
@ -8968,7 +8968,7 @@ Lockdatei:
<translation>Die Datei wurde zur Downloadliste hinzugefügt.</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="-1144"/>
<location filename="../gui/MessagesDialog.cpp" line="-1146"/>
<location filename="../gui/RetroShareLink.cpp" line="+8"/>
<source>File Request canceled</source>
<translation>Dateianforderung abgebrochen</translation>
@ -9038,12 +9038,17 @@ Lockdatei:
<source>The channel message in channel &quot;%1&quot; could not be found.</source>
<translation>Der Kanalbeitrag im Kanal &quot;%1&quot; konnte nicht gefunden werden.</translation>
</message>
<message>
<location line="+58"/>
<source>The receipient of the message is unknown.</source>
<translation>Der Empfänger der Nachricht ist unbekannt.</translation>
</message>
<message>
<source>The forum message could not be found.</source>
<translation type="obsolete">Der Forumbeitrag &quot;%1&quot; konnte nicht gefunden werden.</translation>
</message>
<message>
<location line="-11"/>
<location line="-69"/>
<location line="+11"/>
<source>Channel Request canceled</source>
<translation>Kanalanfrage abgebrochen</translation>
@ -9054,7 +9059,22 @@ Lockdatei:
<translation>Der Kanal &quot;%1&quot; konnte nicht gefunden werden.</translation>
</message>
<message>
<location line="+48"/>
<location line="+62"/>
<source>Cannot send a message to a not accepted receipient &quot;%1&quot;.</source>
<translation>Nachricht kann nicht an den nicht akzeptierten Empfänger &quot;%1&quot; senden.</translation>
</message>
<message>
<location line="+0"/>
<location line="+7"/>
<source>Message Request canceled</source>
<translation>Nachrichtenanfrage abgebrochen</translation>
</message>
<message>
<source>The receipient of the message &quot;%1&quot; is unknown.</source>
<translation type="obsolete">Der Empfänger der Nachricht &quot;%1&quot; ist unbekannt.</translation>
</message>
<message>
<location line="+13"/>
<source>File Request Error</source>
<translation>Fehler bei der Dateianforderung</translation>
</message>
@ -9671,12 +9691,12 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+319"/>
<location filename="../gui/SearchDialog.cpp" line="+281"/>
<location filename="../gui/SearchDialog.cpp" line="+287"/>
<source>Download</source>
<translation>Herunterladen</translation>
</message>
<message>
<location filename="../gui/SearchDialog.cpp" line="-178"/>
<location filename="../gui/SearchDialog.cpp" line="-183"/>
<source>Enter a keyword here (at least 3 char long)</source>
<translation>Gib einen Suchbegriff ein (min. 3 Zeichen)</translation>
</message>
@ -9697,7 +9717,7 @@ p, li { white-space: pre-wrap; }
<translation type="obsolete">Freunden empfehlen</translation>
</message>
<message>
<location line="+180"/>
<location line="+185"/>
<location line="+139"/>
<source>Copy RetroShare Link</source>
<translation>Kopiere RetroShare Link</translation>