Exemple #1
0
QUrl setUpRemoteTestDir(const QString& testFile)
{
    QWidget* authWindow = 0;
    if (qgetenv("GV_REMOTE_TESTS_BASE_URL").isEmpty()) {
        qWarning() << "Environment variable GV_REMOTE_TESTS_BASE_URL not set: remote tests disabled";
        return QUrl();
    }

    QUrl baseUrl(QString::fromLocal8Bit(qgetenv("GV_REMOTE_TESTS_BASE_URL")));
    baseUrl = baseUrl.adjusted(QUrl::StripTrailingSlash);
    baseUrl.setPath(baseUrl.path() + "/gwenview-remote-tests");

    KIO::StatJob *statJob = KIO::stat(baseUrl, KIO::StatJob::DestinationSide, 0);
    KJobWidgets::setWindow(statJob, authWindow);

    if (statJob->exec()) {
        KIO::DeleteJob *deleteJob = KIO::del(baseUrl);
        KJobWidgets::setWindow(deleteJob, authWindow);
        deleteJob->exec();
    }

    KIO::MkdirJob *mkdirJob = KIO::mkdir(baseUrl);
    KJobWidgets::setWindow(mkdirJob, authWindow);
    if (!mkdirJob->exec()) {
        qCritical() << "Could not create dir" << baseUrl << ":" << mkdirJob->errorString();
        return QUrl();
    }

    if (!testFile.isEmpty()) {
        QUrl dstUrl = baseUrl;
        dstUrl = dstUrl.adjusted(QUrl::StripTrailingSlash);
        dstUrl.setPath(dstUrl.path() + '/' + testFile);
        KIO::FileCopyJob *copyJob = KIO::file_copy(urlForTestFile(testFile), dstUrl);
        KJobWidgets::setWindow(copyJob, authWindow);
        if (!copyJob->exec()) {
            qCritical() << "Could not copy" << testFile << "to" << dstUrl << ":" << copyJob->errorString();
            return QUrl();
        }
    }

    return baseUrl;
}
Exemple #2
0
void Preview::showPreview( const QUrl &u, int size )
{
    if ( u.isLocalFile() ) {
	QString path = u.path();
	QFileInfo fi( path );
	if ( fi.isFile() && (int)fi.size() > size * 1000 ) {
	    normalText->setText( tr( "The File\n%1\nis too large, so I don't show it!" ).arg( path ) );
	    raiseWidget( normalText );
	    return;
	}
	
	QPixmap pix( path );
	if ( pix.isNull() ) {
	    if ( fi.isFile() ) {
		QFile f( path );
		if ( f.open( IO_ReadOnly ) ) {
		    QTextStream ts( &f );
		    QString text = ts.read();
		    f.close();
		    if ( fi.extension().lower().contains( "htm" ) ) {
			QString url = html->mimeSourceFactory()->makeAbsolute( path, html->context() );
			html->setText( text, url ); 	
			raiseWidget( html );
			return;
		    } else {
			normalText->setText( text ); 	
			raiseWidget( normalText );
			return;
		    }
		}
	    }
	    normalText->setText( QString::null );
	    raiseWidget( normalText );
	} else {
	    pixmap->setPixmap( pix );
	    raiseWidget( pixmap );
	}
    } else {
	normalText->setText( "I only show local files!" );
	raiseWidget( normalText );
    }
}
Exemple #3
0
void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex)
{
    setData(index, url, UrlRole);
    if (url.path().isEmpty()) {
        setData(index, fileSystemModel->myComputer());
        setData(index, fileSystemModel->myComputer(Qt::DecorationRole), Qt::DecorationRole);
    } else {
        QString newName;
        if (showFullPath) {
            //On windows the popup display the "C:\", convert to nativeSeparators
            newName = QDir::toNativeSeparators(dirIndex.data(QFileSystemModel::FilePathRole).toString());
        } else {
            newName = dirIndex.data().toString();
        }

        QIcon newIcon = qvariant_cast<QIcon>(dirIndex.data(Qt::DecorationRole));
        if (!dirIndex.isValid()) {
            newIcon = fileSystemModel->iconProvider()->icon(QFileIconProvider::Folder);
            newName = QFileInfo(url.toLocalFile()).fileName();
            if (!invalidUrls.contains(url))
                invalidUrls.append(url);
            //The bookmark is invalid then we set to false the EnabledRole
            setData(index, false, EnabledRole);
        } else {
            //The bookmark is valid then we set to true the EnabledRole
            setData(index, true, EnabledRole);
        }

        // Make sure that we have at least 32x32 images
        const QSize size = newIcon.actualSize(QSize(32,32));
        if (size.width() < 32) {
            QPixmap smallPixmap = newIcon.pixmap(QSize(32, 32));
            newIcon.addPixmap(smallPixmap.scaledToWidth(32, Qt::SmoothTransformation));
        }

        if (index.data().toString() != newName)
            setData(index, newName);
        QIcon oldIcon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
        if (oldIcon.cacheKey() != newIcon.cacheKey())
            setData(index, newIcon, Qt::DecorationRole);
    }
}
Exemple #4
0
	QList<QUrl> Core::GetPackageURLs (int packageId) const
	{
		QList<QUrl> result;

		const auto& repo2cmpt = Storage_->GetPackageLocations (packageId);

		PackageShortInfo info;
		try
		{
			info = Storage_->GetPackage (packageId);
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
					<< "error getting package"
					<< packageId;
			return result;
		}

		auto pathAddition = QString ("dists/%1/all/");
		const auto& normalized = NormalizePackageName (info.Name_);
		const auto& version = info.Versions_.at (0);
		pathAddition += QString ("%1/%1-%2.tar.%3")
				.arg (normalized)
				.arg (version)
				.arg (info.VersionArchivers_.value (version, "gz"));

		Q_FOREACH (int repoId, repo2cmpt.keys ())
		{
			RepoInfo ri = Storage_->GetRepo (repoId);
			QUrl url = ri.GetUrl ();
			QString path = url.path ();
			if (!path.endsWith ('/'))
				path += '/';

			Q_FOREACH (const QString& component, repo2cmpt [repoId])
			{
				QUrl tmp = url;
				tmp.setPath (path + pathAddition.arg (component));
				result << tmp;
			}
		}
Exemple #5
0
QNetworkReply *LRNAM::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{	
	QUrl url = request.url();

	QString path = url.path();
	if (op == QNetworkAccessManager::GetOperation && url.isLocalFile())
	{
			path = url.toLocalFile();
			return new LRNAMReply(path);
	}
	else if (path.startsWith("/core/resources/"))
	{
		path = _baseResourceDirectory + path.mid(5);
		return new LRNAMReply(path);
	}
	else
	{
		return QNetworkAccessManager::createRequest(op, request, outgoingData);
	}
}
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
	const QMimeData *data = event->mimeData();

	if (data->hasUrls())
	{
		QList<QUrl> urls = data->urls();
		QUrl first = urls.first();
		QFileInfo file(first.path());

		if (file.exists() && (file.completeSuffix() == "csv" || file.completeSuffix() == "jasp"))
			event->accept();
		else
			event->ignore();
	}
	else
	{
		event->ignore();
	}
}
LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runControl)
    : SimpleTargetRunner(runControl)
{
    setId("LocalQmlPreviewSupport");
    const QUrl serverUrl = Utils::urlFromLocalSocket();

    QmlPreviewRunner *preview = qobject_cast<QmlPreviewRunner *>(
                runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE));
    preview->setServerUrl(serverUrl);

    addStopDependency(preview);
    addStartDependency(preview);

    ProjectExplorer::Runnable run = runnable();

    Utils::QtcProcess::addArg(&run.commandLineArguments,
                              QmlDebug::qmlDebugLocalArguments(QmlDebug::QmlPreviewServices,
                                                               serverUrl.path()));
    setRunnable(run);
}
Exemple #8
0
IndexedString::IndexedString( const QUrl& url ) {
  QByteArray array(url.path().toUtf8());

  const char* str = array.constData();

  int size = array.size();

  if(!size)
    m_index = 0;
  else if(size == 1)
    m_index = 0xffff0000 | str[0];
  else {
    m_index = getIndex(QString::fromUtf8(str));
    /*QMutexLocker lock(globalIndexedStringRepository->mutex());
    m_index = globalIndexedStringRepository->index(IndexedStringRepositoryItemRequest(str, hashString(str, size), size));
    
    if(shouldDoDUChainReferenceCounting(this))
      increase(globalIndexedStringRepository->dynamicItemFromIndexSimple(m_index)->refCount);*/
  }
}
Exemple #9
0
void TDownlad::startRequest(QUrl url)
{
    qDebug() << "url host: " << url.host();
    this->http = new QHttp(url.host(), QHttp::ConnectionModeHttp, 80);
    qDebug("http init");
    connect(http, SIGNAL(requestFinished(int, bool)),
                 this, SLOT(httpFinished(int, bool)));
    connect(http, SIGNAL(dataReadProgress(int, int)),
                 this, SLOT(downloadProgress(int, int)));
    QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
    qDebug() << path;
    if (path.isEmpty())
        path = "/";
    qDebug() << "state: " << http->state();
    reply = this->http->get(path, file);
    http->ignoreSslErrors();
    http->close();
    qDebug() << "get id" << reply;
    qDebug("http request send");
}
Exemple #10
0
QUrlInfo::QUrlInfo(const QUrl &url, int permissions, const QString &owner,
                    const QString &group, qint64 size, const QDateTime &lastModified,
                    const QDateTime &lastRead, bool isDir, bool isFile, bool isSymLink,
                    bool isWritable, bool isReadable, bool isExecutable)
{
    d = new QUrlInfoPrivate;
    d->name = QFileInfo(url.path()).fileName();
    d->permissions = permissions;
    d->owner = owner;
    d->group = group;
    d->size = size;
    d->lastModified = lastModified;
    d->lastRead = lastRead;
    d->isDir = isDir;
    d->isFile = isFile;
    d->isSymLink = isSymLink;
    d->isWritable = isWritable;
    d->isReadable = isReadable;
    d->isExecutable = isExecutable;
}
Exemple #11
0
QString DownloadManager::saveFileName(const QUrl &url)
{
	QString path = url.path();
	QString basename = QFileInfo(path).fileName();

	if (basename.isEmpty())
		basename = "download";

	if (QFile::exists(basename)) {
		// already exists, don't overwrite
		int i = 0;
		basename += '.';
		while (QFile::exists(basename + QString::number(i)))
			++i;

		basename += QString::number(i);
	}

	return basename;
}
Exemple #12
0
void BrowserView::load(const QUrl & url)
{
    if(isLoading)
        stop();

    view->load(url);
    view->setUrl(url);
    if (url.scheme().size() < 2) {
        QString path     = url.path();
        QFileInfo fi(path);
        QString name = fi.baseName();

        setWindowTitle(name);
    }
    else {
        setWindowTitle(url.host());
    }

    setWindowIcon(QWebSettings::iconForUrl(url));
}
Exemple #13
0
QString DownloadManager::saveFileName(const QUrl &url)
{
#if QT_VERSION < 0x050000
    QString dataPath = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/chessdata";
#else
    QString dataPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/chessdata";
#endif

    QString dir = AppSettings->value("/General/DefaultDataPath", dataPath).toString();
    QDir().mkpath(dir);

    QString path = url.path();

    QString basename = QFileInfo(path).fileName();

    if (basename.isEmpty())
        basename = "download.pgn";

    return dir + "/" + basename;
}
QString ThumbnailModel::thumbnailPath(const QUrl &url) const
{
#if defined(Q_OS_UNIX) && !(defined(Q_OS_SYMBIAN) || defined(Q_OS_MAC))
#if defined(Q_WS_MAEMO_5)
    QString thumbnailPath = QDir::homePath()
            + QLatin1String("/.thumbnails/cropped/")
            + QCryptographicHash::hash(url.toString().toUtf8(), QCryptographicHash::Md5).toHex()
            + QLatin1String(".jpeg");
#else
    QString thumbnailPath = QDir::homePath()
            + QLatin1String("/.thumbnails/normal/")
            + QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Md5).toHex()
            + QLatin1String(".png");
