~ken-vandine/libqofono/0.90-suggests

« back to all changes in this revision

Viewing changes to src/qofonomanager.cpp

  • Committer: Slava Monich
  • Date: 2016-03-21 21:47:13 UTC
  • mto: (207.2.15)
  • mto: This revision was merged to the branch mainline in revision 215.
  • Revision ID: git-v1:33e5b62d2fd0af5ab726a3ddf02962a5d0a36677
[libqofono] Retry GetModems on timeout. Contributes to JB#33995

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
2
**
3
 
** Copyright (C) 2013-2015 Jolla Ltd.
 
3
** Copyright (C) 2013-2016 Jolla Ltd.
4
4
** Contact: lorn.potter@jollamobile.com
5
5
**
6
6
** GNU Lesser General Public License Usage
14
14
****************************************************************************/
15
15
 
16
16
#include "qofonomanager.h"
 
17
#include "qofonoutils_p.h"
17
18
#include "ofono_manager_interface.h"
18
19
 
19
20
class QOfonoManager::Private
24
25
    bool available;
25
26
 
26
27
    Private() : ofonoManager(NULL), available(false) {}
 
28
 
 
29
    void getModems(QOfonoManager *manager);
27
30
};
28
31
 
 
32
void QOfonoManager::Private::getModems(QOfonoManager *manager)
 
33
{
 
34
    if (ofonoManager) {
 
35
        connect(new QDBusPendingCallWatcher(
 
36
            ofonoManager->GetModems(), ofonoManager),
 
37
            SIGNAL(finished(QDBusPendingCallWatcher*)), manager,
 
38
            SLOT(onGetModemsFinished(QDBusPendingCallWatcher*)));
 
39
    }
 
40
}
 
41
 
29
42
QOfonoManager::QOfonoManager(QObject *parent) :
30
43
    QObject(parent),
31
44
    d_ptr(new Private)
107
120
{
108
121
    QDBusPendingReply<ObjectPathPropertiesList> reply(*watcher);
109
122
    watcher->deleteLater();
110
 
    if (reply.isValid() && !reply.isError()) {
 
123
    if (reply.isError()) {
 
124
        if (qofono::isTimeout(reply.error())) {
 
125
            qDebug() << "Retrying GetModems...";
 
126
            d_ptr->getModems(this);
 
127
        } else {
 
128
            qWarning() << reply.error();
 
129
        }
 
130
    } else {
111
131
        QString prevDefault = defaultModem();
112
132
        QStringList newModems;
113
133
        Q_FOREACH(ObjectPathProperties modem, reply.value()) {
133
153
        OfonoManager* mgr = new OfonoManager("org.ofono", "/", QDBusConnection::systemBus(), this);
134
154
        if (mgr->isValid()) {
135
155
            d_ptr->ofonoManager = mgr;
136
 
            connect(new QDBusPendingCallWatcher(mgr->GetModems(), mgr),
137
 
                SIGNAL(finished(QDBusPendingCallWatcher*)),
138
 
                SLOT(onGetModemsFinished(QDBusPendingCallWatcher*)));
139
156
            connect(mgr,
140
157
                SIGNAL(ModemAdded(QDBusObjectPath,QVariantMap)),
141
158
                SLOT(onModemAdded(QDBusObjectPath,QVariantMap)));
142
159
            connect(mgr,
143
160
                SIGNAL(ModemRemoved(QDBusObjectPath)),
144
161
                SLOT(onModemRemoved(QDBusObjectPath)));
 
162
            d_ptr->getModems(this);
145
163
        } else {
146
164
            delete mgr;
147
165
        }