Initial commit
[profile/ivi/ofono-qt.git] / lib / ofonointerface.h
1 /**
2  * This file is part of CellularQt
3  *
4  * Copyright (C) 2010 Nokia Corporation. All rights reserved.
5  */
6
7 #ifndef OFONOINTERFACE_H
8 #define OFONOINTERFACE_H
9
10 /*
11  * This file is part of ofono-qt
12  *
13  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
14  *
15  * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
16  *
17  * This library is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU Lesser General Public License
19  * version 2.1 as published by the Free Software Foundation.
20  *
21  * This library is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  * Lesser General Public License for more details.
25  *
26  * You should have received a copy of the GNU Lesser General Public
27  * License along with this library; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29  * 02110-1301 USA
30  *
31  */
32
33 #include <QtCore/QObject>
34 #include <QVariant>
35 #include <QDBusVariant>
36 #include <QDBusError>
37 #include "libofono-qt_global.h"
38
39 class OFONO_QT_EXPORT OfonoInterface : public QObject
40 {
41     Q_OBJECT
42 public:
43     enum GetPropertySetting {
44         GetAllOnStartup,
45         GetAllOnFirstRequest
46     };
47
48     OfonoInterface(const QString& path, const QString& ifname, GetPropertySetting setting, QObject *parent=0);
49     ~OfonoInterface();
50
51     QVariantMap properties() const;
52     void requestProperty(const QString& name);
53     void setProperty(const QString& name, const QVariant& property);
54     void resetProperties();
55     
56     QString path() const {return m_path;}
57     
58     QString ifname() const {return m_ifname;}
59     QString errorName() const {return m_errorName;}
60     QString errorMessage() const {return m_errorMessage;}
61
62 signals:
63     void propertyChanged(const QString& name, const QVariant& property);
64     void requestPropertyComplete(bool success, const QString& name, const QVariant& property);
65     void setPropertyFailed(const QString& name);
66
67 private slots:
68     void onPropertyChanged(QString property, QDBusVariant value);
69     void getPropertiesAsyncResp(QVariantMap properties);
70     void getPropertiesAsyncErr(const QDBusError&);
71     void setPropertyResp();
72     void setPropertyErr(const QDBusError& error);
73 protected slots:
74     void setPath(const QString& path);
75 private:
76     QVariantMap getAllPropertiesSync();
77     
78 protected:
79    QString m_errorName;
80    QString m_errorMessage;
81     
82 private:
83    QString m_path;
84    QString m_ifname;
85    QVariantMap m_properties;
86    QString m_pendingProperty;
87    GetPropertySetting m_getpropsetting;
88 };
89
90 #endif