예제 #1
0
void CAppButton::setIcon(const QString on,const QString off,bool bPaint)
{
    QImage img_on,img_off;
    if(bPaint)
    {
        //if(!img_on.load(on))
        {
            QUrl qurl(on);
            img_on.load(":images/app_on.png");
            img_on = img_on.scaled(width(),height(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            QImage onImage(qurl.path());
            //onImage = onImage.scaled(height()*0.4,height()*0.4);
            do
            {
                QPainter painter(&img_on);
                QRect irect=onImage.rect();
                QRect orect=img_on.rect();
                int sx=(orect.width()-irect.width())/2;
                int sy=(orect.height()-irect.height())/4;
                painter.drawImage(sx,sy,onImage,0,0);
            }while(0);
        }

        //if(!img_off.load(off))
        {
            QUrl qurl(off);
            img_off.load(":images/app_off.png");
            img_off = img_off.scaled(width(),height(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            QImage offImage(qurl.path());
            //offImage = offImage.scaled(width()*0.6,height()*0.6,Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
            do{
                QPainter painter(&img_off);
                QRect irect=offImage.rect();
                QRect orect=img_off.rect();
                int sx=(orect.width()-irect.width())/2;
                int sy=(orect.height()-irect.height())/4;
                painter.drawImage(sx,sy,offImage);
            }while(0);
        }
    }
    else
    {
        img_on.load(on);
        img_off.load(off);
    }

    MenuButton::setIcon(img_on,img_off);
}
예제 #2
0
QString MetadataDownload::getMXMLPath(QString filename)
{
    QString ret;
    QString xmlname;
    QUrl qurl(filename);
    QString ext = QFileInfo(qurl.path()).suffix();
    xmlname = filename.left(filename.size() - ext.size()) + "mxml";
    QUrl xurl(xmlname);

    if (xmlname.startsWith("myth://"))
    {
        if (qurl.host().toLower() != gCoreContext->GetHostName().toLower() &&
            (qurl.host() != gCoreContext->GetSettingOnHost("BackendServerIP",
                                               gCoreContext->GetHostName())))
        {
            if (RemoteFile::Exists(xmlname))
                ret = xmlname;
        }
        else
        {
            StorageGroup sg;
            QString fn = sg.FindFile(xurl.path());
            if (!fn.isEmpty() && QFile::exists(fn))
                ret = xmlname;
        }
    }
    else
    {
        if (QFile::exists(xmlname))
            ret = xmlname;
    }

    return ret;
}
예제 #3
0
QString getDownloadFilename(QString title, QString url)
{
    QString fileprefix = GetConfDir();

    QDir dir(fileprefix);
    if (!dir.exists())
        dir.mkdir(fileprefix);

    fileprefix += "/cache/metadata-thumbcache";

    dir = QDir(fileprefix);
    if (!dir.exists())
        dir.mkdir(fileprefix);

    QByteArray titlearr(title.toLatin1());
    quint16 titleChecksum = qChecksum(titlearr.data(), titlearr.length());
    QByteArray urlarr(url.toLatin1());
    quint16 urlChecksum = qChecksum(urlarr.data(), urlarr.length());
    QUrl qurl(url);
    QString ext = QFileInfo(qurl.path()).suffix();
    QString basefilename = QString("thumbnail_%1_%2.%3")
                           .arg(QString::number(urlChecksum))
                           .arg(QString::number(titleChecksum)).arg(ext);

    QString outputfile = QString("%1/%2").arg(fileprefix).arg(basefilename);

    return outputfile;
}
예제 #4
0
/**
  * Sends result(s) to the server in xml format.
  * Send authentication information in the header.
  */
void HttpClient::sendResultXml(QString category, double result)
{
    qDebug() << "_sendResultXml";
    qDebug() << category;

    QBuffer *xmlbuffer = new QBuffer();

    QUrl qurl("http://www.speedfreak-app.com/results/update/" + category);

    qDebug() << qurl.toString();
    QNetworkRequest request(qurl);
    QNetworkReply *currentDownload;

    xmlbuffer->open(QBuffer::ReadWrite);
    myXmlwriter->writeResult(xmlbuffer, result);
    qDebug() << "carmainwindow: xmlbuffer->data(): " << xmlbuffer->data();

    QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
    credentials = "Basic " + credentials.toAscii().toBase64();
    request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());

    currentDownload = netManager->post(request, ("xml=" + xmlbuffer->data()));
    connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfResult()));
    //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));

    //Indicating user
    if(myMainw->accstart->accRealTimeDialog->resultDialog)
        myMainw->accstart->accRealTimeDialog->resultDialog->setLabelInfoToUser("Sending result to server");

    xmlbuffer->close();
}
예제 #5
0
파일: rsseditor.cpp 프로젝트: Cougar/mythtv
void RSSEditPopup::parseAndSave(void)
{
    if (m_editing)
    {
        QString title = m_titleEdit->GetText();
        QString desc = m_descEdit->GetText();
        QString author = m_authorEdit->GetText();
        QString link = m_urlEdit->GetText();
        QString filename = m_thumbImage->GetFilename();

        bool download;
        if (m_download->GetCheckState() == MythUIStateType::Full)
            download = true;
        else
            download = false;

        removeFromDB(m_urlText, VIDEO_PODCAST);

        if (insertInDB(new RSSSite(title, filename, VIDEO_PODCAST,
                desc, link, author, download, QDateTime::currentDateTime())))
            emit saving();
        Close();
    }
    else
    {
        m_manager = new QNetworkAccessManager();
        QUrl qurl(m_urlEdit->GetText());

        m_reply = m_manager->get(QNetworkRequest(qurl));

        connect(m_manager, SIGNAL(finished(QNetworkReply*)), this,
                           SLOT(slotCheckRedirect(QNetworkReply*)));
    }
}
예제 #6
0
void MythUIFileBrowser::SetPath(const QString &startPath)
{
    if (startPath.startsWith("myth://"))
    {
        m_isRemote = true;

        QUrl qurl(startPath);

        if (!qurl.path().isEmpty())
        {
            // Force browing of remote SG's to start at their root
            m_baseDirectory = gCoreContext->GenMythURL(qurl.host(),
                                                       0,
                                                       "",
                                                       qurl.userName());

        }
        else
        {
            m_baseDirectory = startPath;

            if (m_baseDirectory.endsWith("/"))
                m_baseDirectory.remove(m_baseDirectory.length() - 1, 1);
        }

        m_subDirectory = "";
        m_storageGroupDir = "";
    }
    else
    {
        m_isRemote = false;
        m_baseDirectory = "";
        m_subDirectory = startPath;
    }
}
예제 #7
0
void webview_seturl(void* p, const char* url, int urllen)
{
    GET_WEB_PTR(web, p)
    QString urlstr = QString::fromUtf8(url, urllen);
    QUrl qurl(urlstr);
    web->setUrl(qurl);
}
예제 #8
0
파일: goqml.cpp 프로젝트: chai2010/qml
void componentSetData(QQmlComponent_ *component, const char *data, int dataLen, const char *url, int urlLen)
{
    QByteArray qdata(data, dataLen);
    QByteArray qurl(url, urlLen);
    QString qsurl = QString::fromUtf8(qurl);
    reinterpret_cast<QQmlComponent *>(component)->setData(qdata, qsurl);
}
예제 #9
0
QString MetadataDownload::getNFOPath(QString filename)
{
    QString ret;
    QString nfoname;
    QUrl qurl(filename);
    QString ext = QFileInfo(qurl.path()).suffix();
    nfoname = filename.left(filename.size() - ext.size()) + "nfo";
    QUrl nurl(nfoname);

    if (nfoname.startsWith("myth://"))
    {
        if (qurl.host().toLower() != gCoreContext->GetHostName().toLower() &&
            (!gCoreContext->IsThisHost(qurl.host())))
        {
            if (RemoteFile::Exists(nfoname))
                ret = nfoname;
        }
        else
        {
            StorageGroup sg;
            QString fn = sg.FindFile(nurl.path());
            if (!fn.isEmpty() && QFile::exists(fn))
                ret = nfoname;
        }
    }
    else
    {
        if (QFile::exists(nfoname))
            ret = nfoname;
    }

    return ret;
}
예제 #10
0
bool MythUIFileBrowser::GetRemoteFileList(const QString &url,
                                          const QString &sgDir,
                                          QStringList &list)
{
    QUrl qurl(url);
    QString storageGroup = qurl.userName();

    list.clear();

    if (storageGroup.isEmpty())
        storageGroup = "Default";

    list << "QUERY_SG_GETFILELIST";
    list << qurl.host();
    list << storageGroup;

    QString path = sgDir + qurl.path();

    if (!qurl.fragment().isEmpty())
        path += "#" + qurl.fragment();

    list << path;
    list << "0";

    bool ok = gCoreContext->SendReceiveStringList(list);

    if ((list.size() == 1) && (list[0] == "EMPTY LIST"))
        list.clear();

    return ok;

}
예제 #11
0
/**
 * \fn UPNPScanner::AddServer(const QString&, const QString&)
 *  Adds the server identified by usn and reachable via url to the list of
 *  known media servers and schedules an update to initiate a connection.
 */
void UPNPScanner::AddServer(const QString &usn, const QString &url)
{
    if (url.isEmpty())
    {
        RemoveServer(usn);
        return;
    }

    // sometimes initialisation is too early and m_masterHost is empty
    if (m_masterHost.isEmpty())
    {
        m_masterHost = gCoreContext->GetSetting("MasterServerIP");
        m_masterPort = gCoreContext->GetSettingOnHost("BackendStatusPort",
                       m_masterHost, "6544").toInt();
    }

    QUrl qurl(url);
    if (qurl.host() == m_masterHost && qurl.port() == m_masterPort)
    {
        LOG(VB_UPNP, LOG_INFO, LOC + "Ignoring master backend.");
        return;
    }

    m_lock.lock();
    if (!m_servers.contains(usn))
    {
        m_servers.insert(usn, new MediaServer(url));
        LOG(VB_GENERAL, LOG_INFO, LOC + QString("Adding: %1").arg(usn));
        ScheduleUpdate();
    }
    m_lock.unlock();
}
/// <summary>
/// Execute http get request
/// </summary>
/// <param name="url">url for the http get request</param>
/// <returns>string of the http get request or empty string in case of failure</returns>
string VulkanDatabase::httpGet(string url)
{
    manager = new QNetworkAccessManager(NULL);

    QUrl qurl(QString::fromStdString(url));

    if (dbLogin)
    {
        qurl.setUserName(dbUser);
        qurl.setPassword(dbPass);
    }

    QNetworkReply* reply = manager->get(QNetworkRequest(qurl));

    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();

    if (reply->error() == QNetworkReply::NoError)
    {
        QByteArray bytes = reply->readAll();
        QString replyStr(bytes);
        delete(manager);
        return replyStr.toStdString();
    }
    else
    {
        QString err;
        err = reply->errorString();
        delete(manager);
        return "";
    }
}
예제 #13
0
/**
  * Request the users list of all users from the server.
  * Send authentication information in the header.
  */
void HttpClient::requestUsers()
{  
    qDebug() << "_requestUsers" ;

    QUrl qurl("http://www.speedfreak-app.com/users/list_all");
    qDebug() << qurl.toString();
    QNetworkRequest request(qurl);
    QNetworkReply *currentDownload;

    QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
    credentials = "Basic " + credentials.toAscii().toBase64();
    request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());

    currentDownload = netManager->post(request, ("data=" ));
    connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfUsers()));


    //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));

    //Indicating user
    if(myMainw->usersDialog)
        myMainw->usersDialog->setLabelInfoToUser("Reguesting users from server");

    //ackOfUsers();
}
예제 #14
0
void MFileInfo::init(QString fileName, QString sgDir, bool isDir,
                     qint64 size)
{
    m_fileName = fileName;
    m_isRemote = false;
    m_isParentDir = false;

    if (fileName.startsWith("myth://"))
    {
        QUrl qurl(fileName);
        m_hostName = qurl.host();
        m_storageGroup = qurl.userName();
        m_storageGroupDir = sgDir;
        m_subDir = qurl.path();

        if (!qurl.fragment().isEmpty())
            m_subDir += "#" + qurl.fragment();

        if (m_subDir.startsWith("/"))
            m_subDir.remove(0, 1);

        m_isRemote = true;

        m_isDir = isDir;
        m_isFile = !isDir;
        m_size = size;
    }

    if (!fileName.isEmpty())
        QFileInfo::setFile(fileName);
}
QString getDownloadFilename(VideoArtworkType type, MetadataLookup *lookup,
                            QString url)
{
    QString basefilename;
    QString title;
    QString inter;
    uint tracknum = lookup->GetTrackNumber();
    uint season = lookup->GetSeason();
    uint episode = lookup->GetEpisode();
    QString system = lookup->GetSystem();
    if (season > 0 || episode > 0)
    {
        title = lookup->GetTitle();
        if (title.contains("/"))
            title.replace("/", "-");
        if (title.contains("?"))
            title.replace("?", "");
        if (title.contains("*"))
            title.replace("*", "");
        inter = QString(" Season %1").arg(QString::number(season));
        if (type == kArtworkScreenshot)
            inter += QString("x%1").arg(QString::number(episode));
    }
    else if (lookup->GetType() == kMetadataVideo ||
             lookup->GetType() == kMetadataRecording)
        title = lookup->GetInetref();
    else if (lookup->GetType() == kMetadataGame)
        title = QString("%1 (%2)").arg(lookup->GetTitle())
                    .arg(lookup->GetSystem());

    if (tracknum > 0)
        inter = QString(" Track %1").arg(QString::number(tracknum));
    else if (!system.isEmpty())
        inter = QString(" (%1)").arg(system);

    QString suffix;
    QUrl qurl(url);
    QString ext = QFileInfo(qurl.path()).suffix();

    if (type == kArtworkCoverart)
        suffix = "_coverart";
    else if (type == kArtworkFanart)
        suffix = "_fanart";
    else if (type == kArtworkBanner)
        suffix = "_banner";
    else if (type == kArtworkScreenshot)
        suffix = "_screenshot";
    else if (type == kArtworkPoster)
        suffix = "_poster";
    else if (type == kArtworkBackCover)
        suffix = "_backcover";
    else if (type == kArtworkInsideCover)
        suffix = "_insidecover";
    else if (type == kArtworkCDImage)
        suffix = "_cdimage";

    basefilename = title + inter + suffix + "." + ext;

    return basefilename;
}
void transactionview::setmodel(walletmodel *model)
{
    this->model = model;
    if(model)
    {
        transactionproxymodel = new transactionfilterproxy(this);
        transactionproxymodel->setsourcemodel(model->gettransactiontablemodel());
        transactionproxymodel->setdynamicsortfilter(true);
        transactionproxymodel->setsortcasesensitivity(qt::caseinsensitive);
        transactionproxymodel->setfiltercasesensitivity(qt::caseinsensitive);

        transactionproxymodel->setsortrole(qt::editrole);

        transactionview->sethorizontalscrollbarpolicy(qt::scrollbaralwaysoff);
        transactionview->setmodel(transactionproxymodel);
        transactionview->setalternatingrowcolors(true);
        transactionview->setselectionbehavior(qabstractitemview::selectrows);
        transactionview->setselectionmode(qabstractitemview::extendedselection);
        transactionview->setsortingenabled(true);
        transactionview->sortbycolumn(transactiontablemodel::status, qt::descendingorder);
        transactionview->verticalheader()->hide();

        transactionview->setcolumnwidth(transactiontablemodel::status, status_column_width);
        transactionview->setcolumnwidth(transactiontablemodel::watchonly, watchonly_column_width);
        transactionview->setcolumnwidth(transactiontablemodel::date, date_column_width);
        transactionview->setcolumnwidth(transactiontablemodel::type, type_column_width);
        transactionview->setcolumnwidth(transactiontablemodel::amount, amount_minimum_column_width);

        columnresizingfixer = new guiutil::tableviewlastcolumnresizingfixer(transactionview, amount_minimum_column_width, minimum_column_width);

        if (model->getoptionsmodel())
        {
            // add third party transaction urls to context menu
            qstringlist listurls = model->getoptionsmodel()->getthirdpartytxurls().split("|", qstring::skipemptyparts);
            for (int i = 0; i < listurls.size(); ++i)
            {
                qstring host = qurl(listurls[i].trimmed(), qurl::strictmode).host();
                if (!host.isempty())
                {
                    qaction *thirdpartytxurlaction = new qaction(host, this); // use host as menu item label
                    if (i == 0)
                        contextmenu->addseparator();
                    contextmenu->addaction(thirdpartytxurlaction);
                    connect(thirdpartytxurlaction, signal(triggered()), mapperthirdpartytxurls, slot(map()));
                    mapperthirdpartytxurls->setmapping(thirdpartytxurlaction, listurls[i].trimmed());
                }
            }
        }

        // show/hide column watch-only
        updatewatchonlycolumn(model->havewatchonly());

        // watch-only signal
        connect(model, signal(notifywatchonlychanged(bool)), this, slot(updatewatchonlycolumn(bool)));
    }
}
예제 #17
0
void LinTORManager::retrieveTORItems(
  QTreeWidgetItem *treeItem)
{
  if (itemIDsReply)
  {
    // Already making an item IDs request.
    return;
  }

  QString collectionID;

  LinTORFolderItem *tfi = dynamic_cast<LinTORFolderItem *>(treeItem);

  if (tfi)
  {
    collectionID = tfi->getID();
  }
  else
  {
    LinTORSubscriptionItem *tsi =
      dynamic_cast<LinTORSubscriptionItem *>(treeItem);

    if (!tsi)
    {
      // Unable to parse tree item, report an error.
      return;
    }

    collectionID = tsi->getID();
  }

  QString itemIDsRequestString =
    "https://theoldreader.com/reader/api/0/stream/items/ids?output=json";

  // Need to determine how many items to pull over maximum:
  itemIDsRequestString += "&n=500";

  itemIDsRequestString += "&s=";
  itemIDsRequestString += collectionID;

  QUrl qurl(itemIDsRequestString);

  QNetworkRequest itemIDsRequest(qurl);

  itemIDsRequest.setRawHeader(
    "Authorization", authHeaderString.toAscii());

  itemIDsReply = qnam->get(itemIDsRequest);

  connect(
    itemIDsReply,
    SIGNAL(finished()),
    this,
    SLOT(parseItemIDs()));
}
예제 #18
0
void QQTextEdit::insertImg(const QString &url, const QString &path)
{
    QTextDocument *doc = document();
    QTextCursor cursor(doc);
    cursor.movePosition(QTextCursor::End);

    QImage img(path);
    QUrl qurl(url);
    doc->addResource(QTextDocument::ImageResource, qurl, img);
    cursor.insertImage(url);
}
예제 #19
0
QString getDownloadFilename(ArtworkType type, MetadataLookup *lookup,
                            QString url)
{
    QString basefilename;
    QString title;
    QString inter;
    uint tracknum = lookup->GetTrackNumber();
    uint season = lookup->GetSeason();
    uint episode = lookup->GetEpisode();
    QString system = lookup->GetSystem();
    if (season > 0 || episode > 0)
    {
        title = lookup->GetTitle();
        inter = QString(" Season %1").arg(QString::number(season));
        if (type == SCREENSHOT)
            inter += QString("x%1").arg(QString::number(episode));
    }
    else if (lookup->GetType() == VID)
        title = lookup->GetInetref();
    else if (lookup->GetType() == GAME)
        title = QString("%1 (%2)").arg(lookup->GetTitle())
                    .arg(lookup->GetSystem());

    if (tracknum > 0)
        inter = QString(" Track %1").arg(QString::number(tracknum));
    else if (!system.isEmpty())
        inter = QString(" (%1)").arg(system);

    QString suffix;
    QUrl qurl(url);
    QString ext = QFileInfo(qurl.path()).suffix();

    if (type == COVERART)
        suffix = "_coverart";
    else if (type == FANART)
        suffix = "_fanart";
    else if (type == BANNER)
        suffix = "_banner";
    else if (type == SCREENSHOT)
        suffix = "_screenshot";
    else if (type == POSTER)
        suffix = "_poster";
    else if (type == BACKCOVER)
        suffix = "_backcover";
    else if (type == INSIDECOVER)
        suffix = "_insidecover";
    else if (type == CDIMAGE)
        suffix = "_cdimage";

    basefilename = title + inter + suffix + "." + ext;

    return basefilename;
}
예제 #20
0
int mythdir_opendir(const char *dirname)
{
    LOG(VB_FILE, LOG_DEBUG, LOC + QString("mythdir_opendir(%1)").arg(dirname));

    int id = 0;
    if (strncmp(dirname, "myth://", 7))
    {
        DIR *dir = opendir(dirname);

        m_dirWrapperLock.lockForWrite();
        id = getNextDirID();
        m_localdirs[id] = dir;
        m_dirnames[id] = dirname;
        m_dirWrapperLock.unlock();
    }
    else
    {
        QStringList list;
        QUrl qurl(dirname);
        QString storageGroup = qurl.userName();

        list.clear();

        if (storageGroup.isEmpty())
            storageGroup = "Default";

        list << "QUERY_SG_GETFILELIST";
        list << qurl.host();
        list << storageGroup;

        QString path = qurl.path();
        if (!qurl.fragment().isEmpty())
            path += "#" + qurl.fragment();

        list << path;
        list << "1";

        bool ok = gCoreContext->SendReceiveStringList(list);

        if ((!ok) ||
            ((list.size() == 1) && (list[0] == "EMPTY LIST")))
            list.clear();

        m_dirWrapperLock.lockForWrite();
        id = getNextDirID();
        m_remotedirs[id] = list;
        m_remotedirPositions[id] = 0;
        m_dirnames[id] = dirname;
        m_dirWrapperLock.unlock();
    }

    return id;
}
예제 #21
0
파일: netutils.cpp 프로젝트: bwarden/mythtv
QString GetDownloadFilename(QString title, QString url)
{
    QByteArray urlarr(url.toLatin1());
    quint16 urlChecksum = qChecksum(urlarr.data(), urlarr.length());
    QByteArray titlearr(title.toLatin1());
    quint16 titleChecksum = qChecksum(titlearr.data(), titlearr.length());
    QUrl qurl(url);
    QString ext = QFileInfo(qurl.path()).suffix();
    QString basefilename = QString("download_%1_%2.%3")
                           .arg(QString::number(urlChecksum))
                           .arg(QString::number(titleChecksum)).arg(ext);

    return basefilename;
}
예제 #22
0
/**
  * Sends route to the server in xml format.
  * Send authentication information in the header.
  *
  * @param QString filename
  * @param int 1(send to server) or 0(no send)
  */
