~ubuntu-branches/ubuntu/precise/knemo/precise

« back to all changes in this revision

Viewing changes to src/knemod/knemodaemon.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-06-15 18:58:30 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20100615185830-2zeqn9vpn3jjx6gd
Tags: 0.6.3-1
* New upstream release 
  - Fixes (LP: #559683, LP: #248294)
  - save changes to traffic threshold setting
  - add option to report traffic rate in bit/s
  - update the signal plotter from KDE SC 4.4 branch; a few minor plotter
    config options were dropped as a result
  - on startup sync recent traffic statistics with vnstat if it's available;
    this should help KNemo account for traffic between sessions
  - fix possible hang when text icon theme uses fixed fonts

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <KStandardDirs>
28
28
 
29
29
#include "config-knemo.h"
 
30
#include "global.h"
30
31
#include "knemodaemon.h"
31
32
#include "interface.h"
32
33
#include "backends/backendfactory.h"
35
36
QString KNemoDaemon::sSelectedInterface = QString::null;
36
37
 
37
38
BackendBase *backend = NULL;
 
39
GeneralSettings *generalSettings = NULL;
38
40
 
39
41
KNemoDaemon::KNemoDaemon()
40
42
    : QObject(),
46
48
      mColorOutgoing( 0xFF7F08 ),
47
49
      mColorBackground( 0x313031 )
48
50
{
 
51
    generalSettings = new GeneralSettings();
49
52
    backend = BackendFactory::backend();
50
53
    QDBusConnection::sessionBus().registerObject("/knemo", this, QDBusConnection::ExportScriptableSlots);
51
54
    mPollTimer = new QTimer();
63
66
        Interface *interface = mInterfaceHash.take( key );
64
67
        delete interface;
65
68
    }
 
69
    delete generalSettings;
66
70
}
67
71
 
68
72
void KNemoDaemon::readConfig()
74
78
    config->reparseConfiguration();
75
79
 
76
80
    // General
 
81
    GeneralSettings g;
77
82
    KConfigGroup generalGroup( config, confg_general );
78
 
    mGeneralData.pollInterval = clamp<double>(generalGroup.readEntry( conf_pollInterval, 1.0 ), 0.1, 2.0 );
79
 
    mGeneralData.pollInterval = validatePoll( mGeneralData.pollInterval );
80
 
    mGeneralData.saveInterval = clamp<int>(generalGroup.readEntry( conf_saveInterval, 60 ), 0, 300 );
81
 
    mGeneralData.statisticsDir = generalGroup.readEntry( conf_statisticsDir, KGlobal::dirs()->saveLocation( "data", "knemo/" ) );
82
 
    mGeneralData.toolTipContent = generalGroup.readEntry( conf_toolTipContent, defaultTip );
 
83
    generalSettings->pollInterval = clamp<double>(generalGroup.readEntry( conf_pollInterval, g.pollInterval ), 0.1, 2.0 );
 
84
    generalSettings->pollInterval = validatePoll( generalSettings->pollInterval );
 
85
    generalSettings->useBitrate = generalGroup.readEntry( conf_useBitrate, g.useBitrate );
 
86
    generalSettings->saveInterval = clamp<int>(generalGroup.readEntry( conf_saveInterval, g.saveInterval ), 0, 300 );
 
87
    generalSettings->statisticsDir = generalGroup.readEntry( conf_statisticsDir, g.statisticsDir );
 
88
    generalSettings->toolTipContent = generalGroup.readEntry( conf_toolTipContent, g.toolTipContent );
83
89
    // If we already have an Interfaces key--even if its empty--then we
84
90
    // shouldn't try to set up a default interface
85
91
    if ( generalGroup.hasKey( conf_interfaces ) )
124
130
        if ( !mInterfaceHash.contains( key ) )
125
131
        {
126
132
            const BackendData * data = backend->add( key );
127
 
            Interface *iface = new Interface( key, data, mGeneralData );
 
133
            Interface *iface = new Interface( key, data );
128
134
            mInterfaceHash.insert( key, iface );
129
135
            newIfaces << key;
130
136
        }
145
151
            connect( backend, SIGNAL( updateComplete() ), iface, SLOT( processUpdate() ) );
146
152
        }
147
153
    }
148
 
    mPollTimer->start( mGeneralData.pollInterval * 1000 );
 
154
    mPollTimer->start( generalSettings->pollInterval * 1000 );
149
155
}
150
156
 
151
157
void KNemoDaemon::reparseConfiguration()
178
184
                      ki18n( description ),
179
185
                      KAboutData::License_GPL_V2,
180
186
                      KLocalizedString(),
181
 
                      ki18n( "Copyright (C) 2004, 2005, 2006 Percy Leonhardt\nCopyright (C) 2009 John Stamp\n\nSignal plotter taken from KSysGuard\nCopyright (C) 1999 - 2002, Chris Schlaeger\nCopyright (C) 2006 John Tapsell" ),
 
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" ),
182
188
                      "http://extragear.kde.org/apps/knemo/",
183
189
                      "jstamp@users.sourceforge.net");
184
190