void on_chime_new_group_conv()

in prpl/chat.c [1087:1113]


void on_chime_new_group_conv(ChimeConnection *cxn, ChimeConversation *conv, PurpleConnection *conn)
{
	const gchar *last_sent;
	GTimeVal sent_tv;

	/* If no LastMentioned or we can't parse it, nothing to do */
	last_sent = chime_conversation_get_last_sent(conv);
	if (!last_sent || !g_time_val_from_iso8601(last_sent, &sent_tv) ||
	    (!sent_tv.tv_sec && !sent_tv.tv_usec))
		return;

	const gchar *seen_time;
	GTimeVal seen_tv;

	if (chime_read_last_msg(conn, CHIME_OBJECT(conv), &seen_time, NULL) &&
	    g_time_val_from_iso8601(seen_time, &seen_tv) &&
	    (sent_tv.tv_sec < seen_tv.tv_sec ||
	     (sent_tv.tv_sec == seen_tv.tv_sec && sent_tv.tv_usec <= seen_tv.tv_usec))) {
		/* LastSent is older than we've already seen. Nothing to do except
		 * hook up the signal to open the "chat" when a message comes in */
		g_signal_connect(conv, "message", G_CALLBACK(on_group_conv_msg), conn);
		return;
	}

	/* There is a recent message in this conversation. Open it now. */
	do_join_chat(conn, cxn, CHIME_OBJECT(conv), NULL, NULL);
}