• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kded
 

kded

  • kded
kbuildservicegroupfactory.cpp
1/* This file is part of the KDE libraries
2 * Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License version 2 as published by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public License
14 * along with this library; see the file COPYING.LIB. If not, write to
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 **/
18
19#include "kbuildservicegroupfactory.h"
20#include "tdesycoca.h"
21#include "tdesycocadict.h"
22#include "kresourcelist.h"
23
24#include <tdeglobal.h>
25#include <tdestandarddirs.h>
26#include <kmessageboxwrapper.h>
27#include <kdebug.h>
28#include <tdelocale.h>
29#include <assert.h>
30
31KBuildServiceGroupFactory::KBuildServiceGroupFactory() :
32 KServiceGroupFactory()
33{
34 m_resourceList = new KSycocaResourceList();
35// m_resourceList->add( "apps", "*.directory" );
36}
37
38// return all service types for this factory
39// i.e. first arguments to m_resourceList->add() above
40TQStringList KBuildServiceGroupFactory::resourceTypes()
41{
42 return TQStringList(); // << "apps";
43}
44
45KBuildServiceGroupFactory::~KBuildServiceGroupFactory()
46{
47 delete m_resourceList;
48}
49
50KServiceGroup *
51KBuildServiceGroupFactory::createEntry( const TQString&, const char * )
52{
53 // Unused
54 kdWarning("!!!! KBuildServiceGroupFactory::createEntry called!");
55 return 0;
56}
57
58
59void KBuildServiceGroupFactory::addNewEntryTo( const TQString &menuName, KService *newEntry)
60{
61 KServiceGroup *entry = 0;
62 KSycocaEntry::Ptr *ptr = m_entryDict->find(menuName);
63 if (ptr)
64 entry = dynamic_cast<KServiceGroup *>(ptr->data());
65
66 if (!entry)
67 {
68 kdWarning(7021) << "KBuildServiceGroupFactory::addNewEntryTo( " << menuName << ", " << newEntry->name() << " ): menu does not exists!" << endl;
69 return;
70 }
71 entry->addEntry( newEntry );
72}
73
74KServiceGroup *
75KBuildServiceGroupFactory::addNew( const TQString &menuName, const TQString& file, KServiceGroup *entry, bool isDeleted)
76{
77 KSycocaEntry::Ptr *ptr = m_entryDict->find(menuName);
78 if (ptr)
79 {
80 kdWarning(7021) << "KBuildServiceGroupFactory::addNew( " << menuName << ", " << file << " ): menu already exists!" << endl;
81 return static_cast<KServiceGroup *>(static_cast<KSycocaEntry *>(*ptr));
82 }
83
84 // Create new group entry
85 if (!entry)
86 entry = new KServiceGroup(file, menuName);
87
88 entry->m_childCount = -1; // Recalculate
89
90 addEntry( entry, "apps" ); // "vfolder" ??
91
92 if (menuName != "/")
93 {
94 // Make sure parent dir exists.
95 KServiceGroup *parentEntry = 0;
96 TQString parent = menuName.left(menuName.length()-1);
97 int i = parent.findRev('/');
98 if (i > 0) {
99 parent = parent.left(i+1);
100 } else {
101 parent = "/";
102 }
103 parentEntry = 0;
104 ptr = m_entryDict->find(parent);
105 if (ptr)
106 parentEntry = dynamic_cast<KServiceGroup *>(ptr->data());
107 if (!parentEntry)
108 {
109 kdWarning(7021) << "KBuildServiceGroupFactory::addNew( " << menuName << ", " << file << " ): parent menu does not exist!" << endl;
110 }
111 else
112 {
113 if (!isDeleted && !entry->isDeleted())
114 parentEntry->addEntry( entry );
115 }
116 }
117 return entry;
118}
119
120KServiceGroup *
121KBuildServiceGroupFactory::addNewChild( const TQString &parent, const char *resource, KSycocaEntry *newEntry)
122{
123 TQString name = "#parent#"+parent;
124
125 KServiceGroup *entry = 0;
126 KSycocaEntry::Ptr *ptr = m_entryDict->find(name);
127 if (ptr)
128 entry = dynamic_cast<KServiceGroup *>(ptr->data());
129
130 if (!entry)
131 {
132 entry = new KServiceGroup(name);
133 addEntry( entry, resource );
134 }
135 if (newEntry)
136 entry->addEntry( newEntry );
137
138 return entry;
139
140}
141
142void
143KBuildServiceGroupFactory::addEntry( KSycocaEntry *newEntry, const char *resource)
144{
145 KSycocaFactory::addEntry(newEntry, resource);
146 KServiceGroup * serviceGroup = (KServiceGroup *) newEntry;
147 serviceGroup->m_serviceList.clear();
148
149 if ( !serviceGroup->baseGroupName().isEmpty() )
150 {
151 m_baseGroupDict->add( serviceGroup->baseGroupName(), newEntry );
152 }
153}
154
155void
156KBuildServiceGroupFactory::saveHeader(TQDataStream &str)
157{
158 KSycocaFactory::saveHeader(str);
159
160 str << (TQ_INT32) m_baseGroupDictOffset;
161}
162
163void
164KBuildServiceGroupFactory::save(TQDataStream &str)
165{
166 KSycocaFactory::save(str);
167
168 m_baseGroupDictOffset = str.device()->at();
169 m_baseGroupDict->save(str);
170
171 int endOfFactoryData = str.device()->at();
172
173 // Update header (pass #3)
174 saveHeader(str);
175
176 // Seek to end.
177 str.device()->at(endOfFactoryData);
178}
KBuildServiceGroupFactory::resourceTypes
static TQStringList resourceTypes()
Returns all resource types for this service factory.
Definition: kbuildservicegroupfactory.cpp:40
KBuildServiceGroupFactory::createEntry
virtual KServiceGroup * createEntry(const TQString &, const char *)
Create new entry.
Definition: kbuildservicegroupfactory.cpp:51
KBuildServiceGroupFactory::saveHeader
virtual void saveHeader(TQDataStream &str)
Write out header information.
Definition: kbuildservicegroupfactory.cpp:156
KBuildServiceGroupFactory::addNew
KServiceGroup * addNew(const TQString &menuName, const TQString &file, KServiceGroup *entry, bool isDeleted)
Add new menu menuName defined by file When entry is non-null it is re-used, otherwise a new group is ...
Definition: kbuildservicegroupfactory.cpp:75
KBuildServiceGroupFactory::addNewChild
KServiceGroup * addNewChild(const TQString &parent, const char *resource, KSycocaEntry *newEntry)
Adds the entry newEntry to the "parent group" parent, creating the group if necassery.
Definition: kbuildservicegroupfactory.cpp:121
KBuildServiceGroupFactory::save
virtual void save(TQDataStream &str)
Write out servicegroup specific index files.
Definition: kbuildservicegroupfactory.cpp:164
KBuildServiceGroupFactory::KBuildServiceGroupFactory
KBuildServiceGroupFactory()
Create factory.
Definition: kbuildservicegroupfactory.cpp:31
KBuildServiceGroupFactory::addEntry
virtual void addEntry(KSycocaEntry *newEntry, const char *resource)
Add a new menu entry.
Definition: kbuildservicegroupfactory.cpp:143
KBuildServiceGroupFactory::addNewEntryTo
void addNewEntryTo(const TQString &menuName, KService *newEntry)
Adds the entry newEntry to the menu menuName.
Definition: kbuildservicegroupfactory.cpp:59

kded

Skip menu "kded"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kded

Skip menu "kded"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kded by doxygen 1.9.4
This website is maintained by Timothy Pearson.