2012-05-08 01:50:25 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-21 07:21:24 +04:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-08 01:50:25 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "RawDBusConnection.h"
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
|
|
|
|
RawDBusConnection::RawDBusConnection() {
|
|
|
|
}
|
|
|
|
|
|
|
|
RawDBusConnection::~RawDBusConnection() {
|
|
|
|
}
|
|
|
|
|
2012-06-02 22:23:16 +04:00
|
|
|
nsresult RawDBusConnection::EstablishDBusConnection() {
|
2012-05-08 01:50:25 +04:00
|
|
|
DBusError err;
|
|
|
|
dbus_error_init(&err);
|
|
|
|
mConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
|
|
|
|
if (dbus_error_is_set(&err)) {
|
|
|
|
dbus_error_free(&err);
|
2012-06-02 22:23:16 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-05-08 01:50:25 +04:00
|
|
|
}
|
|
|
|
dbus_connection_set_exit_on_disconnect(mConnection, FALSE);
|
2012-06-02 22:23:16 +04:00
|
|
|
return NS_OK;
|
2012-05-08 01:50:25 +04:00
|
|
|
}
|
|
|
|
|
2012-06-02 22:23:16 +04:00
|
|
|
void RawDBusConnection::ScopedDBusConnectionPtrTraits::release(DBusConnection* ptr)
|
|
|
|
{
|
2012-07-18 07:41:54 +04:00
|
|
|
if (ptr) dbus_connection_unref(ptr);
|
2012-06-02 22:23:16 +04:00
|
|
|
}
|