File indexing completed on 2024-04-14 14:27:27

0001 /*
0002     SPDX-FileCopyrightText: 2002-2006 David Faure <faure@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #include <QCoreApplication>
0008 #include <QDebug>
0009 #include <kservice.h>
0010 #include <kservicegroup.h>
0011 
0012 int main(int argc, char *argv[])
0013 {
0014     QCoreApplication k(argc, argv);
0015 
0016     KServiceGroup::Ptr root = KServiceGroup::root();
0017     KServiceGroup::List list = root->entries();
0018 
0019     KServiceGroup::Ptr first;
0020 
0021     qDebug("Found %d entries", list.count());
0022     for (const KSycocaEntry::Ptr &p : std::as_const(list)) {
0023         if (p->isType(KST_KService)) {
0024             KService::Ptr service(static_cast<KService *>(p.data()));
0025             qDebug("%s", qPrintable(service->name()));
0026             qDebug("%s", qPrintable(service->entryPath()));
0027         } else if (p->isType(KST_KServiceGroup)) {
0028             KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup *>(p.data()));
0029             qDebug("             %s -->", qPrintable(serviceGroup->caption()));
0030             if (!first) {
0031                 first = serviceGroup;
0032             }
0033         } else {
0034             qDebug("KServiceGroup: Unexpected object in list!");
0035         }
0036     }
0037 
0038     if (first) {
0039         list = first->entries();
0040         qDebug("Found %d entries", list.count());
0041         for (const KSycocaEntry::Ptr &p : std::as_const(list)) {
0042             if (p->isType(KST_KService)) {
0043                 KService::Ptr service(static_cast<KService *>(p.data()));
0044                 qDebug("             %s", qPrintable(service->name()));
0045             } else if (p->isType(KST_KServiceGroup)) {
0046                 KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup *>(p.data()));
0047                 qDebug("             %s -->", qPrintable(serviceGroup->caption()));
0048             } else {
0049                 qDebug("KServiceGroup: Unexpected object in list!");
0050             }
0051         }
0052     }
0053 
0054     return 0;
0055 }