mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kded: merge KHostnameD class into Kded class
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8a33e662f0
commit
b6671dbbac
2 changed files with 46 additions and 58 deletions
|
@ -56,10 +56,10 @@
|
|||
|
||||
Kded *Kded::_self = 0;
|
||||
|
||||
static int iHostnamePollInterval = 5000;
|
||||
static bool bCheckStamps = true;
|
||||
static bool bCheckSycoca = true;
|
||||
static bool bCheckStamps = true;
|
||||
static bool bCheckHostname = true;
|
||||
static int iHostnamePollInterval = 5000;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern Q_DBUS_EXPORT void qDBusAddSpyHook(void (*)(const QDBusMessage&));
|
||||
|
@ -88,7 +88,7 @@ Kded::Kded(QObject *parent)
|
|||
: QObject(parent),
|
||||
m_pDirWatch(nullptr),
|
||||
m_pTimer(nullptr),
|
||||
m_pHostnameD(nullptr),
|
||||
m_hTimer(nullptr),
|
||||
m_serviceWatcher(nullptr)
|
||||
{
|
||||
_self = this;
|
||||
|
@ -118,8 +118,11 @@ Kded::Kded(QObject *parent)
|
|||
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(recreate()));
|
||||
|
||||
if (bCheckHostname) {
|
||||
// Watch for hostname changes
|
||||
m_pHostnameD = new KHostnameD(this);
|
||||
// Watch for hostname changes
|
||||
m_hTimer = new QTimer(this);
|
||||
m_hTimer->start(iHostnamePollInterval); // repetitive timer (not single-shot)
|
||||
connect(m_hTimer, SIGNAL(timeout()), this, SLOT(checkHostname()));
|
||||
checkHostname();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +139,10 @@ Kded::~Kded()
|
|||
delete m_pTimer;
|
||||
delete m_pDirWatch;
|
||||
|
||||
delete m_pHostnameD;
|
||||
if (m_hTimer) {
|
||||
m_hTimer->stop();
|
||||
delete m_hTimer;
|
||||
}
|
||||
|
||||
QHashIterator<QString,KDEDModule*> it(m_modules);
|
||||
while (it.hasNext()) {
|
||||
|
@ -482,6 +488,26 @@ void Kded::update(const QString& path)
|
|||
}
|
||||
}
|
||||
|
||||
void Kded::checkHostname()
|
||||
{
|
||||
const QByteArray newHostname = QHostInfo::localHostName().toUtf8();
|
||||
if (newHostname.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_hostname.isEmpty()) {
|
||||
m_hostname = newHostname;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_hostname == newHostname) {
|
||||
return;
|
||||
}
|
||||
|
||||
runDontChangeHostname(m_hostname, newHostname);
|
||||
m_hostname = newHostname;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Kded::isWindowRegistered(long windowId) const
|
||||
{
|
||||
|
@ -526,35 +552,6 @@ void Kded::unregisterWindowId(qlonglong windowId, const QString &sender)
|
|||
}
|
||||
}
|
||||
|
||||
KHostnameD::KHostnameD(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_Timer.start(iHostnamePollInterval); // repetitive timer (not single-shot)
|
||||
connect(&m_Timer, SIGNAL(timeout()), this, SLOT(checkHostname()));
|
||||
checkHostname();
|
||||
}
|
||||
|
||||
void KHostnameD::checkHostname()
|
||||
{
|
||||
const QByteArray newHostname = QHostInfo::localHostName().toUtf8();
|
||||
if (newHostname.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_hostname.isEmpty()) {
|
||||
m_hostname = newHostname;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_hostname == newHostname) {
|
||||
return;
|
||||
}
|
||||
|
||||
runDontChangeHostname(m_hostname, newHostname);
|
||||
m_hostname = newHostname;
|
||||
}
|
||||
|
||||
|
||||
KBuildsycocaAdaptor::KBuildsycocaAdaptor(QObject *parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
|
@ -598,10 +595,10 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
KConfigGroup cg(config, "General");
|
||||
iHostnamePollInterval = cg.readEntry("HostnamePollInterval", 5000);
|
||||
bCheckSycoca = cg.readEntry("CheckSycoca", true);
|
||||
bCheckHostname = cg.readEntry("CheckHostname", true);
|
||||
bCheckStamps = cg.readEntry("CheckFileStamps", true);
|
||||
bCheckHostname = cg.readEntry("CheckHostname", true);
|
||||
iHostnamePollInterval = cg.readEntry("HostnamePollInterval", 5000);
|
||||
|
||||
Kded kded(&app);
|
||||
|
||||
|
|
33
kded/kded.h
33
kded/kded.h
|
@ -38,23 +38,6 @@
|
|||
|
||||
class KDirWatch;
|
||||
|
||||
class KHostnameD : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KHostnameD(QObject *parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
void checkHostname();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Timer for interval hostname checking.
|
||||
*/
|
||||
QTimer m_Timer;
|
||||
QByteArray m_hostname;
|
||||
};
|
||||
|
||||
// Apps get read-only access
|
||||
class Kded : public QObject
|
||||
{
|
||||
|
@ -169,13 +152,18 @@ public Q_SLOTS:
|
|||
*/
|
||||
void slotKDEDModuleRemoved(KDEDModule *);
|
||||
|
||||
protected Q_SLOTS:
|
||||
private Q_SLOTS:
|
||||
|
||||
/**
|
||||
* @internal Triggers rebuilding
|
||||
*/
|
||||
void update(const QString& dir);
|
||||
|
||||
/**
|
||||
* @internal Executes kdontchangethehostname when hostname changes
|
||||
*/
|
||||
void checkHostname();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Pointer to the dirwatch class which tells us, when some directories
|
||||
|
@ -191,10 +179,13 @@ private:
|
|||
QTimer* m_pTimer;
|
||||
|
||||
/**
|
||||
* Pointer to the hostname class which updates X11 authorization when
|
||||
* hostname changes.
|
||||
* Timer for periodic hostname checking.
|
||||
*/
|
||||
KHostnameD* m_pHostnameD;
|
||||
QTimer* m_hTimer;
|
||||
/**
|
||||
* The current hostname.
|
||||
*/
|
||||
QByteArray m_hostname;
|
||||
|
||||
QHash<QString,KDEDModule *> m_modules;
|
||||
//QHash<QString,QLibrary *> m_libs;
|
||||
|
|
Loading…
Add table
Reference in a new issue