[Telepathy-commits] [telepathy-gabble/master] factor out _gabble_roster_channel_send_presence to gabble_connection_send_presence
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:16 PDT 2008
20080602093817-7fe3f-706cefe70e92516c7f424391f011bf3ffbd11454.gz
---
src/connection.c | 28 ++++++++++++++++++++++++++++
src/connection.h | 4 ++++
src/roster-channel.c | 22 +++-------------------
3 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index b6d6f99..56f58a8 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2861,6 +2861,34 @@ gabble_connection_ensure_capabilities (GabbleConnection *self,
}
}
+gboolean
+gabble_connection_send_presence (GabbleConnection *conn,
+ LmMessageSubType sub_type,
+ const gchar *contact,
+ const gchar *status,
+ GError **error)
+{
+ LmMessage *message;
+ gboolean result;
+
+ message = lm_message_new_with_sub_type (contact,
+ LM_MESSAGE_TYPE_PRESENCE,
+ sub_type);
+
+ if (LM_MESSAGE_SUB_TYPE_SUBSCRIBE == sub_type)
+ lm_message_node_add_own_nick (message->node, conn);
+
+ if (status != NULL && status[0] != '\0')
+ lm_message_node_add_child (message->node, "status", status);
+
+ result = _gabble_connection_send (conn, message, error);
+
+ lm_message_unref (message);
+
+ return result;
+
+}
+
/* We reimplement RequestHandles to be able to do async validation on
* room handles */
static void
diff --git a/src/connection.h b/src/connection.h
index 4757308..405d83b 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -209,6 +209,10 @@ gboolean _gabble_connection_signal_own_presence (GabbleConnection *,
void gabble_connection_ensure_capabilities (GabbleConnection *conn,
GabblePresenceCapabilities caps);
+gboolean gabble_connection_send_presence (GabbleConnection *conn,
+ LmMessageSubType sub_type, const gchar *contact, const gchar *status,
+ GError **error);
+
/* extern only for the benefit of the unit tests */
void _gabble_connection_create_handle_repos (TpBaseConnection *conn,
TpHandleRepoIface *repos[NUM_TP_HANDLE_TYPES]);
diff --git a/src/roster-channel.c b/src/roster-channel.c
index 962e7a0..92699f5 100644
--- a/src/roster-channel.c
+++ b/src/roster-channel.c
@@ -457,7 +457,6 @@ gabble_roster_channel_finalize (GObject *object)
G_OBJECT_CLASS (gabble_roster_channel_parent_class)->finalize (object);
}
-
static gboolean
_gabble_roster_channel_send_presence (GabbleRosterChannel *chan,
LmMessageSubType sub_type,
@@ -468,30 +467,15 @@ _gabble_roster_channel_send_presence (GabbleRosterChannel *chan,
GabbleRosterChannelPrivate *priv;
TpBaseConnection *conn;
TpHandleRepoIface *repo;
- const char *contact;
- LmMessage *message;
- gboolean result;
+ const gchar *contact;
priv = GABBLE_ROSTER_CHANNEL_GET_PRIVATE (chan);
conn = (TpBaseConnection *) priv->conn;
repo = tp_base_connection_get_handles (conn, TP_HANDLE_TYPE_CONTACT);
contact = tp_handle_inspect (repo, handle);
- message = lm_message_new_with_sub_type (contact,
- LM_MESSAGE_TYPE_PRESENCE,
- sub_type);
-
- if (LM_MESSAGE_SUB_TYPE_SUBSCRIBE == sub_type)
- lm_message_node_add_own_nick (message->node, priv->conn);
-
- if (status != NULL && status[0] != '\0')
- lm_message_node_add_child (message->node, "status", status);
-
- result = _gabble_connection_send (priv->conn, message, error);
-
- lm_message_unref (message);
-
- return result;
+ return gabble_connection_send_presence (priv->conn, sub_type, contact, status,
+ error);
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list