| Current File : //usr/share/doc/dbus/api/dbus-server_8c_source.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>D-Bus: dbus-server.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">D-Bus
 <span id="projectnumber">1.8.20</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.6.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
</div>
<div class="header">
<div class="headertitle">
<div class="title">dbus-server.c</div> </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-server.c DBusServer object</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Licensed under the Academic Free License version 2.1</span>
<a name="l00007"></a>00007 <span class="comment"> * </span>
<a name="l00008"></a>00008 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00009"></a>00009 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00010"></a>00010 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00011"></a>00011 <span class="comment"> * (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00016"></a>00016 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> * </span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00019"></a>00019 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> *</span>
<a name="l00022"></a>00022 <span class="comment"> */</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include <config.h></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "dbus-server.h"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "dbus-server-unix.h"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "dbus-server-socket.h"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "dbus-string.h"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#ifdef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#include "dbus-server-debug-pipe.h"</span>
<a name="l00031"></a>00031 <span class="preprocessor">#endif</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#include "dbus-address.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "dbus-protocol.h"</span>
<a name="l00034"></a>00034
<a name="l00056"></a>00056 <span class="preprocessor">#ifndef _dbus_server_trace_ref</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span><span class="keywordtype">void</span>
<a name="l00058"></a>00058 _dbus_server_trace_ref (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00059"></a>00059 <span class="keywordtype">int</span> old_refcount,
<a name="l00060"></a>00060 <span class="keywordtype">int</span> new_refcount,
<a name="l00061"></a>00061 <span class="keyword">const</span> <span class="keywordtype">char</span> *why)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063 <span class="keyword">static</span> <span class="keywordtype">int</span> enabled = -1;
<a name="l00064"></a>00064
<a name="l00065"></a>00065 _dbus_trace_ref (<span class="stringliteral">"DBusServer"</span>, server, old_refcount, new_refcount, why,
<a name="l00066"></a>00066 <span class="stringliteral">"DBUS_SERVER_TRACE"</span>, &enabled);
<a name="l00067"></a>00067 }
<a name="l00068"></a>00068 <span class="preprocessor">#endif</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span>
<a name="l00070"></a>00070 <span class="comment">/* this is a little fragile since it assumes the address doesn't</span>
<a name="l00071"></a>00071 <span class="comment"> * already have a guid, but it shouldn't</span>
<a name="l00072"></a>00072 <span class="comment"> */</span>
<a name="l00073"></a>00073 <span class="keyword">static</span> <span class="keywordtype">char</span>*
<a name="l00074"></a>00074 copy_address_with_guid_appended (<span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *address,
<a name="l00075"></a>00075 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *guid_hex)
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077 <a class="code" href="structDBusString.html">DBusString</a> with_guid;
<a name="l00078"></a>00078 <span class="keywordtype">char</span> *retval;
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&with_guid))
<a name="l00081"></a>00081 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (address, 0, &with_guid,
<a name="l00084"></a>00084 <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&with_guid)) ||
<a name="l00085"></a>00085 !<a class="code" href="group__DBusString.html#ga100c5ce0696822c5a4cfbdfaba674d96" title="Appends a nul-terminated C-style string to a DBusString.">_dbus_string_append</a> (&with_guid, <span class="stringliteral">",guid="</span>) ||
<a name="l00086"></a>00086 !<a class="code" href="group__DBusString.html#ga3c10f0d1bcaa3b450025b9c6a8b901d7" title="Like _dbus_string_move(), but does not delete the section of the source string that's copied to the d...">_dbus_string_copy</a> (guid_hex, 0,
<a name="l00087"></a>00087 &with_guid, <a class="code" href="group__DBusString.html#gaa5136e6fd2c5188f4b88de7863369c6d" title="Gets the length of a string (not including nul termination).">_dbus_string_get_length</a> (&with_guid)))
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&with_guid);
<a name="l00090"></a>00090 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092
<a name="l00093"></a>00093 retval = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00094"></a>00094 <a class="code" href="group__DBusString.html#ga556cc30c3ab032dbc63e217119f0d1f5" title="Like _dbus_string_get_data(), but removes the gotten data from the original string.">_dbus_string_steal_data</a> (&with_guid, &retval);
<a name="l00095"></a>00095
<a name="l00096"></a>00096 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&with_guid);
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keywordflow">return</span> retval; <span class="comment">/* may be NULL if steal_data failed */</span>
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100
<a name="l00110"></a>00110 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00111"></a><a class="code" href="group__DBusServerInternals.html#gaacfb3d29553f205b362c850cfda02fd9">00111</a> <a class="code" href="group__DBusServerInternals.html#gaacfb3d29553f205b362c850cfda02fd9" title="Initializes the members of the DBusServer base class.">_dbus_server_init_base</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00112"></a>00112 <span class="keyword">const</span> <a class="code" href="structDBusServerVTable.html" title="Virtual table to be implemented by all server "subclasses".">DBusServerVTable</a> *vtable,
<a name="l00113"></a>00113 <span class="keyword">const</span> <a class="code" href="structDBusString.html">DBusString</a> *address)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115 server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a> = vtable;
<a name="l00116"></a>00116
<a name="l00117"></a>00117 <span class="preprocessor">#ifdef DBUS_DISABLE_ASSERT</span>
<a name="l00118"></a>00118 <span class="preprocessor"></span> <a class="code" href="group__DBusSysdeps.html#gae74c3fcf12acaeccdb152ef907de951c" title="Atomically increments an integer.">_dbus_atomic_inc</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00119"></a>00119 <span class="preprocessor">#else</span>
<a name="l00120"></a>00120 <span class="preprocessor"></span> {
<a name="l00121"></a>00121 <a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> old_refcount = <a class="code" href="group__DBusSysdeps.html#gae74c3fcf12acaeccdb152ef907de951c" title="Atomically increments an integer.">_dbus_atomic_inc</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00122"></a>00122
<a name="l00123"></a>00123 _dbus_assert (old_refcount == 0);
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125 <span class="preprocessor">#endif</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span>
<a name="l00127"></a>00127 server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00128"></a>00128 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00129"></a>00129 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00130"></a>00130 server-><a class="code" href="structDBusServer.html#a01a6dbb2573ce35f639873cd4dd85b4d" title="flag which indicates that server has published its bus address.">published_address</a> = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00131"></a>00131
<a name="l00132"></a>00132 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusString.html#ga348252317f7bb8ac43529972945830ae" title="Initializes a string.">_dbus_string_init</a> (&server-><a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>))
<a name="l00133"></a>00133 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00134"></a>00134
<a name="l00135"></a>00135 <a class="code" href="group__DBusInternalsUtils.html#ga08c2922335845e5c857e88399436b9ba" title="Generates a new UUID.">_dbus_generate_uuid</a> (&server-><a class="code" href="structDBusServer.html#a799a94be0e3078f2e636f322f57d66f9" title="Globally unique ID of server.">guid</a>);
<a name="l00136"></a>00136
<a name="l00137"></a>00137 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusInternalsUtils.html#gaf08364813376bd2d8f455d435d85323e" title="Hex-encode a UUID.">_dbus_uuid_encode</a> (&server-><a class="code" href="structDBusServer.html#a799a94be0e3078f2e636f322f57d66f9" title="Globally unique ID of server.">guid</a>, &server-><a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>))
<a name="l00138"></a>00138 <span class="keywordflow">goto</span> failed;
<a name="l00139"></a>00139
<a name="l00140"></a>00140 server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a> = copy_address_with_guid_appended (address,
<a name="l00141"></a>00141 &server-><a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>);
<a name="l00142"></a>00142 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00143"></a>00143 <span class="keywordflow">goto</span> failed;
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <a class="code" href="group__DBusThreadsInternals.html#ga191deedb97c76fae82bdbc8e1559a849" title="Creates a new mutex or creates a no-op mutex if threads are not initialized.">_dbus_rmutex_new_at_location</a> (&server-><a class="code" href="structDBusServer.html#a89c4751e61ed16591254b00cb9db1661" title="Lock on the server object.">mutex</a>);
<a name="l00146"></a>00146 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#a89c4751e61ed16591254b00cb9db1661" title="Lock on the server object.">mutex</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00147"></a>00147 <span class="keywordflow">goto</span> failed;
<a name="l00148"></a>00148
<a name="l00149"></a>00149 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = <a class="code" href="group__DBusWatchInternals.html#ga5d9db5d0af5916a5ec890eb38d5741eb" title="Creates a new watch list.">_dbus_watch_list_new</a> ();
<a name="l00150"></a>00150 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00151"></a>00151 <span class="keywordflow">goto</span> failed;
<a name="l00152"></a>00152
<a name="l00153"></a>00153 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = <a class="code" href="group__DBusTimeoutInternals.html#ga5b122b35cdb3926b7dc2d084ddff9d62" title="Creates a new timeout list.">_dbus_timeout_list_new</a> ();
<a name="l00154"></a>00154 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00155"></a>00155 <span class="keywordflow">goto</span> failed;
<a name="l00156"></a>00156
<a name="l00157"></a>00157 <a class="code" href="group__DBusDataSlot.html#ga6de49b3a1210202215d40a5a19806992" title="Initializes a slot list.">_dbus_data_slot_list_init</a> (&server-><a class="code" href="structDBusServer.html#a0601cca8307ba17d4a8bcebe48b08362" title="Data stored by allocated integer ID.">slot_list</a>);
<a name="l00158"></a>00158
<a name="l00159"></a>00159 _dbus_verbose (<span class="stringliteral">"Initialized server on address %s\n"</span>, server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a>);
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00162"></a>00162
<a name="l00163"></a>00163 failed:
<a name="l00164"></a>00164 <a class="code" href="group__DBusThreadsInternals.html#gae1c95a3f47bcc78d32fc0a5a8ed37c91" title="Frees a DBusRMutex; does nothing if passed a NULL pointer.">_dbus_rmutex_free_at_location</a> (&server-><a class="code" href="structDBusServer.html#a89c4751e61ed16591254b00cb9db1661" title="Lock on the server object.">mutex</a>);
<a name="l00165"></a>00165 server-><a class="code" href="structDBusServer.html#a89c4751e61ed16591254b00cb9db1661" title="Lock on the server object.">mutex</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00166"></a>00166 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a>)
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168 <a class="code" href="group__DBusWatchInternals.html#gac3f75c0da2c8c51e8708f45dd27f9e2d" title="Frees a DBusWatchList.">_dbus_watch_list_free</a> (server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a>);
<a name="l00169"></a>00169 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00170"></a>00170 }
<a name="l00171"></a>00171 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a>)
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173 <a class="code" href="group__DBusTimeoutInternals.html#ga1b399ef2d7f128e59bb32dbb5b590e1b" title="Frees a DBusTimeoutList.">_dbus_timeout_list_free</a> (server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a>);
<a name="l00174"></a>00174 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 <span class="keywordflow">if</span> (server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a>)
<a name="l00177"></a>00177 {
<a name="l00178"></a>00178 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a>);
<a name="l00179"></a>00179 server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&server-><a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>);
<a name="l00182"></a>00182
<a name="l00183"></a>00183 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00192"></a>00192 <span class="keywordtype">void</span>
<a name="l00193"></a><a class="code" href="group__DBusServerInternals.html#ga93b5bca90e69122d5acbbeef2b4ca03e">00193</a> <a class="code" href="group__DBusServerInternals.html#ga93b5bca90e69122d5acbbeef2b4ca03e" title="Finalizes the members of the DBusServer base class.">_dbus_server_finalize_base</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 <span class="comment">/* We don't have the lock, but nobody should be accessing</span>
<a name="l00196"></a>00196 <span class="comment"> * concurrently since they don't have a ref</span>
<a name="l00197"></a>00197 <span class="comment"> */</span>
<a name="l00198"></a>00198 <span class="preprocessor">#ifndef DBUS_DISABLE_CHECKS</span>
<a name="l00199"></a>00199 <span class="preprocessor"></span> _dbus_assert (!server-><a class="code" href="structDBusServer.html#adba8dd016471a800525a42926f9ee061" title="Does someone have the server mutex locked.">have_server_lock</a>);
<a name="l00200"></a>00200 <span class="preprocessor">#endif</span>
<a name="l00201"></a>00201 <span class="preprocessor"></span> _dbus_assert (server-><a class="code" href="structDBusServer.html#a7dabb30cdc09d6102810029fb56b8dfe" title="TRUE if we are disconnected.">disconnected</a>);
<a name="l00202"></a>00202
<a name="l00203"></a>00203 <span class="comment">/* calls out to application code... */</span>
<a name="l00204"></a>00204 <a class="code" href="group__DBusDataSlot.html#gabc399733376c462c3010271a2d431e73" title="Frees the data slot list and all data slots contained in it, calling application-provided free functi...">_dbus_data_slot_list_free</a> (&server-><a class="code" href="structDBusServer.html#a0601cca8307ba17d4a8bcebe48b08362" title="Data stored by allocated integer ID.">slot_list</a>);
<a name="l00205"></a>00205
<a name="l00206"></a>00206 <a class="code" href="group__DBusServer.html#gaa14d9109e04adccffd9a40460c28c53b" title="Sets a function to be used for handling new connections.">dbus_server_set_new_connection_function</a> (server, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00207"></a>00207
<a name="l00208"></a>00208 <a class="code" href="group__DBusWatchInternals.html#gac3f75c0da2c8c51e8708f45dd27f9e2d" title="Frees a DBusWatchList.">_dbus_watch_list_free</a> (server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a>);
<a name="l00209"></a>00209 <a class="code" href="group__DBusTimeoutInternals.html#ga1b399ef2d7f128e59bb32dbb5b590e1b" title="Frees a DBusTimeoutList.">_dbus_timeout_list_free</a> (server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a>);
<a name="l00210"></a>00210
<a name="l00211"></a>00211 <a class="code" href="group__DBusThreadsInternals.html#gae1c95a3f47bcc78d32fc0a5a8ed37c91" title="Frees a DBusRMutex; does nothing if passed a NULL pointer.">_dbus_rmutex_free_at_location</a> (&server-><a class="code" href="structDBusServer.html#a89c4751e61ed16591254b00cb9db1661" title="Lock on the server object.">mutex</a>);
<a name="l00212"></a>00212
<a name="l00213"></a>00213 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a>);
<a name="l00214"></a>00214
<a name="l00215"></a>00215 <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (server-><a class="code" href="structDBusServer.html#adc1032bbed41413e5d0e01578f2bfffc" title="Array of allowed authentication mechanisms.">auth_mechanisms</a>);
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <a class="code" href="group__DBusString.html#ga781ca91acda49a834dce7d0ed0eef212" title="Frees a string created by _dbus_string_init().">_dbus_string_free</a> (&server-><a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>);
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00220"></a>00220
<a name="l00222"></a><a class="code" href="group__DBusServerInternals.html#gab3c673c1e36e293c5f2baa92418603a3">00222</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusConnectionInternals.html#gab3c673c1e36e293c5f2baa92418603a3" title="Function to be called in protected_change_watch() with refcount held.">DBusWatchAddFunction</a>) (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *list,
<a name="l00223"></a>00223 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch);
<a name="l00225"></a><a class="code" href="group__DBusServerInternals.html#ga475a0e9a2f2b7a279ba07fa3352114d4">00225</a> <span class="keyword">typedef</span> void (* <a class="code" href="group__DBusConnectionInternals.html#ga475a0e9a2f2b7a279ba07fa3352114d4" title="Function to be called in protected_change_watch() with refcount held.">DBusWatchRemoveFunction</a>) (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *list,
<a name="l00226"></a>00226 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch);
<a name="l00228"></a><a class="code" href="group__DBusServerInternals.html#ga851f0958d46980f5a39bcfb874a4cb78">00228</a> <span class="keyword">typedef</span> void (* <a class="code" href="group__DBusConnectionInternals.html#ga851f0958d46980f5a39bcfb874a4cb78" title="Function to be called in protected_change_watch() with refcount held.">DBusWatchToggleFunction</a>) (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *list,
<a name="l00229"></a>00229 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch,
<a name="l00230"></a>00230 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> enabled);
<a name="l00231"></a>00231
<a name="l00232"></a>00232 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00233"></a>00233 protected_change_watch (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00234"></a>00234 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch,
<a name="l00235"></a>00235 <a class="code" href="group__DBusConnectionInternals.html#gab3c673c1e36e293c5f2baa92418603a3" title="Function to be called in protected_change_watch() with refcount held.">DBusWatchAddFunction</a> add_function,
<a name="l00236"></a>00236 <a class="code" href="group__DBusConnectionInternals.html#ga475a0e9a2f2b7a279ba07fa3352114d4" title="Function to be called in protected_change_watch() with refcount held.">DBusWatchRemoveFunction</a> remove_function,
<a name="l00237"></a>00237 <a class="code" href="group__DBusConnectionInternals.html#ga851f0958d46980f5a39bcfb874a4cb78" title="Function to be called in protected_change_watch() with refcount held.">DBusWatchToggleFunction</a> toggle_function,
<a name="l00238"></a>00238 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> enabled)
<a name="l00239"></a>00239 {
<a name="l00240"></a>00240 <a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *watches;
<a name="l00241"></a>00241 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00242"></a>00242
<a name="l00243"></a>00243 HAVE_LOCK_CHECK (server);
<a name="l00244"></a>00244
<a name="l00245"></a>00245 <span class="comment">/* This isn't really safe or reasonable; a better pattern is the "do</span>
<a name="l00246"></a>00246 <span class="comment"> * everything, then drop lock and call out" one; but it has to be</span>
<a name="l00247"></a>00247 <span class="comment"> * propagated up through all callers</span>
<a name="l00248"></a>00248 <span class="comment"> */</span>
<a name="l00249"></a>00249
<a name="l00250"></a>00250 watches = server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a>;
<a name="l00251"></a>00251 <span class="keywordflow">if</span> (watches)
<a name="l00252"></a>00252 {
<a name="l00253"></a>00253 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00254"></a>00254 <a class="code" href="group__DBusServerInternals.html#ga987e9bf42ab4e4cededa8e8f65c54e2e" title="Like dbus_server_ref() but does not acquire the lock (must already be held)">_dbus_server_ref_unlocked</a> (server);
<a name="l00255"></a>00255 SERVER_UNLOCK (server);
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="keywordflow">if</span> (add_function)
<a name="l00258"></a>00258 retval = (* add_function) (watches, watch);
<a name="l00259"></a>00259 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (remove_function)
<a name="l00260"></a>00260 {
<a name="l00261"></a>00261 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00262"></a>00262 (* remove_function) (watches, watch);
<a name="l00263"></a>00263 }
<a name="l00264"></a>00264 <span class="keywordflow">else</span>
<a name="l00265"></a>00265 {
<a name="l00266"></a>00266 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00267"></a>00267 (* toggle_function) (watches, watch, enabled);
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269
<a name="l00270"></a>00270 SERVER_LOCK (server);
<a name="l00271"></a>00271 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = watches;
<a name="l00272"></a>00272 <a class="code" href="group__DBusServerInternals.html#ga6e1d0b379c98b0d59ebd19dc9b8a2dbe" title="Like dbus_server_unref() but does not acquire the lock (must already be held)">_dbus_server_unref_unlocked</a> (server);
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="keywordflow">return</span> retval;
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276 <span class="keywordflow">else</span>
<a name="l00277"></a>00277 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279
<a name="l00287"></a>00287 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00288"></a><a class="code" href="group__DBusServerInternals.html#ga0866e5b205b8a570c77c8ad787b665fd">00288</a> <a class="code" href="group__DBusServerInternals.html#ga0866e5b205b8a570c77c8ad787b665fd" title="Adds a watch for this server, chaining out to application-provided watch handlers.">_dbus_server_add_watch</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00289"></a>00289 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00290"></a>00290 {
<a name="l00291"></a>00291 HAVE_LOCK_CHECK (server);
<a name="l00292"></a>00292 <span class="keywordflow">return</span> protected_change_watch (server, watch,
<a name="l00293"></a>00293 <a class="code" href="group__DBusWatchInternals.html#gaec61655a4bd6186a6a1ec104771d8af5" title="Adds a new watch to the watch list, invoking the application DBusAddWatchFunction if appropriate...">_dbus_watch_list_add_watch</a>,
<a name="l00294"></a>00294 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00295"></a>00295 }
<a name="l00296"></a>00296
<a name="l00303"></a>00303 <span class="keywordtype">void</span>
<a name="l00304"></a><a class="code" href="group__DBusServerInternals.html#ga61cfdbfcc9316d4bae55f83b069f248c">00304</a> <a class="code" href="group__DBusServerInternals.html#ga61cfdbfcc9316d4bae55f83b069f248c" title="Removes a watch previously added with _dbus_server_remove_watch().">_dbus_server_remove_watch</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00305"></a>00305 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00306"></a>00306 {
<a name="l00307"></a>00307 HAVE_LOCK_CHECK (server);
<a name="l00308"></a>00308 protected_change_watch (server, watch,
<a name="l00309"></a>00309 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00310"></a>00310 <a class="code" href="group__DBusWatchInternals.html#ga76894d297bc7d7d23cbacdc2b1778884" title="Removes a watch from the watch list, invoking the application's DBusRemoveWatchFunction if appropriat...">_dbus_watch_list_remove_watch</a>,
<a name="l00311"></a>00311 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313
<a name="l00321"></a>00321 <span class="keywordtype">void</span>
<a name="l00322"></a><a class="code" href="group__DBusServerInternals.html#gabdc55833c157737f5cb8b3662f8fc0ed">00322</a> <a class="code" href="group__DBusServerInternals.html#gabdc55833c157737f5cb8b3662f8fc0ed" title="Toggles all watch and notifies app via server's DBusWatchToggledFunction if available.">_dbus_server_toggle_all_watches</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00323"></a>00323 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> enabled)
<a name="l00324"></a>00324 {
<a name="l00325"></a>00325 <a class="code" href="group__DBusWatchInternals.html#ga935ba95d94a14aee79d80abe970eae53" title="Sets all watches to the given enabled state, invoking the application's DBusWatchToggledFunction if a...">_dbus_watch_list_toggle_all_watches</a> (server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a>, enabled);
<a name="l00326"></a>00326 }
<a name="l00327"></a>00327
<a name="l00329"></a><a class="code" href="group__DBusServerInternals.html#ga6ca28a0af7de84c51fdbafe8786d3446">00329</a> <span class="keyword">typedef</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> (* <a class="code" href="group__DBusConnectionInternals.html#ga6ca28a0af7de84c51fdbafe8786d3446" title="Function to be called in protected_change_timeout() with refcount held.">DBusTimeoutAddFunction</a>) (<a class="code" href="structDBusTimeoutList.html" title="DBusTimeoutList implementation details.">DBusTimeoutList</a> *list,
<a name="l00330"></a>00330 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout);
<a name="l00332"></a><a class="code" href="group__DBusServerInternals.html#gafe75d05f2abf712c7fe13691ef27754c">00332</a> <span class="keyword">typedef</span> void (* <a class="code" href="group__DBusConnectionInternals.html#gafe75d05f2abf712c7fe13691ef27754c" title="Function to be called in protected_change_timeout() with refcount held.">DBusTimeoutRemoveFunction</a>) (<a class="code" href="structDBusTimeoutList.html" title="DBusTimeoutList implementation details.">DBusTimeoutList</a> *list,
<a name="l00333"></a>00333 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout);
<a name="l00335"></a><a class="code" href="group__DBusServerInternals.html#ga1b4c97e7ef6f2cb8704cf74acc03c727">00335</a> <span class="keyword">typedef</span> void (* <a class="code" href="group__DBusConnectionInternals.html#ga1b4c97e7ef6f2cb8704cf74acc03c727" title="Function to be called in protected_change_timeout() with refcount held.">DBusTimeoutToggleFunction</a>) (<a class="code" href="structDBusTimeoutList.html" title="DBusTimeoutList implementation details.">DBusTimeoutList</a> *list,
<a name="l00336"></a>00336 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout,
<a name="l00337"></a>00337 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> enabled);
<a name="l00338"></a>00338
<a name="l00339"></a>00339
<a name="l00340"></a>00340 <span class="keyword">static</span> <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00341"></a>00341 protected_change_timeout (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00342"></a>00342 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout,
<a name="l00343"></a>00343 <a class="code" href="group__DBusConnectionInternals.html#ga6ca28a0af7de84c51fdbafe8786d3446" title="Function to be called in protected_change_timeout() with refcount held.">DBusTimeoutAddFunction</a> add_function,
<a name="l00344"></a>00344 <a class="code" href="group__DBusConnectionInternals.html#gafe75d05f2abf712c7fe13691ef27754c" title="Function to be called in protected_change_timeout() with refcount held.">DBusTimeoutRemoveFunction</a> remove_function,
<a name="l00345"></a>00345 <a class="code" href="group__DBusConnectionInternals.html#ga1b4c97e7ef6f2cb8704cf74acc03c727" title="Function to be called in protected_change_timeout() with refcount held.">DBusTimeoutToggleFunction</a> toggle_function,
<a name="l00346"></a>00346 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> enabled)
<a name="l00347"></a>00347 {
<a name="l00348"></a>00348 <a class="code" href="structDBusTimeoutList.html" title="DBusTimeoutList implementation details.">DBusTimeoutList</a> *timeouts;
<a name="l00349"></a>00349 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00350"></a>00350
<a name="l00351"></a>00351 HAVE_LOCK_CHECK (server);
<a name="l00352"></a>00352
<a name="l00353"></a>00353 <span class="comment">/* This isn't really safe or reasonable; a better pattern is the "do everything, then</span>
<a name="l00354"></a>00354 <span class="comment"> * drop lock and call out" one; but it has to be propagated up through all callers</span>
<a name="l00355"></a>00355 <span class="comment"> */</span>
<a name="l00356"></a>00356
<a name="l00357"></a>00357 timeouts = server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a>;
<a name="l00358"></a>00358 <span class="keywordflow">if</span> (timeouts)
<a name="l00359"></a>00359 {
<a name="l00360"></a>00360 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00361"></a>00361 <a class="code" href="group__DBusServerInternals.html#ga987e9bf42ab4e4cededa8e8f65c54e2e" title="Like dbus_server_ref() but does not acquire the lock (must already be held)">_dbus_server_ref_unlocked</a> (server);
<a name="l00362"></a>00362 SERVER_UNLOCK (server);
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="keywordflow">if</span> (add_function)
<a name="l00365"></a>00365 retval = (* add_function) (timeouts, timeout);
<a name="l00366"></a>00366 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (remove_function)
<a name="l00367"></a>00367 {
<a name="l00368"></a>00368 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00369"></a>00369 (* remove_function) (timeouts, timeout);
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371 <span class="keywordflow">else</span>
<a name="l00372"></a>00372 {
<a name="l00373"></a>00373 retval = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00374"></a>00374 (* toggle_function) (timeouts, timeout, enabled);
<a name="l00375"></a>00375 }
<a name="l00376"></a>00376
<a name="l00377"></a>00377 SERVER_LOCK (server);
<a name="l00378"></a>00378 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = timeouts;
<a name="l00379"></a>00379 <a class="code" href="group__DBusServerInternals.html#ga6e1d0b379c98b0d59ebd19dc9b8a2dbe" title="Like dbus_server_unref() but does not acquire the lock (must already be held)">_dbus_server_unref_unlocked</a> (server);
<a name="l00380"></a>00380
<a name="l00381"></a>00381 <span class="keywordflow">return</span> retval;
<a name="l00382"></a>00382 }
<a name="l00383"></a>00383 <span class="keywordflow">else</span>
<a name="l00384"></a>00384 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00385"></a>00385 }
<a name="l00386"></a>00386
<a name="l00396"></a>00396 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00397"></a><a class="code" href="group__DBusServerInternals.html#ga7e10a662386fb7f693e0d168161e395b">00397</a> <a class="code" href="group__DBusServerInternals.html#ga7e10a662386fb7f693e0d168161e395b" title="Adds a timeout for this server, chaining out to application-provided timeout handlers.">_dbus_server_add_timeout</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00398"></a>00398 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout)
<a name="l00399"></a>00399 {
<a name="l00400"></a>00400 <span class="keywordflow">return</span> protected_change_timeout (server, timeout,
<a name="l00401"></a>00401 <a class="code" href="group__DBusTimeoutInternals.html#ga14955f061551ece122808b9e6ddc0757" title="Adds a new timeout to the timeout list, invoking the application DBusAddTimeoutFunction if appropriat...">_dbus_timeout_list_add_timeout</a>,
<a name="l00402"></a>00402 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00403"></a>00403 }
<a name="l00404"></a>00404
<a name="l00411"></a>00411 <span class="keywordtype">void</span>
<a name="l00412"></a><a class="code" href="group__DBusServerInternals.html#ga69509697f091e354442cedb63886c20e">00412</a> <a class="code" href="group__DBusServerInternals.html#ga69509697f091e354442cedb63886c20e" title="Removes a timeout previously added with _dbus_server_add_timeout().">_dbus_server_remove_timeout</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00413"></a>00413 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout)
<a name="l00414"></a>00414 {
<a name="l00415"></a>00415 protected_change_timeout (server, timeout,
<a name="l00416"></a>00416 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00417"></a>00417 <a class="code" href="group__DBusTimeoutInternals.html#gaec0ffafdcac87f23878a2ddded044822" title="Removes a timeout from the timeout list, invoking the application's DBusRemoveTimeoutFunction if appr...">_dbus_timeout_list_remove_timeout</a>,
<a name="l00418"></a>00418 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00419"></a>00419 }
<a name="l00420"></a>00420
<a name="l00430"></a>00430 <span class="keywordtype">void</span>
<a name="l00431"></a><a class="code" href="group__DBusServerInternals.html#ga74d2714ce80a089d2607a6fc5763d819">00431</a> <a class="code" href="group__DBusServerInternals.html#ga74d2714ce80a089d2607a6fc5763d819" title="Toggles a timeout and notifies app via server's DBusTimeoutToggledFunction if available.">_dbus_server_toggle_timeout</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00432"></a>00432 <a class="code" href="structDBusTimeout.html" title="Internals of DBusTimeout.">DBusTimeout</a> *timeout,
<a name="l00433"></a>00433 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> enabled)
<a name="l00434"></a>00434 {
<a name="l00435"></a>00435 protected_change_timeout (server, timeout,
<a name="l00436"></a>00436 <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>,
<a name="l00437"></a>00437 <a class="code" href="group__DBusTimeoutInternals.html#ga3d1ee0968a47651c5428ebf48711b217" title="Sets a timeout to the given enabled state, invoking the application's DBusTimeoutToggledFunction if a...">_dbus_timeout_list_toggle_timeout</a>,
<a name="l00438"></a>00438 enabled);
<a name="l00439"></a>00439 }
<a name="l00440"></a>00440
<a name="l00441"></a>00441
<a name="l00447"></a>00447 <span class="keywordtype">void</span>
<a name="l00448"></a><a class="code" href="group__DBusServerInternals.html#ga987e9bf42ab4e4cededa8e8f65c54e2e">00448</a> <a class="code" href="group__DBusServerInternals.html#ga987e9bf42ab4e4cededa8e8f65c54e2e" title="Like dbus_server_ref() but does not acquire the lock (must already be held)">_dbus_server_ref_unlocked</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00449"></a>00449 {
<a name="l00450"></a>00450 <a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> old_refcount;
<a name="l00451"></a>00451
<a name="l00452"></a>00452 _dbus_assert (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00453"></a>00453 HAVE_LOCK_CHECK (server);
<a name="l00454"></a>00454
<a name="l00455"></a>00455 old_refcount = <a class="code" href="group__DBusSysdeps.html#gae74c3fcf12acaeccdb152ef907de951c" title="Atomically increments an integer.">_dbus_atomic_inc</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00456"></a>00456 _dbus_assert (old_refcount > 0);
<a name="l00457"></a>00457 _dbus_server_trace_ref (server, old_refcount, old_refcount + 1,
<a name="l00458"></a>00458 <span class="stringliteral">"ref_unlocked"</span>);
<a name="l00459"></a>00459 }
<a name="l00460"></a>00460
<a name="l00466"></a>00466 <span class="keywordtype">void</span>
<a name="l00467"></a><a class="code" href="group__DBusServerInternals.html#ga6e1d0b379c98b0d59ebd19dc9b8a2dbe">00467</a> <a class="code" href="group__DBusServerInternals.html#ga6e1d0b379c98b0d59ebd19dc9b8a2dbe" title="Like dbus_server_unref() but does not acquire the lock (must already be held)">_dbus_server_unref_unlocked</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00468"></a>00468 {
<a name="l00469"></a>00469 <a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> old_refcount;
<a name="l00470"></a>00470
<a name="l00471"></a>00471 <span class="comment">/* Keep this in sync with dbus_server_unref */</span>
<a name="l00472"></a>00472
<a name="l00473"></a>00473 _dbus_assert (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00474"></a>00474
<a name="l00475"></a>00475 HAVE_LOCK_CHECK (server);
<a name="l00476"></a>00476
<a name="l00477"></a>00477 old_refcount = <a class="code" href="group__DBusSysdeps.html#ga3c50a069f795dceeb9172fe2b517bbdc" title="Atomically decrement an integer.">_dbus_atomic_dec</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00478"></a>00478 _dbus_assert (old_refcount > 0);
<a name="l00479"></a>00479
<a name="l00480"></a>00480 _dbus_server_trace_ref (server, old_refcount, old_refcount - 1,
<a name="l00481"></a>00481 <span class="stringliteral">"unref_unlocked"</span>);
<a name="l00482"></a>00482
<a name="l00483"></a>00483 <span class="keywordflow">if</span> (old_refcount == 1)
<a name="l00484"></a>00484 {
<a name="l00485"></a>00485 _dbus_assert (server-><a class="code" href="structDBusServer.html#a7dabb30cdc09d6102810029fb56b8dfe" title="TRUE if we are disconnected.">disconnected</a>);
<a name="l00486"></a>00486
<a name="l00487"></a>00487 SERVER_UNLOCK (server);
<a name="l00488"></a>00488
<a name="l00489"></a>00489 _dbus_assert (server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a>-><a class="code" href="structDBusServerVTable.html#acd97315e812352da38449f910775b08d" title="The finalize method must free the server.">finalize</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00490"></a>00490
<a name="l00491"></a>00491 (* server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a>-><a class="code" href="structDBusServerVTable.html#acd97315e812352da38449f910775b08d" title="The finalize method must free the server.">finalize</a>) (server);
<a name="l00492"></a>00492 }
<a name="l00493"></a>00493 }
<a name="l00494"></a>00494
<a name="l00516"></a>00516 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">struct </span>{
<a name="l00517"></a>00517 DBusServerListenResult (* func) (<a class="code" href="structDBusAddressEntry.html" title="Internals of DBusAddressEntry.">DBusAddressEntry</a> *entry,
<a name="l00518"></a>00518 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> **server_p,
<a name="l00519"></a>00519 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> *error);
<a name="l00520"></a>00520 } listen_funcs[] = {
<a name="l00521"></a>00521 { <a class="code" href="group__DBusServerSocket.html#ga90a89943c15760592e5ddce31bf0e021" title="Tries to interpret the address entry for various socket-related addresses (well, currently only tcp a...">_dbus_server_listen_socket</a> }
<a name="l00522"></a>00522 , { <a class="code" href="group__DBusServerUnix.html#gaec00cdf4977b9bd33621df684406a779" title="Tries to interpret the address entry in a platform-specific way, creating a platform-specific server ...">_dbus_server_listen_platform_specific</a> }
<a name="l00523"></a>00523 <span class="preprocessor">#ifdef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l00524"></a>00524 <span class="preprocessor"></span> , { _dbus_server_listen_debug_pipe }
<a name="l00525"></a>00525 <span class="preprocessor">#endif</span>
<a name="l00526"></a>00526 <span class="preprocessor"></span>};
<a name="l00527"></a>00527
<a name="l00548"></a>00548 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a>*
<a name="l00549"></a><a class="code" href="group__DBusServer.html#ga4c83cf9f2c186afa97decdc25ac163d8">00549</a> <a class="code" href="group__DBusServer.html#ga4c83cf9f2c186afa97decdc25ac163d8" title="Listens for new connections on the given address.">dbus_server_listen</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *address,
<a name="l00550"></a>00550 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> *error)
<a name="l00551"></a>00551 {
<a name="l00552"></a>00552 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server;
<a name="l00553"></a>00553 <a class="code" href="structDBusAddressEntry.html" title="Internals of DBusAddressEntry.">DBusAddressEntry</a> **entries;
<a name="l00554"></a>00554 <span class="keywordtype">int</span> len, i;
<a name="l00555"></a>00555 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> first_connect_error = <a class="code" href="group__DBusErrorInternals.html#ga961cc70e3891282a65205c4c8418d88e" title="Expands to a suitable initializer for a DBusError on the stack.">DBUS_ERROR_INIT</a>;
<a name="l00556"></a>00556 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> handled_once;
<a name="l00557"></a>00557
<a name="l00558"></a>00558 _dbus_return_val_if_fail (address != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00559"></a>00559 _dbus_return_val_if_error_is_set (error, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00560"></a>00560
<a name="l00561"></a>00561 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusAddress.html#ga3cbf5947262b79601598276c720e2098" title="Parses an address string of the form:">dbus_parse_address</a> (address, &entries, &len, error))
<a name="l00562"></a>00562 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00563"></a>00563
<a name="l00564"></a>00564 server = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00565"></a>00565 handled_once = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00566"></a>00566
<a name="l00567"></a>00567 <span class="keywordflow">for</span> (i = 0; i < len; i++)
<a name="l00568"></a>00568 {
<a name="l00569"></a>00569 <span class="keywordtype">int</span> j;
<a name="l00570"></a>00570
<a name="l00571"></a>00571 <span class="keywordflow">for</span> (j = 0; j < (int) _DBUS_N_ELEMENTS (listen_funcs); ++j)
<a name="l00572"></a>00572 {
<a name="l00573"></a>00573 DBusServerListenResult result;
<a name="l00574"></a>00574 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> tmp_error = <a class="code" href="group__DBusErrorInternals.html#ga961cc70e3891282a65205c4c8418d88e" title="Expands to a suitable initializer for a DBusError on the stack.">DBUS_ERROR_INIT</a>;
<a name="l00575"></a>00575
<a name="l00576"></a>00576 result = (* listen_funcs[j].func) (entries[i],
<a name="l00577"></a>00577 &server,
<a name="l00578"></a>00578 &tmp_error);
<a name="l00579"></a>00579
<a name="l00580"></a>00580 <span class="keywordflow">if</span> (result == DBUS_SERVER_LISTEN_OK)
<a name="l00581"></a>00581 {
<a name="l00582"></a>00582 _dbus_assert (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00583"></a>00583 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
<a name="l00584"></a>00584 handled_once = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00585"></a>00585 <span class="keywordflow">goto</span> out;
<a name="l00586"></a>00586 }
<a name="l00587"></a>00587 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result == DBUS_SERVER_LISTEN_ADDRESS_ALREADY_USED)
<a name="l00588"></a>00588 {
<a name="l00589"></a>00589 _dbus_assert (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00590"></a>00590 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error,
<a name="l00591"></a>00591 <a class="code" href="group__DBusProtocol.html#ga3d13424a19bb774cf3481216bf4ba366" title="Can't bind a socket since its address is in use (i.e.">DBUS_ERROR_ADDRESS_IN_USE</a>,
<a name="l00592"></a>00592 <span class="stringliteral">"Address '%s' already used"</span>,
<a name="l00593"></a>00593 <a class="code" href="group__DBusAddress.html#ga7e6b2572d6e637826acada01377b5487" title="Returns the method string of an address entry.">dbus_address_entry_get_method</a> (entries[0]));
<a name="l00594"></a>00594 handled_once = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00595"></a>00595 <span class="keywordflow">goto</span> out;
<a name="l00596"></a>00596 }
<a name="l00597"></a>00597 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result == DBUS_SERVER_LISTEN_BAD_ADDRESS)
<a name="l00598"></a>00598 {
<a name="l00599"></a>00599 _dbus_assert (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00600"></a>00600 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
<a name="l00601"></a>00601 <a class="code" href="group__DBusErrors.html#ga0a27fb9f1af0c2bfd105d7e8622b93f4" title="Moves an error src into dest, freeing src and overwriting dest.">dbus_move_error</a> (&tmp_error, error);
<a name="l00602"></a>00602 handled_once = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00603"></a>00603 <span class="keywordflow">goto</span> out;
<a name="l00604"></a>00604 }
<a name="l00605"></a>00605 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result == DBUS_SERVER_LISTEN_NOT_HANDLED)
<a name="l00606"></a>00606 {
<a name="l00607"></a>00607 _dbus_assert (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00608"></a>00608 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
<a name="l00609"></a>00609
<a name="l00610"></a>00610 <span class="comment">/* keep trying addresses */</span>
<a name="l00611"></a>00611 }
<a name="l00612"></a>00612 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (result == DBUS_SERVER_LISTEN_DID_NOT_CONNECT)
<a name="l00613"></a>00613 {
<a name="l00614"></a>00614 _dbus_assert (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00615"></a>00615 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
<a name="l00616"></a>00616 <span class="keywordflow">if</span> (!<a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&first_connect_error))
<a name="l00617"></a>00617 <a class="code" href="group__DBusErrors.html#ga0a27fb9f1af0c2bfd105d7e8622b93f4" title="Moves an error src into dest, freeing src and overwriting dest.">dbus_move_error</a> (&tmp_error, &first_connect_error);
<a name="l00618"></a>00618 <span class="keywordflow">else</span>
<a name="l00619"></a>00619 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&tmp_error);
<a name="l00620"></a>00620
<a name="l00621"></a>00621 handled_once = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00622"></a>00622
<a name="l00623"></a>00623 <span class="comment">/* keep trying addresses */</span>
<a name="l00624"></a>00624 }
<a name="l00625"></a>00625 }
<a name="l00626"></a>00626
<a name="l00627"></a>00627 _dbus_assert (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00628"></a>00628 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00629"></a>00629 }
<a name="l00630"></a>00630
<a name="l00631"></a>00631 out:
<a name="l00632"></a>00632
<a name="l00633"></a>00633 <span class="keywordflow">if</span> (!handled_once)
<a name="l00634"></a>00634 {
<a name="l00635"></a>00635 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00636"></a>00636 <span class="keywordflow">if</span> (len > 0)
<a name="l00637"></a>00637 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error,
<a name="l00638"></a>00638 <a class="code" href="group__DBusProtocol.html#ga3fa04eb600edda4afc2dd9fe2e0f8b02" title="A D-Bus bus address was malformed.">DBUS_ERROR_BAD_ADDRESS</a>,
<a name="l00639"></a>00639 <span class="stringliteral">"Unknown address type '%s'"</span>,
<a name="l00640"></a>00640 <a class="code" href="group__DBusAddress.html#ga7e6b2572d6e637826acada01377b5487" title="Returns the method string of an address entry.">dbus_address_entry_get_method</a> (entries[0]));
<a name="l00641"></a>00641 <span class="keywordflow">else</span>
<a name="l00642"></a>00642 <a class="code" href="group__DBusErrors.html#ga89d2ad4bde21f9e0057fac07a79885e3" title="Assigns an error name and message to a DBusError.">dbus_set_error</a> (error,
<a name="l00643"></a>00643 <a class="code" href="group__DBusProtocol.html#ga3fa04eb600edda4afc2dd9fe2e0f8b02" title="A D-Bus bus address was malformed.">DBUS_ERROR_BAD_ADDRESS</a>,
<a name="l00644"></a>00644 <span class="stringliteral">"Empty address '%s'"</span>,
<a name="l00645"></a>00645 address);
<a name="l00646"></a>00646 }
<a name="l00647"></a>00647
<a name="l00648"></a>00648 <a class="code" href="group__DBusAddress.html#ga37a7009b07cf991ff07f3e86d71bf352" title="Frees a NULL-terminated array of address entries.">dbus_address_entries_free</a> (entries);
<a name="l00649"></a>00649
<a name="l00650"></a>00650 <span class="keywordflow">if</span> (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00651"></a>00651 {
<a name="l00652"></a>00652 _dbus_assert (error == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> || <a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&first_connect_error) ||
<a name="l00653"></a>00653 <a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (error));
<a name="l00654"></a>00654
<a name="l00655"></a>00655 <span class="keywordflow">if</span> (error && <a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (error))
<a name="l00656"></a>00656 {
<a name="l00657"></a>00657 <span class="comment">/* already set the error */</span>
<a name="l00658"></a>00658 }
<a name="l00659"></a>00659 <span class="keywordflow">else</span>
<a name="l00660"></a>00660 {
<a name="l00661"></a>00661 <span class="comment">/* didn't set the error but either error should be</span>
<a name="l00662"></a>00662 <span class="comment"> * NULL or first_connect_error should be set.</span>
<a name="l00663"></a>00663 <span class="comment"> */</span>
<a name="l00664"></a>00664 _dbus_assert (error == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a> || <a class="code" href="group__DBusErrors.html#gab0ed62e9fc2685897eb2d41467c89405" title="Checks whether an error occurred (the error is set).">dbus_error_is_set</a> (&first_connect_error));
<a name="l00665"></a>00665 <a class="code" href="group__DBusErrors.html#ga0a27fb9f1af0c2bfd105d7e8622b93f4" title="Moves an error src into dest, freeing src and overwriting dest.">dbus_move_error</a> (&first_connect_error, error);
<a name="l00666"></a>00666 }
<a name="l00667"></a>00667
<a name="l00668"></a>00668 _DBUS_ASSERT_ERROR_IS_CLEAR (&first_connect_error); <span class="comment">/* be sure we freed it */</span>
<a name="l00669"></a>00669 _DBUS_ASSERT_ERROR_IS_SET (error);
<a name="l00670"></a>00670
<a name="l00671"></a>00671 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00672"></a>00672 }
<a name="l00673"></a>00673 <span class="keywordflow">else</span>
<a name="l00674"></a>00674 {
<a name="l00675"></a>00675 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
<a name="l00676"></a>00676 <span class="keywordflow">return</span> server;
<a name="l00677"></a>00677 }
<a name="l00678"></a>00678 }
<a name="l00679"></a>00679
<a name="l00686"></a>00686 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *
<a name="l00687"></a><a class="code" href="group__DBusServer.html#gabe1c14264ef6bf3e5fe446ab9bf8b913">00687</a> <a class="code" href="group__DBusServer.html#gabe1c14264ef6bf3e5fe446ab9bf8b913" title="Increments the reference count of a DBusServer.">dbus_server_ref</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00688"></a>00688 {
<a name="l00689"></a>00689 <a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> old_refcount;
<a name="l00690"></a>00690
<a name="l00691"></a>00691 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00692"></a>00692
<a name="l00693"></a>00693 old_refcount = <a class="code" href="group__DBusSysdeps.html#gae74c3fcf12acaeccdb152ef907de951c" title="Atomically increments an integer.">_dbus_atomic_inc</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00694"></a>00694
<a name="l00695"></a>00695 <span class="preprocessor">#ifndef DBUS_DISABLE_CHECKS</span>
<a name="l00696"></a>00696 <span class="preprocessor"></span> <span class="keywordflow">if</span> (_DBUS_UNLIKELY (old_refcount <= 0))
<a name="l00697"></a>00697 {
<a name="l00698"></a>00698 <a class="code" href="group__DBusSysdeps.html#ga3c50a069f795dceeb9172fe2b517bbdc" title="Atomically decrement an integer.">_dbus_atomic_dec</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00699"></a>00699 <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a> (<a class="code" href="group__DBusInternalsUtils.html#ga748d6ccfb8090bf9f0bf338946c8f5e2" title="String used in _dbus_return_if_fail macro.">_dbus_return_if_fail_warning_format</a>,
<a name="l00700"></a>00700 _DBUS_FUNCTION_NAME, <span class="stringliteral">"old_refcount > 0"</span>,
<a name="l00701"></a>00701 __FILE__, __LINE__);
<a name="l00702"></a>00702 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00703"></a>00703 }
<a name="l00704"></a>00704 <span class="preprocessor">#endif</span>
<a name="l00705"></a>00705 <span class="preprocessor"></span>
<a name="l00706"></a>00706 _dbus_server_trace_ref (server, old_refcount, old_refcount + 1, <span class="stringliteral">"ref"</span>);
<a name="l00707"></a>00707
<a name="l00708"></a>00708 <span class="keywordflow">return</span> server;
<a name="l00709"></a>00709 }
<a name="l00710"></a>00710
<a name="l00719"></a>00719 <span class="keywordtype">void</span>
<a name="l00720"></a><a class="code" href="group__DBusServer.html#ga95d0b6cb9795b4919aa08f667807c555">00720</a> <a class="code" href="group__DBusServer.html#ga95d0b6cb9795b4919aa08f667807c555" title="Decrements the reference count of a DBusServer.">dbus_server_unref</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00721"></a>00721 {
<a name="l00722"></a>00722 <a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> old_refcount;
<a name="l00723"></a>00723
<a name="l00724"></a>00724 <span class="comment">/* keep this in sync with unref_unlocked */</span>
<a name="l00725"></a>00725
<a name="l00726"></a>00726 _dbus_return_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00727"></a>00727
<a name="l00728"></a>00728 old_refcount = <a class="code" href="group__DBusSysdeps.html#ga3c50a069f795dceeb9172fe2b517bbdc" title="Atomically decrement an integer.">_dbus_atomic_dec</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00729"></a>00729
<a name="l00730"></a>00730 <span class="preprocessor">#ifndef DBUS_DISABLE_CHECKS</span>
<a name="l00731"></a>00731 <span class="preprocessor"></span> <span class="keywordflow">if</span> (_DBUS_UNLIKELY (old_refcount <= 0))
<a name="l00732"></a>00732 {
<a name="l00733"></a>00733 <span class="comment">/* undo side-effect first</span>
<a name="l00734"></a>00734 <span class="comment"> * please do not try to simplify the code here by using</span>
<a name="l00735"></a>00735 <span class="comment"> * _dbus_atomic_get(), why we don't use it is</span>
<a name="l00736"></a>00736 <span class="comment"> * because it issues another atomic operation even though</span>
<a name="l00737"></a>00737 <span class="comment"> * DBUS_DISABLE_CHECKS defined.</span>
<a name="l00738"></a>00738 <span class="comment"> * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303</span>
<a name="l00739"></a>00739 <span class="comment"> */</span>
<a name="l00740"></a>00740 <a class="code" href="group__DBusSysdeps.html#gae74c3fcf12acaeccdb152ef907de951c" title="Atomically increments an integer.">_dbus_atomic_inc</a> (&server-><a class="code" href="structDBusServer.html#a7578bd99fc8aee641cbb5198cb2e7004" title="Reference count.">refcount</a>);
<a name="l00741"></a>00741 <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a> (<a class="code" href="group__DBusInternalsUtils.html#ga748d6ccfb8090bf9f0bf338946c8f5e2" title="String used in _dbus_return_if_fail macro.">_dbus_return_if_fail_warning_format</a>,
<a name="l00742"></a>00742 _DBUS_FUNCTION_NAME, <span class="stringliteral">"old_refcount > 0"</span>,
<a name="l00743"></a>00743 __FILE__, __LINE__);
<a name="l00744"></a>00744 <span class="keywordflow">return</span>;
<a name="l00745"></a>00745 }
<a name="l00746"></a>00746 <span class="preprocessor">#endif</span>
<a name="l00747"></a>00747 <span class="preprocessor"></span>
<a name="l00748"></a>00748 _dbus_server_trace_ref (server, old_refcount, old_refcount - 1, <span class="stringliteral">"unref"</span>);
<a name="l00749"></a>00749
<a name="l00750"></a>00750 <span class="keywordflow">if</span> (old_refcount == 1)
<a name="l00751"></a>00751 {
<a name="l00752"></a>00752 <span class="comment">/* lock not held! */</span>
<a name="l00753"></a>00753 _dbus_assert (server-><a class="code" href="structDBusServer.html#a7dabb30cdc09d6102810029fb56b8dfe" title="TRUE if we are disconnected.">disconnected</a>);
<a name="l00754"></a>00754
<a name="l00755"></a>00755 _dbus_assert (server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a>-><a class="code" href="structDBusServerVTable.html#acd97315e812352da38449f910775b08d" title="The finalize method must free the server.">finalize</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00756"></a>00756
<a name="l00757"></a>00757 (* server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a>-><a class="code" href="structDBusServerVTable.html#acd97315e812352da38449f910775b08d" title="The finalize method must free the server.">finalize</a>) (server);
<a name="l00758"></a>00758 }
<a name="l00759"></a>00759 }
<a name="l00760"></a>00760
<a name="l00769"></a>00769 <span class="keywordtype">void</span>
<a name="l00770"></a><a class="code" href="group__DBusServer.html#ga1ff306fbaaa608306b0619ba5c0029a1">00770</a> <a class="code" href="group__DBusServer.html#ga1ff306fbaaa608306b0619ba5c0029a1" title="Releases the server's address and stops listening for new clients.">dbus_server_disconnect</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00771"></a>00771 {
<a name="l00772"></a>00772 _dbus_return_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00773"></a>00773
<a name="l00774"></a>00774 <a class="code" href="group__DBusServer.html#gabe1c14264ef6bf3e5fe446ab9bf8b913" title="Increments the reference count of a DBusServer.">dbus_server_ref</a> (server);
<a name="l00775"></a>00775 SERVER_LOCK (server);
<a name="l00776"></a>00776
<a name="l00777"></a>00777 _dbus_assert (server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a>-><a class="code" href="structDBusServerVTable.html#a148b105ac0a3a5ae8efbba29bf7fe676" title="Disconnect this server.">disconnect</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00778"></a>00778
<a name="l00779"></a>00779 <span class="keywordflow">if</span> (!server-><a class="code" href="structDBusServer.html#a7dabb30cdc09d6102810029fb56b8dfe" title="TRUE if we are disconnected.">disconnected</a>)
<a name="l00780"></a>00780 {
<a name="l00781"></a>00781 <span class="comment">/* this has to be first so recursive calls to disconnect don't happen */</span>
<a name="l00782"></a>00782 server-><a class="code" href="structDBusServer.html#a7dabb30cdc09d6102810029fb56b8dfe" title="TRUE if we are disconnected.">disconnected</a> = <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l00783"></a>00783
<a name="l00784"></a>00784 (* server-><a class="code" href="structDBusServer.html#aa5068890fea8c7e7261b600e7256e009" title="Virtual methods for this instance.">vtable</a>-><a class="code" href="structDBusServerVTable.html#a148b105ac0a3a5ae8efbba29bf7fe676" title="Disconnect this server.">disconnect</a>) (server);
<a name="l00785"></a>00785 }
<a name="l00786"></a>00786
<a name="l00787"></a>00787 SERVER_UNLOCK (server);
<a name="l00788"></a>00788 <a class="code" href="group__DBusServer.html#ga95d0b6cb9795b4919aa08f667807c555" title="Decrements the reference count of a DBusServer.">dbus_server_unref</a> (server);
<a name="l00789"></a>00789 }
<a name="l00790"></a>00790
<a name="l00796"></a>00796 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00797"></a><a class="code" href="group__DBusServer.html#ga93c36d8b42a3f2a4f3706a0c3609b3d1">00797</a> <a class="code" href="group__DBusServer.html#ga93c36d8b42a3f2a4f3706a0c3609b3d1" title="Returns TRUE if the server is still listening for new connections.">dbus_server_get_is_connected</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00798"></a>00798 {
<a name="l00799"></a>00799 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l00800"></a>00800
<a name="l00801"></a>00801 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00802"></a>00802
<a name="l00803"></a>00803 SERVER_LOCK (server);
<a name="l00804"></a>00804 retval = !server-><a class="code" href="structDBusServer.html#a7dabb30cdc09d6102810029fb56b8dfe" title="TRUE if we are disconnected.">disconnected</a>;
<a name="l00805"></a>00805 SERVER_UNLOCK (server);
<a name="l00806"></a>00806
<a name="l00807"></a>00807 <span class="keywordflow">return</span> retval;
<a name="l00808"></a>00808 }
<a name="l00809"></a>00809
<a name="l00817"></a>00817 <span class="keywordtype">char</span>*
<a name="l00818"></a><a class="code" href="group__DBusServer.html#ga63a133dc2786afed48c87127baa96927">00818</a> <a class="code" href="group__DBusServer.html#ga63a133dc2786afed48c87127baa96927" title="Returns the address of the server, as a newly-allocated string which must be freed by the caller...">dbus_server_get_address</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00819"></a>00819 {
<a name="l00820"></a>00820 <span class="keywordtype">char</span> *retval;
<a name="l00821"></a>00821
<a name="l00822"></a>00822 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00823"></a>00823
<a name="l00824"></a>00824 SERVER_LOCK (server);
<a name="l00825"></a>00825 retval = <a class="code" href="group__DBusInternalsUtils.html#ga9d00d77f6595b9d7ac1baf59d44bf58c" title="Duplicates a string.">_dbus_strdup</a> (server-><a class="code" href="structDBusServer.html#a359852bf33b3051180a9477da4d89acd" title="Address this server is listening on.">address</a>);
<a name="l00826"></a>00826 SERVER_UNLOCK (server);
<a name="l00827"></a>00827
<a name="l00828"></a>00828 <span class="keywordflow">return</span> retval;
<a name="l00829"></a>00829 }
<a name="l00830"></a>00830
<a name="l00853"></a>00853 <span class="keywordtype">char</span>*
<a name="l00854"></a><a class="code" href="group__DBusServer.html#ga3b2920b3c65836113781d9dd00d1e139">00854</a> <a class="code" href="group__DBusServer.html#ga3b2920b3c65836113781d9dd00d1e139" title="Returns the unique ID of the server, as a newly-allocated string which must be freed by the caller...">dbus_server_get_id</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server)
<a name="l00855"></a>00855 {
<a name="l00856"></a>00856 <span class="keywordtype">char</span> *retval;
<a name="l00857"></a>00857
<a name="l00858"></a>00858 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00859"></a>00859
<a name="l00860"></a>00860 SERVER_LOCK (server);
<a name="l00861"></a>00861 retval = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00862"></a>00862 <a class="code" href="group__DBusString.html#ga7e509d4f959d19d96f83250e62287b06" title="Copies the data from the string into a char*.">_dbus_string_copy_data</a> (&server-><a class="code" href="structDBusServer.html#a79cd5d1b25412d56b7fd41902d575794" title="Hex-encoded version of GUID.">guid_hex</a>, &retval);
<a name="l00863"></a>00863 SERVER_UNLOCK (server);
<a name="l00864"></a>00864
<a name="l00865"></a>00865 <span class="keywordflow">return</span> retval;
<a name="l00866"></a>00866 }
<a name="l00867"></a>00867
<a name="l00888"></a>00888 <span class="keywordtype">void</span>
<a name="l00889"></a><a class="code" href="group__DBusServer.html#gaa14d9109e04adccffd9a40460c28c53b">00889</a> <a class="code" href="group__DBusServer.html#gaa14d9109e04adccffd9a40460c28c53b" title="Sets a function to be used for handling new connections.">dbus_server_set_new_connection_function</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00890"></a>00890 <a class="code" href="group__DBusServer.html#ga8478cd198973f6a6cb224ec23175faa7" title="Called when a new connection to the server is available.">DBusNewConnectionFunction</a> <span class="keyword">function</span>,
<a name="l00891"></a>00891 <span class="keywordtype">void</span> *data,
<a name="l00892"></a>00892 <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> free_data_function)
<a name="l00893"></a>00893 {
<a name="l00894"></a>00894 <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> old_free_function;
<a name="l00895"></a>00895 <span class="keywordtype">void</span> *old_data;
<a name="l00896"></a>00896
<a name="l00897"></a>00897 _dbus_return_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00898"></a>00898
<a name="l00899"></a>00899 SERVER_LOCK (server);
<a name="l00900"></a>00900 old_free_function = server-><a class="code" href="structDBusServer.html#a5d5b68a92cf47a3eb50e5e6ec7d2ca3a" title="Callback to invoke to free new_connection_data when server is finalized or data is replaced...">new_connection_free_data_function</a>;
<a name="l00901"></a>00901 old_data = server-><a class="code" href="structDBusServer.html#acfba406ae6f288887feaccc3d621d094" title="Data for new connection callback.">new_connection_data</a>;
<a name="l00902"></a>00902
<a name="l00903"></a>00903 server-><a class="code" href="structDBusServer.html#a964ff125a29a7dac02f81e1a26233ff6" title="Callback to invoke when a new connection is created.">new_connection_function</a> = <span class="keyword">function</span>;
<a name="l00904"></a>00904 server-><a class="code" href="structDBusServer.html#acfba406ae6f288887feaccc3d621d094" title="Data for new connection callback.">new_connection_data</a> = data;
<a name="l00905"></a>00905 server-><a class="code" href="structDBusServer.html#a5d5b68a92cf47a3eb50e5e6ec7d2ca3a" title="Callback to invoke to free new_connection_data when server is finalized or data is replaced...">new_connection_free_data_function</a> = free_data_function;
<a name="l00906"></a>00906 SERVER_UNLOCK (server);
<a name="l00907"></a>00907
<a name="l00908"></a>00908 <span class="keywordflow">if</span> (old_free_function != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00909"></a>00909 (* old_free_function) (old_data);
<a name="l00910"></a>00910 }
<a name="l00911"></a>00911
<a name="l00928"></a>00928 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00929"></a><a class="code" href="group__DBusServer.html#gaa5723810ea52e9f1815062fd91395892">00929</a> <a class="code" href="group__DBusServer.html#gaa5723810ea52e9f1815062fd91395892" title="Sets the watch functions for the server.">dbus_server_set_watch_functions</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00930"></a>00930 <a class="code" href="group__DBusConnection.html#ga9188ca3fd89c957dc269dbe8601b270e" title="Called when libdbus needs a new watch to be monitored by the main loop.">DBusAddWatchFunction</a> add_function,
<a name="l00931"></a>00931 <a class="code" href="group__DBusConnection.html#gaaab846a872d938b27503129551ea0c62" title="Called when libdbus no longer needs a watch to be monitored by the main loop.">DBusRemoveWatchFunction</a> remove_function,
<a name="l00932"></a>00932 <a class="code" href="group__DBusConnection.html#gace13544ff3075b5fccbce896682ec6ff" title="Called when dbus_watch_get_enabled() may return a different value than it did before.">DBusWatchToggledFunction</a> toggled_function,
<a name="l00933"></a>00933 <span class="keywordtype">void</span> *data,
<a name="l00934"></a>00934 <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> free_data_function)
<a name="l00935"></a>00935 {
<a name="l00936"></a>00936 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> result;
<a name="l00937"></a>00937 <a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *watches;
<a name="l00938"></a>00938
<a name="l00939"></a>00939 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00940"></a>00940
<a name="l00941"></a>00941 SERVER_LOCK (server);
<a name="l00942"></a>00942 watches = server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a>;
<a name="l00943"></a>00943 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00944"></a>00944 <span class="keywordflow">if</span> (watches)
<a name="l00945"></a>00945 {
<a name="l00946"></a>00946 SERVER_UNLOCK (server);
<a name="l00947"></a>00947 result = <a class="code" href="group__DBusWatchInternals.html#gae9ab8cf14f4191191e94183be9a031d9" title="Sets the watch functions.">_dbus_watch_list_set_functions</a> (watches,
<a name="l00948"></a>00948 add_function,
<a name="l00949"></a>00949 remove_function,
<a name="l00950"></a>00950 toggled_function,
<a name="l00951"></a>00951 data,
<a name="l00952"></a>00952 free_data_function);
<a name="l00953"></a>00953 SERVER_LOCK (server);
<a name="l00954"></a>00954 }
<a name="l00955"></a>00955 <span class="keywordflow">else</span>
<a name="l00956"></a>00956 {
<a name="l00957"></a>00957 <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a> (<span class="stringliteral">"Re-entrant call to %s\n"</span>, _DBUS_FUNCTION_NAME);
<a name="l00958"></a>00958 result = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l00959"></a>00959 }
<a name="l00960"></a>00960 server-><a class="code" href="structDBusServer.html#a7955050967aeaf09679f8ba1f2941880" title="Our watches.">watches</a> = watches;
<a name="l00961"></a>00961 SERVER_UNLOCK (server);
<a name="l00962"></a>00962
<a name="l00963"></a>00963 <span class="keywordflow">return</span> result;
<a name="l00964"></a>00964 }
<a name="l00965"></a>00965
<a name="l00981"></a>00981 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00982"></a><a class="code" href="group__DBusServer.html#gacafa42ffc063a7386db40a975c32d530">00982</a> <a class="code" href="group__DBusServer.html#gacafa42ffc063a7386db40a975c32d530" title="Sets the timeout functions for the server.">dbus_server_set_timeout_functions</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l00983"></a>00983 <a class="code" href="group__DBusConnection.html#ga01a45587090d82ee97b5042b49037a08" title="Called when libdbus needs a new timeout to be monitored by the main loop.">DBusAddTimeoutFunction</a> add_function,
<a name="l00984"></a>00984 <a class="code" href="group__DBusConnection.html#ga13aae9d5981de45abca0db1717dc7daf" title="Called when libdbus no longer needs a timeout to be monitored by the main loop.">DBusRemoveTimeoutFunction</a> remove_function,
<a name="l00985"></a>00985 <a class="code" href="group__DBusConnection.html#ga62eea9a2032ae15b6738534b93d18e86" title="Called when dbus_timeout_get_enabled() may return a different value than it did before.">DBusTimeoutToggledFunction</a> toggled_function,
<a name="l00986"></a>00986 <span class="keywordtype">void</span> *data,
<a name="l00987"></a>00987 <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> free_data_function)
<a name="l00988"></a>00988 {
<a name="l00989"></a>00989 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> result;
<a name="l00990"></a>00990 <a class="code" href="structDBusTimeoutList.html" title="DBusTimeoutList implementation details.">DBusTimeoutList</a> *timeouts;
<a name="l00991"></a>00991
<a name="l00992"></a>00992 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l00993"></a>00993
<a name="l00994"></a>00994 SERVER_LOCK (server);
<a name="l00995"></a>00995 timeouts = server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a>;
<a name="l00996"></a>00996 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00997"></a>00997 <span class="keywordflow">if</span> (timeouts)
<a name="l00998"></a>00998 {
<a name="l00999"></a>00999 SERVER_UNLOCK (server);
<a name="l01000"></a>01000 result = <a class="code" href="group__DBusTimeoutInternals.html#ga6760d1963b870b45f855501e38b49fd9" title="Sets the timeout functions.">_dbus_timeout_list_set_functions</a> (timeouts,
<a name="l01001"></a>01001 add_function,
<a name="l01002"></a>01002 remove_function,
<a name="l01003"></a>01003 toggled_function,
<a name="l01004"></a>01004 data,
<a name="l01005"></a>01005 free_data_function);
<a name="l01006"></a>01006 SERVER_LOCK (server);
<a name="l01007"></a>01007 }
<a name="l01008"></a>01008 <span class="keywordflow">else</span>
<a name="l01009"></a>01009 {
<a name="l01010"></a>01010 <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a "critical" warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a> (<span class="stringliteral">"Re-entrant call to %s\n"</span>, _DBUS_FUNCTION_NAME);
<a name="l01011"></a>01011 result = <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01012"></a>01012 }
<a name="l01013"></a>01013 server-><a class="code" href="structDBusServer.html#afcaccd00f2392a390616c47e425bae85" title="Our timeouts.">timeouts</a> = timeouts;
<a name="l01014"></a>01014 SERVER_UNLOCK (server);
<a name="l01015"></a>01015
<a name="l01016"></a>01016 <span class="keywordflow">return</span> result;
<a name="l01017"></a>01017 }
<a name="l01018"></a>01018
<a name="l01032"></a>01032 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01033"></a><a class="code" href="group__DBusServer.html#ga309e5f1510c74c4b221d12d874d53341">01033</a> <a class="code" href="group__DBusServer.html#ga309e5f1510c74c4b221d12d874d53341" title="Sets the authentication mechanisms that this server offers to clients, as a NULL-terminated array of ...">dbus_server_set_auth_mechanisms</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l01034"></a>01034 <span class="keyword">const</span> <span class="keywordtype">char</span> **mechanisms)
<a name="l01035"></a>01035 {
<a name="l01036"></a>01036 <span class="keywordtype">char</span> **copy;
<a name="l01037"></a>01037
<a name="l01038"></a>01038 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l01039"></a>01039
<a name="l01040"></a>01040 SERVER_LOCK (server);
<a name="l01041"></a>01041
<a name="l01042"></a>01042 <span class="keywordflow">if</span> (mechanisms != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01043"></a>01043 {
<a name="l01044"></a>01044 copy = <a class="code" href="group__DBusInternalsUtils.html#ga53bbcbbd0b564c14c599813dde535443" title="Duplicates a string array.">_dbus_dup_string_array</a> (mechanisms);
<a name="l01045"></a>01045 <span class="keywordflow">if</span> (copy == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01046"></a>01046 {
<a name="l01047"></a>01047 SERVER_UNLOCK (server);
<a name="l01048"></a>01048 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>;
<a name="l01049"></a>01049 }
<a name="l01050"></a>01050 }
<a name="l01051"></a>01051 <span class="keywordflow">else</span>
<a name="l01052"></a>01052 copy = <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l01053"></a>01053
<a name="l01054"></a>01054 <a class="code" href="group__DBusMemory.html#gac200b2dbc8b3f6ecac4d42426fb97b40" title="Frees a NULL-terminated array of strings.">dbus_free_string_array</a> (server-><a class="code" href="structDBusServer.html#adc1032bbed41413e5d0e01578f2bfffc" title="Array of allowed authentication mechanisms.">auth_mechanisms</a>);
<a name="l01055"></a>01055 server-><a class="code" href="structDBusServer.html#adc1032bbed41413e5d0e01578f2bfffc" title="Array of allowed authentication mechanisms.">auth_mechanisms</a> = copy;
<a name="l01056"></a>01056
<a name="l01057"></a>01057 SERVER_UNLOCK (server);
<a name="l01058"></a>01058
<a name="l01059"></a>01059 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01060"></a>01060 }
<a name="l01061"></a>01061
<a name="l01062"></a>01062 <span class="keyword">static</span> <a class="code" href="structDBusDataSlotAllocator.html" title="An allocator that tracks a set of slot IDs.">DBusDataSlotAllocator</a> slot_allocator =
<a name="l01063"></a>01063 _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (server_slots));
<a name="l01064"></a>01064
<a name="l01079"></a>01079 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01080"></a><a class="code" href="group__DBusServer.html#ga05d280cd92ea5bb0d49bbe5b1fb1d5c2">01080</a> <a class="code" href="group__DBusServer.html#ga05d280cd92ea5bb0d49bbe5b1fb1d5c2" title="Allocates an integer ID to be used for storing application-specific data on any DBusServer.">dbus_server_allocate_data_slot</a> (<a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> *slot_p)
<a name="l01081"></a>01081 {
<a name="l01082"></a>01082 <span class="keywordflow">return</span> <a class="code" href="group__DBusDataSlot.html#gaf61f2bd0148bace4f67a2d6d97b26ea9" title="Allocates an integer ID to be used for storing data in a DBusDataSlotList.">_dbus_data_slot_allocator_alloc</a> (&slot_allocator,
<a name="l01083"></a>01083 slot_p);
<a name="l01084"></a>01084 }
<a name="l01085"></a>01085
<a name="l01097"></a>01097 <span class="keywordtype">void</span>
<a name="l01098"></a><a class="code" href="group__DBusServer.html#gac6ebc6105e32ab38ef0ac60dec6d5bc8">01098</a> <a class="code" href="group__DBusServer.html#gac6ebc6105e32ab38ef0ac60dec6d5bc8" title="Deallocates a global ID for server data slots.">dbus_server_free_data_slot</a> (<a class="code" href="group__DBusTypes.html#gab18afa60e9b17b6e322735bda3d863d8" title="A 32-bit signed integer on all platforms.">dbus_int32_t</a> *slot_p)
<a name="l01099"></a>01099 {
<a name="l01100"></a>01100 _dbus_return_if_fail (*slot_p >= 0);
<a name="l01101"></a>01101
<a name="l01102"></a>01102 <a class="code" href="group__DBusDataSlot.html#ga059c50a24cd9fc984e918e6159841633" title="Deallocates an ID previously allocated with _dbus_data_slot_allocator_alloc().">_dbus_data_slot_allocator_free</a> (&slot_allocator, slot_p);
<a name="l01103"></a>01103 }
<a name="l01104"></a>01104
<a name="l01118"></a>01118 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01119"></a><a class="code" href="group__DBusServer.html#gab9ecb216dc9c40b0c7d370673fb9b269">01119</a> <a class="code" href="group__DBusServer.html#gab9ecb216dc9c40b0c7d370673fb9b269" title="Stores a pointer on a DBusServer, along with an optional function to be used for freeing the data whe...">dbus_server_set_data</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l01120"></a>01120 <span class="keywordtype">int</span> slot,
<a name="l01121"></a>01121 <span class="keywordtype">void</span> *data,
<a name="l01122"></a>01122 <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> free_data_func)
<a name="l01123"></a>01123 {
<a name="l01124"></a>01124 <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> old_free_func;
<a name="l01125"></a>01125 <span class="keywordtype">void</span> *old_data;
<a name="l01126"></a>01126 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a> retval;
<a name="l01127"></a>01127
<a name="l01128"></a>01128 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to "0".">FALSE</a>);
<a name="l01129"></a>01129
<a name="l01130"></a>01130 SERVER_LOCK (server);
<a name="l01131"></a>01131
<a name="l01132"></a>01132 retval = <a class="code" href="group__DBusDataSlot.html#gad2952f9f686d96e7114fc49ab7452e1a" title="Stores a pointer in the data slot list, along with an optional function to be used for freeing the da...">_dbus_data_slot_list_set</a> (&slot_allocator,
<a name="l01133"></a>01133 &server-><a class="code" href="structDBusServer.html#a0601cca8307ba17d4a8bcebe48b08362" title="Data stored by allocated integer ID.">slot_list</a>,
<a name="l01134"></a>01134 slot, data, free_data_func,
<a name="l01135"></a>01135 &old_free_func, &old_data);
<a name="l01136"></a>01136
<a name="l01137"></a>01137
<a name="l01138"></a>01138 SERVER_UNLOCK (server);
<a name="l01139"></a>01139
<a name="l01140"></a>01140 <span class="keywordflow">if</span> (retval)
<a name="l01141"></a>01141 {
<a name="l01142"></a>01142 <span class="comment">/* Do the actual free outside the server lock */</span>
<a name="l01143"></a>01143 <span class="keywordflow">if</span> (old_free_func)
<a name="l01144"></a>01144 (* old_free_func) (old_data);
<a name="l01145"></a>01145 }
<a name="l01146"></a>01146
<a name="l01147"></a>01147 <span class="keywordflow">return</span> retval;
<a name="l01148"></a>01148 }
<a name="l01149"></a>01149
<a name="l01158"></a>01158 <span class="keywordtype">void</span>*
<a name="l01159"></a><a class="code" href="group__DBusServer.html#gac2bfa9f2e06c4347fefe537b233660d3">01159</a> <a class="code" href="group__DBusServer.html#gac2bfa9f2e06c4347fefe537b233660d3" title="Retrieves data previously set with dbus_server_set_data().">dbus_server_get_data</a> (<a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server,
<a name="l01160"></a>01160 <span class="keywordtype">int</span> slot)
<a name="l01161"></a>01161 {
<a name="l01162"></a>01162 <span class="keywordtype">void</span> *res;
<a name="l01163"></a>01163
<a name="l01164"></a>01164 _dbus_return_val_if_fail (server != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l01165"></a>01165
<a name="l01166"></a>01166 SERVER_LOCK (server);
<a name="l01167"></a>01167
<a name="l01168"></a>01168 res = <a class="code" href="group__DBusDataSlot.html#ga43f741229f0c38788442601e2750ec66" title="Retrieves data previously set with _dbus_data_slot_list_set_data().">_dbus_data_slot_list_get</a> (&slot_allocator,
<a name="l01169"></a>01169 &server-><a class="code" href="structDBusServer.html#a0601cca8307ba17d4a8bcebe48b08362" title="Data stored by allocated integer ID.">slot_list</a>,
<a name="l01170"></a>01170 slot);
<a name="l01171"></a>01171
<a name="l01172"></a>01172 SERVER_UNLOCK (server);
<a name="l01173"></a>01173
<a name="l01174"></a>01174 <span class="keywordflow">return</span> res;
<a name="l01175"></a>01175 }
<a name="l01176"></a>01176
<a name="l01179"></a>01179 <span class="preprocessor">#ifdef DBUS_ENABLE_EMBEDDED_TESTS</span>
<a name="l01180"></a>01180 <span class="preprocessor"></span><span class="preprocessor">#include "dbus-test.h"</span>
<a name="l01181"></a>01181 <span class="preprocessor">#include <string.h></span>
<a name="l01182"></a>01182
<a name="l01183"></a>01183 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l01184"></a>01184 _dbus_server_test (<span class="keywordtype">void</span>)
<a name="l01185"></a>01185 {
<a name="l01186"></a>01186 <span class="keyword">const</span> <span class="keywordtype">char</span> *valid_addresses[] = {
<a name="l01187"></a>01187 <span class="stringliteral">"tcp:port=1234"</span>,
<a name="l01188"></a>01188 <span class="stringliteral">"tcp:host=localhost,port=1234"</span>,
<a name="l01189"></a>01189 <span class="stringliteral">"tcp:host=localhost,port=1234;tcp:port=5678"</span>,
<a name="l01190"></a>01190 <span class="preprocessor">#ifdef DBUS_UNIX</span>
<a name="l01191"></a>01191 <span class="preprocessor"></span> <span class="stringliteral">"unix:path=./boogie"</span>,
<a name="l01192"></a>01192 <span class="stringliteral">"tcp:port=1234;unix:path=./boogie"</span>,
<a name="l01193"></a>01193 <span class="preprocessor">#endif</span>
<a name="l01194"></a>01194 <span class="preprocessor"></span> };
<a name="l01195"></a>01195
<a name="l01196"></a>01196 <a class="code" href="structDBusServer.html" title="Internals of DBusServer object.">DBusServer</a> *server;
<a name="l01197"></a>01197 <span class="keywordtype">int</span> i;
<a name="l01198"></a>01198
<a name="l01199"></a>01199 <span class="keywordflow">for</span> (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++)
<a name="l01200"></a>01200 {
<a name="l01201"></a>01201 <a class="code" href="structDBusError.html" title="Object representing an exception.">DBusError</a> error = <a class="code" href="group__DBusErrorInternals.html#ga961cc70e3891282a65205c4c8418d88e" title="Expands to a suitable initializer for a DBusError on the stack.">DBUS_ERROR_INIT</a>;
<a name="l01202"></a>01202 <span class="keywordtype">char</span> *address;
<a name="l01203"></a>01203 <span class="keywordtype">char</span> *id;
<a name="l01204"></a>01204
<a name="l01205"></a>01205 server = <a class="code" href="group__DBusServer.html#ga4c83cf9f2c186afa97decdc25ac163d8" title="Listens for new connections on the given address.">dbus_server_listen</a> (valid_addresses[i], &error);
<a name="l01206"></a>01206 <span class="keywordflow">if</span> (server == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01207"></a>01207 {
<a name="l01208"></a>01208 <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">"server listen error: %s: %s\n"</span>, error.<a class="code" href="structDBusError.html#a09a9614ff07fdf3ef163b232ff934581" title="public error name field">name</a>, error.<a class="code" href="structDBusError.html#afb559175326de5b6b340e26204e92d72" title="public error message field">message</a>);
<a name="l01209"></a>01209 <a class="code" href="group__DBusErrors.html#gaac6c14ead14829ee4e090f39de6a7568" title="Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...">dbus_error_free</a> (&error);
<a name="l01210"></a>01210 _dbus_assert_not_reached (<span class="stringliteral">"Failed to listen for valid address."</span>);
<a name="l01211"></a>01211 }
<a name="l01212"></a>01212
<a name="l01213"></a>01213 <span class="keywordtype">id</span> = <a class="code" href="group__DBusServer.html#ga3b2920b3c65836113781d9dd00d1e139" title="Returns the unique ID of the server, as a newly-allocated string which must be freed by the caller...">dbus_server_get_id</a> (server);
<a name="l01214"></a>01214 _dbus_assert (<span class="keywordtype">id</span> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l01215"></a>01215 address = <a class="code" href="group__DBusServer.html#ga63a133dc2786afed48c87127baa96927" title="Returns the address of the server, as a newly-allocated string which must be freed by the caller...">dbus_server_get_address</a> (server);
<a name="l01216"></a>01216 _dbus_assert (address != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l01217"></a>01217
<a name="l01218"></a>01218 <span class="keywordflow">if</span> (strstr (address, <span class="keywordtype">id</span>) == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l01219"></a>01219 {
<a name="l01220"></a>01220 <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">"server id '%s' is not in the server address '%s'\n"</span>,
<a name="l01221"></a>01221 <span class="keywordtype">id</span>, address);
<a name="l01222"></a>01222 _dbus_assert_not_reached (<span class="stringliteral">"bad server id or address"</span>);
<a name="l01223"></a>01223 }
<a name="l01224"></a>01224
<a name="l01225"></a>01225 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (<span class="keywordtype">id</span>);
<a name="l01226"></a>01226 <a class="code" href="group__DBusMemory.html#ga34e666b19b015035a9a31e53da84b39a" title="Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().">dbus_free</a> (address);
<a name="l01227"></a>01227
<a name="l01228"></a>01228 <a class="code" href="group__DBusServer.html#ga1ff306fbaaa608306b0619ba5c0029a1" title="Releases the server's address and stops listening for new clients.">dbus_server_disconnect</a> (server);
<a name="l01229"></a>01229 <a class="code" href="group__DBusServer.html#ga95d0b6cb9795b4919aa08f667807c555" title="Decrements the reference count of a DBusServer.">dbus_server_unref</a> (server);
<a name="l01230"></a>01230 }
<a name="l01231"></a>01231
<a name="l01232"></a>01232 <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to "1".">TRUE</a>;
<a name="l01233"></a>01233 }
<a name="l01234"></a>01234
<a name="l01235"></a>01235 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_ENABLE_EMBEDDED_TESTS */</span>
</pre></div></div><!-- contents -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:31 for D-Bus by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>
</body>
</html>