当前位置: 首页>>代码示例>>C++>>正文


C++ RemoteFile类代码示例

本文整理汇总了C++中RemoteFile的典型用法代码示例。如果您正苦于以下问题:C++ RemoteFile类的具体用法?C++ RemoteFile怎么用?C++ RemoteFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RemoteFile类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

    void run()
    {
        bool ok = false;

        RemoteFile *rf = new RemoteFile(m_dlInfo->m_url, false, false, 0);
        ok = rf->SaveAs(m_dlInfo->m_privData);
        delete rf;

        if (!ok)
            m_dlInfo->m_errorCode = QNetworkReply::UnknownNetworkError;

        m_parent->downloadFinished(m_dlInfo);
    }
开发者ID:microe,项目名称:mythtv,代码行数:13,代码来源:mythdownloadmanager.cpp

示例2: RemoteFile

bool AlbumArt::draw(QPainter *p, const QColor &back)
{
    if (needsUpdate())
    {
        QImage art;
        QString imageFilename = gPlayer->getCurrentMetadata()->getAlbumArtFile(m_currImageType);

        if (imageFilename.startsWith("myth://"))
        {
            RemoteFile *rf = new RemoteFile(imageFilename, false, false, 0);

            QByteArray data;
            bool ret = rf->SaveAs(data);

            delete rf;

            if (ret)
                art.loadFromData(data);
        }
        else
            if (!imageFilename.isEmpty())
                art.load(imageFilename);

        if (art.isNull())
        {
            m_cursize = m_size;
            m_image = QImage();
        }
        else
        {
            m_image = art.scaled(m_size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
    }

    if (m_image.isNull())
    {
        drawWarning(p, back, m_size, QObject::tr("?"), 100);
        return true;
    }

    // Paint the image
    p->fillRect(0, 0, m_size.width(), m_size.height(), back);
    p->drawImage((m_size.width() - m_image.width()) / 2,
                 (m_size.height() - m_image.height()) / 2,
                 m_image);

    // Store our new size
    m_cursize = m_size;

    return true;
}
开发者ID:ChristopherNeufeld,项目名称:mythtv,代码行数:51,代码来源:visualize.cpp

示例3: RunProlog


//.........这里部分代码省略.........
                        }
                        else
                            downloaded.insert(type, info);
                    }

                    delete download;
                }
                else
                    downloaded.insert(type, info);
            }
            else
            {
                QString path = getStorageGroupURL(type, lookup->GetHost());
                QString finalfile = path + filename;
                QString oldurl = info.url;
                info.url = finalfile;
                bool exists = false;
                bool onMaster = false;
                QString resolvedFN;
                if ((lookup->GetHost().toLower() == gCoreContext->GetHostName().toLower()) ||
                    (gCoreContext->IsThisHost(lookup->GetHost())))
                {
                    StorageGroup sg;
                    resolvedFN = sg.FindFile(filename);
                    exists = QFile::exists(resolvedFN);
                    if (!exists)
                    {
                        resolvedFN = getLocalStorageGroupPath(type,
                                                 lookup->GetHost()) + "/" + filename;
                    }
                    onMaster = true;
                }
                else
                    exists = RemoteFile::Exists(finalfile);

                if (!exists || lookup->GetAllowOverwrites())
                {

                    if (exists && !onMaster)
                    {
                        QFileInfo fi(finalfile);
                        GetMythUI()->RemoveFromCacheByFile(fi.fileName());
                        RemoteFile::DeleteFile(finalfile);
                    }
                    else if (exists)
                        QFile::remove(resolvedFN);

                    LOG(VB_GENERAL, LOG_INFO,
                        QString("Metadata Image Download: %1 -> %2")
                            .arg(oldurl).arg(finalfile));
                    QByteArray *download = new QByteArray();
                    GetMythDownloadManager()->download(oldurl, download);

                    QImage testImage;
                    bool didLoad = testImage.loadFromData(*download);
                    if (!didLoad)
                    {
                        LOG(VB_GENERAL, LOG_ERR,
                            QString("Tried to write %1, but it appears to be "
                                    "an HTML redirect or corrupt file "
                                    "(filesize %2).")
                                .arg(oldurl).arg(download->size()));
                        delete download;
                        download = NULL;
                        QCoreApplication::postEvent(m_parent,
                                    new ImageDLFailureEvent(lookup));
开发者ID:ChristopherNeufeld,项目名称:mythtv,代码行数:67,代码来源:metadataimagedownload.cpp

示例4: LOG

QPixmap *MythUIHelper::LoadScalePixmap(QString filename, bool fromcache)
{
    LOG(VB_GUI | VB_FILE, LOG_INFO, LOC +
        QString("LoadScalePixmap(%1)").arg(filename));

    if (filename.isEmpty())
        return NULL;

    if (!FindThemeFile(filename) && (!filename.startsWith("myth:")))
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + QString("LoadScalePixmap(%1)")
            .arg(filename) + "Unable to find image file");

        return NULL;
    }

    QPixmap *ret = NULL;
    QImage tmpimage;
    int width, height;
    float wmult, hmult;

    GetScreenSettings(width, wmult, height, hmult);

    if (filename.startsWith("myth://"))
    {
        RemoteFile *rf = new RemoteFile(filename, false, false, 0);

        QByteArray data;
        bool loaded = rf->SaveAs(data);
        delete rf;

        if (loaded)
        {
            tmpimage.loadFromData(data);
        }
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("LoadScalePixmap(%1): failed to load remote image")
                .arg(filename));
        }
    }
    else
    {
        tmpimage.load(filename);
    }

    if (width != d->m_baseWidth || height != d->m_baseHeight)
    {
        if (tmpimage.isNull())
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("LoadScalePixmap(%1) failed to load image")
                .arg(filename));

            return NULL;
        }

        QImage tmp2 = tmpimage.scaled((int)(tmpimage.width() * wmult),
                                      (int)(tmpimage.height() * hmult),
                                      Qt::IgnoreAspectRatio,
                                      Qt::SmoothTransformation);
        ret = new QPixmap(QPixmap::fromImage(tmp2));
    }
    else
    {
        ret = new QPixmap(QPixmap::fromImage(tmpimage));

        if (!ret->width() || !ret->height())
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("LoadScalePixmap(%1) invalid image dimensions")
                .arg(filename));

            delete ret;
            return NULL;
        }
    }

    return ret;
}
开发者ID:chadparry,项目名称:mythtv,代码行数:81,代码来源:mythuihelper.cpp

