mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 16:09:37 -05:00
Enabled distant chat system.
Added system to collect and create chat invites from pgp keys. Finished the GUI (some layouts need fixing, especially the link creation window). Still needed: QoS on generic turtle data items. Will need a new item class for any anyway. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6433 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
94b78a8444
commit
69bf523c7a
@ -156,6 +156,7 @@ public:
|
||||
#define RS_DISTANT_CHAT_ERROR_DECRYPTION_FAILED 0x0001
|
||||
#define RS_DISTANT_CHAT_ERROR_SIGNATURE_MISMATCH 0x0002
|
||||
#define RS_DISTANT_CHAT_ERROR_UNKNOWN_KEY 0x0003
|
||||
#define RS_DISTANT_CHAT_ERROR_UNKNOWN_HASH 0x0004
|
||||
|
||||
class ChatInfo
|
||||
{
|
||||
@ -328,9 +329,11 @@ virtual ChatLobbyId createChatLobby(const std::string& lobby_name,const std::str
|
||||
|
||||
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) = 0 ;
|
||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) = 0;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) = 0;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) = 0;
|
||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) = 0;
|
||||
virtual bool closeDistantChatConnexion(const std::string& hash) = 0;
|
||||
virtual bool removeDistantChatInvite(const std::string& hash) = 0 ;
|
||||
|
||||
};
|
||||
|
||||
|
@ -352,9 +352,13 @@ bool p3Msgs::getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invite
|
||||
{
|
||||
return mChatSrv->getDistantChatInviteList(invites) ;
|
||||
}
|
||||
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,std::string& hash,uint32_t& error_code)
|
||||
bool p3Msgs::initiateDistantChatConnexion(const std::string& encrypted_str,time_t validity_time,std::string& hash,uint32_t& error_code)
|
||||
{
|
||||
return mChatSrv->initiateDistantChatConnexion(encrypted_str,hash,error_code) ;
|
||||
return mChatSrv->initiateDistantChatConnexion(encrypted_str,validity_time,hash,error_code) ;
|
||||
}
|
||||
bool p3Msgs::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
|
||||
{
|
||||
return mChatSrv->initiateDistantChatConnexion(hash,error_code) ;
|
||||
}
|
||||
bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id)
|
||||
{
|
||||
@ -364,4 +368,8 @@ bool p3Msgs::closeDistantChatConnexion(const std::string& hash)
|
||||
{
|
||||
return mChatSrv->closeDistantChatConnexion(hash) ;
|
||||
}
|
||||
bool p3Msgs::removeDistantChatInvite(const std::string& hash)
|
||||
{
|
||||
return mChatSrv->removeDistantChatInvite(hash) ;
|
||||
}
|
||||
|
||||
|
@ -189,9 +189,11 @@ class p3Msgs: public RsMsgs
|
||||
|
||||
virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,std::string& encrypted_string) ;
|
||||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t validity_time,std::string& hash,uint32_t& error_code) ;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ;
|
||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
||||
virtual bool closeDistantChatConnexion(const std::string& hash) ;
|
||||
virtual bool removeDistantChatInvite(const std::string& hash) ;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
* #define CHAT_DEBUG 1
|
||||
* #define DEBUG_DISTANT_CHAT 1
|
||||
****/
|
||||
#define DEBUG_DISTANT_CHAT 1
|
||||
|
||||
static const int CONNECTION_CHALLENGE_MAX_COUNT = 20 ; // sends a connexion challenge every 20 messages
|
||||
static const time_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age of a message to be used in a connexion challenge
|
||||
@ -3233,10 +3234,8 @@ bool p3ChatService::createDistantChatInvite(const std::string& pgp_id,time_t tim
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_str,std::string& hash,uint32_t& error_code)
|
||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_str,time_t time_of_validity,std::string& hash,uint32_t& error_code)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// Un-radix the string.
|
||||
//
|
||||
char *encrypted_data_bin = NULL ;
|
||||
@ -3283,19 +3282,87 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
std::cerr << "Signature successfuly verified!" << std::endl;
|
||||
#endif
|
||||
|
||||
hash = t_RsGenericIdType<DISTANT_CHAT_HASH_SIZE>(data).toStdString(false) ;
|
||||
|
||||
startClientDistantChatConnection(hash,pgp_id.toStdString(),data+DISTANT_CHAT_HASH_SIZE) ;
|
||||
|
||||
// Finally, save the decrypted chat info, so that we can display some info in the GUI in case we want to re-use the link
|
||||
//
|
||||
DistantChatInvite dinvite ;
|
||||
|
||||
dinvite.encrypted_radix64_string = "" ; // means that it's not issued by us
|
||||
dinvite.destination_pgp_id = pgp_id.toStdString() ;
|
||||
dinvite.time_of_validity = time_of_validity ;
|
||||
dinvite.last_hit_time = time(NULL) ;
|
||||
memcpy(dinvite.aes_key,data+DISTANT_CHAT_HASH_SIZE,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
_distant_chat_invites[hash] = dinvite ;
|
||||
}
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
std::cerr << "Saving info for decrypted link, for later use:" << std::endl;
|
||||
std::cerr << " destination pgp id: " << dinvite.destination_pgp_id << std::endl;
|
||||
std::cerr << " validity : " << dinvite.time_of_validity << std::endl;
|
||||
std::cerr << " last hit time : " << dinvite.last_hit_time << std::endl;
|
||||
#endif
|
||||
|
||||
delete[] data ;
|
||||
|
||||
// And notify about chatting.
|
||||
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
getPqiNotify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
|
||||
// Save config, since a new invite was added.
|
||||
//
|
||||
IndicateConfigChanged() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3ChatService::initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code)
|
||||
{
|
||||
std::string pgp_id ;
|
||||
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_invites.end())
|
||||
{
|
||||
error_code = RS_DISTANT_CHAT_ERROR_UNKNOWN_HASH ;
|
||||
return false ;
|
||||
}
|
||||
it->second.last_hit_time = time(NULL) ;
|
||||
pgp_id = it->second.destination_pgp_id;
|
||||
|
||||
memcpy(aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
}
|
||||
|
||||
startClientDistantChatConnection(hash,pgp_id,aes_key) ;
|
||||
|
||||
getPqiNotify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3ChatService::startClientDistantChatConnection(const std::string& hash,const std::string& pgp_id,const unsigned char *aes_key_buf)
|
||||
{
|
||||
DistantChatPeerInfo info ;
|
||||
|
||||
info.last_contact = time(NULL) ;
|
||||
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN ;
|
||||
info.pgp_id = pgp_id.toStdString() ;
|
||||
info.pgp_id = pgp_id ;
|
||||
info.direction = RsTurtleGenericTunnelItem::DIRECTION_SERVER ;
|
||||
memcpy(info.aes_key,data+DISTANT_CHAT_HASH_SIZE,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
memcpy(info.aes_key,aes_key_buf,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
|
||||
_distant_chat_peers[hash] = info ;
|
||||
|
||||
delete[] data ;
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
_distant_chat_peers[hash] = info ;
|
||||
}
|
||||
|
||||
// Now ask the turtle router to manage a tunnel for that hash.
|
||||
|
||||
@ -3304,13 +3371,6 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
||||
#endif
|
||||
|
||||
mTurtle->monitorTunnels(hash,this) ;
|
||||
|
||||
// And notify about chatting.
|
||||
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
|
||||
getPqiNotify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3ChatService::cleanDistantChatInvites()
|
||||
@ -3445,7 +3505,23 @@ void p3ChatService::markDistantChatAsClosed(const std::string& hash)
|
||||
it->second.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED ;
|
||||
}
|
||||
|
||||
|
||||
bool p3ChatService::removeDistantChatInvite(const std::string& hash)
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
std::map<std::string,DistantChatInvite>::iterator it = _distant_chat_invites.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_invites.end()) // server side. Nothing to do.
|
||||
{
|
||||
std::cerr << "Cannot find distant chat invite for hash " << hash << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_distant_chat_invites.erase(it) ;
|
||||
|
||||
IndicateConfigChanged() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -312,8 +312,10 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||
//
|
||||
bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
|
||||
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,time_t time_of_validity,std::string& hash,uint32_t& error_code) ; // from encrypted data
|
||||
bool initiateDistantChatConnexion(const std::string& hash,uint32_t& error_code) ; // from known hash of a decrypted link
|
||||
bool closeDistantChatConnexion(const std::string& hash) ;
|
||||
bool removeDistantChatInvite(const std::string& hash) ;
|
||||
|
||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
||||
|
||||
@ -352,6 +354,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||
void markDistantChatAsClosed(const TurtleFileHash& hash) ;
|
||||
void startClientDistantChatConnection(const std::string& hash,const std::string& pgp_id,const unsigned char *aes_key_buf) ;
|
||||
|
||||
// Utility functions
|
||||
|
||||
|
@ -36,145 +36,23 @@ CreateMsgLinkDialog::CreateMsgLinkDialog()
|
||||
|
||||
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())) ;
|
||||
layout()->addWidget( _gpg_selection = new FriendSelectionWidget(this) ) ;
|
||||
QObject::connect(_create_link_PB,SIGNAL(clicked()),this,SLOT(createLink())) ;
|
||||
QObject::connect(_create_new_PB,SIGNAL(toggled(bool)),this,SLOT(toggleCreateLink(bool))) ;
|
||||
QObject::connect(_existing_links_LW,SIGNAL(currentRowChanged(int)),this,SLOT(updateCurrentRow(int))) ;
|
||||
QObject::connect(_copy_to_clipboard_PB,SIGNAL(clicked()),this,SLOT(copyLinkToClipboard())) ;
|
||||
|
||||
_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) ;
|
||||
layout()->update() ;
|
||||
update() ;
|
||||
updateCurrentRow(-1) ;
|
||||
}
|
||||
|
||||
void CreateMsgLinkDialog::copyLinkToClipboard()
|
||||
void CreateMsgLinkDialog::createNewChatLink()
|
||||
{
|
||||
QList<QListWidgetItem*> selected = _existing_links_LW->selectedItems() ;
|
||||
|
||||
QList<RetroShareLink> links ;
|
||||
|
||||
for(QList<QListWidgetItem*>::const_iterator it(selected.begin());it!=selected.end();++it)
|
||||
{
|
||||
QUrl text = (*it)->data(Qt::UserRole).toUrl() ;
|
||||
RetroShareLink link(text) ;
|
||||
|
||||
links.push_back(link) ;
|
||||
}
|
||||
|
||||
if(!links.empty())
|
||||
RSLinkClipboard::copyLinks(links) ;
|
||||
}
|
||||
|
||||
void CreateMsgLinkDialog::updateCurrentRow(int r)
|
||||
{
|
||||
if(r < 0)
|
||||
{
|
||||
_current_link_type_LE->setText("") ;
|
||||
_current_link_dst_LE->setText("") ;
|
||||
_current_link_date_DE->setDateTime(QDateTime::fromTime_t(0)) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
QUrl text = _existing_links_LW->item(r)->data(Qt::UserRole).toUrl() ;
|
||||
|
||||
std::cerr << "Parsing link : " << text.toString().toStdString() << std::endl;
|
||||
RetroShareLink link(text) ;
|
||||
|
||||
RsPeerDetails detail ;
|
||||
rsPeers->getPeerDetails(link.GPGId().toStdString(),detail) ;
|
||||
|
||||
if( link.type() == RetroShareLink::TYPE_PRIVATE_CHAT )
|
||||
{
|
||||
_current_link_type_LE->setText( tr("Private chat invite") ) ;
|
||||
_usable_LB->setText(tr("Usable only by :")) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
_current_link_type_LE->setText( tr("Public message invite") ) ;
|
||||
_usable_LB->setText(tr("Usable to contact :")) ;
|
||||
}
|
||||
|
||||
_current_link_dst_LE->setText(QString::fromStdString(detail.name)+" ("+link.GPGId()+")") ;
|
||||
_current_link_date_DE->setDateTime(QDateTime::fromTime_t(link.timeStamp())) ;
|
||||
}
|
||||
|
||||
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 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_TB->setHtml(s) ;
|
||||
_gpg_selection->setHidden(false) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString s ;
|
||||
|
||||
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_TB->setHtml(s) ;
|
||||
_gpg_selection->setHidden(true) ;
|
||||
}
|
||||
|
||||
std::vector<DistantChatInviteInfo> invites ;
|
||||
|
||||
rsMsgs->getDistantChatInviteList(invites) ;
|
||||
|
||||
_existing_links_LW->clear() ;
|
||||
|
||||
for(uint32_t i=0;i<invites.size();++i)
|
||||
{
|
||||
RetroShareLink link ;
|
||||
|
||||
if(!link.createPrivateChatInvite(invites[i].time_of_validity,QString::fromStdString(invites[i].destination_pgp_id),QString::fromStdString(invites[i].encrypted_radix64_string))) {
|
||||
std::cerr << "Cannot create link." << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
RsPeerDetails detail ;
|
||||
rsPeers->getPeerDetails(link.GPGId().toStdString(),detail) ;
|
||||
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setData(Qt::DisplayRole,tr("Private chat invite to ")+QString::fromStdString(detail.name)+" ("+QString::fromStdString(invites[i].destination_pgp_id)+")") ;
|
||||
item->setData(Qt::UserRole,link.toString()) ;
|
||||
|
||||
_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("Public message link")) ;
|
||||
item->setData(Qt::UserRole,link.toString()) ;
|
||||
|
||||
_existing_links_LW->insertItem(0,item) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::cerr << "In static method..." << std::endl;
|
||||
CreateMsgLinkDialog dialog ;
|
||||
dialog.exec() ;
|
||||
}
|
||||
|
||||
time_t CreateMsgLinkDialog::computeValidityDuration() const
|
||||
@ -203,8 +81,6 @@ 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) ;
|
||||
@ -226,10 +102,11 @@ void CreateMsgLinkDialog::createLink()
|
||||
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
|
||||
{
|
||||
QMessageBox::information(NULL,tr("Private chat invite created"),tr("Your new chat invite has been created. You can now copy/paste it as a Retroshare link.")) ;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
/* OLD CODE TO CREATE A MSG LINK */
|
||||
|
||||
time_t validity_duration = computeValidityDuration() ;
|
||||
std::string hash;
|
||||
std::string issuer_pgp_id = rsPeers->getGPGOwnId() ;
|
||||
@ -253,8 +130,6 @@ void CreateMsgLinkDialog::createLink()
|
||||
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(100,this,SLOT(update())) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -30,16 +30,15 @@ class CreateMsgLinkDialog : public QDialog, public Ui::CreateMsgLinkDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static void createNewChatLink() ;
|
||||
|
||||
protected:
|
||||
CreateMsgLinkDialog();
|
||||
virtual ~CreateMsgLinkDialog() {}
|
||||
|
||||
private slots:
|
||||
/* actions to take.... */
|
||||
void createLink();
|
||||
void update() ;
|
||||
void toggleCreateLink(bool) ;
|
||||
void updateCurrentRow(int) ;
|
||||
void copyLinkToClipboard() ;
|
||||
|
||||
private:
|
||||
time_t computeValidityDuration() const ;
|
||||
|
@ -7,94 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>590</width>
|
||||
<height>388</height>
|
||||
<height>179</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Create distant chat invite</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QListWidget" name="_existing_links_LW">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Valid until:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="_usable_LB">
|
||||
<property name="text">
|
||||
<string>Usable by:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QDateTimeEdit" name="_current_link_date_DE"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="_current_link_type_LE"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="_current_link_dst_LE"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QPushButton" name="_copy_to_clipboard_PB">
|
||||
<property name="text">
|
||||
<string>Copy to clipboard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_create_new_PB">
|
||||
<property name="text">
|
||||
<string>Create new</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="_new_link_F">
|
||||
<property name="frameShape">
|
||||
@ -105,113 +24,99 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Invite type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="_link_type_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Private chat</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Public message</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Validity time :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="_validity_time_SB">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="_validity_time_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>hour</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>day</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>week</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>month</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>year</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_create_link_PB">
|
||||
<property name="text">
|
||||
<string>Create!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="_info_GB">
|
||||
<property name="title">
|
||||
<string>Information</string>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="justify">To create a private chat invite for a non-friend person, select his key below and a validity time for your invite, then press &quot;Create&quot;. The invite will contain the information required to open a tunnel to chat with you. </p><p align="justify">The invite is encrypted, and does not reveal your identity. Only the selected peer can decrypt the link, and use it to contact you.</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="_info_TB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Invite type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="_link_type_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Private chat</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Validity time :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="_validity_time_SB">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="_validity_time_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>hour</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>day</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>week</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>month</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>year</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_create_link_PB">
|
||||
<property name="text">
|
||||
<string>Create!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -231,10 +231,6 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
|
||||
contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails()));
|
||||
contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
|
||||
contextMnu->addSeparator() ;
|
||||
#ifdef ENABLE_DISTANT_CHAT_AND_MSGS
|
||||
contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Create a distant chat invitation..."), this, SLOT(createChatLink()));
|
||||
contextMnu->addSeparator() ;
|
||||
#endif
|
||||
contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
@ -334,19 +330,6 @@ void NetworkDialog::makeFriend()
|
||||
ConfCertDialog::showIt(getCurrentNeighbour()->text(COLUMN_PEERID).toStdString(), ConfCertDialog::PageTrust);
|
||||
}
|
||||
|
||||
void NetworkDialog::createChatLink()
|
||||
{
|
||||
std::string pgp_id = getCurrentNeighbour()->text(COLUMN_PEERID).toStdString() ;
|
||||
|
||||
std::cerr << "Creating chat link for pgp id " << pgp_id << std::endl;
|
||||
|
||||
std::string hash,estr ;
|
||||
rsMsgs->createDistantChatInvite(pgp_id,time(NULL)+3600,estr) ;
|
||||
|
||||
std::cerr << "Created invite:" << std::endl;
|
||||
std::cerr << " estr = " << estr << std::endl;
|
||||
}
|
||||
|
||||
/** Shows Peer Information/Auth Dialog */
|
||||
void NetworkDialog::peerdetails()
|
||||
{
|
||||
|
@ -69,7 +69,6 @@ private slots:
|
||||
void removeUnusedKeys() ;
|
||||
void makeFriend() ;
|
||||
void denyFriend() ;
|
||||
void createChatLink() ;
|
||||
void deleteCert() ;
|
||||
void peerdetails();
|
||||
void copyLink();
|
||||
|
@ -1226,7 +1226,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
std::string hash ;
|
||||
uint32_t error_code ;
|
||||
|
||||
if(!rsMsgs->initiateDistantChatConnexion(link._encrypted_chat_info.toStdString(),hash,error_code))
|
||||
if(!rsMsgs->initiateDistantChatConnexion(link._encrypted_chat_info.toStdString(),link._time_stamp,hash,error_code))
|
||||
{
|
||||
QString error_msg ;
|
||||
switch(error_code)
|
||||
|
@ -217,6 +217,15 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
|
||||
return;
|
||||
}
|
||||
|
||||
std::string distant_chat_pgp_id ;
|
||||
uint32_t distant_peer_status ;
|
||||
|
||||
if(rsMsgs->getDistantChatStatus(peerId,distant_peer_status,distant_chat_pgp_id))
|
||||
{
|
||||
getChat(peerId,RS_CHAT_OPEN | RS_CHAT_FOCUS); // use own flags
|
||||
return ;
|
||||
}
|
||||
|
||||
ChatLobbyId lid;
|
||||
if (rsMsgs->isLobbyId(peerId, lid)) {
|
||||
getChat(peerId, RS_CHAT_OPEN | RS_CHAT_FOCUS);
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/CreateMsgLinkDialog.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/rsettingswin.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/im_history/ImHistoryBrowser.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
@ -549,9 +550,9 @@ void ChatWidget::contextMenu(QPoint point)
|
||||
QAction *action = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
||||
action->setDisabled(RSLinkClipboard::empty());
|
||||
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
|
||||
#ifdef ENABLE_DISTANT_CHAT_AND_MSGS
|
||||
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this, SLOT(pasteCreateMsgLink()));
|
||||
#endif
|
||||
//#ifdef ENABLE_DISTANT_CHAT_AND_MSGS
|
||||
// contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this, SLOT(pasteCreateMsgLink()));
|
||||
//#endif
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
delete(contextMnu);
|
||||
@ -559,10 +560,7 @@ void ChatWidget::contextMenu(QPoint point)
|
||||
|
||||
void ChatWidget::pasteCreateMsgLink()
|
||||
{
|
||||
CreateMsgLinkDialog dialog ;
|
||||
dialog.exec() ;
|
||||
|
||||
ui->chatTextEdit->insertHtml(RSLinkClipboard::toHtml());
|
||||
RSettingsWin::showYourself(this, RSettingsWin::Chat);
|
||||
}
|
||||
|
||||
void ChatWidget::contextMenuTextBrowser(QPoint point)
|
||||
|
@ -95,7 +95,7 @@ void PopupDistantChatDialog::updateDisplay()
|
||||
_status_label->setPixmap(QPixmap(IMAGE_YEL_LED)) ;
|
||||
_status_label->setToolTip(QObject::tr("Secured tunnel established!")) ;
|
||||
break ;
|
||||
case RS_DISTANT_CHAT_STATUS_CAN_TALK: std::cerr << "Tunnel is ok and works. You can talk!" << std::endl;
|
||||
case RS_DISTANT_CHAT_STATUS_CAN_TALK: std::cerr << "Tunnel is ok and data is transmitted." << std::endl;
|
||||
_status_label->setPixmap(QPixmap(IMAGE_GRN_LED)) ;
|
||||
_status_label->setToolTip(QObject::tr("Secured tunnel is working")) ;
|
||||
break ;
|
||||
|
@ -340,7 +340,7 @@ void FriendSelectionWidget::fillList()
|
||||
gpgItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GPG);
|
||||
|
||||
QString name = QString::fromUtf8(detail.name.c_str());
|
||||
gpgItem->setText(COLUMN_NAME, name);
|
||||
gpgItem->setText(COLUMN_NAME, name + " ("+QString::fromStdString(*gpgIt)+")");
|
||||
|
||||
sslIds.clear();
|
||||
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
|
||||
|
@ -20,11 +20,18 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QFontDialog>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <time.h>
|
||||
|
||||
#include <retroshare/rsnotify.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "ChatPage.h"
|
||||
#include <gui/RetroShareLink.h>
|
||||
#include <gui/CreateMsgLinkDialog.h>
|
||||
#include "gui/chat/ChatStyle.h"
|
||||
#include "gui/chat/ChatDialog.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "rsharesettings.h"
|
||||
|
||||
@ -32,6 +39,10 @@
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
#define VARIANT_STANDARD "Standard"
|
||||
#define IMAGE_CHAT_CREATE ":/images/add_24x24.png"
|
||||
#define IMAGE_CHAT_OPEN ":/images/typing.png"
|
||||
#define IMAGE_CHAT_DELETE ":/images/deletemail24.png"
|
||||
#define IMAGE_CHAT_COPY ":/images/copyrslink.png"
|
||||
|
||||
static QString loadStyleInfo(ChatStyle::enumStyleType type, QListWidget *listWidget, QComboBox *comboBox, QString &styleVariant)
|
||||
{
|
||||
@ -94,12 +105,147 @@ ChatPage::ChatPage(QWidget * parent, Qt::WFlags flags)
|
||||
ui.minimumContrast->hide();
|
||||
#endif
|
||||
|
||||
connect(ui._personal_invites_LW, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(personalInvites_customPopupMenu(QPoint)));
|
||||
connect(ui._collected_contacts_LW, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(collectedContacts_customPopupMenu(QPoint)));
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChatPage::collectedContacts_customPopupMenu(QPoint p)
|
||||
{
|
||||
// items: chat with this person, copy to clipboard, delete
|
||||
std::cerr << "In custom popup menu" << std::endl;
|
||||
|
||||
QListWidgetItem *item = ui._collected_contacts_LW->itemAt(p) ;
|
||||
|
||||
if(item == NULL)
|
||||
return ;
|
||||
|
||||
QList<QListWidgetItem*> selected = ui._collected_contacts_LW->selectedItems() ;
|
||||
|
||||
QMenu contextMnu( this );
|
||||
|
||||
if(selected.size() == 1)
|
||||
contextMnu.addAction( QIcon(IMAGE_CHAT_OPEN), tr("Open secured chat tunnel"), this, SLOT(collectedInvite_openDistantChat()) ) ;
|
||||
|
||||
contextMnu.addAction( QIcon(IMAGE_CHAT_DELETE), tr("Delete this invite"), this, SLOT(collectedInvite_delete()) ) ;
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ChatPage::collectedInvite_openDistantChat()
|
||||
{
|
||||
QList<QListWidgetItem*> selected = ui._collected_contacts_LW->selectedItems() ;
|
||||
|
||||
std::string hash = (*selected.begin())->data(Qt::UserRole).toString().toStdString() ;
|
||||
|
||||
std::cerr << "Openning secured chat tunnel for hash " << hash << ". Please wait..." << std::endl;
|
||||
uint32_t error_code ;
|
||||
|
||||
if(!rsMsgs->initiateDistantChatConnexion(hash,error_code))
|
||||
QMessageBox::critical(NULL,tr("Can't open distant chat"),tr("Cannot open distant chat. Error code=")+QString::number(error_code)) ;
|
||||
else
|
||||
ChatDialog::chatFriend(hash);
|
||||
}
|
||||
|
||||
void ChatPage::collectedInvite_delete()
|
||||
{
|
||||
QList<QListWidgetItem*> selected = ui._collected_contacts_LW->selectedItems() ;
|
||||
|
||||
for(QList<QListWidgetItem*>::const_iterator it(selected.begin());it!=selected.end();++it)
|
||||
{
|
||||
std::string hash = (*it)->data(Qt::UserRole).toString().toStdString() ;
|
||||
|
||||
std::cerr << "Removing chat invite for hash " << hash << std::endl;
|
||||
|
||||
if(!rsMsgs->removeDistantChatInvite(hash))
|
||||
QMessageBox::critical(NULL,tr("Can't open distant chat"),tr("Cannot remove distant chat invite.")) ;
|
||||
}
|
||||
|
||||
load() ;
|
||||
}
|
||||
|
||||
void ChatPage::personalInvites_customPopupMenu(QPoint p)
|
||||
{
|
||||
// items: create invite, copy to clipboard, delete
|
||||
std::cerr << "In custom popup menu" << std::endl;
|
||||
|
||||
QList<QListWidgetItem*> selected = ui._personal_invites_LW->selectedItems() ;
|
||||
|
||||
QMenu contextMnu( this );
|
||||
|
||||
contextMnu.addAction( QIcon(IMAGE_CHAT_CREATE), tr("Create a chat invitation"), this, SLOT(personalInvites_create()) ) ;
|
||||
|
||||
if(!selected.empty())
|
||||
{
|
||||
contextMnu.addAction( QIcon(IMAGE_CHAT_COPY), tr("Copy link to clipboard"), this, SLOT(personalInvites_copyLink()) ) ;
|
||||
contextMnu.addAction( QIcon(IMAGE_CHAT_DELETE), tr("Delete this invite"), this, SLOT(personalInvites_delete()) ) ;
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void ChatPage::personalInvites_copyLink()
|
||||
{
|
||||
QList<QListWidgetItem*> selected = ui._personal_invites_LW->selectedItems() ;
|
||||
QList<RetroShareLink> links ;
|
||||
|
||||
std::vector<DistantChatInviteInfo> invites ;
|
||||
rsMsgs->getDistantChatInviteList(invites) ;
|
||||
|
||||
for(QList<QListWidgetItem*>::const_iterator it(selected.begin());it!=selected.end();++it)
|
||||
{
|
||||
std::string hash = (*it)->data(Qt::UserRole).toString().toStdString() ;
|
||||
|
||||
bool found = false ;
|
||||
for(uint32_t i=0;i<invites.size();++i)
|
||||
if(invites[i].hash == hash)
|
||||
{
|
||||
RetroShareLink link ;
|
||||
|
||||
if(!link.createPrivateChatInvite(invites[i].time_of_validity,QString::fromStdString(invites[i].destination_pgp_id),QString::fromStdString(invites[i].encrypted_radix64_string)))
|
||||
{
|
||||
std::cerr << "Cannot create link." << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
links.push_back(link) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if(!links.empty())
|
||||
RSLinkClipboard::copyLinks(links) ;
|
||||
}
|
||||
|
||||
void ChatPage::personalInvites_delete()
|
||||
{
|
||||
QList<QListWidgetItem*> selected = ui._personal_invites_LW->selectedItems() ;
|
||||
QList<RetroShareLink> links ;
|
||||
|
||||
for(QList<QListWidgetItem*>::const_iterator it(selected.begin());it!=selected.end();++it)
|
||||
{
|
||||
std::string hash = (*it)->data(Qt::UserRole).toString().toStdString() ;
|
||||
|
||||
rsMsgs->removeDistantChatInvite(hash) ;
|
||||
}
|
||||
load() ;
|
||||
}
|
||||
|
||||
void ChatPage::personalInvites_create()
|
||||
{
|
||||
// Call the link creation box
|
||||
|
||||
CreateMsgLinkDialog::createNewChatLink() ;
|
||||
|
||||
// Now update the page
|
||||
//
|
||||
load() ;
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool
|
||||
ChatPage::save(QString &/*errmsg*/)
|
||||
@ -229,6 +375,37 @@ ChatPage::load()
|
||||
uint chatLobbyFlags = Settings->getChatLobbyFlags();
|
||||
|
||||
ui.chatLobby_Blink->setChecked(chatLobbyFlags & RS_CHATLOBBY_BLINK);
|
||||
|
||||
// load personal invites
|
||||
//
|
||||
std::vector<DistantChatInviteInfo> invites ;
|
||||
rsMsgs->getDistantChatInviteList(invites) ;
|
||||
|
||||
ui._personal_invites_LW->clear() ;
|
||||
ui._collected_contacts_LW->clear() ;
|
||||
|
||||
for(uint32_t i=0;i<invites.size();++i)
|
||||
{
|
||||
RsPeerDetails detail ;
|
||||
rsPeers->getPeerDetails(invites[i].destination_pgp_id,detail) ;
|
||||
|
||||
if(invites[i].encrypted_radix64_string.empty())
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setData(Qt::DisplayRole,tr("Private chat invite from ")+QString::fromStdString(detail.name)+" ("+QString::fromStdString(invites[i].destination_pgp_id)+", " + QString::fromStdString(detail.name) + ", valid until " + QDateTime::fromTime_t(invites[i].time_of_validity).toString() + ")") ;
|
||||
item->setData(Qt::UserRole,QString::fromStdString(invites[i].hash)) ;
|
||||
|
||||
ui._collected_contacts_LW->insertItem(0,item) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setData(Qt::DisplayRole,tr("Private chat invite to ")+QString::fromStdString(detail.name)+" ("+QString::fromStdString(invites[i].destination_pgp_id)+", " + QString::fromStdString(detail.name) + ", valid until " + QDateTime::fromTime_t(invites[i].time_of_validity).toString() + ")") ;
|
||||
item->setData(Qt::UserRole,QString::fromStdString(invites[i].hash)) ;
|
||||
|
||||
ui._personal_invites_LW->insertItem(0,item) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatPage::on_pushButtonChangeChatFont_clicked()
|
||||
|
@ -52,6 +52,16 @@ class ChatPage : public ConfigPage
|
||||
void on_privateList_currentRowChanged(int currentRow);
|
||||
void on_historyList_currentRowChanged(int currentRow);
|
||||
|
||||
void personalInvites_customPopupMenu(QPoint) ;
|
||||
void collectedContacts_customPopupMenu(QPoint) ;
|
||||
|
||||
void personalInvites_copyLink() ;
|
||||
void personalInvites_delete() ;
|
||||
void personalInvites_create() ;
|
||||
|
||||
void collectedInvite_openDistantChat() ;
|
||||
void collectedInvite_delete() ;
|
||||
|
||||
private:
|
||||
void setPreviewMessages(QString &stylePath, QString styleVariant, QTextBrowser *textBrowser);
|
||||
void fillPreview(QListWidget *listWidget, QComboBox *comboBox, QTextBrowser *textBrowser);
|
||||
|
@ -6,15 +6,15 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>444</width>
|
||||
<height>390</height>
|
||||
<width>646</width>
|
||||
<height>544</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="general">
|
||||
<attribute name="title">
|
||||
@ -317,6 +317,67 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Distant chat</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="justify">Retroshare allows you to anonymously chat to nearby people beyond your friends in the network, using encrypted tunnels. In your personal invites list you keep chat links for people to contact you. In the &quot;collected contacts&quot; list, you keep such chat links that people sent you to contact them.</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Your personnal invites</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="_personal_invites_LW">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Collected contacts</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QListWidget" name="_collected_contacts_LW">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="history">
|
||||
<attribute name="title">
|
||||
<string>History</string>
|
||||
|
Loading…
Reference in New Issue
Block a user