]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-theme-adium.c
add myself to AUTHORS
[empathy.git] / libempathy-gtk / empathy-theme-adium.c
index a702ded6af5253963517ec4868b6e909118ddb82..0a9fb98301edbf08dfc8d9fc005061a9a182e17a 100644 (file)
@@ -228,19 +228,22 @@ theme_adium_replace_link (const gchar *text,
 {
        GString *string = user_data;
        gchar *real_url;
+       gchar *escaped;
 
-       /* Append the link inside <a href=""></a> tag */
        real_url = empathy_make_absolute_url_len (text, len);
 
-       g_string_append_printf (string, "<a href=\"%s\">", real_url);
-       g_string_append_len (string, text, len);
-       g_string_append (string, "</a>");
+       /* The thing we are making a link of may contain
+        * characters which need escaping */
+       escaped = g_markup_escape_text (text, len);
+
+       /* Append the link inside <a href=""></a> tag */
+       g_string_append_printf (string, "<a href=\"%s\">%s</a>",
+                               real_url, escaped);
 
        g_free (real_url);
+       g_free (escaped);
 }
 
-static gboolean use_smileys = FALSE;
-
 static void
 theme_adium_replace_smiley (const gchar *text,
                            gssize len,
@@ -250,17 +253,10 @@ theme_adium_replace_smiley (const gchar *text,
        EmpathySmileyHit *hit = match_data;
        GString *string = user_data;
 
-       if (use_smileys) {
-               /* Replace smileys by a <img/> tag */
-               g_string_append (string, "<abbr title=\"");
-               g_string_append_len (string, text, len);
-               g_string_append_printf (string, "\"><img src=\"%s\" alt=\"",
-                                       hit->path);
-               g_string_append_len (string, text, len);
-               g_string_append (string, "\"/></abbr>");
-       } else {
-               g_string_append_len (string, text, len);
-       }
+       /* Replace smiley by a <img/> tag */
+       g_string_append_printf (string,
+                               "<img src=\"%s\" alt=\"%.*s\" title=\"%.*s\"/>",
+                               hit->path, (int)len, text, (int)len, text);
 }
 
 static void
@@ -297,6 +293,7 @@ theme_adium_parse_body (const gchar *text)
 {
        EmpathyStringParser *parsers;
        GString *string;
+       gboolean use_smileys;
 
        /* Check if we have to parse smileys */
        empathy_conf_get_bool (empathy_conf_get (),
@@ -441,6 +438,28 @@ theme_adium_append_html (EmpathyThemeAdium *theme,
        g_free (script);
 }
 
+static void
+theme_adium_append_event_escaped (EmpathyChatView *view,
+                                 const gchar     *escaped)
+{
+       EmpathyThemeAdium     *theme = EMPATHY_THEME_ADIUM (view);
+       EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
+
+       if (priv->data->status_html) {
+               theme_adium_append_html (theme, "appendMessage",
+                                        priv->data->status_html,
+                                        priv->data->status_len,
+                                        escaped, NULL, NULL, NULL, NULL,
+                                        "event", empathy_time_get_current ());
+       }
+
+       /* There is no last contact */
+       if (priv->last_contact) {
+               g_object_unref (priv->last_contact);
+               priv->last_contact = NULL;
+       }
+}
+
 static void
 theme_adium_append_message (EmpathyChatView *view,
                            EmpathyMessage  *msg)
@@ -488,7 +507,8 @@ theme_adium_append_message (EmpathyChatView *view,
                gchar *str;
 
                str = g_strdup_printf ("%s %s", name, body_escaped);
-               empathy_chat_view_append_event (view, str);
+               theme_adium_append_event_escaped (view, str);
+
                g_free (str);
                g_free (body_escaped);
                return;
@@ -635,26 +655,11 @@ static void
 theme_adium_append_event (EmpathyChatView *view,
                          const gchar     *str)
 {
-       EmpathyThemeAdium     *theme = EMPATHY_THEME_ADIUM (view);
-       EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
-
-       if (priv->data->status_html) {
-               gchar *str_escaped;
+       gchar *str_escaped;
 
-               str_escaped = g_markup_escape_text (str, -1);
-               theme_adium_append_html (theme, "appendMessage",
-                                        priv->data->status_html,
-                                        priv->data->status_len,
-                                        str_escaped, NULL, NULL, NULL, NULL,
-                                        "event", empathy_time_get_current ());
-               g_free (str_escaped);
-       }
-
-       /* There is no last contact */
-       if (priv->last_contact) {
-               g_object_unref (priv->last_contact);
-               priv->last_contact = NULL;
-       }
+       str_escaped = g_markup_escape_text (str, -1);
+       theme_adium_append_event_escaped (view, str_escaped);
+       g_free (str_escaped);
 }
 
 static void