~ubuntu-branches/ubuntu/natty/vino/natty

« back to all changes in this revision

Viewing changes to server/vino-dbus-listener.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-09-07 14:23:05 UTC
  • mfrom: (1.1.39 upstream)
  • Revision ID: james.westby@ubuntu.com-20090907142305-iweame4y7atzzcii
Tags: 2.27.92-0ubuntu1
* New upstream version:
  - Fix a regression that allows more than one instance of the server to run.
  - Use vino's debug framework instead of g_printerr 
  - Make Avahi use the network interface defined in vino preferences.
  - Use integer (instead of double) as the port parameter in dbus calls.
  - Fixed a warning in libgcrypt initialization.
  - Translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
static gboolean
83
83
vino_dbus_listener_get_external_port (VinoDBusListener *listener,
84
 
                                      gdouble *ret,
85
 
                                      GError **error);
 
84
                                      gint             *ret,
 
85
                                      GError           **error);
86
86
 
87
87
static gboolean
88
88
vino_dbus_listener_get_internal_data (VinoDBusListener *listener,
89
 
                                      char ** hostname,
90
 
                                      char ** avahi_hostname,
91
 
                                      gdouble * port,
92
 
                                      GError **error);
 
89
                                      char             **hostname,
 
90
                                      char             **avahi_hostname,
 
91
                                      gint             *port,
 
92
                                      GError           **error);
93
93
 
94
94
static gboolean
95
95
vino_dbus_listener_share_with_tube (VinoDBusListener *listener,
96
 
                                    const gchar * connection_path,
97
 
                                    const gchar * tube_path,
98
 
                                    GHashTable * properties,
99
 
                                    GError **error);
 
96
                                    const gchar      *connection_path,
 
97
                                    const gchar      *tube_path,
 
98
                                    GHashTable       *properties,
 
99
                                    GError           **error);
100
100
 
101
101
#include "dbus-interface-glue.h"
102
102
 
297
297
 
298
298
static gboolean
299
299
vino_dbus_listener_get_external_port (VinoDBusListener *listener,
300
 
                                      gdouble *ret,
301
 
                                      GError **error)
 
300
                                      gint             *ret,
 
301
                                      GError           **error)
302
302
{
303
303
  *ret = vino_server_get_external_port (listener->priv->server);
304
304
 
308
308
 
309
309
static gboolean
310
310
vino_dbus_listener_get_internal_data (VinoDBusListener *listener,
311
 
                                      char ** hostname,
312
 
                                      char ** avahi_hostname,
313
 
                                      gdouble * port,
314
 
                                      GError **error)
 
311
                                      char             **hostname,
 
312
                                      char             **avahi_hostname,
 
313
                                      gint             *port,
 
314
                                      GError           **error)
315
315
{
316
316
#ifdef VINO_ENABLE_HTTP_SERVER
317
 
  *port = (gdouble)vino_get_http_server_port (listener->priv->server);
 
317
  *port = vino_get_http_server_port (listener->priv->server);
318
318
#else
319
 
  *port = (gdouble)vino_server_get_port (listener->priv->server);
 
319
  *port = vino_server_get_port (listener->priv->server);
320
320
#endif
321
321
 
322
322
  *hostname = get_local_hostname (listener);
323
 
 
324
323
  *avahi_hostname = g_strdup (vino_mdns_get_hostname ());
325
324
 
326
325
  return TRUE;
377
376
 
378
377
  dprintf (DBUS, "Object registered at path '%s'\n", obj_path);
379
378
 
380
 
  g_signal_connect (server, "notify::alternative-port",
381
 
      G_CALLBACK (vino_dbus_listener_info_changed),
382
 
      listener);
 
379
  g_signal_connect (server,
 
380
                    "notify::alternative-port",
 
381
                    G_CALLBACK (vino_dbus_listener_info_changed),
 
382
                    listener);
383
383
 
384
384
  g_free (obj_path);
385
385
}
392
392
  return listener->priv->server;
