static PyObject *meth_QUrlInfo_setLastModified(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf));

    {
        const QDateTime* a0;
        int a0State = 0;
        QUrlInfo *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QUrlInfo, &sipCpp, sipType_QDateTime, &a0, &a0State))
        {
            Py_BEGIN_ALLOW_THREADS
            (sipSelfWasArg ? sipCpp->QUrlInfo::setLastModified(*a0) : sipCpp->setLastModified(*a0));
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QDateTime *>(a0),sipType_QDateTime,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QUrlInfo, sipName_setLastModified, doc_QUrlInfo_setLastModified);

    return NULL;
}
static PyObject *meth_QUrlInfo_setPermissions(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf));

    {
        int a0;
        QUrlInfo *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bi", &sipSelf, sipType_QUrlInfo, &sipCpp, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            (sipSelfWasArg ? sipCpp->QUrlInfo::setPermissions(a0) : sipCpp->setPermissions(a0));
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QUrlInfo, sipName_setPermissions, doc_QUrlInfo_setPermissions);

    return NULL;
}
Exemple #3
0
void SFtpFileEngine::initSFtp()
{
    _fileInfoCache = FtpFileInfoCache::getInstance();

    QString cacheEntry(getCachePath(_path));

    QUrlInfo urlInfo = _fileInfoCache->findFileInfo(cacheEntry);
    if (urlInfo.isValid())
    {
        // non-existent file ?
        if (urlInfo.permissions() == 0)
        {
            _fileFlags = QAbstractFileEngine::FileType;

            return;
        }

        _fileFlags = QAbstractFileEngine::ExistsFlag;

        _fileFlags |= urlInfo.isDir() ? QAbstractFileEngine::DirectoryType :
                                        QAbstractFileEngine::FileType;

        if (_path == "/")
            _fileFlags |= QAbstractFileEngine::RootFlag;

        _fileFlags |= QAbstractFileEngine::FileFlag(urlInfo.permissions());

        _urlInfo = urlInfo;

        return;
    }

    refreshFileInfoCache();
}
QIcon Convert::getFileIcon(const QUrlInfo& url) {
    static QFileIconProvider fileIconProvider;
    if(url.isFile()) {
        return fileIconProvider.icon(QFileIconProvider::File);
    } else if(url.isDir()) {
        return fileIconProvider.icon(QFileIconProvider::Folder);
    } else {
        return QIcon();
    }
}
Exemple #5
0
/**
 * @brief   ftp文件列表
 */
