1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #3027 - completely remove all remaining usages of dbus-glib from our tree

This commit is contained in:
Basilisk-Dev
2026-04-07 15:26:28 -04:00
committed by roytam1
parent 3836a57d47
commit 1d0967ab3c
31 changed files with 10 additions and 976 deletions
-2
View File
@@ -335,8 +335,6 @@ curses.h
cxxabi.h
DateTimeUtils.h
dbus/dbus.h
dbus/dbus-glib.h
dbus/dbus-glib-lowlevel.h
ddeml.h
Debug.h
dem.h
-2
View File
@@ -77,6 +77,4 @@ if CONFIG['MOZ_GAMEPAD']:
]
CFLAGS += CONFIG['GLIB_CFLAGS']
CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
CXXFLAGS += CONFIG['GLIB_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
-2
View File
@@ -99,6 +99,4 @@ if CONFIG['MOZ_GAMEPAD']:
]
CFLAGS += CONFIG['GLIB_CFLAGS']
CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
CXXFLAGS += CONFIG['GLIB_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
-2
View File
@@ -27,6 +27,4 @@ FINAL_LIBRARY = 'xul'
if CONFIG['MOZ_ENABLE_DBUS']:
CFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
CFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
@@ -58,7 +58,7 @@ chromeos_dev_list="libbluetooth-dev libpulse-dev"
# Packages need for development
dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
libcairo2-dev libcups2-dev libcurl4-gnutls-dev libdbus-glib-1-dev
libcairo2-dev libcups2-dev libcurl4-gnutls-dev
libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev
libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev
libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libsctp-dev
@@ -80,7 +80,7 @@ fi
chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
# Full list of required run-time libraries
lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libdbus-glib-1-2
lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2
libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
libgtk2.0-0 libpam0g libpango1.0-0 libpcre3 libpixman-1-0
libpng12-0 libstdc++6 libsqlite3-0 libudev0 libx11-6 libxau6 libxcb1
@@ -89,7 +89,7 @@ lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libdbus-glib-1-2
$chromeos_lib_list"
# Debugging symbols for all of the run-time libraries
dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libdbus-glib-1-2-dbg
dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg
libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg
libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg
libsqlite3-0-dbg
-21
View File
@@ -112,27 +112,6 @@
],
},
], # targets
}, { # chromeos==1
'targets': [
{
# TODO(satorux): Remove this once dbus-glib clients are gone.
'target_name': 'dbus-glib',
'type': 'none',
'direct_dependent_settings': {
'cflags': [
'<!@(<(pkg-config) --cflags dbus-glib-1)',
],
},
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other dbus-glib-1)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l dbus-glib-1)',
],
},
},
],
}]
], # conditions
'targets': [
-15
View File
@@ -61,12 +61,6 @@ config("common_inherited_config") {
}
}
if (rtc_have_dbus_glib) {
pkg_config("dbus-glib") {
packages = [ "dbus-glib-1" ]
}
}
config("common_config") {
cflags = []
cflags_cc = []
@@ -74,15 +68,6 @@ config("common_config") {
defines = [ "WEBRTC_RESTRICT_LOGGING" ]
}
if (rtc_have_dbus_glib) {
defines += [ "HAVE_DBUS_GLIB" ]
# TODO(kjellander): Investigate this, it seems like include <dbus/dbus.h>
# is still not found even if the execution of
# build/config/linux/pkg-config.py dbus-glib-1 returns correct include
# dirs on Linux.
all_dependent_configs = [ "dbus-glib" ]
}
if (build_with_chromium) {
defines += [ "LOGGING_INSIDE_WEBRTC" ]
} else {
-4
View File
@@ -403,10 +403,6 @@ static_library("rtc_base") {
if (is_linux) {
sources += [
"dbus.cc",
"dbus.h",
"libdbusglibsymboltable.cc",
"libdbusglibsymboltable.h",
"linuxfdwalk.c",
"linuxfdwalk.h",
]
-12
View File
@@ -137,8 +137,6 @@
'criticalsection.h',
'cryptstring.cc',
'cryptstring.h',
'dbus.cc',
'dbus.h',
'diskcache.cc',
'diskcache.h',
'diskcache_win32.cc',
@@ -178,8 +176,6 @@
# 'latebindingsymboltable.cc.def',
'latebindingsymboltable.h',
# 'latebindingsymboltable.h.def',
'libdbusglibsymboltable.cc',
'libdbusglibsymboltable.h',
'linux.cc',
'linux.h',
'linuxfdwalk.c',
@@ -389,8 +385,6 @@
'callback.h',
# 'callback.h.pump',
'constructormagic.h',
'dbus.cc',
'dbus.h',
'diskcache_win32.cc',
'diskcache_win32.h',
'filelock.cc',
@@ -406,8 +400,6 @@
# 'latebindingsymboltable.cc.def',
'latebindingsymboltable.h',
# 'latebindingsymboltable.h.def',
'libdbusglibsymboltable.cc',
'libdbusglibsymboltable.h',
'linuxfdwalk.c',
'linuxfdwalk.h',
'x11windowpicker.cc',
@@ -634,10 +626,6 @@
},
}, {
'sources!': [
'dbus.cc',
'dbus.h',
'libdbusglibsymboltable.cc',
'libdbusglibsymboltable.h',
'linuxfdwalk.c',
],
}],
-400
View File
@@ -1,400 +0,0 @@
/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifdef HAVE_DBUS_GLIB
#include "webrtc/base/dbus.h"
#include <glib.h>
#include "webrtc/base/logging.h"
#include "webrtc/base/thread.h"
namespace rtc {
// Avoid static object construction/destruction on startup/shutdown.
static pthread_once_t g_dbus_init_once = PTHREAD_ONCE_INIT;
static LibDBusGlibSymbolTable *g_dbus_symbol = NULL;
// Releases DBus-Glib symbols.
static void ReleaseDBusGlibSymbol() {
if (g_dbus_symbol != NULL) {
delete g_dbus_symbol;
g_dbus_symbol = NULL;
}
}
// Loads DBus-Glib symbols.
static void InitializeDBusGlibSymbol() {
// This is thread safe.
if (NULL == g_dbus_symbol) {
g_dbus_symbol = new LibDBusGlibSymbolTable();
// Loads dbus-glib
if (NULL == g_dbus_symbol || !g_dbus_symbol->Load()) {
LOG(LS_WARNING) << "Failed to load dbus-glib symbol table.";
ReleaseDBusGlibSymbol();
} else {
// Nothing we can do if atexit() failed. Just ignore its returned value.
atexit(ReleaseDBusGlibSymbol);
}
}
}
inline static LibDBusGlibSymbolTable *GetSymbols() {
return DBusMonitor::GetDBusGlibSymbolTable();
}
// Implementation of class DBusSigMessageData
DBusSigMessageData::DBusSigMessageData(DBusMessage *message)
: TypedMessageData<DBusMessage *>(message) {
GetSymbols()->dbus_message_ref()(data());
}
DBusSigMessageData::~DBusSigMessageData() {
GetSymbols()->dbus_message_unref()(data());
}
// Implementation of class DBusSigFilter
// Builds a DBus filter string from given DBus path, interface and member.
std::string DBusSigFilter::BuildFilterString(const std::string &path,
const std::string &interface,
const std::string &member) {
std::string ret(DBUS_TYPE "='" DBUS_SIGNAL "'");
if (!path.empty()) {
ret += ("," DBUS_PATH "='");
ret += path;
ret += "'";
}
if (!interface.empty()) {
ret += ("," DBUS_INTERFACE "='");
ret += interface;
ret += "'";
}
if (!member.empty()) {
ret += ("," DBUS_MEMBER "='");
ret += member;
ret += "'";
}
return ret;
}
// Forwards the message to the given instance.
DBusHandlerResult DBusSigFilter::DBusCallback(DBusConnection *dbus_conn,
DBusMessage *message,
void *instance) {
ASSERT(instance);
if (instance) {
return static_cast<DBusSigFilter *>(instance)->Callback(message);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
// Posts a message to caller thread.
DBusHandlerResult DBusSigFilter::Callback(DBusMessage *message) {
if (caller_thread_) {
caller_thread_->Post(this, DSM_SIGNAL, new DBusSigMessageData(message));
}
// Don't "eat" the message here. Let it pop up.
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
// From MessageHandler.
void DBusSigFilter::OnMessage(Message *message) {
if (message != NULL && DSM_SIGNAL == message->message_id) {
DBusSigMessageData *msg =
static_cast<DBusSigMessageData *>(message->pdata);
if (msg) {
ProcessSignal(msg->data());
delete msg;
}
}
}
// Definition of private class DBusMonitoringThread.
// It creates a worker-thread to listen signals on DBus. The worker-thread will
// be running in a priate GMainLoop forever until either Stop() has been invoked
// or it hits an error.
class DBusMonitor::DBusMonitoringThread : public rtc::Thread {
public:
explicit DBusMonitoringThread(DBusMonitor *monitor,
GMainContext *context,
GMainLoop *mainloop,
std::vector<DBusSigFilter *> *filter_list)
: monitor_(monitor),
context_(context),
mainloop_(mainloop),
connection_(NULL),
idle_source_(NULL),
filter_list_(filter_list) {
ASSERT(monitor_);
ASSERT(context_);
ASSERT(mainloop_);
ASSERT(filter_list_);
}
virtual ~DBusMonitoringThread() {
Stop();
}
// Override virtual method of Thread. Context: worker-thread.
virtual void Run() {
ASSERT(NULL == connection_);
// Setup DBus connection and start monitoring.
monitor_->OnMonitoringStatusChanged(DMS_INITIALIZING);
if (!Setup()) {
LOG(LS_ERROR) << "DBus monitoring setup failed.";
monitor_->OnMonitoringStatusChanged(DMS_FAILED);
CleanUp();
return;
}
monitor_->OnMonitoringStatusChanged(DMS_RUNNING);
g_main_loop_run(mainloop_);
monitor_->OnMonitoringStatusChanged(DMS_STOPPED);
// Done normally. Clean up DBus connection.
CleanUp();
return;
}
// Override virtual method of Thread. Context: caller-thread.
virtual void Stop() {
ASSERT(NULL == idle_source_);
// Add an idle source and let the gmainloop quit on idle.
idle_source_ = g_idle_source_new();
if (idle_source_) {
g_source_set_callback(idle_source_, &Idle, this, NULL);
g_source_attach(idle_source_, context_);
} else {
LOG(LS_ERROR) << "g_idle_source_new() failed.";
QuitGMainloop(); // Try to quit anyway.
}
Thread::Stop(); // Wait for the thread.
}
private:
// Registers all DBus filters.
void RegisterAllFilters() {
ASSERT(NULL != GetSymbols()->dbus_g_connection_get_connection()(
connection_));
for (std::vector<DBusSigFilter *>::iterator it = filter_list_->begin();
it != filter_list_->end(); ++it) {
DBusSigFilter *filter = (*it);
if (!filter) {
LOG(LS_ERROR) << "DBusSigFilter list corrupted.";
continue;
}
GetSymbols()->dbus_bus_add_match()(
GetSymbols()->dbus_g_connection_get_connection()(connection_),
filter->filter().c_str(), NULL);
if (!GetSymbols()->dbus_connection_add_filter()(
GetSymbols()->dbus_g_connection_get_connection()(connection_),
&DBusSigFilter::DBusCallback, filter, NULL)) {
LOG(LS_ERROR) << "dbus_connection_add_filter() failed."
<< "Filter: " << filter->filter();
continue;
}
}
}
// Unregisters all DBus filters.
void UnRegisterAllFilters() {
ASSERT(NULL != GetSymbols()->dbus_g_connection_get_connection()(
connection_));
for (std::vector<DBusSigFilter *>::iterator it = filter_list_->begin();
it != filter_list_->end(); ++it) {
DBusSigFilter *filter = (*it);
if (!filter) {
LOG(LS_ERROR) << "DBusSigFilter list corrupted.";
continue;
}
GetSymbols()->dbus_connection_remove_filter()(
GetSymbols()->dbus_g_connection_get_connection()(connection_),
&DBusSigFilter::DBusCallback, filter);
}
}
// Sets up the monitoring thread.
bool Setup() {
g_main_context_push_thread_default(context_);
// Start connection to dbus.
// If dbus daemon is not running, returns false immediately.
connection_ = GetSymbols()->dbus_g_bus_get_private()(monitor_->type_,
context_, NULL);
if (NULL == connection_) {
LOG(LS_ERROR) << "dbus_g_bus_get_private() unable to get connection.";
return false;
}
if (NULL == GetSymbols()->dbus_g_connection_get_connection()(connection_)) {
LOG(LS_ERROR) << "dbus_g_connection_get_connection() returns NULL. "
<< "DBus daemon is probably not running.";
return false;
}
// Application don't exit if DBus daemon die.
GetSymbols()->dbus_connection_set_exit_on_disconnect()(
GetSymbols()->dbus_g_connection_get_connection()(connection_), FALSE);
// Connect all filters.
RegisterAllFilters();
return true;
}
// Cleans up the monitoring thread.
void CleanUp() {
if (idle_source_) {
// We did an attach() with the GSource, so we need to destroy() it.
g_source_destroy(idle_source_);
// We need to unref() the GSource to end the last reference we got.
g_source_unref(idle_source_);
idle_source_ = NULL;
}
if (connection_) {
if (GetSymbols()->dbus_g_connection_get_connection()(connection_)) {
UnRegisterAllFilters();
GetSymbols()->dbus_connection_close()(
GetSymbols()->dbus_g_connection_get_connection()(connection_));
}
GetSymbols()->dbus_g_connection_unref()(connection_);
connection_ = NULL;
}
g_main_loop_unref(mainloop_);
mainloop_ = NULL;
g_main_context_unref(context_);
context_ = NULL;
}
// Handles callback on Idle. We only add this source when ready to stop.
static gboolean Idle(gpointer data) {
static_cast<DBusMonitoringThread *>(data)->QuitGMainloop();
return TRUE;
}
// We only hit this when ready to quit.
void QuitGMainloop() {
g_main_loop_quit(mainloop_);
}
DBusMonitor *monitor_;
GMainContext *context_;
GMainLoop *mainloop_;
DBusGConnection *connection_;
GSource *idle_source_;
std::vector<DBusSigFilter *> *filter_list_;
};
// Implementation of class DBusMonitor
// Returns DBus-Glib symbol handle. Initialize it first if hasn't.
LibDBusGlibSymbolTable *DBusMonitor::GetDBusGlibSymbolTable() {
// This is multi-thread safe.
pthread_once(&g_dbus_init_once, InitializeDBusGlibSymbol);
return g_dbus_symbol;
};
// Creates an instance of DBusMonitor
DBusMonitor *DBusMonitor::Create(DBusBusType type) {
if (NULL == DBusMonitor::GetDBusGlibSymbolTable()) {
return NULL;
}
return new DBusMonitor(type);
}
DBusMonitor::DBusMonitor(DBusBusType type)
: type_(type),
status_(DMS_NOT_INITIALIZED),
monitoring_thread_(NULL) {
ASSERT(type_ == DBUS_BUS_SYSTEM || type_ == DBUS_BUS_SESSION);
}
DBusMonitor::~DBusMonitor() {
StopMonitoring();
}
bool DBusMonitor::AddFilter(DBusSigFilter *filter) {
if (monitoring_thread_) {
return false;
}
if (!filter) {
return false;
}
filter_list_.push_back(filter);
return true;
}
bool DBusMonitor::StartMonitoring() {
if (!monitoring_thread_) {
g_type_init();
// g_thread_init API is deprecated since glib 2.31.0, see release note:
// http://mail.gnome.org/archives/gnome-announce-list/2011-October/msg00041.html
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#endif
GetSymbols()->dbus_g_thread_init()();
GMainContext *context = g_main_context_new();
if (NULL == context) {
LOG(LS_ERROR) << "g_main_context_new() failed.";
return false;
}
GMainLoop *mainloop = g_main_loop_new(context, FALSE);
if (NULL == mainloop) {
LOG(LS_ERROR) << "g_main_loop_new() failed.";
g_main_context_unref(context);
return false;
}
monitoring_thread_ = new DBusMonitoringThread(this, context, mainloop,
&filter_list_);
if (monitoring_thread_ == NULL) {
LOG(LS_ERROR) << "Failed to create DBus monitoring thread.";
g_main_context_unref(context);
g_main_loop_unref(mainloop);
return false;
}
monitoring_thread_->Start();
}
return true;
}
bool DBusMonitor::StopMonitoring() {
if (monitoring_thread_) {
monitoring_thread_->Stop();
monitoring_thread_ = NULL;
}
return true;
}
DBusMonitor::DBusMonitorStatus DBusMonitor::GetStatus() {
return status_;
}
void DBusMonitor::OnMonitoringStatusChanged(DBusMonitorStatus status) {
status_ = status;
}
#undef LATE
} // namespace rtc
#endif // HAVE_DBUS_GLIB
-168
View File
@@ -1,168 +0,0 @@
/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_BASE_DBUS_H_
#define WEBRTC_BASE_DBUS_H_
#ifdef HAVE_DBUS_GLIB
#include <dbus/dbus.h>
#include <string>
#include <vector>
#include "webrtc/base/libdbusglibsymboltable.h"
#include "webrtc/base/messagehandler.h"
#include "webrtc/base/thread.h"
namespace rtc {
#define DBUS_TYPE "type"
#define DBUS_SIGNAL "signal"
#define DBUS_PATH "path"
#define DBUS_INTERFACE "interface"
#define DBUS_MEMBER "member"
#ifdef CHROMEOS
#define CROS_PM_PATH "/"
#define CROS_PM_INTERFACE "org.chromium.PowerManager"
#define CROS_SIG_POWERCHANGED "PowerStateChanged"
#define CROS_VALUE_SLEEP "mem"
#define CROS_VALUE_RESUME "on"
#else
#define UP_PATH "/org/freedesktop/UPower"
#define UP_INTERFACE "org.freedesktop.UPower"
#define UP_SIG_SLEEPING "Sleeping"
#define UP_SIG_RESUMING "Resuming"
#endif // CHROMEOS
// Wraps a DBus messages.
class DBusSigMessageData : public TypedMessageData<DBusMessage *> {
public:
explicit DBusSigMessageData(DBusMessage *message);
~DBusSigMessageData();
};
// DBusSigFilter is an abstract class that defines the interface of DBus
// signal handling.
// The subclasses implement ProcessSignal() for various purposes.
// When a DBus signal comes, a DSM_SIGNAL message is posted to the caller thread
// which will then invokes ProcessSignal().
class DBusSigFilter : protected MessageHandler {
public:
enum DBusSigMessage { DSM_SIGNAL };
// This filter string should ususally come from BuildFilterString()
explicit DBusSigFilter(const std::string &filter)
: caller_thread_(Thread::Current()), filter_(filter) {
}
// Builds a DBus monitor filter string from given DBus path, interface, and
// member.
// See http://dbus.freedesktop.org/doc/api/html/group__DBusConnection.html
static std::string BuildFilterString(const std::string &path,
const std::string &interface,
const std::string &member);
// Handles callback on DBus messages by DBus system.
static DBusHandlerResult DBusCallback(DBusConnection *dbus_conn,
DBusMessage *message,
void *instance);
// Handles callback on DBus messages to each DBusSigFilter instance.
DBusHandlerResult Callback(DBusMessage *message);
// From MessageHandler.
virtual void OnMessage(Message *message);
// Returns the DBus monitor filter string.
const std::string &filter() const { return filter_; }
private:
// On caller thread.
virtual void ProcessSignal(DBusMessage *message) = 0;
Thread *caller_thread_;
const std::string filter_;
};
// DBusMonitor is a class for DBus signal monitoring.
//
// The caller-thread calls AddFilter() first to add the signals that it wants to
// monitor and then calls StartMonitoring() to start the monitoring.
// This will create a worker-thread which listens on DBus connection and sends
// DBus signals back through the callback.
// The worker-thread will be running forever until either StopMonitoring() is
// called from the caller-thread or the worker-thread hit some error.
//
// Programming model:
// 1. Caller-thread: Creates an object of DBusMonitor.
// 2. Caller-thread: Calls DBusMonitor::AddFilter() one or several times.
// 3. Caller-thread: StartMonitoring().
// ...
// 4. Worker-thread: DBus signal recieved. Post a message to caller-thread.
// 5. Caller-thread: DBusFilterBase::ProcessSignal() is invoked.
// ...
// 6. Caller-thread: StopMonitoring().
//
// Assumption:
// AddFilter(), StartMonitoring(), and StopMonitoring() methods are called by
// a single thread. Hence, there is no need to make them thread safe.
class DBusMonitor {
public:
// Status of DBus monitoring.
enum DBusMonitorStatus {
DMS_NOT_INITIALIZED, // Not initialized.
DMS_INITIALIZING, // Initializing the monitoring thread.
DMS_RUNNING, // Monitoring.
DMS_STOPPED, // Not monitoring. Stopped normally.
DMS_FAILED, // Not monitoring. Failed.
};
// Returns the DBus-Glib symbol table.
// We should only use this function to access DBus-Glib symbols.
static LibDBusGlibSymbolTable *GetDBusGlibSymbolTable();
// Creates an instance of DBusMonitor.
static DBusMonitor *Create(DBusBusType type);
~DBusMonitor();
// Adds a filter to DBusMonitor.
bool AddFilter(DBusSigFilter *filter);
// Starts DBus message monitoring.
bool StartMonitoring();
// Stops DBus message monitoring.
bool StopMonitoring();
// Gets the status of DBus monitoring.
DBusMonitorStatus GetStatus();
private:
// Forward declaration. Defined in the .cc file.
class DBusMonitoringThread;
explicit DBusMonitor(DBusBusType type);
// Updates status_ when monitoring status has changed.
void OnMonitoringStatusChanged(DBusMonitorStatus status);
DBusBusType type_;
DBusMonitorStatus status_;
DBusMonitoringThread *monitoring_thread_;
std::vector<DBusSigFilter *> filter_list_;
};
} // namespace rtc
#endif // HAVE_DBUS_GLIB
#endif // WEBRTC_BASE_DBUS_H_
@@ -1,232 +0,0 @@
/*
* Copyright 2011 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifdef HAVE_DBUS_GLIB
#include "webrtc/base/dbus.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/thread.h"
namespace rtc {
#define SIG_NAME "NameAcquired"
static const uint32 kTimeoutMs = 5000U;
class DBusSigFilterTest : public DBusSigFilter {
public:
// DBusSigFilterTest listens on DBus service itself for "NameAcquired" signal.
// This signal should be received when the application connects to DBus
// service and gains ownership of a name.
// http://dbus.freedesktop.org/doc/dbus-specification.html
DBusSigFilterTest()
: DBusSigFilter(GetFilter()),
message_received_(false) {
}
bool MessageReceived() {
return message_received_;
}
private:
static std::string GetFilter() {
return rtc::DBusSigFilter::BuildFilterString("", "", SIG_NAME);
}
// Implement virtual method of DBusSigFilter. On caller thread.
virtual void ProcessSignal(DBusMessage *message) {
EXPECT_TRUE(message != NULL);
message_received_ = true;
}
bool message_received_;
};
TEST(DBusMonitorTest, StartStopStartStop) {
DBusSigFilterTest filter;
rtc::scoped_ptr<rtc::DBusMonitor> monitor;
monitor.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor) {
EXPECT_TRUE(monitor->AddFilter(&filter));
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_NOT_INITIALIZED);
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_RUNNING);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
} else {
LOG(LS_WARNING) << "DBus Monitor not started. Skipping test.";
}
}
// DBusMonitorTest listens on DBus service itself for "NameAcquired" signal.
// This signal should be received when the application connects to DBus
// service and gains ownership of a name.
// This test is to make sure that we capture the "NameAcquired" signal.
TEST(DBusMonitorTest, ReceivedNameAcquiredSignal) {
DBusSigFilterTest filter;
rtc::scoped_ptr<rtc::DBusMonitor> monitor;
monitor.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor) {
EXPECT_TRUE(monitor->AddFilter(&filter));
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter.MessageReceived(), kTimeoutMs);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
} else {
LOG(LS_WARNING) << "DBus Monitor not started. Skipping test.";
}
}
TEST(DBusMonitorTest, ConcurrentMonitors) {
DBusSigFilterTest filter1;
rtc::scoped_ptr<rtc::DBusMonitor> monitor1;
monitor1.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor1) {
EXPECT_TRUE(monitor1->AddFilter(&filter1));
DBusSigFilterTest filter2;
rtc::scoped_ptr<rtc::DBusMonitor> monitor2;
monitor2.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
EXPECT_TRUE(monitor2->AddFilter(&filter2));
EXPECT_TRUE(monitor1->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor1->GetStatus(), kTimeoutMs);
EXPECT_TRUE(monitor2->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor2->GetStatus(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter2.MessageReceived(), kTimeoutMs);
EXPECT_TRUE(monitor2->StopMonitoring());
EXPECT_EQ(monitor2->GetStatus(), DBusMonitor::DMS_STOPPED);
EXPECT_TRUE_WAIT(filter1.MessageReceived(), kTimeoutMs);
EXPECT_TRUE(monitor1->StopMonitoring());
EXPECT_EQ(monitor1->GetStatus(), DBusMonitor::DMS_STOPPED);
} else {
LOG(LS_WARNING) << "DBus Monitor not started. Skipping test.";
}
}
TEST(DBusMonitorTest, ConcurrentFilters) {
DBusSigFilterTest filter1;
DBusSigFilterTest filter2;
rtc::scoped_ptr<rtc::DBusMonitor> monitor;
monitor.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor) {
EXPECT_TRUE(monitor->AddFilter(&filter1));
EXPECT_TRUE(monitor->AddFilter(&filter2));
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter1.MessageReceived(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter2.MessageReceived(), kTimeoutMs);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
} else {
LOG(LS_WARNING) << "DBus Monitor not started. Skipping test.";
}
}
TEST(DBusMonitorTest, NoAddFilterIfRunning) {
DBusSigFilterTest filter1;
DBusSigFilterTest filter2;
rtc::scoped_ptr<rtc::DBusMonitor> monitor;
monitor.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor) {
EXPECT_TRUE(monitor->AddFilter(&filter1));
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_FALSE(monitor->AddFilter(&filter2));
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
} else {
LOG(LS_WARNING) << "DBus Monitor not started. Skipping test.";
}
}
TEST(DBusMonitorTest, AddFilterAfterStop) {
DBusSigFilterTest filter1;
DBusSigFilterTest filter2;
rtc::scoped_ptr<rtc::DBusMonitor> monitor;
monitor.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor) {
EXPECT_TRUE(monitor->AddFilter(&filter1));
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter1.MessageReceived(), kTimeoutMs);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
EXPECT_TRUE(monitor->AddFilter(&filter2));
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_EQ_WAIT(DBusMonitor::DMS_RUNNING, monitor->GetStatus(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter1.MessageReceived(), kTimeoutMs);
EXPECT_TRUE_WAIT(filter2.MessageReceived(), kTimeoutMs);
EXPECT_TRUE(monitor->StopMonitoring());
EXPECT_EQ(monitor->GetStatus(), DBusMonitor::DMS_STOPPED);
} else {
LOG(LS_WARNING) << "DBus Monitor not started. Skipping test.";
}
}
TEST(DBusMonitorTest, StopRightAfterStart) {
DBusSigFilterTest filter;
rtc::scoped_ptr<rtc::DBusMonitor> monitor;
monitor.reset(rtc::DBusMonitor::Create(DBUS_BUS_SYSTEM));
if (monitor) {
EXPECT_TRUE(monitor->AddFilter(&filter));
EXPECT_TRUE(monitor->StartMonitoring());
EXPECT_TRUE(monitor->StopMonitoring());
// Stop the monitoring thread right after it had been started.
// If the monitoring thread got a chance to receive a DBus signal, it would
// post a message to the main thread and signal the main thread wakeup.
// This message will be cleaned out automatically when the filter get
// destructed. Here we also consume the wakeup signal (if there is one) so
// that the testing (main) thread is reset to a clean state.
rtc::Thread::Current()->ProcessMessages(1);
} else {
LOG(LS_WARNING) << "DBus Monitor not started.";
}
}
TEST(DBusSigFilter, BuildFilterString) {
EXPECT_EQ(DBusSigFilter::BuildFilterString("", "", ""),
(DBUS_TYPE "='" DBUS_SIGNAL "'"));
EXPECT_EQ(DBusSigFilter::BuildFilterString("p", "", ""),
(DBUS_TYPE "='" DBUS_SIGNAL "'," DBUS_PATH "='p'"));
EXPECT_EQ(DBusSigFilter::BuildFilterString("p","i", ""),
(DBUS_TYPE "='" DBUS_SIGNAL "'," DBUS_PATH "='p',"
DBUS_INTERFACE "='i'"));
EXPECT_EQ(DBusSigFilter::BuildFilterString("p","i","m"),
(DBUS_TYPE "='" DBUS_SIGNAL "'," DBUS_PATH "='p',"
DBUS_INTERFACE "='i'," DBUS_MEMBER "='m'"));
}
} // namespace rtc
#endif // HAVE_DBUS_GLIB
@@ -1,24 +0,0 @@
/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifdef HAVE_DBUS_GLIB
#include "webrtc/base/libdbusglibsymboltable.h"
namespace rtc {
#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBDBUS_GLIB_CLASS_NAME
#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBDBUS_GLIB_SYMBOLS_LIST
#define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libdbus-glib-1.so.2"
#include "webrtc/base/latebindingsymboltable.cc.def"
} // namespace rtc
#endif // HAVE_DBUS_GLIB
@@ -1,56 +0,0 @@
/*
* Copyright 2004 The WebRTC Project Authors. All rights reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_BASE_LIBDBUSGLIBSYMBOLTABLE_H_
#define WEBRTC_BASE_LIBDBUSGLIBSYMBOLTABLE_H_
#ifdef HAVE_DBUS_GLIB
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include "webrtc/base/latebindingsymboltable.h"
namespace rtc {
#define LIBDBUS_GLIB_CLASS_NAME LibDBusGlibSymbolTable
// The libdbus-glib symbols we need, as an X-Macro list.
// This list must contain precisely every libdbus-glib function that is used in
// dbus.cc.
#define LIBDBUS_GLIB_SYMBOLS_LIST \
X(dbus_bus_add_match) \
X(dbus_connection_add_filter) \
X(dbus_connection_close) \
X(dbus_connection_remove_filter) \
X(dbus_connection_set_exit_on_disconnect) \
X(dbus_g_bus_get) \
X(dbus_g_bus_get_private) \
X(dbus_g_connection_get_connection) \
X(dbus_g_connection_unref) \
X(dbus_g_thread_init) \
X(dbus_message_get_interface) \
X(dbus_message_get_member) \
X(dbus_message_get_path) \
X(dbus_message_get_type) \
X(dbus_message_iter_get_arg_type) \
X(dbus_message_iter_get_basic) \
X(dbus_message_iter_init) \
X(dbus_message_ref) \
X(dbus_message_unref)
#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBDBUS_GLIB_CLASS_NAME
#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBDBUS_GLIB_SYMBOLS_LIST
#include "webrtc/base/latebindingsymboltable.h.def"
} // namespace rtc
#endif // HAVE_DBUS_GLIB
#endif // WEBRTC_BASE_LIBDBUSGLIBSYMBOLTABLE_H_
@@ -107,9 +107,6 @@
'build_openmax_dl%': 1,
'build_opus%': 1,
# Disable by default
'have_dbus_glib%': 0,
# Enable to use the Mozilla internal settings.
'build_with_mozilla%': 0,
@@ -205,14 +202,6 @@
'WEBRTC_MOZILLA_BUILD',
],
}],
['have_dbus_glib==1', {
'defines': [
'HAVE_DBUS_GLIB',
],
'cflags': [
'<!@(pkg-config --cflags dbus-glib-1)',
],
}],
['rtc_relative_path==1', {
'defines': ['EXPAT_RELATIVE_PATH',],
}],
@@ -510,4 +499,3 @@
},
}, # target_defaults
}
@@ -45,9 +45,6 @@ declare_args() {
rtc_build_ssl = true
rtc_build_opus = true
# Disable by default.
rtc_have_dbus_glib = false
# Enable to use the Mozilla internal settings.
build_with_mozilla = false
+1 -1
View File
@@ -54,6 +54,6 @@ if CONFIG['NECKO_WIFI_DBUS']:
CXXFLAGS += ['-Wno-error=shadow']
if CONFIG['NECKO_WIFI_DBUS']:
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
FINAL_LIBRARY = 'xul'
-1
View File
@@ -2410,7 +2410,6 @@ then
if test "$MOZ_ENABLE_DBUS"
then
PKG_CHECK_MODULES(MOZ_DBUS, dbus-1 >= $DBUS_VERSION)
PKG_CHECK_MODULES(MOZ_DBUS_GLIB, dbus-glib-1 >= $DBUS_VERSION)
AC_DEFINE(MOZ_ENABLE_DBUS)
fi
fi
-1
View File
@@ -44,7 +44,6 @@ RUN apt-get update && apt-get install -y --force-yes \
libcanberra-pulse \
libcurl4-openssl-dev \
libdbus-1-dev \
libdbus-glib-1-dev \
libdrm-intel1:i386 \
libdrm-nouveau1a:i386 \
libdrm-radeon1:i386 \
@@ -50,10 +50,6 @@ install check-devel.i686
install check-devel.x86_64
install check.i686
install check.x86_64
install dbus-glib-devel.i686
install dbus-glib-devel.x86_64
install dbus-glib.i686
install dbus-glib.x86_64
install fontconfig-devel.i686
install fontconfig-devel.x86_64
install fontconfig.i686
@@ -29,7 +29,6 @@ parts:
source: source
stage-packages:
- libxt6
- libdbus-glib-1-2
- libasound2
- libpulse0
- libgl1-mesa-dri
@@ -44,7 +44,6 @@ apt_packages+=('libasound2-plugins:i386')
apt_packages+=('libcanberra-pulse')
apt_packages+=('libcurl4-openssl-dev')
apt_packages+=('libdbus-1-dev')
apt_packages+=('libdbus-glib-1-dev')
apt_packages+=('libdrm-intel1:i386')
apt_packages+=('libdrm-nouveau1a:i386')
apt_packages+=('libdrm-radeon1:i386')
@@ -37,7 +37,6 @@ apt_packages+=('libasound2-dev')
apt_packages+=('libcanberra-pulse')
apt_packages+=('libcurl4-openssl-dev')
apt_packages+=('libdbus-1-dev')
apt_packages+=('libdbus-glib-1-dev')
apt_packages+=('libgconf2-dev')
apt_packages+=('libgstreamer-plugins-base0.10-dev')
apt_packages+=('libgstreamer0.10-dev')
@@ -134,7 +134,7 @@ config = {
# -devel packages dependencies. So manually install the dependencies
# of the above packages.
'ORBit2-devel.i686', 'atk-devel.i686', 'cairo-devel.i686',
'check-devel.i686', 'dbus-devel.i686', 'dbus-glib-devel.i686',
'check-devel.i686', 'dbus-devel.i686',
'fontconfig-devel.i686', 'glib2-devel.i686',
'hal-devel.i686', 'libICE-devel.i686', 'libIDL-devel.i686',
'libSM-devel.i686', 'libXau-devel.i686', 'libXcomposite-devel.i686',
@@ -90,7 +90,7 @@ config = {
# -devel packages dependencies. So manually install the dependencies
# of the above packages.
'ORBit2-devel.i686', 'atk-devel.i686', 'cairo-devel.i686',
'check-devel.i686', 'dbus-devel.i686', 'dbus-glib-devel.i686',
'check-devel.i686', 'dbus-devel.i686',
'fontconfig-devel.i686', 'glib2-devel.i686',
'hal-devel.i686', 'libICE-devel.i686', 'libIDL-devel.i686',
'libSM-devel.i686', 'libXau-devel.i686', 'libXcomposite-devel.i686',
@@ -96,7 +96,7 @@ config = {
# -devel packages dependencies. So manually install the dependencies
# of the above packages.
'ORBit2-devel.i686', 'atk-devel.i686', 'cairo-devel.i686',
'check-devel.i686', 'dbus-devel.i686', 'dbus-glib-devel.i686',
'check-devel.i686', 'dbus-devel.i686',
'fontconfig-devel.i686', 'glib2-devel.i686',
'hal-devel.i686', 'libICE-devel.i686', 'libIDL-devel.i686',
'libSM-devel.i686', 'libXau-devel.i686', 'libXcomposite-devel.i686',
+1 -1
View File
@@ -58,7 +58,7 @@ config = {
"gmp-devel", "nspr", "nspr-devel",
# For building the browser
"dbus-devel", "dbus-glib-devel", "hal-devel",
"dbus-devel", "hal-devel",
"libICE-devel", "libIDL-devel",
# For mach resource-usage
@@ -92,7 +92,7 @@ config = {
# -devel packages dependencies. So manually install the dependencies
# of the above packages.
'ORBit2-devel.i686', 'atk-devel.i686', 'cairo-devel.i686',
'check-devel.i686', 'dbus-devel.i686', 'dbus-glib-devel.i686',
'check-devel.i686', 'dbus-devel.i686',
'fontconfig-devel.i686', 'glib2-devel.i686',
'hal-devel.i686', 'libICE-devel.i686', 'libIDL-devel.i686',
'libSM-devel.i686', 'libXau-devel.i686', 'libXcomposite-devel.i686',
+1 -1
View File
@@ -218,7 +218,7 @@ if CONFIG['MOZ_SNDIO']:
]
if CONFIG['MOZ_ENABLE_DBUS']:
OS_LIBS += CONFIG['MOZ_DBUS_GLIB_LIBS']
OS_LIBS += CONFIG['MOZ_DBUS_LIBS']
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
-1
View File
@@ -134,7 +134,6 @@ if CONFIG['MOZ_ENABLE_XREMOTE']:
CXXFLAGS += CONFIG['TK_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
-1
View File
@@ -122,4 +122,3 @@ if CONFIG['MOZ_ENABLE_DBUS']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
CXXFLAGS += CONFIG['TK_CFLAGS']
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']