mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-13 11:32:48 -04:00
added code to create/paste/read private chat and msg links
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6305 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9e8b9b6c05
commit
e7871b598b
7 changed files with 334 additions and 115 deletions
|
@ -19,8 +19,11 @@
|
|||
****************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include <QMessageBox>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include "CreateMsgLinkDialog.h"
|
||||
#include <gui/common/FriendSelectionWidget.h>
|
||||
#include <gui/RetroShareLink.h>
|
||||
|
||||
CreateMsgLinkDialog::CreateMsgLinkDialog(QWidget *parent)
|
||||
:QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
|
||||
|
@ -28,39 +31,104 @@ CreateMsgLinkDialog::CreateMsgLinkDialog(QWidget *parent)
|
|||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
|
||||
_info_GB->layout()->addWidget( _gpg_selection = new FriendSelectionWidget(this) ) ;
|
||||
|
||||
QObject::connect(_link_type_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(update())) ;
|
||||
QObject::connect(_create_link_PB,SIGNAL(clicked()),this,SLOT(create())) ;
|
||||
QObject::connect(_create_link_PB,SIGNAL(clicked()),this,SLOT(createLink())) ;
|
||||
QObject::connect(_create_new_PB,SIGNAL(toggled(bool)),this,SLOT(toggleCreateLink(bool))) ;
|
||||
|
||||
_gpg_selection->setModus(FriendSelectionWidget::MODUS_SINGLE) ;
|
||||
_gpg_selection->setShowType(FriendSelectionWidget::SHOW_NON_FRIEND_GPG | FriendSelectionWidget::SHOW_GPG) ;
|
||||
_gpg_selection->setHeaderText(QObject::tr("Select who can contact you:")) ;
|
||||
_gpg_selection->start() ;
|
||||
|
||||
toggleCreateLink(false) ;
|
||||
update() ;
|
||||
}
|
||||
|
||||
void CreateMsgLinkDialog::toggleCreateLink(bool b)
|
||||
{
|
||||
_new_link_F->setHidden(!b) ;
|
||||
}
|
||||
void CreateMsgLinkDialog::update()
|
||||
{
|
||||
if(_link_type_CB->currentIndex() == 0)
|
||||
{
|
||||
QString s ;
|
||||
|
||||
s += "A private chat invite allows a specific peer to contact you\nusing encrypted private chat. You need to select a destination peer from your PGP keyring\nbefore creating the link. The link contains the encryption code and your PGP signature, so that the peer can authenticate you." ;
|
||||
s += "A private chat invite allows a specific peer to contact you using encrypted private chat. You need to select a destination peer from your PGP keyring before creating the link. The link contains the encryption code and your PGP signature, so that the peer can authenticate you." ;
|
||||
|
||||
_info_LB->setText(s) ;
|
||||
_info_TB->setHtml(s) ;
|
||||
_gpg_selection->setHidden(false) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString s ;
|
||||
|
||||
s += "A private chat invite allows a specific peer to contact you\nusing encrypted private chat. You need to select a destination peer from your PGP keyring\nbefore creating the link. The link contains the encryption code and your PGP signature, so that the peer can authenticate you." ;
|
||||
s += "A public message link allows any peer in the nearby network to send a private message to you. The message is encrypted and only you can read it." ;
|
||||
|
||||
_info_LB->setText(s) ;
|
||||
_info_TB->setHtml(s) ;
|
||||
_gpg_selection->setHidden(true) ;
|
||||
}
|
||||
}
|
||||
|
||||
time_t CreateMsgLinkDialog::computeValidityDuration() const
|
||||
{
|
||||
time_t unit ;
|
||||
|
||||
switch(_validity_time_CB->currentIndex())
|
||||
{
|
||||
default:
|
||||
case 0: unit = 3600 ;
|
||||
break ;
|
||||
case 1: unit = 3600*24 ;
|
||||
break ;
|
||||
case 2: unit = 3600*24*7 ;
|
||||
break ;
|
||||
case 3: unit = 3600*24*30 ;
|
||||
break ;
|
||||
case 4: unit = 3600*24*365 ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return unit * _validity_time_SB->value() ;
|
||||
}
|
||||
|
||||
void CreateMsgLinkDialog::createLink()
|
||||
{
|
||||
std::cerr << "Creating link!" << std::endl;
|
||||
|
||||
if(_link_type_CB->currentIndex() == 0)
|
||||
{
|
||||
time_t validity_duration = computeValidityDuration() ;
|
||||
FriendSelectionWidget::IdType type ;
|
||||
std::string current_pgp_id = _gpg_selection->selectedId(type) ;
|
||||
|
||||
std::string encrypted_string ;
|
||||
|
||||
bool res = rsMsgs->createDistantChatInvite(current_pgp_id,validity_duration,encrypted_string) ;
|
||||
|
||||
RetroShareLink link ;
|
||||
|
||||
if(!link.createPrivateChatInvite(validity_duration + time(NULL),QString::fromStdString(current_pgp_id),QString::fromStdString(encrypted_string)) )
|
||||
std::cerr << "Cannot create link." << std::endl;
|
||||
|
||||
QList<RetroShareLink> links ;
|
||||
links.push_back(link) ;
|
||||
|
||||
RSLinkClipboard::copyLinks(links) ;
|
||||
|
||||
if(!res)
|
||||
QMessageBox::critical(NULL,tr("Private chat invite creation failed"),tr("The creation of the chat invite failed")) ;
|
||||
else
|
||||
QMessageBox::information(NULL,tr("Private chat invite created"),tr("Your new chat invite has been copied to clipboard. You can now paste it as a Retroshare link.")) ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Private msg links not yet implemented." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue