~ubuntu-branches/ubuntu/natty/kde4libs/natty-proposed

« back to all changes in this revision

Viewing changes to kdecore/sycoca/ksycoca.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell, Scott Kitterman, Jonathan Riddell
  • Date: 2010-11-22 17:59:02 UTC
  • mfrom: (1.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122175902-yubxubd0pg6hn11z
Tags: 4:4.5.80a-0ubuntu1
[ Scott Kitterman ]
* New upstream beta release
  - Refreshed all patches
  - Updated debian/patches/10_make_libkdeinit4_private.diff to use Qfile
    instead of Qstring in kdecore/kernel/kstandarddirs_unix.cpp
  - Updated debian/patches/kubuntu_01_kubuntu_useragent.diff to provide
    Kubuntu in the Konqueror user agen string with the changes in
    kio/kio/kprotocolmanager.cpp
  - Partially updated debian/patches/kubuntu_05_langpack_desktop_files.diff
    and left the balance in kdecore/localization/klocale.cpp.rej for later
    revision
  - Update debian/patches/kubuntu_06_user_disk_mounting.diff for changes in
    solid/solid/backends/hal/halstorageaccess.cpp
  - Remove debian/patches/kubuntu_71_backport_plasma_webview_changes.diff
    (backported from upstream, so already present now)
  - Add minimum version for libattica-dev of 0.1.90 to build-depends
  - Bump minimum version for libsoprano-dev build-depend to 2.5.60
  - Add minimum version for shared-desktop-ontologies of 0.5 in build-dep

[ Jonathan Riddell ]
* Add build-depends on grantlee, libudev-dev, hupnp (FIXME needs packaging fixes)
* Update kubuntu_04_add_langpack_path.diff 28_find_old_kde4_html_documentation.diff
  22_hack_in_etc_kde4_in_kstandarddirs.diff for QT_NO_CAST_FROM_ASCII
* Update kubuntu_05_langpack_desktop_files.diff for new upstream code
* Add kubuntu_78_solid_trunk.diff to fix solid linking
* Add libnepomukutils4 package for new library
* Don't install kcm_ssl for now, e-mailed upstream to suggest moving to kdebase
* Add kubuntu_79_knewstuff_fix.diff to fix compile broken by non-trunk commit
  http://websvn.kde.org/?view=revision&revision=1199825
* kdelibs5-data replaces old kdebase-runtime-data due to moved file
* Add kubuntu_80_find_hupnp.diff to find hupnp include files, committed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 * If the existing file is outdated, it will not get read
56
56
 * but instead we'll ask kded to regenerate a new one...
57
57
 */
58
 
#define KSYCOCA_VERSION 162
 
58
#define KSYCOCA_VERSION 201
59
59
 
60
60
/**
61
61
 * Sycoca file name, used internally (by kbuildsycoca)
108
108
}
109
109
 
110
110
void KSycocaPrivate::setStrategyFromString(const QString& strategy) {
111
 
    if (strategy == "mmap")
 
111
    if (strategy == QLatin1String("mmap"))
112
112
        m_sycocaStrategy = StrategyMmap;
113
 
    else if (strategy == "file")
 
113
    else if (strategy == QLatin1String("file"))
114
114
        m_sycocaStrategy = StrategyFile;
115
 
    else if (strategy == "sharedmem")
 
115
    else if (strategy == QLatin1String("sharedmem"))
116
116
        m_sycocaStrategy = StrategyMemFile;
117
117
    else if (!strategy.isEmpty())
118
118
        kWarning(7011) << "Unknown sycoca strategy:" << strategy;
181
181
  : d(new KSycocaPrivate)
182
182
{
183
183
    QDBusConnection::sessionBus().connect(QString(), QString(),
184
 
                                          "org.kde.KSycoca", "notifyDatabaseChanged",
 
184
                                          QString::fromLatin1("org.kde.KSycoca"),
 
185
                                          QString::fromLatin1("notifyDatabaseChanged"),
185
186
                                          this, SLOT(notifyDatabaseChanged(QStringList)));
186
187
}
187
188
 
193
194
    QString path = KSycoca::absoluteFilePath();
194
195
 
195
196
    bool canRead = KDE::access(path, R_OK) == 0;
196
 
    kDebug(7011) << "Trying to open ksycoca from " << path;
 
197
    kDebug(7011) << "Trying to open ksycoca from" << path;
197
198
    if (!canRead) {
198
199
        path = KSycoca::absoluteFilePath(KSycoca::GlobalDatabase);
199
200
        if (!path.isEmpty()) {
246
247
            }
247
248
        }
248
249
#endif
 
250
#ifndef QT_NO_SHAREDMEMORY
249
251
        if (!device && m_sycocaStrategy == StrategyMemFile) {
250
252
            device = new KSycocaMemFileDevice(m_databasePath);
251
253
            if (!device->device()->open(QIODevice::ReadOnly)) {
252
254
                delete device; device = 0;
253
255
            }
254
256
        }
255
 
 
 
257
#endif
256
258
        if (!device) {
257
259
            device = new KSycocaFileDevice(m_databasePath);
258
260
            if (!device->device()->open(QIODevice::ReadOnly)) {
341
343
    d->addFactory(factory);
342
344
}
343
345
 
 
346
#ifndef KDE_NO_DEPRECATED
344
347
bool KSycoca::isChanged(const char *type)
345
348
{
346
 
    return self()->d->changeList.contains(type);
 
349
    return self()->d->changeList.contains(QString::fromLatin1(type));
347
350
}
 
351
#endif
348
352
 
349
353
void KSycoca::notifyDatabaseChanged(const QStringList &changeList)
350
354
{
357
361
    d->closeDatabase();
358
362
 
359
363
    // Now notify applications
 
364
#ifndef KDE_NO_DEPRECATED
360
365
    emit databaseChanged();
 
366
#endif
361
367
    emit databaseChanged(changeList);
362
368
}
363
369
 
410
416
 
411
417
    // We can only use the installed ksycoca file if kdeinit+klauncher+kded are running,
412
418
    // since kded is what keeps the file uptodate.
413
 
    const bool kdeinitRunning = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.klauncher");
 
419
    const bool kdeinitRunning = QDBusConnection::sessionBus().interface()->isServiceRegistered(QString::fromLatin1("org.kde.klauncher"));
414
420
 
415
421
    // Check if new database already available
416
422
    if (kdeinitRunning && openDatabase(ifNotFound & IfNotFoundOpenDummy)) {
429
435
            // and since kdeinit4 only returns after kbuildsycoca4 is done, we can proceed.
430
436
        } else {
431
437
            kDebug(7011) << QThread::currentThread() << "We have no database.... launching" << KBUILDSYCOCA_EXENAME;
432
 
            if (QProcess::execute(KStandardDirs::findExe(KBUILDSYCOCA_EXENAME)) != 0)
 
438
            if (QProcess::execute(KStandardDirs::findExe(QString::fromLatin1(KBUILDSYCOCA_EXENAME))) != 0)
433
439
                qWarning("ERROR: Running KSycoca failed.");
434
440
        }
435
441
 
522
528
 
523
529
QString KSycoca::absoluteFilePath(DatabaseType type)
524
530
{
525
 
   if (type == GlobalDatabase)
526
 
      return KStandardDirs::locate("services", KSYCOCA_FILENAME);
 
531
    if (type == GlobalDatabase)
 
532
        return KGlobal::dirs()->saveLocation("services") + QString::fromLatin1(KSYCOCA_FILENAME);
527
533
 
528
 
   const QByteArray ksycoca_env = qgetenv("KDESYCOCA");
529
 
   if (ksycoca_env.isEmpty())
530
 
      return KGlobal::dirs()->saveLocation("cache") + KSYCOCA_FILENAME;
531
 
   else
532
 
      return QFile::decodeName(ksycoca_env);
 
534
    const QByteArray ksycoca_env = qgetenv("KDESYCOCA");
 
535
    if (ksycoca_env.isEmpty())
 
536
        return KGlobal::dirs()->saveLocation("cache") + QString::fromLatin1(KSYCOCA_FILENAME);
 
537
    else
 
538
        return QFile::decodeName(ksycoca_env);
533
539
}
534
540
 
535
541
QString KSycoca::language()
555
561
    d->readError = true;
556
562
    if (s_autoRebuild) {
557
563
        // Rebuild the damned thing.
558
 
        if (QProcess::execute(KStandardDirs::findExe(KBUILDSYCOCA_EXENAME)) != 0)
 
564
        if (QProcess::execute(KStandardDirs::findExe(QString::fromLatin1(KBUILDSYCOCA_EXENAME))) != 0)
559
565
            qWarning("ERROR: Running %s failed", KBUILDSYCOCA_EXENAME);
560
566
        // Old comment, maybe not true anymore:
561
567
        // Do not wait until the DBUS signal from kbuildsycoca here.
563
569
    }
564
570
}
565
571
 
 
572
#ifndef KDE_NO_DEPRECATED
566
573
bool KSycoca::readError() // KDE5: remove
567
574
{
568
575
    return false;
569
576
}
 
577
#endif
570
578
 
571
579
bool KSycoca::isBuilding()
572
580
{