Bug 38061 - Add tp_message_set_message() method
Summary: Add tp_message_set_message() method
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: tp-glib (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL: http://cgit.collabora.com/git/user/da...
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-06-07 20:38 UTC by Danielle Madeley
Modified: 2011-07-25 11:05 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Danielle Madeley 2011-06-07 20:38:33 UTC
Sometimes you want to keep your message for later. It would be nice to have a set_message() method to compliment take_message().
Comment 2 Will Thompson 2011-06-08 09:05:37 UTC
> Compliments tp_cm_message_take_message().

“Have you been working out, tp_cm_message_take_message()? You look great!”

+  g_return_if_fail (self != message);

Nice attention to detail. :)

+  g_hash_table_insert (g_ptr_array_index (self->parts, part),
+      g_strdup (key),
+      tp_g_value_slice_new_boxed (TP_ARRAY_TYPE_MESSAGE_PART_LIST,
+          message->parts));

I *believe* that this will not copy the message parts, just ref 'em. In other words, if you modify @message after calling tp_cm_message_set_message(), it will also modify the copy in @self.

We need to document this one way or another.

We could just say that this is the case: but I bet it will trip people up. There have been bugs in Wocky due to repeatedly passing the same WockyStanza * to wocky_porter_send_async(), changing (say) its recipient each time, and accidentally sending n copies of the stanza to the last recipient.

Or we could explicitly copy @message. (It could be that this is actually already what happens, in which case, ideal!)

I leave the decision in your capable hands.
Comment 3 Danielle Madeley 2011-06-08 19:15:00 UTC
(In reply to comment #2)

> I *believe* that this will not copy the message parts, just ref 'em. In other
> words, if you modify @message after calling tp_cm_message_set_message(), it
> will also modify the copy in @self.

You're right, in recent GLib g_boxed_copy() will frequently take refs instead of copying. I think we want to take a copy, so you can throw away the message at your leisure (or change it, as you say).
Comment 4 Danielle Madeley 2011-06-08 22:41:22 UTC
Updated. Now with tests!
Comment 5 Will Thompson 2011-07-25 11:05:47 UTC
Merged to master. Miaow, says Escher!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.