void HttpClient::sendRouteXml(QString oldName, QString newName, int i)
{
    qDebug() << "_sendRouteXml";

    //QString filename = "/home/user/MyDocs/speedfreak/route/route.xml";
    qDebug() << "__old:" + oldName;
    QString filename = newName; //+ ".xml";

    if(newName != "")
    {
        qDebug() << "_rename xml";
        QDir dir(filename);
        qDebug() << "__new:" + filename;
        qDebug() << dir.rename(oldName, filename);
    }

    if(i == 1)
    {
        qDebug() << "_send route";
        QFile file(filename);
        if (!file.open(QFile::ReadOnly))
        {
            qDebug() << "_sendRouteXml file.open() fail";
            return;
        }

        QUrl qurl("http://speedfreak-app.com/update/route");
        qDebug() << qurl.toString();
        QNetworkRequest request(qurl);
        QNetworkReply *currentDownload;

        QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
        credentials = "Basic " + credentials.toAscii().toBase64();
        request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());

        currentDownload = netManager->post(request, ("xml=" + file.readAll()));
        connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfRoute()));
        //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));

        //Indicating user
        if(myMainw->routeSaveDialog->routeDialog)
            myMainw->routeSaveDialog->routeDialog->setLabelInfoToUser("Sending route to server");

        file.close();
    }
}
QString IPTVChannelFetcher::DownloadPlaylist(const QString &url,
                                             bool inQtThread)
{
    if (url.startsWith("file", Qt::CaseInsensitive))
    {
        QString ret = "";
        QUrl qurl(url);
        QFile file(qurl.toLocalFile());
        if (!file.open(QIODevice::ReadOnly))
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + QString("Opening '%1'")
                    .arg(qurl.toLocalFile()) + ENO);
            return ret;
        }

        QTextStream stream(&file);
        while (!stream.atEnd())
            ret += stream.readLine() + "\n";

        file.close();
        return ret;
    }

    // Use Myth HttpComms for http URLs
    QString redirected_url = url;

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QString tmp = HttpComms::getHttp(
        redirected_url,
        10000 /* ms        */, 3     /* retries      */,
        3     /* redirects */, true  /* allow gzip   */,
        NULL  /* login     */, inQtThread);
