Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_ipc_dbus_gonk_rawdbusconnection_h__ |
michael@0 | 8 | #define mozilla_ipc_dbus_gonk_rawdbusconnection_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Scoped.h" |
michael@0 | 11 | |
michael@0 | 12 | struct DBusConnection; |
michael@0 | 13 | struct DBusError; |
michael@0 | 14 | struct DBusMessage; |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace ipc { |
michael@0 | 18 | |
michael@0 | 19 | typedef void (*DBusReplyCallback)(DBusMessage*, void*); |
michael@0 | 20 | |
michael@0 | 21 | class RawDBusConnection |
michael@0 | 22 | { |
michael@0 | 23 | struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits<DBusConnection> |
michael@0 | 24 | { |
michael@0 | 25 | static void release(DBusConnection* ptr); |
michael@0 | 26 | }; |
michael@0 | 27 | |
michael@0 | 28 | public: |
michael@0 | 29 | RawDBusConnection(); |
michael@0 | 30 | virtual ~RawDBusConnection(); |
michael@0 | 31 | |
michael@0 | 32 | nsresult EstablishDBusConnection(); |
michael@0 | 33 | |
michael@0 | 34 | bool Watch(); |
michael@0 | 35 | |
michael@0 | 36 | DBusConnection* GetConnection() |
michael@0 | 37 | { |
michael@0 | 38 | return mConnection; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | bool Send(DBusMessage* aMessage); |
michael@0 | 42 | |
michael@0 | 43 | bool SendWithReply(DBusReplyCallback aCallback, void* aData, |
michael@0 | 44 | int aTimeout, DBusMessage* aMessage); |
michael@0 | 45 | |
michael@0 | 46 | bool SendWithReply(DBusReplyCallback aCallback, void* aData, |
michael@0 | 47 | int aTimeout, |
michael@0 | 48 | const char* aDestination, |
michael@0 | 49 | const char* aPath, const char* aIntf, |
michael@0 | 50 | const char *aFunc, int aFirstArgType, ...); |
michael@0 | 51 | |
michael@0 | 52 | protected: |
michael@0 | 53 | DBusMessage* BuildDBusMessage(const char* aDestination, |
michael@0 | 54 | const char* aPath, const char* aIntf, |
michael@0 | 55 | const char* aFunc, int aFirstArgType, |
michael@0 | 56 | va_list args); |
michael@0 | 57 | |
michael@0 | 58 | Scoped<ScopedDBusConnectionPtrTraits> mConnection; |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | static bool sDBusIsInit; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | #endif |