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

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

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

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

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

    return NULL;
}
Esempio n. 2
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() );
	}
    }
}
Esempio n. 3
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() );
    }

}
Esempio n. 4
0
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);
	}
}