#include <QApplication>
#include <QDBusConnection>
#include <QDBusError>
#include <QDebug>

#include "ukccsessionserver.h"
#include "session_adaptor.h"
#include "screenStruct.h"

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QCoreApplication::setOrganizationName("Kylin Team");
    QCoreApplication::setApplicationName("ukcc-session-service");
    qRegisterMetaType<ScreenConfig>("ScreenConfig");
    qDBusRegisterMetaType<ScreenConfig>();

    QTranslator translator;
    translator.load("/usr/share/ukui-control-center/shell/res/i18n/" + QLocale::system().name());
    app.installTranslator(&translator);

    ukccSessionServer service;
    new InterfaceAdaptor(&service);

    QDBusConnection sessionBus = QDBusConnection::sessionBus();
    if (!sessionBus.registerService("org.ukui.ukcc.session")) {
        qCritical() << "QDbus register service failed reason:" << sessionBus.lastError();
        exit(1);
    }

    if (!sessionBus.registerObject("/", &service)) {
        qCritical() << "QDbus register object failed reason:" << sessionBus.lastError();
        exit(2);
    }

    return app.exec();
}
