/*! \internal */
void SocialNetworkInterfacePrivate::purgeDoomedNode(IdentifiableContentItemInterface *n)
{
    QList<CacheEntry*> cacheData = nodeContent.values(n);
    foreach (CacheEntry *currData, cacheData)
        removeEntryFromNodeContent(n, currData);
    CacheEntry *nodeCacheEntry = findCacheEntry(n, false);
    if (nodeCacheEntry)
        derefCacheEntry(nodeCacheEntry);
}
void KNMemoryManager::removeCacheEntry( KNArticleCollection::Ptr c )
{
  CollectionItem *ci;
  ci=findCacheEntry(c, true);

  if(ci) {
    c_ollCacheSize -= ci->storageSize;
    delete ci;

    kDebug(5003) <<"KNMemoryManager::removeCacheEntry() : collection removed (" << c->name() <<"),"
                  << mColList.count() << "collections left in cache";
  }
}
void KNMemoryManager::removeCacheEntry( KNArticle::Ptr a )
{
  ArticleItem *ai;

  if( (ai=findCacheEntry(a, true)) ) {
    a_rtCacheSize -= ai->storageSize;
    delete ai;

    kDebug(5003) <<"KNMemoryManager::removeCacheEntry() : article removed,"
                  << mArtList.count() << "articles left in cache";

  }
}
void KNMemoryManager::updateCacheEntry( KNArticle::Ptr a )
{
  ArticleItem *ai;
  int oldSize=0;

  if( (ai=findCacheEntry(a, true)) ) {
    oldSize=ai->storageSize;
    ai->sync();
    kDebug(5003) <<"KNMemoryManager::updateCacheEntry() : article updated";
  }
  else {
    ai=new ArticleItem(a);
    kDebug(5003) <<"KNMemoryManager::updateCacheEntry() : article added";
  }

  mArtList.append(ai);
  a_rtCacheSize += (ai->storageSize - oldSize);
  checkMemoryUsageArticles();
}
void KNMemoryManager::updateCacheEntry( KNArticleCollection::Ptr c )
{
  CollectionItem *ci;
  int oldSize=0;

  if( (ci=findCacheEntry(c, true)) ) { // item is taken from the list
    oldSize=ci->storageSize;
    ci->sync();
    kDebug(5003) <<"KNMemoryManager::updateCacheEntry() : collection (" << c->name() <<") updated";
  }
  else {
    ci=new CollectionItem(c);
    kDebug(5003) <<"KNMemoryManager::updateCacheEntry() : collection (" << c->name() <<") added";
  }

  mColList.append(ci);
  c_ollCacheSize += (ci->storageSize - oldSize);
  checkMemoryUsageCollections();
}