/**
 * @brief Constructs UserStore object.
 * @param host
 *   www.evernote.com or sandbox.evernote.com
 * @param authenticationToken
 *   This token that will be used as the default token.
 */
qevercloud::UserStore::UserStore(QString host, QString authenticationToken, QObject *parent): QObject(parent)
{
    QUrl url;
    url.setScheme("https");
    url.setHost(host);
    url.setPath("/edam/user");
    url_ = url.toString(QUrl::StripTrailingSlash);
    setAuthenticationToken(authenticationToken);
}
Exemple #2
0
const QUrl AddressManager::currentAddress() const {
    QUrl hifiURL;
    
    hifiURL.setScheme(HIFI_URL_SCHEME);
    hifiURL.setHost(_rootPlaceName);
    hifiURL.setPath(currentPath());
    
    return hifiURL;
}
void TsDataRetrieverFTP::TestFailUriInvalid()
{
  try
  {
    QUrl url;
    url.setHost("ftp.dgi.inpe.br");
    url.setPath("/operacao/");
    url.setScheme("FTP");
    url.setPort(21);
    url.setUserName("queimadas");
    url.setPassword("inpe_2012");

    curl_global_init(CURL_GLOBAL_ALL);

    //DataProvider information
    terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider();
    terrama2::core::DataProviderPtr dataProviderPtr(dataProvider);
    dataProvider->uri = url.url().toStdString();
    dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT;
    dataProvider->dataProviderType = "FTP";
    dataProvider->active = true;

    //empty filter
    terrama2::core::Filter filter;

    MockCurlWrapper mock_;

    ON_CALL(mock_, verifyURL(_)).WillByDefault(Return(CURLE_COULDNT_RESOLVE_HOST));

    try
    {
      terrama2::core::DataRetrieverFTP retrieverFTP(dataProviderPtr, std::move(mock_));

      QFAIL("Exception expected!");
    }
    catch(const terrama2::core::DataRetrieverException& e)
    {

    }

    curl_global_cleanup();

  }
  catch(const terrama2::Exception& e)
  {
    QFAIL(boost::get_error_info< terrama2::ErrorDescription >(e)->toStdString().c_str());
  }

  catch(...)
  {
    QFAIL("Unexpected exception!");
  }

  return;

}
void Wikipedia::getTranslation()
{
    if (langCode().isEmpty() || entry().isEmpty()) {
        return;
    }

    QSettings s;
    QString lang = s.value(QStringLiteral("display/language")).toString().left(2).toUpper();
    if (lang.isEmpty() || (lang == QLatin1String("C"))) {
        lang = QLocale::system().name().left(2);
    }

    QUrl wpURL;
    wpURL.setScheme(QStringLiteral("https"));


    if (lang == langCode()) {
        wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(langCode()));
        wpURL.setPath(QStringLiteral("/wiki/%1").arg(entry()));
    } else {

        QString enFallback;

        QMap<QString, QString> interWiki = reqTranslations(langCode(), entry());
        if (interWiki.contains(QStringLiteral("en"))) {
            enFallback = interWiki.value(QStringLiteral("en"));
        }

        while (!interWiki.contains(lang) && (interWiki[QStringLiteral("cont")] != QStringLiteral(""))) {

            interWiki = reqTranslations(langCode(), entry(), interWiki[QStringLiteral("cont")]);

            if (interWiki.contains(QStringLiteral("en"))) {
                enFallback = interWiki.value(QStringLiteral("en"));
            }
        }

        if (interWiki.contains(lang)) {
            wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(lang));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(interWiki[lang]));
        } else if (!enFallback.isEmpty()) {
            wpURL.setHost(QStringLiteral("en.wikipedia.org"));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(enFallback));
        } else {
            wpURL.setHost(QStringLiteral("%1.wikipedia.org").arg(langCode()));
            wpURL.setPath(QStringLiteral("/wiki/%1").arg(entry()));
        }

#ifdef QT_DEBUG
        qDebug() << "Wikipedia URL: " << wpURL;
