Exemple #1
0
void DOMTreeView::slotSaveClicked()
{
  //kdDebug(90180) << "void KfingerCSSWidget::slotSaveAs()" << endl;
  KURL url = KFileDialog::getSaveFileName( part->url().url(), "*.html",
					   this, i18n("Save DOM Tree as HTML") );
  if (!(url.isEmpty()) && url.isValid()) {
    QFile file(url.path());

    if (file.exists()) {
      const QString title = i18n( "File Exists" );
      const QString text = i18n( "Do you really want to overwrite: \n%1?" ).arg(url.url());
      if (KMessageBox::Continue != KMessageBox::warningContinueCancel(this, text, title, i18n("Overwrite") ) ) {
	return;
      }
    }

    if (file.open(IO_WriteOnly) ) {
      kdDebug(90180) << "Opened File: " << url.url() << endl;
      m_textStream = new QTextStream(&file); //(stdOut)
      saveTreeAsHTML(part->document());
      file.close();
      kdDebug(90180) << "File closed " << endl;
      delete m_textStream;
    } else {
      const QString title = i18n( "Unable to Open File" );
      const QString text = i18n( "Unable to open \n %1 \n for writing" ).arg(url.path());
      KMessageBox::sorry( this, text, title );
    }
  } else {
    const QString title = i18n( "Invalid URL" );
    const QString text = i18n( "This URL \n %1 \n is not valid." ).arg(url.url());
    KMessageBox::sorry( this, text, title );
  }
}
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;
    }
}
Exemple #3
0
bool
HelixEngine::load( const KURL &url, bool isStream )
{
   debug() << "In load " << url.url() << endl;

   if (!m_inited)
      return false;

   if (!canDecode(url))
   {
      const QString path = url.path();
      const QString ext  = path.mid( path.findRev( '.' ) + 1 ).lower();
      emit statusText( i18n("No plugin found for the %1 format").arg(ext) );
      return false;
   }

   debug() << "xfadeLength is " << m_xfadeLength << endl;
   if( m_xfadeLength > 0 && m_state == Engine::Playing )
   {
      int nextPlayer = m_current ? 0 : 1;

      // prepare the next player
      PlayerControl::stop(nextPlayer);
      resetScope(nextPlayer);
      memset(&hscope[nextPlayer], 0, sizeof(HelixScope));
      memset(&m_pfade[nextPlayer], 0, sizeof(FadeTrack));

      if (isPlaying(m_current))
      {
         m_pfade[m_current].m_fadeactive = true;
         m_pfade[m_current].m_startfadetime = PlayerControl::where(m_current);
         setFadeout(true, m_xfadeLength, m_current);
      }
      Engine::Base::load( url, false ); // we dont crossfade streams ?? do we load the base here ??
      PlayerControl::setURL( QFile::encodeName( url.url() ), nextPlayer, !isStream );
      m_isStream = false;
   }
   else
      cleanup();

   m_isStream = isStream;
   int nextPlayer;

   nextPlayer = m_current ? 0 : 1;

   Engine::Base::load( url, isStream || url.protocol() == "http" );
   m_state = Engine::Idle;
   emit stateChanged( Engine::Idle );
   m_url = url;

   if (url.isLocalFile())
      PlayerControl::setURL( QFile::encodeName( url.url() ), nextPlayer, !m_isStream );
   else
   {
      m_isStream = true;
      PlayerControl::setURL( QFile::encodeName( url.url() ), nextPlayer, !m_isStream );
   }

   return true;
}
Exemple #4
0
bool PreviewJob::statResultThumbnail()
{
    if ( d->thumbPath.isEmpty() )
        return false;

    KURL url = d->currentItem.item->url();
    // Don't include the password if any
    url.setPass(TQString::null);
    // The TMS defines local files as file:///path/to/file instead of KDE's
    // way (file:/path/to/file)
#ifdef KURL_TRIPLE_SLASH_FILE_PROT
    d->origName = url.url();
#else
    if (url.protocol() == "file") d->origName = "file://" + url.path();
    else d->origName = url.url();
#endif

    KMD5 md5( TQFile::encodeName( d->origName ).data() );
    d->thumbName = TQFile::encodeName( md5.hexDigest() ) + ".png";

    TQImage thumb;
    if ( !thumb.load( d->thumbPath + d->thumbName ) ) return false;

    if ( thumb.text( "Thumb::URI", 0 ) != d->origName ||
         thumb.text( "Thumb::MTime", 0 ).toInt() != d->tOrig ) return false;

    // Found it, use it
    emitPreview( thumb );
    d->succeeded = true;
    determineNextFile();
    return true;
}
Exemple #5
0
void GroupDavAddressBookAdaptor::customAdaptUploadUrl( KURL &url )
{
kdDebug()<<"GroupDavAddressBookAdaptor::adaptUploadUrl( "<<url.url()<<")"<<endl;
  url = WebdavHandler::toDAV( url );
//   url.setPath( url.path() + "/new.vcf" );
// url.addPath( "new.vcf" );
kdDebug()<<"after GroupDavAddressBookAdaptor::adaptUploadUrl( "<<url.url()<<")"<<endl;
}
Exemple #6
0
KIO::filesize_t K3b::imageFilesize( const KURL& url )
{
  KIO::filesize_t size = K3b::filesize( url );
  int cnt = 0;
  while( KIO::NetAccess::exists( KURL::fromPathOrURL( url.url() + '.' + QString::number(cnt).rightJustify( 3, '0' ) ), true ) )
    size += K3b::filesize( KURL::fromPathOrURL( url.url() + '.' + QString::number(cnt++).rightJustify( 3, '0' ) ) );
  return size;
}
Exemple #7
0
void KMWIppSelect::updatePrinter(KMPrinter *p)
{
	KURL	url = p->device();
	QString	path = m_list->currentText();
	path.prepend("/printers/");
	url.setPath(path);
	p->setDevice(url.url());
kdDebug(500) << url.url() << endl;
}
Exemple #8
0
/*
        bundle->setUrl( Amarok::QStringx("http://%1:3689/databases/%2/items/%3.%4?%5").args(
            QStringList() << m_host
                        << m_databaseId
                        << QString::number( (*it).asMap()["miid"].asList()[0].asInt() )
                        << (*it).asMap()["asfm"].asList()[0].asString()
                        << m_loginString ) );

*/
Proxy::Proxy(KURL stream, DaapClient* client, const char* name)
    : QObject(client, name)
    , m_proxy( new Amarok::ProcIO() )
{
    DEBUG_BLOCK
    //find the request id and increment it
    const QString hostKey = stream.host() + ':' + QString::number(stream.port());
    const int revisionId = client->incRevision( hostKey );
    const int sessionId = client->getSession( hostKey );
    //compose URL
    KURL realStream = realStreamUrl( stream, sessionId );

    //get hash
    char hash[33] = {0};
    GenerateHash( 3
        , reinterpret_cast<const unsigned char*>((realStream.path() + realStream.query()).ascii())
        , 2
        , reinterpret_cast<unsigned char*>(hash)
        , revisionId );

    // Find free port
    MyServerSocket* socket = new MyServerSocket();
    const int port = socket->port();
    debug() << "Proxy server using port: " << port << endl;
    delete socket;
    m_proxyUrl = KURL( QString("http://localhost:%1/daap.mp3").arg( port ) );
    //start proxy
    m_proxy->setComm( KProcess::Communication( KProcess::AllOutput ) );
    *m_proxy << "amarok_proxy.rb";
    *m_proxy << "--daap";
    *m_proxy << QString::number( port );
    *m_proxy << realStream.url();
    *m_proxy << AmarokConfig::soundSystem();
    *m_proxy << hash;
    *m_proxy << QString::number( revisionId );
    *m_proxy << Amarok::proxyForUrl( realStream.url() );

    if( !m_proxy->start( KProcIO::NotifyOnExit, true ) ) {
        error() << "Failed to start amarok_proxy.rb" << endl;
        return;
    }

    QString line;
    while( true ) {
        kapp->processEvents();
        m_proxy->readln( line );
        if( line == "AMAROK_PROXY: startup" ) break;
    }
    debug() << "started amarok_proxy.rb --daap " << QString::number( port ) << ' ' << realStream.url() << ' ' << AmarokConfig::soundSystem() << ' ' << hash << ' ' << revisionId << endl;
    connect( m_proxy, SIGNAL( processExited( KProcess* ) ), this, SLOT( playbackStopped() ) );
    connect( m_proxy, SIGNAL( readReady( KProcIO* ) ), this, SLOT( readProxy() ) );
}
Exemple #9
0
//-----------------------------------------------------------------------------
HighscoresWidget::HighscoresWidget(QWidget *parent)
    : QWidget(parent, "show_highscores_widget"),
      _scoresUrl(0), _playersUrl(0), _statsTab(0), _histoTab(0)
{
    const ScoreInfos &s = internal->scoreInfos();
    const PlayerInfos &p = internal->playerInfos();

    QVBoxLayout *vbox = new QVBoxLayout(this, KDialogBase::spacingHint());

    _tw = new QTabWidget(this);
    connect(_tw, SIGNAL(currentChanged(QWidget *)), SLOT(tabChanged()));
    vbox->addWidget(_tw);

    // scores tab
    _scoresList = new HighscoresList(_tw);
    _scoresList->addHeader(s);
    _tw->addTab(_scoresList, i18n("Best &Scores"));

    // players tab
    _playersList = new HighscoresList(_tw);
    _playersList->addHeader(p);
    _tw->addTab(_playersList, i18n("&Players"));

    // statistics tab
    if ( internal->showStatistics ) {
        _statsTab = new StatisticsTab(_tw);
        _tw->addTab(_statsTab, i18n("Statistics"));
    }

    // histogram tab
    if ( p.histogram().size()!=0 ) {
        _histoTab = new HistogramTab(_tw);
        _tw->addTab(_histoTab, i18n("Histogram"));
    }

    // url labels
    if ( internal->isWWHSAvailable() ) {
        KURL url = internal->queryURL(ManagerPrivate::Scores);
        _scoresUrl = new KURLLabel(url.url(),
                                   i18n("View world-wide highscores"), this);
        connect(_scoresUrl, SIGNAL(leftClickedURL(const QString &)),
                SLOT(showURL(const QString &)));
        vbox->addWidget(_scoresUrl);

        url = internal->queryURL(ManagerPrivate::Players);
        _playersUrl = new KURLLabel(url.url(),
                                    i18n("View world-wide players"), this);
        connect(_playersUrl, SIGNAL(leftClickedURL(const QString &)),
                SLOT(showURL(const QString &)));
        vbox->addWidget(_playersUrl);
    }
}
Exemple #10
0
bool KPartSaver::openURL( KURL url )
{
    closeURL();

    // find mime type
    TQString mime = KMimeType::findByURL( url )->name();

    // find fitting kparts
    KTrader::OfferList offers;
    offers = KTrader::self()->query( mime, "'KParts/ReadOnlyPart' in ServiceTypes" );
    if( offers.count()==0 ) {
        kdDebug() << "Can't find proper kpart for " << mime << endl;
        return false;
    }

    // load kpart library
    TQString lib = offers.first()->library();
    KLibFactory *factory = KLibLoader::self()->factory( lib.latin1() );
    if( !factory ) {
        kdDebug() << "Library " << lib << " not found." << endl;
        return false;
    }

    // create kpart
    m_part = (KParts::ReadOnlyPart *)factory->create( TQT_TQOBJECT(this), "kpart", "KParts::ReadOnlyPart" );
    if( !m_part ) {
        kdDebug() << "Part for " << url.url() << " can't be constructed" << endl;
        return false;
    } else
        embed( m_part->widget() );

    // show kpart
    delete m_back;
    m_back = 0;

    show();
    m_part->widget()->show();

    // load url
    if( !m_part->openURL( url ) ) {
        kdDebug() << "Can't load " << url.url() << endl;
        closeURL();
        return false;
    }



    return true;
}
Exemple #11
0
void kerp::load(const KURL& url)
{
    QString target;
    // the below code is what you should normally do.  in this
    // example case, we want the url to our own.  you probably
    // want to use this code instead for your app

    #if 0
    // download the contents
    if (KIO::NetAccess::download(url, target))
    {
        // set our caption
        setCaption(url);

        // load in the file (target is always local)
        loadFile(target);

        // and remove the temp file
        KIO::NetAccess::removeTempFile(target);
    }
    #endif

    setCaption(url.url());
   // m_view->openURL(url);
}
Exemple #12
0
bool GMXXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
{
  KURL url = KFileDialog::getSaveURL( ":xxport_gmx", GMX_FILESELECTION_STRING );
  if ( url.isEmpty() )
      return true;

  if ( !url.isLocalFile() ) {
    KTempFile tmpFile;
    if ( tmpFile.status() != 0 ) {
      QString txt = i18n( "<qt>Unable to open file <b>%1</b>.%2.</qt>" );
      KMessageBox::error( parentWidget(), txt.arg( url.url() )
                          .arg( strerror( tmpFile.status() ) ) );
      return false;
    }

    doExport( tmpFile.file(), list );
    tmpFile.close();

    return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() );
  } else {
    QString filename = url.path();
    QFile file( filename );

    if ( !file.open( IO_WriteOnly ) ) {
      QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
      KMessageBox::error( parentWidget(), txt.arg( filename ) );
      return false;
    }

    doExport( &file, list );
    file.close();

    return true;
  }
}
Exemple #13
0
void TrashProtocol::stat(const KURL &url)
{
    INIT_IMPL;
    const QString path = url.path();
    if(path.isEmpty() || path == "/")
    {
        // The root is "virtual" - it's not a single physical directory
        KIO::UDSEntry entry;
        createTopLevelDirEntry(entry);
        statEntry(entry);
        finished();
    }
    else
    {
        int trashId;
        QString fileId, relativePath;

        bool ok = TrashImpl::parseURL(url, trashId, fileId, relativePath);

        if(!ok)
        {
            // ######## do we still need this?
            kdDebug() << k_funcinfo << url << " looks fishy, returning does-not-exist" << endl;
            // A URL like trash:/file simply means that CopyJob is trying to see if
            // the destination exists already (it made up the URL by itself).
            error(KIO::ERR_DOES_NOT_EXIST, url.prettyURL());
            // error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1" ).arg( url.prettyURL() ) );
            return;
        }

        const QString filePath = impl.physicalPath(trashId, fileId, relativePath);
        if(filePath.isEmpty())
        {
            error(impl.lastErrorCode(), impl.lastErrorMessage());
            return;
        }

        QString fileName = filePath.section('/', -1, -1, QString::SectionSkipEmpty);

        QString fileURL = QString::null;
        if(url.path().length() > 1)
        {
            fileURL = url.url();
        }

        KIO::UDSEntry entry;
        TrashedFileInfo info;
        ok = impl.infoForFile(trashId, fileId, info);
        if(ok)
            ok = createUDSEntry(filePath, fileName, fileURL, entry, info);

        if(!ok)
        {
            error(KIO::ERR_COULD_NOT_STAT, url.prettyURL());
        }

        statEntry(entry);
        finished();
    }
}
void SiteSettingsDialog::populate(const QString& name, const KURL& url,
                                  const KURL& remoteBaseDir, const KURL& localBaseDir,
                                  const KURL& defaultFile, const QString& debuggerName,
                                  QMap<QString,QString>& mappings)
{
  m_edName->setText(name);
  m_edUrl->setText(url.url());
  m_edRemoteBaseDir->setText(remoteBaseDir.pathOrURL());
  m_edLocalBaseDir->setURL(localBaseDir.pathOrURL());
  m_edDefaultFile->setURL(defaultFile.pathOrURL());

  QMap<QString, QString>::iterator it;
  QString dlabel;
  for(it = m_debuggerMap.begin(); it != m_debuggerMap.end(); ++it) 
  {
    if(it.data() == debuggerName)
    {
      dlabel = it.key();
      break;
    }
  }
  if(!dlabel.isEmpty())
  {
    m_cbDebuggerName->setCurrentText(dlabel);
  }
  
  m_mappingWidget->setMappings(mappings);
}
bool SearchManager::checkable(KURL const& url, LinkStatus const& link_parent) const
{
    if(existUrl(url, link_parent.absoluteUrl()))
        return false;

    if(!checkableByDomain(url, link_parent))
        return false;

    if(!check_parent_dirs_)
    {
        if(Url::parentDir(root_.absoluteUrl(), url))
            return false;
    }
    if(!check_external_links_)
    {
        if(Url::externalLink(root_.absoluteUrl(), url))
            return false;
    }
    if(check_regular_expressions_)
    {
        Q_ASSERT(!reg_exp_.isEmpty());

        if(reg_exp_.search(url.url()) != -1)
            return false;
    }

    //kdDebug(23100) <<  "url " << url.url() << " is checkable!" << endl;
    return true;
}
Exemple #16
0
void KonqSidebarTree::FilesAdded( const KURL & dir )
{
    kdDebug(1201) << "KonqSidebarTree::FilesAdded " << dir.url() << endl;
    if ( m_dirtreeDir.dir.isParentOf( dir ) )
        // We use a timer in case of DCOP re-entrance..
        QTimer::singleShot( 0, this, SLOT( rescanConfiguration() ) );
}
Exemple #17
0
void KOrganizerApp::processCalendar( const KURL &url )
{
  KOrg::MainWindow *korg = ActionManager::findInstance( url );
  if ( !korg ) {
    bool hasDocument = !url.isEmpty();
    korg = new KOrganizer( "KOrganizer MainWindow" );
    korg->init( hasDocument );
    korg->topLevelWidget()->show();

    kdDebug(5850) << "KOrganizerApp::processCalendar(): '" << url.url()
                  << "'" << endl;

    if ( hasDocument )
      korg->openURL( url );
    else {
      KOrg::StdCalendar::self()->load();
      korg->view()->updateCategories();
      korg->view()->updateView();
    }
  } else {
    korg->topLevelWidget()->show();
  }

  // Handle window activation
#if defined Q_WS_X11 && ! defined K_WS_QTONLY
  KStartupInfo::setNewStartupId( korg->topLevelWidget(), startupId() );
#endif
}
Exemple #18
0
void KeyWidget::addKey()
{
  QMap<QString, int> keyMap;
  QStringList keyTypeNames;
  QStringList existingKeyTypes;

  KABC::Key::List::ConstIterator listIt;
  for ( listIt = mKeyList.begin(); listIt != mKeyList.end(); ++listIt ) {
    if ( (*listIt).type() != KABC::Key::Custom )
      existingKeyTypes.append( KABC::Key::typeLabel( (*listIt).type() ) );
  }

  KABC::Key::TypeList typeList = KABC::Key::typeList();
  KABC::Key::TypeList::ConstIterator it;
  for ( it = typeList.begin(); it != typeList.end(); ++it ) {
    if ( (*it) != KABC::Key::Custom &&
         !existingKeyTypes.contains( KABC::Key::typeLabel( *it ) ) ) {
      keyMap.insert( KABC::Key::typeLabel( *it ), *it );
      keyTypeNames.append( KABC::Key::typeLabel( *it ) );
    }
  }

  bool ok;
  QString name = KInputDialog::getItem( i18n( "Key Type" ), i18n( "Select the key type:" ), keyTypeNames, 0, true, &ok );
  if ( !ok || name.isEmpty() )
    return;

  int type = keyMap[ name ];
  if ( !keyTypeNames.contains( name ) )
    type = KABC::Key::Custom;

  KURL url = KFileDialog::getOpenURL();
  if ( url.isEmpty() )
    return;

  QString tmpFile;
  if ( KIO::NetAccess::download( url, tmpFile, this ) ) {
    QFile file( tmpFile );
    if ( !file.open( IO_ReadOnly ) ) {
      QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
      KMessageBox::error( this, text.arg( url.url() ) );
      return;
    }

    QTextStream s( &file );
    QString data;

    s.setEncoding( QTextStream::UnicodeUTF8 );
    s >> data;
    file.close();

    KABC::Key key( data, type );
    if ( type == KABC::Key::Custom )
      key.setCustomTypeString( name );
    mKeyList.append( key );

    emit changed();

    KIO::NetAccess::removeTempFile( tmpFile );
  }
Exemple #19
0
String cookies(const KURL& url)
{
    DeprecatedString str = url.url();
    char domainBuffer[SIZE_OF_LATIN1_BUFFERS];
    char pathBuffer[SIZE_OF_LATIN1_BUFFERS];
    int tl_domainLocationInUrlBegins = str.find("://") + SIZE_OF_COLONSLASHSLASH;
    int tl_domainLocationInUrlEnds = str.find("/",tl_domainLocationInUrlBegins) - 1;
    int tl_pathLocationInUrlEnds = str.findRev("/");
    
    strncpy(domainBuffer, str.ascii() + tl_domainLocationInUrlBegins, tl_domainLocationInUrlEnds - tl_domainLocationInUrlBegins + 1);
    domainBuffer[tl_domainLocationInUrlEnds - tl_domainLocationInUrlBegins + 1] = '\0';

    strncpy(pathBuffer, str.ascii() + tl_domainLocationInUrlEnds + 1, tl_pathLocationInUrlEnds - tl_domainLocationInUrlEnds);
    pathBuffer[tl_pathLocationInUrlEnds - tl_domainLocationInUrlEnds] = '\0';

    char* cookStr = WebKitApollo::g_HostFunctions->getJavaScriptCookies(domainBuffer,pathBuffer);
    if(!cookStr)
    {
        return String();
    }

    String cookieString(cookStr);
    ::free(cookStr);
    return cookieString;
}
String cookies(const KURL& url)
{
#if USE(CFNETWORK)
    CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage();
    if (!defaultCookieStorage)
        return String();

    String cookieString;
    RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());

    bool secure = equalIgnoringCase(url.protocol(), "https");

    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(defaultCookieStorage, urlCF.get(), secure));
    RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get()));

    return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
