3
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
*
|
|
5 |
* This program is free software: you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU Lesser General Public License as published by
|
|
7 |
* the Free Software Foundation, version 2.1 of the License.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU Lesser General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU Lesser General Public License
|
|
15 |
* along with this program. If not,
|
|
16 |
* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
|
|
17 |
*
|
|
18 |
* Description:
|
|
19 |
* This file defines the NetworkDelegate, NetworkImpl and DefaultNetworkImpl classes.
|
|
20 |
*/
|
|
21 |
#ifndef NETWORKDELEGATE_H
|
|
22 |
#define NETWORKDELEGATE_H
|
|
23 |
|
|
24 |
#include <QObject>
|
|
25 |
#include <QString>
|
|
26 |
|
|
27 |
#if !defined(QT_MOBILITY_SYSINFO) && defined(QT_MOBILITY_BEARER_MANAGEMENT)
|
|
28 |
#include "WebNetworkConnectionManagerSingleton.h"
|
|
29 |
#endif
|
|
30 |
|
|
31 |
#ifdef QT_MOBILITY_SYSINFO
|
|
32 |
#define NETWORKIMPL SystemNetworkImpl
|
|
33 |
#else
|
|
34 |
#define NETWORKIMPL DefaultNetworkImpl
|
|
35 |
#endif // QT_MOBILITY_SYSINFO
|
|
36 |
|
|
37 |
namespace GVA {
|
|
38 |
|
|
39 |
/*!
|
|
40 |
Class to provide device information. It uses QtMobility to provide
|
|
41 |
information about battery level, network signal strength, and network name.
|
|
42 |
*/
|
|
43 |
class NetworkImpl : public QObject
|
|
44 |
{
|
|
45 |
Q_OBJECT
|
|
46 |
public:
|
|
47 |
NetworkImpl() {};
|
|
48 |
virtual ~NetworkImpl() {};
|
|
49 |
|
|
50 |
virtual QString getNetworkName() const = 0;
|
|
51 |
virtual int getNetworkSignalStrength() const = 0;
|
|
52 |
|
|
53 |
signals:
|
|
54 |
// Sent when the network name changes.
|
|
55 |
void networkNameChanged(const QString&);
|
|
56 |
// Sent when the network signal strength changes.
|
|
57 |
void networkSignalStrengthChanged(int);
|
|
58 |
};
|
|
59 |
|
|
60 |
class DefaultNetworkImpl : public NetworkImpl
|
|
61 |
{
|
|
62 |
Q_OBJECT
|
|
63 |
public:
|
|
64 |
DefaultNetworkImpl()
|
|
65 |
{
|
|
66 |
#if !defined(QT_MOBILITY_SYSINFO) && defined(QT_MOBILITY_BEARER_MANAGEMENT)
|
|
67 |
// Get the singleton instance of WebNetworkConnectionManager
|
|
68 |
WRT::WebNetworkConnectionManagerSingleton::Instance().updateConfigurations();
|
|
69 |
#endif
|
|
70 |
};
|
|
71 |
~DefaultNetworkImpl() {};
|
|
72 |
|
|
73 |
virtual QString getNetworkName() const { return ""; };
|
|
74 |
virtual int getNetworkSignalStrength() const { return 100; };
|
|
75 |
};
|
|
76 |
|
|
77 |
/*!
|
|
78 |
Class to provide device information. It uses QtMobility to provide
|
|
79 |
information about battery level, network signal strength, and network name.
|
|
80 |
*/
|
|
81 |
class NetworkDelegate : public QObject
|
|
82 |
{
|
|
83 |
Q_OBJECT
|
|
84 |
public:
|
|
85 |
NetworkDelegate(NetworkImpl *networkImpl);
|
|
86 |
~NetworkDelegate();
|
|
87 |
|
|
88 |
// properties accessible to javascript snippets
|
|
89 |
Q_PROPERTY(int networkSignalStrength READ getNetworkSignalStrength)
|
|
90 |
Q_PROPERTY(QString networkName READ getNetworkName)
|
|
91 |
|
|
92 |
QString getNetworkName() const;
|
|
93 |
int getNetworkSignalStrength() const;
|
|
94 |
|
|
95 |
signals:
|
|
96 |
// Sent when the network name changes.
|
|
97 |
void networkNameChanged(const QString&);
|
|
98 |
// Sent when the network signal strength changes.
|
|
99 |
void networkSignalStrengthChanged(int);
|
|
100 |
|
|
101 |
private:
|
|
102 |
NetworkImpl *m_networkImpl;
|
|
103 |
};
|
|
104 |
|
|
105 |
} // GVA
|
|
106 |
|
|
107 |
#endif // NETWORKDELEGATE_H
|