mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Refuse directory drop for extrafile
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1220 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
35740d89b1
commit
fc9ed005bf
@ -20,6 +20,7 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "PopupChatDialog.h"
|
||||
|
||||
@ -849,7 +850,7 @@ void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
std::cerr << "GeneralMsgDialog::dropEvent() Urls:";
|
||||
std::cerr << "PopupChatDialog::dropEvent() Urls:";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
@ -864,8 +865,21 @@ void PopupChatDialog::dropEvent(QDropEvent *event)
|
||||
|
||||
if (localpath.size() > 0)
|
||||
{
|
||||
|
||||
PopupChatDialog::addAttachment(localpath);
|
||||
struct stat buf;
|
||||
//Check that the file does exist and is not a directory
|
||||
if ((-1 == stat(localpath.c_str(), &buf))) {
|
||||
std::cerr << "PopupChatDialog::dropEvent() file does not exists."<< std::endl;
|
||||
QMessageBox mb(tr("Drop file error."), tr("The dropped does not exist."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||
mb.exec();
|
||||
} else if (S_ISDIR(buf.st_mode)) {
|
||||
std::cerr << "PopupChatDialog::dropEvent() directory not accepted."<< std::endl;
|
||||
QMessageBox mb(tr("Drop file error."), tr("Directory can't be dropped, only files are accepted."),QMessageBox::Information,QMessageBox::Ok,0,0);
|
||||
mb.setButtonText( QMessageBox::Ok, "OK" );
|
||||
mb.exec();
|
||||
} else {
|
||||
PopupChatDialog::addAttachment(localpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user