示例5: LOG

MetadataLookupList MetadataDownload::readNFO(QString NFOpath,
                                             MetadataLookup* lookup)
{
    MetadataLookupList list;

    LOG(VB_GENERAL, LOG_INFO,
        QString("Matching NFO file found. Parsing %1 for metadata...")
               .arg(NFOpath));

    if (lookup->GetType() == kMetadataVideo)
    {
        QByteArray nforaw;
        QDomElement item;
        if (NFOpath.startsWith("myth://"))
        {
            RemoteFile *rf = new RemoteFile(NFOpath);
            if (rf && rf->Open())
            {
                bool loaded = rf->SaveAs(nforaw);
                if (loaded)
                {
                    QDomDocument doc;
                    if (doc.setContent(nforaw, true))
                    {
                        lookup->SetStep(kLookupData);
                        item = doc.documentElement();
                    }
                    else
                        LOG(VB_GENERAL, LOG_ERR,
                            QString("PIRATE ERROR: Invalid NFO file found."));
                }
                rf->Close();
            }

            delete rf;
            rf = NULL;
        }
        else
        {
            QFile file(NFOpath);
            if (file.open(QIODevice::ReadOnly))
            {
                nforaw = file.readAll();
                QDomDocument doc;
                if (doc.setContent(nforaw, true))
                {
                    lookup->SetStep(kLookupData);
                    item = doc.documentElement();
                }
                else
                    LOG(VB_GENERAL, LOG_ERR,
                        QString("PIRATE ERROR: Invalid NFO file found."));
                file.close();
            }
        }

        MetadataLookup *tmp = ParseMetadataMovieNFO(item, lookup);
        list.append(tmp);
    }

    return list;
}
开发者ID:killerkiwi,项目名称:mythtv,代码行数:62,代码来源:metadatadownload.cpp

示例6: while


