#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <glade/glade.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-log-manager.h>
#include "gossip-geometry.h"
#include "gossip-preferences.h"
#include "gossip-spell.h"
-//#include "gossip-spell-dialog.h"
+#include "gossip-spell-dialog.h"
#include "gossip-ui-utils.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CHAT, GossipChatPriv))
GList *compositors;
guint scroll_idle_id;
gboolean first_tp_chat;
+ GossipTime time_joined;
/* Used to automatically shrink a window that has temporarily
* grown due to long input.
*/
chat_send (GossipChat *chat,
const gchar *msg)
{
- GossipChatPriv *priv;
- GossipMessage *message;
- GossipContact *own_contact;
+ GossipChatPriv *priv;
+ GossipMessage *message;
priv = GET_PRIV (chat);
/* FIXME: add here something to let group/privrate chat handle
* some special messages */
- own_contact = empathy_contact_manager_get_user (priv->manager, chat->account);
message = gossip_message_new (msg);
- gossip_message_set_sender (message, own_contact);
empathy_tp_chat_send (priv->tp_chat, message);
{
GossipChatPriv *priv;
GossipContact *sender;
+ GossipTime timestamp;
priv = GET_PRIV (chat);
gossip_debug (DEBUG_DOMAIN, "Appending message ('%s')",
gossip_contact_get_name (sender));
- empathy_log_manager_add_message (priv->log_manager,
- gossip_chat_get_id (chat),
- message);
+ /* Log the message only if it's not backlog */
+ timestamp = gossip_message_get_timestamp (message);
+ if (timestamp >= priv->time_joined) {
+ empathy_log_manager_add_message (priv->log_manager,
+ gossip_chat_get_id (chat),
+ gossip_chat_is_group_chat (chat),
+ message);
+ }
gossip_chat_view_append_message (chat->view, message);
chat_text_check_word_spelling_cb (GtkMenuItem *menuitem,
GossipChatSpell *chat_spell)
{
-/*FIXME: gossip_spell_dialog_show (chat_spell->chat,
+ gossip_spell_dialog_show (chat_spell->chat,
chat_spell->start,
chat_spell->end,
- chat_spell->word);*/
+ chat_spell->word);
}
static GossipChatSpell *
GossipChat *chat)
{
GossipChatPriv *priv;
- GossipContact *own_contact;
GList *l;
gboolean was_composing;
priv = GET_PRIV (chat);
- own_contact = gossip_contact_get_user (contact);
- if (gossip_contact_equal (own_contact, contact)) {
+ if (gossip_contact_is_user (contact)) {
/* We don't care about our own chat state */
return;
}
(!was_composing && priv->compositors)) {
/* Composing state changed */
g_signal_emit (chat, signals[COMPOSING], 0,
- (gboolean) priv->compositors);
+ priv->compositors != NULL);
}
}
priv = GET_PRIV (chat);
+ /* Do not display backlog for chatrooms */
+ if (gossip_chat_is_group_chat (chat)) {
+ return;
+ }
+
/* Turn off scrolling temporarily */
gossip_chat_view_scroll (chat->view, FALSE);
/* Add messages from last conversation */
messages = empathy_log_manager_get_last_messages (priv->log_manager,
chat->account,
- gossip_chat_get_id (chat));
+ gossip_chat_get_id (chat),
+ gossip_chat_is_group_chat (chat));
num_messages = g_list_length (messages);
for (l = messages, i = 0; l; l = l->next, i++) {
g_free (priv->id);
priv->tp_chat = g_object_ref (tp_chat);
priv->id = g_strdup (empathy_tp_chat_get_id (tp_chat));
+ priv->time_joined = gossip_time_get_current ();
if (priv->first_tp_chat) {
chat_add_logs (chat);
gboolean
gossip_chat_should_highlight_nick (GossipMessage *message)
{
- GossipContact *my_contact;
+ GossipContact *contact;
const gchar *msg, *to;
gchar *cf_msg, *cf_to;
gchar *ch;
return FALSE;
}
- my_contact = gossip_contact_get_user (gossip_message_get_sender (message));
- to = gossip_contact_get_name (my_contact);
+ contact = gossip_message_get_receiver (message);
+ if (!contact || !gossip_contact_is_user (contact)) {
+ return FALSE;
+ }
+
+ to = gossip_contact_get_name (contact);
if (!to) {
return FALSE;
}