Ejemplo n.º 1
0
void WebTab::showRSSInfo(const QPoint &pos)
{
    QWebElementCollection col = page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]");
    col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));

    QMap<KUrl, QString> map;

    foreach(const QWebElement &el, col)
    {
        QString urlString;
        if (el.attribute("href").startsWith(QL1S("http")))
            urlString = el.attribute("href");
        else
        {
            KUrl u = url();
            // NOTE
            // cd() is probably better than setPath() here,
            // for all those url sites just having a path
            if (u.cd(el.attribute("href")))
                urlString = u.toMimeDataString();
        }

        QString title = el.attribute("title");
        if (title.isEmpty())
            title = el.attribute("href");

        map.insert(KUrl(urlString), title);
    }
Ejemplo n.º 2
0
 void SieveJob::schedule( Command command ) {
   switch ( command ) {
   case Get:
     kDebug() << "get(" << mUrl.prettyUrl() << ")";
     mJob = KIO::get( mUrl );
     connect( mJob, SIGNAL(data(KIO::Job*,const QByteArray&)),
              SLOT(slotData(KIO::Job*,const QByteArray&)) );
     break;
   case Put:
     kDebug() << "put(" << mUrl.prettyUrl() << ")";
     mJob = KIO::put( mUrl, 0600, KIO::Overwrite );
     connect( mJob, SIGNAL(dataReq(KIO::Job*,QByteArray&)),
              SLOT(slotDataReq(KIO::Job*,QByteArray&)) );
     break;
   case Activate:
     kDebug() << "chmod(" << mUrl.prettyUrl() <<", 0700 )";
     mJob = KIO::chmod( mUrl, 0700 );
     break;
   case Deactivate:
     kDebug() << "chmod(" << mUrl.prettyUrl() <<", 0600 )";
     mJob = KIO::chmod( mUrl, 0600 );
     break;
   case SearchActive:
     kDebug() << "listDir(" << mUrl.prettyUrl() << ")";
     {
       KUrl url = mUrl;
       QString query = url.query(); //save query part, because KUrl::cd() erases it
       if ( !url.fileName().isEmpty() )
         url.cd("..");
       url.setQuery( query );
       kDebug() << "listDir's real URL:" << url.prettyUrl();
       mJob = KIO::listDir( url );
       connect( mJob, SIGNAL(entries(KIO::Job*,const KIO::UDSEntryList&)),
                SLOT(slotEntries(KIO::Job*,const KIO::UDSEntryList&)) );
       break;
     }
   case List:
     kDebug() << "listDir(" << mUrl.prettyUrl() << ")";
     {
       mJob = KIO::listDir( mUrl );
       connect( mJob, SIGNAL( entries(KIO::Job *, const KIO::UDSEntryList & ) ),
                SLOT( slotEntries( KIO::Job *, const KIO::UDSEntryList & ) ) );
       break;
     }
   case Delete:
     kDebug() << "delete(" << mUrl.prettyUrl() << ")";
     mJob = KIO::del( mUrl );
     break;
   default:
     assert( 0 );
   }
   // common to all jobs:
   connect( mJob, SIGNAL(result(KJob*)), SLOT(slotResult(KJob*)) );
 }
Ejemplo n.º 3
0
    void renameImportedUrl(const KUrl& src)
    {
        KUrl dst = src;
        dst.cd("..");
        QString fileName;
        if (mFileNameFormater.get()) {
            KFileItem item(KFileItem::Unknown, KFileItem::Unknown, src, true /* delayedMimeTypes */);
            // Get the document time, but do not cache the result because the
            // 'src' url is temporary: if we import "foo/image.jpg" and
            // "bar/image.jpg", both images will be temporarily saved in the
            // 'src' url.
            KDateTime dateTime = TimeUtils::dateTimeForFileItem(item, TimeUtils::SkipCache);
            fileName = mFileNameFormater->format(src, dateTime);
        } else {
            fileName = src.fileName();
        }
        dst.setFileName(fileName);

        FileUtils::RenameResult result = FileUtils::rename(src, dst, mAuthWindow);
        switch (result) {
        case FileUtils::RenamedOK:
            mImportedUrlList << mCurrentUrl;
            break;
        case FileUtils::RenamedUnderNewName:
            mRenamedCount++;
            mImportedUrlList << mCurrentUrl;
            break;
        case FileUtils::Skipped:
            mSkippedUrlList << mCurrentUrl;
            break;
        case FileUtils::RenameFailed:
            kWarning() << "Rename failed for" << mCurrentUrl;
        }
        q->advance();
        importNext();
    }