File: ofonointerface.h

package info (click to toggle)
libofono-qt 1.30-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 960 kB
  • sloc: cpp: 6,663; xml: 77; makefile: 14
file content (153 lines) | stat: -rw-r--r-- 4,951 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * This file is part of ofono-qt
 *
 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef OFONOINTERFACE_H
#define OFONOINTERFACE_H

#include <QtCore/QObject>
#include <QVariant>
#include <QDBusVariant>
#include <QDBusError>
#include "ofonopropertysetting.h"
#include "libofono-qt_global.h"

//! Basic oFono interface class
/*!
 * This class implements basic access to properties of oFono interfaces.
 * It should not be instantiated directly; instead you should instantiate
 * interface-specific classes.
 */
class OFONO_QT_EXPORT OfonoInterface : public QObject
{
    Q_OBJECT
public:

    /*!
     * \param path D-Bus path to the interface
     * \param ifname D-Bus name of the interface
     * \param setting specifies how the object should handle oFono properties of the interface
     */
    OfonoInterface(const QString &path, const QString &ifname, OfonoGetPropertySetting setting, QObject *parent=0);
    ~OfonoInterface();

    //! Get all properties
    /*!
     * Returns the full set of current properties. If the object was constructed with
     * OfonoInterface::GetAllOnFirstRequest, and no properties have been explicitly queried yet
     * via requestProperty(), then returns nothing.
     */
    QVariantMap properties() const;
    
    //! Request a property asynchronously.
    /*! 
     * Result is returned via requestPropertyComplete() signal.
     */
    void requestProperty(const QString &name);

    //! Set a property asynchronously.
    /*!
     * Result is returned via propertyChanged() signal
     * if setting is successful or via setPropertyFailed() signal if setting has failed.
     */
    void setProperty(const QString &name, const QVariant &property, const QString& password=0);
    
    //! Resets the property cache.
    void resetProperties();
    
    //! Get the interface D-Bus path
    QString path() const {return m_path;}
    
    //! Get the interface D-Bus name
    QString ifname() const {return m_ifname;}

    //! Get the D-Bus error name of the last operation.
    /*!
     * Returns the D-Bus error name of the last operation (setting a property
     * or calling a method) if it has failed
     */
    QString errorName() const {return m_errorName;}

    //! Get the D-Bus error message of the last operation.
    /*!
     * Returns the D-Bus error message of the last operation (setting a property
     * or calling a method) if it has failed
     */
    QString errorMessage() const {return m_errorMessage;}

public Q_SLOTS:
    //! Changes the interface path
    /*!
     * This method changes the D-Bus path to the interface.
     * Properties are updated immediately if property setting is set to
     * GetAllOnStartup or reset otherwise.
     */
    void setPath(const QString &path);
    
    //! Sets the last error explicitly
    void setError(const QString &errorName, const QString &errorMessage);

Q_SIGNALS:
    //! Issued when a property has changed
    /*!
     * \param name name of the property
     * \param property value of the property
     */
    void propertyChanged(const QString &name, const QVariant &property);
    
    //! Issued when requesting a property has completed
    /*!
     * \param success true if requesting a property was successful, false if there was an error
     * \param name name of the property
     * \param property value of the property
     */
    void requestPropertyComplete(bool success, const QString &name, const QVariant &property);
    
    //! Issued when setting a property has failed
    /*!
     * \param name name of the property
     */
    void setPropertyFailed(const QString &name);

private Q_SLOTS:
    void onPropertyChanged(QString property, QDBusVariant value);
    void getPropertiesAsyncResp(QVariantMap properties);
    void getPropertiesAsyncErr(const QDBusError&);
    void setPropertyResp();
    void setPropertyErr(const QDBusError& error);
protected Q_SLOTS:
private:
    QVariantMap getAllPropertiesSync();
    
protected:
   QString m_errorName;
   QString m_errorMessage;
    
private:
   QString m_path;
   QString m_ifname;
   QVariantMap m_properties;
   QString m_pendingProperty;
   OfonoGetPropertySetting m_getpropsetting;
};

#endif