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)
|
||||
{
|
||||
fc->mCreator->closeFile() ;
|
||||
delete fc->mCreator;
|
||||
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,
|
||||
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 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;
|
||||
std::list<std::string>::iterator it;
|
||||
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(). */
|
||||
/* Check File is open */
|
||||
|
||||
if (fd == NULL)
|
||||
if (!initializeFileAttrs())
|
||||
return false;
|
||||
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
|
||||
if (fd == NULL)
|
||||
if (!locked_initializeFileAttrs())
|
||||
return false;
|
||||
|
||||
/*
|
||||
* 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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return 0;
|
||||
@ -186,7 +186,7 @@ void ftFileCreator::removeFileSource(const std::string& peer_id)
|
||||
chunkMap.removeFileSource(peer_id) ;
|
||||
}
|
||||
|
||||
int ftFileCreator::initializeFileAttrs()
|
||||
int ftFileCreator::locked_initializeFileAttrs()
|
||||
{
|
||||
#ifdef FILE_DEBUG
|
||||
std::cerr << "ftFileCreator::initializeFileAttrs() Filename: " << file_name << " this: " << this << std::endl;
|
||||
@ -197,7 +197,6 @@ int ftFileCreator::initializeFileAttrs()
|
||||
* cant use FileProviders verion because that opens readonly.
|
||||
*/
|
||||
|
||||
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
|
||||
if (fd)
|
||||
return 1;
|
||||
|
||||
@ -235,21 +234,6 @@ int ftFileCreator::initializeFileAttrs()
|
||||
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
|
||||
std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl;
|
||||
#endif
|
||||
|
@ -98,7 +98,7 @@ class ftFileCreator: public ftFileProvider
|
||||
|
||||
protected:
|
||||
|
||||
virtual int initializeFileAttrs();
|
||||
virtual int locked_initializeFileAttrs();
|
||||
|
||||
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) {
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
return DoOwnSignature_locked(data, datalen,
|
||||
sign, signlen);
|
||||
}
|
||||
|
||||
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,
|
||||
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)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
/* The key should be in Others list and not in 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.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.textboldChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
||||
@ -211,6 +215,23 @@ PeersDialog::PeersDialog(QWidget *parent)
|
||||
#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 )
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentPeer();
|
||||
@ -300,8 +321,6 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
|
||||
contextMnu.addAction( expandAll);
|
||||
contextMnu.addAction( collapseAll);
|
||||
contextMnu.exec( mevent->globalPos() );
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PeersDialog::keyPressEvent(QKeyEvent *e)
|
||||
@ -1600,8 +1619,12 @@ void PeersDialog::fileHashingFinished(AttachFileItem* file) {
|
||||
sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||
std::string fileSize = *(&fileSizeChar);
|
||||
|
||||
std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
||||
+ "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>";
|
||||
std::string mesgString = RetroShareLink(QString::fromStdString(file->FileName()),
|
||||
file->FileSize(),
|
||||
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;
|
||||
#endif
|
||||
|
@ -86,6 +86,8 @@ protected:
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
|
||||
private slots:
|
||||
void pasteLink() ;
|
||||
void contextMenu(QPoint) ;
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void peertreeWidgetCostumPopupMenu( QPoint point );
|
||||
@ -157,6 +159,7 @@ private:
|
||||
QMenu* contextMnu;
|
||||
/** Defines the actions for the context menu */
|
||||
QAction* chatAct;
|
||||
QAction* pasteLinkAct;
|
||||
QAction* msgAct;
|
||||
QAction* connectfriendAct;
|
||||
QAction* profileviewAct;
|
||||
|
@ -1210,6 +1210,7 @@ void SearchDialog::copysearchLink()
|
||||
|
||||
RetroShareLink link(fname, fsize, fhash);
|
||||
|
||||
std::cerr << "new link added to clipboard: " << link.toString().toStdString() << std::endl ;
|
||||
if(link.valid())
|
||||
urls.push_back(link) ;
|
||||
}
|
||||
|
@ -409,7 +409,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
|
||||
contextMnu.addAction( openfolderAct);
|
||||
contextMnu.addAction( detailsfileAct);
|
||||
contextMnu.addSeparator();
|
||||
|
||||
}
|
||||
|
||||
contextMnu.addAction( clearcompletedAct);
|
||||
@ -774,6 +773,7 @@ void TransfersDialog::insertTransfers()
|
||||
|
||||
std::set<int> used_rows ;
|
||||
|
||||
if(info.downloadStatus != FT_STATE_COMPLETE)
|
||||
for (pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
||||
{
|
||||
QString peerName = getPeerName(pit->peerId);
|
||||
@ -794,7 +794,7 @@ void TransfersDialog::insertTransfers()
|
||||
default: status = tr(""); break;
|
||||
}
|
||||
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;
|
||||
|
||||
FileProgressInfo peerpinfo ;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "PopupChatDialog.h"
|
||||
#include <gui/RetroShareLink.h>
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <QTextEdit>
|
||||
@ -53,6 +54,7 @@
|
||||
/*****
|
||||
* #define CHAT_DEBUG 1
|
||||
*****/
|
||||
#define CHAT_DEBUG 1
|
||||
|
||||
/** Default constructor */
|
||||
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 &)));
|
||||
|
||||
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
|
||||
resetStatusBar() ;
|
||||
|
||||
@ -136,10 +142,32 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
colorChanged(mCurrentColor);
|
||||
setFont();
|
||||
|
||||
pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this );
|
||||
connect( pasteLinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
|
||||
|
||||
updateAvatar() ;
|
||||
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()
|
||||
{
|
||||
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 */
|
||||
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
||||
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 << std::endl;
|
||||
|
||||
@ -781,7 +811,10 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file) {
|
||||
sprintf(fileSizeChar, "%lld", file->FileSize());
|
||||
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
|
||||
std::cerr << "PopupChatDialog::anchorClicked mesgString : " << mesgString << std::endl;
|
||||
#endif
|
||||
@ -813,24 +846,26 @@ void PopupChatDialog::fileHashingFinished(AttachFileItem* file) {
|
||||
rsMsgs -> ChatSend(ci);
|
||||
}
|
||||
|
||||
void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
||||
void PopupChatDialog::anchorClicked (const QUrl& link )
|
||||
{
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "PopupChatDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
||||
#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);
|
||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||
@ -842,14 +877,6 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||
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")
|
||||
QDesktopServices::openUrl(link);
|
||||
@ -860,7 +887,6 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) {
|
||||
newAddress.prepend("http://");
|
||||
QDesktopServices::openUrl(QUrl(newAddress));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||
|
@ -72,6 +72,8 @@ public slots:
|
||||
|
||||
void getfocus();
|
||||
void flash();
|
||||
void pasteLink() ;
|
||||
void contextMenu(QPoint) ;
|
||||
|
||||
void smileyWidget();
|
||||
void addSmiley();
|
||||
@ -115,6 +117,7 @@ private:
|
||||
QAction *actionTextBold;
|
||||
QAction *actionTextUnderline;
|
||||
QAction *actionTextItalic;
|
||||
QAction *pasteLinkAct ;
|
||||
|
||||
std::string dialogId, dialogName;
|
||||
unsigned int lastChatTime;
|
||||
|
Loading…
Reference in New Issue
Block a user