#else
    DeprecatedString str = url.url();
    str.append((UChar)'\0');

    DWORD count = str.length();
    InternetGetCookie((UChar*)str.unicode(), 0, 0, &count);
    if (count <= 1) // Null terminator counts as 1.
        return String();

    UChar* buffer = new UChar[count];
    InternetGetCookie((UChar*)str.unicode(), 0, buffer, &count);
    String& result = String(buffer, count-1); // Ignore the null terminator.
    delete[] buffer;
    return result;
#endif
}
void setCookies(const KURL& url, const KURL& policyURL, const String& value)
{
#if USE(CFNETWORK)
    CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage();
    if (!defaultCookieStorage)
        return;

    RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
    RetainPtr<CFURLRef> policyURLCF(AdoptCF, policyURL.createCFURL());

    // <http://bugzilla.opendarwin.org/show_bug.cgi?id=6531>, <rdar://4409034>
    // cookiesWithResponseHeaderFields doesn't parse cookies without a value
    String cookieString = value.contains('=') ? value : value + "=";

    RetainPtr<CFStringRef> cookieStringCF(AdoptCF, cookieString.createCFString());
    RetainPtr<CFDictionaryRef> headerFieldsCF(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, (const void**)&s_setCookieKeyCF, 
        (const void**)&cookieStringCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));

    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault,
        headerFieldsCF.get(), urlCF.get()));

    CFHTTPCookieStorageSetCookies(defaultCookieStorage, cookiesCF.get(), urlCF.get(), policyURLCF.get());
