/usr/share/doc/libdbus-java/dbus-java/dbus-javase14.html is in libdbus-java-doc 2.8-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | <?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->
<html xmlns="http://www.w3.org/1999/xhtml"
>
<head><title>Examples</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" />
<!-- xhtml,2,html -->
<meta name="src" content="dbus-java.tex" />
<meta name="date" content="2015-02-13 22:35:00" />
<link rel="stylesheet" type="text/css" href="dbus-java.css" />
</head><body
>
<!--l. 1064--><div class="crosslinks"><p class="noindent">[<a
href="dbus-javase13.html" >prev</a>] [<a
href="dbus-javase13.html#taildbus-javase13.html" >prev-tail</a>] [<a
href="#taildbus-javase14.html">tail</a>] [<a
href="dbus-java.html# " >up</a>] </p></div>
<h3 class="sectionHead"><span class="titlemark">14 </span> <a
id="x41-4400014"></a>Examples</h3>
<!--l. 1066--><p class="noindent" >As an example here are a complete set of interfaces for the
bluemon<span class="footnote-mark"><a
href="dbus-java42.html#fn24x0"><sup class="textsuperscript">24</sup></a></span><a
id="x41-44001f24"></a>
daemon, which communicates over D-Bus. These interfaces were all created by querying
introspection data over the bus.
</p><!--l. 1071--><p class="indent" >
</p>
<hr class="figure" /><div class="figure"
>
<a
id="x41-4400221"></a>
<div class="center"
>
<!--l. 1074--><p class="noindent" >
</p>
<div class="verbatim" id="verbatim-32">
package cx.ath.matthew.bluemon;
 <br />import org.freedesktop.dbus.DBusInterface;
 <br />import org.freedesktop.dbus.UInt32;
 <br />public interface Bluemon extends DBusInterface
 <br />{
 <br />  public Triplet<String, Boolean, UInt32>
 <br />  Status(String address);
 <br />}
</div>
<!--l. 1084--><p class="nopar" ></p></div>
<br /> <div class="caption"
><span class="id">Figure 21: </span><span
class="content">cx/ath/matthew/bluemon/Bluemon.java</span></div><!--tex4ht:label?: x41-4400221 -->
</div><hr class="endfigure" />
<!--l. 1089--><p class="indent" >
</p>
<hr class="figure" /><div class="figure"
>
<a
id="x41-4400322"></a>
<div class="center"
>
<!--l. 1092--><p class="noindent" >
</p>
<div class="verbatim" id="verbatim-33">
package cx.ath.matthew.bluemon;
 <br />import org.freedesktop.dbus.DBusInterface;
 <br />import org.freedesktop.dbus.DBusSignal;
 <br />import org.freedesktop.dbus.exceptions.DBusException;
 <br />public interface ProximitySignal extends DBusInterface
 <br />{
 <br />   public static class Connect extends DBusSignal
 <br />   {
 <br />      public final String address;
 <br />      public Connect(String path, String address)
 <br />                                 throws DBusException
 <br />      {
 <br />         super(path, address);
 <br />         this.address = address;
 <br />      }
 <br />   }
 <br />   public static class Disconnect extends DBusSignal
 <br />   {
 <br />      public final String address;
 <br />      public Disconnect(String path, String address)
 <br />                                 throws DBusException
 <br />      {
 <br />         super(path, address);
 <br />         this.address = address;
 <br />      }
 <br />   }
 <br />}
</div>
<!--l. 1121--><p class="nopar" ></p></div>
<br /> <div class="caption"
><span class="id">Figure 22: </span><span
class="content">cx/ath/matthew/bluemon/ProximitySignal.java</span></div><!--tex4ht:label?: x41-4400322 -->
</div><hr class="endfigure" />
<!--l. 1126--><p class="indent" >
</p>
<hr class="figure" /><div class="figure"
>
<a
id="x41-4400423"></a>
<div class="center"
>
<!--l. 1129--><p class="noindent" >
</p>
<div class="verbatim" id="verbatim-34">
package cx.ath.matthew.bluemon;
 <br />import org.freedesktop.dbus.Tuple;
 <br />/** Just a typed container class */
 <br />public final class Triplet <A,B,C> extends Tuple
 <br />{
 <br />   public final A a;
 <br />   public final B b;
 <br />   public final C c;
 <br />   public Triplet(A a, B b, C c)
 <br />   {
 <br />      super(a, b, c);
 <br />      this.a = a;
 <br />      this.b = b;
 <br />      this.c = c;
 <br />   }
 <br />}
