void ContextMenuClientEfl::downloadURL(const KURL& url)
{
    if (!m_view)
        return;

    Ewk_Download download;

    CString downloadUrl = url.prettyURL().utf8();
    download.url = downloadUrl.data();
    ewk_view_download_request(m_view, &download);
}
Example #2
0
void TrashProtocol::get(const KURL &url)
{
    INIT_IMPL;
    kdDebug() << "get() : " << url << endl;
    if(!url.isValid())
    {
        kdDebug() << kdBacktrace() << endl;
        error(KIO::ERR_SLAVE_DEFINED, i18n("Malformed URL %1").arg(url.url()));
        return;
    }
    if(url.path().length() <= 1)
    {
        error(KIO::ERR_IS_DIRECTORY, url.prettyURL());
        return;
    }
    int trashId;
    QString fileId;
    QString relativePath;
    bool ok = TrashImpl::parseURL(url, trashId, fileId, relativePath);
    if(!ok)
    {
        error(KIO::ERR_SLAVE_DEFINED, i18n("Malformed URL %1").arg(url.prettyURL()));
        return;
    }
    const QString physicalPath = impl.physicalPath(trashId, fileId, relativePath);
    if(physicalPath.isEmpty())
    {
        error(impl.lastErrorCode(), impl.lastErrorMessage());
        return;
    }

    // Usually we run jobs in TrashImpl (for e.g. future kdedmodule)
    // But for this one we wouldn't use DCOP for every bit of data...
    KURL fileURL;
    fileURL.setPath(physicalPath);
    KIO::Job *job = KIO::get(fileURL);
    connect(job, SIGNAL(data(KIO::Job *, const QByteArray &)), this, SLOT(slotData(KIO::Job *, const QByteArray &)));
    connect(job, SIGNAL(mimetype(KIO::Job *, const QString &)), this, SLOT(slotMimetype(KIO::Job *, const QString &)));
    connect(job, SIGNAL(result(KIO::Job *)), this, SLOT(jobFinished(KIO::Job *)));
    qApp->eventLoop()->enterLoop();
}
void subversionCore::revert( const KURL::List& list ) {
	KURL servURL = "kdevsvn+svn://blah/";
	kdDebug(9036) << "Reverting servURL : " << servURL.prettyURL() << endl;
	
	QByteArray parms;
	QDataStream s( parms, IO_WriteOnly );
	int cmd = 8;
	s << cmd << list;
	SimpleJob * job = KIO::special(servURL, parms, false);
	job->setWindow( m_part->mainWindow()->main() );
	connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
}
Example #4
0
int main( int argc, char **argv )
{
    KApplication app(argc, argv, "kdirselectdialogtest");

    KURL u = KDirSelectDialog::selectDirectory( (argc >= 1) ? argv[1] : QString::null );
    if ( u.isValid() )
        KMessageBox::information( 0L,
                                QString::fromLatin1("You selected the url: %1")
                                .arg( u.prettyURL() ), "Selected URL" );

    return 0;
}
Example #5
0
void kio_afpProtocol::listDir( const KURL & url )
{
    kdDebug(7101) << "\n\nlistdir " << url.prettyURL() << endl;

    if (url.path().isEmpty()) {
       listVolumes(url);
    } else {
       listRealDir(url);
    }
    finished();
    return;
}
Example #6
0
/**
 * Test if the url contains a directory or a file.
 */
