Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ssud] Initial version of ssu dbus service
- Loading branch information
Bernd Wachter
committed
Sep 3, 2013
1 parent
fd7618a
commit 6ed1598
Showing
14 changed files
with
322 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE busconfig PUBLIC | ||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
|
||
<busconfig> | ||
<policy user="root"> | ||
<allow own="org.nemo.ssu"/> | ||
<allow send_destination="org.nemo.ssu" send_interface="org.nemo.ssu"/> | ||
</policy> | ||
|
||
<policy group="system"> | ||
<allow send_destination="org.nemo.ssu" send_interface="org.nemo.ssu"/> | ||
<allow send_destination="org.nemo.ssu" send_interface="org.freedesktop.DBus.Introspectable"/> | ||
<allow send_destination="org.nemo.ssu" send_interface="org.freedesktop.DBus.Peer"/> | ||
<allow send_destination="org.nemo.ssu" send_interface="org.freedesktop.DBus.Properties"/> | ||
</policy> | ||
</busconfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[D-BUS Service] | ||
Interface=org.nemo.ssu | ||
Name=org.nemo.ssu | ||
Exec=/usr/bin/ssud | ||
User=root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | ||
|
||
<!-- | ||
/** | ||
* DBus service for interfacing with ssu management | ||
* Copyright (C) 2013 Jolla Ltd. | ||
* Contact: Bernd Wachter <bernd.wachter@jollamobile.com> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
**/ | ||
--> | ||
|
||
<node name="/org/nemo/ssu"> | ||
<interface name="org.nemo.ssu"> | ||
<method name="registerDevice"> | ||
<arg direction="in" type="s" name="username"/> | ||
<arg direction="in" type="s" name="password"/> | ||
</method> | ||
<method name="unregisterDevice"> | ||
</method> | ||
<method name="isRegistered"> | ||
<arg direction="out" type="b" name="status"/> | ||
</method> | ||
<method name="deviceModel"> | ||
<arg direction="out" type="s" name="model"/> | ||
</method> | ||
<method name="deviceUid"> | ||
<arg direction="out" type="s" name="model"/> | ||
</method> | ||
<method name="error"> | ||
<arg direction="out" type="b" name="status"/> | ||
</method> | ||
<method name="lastError"> | ||
<arg direction="out" type="s" name="status"/> | ||
</method> | ||
<method name="quit"> | ||
</method> | ||
|
||
<signal name="credentialsChanged"> | ||
</signal> | ||
<signal name="done"> | ||
</signal> | ||
<signal name="registrationStatusChanged"> | ||
</signal> | ||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @file main.cpp | ||
* @copyright 2013 Jolla Ltd. | ||
* @author Bernd Wachter <bwachter@lart.info> | ||
* @date 2013 | ||
*/ | ||
|
||
#include <QCoreApplication> | ||
#include <QTranslator> | ||
#include <QLocale> | ||
#include <QLibraryInfo> | ||
#include <QNetworkProxyFactory> | ||
#include "ssud.h" | ||
|
||
int main(int argc, char** argv){ | ||
QCoreApplication app(argc, argv); | ||
QCoreApplication::setOrganizationName("Jolla"); | ||
QCoreApplication::setOrganizationDomain("http://www.jollamobile.com"); | ||
QCoreApplication::setApplicationName("ssud"); | ||
|
||
QTranslator qtTranslator; | ||
qtTranslator.load("qt_" + QLocale::system().name(), | ||
QLibraryInfo::location(QLibraryInfo::TranslationsPath)); | ||
app.installTranslator(&qtTranslator); | ||
|
||
QNetworkProxyFactory::setUseSystemConfiguration(true); | ||
|
||
Ssud ssud; | ||
|
||
app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* @file ssud.cpp | ||
* @copyright 2013 Jolla Ltd. | ||
* @author Bernd Wachter <bwachter@lart.info> | ||
* @date 2013 | ||
*/ | ||
|
||
#include "ssud.h" | ||
#include "ssuadaptor.h" | ||
|
||
#include "libssu/ssudeviceinfo.h" | ||
|
||
#include <QDBusConnection> | ||
|
||
const char *Ssud::SERVICE_NAME = "org.nemo.ssu"; | ||
const char *Ssud::OBJECT_PATH = "/org/nemo/ssu"; | ||
|
||
Ssud::Ssud(QObject *parent): QObject(parent){ | ||
QDBusConnection connection = QDBusConnection::systemBus(); | ||
if (!connection.registerService(SERVICE_NAME)) { | ||
qFatal("Cannot register D-Bus service at %s", SERVICE_NAME); | ||
} | ||
|
||
if (!connection.registerObject(OBJECT_PATH, this)) { | ||
qFatal("Cannot register object at %s", OBJECT_PATH); | ||
} | ||
|
||
new SsuAdaptor(this); | ||
|
||
connect(&ssu, SIGNAL(done()), | ||
this, SIGNAL(done())); | ||
connect(&ssu, SIGNAL(credentialsChanged()), | ||
this, SIGNAL(credentialsChanged())); | ||
connect(&ssu, SIGNAL(registrationStatusChanged()), | ||
this, SIGNAL(registrationStatusChanged())); | ||
} | ||
|
||
Ssud::~Ssud(){ | ||
} | ||
|
||
QString Ssud::deviceModel(){ | ||
SsuDeviceInfo deviceInfo; | ||
|
||
return deviceInfo.deviceModel(); | ||
}; | ||
|
||
QString Ssud::deviceUid(){ | ||
SsuDeviceInfo deviceInfo; | ||
|
||
return deviceInfo.deviceUid(); | ||
}; | ||
|
||
bool Ssud::error(){ | ||
return ssu.error(); | ||
} | ||
|
||
QString Ssud::lastError(){ | ||
return ssu.lastError(); | ||
} | ||
|
||
bool Ssud::isRegistered(){ | ||
return ssu.isRegistered(); | ||
} | ||
|
||
void Ssud::quit(){ | ||
QCoreApplication::quit(); | ||
} | ||
|
||
void Ssud::registerDevice(const QString &username, const QString &password){ | ||
ssu.sendRegistration(username, password); | ||
} | ||
|
||
void Ssud::unregisterDevice(){ | ||
ssu.unregister(); | ||
}; |
Oops, something went wrong.