</div>
<!--l. 1147--><p class="nopar" ></p></div>
<br /> <div class="caption"
><span class="id">Figure 23: </span><span
class="content">cx/ath/matthew/bluemon/Triplet.java</span></div><!--tex4ht:label?: x41-4400423 -->
</div><hr class="endfigure" />
<!--l. 1152--><p class="indent" >
</p>
<hr class="figure" /><div class="figure"
>
<a
id="x41-4400524"></a>
<div class="center"
>
<!--l. 1155--><p class="noindent" >
</p>
<div class="verbatim" id="verbatim-35">
package cx.ath.matthew.bluemon;
 <br />import org.freedesktop.dbus.DBusConnection;
 <br />import org.freedesktop.dbus.DBusSigHandler;
 <br />import org.freedesktop.dbus.DBusSignal;
 <br />import org.freedesktop.dbus.UInt32;
 <br />import org.freedesktop.dbus.exceptions.DBusException;
 <br />
 <br />public class Query {
 <br />   public static void main(String[] args) {
 <br />      String btid;
 <br />      Triplet<String, Boolean, UInt32> rv = null;
 <br />
 <br />      if (0 == args.length) btid = "";
 <br />      else btid = args[0];
 <br />
 <br />      DBusConnection conn = null;
 <br />      try {
 <br />         conn = DBusConnection.getConnection(DBusConnection.SYSTEM);
 <br />      } catch (DBusException De) {
 <br />         System.exit(1);
 <br />      }
 <br />      Bluemon b = (Bluemon) conn.getRemoteObject(
 <br />            "cx.ath.matthew.bluemon.server",
 <br />            "/cx/ath/matthew/bluemon/Bluemon", Bluemon.class);
 <br />      try {
 <br />         rv = b.Status(btid);
 <br />      } catch (RuntimeException Re) {
 <br />         System.exit(1);
 <br />      }
 <br />      String address = rv.a;
 <br />      boolean status = rv.b;
 <br />      int level = rv.c.intValue();
 <br />
 <br />      if (status)
 <br />         System.out.println("Device "+address+
 <br />                            " connected with level "+level);
 <br />      else
 <br />         System.out.println("Device "+address+" not connected");
 <br />      conn.disconnect();
 <br />   }
 <br />}
</div>
<!--l. 1198--><p class="nopar" ></p></div>
<br /> <div class="caption"
><span class="id">Figure 24: </span><span
class="content">cx/ath/matthew/bluemon/Query.java</span></div><!--tex4ht:label?: x41-4400524 -->
</div><hr class="endfigure" />
<!--l. 1203--><p class="indent" >
</p>
<hr class="figure" /><div class="figure"
>
<a
id="x41-4400625"></a>
<div class="center"
>
<!--l. 1206--><p class="noindent" >
</p>
<div class="verbatim" id="verbatim-36">
/* cx/ath/matthew/bluemon/Client.java */
 <br />package cx.ath.matthew.bluemon;
 <br />
 <br />import org.freedesktop.dbus.DBusConnection;
 <br />import org.freedesktop.dbus.DBusSigHandler;
 <br />import org.freedesktop.dbus.DBusSignal;
 <br />import org.freedesktop.dbus.exceptions.DBusException;
 <br />
 <br />public class Client implements DBusSigHandler
 <br />{
 <br />   public void handle(DBusSignal s)
 <br />   {
 <br />      if (s instanceof ProximitySignal.Connect)
 <br />         System.out.println("Got a connect for "
 <br />               +((ProximitySignal.Connect) s).address);
 <br />      else if (s instanceof ProximitySignal.Disconnect)
 <br />         System.out.println("Got a disconnect for "
 <br />               +((ProximitySignal.Disconnect) s).address);
 <br />   }
 <br />   public static void main(String[] args)
 <br />   {
 <br />      System.out.println("Creating Connection");
 <br />      DBusConnection conn = null;
 <br />      try {
 <br />         conn = DBusConnection
 <br />                  .getConnection(DBusConnection.SYSTEM);
 <br />      } catch (DBusException DBe) {
 <br />         System.out.println("Could not connect to bus");
 <br />         System.exit(1);
 <br />      }
 <br />
 <br />      try {
 <br />         conn.addSigHandler(ProximitySignal.Connect.class,
 <br />         new Client());
 <br />         conn.addSigHandler(ProximitySignal.Disconnect.class,
 <br />         new Client());
 <br />      } catch (DBusException DBe) {
 <br />         conn.disconnect();
 <br />         System.exit(1);
 <br />      }
 <br />   }
 <br />}
</div>
<!--l. 1250--><p class="nopar" ></p></div>
<br /> <div class="caption"
><span class="id">Figure 25: </span><span
class="content">cx/ath/matthew/bluemon/Client.java</span></div><!--tex4ht:label?: x41-4400625 -->
</div><hr class="endfigure" />
<!--l. 1255--><p class="indent" >
</p>
<!--l. 1257--><div class="crosslinks"><p class="noindent">[<a
href="dbus-javase13.html" >prev</a>] [<a
href="dbus-javase13.html#taildbus-javase13.html" >prev-tail</a>] [<a
href="dbus-javase14.html" >front</a>] [<a
href="dbus-java.html# " >up</a>] </p></div>
<!--l. 1257--><p class="indent" > <a
id="taildbus-javase14.html"></a> </p>
</body></html>
|