Sometimes you want to keep your message for later. It would be nice to have a set_message() method to compliment take_message().
> 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,
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.
(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).
Updated. Now with tests!
Merged to master. Miaow, says Escher!