#else
#warning IPTVChannelFetcher::DownloadPlaylist not yet ported to Qt5.
    QString tmp("");
#endif

    if (redirected_url != url)
    {
        LOG(VB_CHANNEL, LOG_INFO, QString("Channel URL redirected to %1")
                .arg(redirected_url));
    }

    return QString::fromUtf8(tmp.toLatin1().constData());
}
예제 #24
0
/**
  * Request the user information of certain user from the server.
  * Send authentication information in the header.
  *
  * @param QString username which information we want.
  */
void HttpClient::requestUserInfo(QString username)
{
    qDebug() << "_requestUsersInfo" ;

    QUrl qurl("http://speedfreak-app.com/users/info/" + username);
    qDebug() << qurl.toString();
    QNetworkRequest request(qurl);
    QNetworkReply *currentDownload;

    QString credentials = myMainw->settingsDialog->getUserName() + ":" + myMainw->settingsDialog->getPassword();
    credentials = "Basic " + credentials.toAscii().toBase64();
    request.setRawHeader(QByteArray("Authorization"),credentials.toAscii());

    currentDownload = netManager->post(request, ("data=" ));
    connect(currentDownload,SIGNAL(finished()),this,SLOT(ackOfUserInfo()));

    //qDebug() << "requestUserInfo";
    //ackOfUserInfo();
}
예제 #25
0
int 
QDjViewOutline::pageNumber(const char *link)
{
  if (link && link[0] == '#')
    return djview->pageNumber(QString::fromUtf8(link+1));
  if (link == 0 || link[0] != '?')
    return -1;
  QByteArray burl = QByteArray("http://f/f") + link;
#if QT_VERSION >= 0x50000
  QUrlQuery qurl(QUrl::fromEncoded(burl));
#else
  QUrl qurl = QUrl::fromEncoded(burl);
#endif
  if (qurl.hasQueryItem("page"))
    return djview->pageNumber(qurl.queryItemValue("page"));
  else if (qurl.hasQueryItem("pageno"))
    return djview->pageNumber("$" + qurl.queryItemValue("pageno"));
  return -1;
}
/// <summary>
/// Execute http post
/// </summary>
/// <param name="url">url for the http post</param>
/// <param name="data">string data to post</param>
/// <returns>Server answer</returns>
string VulkanDatabase::httpPost(string url, string data)
{
    manager = new QNetworkAccessManager(NULL);

    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

    QHttpPart jsonPart;
    jsonPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"data\"; filename=\"vulkanreport.json\""));
    jsonPart.setBody(QString::fromStdString(data).toLatin1());
    multiPart->append(jsonPart);

    QUrl qurl(QString::fromStdString(url));

    if (dbLogin)
    {
        qurl.setUserName(dbUser);
        qurl.setPassword(dbPass);
    }

    QNetworkRequest request(qurl);
    QNetworkReply *reply = manager->post(request, multiPart);
    multiPart->setParent(reply);

    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec();

    if (reply->error() == QNetworkReply::NoError)
    {
        QByteArray bytes = reply->readAll();
        QString replyStr(bytes);
        delete(manager);
        return replyStr.toStdString();
    }
    else
    {
        QString err;
        err = reply->errorString();
        delete(manager);
        return err.toStdString();
    }
}
/// <summary>
/// Checks if the online database can be reached
/// </summary>
bool VulkanDatabase::checkServerConnection()
{
    manager = new QNetworkAccessManager(NULL);

    QUrl qurl(QString::fromStdString(getBaseUrl() + "/services/serverstate.php"));

    if (dbLogin)
    {
        qurl.setUserName(dbUser);
        qurl.setPassword(dbPass);
    }

    QNetworkReply* reply = manager->get(QNetworkRequest(qurl));

    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
    loop.exec(QEventLoop::ExcludeUserInputEvents);

    return (reply->error() == QNetworkReply::NoError);
}
예제 #28
0
QString IPTVChannelFetcher::DownloadPlaylist(const QString &url,
                                             bool inQtThread)
{
    if (url.left(4).toLower() == "file")
    {
        QString ret = "";
        QUrl qurl(url);
        QFile file(qurl.toLocalFile());
        if (!file.open(QIODevice::ReadOnly))
        {
            VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Opening '%1'")
                    .arg(qurl.toLocalFile()) + ENO);
            return ret;
        }

        QTextStream stream(&file);
        while (!stream.atEnd())
            ret += stream.readLine() + "\n";

        file.close();
        return ret;
    }

    // Use Myth HttpComms for http URLs
    QString redirected_url = url;

    QString tmp = HttpComms::getHttp(
        redirected_url,
        10000 /* ms        */, 3     /* retries      */,
        3     /* redirects */, true  /* allow gzip   */,
        NULL  /* login     */, inQtThread);

    if (redirected_url != url)
    {
        VERBOSE(VB_CHANNEL, QString("Channel URL redirected to %1")
                .arg(redirected_url));
    }

    return QString::fromUtf8(tmp.toAscii().constData());
}
예제 #29
0
파일: main.cpp 프로젝트: PhobosK/plexydesk
int main(int argc, char * *argv)
{
    QApplication app(argc, argv);
    QString url = QString("http://www.google.com");

    QWebSettings::setMaximumPagesInCache(4);
    QWebSettings::setObjectCacheCapacities((16*1024*1024)/8, (16*1024*1024)/8, 16*1024*1024);

    QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
    QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

    const QStringList args = app.arguments();
    if (args.count() > 1)
        url = args.at(1);

    QUrl qurl(url);
    if (qurl.scheme().isEmpty())
        qurl = QUrl::fromLocalFile(QFileInfo(url).absoluteFilePath());

    QGraphicsScene *s = new  QGraphicsScene();
    WebView window(s);   ///WebView is a GraphicsView dose not relate to QWebView
    window.resize(800, 480);
    window.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);

    QWebViewItem *item = new QWebViewItem();
    item->setUrl(qurl);
    s->addItem(item);
    //item->hide();
    item->load(qurl);
    item->grabMouse();
    item->grabKeyboard();
    window.addWebPage(item); //some thing i needed for reflectiondemo
