2 * This file is part of ofono-qt
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
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.
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.
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
24 #ifndef OFONOINTERFACE_H
25 #define OFONOINTERFACE_H
27 #include <QtCore/QObject>
29 #include <QDBusVariant>
31 #include "libofono-qt_global.h"
33 //! Basic oFono interface class
35 * This class implements basic access to properties of oFono interfaces.
36 * It should not be instantiated directly; instead you should instantiate
37 * interface-specific subclasses.
39 class OFONO_QT_EXPORT OfonoInterface : public QObject
44 //! How to handle getting the properties
45 enum GetPropertySetting {
46 GetAllOnStartup, /*!< Get all properties synchronously on startup;
47 * they would be immediately available. */
48 GetAllOnFirstRequest /*!< Do not get properties on startup;
49 * get them in an asynhronous way when the first
50 * property is requested. */
54 * \param path D-Bus path to the interface
55 * \param ifname D-Bus name of the interface
56 * \param setting specifies how the object should handle oFono properties of the interface
58 OfonoInterface(const QString &path, const QString &ifname, GetPropertySetting setting, QObject *parent=0);
61 //! Get all properties
63 * Returns the full set of current properties. If the object was constructed with
64 * OfonoInterface::GetAllOnFirstRequest, and no properties have been explicitly queried yet
65 * via requestProperty(), then returns nothing.
67 QVariantMap properties() const;
69 //! Request a property asynchronously.
71 * Result is returned via requestPropertyComplete() signal.
73 void requestProperty(const QString &name);
75 //! Set a property asynchronously.
77 * Result is returned via propertyChanged() signal
78 * if setting is successful or via setPropertyFailed() signal if setting has failed.
80 void setProperty(const QString &name, const QVariant &property);
82 //! Resets the property cache.
83 void resetProperties();
85 //! Get the interface D-Bus path
86 QString path() const {return m_path;}
88 //! Get the interface D-Bus name
89 QString ifname() const {return m_ifname;}
91 //! Get the D-Bus error name of the last operation.
93 * Returns the D-Bus error name of the last operation (setting a property
94 * or calling a method) if it has failed
96 QString errorName() const {return m_errorName;}
98 //! Get the D-Bus error message of the last operation.
100 * Returns the D-Bus error message of the last operation (setting a property
101 * or calling a method) if it has failed
103 QString errorMessage() const {return m_errorMessage;}
106 //! Issued when a property has changed
108 * \param name name of the property
109 * \param property value of the property
111 void propertyChanged(const QString &name, const QVariant &property);
113 //! Issued when requesting a property has completed
115 * \param success true if requesting a property was successful, false if there was an error
116 * \param name name of the property
117 * \param property value of the property
119 void requestPropertyComplete(bool success, const QString &name, const QVariant &property);
121 //! Issued when setting a property has failed
123 * \param name name of the property
125 void setPropertyFailed(const QString &name);
128 void onPropertyChanged(QString property, QDBusVariant value);
129 void getPropertiesAsyncResp(QVariantMap properties);
130 void getPropertiesAsyncErr(const QDBusError&);
131 void setPropertyResp();
132 void setPropertyErr(const QDBusError& error);
134 void setPath(const QString &path);
136 QVariantMap getAllPropertiesSync();
140 QString m_errorMessage;
145 QVariantMap m_properties;
146 QString m_pendingProperty;
147 GetPropertySetting m_getpropsetting;