summaryrefslogtreecommitdiff
path: root/gio/src/dbusserver.hg
blob: 32ea99b9c9965a3731b27a479b08d1790508e508 (plain)
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
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-

/* Copyright (C) 2010 The giomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/object.h>
#include <giomm/initable.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{

_WRAP_ENUM(DBusServerFlags, GDBusServerFlags, NO_GTYPE)

class DBusAuthObserver;
class DBusConnection;

//TODO: Add example from the C API in class docs.
/** DBusServer - Helper for accepting connections.
 * DBusServer is a helper for listening to and accepting D-Bus connections.
 * Since DBusServer implements the Initable interface, its constructors can
 * throw an exception if construction fails.
 *
 * @newin{2,28}
 * @ingroup DBus
 */
class DBusServer : public Glib::Object, public Initable
{
  _CLASS_GOBJECT(DBusServer, GDBusServer, G_DBUS_SERVER, Glib::Object, GObject)
  _IMPLEMENTS_INTERFACE(Initable)

protected:

  DBusServer(const Glib::ustring& address,
    const std::string& guid,
    const Glib::RefPtr<DBusAuthObserver>& observer,
    const Glib::RefPtr<Cancellable>& cancellable,
    DBusServerFlags flags);

  DBusServer(const Glib::ustring& address,
    const std::string& guid,
    const Glib::RefPtr<Cancellable>& cancellable,
    DBusServerFlags flags);

  DBusServer(const Glib::ustring& address,
    const std::string& guid,
    const Glib::RefPtr<DBusAuthObserver>& observer,
    DBusServerFlags flags);

  DBusServer(const Glib::ustring& address,
    const std::string& guid,
    DBusServerFlags flags);

public:

  _WRAP_METHOD_DOCS_ONLY(g_dbus_server_new_sync)
  /// @throw Glib::Error.
  static Glib::RefPtr<DBusServer> create_sync(const Glib::ustring& address,
    const std::string& guid,
    const Glib::RefPtr<DBusAuthObserver>& observer,
    const Glib::RefPtr<Cancellable>& cancellable,
    DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE);

  _WRAP_METHOD_DOCS_ONLY(g_dbus_server_new_sync)
  /// @throw Glib::Error.
  static Glib::RefPtr<DBusServer> create_sync(const Glib::ustring& address,
    const std::string& guid,
    const Glib::RefPtr<Cancellable>& cancellable,
    DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE);

  /// Non-cancellable version of create_sync().
  static Glib::RefPtr<DBusServer> create_sync(const Glib::ustring& address,
    const std::string& guid,
    const Glib::RefPtr<DBusAuthObserver>& observer,
    DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE);

  /// Non-cancellable version of create_sync().
  static Glib::RefPtr<DBusServer> create_sync(const Glib::ustring& address,
    const std::string& guid,
    DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE);

  _WRAP_METHOD(void start(), g_dbus_server_start)
  _WRAP_METHOD(void stop(), g_dbus_server_stop)
  _WRAP_METHOD(bool is_active() const, g_dbus_server_is_active)
  _WRAP_METHOD(std::string get_guid() const, g_dbus_server_get_guid)
  _WRAP_METHOD(DBusServerFlags get_flags() const, g_dbus_server_get_flags)
  _WRAP_METHOD(Glib::ustring get_client_address() const, g_dbus_server_get_client_address)

  _WRAP_PROPERTY("active", bool)
  _WRAP_PROPERTY("address", Glib::ustring)
  _WRAP_PROPERTY("authentication-observer", Glib::RefPtr<DBusAuthObserver>)
  _WRAP_PROPERTY("client-address", Glib::ustring)
  _WRAP_PROPERTY("flags", DBusServerFlags)
  _WRAP_PROPERTY("guid", std::string)

#m4 _CONVERSION(`GDBusConnection*', `const Glib::RefPtr<DBusConnection>&', `Glib::wrap($3, true)')
  _WRAP_SIGNAL(bool new_connection(const Glib::RefPtr<DBusConnection>& connection), "new-connection", no_default_handler)
};

} // namespace Gio