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

kded

  • kded
kdedmodule.cpp
1/*
2 This file is part of the KDE libraries
3
4 Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21*/
22
23#include <tqtimer.h>
24
25#include "kded.h"
26#include "kdedmodule.h"
27#include "tdeconfigdata.h"
28
29typedef TQMap<KEntryKey, TDESharedPtr<TDEShared> > KDEDObjectMap;
30
31class KDEDModulePrivate
32{
33public:
34 KDEDObjectMap *objMap;
35 int timeout;
36 TQTimer timer;
37};
38
39KDEDModule::KDEDModule(const TQCString &name) : TQObject(), DCOPObject(name)
40{
41 d = new KDEDModulePrivate;
42 d->objMap = 0;
43 d->timeout = 0;
44 connect(&(d->timer), TQ_SIGNAL(timeout()), this, TQ_SLOT(idle()));
45}
46
47KDEDModule::~KDEDModule()
48{
49 emit moduleDeleted(this);
50 delete d; d = 0;
51}
52
53void KDEDModule::setIdleTimeout(int secs)
54{
55 d->timeout = secs*1000;
56}
57
58void KDEDModule::resetIdle()
59{
60 d->timer.stop();
61 if (!d->objMap || d->objMap->isEmpty())
62 d->timer.start(d->timeout, true);
63}
64
65void KDEDModule::insert(const TQCString &app, const TQCString &key, TDEShared *obj)
66{
67 if (!d->objMap)
68 d->objMap = new KDEDObjectMap;
69
70 // appKey acts as a placeholder
71 KEntryKey appKey(app, 0);
72 d->objMap->replace(appKey, 0);
73
74 KEntryKey indexKey(app, key);
75
76 // Prevent deletion in case the same object is inserted again.
77 TDESharedPtr<TDEShared> _obj = obj;
78
79 d->objMap->replace(indexKey, _obj);
80 resetIdle();
81}
82
83TDEShared * KDEDModule::find(const TQCString &app, const TQCString &key)
84{
85 if (!d->objMap)
86 return 0;
87 KEntryKey indexKey(app, key);
88
89 KDEDObjectMap::Iterator it = d->objMap->find(indexKey);
90 if (it == d->objMap->end())
91 return 0;
92
93 return it.data().data();
94}
95
96void KDEDModule::remove(const TQCString &app, const TQCString &key)
97{
98 if (!d->objMap)
99 return;
100 KEntryKey indexKey(app, key);
101
102 d->objMap->remove(indexKey);
103 resetIdle();
104}
105
106void KDEDModule::removeAll(const TQCString &app)
107{
108 if (!d->objMap)
109 return;
110
111 KEntryKey indexKey(app, 0);
112 // Search for placeholder.
113
114 KDEDObjectMap::Iterator it = d->objMap->find(indexKey);
115 while (it != d->objMap->end())
116 {
117 KDEDObjectMap::Iterator it2 = it++;
118 if (it2.key().mGroup != app)
119 break; // All keys for this app have been removed.
120 d->objMap->remove(it2);
121 }
122 resetIdle();
123}
124
125bool KDEDModule::isWindowRegistered(long windowId)
126{
127 return Kded::self()->isWindowRegistered(windowId);
128}
129#include "kdedmodule.moc"
KDEDModule::remove
void remove(const TQCString &app, const TQCString &key)
remove object indexed with app and key.
Definition: kdedmodule.cpp:96
KDEDModule::idle
virtual void idle()
Called whenever the last referenced object gets dereferenced.
Definition: kdedmodule.h:126
KDEDModule::setIdleTimeout
void setIdleTimeout(int secs)
Specifies the idle timeout in seconds.
Definition: kdedmodule.cpp:53
KDEDModule::KDEDModule
KDEDModule(const TQCString &name)
Create a DCOPObject named name.
Definition: kdedmodule.cpp:39
KDEDModule::isWindowRegistered
bool isWindowRegistered(long windowId)
Returns whether a certain mainwindow has registered itself with KDED.
Definition: kdedmodule.cpp:125
KDEDModule::resetIdle
void resetIdle()
Reset the idle timeout counter.
Definition: kdedmodule.cpp:58
KDEDModule::insert
void insert(const TQCString &app, const TQCString &key, TDEShared *obj)
Insert obj indexed with app and key.
Definition: kdedmodule.cpp:65
KDEDModule::removeAll
void removeAll(const TQCString &app)
remove all objects indexed with app.
Definition: kdedmodule.cpp:106
KDEDModule::find
TDEShared * find(const TQCString &app, const TQCString &key)
Lookup object indexed with app and key.
Definition: kdedmodule.cpp:83
KDEDModule::moduleDeleted
void moduleDeleted(KDEDModule *)
Emitted when the module is being deleted.

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.