static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *object = G_OBJECT_CLASS (example_echo_channel_parent_class)->constructor (type, n_props, props); ExampleEchoChannel *self = EXAMPLE_ECHO_CHANNEL (object); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (self->priv->conn, TP_HANDLE_TYPE_CONTACT); tp_dbus_daemon_register_object ( tp_base_connection_get_dbus_daemon (self->priv->conn), self->priv->object_path, self); tp_text_mixin_init (object, G_STRUCT_OFFSET (ExampleEchoChannel, text), contact_repo); tp_text_mixin_set_message_types (object, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE, G_MAXUINT); return object; }
static void constructed (GObject *object) { ExampleContactListBase *self = EXAMPLE_CONTACT_LIST_BASE (object); void (*chain_up) (GObject *) = ((GObjectClass *) example_contact_list_base_parent_class)->constructed; TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (self->priv->conn, TP_HANDLE_TYPE_CONTACT); TpHandle self_handle = self->priv->conn->self_handle; TpHandleRepoIface *handle_repo = tp_base_connection_get_handles (self->priv->conn, self->priv->handle_type); if (chain_up != NULL) chain_up (object); g_assert (TP_IS_BASE_CONNECTION (self->priv->conn)); g_assert (EXAMPLE_IS_CONTACT_LIST_MANAGER (self->priv->manager)); tp_dbus_daemon_register_object ( tp_base_connection_get_dbus_daemon (self->priv->conn), self->priv->object_path, self); tp_handle_ref (handle_repo, self->priv->handle); tp_group_mixin_init (object, G_STRUCT_OFFSET (ExampleContactListBase, group), contact_repo, self_handle); /* Both the subclasses have full support for telepathy-spec 0.17.6. */ tp_group_mixin_change_flags (object, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0); }
static void constructed (GObject *object) { ExampleCallStream *self = EXAMPLE_CALL_STREAM (object); void (*chain_up) (GObject *) = ((GObjectClass *) example_call_stream_parent_class)->constructed; if (chain_up != NULL) chain_up (object); tp_dbus_daemon_register_object ( tp_base_connection_get_dbus_daemon (self->priv->conn), self->priv->object_path, self); if (self->priv->locally_requested) { example_call_stream_change_direction (self, TRUE, TRUE); } else { example_call_stream_receive_direction_request (self, TRUE, TRUE); } if (self->priv->handle != 0) { TpHandleRepoIface *contact_repo = tp_base_connection_get_handles ( self->priv->conn, TP_HANDLE_TYPE_CONTACT); tp_handle_ref (contact_repo, self->priv->handle); } }
static void tp_base_call_stream_constructed (GObject *obj) { TpBaseCallStream *self = TP_BASE_CALL_STREAM (obj); TpDBusDaemon *bus = tp_base_connection_get_dbus_daemon ( (TpBaseConnection *) self->priv->conn); if (G_OBJECT_CLASS (tp_base_call_stream_parent_class)->constructed != NULL) G_OBJECT_CLASS (tp_base_call_stream_parent_class)->constructed (obj); /* register object on the bus */ DEBUG ("Registering %s", self->priv->object_path); tp_dbus_daemon_register_object (bus, self->priv->object_path, obj); }
static void empathy_chat_manager_constructed (GObject *obj) { TpDBusDaemon *dbus_daemon; dbus_daemon = tp_dbus_daemon_dup (NULL); if (dbus_daemon != NULL) { tp_dbus_daemon_register_object (dbus_daemon, "/org/gnome/Empathy/ChatManager", obj); g_object_unref (dbus_daemon); } }
static GObject * constructor (GType type, guint n_props, GObjectConstructParam *props) { GObject *object = G_OBJECT_CLASS (tp_tests_text_channel_group_parent_class)->constructor (type, n_props, props); TpTestsTextChannelGroup *self = TP_TESTS_TEXT_CHANNEL_GROUP (object); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (self->conn, TP_HANDLE_TYPE_CONTACT); TpChannelGroupFlags flags = 0; tp_dbus_daemon_register_object ( tp_base_connection_get_dbus_daemon (self->conn), self->priv->object_path, self); tp_text_mixin_init (object, G_STRUCT_OFFSET (TpTestsTextChannelGroup, text), contact_repo); tp_text_mixin_set_message_types (object, TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE, G_MAXUINT); if (self->priv->detailed) flags |= TP_CHANNEL_GROUP_FLAG_MEMBERS_CHANGED_DETAILED; if (self->priv->properties) flags |= TP_CHANNEL_GROUP_FLAG_PROPERTIES; tp_group_mixin_init (object, G_STRUCT_OFFSET (TpTestsTextChannelGroup, group), contact_repo, self->conn->self_handle); tp_group_mixin_change_flags (object, flags, 0); return object; }
static gchar * create_channel_request (TpTestsSimpleChannelDispatcher *self, const gchar *account, GHashTable *request, gint64 user_action_time, const gchar *preferred_handler) { TpTestsSimpleChannelRequest *chan_request; GPtrArray *requests; static guint count = 0; gchar *path; TpDBusDaemon *dbus; requests = g_ptr_array_sized_new (1); g_ptr_array_add (requests, request); path = g_strdup_printf ("/Request%u", count++); chan_request = tp_tests_simple_channel_request_new (path, self->priv->conn, account, user_action_time, preferred_handler, requests); self->priv->requests = g_slist_append (self->priv->requests, chan_request); g_ptr_array_free (requests, TRUE); dbus = tp_dbus_daemon_dup (NULL); g_assert (dbus != NULL); tp_dbus_daemon_register_object (dbus, path, chan_request); g_object_unref (dbus); g_signal_emit (self, signals[CHANNEL_REQUEST_CREATED], 0, chan_request); return path; }
gboolean tp_base_connection_manager_register (TpBaseConnectionManager *self) { GError *error = NULL; TpBaseConnectionManagerClass *cls; GString *string = NULL; guint i; GHashTableIter iter; gpointer name, protocol; g_assert (TP_IS_BASE_CONNECTION_MANAGER (self)); cls = TP_BASE_CONNECTION_MANAGER_GET_CLASS (self); if (!tp_base_connection_manager_ensure_dbus (self, &error)) goto except; if (cls->protocol_params != NULL) { for (i = 0; cls->protocol_params[i].name != NULL; i++) { TpBaseProtocol *p = _tp_legacy_protocol_new (self, cls->protocol_params + i); tp_base_connection_manager_add_protocol (self, p); g_object_unref (p); } } g_assert (self->priv->dbus_daemon != NULL); string = g_string_new (TP_CM_BUS_NAME_BASE); g_string_append (string, cls->cm_dbus_name); if (!tp_dbus_daemon_request_name (self->priv->dbus_daemon, string->str, TRUE, &error)) goto except; g_string_assign (string, TP_CM_OBJECT_PATH_BASE); g_string_append (string, cls->cm_dbus_name); tp_dbus_daemon_register_object (self->priv->dbus_daemon, string->str, self); g_hash_table_iter_init (&iter, self->priv->protocols); while (g_hash_table_iter_next (&iter, &name, &protocol)) { TpBaseProtocolClass *protocol_class = TP_BASE_PROTOCOL_GET_CLASS (protocol); if (!tp_connection_manager_check_valid_protocol_name (name, &error)) { g_critical ("%s", error->message); goto except; } /* don't export uninformative "stub" protocol objects on D-Bus */ if (protocol_class->is_stub) continue; g_string_assign (string, TP_CM_OBJECT_PATH_BASE); g_string_append (string, cls->cm_dbus_name); g_string_append_c (string, '/'); g_string_append (string, name); g_strdelimit (string->str, "-", '_'); tp_dbus_daemon_register_object (self->priv->dbus_daemon, string->str, protocol); } g_string_free (string, TRUE); self->priv->registered = TRUE; return TRUE; except: WARNING ("Couldn't claim bus name. If you are trying to debug this " "connection manager, disable all accounts and kill any running " "copies of this CM, then try again. %s", error->message); g_error_free (error); if (string != NULL) g_string_free (string, TRUE); return FALSE; }
static void constructed (GObject *object) { void (*chain_up) (GObject *) = ((GObjectClass *) example_callable_media_channel_parent_class)->constructed; ExampleCallableMediaChannel *self = EXAMPLE_CALLABLE_MEDIA_CHANNEL (object); TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (self->priv->conn, TP_HANDLE_TYPE_CONTACT); TpIntSet *members; TpIntSet *local_pending; if (chain_up != NULL) chain_up (object); tp_handle_ref (contact_repo, self->priv->handle); tp_handle_ref (contact_repo, self->priv->initiator); tp_dbus_daemon_register_object ( tp_base_connection_get_dbus_daemon (self->priv->conn), self->priv->object_path, self); tp_group_mixin_init (object, G_STRUCT_OFFSET (ExampleCallableMediaChannel, group), contact_repo, self->priv->conn->self_handle); /* Initially, the channel contains the initiator as a member; they are also * the actor for the change that adds any initial members. */ members = tp_intset_new_containing (self->priv->initiator); if (self->priv->locally_requested) { /* Nobody is locally pending. The remote peer will turn up in * remote-pending state when we actually contact them, which is done * in RequestStreams */ self->priv->progress = PROGRESS_NONE; local_pending = NULL; } else { /* This is an incoming call, so the self-handle is locally * pending, to indicate that we need to answer. */ self->priv->progress = PROGRESS_CALLING; local_pending = tp_intset_new_containing (self->priv->conn->self_handle); } tp_group_mixin_change_members (object, "", members /* added */, NULL /* nobody removed */, local_pending, /* added to local-pending */ NULL /* nobody added to remote-pending */, self->priv->initiator /* actor */, TP_CHANNEL_GROUP_CHANGE_REASON_NONE); tp_intset_destroy (members); if (local_pending != NULL) tp_intset_destroy (local_pending); /* We don't need to allow adding or removing members to this Group in ways * that need flags set, so the only flag we set is to say we support the * Properties interface to the Group. * * It doesn't make sense to add anyone to the Group, since we already know * who we're going to call (or were called by). The only call to AddMembers * we need to support is to move ourselves from local-pending to member in * the incoming call case, and that's always allowed anyway. * * (Connection managers that support the various backwards-compatible * ways to make an outgoing StreamedMedia channel have to support adding the * peer to remote-pending, but that has no actual effect other than to * obscure what's going on; in this one, there's no need to support that * usage.) * * Similarly, it doesn't make sense to remove anyone from this Group apart * from ourselves (to hang up), and removing the SelfHandle is always * allowed anyway. */ tp_group_mixin_change_flags (object, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0); /* Future versions of telepathy-spec will allow a channel request to * say "initially include an audio stream" and/or "initially include a video * stream", which would be represented like this; we don't support this * usage yet, though, so ExampleCallableMediaManager will never invoke * our constructor in this way. */ g_assert (!(self->priv->locally_requested && self->priv->initial_audio)); g_assert (!(self->priv->locally_requested && self->priv->initial_video)); if (!self->priv->locally_requested) { /* the caller has almost certainly asked us for some streams - there's * not much point in having a call otherwise */ if (self->priv->initial_audio) { g_message ("Channel initially has an audio stream"); example_callable_media_channel_add_stream (self, TP_MEDIA_STREAM_TYPE_AUDIO, FALSE); } if (self->priv->initial_video) { g_message ("Channel initially has a video stream"); example_callable_media_channel_add_stream (self, TP_MEDIA_STREAM_TYPE_VIDEO, FALSE); } } }