#endif
    if (QFile::exists(thumbnailPath))
        return thumbnailPath;
#endif

    return url.path();
}
Exemple #15
0
HttpWindow::HttpWindow(QWidget *parent, QUrl _url, QString _savePath) :
		QDialog(parent) {

	this->setFont(THE_REPO->fontVariableWidthSmall);
	this->fullUrlString = _url.scheme() + "://" + _url.authority()
	+ _url.path();
	this->downloadSuccess = false;
	this->uploadFlag = false;
	this->savePath = _savePath;
	progressDialog = new QProgressDialog(this);

	connect(&qnam,
			SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
			this,
			SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));

	connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));

	this->downloadFile();
}
Exemple #16
0
void HTTPTransport::prepareRequest( QNetworkRequest& aRequest, const QByteArray& aContentType,
                                    int aContentLength )
{
    FUNCTION_CALL_TRACE;

    QUrl url;
    // The URL might be percent encoded
    url = QUrl::fromEncoded( getRemoteLocURI().toLatin1() );
    if( !url.isValid() )
    {
        url = QUrl( getRemoteLocURI() );
    }
    aRequest.setRawHeader( HTTP_HDRSTR_POST, url.path().toLatin1());
    aRequest.setUrl( url );
    aRequest.setRawHeader( HTTP_HDRSTR_UA, HTTP_UA_VALUE);
    aRequest.setRawHeader( HTTP_HDRSTR_CONTENT_TYPE, aContentType );
    aRequest.setRawHeader( HTTP_HDRSTR_ACCEPT,HTTP_ACCEPT_VALUE );
    aRequest.setHeader( QNetworkRequest::ContentLengthHeader, QVariant( aContentLength ) );
    QMap<QString, QString>::const_iterator i;
    for (i = iXheaders.constBegin(); i != iXheaders.constEnd(); i++) {
            aRequest.setRawHeader(i.key().toLatin1(), i.value().toLatin1());
    }

#ifndef QT_NO_OPENSSL
    //do it only for https
    if( url.toString().contains(SYNCML_SCHEMA_HTTPS)) {
        LOG_DEBUG("HTTPS protocol detected");
//        Don't remove the below commented code.
//        this can be used while adding full fledged ssl support.
//        QNetworkAccessManager sets the default configuration needed for https
//        if we want to change the protocol , we will have do it as follows.
//        QSslConfiguration ssl = request.sslConfiguration();
//        if( ssl.isNull() )
//        {
//            ssl.setProtocol(QSsl::SslV3);
//        }
//        request.setSslConfiguration(ssl);
    }
#endif  //  QT_NO_OPENSSL

}
Exemple #17
0
void ScriptsModel::requestDefaultFiles(QString marker) {
    QUrl url(PathUtils::defaultScriptsLocation());

    // targets that don't have a scripts folder in the appropriate location will have an empty URL here
    if (!url.isEmpty()) {
        if (url.isLocalFile()) {
            // if the url indicates a local directory, use QDirIterator
            QString localDir = expandScriptUrl(url).toLocalFile();
            int localDirPartCount = localDir.split("/").size();
            if (localDir.endsWith("/")) {
                localDirPartCount--;
            }
#ifdef Q_OS_WIN
            localDirPartCount++; // one for the drive letter
#endif
            QDirIterator it(localDir, QStringList() << "*.js", QDir::Files, QDirIterator::Subdirectories);
            while (it.hasNext()) {
                QUrl jsFullPath = QUrl::fromLocalFile(it.next());
                QString jsPartialPath = jsFullPath.path().split("/").mid(localDirPartCount).join("/");
                jsFullPath = normalizeScriptURL(jsFullPath);
                _treeNodes.append(new TreeNodeScript(jsPartialPath, jsFullPath.toString(), SCRIPT_ORIGIN_DEFAULT));
            }
            _loadingScripts = false;
        } else {
            // the url indicates http(s), use QNetworkRequest
            QUrlQuery query;
            query.addQueryItem(PREFIX_PARAMETER_NAME, ".");
            if (!marker.isEmpty()) {
                query.addQueryItem(MARKER_PARAMETER_NAME, marker);
            }
            url.setQuery(query);

            QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
            QNetworkRequest request(url);
            request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
            request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
            QNetworkReply* reply = networkAccessManager.get(request);
            connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
        }
    }
}
Exemple #18
0
void HelpWindow::setSource(const QUrl &name)
{
    if (name.isValid()) {
        if (name.scheme() == QLatin1String("http") || name.scheme() == QLatin1String("ftp") 
            || name.scheme() == QLatin1String("mailto") || name.path().endsWith(QLatin1String("pdf"))) {
            bool launched = QDesktopServices::openUrl(name);
            if (!launched) {
                QMessageBox::information(mw, tr("Help"),
                             tr("Unable to launch web browser.\n"),
                             tr("OK"));
            }
            return;
        }

        QFileInfo fi(name.toLocalFile());
        if (name.scheme() == QLatin1String("file") && fi.exists()) {
            if (newWindow || (shiftPressed && hasFocus())) {
                shiftPressed = false;
                mw->saveSettings();
                MainWindow *nmw = new MainWindow;
                nmw->move(mw->geometry().topLeft());
                nmw->show();
                
                if (mw->isMaximized())
                    nmw->showMaximized();
                
                nmw->setup();
                nmw->showLink(name.toString());
            } else {
                QTextBrowser::setSource(name);
                QTextBrowser::scrollToAnchor(name.fragment());
            }
            return;
        }
    }

    mw->statusBar()->showMessage(tr("Failed to open link: '%1'").arg(name.toString()), 5000);
    setHtml(tr("<div align=\"center\"><h1>The page could not be found</h1><br>"
        "<h3>'%1'</h3></div>").arg(name.toString()));
    mw->browsers()->updateTitle(tr("Error..."));
}
Exemple #19
0
SpriteDefinition::SpriteDefinition(QObject *parent,
                                   const QUrl &url,
                                   int variant)
    : Resource(url, parent)
    , mVariant(variant)
    , mVariantCount(0)
    , mVariantOffset(0)
{
    setStatus(Resource::Loading);

    QString path = url.path(QUrl::FullyDecoded);
    int pos = path.indexOf(QLatin1Char('|'));
    if (pos != -1)
        mPalettes = path.mid(pos + 1);

    const QString pathWithoutDye = path.left(pos);
    QUrl urlWithoutDye = url;
    urlWithoutDye.setPath(pathWithoutDye, QUrl::DecodedMode);

    requestFile(urlWithoutDye);
}
Exemple #20
0
QString MainWindow::saveFileName(const QUrl &url)
{
    QString path = url.path();
    QString basename = QFileInfo(path).fileName();

    if (basename.isEmpty())
        basename = "download";

    if (QFile::exists(basename)) {
        // already exists, don't overwrite
        int i = 0;
        basename += '.';
        while (QFile::exists(basename + QString::number(i)))
            ++i;

        basename += QString::number(i);
    }
    std::cout << qPrintable(basename) << std::endl;
    return basename;

}
bool Downloader::handleDownloadRequest(QNetworkAccessManager *manager, QNetworkReply *r)
{
    reply = r;
    QUrl url = reply->url();
    fileName = QFileInfo(url.path()).fileName();
	if(QMessageBox::question(this,tr("Download the file?"),tr("Do you really wish to download ") + fileName) != QMessageBox::Ok)
		return false;
    absFileName = downloadsDir.absoluteFilePath(fileName);
    if(absFileName.isEmpty())
        return false;
    file = new QFile(absFileName);
    file->open(QIODevice::WriteOnly);
    label->setText(tr("Downloading ") + fileName);
    setTitle(tr("Downloading"));
    cancelButton->setText(tr("Cancel"));
    connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(setProgress(qint64,qint64)));
    connect(cancelButton,SIGNAL(clicked()),this,SLOT(abortDownload()));
    connect(reply,SIGNAL(finished()),this,SLOT(finished()));
    connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
    return true;
}
Exemple #22
0
bool XmppUriQueries::parseXmppUri(const QUrl &AUrl, Jid &AContactJid, QString &AAction, QMultiMap<QString, QString> &AParams) const
{
	if (AUrl.isValid() && AUrl.scheme()==XMPP_URI_SCHEME)
	{
		QUrl url =  QUrl::fromEncoded(AUrl.toEncoded().replace(';','&'), QUrl::StrictMode);

		QList< QPair<QString, QString> > keyValues = url.queryItems();
		if (!keyValues.isEmpty())
		{
			AContactJid = url.path();
			AAction = keyValues.takeAt(0).first;
			if (AContactJid.isValid() && !AAction.isEmpty())
			{
				for (int i=0; i<keyValues.count(); i++)
					AParams.insertMulti(keyValues.at(i).first, keyValues.at(i).second);
				return true;
			}
		}
	}
	return false;
}
Exemple #23
0
UBAppleWidget::UBAppleWidget(const QUrl& pWidgetUrl, QWidget *parent)
    : UBAbstractWidget(pWidgetUrl, parent)
{
    QString path = pWidgetUrl.toLocalFile();

    if (!path.endsWith(".wdgt") && !path.endsWith(".wdgt/"))
    {
        int lastSlashIndex = path.lastIndexOf("/");
        if (lastSlashIndex > 0)
        {
            path = path.mid(0, lastSlashIndex + 1);
        }
    }

    QFile plistFile(path + "/Info.plist");
    plistFile.open(QFile::ReadOnly);

    QByteArray plistBin = plistFile.readAll();
    QString plist = QString::fromUtf8(plistBin);

    int mainHtmlIndex = plist.indexOf("MainHTML");
    int mainHtmlIndexStart = plist.indexOf("<string>", mainHtmlIndex);
    int mainHtmlIndexEnd = plist.indexOf("</string>", mainHtmlIndexStart);

    if (mainHtmlIndex > -1 && mainHtmlIndexStart > -1 && mainHtmlIndexEnd > -1)
    {
        mMainHtmlFileName = plist.mid(mainHtmlIndexStart + 8, mainHtmlIndexEnd - mainHtmlIndexStart - 8);
    }

    mMainHtmlUrl = pWidgetUrl;
    mMainHtmlUrl.setPath(pWidgetUrl.path() + "/" + mMainHtmlFileName);

    QWebView::load(mMainHtmlUrl);

    QPixmap defaultPixmap(pWidgetUrl.toLocalFile() + "/Default.png");

    setFixedSize(defaultPixmap.size());

    mNominalSize = defaultPixmap.size();
}
Exemple #24
0
    void setUrl(const QUrl &url)
    {
        QString hdr;
        hdr = QString("GET %PATH% HTTP/1.1\r\n"
                      "Host: %HOST%\r\n"
                      "User-Agent: MythMusic/%VERSION%\r\n"
                      "Accept: */*\r\n");

        QString path = url.path();
        QString host = url.host();

        if (path.isEmpty())
            path = "/";

        if (url.hasQuery())
            path += '?' + url.encodedQuery();

        if (url.port() != -1)
            host += QString(":%1").arg(url.port());

        hdr.replace("%PATH%", path);
        hdr.replace("%HOST%", host);
        hdr.replace("%VERSION%", MYTH_BINARY_VERSION);

        if (!url.userName().isEmpty() && !url.password().isEmpty()) 
        {
            QString authstring = url.userName() + ":" + url.password();
            QString auth = QCodecs::base64Encode(authstring.toLocal8Bit());

            hdr += "Authorization: Basic " + auth + "\r\n";
        }

        hdr += QString("TE: trailers\r\n"
                       "Icy-Metadata: 1\r\n"
                       "\r\n");

        LOG(VB_NETWORK, LOG_INFO, QString("ShoutCastRequest: '%1'").arg(hdr));

        m_data = hdr.toAscii();
    }