//.........这里部分代码省略.........
                    {
                        VERBOSE(VB_IMPORTANT,QString("Tried to write %1, "
                                "but it appears to be an HTML redirect "
                                "(filesize %2).")
                                .arg(oldurl).arg(download->size()));
                        delete download;
                        download = NULL;
                        continue;
                    }

                    if (dest_file.open(QIODevice::WriteOnly))
                    {
                        off_t size = dest_file.write(*download, download->size());
                        if (size != download->size())
                        {
                            VERBOSE(VB_IMPORTANT,
                            QString("Image Download: Error Writing Image "
                                    "to file: %1").arg(finalfile));
                        }
                        else
                            downloaded.insert(type, info);
                    }

                    delete download;
                }
                else
                    downloaded.insert(type, info);
            }
            else
            {
                QString path = getStorageGroupURL(type, lookup->GetHost());
                QString finalfile = path + filename;
                QString oldurl = info.url;
                info.url = finalfile;
                if (!RemoteFile::Exists(finalfile) || lookup->GetAllowOverwrites())
                {

                    if (RemoteFile::Exists(finalfile))
                    {
                        QFileInfo fi(finalfile);
                        GetMythUI()->RemoveFromCacheByFile(fi.fileName());
                        RemoteFile::DeleteFile(finalfile);
                    }

                    VERBOSE(VB_GENERAL,
                        QString("Metadata Image Download: %1 -> %2")
                        .arg(oldurl).arg(finalfile));
                    QByteArray *download = new QByteArray();
                    GetMythDownloadManager()->download(oldurl, download);

                    QImage testImage;
                    bool didLoad = testImage.loadFromData(*download);
                    if (!didLoad)
                    {
                        VERBOSE(VB_IMPORTANT,QString("Tried to write %1, "
                                "but it appears to be an HTML redirect "
                                "or corrupt file (filesize %2).")
                                .arg(oldurl).arg(download->size()));
                        delete download;
                        download = NULL;
                        continue;
                    }

                    RemoteFile *outFile = new RemoteFile(finalfile, true);
                    if (!outFile->isOpen())
                    {
                        VERBOSE(VB_IMPORTANT,
                            QString("Image Download: Failed to open "
                                    "remote file (%1) for write.  Does "
                                    "Storage Group Exist?")
                                    .arg(finalfile));
                        delete outFile;
                        outFile = NULL;
                    }
                    else
                    {
                        off_t written = outFile->Write(*download,
                                                       download->size());
                        if (written != download->size())
                        {
                            VERBOSE(VB_IMPORTANT,
                            QString("Image Download: Error Writing Image "
                                    "to file: %1").arg(finalfile));
                        }
                        else
                            downloaded.insert(type, info);
                        delete outFile;
                        outFile = NULL;
                    }

                    delete download;
                }
                else
                    downloaded.insert(type, info);
            }
        }
        lookup->SetDownloads(downloaded);
        QCoreApplication::postEvent(m_parent, new ImageDLEvent(lookup));
    }
}
开发者ID:DocOnDev,项目名称:mythtv,代码行数:101,代码来源:metadataimagedownload.cpp

示例7: QString

bool PixmapChannel::CacheChannelIcon(void)
{
    if (icon.isEmpty())
        return false;

    m_localIcon = icon;

    // Is icon local?
    if (QFile(icon).exists())
        return true;

    QString localDirStr = QString("%1/channels").arg(GetConfDir());
    QDir localDir(localDirStr);

    if (!localDir.exists() && !localDir.mkdir(localDirStr))
    {
        VERBOSE(VB_IMPORTANT, QString("Icons directory is missing and could "
                                      "not be created: %1").arg(localDirStr));
        icon.clear();
        return false;
    }

    // Has it been saved to the local cache?
    m_localIcon = QString("%1/%2").arg(localDirStr)
                                 .arg(QFileInfo(icon).fileName());
    if (QFile(m_localIcon).exists())
        return true;

    // Get address of master backed
    QString url = gCoreContext->GetMasterHostPrefix();
    if (url.length() < 1)
    {
        icon.clear();
        return false;
    }

    url.append(icon);

    QUrl qurl = url;
    if (qurl.host().isEmpty())
    {
        icon.clear();
        return false;
    }

    RemoteFile *rf = new RemoteFile(url, false, false, 0);

    QByteArray data;
    bool ret = rf->SaveAs(data);

    delete rf;

    if (ret && data.size())
    {
        QImage image;

        image.loadFromData(data);

        //if (image.loadFromData(data) && image.width() > 0

        if (image.save(m_localIcon))
        {
            VERBOSE(VB_GENERAL, QString("Caching channel icon %1").arg(m_localIcon));
            return true;
        }
        else
            VERBOSE(VB_GENERAL, QString("Failed to save to %1").arg(m_localIcon));
    }

    // if we get here then the icon is set in the db but couldn't be found
    // anywhere so maybe we should remove it from the DB?
    icon.clear();

    return false;
}
开发者ID:microe,项目名称:mythtv,代码行数:75,代码来源:dbchannelinfo.cpp


注:本文中的RemoteFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。