//     item->setPos((window.width()- item->boundingRect().width())/2, (window.height() - item->boundingRect().height())/2);
    int x = 1;
    int y = x;
//     item->setTransform(QTransform().translate(x, y).scale(2.0,2.0).translate(-x, -y));
    window.show();

    return app.exec();
}
예제 #30
0
QString IPTVChannelFetcher::DownloadPlaylist(const QString &url,
                                             bool inQtThread)
{
    if (url.startsWith("file", Qt::CaseInsensitive))
    {
        QString ret = "";
        QUrl qurl(url);
        QFile file(qurl.toLocalFile());
        if (!file.open(QIODevice::ReadOnly))
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + QString("Opening '%1'")
                    .arg(qurl.toLocalFile()) + ENO);
            return ret;
        }

        QTextStream stream(&file);
        while (!stream.atEnd())
            ret += stream.readLine() + "\n";

        file.close();
        return ret;
    }

    // Use MythDownloadManager for http URLs
    QByteArray data;
    QString tmp;

    if (!GetMythDownloadManager()->download(url, &data))
    {
        LOG(VB_GENERAL, LOG_INFO,
            QString("IPTVChannelFetcher::DownloadPlaylist failed to "
                    "download from %1").arg(url));
    }
    else
        tmp = QString(data);

    return tmp.isNull() ? tmp : QString::fromUtf8(tmp.toLatin1().constData());
}