LCOV - code coverage report
Current view: top level - ipc/dbus - RawDBusConnection.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 41 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "RawDBusConnection.h"
       8             : #include "base/message_loop.h"
       9             : #include "mozilla/ipc/DBusHelpers.h"
      10             : #include "mozilla/ipc/DBusWatcher.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace ipc {
      14             : 
      15             : //
      16             : // RawDBusConnection
      17             : //
      18             : 
      19             : bool RawDBusConnection::sDBusIsInit(false);
      20             : 
      21           0 : RawDBusConnection::RawDBusConnection()
      22             : {
      23           0 : }
      24             : 
      25           0 : RawDBusConnection::~RawDBusConnection()
      26             : {
      27           0 : }
      28             : 
      29           0 : nsresult RawDBusConnection::EstablishDBusConnection()
      30             : {
      31           0 :   if (!sDBusIsInit) {
      32           0 :     dbus_bool_t success = dbus_threads_init_default();
      33           0 :     NS_ENSURE_TRUE(success == TRUE, NS_ERROR_FAILURE);
      34           0 :     sDBusIsInit = true;
      35             :   }
      36             : 
      37             :   DBusError err;
      38           0 :   dbus_error_init(&err);
      39             : 
      40           0 :   mConnection = already_AddRefed<DBusConnection>(
      41           0 :     dbus_bus_get_private(DBUS_BUS_SYSTEM, &err));
      42             : 
      43           0 :   if (dbus_error_is_set(&err)) {
      44           0 :     dbus_error_free(&err);
      45           0 :     return NS_ERROR_FAILURE;
      46             :   }
      47             : 
      48           0 :   dbus_connection_set_exit_on_disconnect(mConnection, FALSE);
      49             : 
      50           0 :   return NS_OK;
      51             : }
      52             : 
      53           0 : bool RawDBusConnection::Watch()
      54             : {
      55           0 :   MOZ_ASSERT(MessageLoop::current());
      56             : 
      57           0 :   return NS_SUCCEEDED(DBusWatchConnection(mConnection));
      58             : }
      59             : 
      60           0 : bool RawDBusConnection::Send(DBusMessage* aMessage)
      61             : {
      62           0 :   MOZ_ASSERT(MessageLoop::current());
      63             : 
      64           0 :   auto rv = DBusSendMessage(mConnection, aMessage);
      65             : 
      66           0 :   if (NS_FAILED(rv)) {
      67           0 :     dbus_message_unref(aMessage);
      68           0 :     return false;
      69             :   }
      70             : 
      71           0 :   return true;
      72             : }
      73             : 
      74           0 : bool RawDBusConnection::SendWithReply(DBusReplyCallback aCallback,
      75             :                                       void* aData,
      76             :                                       int aTimeout,
      77             :                                       DBusMessage* aMessage)
      78             : {
      79           0 :   MOZ_ASSERT(MessageLoop::current());
      80             : 
      81           0 :   auto rv = DBusSendMessageWithReply(mConnection, aCallback, aData, aTimeout,
      82           0 :                                      aMessage);
      83           0 :   if (NS_FAILED(rv)) {
      84           0 :     return false;
      85             :   }
      86             : 
      87           0 :   dbus_message_unref(aMessage);
      88             : 
      89           0 :   return true;
      90             : }
      91             : 
      92           0 : bool RawDBusConnection::SendWithReply(DBusReplyCallback aCallback,
      93             :                                       void* aData,
      94             :                                       int aTimeout,
      95             :                                       const char* aDestination,
      96             :                                       const char* aPath,
      97             :                                       const char* aIntf,
      98             :                                       const char* aFunc,
      99             :                                       int aFirstArgType,
     100             :                                       ...)
     101             : {
     102             :   va_list args;
     103           0 :   va_start(args, aFirstArgType);
     104             : 
     105           0 :   auto rv = DBusSendMessageWithReply(mConnection, aCallback, aData,
     106             :                                      aTimeout, aDestination, aPath, aIntf,
     107           0 :                                      aFunc, aFirstArgType, args);
     108           0 :   va_end(args);
     109             : 
     110           0 :   return NS_SUCCEEDED(rv);
     111             : }
     112             : 
     113             : }
     114             : }

Generated by: LCOV version 1.13