void Ftp::ftp_list(const QUrlInfo &url_info)
{
    file_info info;

    info.name = url_info.name();
    info.size = url_info.size();
    info.is_dir = url_info.isDir();
    info.lastTime = url_info.lastModified().toString("yy/MM/dd hh:mm");

    lists.append(info);
}
Exemple #6
0
RsyncEntry::RsyncEntry(const QUrlInfo& info)
{
    d = new RsyncEntryData;
    d->urlInfo = info;
    if(info.isDir())
        d->childrenFetched = false;
    else
        d->childrenFetched = true;

    if(info.isValid())
        d->icon = FileIconCache::instance().icon(info);
}
void FtpClientWindow::changeList(const QUrlInfo &urlInfo)
{
	QListWidgetItem *item = new QListWidgetItem;
	item->setText(urlInfo.name());
	QPixmap pixmap(urlInfo.isDir() ? ":/images/dir.png" : ":/images/file.png");
	item->setIcon(pixmap);
	listWidget->addItem(item);
	if (!listWidget->currentItem()) {
		listWidget->setCurrentItem(listWidget->item(0));
		listWidget->setEnabled(true);
	}
}
Exemple #8
0
void ftpClient::addToList(const QUrlInfo &urlInfo)
{
    if(urlInfo.isDir())
    {
        qDebug()<<tr("Folder on server %1").arg(urlInfo.name());
    }
    else
    {
        qDebug()<<tr("File on server %1").arg(urlInfo.name());
        f_list<<urlInfo.name(); /** Если имя не задано - заносим в список все без разбора **/
    }
}
void FtpApp::addToList(const QUrlInfo &urlInfo)
{
    QTreeWidgetItem *item = new QTreeWidgetItem;
    item->setText(0, urlInfo.name());
    item->setText(1, QString::number(float(urlInfo.size())/1000)+"KB");
    item->setText(2, urlInfo.owner());
    item->setText(3, urlInfo.group());
    item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));    

    fileSize[urlInfo.name()]=urlInfo.size();

    QPixmap pixmap(urlInfo.isDir() ? ":/images/dir.png" : ":/images/file.png");
    item->setIcon(0, pixmap);

    fileList->addTopLevelItem(item);
    if (!fileList->currentItem()) {
        fileList->setCurrentItem(fileList->topLevelItem(0));
        fileList->setEnabled(true);
    }
    statusLabel->setText("Status");
    this->setContentsMargins(0,0,0,0);
    this->setCentralWidget(fileList);
    //if(processLabel!=0) {delete processLabel;std::cout<<"Success";}
    splash->close();
    this->show();
}
Exemple #10
0
void Widget::addToList(const QUrlInfo &urlInfo)
{
    QTreeWidgetItem *item = new QTreeWidgetItem;
    QPixmap pixmap(urlInfo.isDir() ? ":fileImage/images/dir.png" : ":fileImage/images/file.png");
    item->setIcon(0, pixmap);
    item->setText(0, urlInfo.name());
    if(urlInfo.isDir())
    {
//        item->setText(1, QString::number(getDirSize(urlInfo.name())));
    }
    else if(urlInfo.isFile())
    {
        item->setText(1, QString::number(urlInfo.size()));
//        item->setText(2, urlInfo.owner());
//        item->setText(3, urlInfo.group());
        //        item->setText(1, QString::number(urlInfo.size());
    }
    else
        qDebug() << "addToList() if else";
    item->setText(2, urlInfo.lastModified().toString("yyyy/M/d h:m:ss"));

    //***
    isDirectory[urlInfo.name()] = urlInfo.isDir();
    ui->fileListTreeWidget->addTopLevelItem(item);
//    if(!ui->fileListTreeWidget->currentItem())
//    {
//        ui->fileListTreeWidget->setCurrentItem(ui->fileListTreeWidget->topLevelItem(0));
//        ui->fileListTreeWidget->setEnabled(true);
//    }
    return;
}
Exemple #11
0
void DNetLoad::addToList(const QUrlInfo &urlInfo)
{
    QTreeWidgetItem *item = new QTreeWidgetItem;
    item->setText(0, urlInfo.name());
    item->setText(1, QString::number(urlInfo.size()));
    item->setText(2, urlInfo.owner());
    item->setText(3, urlInfo.group());
    item->setText(4, urlInfo.lastModified().toString("yyyy-MM-dd"));

    tree->addTopLevelItem(item);

//    if(!tree->currentItem())
//    {
//        tree->setCurrentItem(tree->topLevelItem(0));
////        tree->setEnabled(true);
//    }
}
Exemple #12
0
void Qip::socketReadyRead()
{
    // read from the server
    QTextStream stream( socket );
    QString line;
    while ( socket->canReadLine() ) {
	line = stream.readLine();
	if ( line.startsWith( "500" ) ) {
	    error( ErrValid, line.mid( 4 ) ); 
	} else if ( line.startsWith( "550" ) ) {
	    error( ErrFileNotExisting, line.mid( 4 ) ); 
	} else if ( line.startsWith( "212+" ) ) {
	    if ( state != List ) {
		state = List;
	        emit start( operationInProgress() );
	    }
	    QUrlInfo inf;
	    inf.setName( line.mid( 6 ) + QString( ( line[ 4 ] == 'D' ) ? "/" : "" ) );
	    inf.setDir( line[ 4 ] == 'D' );
	    inf.setSymLink( FALSE );
	    inf.setFile( line[ 4 ] == 'F' );
	    inf.setWritable( FALSE );
	    inf.setReadable( TRUE );
	    emit newChild( inf, operationInProgress() );
	} else if ( line.startsWith( "213+" ) ) {
	    state = Data;
	    emit data( line.mid( 4 ).utf8(), operationInProgress() );
	}
	if( line[3] == ' ' && state != Start) {
	    state = Start;
	    operationInProgress()->setState( StDone );
	    emit finished( operationInProgress() );
	}
    }
}
Exemple #13
0
void FTPUpdate::listInfoReceived(const QUrlInfo &info)
{
    //Only check filenames
    if (info.isFile())
    {
        //Get version from file
        QString fileName = info.name();
        if (fileName.startsWith("ArpmanetDC"))
        {
            QString version = fileName;
            version.remove("ArpmanetDC v");
            version.remove(".exe");

            //Check if newer version
            if (firstVersionLarger(version, VERSION_STRING) && version != VERSION_STRING)
            {
                //If this is just a version check
                if (ftpServer->currentId() == listIndex)
                {
                    newestVersion = version;
                    newerVersionAvailable = true;
                }
                //If this is a download request
                else if (ftpServer->currentId() == downloadListIndex)
                {
                    //Get file
                    downloadingFileName = fileName;
                    QString currentPath = QDir::currentPath();
                    if (!currentPath.endsWith("/"))
                        currentPath.append("/");
                    file.setFileName(currentPath + downloadingFileName);
                    if (file.exists())
                        file.remove(); //Remove existing file to ensure appending works
                    file.open(QIODevice::Append);

                    downloadGetIndex = ftpServer->get(fileName);
                    ftpServer->close();
                }
            }
        }
    }
}
void QtWebKitFtpListingNetworkReply::addEntry(const QUrlInfo &entry)
{
	if (entry.isDir())
	{
		m_directories.append(entry);
	}
	else
	{
		m_files.append(entry);
	}
}
Exemple #15
0
void MainWindow::dlFile(QUrlInfo info)
{

    if(info.isFile()){


        files.append(new QFile(info.name()));

        if(!files.last()->open(QIODevice::WriteOnly)){
            delete files.last();
            QMessageBox msgBox;
             msgBox.setText("Erreur lors de la creation de fichier");
             msgBox.exec();

            return;
        }
        nbFileDld++;
        ftp->get(info.name(), files.last());
    }
}
Exemple #16
0
void Transfer::OnListInfo(const QUrlInfo& info){

    switch(list_step_){
    case IN_ROOT:{
        if(info.isDir()
                &&info.name() == HOST_NAME){
            have_host_ = true;
        }
    }break;
    case IN_HOST:{
        if(info.isDir()
                &&info.name() == g_configuer->user_name_){
            have_user_dir_ = true;
        }
    }break;
    case IN_USER_NAME:{

        if(info.isFile()){
            have_no_file_ = false;
            ftp_.remove(info.name());
        }
    }break;
    default:
        break;
    }
}
Exemple #17
0
QAbstractFileEngine::Iterator*
SFtpFileEngine::beginEntryList(QDir::Filters filters,
                              const QStringList &filterNames)
{
    qDebug() << "beginEntryList() : " << _fileName << _fileFlags;

    QString cachePath(getCachePath(_path, true));
    FtpFileInfoCache::QUrlInfoList list =
            _fileInfoCache->findDirInfo(cachePath);

    if (list.size() == 0
            && (_fileFlags & QAbstractFileEngine::DirectoryType)
            && sftpConnect())
    {
        readDir(_path);

        sftpDisconnect();
    }

    QMap<QString, QUrlInfo> entriesMap;

    list = _fileInfoCache->findDirInfo(cachePath);
    if (list.size() > 0)
    {
        FtpFileInfoCache::QUrlInfoListIterator it(list);
        while (it.hasNext())
        {
            QUrlInfo urlInfo = it.next();

            // exclude an empty entry inserted by us and a non-existent entry
            if (urlInfo.isValid() && urlInfo.permissions())
                entriesMap.insert(urlInfo.name(), urlInfo);
        }
    }

    return new FtpFileEngineIterator(filters, filterNames,
                                     filterEntries(filters, filterNames,
                                                   entriesMap));
}
Exemple #18
0
void MainWindow::addToList(const QUrlInfo &urlInfo)
{
    QTreeWidgetItem *item = new QTreeWidgetItem;
    item->setText(0, urlInfo.name());
    item->setText(1, QString::number(urlInfo.size()));
    item->setText(2, urlInfo.owner());
    item->setText(3, urlInfo.group());
    item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));
    QPixmap pixmap(urlInfo.isDir() ? "../myFTP/dir.png" : "../myFTP/file.png");
    item->setIcon(0, pixmap);
    isDirectory[urlInfo.name()] = urlInfo.isDir();
    ui->fileList->addTopLevelItem(item);
    if (!ui->fileList->currentItem()) {
        ui->fileList->setCurrentItem(ui->fileList->topLevelItem(0));
        ui->fileList->setEnabled(true);
    }
}
Exemple #19
0
void Nntp::parseGroups()
{
    if ( !commandSocket->canReadLine() )
	return;

    // read one line after the other
    while ( commandSocket->canReadLine() ) {
	QString s = commandSocket->readLine();

	// if the  line starts with a dot, all groups or articles have been listed,
	// so we finished processing the listChildren() command
	if ( s[ 0 ] == '.' ) {
	    readGroups = FALSE;
	    operationInProgress()->setState( StDone );
	    emit finished( operationInProgress() );
	    return;
	}

	// if the code of the server response is 215 or 211
	// the next line will be the first group or article (depending on what we read).
	// So let others know that we start reading now...
	if ( s.left( 3 ) == "215" || s.left( 3 ) == "211" ) {
	    operationInProgress()->setState( StInProgress );
	    emit start( operationInProgress() );
	    continue;
	}

	// parse the line and create a QUrlInfo object
	// which describes the child (group or article)
	bool tab = s.find( '\t' ) != -1;
	QString group = s.mid( 0, s.find( tab ? '\t' : ' ' ) );
	QUrlInfo inf;
	inf.setName( group );
	QString path = url()->path();
	inf.setDir( path.isEmpty() || path == "/" );
	inf.setSymLink( FALSE );
	inf.setFile( !inf.isDir() );
	inf.setWritable( FALSE );
	inf.setReadable( TRUE );

	// let others know about our new child
	emit newChild( inf, operationInProgress() );
    }

}
Exemple #20
0
// Make the file list with directories and files
void CFtpSelection::AddToList(const QUrlInfo &urlInfo)
{
	QTreeWidgetItem *item = new QTreeWidgetItem;
	item->setText(0, urlInfo.name());
	item->setText(1, QString::number(urlInfo.size()));
	item->setText(2, urlInfo.owner());
	item->setText(3, urlInfo.group());
	item->setText(4, urlInfo.lastModified().toString("MMM dd yyyy"));

	QPixmap pixmap(urlInfo.isDir() ? ":/translationManager/images/dir.png" : ":/translationManager/images/file.png");
	item->setIcon(0, pixmap);

	isDirectory[urlInfo.name()] = urlInfo.isDir();
	_ui.fileList->addTopLevelItem(item);
	if (!_ui.fileList->currentItem())
	{
		_ui.fileList->setCurrentItem(_ui.fileList->topLevelItem(0));
		_ui.fileList->setEnabled(true);
	}
}
Exemple #21
0
bool QUrlInfo::equal(const QUrlInfo &i1, const QUrlInfo &i2,
                      int sortBy)
{
    switch (sortBy) {
    case QDir::Name:
        return i1.name() == i2.name();
    case QDir::Time:
        return i1.lastModified() == i2.lastModified();
    case QDir::Size:
        return i1.size() == i2.size();
    default:
        return false;
    }
}
//![10]
void FtpDownloader::addToList(const QUrlInfo &urlInfo)
{
    // Fill an FtpItem with the data from FTP directory listing ...
    FtpItem item;
    item.fileName = urlInfo.name();
    item.fileSize = urlInfo.size();
    item.owner = urlInfo.owner();
    item.group = urlInfo.group();
    item.time = urlInfo.lastModified();
    item.isDirectory = urlInfo.isDir();

    const bool wasEmpty = m_model.isEmpty();

    // ... and append it to the model
    m_model.append(item);

    // If this is the first entry in the model, also update the status property
    if (wasEmpty) {
        m_selectionPossible = true;
        emit selectionPossibleChanged();
    }
}
void atWrapper::ftpRmDirAddToList( const QUrlInfo &urlInfo )
{
    //Just adding the file to the list for deletion
    rmDirList << urlInfo.name();
}
void atWrapper::ftpMgetAddToList( const QUrlInfo &urlInfo )
{
    //Simply adding to the list of files to download.
    mgetDirList << urlInfo.name();

}
QIcon Convert::getFileIcon(const QUrlInfo& url) {
    return Convert::getFileIcon(url.name());
}
Exemple #26
0
void MainWindow::addToList(QUrlInfo url)
{
    qDebug()<<url.name();

    if(url.isDir() && !url.isSymLink())
    {
        if(currentDirectory.isEmpty())
            unparsedDirectory << url.name();
        else
            unparsedDirectory << currentDirectory + "/" + url.name();
    }

    if(currentDirectory.isEmpty())
    {
        if(url.isDir() && !url.isSymLink())
        {
            fullFilesList << url.name() + "/";
            fullFilesMap[url.name() + "/"] = url;
        }
        else
        {
            if(url.name() == "playlist.txt")
                playlistPath << "/";

            fullFilesList << url.name();
            fullFilesMap[url.name()] = url;
        }
    }
    else
    {
        if(url.isDir() && !url.isSymLink())
        {
            fullFilesList << currentDirectory + "/" + url.name() + "/";
            fullFilesMap[currentDirectory + "/" + url.name() + "/"] = url;
        }
        else
        {
            if(url.name() == "playlist.txt")
                playlistPath << currentDirectory + "/";

            fullFilesList << currentDirectory + "/" + url.name();
            fullFilesMap[currentDirectory + "/" + url.name()] = url;
        }
    }
}
void TelechargerFichier::nouveauTelechargement(const QString lien)
{
	show();
	emit DesactiverIcone();

	if (lien.isEmpty() && lineLien->text().isEmpty())
		return;

	QUrl urlFichier = lineLien->text();

	if (!lien.isEmpty())
		urlFichier = lien;

	QUrlInfo infosUrl;
		infosUrl.setName(lineLien->text());

	if (!lien.isEmpty())
		infosUrl.setName(lien);


	if (infosUrl.isFile())
	{
		QFileInfo infosDL(infosUrl.name());

		if (QMessageBox::question(this, "Multiuso", "Voulez-vous enregistrer <em>« " + infosDL.fileName() + " »</em> ?",
					QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
			return;


		QSettings emplacementDossier(Multiuso::appDirPath() + "/ini/config.ini", QSettings::IniFormat);

		QDir dir;
			dir.mkpath(emplacementDossier.value("telechargements/dossier").toString() + "/Multiuso - Téléchargements");

		QFile fileTmp(emplacementDossier.value("telechargements/dossier").toString() + "/Multiuso - Téléchargements/" + infosDL.fileName());

		if (fileTmp.exists())
		{
			int reponse = QMessageBox::question(this, "Multiuso", "Le fichier <em>« " + infosDL.fileName() + " »</em> existe déjà !<br />"
					"Voulez-vous le remplacer ?", QMessageBox::Yes | QMessageBox::No);

			if (reponse == QMessageBox::Yes)
				fileTmp.remove();

			else
				return;
		}

		QNetworkRequest requete(urlFichier);

		QNetworkAccessManager *manager = new QNetworkAccessManager;

		QNetworkReply *reponse = manager->get(requete);

		connect(reponse, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(telechargementContinue(qint64, qint64)));
		connect(reponse, SIGNAL(finished()), this, SLOT(finTelechargement()));

		reponses << reponse;

		QProgressBar *progression = new QProgressBar;

		progressionsTelechargements << progression;

		nomsFichiers << infosDL.fileName();

		QString nomDuFichierActuel = infosDL.fileName();
			nomDuFichierActuel = Multiuso::htmlspecialchars(nomDuFichierActuel);

		QTableWidgetItem *nom = new QTableWidgetItem(nomDuFichierActuel);
			nom->setFlags(nom->flags() & ~Qt::ItemIsEditable);

		QTableWidgetItem *statut = new QTableWidgetItem("En attente...");
			statut->setFlags(statut->flags() & ~Qt::ItemIsEditable);

		QPushButton *annuler = new QPushButton;
			annuler->setToolTip("Téléchargement n°" + QString::number(listeTelechargements->rowCount() + 1));
			annuler->setIcon(QIcon(":/icones/telechargements/annuler.png"));
			connect(annuler, SIGNAL(clicked()), this, SLOT(annulerTelechargement()));

		int ligne = listeTelechargements->rowCount();

		listeTelechargements->setRowCount(listeTelechargements->rowCount() + 1);
		listeTelechargements->setCellWidget(ligne, 0, annuler);
		listeTelechargements->setItem(ligne, 1, nom);
		listeTelechargements->setCellWidget(ligne, 2, progression);
		listeTelechargements->setItem(ligne, 3, statut);

		listeTelechargements->resizeColumnsToContents();
		listeTelechargements->horizontalHeader()->setStretchLastSection(true);
	}
}
Exemple #28
0
void CFtpTransfer::slotListInfo(const QUrlInfo &urlInfo)
{
    qDebug()<<"urlinfo"<<urlInfo.size();
    m_listFile.append(urlInfo.name());
    m_flagProcessOk=true;
}
Exemple #29
0
void Fritzbox::finishFtpList(QUrlInfo url) {
	if (lastFtpJob.second == FTPdefaultDir) {
		lastFtpJob.first = ftp.cd(url.name() + "/FRITZ/voicebox");
		lastFtpJob.second = FTPenterVoicebox;
	}
}
Exemple #30
0
FtpViewItem::FtpViewItem( QListView *parent, const QUrlInfo &i )
    : QListViewItem( parent, i.name() ), info( i )
{
}