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 "ofonopropertysetting.h"
32 #include "libofono-qt_global.h"
34 //! Basic oFono interface class
36 * This class implements basic access to properties of oFono interfaces.
37 * It should not be instantiated directly; instead you should instantiate
38 * interface-specific subclasses.
40 class OFONO_QT_EXPORT OfonoInterface : public QObject
46 * \param path D-Bus path to the interface
47 * \param ifname D-Bus name of the interface
48 * \param setting specifies how the object should handle oFono properties of the interface
50 OfonoInterface(const QString &path, const QString &ifname, OfonoGetPropertySetting setting, QObject *parent=0);
53 //! Get all properties
55 * Returns the full set of current properties. If the object was constructed with
56 * OfonoInterface::GetAllOnFirstRequest, and no properties have been explicitly queried yet
57 * via requestProperty(), then returns nothing.
59 QVariantMap properties() const;
61 //! Request a property asynchronously.
63 * Result is returned via requestPropertyComplete() signal.
65 void requestProperty(const QString &name);
67 //! Set a property asynchronously.
69 * Result is returned via propertyChanged() signal
70 * if setting is successful or via setPropertyFailed() signal if setting has failed.
72 void setProperty(const QString &name, const QVariant &property);
74 //! Resets the property cache.
75 void resetProperties();
77 //! Get the interface D-Bus path
78 QString path() const {return m_path;}
80 //! Get the interface D-Bus name
81 QString ifname() const {return m_ifname;}
83 //! Get the D-Bus error name of the last operation.
85 * Returns the D-Bus error name of the last operation (setting a property
86 * or calling a method) if it has failed
88 QString errorName() const {return m_errorName;}
90 //! Get the D-Bus error message of the last operation.
92 * Returns the D-Bus error message of the last operation (setting a property
93 * or calling a method) if it has failed
95 QString errorMessage() const {return m_errorMessage;}
98 //! Changes the interface path
100 * This method changes the D-Bus path to the interface.
101 * Properties are updated immediately if property setting is set to
102 * GetAllOnStartup or reset otherwise.
104 void setPath(const QString &path);
106 //! Sets the last error explicitly
107 void setError(const QString &errorName, const QString &errorMessage);
110 //! Issued when a property has changed
112 * \param name name of the property
113 * \param property value of the property
115 void propertyChanged(const QString &name, const QVariant &property);
117 //! Issued when requesting a property has completed
119 * \param success true if requesting a property was successful, false if there was an error
120 * \param name name of the property
121 * \param property value of the property
123 void requestPropertyComplete(bool success, const QString &name, const QVariant &property);
125 //! Issued when setting a property has failed
127 * \param name name of the property
129 void setPropertyFailed(const QString &name);
132 void onPropertyChanged(QString property, QDBusVariant value);
133 void getPropertiesAsyncResp(QVariantMap properties);
134 void getPropertiesAsyncErr(const QDBusError&);
135 void setPropertyResp();
136 void setPropertyErr(const QDBusError& error);
139 QVariantMap getAllPropertiesSync();
143 QString m_errorMessage;
148 QVariantMap m_properties;
149 QString m_pendingProperty;
150 OfonoGetPropertySetting m_getpropsetting;