2 * Copyright (C) 2010 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Xavier Claessens <xclaesse@gmail.com>
22 #include "empathy-string-parser.h"
24 #include "empathy-smiley-manager.h"
27 empathy_string_match_smiley (const gchar
*text
,
29 TpawStringReplace replace_func
,
30 TpawStringParser
*sub_parsers
,
34 EmpathySmileyManager
*smiley_manager
;
37 smiley_manager
= empathy_smiley_manager_dup_singleton ();
38 hits
= empathy_smiley_manager_parse_len (smiley_manager
, text
, len
);
40 for (l
= hits
; l
; l
= l
->next
) {
41 EmpathySmileyHit
*hit
= l
->data
;
43 if (hit
->start
> last
) {
44 /* Append the text between last smiley (or the
45 * start of the message) and this smiley */
46 tpaw_string_parser_substr (text
+ last
,
48 sub_parsers
, user_data
);
51 replace_func (text
+ hit
->start
, hit
->end
- hit
->start
,
56 empathy_smiley_hit_free (hit
);
59 g_object_unref (smiley_manager
);
61 tpaw_string_parser_substr (text
+ last
, len
- last
,
62 sub_parsers
, user_data
);