void LDAPProtocol::stat( const KURL &_url )
{
  kdDebug(7125) << "stat(" << _url << ")" << endl;

  TQStringList att,saveatt;
  LDAPUrl usrc(_url);
  LDAPMessage *msg;
  int ret, id;
  
  changeCheck( usrc );
  if ( !mLDAP ) {
    finished();
    return;
  }
  
  // look how many entries match
  saveatt = usrc.attributes();
  att.append( "dn" );
  usrc.setAttributes( att );
  if ( _url.query().isEmpty() ) usrc.setScope( LDAPUrl::One );
  
  if ( (id = asyncSearch( usrc )) == -1 ) {
    LDAPErr( _url );
    return;
  }
  
  kdDebug(7125) << "stat() getting result" << endl;
  do {
    ret = ldap_result( mLDAP, id, 0, NULL, &msg );
    if ( ret == -1 ) {
      LDAPErr( _url );
      return;
    }
    if ( ret == LDAP_RES_SEARCH_RESULT ) {
      ldap_msgfree( msg );
      error( ERR_DOES_NOT_EXIST, _url.prettyURL() );
      return;
    }
  } while ( ret != LDAP_RES_SEARCH_ENTRY );
  
  ldap_msgfree( msg );
  ldap_abandon( mLDAP, id );
  
  usrc.setAttributes( saveatt );
  
  UDSEntry uds;  
  bool critical;
  LDAPEntry2UDSEntry( usrc.dn(), uds, usrc, usrc.extension("x-dir", critical) != "base" );
  
  statEntry( uds );
  // we are done
  finished();
}
void XsldbgConfigImpl::slotChooseOutputFile()
{
	KURL url = KFileDialog::getSaveURL(QString::null, "*.xml; *.XML; *.Xml \n*.docbook \n *.txt; *.TXT \n *.htm;*.HTM;*.htm;*.HTML \n*.*", this,
									i18n("Choose Output File for XSL Transformation"));
	QString fileName;

	if (url.isLocalFile()){
	    fileName = url.prettyURL();
	    if ((!fileName.isNull()) && (fileName.length() > 0))
		outputFileEdit->setText(XsldbgDebugger::fixLocalPaths(fileName));
	}
}
Example #8
0
void RemoteProtocol::del(const KURL &url, bool /*isFile*/)
{
    kdDebug(1220) << "RemoteProtocol::del: " << url << endl;

    if(!m_impl.isWizardURL(url) && m_impl.deleteNetworkFolder(url.fileName()))
    {
        finished();
        return;
    }

    error(KIO::ERR_CANNOT_DELETE, url.prettyURL());
}
Example #9
0
void FileBrowser::setUrl( const KURL &url )
{
    m_dir->setFocus();
    if (!m_medium)
        m_dir->setURL( url, true );
    else {
        QString urlpath = url.isLocalFile() ? url.path() : url.prettyURL();
        KURL newURL( urlpath.prepend( m_medium->mountPoint() ).remove("..") );
        //debug() << "set-url-kurl: changing to: " << newURL.path() << endl;
        m_dir->setURL( newURL, true );
    }
}
Example #10
0
void subversionCore::del( const KURL::List& list ) {
	KURL servURL = "kdevsvn+svn://blah/";
	kdDebug(9036) << "Deleting servURL : " << servURL.prettyURL() << endl;
	
	QByteArray parms;
	QDataStream s( parms, IO_WriteOnly );
	int cmd = 7;
	s << cmd << list;
	// add/delete/revert works on local copy. Don't need to show progress dialog
	SimpleJob * job = KIO::special(servURL, parms, false);
	job->setWindow( m_part->mainWindow()->main() );
	connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
}
Example #11
0
bool KMiniEdit::loadFile(KURL newurl)
{
  if (newurl.isMalformed())
  {
    QString text = i18n("<b>The URL %1 is not correct!</b>");
    KMessageBox::sorry(this, text.arg(newurl.prettyURL()));
    return false;
  }

  QString filename;
  if (newurl.isLocalFile())
    filename = newurl.path();
  else
  {
    if (!KIO::NetAccess::download(newurl, filename))
    {
      QString text = i18n("<b>Error downloading %1!</b>");
      KMessageBox::sorry(this, text.arg(newurl.prettyURL()));
      return false;
    }
  }

  QFile file(filename);
  file.open(IO_ReadOnly);
  QTextStream stream(&file);
  //stream.setEncoding(QTextStream::Unicode);
  edit->setText(stream.read());
  file.close();

  KIO::NetAccess::removeTempFile(filename);

  url = newurl;

  addURLtoRecent();

  resetEdited();
  return true;
}
Example #12
0
void subversionCore::update( const KURL::List& list ) {
	KURL servURL = "kdevsvn+svn://blah/";
	kdDebug(9036) << "Updating. servURL : " << servURL.prettyURL() << endl;
	
	QByteArray parms;
	QDataStream s( parms, IO_WriteOnly );
	int cmd = 2;
	int rev = -1;
	s << cmd << list << rev << QString( "HEAD" );
	
	SimpleJob * job = KIO::special(servURL, parms, false);
	connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
	initProcessDlg( (KIO::Job*)job, i18n("Subversion Update") , i18n("Subversion Update") );
}
Example #13
0
void TrashProtocol::rename(const KURL &oldURL, const KURL &newURL, bool overwrite)
{
    INIT_IMPL;

    kdDebug() << "TrashProtocol::rename(): old=" << oldURL << " new=" << newURL << " overwrite=" << overwrite << endl;

    if(oldURL.protocol() == "trash" && newURL.protocol() == "trash")
    {
        error(KIO::ERR_CANNOT_RENAME, oldURL.prettyURL());
        return;
    }

    copyOrMove(oldURL, newURL, overwrite, Move);
}
Example #14
0
void MainWindow::openFile(const KURL& url)
{
  KFileItem file(KFileItem::Unknown, KFileItem::Unknown, url);
  if(file.isReadable())
  {
    if(m_tabEditor->openDocument(url))
    {
      m_actionRecent->addURL(url);
      return;
    }
  }

  m_actionRecent->removeURL(url);
  showSorry(QString("\"") + url.prettyURL() + "\" is unreadable.");
}
Example #15
0
void HTTPTracker::doAnnounce(const KURL & u)
{
    Out(SYS_TRK|LOG_NOTICE) << "Doing tracker request to url : " << u.prettyURL() << endl;
    KIO::MetaData md;
    setupMetaData(md);
    KIO::StoredTransferJob* j = KIO::storedGet(u,false,false);
    // set the meta data
    j->setMetaData(md);
    KIO::Scheduler::scheduleJob(j);

    connect(j,SIGNAL(result(KIO::Job* )),this,SLOT(onAnnounceResult( KIO::Job* )));

    active_job = j;
    requestPending();
}
Example #16
0
static void printToStandardOut(MessageLevel level, ExecState* exec, const ArgList& args, const KURL& url)
{
    if (!Console::shouldPrintExceptions())
        return;

    printSourceURLAndLine(url.prettyURL(), 0);
    printMessageSourceAndLevelPrefix(JSMessageSource, level);

    for (size_t i = 0; i < args.size(); ++i) {
        UString argAsString = args.at(exec, i)->toString(exec);
        printf(" %s", argAsString.UTF8String().c_str());
    }

    printf("\n");
}
Example #17
0
void MediaProtocol::mkdir(const KURL &url, int permissions)
{
    kdDebug(1219) << "MediaProtocol::mkdir: " << url << endl;

    QString name, path;
    bool ok = m_impl.parseURL(url, name, path);

    if ( ok && path.isEmpty() )
    {
        error(KIO::ERR_COULD_NOT_MKDIR, url.prettyURL());
    }
    else
    {
        ForwardingSlaveBase::mkdir(url, permissions);
    }
}
Example #18
0
void MediaProtocol::del(const KURL &url, bool isFile)
{
    kdDebug(1219) << "MediaProtocol::del: " << url << endl;

    QString name, path;
    bool ok = m_impl.parseURL(url, name, path);

    if ( ok && path.isEmpty() )
    {
        error(KIO::ERR_CANNOT_DELETE, url.prettyURL());
    }
    else
    {
        ForwardingSlaveBase::del(url, isFile);
    }
}
Example #19
0
bool KSnapshot::save( const KURL& url )
{
    if ( KIO::NetAccess::exists( url, false, this ) ) {
        const QString title = i18n( "File Exists" );
        const QString text = i18n( "<qt>Do you really want to overwrite <b>%1</b>?</qt>" ).arg(url.prettyURL());
        if (KMessageBox::Continue != KMessageBox::warningContinueCancel( this, text, title, i18n("Overwrite") ) ) 
        {
            return false;
        }
    }

    QString type( KImageIO::type(url.path()) );
    if ( type.isNull() )
	type = "PNG";

    bool ok = false;

    if ( url.isLocalFile() ) {
	KSaveFile saveFile( url.path() );
	if ( saveFile.status() == 0 ) {
	    if ( snapshot.save( saveFile.file(), type.latin1() ) )
		ok = saveFile.close();
	}
    }
    else {
	KTempFile tmpFile;
        tmpFile.setAutoDelete( true );
	if ( tmpFile.status() == 0 ) {
	    if ( snapshot.save( tmpFile.file(), type.latin1() ) ) {
		if ( tmpFile.close() )
		    ok = KIO::NetAccess::upload( tmpFile.name(), url, this );
	    }
	}
    }

    QApplication::restoreOverrideCursor();
    if ( !ok ) {
	kdWarning() << "KSnapshot was unable to save the snapshot" << endl;

	QString caption = i18n("Unable to save image");
	QString text = i18n("KSnapshot was unable to save the image to\n%1.")
	               .arg(url.prettyURL());
	KMessageBox::error(this, text, caption);
    }

    return ok;
}
Example #20
0
void LANProtocol::mimetype( const KURL& url)
{
   kdDebug(7101)<<"LANProtocol::mimetype -"<<url.prettyURL()<<"-"<<endl;
   QString path( QFile::encodeName(url.path()));
   QStringList pathList=QStringList::split( "/",path);
   if ((pathList.count()==2) && (pathList[1].upper()=="HTTP"))
   {
      //kdDebug(7101)<<"LANProtocol::mimeType text/html"<<endl;
      mimeType("text/html");
   }
   else
   {
      mimeType("inode/directory");
      //kdDebug(7101)<<"LANProtocol::mimeType inode/directory"<<endl;
   }
   finished();
}
Example #21
0
void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags)
{
    // check if the element is a link...
    bool isLink = hit.isLiveLink();
    if (isLink) {
        KURL url = hit.absoluteLinkURL();
        if (!url.isEmpty() && url != m_hoveredLinkURL) {
            CString titleString = hit.title().utf8();
            CString urlString = url.prettyURL().utf8();
            g_signal_emit_by_name(m_webView, "hovering-over-link", titleString.data(), urlString.data());
            m_hoveredLinkURL = url;
        }
    } else if (!isLink && !m_hoveredLinkURL.isEmpty()) {
        g_signal_emit_by_name(m_webView, "hovering-over-link", 0, 0);
        m_hoveredLinkURL = KURL();
    }
}
Example #22
0
void MediaProtocol::put(const KURL &url, int permissions,
                        bool overwrite, bool resume)
{
    kdDebug(1219) << "MediaProtocol::put: " << url << endl;

    QString name, path;
    bool ok = m_impl.parseURL(url, name, path);

    if ( ok && path.isEmpty() )
    {
        error(KIO::ERR_CANNOT_OPEN_FOR_WRITING, url.prettyURL());
    }
    else
    {
        ForwardingSlaveBase::put(url, permissions, overwrite, resume);
    }
}
Example #23
0
void KSB_MediaWidget::playerFinished()
{
	if( m_kuri_list.count() > 0 )
	{
		KURL kurl = m_kuri_list.first();
		m_kuri_list.remove( kurl );
		bool validFile = player->openFile( kurl );
		if (validFile) {
			currentFile->setText( kurl.fileName() );
			player->play();
			needLengthUpdate=true;
			pretty=kurl.prettyURL();
		} else {
			currentFile->setText( i18n("Not a sound file") );
			playerFinished();
		}
	}
}
Example #24
0
inline void
FileBrowser::urlChanged( const KURL &u )
{
    //the DirOperator's URL has changed

    QString url = u.isLocalFile() ? u.path() : u.prettyURL();

    if( m_medium ){
        //remove the leading mountPoint value
        url.remove( 0, m_medium->mountPoint().length() );
    }

    QStringList urls = m_combo->urls();
    urls.remove( url );
    urls.prepend( url );

    m_combo->setURLs( urls, KURLComboBox::RemoveBottom );
}
Example #25
0
bool SystemProtocol::rewriteURL(const KURL &url, KURL &newUrl)
{
    QString name, path;

    if(!m_impl.parseURL(url, name, path))
    {
        error(KIO::ERR_MALFORMED_URL, url.prettyURL());
        return false;
    }

    if(!m_impl.realURL(name, path, newUrl))
    {
        error(m_impl.lastErrorCode(), m_impl.lastErrorMessage());
        return false;
    }

    return true;
}
Example #26
0
void KexiImageContextMenu::insertFromFile()
{
//	QWidget *focusWidget = qApp->focusWidget();
#ifdef Q_WS_WIN
	QString recentDir;
	QString fileName = QFileDialog::getOpenFileName(
		KFileDialog::getStartURL(":LastVisitedImagePath", recentDir).path(), 
		convertKFileDialogFilterToQFileDialogFilter(KImageIO::pattern(KImageIO::Reading)), 
		this, 0, i18n("Insert Image From File"));
	KURL url;
	if (!fileName.isEmpty())
		url.setPath( fileName );
#else
	KURL url( KFileDialog::getImageOpenURL(
		":LastVisitedImagePath", this, i18n("Insert Image From File")) );
//	QString fileName = url.isLocalFile() ? url.path() : url.prettyURL();

	//! @todo download the file if remote, then set fileName properly
#endif
	if (!url.isValid()) {
		//focus the app again because to avoid annoying the user with unfocused main window
		if (qApp->mainWidget()) {
			//focusWidget->raise();
			//focusWidget->setFocus();
			qApp->mainWidget()->raise();
		}
		return;
	}
	kexipluginsdbg << "fname=" << url.prettyURL() << endl;

#ifdef Q_WS_WIN
	//save last visited path
//	KURL url(fileName);
	if (url.isLocalFile())
		KRecentDirs::add(":LastVisitedImagePath", url.directory());
#endif

	emit insertFromFileRequested(url);
	if (qApp->mainWidget()) {
//		focusWidget->raise();
//		focusWidget->setFocus();
		qApp->mainWidget()->raise();
	}
}
/** No descriptions */
void ProjectNewLocal::slotAddFolder()
{
//TODO/FIXME: This returns null if the selected directory is not on the local disk.
//I think this is a KDE bug
  QExtFileInfo::createDir(baseURL, this);
  KURL dirURL ;
  dirURL = KFileDialog::getExistingURL(
           baseURL.url(),  this, i18n("Insert Folder in Project"));

  if ( !dirURL.isEmpty() )
  {
    dirURL.adjustPath(1);

    KURL sdir = dirURL;
    sdir = QExtFileInfo::toRelative( sdir, baseURL, false);

    if ( sdir.path().startsWith("..") || sdir.path().startsWith("/") )
    {

      KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( baseURL.prettyURL(), this, "");
      urlRequesterDlg->setCaption(i18n("%1: Copy to Project").arg(dirURL.prettyURL(0, KURL::StripFileProtocol)));
      urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly);
      urlRequesterDlg->exec();
      KURL destination = urlRequesterDlg->selectedURL();
      delete urlRequesterDlg;

      if ( !destination.isEmpty())
      {
        CopyTo *dlg = new CopyTo( baseURL);
        connect(dlg, SIGNAL(addFilesToProject(const KURL::List&)),
                     SLOT  (slotInsertFolderAfterCopying(const KURL::List&)));
        connect(dlg, SIGNAL(deleteDialog(CopyTo *)),
                     SLOT  (slotDeleteCopyToDialog(CopyTo *)));
        dirURL = dlg->copy(dirURL, destination);
        return;
      } else
      {
        return;
      }
    }

    slotInsertFolderAfterCopying(dirURL);
  }
}
void KNetworkProtocol::operationRemove(QNetworkOperation* op)
{
    KURL kurl = convertURL(url());
    kurl = KURL(kurl.prettyURL() + "/" + op->arg(0));

    KIO::Job* job = KIO::del(kurl);
    if (job == 0)
    {
        op->setState(StFailed);
        emit finished(op);
        return;
    }

    m_operations.insert(job, op);
    connectJob(job);

    op->setState(StInProgress);
    emit start(op);
}
Example #29
0
void subversionCore::resolve( const KURL::List& list ) {
	KURL servURL = m_part->baseURL();
	if ( servURL.isEmpty() ) servURL="kdevsvn+svn://blah/";
	if ( ! servURL.protocol().startsWith( "kdevsvn+" ) ) {
		servURL.setProtocol( "kdevsvn+" + servURL.protocol() ); //make sure it starts with "svn"
	}
	kdDebug(9036) << "servURL : " << servURL.prettyURL() << endl;
	for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) {
		kdDebug(9036) << "resolving: " << (*it).prettyURL() << endl;
		QByteArray parms;
		QDataStream s( parms, IO_WriteOnly );
		int cmd = 11;
		bool recurse = true;
		s << cmd << *it << recurse;
		SimpleJob * job = KIO::special(servURL, parms, true);
		job->setWindow( m_part->mainWindow()->main() );
		connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) );
	}
}
void WebFrameLoaderClient::setTitle(const String& title, const KURL& url)
{
#if PLATFORM(AMIGAOS4)
    if (!m_webFrame->parentFrame()) {
        BalWidget* viewWindow = m_webFrame->webView()->viewWindow();
        if (viewWindow && viewWindow->window) {
            CString titleLatin1 = title.latin1();
            const char *titlestr = titleLatin1.data();
            if (titlestr && titlestr[0])
                snprintf(viewWindow->title, sizeof(viewWindow->title), "OWB: %s", titlestr);
            else
                strcpy(viewWindow->title, "Origyn Web Browser");
            IIntuition->SetWindowTitles(viewWindow->window, viewWindow->title, (STRPTR)~0UL);

            CString urlLatin1 = url.prettyURL().latin1();
            const char *urlstr = urlLatin1.data();
            if (urlstr && urlstr[0] && viewWindow->gad_url) {
                snprintf(viewWindow->url, sizeof(viewWindow->url), "%s", urlstr);
                IIntuition->RefreshSetGadgetAttrs(viewWindow->gad_url, viewWindow->window, NULL,
                                                  STRINGA_TextVal, viewWindow->url,
                                                  TAG_DONE);
            }
        }
    }
#endif
    bool privateBrowsingEnabled = false;
    WebPreferences* preferences = m_webFrame->webView()->preferences();
    if (preferences)
        privateBrowsingEnabled = preferences->privateBrowsingEnabled();
    if (privateBrowsingEnabled)
        return;

    // update title in global history
    WebHistory* history = webHistory();
    if (!history)
        return;

    WebHistoryItem* item = history->itemForURL(url.string());
    if (!item)
        return;

    item->setTitle(title);
}