diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /krfb/kinetd | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krfb/kinetd')
-rw-r--r-- | krfb/kinetd/kinetd.cpp | 130 | ||||
-rw-r--r-- | krfb/kinetd/kinetd.h | 74 |
2 files changed, 102 insertions, 102 deletions
diff --git a/krfb/kinetd/kinetd.cpp b/krfb/kinetd/kinetd.cpp index 5094712e..2f4acadd 100644 --- a/krfb/kinetd/kinetd.cpp +++ b/krfb/kinetd/kinetd.cpp @@ -21,7 +21,7 @@ #include "kinetinterface.h" #include "kuser.h" #include "uuid.h" -#include <qregexp.h> +#include <tqregexp.h> #include <kservicetype.h> #include <kdebug.h> #include <kstandarddirs.h> @@ -77,8 +77,8 @@ bool PortListener::acquirePort() { delete m_socket; m_socket = new KServerSocket(m_port, false); } - connect(m_socket, SIGNAL(accepted(KSocket*)), - SLOT(accepted(KSocket*))); + connect(m_socket, TQT_SIGNAL(accepted(KSocket*)), + TQT_SLOT(accepted(KSocket*))); bool s = m_registerService; bool sd =m_dnssdRegister; @@ -102,10 +102,10 @@ void PortListener::loadConfig(KService::Ptr s) { m_valid = true; m_autoPortRange = 0; m_enabled = true; - m_argument = QString::null; + m_argument = TQString::null; m_multiInstance = false; - QVariant vid, vport, vautoport, venabled, vargument, vmultiInstance, vurl, + TQVariant vid, vport, vautoport, venabled, vargument, vmultiInstance, vurl, vsattributes, vslifetime, vdname, vdtype, vddata; m_execPath = s->exec().utf8(); @@ -154,7 +154,7 @@ void PortListener::loadConfig(KService::Ptr s) { m_registerService = true; } else { - m_serviceURL = QString::null; + m_serviceURL = TQString::null; m_registerService = false; } if (vsattributes.isValid()) { @@ -163,11 +163,11 @@ void PortListener::loadConfig(KService::Ptr s) { else m_serviceAttributes = ""; if (vddata.isValid()) { - QStringList attrs = vddata.toStringList(); - for (QStringList::iterator it=attrs.begin(); + TQStringList attrs = vddata.toStringList(); + for (TQStringList::iterator it=attrs.begin(); it!=attrs.end();it++) { - QString key = (*it).section('=',0,0); - QString value = processServiceTemplate((*it).section('=',1))[0]; + TQString key = (*it).section('=',0,0); + TQString value = processServiceTemplate((*it).section('=',1))[0]; if (!key.isEmpty()) m_dnssdData[key]=value; } } @@ -181,7 +181,7 @@ void PortListener::loadConfig(KService::Ptr s) { m_dnssdRegister = false; - m_slpLifetimeEnd = QDateTime::currentDateTime().addSecs(m_serviceLifetime); + m_slpLifetimeEnd = TQDateTime::currentDateTime().addSecs(m_serviceLifetime); m_defaultPortBase = m_portBase; m_defaultAutoPortRange = m_autoPortRange; @@ -192,17 +192,17 @@ void PortListener::loadConfig(KService::Ptr s) { m_portBase); m_autoPortRange = m_config->readNumEntry("auto_port_range_" + m_serviceName, m_autoPortRange); - QDateTime nullTime; + TQDateTime nullTime; m_expirationTime = m_config->readDateTimeEntry("enabled_expiration_"+m_serviceName, &nullTime); - if ((!m_expirationTime.isNull()) && (m_expirationTime < QDateTime::currentDateTime())) + if ((!m_expirationTime.isNull()) && (m_expirationTime < TQDateTime::currentDateTime())) m_enabled = false; m_registerService = m_config->readBoolEntry("enabled_srvreg_"+m_serviceName, m_registerService); } void PortListener::accepted(KSocket *sock) { - QString host, port; + TQString host, port; KSocketAddress *ksa = KExtendedSocket::peerAddress(sock->socket()); if ((!ksa) || !ksa->address()) { delete sock; @@ -223,7 +223,7 @@ void PortListener::accepted(KSocket *sock) { fcntl(sock->socket(), F_SETFD, fcntl(sock->socket(), F_GETFD) & ~FD_CLOEXEC); m_process.clearArguments(); - m_process << m_execPath << m_argument << QString::number(sock->socket()); + m_process << m_execPath << m_argument << TQString::number(sock->socket()); if (!m_process.start(KProcess::DontCare)) { KNotifyClient::event("ProcessFailed", i18n("Call \"%1 %2 %3\" failed").arg(m_execPath) @@ -246,22 +246,22 @@ int PortListener::port() { return m_port; } -QStringList PortListener::processServiceTemplate(const QString &a) { - QStringList l; - QValueVector<KInetInterface> v = KInetInterface::getAllInterfaces(false); - QValueVector<KInetInterface>::Iterator it = v.begin(); +TQStringList PortListener::processServiceTemplate(const TQString &a) { + TQStringList l; + TQValueVector<KInetInterface> v = KInetInterface::getAllInterfaces(false); + TQValueVector<KInetInterface>::Iterator it = v.begin(); while (it != v.end()) { KInetSocketAddress *address = (*(it++)).address(); if (!address) continue; - QString hostName = address->nodeName(); + TQString hostName = address->nodeName(); KUser u; - QString x = a; // replace does not work in const QString. Why?? - l.append(x.replace(QRegExp("%h"), KServiceRegistry::encodeAttributeValue(hostName)) - .replace(QRegExp("%p"), QString::number(m_port)) - .replace(QRegExp("%u"), KServiceRegistry::encodeAttributeValue(u.loginName())) - .replace(QRegExp("%i"), KServiceRegistry::encodeAttributeValue(m_uuid)) - .replace(QRegExp("%f"), KServiceRegistry::encodeAttributeValue(u.fullName()))); + TQString x = a; // replace does not work in const TQString. Why?? + l.append(x.replace(TQRegExp("%h"), KServiceRegistry::encodeAttributeValue(hostName)) + .replace(TQRegExp("%p"), TQString::number(m_port)) + .replace(TQRegExp("%u"), KServiceRegistry::encodeAttributeValue(u.loginName())) + .replace(TQRegExp("%i"), KServiceRegistry::encodeAttributeValue(m_uuid)) + .replace(TQRegExp("%f"), KServiceRegistry::encodeAttributeValue(u.fullName()))); } return l; } @@ -294,10 +294,10 @@ bool PortListener::setPort(int port, int autoPortRange) { } void PortListener::setEnabled(bool e) { - setEnabledInternal(e, QDateTime()); + setEnabledInternal(e, TQDateTime()); } -void PortListener::setEnabledInternal(bool e, const QDateTime &ex) { +void PortListener::setEnabledInternal(bool e, const TQDateTime &ex) { m_config->setGroup("ListenerConfig"); m_config->writeEntry("enabled_" + m_serviceName, e); m_config->writeEntry("enabled_expiration_"+m_serviceName, ex); @@ -317,7 +317,7 @@ void PortListener::setEnabledInternal(bool e, const QDateTime &ex) { } } -void PortListener::setEnabled(const QDateTime &ex) { +void PortListener::setEnabled(const TQDateTime &ex) { setEnabledInternal(true, ex); } @@ -343,9 +343,9 @@ void PortListener::setServiceRegistrationEnabledInternal(bool e) { if (m_enabled && e) { m_registeredServiceURLs = processServiceTemplate(m_serviceURL); - QStringList attributes = processServiceTemplate(m_serviceAttributes); - QStringList::Iterator it = m_registeredServiceURLs.begin(); - QStringList::Iterator it2 = attributes.begin(); + TQStringList attributes = processServiceTemplate(m_serviceAttributes); + TQStringList::Iterator it = m_registeredServiceURLs.begin(); + TQStringList::Iterator it2 = attributes.begin(); while ((it != m_registeredServiceURLs.end()) && (it2 != attributes.end())) { if (!m_srvreg->registerService( @@ -356,9 +356,9 @@ void PortListener::setServiceRegistrationEnabledInternal(bool e) { } m_serviceRegistered = true; // make lifetime 30s shorter, because the timeout is not precise - m_slpLifetimeEnd = QDateTime::currentDateTime().addSecs(m_serviceLifetime-30); + m_slpLifetimeEnd = TQDateTime::currentDateTime().addSecs(m_serviceLifetime-30); } else { - QStringList::Iterator it = m_registeredServiceURLs.begin(); + TQStringList::Iterator it = m_registeredServiceURLs.begin(); while (it != m_registeredServiceURLs.end()) m_srvreg->unregisterService(*(it++)); m_serviceRegistered = false; @@ -383,24 +383,24 @@ void PortListener::dnssdRegister(bool e) { } void PortListener::refreshRegistration() { - if (m_serviceRegistered && (m_slpLifetimeEnd.addSecs(-90) < QDateTime::currentDateTime())) { + if (m_serviceRegistered && (m_slpLifetimeEnd.addSecs(-90) < TQDateTime::currentDateTime())) { setServiceRegistrationEnabledInternal(false); setServiceRegistrationEnabledInternal(true); } } -QDateTime PortListener::expiration() { +TQDateTime PortListener::expiration() { return m_expirationTime; } -QDateTime PortListener::serviceLifetimeEnd() { +TQDateTime PortListener::serviceLifetimeEnd() { if (m_serviceRegistered) return m_slpLifetimeEnd; else - return QDateTime(); + return TQDateTime(); } -QString PortListener::name() { +TQString PortListener::name() { return m_serviceName; } @@ -410,7 +410,7 @@ PortListener::~PortListener() { } -KInetD::KInetD(QCString &n) : +KInetD::KInetD(TQCString &n) : KDEDModule(n) { m_config = new KConfig("kinetdrc"); @@ -421,9 +421,9 @@ KInetD::KInetD(QCString &n) : m_srvreg = 0; } m_portListeners.setAutoDelete(true); - connect(&m_expirationTimer, SIGNAL(timeout()), SLOT(setExpirationTimer())); - connect(&m_portRetryTimer, SIGNAL(timeout()), SLOT(portRetryTimer())); - connect(&m_reregistrationTimer, SIGNAL(timeout()), SLOT(reregistrationTimer())); + connect(&m_expirationTimer, TQT_SIGNAL(timeout()), TQT_SLOT(setExpirationTimer())); + connect(&m_portRetryTimer, TQT_SIGNAL(timeout()), TQT_SLOT(portRetryTimer())); + connect(&m_reregistrationTimer, TQT_SIGNAL(timeout()), TQT_SLOT(reregistrationTimer())); loadServiceList(); } @@ -456,9 +456,9 @@ void KInetD::expirationTimer() { } void KInetD::setExpirationTimer() { - QDateTime nextEx = getNextExpirationTime(); // disables expired portlistener! + TQDateTime nextEx = getNextExpirationTime(); // disables expired portlistener! if (!nextEx.isNull()) - m_expirationTimer.start(QDateTime::currentDateTime().secsTo(nextEx)*1000 + 30000, + m_expirationTimer.start(TQDateTime::currentDateTime().secsTo(nextEx)*1000 + 30000, false); else m_expirationTimer.stop(); @@ -470,12 +470,12 @@ void KInetD::portRetryTimer() { } void KInetD::setReregistrationTimer() { - QDateTime d; + TQDateTime d; PortListener *pl = m_portListeners.first(); while (pl) { - QDateTime d2 = pl->serviceLifetimeEnd(); + TQDateTime d2 = pl->serviceLifetimeEnd(); if (!d2.isNull()) { - if (d2 < QDateTime::currentDateTime()) { + if (d2 < TQDateTime::currentDateTime()) { m_reregistrationTimer.start(0, true); return; } @@ -486,7 +486,7 @@ void KInetD::setReregistrationTimer() { } if (!d.isNull()) { - int s = QDateTime::currentDateTime().secsTo(d); + int s = TQDateTime::currentDateTime().secsTo(d); if (s < 30) s = 30; // max frequency 30s m_reregistrationTimer.start(s*1000, true); @@ -525,7 +525,7 @@ void KInetD::setPortRetryTimer(bool retry) { m_portRetryTimer.stop(); } -PortListener *KInetD::getListenerByName(QString name) +PortListener *KInetD::getListenerByName(TQString name) { PortListener *pl = m_portListeners.first(); while (pl) { @@ -537,14 +537,14 @@ PortListener *KInetD::getListenerByName(QString name) } // gets next expiration timer, SIDEEFFECT: disables expired portlisteners while doing this -QDateTime KInetD::getNextExpirationTime() +TQDateTime KInetD::getNextExpirationTime() { PortListener *pl = m_portListeners.first(); - QDateTime d; + TQDateTime d; while (pl) { - QDateTime d2 = pl->expiration(); + TQDateTime d2 = pl->expiration(); if (!d2.isNull()) { - if (d2 < QDateTime::currentDateTime()) + if (d2 < TQDateTime::currentDateTime()) pl->setEnabled(false); else if (d.isNull() || (d2 < d)) d = d2; @@ -554,9 +554,9 @@ QDateTime KInetD::getNextExpirationTime() return d; } -QStringList KInetD::services() +TQStringList KInetD::services() { - QStringList list; + TQStringList list; PortListener *pl = m_portListeners.first(); while (pl) { list.append(pl->name()); @@ -565,7 +565,7 @@ QStringList KInetD::services() return list; } -bool KInetD::isEnabled(QString service) +bool KInetD::isEnabled(TQString service) { PortListener *pl = getListenerByName(service); if (!pl) @@ -574,7 +574,7 @@ bool KInetD::isEnabled(QString service) return pl->isEnabled(); } -int KInetD::port(QString service) +int KInetD::port(TQString service) { PortListener *pl = getListenerByName(service); if (!pl) @@ -583,7 +583,7 @@ int KInetD::port(QString service) return pl->port(); } -bool KInetD::setPort(QString service, int port, int autoPortRange) +bool KInetD::setPort(TQString service, int port, int autoPortRange) { PortListener *pl = getListenerByName(service); if (!pl) @@ -595,13 +595,13 @@ bool KInetD::setPort(QString service, int port, int autoPortRange) return s; } -bool KInetD::isInstalled(QString service) +bool KInetD::isInstalled(TQString service) { PortListener *pl = getListenerByName(service); return (pl != 0); } -void KInetD::setEnabled(QString service, bool enable) +void KInetD::setEnabled(TQString service, bool enable) { PortListener *pl = getListenerByName(service); if (!pl) @@ -612,7 +612,7 @@ void KInetD::setEnabled(QString service, bool enable) setReregistrationTimer(); } -void KInetD::setEnabled(QString service, QDateTime expiration) +void KInetD::setEnabled(TQString service, TQDateTime expiration) { PortListener *pl = getListenerByName(service); if (!pl) @@ -623,7 +623,7 @@ void KInetD::setEnabled(QString service, QDateTime expiration) setReregistrationTimer(); } -void KInetD::setServiceRegistrationEnabled(QString service, bool enable) +void KInetD::setServiceRegistrationEnabled(TQString service, bool enable) { PortListener *pl = getListenerByName(service); if (!pl) @@ -633,7 +633,7 @@ void KInetD::setServiceRegistrationEnabled(QString service, bool enable) setReregistrationTimer(); } -bool KInetD::isServiceRegistrationEnabled(QString service) +bool KInetD::isServiceRegistrationEnabled(TQString service) { PortListener *pl = getListenerByName(service); if (!pl) @@ -650,7 +650,7 @@ KInetD::~KInetD() { } extern "C" { - KDE_EXPORT KDEDModule *create_kinetd(QCString &name) + KDE_EXPORT KDEDModule *create_kinetd(TQCString &name) { KGlobal::locale()->insertCatalogue("kinetd"); return new KInetD(name); diff --git a/krfb/kinetd/kinetd.h b/krfb/kinetd/kinetd.h index e6283e83..32bb2885 100644 --- a/krfb/kinetd/kinetd.h +++ b/krfb/kinetd/kinetd.h @@ -23,36 +23,36 @@ #include <kservice.h> #include <ksock.h> #include <kprocess.h> -#include <qstringlist.h> -#include <qstring.h> -#include <qdatetime.h> -#include <qtimer.h> +#include <tqstringlist.h> +#include <tqstring.h> +#include <tqdatetime.h> +#include <tqtimer.h> #include <dnssd/publicservice.h> #include "kserviceregistry.h" -class PortListener : public QObject { +class PortListener : public TQObject { Q_OBJECT private: bool m_valid; - QString m_serviceName; - QString m_serviceURL, m_serviceAttributes; - QStringList m_registeredServiceURLs; - QString m_dnssdName, m_dnssdType; - QMap<QString,QString> m_dnssdData; + TQString m_serviceName; + TQString m_serviceURL, m_serviceAttributes; + TQStringList m_registeredServiceURLs; + TQString m_dnssdName, m_dnssdType; + TQMap<TQString,TQString> m_dnssdData; int m_serviceLifetime; int m_port; int m_portBase, m_autoPortRange; int m_defaultPortBase, m_defaultAutoPortRange; bool m_multiInstance; - QString m_execPath; - QString m_argument; + TQString m_execPath; + TQString m_argument; bool m_enabled; bool m_serviceRegistered, m_registerService; bool m_dnssdRegister, m_dnssdRegistered; - QDateTime m_expirationTime; - QDateTime m_slpLifetimeEnd; - QString m_uuid; + TQDateTime m_expirationTime; + TQDateTime m_slpLifetimeEnd; + TQString m_uuid; KServerSocket *m_socket; KProcess m_process; @@ -63,7 +63,7 @@ private: void freePort(); void loadConfig(KService::Ptr s); - void setEnabledInternal(bool e, const QDateTime &ex); + void setEnabledInternal(bool e, const TQDateTime &ex); void dnssdRegister(bool enabled); void setServiceRegistrationEnabledInternal(bool enabled); @@ -73,16 +73,16 @@ public: bool acquirePort(); bool isValid(); - QString name(); + TQString name(); void setEnabled(bool enabled); - void setEnabled(const QDateTime &expiration); + void setEnabled(const TQDateTime &expiration); void setServiceRegistrationEnabled(bool enabled); bool isServiceRegistrationEnabled(); - QDateTime expiration(); - QDateTime serviceLifetimeEnd(); + TQDateTime expiration(); + TQDateTime serviceLifetimeEnd(); bool isEnabled(); int port(); - QStringList processServiceTemplate(const QString &a); + TQStringList processServiceTemplate(const TQString &a); bool setPort(int port = -1, int autoProbeRange = 1); void refreshRegistration(); @@ -102,14 +102,14 @@ k_dcop: * (see kinetdmodule.desktop in servicetypes dir). * @return a list with the names of all services */ - QStringList services(); + TQStringList services(); /** * Returns true if the service exists and is available. * @param service name of a service as specified in its .desktop file * @return true if a service with the given name exists and is enabled */ - bool isEnabled(QString service); + bool isEnabled(TQString service); /** * Enables or disabled the given service. Ignored if the given service @@ -117,7 +117,7 @@ k_dcop: * @param service name of a service as specified in its .desktop file * @param enable true to enable, false to disable. */ - void setEnabled(QString service, bool enable); + void setEnabled(TQString service, bool enable); /** * Enables the given service until the given time. Ignored if the given @@ -125,14 +125,14 @@ k_dcop: * @param service name of a service as specified in its .desktop file * @param expiration the time the service will be disabled at */ - void setEnabled(QString service, QDateTime expiration); + void setEnabled(TQString service, TQDateTime expiration); /** * Returns the port of the service, or -1 if not listening. * @param service name of a service as specified in its .desktop file * @return the port or -1 if no port used or service does not exist */ - int port(QString service); + int port(TQString service); /** * Sets the port of the service, and possibly a range of ports to try. @@ -144,14 +144,14 @@ k_dcop: * @return true if a port could be found or service is disabled, false * otherwise. */ - bool setPort(QString service, int port = -1, int autoPortRange = 1); + bool setPort(TQString service, int port = -1, int autoPortRange = 1); /** * Tests whether the given service is installed.. * @param service name of a service as specified in its .desktop file * @return true if installed, false otherwise */ - bool isInstalled(QString service); + bool isInstalled(TQString service); /** * Enables or disables the SLP registration. Ignored if the service does @@ -160,7 +160,7 @@ k_dcop: * @param service name of a service as specified in its .desktop file * @param enable true to enable, false to disable. */ - void setServiceRegistrationEnabled(QString service, bool enabled); + void setServiceRegistrationEnabled(TQString service, bool enabled); /** * Returns true if service registration for the given service is enabled. @@ -169,19 +169,19 @@ k_dcop: * @param service name of a service as specified in its .desktop file * @return true if service registration is enabled */ - bool isServiceRegistrationEnabled(QString service); + bool isServiceRegistrationEnabled(TQString service); private: - QDateTime getNextExpirationTime(); + TQDateTime getNextExpirationTime(); void setPortRetryTimer(bool retry); void setReregistrationTimer(); KConfig *m_config; KServiceRegistry *m_srvreg; - QPtrList<PortListener> m_portListeners; - QTimer m_expirationTimer; - QTimer m_portRetryTimer; - QTimer m_reregistrationTimer; + TQPtrList<PortListener> m_portListeners; + TQTimer m_expirationTimer; + TQTimer m_portRetryTimer; + TQTimer m_reregistrationTimer; private slots: void setExpirationTimer(); @@ -190,10 +190,10 @@ k_dcop: void reregistrationTimer(); public: - KInetD(QCString &n); + KInetD(TQCString &n); virtual ~KInetD(); void loadServiceList(); - PortListener *getListenerByName(QString name); + PortListener *getListenerByName(TQString name); }; |