diff --git a/.cvsignore b/.cvsignore index eac3092..f5b6a9e 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -12956-knemo-0.4.7.tar.bz2 +12956-knemo-0.5.1.tar.gz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..afa39cc --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: knemo +# $Id$ +NAME := knemo +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/dead.package b/dead.package deleted file mode 100644 index 7e2f3c1..0000000 --- a/dead.package +++ /dev/null @@ -1 +0,0 @@ -Obsolete in KDE4; this is a KDE 3 service and KDE 3 KControl module diff --git a/import.log b/import.log new file mode 100644 index 0000000..8ff529b --- /dev/null +++ b/import.log @@ -0,0 +1 @@ +knemo-0_5_1-4_fc10:HEAD:knemo-0.5.1-4.fc10.src.rpm:1237231471 diff --git a/knemo-git-2009-03-14.patch b/knemo-git-2009-03-14.patch new file mode 100644 index 0000000..6ac68d2 --- /dev/null +++ b/knemo-git-2009-03-14.patch @@ -0,0 +1,1393 @@ +--- knemo-0.5.1/CMakeLists.txt 2009-03-05 03:20:26.000000000 +0200 ++++ knemo/CMakeLists.txt 2009-03-14 06:08:10.000000000 +0200 +@@ -11,6 +11,7 @@ set( ifconfig_FIND_REQUIRED TRUE ) + + find_program( PATH_IFCONFIG ifconfig ) + find_program( PATH_IWCONFIG iwconfig ) ++find_program( PATH_IWLIST iwlist ) + find_program( PATH_ROUTE route ) + find_library( LIBIW_LIBRARY iw ) + +@@ -21,6 +22,8 @@ find_package_handle_standard_args( libiw + + if ( LIBIW_LIBRARY ) + set ( HAVE_LIBIW 1 ) ++else ( LIBIW_LIBRARY ) ++ set ( LIBIW_LIBRARY "" ) + endif ( LIBIW_LIBRARY ) + + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake +--- knemo-0.5.1/config.h.cmake 2009-02-22 04:04:39.000000000 +0200 ++++ knemo/config.h.cmake 2009-03-14 06:08:10.000000000 +0200 +@@ -3,5 +3,6 @@ + #cmakedefine KNEMO_VERSION "${KNEMO_VERSION}" + #cmakedefine PATH_IFCONFIG "${PATH_IFCONFIG}" + #cmakedefine PATH_IWCONFIG "${PATH_IWCONFIG}" ++#cmakedefine PATH_IWLIST "${PATH_IWLIST}" + #cmakedefine PATH_ROUTE "${PATH_ROUTE}" + #cmakedefine HAVE_LIBIW 1 +--- knemo-0.5.1/src/kcm/configdialog.cpp 2009-03-03 07:11:00.000000000 +0200 ++++ knemo/src/kcm/configdialog.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -390,19 +390,28 @@ void ConfigDialog::save() + KConfigGroup interfaceGroup( config, "Interface_" + it ); + + // Preserve settings set by the app before delete +- QByteArray plotterG = interfaceGroup.readEntry( "PlotterGeometry", QByteArray() ); +- QByteArray statisticsG = interfaceGroup.readEntry( "StatisticsGeometry", QByteArray() ); +- QByteArray statusG = interfaceGroup.readEntry( "StatusGeometry", QByteArray() ); ++ QPoint plotterPos = interfaceGroup.readEntry( "PlotterPos", QPoint() ); ++ QSize plotterSize = interfaceGroup.readEntry( "PlotterSize", QSize() ); ++ QPoint statisticsPos = interfaceGroup.readEntry( "StatisticsPos", QPoint() ); ++ QSize statisticsSize = interfaceGroup.readEntry( "StatisticsSize", QSize() ); ++ QPoint statusPos = interfaceGroup.readEntry( "StatusPos", QPoint() ); ++ QSize statusSize = interfaceGroup.readEntry( "StatusSize", QSize() ); + + // Make sure we don't get crufty commands left over + interfaceGroup.deleteGroup(); + +- if ( !plotterG.isEmpty() ) +- interfaceGroup.writeEntry( "PlotterGeometry", plotterG ); +- if ( !statisticsG.isEmpty() ) +- interfaceGroup.writeEntry( "StatisticsGeometry", statisticsG ); +- if ( !statusG.isEmpty() ) +- interfaceGroup.writeEntry( "StatusGeometry", statusG ); ++ if ( !plotterPos.isNull() ) ++ interfaceGroup.writeEntry( "PlotterPos", plotterPos ); ++ if ( !plotterSize.isEmpty() ) ++ interfaceGroup.writeEntry( "PlotterSize", plotterSize ); ++ if ( !statisticsPos.isNull() ) ++ interfaceGroup.writeEntry( "StatisticsPos", statisticsPos ); ++ if ( !statisticsSize.isEmpty() ) ++ interfaceGroup.writeEntry( "StatisticsSize", statisticsSize ); ++ if ( !statusPos.isNull() ) ++ interfaceGroup.writeEntry( "StatusPos", statusPos ); ++ if ( !statusSize.isEmpty() ) ++ interfaceGroup.writeEntry( "StatusSize", statusSize ); + if ( !settings->alias.isEmpty() ) + interfaceGroup.writeEntry( "Alias", settings->alias ); + +--- knemo-0.5.1/src/knemod/backends/nettoolsbackend.cpp 2009-02-25 01:17:59.000000000 +0200 ++++ knemo/src/knemod/backends/nettoolsbackend.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -349,12 +349,12 @@ void NetToolsBackend::parseIwconfigOutpu + { + // Update the wireless data of the interface. + interface->getData().wirelessDevice = true; +- updateWirelessData( configs[key], interface->getWirelessData() ); ++ updateWirelessData( key, configs[key], interface->getWirelessData() ); + } + } + } + +-void NetToolsBackend::updateWirelessData( QString& config, WirelessData& data ) ++void NetToolsBackend::updateWirelessData( QString& ifaceName, QString& config, WirelessData& data ) + { + QRegExp regExp( "ESSID:([^\"][\\S]*)" ); + if ( regExp.indexIn( config ) > -1 ) +@@ -395,31 +395,65 @@ void NetToolsBackend::updateWirelessData + regExp.setPattern( "(.{2}:.{2}:.{2}:.{2}:.{2}:.{2})" ); + if ( regExp.indexIn( config ) > -1 ) + data.accessPoint = regExp.cap( 1 ); ++ else ++ data.accessPoint.clear(); + + regExp.setPattern( "Nickname:\"(\\w*)\"" ); + if ( regExp.indexIn( config ) > -1 ) + data.nickName = regExp.cap( 1 ); + +- regExp.setPattern( "Link Quality[=:]([\\d]*)" ); +- if ( regExp.indexIn( config ) > -1 ) +- data.linkQuality = regExp.cap( 1 ); +- +- regExp.setPattern( "Encryption key:" ); ++ regExp.setPattern( "Link Quality[=:]([\\d]*)(\\/([\\d]+))?" ); + if ( regExp.indexIn( config ) > -1 ) + { +- regExp.setPattern( "Encryption key:off" ); +- if ( regExp.indexIn( config ) > -1 ) +- { +- data.encryption = false; +- } ++ if ( regExp.numCaptures() == 3 ) ++ data.linkQuality = QString( "%1%" ).arg( 100 * regExp.cap( 1 ).toInt() / regExp.cap( 3 ).toInt() ); + else +- { +- data.encryption = true; +- } ++ data.linkQuality = regExp.cap( 1 ); + } +- else ++ ++#ifdef PATH_IWLIST ++ if ( data.accessPoint != data.prevAccessPoint ) + { ++ /* Reset encryption status for new access point */ + data.encryption = false; ++ data.prevAccessPoint = data.accessPoint; ++ } ++ /* We only use left-over wireless scans to prevent doing a new scan every ++ * polling period. This requires that we run iwlist once per wireless ++ * device. If our current access point disappears from the results then ++ * parseWirelessEncryption will use the last encryption status until the ++ * results are updated again. */ ++ KProcess iwlistProcess; ++ iwlistProcess.setOutputChannelMode( KProcess::MergedChannels ); ++ iwlistProcess.setEnv( "LANG", "C" ); ++ iwlistProcess.setEnv( "LC_ALL", "C" ); ++ iwlistProcess << PATH_IWLIST << ifaceName << "scan" << "last"; ++ ++ iwlistProcess.execute(); ++ QString iwlistOutput = iwlistProcess.readAllStandardOutput(); ++ parseWirelessEncryption( iwlistOutput, data ); ++#endif ++} ++ ++void NetToolsBackend::parseWirelessEncryption( QString& config, WirelessData& data ) ++{ ++ QStringList apList = config.split( "Cell [0-9]{2} - ", QString::SkipEmptyParts ); ++ foreach( QString ap, apList ) ++ { ++ QRegExp regExp( "Address: (.{2}:.{2}:.{2}:.{2}:.{2}:.{2})" ); ++ if ( regExp.indexIn( ap ) > -1 && regExp.cap( 1 ) == data.accessPoint ) ++ { ++ regExp.setPattern( "Encryption key:" ); ++ if ( regExp.indexIn( ap ) > -1 ) ++ { ++ regExp.setPattern( "Encryption key:off" ); ++ if ( regExp.indexIn( ap ) > -1 ) ++ data.encryption = false; ++ else ++ data.encryption = true; ++ return; ++ } ++ } + } + } + +--- knemo-0.5.1/src/knemod/backends/nettoolsbackend.h 2009-02-25 01:17:59.000000000 +0200 ++++ knemo/src/knemod/backends/nettoolsbackend.h 2009-03-14 06:08:10.000000000 +0200 +@@ -59,7 +59,8 @@ private: + void parseIfconfigOutput(); + void updateInterfaceData( QString& config, InterfaceData& data, int type ); + void parseIwconfigOutput(); +- void updateWirelessData( QString& config, WirelessData& data ); ++ void updateWirelessData( QString& ifaceName, QString& config, WirelessData& data ); ++ void parseWirelessEncryption( QString& config, WirelessData& data ); + + QString mRouteStdout; + QString mIfconfigStdout; +--- knemo-0.5.1/src/knemod/backends/sysbackend.cpp 2009-02-25 01:17:59.000000000 +0200 ++++ knemo/src/knemod/backends/sysbackend.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -29,9 +29,7 @@ + #include "config.h" + #include "sysbackend.h" + +-#ifdef HAVE_LIBIW +-#include +-#else ++#ifndef HAVE_LIBIW + #include + #endif + +@@ -70,10 +68,15 @@ void SysBackend::update() + } + else + { +- if ( QFile::exists( SYSPATH + key + "/wireless" ) ) ++#ifdef HAVE_LIBIW ++ int fd = iw_sockets_open(); ++ if ( fd > 0 ) + { +- interface->getData().wirelessDevice = true; ++ struct wireless_config wc; ++ if ( iw_get_basic_config( fd, key.toLatin1(), &wc ) >= 0 ) ++ interface->getData().wirelessDevice = true; + } ++#endif + + unsigned int carrier = 0; + if ( !readNumberFromFile( SYSPATH + key + "/carrier", carrier ) || +@@ -102,11 +105,17 @@ void SysBackend::update() + interface->getData().available = true; + updateInterfaceData( key, interface->getData(), interface->getType() ); + ++#ifdef HAVE_LIBIW + if ( interface->getData().wirelessDevice == true ) + { +- updateWirelessData( key, interface->getWirelessData() ); ++ updateWirelessData( fd, key, interface->getWirelessData() ); + } + } ++ if ( fd > 0 ) ++ close( fd ); ++#else ++ } ++#endif + } + } + updateComplete(); +@@ -292,29 +301,31 @@ void SysBackend::updateInterfaceData( co + } + } + +-void SysBackend::updateWirelessData( const QString& ifName, WirelessData& data ) ++void SysBackend::updateWirelessData( int fd, const QString& ifName, WirelessData& data ) + { +- QString wirelessFolder = SYSPATH + ifName + "/wireless/"; +- +- unsigned int link = 0; +- if ( readNumberFromFile( wirelessFolder + "link", link ) ) +- { +- data.linkQuality = QString::number( link ); +- } +- + #ifdef HAVE_LIBIW +- // The following code was taken from iwconfig.c and iwlib.c. +- int fd; +- if ( ( fd = iw_sockets_open() ) > 0 ) ++ if ( fd > 0 ) + { ++ // The following code was taken from iwconfig.c and iwlib.c. + struct iwreq wrq; + char buffer[128]; ++ struct iw_range range; ++ bool has_range = ( iw_get_range_info( fd, ifName.toLatin1(), &range ) >= 0 ); ++ ++ struct wireless_info info; ++ if ( iw_get_stats( fd, ifName.toLatin1(), &(info.stats), 0, 0 ) >= 0 ) ++ { ++ if ( has_range ) ++ data.linkQuality = QString( "%1%" ).arg( 100 * info.stats.qual.qual / range.max_qual.qual ); ++ else ++ data.linkQuality = QString::number( info.stats.qual.qual ); ++ } ++ + if ( iw_get_ext( fd, ifName.toLatin1(), SIOCGIWFREQ, &wrq ) >= 0 ) + { + int channel = -1; + double freq = iw_freq2float( &( wrq.u.freq ) ); +- struct iw_range range; +- if( iw_get_range_info( fd, ifName.toLatin1(), &range ) >= 0 ) ++ if( has_range ) + { + if ( freq < KILO ) + { +@@ -353,6 +364,8 @@ void SysBackend::updateWirelessData( con + iw_ether_ntop( (const ether_addr*) wrq.u.ap_addr.sa_data, ap_addr); + data.accessPoint = ap_addr; + } ++ else ++ data.accessPoint.clear(); + + memset( essid, 0, IW_ESSID_MAX_SIZE + 1 ); + wrq.u.essid.pointer = (caddr_t) essid; +@@ -391,27 +404,112 @@ void SysBackend::updateWirelessData( con + } + } + +- unsigned char key[IW_ENCODING_TOKEN_MAX]; +- wrq.u.data.pointer = (caddr_t) key; +- wrq.u.data.length = IW_ENCODING_TOKEN_MAX; +- wrq.u.data.flags = 0; +- if ( iw_get_ext( fd, ifName.toLatin1(), SIOCGIWENCODE, &wrq ) >= 0 ) +- { +- if ( ( wrq.u.data.flags & IW_ENCODE_DISABLED ) || ( wrq.u.data.length == 0 ) ) +- { +- data.encryption = false; +- } +- else +- { +- data.encryption = true; +- } +- } +- else ++ if ( data.accessPoint != data.prevAccessPoint ) + { ++ /* Reset encryption status for new access point */ + data.encryption = false; ++ data.prevAccessPoint = data.accessPoint; + } +- close( fd ); ++ if ( has_range ) ++ updateWirelessEncData( fd, ifName, range, data ); + } + #endif + } + ++#ifdef HAVE_LIBIW ++void SysBackend::updateWirelessEncData( int fd, const QString& ifName, ++ const iw_range& range, WirelessData& data ) ++{ ++ /* We only use left-over wireless scans to prevent doing a new scan every ++ * polling period. If our current access point disappears from the results ++ * then updateWirelessEncData will use the last encryption status until the ++ * results are updated again. */ ++ struct iwreq wrq; ++ unsigned char * buffer = NULL; ++ unsigned char * newbuf; ++ int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */ ++ ++ // The following code was taken from iwlist.c with some small changes ++realloc: ++ /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */ ++ newbuf = (unsigned char *)realloc( buffer, buflen ); ++ if ( newbuf == NULL ) ++ { ++ if ( buffer ) ++ free( buffer ); ++ return; ++ } ++ buffer = newbuf; ++ ++ /* Try to read the results */ ++ wrq.u.data.pointer = buffer; ++ wrq.u.data.flags = 0; ++ wrq.u.data.length = buflen; ++ if ( iw_get_ext( fd, ifName.toLatin1(), SIOCGIWSCAN, &wrq ) < 0 ) ++ { ++ /* Check if buffer was too small (WE-17 only) */ ++ if( (errno == E2BIG) && (range.we_version_compiled > 16) ) ++ { ++ /* Some driver may return very large scan results, either ++ * because there are many cells, or because they have many ++ * large elements in cells (like IWEVCUSTOM). Most will ++ * only need the regular sized buffer. We now use a dynamic ++ * allocation of the buffer to satisfy everybody. Of course, ++ * as we don't know in advance the size of the array, we try ++ * various increasing sizes. Jean II */ ++ ++ /* Check if the driver gave us any hints. */ ++ if( wrq.u.data.length > buflen ) ++ buflen = wrq.u.data.length; ++ else ++ buflen *= 2; ++ ++ /* Try again */ ++ goto realloc; ++ } ++ ++ /* EAGAIN or bad error ++ * Try again on next poll tick */ ++ free( buffer ); ++ return; ++ } ++ ++ if ( wrq.u.data.length ) ++ { ++ struct iw_event iwe; ++ struct stream_descr stream; ++ int ret; ++ bool foundAP = false; ++ ++ iw_init_event_stream( &stream, (char *)buffer, wrq.u.data.length ); ++ do ++ { ++ /* Extract the event and process it */ ++ ret = iw_extract_event_stream( &stream, &iwe, range.we_version_compiled ); ++ if (ret > 0 ) ++ { ++ switch ( iwe.cmd ) ++ { ++ case SIOCGIWAP: ++ if ( data.accessPoint == iw_saether_ntop( &iwe.u.ap_addr, (char *)buffer ) ) ++ foundAP = true; ++ break; ++ case SIOCGIWENCODE: ++ if ( foundAP ) ++ { ++ if ( iwe.u.data.flags & IW_ENCODE_DISABLED ) ++ data.encryption = false; ++ else ++ data.encryption = true; ++ free( buffer ); ++ return; ++ } ++ break; ++ } ++ } ++ } ++ while ( ret > 0 ); ++ } ++ free( buffer ); ++} ++#endif +--- knemo-0.5.1/src/knemod/backends/sysbackend.h 2009-02-25 01:17:59.000000000 +0200 ++++ knemo/src/knemod/backends/sysbackend.h 2009-03-14 06:08:10.000000000 +0200 +@@ -22,6 +22,9 @@ + #define SYSBACKEND_H + + #include "backendbase.h" ++#ifdef HAVE_LIBIW ++#include ++#endif + + /** + * The sys backend uses the sys filesystem available in 2.6 +@@ -47,8 +50,11 @@ public: + private: + bool readNumberFromFile( const QString& fileName, unsigned int& value ); + bool readStringFromFile( const QString& fileName, QString& string ); +- void updateWirelessData( const QString& ifName, WirelessData& data ); ++ void updateWirelessData( int fd, const QString& ifName, WirelessData& data ); + void updateInterfaceData( const QString& ifName, InterfaceData& data, int type ); ++#ifdef HAVE_LIBIW ++ void updateWirelessEncData( int fd, const QString& ifName, const iw_range& range, WirelessData& data ); ++#endif + + }; + +--- knemo-0.5.1/src/knemod/global.h 2009-03-01 02:36:20.000000000 +0200 ++++ knemo/src/knemod/global.h 2009-03-14 06:08:10.000000000 +0200 +@@ -91,6 +91,7 @@ struct WirelessData + QString bitRate; + QString linkQuality; + QString accessPoint; ++ QString prevAccessPoint; + QString nickName; + bool encryption; + }; +--- knemo-0.5.1/src/knemod/interface.cpp 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interface.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -44,6 +44,11 @@ Interface::Interface( QString ifname, + mGeneralData( generalData ), + mPlotterSettings( plotterSettings ) + { ++ mPlotterDialog = new InterfacePlotterDialog( mPlotterSettings, mName ); ++ mPlotterTimer = new QTimer(); ++ ++ connect( mPlotterTimer, SIGNAL( timeout() ), ++ this, SLOT( updatePlotter() ) ); + connect( &mMonitor, SIGNAL( statusChanged( int ) ), + &mIcon, SLOT( updateStatus( int ) ) ); + connect( &mMonitor, SIGNAL( available( int ) ), +@@ -90,7 +95,6 @@ void Interface::configChanged() + mIcon.updateTrayStatus( UNKNOWN_STATE ); + // handle changed iconset by user + mIcon.updateStatus( mState ); +- mIcon.updateToolTipTime( QString () ); + mIcon.updateMenu(); + + if ( mPlotterDialog != 0L ) +@@ -128,6 +132,9 @@ void Interface::activateMonitor() + void Interface::setStartTime( int ) + { + mUptime = 0; ++ mUptimeString = "00:00:00"; ++ if ( !mPlotterTimer->isActive() ) ++ mPlotterTimer->start( 1000 ); + } + + void Interface::showStatusDialog() +@@ -160,32 +167,18 @@ void Interface::showStatusDialog() + + void Interface::showSignalPlotter( bool wasMiddleButton ) + { +- // No plotter, create it. +- if ( mPlotterDialog == 0L ) ++ if ( wasMiddleButton ) + { +- mPlotterDialog = new InterfacePlotterDialog( mPlotterSettings, mName ); +- //mPlotter->setTitle( mName ); +- mPlotterDialog->configChanged(); +- activateOrHide( mPlotterDialog, true ); +- +- mPlotterTimer = new QTimer(); +- connect( mPlotterTimer, SIGNAL( timeout() ), +- this, SLOT( updatePlotter() ) ); +- mPlotterTimer->start( 1000 ); ++ // Toggle the signal plotter. ++ activateOrHide( mPlotterDialog ); + } + else + { +- if ( wasMiddleButton ) +- { +- // Toggle the signal plotter. +- activateOrHide( mPlotterDialog ); +- } +- else +- { +- // Called from the context menu, show the dialog. +- activateOrHide( mPlotterDialog, true ); +- } ++ // Called from the context menu, show the dialog. ++ activateOrHide( mPlotterDialog, true ); + } ++ if ( mPlotterDialog->isVisible() && !mPlotterTimer->isActive() ) ++ mPlotterTimer->start( 1000 ); + } + + void Interface::showStatisticsDialog() +@@ -267,8 +260,9 @@ void Interface::updateDetails() + time.sprintf( "%02d:%02d:%02d", hrs, mins, secs ); + uptime += time; + } ++ mUptimeString = uptime; + +- mIcon.updateToolTipTime( uptime ); ++ mIcon.updateToolTip(); + if ( mStatusDialog ) + mStatusDialog->updateDialog(); + } +--- knemo-0.5.1/src/knemod/interface.h 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interface.h 2009-03-14 06:08:10.000000000 +0200 +@@ -83,6 +83,11 @@ public: + return mUptime; + } + ++ QString getUptimeString() ++ { ++ return mUptimeString; ++ } ++ + const QString& getName() const + { + return mName; +@@ -215,6 +220,7 @@ private: + QString mName; + QTimer* mPlotterTimer; + time_t mUptime; ++ QString mUptimeString; + InterfaceIcon mIcon; + InterfaceData mData; + InterfaceMonitor mMonitor; +--- knemo-0.5.1/src/knemod/interfaceicon.cpp 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interfaceicon.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -20,7 +20,6 @@ + + #include + +-#include + #include + #include + #include +@@ -51,7 +50,6 @@ InterfaceIcon::InterfaceIcon( Interface* + mInterface( interface ), + mTray( 0L ) + { +- setupToolTipArray(); + commandActions = new KActionCollection( this ); + plotterAction = new KAction( KIcon( "utilities-system-monitor" ), + i18n( "&Open Traffic Plotter" ), this ); +@@ -98,20 +96,13 @@ void InterfaceIcon::updateStatus( int st + { + mTray->setIcon( UserIcon( iconSet + ICON_CONNECTED ) ); + } +- updateToolTipData(); + } + + void InterfaceIcon::updateToolTip() + { + if ( mTray == 0L ) + return; +- mTray->updateToolTip( mToolTipTop + mToolTipTime + mToolTipBottom ); +-} +- +-void InterfaceIcon::updateToolTipTime( QString uptime ) +-{ +- mToolTipTime = "" + mToolTips.value( UPTIME ) + "" + uptime + "" ; +- updateToolTip(); ++ mTray->updateToolTip(); + } + + void InterfaceIcon::updateMenu() +@@ -169,7 +160,7 @@ void InterfaceIcon::updateTrayStatus( in + else + title = mInterface->getName(); + +- KNotification::event( "knemo_disconnected", ++ KNotification::event( "disconnected", + title + ":\n" + i18n( "Not connected." ) ); + } + +@@ -186,7 +177,7 @@ void InterfaceIcon::updateTrayStatus( in + else + title = mInterface->getName(); + +- KNotification::event( "knemo_notexisting", ++ KNotification::event( "notexisting", + title + ":\n" + i18n( "Not existing." ) ); + } + +@@ -214,8 +205,7 @@ void InterfaceIcon::updateTrayStatus( in + ( !interfaceAvailable && !hideWhenNotAvailable && interfaceExists ) || + ( !interfaceExists && !hideWhenNotExisting && !hideWhenNotAvailable ) ) ) + { +- mTray = new InterfaceTray( mInterface->getName() ); +- mTray->updateToolTip( mInterface->getName() ); ++ mTray = new InterfaceTray( mInterface, mInterface->getName() ); + KMenu* menu = (KMenu *)mTray->contextMenu(); + + menu->removeAction( menu->actions().at( 0 ) ); +@@ -238,7 +228,6 @@ void InterfaceIcon::updateTrayStatus( in + this, SLOT( showConfigDialog() ) ); + + updateStatus( mInterface->getState() ); +- updateToolTipData(); + updateMenu(); + mTray->show(); + } +@@ -258,13 +247,13 @@ void InterfaceIcon::updateTrayStatus( in + + if ( mInterface->getData().wirelessDevice ) + { +- KNotification::event( "knemo_connected", ++ KNotification::event( "connected", + title + ":\n" + i18n( "Connection established to\n" ) + + mInterface->getWirelessData().essid ); + } + else + { +- KNotification::event( "knemo_connected", ++ KNotification::event( "connected", + title + ":\n" + i18n( "Connection established." ) ); + } + } +@@ -312,138 +301,6 @@ void InterfaceIcon::menuTriggered( QActi + process.startDetached(); + } + +-void InterfaceIcon::updateToolTipData() +-{ +- int toolTipContent = mInterface->getGeneralData().toolTipContent; +- InterfaceData& data = mInterface->getData(); +- +- mToolTipTop = ""; +- mToolTipBottom.clear(); +- +- if ( ( toolTipContent & ALIAS ) && +- mInterface->getSettings().alias != QString::null ) +- mToolTipTop += ""; +- if ( toolTipContent & INTERFACE ) +- mToolTipTop += ""; +- if ( data.available ) +- { +- if ( toolTipContent & STATUS ) +- mToolTipTop += ""; +- } +- else if ( data.existing ) +- { +- if ( toolTipContent & STATUS ) +- mToolTipTop += ""; +- } +- else +- { +- if ( toolTipContent & STATUS ) +- mToolTipTop += ""; +- } +- +- if ( data.available ) +- { +- if ( toolTipContent & IP_ADDRESS ) +- mToolTipBottom += ""; +- if ( toolTipContent & SUBNET_MASK ) +- mToolTipBottom += ""; +- if ( mInterface->getType() == Interface::ETHERNET ) +- { +- if ( toolTipContent & BCAST_ADDRESS ) +- mToolTipBottom += ""; +- if ( toolTipContent & GATEWAY ) +- mToolTipBottom += ""; +- if ( toolTipContent & HW_ADDRESS ) +- mToolTipBottom += ""; +- } +- if ( mInterface->getType() == Interface::PPP ) +- { +- if ( toolTipContent & PTP_ADDRESS ) +- mToolTipBottom += ""; +- } +- if ( toolTipContent & RX_PACKETS ) +- mToolTipBottom += ""; +- if ( toolTipContent & TX_PACKETS ) +- mToolTipBottom += ""; +- if ( toolTipContent & RX_BYTES ) +- mToolTipBottom += ""; +- if ( toolTipContent & TX_BYTES ) +- mToolTipBottom += ""; +- if ( toolTipContent & DOWNLOAD_SPEED ) +- { +- unsigned long bytesPerSecond = data.incomingBytes / mInterface->getGeneralData().pollInterval; +- mToolTipBottom += ""; +- } +- if ( toolTipContent & UPLOAD_SPEED ) +- { +- unsigned long bytesPerSecond = data.outgoingBytes / mInterface->getGeneralData().pollInterval; +- mToolTipBottom += ""; +- } +- } +- +- if ( data.available && data.wirelessDevice ) +- { +- WirelessData& wdata = mInterface->getWirelessData(); +- if ( toolTipContent & ESSID ) +- mToolTipBottom += ""; +- if ( toolTipContent & MODE ) +- mToolTipBottom += ""; +- if ( toolTipContent & FREQUENCY ) +- mToolTipBottom += ""; +- if ( toolTipContent & BIT_RATE ) +- mToolTipBottom += ""; +- if ( toolTipContent & ACCESS_POINT ) +- mToolTipBottom += ""; +- if ( toolTipContent & LINK_QUALITY ) +- mToolTipBottom += ""; +- if ( toolTipContent & NICK_NAME ) +- mToolTipBottom += ""; +- if ( toolTipContent & ENCRYPTION ) +- { +- if ( wdata.encryption == true ) +- { +- mToolTipBottom += ""; +- } +- else +- { +- mToolTipBottom += ""; +- } +- } +- } +- mToolTipBottom += "
" + mInterface->getSettings().alias + "
" + mToolTips.value( INTERFACE ) + "" + mInterface->getName() + "
" + mToolTips.value( STATUS ) + "" + i18n( "Connection established." ) + "
" + mToolTips.value( STATUS ) + "" + i18n( "Not connected." ) + "
" + mToolTips.value( STATUS ) + "" + i18n( "Not existing." ) + "
" + mToolTips.value( IP_ADDRESS ) + "" + data.ipAddress + "
" + mToolTips.value( SUBNET_MASK ) + "" + data.subnetMask + "
" + mToolTips.value( BCAST_ADDRESS ) + "" + data.broadcastAddress + "
" + mToolTips.value( GATEWAY ) + "" + data.defaultGateway + "
" + mToolTips.value( HW_ADDRESS ) + "" + data.hwAddress + "
" + mToolTips.value( PTP_ADDRESS ) + "" + data.ptpAddress + "
" + mToolTips.value( RX_PACKETS ) + "" + QString::number( data.rxPackets ) + "
" + mToolTips.value( TX_PACKETS ) + "" + QString::number( data.txPackets ) + "
" + mToolTips.value( RX_BYTES ) + "" + data.rxString + "
" + mToolTips.value( TX_BYTES ) + "" + data.txString + "
" + mToolTips.value( DOWNLOAD_SPEED ) + "" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "
" + mToolTips.value( UPLOAD_SPEED ) + "" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "
" + mToolTips.value( ESSID ) + "" + wdata.essid + "
" + mToolTips.value( MODE ) + "" + wdata.mode + "
" + mToolTips.value( FREQUENCY ) + "" + wdata.frequency + "
" + mToolTips.value( BIT_RATE ) + "" + wdata.bitRate + "
" + mToolTips.value( ACCESS_POINT ) + "" + wdata.accessPoint + "
" + mToolTips.value( LINK_QUALITY ) + "" + wdata.linkQuality + "
" + mToolTips.value( NICK_NAME ) + "" + wdata.nickName + "
" + mToolTips.value( ENCRYPTION ) + "" + i18n( "active" ) + "
" + mToolTips.value( ENCRYPTION ) + "" + i18n( "off" ) + "
"; +- updateToolTip(); +-} +- +-void InterfaceIcon::setupToolTipArray() +-{ +- // Cannot make this data static as the i18n macro doesn't seem +- // to work when called to early i.e. before setting the catalogue. +- mToolTips.insert( INTERFACE, i18n( "Interface" ) ); +- mToolTips.insert( ALIAS, i18n( "Alias" ) ); +- mToolTips.insert( STATUS, i18n( "Status" ) ); +- mToolTips.insert( UPTIME, i18n( "Uptime" ) ); +- mToolTips.insert( IP_ADDRESS, i18n( "IP-Address" ) ); +- mToolTips.insert( SUBNET_MASK, i18n( "Subnet Mask" ) ); +- mToolTips.insert( HW_ADDRESS, i18n( "HW-Address" ) ); +- mToolTips.insert( PTP_ADDRESS, i18n( "PtP-Address" ) ); +- mToolTips.insert( RX_PACKETS, i18n( "Packets Received" ) ); +- mToolTips.insert( TX_PACKETS, i18n( "Packets Sent" ) ); +- mToolTips.insert( RX_BYTES, i18n( "Bytes Received" ) ); +- mToolTips.insert( TX_BYTES, i18n( "Bytes Sent" ) ); +- mToolTips.insert( ESSID, i18n( "ESSID" ) ); +- mToolTips.insert( MODE, i18n( "Mode" ) ); +- mToolTips.insert( FREQUENCY, i18n( "Frequency" ) ); +- mToolTips.insert( BIT_RATE, i18n( "Bit Rate" ) ); +- mToolTips.insert( ACCESS_POINT, i18n( "Access Point" ) ); +- mToolTips.insert( LINK_QUALITY, i18n( "Link Quality" ) ); +- mToolTips.insert( BCAST_ADDRESS, i18n( "Broadcast Address" ) ); +- mToolTips.insert( GATEWAY, i18n( "Default Gateway" ) ); +- mToolTips.insert( DOWNLOAD_SPEED, i18n( "Download Speed" ) ); +- mToolTips.insert( UPLOAD_SPEED, i18n( "Upload Speed" ) ); +- mToolTips.insert( NICK_NAME, i18n( "Nickname" ) ); +- mToolTips.insert( ENCRYPTION, i18n( "Encryption" ) ); +-} +- + void InterfaceIcon::showStatistics() + { + emit statisticsSelected(); +--- knemo-0.5.1/src/knemod/interfaceicon.h 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interfaceicon.h 2009-03-14 06:08:10.000000000 +0200 +@@ -76,8 +76,7 @@ public slots: + /* + * Change the tooltip according to the alias of the interface + */ +- void updateToolTipTime( QString uptime ); +- void updateToolTipData(); ++ void updateToolTip(); + + private slots: + /* +@@ -97,10 +96,6 @@ private slots: + void showStatistics(); + + private: +- QString toolTipText(); +- void updateToolTip(); +- void setupToolTipArray(); +- + // the interface this icon belongs to + Interface* mInterface; + // the real tray icon +@@ -109,11 +104,6 @@ private: + KAction* plotterAction; + KAction* statisticsAction; + KAction* configAction; +- QMap mToolTips; +- QString mToolTipTop; +- QString mToolTipTime; +- QString mToolTipBottom; +- QString mTimeStr; + + static const QString ICON_DISCONNECTED; + static const QString ICON_CONNECTED; +--- knemo-0.5.1/src/knemod/interfaceplotterdialog.cpp 2009-03-02 04:57:00.000000000 +0200 ++++ knemo/src/knemod/interfaceplotterdialog.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -57,8 +57,8 @@ public: + InterfacePlotterDialog::InterfacePlotterDialog( const PlotterSettings &plotterSettings, QString name ) + : KDialog(), + mConfig( KGlobal::config() ), +- mPosInitialized( false ), +- mSizeInitialized( false ), ++ mSetPos( true ), ++ mWasShown( false ), + mPlotterSettings( plotterSettings ), + mName( name ), + mOutgoingPos( 0 ), +@@ -73,10 +73,8 @@ InterfacePlotterDialog::InterfacePlotter + if (fm.inFont(QChar(0x25CF))) + mIndicatorSymbol = QChar(0x25CF); + +- QWidget *main = new QWidget( this ); +- setMainWidget( main ); + QBoxLayout *layout = new QVBoxLayout(); +- main->setLayout( layout ); ++ mainWidget()->setLayout( layout ); + layout->setSpacing(0); + mPlotter = new KSignalPlotter( this ); + mPlotter->setThinFrame( true ); +@@ -102,51 +100,68 @@ InterfacePlotterDialog::InterfacePlotter + mLabelLayout->addWidget( mSentLabel ); + mLabelLayout->addWidget( mReceivedLabel ); + +- setMainWidget( main ); +- + // Restore window size and position. + KConfig *config = mConfig.data(); + KConfigGroup interfaceGroup( config, "Interface_" + mName ); + if ( interfaceGroup.hasKey( "PlotterPos" ) ) + { +- mPos = interfaceGroup.readEntry( "PlotterPos", QPoint() ); +- mPosInitialized = true; ++ QPoint p = interfaceGroup.readEntry( "PlotterPos", QPoint() ); ++ // See comment in event() ++ mSetPos = false; ++ move( p ); + } + if ( interfaceGroup.hasKey( "PlotterSize" ) ) + { +- mSize = interfaceGroup.readEntry( "PlotterSize", QSize() ); +- mSizeInitialized = true; ++ QSize s = interfaceGroup.readEntry( "PlotterSize", QSize() ); ++ // A little hack so the plotter's data isn't chopped off the first time ++ // the dialog appears ++ mPlotter->resize( s ); ++ resize( s ); + } ++ else ++ { ++ // HACK ++ mPlotter->resize( 500, 350 ); ++ // Improve the chance that we have a decent sized dialog ++ // the first time it's shown ++ resize( 500, 350 ); ++ } ++ configChanged(); + } + + InterfacePlotterDialog::~InterfacePlotterDialog() + { + KConfig *config = mConfig.data(); + KConfigGroup interfaceGroup( config, "Interface_" + mName ); +- interfaceGroup.writeEntry( "PlotterPos", pos() ); + interfaceGroup.writeEntry( "PlotterSize", size() ); ++ ++ // If the dialog was never shown, then the position ++ // will be wrong ++ if ( mWasShown ) ++ interfaceGroup.writeEntry( "PlotterPos", pos() ); ++ + config->sync(); + } + + bool InterfacePlotterDialog::event( QEvent *e ) + { +- if ( e->type() == QEvent::Hide ) +- { +- mPos = pos(); +- mSize = size(); +- mPosInitialized = true; +- mSizeInitialized = true; +- } +- if ( e->type() == QEvent::Show ) ++ /* If we do not explicitly call size() and move() at least once then ++ * hiding and showing the dialog will cause it to forget its previous ++ * size and position. */ ++ switch ( e->type() ) + { +- if ( mPosInitialized ) +- move( mPos ); +- if ( mSizeInitialized ) +- resize( mSize ); +- else +- // Improve the chance that we have a decent sized plotter +- // the first time dialog for this interface is shown. +- resize( 500, 350 ); ++ case QEvent::Move: ++ if ( mSetPos && !pos().isNull() ) ++ { ++ mSetPos = false; ++ move( pos() ); ++ } ++ break; ++ case QEvent::Show: ++ mWasShown = true; ++ break; ++ default: ++ ;; + } + + return KDialog::event( e ); +--- knemo-0.5.1/src/knemod/interfaceplotterdialog.h 2009-03-02 04:57:00.000000000 +0200 ++++ knemo/src/knemod/interfaceplotterdialog.h 2009-03-14 06:08:10.000000000 +0200 +@@ -61,10 +61,8 @@ private: + }; + + KSharedConfigPtr mConfig; +- QPoint mPos; +- QSize mSize; +- bool mPosInitialized; +- bool mSizeInitialized; ++ bool mSetPos; ++ bool mWasShown; + const PlotterSettings& mPlotterSettings; + QString mName; + int mOutgoingPos; +--- knemo-0.5.1/src/knemod/interfacestatisticsdialog.cpp 2009-03-02 06:07:42.000000000 +0200 ++++ knemo/src/knemod/interfacestatisticsdialog.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -35,18 +35,14 @@ + + InterfaceStatisticsDialog::InterfaceStatisticsDialog( Interface* interface, QWidget* parent ) + : KDialog( parent ), +- mPosInitialized( false ), +- mSizeInitialized( false ), ++ mSetPos( true ), + mConfig( KGlobal::config() ), + mInterface( interface ) + { + setCaption( interface->getName() + " " + i18n( "Statistics" ) ); + setButtons( Close ); + +- QWidget *main = new QWidget( this ); +- setMainWidget( main ); +- ui.setupUi( main ); +- setMainWidget( main ); ++ ui.setupUi( mainWidget() ); + + dailyModel = new QStandardItemModel( this ); + monthlyModel = new QStandardItemModel( this ); +@@ -71,13 +67,21 @@ InterfaceStatisticsDialog::InterfaceStat + KConfigGroup interfaceGroup( config, "Interface_" + mInterface->getName() ); + if ( interfaceGroup.hasKey( "StatisticsPos" ) ) + { +- mPos = interfaceGroup.readEntry( "StatisticsPos", QPoint() ); +- mPosInitialized = true; ++ QPoint p = interfaceGroup.readEntry( "StatisticsPos", QPoint() ); ++ // See comment in event() ++ mSetPos = false; ++ move( p ); + } + if ( interfaceGroup.hasKey( "StatisticsSize" ) ) + { +- mSize = interfaceGroup.readEntry( "StatisticsSize", QSize() ); +- mSizeInitialized = true; ++ QSize s = interfaceGroup.readEntry( "StatisticsSize", QSize() ); ++ resize( s ); ++ } ++ else ++ { ++ // Improve the chance that we have a decent sized dialog ++ // the first time it's shown ++ resize( 600, 450 ); + } + } + +@@ -92,19 +96,16 @@ InterfaceStatisticsDialog::~InterfaceSta + + bool InterfaceStatisticsDialog::event( QEvent *e ) + { +- if ( e->type() == QEvent::Hide ) +- { +- mPos = pos(); +- mSize = size(); +- mPosInitialized = true; +- mSizeInitialized = true; +- } +- if ( e->type() == QEvent::Show ) +- { +- if ( mPosInitialized ) +- move( mPos ); +- if ( mSizeInitialized ) +- resize( mSize ); ++ /* If we do not explicitly call size() and move() at least once then ++ * hiding and showing the dialog will cause it to forget its previous ++ * size and position. */ ++ if ( e->type() == QEvent::Move ) ++ { ++ if ( mSetPos && !pos().isNull() ) ++ { ++ mSetPos = false; ++ move( pos() ); ++ } + } + + return KDialog::event( e ); +--- knemo-0.5.1/src/knemod/interfacestatisticsdialog.h 2009-03-02 04:57:00.000000000 +0200 ++++ knemo/src/knemod/interfacestatisticsdialog.h 2009-03-14 06:08:10.000000000 +0200 +@@ -67,10 +67,7 @@ protected: + + private: + Ui::InterfaceStatisticsDlg ui; +- QPoint mPos; +- QSize mSize; +- bool mPosInitialized; +- bool mSizeInitialized; ++ bool mSetPos; + KSharedConfigPtr mConfig; + Interface* mInterface; + QStandardItemModel* dailyModel; +--- knemo-0.5.1/src/knemod/interfacestatusdialog.cpp 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interfacestatusdialog.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -27,18 +27,14 @@ + + InterfaceStatusDialog::InterfaceStatusDialog( Interface* interface, QWidget* parent ) + : KDialog( parent ), +- mPosInitialized( false ), +- mSizeInitialized( false ), ++ mSetPos( true ), + mConfig( KGlobal::config() ), + mInterface( interface ) + { + setCaption( interface->getName() + " " + i18n( "Interface Status" ) ); + setButtons( Close ); + +- QWidget *main = new QWidget( this ); +- setMainWidget( main ); +- ui.setupUi( main ); +- setMainWidget( main ); ++ ui.setupUi( mainWidget() ); + + updateDialog(); + if ( interface->getData().available ) +@@ -66,14 +62,18 @@ InterfaceStatusDialog::InterfaceStatusDi + KConfigGroup interfaceGroup( config, "Interface_" + mInterface->getName() ); + if ( interfaceGroup.hasKey( "StatusPos" ) ) + { +- mPos = interfaceGroup.readEntry( "StatusPos", QPoint() ); +- mPosInitialized = true; ++ QPoint p = interfaceGroup.readEntry( "StatusPos", QPoint() ); ++ // See comment in event() ++ mSetPos = false; ++ move( p ); + } + if ( interfaceGroup.hasKey( "StatusSize" ) ) + { +- mSize = interfaceGroup.readEntry( "StatusSize", QSize() ); +- mSizeInitialized = true; ++ QSize s = interfaceGroup.readEntry( "StatusSize", QSize() ); ++ resize( s ); + } ++ else ++ resize( sizeHint() ); + + statisticsChanged(); + } +@@ -89,19 +89,16 @@ InterfaceStatusDialog::~InterfaceStatusD + + bool InterfaceStatusDialog::event( QEvent *e ) + { +- if ( e->type() == QEvent::Hide ) ++ /* If we do not explicitly call size() and move() at least once then ++ * hiding and showing the dialog will cause it to forget its previous ++ * size and position. */ ++ if ( e->type() == QEvent::Move ) + { +- mPos = pos(); +- mSize = size(); +- mPosInitialized = true; +- mSizeInitialized = true; +- } +- if ( e->type() == QEvent::Show ) +- { +- if ( mPosInitialized ) +- move( mPos ); +- if ( mSizeInitialized ) +- resize( mSize ); ++ if ( mSetPos && !pos().isNull() ) ++ { ++ mSetPos = false; ++ move( pos() ); ++ } + } + + return KDialog::event( e ); +@@ -207,7 +204,7 @@ void InterfaceStatusDialog::updateDialog + ui.textLabelMode->setText( wdata.mode ); + ui.textLabelFreqChannel->setText( wdata.frequency + " [" + wdata.channel + "]" ); + ui.textLabelBitRate->setText( wdata.bitRate ); +- ui.textLabelLinkQuality->setText( wdata.linkQuality + "%" ); ++ ui.textLabelLinkQuality->setText( wdata.linkQuality ); + if ( wdata.encryption == true ) + { + ui.textLabelEncryption->setText( i18n( "active" ) ); +--- knemo-0.5.1/src/knemod/interfacestatusdialog.h 2009-03-02 04:57:00.000000000 +0200 ++++ knemo/src/knemod/interfacestatusdialog.h 2009-03-14 06:08:10.000000000 +0200 +@@ -75,10 +75,7 @@ protected: + + private: + Ui::InterfaceStatusDlg ui; +- QPoint mPos; +- QSize mSize; +- bool mPosInitialized; +- bool mSizeInitialized; ++ bool mSetPos; + + KSharedConfigPtr mConfig; + Interface* mInterface; +--- knemo-0.5.1/src/knemod/interfacetray.cpp 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interfacetray.cpp 2009-03-14 06:08:10.000000000 +0200 +@@ -19,35 +19,179 @@ + */ + + #include "interfacetray.h" ++ ++#include ++#include ++ + #include + #include + +-InterfaceTray::InterfaceTray( const QString& icon, QWidget* parent ) : KSystemTrayIcon( icon, parent ) ++InterfaceTray::InterfaceTray( Interface* interface, const QString& icon, QWidget* parent ) : KSystemTrayIcon( icon, parent ) + { ++ mInterface = interface; ++ setupToolTipArray(); + } + + InterfaceTray::~InterfaceTray() + { + } + +-void InterfaceTray::updateToolTip( const QString& tip ) ++void InterfaceTray::updateToolTip() + { +- setToolTip( tip ); + QPoint pos = QCursor::pos(); + /* If a tooltip is already visible and the global cursor position is in + * our rect then it must be our tooltip, right? */ + if ( !QToolTip::text().isEmpty() && geometry().contains( pos ) ) ++ { + /* Sure. Update its text in case any data changed. */ ++ setToolTip( toolTipData() ); + QToolTip::showText( pos, toolTip() ); ++ } + } + + bool InterfaceTray::event( QEvent *e ) + { + if (e->type() == QEvent::ToolTip) { + QHelpEvent *helpEvent = static_cast(e); ++ setToolTip( toolTipData() ); + QToolTip::showText(helpEvent->globalPos(), toolTip() ); + return true; + } + else + return KSystemTrayIcon::event(e); + } ++ ++QString InterfaceTray::toolTipData() ++{ ++ QString tipData; ++ int toolTipContent = mInterface->getGeneralData().toolTipContent; ++ InterfaceData& data = mInterface->getData(); ++ ++ tipData = ""; ++ ++ if ( ( toolTipContent & ALIAS ) && ++ mInterface->getSettings().alias != QString::null ) ++ tipData += ""; ++ if ( toolTipContent & INTERFACE ) ++ tipData += ""; ++ if ( data.available ) ++ { ++ if ( toolTipContent & STATUS ) ++ tipData += ""; ++ } ++ else if ( data.existing ) ++ { ++ if ( toolTipContent & STATUS ) ++ tipData += ""; ++ } ++ else ++ { ++ if ( toolTipContent & STATUS ) ++ tipData += ""; ++ } ++ ++ if ( toolTipContent & UPTIME ) ++ tipData = "" ; ++ ++ if ( data.available ) ++ { ++ if ( toolTipContent & IP_ADDRESS ) ++ tipData += ""; ++ if ( toolTipContent & SUBNET_MASK ) ++ tipData += ""; ++ if ( mInterface->getType() == Interface::ETHERNET ) ++ { ++ if ( toolTipContent & BCAST_ADDRESS ) ++ tipData += ""; ++ if ( toolTipContent & GATEWAY ) ++ tipData += ""; ++ if ( toolTipContent & HW_ADDRESS ) ++ tipData += ""; ++ } ++ if ( mInterface->getType() == Interface::PPP ) ++ { ++ if ( toolTipContent & PTP_ADDRESS ) ++ tipData += ""; ++ } ++ if ( toolTipContent & RX_PACKETS ) ++ tipData += ""; ++ if ( toolTipContent & TX_PACKETS ) ++ tipData += ""; ++ if ( toolTipContent & RX_BYTES ) ++ tipData += ""; ++ if ( toolTipContent & TX_BYTES ) ++ tipData += ""; ++ if ( toolTipContent & DOWNLOAD_SPEED ) ++ { ++ unsigned long bytesPerSecond = data.incomingBytes / mInterface->getGeneralData().pollInterval; ++ tipData += ""; ++ } ++ if ( toolTipContent & UPLOAD_SPEED ) ++ { ++ unsigned long bytesPerSecond = data.outgoingBytes / mInterface->getGeneralData().pollInterval; ++ tipData += ""; ++ } ++ } ++ ++ if ( data.available && data.wirelessDevice ) ++ { ++ WirelessData& wdata = mInterface->getWirelessData(); ++ if ( toolTipContent & ESSID ) ++ tipData += ""; ++ if ( toolTipContent & MODE ) ++ tipData += ""; ++ if ( toolTipContent & FREQUENCY ) ++ tipData += ""; ++ if ( toolTipContent & BIT_RATE ) ++ tipData += ""; ++ if ( toolTipContent & ACCESS_POINT ) ++ tipData += ""; ++ if ( toolTipContent & LINK_QUALITY ) ++ tipData += ""; ++ if ( toolTipContent & NICK_NAME ) ++ tipData += ""; ++ if ( toolTipContent & ENCRYPTION ) ++ { ++ if ( wdata.encryption == true ) ++ { ++ tipData += ""; ++ } ++ else ++ { ++ tipData += ""; ++ } ++ } ++ } ++ tipData += "
" + mInterface->getSettings().alias + "
" + mToolTips.value( INTERFACE ) + "" + mInterface->getName() + "
" + mToolTips.value( STATUS ) + "" + i18n( "Connection established." ) + "
" + mToolTips.value( STATUS ) + "" + i18n( "Not connected." ) + "
" + mToolTips.value( STATUS ) + "" + i18n( "Not existing." ) + "
" + mToolTips.value( UPTIME ) + "" + mInterface->getUptimeString() + "
" + mToolTips.value( IP_ADDRESS ) + "" + data.ipAddress + "
" + mToolTips.value( SUBNET_MASK ) + "" + data.subnetMask + "
" + mToolTips.value( BCAST_ADDRESS ) + "" + data.broadcastAddress + "
" + mToolTips.value( GATEWAY ) + "" + data.defaultGateway + "
" + mToolTips.value( HW_ADDRESS ) + "" + data.hwAddress + "
" + mToolTips.value( PTP_ADDRESS ) + "" + data.ptpAddress + "
" + mToolTips.value( RX_PACKETS ) + "" + QString::number( data.rxPackets ) + "
" + mToolTips.value( TX_PACKETS ) + "" + QString::number( data.txPackets ) + "
" + mToolTips.value( RX_BYTES ) + "" + data.rxString + "
" + mToolTips.value( TX_BYTES ) + "" + data.txString + "
" + mToolTips.value( DOWNLOAD_SPEED ) + "" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "
" + mToolTips.value( UPLOAD_SPEED ) + "" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "
" + mToolTips.value( ESSID ) + "" + wdata.essid + "
" + mToolTips.value( MODE ) + "" + wdata.mode + "
" + mToolTips.value( FREQUENCY ) + "" + wdata.frequency + "
" + mToolTips.value( BIT_RATE ) + "" + wdata.bitRate + "
" + mToolTips.value( ACCESS_POINT ) + "" + wdata.accessPoint + "
" + mToolTips.value( LINK_QUALITY ) + "" + wdata.linkQuality + "
" + mToolTips.value( NICK_NAME ) + "" + wdata.nickName + "
" + mToolTips.value( ENCRYPTION ) + "" + i18n( "active" ) + "
" + mToolTips.value( ENCRYPTION ) + "" + i18n( "off" ) + "
"; ++ return tipData; ++} ++ ++void InterfaceTray::setupToolTipArray() ++{ ++ // Cannot make this data static as the i18n macro doesn't seem ++ // to work when called to early i.e. before setting the catalogue. ++ mToolTips.insert( INTERFACE, i18n( "Interface" ) ); ++ mToolTips.insert( ALIAS, i18n( "Alias" ) ); ++ mToolTips.insert( STATUS, i18n( "Status" ) ); ++ mToolTips.insert( UPTIME, i18n( "Uptime" ) ); ++ mToolTips.insert( IP_ADDRESS, i18n( "IP-Address" ) ); ++ mToolTips.insert( SUBNET_MASK, i18n( "Subnet Mask" ) ); ++ mToolTips.insert( HW_ADDRESS, i18n( "HW-Address" ) ); ++ mToolTips.insert( PTP_ADDRESS, i18n( "PtP-Address" ) ); ++ mToolTips.insert( RX_PACKETS, i18n( "Packets Received" ) ); ++ mToolTips.insert( TX_PACKETS, i18n( "Packets Sent" ) ); ++ mToolTips.insert( RX_BYTES, i18n( "Bytes Received" ) ); ++ mToolTips.insert( TX_BYTES, i18n( "Bytes Sent" ) ); ++ mToolTips.insert( ESSID, i18n( "ESSID" ) ); ++ mToolTips.insert( MODE, i18n( "Mode" ) ); ++ mToolTips.insert( FREQUENCY, i18n( "Frequency" ) ); ++ mToolTips.insert( BIT_RATE, i18n( "Bit Rate" ) ); ++ mToolTips.insert( ACCESS_POINT, i18n( "Access Point" ) ); ++ mToolTips.insert( LINK_QUALITY, i18n( "Link Quality" ) ); ++ mToolTips.insert( BCAST_ADDRESS, i18n( "Broadcast Address" ) ); ++ mToolTips.insert( GATEWAY, i18n( "Default Gateway" ) ); ++ mToolTips.insert( DOWNLOAD_SPEED, i18n( "Download Speed" ) ); ++ mToolTips.insert( UPLOAD_SPEED, i18n( "Upload Speed" ) ); ++ mToolTips.insert( NICK_NAME, i18n( "Nickname" ) ); ++ mToolTips.insert( ENCRYPTION, i18n( "Encryption" ) ); ++} +--- knemo-0.5.1/src/knemod/interfacetray.h 2009-03-05 03:05:27.000000000 +0200 ++++ knemo/src/knemod/interfacetray.h 2009-03-14 06:08:10.000000000 +0200 +@@ -22,6 +22,8 @@ + + #include + ++#include "interface.h" ++ + class InterfaceTray : public KSystemTrayIcon + { + Q_OBJECT +@@ -29,17 +31,24 @@ public: + /** + * Default Constructor + */ +- InterfaceTray( const QString& icon, QWidget* parent = 0 ); ++ InterfaceTray( Interface* interface, const QString& icon, QWidget* parent = 0 ); + + /** + * Default Destructor + */ + virtual ~InterfaceTray(); + +- void updateToolTip( const QString& toolTip ); ++ void updateToolTip(); + + protected: + bool event( QEvent * ); ++ ++private: ++ Interface* mInterface; ++ QMap mToolTips; ++ ++ QString toolTipData(); ++ void setupToolTipArray(); + }; + + #endif // INTERFACETRAY_H +--- knemo-0.5.1/src/knemod/knemo.notifyrc 2009-02-25 01:17:59.000000000 +0200 ++++ knemo/src/knemod/knemo.notifyrc 2009-03-14 06:08:10.000000000 +0200 +@@ -29,7 +29,7 @@ Comment[uk]=Монітор мережі + Comment[xx]=xxKDE Network Monitorxx + Comment[zh_CN]=KDE 网络监视器 + +-[knemo_connected] ++[Event/connected] + Name=Connected + Name[bg]=Активно + Name[br]=Kevreet +@@ -94,7 +94,7 @@ Comment[zh_CN]=接口已连接 + Sound=KDE_Sys-App-Positive.ogg + Action=Popup + +-[knemo_disconnected] ++[Event/disconnected] + Name=Disconnected + Name[bg]=Неактивен + Name[br]=Digevreet +@@ -159,7 +159,7 @@ Comment[zh_CN]=接口已断开 + Sound=KDE_Sys-App-Negative.ogg + Action=Popup + +-[knemo_notexisting] ++[Event/notexisting] + Name=Not existing + Name[bg]=Несъществуващ + Name[br]=N'eo ket endeo diff --git a/knemo.spec b/knemo.spec new file mode 100644 index 0000000..e1f5615 --- /dev/null +++ b/knemo.spec @@ -0,0 +1,124 @@ +Name: knemo +Version: 0.5.1 +Release: 4%{?dist} +Summary: A KDE network monitoring tool +Group: Applications/Internet +License: GPLv2 +URL: http://extragear.kde.org/apps/knemo/ +Source0: http://kde-apps.org/content/files/12956-%{name}-%{version}.tar.gz +Patch0: knemo-git-2009-03-14.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: cmake desktop-file-utils gettext +BuildRequires: kdelibs-devel wireless-tools-devel net-tools +Requires: kdelibs wireless-tools net-tools +Requires(post): xdg-utils +Requires(postun): xdg-utils + +%description +KNemo displays for every network interface an icon in the systray. Tooltips +and an info dialog provide further information about the interface. Passive +popups inform about interface changes. A traffic plotter is also integrated. +It polls the network interface status every second using the ifconfig, route +and iwconfig tools. + +%prep +%setup -q +%patch0 -p1 + +%build +mkdir -p %{_target_platform} +pushd %{_target_platform} +%{cmake_kde4} .. +popd + +make %{?_smp_mflags} -C %{_target_platform} + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} -C %{_target_platform} + +desktop-file-install --vendor "" \ + --dir %{buildroot}%{_datadir}/applications/kde4 \ + --remove-key=Path \ + %{buildroot}%{_datadir}/applications/kde4/%{name}.desktop + +%find_lang %{name} +%find_lang kcm_%{name} +cat kcm_%{name}.lang >> %{name}.lang + +%clean +rm -rf %{buildroot} + +%post +xdg-icon-resource forceupdate --theme hicolor 2> /dev/null || : +xdg-desktop-menu forceupdate 2> /dev/null || : + +%postun +xdg-icon-resource forceupdate --theme hicolor 2> /dev/null || : +xdg-desktop-menu forceupdate 2> /dev/null || : + +%files -f %{name}.lang +%defattr(-,root,root,-) +%doc AUTHORS ChangeLog COPYING README TODO +%{_kde4_bindir}/knemo +%{_kde4_libdir}/kde4/kcm_knemo.so +%{_kde4_appsdir}/knemo/ +%{_kde4_datadir}/applications/kde4/knemo.desktop +%{_kde4_datadir}/kde4/services/kcm_knemo.desktop +%{_kde4_datadir}/autostart/knemo.desktop +%{_kde4_iconsdir}/hicolor/*/apps/knemo.* + +%changelog +* Sat Mar 14 2009 nucleo - 0.5.1-4 +- Upstream update from git.mehercule.net + +* Thu Mar 5 2009 nucleo - 0.5.1-1 +- Update to version 0.5.1 + +* Wed Feb 25 2009 nucleo - 0.5.0-3 +- Update to version 0.5.0 for KDE4 + +* Tue Apr 17 2007 Francois Aucamp - 0.4.7-1 +- Update to version 0.4.7 +- Removed unnecessary desktop-file-install statements (KDE-specific desktop + files) +- Removed desktop file patch - desktop file "Keywords" keys used internally + by KDE +- Added "OnlyShowIn=KDE" to kcm desktop file +- Removed unnecessary BuildRequires: qt-devel desktop-file-utils +- Simplified %%post and %%postun scriplets +- Use RPM_BUILD_ROOT variable format consistently + +* Wed Sep 13 2006 Hugo Cisneiros 0.4.3-2 +- Rebuilt for FC6 + +* Sun Aug 6 2006 Hugo Cisneiros 0.4.3-1 +- New upstream version + +* Mon Jun 26 2006 Hugo Cisneiros 0.4.2-1 +- Upstream update +- Fixes crashing when you click in panel icon (bz #196576) +- ifconfig and iwconfig are now in both Requires and + BuildRequires (it checks while building too) + +* Tue Jun 13 2006 Hugo Cisneiros 0.4.1-2 +- ifconfig and iwconfig are now in Requires section instead + of BuildRequires. They are runtime dependencies. Thanks to + Kevin Kofler for pointing this. + +* Mon Jun 12 2006 Hugo Cisneiros 0.4.1-1 +- Upstream update + +* Tue May 30 2006 Hugo Cisneiros 0.4.0-4 +- Created BuildRequires for the ifconfig and iwconfig commands, + as knemo utilizes it for monitoring. +- Removed addition of categories in desktop-file-install command + +* Thu May 25 2006 Hugo Cisneiros 0.4.0-3 +- Removed vendor option from desktop-file-install (no renaming) + +* Sat May 20 2006 Hugo Cisneiros 0.4.0-2 +- Installed .desktop files now use desktop-file-install + +* Sat May 20 2006 Hugo Cisneiros 0.4.0-1 +- Initial RPM release. diff --git a/sources b/sources new file mode 100644 index 0000000..090bf57 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +5968cde508282ca5cee84dce64c928fa 12956-knemo-0.5.1.tar.gz