Example #1
0
void JobTest::moveFileNoPermissions()
{
    kdDebug() << k_funcinfo << endl;
    const QString src = "/etc/passwd";
    const QString dest = homeTmpDir() + "passwd";
    assert(QFile::exists(src));
    assert(QFileInfo(src).isFile());
    KURL u;
    u.setPath(src);
    KURL d;
    d.setPath(dest);

    KIO::CopyJob *job = KIO::move(u, d, 0);
    job->setInteractive(false); // no skip dialog, thanks
    QMap< QString, QString > metaData;
    bool ok = KIO::NetAccess::synchronousRun(job, 0, 0, 0, &metaData);
    assert(!ok);
    assert(KIO::NetAccess::lastError() == KIO::ERR_ACCESS_DENIED);
    // OK this is fishy. Just like mv(1), KIO's behavior depends on whether
    // a direct rename(2) was used, or a full copy+del. In the first case
    // there is no destination file created, but in the second case the
    // destination file remains.
    // In fact we assume /home is a separate partition, in this test, so:
    assert(QFile::exists(dest));
    assert(QFile::exists(src));
}
Example #2
0
void JobTest::copyLocalFile(const QString &src, const QString &dest)
{
    KURL u;
    u.setPath(src);
    KURL d;
    d.setPath(dest);

    // copy the file with file_copy
    bool ok = KIO::NetAccess::file_copy(u, d);
    assert(ok);
    assert(QFile::exists(dest));
    assert(QFile::exists(src)); // still there

    {
        // check that the timestamp is the same (#24443)
        // Note: this only works because of copy() in kio_file.
        // The datapump solution ignores mtime, the app has to call FileCopyJob::setModificationTime()
        QFileInfo srcInfo(src);
        QFileInfo destInfo(dest);
        assert(srcInfo.lastModified() == destInfo.lastModified());
    }

    // cleanup and retry with KIO::copy()
    QFile::remove(dest);
    ok = KIO::NetAccess::dircopy(u, d, 0);
    assert(ok);
    assert(QFile::exists(dest));
    assert(QFile::exists(src)); // still there
    {
        // check that the timestamp is the same (#24443)
        QFileInfo srcInfo(src);
        QFileInfo destInfo(dest);
        assert(srcInfo.lastModified() == destInfo.lastModified());
    }
}
Example #3
0
void BaseTreeView::slotCreateFile()
{
  bool ok;
  QString fileName = KInputDialog::getText(i18n("Create New File"), i18n("File name:"), "", &ok, this);
  if (ok)
  {
    KURL url = currentURL();
    if (currentKFileTreeViewItem()->isDir())
      url.setPath(url.path() + "/" + fileName);
    else
      url.setPath(url.directory() + "/" + fileName);
    if (QExtFileInfo::exists(url, false, this))
    {
      KMessageBox::error(this, i18n("<qt>Cannot create file, because a file named <b>%1</b> already exists.</qt>").arg(fileName), i18n("Error Creating File"));
      return;
    }
    KTempFile *tempFile = new KTempFile(tmpDir);
    tempFile->setAutoDelete(true);
    tempFile->close();
    if (QuantaNetAccess::copy(KURL::fromPathOrURL(tempFile->name()), url, this))
    {
      emit openFile(url);
    }
    delete tempFile;
  }
}
Example #4
0
QString KDesktopFile::readURL() const
{
    if(hasDeviceType())
    {
        QString device = readDevice();
        KMountPoint::List mountPoints = KMountPoint::possibleMountPoints();

        for(KMountPoint::List::ConstIterator it = mountPoints.begin(); it != mountPoints.end(); ++it)
        {
            KMountPoint *mp = *it;
            if(mp->mountedFrom() == device)
            {
                KURL u;
                u.setPath(mp->mountPoint());
                return u.url();
            }
        }
        return QString::null;
    }
    else
    {
        QString url = readPathEntry("URL");
        if(!url.isEmpty() && !QDir::isRelativePath(url))
        {
            // Handle absolute paths as such (i.e. we need to escape them)
            KURL u;
            u.setPath(url);
            return u.url();
        }
        return url;
    }
}
IconURL IconController::defaultURL(IconType iconType)
{
    // Don't return a favicon iconURL unless we're http or https
    KURL documentURL = m_frame->document()->url();
    if (!documentURL.protocolIsInHTTPFamily())
        return IconURL();

    KURL url;
    bool couldSetProtocol = url.setProtocol(documentURL.protocol());
    ASSERT_UNUSED(couldSetProtocol, couldSetProtocol);
    url.setHost(documentURL.host());
    if (documentURL.hasPort())
        url.setPort(documentURL.port());

    if (iconType == Favicon) {
        url.setPath("/favicon.ico");
        return IconURL::defaultIconURL(url, Favicon);
    }
#if ENABLE(TOUCH_ICON_LOADING)
    if (iconType == TouchPrecomposedIcon) {
        url.setPath("/apple-touch-icon-precomposed.png");
        return IconURL::defaultIconURL(url, TouchPrecomposedIcon);
    }
    if (iconType == TouchIcon) {
        url.setPath("/apple-touch-icon.png");
        return IconURL::defaultIconURL(url, TouchIcon);
    }
#endif
    return IconURL();
}
Example #6
0
void JobTest::copyLocalDirectory(const QString &src, const QString &_dest, int flags)
{
    assert(QFileInfo(src).isDir());
    assert(QFileInfo(src + "/testfile").isFile());
    KURL u;
    u.setPath(src);
    QString dest(_dest);
    KURL d;
    d.setPath(dest);
    if(flags & AlreadyExists)
        assert(QFile::exists(dest));
    else
        assert(!QFile::exists(dest));

    bool ok = KIO::NetAccess::dircopy(u, d, 0);
    assert(ok);

    if(flags & AlreadyExists)
    {
        dest += "/" + u.fileName();
        // kdDebug() << "Expecting dest=" << dest << endl;
    }

    assert(QFile::exists(dest));
    assert(QFileInfo(dest).isDir());
    assert(QFileInfo(dest + "/testfile").isFile());
    assert(QFile::exists(src)); // still there
    {
        // check that the timestamp is the same (#24443)
        QFileInfo srcInfo(src);
        QFileInfo destInfo(dest);
        assert(srcInfo.lastModified() == destInfo.lastModified());
    }
}
Example #7
0
bool TrashImpl::move( const TQString& src, const TQString& dest )
{
    if ( directRename( src, dest ) ) {
        // This notification is done by TDEIO::moveAs when using the code below
        // But if we do a direct rename we need to do the notification ourselves
        KDirNotify_stub allDirNotify( "*", "KDirNotify*" );
        KURL urlDest; urlDest.setPath( dest );
        urlDest.setPath( urlDest.directory() );
        allDirNotify.FilesAdded( urlDest );
        return true;
    }
    if ( m_lastErrorCode != TDEIO::ERR_UNSUPPORTED_ACTION )
        return false;

    KURL urlSrc, urlDest;
    urlSrc.setPath( src );
    urlDest.setPath( dest );
    kdDebug() << k_funcinfo << urlSrc << " -> " << urlDest << endl;
    TDEIO::CopyJob* job = TDEIO::moveAs( urlSrc, urlDest, false );
#ifdef TDEIO_COPYJOB_HAS_SETINTERACTIVE
    job->setInteractive( false );
#endif
    connect( job, TQT_SIGNAL( result(TDEIO::Job *) ),
             this, TQT_SLOT( jobFinished(TDEIO::Job *) ) );
    tqApp->eventLoop()->enterLoop();

    return m_lastErrorCode == 0;
}
Example #8
0
void Project::insertFile(const KURL& nameURL, bool repaint )
{
  if (d->excludeRx.exactMatch(nameURL.path()))
      return;
  KURL url = nameURL;

  if ( !d->baseURL.isParentOf(url) )
  {
    KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( d->baseURL.prettyURL(), d->m_mainWindow, "");
    urlRequesterDlg->setCaption(i18n("%1: Copy to Project").arg(nameURL.prettyURL(0, KURL::StripFileProtocol)));
    urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly);
    urlRequesterDlg->exec();
    KURL destination = urlRequesterDlg->selectedURL();
    if (destination.isLocalFile())
    {
      QDir dir(destination.path());
      destination.setPath(dir.canonicalPath());
    }
    delete urlRequesterDlg;
    if ( !destination.isEmpty() )
    {
      CopyTo *dlg = new CopyTo(d->baseURL);
      connect(dlg, SIGNAL(deleteDialog(CopyTo*)), d,
                   SLOT(slotDeleteCopytoDlg(CopyTo*)));
      url = dlg->copy( nameURL, destination );
    }
    else  // Copy canceled, addition aborted
    {
      return;
    }
  }
  QDomElement  el;
  while ( d->baseURL.isParentOf(url) )
  {
    if ( !d->m_projectFiles.contains(url) )
    {
      el = d->dom.createElement("item");
      el.setAttribute("url", QuantaCommon::qUrl( QExtFileInfo::toRelative(url, d->baseURL) ));
      d->dom.firstChild().firstChild().appendChild( el );
      KURL u = url.upURL();
      ProjectURL *parentURL = d->m_projectFiles.find(u);
      int uploadStatus = 1;
      if (parentURL)
        uploadStatus = parentURL->uploadStatus;
      d->m_projectFiles.insert( new ProjectURL(url, "", uploadStatus, false, el) );
    }
    url.setPath(url.directory(false));
  }
  emit eventHappened("after_project_add", url.url(), QString::null);
  setModified();
  if ( repaint )
  {
    emit reloadTree( &(d->m_projectFiles), false, QStringList());
    emit newStatus();
  }
}
Example #9
0
void HTMLAnchorElement::setPathname(const String& value)
{
    KURL url = href();
    if (!url.canSetPathname())
        return;

    if (value[0] == '/')
        url.setPath(value);
    else
        url.setPath("/" + value);

    setHref(url.string());
}
Example #10
0
void BaseTreeView::slotCreateFolder()
{
  bool ok;
  QString folderName = KInputDialog::getText(i18n("Create New Folder"), i18n("Folder name:"), "", &ok, this);
  if (ok)
  {
    KURL url = currentURL();
    if (currentKFileTreeViewItem()->isDir())
      url.setPath(url.path() + "/" + folderName + "/");
    else
      url.setPath(url.directory() + "/" + folderName +"/");
    QuantaNetAccess::mkdir(url, this, -1);
  }
}
Example #11
0
void HomeImpl::createHomeEntry(KIO::UDSEntry &entry,
                               const KUser &user)
{
	kdDebug() << "HomeImpl::createHomeEntry" << endl;
	
	entry.clear();
	
	QString full_name = user.loginName();
	
	if (!user.fullName().isEmpty())
	{
		full_name = user.fullName()+" ("+user.loginName()+")";
	}
	
	full_name = KIO::encodeFileName( full_name );
	
	addAtom(entry, KIO::UDS_NAME, 0, full_name);
	addAtom(entry, KIO::UDS_URL, 0, "home:/"+user.loginName());
	
	addAtom(entry, KIO::UDS_FILE_TYPE, S_IFDIR);
	addAtom(entry, KIO::UDS_MIME_TYPE, 0, "inode/directory");

	QString icon_name = "folder_home2";

	if (user.uid()==m_effectiveUid)
	{
		icon_name = "folder_home";
	}
	
	addAtom(entry, KIO::UDS_ICON_NAME, 0, icon_name);

	KURL url;
	url.setPath(user.homeDir());
	entry += extractUrlInfos(url);
}
Example #12
0
KoFilter::ConversionStatus MagickExport::convert(const QCString& from, const QCString& to)
{
    kdDebug(41008) << "magick export! From: " << from << ", To: " << to << "\n";
    
    if (from != "application/x-krita")
        return KoFilter::NotImplemented;

    // XXX: Add dialog about flattening layers here

    KisDoc *output = dynamic_cast<KisDoc*>(m_chain->inputDocument());
    QString filename = m_chain->outputFile();
    
    if (!output)
        return KoFilter::CreationError;
    
    if (filename.isEmpty()) return KoFilter::FileNotFound;

    KURL url;
    url.setPath(filename);

    KisImageSP img = output->currentImage();

    KisImageMagickConverter ib(output, output->undoAdapter());

    KisPaintDeviceSP pd = new KisPaintDevice(*img->projection());
    KisPaintLayerSP l = new KisPaintLayer(img, "projection", OPACITY_OPAQUE, pd);
    
    vKisAnnotationSP_it beginIt = img->beginAnnotations();
    vKisAnnotationSP_it endIt = img->endAnnotations();
    if (ib.buildFile(url, l, beginIt, endIt) == KisImageBuilder_RESULT_OK) {
        return KoFilter::OK;
    }
    return KoFilter::InternalError;
}
Example #13
0
void TDMAppearanceWidget::iconLoaderDropEvent(TQDropEvent *e)
{
    KURL pixurl;
    bool istmp;

    KURL *url = decodeImgDrop(e, this);
    if (url) {

	// we gotta check if it is a non-local file and make a tmp copy at the hd.
	if(!url->isLocalFile()) {
	    pixurl.setPath(TDEGlobal::dirs()->resourceDirs("data").last() +
		     "tdm/pics/" + url->fileName());
	    TDEIO::NetAccess::copy(*url, pixurl, parentWidget());
	    istmp = true;
	} else {
	    pixurl = *url;
	    istmp = false;
	}

	// By now url should be "file:/..."
	if (!setLogo(pixurl.path())) {
	    TDEIO::NetAccess::del(pixurl, parentWidget());
	    TQString msg = i18n("There was an error loading the image:\n"
			       "%1\n"
			       "It will not be saved.")
			       .arg(pixurl.path());
	    KMessageBox::sorry(this, msg);
	}

	delete url;
    }
}
Example #14
0
void XDNet::startDebugging(const QString& filePath, SiteSettings* site, bool local)
{
  int id = kapp->random();
  if(local) 
  {
    QStringList env;
    env << "XDEBUG_CONFIG"
        << ("remote_port=" 
            + QString::number(m_debugger->settings()->listenPort())
            + "\\ remote_host=localhost"
           )
        << "XDEBUG_SESSION_START"
        << QString::number(id);

    Session::self()->start(filePath, env, true);
  } 
  else
  {
    QString uri = filePath;
    uri = uri.remove(0, site->localBaseDir().length());

    KURL url = site->effectiveURL();
    url.setPath(url.path() + uri);
    url.setQuery(QString("XDEBUG_SESSION_START=")+QString::number(id));
  
    Session::self()->start(url);    
  }
}
Example #15
0
void Loader::Host::servePendingRequests(RequestQueue& requestsPending)
{
    while (m_requestsLoading.size() < m_maxRequestsInFlight && !requestsPending.isEmpty()) {        
        Request* request = requestsPending.first();
        requestsPending.removeFirst();

        DocLoader* docLoader = request->docLoader();
        
        ResourceRequest resourceRequest(request->cachedResource()->url());
        
        if (!request->cachedResource()->accept().isEmpty())
            resourceRequest.setHTTPAccept(request->cachedResource()->accept());
        
        KURL referrer = docLoader->doc()->url();
        if ((referrer.protocolIs("http") || referrer.protocolIs("https")) && referrer.path().isEmpty())
            referrer.setPath("/");
        resourceRequest.setHTTPReferrer(referrer.string());

        RefPtr<SubresourceLoader> loader = SubresourceLoader::create(docLoader->doc()->frame(),
                                                                     this, resourceRequest, request->shouldSkipCanLoadCheck(), request->sendResourceLoadCallbacks());
        if (loader) {
            m_requestsLoading.add(loader.release(), request);
            request->cachedResource()->setRequestedFromNetworkingLayer();
#if REQUEST_DEBUG
            printf("HOST %s COUNT %d LOADING %s\n", resourceRequest.url().host().latin1().data(), m_requestsLoading.size(), request->cachedResource()->url().latin1().data());
#endif
        } else {            
            docLoader->decrementRequestCount();
            docLoader->setLoadInProgress(true);
            request->cachedResource()->error();
            docLoader->setLoadInProgress(false);
            delete request;
        }
    }
}
Example #16
0
void MediaPlayerPrivate::load(const String& url)
{
    String modifiedUrl(url);

    if (modifiedUrl.startsWith("local://")) {
        KURL kurl = KURL(KURL(), modifiedUrl);
        kurl.setProtocol("file");
        String tempPath(BlackBerry::Platform::Client::get()->getApplicationLocalDirectory().c_str());
        tempPath.append(kurl.path());
        kurl.setPath(tempPath);
        modifiedUrl = kurl.string();
    }
    if (modifiedUrl.startsWith("file://")) {
        // The QNX Multimedia Framework cannot handle filenames containing URL escape sequences.
        modifiedUrl = decodeURLEscapeSequences(modifiedUrl);
    }

    String cookiePairs;
    if (!url.isEmpty())
        cookiePairs = cookieManager().getCookie(KURL(ParsedURLString, url.utf8().data()), WithHttpOnlyCookies);
    if (!cookiePairs.isEmpty() && cookiePairs.utf8().data())
        m_platformPlayer->load(modifiedUrl.utf8().data(), userAgent(modifiedUrl).utf8().data(), cookiePairs.utf8().data());
    else
        m_platformPlayer->load(modifiedUrl.utf8().data(), userAgent(modifiedUrl).utf8().data(), 0);
}
Example #17
0
void KMSoundTestWidget::openSoundDialog( KURLRequester * )
{
    static bool init = true;
    if ( !init )
        return;

    init = false;

    KFileDialog *fileDialog = m_urlRequester->fileDialog();
    fileDialog->setCaption( i18n("Select Sound File") );
    QStringList filters;
    filters << "audio/x-wav" << "audio/x-mp3" << "application/x-ogg"
            << "audio/x-adpcm";
    fileDialog->setMimeFilter( filters );

   QStringList soundDirs = KGlobal::dirs()->resourceDirs( "sound" );

    if ( !soundDirs.isEmpty() ) {
        KURL soundURL;
        QDir dir;
        dir.setFilter( QDir::Files | QDir::Readable );
        QStringList::ConstIterator it = soundDirs.begin();
        while ( it != soundDirs.end() ) {
            dir = *it;
            if ( dir.isReadable() && dir.count() > 2 ) {
                soundURL.setPath( *it );
                fileDialog->setURL( soundURL );
                break;
            }
            ++it;
        }
    }

}
Example #18
0
void KHelpDlg::rCommandDone (RCommand *command) {
	KURL url;
	if (command->getFlags () == HELP_SEARCH) {
		resultsList->clear ();
		RK_ASSERT ((command->getDataLength () % 3) == 0);
		int count = (command->getDataLength () / 3);
		for (int i=0; i < count; ++i) {
			new QListViewItem (resultsList, command->getStringVector ()[i], command->getStringVector ()[count + i], command->getStringVector ()[2*count + i]);
		}
		setEnabled(true);
	} else if (command->getFlags () == GET_HELP_URL) {
		RK_ASSERT (command->getDataLength ());
		url.setPath(command->getStringVector ()[0]);
		if (QFile::exists (url.path ())) {
			RKWardMainWindow::getMain ()->openHTML (url);
			return;
		} else {
			KMessageBox::sorry (this, i18n ("No help found on '%1'. Maybe the corresponding package is not installed/loaded, or maybe you mistyped the command. Try using Help->Search R Help for more options.").arg (command->command ().section ("\"", 1, 1)), i18n ("No help found"));
		}
	} else if (command->getFlags () == GET_INSTALLED_PACKAGES) {
		RK_ASSERT (command->getDataType () == RData::StringVector);
		unsigned int count = command->getDataLength ();
		for (unsigned int i=0; i < count; ++i) {
			packagesList->insertItem (command->getStringVector ()[i]);
		}
	} else {
		RK_ASSERT (false);
	}
}
Example #19
0
void ServiceButton::properties()
{
    if (!_service)
    {
        return;
    }

    QString path = _service->desktopEntryPath();

    // If the path to the desktop file is relative, try to get the full
    // path from KStdDirs.
    path = locate("apps", path);
    KURL serviceURL;
    serviceURL.setPath(path);

    // the KPropertiesDialog deletes itself, so this isn't a memory leak
    KPropertiesDialog* dialog = new KPropertiesDialog(serviceURL, 0, 0,
                                                      false, false);
    dialog->setFileNameReadOnly(true);
    connect(dialog, SIGNAL(saveAs(const KURL &, KURL &)),
            this, SLOT(slotSaveAs(const KURL &, KURL &)));
    connect(dialog, SIGNAL(propertiesClosed()),
            this, SLOT(slotUpdate()));
    dialog->show();
}
Example #20
0
void
NfsDeviceHandler::getURL( KURL &absolutePath, const KURL &relativePath )
{
    absolutePath.setPath( m_mountPoint );
    absolutePath.addPath( relativePath.path() );
    absolutePath.cleanPath();
}
Example #21
0
KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const {
  ASSERT(DOMFilePath::isAbsolute(fullPath));

  if (type() == FileSystemTypeExternal) {
    // For external filesystem originString could be different from what we have
    // in m_filesystemRootURL.
    StringBuilder result;
    result.append("filesystem:");
    result.append(getSecurityOrigin()->toString());
    result.append('/');
    result.append(externalPathPrefix);
    result.append(m_filesystemRootURL.path());
    // Remove the extra leading slash.
    result.append(encodeWithURLEscapeSequences(fullPath.substring(1)));
    return KURL(ParsedURLString, result.toString());
  }

  // For regular types we can just append the entry's fullPath to the
  // m_filesystemRootURL that should look like
  // 'filesystem:<origin>/<typePrefix>'.
  ASSERT(!m_filesystemRootURL.isEmpty());
  KURL url = m_filesystemRootURL;
  // Remove the extra leading slash.
  url.setPath(url.path() + encodeWithURLEscapeSequences(fullPath.substring(1)));
  return url;
}
Example #22
0
void HomeDirNotify::init()
{
    if(mInited)
        return;
    mInited = true;

    KUser current_user;
    QValueList< KUserGroup > groups = current_user.groups();
    QValueList< int > uid_list;

    QValueList< KUserGroup >::iterator groups_it = groups.begin();
    QValueList< KUserGroup >::iterator groups_end = groups.end();

    for(; groups_it != groups_end; ++groups_it)
    {
        QValueList< KUser > users = (*groups_it).users();

        QValueList< KUser >::iterator it = users.begin();
        QValueList< KUser >::iterator users_end = users.end();

        for(; it != users_end; ++it)
        {
            if((*it).uid() >= MINIMUM_UID && !uid_list.contains((*it).uid()))
            {
                uid_list.append((*it).uid());

                QString name = (*it).loginName();
                KURL url;
                url.setPath((*it).homeDir());

                m_homeFoldersMap[name] = url;
            }
        }
    }
}
Example #23
0
// ### TODO: network transparency
void KWordViewIface::insertFile(const QString & path)
{

    KURL url;
    url.setPath( path );
    view->insertFile( url );
}
Example #24
0
    QValueList<Mirror>
  Sites::siteList()
  {
    KURL url;
    url.setProtocol( "http" );
    url.setHost( "freedb.freedb.org" );
    url.setPort( 80 );
    url.setPath( "/~cddb/cddb.cgi" );

    url.setQuery( QString::null );

    QString hello = QString("%1 %2 %3 %4")
        .arg(user_, localHostName_, clientName(), clientVersion());

    url.addQueryItem( "cmd", "sites" );
    url.addQueryItem( "hello", hello );
    url.addQueryItem( "proto", "5" );

    QValueList<Mirror> result;

    QString tmpFile;
    if( KIO::NetAccess::download( url, tmpFile, 0 ) )
    {
      result = readFile( tmpFile );
      KIO::NetAccess::removeTempFile( tmpFile );
    }

    return result;
  }