Exemple #25
0
void Login::login()
{
	QRegExp emailRegExp("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9]"
		"[\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$");

	if( !emailRegExp.exactMatch( ui.emailEdit->text() ) )
	{
		QMessageBox::warning(this, tr("Login Error"), tr("You must enter a "
			"valid email address."));

		return;
	}

	QString pass = ui.passwordEdit->text();
	QRegExp passMatcher("[a-zA-Z0-9]{6,}");

	if( !passMatcher.exactMatch(pass) )
	{
		QMessageBox::warning(this, tr("Login Error"), tr("Invalid password. "
			"Passwords can only contain a-z, A-Z, and 0-9 and must be at least 6 "
			"characters long"));

		return;
	}

	QUrl url = settings->url();
	QString backend_path = QFileInfo( url.path() ).dir().path();
	if(backend_path == "/")
		url.setPath("/register.php");
	else
		url.setPath(backend_path + "/register.php");

	mRegistration = new registration;
	mRegistration->loadValidationImage(url);

	connect(mRegistration, SIGNAL(validationImage(const QPixmap&, const QString&)),
		this, SLOT(validationImage(const QPixmap&, const QString&)));

	setEnabled(false);
}
Exemple #26
0
QUrl Account::concatUrlPath(const QUrl &url, const QString &concatPath,
                            const QList< QPair<QString, QString> > &queryItems)
{
    QString path = url.path();
    if (! concatPath.isEmpty()) {
        // avoid '//'
        if (path.endsWith('/') && concatPath.startsWith('/')) {
            path.chop(1);
        } // avoid missing '/'
        else if (!path.endsWith('/') && !concatPath.startsWith('/')) {
            path += QLatin1Char('/');
        }
        path += concatPath; // put the complete path together
    }

    QUrl tmpUrl = url;
    tmpUrl.setPath(path);
    if( queryItems.size() > 0 ) {
        tmpUrl.setQueryItems(queryItems);
    }
    return tmpUrl;
}
Exemple #27
0
bool VideoShape::loadOdfFrameElement(const KoXmlElement &element, KoShapeLoadingContext &context)
{
    /* the loading of the attributes might set the event actions which removes the m_videoEventAction
     * when there are other eventactions for the shape. Therefore we need to add it again. It is no
     * problem to add it again as internally a set is used and so it is not problematic when it is 
     * already set. */
    addEventAction(m_videoEventAction);

    if (m_videoCollection) {
        const QString href = element.attribute("href");
        // this can happen in case it is a presentation:placeholder
        if (!href.isEmpty()) {
            QUrl url = QUrl::fromUserInput(href);
            VideoData *data=0;

            if(href.startsWith("../")) {
                // file is outside store
                QUrl url = context.odfLoadingContext().store()->urlOfStore();
                QString path = url.path();
                if (!path.endsWith(QLatin1Char('/'))) {
                    path.append(QLatin1Char('/'));
                }
                path.append(href.mid(3));
                url.setPath(path);
                data = m_videoCollection->createExternalVideoData(url, false);
            } else if(!url.isRelative()) {
                // file is outside store and absolute
                data = m_videoCollection->createExternalVideoData(QUrl::fromUserInput(href), false);
            } else {
                // file is inside store
                KoStore *store = context.odfLoadingContext().store();
                data = m_videoCollection->createVideoData(href, store);
            }
            setUserData(data);
        }
    }

    return true;
}
Exemple #28
0
QUrl PathUtils::expandToLocalDataAbsolutePath(const QUrl& fileUrl) {
    QString path = fileUrl.path();

    if (path.startsWith("/~/")) {
        // this results in a qrc:// url...
        // return resourcesUrl(path.mid(3));

#ifdef Q_OS_MAC
        static const QString staticResourcePath = QCoreApplication::applicationDirPath() + "/../Resources/";
#elif defined (ANDROID)
        static const QString staticResourcePath =
            QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/resources/";
#else
        static const QString staticResourcePath = QCoreApplication::applicationDirPath() + "/resources/";
#endif
        path.replace(0, 3, staticResourcePath);
        QUrl expandedURL = QUrl::fromLocalFile(path);
        return expandedURL;
    }

    return fileUrl;
}
void jewelryUpdate::requestHttp(QUrl url)
{
    qDebug() <<url;
    QFileInfo info(url.path());
    QString fileName(info.fileName());
    if (fileName.isEmpty())
    {
      QMessageBox::critical(this, "系统消息", "版本文件错误或者丢失,请向程序开发人员联系!");
      return;
    }
    m_file = new QFile(fileName);
    if (!m_file->open(QIODevice::WriteOnly))
    {
      delete m_file;
      m_file = 0;
      return;
    }
    m_reply = m_manager.get(QNetworkRequest(url));
    connect(m_reply,SIGNAL(finished()),this,SLOT(httpFinished())); //更新完成后
    connect(m_reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead())); //有可用数据时
    connect(m_reply,SIGNAL(downloadProgress(qint64,qint64)), this,SLOT(updateDataReadProgress(qint64,qint64)));//更新进度条
}
Exemple #30
0
void
SmugMug::WebService::imageDownload (const QString &ImageUrl) {

    if (!_downloadId) {

        if (_downloadBuffer.open (QIODevice::WriteOnly)) {

            QUrl url (ImageUrl);

            _downloadAborted = false;
            _downloadHttp.setHost (url.host (), url.port (80));
            _downloadId = _downloadHttp.get (url.path (), &_downloadBuffer);

            qDebug () << "imageDownload:" << _downloadId << url.toString ();

            if (_downloadId) {

                emit imageDownloadStarted ();
            }
        }
    }
}