|
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
|
2 /* vim: set ts=2 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 file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_ipc_dbus_gonk_rawdbusconnection_h__ |
|
8 #define mozilla_ipc_dbus_gonk_rawdbusconnection_h__ |
|
9 |
|
10 #include "mozilla/Scoped.h" |
|
11 |
|
12 struct DBusConnection; |
|
13 struct DBusError; |
|
14 struct DBusMessage; |
|
15 |
|
16 namespace mozilla { |
|
17 namespace ipc { |
|
18 |
|
19 typedef void (*DBusReplyCallback)(DBusMessage*, void*); |
|
20 |
|
21 class RawDBusConnection |
|
22 { |
|
23 struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits<DBusConnection> |
|
24 { |
|
25 static void release(DBusConnection* ptr); |
|
26 }; |
|
27 |
|
28 public: |
|
29 RawDBusConnection(); |
|
30 virtual ~RawDBusConnection(); |
|
31 |
|
32 nsresult EstablishDBusConnection(); |
|
33 |
|
34 bool Watch(); |
|
35 |
|
36 DBusConnection* GetConnection() |
|
37 { |
|
38 return mConnection; |
|
39 } |
|
40 |
|
41 bool Send(DBusMessage* aMessage); |
|
42 |
|
43 bool SendWithReply(DBusReplyCallback aCallback, void* aData, |
|
44 int aTimeout, DBusMessage* aMessage); |
|
45 |
|
46 bool SendWithReply(DBusReplyCallback aCallback, void* aData, |
|
47 int aTimeout, |
|
48 const char* aDestination, |
|
49 const char* aPath, const char* aIntf, |
|
50 const char *aFunc, int aFirstArgType, ...); |
|
51 |
|
52 protected: |
|
53 DBusMessage* BuildDBusMessage(const char* aDestination, |
|
54 const char* aPath, const char* aIntf, |
|
55 const char* aFunc, int aFirstArgType, |
|
56 va_list args); |
|
57 |
|
58 Scoped<ScopedDBusConnectionPtrTraits> mConnection; |
|
59 |
|
60 private: |
|
61 static bool sDBusIsInit; |
|
62 }; |
|
63 |
|
64 } |
|
65 } |
|
66 |
|
67 #endif |