| 1 |
/* |
| 2 |
* Copyright (C) 2018 Aetf <[email protected]> |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 or (at your option) |
| 7 |
* version 3 of the License. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "DBusObject.h" |
| 19 |
|
| 20 |
#include <QUrl> |
| 21 |
|
| 22 |
namespace FdoSecrets |
| 23 |
{ |
| 24 |
|
| 25 |
DBusObject::DBusObject(DBusObject* parent) |
| 26 |
: QObject(parent) |
| 27 |
, m_dbus(parent->dbus()) |
| 28 |
{ |
| 29 |
} |
| 30 |
|
| 31 |
DBusObject::DBusObject(QSharedPointer<DBusMgr> dbus) |
| 32 |
: QObject(nullptr) |
| 33 |
, m_objectPath("/") |
| 34 |
, m_dbus(std::move(dbus)) |
| 35 |
{ |
| 36 |
} |
| 37 |
|
| 38 |
DBusObject::~DBusObject() |
| 39 |
{ |
| 40 |
emit destroyed(this); |
| 41 |
} |
| 42 |
|
| 43 |
void DBusObject::setObjectPath(const QString& path) |
| 44 |
{ |
| 45 |
m_objectPath.setPath(path); |
| 46 |
} |
| 47 |
|
| 48 |
QString encodePath(const QString& value) |
| 49 |
{ |
| 50 |
// toPercentEncoding encodes everything except those in the unreserved group: |
| 51 |
// ALPHA / DIGIT / "-" / "." / "_" / "~" |
| 52 |
// we want only ALPHA / DIGIT / "_", with "_" as the escape character |
| 53 |
// so force "-.~_" to be encoded |
| 54 |
return QUrl::toPercentEncoding(value, "", "-.~_").replace('%', '_'); |
| 55 |
} |
| 56 |
|
| 57 |
} // namespace FdoSecrets |