X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbusserver.c;h=cf821304cecf93ed9435023fb4b5334de91ccd5e;hb=174ebaefcc2b1b94f4a628e60f150b7209230dbf;hp=5e7dd85fa14e210c15f9fe23fc5733ddb43c386f;hpb=4143842eb47c1f38b2b4742b0928e4049e38afb9;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index 5e7dd85..cf82130 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -13,9 +13,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Author: David Zeuthen
*/
@@ -25,12 +23,6 @@
#include
#include
#include
-#ifdef HAVE_UNISTD_H
-#include
-#endif
-#ifdef _WIN32
-#include
-#endif
#include "giotypes.h"
#include "gioerror.h"
@@ -45,12 +37,20 @@
#include "gsocketservice.h"
#include "gthreadedsocketservice.h"
#include "gresolver.h"
+#include "glib/gstdio.h"
#include "ginetaddress.h"
#include "ginetsocketaddress.h"
#include "ginputstream.h"
#include "giostream.h"
#ifdef G_OS_UNIX
+#include
+#endif
+#ifdef G_OS_WIN32
+#include
+#endif
+
+#ifdef G_OS_UNIX
#include "gunixsocketaddress.h"
#endif
@@ -70,7 +70,8 @@
* To just export an object on a well-known name on a message bus, such as the
* session or system bus, you should instead use g_bus_own_name().
*
- * D-Bus peer-to-peer exampleFIXME: MISSING XINCLUDE CONTENT
+ * An example of peer-to-peer communication with G-DBus can be found
+ * in [gdbus-example-peer.c](https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-peer.c).
*/
/**
@@ -404,9 +405,9 @@ g_dbus_server_class_init (GDBusServerClass *klass)
*
* If #GDBusServer:flags contains %G_DBUS_SERVER_FLAGS_RUN_IN_THREAD
* then the signal is emitted in a new thread dedicated to the
- * connection. Otherwise the signal is emitted in the thread-default main
- * loop of the thread that @server was constructed in.
+ * connection. Otherwise the signal is emitted in the
+ * [thread-default main context][g-main-context-push-thread-default]
+ * of the thread that @server was constructed in.
*
* You are guaranteed that signal handlers for this signal runs
* before incoming messages on @connection are processed. This means
@@ -463,8 +464,7 @@ on_run (GSocketService *service,
* The returned #GDBusServer isn't active - you have to start it with
* g_dbus_server_start().
*
- * See for how #GDBusServer can
- * be used.
+ * #GDBusServer is used in this [example][gdbus-peer-to-peer].
*
* This is a synchronous failable constructor. See
* g_dbus_server_new() for the asynchronous version.
@@ -843,6 +843,7 @@ try_tcp (GDBusServer *server,
guint n;
gsize bytes_written;
gsize bytes_remaining;
+ char *file_escaped;
server->nonce = g_new0 (guchar, 16);
for (n = 0; n < 16; n++)
@@ -869,7 +870,7 @@ try_tcp (GDBusServer *server,
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error writing nonce file at `%s': %s"),
+ _("Error writing nonce file at '%s': %s"),
server->nonce_file,
strerror (errno));
goto out;
@@ -877,11 +878,14 @@ try_tcp (GDBusServer *server,
bytes_written += ret;
bytes_remaining -= ret;
}
- close (fd);
+ if (!g_close (fd, error))
+ goto out;
+ file_escaped = g_uri_escape_string (server->nonce_file, "/\\", FALSE);
server->client_address = g_strdup_printf ("nonce-tcp:host=%s,port=%d,noncefile=%s",
host,
port_num,
- server->nonce_file);
+ file_escaped);
+ g_free (file_escaped);
}
else
{
@@ -892,7 +896,8 @@ try_tcp (GDBusServer *server,
out:
g_list_free_full (resolved_addresses, g_object_unref);
- g_object_unref (resolver);
+ if (resolver)
+ g_object_unref (resolver);
return ret;
}
@@ -1007,6 +1012,7 @@ on_run (GSocketService *service,
emit_new_connection_in_idle,
data,
(GDestroyNotify) emit_idle_data_free);
+ g_source_set_name (idle_source, "[gio] emit_new_connection_in_idle");
g_source_attach (idle_source, server->main_context_at_construction);
g_source_unref (idle_source);
}
@@ -1035,7 +1041,7 @@ initable_init (GInitable *initable,
g_set_error (&last_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("The string `%s' is not a valid D-Bus GUID"),
+ _("The string '%s' is not a valid D-Bus GUID"),
server->guid);
goto out;
}
@@ -1075,7 +1081,7 @@ initable_init (GInitable *initable,
g_set_error (&this_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
- _("Cannot listen on unsupported transport `%s'"),
+ _("Cannot listen on unsupported transport '%s'"),
transport_name);
g_free (transport_name);