1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include "mozilla/ipc/GeckoChildProcessHost.h"
10 #include "nsNativeAppSupportQt.h"
12 #include "nsIObserverService.h"
13 #include "mozilla/Services.h"
15 #ifdef MOZ_ENABLE_QMSYSTEM2
17 nsNativeAppSupportQt::activityChanged(MeeGo::QmActivity::Activity activity
)
19 nsCOMPtr
<nsIObserverService
> os
= mozilla::services::GetObserverService();
23 if (MeeGo::QmActivity::Inactive
== activity
) {
24 os
->NotifyObservers(nullptr, "system-idle", nullptr);
26 os
->NotifyObservers(nullptr, "system-active", nullptr);
31 nsNativeAppSupportQt::displayStateChanged(MeeGo::QmDisplayState::DisplayState state
)
33 nsCOMPtr
<nsIObserverService
> os
= mozilla::services::GetObserverService();
38 case MeeGo::QmDisplayState::On
:
39 os
->NotifyObservers(nullptr, "system-display-on", nullptr);
41 case MeeGo::QmDisplayState::Off
:
42 os
->NotifyObservers(nullptr, "system-display-off", nullptr);
44 case MeeGo::QmDisplayState::Dimmed
:
45 os
->NotifyObservers(nullptr, "system-display-dimmed", nullptr);
48 NS_WARNING("Unknown display state");
53 void nsNativeAppSupportQt::deviceModeChanged(MeeGo::QmDeviceMode::DeviceMode mode
)
55 nsCOMPtr
<nsIObserverService
> os
= mozilla::services::GetObserverService();
60 case MeeGo::QmDeviceMode::DeviceMode::Normal
:
61 os
->NotifyObservers(nullptr, "profile-change-net-restore", nullptr);
63 case MeeGo::QmDeviceMode::DeviceMode::Flight
:
64 os
->NotifyObservers(nullptr, "profile-change-net-teardown", nullptr);
66 case MeeGo::QmDeviceMode::DeviceMode::Error
:
68 NS_WARNING("Unknown DeviceMode");
73 void nsNativeAppSupportQt::RefreshStates()
75 activityChanged(mActivity
.get());
76 displayStateChanged(mDisplayState
.get());
77 deviceModeChanged(mDeviceMode
.getMode());
82 nsNativeAppSupportQt::Start(bool* aRetVal
)
84 NS_ASSERTION(gAppData
, "gAppData must not be null.");
86 #ifdef MOZ_ENABLE_QMSYSTEM2
87 connect(&mActivity
, SIGNAL(activityChanged(MeeGo::QmActivity::Activity
)), this, SLOT(activityChanged(MeeGo::QmActivity::Activity
)));
88 connect(&mDeviceMode
, SIGNAL(deviceModeChanged(MeeGo::QmDeviceMode::DeviceMode
)), this, SLOT(deviceModeChanged(MeeGo::QmDeviceMode::DeviceMode
)));
89 connect(&mDisplayState
, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState
)), this, SLOT(displayStateChanged(MeeGo::QmDisplayState::DisplayState
)));
90 // Init states withing next event loop iteration
91 QTimer::singleShot(0, this, SLOT(RefreshStates()));
99 nsNativeAppSupportQt::Stop(bool* aResult
)
101 NS_ENSURE_ARG(aResult
);
108 NS_CreateNativeAppSupport(nsINativeAppSupport
** aResult
)
110 nsNativeAppSupportBase
* native
= new nsNativeAppSupportQt();
112 return NS_ERROR_OUT_OF_MEMORY
;