[folks] Bug 642036 — No way to pass a message when adding a contact
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Bug 642036 — No way to pass a message when adding a contact
- Date: Mon, 14 Feb 2011 22:38:09 +0000 (UTC)
commit d4ec25154f72711c9c1e5e81f224051ab12c5e82
Author: Philip Withnall <philip withnall collabora co uk>
Date: Mon Feb 14 22:18:36 2011 +0000
Bug 642036 â?? No way to pass a message when adding a contact
Document that the "message" key in the details hash table passed to
IndividualAggregator.add_persona_from_details() may (by convention) be used
to pass a human-readable message to the persona being added.
Implement this in the Telepathy backend. Closes: bgo#642036
backends/telepathy/lib/tp-lowlevel.c | 5 +++--
backends/telepathy/lib/tp-lowlevel.h | 9 +++++++++
backends/telepathy/lib/tpf-persona-store.vala | 22 ++++++++++++++--------
folks/individual-aggregator.vala | 1 +
4 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/backends/telepathy/lib/tp-lowlevel.c b/backends/telepathy/lib/tp-lowlevel.c
index e7f7f16..2e9150f 100644
--- a/backends/telepathy/lib/tp-lowlevel.c
+++ b/backends/telepathy/lib/tp-lowlevel.c
@@ -739,6 +739,7 @@ void
folks_tp_lowlevel_channel_group_change_membership (TpChannel *channel,
guint handle,
gboolean is_member,
+ const gchar *message,
GError **error)
{
GArray *handles;
@@ -758,12 +759,12 @@ folks_tp_lowlevel_channel_group_change_membership (TpChannel *channel,
if (is_member)
{
tp_cli_channel_interface_group_call_add_members (channel, -1, handles,
- NULL, group_add_members_cb, NULL, NULL, NULL);
+ message, group_add_members_cb, NULL, NULL, NULL);
}
else
{
tp_cli_channel_interface_group_call_remove_members (channel, -1, handles,
- NULL, group_remove_members_cb, NULL, NULL, NULL);
+ message, group_remove_members_cb, NULL, NULL, NULL);
}
g_array_free (handles, TRUE);
diff --git a/backends/telepathy/lib/tp-lowlevel.h b/backends/telepathy/lib/tp-lowlevel.h
index d8d09ee..08f5867 100644
--- a/backends/telepathy/lib/tp-lowlevel.h
+++ b/backends/telepathy/lib/tp-lowlevel.h
@@ -62,10 +62,19 @@ typedef enum {
FolksTpLowlevel *
folks_tp_lowlevel_new (void) G_GNUC_WARN_UNUSED_RESULT;
+/**
+ * folks_tp_lowlevel_channel_group_change_membership:
+ * @channel:
+ * @handle:
+ * @is_member:
+ * @message: (allow-none):
+ * @error:
+ */
void
folks_tp_lowlevel_channel_group_change_membership (TpChannel *channel,
guint handle,
gboolean is_member,
+ const gchar *message,
GError **error);
/**
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 8fcda26..c7f7f52 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -659,7 +659,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
try
{
this._ll.channel_group_change_membership (channel,
- (Handle) persona.contact.handle, entry.value);
+ (Handle) persona.contact.handle, entry.value, null);
}
catch (GLib.Error e)
{
@@ -984,7 +984,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
try
{
this._ll.channel_group_change_membership (this._stored,
- (Handle) tp_persona.contact.handle, false);
+ (Handle) tp_persona.contact.handle, false, null);
}
catch (GLib.Error e1)
{
@@ -1000,7 +1000,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
try
{
this._ll.channel_group_change_membership (this._subscribe,
- (Handle) tp_persona.contact.handle, false);
+ (Handle) tp_persona.contact.handle, false, null);
}
catch (GLib.Error e2)
{
@@ -1016,7 +1016,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
try
{
this._ll.channel_group_change_membership (this._publish,
- (Handle) tp_persona.contact.handle, false);
+ (Handle) tp_persona.contact.handle, false, null);
}
catch (GLib.Error e3)
{
@@ -1144,14 +1144,15 @@ public class Tpf.PersonaStore : Folks.PersonaStore
}
private void _change_standard_contact_list_membership (
- TelepathyGLib.Channel channel, Folks.Persona persona, bool is_member)
+ TelepathyGLib.Channel channel, Folks.Persona persona, bool is_member,
+ string? message)
{
var tp_persona = (Tpf.Persona) persona;
try
{
this._ll.channel_group_change_membership (channel,
- (Handle) tp_persona.contact.handle, is_member);
+ (Handle) tp_persona.contact.handle, is_member, message);
}
catch (GLib.Error e)
{
@@ -1454,6 +1455,11 @@ public class Tpf.PersonaStore : Folks.PersonaStore
this.type_id, this.id, contact_id);
}
+ // Optional message to pass to the new persona
+ var add_message = TelepathyGLib.asv_get_string (details, "message");
+ if (add_message == "")
+ add_message = null;
+
var status = this.account.get_connection_status (null);
if ((status == TelepathyGLib.ConnectionStatus.DISCONNECTED) ||
(status == TelepathyGLib.ConnectionStatus.CONNECTING) ||
@@ -1482,7 +1488,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
if (this._subscribe != null)
this._change_standard_contact_list_membership (this._subscribe,
- persona, true);
+ persona, true, add_message);
if (this._publish != null)
{
@@ -1491,7 +1497,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
ChannelGroupFlags.CAN_ADD)
{
this._change_standard_contact_list_membership (
- this._publish, persona, true);
+ this._publish, persona, true, add_message);
}
}
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 33f2f2b..e2acd37 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -716,6 +716,7 @@ public class Folks.IndividualAggregator : Object
* Common keys include:
*
* * contact - service-specific contact ID
+ * * message - a user-readable message to pass to the persona being added
*
* If a { link Persona} with the given details already exists in the store, no
* error will be thrown and this function will return `null`.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]