gboolean polari_room_should_highlight_message (PolariRoom *room, TpMessage *message) { PolariRoomPrivate *priv; TpConnection *conn; TpContact *sender, *self; char *text; gboolean result; g_return_val_if_fail (POLARI_IS_ROOM (room), FALSE); priv = room->priv; if (!priv->channel) return FALSE; conn = tp_channel_get_connection (room->priv->channel); self = tp_connection_get_self_contact (conn); if (tp_signalled_message_get_sender (message) == self) return FALSE; text = tp_message_to_text (message, NULL); result = strstr(text, tp_contact_get_alias (self)) != NULL; g_free (text); return result; }
static void message_cb (TpMessage *message) { TpContact *sender = tp_signalled_message_get_sender (message); GDateTime *received = g_date_time_new_from_unix_utc ( tp_message_get_received_timestamp (message)); gchar *timestamp = g_date_time_format (received, "%Y-%m-%d %H:%M:%S"); const gchar *sender_identifier = tp_contact_get_identifier (sender); const gchar *sender_alias = tp_contact_get_alias (sender); if (!writer.first) { g_print ("\n\n"); } else { writer.first = 0; } printf ("Message-Token: %s\n", tp_message_get_token (message)); printf ("From: \"%s\" <%s>\n", sender_alias, sender_identifier); printf ("Date: %s\n\n", timestamp); g_free (timestamp); unsigned int parts = tp_message_count_parts (message); for (unsigned int i = 1; i < parts; i++) { const GHashTable *part = tp_message_peek (message, i); const gchar *content_type = g_value_get_string ( g_hash_table_lookup ((GHashTable*)part, "content-type")); const gchar *content = g_value_get_string ( g_hash_table_lookup ((GHashTable*)part, "content")); if (verbose) { printf ("- #%d %s\n", i, content_type); } printf ("%s\n", content); } }