ipc/dbus/RawDBusConnection.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/dbus/RawDBusConnection.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_ipc_dbus_gonk_rawdbusconnection_h__
    1.11 +#define mozilla_ipc_dbus_gonk_rawdbusconnection_h__
    1.12 +
    1.13 +#include "mozilla/Scoped.h"
    1.14 +
    1.15 +struct DBusConnection;
    1.16 +struct DBusError;
    1.17 +struct DBusMessage;
    1.18 +
    1.19 +namespace mozilla {
    1.20 +namespace ipc {
    1.21 +
    1.22 +typedef void (*DBusReplyCallback)(DBusMessage*, void*);
    1.23 +
    1.24 +class RawDBusConnection
    1.25 +{
    1.26 +  struct ScopedDBusConnectionPtrTraits : ScopedFreePtrTraits<DBusConnection>
    1.27 +  {
    1.28 +    static void release(DBusConnection* ptr);
    1.29 +  };
    1.30 +
    1.31 +public:
    1.32 +  RawDBusConnection();
    1.33 +  virtual ~RawDBusConnection();
    1.34 +
    1.35 +  nsresult EstablishDBusConnection();
    1.36 +
    1.37 +  bool Watch();
    1.38 +
    1.39 +  DBusConnection* GetConnection()
    1.40 +  {
    1.41 +    return mConnection;
    1.42 +  }
    1.43 +
    1.44 +  bool Send(DBusMessage* aMessage);
    1.45 +
    1.46 +  bool SendWithReply(DBusReplyCallback aCallback, void* aData,
    1.47 +                     int aTimeout, DBusMessage* aMessage);
    1.48 +
    1.49 +  bool SendWithReply(DBusReplyCallback aCallback, void* aData,
    1.50 +                     int aTimeout,
    1.51 +                     const char* aDestination,
    1.52 +                     const char* aPath, const char* aIntf,
    1.53 +                     const char *aFunc, int aFirstArgType, ...);
    1.54 +
    1.55 +protected:
    1.56 +  DBusMessage* BuildDBusMessage(const char* aDestination,
    1.57 +                                const char* aPath, const char* aIntf,
    1.58 +                                const char* aFunc, int aFirstArgType,
    1.59 +                                va_list args);
    1.60 +
    1.61 +  Scoped<ScopedDBusConnectionPtrTraits> mConnection;
    1.62 +
    1.63 +private:
    1.64 +  static bool sDBusIsInit;
    1.65 +};
    1.66 +
    1.67 +}
    1.68 +}
    1.69 +
    1.70 +#endif

mercurial