43 |
43 |
44 #include "qnetworkconfigmanager_p.h" |
44 #include "qnetworkconfigmanager_p.h" |
45 #include "qbearerengine_p.h" |
45 #include "qbearerengine_p.h" |
46 |
46 |
47 #include <QtCore/qstringlist.h> |
47 #include <QtCore/qstringlist.h> |
|
48 #include <QtCore/qcoreapplication.h> |
48 |
49 |
49 #ifndef QT_NO_BEARERMANAGEMENT |
50 #ifndef QT_NO_BEARERMANAGEMENT |
50 |
51 |
51 QT_BEGIN_NAMESPACE |
52 QT_BEGIN_NAMESPACE |
52 |
53 |
53 Q_GLOBAL_STATIC(QNetworkConfigurationManagerPrivate, connManager); |
54 #define Q_GLOBAL_STATIC_QAPP_DESTRUCTION(TYPE, NAME) \ |
|
55 Q_GLOBAL_STATIC_INIT(TYPE, NAME); \ |
|
56 static void NAME##_cleanup() \ |
|
57 { \ |
|
58 delete this_##NAME.pointer; \ |
|
59 this_##NAME.pointer = 0; \ |
|
60 this_##NAME.destroyed = true; \ |
|
61 } \ |
|
62 static TYPE *NAME() \ |
|
63 { \ |
|
64 if (!this_##NAME.pointer && !this_##NAME.destroyed) { \ |
|
65 TYPE *x = new TYPE; \ |
|
66 if (!this_##NAME.pointer.testAndSetOrdered(0, x)) \ |
|
67 delete x; \ |
|
68 else \ |
|
69 qAddPostRoutine(NAME##_cleanup); \ |
|
70 } \ |
|
71 return this_##NAME.pointer; \ |
|
72 } |
|
73 |
|
74 Q_GLOBAL_STATIC_QAPP_DESTRUCTION(QNetworkConfigurationManagerPrivate, connManager); |
54 |
75 |
55 QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() |
76 QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() |
56 { |
77 { |
57 return connManager(); |
78 static bool initialized = false; |
|
79 |
|
80 QNetworkConfigurationManagerPrivate *m = connManager(); |
|
81 if (!initialized) { |
|
82 initialized = true; |
|
83 m->updateConfigurations(); |
|
84 } |
|
85 |
|
86 return m; |
58 } |
87 } |
59 |
88 |
60 /*! |
89 /*! |
61 \class QNetworkConfigurationManager |
90 \class QNetworkConfigurationManager |
62 |
91 |
176 Constructs a QNetworkConfigurationManager with the given \a parent. |
205 Constructs a QNetworkConfigurationManager with the given \a parent. |
177 */ |
206 */ |
178 QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) |
207 QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) |
179 : QObject(parent) |
208 : QObject(parent) |
180 { |
209 { |
181 QNetworkConfigurationManagerPrivate *priv = connManager(); |
210 QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate(); |
182 |
211 |
183 connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)), |
212 connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)), |
184 this, SIGNAL(configurationAdded(QNetworkConfiguration))); |
213 this, SIGNAL(configurationAdded(QNetworkConfiguration))); |
185 connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)), |
214 connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)), |
186 this, SIGNAL(configurationRemoved(QNetworkConfiguration))); |
215 this, SIGNAL(configurationRemoved(QNetworkConfiguration))); |