Commit a593e81f authored by Anupam Basak's avatar Anupam Basak

Updated DBus Methods and Implementation

parent cf00cd75
......@@ -19,12 +19,10 @@ find_package(
COMPONENTS
Core
DBus
Network
)
find_package(
KF5 REQUIRED
COMPONENTS
Wallet
libdavclient REQUIRED
)
set(
......@@ -53,7 +51,45 @@ target_link_libraries(
Qt5::Core
Qt5::DBus
KF5::Wallet
Qt5::Network
libdavclient.so
)
install(
TARGETS ${PROJECT_NAME}
DESTINATION bin
)
install(
FILES dbus-org.maui-accounts-dbus-daemon.service
DESTINATION /etc/systemd/system/
)
install(
FILES org.mauikit.accounts.conf
DESTINATION /etc/dbus-1/system.d/
)
### CPack Configurations
include(InstallRequiredSystemLibraries)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Anupam Basak")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MAUI Accounts DBus Daemon")
set(CPACK_PACKAGE_VENDOR "Anupam Basak")
set(CPACK_PACKAGE_CONTACT "Anupam Basak <anupam.basak27@gmail.com>")
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
set(CPACK_SOURCE_STRIP_FILES "")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/cpack-package-control-extra-scripts/preinst;${CMAKE_CURRENT_SOURCE_DIR}/cpack-package-control-extra-scripts/postinst;${CMAKE_CURRENT_SOURCE_DIR}/cpack-package-control-extra-scripts/prerm;${CMAKE_CURRENT_SOURCE_DIR}/cpack-package-control-extra-scripts/postrm")
include(CPack)
### END CPack Configurations
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
echo "POSTinst $@"
systemctl start dbus-org.maui-accounts-dbus-daemon.service
systemctl enable dbus-org.maui-accounts-dbus-daemon.service
echo "POSTrm $@"
\ No newline at end of file
echo "PREinst $@"
systemctl is-active --quiet dbus-org.maui-accounts-dbus-daemon.service && systemctl stop dbus-org.maui-accounts-dbus-daemon.service
systemctl is-active --quiet dbus-org.maui-accounts-dbus-daemon.service && systemctl disable dbus-org.maui-accounts-dbus-daemon.service
exit 0
\ No newline at end of file
echo "PRErm $@"
systemctl stop dbus-org.maui-accounts-dbus-daemon.service
systemctl disable dbus-org.maui-accounts-dbus-daemon.service
[Unit]
Description=MAUI Accounts DBus Service
[Service]
Type=dbus
BusName=org.mauikit.accounts
ExecStart=/usr/bin/maui-accounts-dbus-daemon
Restart=on-failure
[Install]
WantedBy=multi-user.target
<busconfig>
<!-- Only root user can own the service -->
<policy user="root">
<allow own="org.mauikit.accounts"/>
</policy>
<policy context="default">
<allow send_destination="org.mauikit.accounts"/>
<allow receive_sender="org.mauikit.accounts"/>
</policy>
</busconfig>
This diff is collapsed.
......@@ -3,7 +3,6 @@
#include "DBusInterface.hpp"
#include <KWallet>
#include <QJsonObject>
#include <QList>
#include <QString>
......@@ -18,26 +17,31 @@ class RootDBusInterface : public DBusInterface {
RootDBusInterface();
private:
KWallet::Wallet *wallet;
QJsonObject accountsJsonObject;
const QString WALLET_FOLDER_NAME = "org.mauikit.accounts";
const QString WALLET_ENTRY_ACCOUNTS = "accounts";
const QString JSON_FIELD_ACCOUNTS = "accounts";
const QString JSON_ACCOUNT_ARRAY_FIELD_EXTRAS = "extras";
const QString JSON_ACCOUNT_ARRAY_FIELD_USERNAME = "username";
const QString JSON_ACCOUNT_ARRAY_FIELD_ACCOUNTNAME = "account_name";
const QString JSON_ACCOUNT_ARRAY_FIELD_ID = "_id";
const QString JSON_ACCOUNT_ARRAY_FIELD_SECRET = "secret";
const QString JSON_ACCOUNT_ARRAY_FIELD_APPID = "appId";
const QString JSON_ACCOUNT_ARRAY_FIELD_TYPE = "type";
const QString JSON_ACCOUNT_ARRAY_FIELD_USERNAME = "username";
const QString JSON_ACCOUNT_ARRAY_FIELD_PASSWORD = "password";
const QString JSON_ACCOUNT_ARRAY_FIELD_URL = "url";
QString accountsJsonFilePath;
void writeAccountsJsonObjectToFile();
QString getManifestPath(QString appId);
public slots:
Q_SCRIPTABLE QList<QVariant> getAccountNames();
Q_SCRIPTABLE QList<QVariant> getAccountIds();
Q_SCRIPTABLE QList<QVariant> getAccountIdsByType(QString type);
Q_SCRIPTABLE QMap<QString, QVariant> getAccount(QString id);
Q_SCRIPTABLE QString createAccount(QString name, QString username,
QString password, QString extras);
Q_SCRIPTABLE QString getAccountPassword(QString secret);
Q_SCRIPTABLE QString createWebDAVAccount(QString appId, QString username,
QString password, QString url);
Q_SCRIPTABLE QString createCardDAVAccount(QString appId, QString username,
QString password, QString url);
Q_SCRIPTABLE bool removeAccount(QString id);
};
......
......@@ -10,23 +10,20 @@
int main(int argc, char *argv[]) {
QCoreApplication app(argc, argv);
if (!QDBusConnection::sessionBus().isConnected()) {
fprintf(stderr,
"Cannot connect to the D-Bus session bus.\n"
"To start it, run:\n"
"\teval `dbus-launch --auto-syntax`\n");
if (!QDBusConnection::systemBus().isConnected()) {
fprintf(stderr, "Cannot connect to the D-Bus system bus.\n");
return 1;
}
if (!QDBusConnection::sessionBus().registerService(SERVICE_NAME)) {
if (!QDBusConnection::systemBus().registerService(SERVICE_NAME)) {
fprintf(stderr, "%s\n",
qPrintable(QDBusConnection::sessionBus().lastError().message()));
qPrintable(QDBusConnection::systemBus().lastError().message()));
exit(1);
}
RootDBusInterface *interface = new RootDBusInterface();
QDBusConnection::sessionBus().registerObject(
"/", interface->name(), interface, QDBusConnection::ExportAllSlots);
QDBusConnection::systemBus().registerObject("/", interface->name(), interface,
QDBusConnection::ExportAllSlots);
return app.exec();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment