mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
ported v0.5.0 commits 2561,2562 and 2574 to trunk
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2575 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
12a0f45625
commit
f8d6590952
@ -727,6 +727,7 @@ bool ftController::completeFile(std::string hash)
|
|||||||
|
|
||||||
if (fc->mCreator)
|
if (fc->mCreator)
|
||||||
{
|
{
|
||||||
|
fc->mCreator->closeFile() ;
|
||||||
delete fc->mCreator;
|
delete fc->mCreator;
|
||||||
fc->mCreator = NULL;
|
fc->mCreator = NULL;
|
||||||
}
|
}
|
||||||
@ -929,6 +930,11 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
uint64_t size, std::string dest, uint32_t flags,
|
uint64_t size, std::string dest, uint32_t flags,
|
||||||
std::list<std::string> &srcIds)
|
std::list<std::string> &srcIds)
|
||||||
{
|
{
|
||||||
|
/* check if we have the file */
|
||||||
|
|
||||||
|
if(alreadyHaveFile(hash))
|
||||||
|
return false ;
|
||||||
|
|
||||||
if(size == 0) // we treat this special case because
|
if(size == 0) // we treat this special case because
|
||||||
{
|
{
|
||||||
/* if no destpath - send to download directory */
|
/* if no destpath - send to download directory */
|
||||||
@ -967,11 +973,6 @@ bool ftController::FileRequest(std::string fname, std::string hash,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if we have the file */
|
|
||||||
|
|
||||||
if(alreadyHaveFile(hash))
|
|
||||||
return true ;
|
|
||||||
|
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
std::list<TransferInfo>::iterator pit;
|
std::list<TransferInfo>::iterator pit;
|
||||||
|
@ -88,12 +88,12 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
|
|||||||
/* dodgey checking outside of mutex... much check again inside FileAttrs(). */
|
/* dodgey checking outside of mutex... much check again inside FileAttrs(). */
|
||||||
/* Check File is open */
|
/* Check File is open */
|
||||||
|
|
||||||
if (fd == NULL)
|
|
||||||
if (!initializeFileAttrs())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
if (fd == NULL)
|
||||||
|
if (!locked_initializeFileAttrs())
|
||||||
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check its at the correct location
|
* check its at the correct location
|
||||||
*/
|
*/
|
||||||
@ -109,13 +109,13 @@ bool ftFileCreator::addFileData(uint64_t offset, uint32_t chunk_size, void *data
|
|||||||
*/
|
*/
|
||||||
if (0 != fseeko64(this->fd, offset, SEEK_SET))
|
if (0 != fseeko64(this->fd, offset, SEEK_SET))
|
||||||
{
|
{
|
||||||
std::cerr << "ftFileCreator::addFileData() Bad fseek" << std::endl;
|
std::cerr << "ftFileCreator::addFileData() Bad fseek at offset " << offset << ", fd=" << (void*)(this->fd) << ", size=" << mSize << ", errno=" << errno << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 != fwrite(data, chunk_size, 1, this->fd))
|
if (1 != fwrite(data, chunk_size, 1, this->fd))
|
||||||
{
|
{
|
||||||
std::cerr << "ftFileCreator::addFileData() Bad fwrite" << std::endl;
|
std::cerr << "ftFileCreator::addFileData() Bad fwrite." << std::endl;
|
||||||
std::cerr << "ERRNO: " << errno << std::endl;
|
std::cerr << "ERRNO: " << errno << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -186,18 +186,17 @@ void ftFileCreator::removeFileSource(const std::string& peer_id)
|
|||||||
chunkMap.removeFileSource(peer_id) ;
|
chunkMap.removeFileSource(peer_id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ftFileCreator::initializeFileAttrs()
|
int ftFileCreator::locked_initializeFileAttrs()
|
||||||
{
|
{
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
|
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if the file exists
|
* check if the file exists
|
||||||
* cant use FileProviders verion because that opens readonly.
|
* cant use FileProviders verion because that opens readonly.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
|
||||||
if (fd)
|
if (fd)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -206,9 +205,9 @@ int ftFileCreator::initializeFileAttrs()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() trying (r+b) " << file_name << " this: " << this << std::endl;
|
std::cerr << "ftFileCreator::initializeFileAttrs() trying (r+b) " << file_name << " this: " << this << std::endl;
|
||||||
#endif
|
#endif
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,21 +234,6 @@ int ftFileCreator::initializeFileAttrs()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* if it opened, find it's length
|
|
||||||
* move to the end
|
|
||||||
*/
|
|
||||||
|
|
||||||
// if (0 != fseeko64(fd, 0L, SEEK_END))
|
|
||||||
// {
|
|
||||||
// std::cerr << "ftFileCreator::initializeFileAttrs() Seek Failed" << std::endl;
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#ifdef FILE_DEBUG
|
#ifdef FILE_DEBUG
|
||||||
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,7 +98,7 @@ class ftFileCreator: public ftFileProvider
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual int initializeFileAttrs();
|
virtual int locked_initializeFileAttrs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -1346,11 +1346,13 @@ bool AuthGPG::SignDataBin(std::string input, unsigned char *sign, unsigned int *
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen) {
|
bool AuthGPG::SignDataBin(const void *data, unsigned int datalen, unsigned char *sign, unsigned int *signlen) {
|
||||||
|
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||||
return DoOwnSignature_locked(data, datalen,
|
return DoOwnSignature_locked(data, datalen,
|
||||||
sign, signlen);
|
sign, signlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, std::string withfingerprint) {
|
bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *sign, unsigned int signlen, std::string withfingerprint) {
|
||||||
|
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||||
return VerifySignature_locked(data, datalen,
|
return VerifySignature_locked(data, datalen,
|
||||||
sign, signlen, withfingerprint);
|
sign, signlen, withfingerprint);
|
||||||
}
|
}
|
||||||
@ -1360,6 +1362,7 @@ bool AuthGPG::VerifySignBin(const void *data, uint32_t datalen, unsigned char *s
|
|||||||
|
|
||||||
int AuthGPG::privateSignCertificate(std::string id)
|
int AuthGPG::privateSignCertificate(std::string id)
|
||||||
{
|
{
|
||||||
|
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||||
/* The key should be in Others list and not in Peers list ??
|
/* The key should be in Others list and not in Peers list ??
|
||||||
* Once the key is signed, it moves from Others to Peers list ???
|
* Once the key is signed, it moves from Others to Peers list ???
|
||||||
*/
|
*/
|
||||||
|
@ -142,8 +142,12 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||||||
connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
|
connect(ui.Sendbtn, SIGNAL(clicked()), this, SLOT(sendMsg()));
|
||||||
connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));
|
connect(ui.emoticonBtn, SIGNAL(clicked()), this, SLOT(smileyWidgetgroupchat()));
|
||||||
|
|
||||||
|
ui.lineEdit->setContextMenuPolicy(Qt::CustomContextMenu) ;
|
||||||
|
connect(ui.lineEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
|
||||||
|
|
||||||
|
pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this );
|
||||||
|
connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||||
|
|
||||||
//connect( ui.msgSendList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgSendListCostumPopupMenu( QPoint ) ) );
|
|
||||||
connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
|
connect( ui.msgText, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoChatMenu(const QPoint&)));
|
||||||
|
|
||||||
connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
connect(ui.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
||||||
@ -211,6 +215,23 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PeersDialog::pasteLink()
|
||||||
|
{
|
||||||
|
ui.lineEdit->insertHtml(RSLinkClipboard::toHtml()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PeersDialog::contextMenu( QPoint point )
|
||||||
|
{
|
||||||
|
if(RSLinkClipboard::empty())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
QMenu contextMnu(this);
|
||||||
|
contextMnu.addAction( pasteLinkAct);
|
||||||
|
|
||||||
|
QMouseEvent mevent(QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
|
||||||
|
contextMnu.exec( mevent.globalPos() );
|
||||||
|
}
|
||||||
|
|
||||||
void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *c = getCurrentPeer();
|
QTreeWidgetItem *c = getCurrentPeer();
|
||||||
@ -300,8 +321,6 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
|||||||
contextMnu.addAction( expandAll);
|
contextMnu.addAction( expandAll);
|
||||||
contextMnu.addAction( collapseAll);
|
contextMnu.addAction( collapseAll);
|
||||||
contextMnu.exec( mevent->globalPos() );
|
contextMnu.exec( mevent->globalPos() );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeersDialog::keyPressEvent(QKeyEvent *e)
|
void PeersDialog::keyPressEvent(QKeyEvent *e)
|
||||||
@ -1600,11 +1619,15 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
|||||||
sprintf(fileSizeChar, "%lld", file->FileSize());
|
sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||||
std::string fileSize = *(&fileSizeChar);
|
std::string fileSize = *(&fileSizeChar);
|
||||||
|
|
||||||
std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
std::string mesgString = RetroShareLink(QString::fromStdString(file->FileName()),
|
||||||
+ "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>";
|
file->FileSize(),
|
||||||
#ifdef PEERS_DEBUG
|
QString::fromStdString(file->FileHash())).toHtml().toStdString() ;
|
||||||
|
|
||||||
|
// std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
||||||
|
// + "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>";
|
||||||
|
#ifdef PEERS_DEBUG
|
||||||
std::cerr << "PeersDialog::fileHashingFinished mesgString : " << mesgString << std::endl;
|
std::cerr << "PeersDialog::fileHashingFinished mesgString : " << mesgString << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char * messageString = mesgString.c_str ();
|
const char * messageString = mesgString.c_str ();
|
||||||
|
|
||||||
|
@ -86,6 +86,8 @@ protected:
|
|||||||
virtual void dropEvent(QDropEvent *event);
|
virtual void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void pasteLink() ;
|
||||||
|
void contextMenu(QPoint) ;
|
||||||
|
|
||||||
/** Create the context popup menu and it's submenus */
|
/** Create the context popup menu and it's submenus */
|
||||||
void peertreeWidgetCostumPopupMenu( QPoint point );
|
void peertreeWidgetCostumPopupMenu( QPoint point );
|
||||||
@ -157,6 +159,7 @@ private:
|
|||||||
QMenu* contextMnu;
|
QMenu* contextMnu;
|
||||||
/** Defines the actions for the context menu */
|
/** Defines the actions for the context menu */
|
||||||
QAction* chatAct;
|
QAction* chatAct;
|
||||||
|
QAction* pasteLinkAct;
|
||||||
QAction* msgAct;
|
QAction* msgAct;
|
||||||
QAction* connectfriendAct;
|
QAction* connectfriendAct;
|
||||||
QAction* profileviewAct;
|
QAction* profileviewAct;
|
||||||
|
@ -1210,6 +1210,7 @@ void SearchDialog::copysearchLink()
|
|||||||
|
|
||||||
RetroShareLink link(fname, fsize, fhash);
|
RetroShareLink link(fname, fsize, fhash);
|
||||||
|
|
||||||
|
std::cerr << "new link added to clipboard: " << link.toString().toStdString() << std::endl ;
|
||||||
if(link.valid())
|
if(link.valid())
|
||||||
urls.push_back(link) ;
|
urls.push_back(link) ;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
|||||||
contextMnu.addAction( openfolderAct);
|
contextMnu.addAction( openfolderAct);
|
||||||
contextMnu.addAction( detailsfileAct);
|
contextMnu.addAction( detailsfileAct);
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMnu.addAction( clearcompletedAct);
|
contextMnu.addAction( clearcompletedAct);
|
||||||
@ -774,6 +773,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
std::set<int> used_rows ;
|
std::set<int> used_rows ;
|
||||||
|
|
||||||
|
if(info.downloadStatus != FT_STATE_COMPLETE)
|
||||||
for (pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
||||||
{
|
{
|
||||||
QString peerName = getPeerName(pit->peerId);
|
QString peerName = getPeerName(pit->peerId);
|
||||||
@ -794,7 +794,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
default: status = tr(""); break;
|
default: status = tr(""); break;
|
||||||
}
|
}
|
||||||
double peerDlspeed = 0;
|
double peerDlspeed = 0;
|
||||||
if ((uint32_t)pit->status == FT_STATE_DOWNLOADING && info.downloadStatus != FT_STATE_PAUSED)
|
if ((uint32_t)pit->status == FT_STATE_DOWNLOADING && info.downloadStatus != FT_STATE_PAUSED && info.downloadStatus != FT_STATE_COMPLETE)
|
||||||
peerDlspeed = pit->tfRate * 1024.0;
|
peerDlspeed = pit->tfRate * 1024.0;
|
||||||
|
|
||||||
FileProgressInfo peerpinfo ;
|
FileProgressInfo peerpinfo ;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "PopupChatDialog.h"
|
#include "PopupChatDialog.h"
|
||||||
|
#include <gui/RetroShareLink.h>
|
||||||
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
@ -53,6 +54,7 @@
|
|||||||
/*****
|
/*****
|
||||||
* #define CHAT_DEBUG 1
|
* #define CHAT_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
|
#define CHAT_DEBUG 1
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||||
@ -96,6 +98,10 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
|
|
||||||
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
||||||
|
|
||||||
|
std::cerr << "Connecting custom context menu" << std::endl;
|
||||||
|
ui.chattextEdit->setContextMenuPolicy(Qt::CustomContextMenu) ;
|
||||||
|
connect(ui.chattextEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
|
||||||
|
|
||||||
// Create the status bar
|
// Create the status bar
|
||||||
resetStatusBar() ;
|
resetStatusBar() ;
|
||||||
|
|
||||||
@ -136,10 +142,32 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
|||||||
colorChanged(mCurrentColor);
|
colorChanged(mCurrentColor);
|
||||||
setFont();
|
setFont();
|
||||||
|
|
||||||
|
pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this );
|
||||||
|
connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||||
|
|
||||||
updateAvatar() ;
|
updateAvatar() ;
|
||||||
updatePeerAvatar(id) ;
|
updatePeerAvatar(id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::pasteLink()
|
||||||
|
{
|
||||||
|
std::cerr << "In paste link" << std::endl ;
|
||||||
|
ui.chattextEdit->insertHtml(RSLinkClipboard::toHtml()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::contextMenu( QPoint point )
|
||||||
|
{
|
||||||
|
std::cerr << "In context menu" << std::endl ;
|
||||||
|
if(RSLinkClipboard::empty())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
QMenu contextMnu(this);
|
||||||
|
contextMnu.addAction( pasteLinkAct);
|
||||||
|
|
||||||
|
QMouseEvent mevent(QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier);
|
||||||
|
contextMnu.exec( mevent.globalPos() );
|
||||||
|
}
|
||||||
|
|
||||||
void PopupChatDialog::resetStatusBar()
|
void PopupChatDialog::resetStatusBar()
|
||||||
{
|
{
|
||||||
statusBar()->showMessage(tr("Chatting with ") + QString::fromStdString(dialogName)) ;
|
statusBar()->showMessage(tr("Chatting with ") + QString::fromStdString(dialogName)) ;
|
||||||
@ -732,7 +760,8 @@ void PopupChatDialog::addExtraFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::addAttachment(std::string filePath) {
|
void PopupChatDialog::addAttachment(std::string filePath)
|
||||||
|
{
|
||||||
/* add a AttachFileItem to the attachment section */
|
/* add a AttachFileItem to the attachment section */
|
||||||
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -751,7 +780,8 @@ void PopupChatDialog::addAttachment(std::string filePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::fileHashingFinished(AttachFileItem* file) {
|
void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
|
||||||
|
{
|
||||||
std::cerr << "PopupChatDialog::fileHashingFinished() started.";
|
std::cerr << "PopupChatDialog::fileHashingFinished() started.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
@ -781,7 +811,10 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file) {
|
|||||||
sprintf(fileSizeChar, "%lld", file->FileSize());
|
sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||||
std::string fileSize = *(&fileSizeChar);
|
std::string fileSize = *(&fileSizeChar);
|
||||||
|
|
||||||
std::string mesgString = "<a href='file:?fileHash=" + (file->FileHash()) + "&fileName=" + (file->FileName()) + "&fileSize=" + fileSize + "'>" + (file->FileName()) + "</a>";
|
// std::string mesgString = "<a href='file:?fileHash=" + (file->FileHash()) + "&fileName=" + (file->FileName()) + "&fileSize=" + fileSize + "'>" + (file->FileName()) + "</a>";
|
||||||
|
|
||||||
|
std::string mesgString = RetroShareLink(QString::fromStdString(file->FileName()),file->FileSize(),QString::fromStdString(file->FileHash())).toHtml().toStdString() ;
|
||||||
|
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl;
|
std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -813,24 +846,26 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file) {
|
|||||||
rsMsgs -> ChatSend(ci);
|
rsMsgs -> ChatSend(ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
void PopupChatDialog::anchorClicked (const QUrl& link )
|
||||||
|
{
|
||||||
#ifdef CHAT_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << "PopupChatDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
std::cerr << "PopupChatDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (link.scheme() == "file") {
|
|
||||||
std::string fileName = link.queryItemValue(QString("fileName")).toStdString();
|
|
||||||
std::string fileHash = link.queryItemValue(QString("fileHash")).toStdString();
|
|
||||||
uint32_t fileSize = link.queryItemValue(QString("fileSize")).toInt();
|
|
||||||
#ifdef CHAT_DEBUG
|
|
||||||
std::cerr << "PopupChatDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize;
|
|
||||||
std::cerr << ". source id : " << dialogId << std::endl;
|
|
||||||
#endif
|
|
||||||
if (fileName != "" &&
|
|
||||||
fileHash != "") {
|
|
||||||
std::list<std::string> srcIds;
|
|
||||||
srcIds.push_front(dialogId);
|
|
||||||
|
|
||||||
if(rsFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
|
|
||||||
|
if(link.scheme() == "retroshare")
|
||||||
|
{
|
||||||
|
RetroShareLink rslink(link) ;
|
||||||
|
|
||||||
|
if(!rslink.valid())
|
||||||
|
{
|
||||||
|
QMessageBox mb(tr("Badly formed RS link"), tr("This RetroShare link is malformed. This is bug. Please contact the developers."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||||
|
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||||
|
mb.exec();
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rsFiles->FileRequest(rslink.name().toStdString(), rslink.hash().toStdString(), rslink.size(), "", RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>()))
|
||||||
{
|
{
|
||||||
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||||
@ -842,14 +877,6 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
|||||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||||
mb.exec();
|
mb.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
|
||||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
|
||||||
mb.exec();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (link.scheme() == "http")
|
else if (link.scheme() == "http")
|
||||||
QDesktopServices::openUrl(link);
|
QDesktopServices::openUrl(link);
|
||||||
@ -860,7 +887,6 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
|||||||
newAddress.prepend("http://");
|
newAddress.prepend("http://");
|
||||||
QDesktopServices::openUrl(QUrl(newAddress));
|
QDesktopServices::openUrl(QUrl(newAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::dropEvent(QDropEvent *event)
|
void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||||
|
@ -72,6 +72,8 @@ public slots:
|
|||||||
|
|
||||||
void getfocus();
|
void getfocus();
|
||||||
void flash();
|
void flash();
|
||||||
|
void pasteLink() ;
|
||||||
|
void contextMenu(QPoint) ;
|
||||||
|
|
||||||
void smileyWidget();
|
void smileyWidget();
|
||||||
void addSmiley();
|
void addSmiley();
|
||||||
@ -115,6 +117,7 @@ private:
|
|||||||
QAction *actionTextBold;
|
QAction *actionTextBold;
|
||||||
QAction *actionTextUnderline;
|
QAction *actionTextUnderline;
|
||||||
QAction *actionTextItalic;
|
QAction *actionTextItalic;
|
||||||
|
QAction *pasteLinkAct ;
|
||||||
|
|
||||||
std::string dialogId, dialogName;
|
std::string dialogId, dialogName;
|
||||||
unsigned int lastChatTime;
|
unsigned int lastChatTime;
|
||||||
|
Loading…
Reference in New Issue
Block a user