Add more Q_PROPERTY declarations
[profile/ivi/ofono-qt.git] / lib / ofonomodeminterface.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 #ifndef OFONOMODEMINTERFACE_H
25 #define OFONOMODEMINTERFACE_H
26
27 #include <QtCore/QObject>
28 #include <QStringList>
29 #include "ofonomodem.h"
30 #include "ofonopropertysetting.h"
31 #include "libofono-qt_global.h"
32
33 class OfonoInterface;
34
35 //! This class implements a generic modem interface object
36 /*!
37  * It provides validity checking and modem binding.
38  * It should not be instantiated directly; instead you should instantiate
39  * interface-specific subclasses.
40  */
41 class OFONO_QT_EXPORT OfonoModemInterface : public QObject
42 {
43     Q_OBJECT
44     
45     Q_PROPERTY(bool isValid READ isValid NOTIFY validityChanged)
46     Q_PROPERTY(QString path READ path)
47     Q_PROPERTY(QString errorName READ errorName)
48     Q_PROPERTY(QString errorMessage READ errorMessage)
49     
50 public:
51
52     //! Construct a modem interface object
53     /*!
54      * \param modemSetting modem selection setting
55      * \param modemPath path to the modem (may not be significant, depending on modemSetting)
56      * \param ifname d-bus interface name
57      * \param propertySetting oFono d-bus properties setting
58      */
59     OfonoModemInterface(OfonoModem::SelectionSetting modemSetting, const QString& modemPath, const QString& ifname, OfonoGetPropertySetting propertySetting, QObject *parent=0);
60     ~OfonoModemInterface();
61
62     //! Check that the modem interface object is valid
63     /*!
64      * This means that a modem d-bus object
65      * exists and has the d-bus interface specified in the contstructor.
66      */
67     bool isValid() const;
68     
69     //! Get the modem object that this interface belongs to.
70     /*!
71      * The ownership of the modem object stays with the OfonoModemInterface object.
72      */
73     OfonoModem *modem() const;
74     
75     //! Returns the D-Bus object path of the interface
76     QString path() const;
77     
78     //! Get the D-Bus error name of the last operation.
79     /*!
80      * Returns the D-Bus error name of the last operation (setting a property
81      * or calling a method) if it has failed
82      */
83     QString errorName() const;
84
85     //! Get the D-Bus error message of the last operation.
86     /*!
87      * Returns the D-Bus error message of the last operation (setting a property
88      * or calling a method) if it has failed
89      */
90     QString errorMessage() const;
91
92 signals:
93     //! Interface validity has changed
94     /*!
95      * This may mean that modem has become unavailable
96      * (or available again) or that the modem interface has become unavailable
97      * (or available again)
98      */
99     void validityChanged(bool validity);
100
101 private:
102     bool checkValidity();
103     void updateValidity();
104
105 private slots:
106     void modemValidityChanged(bool validity);
107     void interfacesChanged(const QStringList &interfaces);
108
109 protected:
110     OfonoInterface *m_if;
111
112 private:
113     OfonoModem *m_m;
114     bool m_isValid;
115 };
116 #endif