Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / widget / gtk / DBusService.h
blob6e8bbf8a354375ef4314daeac36a1c3d1e8b6b3b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef DBusService_h__
7 #define DBusService_h__
9 #include <glib.h>
10 #include <gio/gio.h>
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/GRefPtr.h"
14 namespace mozilla::widget {
16 class DBusService final {
17 public:
18 explicit DBusService(const char* aAppFile) : mAppFile(aAppFile) {}
19 ~DBusService();
21 // nsBaseAppShell overrides:
22 bool Init();
23 void Run();
25 void StartDBusListening();
26 void StopDBusListening();
28 static void DBusSessionSleepCallback(GDBusProxy* aProxy, gchar* aSenderName,
29 gchar* aSignalName,
30 GVariant* aParameters,
31 gpointer aUserData);
32 static void DBusTimedatePropertiesChangedCallback(GDBusProxy* aProxy,
33 gchar* aSenderName,
34 gchar* aSignalName,
35 GVariant* aParameters,
36 gpointer aUserData);
37 static void DBusConnectClientResponse(GObject* aObject, GAsyncResult* aResult,
38 gpointer aUserData);
40 bool LaunchApp(const char* aCommand, const char** aURIList, int aURIListLen);
42 void HandleFreedesktopActivate(GVariant* aParameters,
43 GDBusMethodInvocation* aReply);
44 void HandleFreedesktopOpen(GVariant* aParameters,
45 GDBusMethodInvocation* aReply);
46 void HandleFreedesktopActivateAction(GVariant* aParameters,
47 GDBusMethodInvocation* aReply);
49 bool StartFreedesktopListener();
50 void StopFreedesktopListener();
52 void OnBusAcquired(GDBusConnection* aConnection);
53 void OnNameAcquired(GDBusConnection* aConnection);
54 void OnNameLost(GDBusConnection* aConnection);
56 private:
57 // The connection is owned by DBus library
58 uint mDBusID = 0;
59 uint mRegistrationId = 0;
60 GDBusConnection* mConnection = nullptr;
61 RefPtr<GDBusNodeInfo> mIntrospectionData;
62 const char* mAppFile = nullptr;
65 } // namespace mozilla::widget
67 #endif // DBusService_h__