mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 759883 - [b2g-bluetooth] Divide out bluetooth specifics from DBusThread object; r=echou
This commit is contained in:
parent
77643d12cf
commit
b4c6de65bf
@ -338,7 +338,9 @@ GetProperty(DBusMessageIter aIter, Properties* aPropertyTypes,
|
||||
// This happens when the array is 0-length. Apparently we get a
|
||||
// DBUS_TYPE_INVALID type.
|
||||
propertyValue = InfallibleTArray<nsString>();
|
||||
#ifdef DEBUG
|
||||
NS_WARNING("Received array type that's not a string array!");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -614,6 +616,22 @@ BluetoothDBusService::StartInternal()
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
DBusError err;
|
||||
dbus_error_init(&err);
|
||||
|
||||
// Set which messages will be processed by this dbus connection.
|
||||
// Since we are maintaining a single thread for all the DBus bluez
|
||||
// signals we want, register all of them in this thread at startup.
|
||||
// The event handler will sort the destinations out as needed.
|
||||
for (uint32_t i = 0; i < ArrayLength(sBluetoothDBusSignals); ++i) {
|
||||
dbus_bus_add_match(mConnection,
|
||||
sBluetoothDBusSignals[i],
|
||||
&err);
|
||||
if (dbus_error_is_set(&err)) {
|
||||
LOG_AND_FREE_DBUS_ERROR(&err);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a filter for all incoming messages_base
|
||||
if (!dbus_connection_add_filter(mConnection, EventFilter,
|
||||
NULL, NULL)) {
|
||||
@ -634,7 +652,20 @@ BluetoothDBusService::StopInternal()
|
||||
StopDBus();
|
||||
return NS_OK;
|
||||
}
|
||||
dbus_connection_remove_filter(mConnection, EventFilter, NULL);
|
||||
|
||||
DBusError err;
|
||||
dbus_error_init(&err);
|
||||
for (uint32_t i = 0; i < ArrayLength(sBluetoothDBusSignals); ++i) {
|
||||
dbus_bus_remove_match(mConnection,
|
||||
sBluetoothDBusSignals[i],
|
||||
&err);
|
||||
if (dbus_error_is_set(&err)) {
|
||||
LOG_AND_FREE_DBUS_ERROR(&err);
|
||||
}
|
||||
}
|
||||
|
||||
dbus_connection_remove_filter(mConnection, EventFilter, nullptr);
|
||||
|
||||
mConnection = nullptr;
|
||||
mBluetoothSignalObserverTable.Clear();
|
||||
StopDBus();
|
||||
|
@ -77,21 +77,6 @@ enum {
|
||||
DBUS_EVENT_LOOP_REMOVE = 3,
|
||||
} DBusEventTypes;
|
||||
|
||||
// Signals that the DBus thread should listen for. Needs to include
|
||||
// all signals any DBus observer object may need.
|
||||
|
||||
static const char* DBUS_SIGNALS[] =
|
||||
{
|
||||
"type='signal',interface='org.bluez.Adapter'",
|
||||
"type='signal',interface='org.bluez.Manager'",
|
||||
"type='signal',interface='org.bluez.Device'",
|
||||
"type='signal',interface='org.bluez.Input'",
|
||||
"type='signal',interface='org.bluez.Network'",
|
||||
"type='signal',interface='org.bluez.NetworkServer'",
|
||||
"type='signal',interface='org.bluez.HealthDevice'",
|
||||
"type='signal',interface='org.bluez.AudioSink'"
|
||||
};
|
||||
|
||||
static unsigned int UnixEventsToDBusFlags(short events)
|
||||
{
|
||||
return (events & DBUS_WATCH_READABLE ? POLLIN : 0) |
|
||||
@ -150,7 +135,6 @@ struct DBusThread : public RawDBusConnection
|
||||
protected:
|
||||
bool SetUpEventLoop();
|
||||
bool TearDownData();
|
||||
bool TearDownEventLoop();
|
||||
};
|
||||
|
||||
static nsAutoPtr<DBusThread> sDBusThread;
|
||||
@ -322,19 +306,6 @@ DBusThread::SetUpEventLoop()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set which messages will be processed by this dbus connection.
|
||||
// Since we are maintaining a single thread for all the DBus bluez
|
||||
// signals we want, register all of them in this thread at startup.
|
||||
// The event handler will sort the destinations out as needed.
|
||||
for (uint32_t i = 0; i < ArrayLength(DBUS_SIGNALS); ++i) {
|
||||
dbus_bus_add_match(mConnection,
|
||||
DBUS_SIGNALS[i],
|
||||
&err);
|
||||
if (dbus_error_is_set(&err)) {
|
||||
LOG_AND_FREE_DBUS_ERROR(&err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -356,26 +327,6 @@ DBusThread::TearDownData()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
DBusThread::TearDownEventLoop()
|
||||
{
|
||||
MOZ_ASSERT(mConnection);
|
||||
|
||||
DBusError err;
|
||||
dbus_error_init(&err);
|
||||
|
||||
for (uint32_t i = 0; i < ArrayLength(DBUS_SIGNALS); ++i) {
|
||||
dbus_bus_remove_match(mConnection,
|
||||
DBUS_SIGNALS[i],
|
||||
&err);
|
||||
if (dbus_error_is_set(&err)) {
|
||||
LOG_AND_FREE_DBUS_ERROR(&err);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
DBusThread::EventLoop()
|
||||
{
|
||||
@ -400,7 +351,6 @@ DBusThread::EventLoop()
|
||||
LOG("DBus Event Loop Exiting\n");
|
||||
dbus_connection_set_watch_functions(mConnection,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
TearDownEventLoop();
|
||||
return;
|
||||
case DBUS_EVENT_LOOP_ADD:
|
||||
HandleWatchAdd(this);
|
||||
|
Loading…
Reference in New Issue
Block a user