#endif

    }

    setUrl(wpURL);
}
void SidebarPrivate::linkClickedFinished()
{
    QNetworkReply * reply = static_cast< QNetworkReply * >(sender());

    QString target = reply->property("__target").toString();
    QVariant redirectsVariant = reply->property("__redirects");
    int redirects = redirectsVariant.isNull() ? 20 : redirectsVariant.toInt();

    // Redirect?
    QUrl redirectedUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    if (redirectedUrl.isValid())
    {
        if (redirectedUrl.isRelative())
        {
            QUrl oldUrl = reply->url();
            redirectedUrl.setScheme(oldUrl.scheme());
            redirectedUrl.setAuthority(oldUrl.authority());
        }
        if (redirects > 0)
        {
            QNetworkRequest request = reply->request();
            request.setUrl(redirectedUrl);
            QNetworkReply * reply = networkAccessManager()->get(request);
            reply->setProperty("__target", target);
            connect(reply, SIGNAL(finished()), this, SLOT(linkClickedFinished()));
        }
        else
        {
            // TOO MANY REDIRECTS
        }
        reply->deleteLater();
        return;
    }

    // Check headers... if PDF then launch a new window, otherwise give it to the OS
    QString contentType(reply->header(QNetworkRequest::ContentTypeHeader).toString());
    if (contentType.contains("application/pdf")) {
        emit urlRequested(reply->request().url(), "tab");
    } else {
        QUrl href(reply->request().url());
        if (href.isValid()) {
            if (href.scheme() == "http" || href.scheme() == "https") {
                if (target == "sidebar") {
                    webView->setUrl(href);
                    slideLayout->push("web");
                    return;
                }
            }

            QDesktopServices::openUrl(href);
        }
        // FIXME error
    }

    reply->deleteLater();
}
Exemple #6
0
QUrl Session::url(const QString& path) const
{
    QUrl url;
    url.setScheme("http");
    url.setHost(m_host);
    url.setPort(EDAM_PORT);
    QString uid = m_data.getProperty("Uid").toString();
    url.setPath(QString("/shard/%1/%2").arg(uid).arg(path));
    return url;
}
Exemple #7
0
QString HelpBrowser::parseUrl(const QString &str)
{
    if (!str.startsWith("gfile:"))
        return str;

    QString path = str.mid(6);
    QUrl url = QUrl::fromLocalFile(path);
    url.setScheme("gfile");
    return url.toString();
}
QScriptValue QWebSecurityOriginPointerToScriptValue(QScriptEngine *engine, QWebSecurityOrigin* const &item)
{
  QScriptValue obj = engine->newObject();
  QUrl url = QUrl();
  url.setHost(item->host());
  url.setPort(item->port());
  url.setScheme(item->scheme());
  obj.setProperty("_url", qPrintable(url.toString()));
  return obj;
}
Exemple #9
0
QUrl QHelpDBReader::buildQUrl(const QString &ns, const QString &folder,
                              const QString &relFileName, const QString &anchor) const
{
    QUrl url;
    url.setScheme(QLatin1String("qthelp"));
    url.setAuthority(ns);
    url.setPath(QLatin1Char('/') + folder + QLatin1Char('/') + relFileName);
    url.setFragment(anchor);
    return url;
}
QUrl SessionListingModel::sessionUrl(int index) const
{
	const Session &s = m_filtered.at(index);
	QUrl url;
	url.setScheme("drawpile");
	url.setHost(s.host);
	if(s.port != DRAWPILE_PROTO_DEFAULT_PORT)
		url.setPort(s.port);
	url.setPath("/" + s.id);
	return url;
}
Exemple #11
0
void SpotifyIO::_makeLandingPageRequest()
{
    qDebug() << "tokens request";
    QUrl url;
    url.setScheme("https");
    url.setHost(authServer);
    url.setPath(landingUrl);
    QNetworkRequest req(url);
    req.setHeader(QNetworkRequest::UserAgentHeader, userAgent);
    QObject::connect(nam->get(req), SIGNAL(finished()), this, SLOT(landingFilished()));
}
Exemple #12
0
// Format an URL for a XML request
static inline QUrl xmlRequest(const QString &host, const QString &request, int page = -1)
{
    QUrl url;
    url.setScheme(QLatin1String("http"));
    url.setHost(host);
    url.setPath(QLatin1Char('/') + request);
    url.addQueryItem(QLatin1String("format"), QLatin1String("xml"));
    if (page >= 0)
        url.addQueryItem(QLatin1String("page"), QString::number(page));
    return url;
}
Exemple #13
0
QSizeF EpsRenderer::renderToResource(QTextDocument *document, const QUrl &url)
{
    QSizeF size;
    QImage img = renderToImage(url, &size);

    QUrl internal = url;
    internal.setScheme(QLatin1String("internal"));
    qDebug() << internal;
    document->addResource(QTextDocument::ImageResource, internal, QVariant(img) );
    return size;
}
Exemple #14
0
QString WaveUrl::toString() const
{
    QUrl url;
    url.setScheme("wave");
    url.setHost(m_waveletDomain);
    if ( m_waveletDomain == m_waveDomain)
        url.setPath( "/" + m_waveId + "/" + m_waveletId );
    else
        url.setPath( "/" + m_waveDomain + "$" + m_waveId + "/" + m_waveletId );
    return url.toString();
}
Exemple #15
0
QUrl PIMSearchStore::constructUrl(const Xapian::docid &docid)
{
    QUrl url;
    url.setScheme(QStringLiteral("akonadi"));

    QUrlQuery query;
    query.addQueryItem(QStringLiteral("item"), QString::number(docid));
    url.setQuery(query);

    return url;
}
static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy)
{
    QByteArray result;
    QUrl copy = url;
    bool isEncrypted = copy.scheme().toLower() == QLatin1String("https");
    copy.setPort(copy.port(isEncrypted ? 443 : 80));
    result = copy.toEncoded(QUrl::RemoveUserInfo | QUrl::RemovePath |
                            QUrl::RemoveQuery | QUrl::RemoveFragment);

#ifndef QT_NO_NETWORKPROXY
    if (proxy && proxy->type() != QNetworkProxy::NoProxy) {
        QUrl key;

        switch (proxy->type()) {
        case QNetworkProxy::Socks5Proxy:
            key.setScheme(QLatin1String("proxy-socks5"));
            break;

        case QNetworkProxy::HttpProxy:
        case QNetworkProxy::HttpCachingProxy:
            key.setScheme(QLatin1String("proxy-http"));
            break;

        default:
            break;
        }

        if (!key.scheme().isEmpty()) {
            key.setUserName(proxy->user());
            key.setHost(proxy->hostName());
            key.setPort(proxy->port());
            key.setEncodedQuery(result);
            result = key.toEncoded();
        }
    }
#else
    Q_UNUSED(proxy)
#endif

    return "http-connection:" + result;
}
Exemple #17
0
void KgProtocols::loadProtocols()
{
    QStringList protocols = KProtocolInfo::protocols();
    protocols.sort();

    foreach(const QString &protocol, protocols) {
        QUrl u;
        u.setScheme(protocol);
        if(KProtocolManager::inputType(u) == KProtocolInfo::T_FILESYSTEM) {
            protocolList->addItem(protocol);
        }
    }
QUrl QQuickControlSettings::style() const
{
    QUrl result;
    QString path = styleFilePath();
    if (fromResource(path)) {
        result.setScheme("qrc");
        path.remove(0, 1); // remove ':' prefix
        result.setPath(path);
    } else
        result = QUrl::fromLocalFile(path);
    return result;
}
Exemple #19
0
void FileBrowser::viewGodoc()
{
    QDir dir = contextDir();
    LiteApi::IGolangDoc *doc = LiteApi::findExtensionObject<LiteApi::IGolangDoc*>(m_liteApp,"LiteApi.IGolangDoc");
    if (doc) {
        QUrl url;
        url.setScheme("pdoc");
        url.setPath(dir.path());
        doc->openUrl(url);
        doc->activeBrowser();
    }
}
Exemple #20
0
QUrl Client::sessionUrl(bool includeUser) const
{
	if(!isConnected())
		return QUrl();

	QUrl url = static_cast<const TcpServer*>(_server)->url();
	url.setScheme("drawpile");
	if(!includeUser)
		url.setUserInfo(QString());
	url.setPath("/" + sessionId());
	return url;
}
Exemple #21
0
WebFetch::WebFetch(QUrl url, QObject *obj, const char *slot) : QObject(), qoObject(obj), cpSlot(slot) {
	url.setScheme(QLatin1String("http"));

	// Fix in case the regional host is broken
	url.setHost(g.s.qsRegionalHost);
	if (url.host() != g.s.qsRegionalHost)
		url.setHost(QLatin1String("mumble.info"));

	qnr = Network::get(url);
	connect(qnr, SIGNAL(finished()), this, SLOT(finished()));
	connect(this, SIGNAL(fetched(QByteArray,QUrl,QMap<QString,QString>)), obj, slot);
}
Exemple #22
0
QString DNSUpdater::getUpdateUrl() const
{
    QUrl url;
#ifdef QT_NO_OPENSSL
    url.setScheme("http");
#else
    url.setScheme("https");
#endif
    url.setUserName(m_username);
    url.setPassword(m_password);

    Q_ASSERT(!m_lastIP.isNull());
    // Service specific
    switch(m_service) {
    case DNS::DYNDNS:
        url.setHost("members.dyndns.org");
        break;
    case DNS::NOIP:
        url.setHost("dynupdate.no-ip.com");
        break;
    default:
        qWarning() << "Unrecognized Dynamic DNS service!";
        Q_ASSERT(0);
    }
    url.setPath("/nic/update");

#ifndef QBT_USES_QT5
    url.addQueryItem("hostname", m_domain);
    url.addQueryItem("myip", m_lastIP.toString());
#else
    QUrlQuery urlQuery(url);
    urlQuery.addQueryItem("hostname", m_domain);
    urlQuery.addQueryItem("myip", m_lastIP.toString());
    url.setQuery(urlQuery);
#endif
    Q_ASSERT(url.isValid());

    qDebug() << Q_FUNC_INFO << url.toString();
    return url.toString();
}
Exemple #23
0
void QtWebKitWebWidget::setUrl(const QUrl &url, bool typed)
{
	if (url.scheme() == QLatin1String("javascript"))
	{
		evaluateJavaScript(url.path());

		return;
	}

	if (!url.fragment().isEmpty() && url.matches(getUrl(), (QUrl::RemoveFragment | QUrl::StripTrailingSlash | QUrl::NormalizePathSegments)))
	{
		m_webView->page()->mainFrame()->scrollToAnchor(url.fragment());

		return;
	}

	m_isTyped = typed;

	if (url.isValid() && url.scheme().isEmpty() && !url.path().startsWith('/'))
	{
		QUrl httpUrl = url;
		httpUrl.setScheme(QLatin1String("http"));

		m_webView->setUrl(httpUrl);
	}
	else if (url.isValid() && (url.scheme().isEmpty() || url.scheme() == "file"))
	{
		QUrl localUrl = url;
		localUrl.setScheme(QLatin1String("file"));

		m_webView->setUrl(localUrl);
	}
	else
	{
		m_webView->setUrl(url);
	}

	notifyTitleChanged();
	notifyIconChanged();
}
Exemple #24
0
void KateSyntaxTest::testSyntaxHighlighting()
{
    /**
     * get current test case
     */
    QFETCH(QString, hlTestCase);

    /**
     * create a document with a view to be able to export stuff
     */
    KTextEditor::DocumentPrivate doc;
    auto view = static_cast<KTextEditor::ViewPrivate*>(doc.createView(Q_NULLPTR));

    /**
     * load the test case
     * enforce UTF-8 to avoid locale problems
     */
    QUrl url;
    url.setScheme(QLatin1String("file"));
    url.setPath(hlTestCase);
    doc.setEncoding(QStringLiteral("UTF-8"));
    QVERIFY(doc.openUrl(url));

    /**
     * compute needed dirs
     */
    const QFileInfo info(hlTestCase);
    const QString resultDir(info.absolutePath() + QLatin1String("/results/"));
    const QString currentResult(resultDir + info.fileName() + QLatin1String(".current.html"));
    const QString referenceResult(resultDir + info.fileName() + QLatin1String(".reference.html"));

    /**
     * export the result
     */
    view->exportHtmlToFile(currentResult);

    /**
     * verify the result against reference
     */
    QProcess diff;
    diff.setProcessChannelMode(QProcess::MergedChannels);
    QStringList args;
    args << QLatin1String("-u") << (referenceResult) << (currentResult);
    diff.start(QLatin1String("diff"), args);
    diff.waitForFinished();
    QByteArray out = diff.readAllStandardOutput();
    if (!out.isEmpty()) {
        printf("DIFF:\n");
        QList<QByteArray> outLines = out.split('\n');
        Q_FOREACH(const QByteArray &line, outLines) {
            printf("%s\n", qPrintable(line));
        }
Exemple #25
0
void SpotifyIO::onTextMessageReceived(const QString &message)
{
    QVariantMap json = QJsonDocument::fromJson(message.toUtf8()).toVariant().toMap();
    if (json.contains("message")) {
        qDebug() << message;
        QStringList args = json["message"].toStringList();
        if (args[0] == "do_work") {
            QScriptEngine engine;
            QScriptValue replyFunction = engine.newFunction(reply);
            engine.globalObject().setProperty("reply", replyFunction);
            QScriptValue value = engine.evaluate(args[1]);
            sendCommand("sp/work_done", QVariantList() << value.toString());
        }
        else if (args[0] == "ping_flash2") {
            QString ping = args[1];
            //QString pong = _constructPong(ping);
            //sendCommand("sp/pong_flash2", QVariantList() << pong);
            ping = ping.split(" ").join("-");
            QUrl url;
            url.setScheme("http");
            url.setHost("ping-pong.spotify.nodestuff.net");
            url.setPath("/" + ping);
            QNetworkRequest req(url);
            req.setHeader(QNetworkRequest::UserAgentHeader, userAgent);
            QObject::connect(nam->get(req), SIGNAL(finished()), this, SLOT(onPongReply()));
        }
        else if (args[0] == "login_complete") {
            sendCommand("sp/log", QVariantList() << 41 << 1 << 0 << 0 << 0 << 0);
            sendCommand("sp/user_info", QVariantList(), this, COMMANDCALLBACK(onUserInfo));

            getPlaylists(username, this, COMMANDCALLBACK(onMyPlaylists));

            _state = LoggedInState;
            Q_EMIT stateChanged();

            heartbeat->start();
        }
        else {
            qWarning() << args[0] << "NOT IMPLEMENTED!";
        }
    }
    else if (json.contains("id")) {
        int id = json["id"].toInt();
        if (callbacks.contains(id)) {
            //qDebug() << "have callback for" << id << callbacks[id];
            QMetaObject::invokeMethod(receivers.take(id), callbacks.take(id), Q_ARG(QVariant, json["result"]));
        }
        else {
            qDebug() << message;
        }
    }
}
Exemple #26
0
/*!
  \a url points to the new MMS server.

  \sa mmsServer()
*/
void QWapAccount::setMmsServer( const QUrl& url )
{
    QUrl server;
    if ( !url.host().isEmpty() )
        server.setHost( url.host() );
    if ( !url.scheme().isEmpty() )
        server.setScheme( url.scheme() );
    if ( !url.path().isEmpty() )
        server.setPath( url.path() );

    d->conf->setValue( QLatin1String("MMS/Server"), server.toString() );
    d->conf->setValue( QLatin1String("MMS/Port"), url.port() );
}
bool SystemEditor::startEditor(const QString &fileName, QString *errorMessage)
{
    Q_UNUSED(errorMessage)
    QUrl url;
    url.setPath(fileName);
    url.setScheme(QLatin1String("file"));
    if (!QDesktopServices::openUrl(url)) {
        if (errorMessage)
            *errorMessage = tr("Could not open url %1.").arg(url.toString());
        return false;
    }
    return true;
}
Exemple #28
0
QUrl
lastfm::UrlBuilder::url() const
{
    QUrl url;
    url.setScheme( "http" );
    url.setHost( host() );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
    url.setPath( d->path );
#else
    url.setEncodedPath( d->path );
#endif
    return url;
}
QUrl ServicesDbTestUtils::getDbModifyUrl()
{
  // read the DB values from the DB config file.
  Settings s = _readDbConfig();
  QUrl result;
  result.setScheme("hootapidb");
  result.setHost(s.get("DB_HOST").toString());
  result.setPort(s.get("DB_PORT").toInt());
  result.setUserName(s.get("DB_USER").toString());
  result.setPassword(s.get("DB_PASSWORD").toString());
  result.setPath("/" + s.get("DB_NAME").toString() + "/testMap");
  return result;
}
Exemple #30
0
QUrl SM_QDropbox::authorizeLink()
{
    QUrl link;
    link.setScheme("https");
    link.setHost("www.dropbox.com");
    link.setPath(QString("/%1/oauth/authorize")
                 .arg(_version.left(1)));

    QUrlQuery query;
    query.addQueryItem("oauth_token", oauthToken);
    link.setQuery(query);
    return link;
}