michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_ipc_dbus_gonk_rawdbusconnection_h__ michael@0: #define mozilla_ipc_dbus_gonk_rawdbusconnection_h__ michael@0: michael@0: #include "mozilla/Scoped.h" michael@0: michael@0: struct DBusConnection; michael@0: struct DBusError; michael@0: struct DBusMessage; michael@0: michael@0: namespace mozilla { michael@0: namespace ipc { michael@0: michael@0: typedef void (*DBusReplyCallback)(DBusMessage*, void*); michael@0: michael@0: class RawDBusConnection michael@0: { michael@0: struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits michael@0: { michael@0: static void release(DBusConnection* ptr); michael@0: }; michael@0: michael@0: public: michael@0: RawDBusConnection(); michael@0: virtual ~RawDBusConnection(); michael@0: michael@0: nsresult EstablishDBusConnection(); michael@0: michael@0: bool Watch(); michael@0: michael@0: DBusConnection* GetConnection() michael@0: { michael@0: return mConnection; michael@0: } michael@0: michael@0: bool Send(DBusMessage* aMessage); michael@0: michael@0: bool SendWithReply(DBusReplyCallback aCallback, void* aData, michael@0: int aTimeout, DBusMessage* aMessage); michael@0: michael@0: bool SendWithReply(DBusReplyCallback aCallback, void* aData, michael@0: int aTimeout, michael@0: const char* aDestination, michael@0: const char* aPath, const char* aIntf, michael@0: const char *aFunc, int aFirstArgType, ...); michael@0: michael@0: protected: michael@0: DBusMessage* BuildDBusMessage(const char* aDestination, michael@0: const char* aPath, const char* aIntf, michael@0: const char* aFunc, int aFirstArgType, michael@0: va_list args); michael@0: michael@0: Scoped mConnection; michael@0: michael@0: private: michael@0: static bool sDBusIsInit; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif