Merge commit 'refs/merge-requests/1' of gitorious.org:meego-cellular/ofono-qt into...
[profile/ivi/ofono-qt.git] / lib / ofonomodem.h
1 /*
2  * This file is part of ofono-qt
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23  
24
25 #ifndef OFONOMODEM_H
26 #define OFONOMODEM_H
27
28 #include <QtCore/QObject>
29 #include <QtCore/QStringList>
30 #include "libofono-qt_global.h"
31
32 class OfonoModemManager;
33 class OfonoInterface;
34
35 //! This class is used to access an oFono modem object and its properties
36 /*!
37  * oFono modem properties are documented in
38  * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/modem-api.txt
39  */
40 class OFONO_QT_EXPORT OfonoModem : public QObject 
41 {
42
43 Q_OBJECT
44
45 Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged)
46 Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged)
47 Q_PROPERTY(bool emergency READ emergency NOTIFY emergencyChanged)
48
49 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
50 Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged)
51 Q_PROPERTY(QString model READ model NOTIFY modelChanged)
52 Q_PROPERTY(QString revision READ revision NOTIFY revisionChanged)
53 Q_PROPERTY(QString serial READ serial NOTIFY serialChanged)
54
55 Q_PROPERTY(QStringList features READ features NOTIFY featuresChanged)
56 Q_PROPERTY(QStringList interfaces READ interfaces NOTIFY interfacesChanged)
57
58 public:
59
60     //! How the modem object should select a modem
61     enum SelectionSetting {
62         AutomaticSelect,        /*!< Select the first available modem automatically;
63                                  * if that modem becomes unavailable, select the first available
64                                  * modem again. */
65         ManualSelect    /*!< Do not select a modem automatically,
66                          * use the modem path provided in the constructor, and do not
67                          * attempt to select another modem if the first one becomes 
68                          * unavailable. */
69     };
70
71     /*!
72      * \param setting sets the modem selection policy for the object
73      * \param modemPath if modem selection policy is ManualSelect, then this contains
74      * the D-Bus path to the modem object. Otherwise, it is ignored.
75      */
76     OfonoModem(SelectionSetting setting, const QString& modemPath, QObject *parent=0);
77
78     ~OfonoModem();
79
80     //! Returns true if D-Bus modem object exists.
81     bool isValid() const;
82     
83     //! Returns the D-Bus object path of the modem
84     QString path() const;
85     
86     //! Get the D-Bus error name of the last operation.
87     /*!
88      * Returns the D-Bus error name of the last operation (setting a property
89      * or calling a method) if it has failed
90      */
91     QString errorName() const;
92
93     //! Get the D-Bus error message of the last operation.
94     /*!
95      * Returns the D-Bus error message of the last operation (setting a property
96      * or calling a method) if it has failed
97      */
98     QString errorMessage() const;
99
100     bool powered() const;
101     void setPowered(bool powered);
102     bool online() const;
103     void setOnline(bool online);
104     bool emergency() const;
105     
106     QString name() const;
107     QString manufacturer() const;
108     QString model() const;
109     QString revision() const;
110     QString serial() const;
111     
112     QStringList features() const;
113     QStringList interfaces() const;
114
115 signals:
116     //! Issued when a modem becomes unavailable or available again
117     void validityChanged(bool validity);
118     //! Issued when the object has switched to another modem
119     void pathChanged(QString modemPath);
120     
121     void poweredChanged(bool powered);
122     void setPoweredFailed();
123     void onlineChanged(bool online);
124     void setOnlineFailed();
125     void emergencyChanged(bool emergency);
126
127     void nameChanged(const QString &name);
128     void manufacturerChanged(const QString &manufacturer);
129     void modelChanged(const QString &model);
130     void revisionChanged(const QString &revision);
131     void serialChanged(const QString &serial);
132
133     void featuresChanged(const QStringList &features);
134     void interfacesChanged(const QStringList &interfaces);
135
136
137 private slots:
138     void propertyChanged(const QString &property, const QVariant &value);
139     void setPropertyFailed(const QString& property);
140     void modemAdded(const QString &modem);
141     void modemRemoved(const QString &modem);
142
143 private:
144     void modemsChanged();
145
146 private:
147     OfonoModemManager *m_mm;
148     OfonoInterface *m_if;
149     SelectionSetting m_selectionSetting;
150     bool m_isValid;
151 };
152 #endif