Example #25
0
int main(int argc, char **argv) {
    KAboutData aboutData("kprotocolinfotest", "KProtocolinfo Test",
                        "1.0");

    KCmdLineArgs::init(argc, argv, &aboutData);
    KApplication app;

    KURL url;
    url.setPath("/tmp");
    assert( KProtocolInfo::supportsListing( KURL( "ftp://10.1.1.10") ) );
    assert( KProtocolInfo::inputType(url) == KProtocolInfo::T_NONE );
    assert( KProtocolInfo::outputType(url) == KProtocolInfo::T_FILESYSTEM );
    assert( KProtocolInfo::supportsReading(url) == true );
    KProtocolInfo::ExtraFieldList extraFields = KProtocolInfo::extraFields(url);
    KProtocolInfo::ExtraFieldList::Iterator extraFieldsIt = extraFields.begin();
    for ( ; extraFieldsIt != extraFields.end() ; ++extraFieldsIt )
        kdDebug() << (*extraFieldsIt).name << " " << (*extraFieldsIt).type << endl;

    assert( KProtocolInfo::showFilePreview( "file" ) == true );
    assert( KProtocolInfo::showFilePreview( "audiocd" ) == false );
    assert( KGlobalSettings::showFilePreview( "audiocd:/" ) == false );

    QString proxy;
    QString protocol = KProtocolManager::slaveProtocol( "http://bugs.kde.org", proxy );
    assert( protocol == "http" );

    QStringList capabilities = KProtocolInfo::capabilities( "imap" );
    kdDebug() << "kio_imap capabilities: " << capabilities << endl;
    //assert(capabilities.contains("ACL"));

    return 0;
}
Example #26
0
void PMShell::saveAs( )
{
   KFileDialog dlg( QString::null,
                    QString( "*.kpm|" ) + i18n( "Povray Modeler Files (*.kpm)" ) +
                    QString( "\n*|" ) + i18n( "All Files" ),
                    0, "filedialog", true );
   dlg.setCaption( i18n( "Save As" ) );
   dlg.setOperationMode( KFileDialog::Saving );
   dlg.exec( );

   KURL url = dlg.selectedURL( );

   if( !url.isEmpty( ) )
   {
      if( dlg.currentFilter( ) == QString( "*.kpm" ) )
         if( QFileInfo( url.path( ) ).extension( ).isEmpty( ) )
            url.setPath( url.path( ) + ".kpm" );

      if( overwriteURL( url ) )
      {
         m_pRecent->addURL( url );
         if( m_pPart->saveAs( url ) )
            setCaption( url.prettyURL( ) );
         else
            KMessageBox::sorry( this, i18n( "Couldn't save the file." ) );
      }
   }
}
Example #27
0
void SloxFolderManager::requestFolders()
{
  kdDebug() << k_funcinfo << endl;

  if ( mDownloadJob ) {
    kdDebug() << k_funcinfo << "Download still in progress" << endl;
    return;
  }

  KURL url = mBaseUrl;
  url.setPath( "/servlet/webdav.folders/file.xml" );

  QDomDocument doc;
  QDomElement root = WebdavHandler::addDavElement( doc, doc, "propfind" );
  QDomElement prop = WebdavHandler::addDavElement( doc, root, "prop" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "objectmode", "NEW_AND_MODIFIED" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "lastsync", "0" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "foldertype", "PRIVATE" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "foldertype", "PUBLIC" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "foldertype", "SHARED" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "foldertype", "GLOBALADDRESSBOOK" );
  WebdavHandler::addSloxElement( mRes, doc, prop, "foldertype", "INTERNALUSERS" );

  kdDebug() << k_funcinfo << doc.toString( 2 ) << endl;

  mDownloadJob = KIO::davPropFind( url, doc, "0", false );

  connect( mDownloadJob, SIGNAL( result( KIO::Job * ) ),
           SLOT( slotResult( KIO::Job * ) ) );
}
Example #28
0
void PanelBrowserMenu::mouseMoveEvent(QMouseEvent *e)
{
    QPopupMenu::mouseMoveEvent(e);

    if (!(e->state() & LeftButton)) return;
    if(_lastpress == QPoint(-1, -1)) return;

    // DND delay
    if((_lastpress - e->pos()).manhattanLength() < 12) return;

    // get id
    int id = idAt(_lastpress);
    if(!_filemap.contains(id)) return;

    // reset _lastpress
    _lastpress = QPoint(-1, -1);

    // start drag
    KURL url;
    url.setPath(path() + "/" + _filemap[id]);
    KURL::List files(url);
    KURLDrag *d = new KURLDrag(files, this);
    connect(d, SIGNAL(destroyed()), this, SLOT(slotDragObjectDestroyed()));
    d->setPixmap(iconSet(id)->pixmap());
    d->drag();
}
void MediaPlayerPrivate::load(const WTF::String& url)
{
    WTF::String modifiedUrl(url);

    if (modifiedUrl.startsWith("local://")) {
        KURL kurl = KURL(KURL(), modifiedUrl);
        kurl.setProtocol("file");
        WTF::String tempPath(BlackBerry::Platform::Settings::instance()->applicationLocalDirectory().c_str());
        tempPath.append(kurl.path());
        kurl.setPath(tempPath);
        modifiedUrl = kurl.string();
    }
    if (modifiedUrl.startsWith("file://")) {
        // The QNX Multimedia Framework cannot handle filenames containing URL escape sequences.
        modifiedUrl = decodeURLEscapeSequences(modifiedUrl);
    }

    void* tabId = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient();
    int playerID = m_webCorePlayer->mediaPlayerClient()->mediaPlayerHostWindow()->platformPageClient()->playerID();

    deleteGuardedObject(m_platformPlayer);
#if USE(ACCELERATED_COMPOSITING)
    m_platformPlayer = PlatformPlayer::create(this, tabId, true, modifiedUrl.utf8().data());
#else
    m_platformPlayer = PlatformPlayer::create(this, tabId, false, modifiedUrl.utf8().data());
#endif

    WTF::String cookiePairs;
    if (!url.isEmpty())
        cookiePairs = cookieManager().getCookie(KURL(ParsedURLString, url.utf8().data()), WithHttpOnlyCookies);
    if (!cookiePairs.isEmpty() && cookiePairs.utf8().data())
        m_platformPlayer->load(playerID, modifiedUrl.utf8().data(), m_webCorePlayer->userAgent().utf8().data(), cookiePairs.utf8().data());
    else
        m_platformPlayer->load(playerID, modifiedUrl.utf8().data(), m_webCorePlayer->userAgent().utf8().data(), 0);
}
Example #30
0
KalziumDataObject::KalziumDataObject()
{
	QDomDocument doc( "datadocument" );

	KURL url;
	url.setPath( locate("data", "kalzium/data/"));
	url.setFileName( "data.xml" );
	QFile layoutFile( url.path() );

	if (!layoutFile.exists())
	{
		kdDebug() << "data.xml not found, exiting" << endl;
		kapp->exit(0);
		return;
	}

	if (!layoutFile.open(IO_ReadOnly))
	{
		kdDebug() << "data.xml IO-error" << endl;
		return;
	}

	// Check if the document is well-formed
	if (!doc.setContent(&layoutFile))
	{
		kdDebug() << "wrong xml" << endl;
		layoutFile.close();
		return;
	}
	layoutFile.close();

	ElementList = readData( doc );
	m_numOfElements = ElementList.count();
}