Current File : //usr/share/doc/dbus/api/dbus-watch_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-watch.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
   &#160;<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&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;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&#160;List</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">dbus-watch.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: &quot;gnu&quot;; indent-tabs-mode: nil; -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/* dbus-watch.c DBusWatch implementation</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002, 2003  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 &lt;config.h&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;dbus-internals.h&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;dbus-watch.h&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;dbus-list.h&quot;</span>
<a name="l00028"></a>00028 
<a name="l00040"></a><a class="code" href="structDBusWatch.html">00040</a> <span class="keyword">struct </span><a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>
<a name="l00041"></a>00041 {
<a name="l00042"></a><a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978">00042</a>   <span class="keywordtype">int</span> <a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978" title="Reference count.">refcount</a>;                        
<a name="l00043"></a><a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217">00043</a>   <span class="keywordtype">int</span> <a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a>;                              
<a name="l00044"></a><a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a">00044</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a>;                  
<a name="l00046"></a><a class="code" href="structDBusWatch.html#aad3fb97da0ad7e5897611930f7a1c3e9">00046</a>   <a class="code" href="group__DBusWatchInternals.html#gae71d41a6a6c6a3b845ccc30b09004228" title="function to run when the watch is handled">DBusWatchHandler</a> <a class="code" href="structDBusWatch.html#aad3fb97da0ad7e5897611930f7a1c3e9" title="Watch handler.">handler</a>;                    
<a name="l00047"></a><a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87">00047</a>   <span class="keywordtype">void</span> *<a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87" title="Watch handler data.">handler_data</a>;                          
<a name="l00048"></a><a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8">00048</a>   <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> <a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a>; 
<a name="l00050"></a><a class="code" href="structDBusWatch.html#a71877a39d8c2a7d533c0c6f280648d53">00050</a>   <span class="keywordtype">void</span> *<a class="code" href="structDBusWatch.html#a71877a39d8c2a7d533c0c6f280648d53" title="Application data.">data</a>;                          
<a name="l00051"></a><a class="code" href="structDBusWatch.html#ad848cbd636518fd346039d0d771ba021">00051</a>   <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> <a class="code" href="structDBusWatch.html#ad848cbd636518fd346039d0d771ba021" title="Free the application data.">free_data_function</a>; 
<a name="l00052"></a><a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64">00052</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a> : 1;            
<a name="l00053"></a><a class="code" href="structDBusWatch.html#a1020150c9fd9764ac85919d2c48bb6e1">00053</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structDBusWatch.html#a1020150c9fd9764ac85919d2c48bb6e1" title="Whether it was OOM last time.">oom_last_time</a> : 1;      
<a name="l00054"></a>00054 };
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00057"></a>00057 _dbus_watch_get_enabled (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00058"></a>00058 {
<a name="l00059"></a>00059   <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a>;
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00063"></a>00063 _dbus_watch_get_oom_last_time (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065   <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#a1020150c9fd9764ac85919d2c48bb6e1" title="Whether it was OOM last time.">oom_last_time</a>;
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067 
<a name="l00068"></a>00068 <span class="keywordtype">void</span>
<a name="l00069"></a>00069 _dbus_watch_set_oom_last_time (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>   *watch,
<a name="l00070"></a>00070                                <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>  oom)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072   watch-&gt;<a class="code" href="structDBusWatch.html#a1020150c9fd9764ac85919d2c48bb6e1" title="Whether it was OOM last time.">oom_last_time</a> = oom;
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 
<a name="l00087"></a>00087 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>*
<a name="l00088"></a><a class="code" href="group__DBusWatchInternals.html#ga1f940e505b20e6429ae858a7b70b0541">00088</a> <a class="code" href="group__DBusWatchInternals.html#ga1f940e505b20e6429ae858a7b70b0541" title="Creates a new DBusWatch.">_dbus_watch_new</a> (<span class="keywordtype">int</span>               fd,
<a name="l00089"></a>00089                  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>      flags,
<a name="l00090"></a>00090                  <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>       enabled,
<a name="l00091"></a>00091                  <a class="code" href="group__DBusWatchInternals.html#gae71d41a6a6c6a3b845ccc30b09004228" title="function to run when the watch is handled">DBusWatchHandler</a>  handler,
<a name="l00092"></a>00092                  <span class="keywordtype">void</span>             *data,
<a name="l00093"></a>00093                  <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="l00094"></a>00094 {
<a name="l00095"></a>00095   <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch;
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 <span class="preprocessor">#define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE)</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span>  
<a name="l00099"></a>00099   _dbus_assert ((flags &amp; VALID_WATCH_FLAGS) == flags);
<a name="l00100"></a>00100   
<a name="l00101"></a>00101   watch = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>, 1);
<a name="l00102"></a>00102   <span class="keywordflow">if</span> (watch == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00103"></a>00103     <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="l00104"></a>00104   
<a name="l00105"></a>00105   watch-&gt;<a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978" title="Reference count.">refcount</a> = 1;
<a name="l00106"></a>00106   watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a> = fd;
<a name="l00107"></a>00107   watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a> = flags;
<a name="l00108"></a>00108   watch-&gt;<a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a> = enabled;
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   watch-&gt;<a class="code" href="structDBusWatch.html#aad3fb97da0ad7e5897611930f7a1c3e9" title="Watch handler.">handler</a> = handler;
<a name="l00111"></a>00111   watch-&gt;<a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87" title="Watch handler data.">handler_data</a> = data;
<a name="l00112"></a>00112   watch-&gt;<a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a> = free_data_function;
<a name="l00113"></a>00113   
<a name="l00114"></a>00114   <span class="keywordflow">return</span> watch;
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 
<a name="l00123"></a>00123 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *
<a name="l00124"></a><a class="code" href="group__DBusWatchInternals.html#ga0db8530cc53589589d67dfb35d03db61">00124</a> <a class="code" href="group__DBusWatchInternals.html#ga0db8530cc53589589d67dfb35d03db61" title="Increments the reference count of a DBusWatch object.">_dbus_watch_ref</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00125"></a>00125 {
<a name="l00126"></a>00126   watch-&gt;<a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978" title="Reference count.">refcount</a> += 1;
<a name="l00127"></a>00127 
<a name="l00128"></a>00128   <span class="keywordflow">return</span> watch;
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 
<a name="l00137"></a>00137 <span class="keywordtype">void</span>
<a name="l00138"></a><a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0">00138</a> <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140   _dbus_assert (watch != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00141"></a>00141   _dbus_assert (watch-&gt;<a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978" title="Reference count.">refcount</a> &gt; 0);
<a name="l00142"></a>00142 
<a name="l00143"></a>00143   watch-&gt;<a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978" title="Reference count.">refcount</a> -= 1;
<a name="l00144"></a>00144   <span class="keywordflow">if</span> (watch-&gt;<a class="code" href="structDBusWatch.html#a3984cbcb64ed76d2f0c1182c386f7978" title="Reference count.">refcount</a> == 0)
<a name="l00145"></a>00145     {
<a name="l00146"></a>00146       <span class="keywordflow">if</span> (watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a> != -1)
<a name="l00147"></a>00147         <a class="code" href="group__DBusInternalsUtils.html#gabea2c16d6d3fe7c4eb5b9496fc877f84" title="Prints a warning message to stderr.">_dbus_warn</a> (<span class="stringliteral">&quot;this watch should have been invalidated&quot;</span>);
<a name="l00148"></a>00148 
<a name="l00149"></a>00149       <a class="code" href="group__DBusWatch.html#ga5c75a65cf0680956cc0188d86a05cfae" title="Sets data which can be retrieved with dbus_watch_get_data().">dbus_watch_set_data</a> (watch, <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>); <span class="comment">/* call free_data_function */</span>
<a name="l00150"></a>00150 
<a name="l00151"></a>00151       <span class="keywordflow">if</span> (watch-&gt;<a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a>)
<a name="l00152"></a>00152         (* watch-&gt;<a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a>) (watch-&gt;<a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87" title="Watch handler data.">handler_data</a>);
<a name="l00153"></a>00153       
<a name="l00154"></a>00154       <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> (watch);
<a name="l00155"></a>00155     }
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 
<a name="l00168"></a>00168 <span class="keywordtype">void</span>
<a name="l00169"></a><a class="code" href="group__DBusWatchInternals.html#gad8521d64123c1d1ae9a094bac8addd31">00169</a> <a class="code" href="group__DBusWatchInternals.html#gad8521d64123c1d1ae9a094bac8addd31" title="Clears the file descriptor from a now-invalid watch object so that no one tries to use it...">_dbus_watch_invalidate</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171   watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a> = -1;
<a name="l00172"></a>00172   watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a> = 0;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 
<a name="l00184"></a>00184 <span class="keywordtype">void</span>
<a name="l00185"></a><a class="code" href="group__DBusWatchInternals.html#gab8f49926fe9ee56cb4ae7c1c8071cca3">00185</a> <a class="code" href="group__DBusWatchInternals.html#gab8f49926fe9ee56cb4ae7c1c8071cca3" title="Sanitizes the given condition so that it only contains flags that the DBusWatch requested.">_dbus_watch_sanitize_condition</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>    *watch,
<a name="l00186"></a>00186                                 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *condition)
<a name="l00187"></a>00187 {
<a name="l00188"></a>00188   <span class="keywordflow">if</span> (!(watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a> &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a178bd7a88e9bfbb8505db76eb7e0ccc4" title="As in POLLIN.">DBUS_WATCH_READABLE</a>))
<a name="l00189"></a>00189     *condition &amp;= ~<a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a178bd7a88e9bfbb8505db76eb7e0ccc4" title="As in POLLIN.">DBUS_WATCH_READABLE</a>;
<a name="l00190"></a>00190   <span class="keywordflow">if</span> (!(watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a> &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a62ddca29b06bfbbc08bb7f3dfd3d307f" title="As in POLLOUT.">DBUS_WATCH_WRITABLE</a>))
<a name="l00191"></a>00191     *condition &amp;= ~<a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a62ddca29b06bfbbc08bb7f3dfd3d307f" title="As in POLLOUT.">DBUS_WATCH_WRITABLE</a>;
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193 
<a name="l00194"></a>00194 
<a name="l00214"></a><a class="code" href="structDBusWatchList.html">00214</a> <span class="keyword">struct </span><a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a>
<a name="l00215"></a>00215 {
<a name="l00216"></a><a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d">00216</a>   <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>;           
<a name="l00218"></a><a class="code" href="structDBusWatchList.html#ae515ab01e8d08e6b252e468be7dc7074">00218</a>   <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> <a class="code" href="structDBusWatchList.html#ae515ab01e8d08e6b252e468be7dc7074" title="Callback for adding a watch.">add_watch_function</a>;    
<a name="l00219"></a><a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a">00219</a>   <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> <a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a" title="Callback for removing a watch.">remove_watch_function</a>; 
<a name="l00220"></a><a class="code" href="structDBusWatchList.html#aed21ba690eb810c4c2da581feaed822a">00220</a>   <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> <a class="code" href="structDBusWatchList.html#aed21ba690eb810c4c2da581feaed822a" title="Callback on toggling enablement.">watch_toggled_function</a>; 
<a name="l00221"></a><a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727">00221</a>   <span class="keywordtype">void</span> *<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a>;                           
<a name="l00222"></a><a class="code" href="structDBusWatchList.html#a2308b08f7f4cb858fbcca718f2bef735">00222</a>   <a class="code" href="group__DBusMemory.html#ga061bcded226d76c7d7de35beaa165cb5" title="The type of a function which frees a block of memory.">DBusFreeFunction</a> <a class="code" href="structDBusWatchList.html#a2308b08f7f4cb858fbcca718f2bef735" title="Free function for watch callback data.">watch_free_data_function</a>;  
<a name="l00223"></a>00223 };
<a name="l00224"></a>00224 
<a name="l00231"></a>00231 <a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a>*
<a name="l00232"></a><a class="code" href="group__DBusWatchInternals.html#ga5d9db5d0af5916a5ec890eb38d5741eb">00232</a> <a class="code" href="group__DBusWatchInternals.html#ga5d9db5d0af5916a5ec890eb38d5741eb" title="Creates a new watch list.">_dbus_watch_list_new</a> (<span class="keywordtype">void</span>)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234   <a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *watch_list;
<a name="l00235"></a>00235 
<a name="l00236"></a>00236   watch_list = <a class="code" href="group__DBusMemory.html#gaba9d823abda7f4cadbaf5177d3b8b793" title="Safe macro for using dbus_malloc0().">dbus_new0</a> (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a>, 1);
<a name="l00237"></a>00237   <span class="keywordflow">if</span> (watch_list == <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00238"></a>00238     <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="l00239"></a>00239 
<a name="l00240"></a>00240   <span class="keywordflow">return</span> watch_list;
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 
<a name="l00248"></a>00248 <span class="keywordtype">void</span>
<a name="l00249"></a><a class="code" href="group__DBusWatchInternals.html#gac3f75c0da2c8c51e8708f45dd27f9e2d">00249</a> <a class="code" href="group__DBusWatchInternals.html#gac3f75c0da2c8c51e8708f45dd27f9e2d" title="Frees a DBusWatchList.">_dbus_watch_list_free</a> (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *watch_list)
<a name="l00250"></a>00250 {
<a name="l00251"></a>00251   <span class="comment">/* free watch_data and removes watches as a side effect */</span>
<a name="l00252"></a>00252   <a class="code" href="group__DBusWatchInternals.html#gae9ab8cf14f4191191e94183be9a031d9" title="Sets the watch functions.">_dbus_watch_list_set_functions</a> (watch_list,
<a name="l00253"></a>00253                                   <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 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="l00254"></a>00254   <a class="code" href="group__DBusList.html#ga8dd69084b53361803a765e6d53d5b9d1" title="Calls the given function for each element in the list.">_dbus_list_foreach</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>,
<a name="l00255"></a>00255                       (DBusForeachFunction) <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a>,
<a name="l00256"></a>00256                       <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00257"></a>00257   <a class="code" href="group__DBusList.html#gaa36d13444a050a923941c53650b72f9d" title="Frees all links in the list and sets the list head to NULL.">_dbus_list_clear</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>);
<a name="l00258"></a>00258 
<a name="l00259"></a>00259   <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> (watch_list);
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261 
<a name="l00262"></a>00262 <span class="preprocessor">#ifdef DBUS_ENABLE_VERBOSE_MODE</span>
<a name="l00263"></a>00263 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>*
<a name="l00264"></a>00264 watch_flags_to_string (<span class="keywordtype">int</span> flags)
<a name="l00265"></a>00265 {
<a name="l00266"></a>00266   <span class="keyword">const</span> <span class="keywordtype">char</span> *watch_type;
<a name="l00267"></a>00267 
<a name="l00268"></a>00268   <span class="keywordflow">if</span> ((flags &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a178bd7a88e9bfbb8505db76eb7e0ccc4" title="As in POLLIN.">DBUS_WATCH_READABLE</a>) &amp;&amp;
<a name="l00269"></a>00269       (flags &amp; <a class="code" href="group__DBusConnection.html#gga0556779e61aeb19eb9cf6b6466bd1b98a62ddca29b06bfbbc08bb7f3dfd3d307f" title="As in POLLOUT.">DBUS_WATCH_WRITABLE</a>))
<a name="l00270"></a>00270     watch_type = <span class="stringliteral">&quot;readwrite&quot;</span>;
<a name="l00271"></a>00271   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (flags &amp; DBUS_WATCH_READABLE)
<a name="l00272"></a>00272     watch_type = <span class="stringliteral">&quot;read&quot;</span>;
<a name="l00273"></a>00273   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (flags &amp; DBUS_WATCH_WRITABLE)
<a name="l00274"></a>00274     watch_type = <span class="stringliteral">&quot;write&quot;</span>;
<a name="l00275"></a>00275   <span class="keywordflow">else</span>
<a name="l00276"></a>00276     watch_type = <span class="stringliteral">&quot;not read or write&quot;</span>;
<a name="l00277"></a>00277   <span class="keywordflow">return</span> watch_type;
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 <span class="preprocessor">#endif </span><span class="comment">/* DBUS_ENABLE_VERBOSE_MODE */</span>
<a name="l00280"></a>00280 
<a name="l00295"></a>00295 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00296"></a><a class="code" href="group__DBusWatchInternals.html#gae9ab8cf14f4191191e94183be9a031d9">00296</a> <a class="code" href="group__DBusWatchInternals.html#gae9ab8cf14f4191191e94183be9a031d9" title="Sets the watch functions.">_dbus_watch_list_set_functions</a> (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a>           *watch_list,
<a name="l00297"></a>00297                                 <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="l00298"></a>00298                                 <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="l00299"></a>00299                                 <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="l00300"></a>00300                                 <span class="keywordtype">void</span>                    *data,
<a name="l00301"></a>00301                                 <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="l00302"></a>00302 {
<a name="l00303"></a>00303   <span class="comment">/* Add watches with the new watch function, failing on OOM */</span>
<a name="l00304"></a>00304   <span class="keywordflow">if</span> (add_function != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00305"></a>00305     {
<a name="l00306"></a>00306       <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *link;
<a name="l00307"></a>00307       
<a name="l00308"></a>00308       link = <a class="code" href="group__DBusList.html#ga1e26ce4fb4acb50593bd5ed2f4eeb3ae" title="Gets the first link in the list.">_dbus_list_get_first_link</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>);
<a name="l00309"></a>00309       <span class="keywordflow">while</span> (link != <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 name="l00311"></a>00311           <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *next = <a class="code" href="group__DBusList.html#gaede4ace46d5ee497d75074bfec4490a2" title="Gets the next link in the list, or NULL if there are no more links.">_dbus_list_get_next_link</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>,
<a name="l00312"></a>00312                                                      link);
<a name="l00313"></a>00313 
<a name="l00314"></a>00314           _dbus_verbose (<span class="stringliteral">&quot;Adding a %s watch on fd %d using newly-set add watch function\n&quot;</span>,
<a name="l00315"></a>00315                          watch_flags_to_string (<a class="code" href="group__DBusWatch.html#gaf172a2b1d1f82333e67cec8d99c9204a" title="Gets flags from DBusWatchFlags indicating what conditions should be monitored on the file descriptor...">dbus_watch_get_flags</a> (link-&gt;<a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>)),
<a name="l00316"></a>00316                          <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (link-&gt;<a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>));
<a name="l00317"></a>00317           
<a name="l00318"></a>00318           <span class="keywordflow">if</span> (!(* add_function) (link-&gt;<a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>, data))
<a name="l00319"></a>00319             {
<a name="l00320"></a>00320               <span class="comment">/* remove it all again and return FALSE */</span>
<a name="l00321"></a>00321               <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *link2;
<a name="l00322"></a>00322               
<a name="l00323"></a>00323               link2 = <a class="code" href="group__DBusList.html#ga1e26ce4fb4acb50593bd5ed2f4eeb3ae" title="Gets the first link in the list.">_dbus_list_get_first_link</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>);
<a name="l00324"></a>00324               <span class="keywordflow">while</span> (link2 != link)
<a name="l00325"></a>00325                 {
<a name="l00326"></a>00326                   <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *next = <a class="code" href="group__DBusList.html#gaede4ace46d5ee497d75074bfec4490a2" title="Gets the next link in the list, or NULL if there are no more links.">_dbus_list_get_next_link</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>,
<a name="l00327"></a>00327                                                              link2);
<a name="l00328"></a>00328                   
<a name="l00329"></a>00329                   _dbus_verbose (<span class="stringliteral">&quot;Removing watch on fd %d using newly-set remove function because initial add failed\n&quot;</span>,
<a name="l00330"></a>00330                                  <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (link2-&gt;<a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>));
<a name="l00331"></a>00331                   
<a name="l00332"></a>00332                   (* remove_function) (link2-&gt;<a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>, data);
<a name="l00333"></a>00333                   
<a name="l00334"></a>00334                   link2 = next;
<a name="l00335"></a>00335                 }
<a name="l00336"></a>00336 
<a name="l00337"></a>00337               <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00338"></a>00338             }
<a name="l00339"></a>00339       
<a name="l00340"></a>00340           link = next;
<a name="l00341"></a>00341         }
<a name="l00342"></a>00342     }
<a name="l00343"></a>00343   
<a name="l00344"></a>00344   <span class="comment">/* Remove all current watches from previous watch handlers */</span>
<a name="l00345"></a>00345 
<a name="l00346"></a>00346   <span class="keywordflow">if</span> (watch_list-&gt;<a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a" title="Callback for removing a watch.">remove_watch_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00347"></a>00347     {
<a name="l00348"></a>00348       _dbus_verbose (<span class="stringliteral">&quot;Removing all pre-existing watches\n&quot;</span>);
<a name="l00349"></a>00349       
<a name="l00350"></a>00350       <a class="code" href="group__DBusList.html#ga8dd69084b53361803a765e6d53d5b9d1" title="Calls the given function for each element in the list.">_dbus_list_foreach</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>,
<a name="l00351"></a>00351                           (DBusForeachFunction) watch_list-&gt;<a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a" title="Callback for removing a watch.">remove_watch_function</a>,
<a name="l00352"></a>00352                           watch_list-&gt;<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a>);
<a name="l00353"></a>00353     }
<a name="l00354"></a>00354 
<a name="l00355"></a>00355   <span class="keywordflow">if</span> (watch_list-&gt;<a class="code" href="structDBusWatchList.html#a2308b08f7f4cb858fbcca718f2bef735" title="Free function for watch callback data.">watch_free_data_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00356"></a>00356     (* watch_list-&gt;<a class="code" href="structDBusWatchList.html#a2308b08f7f4cb858fbcca718f2bef735" title="Free function for watch callback data.">watch_free_data_function</a>) (watch_list-&gt;<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a>);
<a name="l00357"></a>00357   
<a name="l00358"></a>00358   watch_list-&gt;<a class="code" href="structDBusWatchList.html#ae515ab01e8d08e6b252e468be7dc7074" title="Callback for adding a watch.">add_watch_function</a> = add_function;
<a name="l00359"></a>00359   watch_list-&gt;<a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a" title="Callback for removing a watch.">remove_watch_function</a> = remove_function;
<a name="l00360"></a>00360   watch_list-&gt;<a class="code" href="structDBusWatchList.html#aed21ba690eb810c4c2da581feaed822a" title="Callback on toggling enablement.">watch_toggled_function</a> = toggled_function;
<a name="l00361"></a>00361   watch_list-&gt;<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a> = data;
<a name="l00362"></a>00362   watch_list-&gt;<a class="code" href="structDBusWatchList.html#a2308b08f7f4cb858fbcca718f2bef735" title="Free function for watch callback data.">watch_free_data_function</a> = free_data_function;
<a name="l00363"></a>00363 
<a name="l00364"></a>00364   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366 
<a name="l00375"></a>00375 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00376"></a><a class="code" href="group__DBusWatchInternals.html#gaec61655a4bd6186a6a1ec104771d8af5">00376</a> <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 class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *watch_list,
<a name="l00377"></a>00377                             <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>     *watch)
<a name="l00378"></a>00378 {
<a name="l00379"></a>00379   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusList.html#gad99045e79db46159babe69718f343053" title="Appends a value to the list.">_dbus_list_append</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>, watch))
<a name="l00380"></a>00380     <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00381"></a>00381   
<a name="l00382"></a>00382   <a class="code" href="group__DBusWatchInternals.html#ga0db8530cc53589589d67dfb35d03db61" title="Increments the reference count of a DBusWatch object.">_dbus_watch_ref</a> (watch);
<a name="l00383"></a>00383 
<a name="l00384"></a>00384   <span class="keywordflow">if</span> (watch_list-&gt;<a class="code" href="structDBusWatchList.html#ae515ab01e8d08e6b252e468be7dc7074" title="Callback for adding a watch.">add_watch_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00385"></a>00385     {
<a name="l00386"></a>00386       _dbus_verbose (<span class="stringliteral">&quot;Adding watch on fd %d\n&quot;</span>,
<a name="l00387"></a>00387                      <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (watch));
<a name="l00388"></a>00388       
<a name="l00389"></a>00389       <span class="keywordflow">if</span> (!(* watch_list-&gt;<a class="code" href="structDBusWatchList.html#ae515ab01e8d08e6b252e468be7dc7074" title="Callback for adding a watch.">add_watch_function</a>) (watch,
<a name="l00390"></a>00390                                                watch_list-&gt;<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a>))
<a name="l00391"></a>00391         {
<a name="l00392"></a>00392           <a class="code" href="group__DBusList.html#gad93f1fc853914144e94fc7a7dc0945aa" title="Removes a value from the list.">_dbus_list_remove_last</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>, watch);
<a name="l00393"></a>00393           <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a> (watch);
<a name="l00394"></a>00394           <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa93f0eb578d23995850d61f7d61c55c1" title="Expands to &quot;0&quot;.">FALSE</a>;
<a name="l00395"></a>00395         }
<a name="l00396"></a>00396     }
<a name="l00397"></a>00397   
<a name="l00398"></a>00398   <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400 
<a name="l00408"></a>00408 <span class="keywordtype">void</span>
<a name="l00409"></a><a class="code" href="group__DBusWatchInternals.html#ga76894d297bc7d7d23cbacdc2b1778884">00409</a> <a class="code" href="group__DBusWatchInternals.html#ga76894d297bc7d7d23cbacdc2b1778884" title="Removes a watch from the watch list, invoking the application&#39;s DBusRemoveWatchFunction if appropriat...">_dbus_watch_list_remove_watch</a>  (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a> *watch_list,
<a name="l00410"></a>00410                                 <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>     *watch)
<a name="l00411"></a>00411 {
<a name="l00412"></a>00412   <span class="keywordflow">if</span> (!<a class="code" href="group__DBusList.html#ga202e6ac8ad3e4a9d4413e0248ffcf3e3" title="Removes a value from the list.">_dbus_list_remove</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>, watch))
<a name="l00413"></a>00413     _dbus_assert_not_reached (<span class="stringliteral">&quot;Nonexistent watch was removed&quot;</span>);
<a name="l00414"></a>00414   
<a name="l00415"></a>00415   <span class="keywordflow">if</span> (watch_list-&gt;<a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a" title="Callback for removing a watch.">remove_watch_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00416"></a>00416     {
<a name="l00417"></a>00417       _dbus_verbose (<span class="stringliteral">&quot;Removing watch on fd %d\n&quot;</span>,
<a name="l00418"></a>00418                      <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (watch));
<a name="l00419"></a>00419       
<a name="l00420"></a>00420       (* watch_list-&gt;<a class="code" href="structDBusWatchList.html#a3b4b6c6d8aeb77d9b08404575e0b805a" title="Callback for removing a watch.">remove_watch_function</a>) (watch,
<a name="l00421"></a>00421                                              watch_list-&gt;<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a>);
<a name="l00422"></a>00422     }
<a name="l00423"></a>00423   
<a name="l00424"></a>00424   <a class="code" href="group__DBusWatchInternals.html#ga7d27dfc13a3ccfbaa99ceab331bb46f0" title="Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...">_dbus_watch_unref</a> (watch);
<a name="l00425"></a>00425 }
<a name="l00426"></a>00426 
<a name="l00435"></a>00435 <span class="keywordtype">void</span>
<a name="l00436"></a><a class="code" href="group__DBusWatchInternals.html#ga14bb50e8663a1d9d3960b4f73c09c097">00436</a> <a class="code" href="group__DBusWatchInternals.html#ga14bb50e8663a1d9d3960b4f73c09c097" title="Sets a watch to the given enabled state, invoking the application&#39;s DBusWatchToggledFunction if appro...">_dbus_watch_list_toggle_watch</a> (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a>           *watch_list,
<a name="l00437"></a>00437                                <a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>               *watch,
<a name="l00438"></a>00438                                <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>              enabled)
<a name="l00439"></a>00439 {
<a name="l00440"></a>00440   enabled = !!enabled;
<a name="l00441"></a>00441   
<a name="l00442"></a>00442   <span class="keywordflow">if</span> (enabled == watch-&gt;<a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a>)
<a name="l00443"></a>00443     <span class="keywordflow">return</span>;
<a name="l00444"></a>00444 
<a name="l00445"></a>00445   watch-&gt;<a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a> = enabled;
<a name="l00446"></a>00446   
<a name="l00447"></a>00447   <span class="keywordflow">if</span> (watch_list-&gt;<a class="code" href="structDBusWatchList.html#aed21ba690eb810c4c2da581feaed822a" title="Callback on toggling enablement.">watch_toggled_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00448"></a>00448     {
<a name="l00449"></a>00449       _dbus_verbose (<span class="stringliteral">&quot;Toggling watch %p on fd %d to %d\n&quot;</span>,
<a name="l00450"></a>00450                      watch, <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (watch), watch-&gt;<a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a>);
<a name="l00451"></a>00451       
<a name="l00452"></a>00452       (* watch_list-&gt;<a class="code" href="structDBusWatchList.html#aed21ba690eb810c4c2da581feaed822a" title="Callback on toggling enablement.">watch_toggled_function</a>) (watch,
<a name="l00453"></a>00453                                               watch_list-&gt;<a class="code" href="structDBusWatchList.html#a767770241baf8ddcdb4b5c4b4f2a9727" title="Data for watch callbacks.">watch_data</a>);
<a name="l00454"></a>00454     }
<a name="l00455"></a>00455 }
<a name="l00456"></a>00456 
<a name="l00464"></a>00464 <span class="keywordtype">void</span>
<a name="l00465"></a><a class="code" href="group__DBusWatchInternals.html#ga935ba95d94a14aee79d80abe970eae53">00465</a> <a class="code" href="group__DBusWatchInternals.html#ga935ba95d94a14aee79d80abe970eae53" title="Sets all watches to the given enabled state, invoking the application&#39;s DBusWatchToggledFunction if a...">_dbus_watch_list_toggle_all_watches</a> (<a class="code" href="structDBusWatchList.html" title="DBusWatchList implementation details.">DBusWatchList</a>           *watch_list,
<a name="l00466"></a>00466                                      <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>              enabled)
<a name="l00467"></a>00467 {
<a name="l00468"></a>00468   <a class="code" href="structDBusList.html" title="A node in a linked list.">DBusList</a> *link;
<a name="l00469"></a>00469 
<a name="l00470"></a>00470   <span class="keywordflow">for</span> (link = <a class="code" href="group__DBusList.html#ga1e26ce4fb4acb50593bd5ed2f4eeb3ae" title="Gets the first link in the list.">_dbus_list_get_first_link</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>);
<a name="l00471"></a>00471        link != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>;
<a name="l00472"></a>00472        link = <a class="code" href="group__DBusList.html#gaede4ace46d5ee497d75074bfec4490a2" title="Gets the next link in the list, or NULL if there are no more links.">_dbus_list_get_next_link</a> (&amp;watch_list-&gt;<a class="code" href="structDBusWatchList.html#ab4e73fc61203dd03949f0b7d163d456d" title="Watch objects.">watches</a>, link))
<a name="l00473"></a>00473     {
<a name="l00474"></a>00474       <a class="code" href="group__DBusWatchInternals.html#ga14bb50e8663a1d9d3960b4f73c09c097" title="Sets a watch to the given enabled state, invoking the application&#39;s DBusWatchToggledFunction if appro...">_dbus_watch_list_toggle_watch</a> (watch_list, link-&gt;<a class="code" href="structDBusList.html#a29ab457bcf9092252bb0c4282c727055" title="Data stored at this element.">data</a>, enabled);
<a name="l00475"></a>00475     }
<a name="l00476"></a>00476 }
<a name="l00477"></a>00477 
<a name="l00490"></a>00490 <span class="keywordtype">void</span>
<a name="l00491"></a><a class="code" href="group__DBusWatchInternals.html#ga75620808f4d2245914012a41e3b82f3c">00491</a> <a class="code" href="group__DBusWatchInternals.html#ga75620808f4d2245914012a41e3b82f3c" title="Sets the handler for the watch.">_dbus_watch_set_handler</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>        *watch,
<a name="l00492"></a>00492                          <a class="code" href="group__DBusWatchInternals.html#gae71d41a6a6c6a3b845ccc30b09004228" title="function to run when the watch is handled">DBusWatchHandler</a>  handler,
<a name="l00493"></a>00493                          <span class="keywordtype">void</span>             *data,
<a name="l00494"></a>00494                          <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="l00495"></a>00495 {
<a name="l00496"></a>00496   <span class="keywordflow">if</span> (watch-&gt;<a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a>)
<a name="l00497"></a>00497     (* watch-&gt;<a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a>) (watch-&gt;<a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87" title="Watch handler data.">handler_data</a>);
<a name="l00498"></a>00498 
<a name="l00499"></a>00499   watch-&gt;<a class="code" href="structDBusWatch.html#aad3fb97da0ad7e5897611930f7a1c3e9" title="Watch handler.">handler</a> = handler;
<a name="l00500"></a>00500   watch-&gt;<a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87" title="Watch handler data.">handler_data</a> = data;
<a name="l00501"></a>00501   watch-&gt;<a class="code" href="structDBusWatch.html#a64eaf9b88cebfc640bc85d0fd37184c8" title="Free the watch handler data.">free_handler_data_function</a> = free_data_function;
<a name="l00502"></a>00502 }
<a name="l00503"></a>00503 
<a name="l00535"></a>00535 <span class="keywordtype">int</span>
<a name="l00536"></a><a class="code" href="group__DBusWatch.html#ga62d7e86fe386ed48fb90d443b3a2ce7a">00536</a> <a class="code" href="group__DBusWatch.html#ga62d7e86fe386ed48fb90d443b3a2ce7a" title="Deprecated former name of dbus_watch_get_unix_fd().">dbus_watch_get_fd</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00537"></a>00537 {
<a name="l00538"></a>00538   _dbus_return_val_if_fail (watch != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, -1);
<a name="l00539"></a>00539 
<a name="l00540"></a>00540   <span class="keywordflow">return</span> <a class="code" href="group__DBusWatch.html#ga15df7f6120ead3e09bec8a70d3c43c0d" title="Returns a UNIX file descriptor to be watched, which may be a pipe, socket, or other type of descripto...">dbus_watch_get_unix_fd</a>(watch);
<a name="l00541"></a>00541 }
<a name="l00542"></a>00542 
<a name="l00556"></a>00556 <span class="keywordtype">int</span>
<a name="l00557"></a><a class="code" href="group__DBusWatch.html#ga15df7f6120ead3e09bec8a70d3c43c0d">00557</a> <a class="code" href="group__DBusWatch.html#ga15df7f6120ead3e09bec8a70d3c43c0d" title="Returns a UNIX file descriptor to be watched, which may be a pipe, socket, or other type of descripto...">dbus_watch_get_unix_fd</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00558"></a>00558 {
<a name="l00559"></a>00559   _dbus_return_val_if_fail (watch != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, -1);
<a name="l00560"></a>00560 
<a name="l00561"></a>00561   <span class="comment">/* FIXME remove #ifdef and do this on a lower level</span>
<a name="l00562"></a>00562 <span class="comment">   * (watch should have set_socket and set_unix_fd and track</span>
<a name="l00563"></a>00563 <span class="comment">   * which it has, and the transport should provide the</span>
<a name="l00564"></a>00564 <span class="comment">   * appropriate watch type)</span>
<a name="l00565"></a>00565 <span class="comment">   */</span>
<a name="l00566"></a>00566 <span class="preprocessor">#ifdef DBUS_UNIX</span>
<a name="l00567"></a>00567 <span class="preprocessor"></span>  <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a>;
<a name="l00568"></a>00568 <span class="preprocessor">#else</span>
<a name="l00569"></a>00569 <span class="preprocessor"></span>  <span class="keywordflow">return</span> <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a>( watch );
<a name="l00570"></a>00570 <span class="preprocessor">#endif</span>
<a name="l00571"></a>00571 <span class="preprocessor"></span>}
<a name="l00572"></a>00572 
<a name="l00585"></a>00585 <span class="keywordtype">int</span>
<a name="l00586"></a><a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f">00586</a> <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00587"></a>00587 {
<a name="l00588"></a>00588   _dbus_return_val_if_fail (watch != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, -1);
<a name="l00589"></a>00589 
<a name="l00590"></a>00590   <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a>;
<a name="l00591"></a>00591 }
<a name="l00592"></a>00592 
<a name="l00606"></a>00606 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>
<a name="l00607"></a><a class="code" href="group__DBusWatch.html#gaf172a2b1d1f82333e67cec8d99c9204a">00607</a> <a class="code" href="group__DBusWatch.html#gaf172a2b1d1f82333e67cec8d99c9204a" title="Gets flags from DBusWatchFlags indicating what conditions should be monitored on the file descriptor...">dbus_watch_get_flags</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00608"></a>00608 {
<a name="l00609"></a>00609   _dbus_return_val_if_fail (watch != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>, 0);
<a name="l00610"></a>00610   _dbus_assert ((watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a> &amp; VALID_WATCH_FLAGS) == watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a>);
<a name="l00611"></a>00611 
<a name="l00612"></a>00612   <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a>;
<a name="l00613"></a>00613 }
<a name="l00614"></a>00614 
<a name="l00622"></a>00622 <span class="keywordtype">void</span>*
<a name="l00623"></a><a class="code" href="group__DBusWatch.html#ga8dcdbd07f15a56207af4a36cb005da77">00623</a> <a class="code" href="group__DBusWatch.html#ga8dcdbd07f15a56207af4a36cb005da77" title="Gets data previously set with dbus_watch_set_data() or NULL if none.">dbus_watch_get_data</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00624"></a>00624 {
<a name="l00625"></a>00625   _dbus_return_val_if_fail (watch != <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="l00626"></a>00626 
<a name="l00627"></a>00627   <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#a71877a39d8c2a7d533c0c6f280648d53" title="Application data.">data</a>;
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629 
<a name="l00641"></a>00641 <span class="keywordtype">void</span>
<a name="l00642"></a><a class="code" href="group__DBusWatch.html#ga5c75a65cf0680956cc0188d86a05cfae">00642</a> <a class="code" href="group__DBusWatch.html#ga5c75a65cf0680956cc0188d86a05cfae" title="Sets data which can be retrieved with dbus_watch_get_data().">dbus_watch_set_data</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>        *watch,
<a name="l00643"></a>00643                      <span class="keywordtype">void</span>             *data,
<a name="l00644"></a>00644                      <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="l00645"></a>00645 {
<a name="l00646"></a>00646   _dbus_return_if_fail (watch != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>);
<a name="l00647"></a>00647 
<a name="l00648"></a>00648   _dbus_verbose (<span class="stringliteral">&quot;Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n&quot;</span>,
<a name="l00649"></a>00649                  <a class="code" href="group__DBusWatch.html#ga91308f393d41b31babda17c83833517f" title="Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...">dbus_watch_get_socket</a> (watch),
<a name="l00650"></a>00650                  data, free_data_function, watch-&gt;<a class="code" href="structDBusWatch.html#a71877a39d8c2a7d533c0c6f280648d53" title="Application data.">data</a>, watch-&gt;<a class="code" href="structDBusWatch.html#ad848cbd636518fd346039d0d771ba021" title="Free the application data.">free_data_function</a>);
<a name="l00651"></a>00651   
<a name="l00652"></a>00652   <span class="keywordflow">if</span> (watch-&gt;<a class="code" href="structDBusWatch.html#ad848cbd636518fd346039d0d771ba021" title="Free the application data.">free_data_function</a> != <a class="code" href="group__DBusMacros.html#ga070d2ce7b6bb7e5c05602aa8c308d0c4" title="A null pointer, defined appropriately for C or C++.">NULL</a>)
<a name="l00653"></a>00653     (* watch-&gt;<a class="code" href="structDBusWatch.html#ad848cbd636518fd346039d0d771ba021" title="Free the application data.">free_data_function</a>) (watch-&gt;<a class="code" href="structDBusWatch.html#a71877a39d8c2a7d533c0c6f280648d53" title="Application data.">data</a>);
<a name="l00654"></a>00654   
<a name="l00655"></a>00655   watch-&gt;<a class="code" href="structDBusWatch.html#a71877a39d8c2a7d533c0c6f280648d53" title="Application data.">data</a> = data;
<a name="l00656"></a>00656   watch-&gt;<a class="code" href="structDBusWatch.html#ad848cbd636518fd346039d0d771ba021" title="Free the application data.">free_data_function</a> = free_data_function;
<a name="l00657"></a>00657 }
<a name="l00658"></a>00658 
<a name="l00666"></a>00666 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00667"></a><a class="code" href="group__DBusWatch.html#gae7a91e6d4d1bc187419c47c522e33a8f">00667</a> <a class="code" href="group__DBusWatch.html#gae7a91e6d4d1bc187419c47c522e33a8f" title="Returns whether a watch is enabled or not.">dbus_watch_get_enabled</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a> *watch)
<a name="l00668"></a>00668 {
<a name="l00669"></a>00669   _dbus_return_val_if_fail (watch != <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 &quot;0&quot;.">FALSE</a>);
<a name="l00670"></a>00670 
<a name="l00671"></a>00671   <span class="keywordflow">return</span> watch-&gt;<a class="code" href="structDBusWatch.html#a010564b43e0c7dd438b9ac4b0c1dbe64" title="Whether it&#39;s enabled.">enabled</a>;
<a name="l00672"></a>00672 }
<a name="l00673"></a>00673 
<a name="l00674"></a>00674 
<a name="l00697"></a>00697 <a class="code" href="group__DBusTypes.html#ga39c9cb0f3a2a8ad6f55cc4855d035349" title="A boolean, valid values are TRUE and FALSE.">dbus_bool_t</a>
<a name="l00698"></a><a class="code" href="group__DBusWatch.html#gac2acdb1794450ac01a43ec4c3e07ebf7">00698</a> <a class="code" href="group__DBusWatch.html#gac2acdb1794450ac01a43ec4c3e07ebf7" title="Called to notify the D-Bus library when a previously-added watch is ready for reading or writing...">dbus_watch_handle</a> (<a class="code" href="structDBusWatch.html" title="Implementation of DBusWatch.">DBusWatch</a>    *watch,
<a name="l00699"></a>00699                    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>  flags)
<a name="l00700"></a>00700 {
<a name="l00701"></a>00701   _dbus_return_val_if_fail (watch != <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 &quot;0&quot;.">FALSE</a>);
<a name="l00702"></a>00702 
<a name="l00703"></a>00703 <span class="preprocessor">#ifndef DBUS_DISABLE_CHECKS</span>
<a name="l00704"></a>00704 <span class="preprocessor"></span>  <span class="keywordflow">if</span> (watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a> &lt; 0 || watch-&gt;<a class="code" href="structDBusWatch.html#a7f1c2c609410f58a2328681c2893f70a" title="Conditions to watch.">flags</a> == 0)
<a name="l00705"></a>00705     {
<a name="l00706"></a>00706       <a class="code" href="group__DBusInternalsUtils.html#ga63f2f8a068454b781f214ba596e313b4" title="Prints a &quot;critical&quot; warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...">_dbus_warn_check_failed</a> (<span class="stringliteral">&quot;Watch is invalid, it should have been removed\n&quot;</span>);
<a name="l00707"></a>00707       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00708"></a>00708     }
<a name="l00709"></a>00709 <span class="preprocessor">#endif</span>
<a name="l00710"></a>00710 <span class="preprocessor"></span>    
<a name="l00711"></a>00711   _dbus_return_val_if_fail (watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a> &gt;= 0 <span class="comment">/* fails if watch was removed */</span>, <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>);
<a name="l00712"></a>00712   
<a name="l00713"></a>00713   <a class="code" href="group__DBusWatchInternals.html#gab8f49926fe9ee56cb4ae7c1c8071cca3" title="Sanitizes the given condition so that it only contains flags that the DBusWatch requested.">_dbus_watch_sanitize_condition</a> (watch, &amp;flags);
<a name="l00714"></a>00714 
<a name="l00715"></a>00715   <span class="keywordflow">if</span> (flags == 0)
<a name="l00716"></a>00716     {
<a name="l00717"></a>00717       _dbus_verbose (<span class="stringliteral">&quot;After sanitization, watch flags on fd %d were 0\n&quot;</span>,
<a name="l00718"></a>00718                      watch-&gt;<a class="code" href="structDBusWatch.html#ab4021cce958b50cbcda5eeabc6af2217" title="File descriptor.">fd</a>);
<a name="l00719"></a>00719       <span class="keywordflow">return</span> <a class="code" href="group__DBusMacros.html#gaa8cecfc5c5c054d2875c03e77b7be15d" title="Expands to &quot;1&quot;.">TRUE</a>;
<a name="l00720"></a>00720     }
<a name="l00721"></a>00721   <span class="keywordflow">else</span>
<a name="l00722"></a>00722     <span class="keywordflow">return</span> (* watch-&gt;<a class="code" href="structDBusWatch.html#aad3fb97da0ad7e5897611930f7a1c3e9" title="Watch handler.">handler</a>) (watch, flags,
<a name="l00723"></a>00723                                watch-&gt;<a class="code" href="structDBusWatch.html#ae906b28caa8a4323f85c882abe901e87" title="Watch handler data.">handler_data</a>);
<a name="l00724"></a>00724 }
<a name="l00725"></a>00725 
<a name="l00726"></a>00726 
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Thu Mar 3 2016 17:50:32 for D-Bus by &#160;<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>