#else
    // FIXME: Deal with the policy URL.
    DeprecatedString str = url.url();
    str.append((UChar)'\0');
    DeprecatedString val = value.deprecatedString();
    val.append((UChar)'\0');
    InternetSetCookie((UChar*)str.unicode(), 0, (UChar*)val.unicode());
#endif
}
Exemple #22
0
void KURLBar::setCurrentItem(const KURL &url)
{
    d->currentURL = url;

    QString u = url.url(-1);

    if(m_activeItem && m_activeItem->url().url(-1) == u)
        return;

    bool hasURL = false;
    QListBoxItem *item = m_listBox->firstItem();
    while(item)
    {
        if(static_cast< KURLBarItem * >(item)->url().url(-1) == u)
        {
            m_activeItem = static_cast< KURLBarItem * >(item);
            m_listBox->setCurrentItem(item);
            m_listBox->setSelected(item, true);
            hasURL = true;
            break;
        }
        item = item->next();
    }

    if(!hasURL)
    {
        m_activeItem = 0L;
        m_listBox->clearSelection();
    }
}
Exemple #23
0
CachedResource* DocLoader::requestResource(CachedResource::Type type, const String& url, const String* charset, bool skipCanLoadCheck, bool sendResourceLoadCallbacks)
{
    KURL fullURL = m_doc->completeURL(url.deprecatedString());
    
    if (cache()->disabled()) {
        HashMap<String, CachedResource*>::iterator it = m_docResources.find(fullURL.url());
        
        if (it != m_docResources.end()) {
            it->second->setDocLoader(0);
            m_docResources.remove(it);
        }
    }
                                                          
    if (m_frame && m_frame->loader()->isReloading())
        setCachePolicy(CachePolicyReload);

    checkForReload(fullURL);

    CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, skipCanLoadCheck, sendResourceLoadCallbacks);
    if (resource) {
        m_docResources.set(resource->url(), resource);
        checkCacheObjectStatus(resource);
    }
    return resource;
}
Exemple #24
0
void GroupwareUploadJob::slotItemUploadError( const KURL &remoteURL, const QString &/*error*/ )
{
  // TODO: Add to error list, remove from uploading and toUpload list
  kdDebug() << "GroupwareUploadJob::slotItemUploadError, removal not successful: "<< remoteURL.url() << endl;
  KPIM::GroupwareUploadItem::List allit( mChangedItems );
  allit += mItemsUploading;
  allit += mItemsUploaded;

  KPIM::GroupwareUploadItem::List::Iterator it = allit.begin();
  for ( ; it != allit.end(); ++it ) {
    if ( (*it)->url().path() == remoteURL.path() ) {
kdDebug()<<"Found it in the list!"<<endl;
      KPIM::GroupwareUploadItem *item = (*it);
      mChangedItems.remove( item );
      mItemsUploaded.remove( item );
      mItemsUploading.remove( item );
      mItemsUploadError.append( item );
    }
  }

  if ( mUploadProgress ) {
    mUploadProgress->incCompletedItems();
    mUploadProgress->updateProgress();
  }
}
Exemple #25
0
void HelpProtocol::emitFile(const KURL &url)
{
    infoMessage(i18n("Looking up section"));

    QString filename = url.path().mid(url.path().findRev('/') + 1);

    int index = mParsed.find(QString("<FILENAME filename=\"%1\"").arg(filename));
    if(index == -1)
    {
        if(filename == "index.html")
        {
            data(fromUnicode(mParsed));
            return;
        }

        unicodeError(i18n("Could not find filename %1 in %2.").arg(filename).arg(url.url()));
        return;
    }

    QString filedata = splitOut(mParsed, index);
    replaceCharsetHeader(filedata);

    data(fromUnicode(filedata));
    data(QByteArray());
}
Exemple #26
0
void GroupwareUploadJob::slotItemUploaded( const QString &/*localId*/, const KURL &remoteURL )
{
  kdDebug() << "GroupwareUploadJob::slotItemUploaded, upload successful: "<< remoteURL.url() << endl;

  const QString &remote = remoteURL.path();
  const QString &local = adaptor()->idMapper()->localId( remote );
  if ( !local.isEmpty() ) {
    // TODO: Is the deleted status reset in the resource?
//     adaptor()->itemUploaded( local, remoteURL );
  }

  KPIM::GroupwareUploadItem::List allit( mChangedItems );
  allit += mAddedItems;
  allit += mItemsUploading;
  allit += mItemsUploadError;


  KPIM::GroupwareUploadItem::List::Iterator it = allit.begin();
  for ( ; it != allit.end(); ++it ) {
    if ( (*it)->url().path() == remoteURL.path() ) {
kdDebug()<<"Found it in the list!"<<endl;
      KPIM::GroupwareUploadItem *item = (*it);
      mChangedItems.remove( item );
      mAddedItems.remove( item );
      mItemsUploading.remove( item );
      mItemsUploadError.remove( item );
      mItemsUploaded.append( item );
    }
  }

  if ( mUploadProgress ) {
    mUploadProgress->incCompletedItems();
    mUploadProgress->updateProgress();
  }
}
Exemple #27
0
void KonqSidebarBookmarkModule::slotProperties(KonqSidebarBookmarkItem *bi)
{
    if (!bi) {
        bi = dynamic_cast<KonqSidebarBookmarkItem*>( tree()->selectedItem() );
        if (!bi)
            return;
    }

    KBookmark bookmark = bi->bookmark();

    QString folder = bookmark.isGroup() ? QString::null : bookmark.url().pathOrURL();
    BookmarkEditDialog dlg( bookmark.fullText(), folder, 0, 0,
                            i18n("Bookmark Properties") );
    if ( dlg.exec() != KDialogBase::Accepted )
        return;

    makeTextNodeMod(bookmark, "title", dlg.finalTitle());
    if ( !dlg.finalUrl().isNull() )
    {
        KURL u = KURL::fromPathOrURL(dlg.finalUrl());
        bookmark.internalElement().setAttribute("href", u.url(0, 106));
    }

    KBookmarkGroup parentBookmark = bookmark.parentGroup();
    KonqBookmarkManager::self()->emitChanged( parentBookmark );
}
Exemple #28
0
void ProgressItem::setMoving(const KURL &from, const KURL &to)
{
    setText(ListProgress::TB_OPERATION, i18n("Moving"));
    setText(ListProgress::TB_ADDRESS, from.url());
    setText(ListProgress::TB_LOCAL_FILENAME, to.fileName());

    defaultProgress->slotMoving(0, from, to);
}
Exemple #29
0
void ProgressItem::setCreatingDir(const KURL &dir)
{
    setText(ListProgress::TB_OPERATION, i18n("Creating"));
    setText(ListProgress::TB_ADDRESS, dir.url());
    setText(ListProgress::TB_LOCAL_FILENAME, dir.fileName());

    defaultProgress->slotCreatingDir(0, dir);
}
Exemple #30
0
void ProgressItem::setStating(const KURL &url)
{
    setText(ListProgress::TB_OPERATION, i18n("Examining"));
    setText(ListProgress::TB_ADDRESS, url.url());
    setText(ListProgress::TB_LOCAL_FILENAME, url.fileName());

    defaultProgress->slotStating(0, url);
}