Way to find out what objects are going away to load

Mario Teijeiro Otero emeteo at escomposlinux.org
Sun Jun 27 12:18:38 BST 2004


I am trying to make plugin for konqueror, that it has, at first, the same 
functionalities that kadblock on firefox.

That is to say, from a URL's pattern to load or not to load the diverse
objects DOM  in which they are made up a document HTML.

According to I can to investigate, this is not possible to do it, since when 
one is going away to begin the load of an object (loader.cpp l. 1026 ), the 
emitted signal is requestStarted, and the parameters are intern of khtml.

Like workaround, I am working in adding a signal khtml_part, which is emmited  
in khtml_part.cpp l.1848 slotLoaderRequestStarted:

void KHTMLPart::slotLoaderRequestStarted( khtml::DocLoader* dl, 
khtml::CachedObject *obj )
{
  if ( obj && obj->type() == khtml::CachedObject::Image && d->m_doc && 
d->m_doc->docLoader() == dl ) {
    KHTMLPart* p = this;
    while ( p ) {
      KHTMLPart* op = p;
      p->d->m_totalObjectCount++;
      p = p->parentPart();
      if ( !p && op->d->m_loadedObjects <= op->d->m_totalObjectCount
        && !op->d->m_progressUpdateTimer.isActive())
	op->d->m_progressUpdateTimer.start( 200, true );
    }
  }
  bool cancel=false;
  emit loaderRequestStarted( &(obj->url()), &cancel );  
  if (cancel) {
        kdDebug(6050) << " KHTMLPART::slotLoaderRequestStarted: canceling: " 
<< obj->url().string() << endl;
        Cache::loader()->cancelRequest(obj);        
  }
  
}

Also I added a function named cancelRequest to Cache::Loader, that is equal to 
cancelRequests, but only cancel the CacheObject passed as parameter, instead 
of all Request of DocLoader(). This seems to work more or less well: I get to 
avoid to load certains URL's.:

void Loader::cancelRequest (CachedObject * object)
{
    /* Remove from pending list */
    QPtrListIterator<Request> pIt( m_requestsPending );
    while (pIt.current()){
        if (pIt.current()->object == object) {
            CDEBUG << "canceling pending request for " << 
pIt.current()->object->url().string() << endl;
            Cache::removeCacheEntry(object);
            m_requestsPending.remove(pIt);
            return;
        }
        else
            ++pIt;
    }
    
    /* Idem but for the loading list */
    QPtrDictIterator<Request> lIt( m_requestsLoading );
    while (lIt.current()) {
        if ((lIt.current()->object == object)) {
            CDEBUG << "canceling Loading request for " << 
lIt.current()->object->url().string() << endl;
            KIO::Job *job = static_cast<KIO::Job *>( lIt.currentKey() );
            Cache::removeCacheEntry(object);
            m_requestsLoading.remove(lIt.currentKey());
            job->kill();
            return;
        }
        else
            ++lIt;
    }
}


I am putting in an impasse? 

There is another way to do it without having to touch khtml (preferred)?

Regards

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20040627/ff0fb88b/attachment.sig>


More information about the kfm-devel mailing list