Qt 4.8
iapmonitor.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 #include <QStringList>
44 
45 #include <conn_settings.h>
46 #include "iapmonitor.h"
47 
48 namespace Maemo {
49 
50 
51 void conn_settings_notify_func (ConnSettingsType type,
52  const char *id,
53  const char *key,
54  ConnSettingsValue *value,
55  void *user_data);
56 
58 private:
60  ConnSettings *settings;
61 
62 public:
63 
65  : monitor(monitor)
66  {
67  settings = conn_settings_open(CONN_SETTINGS_CONNECTION, NULL);
68  conn_settings_add_notify(
69  settings,
70  (ConnSettingsNotifyFunc *)conn_settings_notify_func,
71  this);
72  }
73 
75  {
76  conn_settings_del_notify(settings);
77  conn_settings_close(settings);
78  }
79 
80  void iapAdded(const QString &iap)
81  {
82  monitor->iapAdded(iap);
83  }
84 
85  void iapRemoved(const QString &iap)
86  {
87  monitor->iapRemoved(iap);
88  }
89 };
90 
91 void conn_settings_notify_func (ConnSettingsType type,
92  const char *id,
93  const char *key,
94  ConnSettingsValue *value,
95  void *user_data)
96 {
97  Q_UNUSED(id);
98 
99  if (type != CONN_SETTINGS_CONNECTION) return;
100  IAPMonitorPrivate *priv = (IAPMonitorPrivate *)user_data;
101 
102  QString iapId(key);
103  iapId = iapId.split("/")[0];
104  if (value != 0) {
105  priv->iapAdded(iapId);
106  } else if (iapId == QString(key)) {
107  // IAP is removed only when the directory gets removed
108  priv->iapRemoved(iapId);
109  }
110 }
111 
113  : d_ptr(new IAPMonitorPrivate(this))
114 {
115 }
116 
118 {
119  delete d_ptr;
120 }
121 
123 {
124  Q_UNUSED(id);
125  // By default do nothing
126 }
127 
129 {
130  Q_UNUSED(id);
131  // By default do nothing
132 }
133 
134 } // namespace Maemo
int type
Definition: qmetatype.cpp:239
virtual void iapRemoved(const QString &id)
Definition: iapmonitor.cpp:128
void iapAdded(const QString &iap)
Definition: iapmonitor.cpp:80
void iapRemoved(const QString &iap)
Definition: iapmonitor.cpp:85
The QString class provides a Unicode character string.
Definition: qstring.h:83
ConnSettings * settings
Definition: iapmonitor.cpp:60
virtual void iapAdded(const QString &id)
Definition: iapmonitor.cpp:122
IAPMonitorPrivate * d_ptr
Definition: iapmonitor.h:61
void conn_settings_notify_func(ConnSettingsType type, const char *id, const char *key, ConnSettingsValue *value, void *user_data)
Definition: iapmonitor.cpp:91
IAPMonitorPrivate(IAPMonitor *monitor)
Definition: iapmonitor.cpp:64
int key
static const QMetaObjectPrivate * priv(const uint *data)
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729