#include <QCoreApplication>
#include <QtSingleCoreApplication>
#include <QDBusConnection>
#include <QDebug>

#include "sysdbusregister.h"

int main(int argc, char *argv[])
{
    QtSingleCoreApplication a(argc, argv);
    a.setOrganizationName("Kylin Team");
    a.setApplicationName("system-bus-bluetooth-service");

    if (a.isRunning()) {
        qDebug() << "system-bus-bluetooth-service is Already running ! ! !";
        return EXIT_SUCCESS;
    } else {
        QDBusConnection systemBus = QDBusConnection::systemBus();
        if (!systemBus.registerService("com.bluetooth.systemdbus")){
            qCritical() << "QDbus register service failed reason:" << systemBus.lastError();
            //exit(1);
        }

        if (!systemBus.registerObject("/", "com.bluetooth.interface", new SysDbusRegister(), QDBusConnection::ExportAllSlots)){
            qCritical() << "QDbus register object failed reason:" << systemBus.lastError();
            //exit(2);
        }
    //    qDebug() << "ok";
        return a.exec();
    }
}

