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

« back to all changes in this revision

Viewing changes to src/common/data.h

  • 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 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
32
32
#include <KStandardDirs>
33
33
#include <KUrl>
34
34
 
 
35
class KCalendarSystem;
 
36
 
35
37
/**
36
38
 * This file contains data structures used to store information about
37
39
 * an interface. It is shared between the daemon and the control center
49
51
        Ethernet,
50
52
        PPP
51
53
    };
52
 
    
53
 
    enum InterfaceState
 
54
 
 
55
    enum IfaceState
54
56
    {
55
57
        UnknownState =  0,
56
58
        Unavailable  =  1,
62
64
    };
63
65
}
64
66
 
 
67
namespace KNemoStats
 
68
{
 
69
    enum TrafficUnits
 
70
    {
 
71
        UnitB = 0,
 
72
        UnitK,
 
73
        UnitM,
 
74
        UnitG
 
75
    };
 
76
 
 
77
    enum TrafficDirection
 
78
    {
 
79
        TrafficIn = 0,
 
80
        TrafficOut,
 
81
        TrafficTotal
 
82
    };
 
83
 
 
84
    enum WarnType
 
85
    {
 
86
        Peak = 0,
 
87
        Offpeak,
 
88
        PeakOffpeak
 
89
    };
 
90
 
 
91
    enum PeriodUnits
 
92
    {
 
93
        Hour = 0,
 
94
        Day,
 
95
        Week,
 
96
        Month,
 
97
        BillPeriod,
 
98
        Year,
 
99
        HourArchive
 
100
    };
 
101
 
 
102
    // Powers of 2
 
103
    enum TrafficType
 
104
    {
 
105
        AllTraffic = 0,
 
106
        OffpeakTraffic = 1
 
107
    };
 
108
 
 
109
};
 
110
 
65
111
static const char NETLOAD_THEME[] = "netloadtheme";
66
112
static const char TEXT_THEME[] = "texttheme";
67
113
static const char SYSTEM_THEME[] = "systemtheme";
77
123
static const char confg_general[] = "General";
78
124
static const char confg_interface[] = "Interface_";
79
125
static const char confg_plotter[] = "Plotter_";
 
126
static const char confg_statsRule[] = "StatsRule_";
 
127
static const char confg_warnRule[] = "WarnRule_";
80
128
 
81
129
static const char conf_firstStart[] = "FirstStart";
82
130
static const char conf_autoStart[] = "AutoStart";
104
152
 
105
153
// interface statistics
106
154
static const char conf_activateStatistics[] = "ActivateStatistics";
107
 
static const char conf_customBilling[] = "CustomBilling";
108
155
static const char conf_calendar[] = "Calendar";
109
 
static const char conf_billingStart[] = "BillingStart";
110
 
static const char conf_billingMonths[] = "BillingMonths";
111
 
static const char conf_billingWarnThresh[] = "BillingWarnThreshold";
112
 
static const char conf_billingWarnUnits[] = "BillingWarnUnits";
113
 
static const char conf_billingWarnType[] = "BillingWarnType";
114
 
static const char conf_billingWarnRxTx[] = "BillingWarnRxTx";
 
156
static const char conf_statsRules[] = "StatsRules";
 
157
static const char conf_warnRules[] = "WarnRules";
 
158
 
 
159
// interface billing
 
160
static const char conf_statsStartDate[] = "StartDate";
 
161
static const char conf_statsPeriodUnits[] = "PeriodUnits";
 
162
static const char conf_statsPeriodCount[] = "PeriodCount";
 
163
static const char conf_logOffpeak[] = "LogOffpeak";
 
164
static const char conf_offpeakStartTime[] = "OffpeakStartTime";
 
165
static const char conf_offpeakEndTime[] = "OffpeakEndTime";
 
166
static const char conf_weekendIsOffpeak[] = "WeekendIsOffpeak";
 
167
static const char conf_weekendDayStart[] = "WeekendDayStart";
 
168
static const char conf_weekendDayEnd[] = "WeekendDayEnd";
 
169
static const char conf_weekendTimeStart[] = "WeekendTimeStart";
 
170
static const char conf_weekendTimeEnd[] = "WeekendTimeEnd";
 
171
 
 
172
// warning
 
173
static const char conf_warnPeriodUnits[] = "PeriodUnits";
 
174
static const char conf_warnPeriodCount[] = "PeriodCount";
 
175
static const char conf_warnTrafficType[] = "TrafficType";
 
176
static const char conf_warnTrafficDirection[] = "TrafficDirection";
 
177
static const char conf_warnTrafficUnits[] = "TrafficUnits";
 
178
static const char conf_warnThreshold[] = "Threshold";
 
179
static const char conf_warnCustomText[] = "CustomText";
115
180
 
116
181
// interface context menu
117
182
static const char conf_numCommands[] = "NumCommands";
137
202
static const char conf_dayState[] = "DayState";
138
203
static const char conf_weekState[] = "WeekState";
139
204
static const char conf_monthState[] = "MonthState";
 
205
static const char conf_billingState[] = "BillingState";
140
206
static const char conf_yearState[] = "YearState";
141
207
 
142
208
enum ToolTipEnums
266
332
    KUrl statisticsDir;
267
333
};
268
334
 
 
335
class StatsRule
 
336
{
 
337
public:
 
338
    StatsRule()
 
339
        :
 
340
        periodCount( 1 ),
 
341
        periodUnits( KNemoStats::Month ),
 
342
        logOffpeak( false ),
 
343
        offpeakStartTime( QTime( 23, 0) ),
 
344
        offpeakEndTime( QTime( 7, 0) ),
 
345
        weekendIsOffpeak( false ),
 
346
        weekendDayStart( 5 ),
 
347
        weekendDayEnd( 1 ),
 
348
        weekendTimeStart( QTime( 23, 0) ),
 
349
        weekendTimeEnd( QTime( 7, 0) )
 
350
    {
 
351
    }
 
352
    bool operator==( StatsRule &r );
 
353
    bool isValid( KCalendarSystem *cal );
 
354
    QDate startDate;
 
355
    int periodCount;
 
356
    int periodUnits;
 
357
    bool logOffpeak;
 
358
    QTime offpeakStartTime;
 
359
    QTime offpeakEndTime;
 
360
    bool weekendIsOffpeak;
 
361
    int weekendDayStart;
 
362
    int weekendDayEnd;
 
363
    QTime weekendTimeStart;
 
364
    QTime weekendTimeEnd;
 
365
};
 
366
 
 
367
struct WarnRule
 
368
{
 
369
    WarnRule()
 
370
        : periodUnits( KNemoStats::Month ),
 
371
        periodCount( 1 ),
 
372
        trafficType( KNemoStats::PeakOffpeak ),
 
373
        trafficDirection( KNemoStats::TrafficIn ),
 
374
        trafficUnits( KNemoStats::UnitG ),
 
375
        threshold( 5.0 ),
 
376
        warnDone( false )
 
377
    {
 
378
    }
 
379
    bool operator==( WarnRule &r )
 
380
    {
 
381
        if ( periodUnits == r.periodUnits &&
 
382
             periodCount == r.periodCount &&
 
383
             trafficType == r.trafficType &&
 
384
             trafficDirection == r.trafficDirection &&
 
385
             trafficUnits == r.trafficUnits &&
 
386
             threshold == r.threshold )
 
387
            return true;
 
388
        else
 
389
            return false;
 
390
    }
 
391
    int periodUnits;
 
392
    uint periodCount;
 
393
    int trafficType;
 
394
    int trafficDirection;
 
395
    int trafficUnits;
 
396
    double threshold;
 
397
    QString customText;
 
398
    bool warnDone;
 
399
};
 
400
 
269
401
struct InterfaceSettings
270
402
{
271
403
    InterfaceSettings()
274
406
        colorOutgoing( 0xFF7F08 ),
275
407
        colorDisabled( 0x888786 ),
276
408
        colorUnavailable( 0x888786 ),
 
409
        colorBackground( 0x888786 ),
277
410
        dynamicColor( false ),
278
411
        colorIncomingMax( 0x96FFFF ),
279
412
        colorOutgoingMax( 0xFFC868 ),
283
416
        iconFont( KGlobalSettings::generalFont() ),
284
417
        numCommands( 0 ),
285
418
        trafficThreshold( 0 ),
286
 
        warnThreshold( 0.0 ),
287
 
        warnUnits( 3 ),
288
 
        warnType( 2 ),
289
 
        warnTotalTraffic( false ),
290
419
        hideWhenUnavailable( false ),
291
420
        hideWhenDisconnected( false ),
292
 
        activateStatistics( false ),
293
 
        customBilling( false ),
294
 
        billingMonths( 1 )
 
421
        activateStatistics( false )
295
422
    {}
296
423
 
297
424
    QString iconTheme;
299
426
    QColor colorOutgoing;
300
427
    QColor colorDisabled;
301
428
    QColor colorUnavailable;
 
429
    QColor colorBackground;
302
430
    bool dynamicColor;
303
431
    QColor colorIncomingMax;
304
432
    QColor colorOutgoingMax;
308
436
    QFont iconFont;
309
437
    int numCommands;
310
438
    unsigned int trafficThreshold;
311
 
    double warnThreshold;
312
 
    int warnUnits;
313
 
    int warnType;
314
 
    bool warnTotalTraffic;
315
439
    bool hideWhenUnavailable;
316
440
    bool hideWhenDisconnected;
317
441
    bool activateStatistics;
318
 
    bool customBilling;
319
 
    QDate billingStart;
320
 
    int billingMonths;
 
442
    QList<StatsRule> statsRules;
 
443
    QList<WarnRule> warnRules;
321
444
    QString calendar;
322
445
    QString alias;
323
446
    QList<InterfaceCommand> commands;
334
457
};
335
458
#endif
336
459
 
337
 
enum NotificationType
338
 
{
339
 
    NotifyHour,
340
 
    NotifyDay,
341
 
    NotifyMonth,
342
 
    NotifyRoll24Hour,
343
 
    NotifyRoll7Day,
344
 
    NotifyRoll30Day
345
 
};
346
 
 
347
460
static const double pollIntervals[] = { 0.1, 0.2, 0.25, 0.5, 1.0, 2.0 };
348
461
 
349
462
#endif // DATA_H