393
393
}
394
394
 
395
 
static DBusGConnection * vino_dbus_connection = NULL;
 
395
static DBusGConnection *vino_dbus_connection = NULL;
396
396
static gboolean        vino_dbus_failed_to_connect = FALSE;
397
397
 
398
398
DBusGConnection *
399
399
vino_dbus_get_connection (void)
400
400
{
401
 
  DBusConnection * dbus_conn;
402
401
  if (vino_dbus_connection == NULL && !vino_dbus_failed_to_connect)
403
402
    {
404
 
      GError * error = NULL;
 
403
      GError *error = NULL;
405
404
 
406
405
      if ((vino_dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error)))
407
 
        {
408
 
          dprintf (DBUS, "Successfully connected to the message bus\n");
409
 
          dbus_conn = dbus_g_connection_get_connection (vino_dbus_connection);
410
 
          dbus_connection_set_exit_on_disconnect (dbus_conn, FALSE);
411
 
        }
 
406
        {
 
407
          DBusConnection * dbus_conn;
 
408
 
 
409
          dprintf (DBUS, "Successfully connected to the message bus\n");
 
410
          dbus_conn = dbus_g_connection_get_connection (vino_dbus_connection);
 
411
          dbus_connection_set_exit_on_disconnect (dbus_conn, FALSE);
 
412
        }
412
413
      else
413
 
        {
414
 
          vino_dbus_failed_to_connect = TRUE;
415
 
          g_printerr ("Failed to open connection to bus: %s\n",
416
 
              error->message);
417
 
          g_error_free (error);
418
 
        }
 
414
        {
 
415
          vino_dbus_failed_to_connect = TRUE;
 
416
          dprintf (DBUS, "Failed to open connection to bus: %s\n", error->message);
 
417
          g_error_free (error);
 
418
        }
419
419
    }
420
420
 
421
421
  return vino_dbus_connection;
426
426
{
427
427
 
428
428
  DBusGConnection *connection;
429
 
  GError *error = NULL;
430
 
  DBusGProxy     *bus_proxy;
431
 
  int request_name_result;
 
429
  DBusGProxy      *bus_proxy;
 
430
  guint           request_name_result;
 
431
  GError          *error = NULL;
432
432
 
433
433
  if (!(connection = vino_dbus_get_connection ()))
434
434
    return FALSE;
435
435
 
436
436
  dbus_g_object_type_install_info (VINO_TYPE_DBUS_LISTENER,
437
 
      &dbus_glib_vino_dbus_listener_object_info);
 
437
                                   &dbus_glib_vino_dbus_listener_object_info);
438
438
 
439
439
  bus_proxy = dbus_g_proxy_new_for_name (connection,
440
440
      "org.freedesktop.DBus",
441
441
      "/org/freedesktop/DBus",
442
442
      "org.freedesktop.DBus");
443
443
 
444
 
  if (!dbus_g_proxy_call(bus_proxy, "RequestName", &error, 
445
 
      G_TYPE_STRING, VINO_DBUS_BUS_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID,
446
 
      G_TYPE_UINT, &request_name_result, G_TYPE_INVALID))
 
444
  if (!dbus_g_proxy_call (bus_proxy,
 
445
                          "RequestName",
 
446
                          &error,
 
447
                          G_TYPE_STRING, VINO_DBUS_BUS_NAME,
 
448
                          G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
 
449
                          G_TYPE_INVALID,
 
450
                          G_TYPE_UINT, &request_name_result,
 
451
                          G_TYPE_INVALID))
447
452
    {
448
 
      g_debug ("Failed to request name: %s",
449
 
                error ? error->message : "No error given");
 
453
      dprintf (DBUS, "Failed to request DBUS name: %s", error ? error->message : "No error given");
450
454
      g_clear_error (&error);
451
 
      return FALSE ;
 
455
      return FALSE;
452
456
    }
453
457
 
454
458
  if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS)