added RSLink for GXS identities

This commit is contained in:
csoler 2017-04-08 21:12:48 +02:00
parent 4f5da86aca
commit 6d290389f0
4 changed files with 259 additions and 164 deletions

View File

@ -2362,6 +2362,9 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
} }
} }
if(n_selected_items==1)
QAction *action = contextMenu->addAction(QIcon(":/images/chat_24.png"),tr("Copy retroshare link"),this,SLOT(copyRetroshareLink())) ;
// always allow to send messages // always allow to send messages
contextMenu->addAction(QIcon(":/images/mail_new.png"), tr("Send message"), this, SLOT(sendMsg())); contextMenu->addAction(QIcon(":/images/mail_new.png"), tr("Send message"), this, SLOT(sendMsg()));
@ -2401,6 +2404,40 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
delete contextMenu; delete contextMenu;
} }
void IdDialog::copyRetroshareLink()
{
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
if (!item)
{
std::cerr << "IdDialog::editIdentity() Invalid item";
std::cerr << std::endl;
return;
}
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
RsIdentityDetails details ;
if(! rsIdentity->getIdDetails(RsGxsId(keyId),details))
return ;
std::string radix ;
if(!rsIdentity->serialiseIdentityToMemory(details.mId,radix))
{
std::cerr << "(EE) Cannot get radix data for key " << keyId << std::endl;
return;
}
QList<RetroShareLink> urls ;
RetroShareLink link ;
link.createIdentity(RsGxsId(keyId),QString::fromUtf8(details.mNickname.c_str()),QString::fromStdString(radix)) ;
RSLinkClipboard::copyLinks(urls) ;
QMessageBox::information(NULL,tr("information"),tr("This identity link was copied to your clipboard. Paste it in a mail, or a message to transmit the identity to someone.")) ;
}
void IdDialog::chatIdentity() void IdDialog::chatIdentity()
{ {
QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); QTreeWidgetItem *item = ui->idTreeWidget->currentItem();

View File

@ -93,6 +93,7 @@ private slots:
void editIdentity(); void editIdentity();
void chatIdentity(); void chatIdentity();
void sendMsg(); void sendMsg();
void copyRetroshareLink();
void on_closeInfoFrameButton_clicked(); void on_closeInfoFrameButton_clicked();
void updateSelection(); void updateSelection();

View File

@ -67,7 +67,8 @@
#define HOST_SEARCH "search" #define HOST_SEARCH "search"
#define HOST_CERTIFICATE "certificate" #define HOST_CERTIFICATE "certificate"
#define HOST_PUBLIC_MSG "public_msg" #define HOST_PUBLIC_MSG "public_msg"
#define HOST_REGEXP "file|extra|person|forum|channel|posted|search|message|certificate|private_chat|public_msg" #define HOST_IDENTITY "identity"
#define HOST_REGEXP "file|extra|person|forum|channel|posted|search|message|certificate|private_chat|public_msg|identity"
#define FILE_NAME "name" #define FILE_NAME "name"
#define FILE_SIZE "size" #define FILE_SIZE "size"
@ -89,6 +90,9 @@
#define POSTED_ID "id" #define POSTED_ID "id"
#define POSTED_MSGID "msgid" #define POSTED_MSGID "msgid"
#define IDENTITY_NAME "name"
#define IDENTITY_ID "gxsid"
#define IDENTITY_GROUP "groupdata"
#define MESSAGE_ID "id" #define MESSAGE_ID "id"
#define MESSAGE_SUBJECT "subject" #define MESSAGE_SUBJECT "subject"
@ -333,6 +337,21 @@ RetroShareLink::RetroShareLink()
clear(); clear();
} }
bool RetroShareLink::createIdentity(const RsGxsId& id, const QString& name, const QString& radix_data)
{
clear();
_name = name;
_hash = QString::fromStdString(id.toStdString());
_radix_group_data = radix_data ;
_type = TYPE_IDENTITY;
check();
return valid();
}
bool RetroShareLink::createExtraFile(const QString& name, uint64_t size, const QString& hash,const QString& ssl_id) bool RetroShareLink::createExtraFile(const QString& name, uint64_t size, const QString& hash,const QString& ssl_id)
{ {
clear(); clear();
@ -534,6 +553,7 @@ void RetroShareLink::clear()
_GPGid = "" ; _GPGid = "" ;
_time_stamp = 0 ; _time_stamp = 0 ;
_encrypted_chat_info = "" ; _encrypted_chat_info = "" ;
_radix_group_data = "" ;
} }
void RetroShareLink::check() void RetroShareLink::check()
@ -565,6 +585,17 @@ void RetroShareLink::check()
if(!checkPGPId(_GPGid)) _valid = false ; if(!checkPGPId(_GPGid)) _valid = false ;
break ; break ;
case TYPE_IDENTITY:
if(_name.isNull())
_valid = false ;
if(_radix_group_data.isNull())
_valid = false ;
if(_hash.isNull())
_valid = false ;
break ;
case TYPE_PERSON: case TYPE_PERSON:
if(_size != 0) if(_size != 0)
_valid = false; _valid = false;
@ -651,6 +682,9 @@ QString RetroShareLink::title() const
return QObject::tr("%1 (%2, Extra - Source included)").arg(hash()).arg(misc::friendlyUnit(size())); return QObject::tr("%1 (%2, Extra - Source included)").arg(hash()).arg(misc::friendlyUnit(size()));
case TYPE_FILE: case TYPE_FILE:
return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size())); return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size()));
case TYPE_IDENTITY:
return _name ;
case TYPE_PERSON: case TYPE_PERSON:
return PeerDefs::rsidFromId(RsPgpId(hash().toStdString())); return PeerDefs::rsidFromId(RsPgpId(hash().toStdString()));
case TYPE_FORUM: case TYPE_FORUM:
@ -711,6 +745,14 @@ QString RetroShareLink::toString() const
break; break;
case TYPE_IDENTITY:
url.setScheme(RSLINK_SCHEME) ;
url.setHost(HOST_IDENTITY) ;
urlQuery.addQueryItem(IDENTITY_ID,_hash) ;
urlQuery.addQueryItem(IDENTITY_NAME,encodeItem(_name)) ;
urlQuery.addQueryItem(IDENTITY_GROUP,_radix_group_data) ;
break ;
case TYPE_EXTRAFILE: case TYPE_EXTRAFILE:
url.setScheme(RSLINK_SCHEME); url.setScheme(RSLINK_SCHEME);
url.setHost(HOST_EXTRAFILE); url.setHost(HOST_EXTRAFILE);
@ -798,9 +840,11 @@ QString RetroShareLink::toString() const
QString RetroShareLink::niceName() const QString RetroShareLink::niceName() const
{ {
if (type() == TYPE_PERSON) { if (type() == TYPE_PERSON)
return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString())); return PeerDefs::rsid(name().toUtf8().constData(), RsPgpId(hash().toStdString()));
}
if(type() == TYPE_IDENTITY)
return QObject::tr("Click this link to add this person (name=%1, ID=%2) to your People tab.").arg(_name).arg(_hash) ;
if(type() == TYPE_PUBLIC_MSG) { if(type() == TYPE_PUBLIC_MSG) {
RsPeerDetails detail; RsPeerDetails detail;
@ -1156,6 +1200,15 @@ static void processList(const QStringList &list, const QString &textSingular, co
} }
break ; break ;
case TYPE_IDENTITY:
{
if(rsIdentity->deserialiseIdentityFromMemory(link.radixGroupData().toStdString()))
QMessageBox::information(NULL,QObject::tr("Identity added to People"),QObject::tr("The identity was added to people. You can now chat with it, send messages to it, etc.")) ;
else
QMessageBox::warning(NULL,QObject::tr("Identity cannot be added to People"),QObject::tr("The identity was not added to people. Some error occured. The link is probably corrupted.")) ;
}
break;
case TYPE_FILE: case TYPE_FILE:
case TYPE_EXTRAFILE: case TYPE_EXTRAFILE:
{ {

View File

@ -68,7 +68,8 @@ class RetroShareLink
TYPE_EXTRAFILE = 0x08, TYPE_EXTRAFILE = 0x08,
TYPE_PRIVATE_CHAT = 0x09, TYPE_PRIVATE_CHAT = 0x09,
TYPE_PUBLIC_MSG = 0x0a, TYPE_PUBLIC_MSG = 0x0a,
TYPE_POSTED = 0x0b TYPE_POSTED = 0x0b,
TYPE_IDENTITY = 0x0c
}; };
public: public:
@ -85,6 +86,7 @@ class RetroShareLink
bool createSearch(const QString& keywords); bool createSearch(const QString& keywords);
bool createMessage(const RsPeerId &peerId, const QString& subject); bool createMessage(const RsPeerId &peerId, const QString& subject);
bool createMessage(const RsGxsId &peerId, const QString& subject); bool createMessage(const RsGxsId &peerId, const QString& subject);
bool createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ;
bool createCertificate(const RsPeerId &ssl_id) ; bool createCertificate(const RsPeerId &ssl_id) ;
bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ; bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;
bool createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ; bool createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
@ -107,6 +109,7 @@ class RetroShareLink
const QString& radix() const { return _radix ; } const QString& radix() const { return _radix ; }
time_t timeStamp() const { return _time_stamp ; } time_t timeStamp() const { return _time_stamp ; }
QString title() const; QString title() const;
QString radixGroupData() const { return _radix_group_data ;}
unsigned int subType() const { return _subType; } unsigned int subType() const { return _subType; }
void setSubType(unsigned int subType) { _subType = subType; } void setSubType(unsigned int subType) { _subType = subType; }
@ -164,6 +167,7 @@ class RetroShareLink
QString _radix ; QString _radix ;
QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite
time_t _time_stamp ; // time stamp at which the link will expire. time_t _time_stamp ; // time stamp at which the link will expire.
QString _radix_group_data;
unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...) unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...)
}; };