rpms/knemo/F-9 Makefile, 1.2, 1.3 import.log, NONE, 1.1 knemo-git-2009-03-14.patch, NONE, 1.1 knemo.spec, 1.11, 1.12 sources, 1.7, 1.8 .cvsignore, 1.6, 1.7 dead.package, 1.1, NONE
Alexey Kurov
nucleo at fedoraproject.org
Tue Mar 17 13:22:10 UTC 2009
- Previous message (by thread): rpms/knemo/devel import.log,1.1,1.2 knemo.spec,1.12,1.13
- Next message (by thread): rpms/php-ZendFramework/devel .cvsignore, 1.6, 1.7 php-ZendFramework.spec, 1.12, 1.13 sources, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: nucleo
Update of /cvs/pkgs/rpms/knemo/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21399/F-9
Modified Files:
.cvsignore
Added Files:
Makefile import.log knemo-git-2009-03-14.patch knemo.spec
sources
Removed Files:
dead.package
Log Message:
Update to version 0.5.1 for KDE4
Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Makefile 17 Mar 2009 13:21:39 -0000 1.3
@@ -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)
--- NEW FILE import.log ---
knemo-0_5_1-4_fc10:F-9:knemo-0.5.1-4.fc10.src.rpm:1237296007
knemo-git-2009-03-14.patch:
--- NEW FILE knemo-git-2009-03-14.patch ---
--- 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 <iwlib.h>
-#else
+#ifndef HAVE_LIBIW
#include <net/if.h>
#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 <iwlib.h>
+#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 <unistd.h>
-#include <kio/global.h>
#include <KHelpMenu>
#include <KIcon>
#include <KAction>
@@ -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 = "<tr><td style='padding-right:1em'>" + mToolTips.value( UPTIME ) + "</td><td>" + uptime + "</td></tr>" ;
- 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 = "<table cellspacing='2'>";
- mToolTipBottom.clear();
-
- if ( ( toolTipContent & ALIAS ) &&
- mInterface->getSettings().alias != QString::null )
- mToolTipTop += "<tr><th colspan='2' align='center'>" + mInterface->getSettings().alias + "</th></tr>";
- if ( toolTipContent & INTERFACE )
- mToolTipTop += "<tr><td style='padding-right:1em'>" + mToolTips.value( INTERFACE ) + "</td><td>" + mInterface->getName() + "</td></tr>";
- if ( data.available )
- {
- if ( toolTipContent & STATUS )
- mToolTipTop += "<tr><td style='padding-right:1em'>" + mToolTips.value( STATUS ) + "</td><td>" + i18n( "Connection established." ) + "</td></tr>";
- }
- else if ( data.existing )
- {
- if ( toolTipContent & STATUS )
- mToolTipTop += "<tr><td style='padding-right:1em'>" + mToolTips.value( STATUS ) + "</td><td>" + i18n( "Not connected." ) + "</td></tr>";
- }
- else
- {
- if ( toolTipContent & STATUS )
- mToolTipTop += "<tr><td style='padding-right:1em'>" + mToolTips.value( STATUS ) + "</td><td>" + i18n( "Not existing." ) + "</td></tr>";
- }
-
- if ( data.available )
- {
- if ( toolTipContent & IP_ADDRESS )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( IP_ADDRESS ) + "</td><td>" + data.ipAddress + "</td></tr>";
- if ( toolTipContent & SUBNET_MASK )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( SUBNET_MASK ) + "</td><td>" + data.subnetMask + "</td></tr>";
- if ( mInterface->getType() == Interface::ETHERNET )
- {
- if ( toolTipContent & BCAST_ADDRESS )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( BCAST_ADDRESS ) + "</td><td>" + data.broadcastAddress + "</td></tr>";
- if ( toolTipContent & GATEWAY )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( GATEWAY ) + "</td><td>" + data.defaultGateway + "</td></tr>";
- if ( toolTipContent & HW_ADDRESS )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( HW_ADDRESS ) + "</td><td>" + data.hwAddress + "</td></tr>";
- }
- if ( mInterface->getType() == Interface::PPP )
- {
- if ( toolTipContent & PTP_ADDRESS )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( PTP_ADDRESS ) + "</td><td>" + data.ptpAddress + "</td></tr>";
- }
- if ( toolTipContent & RX_PACKETS )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( RX_PACKETS ) + "</td><td>" + QString::number( data.rxPackets ) + "</td></tr>";
- if ( toolTipContent & TX_PACKETS )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( TX_PACKETS ) + "</td><td>" + QString::number( data.txPackets ) + "</td></tr>";
- if ( toolTipContent & RX_BYTES )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( RX_BYTES ) + "</td><td>" + data.rxString + "</td></tr>";
- if ( toolTipContent & TX_BYTES )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( TX_BYTES ) + "</td><td>" + data.txString + "</td></tr>";
- if ( toolTipContent & DOWNLOAD_SPEED )
- {
- unsigned long bytesPerSecond = data.incomingBytes / mInterface->getGeneralData().pollInterval;
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( DOWNLOAD_SPEED ) + "</td><td>" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "</td></tr>";
- }
- if ( toolTipContent & UPLOAD_SPEED )
- {
- unsigned long bytesPerSecond = data.outgoingBytes / mInterface->getGeneralData().pollInterval;
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( UPLOAD_SPEED ) + "</td><td>" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "</td></tr>";
- }
- }
-
- if ( data.available && data.wirelessDevice )
- {
- WirelessData& wdata = mInterface->getWirelessData();
- if ( toolTipContent & ESSID )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( ESSID ) + "</td><td>" + wdata.essid + "</td></tr>";
- if ( toolTipContent & MODE )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( MODE ) + "</td><td>" + wdata.mode + "</td></tr>";
- if ( toolTipContent & FREQUENCY )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( FREQUENCY ) + "</td><td>" + wdata.frequency + "</td></tr>";
- if ( toolTipContent & BIT_RATE )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( BIT_RATE ) + "</td><td>" + wdata.bitRate + "</td></tr>";
- if ( toolTipContent & ACCESS_POINT )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( ACCESS_POINT ) + "</td><td>" + wdata.accessPoint + "</td></tr>";
- if ( toolTipContent & LINK_QUALITY )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( LINK_QUALITY ) + "</td><td>" + wdata.linkQuality + "</td></tr>";
- if ( toolTipContent & NICK_NAME )
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( NICK_NAME ) + "</td><td>" + wdata.nickName + "</td></tr>";
- if ( toolTipContent & ENCRYPTION )
- {
- if ( wdata.encryption == true )
- {
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( ENCRYPTION ) + "</td><td>" + i18n( "active" ) + "</td></tr>";
- }
- else
- {
- mToolTipBottom += "<tr><td style='padding-right:1em'>" + mToolTips.value( ENCRYPTION ) + "</td><td>" + i18n( "off" ) + "</td></tr>";
- }
- }
- }
- mToolTipBottom += "</table>";
- 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<quint32, QString> 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 <kio/global.h>
+#include <KLocale>
+
#include <QToolTip>
#include <QHelpEvent>
-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<QHelpEvent *>(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 = "<table cellspacing='2'>";
+
+ if ( ( toolTipContent & ALIAS ) &&
+ mInterface->getSettings().alias != QString::null )
+ tipData += "<tr><th colspan='2' align='center'>" + mInterface->getSettings().alias + "</th></tr>";
+ if ( toolTipContent & INTERFACE )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( INTERFACE ) + "</td><td>" + mInterface->getName() + "</td></tr>";
+ if ( data.available )
+ {
+ if ( toolTipContent & STATUS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( STATUS ) + "</td><td>" + i18n( "Connection established." ) + "</td></tr>";
+ }
+ else if ( data.existing )
+ {
+ if ( toolTipContent & STATUS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( STATUS ) + "</td><td>" + i18n( "Not connected." ) + "</td></tr>";
+ }
+ else
+ {
+ if ( toolTipContent & STATUS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( STATUS ) + "</td><td>" + i18n( "Not existing." ) + "</td></tr>";
+ }
+
+ if ( toolTipContent & UPTIME )
+ tipData = "<tr><td style='padding-right:1em'>" + mToolTips.value( UPTIME ) + "</td><td>" + mInterface->getUptimeString() + "</td></tr>" ;
+
+ if ( data.available )
+ {
+ if ( toolTipContent & IP_ADDRESS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( IP_ADDRESS ) + "</td><td>" + data.ipAddress + "</td></tr>";
+ if ( toolTipContent & SUBNET_MASK )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( SUBNET_MASK ) + "</td><td>" + data.subnetMask + "</td></tr>";
+ if ( mInterface->getType() == Interface::ETHERNET )
+ {
+ if ( toolTipContent & BCAST_ADDRESS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( BCAST_ADDRESS ) + "</td><td>" + data.broadcastAddress + "</td></tr>";
+ if ( toolTipContent & GATEWAY )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( GATEWAY ) + "</td><td>" + data.defaultGateway + "</td></tr>";
+ if ( toolTipContent & HW_ADDRESS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( HW_ADDRESS ) + "</td><td>" + data.hwAddress + "</td></tr>";
+ }
+ if ( mInterface->getType() == Interface::PPP )
+ {
+ if ( toolTipContent & PTP_ADDRESS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( PTP_ADDRESS ) + "</td><td>" + data.ptpAddress + "</td></tr>";
+ }
+ if ( toolTipContent & RX_PACKETS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( RX_PACKETS ) + "</td><td>" + QString::number( data.rxPackets ) + "</td></tr>";
+ if ( toolTipContent & TX_PACKETS )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( TX_PACKETS ) + "</td><td>" + QString::number( data.txPackets ) + "</td></tr>";
+ if ( toolTipContent & RX_BYTES )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( RX_BYTES ) + "</td><td>" + data.rxString + "</td></tr>";
+ if ( toolTipContent & TX_BYTES )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( TX_BYTES ) + "</td><td>" + data.txString + "</td></tr>";
+ if ( toolTipContent & DOWNLOAD_SPEED )
+ {
+ unsigned long bytesPerSecond = data.incomingBytes / mInterface->getGeneralData().pollInterval;
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( DOWNLOAD_SPEED ) + "</td><td>" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "</td></tr>";
+ }
+ if ( toolTipContent & UPLOAD_SPEED )
+ {
+ unsigned long bytesPerSecond = data.outgoingBytes / mInterface->getGeneralData().pollInterval;
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( UPLOAD_SPEED ) + "</td><td>" + KIO::convertSize( bytesPerSecond ) + i18n( "/s" ) + "</td></tr>";
+ }
+ }
+
+ if ( data.available && data.wirelessDevice )
+ {
+ WirelessData& wdata = mInterface->getWirelessData();
+ if ( toolTipContent & ESSID )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( ESSID ) + "</td><td>" + wdata.essid + "</td></tr>";
+ if ( toolTipContent & MODE )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( MODE ) + "</td><td>" + wdata.mode + "</td></tr>";
+ if ( toolTipContent & FREQUENCY )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( FREQUENCY ) + "</td><td>" + wdata.frequency + "</td></tr>";
+ if ( toolTipContent & BIT_RATE )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( BIT_RATE ) + "</td><td>" + wdata.bitRate + "</td></tr>";
+ if ( toolTipContent & ACCESS_POINT )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( ACCESS_POINT ) + "</td><td>" + wdata.accessPoint + "</td></tr>";
+ if ( toolTipContent & LINK_QUALITY )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( LINK_QUALITY ) + "</td><td>" + wdata.linkQuality + "</td></tr>";
+ if ( toolTipContent & NICK_NAME )
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( NICK_NAME ) + "</td><td>" + wdata.nickName + "</td></tr>";
+ if ( toolTipContent & ENCRYPTION )
+ {
+ if ( wdata.encryption == true )
+ {
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( ENCRYPTION ) + "</td><td>" + i18n( "active" ) + "</td></tr>";
+ }
+ else
+ {
+ tipData += "<tr><td style='padding-right:1em'>" + mToolTips.value( ENCRYPTION ) + "</td><td>" + i18n( "off" ) + "</td></tr>";
+ }
+ }
+ }
+ tipData += "</table>";
+ 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 <KSystemTrayIcon>
+#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<quint32, QString> 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
Index: knemo.spec
===================================================================
RCS file: knemo.spec
diff -N knemo.spec
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ knemo.spec 17 Mar 2009 13:21:39 -0000 1.12
@@ -0,0 +1,125 @@
+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 $RPM_BUILD_ROOT
+
+make install DESTDIR=${RPM_BUILD_ROOT} -C %{_target_platform}
+
+desktop-file-install \
+ --dir $RPM_BUILD_ROOT%{_datadir}/applications/kde4 \
+ --remove-key=Path \
+ $RPM_BUILD_ROOT%{_datadir}/applications/kde4/%{name}.desktop
+
+%find_lang %{name}
+%find_lang kcm_%{name}
+cat kcm_%{name}.lang >> %{name}.lang
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%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 Alexey Kurov <nucleo at fedoraproject.org> - 0.5.1-4
+- Upstream update from git.mehercule.net
+
+* Thu Mar 5 2009 Alexey Kurov <nucleo at fedoraproject.org> - 0.5.1-1
+- Update to version 0.5.1
+
+* Wed Feb 25 2009 Alexey Kurov <nucleo at fedoraproject.org> - 0.5.0-3
+- Update to version 0.5.0 for KDE4
+
+* Tue Apr 17 2007 Francois Aucamp <faucamp at csir.co.za> - 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 <hugo at devin.com.br> 0.4.3-2
+- Rebuilt for FC6
+
+* Sun Aug 6 2006 Hugo Cisneiros <hugo at devin.com.br> 0.4.3-1
+- New upstream version
+
+* Mon Jun 26 2006 Hugo Cisneiros <hugo at devin.com.br> 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 <hugo at devin.com.br> 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 <hugo at devin.com.br> 0.4.1-1
+- Upstream update
+
+* Tue May 30 2006 Hugo Cisneiros <hugo at devin.com.br> 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 <hugo at devin.com.br> 0.4.0-3
+- Removed vendor option from desktop-file-install (no renaming)
+
+* Sat May 20 2006 Hugo Cisneiros <hugo at devin.com.br> 0.4.0-2
+- Installed .desktop files now use desktop-file-install
+
+* Sat May 20 2006 Hugo Cisneiros <hugo at devin.com.br> 0.4.0-1
+- Initial RPM release.
Index: sources
===================================================================
RCS file: sources
diff -N sources
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sources 17 Mar 2009 13:21:39 -0000 1.8
@@ -0,0 +1 @@
+5968cde508282ca5cee84dce64c928fa 12956-knemo-0.5.1.tar.gz
Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/knemo/F-9/.cvsignore,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- .cvsignore 17 Apr 2007 11:03:53 -0000 1.6
+++ .cvsignore 17 Mar 2009 13:21:39 -0000 1.7
@@ -1 +1 @@
-12956-knemo-0.4.7.tar.bz2
+12956-knemo-0.5.1.tar.gz
--- dead.package DELETED ---
- Previous message (by thread): rpms/knemo/devel import.log,1.1,1.2 knemo.spec,1.12,1.13
- Next message (by thread): rpms/php-ZendFramework/devel .cvsignore, 1.6, 1.7 php-ZendFramework.spec, 1.12, 1.13 sources, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list