~ubuntu-branches/ubuntu/lucid/kde4libs/lucid-updates

« back to all changes in this revision

Viewing changes to knewstuff/knewstuff3/core/engine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-01-19 20:32:41 UTC
  • mfrom: (1.1.42 upstream)
  • Revision ID: james.westby@ubuntu.com-20100119203241-6qlz4p6emiawose6
Tags: 4:4.3.95-0ubuntu1
* New upstream release candidate:
  - Remove kubuntu_71_knewstuff_crashes.diff, applied upstream
  - Remove kubuntu_72_popupapplet_crash_fix.diff, applied upstream
  - Refresh kubuntu_70_dbusmenu.diff
  - Bump RUNTIME_DEPS value in debian/rules to 4.3.90
  - Update .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "engine.h"
22
22
 
23
 
#include "config-knewstuff3.h"
24
 
 
25
23
#include "entry.h"
26
24
#include "core/installation.h"
27
25
#include "core/xmlloader.h"
53
51
#include <shlobj.h>
54
52
#endif
55
53
 
56
 
#if defined(HAVE_LIBATTICA)
57
54
#include "attica/atticaprovider.h"
58
 
#endif
59
55
 
60
56
#include "core/cache.h"
61
57
#include "staticxml/staticxmlprovider.h"
248
244
 
249
245
        QSharedPointer<KNS3::Provider> provider;
250
246
        if (isAtticaProviderFile || n.attribute("type").toLower() == "rest") {
251
 
#ifdef HAVE_ATTICA
252
247
            provider = QSharedPointer<KNS3::Provider> (new AtticaProvider(d->categories));
253
 
#endif
254
248
        } else {
255
249
            provider = QSharedPointer<KNS3::Provider> (new StaticXmlProvider);
256
250
        }
298
292
 
299
293
    foreach (ProviderInformation p, d->providers) {
300
294
        if (p.provider->isInitialized()) {
301
 
            // FIXME: other parameters
302
 
            // FIXME use cache, if this request was sent already, take it from the cache
303
 
 
304
 
            int page = 0;
305
 
            while (true) {
 
295
            if (d->currentRequest.sortMode == Provider::Installed) {
 
296
                // when asking for installed entries, never use the cache
 
297
                p.provider->loadEntries(d->currentRequest);
 
298
            } else {
 
299
                // take entries from cache until there are no more
306
300
                EntryInternal::List cache = d->cache->requestFromCache(d->currentRequest);
307
 
                if (!cache.isEmpty()) {
 
301
                while (!cache.isEmpty()) {
308
302
                    kDebug() << "From cache";
309
303
                    emit signalEntriesLoaded(cache);
310
 
                    d->currentPage = page;
311
 
                    d->currentRequest.page = page;
312
 
                    ++page;
313
 
                } else {
314
 
                    break;
315
 
                }
316
 
            }
317
 
            if (page == 0) {
318
 
                kDebug() << "From provider";
319
 
                p.provider->loadEntries(d->currentRequest);
 
304
 
 
305
                    d->currentPage = d->currentRequest.page;
 
306
                    ++d->currentRequest.page;
 
307
                    cache = d->cache->requestFromCache(d->currentRequest);
 
308
                }
 
309
                // if the cache was empty, request data from provider
 
310
                if (d->currentPage == -1) {
 
311
                    kDebug() << "From provider";
 
312
                    p.provider->loadEntries(d->currentRequest);
 
313
                }
320
314
            }
321
315
        }
322
316
    }
366
360
 
367
361
    foreach (ProviderInformation p, d->providers) {
368
362
        if (p.provider->isInitialized()) {
369
 
            // FIXME: other parameters
370
 
            // FIXME use cache, if this request was sent already, take it from the cache
371
 
            EntryInternal::List cache = d->cache->requestFromCache(d->currentRequest);
372
 
            if (!cache.isEmpty()) {
373
 
                kDebug() << "From cache";
374
 
                emit signalEntriesLoaded(cache);
375
 
            } else {
376
 
                kDebug() << "From provider";
377
 
                p.provider->loadEntries(d->currentRequest);
378
 
            }
 
363
            p.provider->loadEntries(d->currentRequest);
379
364
        }
380
365
    }
381
366
}
544
529
    // FIXME implement warning?
545
530
}
546
531
 
 
532
bool Engine::userCanVote(const EntryInternal& entry)
 
533
{
 
534
    QSharedPointer<Provider> p = d->providers.value(entry.providerId()).provider;
 
535
    return p->userCanVote();
 
536
}
 
537
 
547
538
void Engine::vote(const EntryInternal& entry, bool positiveVote)
548
539
{
549
540
    QSharedPointer<Provider> p = d->providers.value(entry.providerId()).provider;
550
541
    p->vote(entry, positiveVote);
551
542
}
552
543
 
 
544
bool Engine::userCanBecomeFan(const EntryInternal& entry)
 
545
{
 
546
    QSharedPointer<Provider> p = d->providers.value(entry.providerId()).provider;
 
547
    return p->userCanBecomeFan();
 
548
}
 
549
 
553
550
void Engine::becomeFan(const EntryInternal& entry)
554
551
{
555
552
    QSharedPointer<Provider> p = d->providers.value(entry.providerId()).provider;