/*
* Copyright (C) 2012 Canonical, Ltd.
*
* 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; version 3.
*
* 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, see .
*
* Author: MichaĆ Sawicz
*/
// Qt
#include
#include
#include
#include
#include
// self
#include "plugin.h"
// local
#include "albumartprovider.h"
#include "bottombarvisibilitycommunicatorshell.h"
#include "qlimitproxymodelqml.h"
#include "qsortfilterproxymodelqml.h"
#include "unitymenumodelpaths.h"
static const char* BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_PATH = "/BottomBarVisibilityCommunicator";
static const char* DBUS_SERVICE = "com.canonical.Shell.BottomBarVisibilityCommunicator";
void UtilsPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("Utils"));
qmlRegisterType();
qmlRegisterType(uri, 0, 1, "LimitProxyModel");
qmlRegisterType(uri, 0, 1, "SortFilterProxyModel");
qmlRegisterType(uri, 0, 1, "UnityMenuModelPaths");
qmlRegisterUncreatableType(uri, 0, 1, "BottomBarVisibilityCommunicatorShell", "Can't create BottomBarVisibilityCommunicatorShell");
}
void UtilsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
QQmlExtensionPlugin::initializeEngine(engine, uri);
try
{
engine->addImageProvider(QLatin1String("albumart"), new AlbumArtProvider);
}
catch (const std::runtime_error &e)
{
qWarning() << "Failed to register image provider for albumart:" << e.what();
}
catch (...)
{
qWarning() << "Failed to register image provider for albumart (unknown error)";
}
QDBusConnection::sessionBus().registerService(DBUS_SERVICE);
BottomBarVisibilityCommunicatorShell *bottomBarVisibilityCommunicator = &BottomBarVisibilityCommunicatorShell::instance();
QDBusConnection::sessionBus().registerObject(BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_PATH, bottomBarVisibilityCommunicator, QDBusConnection::ExportAllContents);
engine->rootContext()->setContextProperty("bottomBarVisibilityCommunicatorShell", bottomBarVisibilityCommunicator);
}