00001 /* -*- mode: C; c-file-style: "gnu" -*- */ 00002 /* utils.c General utility functions 00003 * 00004 * Copyright (C) 2003 CodeFactory AB 00005 * Copyright (C) 2003 Red Hat, Inc. 00006 * 00007 * Licensed under the Academic Free License version 1.2 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 * 00023 */ 00024 00025 #include <config.h> 00026 #include "utils.h" 00027 #include <dbus/dbus-sysdeps.h> 00028 #include <dbus/dbus-mainloop.h> 00029 00030 const char bus_no_memory_message[] = "Memory allocation failure in message bus"; 00031 00032 void 00033 bus_connection_dispatch_all_messages (DBusConnection *connection) 00034 { 00035 while (bus_connection_dispatch_one_message (connection)) 00036 ; 00037 } 00038 00039 dbus_bool_t 00040 bus_connection_dispatch_one_message (DBusConnection *connection) 00041 { 00042 DBusDispatchStatus status; 00043 00044 while ((status = dbus_connection_dispatch (connection)) == DBUS_DISPATCH_NEED_MEMORY) 00045 _dbus_wait_for_memory (); 00046 00047 return status == DBUS_DISPATCH_DATA_REMAINS; 00048 }