void Ut_USBModeSelector::testShowDialog() { QFETCH(MeeGo::QmUSBMode::Mode, mode); QSignalSpy spy(usbModeSelector, SIGNAL(dialogShown())); usbModeSelector->usbMode->setDefaultMode(mode); usbModeSelector->applyUSBMode(mode); QCOMPARE(qQuickViews.count(), 1); // Check window properties /* QCOMPARE(qQuickViews.first()->testAttribute(Qt::WA_TranslucentBackground), true); QCOMPARE(qQuickViews.first()->testAttribute(Qt::WA_X11DoNotAcceptFocus), true); QCOMPARE(qQuickViews.first()->testAttribute(Qt::WA_X11NetWmWindowTypeMenu), true); QCOMPARE(qQuickViews.first()->windowTitle(), QString("USB Mode")); QCOMPARE(qQuickViews.first()->viewport()->autoFillBackground(), false); */ QCOMPARE(qQuickViews.first()->resizeMode(), QQuickView::SizeRootObjectToView); QCOMPARE(qQuickViews.first()->rootContext()->contextProperty("initialSize").toSize(), QGuiApplication::primaryScreen()->size()); QCOMPARE(qQuickViews.first()->rootContext()->contextProperty("usbModeSelector"), QVariant::fromValue(static_cast<QObject *>(usbModeSelector))); // Check that the window was shown QCOMPARE(qWindowVisible[static_cast<QWindow *>(qQuickViews.first())], true); QCOMPARE(spy.count(), 1); }
void Ut_USBModeSelector::testConnectingUSBWhenDeviceIsLockedEmitsDialogShown() { QFETCH(MeeGo::QmLocks::State, deviceLocked); QFETCH(int, dialogShownCount); QSignalSpy spy(usbModeSelector, SIGNAL(dialogShown())); gQmLocksStub->stubSetReturnValue("getState", deviceLocked); usbModeSelector->applyUSBMode(MeeGo::QmUSBMode::Connected); QCOMPARE(spy.count(), dialogShownCount); }
HomeApplication::HomeApplication(int &argc, char **argv, const QString &qmlPath) : QGuiApplication(argc, argv) , _mainWindowInstance(0) , _qmlPath(qmlPath) , originalSigIntHandler(signal(SIGINT, quitSignalHandler)) , originalSigTermHandler(signal(SIGTERM, quitSignalHandler)) { setApplicationName("Lipstick"); // TODO: autogenerate this from tags setApplicationVersion(VERSION); QTranslator *engineeringEnglish = new QTranslator(this); engineeringEnglish->load("lipstick_eng_en", "/usr/share/translations"); installTranslator(engineeringEnglish); QTranslator *translator = new QTranslator(this); translator->load(QLocale(), "lipstick", "-", "/usr/share/translations"); installTranslator(translator); // launch a timer for sending a dbus-signal upstart when basic construct is done QTimer::singleShot(0, this, SLOT(sendStartupNotifications())); // Initialize the QML engine qmlEngine = new QQmlEngine(this); // Initialize the notification manager NotificationManager::instance(); new NotificationPreviewPresenter(this); new NotificationFeedbackPlayer(this); // Create screen lock logic - not parented to "this" since destruction happens too late in that case screenLock = new ScreenLock; LipstickSettings::instance()->setScreenLock(screenLock); new ScreenLockAdaptor(screenLock); volumeControl = new VolumeControl; batteryNotifier = new BatteryNotifier(this); usbModeSelector = new USBModeSelector(this); connect(usbModeSelector, SIGNAL(dialogShown()), screenLock, SLOT(unlockScreen())); shutdownScreen = new ShutdownScreen(this); connectionSelector = new ConnectionSelector(this); // MCE expects the service to be registered on the system bus static const char *SCREENLOCK_DBUS_SERVICE = "org.nemomobile.lipstick"; static const char *SCREENLOCK_DBUS_PATH = "/screenlock"; QDBusConnection systemBus = QDBusConnection::systemBus(); if (!systemBus.registerService(SCREENLOCK_DBUS_SERVICE)) { qWarning("Unable to register screen lock D-Bus service %s: %s", SCREENLOCK_DBUS_SERVICE, systemBus.lastError().message().toUtf8().constData()); } if (!systemBus.registerObject(SCREENLOCK_DBUS_PATH, screenLock)) { qWarning("Unable to register screen lock object at path %s: %s", SCREENLOCK_DBUS_PATH, systemBus.lastError().message().toUtf8().constData()); } }
HomeApplication::HomeApplication(int &argc, char **argv, const QString &qmlPath) : QGuiApplication(argc, argv) , _mainWindowInstance(0) , _qmlPath(qmlPath) , originalSigIntHandler(signal(SIGINT, quitSignalHandler)) , originalSigTermHandler(signal(SIGTERM, quitSignalHandler)) , updatesEnabled(true) , homeReadySent(false) , onUpdatesDisabledUnfocusedWindowId(0) { setApplicationName("Lipstick"); // TODO: autogenerate this from tags setApplicationVersion(VERSION); QTranslator *engineeringEnglish = new QTranslator(this); engineeringEnglish->load("lipstick_eng_en", "/usr/share/translations"); installTranslator(engineeringEnglish); QTranslator *translator = new QTranslator(this); translator->load(QLocale(), "lipstick", "-", "/usr/share/translations"); installTranslator(translator); // Initialize the QML engine qmlEngine = new QQmlEngine(this); // Initialize the notification manager NotificationManager::instance(); new NotificationPreviewPresenter(this); // Create screen lock logic - not parented to "this" since destruction happens too late in that case screenLock = new ScreenLock; LipstickSettings::instance()->setScreenLock(screenLock); new ScreenLockAdaptor(screenLock); deviceLock = new DeviceLock(this); new DeviceLockAdaptor(deviceLock); volumeControl = new VolumeControl; new BatteryNotifier(this); new DiskSpaceNotifier(this); new ThermalNotifier(this); usbModeSelector = new USBModeSelector(this); connect(usbModeSelector, SIGNAL(dialogShown()), screenLock, SLOT(unlockScreen())); shutdownScreen = new ShutdownScreen(this); new ShutdownScreenAdaptor(shutdownScreen); connectionSelector = new ConnectionSelector(this); // MCE and usb-moded expect services to be registered on the system bus QDBusConnection systemBus = QDBusConnection::systemBus(); if (!systemBus.registerService(LIPSTICK_DBUS_SERVICE_NAME)) { qWarning("Unable to register D-Bus service %s: %s", LIPSTICK_DBUS_SERVICE_NAME, systemBus.lastError().message().toUtf8().constData()); } new HomeApplicationAdaptor(this); registerDBusObject(systemBus, LIPSTICK_DBUS_PATH, this); registerDBusObject(systemBus, LIPSTICK_DBUS_SCREENLOCK_PATH, screenLock); registerDBusObject(systemBus, LIPSTICK_DBUS_DEVICELOCK_PATH, deviceLock); registerDBusObject(systemBus, LIPSTICK_DBUS_SHUTDOWN_PATH, shutdownScreen); ScreenshotService *screenshotService = new ScreenshotService(this); new ScreenshotServiceAdaptor(screenshotService); QDBusConnection sessionBus = QDBusConnection::sessionBus(); registerDBusObject(sessionBus, LIPSTICK_DBUS_SCREENSHOT_PATH, screenshotService); connect(this, SIGNAL(homeReady()), this, SLOT(sendStartupNotifications())); }
void Ut_Sysuid::testSignalConnections() { QVERIFY(disconnect(sysuid->statusIndicatorMenuBusinessLogic, SIGNAL(statusIndicatorMenuVisibilityChanged(bool)), sysuid, SLOT(updateCompositorNotificationSinkEnabledStatus()))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationUpdated (const Notification &)), sysuid->mCompositorNotificationSink, SLOT(addNotification (const Notification &)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRemoved(uint)), sysuid->mCompositorNotificationSink, SLOT(removeNotification(uint)))); QVERIFY(disconnect(sysuid->mCompositorNotificationSink, SIGNAL(notificationRemovalRequested(uint)), sysuid->notificationManager, SLOT(removeNotification(uint)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationUpdated (const Notification &)), sysuid->ngfNotificationSink, SLOT(addNotification (const Notification &)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRemoved(uint)), sysuid->ngfNotificationSink, SLOT(removeNotification(uint)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationUpdated(const Notification &)), sysuid->notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRemoved(uint)), sysuid->notificationStatusIndicatorSink_, SLOT(removeNotification(uint)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(notificationRestored(const Notification &)), sysuid->notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &)))); QVERIFY(disconnect(sysuid->notificationManager, SIGNAL(groupUpdated(uint, const NotificationParameters &)), sysuid->notificationStatusIndicatorSink_, SLOT(addGroup(uint, const NotificationParameters &)))); QVERIFY(disconnect(sysuid->screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), sysuid, SLOT(updateCompositorNotificationSinkEnabledStatus()))); QVERIFY(disconnect(sysuid->screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), sysuid->mCompositorNotificationSink, SLOT(setTouchScreenLockActive(bool)))); QVERIFY(disconnect(sysuid->screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), sysuid->batteryBusinessLogic, SLOT(setTouchScreenLockActive(bool)))); QVERIFY(disconnect(sysuid->usbUi, SIGNAL(dialogShown()), sysuid->screenLockBusinessLogic, SLOT(unlockScreen()))); #ifdef HAVE_QMSYSTEM QVERIFY(disconnect(&sysuid->qmLocks, SIGNAL(stateChanged (MeeGo::QmLocks::Lock, MeeGo::QmLocks::State)), sysuid, SLOT(updateCompositorNotificationSinkEnabledStatus()))); #endif } void Ut_Sysuid::testUseMode() { testContextItem->setValue(""); QVERIFY(Ut_SysuidCompositorNotificationState); QVERIFY(Ut_SysuidFeedbackNotificationState); testContextItem->setValue("videorecording"); QVERIFY(!Ut_SysuidCompositorNotificationState); QVERIFY(!Ut_SysuidFeedbackNotificationState); }
Sysuid::Sysuid(QObject* parent) : QObject(parent) { instance_ = this; // Load translations of System-UI loadTranslations(); // D-Bus registration QDBusConnection bus = QDBusConnection::sessionBus(); if (!bus.registerService(SYSTEMUI_DBUS_SERVICE)) { qCritical("Unable to register system-ui D-Bus service %s: %s", SYSTEMUI_DBUS_SERVICE, bus.lastError().message().toUtf8().constData()); abort(); } if (!bus.registerObject(SYSTEMUI_DBUS_PATH, instance())) { qCritical("Unable to register system-ui object at path %s: %s", SYSTEMUI_DBUS_PATH, bus.lastError().message().toUtf8().constData()); abort(); } // Initialize notification system notificationManager = new NotificationManager(NOTIFICATION_RELAY_INTERVAL); mCompositorNotificationSink = new MCompositorNotificationSink; ngfNotificationSink = new NGFNotificationSink; notificationStatusIndicatorSink_ = new NotificationStatusIndicatorSink; // Connect the notification signals for the compositor notification sink connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), mCompositorNotificationSink, SLOT(addNotification(const Notification &))); connect(notificationManager, SIGNAL(notificationRemoved(uint)), mCompositorNotificationSink, SLOT(removeNotification(uint))); connect(mCompositorNotificationSink, SIGNAL(notificationRemovalRequested(uint)), notificationManager, SLOT(removeNotification(uint))); // Connect the notification signals for the feedback notification sink connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), ngfNotificationSink, SLOT(addNotification(const Notification &))); connect(notificationManager, SIGNAL(notificationRemoved(uint)), ngfNotificationSink, SLOT(removeNotification(uint))); // Connect the notification signals for the notification status indicator sink connect(notificationManager, SIGNAL(notificationUpdated(const Notification &)), notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &))); connect(notificationManager, SIGNAL(notificationRemoved(uint)), notificationStatusIndicatorSink_, SLOT(removeNotification(uint))); connect(notificationManager, SIGNAL(notificationRestored(const Notification &)), notificationStatusIndicatorSink_, SLOT(addNotification(const Notification &))); connect(notificationManager, SIGNAL(groupUpdated(uint, const NotificationParameters &)), notificationStatusIndicatorSink_, SLOT(addGroup(uint, const NotificationParameters &))); // Subscribe to a context property for getting information about the video recording status ContextFrameworkContext context; useMode = QSharedPointer<ContextItem>(context.createContextItem("/com/nokia/policy/camera")); useMode.data()->subscribe(); connect(useMode.data(), SIGNAL(contentsChanged()), this, SLOT(applyUseMode())); applyUseMode(); // Create shut down UI shutdownBusinessLogic = new ShutdownBusinessLogic(this); new ShutdownBusinessLogicAdaptor(this, shutdownBusinessLogic); // Create a status area renderer for rendering the shared status area pixmap statusAreaRenderer = new StatusAreaRenderer(this); new StatusAreaRendererAdaptor(statusAreaRenderer); bus.registerService("com.meego.core.MStatusBar"); bus.registerObject("/statusbar", statusAreaRenderer); // Create a status indicator menu statusIndicatorMenuBusinessLogic = new StatusIndicatorMenuBusinessLogic(this); connect(statusIndicatorMenuBusinessLogic, SIGNAL(statusIndicatorMenuVisibilityChanged(bool)), this, SLOT(updateCompositorNotificationSinkEnabledStatus())); new StatusIndicatorMenuAdaptor(statusIndicatorMenuBusinessLogic); bus.registerService("com.meego.core.MStatusIndicatorMenu"); bus.registerObject("/statusindicatormenu", statusIndicatorMenuBusinessLogic); // Create screen lock business logic screenLockBusinessLogic = new ScreenLockBusinessLogic(this); new ScreenLockBusinessLogicAdaptor(screenLockBusinessLogic); connect(screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), this, SLOT(updateCompositorNotificationSinkEnabledStatus())); connect(screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), mCompositorNotificationSink, SLOT(setTouchScreenLockActive(bool))); // MCE expects the service to be registered on the system bus QDBusConnection systemBus = QDBusConnection::systemBus(); if (!systemBus.registerService(SCREENLOCK_DBUS_SERVICE)) { qWarning("Unable to register screen lock D-Bus service %s: %s", SCREENLOCK_DBUS_SERVICE, systemBus.lastError().message().toUtf8().constData()); } if (!systemBus.registerObject(SCREENLOCK_DBUS_PATH, screenLockBusinessLogic)) { qWarning("Unable to register screen lock object at path %s: %s", SCREENLOCK_DBUS_PATH, systemBus.lastError().message().toUtf8().constData()); } // Update the enabled status of compositor notification sink based on screen and device locks #ifdef HAVE_QMSYSTEM connect(&qmLocks, SIGNAL(stateChanged(MeeGo::QmLocks::Lock, MeeGo::QmLocks::State)), this, SLOT(updateCompositorNotificationSinkEnabledStatus())); #endif updateCompositorNotificationSinkEnabledStatus(); // Create an extension area for the volume extension volumeExtensionArea = new MApplicationExtensionArea("com.meego.core.VolumeExtensionInterface/0.20"); volumeExtensionArea->setInProcessFilter(QRegExp("/sysuid-volume.desktop$")); volumeExtensionArea->setOutOfProcessFilter(QRegExp("$^")); volumeExtensionArea->init(); // Initialize notifications store after all the signal connections are made to the notification sinks but before any components that may send/remove notifications notificationManager->initializeStore(); // Create components that may create or remove notifications batteryBusinessLogic = new BatteryBusinessLogic(this); connect(screenLockBusinessLogic, SIGNAL(screenIsLocked(bool)), batteryBusinessLogic, SLOT(setTouchScreenLockActive(bool))); usbUi = new UsbUi(this); new DiskSpaceNotifier(this); // Unlock the touch screen lock when displaying the USB dialog connect(usbUi, SIGNAL(dialogShown()), screenLockBusinessLogic, SLOT(unlockScreen())); }