Exemplo n.º 1
0
bool ListBoxDnd::dropEvent( QDropEvent * event )
{
    if ( dragInside ) {
    
	if ( dMode & NullDrop ) { // combined with Move, a NullDrop will delete an item
	    event->accept();
	    emit dropped( 0 ); // a NullDrop
	    return TRUE;
	}
	
	QPoint pos = event->pos();
	QListBoxItem * after = itemAt( pos );

	if ( ListBoxItemDrag::decode( event, (QListBox *) src, after ) ) {
	    event->accept();
	    QListBox * src = (QListBox *) this->src;
	    QListBoxItem * item = ( after ? after->next() : src->firstItem() );
	    src->setCurrentItem( item );
	    emit dropped( item ); // ###FIX: Supports only one item!
	}
    }

    line->hide();
    dragInside = FALSE;

    return TRUE;
}
Exemplo n.º 2
0
bool PlaylistModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
    // Internal reorder
    if (action == Qt::MoveAction) {
        m_dropRow = row;
        return true;
    }
    // Dragged from player or file manager
    else if (data->hasFormat("application/mlt+xml") || data->hasUrls()) {
        emit dropped(data, row);
        return true;
    }
    // Dragged from Recent dock
    else if (data->hasFormat("application/x-qabstractitemmodeldatalist")) {
        QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist");
        QDataStream stream(&encoded, QIODevice::ReadOnly);
        QMap<int,  QVariant> roleDataMap;
        while (!stream.atEnd()) {
            int row, col;
            stream >> row >> col >> roleDataMap;
        }
        if (roleDataMap.contains(Qt::ToolTipRole)) {
            QMimeData *mimeData = new QMimeData;
            QList<QUrl> urls;
            // DisplayRole is just basename, ToolTipRole contains full path
            urls.append(roleDataMap[Qt::ToolTipRole].toUrl());
            mimeData->setUrls(urls);
            emit dropped(mimeData, row);
            return true;
        }
    }
