Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 00/17] RFC: Simplify DBusConnection object handling
@ 2012-09-19 10:22 Andrzej Kaczmarek
  2012-09-19 10:22 ` [PATCH 01/17] Rename get_dbus_connection to btd_get_dbus_connection Andrzej Kaczmarek
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: Andrzej Kaczmarek @ 2012-09-19 10:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

Hi,

Here's series of patches which makes handling of DBusConnection object
across code simpler and more consistent.

Problem with current implementation is that different modules handles
reference to D-Bus in a different way, e.g. some use dbus_bus_get() and
just store it in static variable, others pass this around via multiple
calls to finally store it in per-{adapter,device,request} structure or
some just use get_dbus_connection() call to have it immediately.

This creates a lot of redundant code which only (un)refs DBusConnection
and pass it around for no particular reason, because you can use global
reference which is exactly the same object.

What following patches do is:
(1) prefix get_dbus_connection() with btd_ so it can be used by external
    plugins
(2) make sure D-Bus is disconnected after all modules (agent, mamanger,
    plugins etc.) are shutdown
(3) remove any redundant internal references and function parameters that
    pass/store DBusConnection and just use btd_get_dbus_connection() where
    need to pass valid DBusConnection object (no need to ref it, there's
    one global ref and it's always valid as per #2)

This makes things with D-Bus really simple: you need to pass DBusConnection
object somewhere - call btd_get_dbus_connection() and you have it. No need
to store it, no need to ref it. Perhaps some downside of this approach is
that few files (hdp.c, telephony-maemo{5,6}.c) have quite a lot of such calls
but if this is something to avoid we can still add global static variable
and call btd_get_dbus_connection() once in *_init(), just like dbusoob plugin
does now.

Comments are welcome.


Andrzej Kaczmarek (17):
  Rename get_dbus_connection to btd_get_dbus_connection
  core: Make D-Bus connection valid for entire bluetoothd lifetime
  dbus-common: Remove conn parameter from emit_property_changed
  dbus-common: Remove conn parameter from emit_array_property_changed
  manager: Simplify DBusConnection object handling
  agent: Simplify DBusConnection object handling
  device: Simplify DBusConnection object handling
  adapter: Simplify DBusConnection object handling
  attrib: Simplify DBusConnection object handling
  audio: Simplify DBusConnection object handling
  health: Simplify DBusConnection object handling
  input: Simplify DBusConnection object handling
  network: Simplify DBusConnection object handling
  sap: Simplify DBusConnection object handling
  thermometer: Simplify DBusConnection object handling
  service: Simplify DBusConnection object handling
  dbusoob: Simplify DBusConnection object handling

 attrib/client.c                    |  41 +++----
 attrib/client.h                    |   3 +-
 audio/a2dp.c                       |   9 +-
 audio/a2dp.h                       |   2 +-
 audio/avrcp.c                      |   2 +-
 audio/avrcp.h                      |   2 +-
 audio/control.c                    |  17 +--
 audio/device.c                     |  22 ++--
 audio/device.h                     |   4 +-
 audio/gateway.c                    |  26 ++---
 audio/headset.c                    |  68 ++++++-----
 audio/main.c                       |  15 +--
 audio/manager.c                    |  23 +---
 audio/manager.h                    |   3 +-
 audio/media.c                      |  69 +++++-------
 audio/media.h                      |   2 +-
 audio/sink.c                       |  54 ++++-----
 audio/source.c                     |  30 ++---
 audio/telephony-dummy.c            |  17 ++-
 audio/telephony-maemo5.c           |  51 ++++-----
 audio/telephony-maemo6.c           |  36 +++---
 audio/telephony-ofono.c            |  25 ++---
 audio/transport.c                  |  51 ++++-----
 audio/transport.h                  |   3 +-
 plugins/dbusoob.c                  |  15 ++-
 plugins/service.c                  |  74 +++++-------
 profiles/health/hdp.c              | 182 ++++++++++++++----------------
 profiles/health/hdp.h              |   6 +-
 profiles/health/hdp_main.c         |  16 +--
 profiles/health/hdp_manager.c      |  15 +--
 profiles/health/hdp_manager.h      |   2 +-
 profiles/health/hdp_types.h        |   2 -
 profiles/health/hdp_util.c         |   6 +-
 profiles/input/device.c            |  35 +++---
 profiles/input/device.h            |   6 +-
 profiles/input/main.c              |  12 +-
 profiles/input/manager.c           |  10 +-
 profiles/input/manager.h           |   2 +-
 profiles/network/connection.c      |  70 +++++-------
 profiles/network/connection.h      |   2 -
 profiles/network/main.c            |  15 +--
 profiles/network/manager.c         |  16 +--
 profiles/network/manager.h         |   2 +-
 profiles/network/server.c          |  13 +--
 profiles/network/server.h          |   2 +-
 profiles/proximity/immalert.c      |   2 +-
 profiles/proximity/linkloss.c      |   2 +-
 profiles/proximity/monitor.c       |  22 ++--
 profiles/proximity/reporter.c      |   4 +-
 profiles/sap/main.c                |  16 +--
 profiles/sap/manager.c             |  17 +--
 profiles/sap/manager.h             |   2 +-
 profiles/sap/sap-dummy.c           |  19 +---
 profiles/sap/server.c              |  29 ++---
 profiles/sap/server.h              |   2 -
 profiles/thermometer/main.c        |  17 +--
 profiles/thermometer/manager.c     |  11 +-
 profiles/thermometer/manager.h     |   2 +-
 profiles/thermometer/thermometer.c |  30 +++--
 profiles/thermometer/thermometer.h |   3 +-
 src/adapter.c                      | 199 +++++++++++++++-----------------
 src/adapter.h                      |   8 +-
 src/agent.c                        |  44 +++-----
 src/agent.h                        |   3 -
 src/dbus-common.c                  |  12 +-
 src/dbus-common.h                  |   8 +-
 src/device.c                       | 225 +++++++++++++++++--------------------
 src/device.h                       |  29 +++--
 src/event.c                        |  17 +--
 src/main.c                         |  20 ++--
 src/manager.c                      |  41 ++++---
 src/manager.h                      |   4 +-
 72 files changed, 758 insertions(+), 1108 deletions(-)

-- 
1.7.11.3


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2012-09-21 10:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-19 10:22 [PATCH 00/17] RFC: Simplify DBusConnection object handling Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 01/17] Rename get_dbus_connection to btd_get_dbus_connection Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 02/17] core: Make D-Bus connection valid for entire bluetoothd lifetime Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 03/17] dbus-common: Remove conn parameter from emit_property_changed Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 04/17] dbus-common: Remove conn parameter from emit_array_property_changed Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 05/17] manager: Simplify DBusConnection object handling Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 06/17] agent: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 07/17] device: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 08/17] adapter: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 09/17] attrib: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 10/17] audio: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 11/17] health: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 12/17] input: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 13/17] network: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 14/17] sap: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 15/17] thermometer: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 16/17] service: " Andrzej Kaczmarek
2012-09-19 10:22 ` [PATCH 17/17] dbusoob: " Andrzej Kaczmarek
2012-09-21 10:55 ` [PATCH 00/17] RFC: " Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox