Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | /* |
michael@0 | 4 | ** Copyright 2006, The Android Open Source Project |
michael@0 | 5 | ** |
michael@0 | 6 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 7 | ** you may not use this file except in compliance with the License. |
michael@0 | 8 | ** You may obtain a copy of the License at |
michael@0 | 9 | ** |
michael@0 | 10 | ** http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 11 | ** |
michael@0 | 12 | ** Unless required by applicable law or agreed to in writing, software |
michael@0 | 13 | ** distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 15 | ** See the License for the specific language governing permissions and |
michael@0 | 16 | ** limitations under the License. |
michael@0 | 17 | */ |
michael@0 | 18 | |
michael@0 | 19 | #ifndef mozilla_ipc_dbus_dbusutils_h__ |
michael@0 | 20 | #define mozilla_ipc_dbus_dbusutils_h__ |
michael@0 | 21 | |
michael@0 | 22 | #include "mozilla/RefPtr.h" |
michael@0 | 23 | |
michael@0 | 24 | // LOGE and free a D-Bus error |
michael@0 | 25 | // Using #define so that __FUNCTION__ resolves usefully |
michael@0 | 26 | #define LOG_AND_FREE_DBUS_ERROR_WITH_MSG(err, msg) log_and_free_dbus_error(err, __FUNCTION__, msg); |
michael@0 | 27 | #define LOG_AND_FREE_DBUS_ERROR(err) log_and_free_dbus_error(err, __FUNCTION__); |
michael@0 | 28 | |
michael@0 | 29 | struct DBusError; |
michael@0 | 30 | struct DBusMessage; |
michael@0 | 31 | |
michael@0 | 32 | namespace mozilla { |
michael@0 | 33 | namespace ipc { |
michael@0 | 34 | |
michael@0 | 35 | class DBusMessageRefPtr |
michael@0 | 36 | { |
michael@0 | 37 | public: |
michael@0 | 38 | DBusMessageRefPtr(DBusMessage* aMsg); |
michael@0 | 39 | ~DBusMessageRefPtr(); |
michael@0 | 40 | |
michael@0 | 41 | operator DBusMessage* () |
michael@0 | 42 | { |
michael@0 | 43 | return mMsg; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | DBusMessage* get() |
michael@0 | 47 | { |
michael@0 | 48 | return mMsg; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | private: |
michael@0 | 52 | DBusMessage* mMsg; |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | /** |
michael@0 | 56 | * DBusReplyHandler represents a handler for DBus reply messages. Inherit |
michael@0 | 57 | * from this class and implement the Handle method. The method Callback |
michael@0 | 58 | * should be passed to the DBus send function, with the class instance as |
michael@0 | 59 | * user-data argument. |
michael@0 | 60 | */ |
michael@0 | 61 | class DBusReplyHandler |
michael@0 | 62 | { |
michael@0 | 63 | public: |
michael@0 | 64 | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DBusReplyHandler) |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Implements a call-back function for DBus. The supplied value for |
michael@0 | 68 | * aData must be a pointer to an instance of DBusReplyHandler. |
michael@0 | 69 | */ |
michael@0 | 70 | static void Callback(DBusMessage* aReply, void* aData); |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Call-back method for handling the reply message from DBus. |
michael@0 | 74 | */ |
michael@0 | 75 | virtual void Handle(DBusMessage* aReply) = 0; |
michael@0 | 76 | |
michael@0 | 77 | protected: |
michael@0 | 78 | DBusReplyHandler() |
michael@0 | 79 | { |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | DBusReplyHandler(const DBusReplyHandler& aHandler) |
michael@0 | 83 | { |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | DBusReplyHandler& operator = (const DBusReplyHandler& aRhs) |
michael@0 | 87 | { |
michael@0 | 88 | return *this; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | virtual ~DBusReplyHandler() |
michael@0 | 92 | { |
michael@0 | 93 | } |
michael@0 | 94 | }; |
michael@0 | 95 | |
michael@0 | 96 | void log_and_free_dbus_error(DBusError* err, |
michael@0 | 97 | const char* function, |
michael@0 | 98 | DBusMessage* msg = nullptr); |
michael@0 | 99 | |
michael@0 | 100 | int dbus_returns_int32(DBusMessage *reply); |
michael@0 | 101 | |
michael@0 | 102 | } |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | #endif |
michael@0 | 106 |