Exemplo n.º 3
0
void KFileDetailView::contentsDropEvent( TQDropEvent *e )
{
    d->dropItem = 0;
    d->autoOpenTimer.stop();

    if ( ! acceptDrag( e ) ) { // can we decode this ?
        e->ignore();            // No
        return;
    }
    e->acceptAction();     // Yes

    KFileListViewItem *item = dynamic_cast<KFileListViewItem*>(itemAt( contentsToViewport( e->pos() ) ));
    KFileItem * fileItem = 0;
    if (item)
        fileItem = item->fileInfo();

    emit dropped(e, fileItem);

    KURL::List urls;
    if (KURLDrag::decode( e, urls ) && !urls.isEmpty())
    {
        emit dropped(e, urls, fileItem ? fileItem->url() : KURL());
        sig->dropURLs(fileItem, e, urls);
    }
}
Exemplo n.º 4
0
bool DropPrivileges::dropTo(uid_t uid, gid_t gid) {
  if (dropped() && uid == to_user_ && gid == to_group_) {
    // Privileges are already dropped to the requested user and group.
    return true;
  } else if (dropped()) {
    return false;
  }

  /// Drop process groups.
  if (original_groups_ != nullptr) {
    restoreGroups();
  }

  group_size_ = getgroups(0, nullptr);
  original_groups_ = (gid_t*)malloc(group_size_ * sizeof(gid_t));
  group_size_ = getgroups(group_size_, original_groups_);
  setgroups(1, &gid);
  if (setegid(gid) != 0) {
    return false;
  } else if (seteuid(uid) != 0) {
    (void)setegid(getgid());
    return false;
  }

  // Privileges are now dropped to the requested user/group.
  to_user_ = uid;
  to_group_ = gid;
  dropped_ = true;
  return true;
}
Exemplo n.º 5
0
bool TreeModel::dropMimeData(const QMimeData *data, Qt::DropAction, int row, int, const QModelIndex & parent)
{
	// read nodeid from qmimedata and find node
	int id = data->data("application/silence-nodeid").toInt();
	QModelIndex movingIndex = findByNodeId(id);

	QModelIndex oldparent = movingIndex.parent();
	int oldPos = movingIndex.row();
	Node* oldparentNode = getItem(oldparent);

	QModelIndex newparent = parent;
	if (newparent == movingIndex)
		return false;
	int newPos = row < 0 ? 0 : row;
	Node* newparentNode = getItem(newparent);

	if (getItem(movingIndex)->contains(newparentNode))
		return false;

	if (oldparent == newparent && oldPos < newPos)
		newPos -= 1;

	// move node
	beginRemoveRows(oldparent, oldPos, oldPos);
	Node *movingNode = oldparentNode->takeChild(oldPos);
	endRemoveRows();
	beginInsertRows(newparent, newPos, newPos);
	bool success = newparentNode->addChild(movingNode, newPos);
	endInsertRows();

	if (success)
		emit dropped(newparent.child(newPos, 0));

	return success;
}
Exemplo n.º 6
0
void CustomDropLineEdit::dropEvent(QDropEvent *event)
{
    QString dropPath(QUrl::fromUserInput(event->mimeData()->text())
                     .toDisplayString(QUrl::PreferLocalFile
                                      | QUrl::NormalizePathSegments));

    // remove leading slash on Windows
#ifdef Q_OS_WIN
    if (dropPath.at(0) == QChar(QLatin1Char('/')))
    {
        dropPath = dropPath.mid(1);
    }
#endif

    QFileInfo dropPathInfo(dropPath);
    if (!dropPathInfo.exists())
    {
        return;
    }
    if ((canBeFile_ && dropPathInfo.isFile()) || dropPathInfo.isDir())
    {
        const auto path = dropPathInfo.absoluteFilePath();
//        setText(QDir::toNativeSeparators(path));
//        emit QLineEdit::textChanged(path);
        emit dropped(path);
        event->acceptProposedAction();
    }
}
Exemplo n.º 7
0
bool QIconView::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: selectionChanged(); break;
    case 1: selectionChanged((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 2: currentChanged((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 3: clicked((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 4: clicked((QIconViewItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 5: pressed((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 6: pressed((QIconViewItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 7: doubleClicked((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 8: returnPressed((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 9: rightButtonClicked((QIconViewItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 10: rightButtonPressed((QIconViewItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 11: mouseButtonPressed((int)static_QUType_int.get(_o+1),(QIconViewItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 12: mouseButtonClicked((int)static_QUType_int.get(_o+1),(QIconViewItem*)static_QUType_ptr.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 13: contextMenuRequested((QIconViewItem*)static_QUType_ptr.get(_o+1),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+2))); break;
    case 14: dropped((QDropEvent*)static_QUType_ptr.get(_o+1),(const QValueList<QIconDragItem>&)*((const QValueList<QIconDragItem>*)static_QUType_ptr.get(_o+2))); break;
    case 15: moved(); break;
    case 16: onItem((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 17: onViewport(); break;
    case 18: itemRenamed((QIconViewItem*)static_QUType_ptr.get(_o+1),(const QString&)static_QUType_QString.get(_o+2)); break;
    case 19: itemRenamed((QIconViewItem*)static_QUType_ptr.get(_o+1)); break;
    default:
	return QScrollView::qt_emit(_id,_o);
    }
    return TRUE;
}
Exemplo n.º 8
0
void TreeView::setupTree()
{
	tree = new QTreeView;
	model = new TreeModel;
	tree->setModel(model);
	tree->setSelectionBehavior(QAbstractItemView::SelectItems);
	connect(tree->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,
			const QItemSelection&)),
			this, SLOT(updateActions()));

	tree->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(tree, SIGNAL(customContextMenuRequested (const QPoint&)),
			this, SLOT(showTreeContextMenu()));

	connect(tree->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&,
			const QItemSelection&)),
			this, SLOT(selectItem()));

	// All rows should have the same height so it should be no problem
	// to use this option. It should increace the performance of the TreeView.
	tree->setUniformRowHeights(true);

	tree->setDragEnabled(true);
	tree->setAcceptDrops(true);
	tree->setDropIndicatorShown(true);
	connect(model, SIGNAL(dropped(QModelIndex)), this, SLOT(nodeDropped(QModelIndex)));
}
Exemplo n.º 9
0
void KOAttendeeListView::addAttendee( const QString &newAttendee )
{
  kdDebug(5850) << " Email: " << newAttendee << endl;
  QString name;
  QString email;
  KPIM::getNameAndMail( newAttendee, name, email );
  emit dropped( new Attendee( name, email, true ) );
}
Exemplo n.º 10
0
bool DropPrivileges::dropToParent(const fs::path& path) {
  uid_t to_user{0};
  gid_t to_group{0};
  // Open the parent path of the requested file to operate on.
  int pfd = open(path.parent_path().string().c_str(), O_RDONLY | O_NONBLOCK);
  if (pfd >= 0) {
    struct stat file;
    if (geteuid() == 0 && fstat(pfd, &file) >= 0 &&
        (file.st_uid != 0 || file.st_gid != 0)) {
      // A drop is required if this process is executed as a superuser and
      // the folder can be altered by non-super users.
      to_user = file.st_uid;
      to_group = file.st_gid;
    }
    close(pfd);
  }

  if (to_user == 0 && to_group == 0) {
    // No drop required.
    return true;
  } else if (dropped() && to_user == to_user_ && to_group == to_group_) {
    // They are already dropped to the correct user/group.
    return true;
  } else if (!dropped()) {
    // Privileges should be dropped.
    if (_fs_set_group(to_group) != 0) {
      return false;
    } else if (_fs_set_user(to_user) != 0) {
      // Privileges are not dropped and could not be set for the user.
      // Restore the group and fail.
      (void)_fs_set_group(getgid());
      return false;
    }

    // Privileges are now dropped to the requested user/group.
    to_user_ = to_user;
    to_group_ = to_group;
    dropped_ = true;
    fs_drop_ = true;
    return true;
  }

  // Privileges are dropped but not to the requested user/group.
  // Proceed with extreme caution.
  return false;
}
bool ListViewDnd::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: dropped((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    default:
	return ListDnd::qt_emit(_id,_o);
    }
    return TRUE;
}
Exemplo n.º 12
0
void KOAttendeeListView::addAttendee( const QString &newAttendee )
{
    kDebug() << " Email:" << newAttendee;
    QString name;
    QString email;
    KPIMUtils::extractEmailAddressAndName( newAttendee, email, name );
#ifndef KORG_NODND
    emit dropped( new Attendee( name, email, true ) );
#endif
}
Exemplo n.º 13
0
void LXQtTaskButton::dropEvent(QDropEvent *event)
{
    mDNDTimer->stop();
    if (event->mimeData()->hasFormat(mimeDataFormat()))
    {
        emit dropped(event->source(), event->pos());
        setAttribute(Qt::WA_UnderMouse, false);
    }
    QToolButton::dropEvent(event);
}
Exemplo n.º 14
0
bool DropPrivileges::dropTo(uid_t uid, gid_t gid) {
  if (dropped() && uid == to_user_ && gid == to_group_) {
    // Privileges are already dropped to the requested user and group.
    return true;
  } else if (dropped()) {
    return false;
  }

  if (seteuid(uid) != 0) {
    return false;
  }

  (void)setegid(gid);
  // Privileges are now dropped to the requested user/group.
  to_user_ = uid;
  to_group_ = gid;
  dropped_ = true;
  return true;
}
Exemplo n.º 15
0
void ThumbnailWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
    if(!drag_progress_) {
        QGraphicsObject::mouseReleaseEvent(event);
        return;
    }

    drag_progress_ = false;
    emit dropped(this, event->scenePos());
}
Exemplo n.º 16
0
void DropArea::dropEvent(QDropEvent *event)
{
    const QMimeData *mimeData = event->mimeData();

    if (mimeData->hasUrls()) {
        emit dropped(mimeData->urls());
    }

    event->acceptProposedAction();
}
Exemplo n.º 17
0
//-----------------------------------------------
void KFileDnDDetailView::contentsDropEvent( QDropEvent* e ) {

    kdDebug (9020) << "KFileDndDetailView::contentsDropEvent" << endl;

	if( m_useAutoOpenTimer ) {
		m_autoOpenTimer.stop();
		m_dropItem = 0L;
	}
	if( ! acceptDrag( e ) ) {
		e->acceptAction( false );
		return;
	}
	e->acceptAction();				
	// the drop was accepted so lets emit this to the outside world
	KURL::List urls;
	KURLDrag::decode( e, urls );
	emit dropped( e );
	emit dropped( this, e );
	emit dropped( this, urls );
}
Exemplo n.º 18
0
void TimelineDock::dropEvent(QDropEvent *event)
{
    if (event->mimeData()->hasFormat(Mlt::XmlMimeType)) {
        int trackIndex = currentTrack();
        if (trackIndex >= 0) {
            emit dropAccepted(QString::fromUtf8(event->mimeData()->data(Mlt::XmlMimeType)));
            event->acceptProposedAction();
        }
    }
    emit dropped();
}
Exemplo n.º 19
0
bool PlaylistModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
    if (data->hasFormat("application/mlt+xml") || data->hasUrls()) {
        emit dropped(data, row);
        return true;
    }
    else if (action == Qt::MoveAction)
        return QAbstractTableModel::dropMimeData(data, action, row, column, parent);
    else
        return false;
}
Exemplo n.º 20
0
WindowMain::WindowMain(QWidget *parent) :
	QMainWindow(parent),
	m_ui(new Ui::WindowMain)
{
	/** Initialize the UI */
	m_ui->setupUi(this);

	/** Set the window title */
	setWindowTitle(PACKAGE_STRING);

	/** Connect the actions */
	connect(m_ui->actionAboutQt, SIGNAL(triggered()),
			qApp, SLOT(aboutQt()));
	connect(m_ui->actionAbout, SIGNAL(triggered()),
			this, SLOT(onAbout()));
	connect(m_ui->actionSettings, SIGNAL(triggered()),
			this, SLOT(onSettings()));
	connect(m_ui->actionQuit, SIGNAL(triggered()),
			this, SLOT(close()));
	connect(this, SIGNAL(next()),
			this, SLOT(onNext()));
	connect(this, SIGNAL(done()),
			this, SLOT(onEnd()));

	/** Initialize the settings */
	m_settings = new Settings(this);

	/** Create and setup the drop area */
	m_dropArea = new DropArea();
	connect(m_dropArea, SIGNAL(dropped(QList<QUrl>)),
			this, SLOT(onStart(QList<QUrl>)));
	setCentralWidget(m_dropArea);

	/** Initialize the status bar */
	m_ui->statusBar->setStyleSheet("QStatusBar::item {border: none;}");
	m_ui->statusBar->showMessage(tr("Ready"));

	/** Create the progress bar */
	m_progress = new QProgressBar();

	/** Create the allocine engine */
	m_allocine = new AllocineEngine();
	connect(m_allocine, SIGNAL(found(QList<AllocineResult*>)),
			this, SLOT(onFound(QList<AllocineResult*>)));
	connect(m_allocine, SIGNAL(fetched(AllocineResult*)),
			this, SLOT(onFetched(AllocineResult*)));
	connect(m_allocine, SIGNAL(error(QString)),
			this, SLOT(onError(QString)));

	/** Initialize the processing flag */
	m_processing = false;
}
Exemplo n.º 21
0
void DropLabel::dropEvent( QDropEvent* event )
{
	QFileInfo fileInfo(event->mimeData()->text());

	//A little sting manuipulation to remove the "file:///"-prefix on the file path if dragged from asset browser
	QString filePath;
	if (fileInfo.filePath().startsWith(QLatin1String("file:///")))
	{
		filePath =  fileInfo.filePath().mid(8);
	}
	else
	{
		filePath =  fileInfo.filePath();	
	}

	QDir dirInfo(filePath);
	//Check if there is a name to begin with
	if(fileInfo.baseName() != 0)
	{
		QStringList dirPaths;
		//Collect all dirs up to Assets
		while(dirInfo.dirName() != "Assets")
		{
			dirPaths << dirInfo.dirName();

			if(!dirInfo.cdUp())
				break;
		}

		//Remove and store the file name without suffix
		dirPaths.pop_front();
		//Remove category folder from path list
		dirPaths.pop_back();

		QString relativePath;

		//Construct the relative path
		while (!dirPaths.isEmpty())
		{
			relativePath += dirPaths.takeLast() + "/";
		}

		//Finally add file name to path
		relativePath += fileInfo.completeBaseName();

		emit dropped(relativePath);
	}

	setStyleSheet("");

}
Exemplo n.º 22
0
bool ListViewDnd::dropEvent( QDropEvent * event )
{
    if ( dragInside ) {
    
	if ( dMode & NullDrop ) { // combined with Move, a NullDrop will delete an item
	    event->accept();
	    emit dropped( 0 ); // a NullDrop
	    return TRUE;
	}
	
	QPoint pos = event->pos();

	ListViewItemDrag::DropRelation dr = ListViewItemDrag::Sibling;
	QListViewItem *item = itemAt( pos );
	int dpos = dropDepth( item, pos );

	if ( item ) {
	    if ( dpos > item->depth() && !(dMode & Flat) ) {
		// Child node
		dr = ListViewItemDrag::Child;
	    } else if ( dpos < item->depth() ) {
		// Parent(s) Sibling
		while ( item && (item->depth() > dpos) )
		    item = item->parent();
	    }
	}

	if ( ListViewItemDrag::decode( event, (QListView *) src, item, dr ) ) {
	    event->accept();
	    emit dropped( 0 ); // Use ID instead of item?
	}
    }

    line->hide();
    dragInside = FALSE;

    return TRUE;
}
Exemplo n.º 23
0
void ItemOrderList::dropEvent(QDropEvent *event)
{
    event->accept();

    QListWidget *list = ui->listWidgetItems;
    const QPoint pos = list->mapFromParent(event->pos());

    const int s = list->spacing();
    QModelIndex index = list->indexAt(pos);
    if ( !index.isValid() )
        index = list->indexAt( pos + QPoint(s, - 2 * s) );

    emit dropped( event->mimeData()->text(), index.row() );
}
Exemplo n.º 24
0
	void proc()
	{
		operate();
		if (count >= interval)
		{
			count = 0;
			if (field->drop())
				dropped();
			else if (chn->handle)
				chn->y += 1;
		}
		win->write(field, chn);
		win->print();
		count++;
	}
Exemplo n.º 25
0
bool QTable::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: currentChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 1: clicked((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+4))); break;
    case 2: doubleClicked((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+4))); break;
    case 3: pressed((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+4))); break;
    case 4: selectionChanged(); break;
    case 5: valueChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 6: contextMenuRequested((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+3))); break;
    case 7: dropped((QDropEvent*)static_QUType_ptr.get(_o+1)); break;
    default:
	return QScrollView::qt_emit(_id,_o);
    }
    return TRUE;
}
Exemplo n.º 26
0
void DropArea::dropEvent(QDropEvent *event)
{
	/** Accept only urls */
	if(event->mimeData()->hasUrls()) {

		/** Set default background */
		setBackgroundRole(QPalette::Dark);

		/** Set action to move */
		event->setDropAction(Qt::TargetMoveAction);

		/** Accept event */
		event->accept();

		/** Emit the dropped event */
		emit dropped(event->mimeData()->urls());
	}
}
Exemplo n.º 27
0
void NTreeView::dropEvent(QDropEvent *event) {
    QFileSystemModel *model = (QFileSystemModel *)this->model();

    // 選択されたファイルのパスを取得
    QModelIndex selectedIndex = this->currentIndex();
    QString selectedFilePath = model->filePath(selectedIndex);

    QTreeView::dropEvent(event);

    // ドロップが無視されたら処理を終了。例えば同じディレクトリなどにドロップした場合は無視される
    if (!event->isAccepted()) {
        return;
    }

    /*
     * ドロップされた座標からドロップされた場所のディレクトリパスを取得する.
     * AbobeItem, BelowItemの場合、ドロップ先はindexAtで取得されたものの親要素となる.
     * これはもとのQTreeViewのロジックをみて持ってきた.
     */
    QModelIndex dropIndex = QTreeView::indexAt(event->pos());
    switch (dropIndicatorPosition()) {
    case QAbstractItemView::AboveItem:
    case QAbstractItemView::BelowItem:
        dropIndex = dropIndex.parent();
        break;
    case QAbstractItemView::OnItem:
    case QAbstractItemView::OnViewport:
        break;
    }

    QString dropPath;
    if (dropIndex.isValid()) {
        if (dropIndex == this->rootIndex()) {
            dropPath = model->rootPath();
        } else {
            dropPath = model->filePath(dropIndex);
        }
    } else {
        // ドロップがModelIndexの領域外になった場合は、ルートディレクトリへのドロップである
        dropPath = model->rootPath();
    }

    emit dropped(dropPath, selectedFilePath);
}
Exemplo n.º 28
0
void DirTreeView::dropEvent(QDropEvent *event)
{
    if (event->mimeData()->hasFormat(UrlListMimeData::format()))
    {
        FileSystemSortFilterProxyModel* proxyModel =
                qobject_cast<FileSystemSortFilterProxyModel*>(model());
        QFileSystemModel* dirModel =
                qobject_cast<QFileSystemModel*>(proxyModel->sourceModel());

        emit dropped(UrlListMimeData::listFrom(event->mimeData()),
                     dirModel->filePath(
                         proxyModel->mapToSource(indexAt(event->pos()))),
                     event->dropAction() == Qt::CopyAction);

        event->setDropAction(event->dropAction());
        event->accept();

        return;
    }

    event->ignore();
}
Exemplo n.º 29
0
TEST_F(PermissionsTests, test_explicit_drop) {
  {
    auto dropper = DropPrivileges::get();
    EXPECT_TRUE(dropper->dropTo(getuid(), getgid()));
    // We can attempt to drop to the previously-dropped privilege.
    EXPECT_TRUE(dropper->dropTo(getuid(), getgid()));
  }

  {
    auto dropper = DropPrivileges::get();
    // Make sure that an out-of-scope dropper "restore"
    EXPECT_FALSE(dropper->dropped_);

    uid_t expected_user = 0U;
    EXPECT_EQ(dropper->to_user_, expected_user);

    gid_t expected_group = 0U;
    EXPECT_EQ(dropper->to_group_, expected_group);

    // Checking if we are generally in an unprivileged mode.
    auto dropper2 = DropPrivileges::get();
    EXPECT_FALSE(dropper2->dropped());
  }
}
Exemplo n.º 30
0
void RulesList::dropEvent(QDropEvent *event)
{
    emit dropped(itemAt(event->pos()));

    event->ignore();
}