Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > main-release > by-pkgid > 926d2d1e3111287cee1b0a4fad4fb4f6 > files > 306

lib64dbus-1_3-devel-0.92-6mdv2007.0.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>test-dbus-glib.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>test-dbus-glib.c</h1><div class="fragment"><pre>00001 <font class="comment">/* -*- mode: C; c-file-style: "gnu" -*- */</font>
00002 <font class="preprocessor">#include "dbus-glib.h"</font>
00003 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
00004 
00005 <font class="keywordtype">int</font>
00006 main (<font class="keywordtype">int</font> argc, <font class="keywordtype">char</font> **argv)
00007 {
00008   <a class="code" href="structDBusConnection.html">DBusConnection</a> *connection;
00009   <a class="code" href="structDBusMessage.html">DBusMessage</a> *message, *reply;  
00010   GMainLoop *loop;
00011   <a class="code" href="structDBusError.html">DBusError</a> error;
00012   
00013   <font class="keywordflow">if</font> (argc &lt; 2)
00014     {
00015       g_printerr (<font class="stringliteral">"Give the server address as an argument\n"</font>);
00016       <font class="keywordflow">return</font> 1;
00017     }
00018 
00019   loop = g_main_loop_new (NULL, FALSE);
00020 
00021   dbus_error_init (&amp;error);
00022   connection = dbus_connection_open (argv[1], &amp;error);
00023   <font class="keywordflow">if</font> (connection == NULL)
00024     {
00025       g_printerr (<font class="stringliteral">"Failed to open connection to %s: %s\n"</font>, argv[1],
00026                   error.<a class="code" href="structDBusError.html#m1">message</a>);
00027       dbus_error_free (&amp;error);
00028       <font class="keywordflow">return</font> 1;
00029     }
00030 
00031   dbus_connection_setup_with_g_main (connection, NULL);
00032 
00033   message = dbus_message_new (DBUS_MESSAGE_HELLO,
00034                               DBUS_SERVICE_DBUS);
00035 
00036   dbus_error_init (&amp;error);
00037   reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &amp;error);
00038   <font class="keywordflow">if</font> (reply == NULL)
00039     {
00040       g_printerr (<font class="stringliteral">"Error on hello message: %s\n"</font>, error.<a class="code" href="structDBusError.html#m1">message</a>);
00041       dbus_error_free (&amp;error);
00042       <font class="keywordflow">return</font> 1;
00043     }
00044   
00045   g_print (<font class="stringliteral">"reply name: %s\n"</font>, dbus_message_get_name (reply));
00046   
00047   g_main_loop_run (loop);
00048   
00049   <font class="keywordflow">return</font> 0;
00050 }
</pre></div><hr><address align="right"><small>Generated on Wed Jun 2 06:01:34 2004 for D-BUS by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>