Add documentation, code cleanups
[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 <QtDBus/QtDBus>
29 #include <QtCore/QObject>
30 #include "ofonointerface.h"
31 #include "libofono-qt_global.h"
32
33 class OfonoModemManager;
34
35 //! This class is used to access an oFono modem object and its properties
36 /*!
37  * This class is used to access an oFono modem object and its properties.
38  * oFono modem properties are documented in
39  * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/modem-api.txt
40  */
41 class OFONO_QT_EXPORT OfonoModem : public OfonoInterface 
42 {
43
44 Q_OBJECT
45
46 public:
47
48     //! How the modem object should select a modem
49     enum SelectionSetting {
50         AutomaticSelect,        /*!< Select the first available modem automatically;
51                                  * if that modem becomes unavailable, select the first available
52                                  * modem again. */
53         ManualSelect    /*!< Do not select a modem automatically,
54                          * use the modem path provided in the constructor, and do not
55                          * attempt to select another modem if the first one becomes 
56                          * unavailable. */
57     };
58
59     /*!
60      * \param setting sets the modem selection policy for the object
61      * \param modemPath if modem selection policy is ManualSelect, then this contains
62      * the D-Bus path to the modem object. Otherwise, it is ignored.
63      */
64     OfonoModem(SelectionSetting setting, const QString& modemPath, QObject *parent=0);
65
66     ~OfonoModem();
67
68     //! Returns true if D-Bus modem object exists.
69     bool isValid() const;
70     
71     //! Returns the D-Bus object path of the modem
72     QString modemPath() const;
73
74     bool powered() const;
75     void setPowered(bool powered);
76     bool online() const;
77     void setOnline(bool online);
78     bool emergency() const;
79     
80     QString name() const;
81     QString manufacturer() const;
82     QString model() const;
83     QString revision() const;
84     QString serial() const;
85     
86     QStringList features() const;
87     QStringList interfaces() const;
88
89 signals:
90     //! Issued when a modem becomes unavailable or available again
91     void validityChanged(bool validity);
92     //! Issued when the object has switched to another modem
93     void modemPathChanged(QString modemPath);
94     
95     void poweredChanged(bool powered);
96     void setPoweredFailed();
97     void onlineChanged(bool online);
98     void setOnlineFailed();
99     void emergencyChanged(bool emergency);
100
101     void nameChanged(const QString &name);
102     void manufacturerChanged(const QString &manufacturer);
103     void modelChanged(const QString &model);
104     void revisionChanged(const QString &revision);
105     void serialChanged(const QString &serial);
106
107     void featuresChanged(const QStringList &features);
108     void interfacesChanged(const QStringList &interfaces);
109
110
111 private slots:
112     void propertyChanged(const QString &property, const QVariant &value);
113     void setPropertyFailed(const QString& property);
114     void modemAdded(const QString &modem);
115     void modemRemoved(const QString &modem);
116
117 private:
118     void modemsChanged();
119
120 private:
121     OfonoModemManager *m_mm;
122     SelectionSetting m_selectionSetting;
123     bool m_isValid;
124 };
125 #endif