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
|
// This happens when the array is 0-length. Apparently we get a
|
||||||
// DBUS_TYPE_INVALID type.
|
// DBUS_TYPE_INVALID type.
|
||||||
propertyValue = InfallibleTArray<nsString>();
|
propertyValue = InfallibleTArray<nsString>();
|
||||||
|
#ifdef DEBUG
|
||||||
NS_WARNING("Received array type that's not a string array!");
|
NS_WARNING("Received array type that's not a string array!");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -605,7 +607,7 @@ BluetoothDBusService::StartInternal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mConnection) {
|
if (mConnection) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(EstablishDBusConnection())) {
|
if (NS_FAILED(EstablishDBusConnection())) {
|
||||||
@ -613,7 +615,23 @@ BluetoothDBusService::StartInternal()
|
|||||||
StopDBus();
|
StopDBus();
|
||||||
return NS_ERROR_FAILURE;
|
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
|
// Add a filter for all incoming messages_base
|
||||||
if (!dbus_connection_add_filter(mConnection, EventFilter,
|
if (!dbus_connection_add_filter(mConnection, EventFilter,
|
||||||
NULL, NULL)) {
|
NULL, NULL)) {
|
||||||
@ -634,7 +652,20 @@ BluetoothDBusService::StopInternal()
|
|||||||
StopDBus();
|
StopDBus();
|
||||||
return NS_OK;
|
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;
|
mConnection = nullptr;
|
||||||
mBluetoothSignalObserverTable.Clear();
|
mBluetoothSignalObserverTable.Clear();
|
||||||
StopDBus();
|
StopDBus();
|
||||||
|
@ -77,21 +77,6 @@ enum {
|
|||||||
DBUS_EVENT_LOOP_REMOVE = 3,
|
DBUS_EVENT_LOOP_REMOVE = 3,
|
||||||
} DBusEventTypes;
|
} 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)
|
static unsigned int UnixEventsToDBusFlags(short events)
|
||||||
{
|
{
|
||||||
return (events & DBUS_WATCH_READABLE ? POLLIN : 0) |
|
return (events & DBUS_WATCH_READABLE ? POLLIN : 0) |
|
||||||
@ -150,7 +135,6 @@ struct DBusThread : public RawDBusConnection
|
|||||||
protected:
|
protected:
|
||||||
bool SetUpEventLoop();
|
bool SetUpEventLoop();
|
||||||
bool TearDownData();
|
bool TearDownData();
|
||||||
bool TearDownEventLoop();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static nsAutoPtr<DBusThread> sDBusThread;
|
static nsAutoPtr<DBusThread> sDBusThread;
|
||||||
@ -322,19 +306,6 @@ DBusThread::SetUpEventLoop()
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,26 +327,6 @@ DBusThread::TearDownData()
|
|||||||
return true;
|
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
|
void
|
||||||
DBusThread::EventLoop()
|
DBusThread::EventLoop()
|
||||||
{
|
{
|
||||||
@ -400,7 +351,6 @@ DBusThread::EventLoop()
|
|||||||
LOG("DBus Event Loop Exiting\n");
|
LOG("DBus Event Loop Exiting\n");
|
||||||
dbus_connection_set_watch_functions(mConnection,
|
dbus_connection_set_watch_functions(mConnection,
|
||||||
NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL);
|
||||||
TearDownEventLoop();
|
|
||||||
return;
|
return;
|
||||||
case DBUS_EVENT_LOOP_ADD:
|
case DBUS_EVENT_LOOP_ADD:
|
||||||
HandleWatchAdd(this);
|
HandleWatchAdd(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user