~ubuntu-branches/ubuntu/natty/knemo/natty

« back to all changes in this revision

Viewing changes to src/knemod/knemodaemon.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-02-22 16:36:22 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20110222163622-d8i62gy1stn7tydv
Tags: 0.7.0-0ubuntu1
* New upstream release.
* Switch to source format 3.0 (quilt).
* Make knemo depend on libqt4-sql-sqlite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* This file is part of KNemo
2
2
   Copyright (C) 2004, 2006 Percy Leonhardt <percy@eris23.de>
3
 
   Copyright (C) 2009 John Stamp <jstamp@users.sourceforge.net>
 
3
   Copyright (C) 2009, 2010 John Stamp <jstamp@users.sourceforge.net>
4
4
 
5
5
   KNemo is free software; you can redistribute it and/or modify
6
6
   it under the terms of the GNU Library General Public License as
18
18
   Boston, MA 02110-1301, USA.
19
19
*/
20
20
 
 
21
#include <QSqlDatabase>
21
22
#include <QtDBus/QDBusConnection>
22
23
#include <QTimer>
23
24
 
24
25
#include <KAboutData>
25
26
#include <KConfigGroup>
26
27
#include <KLocale>
 
28
#include <KMessageBox>
27
29
#include <KStandardDirs>
28
30
 
29
31
#include "config-knemo.h"
41
43
KNemoDaemon::KNemoDaemon()
42
44
    : QObject(),
43
45
      mConfig( KGlobal::config() ),
44
 
      mHaveInterfaces( false ),
45
 
      mColorVLines( 0x04FB1D ),
46
 
      mColorHLines( 0x04FB1D ),
47
 
      mColorIncoming( 0x1889FF ),
48
 
      mColorOutgoing( 0xFF7F08 ),
49
 
      mColorBackground( 0x313031 )
 
46
      mHaveInterfaces( false )
50
47
{
51
48
    generalSettings = new GeneralSettings();
52
49
    backend = BackendFactory::backend();
99
96
        {
100
97
            Interface *interface = mInterfaceHash.take( key );
101
98
            delete interface;
102
 
            backend->remove( key );
 
99
            backend->removeIface( key );
103
100
 
104
101
            // If knemo is running while config removes an interface to monitor,
105
102
            // it will keep the interface and plotter groups. Delete them here.
113
110
 
114
111
    if ( !mHaveInterfaces )
115
112
    {
116
 
        QString ifaceName = backend->getDefaultRouteIface( AF_INET );
 
113
        QString ifaceName = backend->defaultRouteIface( AF_INET );
117
114
        if ( ifaceName.isEmpty() )
118
 
            ifaceName = backend->getDefaultRouteIface( AF_INET6 );
 
115
            ifaceName = backend->defaultRouteIface( AF_INET6 );
119
116
        if ( !ifaceName.isEmpty() )
120
117
        {
121
118
            interfaceList << ifaceName;
129
126
    {
130
127
        if ( !mInterfaceHash.contains( key ) )
131
128
        {
132
 
            const BackendData * data = backend->add( key );
 
129
            const BackendData * data = backend->addIface( key );
133
130
            Interface *iface = new Interface( key, data );
134
131
            mInterfaceHash.insert( key, iface );
135
132
            newIfaces << key;
151
148
            connect( backend, SIGNAL( updateComplete() ), iface, SLOT( processUpdate() ) );
152
149
        }
153
150
    }
 
151
 
 
152
    bool statsActivated = false;
 
153
    foreach ( Interface *iface, mInterfaceHash )
 
154
    {
 
155
        if ( iface->settings().activateStatistics )
 
156
            statsActivated = true;
 
157
    }
 
158
    if ( statsActivated )
 
159
    {
 
160
        QStringList drivers = QSqlDatabase::drivers();
 
161
        if ( !drivers.contains( "QSQLITE" ) )
 
162
        {
 
163
            KMessageBox::sorry( 0, i18n( "The Qt4 SQLite database plugin is not available.\n"
 
164
                                         "Please install it to store traffic statistics." ) );
 
165
        }
 
166
    }
 
167
 
154
168
    mPollTimer->start( generalSettings->pollInterval * 1000 );
155
169
}
156
170
 
184
198
                      ki18n( description ),
185
199
                      KAboutData::License_GPL_V2,
186
200
                      KLocalizedString(),
187
 
                      ki18n( "Copyright (C) 2004, 2005, 2006 Percy Leonhardt\nCopyright (C) 2009 John Stamp\n\nSignal plotter taken from KSysGuard\nCopyright (C) 2006 - 2009 John Tapsell" ),
 
201
                      ki18n( "Copyright (C) 2004, 2005, 2006 Percy Leonhardt\nCopyright (C) 2009, 2010 John Stamp\n\nSignal plotter taken from KSysGuard\nCopyright (C) 2006 - 2009 John Tapsell" ),
188
202
                      "http://extragear.kde.org/apps/knemo/",
189
203
                      "jstamp@users.sourceforge.net");
190
204