mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-30 17:59:02 -04:00
first version of distant messages. Still needs some debugging
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-GenericTunneling@6344 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6a88d7382a
commit
ca279ec0c2
13 changed files with 442 additions and 24 deletions
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2008 Robert Fernie
|
||||
* Copyright (C) 2013 Cyril Soler
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "CreateMsgLinkDialog.h"
|
||||
#include <gui/common/FriendSelectionWidget.h>
|
||||
#include <gui/RetroShareLink.h>
|
||||
|
@ -119,6 +120,28 @@ void CreateMsgLinkDialog::update()
|
|||
|
||||
_existing_links_LW->insertItem(0,item) ;
|
||||
}
|
||||
|
||||
std::vector<DistantOfflineMessengingInvite> invites2 ;
|
||||
|
||||
rsMsgs->getDistantOfflineMessengingInvites(invites2) ;
|
||||
|
||||
for(uint32_t i=0;i<invites2.size();++i)
|
||||
{
|
||||
RetroShareLink link ;
|
||||
|
||||
if(!link.createPublicMsgInvite(invites2[i].time_of_validity,QString::fromStdString(invites2[i].issuer_pgp_id),QString::fromStdString(invites2[i].hash)))
|
||||
std::cerr << "Cannot create link." << std::endl;
|
||||
else
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setData(Qt::DisplayRole,tr("Private chat invite to ")+QString::fromStdString(invites2[i].issuer_pgp_id)) ;
|
||||
item->setData(Qt::UserRole,link.toString()) ;
|
||||
|
||||
_existing_links_LW->insertItem(0,item) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
time_t CreateMsgLinkDialog::computeValidityDuration() const
|
||||
|
@ -174,9 +197,31 @@ void CreateMsgLinkDialog::createLink()
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Private msg links not yet implemented." << std::endl;
|
||||
time_t validity_duration = computeValidityDuration() ;
|
||||
std::string hash;
|
||||
std::string issuer_pgp_id = rsPeers->getGPGOwnId() ;
|
||||
|
||||
bool res = rsMsgs->createDistantOfflineMessengingInvite(validity_duration,hash) ;
|
||||
|
||||
RetroShareLink link ;
|
||||
|
||||
if(!link.createPublicMsgInvite(validity_duration + time(NULL),QString::fromStdString(issuer_pgp_id),QString::fromStdString(hash)) )
|
||||
{
|
||||
std::cerr << "Cannot create link." << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
QList<RetroShareLink> links ;
|
||||
links.push_back(link) ;
|
||||
|
||||
RSLinkClipboard::copyLinks(links) ;
|
||||
|
||||
if(!res)
|
||||
QMessageBox::critical(NULL,tr("Messenging invite creation failed"),tr("The creation of the messenging invite failed")) ;
|
||||
else
|
||||
QMessageBox::information(NULL,tr("Messenging invite created"),tr("Your new messenging chat invite has been copied to clipboard. You can now paste it as a Retroshare link.")) ;
|
||||
}
|
||||
|
||||
QTimer::singleShot(500,this,SLOT(update())) ;
|
||||
QTimer::singleShot(100,this,SLOT(update())) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -348,14 +348,14 @@ bool RetroShareLink::createPrivateChatInvite(time_t time_stamp,const QString& gp
|
|||
|
||||
return valid() ;
|
||||
}
|
||||
bool RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash)
|
||||
bool RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& issuer_pgp_id,const QString& hash)
|
||||
{
|
||||
clear() ;
|
||||
|
||||
_type = TYPE_PUBLIC_MSG ;
|
||||
_time_stamp = time_stamp ;
|
||||
_hash = hash ;
|
||||
_GPGid = pgp_id ;
|
||||
_GPGid = issuer_pgp_id ;
|
||||
|
||||
check() ;
|
||||
|
||||
|
@ -844,7 +844,9 @@ QString RetroShareLink::niceName() const
|
|||
return QString("Private chat invite (Valid only for key %1)").arg(_GPGid);
|
||||
}
|
||||
if(type() == TYPE_PUBLIC_MSG) {
|
||||
return QString("Click this line to contact %1 (%2)").arg(_GPGid) ;
|
||||
RsPeerDetails detail;
|
||||
rsPeers->getPeerDetails(_GPGid.toStdString(), detail) ;
|
||||
return QString("Click this link to send a private message to %1 (%2)").arg(QString::fromStdString(detail.name)).arg(_GPGid) ;
|
||||
}
|
||||
if(type() == TYPE_CERTIFICATE) {
|
||||
if (_location.isEmpty()) {
|
||||
|
@ -1190,8 +1192,15 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
std::cerr << "Opening a public msg window " << std::endl;
|
||||
std::cerr << " time_stamp = " << link._time_stamp << std::endl;
|
||||
std::cerr << " hash = " << link._hash.toStdString() << std::endl;
|
||||
std::cerr << " PGP Id = " << link._GPGid.toStdString() << std::endl;
|
||||
std::cerr << "Feature not yet implemented !" << std::endl;
|
||||
std::cerr << " Issuer Id = " << link._GPGid.toStdString() << std::endl;
|
||||
|
||||
if(link._time_stamp < time(NULL))
|
||||
{
|
||||
QMessageBox::information(NULL,QObject::tr("Messenging link is expired"),QObject::tr("This Messenging link is expired. The destination peer will not receive it.")) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
MessageComposer::msgFriend(link._hash.toStdString(), false);
|
||||
}
|
||||
break ;
|
||||
case TYPE_PRIVATE_CHAT:
|
||||
|
|
|
@ -70,19 +70,19 @@ void PopupDistantChatDialog::checkTunnel()
|
|||
{
|
||||
case RS_DISTANT_CHAT_STATUS_UNKNOWN: std::cerr << "Unknown hash. Error!" << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRY_LED)) ;
|
||||
_status_label->setText(tr("Hash error")) ;
|
||||
_status_label->setToolTip(tr("Hash error")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_RED_LED)) ;
|
||||
_status_label->setText(tr("Tunnel is broken")) ;
|
||||
_status_label->setToolTip(tr("Tunnel is broken")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_TUNNEL_OK: std::cerr << "Tunnel is ok. " << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_YEL_LED)) ;
|
||||
_status_label->setText(tr("Tunnel established")) ;
|
||||
_status_label->setToolTip(tr("Tunnel established")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_CAN_TALK: std::cerr << "Tunnel is ok and works. You can talk!" << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRN_LED)) ;
|
||||
_status_label->setText(tr("Tunnel is working")) ;
|
||||
_status_label->setToolTip(tr("Tunnel is working")) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue