dbus-gmain.c 19.8 KB
Newer Older
1 2 3
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-gmain.c GLib main loop integration
 *
4
 * Copyright (C) 2002, 2003 CodeFactory AB
5
 *
6
 * Licensed under the Academic Free License version 2.1
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

24
#include <config.h>
25 26
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
27
#include "dbus-gtest.h"
28
#include "dbus-gutils.h"
29

30 31 32
#include <libintl.h>
#define _(x) dgettext (GETTEXT_PACKAGE, x)
#define N_(x) x
33

34 35 36 37 38 39 40 41 42 43
/**
 * @defgroup DBusGLib GLib bindings
 * @ingroup  DBus
 * @brief API for using D-BUS with GLib
 *
 * Convenience functions are provided for using D-BUS
 * with the GLib library (see http://www.gtk.org for GLib
 * information).
 * 
 */
44

45 46 47 48 49 50 51 52 53 54 55 56 57
/**
 * @defgroup DBusGLibInternals GLib bindings implementation details
 * @ingroup  DBusInternals
 * @brief Implementation details of GLib bindings
 *
 * @{
 */

/** @typedef DBusGSource
 * A GSource representing a #DBusConnection or #DBusServer
 */
typedef struct DBusGSource DBusGSource;

58 59 60
/**
 * A GSource subclass for a DBusConnection.
 */
61
struct DBusGSource
62
{
63
  GSource source; /**< the parent GSource */
64

65
  GList *watch_fds;      /**< descriptors we're watching */
66

James Willcox's avatar
 
James Willcox committed
67 68
  GMainContext *context; /**< the GMainContext to use, NULL for default */

69
  void *connection_or_server; /**< DBusConnection or DBusServer */
70 71
};

72 73 74 75
/**
 * Auxillary struct for pairing up a #DBusWatch and associated
 * #GPollFD
 */
76 77
typedef struct
{
78
  int refcount;     /**< reference count */
79

80 81
  GPollFD poll_fd;  /**< the #GPollFD to use with g_source_add_poll() */
  DBusWatch *watch; /**< the corresponding DBusWatch*/
82
  
83
  unsigned int removed : 1; /**< true if this #WatchFD has been removed */
84 85 86 87 88 89 90 91 92 93 94 95 96
} WatchFD;

static WatchFD *
watch_fd_new (void)
{
  WatchFD *watch_fd;

  watch_fd = g_new0 (WatchFD, 1);
  watch_fd->refcount = 1;

  return watch_fd;
}

97
static WatchFD * 
98 99 100
watch_fd_ref (WatchFD *watch_fd)
{
  watch_fd->refcount += 1;
101 102

  return watch_fd;
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
}

static void
watch_fd_unref (WatchFD *watch_fd)
{
  watch_fd->refcount -= 1;

  if (watch_fd->refcount == 0)
    {
      g_assert (watch_fd->removed);
  
      g_free (watch_fd);
    }
}

118 119
static dbus_int32_t connection_slot = -1;
static dbus_int32_t server_slot = -1;
120

121 122 123 124 125 126 127 128 129 130 131 132
static gboolean gsource_connection_prepare  (GSource     *source,
                                             gint        *timeout);
static gboolean gsource_connection_check    (GSource     *source);
static gboolean gsource_connection_dispatch (GSource     *source,
                                             GSourceFunc  callback,
                                             gpointer     user_data);
static gboolean gsource_server_prepare      (GSource     *source,
                                             gint        *timeout);
static gboolean gsource_server_check        (GSource     *source);
static gboolean gsource_server_dispatch     (GSource     *source,
                                             GSourceFunc  callback,
                                             gpointer     user_data);
133 134

static GSourceFuncs dbus_connection_funcs = {
135 136 137
  gsource_connection_prepare,
  gsource_connection_check,
  gsource_connection_dispatch,
138 139
  NULL
};
140

141
static GSourceFuncs dbus_server_funcs = {
142 143 144
  gsource_server_prepare,
  gsource_server_check,
  gsource_server_dispatch,
145 146 147
  NULL
};

148
static gboolean
149 150
gsource_connection_prepare (GSource *source,
                            gint    *timeout)
151
{
152
  DBusConnection *connection = ((DBusGSource *)source)->connection_or_server;
153
  
154 155
  *timeout = -1;

156
  return (dbus_connection_get_dispatch_status (connection) == DBUS_DISPATCH_DATA_REMAINS);  
157 158
}

159
static gboolean
160 161
gsource_server_prepare (GSource *source,
                        gint    *timeout)
162 163 164 165 166 167 168 169
{
  *timeout = -1;

  return FALSE;
}

static gboolean
dbus_gsource_check (GSource *source)
170 171 172 173
{
  DBusGSource *dbus_source = (DBusGSource *)source;
  GList *list;

174
  list = dbus_source->watch_fds;
175 176 177

  while (list)
    {
178
      WatchFD *watch_fd = list->data;
179

180
      if (watch_fd->poll_fd.revents != 0)
181 182 183 184 185 186 187 188 189
	return TRUE;

      list = list->next;
    }

  return FALSE;  
}

static gboolean
190
gsource_connection_check (GSource *source)
191 192 193 194 195
{
  return dbus_gsource_check (source);
}

static gboolean
196
gsource_server_check (GSource *source)
197 198 199 200 201 202 203 204 205
{
  return dbus_gsource_check (source);
}

static gboolean
dbus_gsource_dispatch (GSource     *source,
                       GSourceFunc  callback,
                       gpointer     user_data,
                       dbus_bool_t  is_server)
206
{
207
   DBusGSource *dbus_source = (DBusGSource *)source;
208
   GList *copy, *list;
209

210 211 212 213
   /* Make a copy of the list and ref all WatchFDs */
   copy = g_list_copy (dbus_source->watch_fds);
   g_list_foreach (copy, (GFunc)watch_fd_ref, NULL);
   
214
   list = copy;
215 216
   while (list)
     {
217
       WatchFD *watch_fd = list->data;
218

219
       if (!watch_fd->removed && watch_fd->poll_fd.revents != 0)
220 221 222
	 {
	   guint condition = 0;
	   
223
	   if (watch_fd->poll_fd.revents & G_IO_IN)
224
	     condition |= DBUS_WATCH_READABLE;
225
	   if (watch_fd->poll_fd.revents & G_IO_OUT)
226
	     condition |= DBUS_WATCH_WRITABLE;
227
	   if (watch_fd->poll_fd.revents & G_IO_ERR)
228
	     condition |= DBUS_WATCH_ERROR;
229
	   if (watch_fd->poll_fd.revents & G_IO_HUP)
230
	     condition |= DBUS_WATCH_HANGUP;
231

232
           dbus_watch_handle (watch_fd->watch, condition);
233
	 }
234

235 236 237
       list = list->next;
     }

238
   g_list_foreach (copy, (GFunc)watch_fd_unref, NULL);   
239
   g_list_free (copy);   
240 241

   return TRUE;
242 243
}

244
static gboolean
245 246 247
gsource_connection_dispatch (GSource     *source,
                             GSourceFunc  callback,
                             gpointer     user_data)
248 249 250 251 252 253 254 255 256 257
{
  DBusGSource *dbus_source = (DBusGSource *)source;
  DBusConnection *connection = dbus_source->connection_or_server;

  dbus_connection_ref (connection);

  dbus_gsource_dispatch (source, callback, user_data,
                         FALSE);
  
  /* Dispatch messages */
258
  while (dbus_connection_dispatch (connection) == DBUS_DISPATCH_DATA_REMAINS)
259 260 261 262 263 264 265 266
    ;

   dbus_connection_unref (connection);
   
   return TRUE;
}

static gboolean
267 268 269
gsource_server_dispatch (GSource     *source,
                         GSourceFunc  callback,
                         gpointer     user_data)
270 271 272 273 274 275 276 277 278 279 280 281 282 283
{
  DBusGSource *dbus_source = (DBusGSource *)source;
  DBusServer *server = dbus_source->connection_or_server;

  dbus_server_ref (server);

  dbus_gsource_dispatch (source, callback, user_data,
                         TRUE);

  dbus_server_unref (server);
   
  return TRUE;
}
     
284
static dbus_bool_t
285 286
add_watch (DBusWatch *watch,
	   gpointer   data)
287
{
288
  WatchFD *watch_fd;
289 290
  DBusGSource *dbus_source;
  guint flags;
291 292 293

  if (!dbus_watch_get_enabled (watch))
    return TRUE;
294 295
  
  dbus_source = data;
296 297 298 299

  watch_fd = watch_fd_new ();
  watch_fd->poll_fd.fd = dbus_watch_get_fd (watch);
  watch_fd->poll_fd.events = 0;
300
  flags = dbus_watch_get_flags (watch);
301
  dbus_watch_set_data (watch, watch_fd, (DBusFreeFunction)watch_fd_unref);
302

303
  if (flags & DBUS_WATCH_READABLE)
304
    watch_fd->poll_fd.events |= G_IO_IN;
305
  if (flags & DBUS_WATCH_WRITABLE)
306 307
    watch_fd->poll_fd.events |= G_IO_OUT;
  watch_fd->poll_fd.events |= G_IO_ERR | G_IO_HUP;
308

309 310 311
  watch_fd->watch = watch;
  
  g_source_add_poll ((GSource *)dbus_source, &watch_fd->poll_fd);
312

313
  dbus_source->watch_fds = g_list_prepend (dbus_source->watch_fds, watch_fd);
314 315

  return TRUE;
316 317 318
}

static void
319 320
remove_watch (DBusWatch *watch,
	      gpointer   data)
321
{
322
  DBusGSource *dbus_source = data;
323
  WatchFD *watch_fd;
324
  
325 326
  watch_fd = dbus_watch_get_data (watch);
  if (watch_fd == NULL)
327
    return; /* probably a not-enabled watch that was added */
328 329 330

  watch_fd->removed = TRUE;
  watch_fd->watch = NULL;  
331
  
332 333 334
  dbus_source->watch_fds = g_list_remove (dbus_source->watch_fds, watch_fd);

  g_source_remove_poll ((GSource *)dbus_source, &watch_fd->poll_fd);
335 336 337 338

  dbus_watch_set_data (watch, NULL, NULL); /* needed due to watch_toggled
                                            * breaking add/remove symmetry
                                            */
339 340
}

341 342 343 344 345 346 347 348 349 350 351 352 353
static void
watch_toggled (DBusWatch *watch,
               void      *data)
{
  /* Because we just exit on OOM, enable/disable is
   * no different from add/remove
   */
  if (dbus_watch_get_enabled (watch))
    add_watch (watch, data);
  else
    remove_watch (watch, data);
}

354 355 356 357 358 359 360
static gboolean
timeout_handler (gpointer data)
{
  DBusTimeout *timeout = data;

  dbus_timeout_handle (timeout);

361
  return TRUE;
362 363
}

364
static dbus_bool_t
365 366
add_timeout (DBusTimeout *timeout,
	     void        *data)
367
{
James Willcox's avatar
 
James Willcox committed
368 369
  DBusGSource *dbus_source = data;
  GSource *source;
370

371 372 373
  if (!dbus_timeout_get_enabled (timeout))
    return TRUE;
  
James Willcox's avatar
 
James Willcox committed
374 375 376
  source = g_timeout_source_new (dbus_timeout_get_interval (timeout));
  g_source_set_callback (source, timeout_handler, timeout, NULL);
  g_source_attach (source, dbus_source->context);
377
  
James Willcox's avatar
 
James Willcox committed
378 379
  dbus_timeout_set_data (timeout, GUINT_TO_POINTER (g_source_get_id (source)),
      			 NULL);
380 381

  return TRUE;
382
}
383

384 385 386 387
static void
remove_timeout (DBusTimeout *timeout,
		void        *data)
{
388 389 390
  guint timeout_tag;
  
  timeout_tag = GPOINTER_TO_UINT (dbus_timeout_get_data (timeout));
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406

  if (timeout_tag != 0) /* if 0, probably timeout was disabled */
    g_source_remove (timeout_tag);
}

static void
timeout_toggled (DBusTimeout *timeout,
                 void        *data)
{
  /* Because we just exit on OOM, enable/disable is
   * no different from add/remove
   */
  if (dbus_timeout_get_enabled (timeout))
    add_timeout (timeout, data);
  else
    remove_timeout (timeout, data);
407
}
408

409

410 411 412 413 414 415
static void
free_source (GSource *source)
{
  g_source_destroy (source);
}

416 417 418
static void
wakeup_main (void *data)
{
James Willcox's avatar
 
James Willcox committed
419 420 421
  DBusGSource *dbus_source = data;

  g_main_context_wakeup (dbus_source->context);
422 423 424
}


425 426 427 428 429 430 431 432
/** @} */ /* End of GLib bindings internals */

/** @addtogroup DBusGLib
 * @{
 */

static GSource*
create_source (void         *connection_or_server,
James Willcox's avatar
 
James Willcox committed
433 434
               GSourceFuncs *funcs,
	       GMainContext *context)
435
{
436 437 438
  GSource *source;
  DBusGSource *dbus_source;

439
  source = g_source_new (funcs, sizeof (DBusGSource));
440 441
  
  dbus_source = (DBusGSource *)source;  
442
  dbus_source->connection_or_server = connection_or_server;
James Willcox's avatar
 
James Willcox committed
443
  dbus_source->context = context;
444 445 446 447 448 449 450

  return source;
}

/**
 * Sets the watch and timeout functions of a #DBusConnection
 * to integrate the connection with the GLib main loop.
451 452
 * Pass in #NULL for the #GMainContext unless you're
 * doing something specialized.
453
 *
454 455 456 457 458
 * If called twice for the same context, does nothing the second
 * time. If called once with context A and once with context B,
 * context B replaces context A as the context monitoring the
 * connection.
 *
459
 * @param connection the connection
460
 * @param context the #GMainContext or #NULL for default context
461 462
 */
void
James Willcox's avatar
 
James Willcox committed
463 464
dbus_connection_setup_with_g_main (DBusConnection *connection,
				   GMainContext   *context)
465 466
{
  GSource *source;
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
  
  /* FIXME we never free the slot, so its refcount just keeps growing,
   * which is kind of broken.
   */
  dbus_connection_allocate_data_slot (&connection_slot);
  if (connection_slot < 0)
    goto nomem;

  /* So we can test for equality below */
  if (context == NULL)
    context = g_main_context_default ();
  
  source = dbus_connection_get_data (connection, connection_slot);
  if (source != NULL)
    {
      if (source->context == context)
        return; /* nothing to do */
484

485 486 487 488 489
      /* Remove the previous source and move to a new context */
      dbus_connection_set_data (connection, connection_slot, NULL, NULL);
      source = NULL;
    }
  
James Willcox's avatar
 
James Willcox committed
490
  source = create_source (connection, &dbus_connection_funcs, context);
491

492 493 494
  if (!dbus_connection_set_watch_functions (connection,
                                            add_watch,
                                            remove_watch,
495
                                            watch_toggled,
496 497
                                            source, NULL))
    goto nomem;
498

499 500 501
  if (!dbus_connection_set_timeout_functions (connection,
                                              add_timeout,
                                              remove_timeout,
502
                                              timeout_toggled,
503
                                              source, NULL))
504 505
    goto nomem;
    
506 507
  dbus_connection_set_wakeup_main_function (connection,
					    wakeup_main,
James Willcox's avatar
 
James Willcox committed
508
					    source, NULL);
509
      
James Willcox's avatar
 
James Willcox committed
510
  g_source_attach (source, context);
511

512 513 514 515 516 517 518 519 520 521 522 523 524
  if (!dbus_connection_set_data (connection, connection_slot, source,
                                 (DBusFreeFunction)free_source))
    goto nomem;

  return;

 nomem:
  g_error ("Not enough memory to set up DBusConnection for use with GLib");
}

/**
 * Sets the watch and timeout functions of a #DBusServer
 * to integrate the server with the GLib main loop.
525
 * In most cases the context argument should be #NULL.
526
 *
527 528 529 530 531
 * If called twice for the same context, does nothing the second
 * time. If called once with context A and once with context B,
 * context B replaces context A as the context monitoring the
 * connection.
 *
532
 * @param server the server
533
 * @param context the #GMainContext or #NULL for default
534 535
 */
void
536 537
dbus_server_setup_with_g_main (DBusServer   *server,
                               GMainContext *context)
538 539 540
{
  GSource *source;

541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
  dbus_server_allocate_data_slot (&server_slot);
  if (server_slot < 0)
    goto nomem;

  /* So we can test for equality below */
  if (context == NULL)
    context = g_main_context_default ();
  
  source = dbus_server_get_data (server, server_slot);
  if (source != NULL)
    {
      if (source->context == context)
        return; /* nothing to do */

      /* Remove the previous source and move to a new context */
      dbus_server_set_data (server, server_slot, NULL, NULL);
      source = NULL;
    }
  
James Willcox's avatar
 
James Willcox committed
560
  source = create_source (server, &dbus_server_funcs, context);
561 562 563 564

  dbus_server_set_watch_functions (server,
                                   add_watch,
                                   remove_watch,
565
                                   watch_toggled,
566 567 568 569 570
                                   source, NULL);

  dbus_server_set_timeout_functions (server,
                                     add_timeout,
                                     remove_timeout,
571
                                     timeout_toggled,
572
                                     NULL, NULL);
573
  
James Willcox's avatar
 
James Willcox committed
574
  g_source_attach (source, context);
575 576 577 578 579 580 581 582 583

  if (!dbus_server_set_data (server, server_slot, source,
                             (DBusFreeFunction)free_source))
    goto nomem;

  return;

 nomem:
  g_error ("Not enough memory to set up DBusServer for use with GLib");
584
}
585

586
/**
587 588 589 590 591
 * Returns a connection to the given bus. The connection is a global variable
 * shared with other callers of this function.
 * 
 * (Internally, calls dbus_bus_get() then calls
 * dbus_connection_setup_with_g_main() on the result.)
592 593 594 595 596
 *
 * @param type bus type
 * @param error address where an error can be returned.
 * @returns a DBusConnection
 */
597 598 599
DBusGConnection*
dbus_g_bus_get (DBusBusType     type,
                GError        **error)
600 601 602 603 604 605 606 607 608 609 610 611 612
{
  DBusConnection *connection;
  DBusError derror;

  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
  
  dbus_error_init (&derror);

  connection = dbus_bus_get (type, &derror);
  if (connection == NULL)
    {
      dbus_set_g_error (error, &derror);
      dbus_error_free (&derror);
613
      return NULL;
614
    }
615 616 617

  /* does nothing if it's already been done */
  dbus_connection_setup_with_g_main (connection, NULL);
618

619
  return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
620 621
}

622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658
/**
 * The implementation of DBUS_GERROR error domain. See documentation
 * for GError in GLib reference manual.
 *
 * @returns the error domain quark for use with GError
 */
GQuark
dbus_g_error_quark (void)
{
  static GQuark quark = 0;
  if (quark == 0)
    quark = g_quark_from_static_string ("g-exec-error-quark");
  return quark;
}


/**
 * Set a GError return location from a DBusError.
 *
 * @todo expand the DBUS_GERROR enum and take advantage of it here
 * 
 * @param gerror location to store a GError, or #NULL
 * @param derror the DBusError
 */
void
dbus_set_g_error (GError   **gerror,
                  DBusError *derror)
{
  g_return_if_fail (derror != NULL);
  g_return_if_fail (dbus_error_is_set (derror));
  
  g_set_error (gerror, DBUS_GERROR,
               DBUS_GERROR_FAILED,
               _("D-BUS error %s: %s"),
               derror->name, derror->message);  
}

659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
/**
 * Get the GLib type ID for a DBusConnection boxed type.
 *
 * @returns GLib type
 */
GType
dbus_connection_get_g_type (void)
{
  static GType our_type = 0;
  
  if (our_type == 0)
    our_type = g_boxed_type_register_static ("DBusConnection",
                                             (GBoxedCopyFunc) dbus_connection_ref,
                                             (GBoxedFreeFunc) dbus_connection_unref);

  return our_type;
}

/**
 * Get the GLib type ID for a DBusMessage boxed type.
 *
 * @returns GLib type
 */
GType
dbus_message_get_g_type (void)
{
  static GType our_type = 0;
  
  if (our_type == 0)
    our_type = g_boxed_type_register_static ("DBusMessage",
                                             (GBoxedCopyFunc) dbus_message_ref,
                                             (GBoxedFreeFunc) dbus_message_unref);

  return our_type;
}

695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
static DBusGConnection*
dbus_g_connection_ref (DBusGConnection *gconnection)
{
  DBusConnection *c;

  c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
  dbus_connection_ref (c);
  return gconnection;
}

static void
dbus_g_connection_unref (DBusGConnection *gconnection)
{
  DBusConnection *c;

  c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
  dbus_connection_unref (c);
}


static DBusGMessage*
dbus_g_message_ref (DBusGMessage *gmessage)
{
  DBusMessage *c;

  c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
  dbus_message_ref (c);
  return gmessage;
}

static void
dbus_g_message_unref (DBusGMessage *gmessage)
{
  DBusMessage *c;

  c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
  dbus_message_unref (c);
}

/**
 * Get the GLib type ID for a DBusGConnection boxed type.
 *
 * @returns GLib type
 */
GType
dbus_g_connection_get_g_type (void)
{
  static GType our_type = 0;
  
  if (our_type == 0)
    our_type = g_boxed_type_register_static ("DBusGConnection",
                                             (GBoxedCopyFunc) dbus_g_connection_ref,
                                             (GBoxedFreeFunc) dbus_g_connection_unref);

  return our_type;
}

/**
 * Get the GLib type ID for a DBusGMessage boxed type.
 *
 * @returns GLib type
 */
GType
dbus_g_message_get_g_type (void)
{
  static GType our_type = 0;
  
  if (our_type == 0)
    our_type = g_boxed_type_register_static ("DBusGMessage",
                                             (GBoxedCopyFunc) dbus_g_message_ref,
                                             (GBoxedFreeFunc) dbus_g_message_unref);

  return our_type;
}

/**
 * Get the DBusConnection corresponding to this DBusGConnection.
 * The return value does not have its refcount incremented.
 *
 * @returns DBusConnection 
 */
DBusConnection*
dbus_g_connection_get_connection (DBusGConnection *gconnection)
{
  return DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
}

/**
 * Get the DBusMessage corresponding to this DBusGMessage.
 * The return value does not have its refcount incremented.
 *
 * @returns DBusMessage 
 */
DBusMessage*
dbus_g_message_get_message (DBusGMessage *gmessage)
{
  return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
}
793

794
/** @} */ /* end of public API */
795 796 797 798 799 800 801 802

#ifdef DBUS_BUILD_TESTS

/**
 * @ingroup DBusGLibInternals
 * Unit test for GLib main loop integration
 * @returns #TRUE on success.
 */
803
gboolean
804 805 806 807 808 809 810
_dbus_gmain_test (const char *test_data_dir)
{
  
  return TRUE;
}

#endif /* DBUS_BUILD_TESTS */