summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-07 14:08:50 +0100
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-06-04 13:43:09 +0200
commit97755a8cef146519f688054d1bafe22f40bc17ff (patch)
treeee127497da1e27b548da8e8aa37d85aec06b6369 /examples
parent5f90a8dd35be28392615de7ba15f1d552ea5c477 (diff)
downloadtelepathy-glib-97755a8cef146519f688054d1bafe22f40bc17ff.tar.gz
Use accessors rather than accessing TpBaseConnection fields directly
Diffstat (limited to 'examples')
-rw-r--r--examples/cm/call/call-channel.c2
-rw-r--r--examples/cm/call/call-manager.c14
-rw-r--r--examples/cm/call/conn.c17
-rw-r--r--examples/cm/channelspecific/conn.c7
-rw-r--r--examples/cm/channelspecific/room-manager.c5
-rw-r--r--examples/cm/channelspecific/room.c9
-rw-r--r--examples/cm/contactlist/conn.c19
-rw-r--r--examples/cm/echo-message-parts/conn.c5
-rw-r--r--examples/cm/echo-message-parts/im-manager.c5
-rw-r--r--examples/cm/extended/conn.c10
10 files changed, 55 insertions, 38 deletions
diff --git a/examples/cm/call/call-channel.c b/examples/cm/call/call-channel.c
index 1ae680669..456bc490f 100644
--- a/examples/cm/call/call-channel.c
+++ b/examples/cm/call/call-channel.c
@@ -521,7 +521,7 @@ example_call_channel_add_content (ExampleCallChannel *self,
if (locally_requested)
{
g_message ("SIGNALLING: send: new %s stream %s", type_str, name);
- creator = self->priv->conn->self_handle;
+ creator = tp_base_connection_get_self_handle (self->priv->conn);
}
path = g_strdup_printf ("%s/Content%u",
diff --git a/examples/cm/call/call-manager.c b/examples/cm/call/call-manager.c
index f637f2b41..ed8464087 100644
--- a/examples/cm/call/call-manager.c
+++ b/examples/cm/call/call-manager.c
@@ -320,14 +320,15 @@ new_channel (ExampleCallManager *self,
/* FIXME: This could potentially wrap around, but only after 4 billion
* calls, which is probably plenty. */
object_path = g_strdup_printf ("%s/CallChannel%u",
- self->priv->conn->object_path, self->priv->next_channel_index++);
+ tp_base_connection_get_object_path (self->priv->conn),
+ self->priv->next_channel_index++);
chan = g_object_new (EXAMPLE_TYPE_CALL_CHANNEL,
"connection", self->priv->conn,
"object-path", object_path,
"handle", handle,
- "initiator-handle", initiator,
- "requested", (self->priv->conn->self_handle == initiator),
+ "initiator-handle",
+ (tp_base_connection_get_self_handle (self->priv->conn) == initiator),
"simulation-delay", self->priv->simulation_delay,
"initial-audio", initial_audio,
"initial-video", initial_video,
@@ -448,7 +449,7 @@ example_call_manager_request (ExampleCallManager *self,
goto error;
}
- if (handle == self->priv->conn->self_handle)
+ if (handle == tp_base_connection_get_self_handle (self->priv->conn))
{
/* In protocols with a concept of multiple "resources" signed in to
* one account (XMPP, and possibly MSN) it is technically possible to
@@ -486,8 +487,9 @@ example_call_manager_request (ExampleCallManager *self,
}
}
- new_channel (self, handle, self->priv->conn->self_handle, request_token,
- initial_audio, initial_video);
+ new_channel (self, handle,
+ tp_base_connection_get_self_handle (self->priv->conn),
+ request_token, initial_audio, initial_video);
return TRUE;
error:
diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c
index fbe885d75..720cbf13f 100644
--- a/examples/cm/call/conn.c
+++ b/examples/cm/call/conn.c
@@ -184,17 +184,20 @@ start_connecting (TpBaseConnection *conn,
ExampleCallConnection *self = EXAMPLE_CALL_CONNECTION (conn);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
+ TpHandle self_handle;
/* In a real connection manager we'd ask the underlying implementation to
* start connecting, then go to state CONNECTED when finished, but here
* we can do it immediately. */
- conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+ self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, error);
- if (conn->self_handle == 0)
+ if (self_handle == 0)
return FALSE;
+ tp_base_connection_set_self_handle (conn, self_handle);
+
tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
TP_CONNECTION_STATUS_REASON_REQUESTED);
@@ -235,10 +238,7 @@ status_available (GObject *object,
{
TpBaseConnection *base = TP_BASE_CONNECTION (object);
- if (base->status != TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
-
- return TRUE;
+ return tp_base_connection_check_connected (base, NULL);
}
static GHashTable *
@@ -264,7 +264,7 @@ get_contact_statuses (GObject *object,
/* we know our own status from the connection; for this example CM,
* everyone else's status is assumed to be "available" */
- if (contact == base->self_handle)
+ if (contact == tp_base_connection_get_self_handle (base))
{
presence = (self->priv->away ? EXAMPLE_CALL_PRESENCE_AWAY
: EXAMPLE_CALL_PRESENCE_AVAILABLE);
@@ -332,7 +332,8 @@ set_own_status (GObject *object,
presences = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, NULL);
- g_hash_table_insert (presences, GUINT_TO_POINTER (base->self_handle),
+ g_hash_table_insert (presences,
+ GUINT_TO_POINTER (tp_base_connection_get_self_handle (base)),
(gpointer) status);
tp_presence_mixin_emit_presence_update (object, presences);
g_hash_table_unref (presences);
diff --git a/examples/cm/channelspecific/conn.c b/examples/cm/channelspecific/conn.c
index f7957cc46..59dba2707 100644
--- a/examples/cm/channelspecific/conn.c
+++ b/examples/cm/channelspecific/conn.c
@@ -189,17 +189,20 @@ start_connecting (TpBaseConnection *conn,
ExampleCSHConnection *self = EXAMPLE_CSH_CONNECTION (conn);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
+ TpHandle self_handle;
/* In a real connection manager we'd ask the underlying implementation to
* start connecting, then go to state CONNECTED when finished, but here
* we can do it immediately. */
- conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+ self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, error);
- if (conn->self_handle == 0)
+ if (self_handle == 0)
return FALSE;
+ tp_base_connection_set_self_handle (conn, self_handle);
+
tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
TP_CONNECTION_STATUS_REASON_REQUESTED);
diff --git a/examples/cm/channelspecific/room-manager.c b/examples/cm/channelspecific/room-manager.c
index 5aa164419..a5c535ea2 100644
--- a/examples/cm/channelspecific/room-manager.c
+++ b/examples/cm/channelspecific/room-manager.c
@@ -235,7 +235,7 @@ new_channel (ExampleCSHRoomManager *self,
GSList *requests = NULL;
object_path = g_strdup_printf ("%s/CSHRoomChannel%u",
- self->priv->conn->object_path, handle);
+ tp_base_connection_get_object_path (self->priv->conn), handle);
chan = g_object_new (EXAMPLE_TYPE_CSH_ROOM_CHANNEL,
"connection", self->priv->conn,
@@ -323,7 +323,8 @@ example_csh_room_manager_request (ExampleCSHRoomManager *self,
if (chan == NULL)
{
- new_channel (self, handle, self->priv->conn->self_handle,
+ new_channel (self, handle,
+ tp_base_connection_get_self_handle (self->priv->conn),
request_token);
}
else if (require_new)
diff --git a/examples/cm/channelspecific/room.c b/examples/cm/channelspecific/room.c
index c701f5ae7..45c8614d4 100644
--- a/examples/cm/channelspecific/room.c
+++ b/examples/cm/channelspecific/room.c
@@ -69,7 +69,8 @@ suggest_room_identity (ExampleCSHRoomChannel *self)
gchar *nick, *id;
TpHandle ret;
- nick = g_strdup (tp_handle_inspect (contact_repo, connection->self_handle));
+ nick = g_strdup (tp_handle_inspect (contact_repo,
+ tp_base_connection_get_self_handle (connection)));
g_strdelimit (nick, "@", '\0');
id = g_strdup_printf ("%s@%s", nick, tp_handle_inspect (room_repo,
tp_base_channel_get_target_handle (TP_BASE_CHANNEL (self))));
@@ -143,7 +144,7 @@ complete_join (ExampleCSHRoomChannel *self)
tp_intset_add (removed, mixin->self_handle);
tp_group_mixin_add_handle_owner ((GObject *) self, new_self,
- conn->self_handle);
+ tp_base_connection_get_self_handle (conn));
tp_group_mixin_change_self_handle ((GObject *) self, new_self);
tp_group_mixin_change_members ((GObject *) self, "", NULL, removed, NULL,
@@ -199,9 +200,9 @@ join_room (ExampleCSHRoomChannel *self)
tp_intset_add (add_remote_pending, mixin->self_handle);
tp_group_mixin_add_handle_owner (object, mixin->self_handle,
- conn->self_handle);
+ tp_base_connection_get_self_handle (conn));
tp_group_mixin_change_members (object, "", NULL, NULL, NULL,
- add_remote_pending, conn->self_handle,
+ add_remote_pending, tp_base_connection_get_self_handle (conn),
TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
tp_intset_destroy (add_remote_pending);
diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c
index 2317eda4c..ab4507740 100644
--- a/examples/cm/contactlist/conn.c
+++ b/examples/cm/contactlist/conn.c
@@ -190,7 +190,7 @@ presence_updated_cb (ExampleContactList *contact_list,
TpPresenceStatus *status;
/* we ignore the presence indicated by the contact list for our own handle */
- if (contact == base->self_handle)
+ if (contact == tp_base_connection_get_self_handle (base))
return;
status = tp_presence_status_new (
@@ -231,17 +231,20 @@ start_connecting (TpBaseConnection *conn,
ExampleContactListConnection *self = EXAMPLE_CONTACT_LIST_CONNECTION (conn);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
+ TpHandle self_handle;
/* In a real connection manager we'd ask the underlying implementation to
* start connecting, then go to state CONNECTED when finished, but here
* we can do it immediately. */
- conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+ self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, error);
- if (conn->self_handle == 0)
+ if (self_handle == 0)
return FALSE;
+ tp_base_connection_set_self_handle (conn, self_handle);
+
tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
TP_CONNECTION_STATUS_REASON_REQUESTED);
@@ -309,10 +312,7 @@ status_available (GObject *object,
{
TpBaseConnection *base = TP_BASE_CONNECTION (object);
- if (base->status != TP_CONNECTION_STATUS_CONNECTED)
- return FALSE;
-
- return TRUE;
+ return tp_base_connection_check_connected (base, NULL);
}
static GHashTable *
@@ -335,7 +335,7 @@ get_contact_statuses (GObject *object,
/* we get our own status from the connection, and everyone else's status
* from the contact lists */
- if (contact == base->self_handle)
+ if (contact == tp_base_connection_get_self_handle (base))
{
presence = (self->priv->away ? EXAMPLE_CONTACT_LIST_PRESENCE_AWAY
: EXAMPLE_CONTACT_LIST_PRESENCE_AVAILABLE);
@@ -383,7 +383,8 @@ set_own_status (GObject *object,
presences = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, NULL);
- g_hash_table_insert (presences, GUINT_TO_POINTER (base->self_handle),
+ g_hash_table_insert (presences,
+ GUINT_TO_POINTER (tp_base_connection_get_self_handle (base)),
(gpointer) status);
tp_presence_mixin_emit_presence_update (object, presences);
g_hash_table_unref (presences);
diff --git a/examples/cm/echo-message-parts/conn.c b/examples/cm/echo-message-parts/conn.c
index 7e6e4c0ec..d93229f15 100644
--- a/examples/cm/echo-message-parts/conn.c
+++ b/examples/cm/echo-message-parts/conn.c
@@ -133,14 +133,17 @@ start_connecting (TpBaseConnection *conn,
ExampleEcho2Connection *self = EXAMPLE_ECHO_2_CONNECTION (conn);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
+ TpHandle self_handle;
/* In a real connection manager we'd ask the underlying implementation to
* start connecting, then go to state CONNECTED when finished, but here
* we can do it immediately. */
- conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+ self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, NULL);
+ tp_base_connection_set_self_handle (conn, self_handle);
+
tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
TP_CONNECTION_STATUS_REASON_REQUESTED);
diff --git a/examples/cm/echo-message-parts/im-manager.c b/examples/cm/echo-message-parts/im-manager.c
index 6451fb8f8..5a8153717 100644
--- a/examples/cm/echo-message-parts/im-manager.c
+++ b/examples/cm/echo-message-parts/im-manager.c
@@ -231,7 +231,7 @@ new_channel (ExampleEcho2ImManager *self,
GSList *requests = NULL;
object_path = g_strdup_printf ("%s/Echo2Channel%u",
- self->priv->conn->object_path, handle);
+ tp_base_connection_get_object_path (self->priv->conn), handle);
chan = g_object_new (EXAMPLE_TYPE_ECHO_2_CHANNEL,
"connection", self->priv->conn,
@@ -319,7 +319,8 @@ example_echo_2_im_manager_request (ExampleEcho2ImManager *self,
if (chan == NULL)
{
- new_channel (self, handle, self->priv->conn->self_handle,
+ new_channel (self, handle,
+ tp_base_connection_get_self_handle (self->priv->conn),
request_token);
}
else if (require_new)
diff --git a/examples/cm/extended/conn.c b/examples/cm/extended/conn.c
index 69e99cc0b..8b2560564 100644
--- a/examples/cm/extended/conn.c
+++ b/examples/cm/extended/conn.c
@@ -148,14 +148,17 @@ start_connecting (TpBaseConnection *conn,
ExampleExtendedConnection *self = EXAMPLE_EXTENDED_CONNECTION (conn);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn,
TP_HANDLE_TYPE_CONTACT);
+ TpHandle self_handle;
/* In a real connection manager we'd ask the underlying implementation to
* start connecting, then go to state CONNECTED when finished, but here
* we can do it immediately. */
- conn->self_handle = tp_handle_ensure (contact_repo, self->priv->account,
+ self_handle = tp_handle_ensure (contact_repo, self->priv->account,
NULL, NULL);
+ tp_base_connection_set_self_handle (conn, self_handle);
+
tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED,
TP_CONNECTION_STATUS_REASON_REQUESTED);
@@ -274,7 +277,7 @@ my_get_hats (ExampleSvcConnectionInterfaceHats *iface,
/* for the sake of a simple example, let's assume nobody except me
* has any hats */
- if (handle == base->self_handle)
+ if (handle == tp_base_connection_get_self_handle (base))
{
g_value_set_string (g_value_array_get_nth (vals, 1),
self->priv->hat_color);
@@ -320,7 +323,8 @@ my_set_hat (ExampleSvcConnectionInterfaceHats *iface,
/* success */
example_svc_connection_interface_hats_emit_hats_changed (self,
- base->self_handle, color, style, properties);
+ tp_base_connection_get_self_handle (base),
+ color, style, properties);
example_svc_connection_interface_hats_return_from_set_hat (context);
}