projects
/
platform
/
upstream
/
glib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doc: improve doc of g_file_equal()
[platform/upstream/glib.git]
/
gio
/
gdbusserver.c
diff --git
a/gio/gdbusserver.c
b/gio/gdbusserver.c
index
ab0bad0
..
cf82130
100644
(file)
--- 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
* 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 <http://www.gnu.org/licenses/>.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
*
* Author: David Zeuthen <davidz@redhat.com>
*/
@@
-25,12
+23,6
@@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef _WIN32
-#include <io.h>
-#endif
#include "giotypes.h"
#include "gioerror.h"
#include "giotypes.h"
#include "gioerror.h"
@@
-41,17
+33,24
@@
#include "gioenumtypes.h"
#include "gdbusprivate.h"
#include "gdbusauthobserver.h"
#include "gioenumtypes.h"
#include "gdbusprivate.h"
#include "gdbusauthobserver.h"
-#include "gio-marshal.h"
#include "ginitable.h"
#include "gsocketservice.h"
#include "gthreadedsocketservice.h"
#include "gresolver.h"
#include "ginitable.h"
#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 "ginetaddress.h"
#include "ginetsocketaddress.h"
#include "ginputstream.h"
#include "giostream.h"
#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
+
+#ifdef G_OS_UNIX
#include "gunixsocketaddress.h"
#endif
#include "gunixsocketaddress.h"
#endif
@@
-71,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().
*
* 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().
*
- * <example id="gdbus-peer-to-peer"><title>D-Bus peer-to-peer example</title><programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gdbus-example-peer.c"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting></example>
+ * 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).
*/
/**
*/
/**
@@
-100,7
+100,7
@@
struct _GDBusServer
gboolean is_using_listener;
gulong run_signal_handler_id;
gboolean is_using_listener;
gulong run_signal_handler_id;
- /* The result of g_main_context_
get
_thread_default() when the object
+ /* The result of g_main_context_
ref
_thread_default() when the object
* was created (the GObject _init() function) - this is used for delivery
* of the :new-connection GObject signal.
*/
* was created (the GObject _init() function) - this is used for delivery
* of the :new-connection GObject signal.
*/
@@
-149,7
+149,7
@@
enum
LAST_SIGNAL,
};
LAST_SIGNAL,
};
-guint _signals[LAST_SIGNAL] = {0};
+
static
guint _signals[LAST_SIGNAL] = {0};
static void initable_iface_init (GInitableIface *initable_iface);
static void initable_iface_init (GInitableIface *initable_iface);
@@
-184,8
+184,7
@@
g_dbus_server_finalize (GObject *object)
*/
g_free (server->nonce_file);
*/
g_free (server->nonce_file);
- if (server->main_context_at_construction != NULL)
- g_main_context_unref (server->main_context_at_construction);
+ g_main_context_unref (server->main_context_at_construction);
G_OBJECT_CLASS (g_dbus_server_parent_class)->finalize (object);
}
G_OBJECT_CLASS (g_dbus_server_parent_class)->finalize (object);
}
@@
-406,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
*
* 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
<link
- *
linkend="g-main-context-push-thread-default">thread-default main
- *
loop</link>
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
*
* You are guaranteed that signal handlers for this signal runs
* before incoming messages on @connection are processed. This means
@@
-426,7
+425,7
@@
g_dbus_server_class_init (GDBusServerClass *klass)
G_STRUCT_OFFSET (GDBusServerClass, new_connection),
g_signal_accumulator_true_handled,
NULL, /* accu_data */
G_STRUCT_OFFSET (GDBusServerClass, new_connection),
g_signal_accumulator_true_handled,
NULL, /* accu_data */
-
_gio_marshal_BOOLEAN__OBJECT
,
+
NULL
,
G_TYPE_BOOLEAN,
1,
G_TYPE_DBUS_CONNECTION);
G_TYPE_BOOLEAN,
1,
G_TYPE_DBUS_CONNECTION);
@@
-435,9
+434,7
@@
g_dbus_server_class_init (GDBusServerClass *klass)
static void
g_dbus_server_init (GDBusServer *server)
{
static void
g_dbus_server_init (GDBusServer *server)
{
- server->main_context_at_construction = g_main_context_get_thread_default ();
- if (server->main_context_at_construction != NULL)
- g_main_context_ref (server->main_context_at_construction);
+ server->main_context_at_construction = g_main_context_ref_thread_default ();
}
static gboolean
}
static gboolean
@@
-451,8
+448,8
@@
on_run (GSocketService *service,
* @address: A D-Bus address.
* @flags: Flags from the #GDBusServerFlags enumeration.
* @guid: A D-Bus GUID.
* @address: A D-Bus address.
* @flags: Flags from the #GDBusServerFlags enumeration.
* @guid: A D-Bus GUID.
- * @observer: A #GDBusAuthObserver or %NULL.
- * @cancellable: A #GCancellable or %NULL.
+ * @observer:
(allow-none):
A #GDBusAuthObserver or %NULL.
+ * @cancellable:
(allow-none):
A #GCancellable or %NULL.
* @error: Return location for server or %NULL.
*
* Creates a new D-Bus server that listens on the first address in
* @error: Return location for server or %NULL.
*
* Creates a new D-Bus server that listens on the first address in
@@
-467,8
+464,7
@@
on_run (GSocketService *service,
* The returned #GDBusServer isn't active - you have to start it with
* g_dbus_server_start().
*
* The returned #GDBusServer isn't active - you have to start it with
* g_dbus_server_start().
*
- * See <xref linkend="gdbus-peer-to-peer"/> 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.
*
* This is a synchronous failable constructor. See
* g_dbus_server_new() for the asynchronous version.
@@
-767,7
+763,7
@@
try_unix (GDBusServer *server,
/* ---------------------------------------------------------------------------------------------------- */
/* note that address_entry has already been validated =>
/* ---------------------------------------------------------------------------------------------------- */
/* note that address_entry has already been validated =>
- * both host and port (guranteed to be a number in [0, 65535]) are set (family is optional)
+ * both host and port (gu
a
ranteed to be a number in [0, 65535]) are set (family is optional)
*/
static gboolean
try_tcp (GDBusServer *server,
*/
static gboolean
try_tcp (GDBusServer *server,
@@
-847,6
+843,7
@@
try_tcp (GDBusServer *server,
guint n;
gsize bytes_written;
gsize bytes_remaining;
guint n;
gsize bytes_written;
gsize bytes_remaining;
+ char *file_escaped;
server->nonce = g_new0 (guchar, 16);
for (n = 0; n < 16; n++)
server->nonce = g_new0 (guchar, 16);
for (n = 0; n < 16; n++)
@@
-873,7
+870,7
@@
try_tcp (GDBusServer *server,
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
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;
server->nonce_file,
strerror (errno));
goto out;
@@
-881,11
+878,14
@@
try_tcp (GDBusServer *server,
bytes_written += ret;
bytes_remaining -= ret;
}
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->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
{
}
else
{
@@
-895,9
+895,9
@@
try_tcp (GDBusServer *server,
ret = TRUE;
out:
ret = TRUE;
out:
- g_list_f
oreach (resolved_addresses, (GFunc) g_object_unref, NULL
);
- g_list_free (resolved_addresses);
- g_object_unref (resolver);
+ g_list_f
ree_full (resolved_addresses, g_object_unref
);
+ if (resolver)
+
g_object_unref (resolver);
return ret;
}
return ret;
}
@@
-1012,6
+1012,7
@@
on_run (GSocketService *service,
emit_new_connection_in_idle,
data,
(GDestroyNotify) emit_idle_data_free);
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);
}
g_source_attach (idle_source, server->main_context_at_construction);
g_source_unref (idle_source);
}
@@
-1040,7
+1041,7
@@
initable_init (GInitable *initable,
g_set_error (&last_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
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;
}
server->guid);
goto out;
}
@@
-1080,7
+1081,7
@@
initable_init (GInitable *initable,
g_set_error (&this_error,
G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT,
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);
transport_name);
g_free (transport_name);