30#include "dbus-server-launchd.h" 
   40#ifdef DBUS_ENABLE_LAUNCHD 
   46#include "dbus-server-socket.h" 
   47#include "dbus-sysdeps-unix.h" 
   70#ifdef DBUS_ENABLE_LAUNCHD 
   74    launch_data_t sockets_dict, checkin_response;
 
   75    launch_data_t checkin_request;
 
   76    launch_data_t listening_fd_array, listening_fd;
 
   77    launch_data_t environment_dict, environment_param;
 
   78    const char *launchd_socket_path, *display;
 
   83    _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
   85    if (launchd_socket_path == 
NULL || *launchd_socket_path == 
'\0')
 
   88                        "launchd's environment variable %s is empty, but should contain a socket path.\n", launchd_env_var);
 
  108    if ((checkin_request = launch_data_new_string (LAUNCH_KEY_CHECKIN)) == 
NULL)
 
  111                        "launch_data_new_string(\"%s\") Unable to create string.\n",
 
  116    if ((checkin_response = launch_msg (checkin_request)) == 
NULL)
 
  119                        "launch_msg(\"%s\") IPC failure: %s\n",
 
  120                        LAUNCH_KEY_CHECKIN, strerror (errno));
 
  124    if (LAUNCH_DATA_ERRNO == launch_data_get_type (checkin_response))
 
  127                        strerror (launch_data_get_errno (checkin_response)));
 
  132      launch_data_dict_lookup (checkin_response, LAUNCH_JOBKEY_SOCKETS);
 
  133    if (
NULL == sockets_dict)
 
  136                        "No sockets found to answer requests on!\n");
 
  141      launch_data_dict_lookup (sockets_dict, 
"unix_domain_listener");
 
  142    if (
NULL == listening_fd_array)
 
  145                        "No known sockets found to answer requests on!\n");
 
  149    if (launch_data_array_get_count (listening_fd_array) != 1)
 
  152                        "Expected 1 socket from launchd, got %d.\n",
 
  153                        launch_data_array_get_count (listening_fd_array));
 
  157    listening_fd = launch_data_array_get_index (listening_fd_array, 0);
 
  158    launchd_fd = launch_data_get_fd (listening_fd);
 
  164        _DBUS_ASSERT_ERROR_IS_SET (error);
 
  166  if (display == 
NULL || *display == 
'\0')
 
  168      environment_dict = launch_data_dict_lookup (checkin_response, LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES);
 
  169      if (
NULL == environment_dict)
 
  171          _dbus_warn (
"Unable to retrieve user environment from launchd.");
 
  175          environment_param = launch_data_dict_lookup (environment_dict, 
"DISPLAY");
 
  176          if (
NULL == environment_param)
 
  178              _dbus_warn (
"Unable to retrieve DISPLAY from launchd.");
 
  182              display = launch_data_get_string(environment_param);
 
  209                    "address type 'launchd' requested, but launchd support not compiled in");
 
 
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
#define NULL
A null pointer, defined appropriately for C or C++.
DBUS_EXPORT dbus_bool_t dbus_setenv(const char *variable, const char *value)
Wrapper for setenv().
#define DBUS_ERROR_BAD_ADDRESS
A D-Bus bus address was malformed.
#define DBUS_ERROR_IO_ERROR
Something went wrong reading or writing to a socket, for example.
#define DBUS_ERROR_LIMITS_EXCEEDED
Some limited resource is exhausted.
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
DBusServer * _dbus_server_new_for_launchd(const char *launchd_env_var, DBusError *error)
Creates a new server from launchd.
DBusServer * _dbus_server_new_for_socket(DBusSocket *fds, int n_fds, const DBusString *address, DBusNonceFile *noncefile, DBusError *error)
Creates a new server listening on the given file descriptor.
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as _DBUS_STRING_IN...
void _dbus_fd_set_close_on_exec(int fd)
Sets the file descriptor to be close on exec.
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Object representing an exception.
Internals of DBusServer object.