Replace hildon-common-strings with proper translation strings in gtk
[modest] / src / modest-text-utils.h
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30
31 /* modest-text-utils.h */
32
33 #ifndef __MODEST_TEXT_UTILS_H__
34 #define __MODEST_TEXT_UTILS_H__
35
36 #include <time.h>
37 #include <glib.h>
38 #include <gdk/gdk.h>
39 #include <gtk/gtk.h>
40
41 #define _FM(str) dgettext("hildon-fm",str)
42 #define _CS(str) dgettext("hildon-common-strings",str)
43 #define _HL(str) dgettext("hildon-libs",str)
44 #define _MD(str) dgettext("maemo-af-desktop",str)
45 #define _AB(str) dgettext("osso-addressbook",str)
46 #define _KR(str) dgettext("ke-recv",str)
47 #define _UR(str) dgettext("osso-uri",str)
48
49 #ifdef MODEST_TOOLKIT_HILDON2
50 #define _HL_SAVE _HL("wdgt_bd_save")
51 #define _HL_YES _HL("wdgt_bd_yes")
52 #define _HL_NO _HL("wdgt_bd_no")
53 #define _HL_VIEW _HL("wdgt_bd_view")
54 #define _HL_TITLE_SORT _HL("ckdg_ti_sort")
55 #define _HL_TITLE_NEW_FOLDER _HL("ckdg_ti_new_folder")
56 #define _HL_TITLE_RENAME_FOLDER _HL("ckdg_ti_rename_folder")
57 #define _HL_DATE _HL("wdgt_va_date")
58 #define _HL_24H_TIME _HL("wdgt_va_24h_time")
59 #define _HL_WEEK _HL("wdgt_va_week")
60 #define _HL_DATE_MEDIUM _HL("wdgt_va_date_medium")
61 #define _HL_12H_TIME_PM _HL("wdgt_va_12h_time_pm")
62 #define _HL_12H_TIME_AM _HL("wdgt_va_12h_time_am")
63 #define _HL_DONE _HL("wdgt_bd_done")
64 #define _HL_DELETE _HL("wdgt_bd_delete")
65 #define _HL_MOVE _HL("wdgt_bd_move")
66 #define _HL_RENAME _HL("wdgt_bd_rename")
67 #define _HL_IB_FIND_COMPLETE _HL("ckct_ib_find_search_complete")
68 #define _HL_IB_FIND_NO_MATCHES _HL("ckct_ib_find_no_matches")
69 #define _HL_IB_ZOOM _HL("wdgt_ib_zoom")
70
71 #define _CS_ILLEGAL_CHARACTERS_ENTERED _CS("ckdg_ib_illegal_characters_entered")
72 #define _CS_CANNOT_ZOOM_HERE _CS("ckct_ib_cannot_zoom_here")
73 #define _CS_MAX_ZOOM_LEVEL_REACHED _CS("ckct_ib_max_zoom_level_reached")
74 #define _CS_MIN_ZOOM_LEVEL_REACHED _CS("ckct_ib_min_zoom_level_reached")
75 #define _CS_MAXIMUM_CHARACTERS_REACHED _CS("ckdg_ib_maximum_characters_reached")
76 #define _CS_FOLDER_ALREADY_EXISTS _CS("ckdg_ib_folder_already_exists")
77 #define _CS_SET_PASSWORD_INCORRECT _CS("ecdg_ib_set_password_incorrect")
78 #define _CS_UNABLE_TO_PASTE_HERE _CS("ckct_ib_unable_to_paste_here")
79 #define _CS_UNABLE_TO_OPEN_FILE_NOT_FOUND _CS("sfil_ni_unable_to_open_file_not_found")
80 #define _CS_UNABLE_TO_RENAME _CS("ckdg_ib_unable_to_rename")
81 #define _CS_UNABLE_TO_DELETE _CS("ckdg_ib_unable_to_delete")
82 #define _CS_NOTHING_TO_SORT _CS("ckdg_ib_nothing_to_sort")
83 #define _CS_NOT_ENOUGH_MEMORY _CS("sfil_ni_not_enough_memory")
84 #define _CS_FOLDER_ALREADY_EXISTS _CS("ckdg_ib_folder_already_exists")
85 #define _CS_PASTING _CS("ckct_nw_pasting")
86 #define _CS_GETTING_ITEMS _CS("mcen_ib_getting_items")
87 #define _CS_COPIED _CS("ecoc_ib_edwin_copied")
88 #define _CS_UNABLE_TO_SEND _CS("sfil_ib_unable_to_send")
89 #define _CS_FIND_REP_ENTER_TEXT _CS("ecdg_ib_find_rep_enter_text")
90 #define _CS_UPDATING _CS("ckdg_pb_updating")
91 #define _CS_SAVED _CS("sfil_ib_saved")
92 #else
93 #define _HL_SAVE _("Save")
94 #define _HL_YES _("Yes")
95 #define _HL_NO _("Yes")
96 #define _HL_VIEW _("View")
97 #define _HL_TITLE_SORT _("Sort")
98 #define _HL_TITLE_NEW_FOLDER _("New folder")
99 #define _HL_TITLE_RENAME_FOLDER _HL("Rename folder")
100 #define _HL_RENAME_NAME _("Name")
101 #define _HL_24H_TIME _("%H:%M")
102 #define _HL_DATE _("%m/%d/%Y")
103 #define _HL_WEEK _("%A")
104 #define _HL_DATE_MEDIUM _("%e %B %Y")
105 #define _HL_12H_TIME_PM _("%l:%M pm")
106 #define _HL_12H_TIME_AM _("%l:%M am")
107 #define _HL_DONE _("Done")
108 #define _HL_DELETE _("Delete")
109 #define _HL_MOVE _("Move")
110 #define _HL_RENAME _("Rename")
111 #define _HL_IB_FIND_COMPLETE _("Search complete")
112 #define _HL_IB_FIND_NO_MATCHES _("No matches")
113 #define _HL_IB_ZOOM _("Zoom %d")
114
115 #define _CS_ILLEGAL_CHARACTERS_ENTERED _("Illegal characters entered")
116 #define _CS_CANNOT_ZOOM_HERE _("Cannot zoom here")
117 #define _CS_MAX_ZOOM_LEVEL_REACHED _("Max. zoom level reached")
118 #define _CS_MIN_ZOOM_LEVEL_REACHED _("Min. zoom level reached")
119 #define _CS_MAXIMUM_CHARACTERS_REACHED _("Maximum characters reached")
120 #define _CS_FOLDER_ALREADY_EXISTS _("Folder already exists")
121 #define _CS_SET_PASSWORD_INCORRECT _("Password incorrect")
122 #define _CS_UNABLE_TO_PASTE_HERE _("Unable to paste here")
123 #define _CS_UNABLE_TO_OPEN_FILE_NOT_FOUND _("File not found")
124 #define _CS_UNABLE_TO_RENAME _("Unable to rename")
125 #define _CS_UNABLE_TO_DELETE _("Unable to delete")
126 #define _CS_NOTHING_TO_SORT _("Nothing to sort")
127 #define _CS_NOT_ENOUGH_MEMORY _("Not enough memory")
128 #define _CS_FOLDER_ALREADY_EXISTS _("Folder already exists")
129 #define _CS_PASTING _("Pasting")
130 #define _CS_GETTING_ITEMS _("Getting items")
131 #define _CS_COPIED _("Copied")
132 #define _CS_UNABLE_TO_SEND _("Unable to send")
133 #define _CS_FIND_REP_ENTER_TEXT _("Enter text to search")
134 #define _CS_UPDATING _("Updating...")
135 #define _CS_SAVED _("Saved")
136 #endif
137
138 /* Forbidden char arrays */
139 extern const gchar account_title_forbidden_chars[];
140 extern const gchar folder_name_forbidden_chars[];
141 extern const gchar user_name_forbidden_chars[];
142 extern const guint ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH;
143 extern const guint FOLDER_NAME_FORBIDDEN_CHARS_LENGTH;
144 extern const guint USER_NAME_FORBIDDEN_CHARS_LENGTH;
145
146 /* It includes a white space as RFC 3676 Section 4.3 about usenet
147    message signatures defines */
148 #define MODEST_TEXT_UTILS_SIGNATURE_MARKER "-- "
149
150 /**
151  * modest_text_utils_derived_subject:
152  * @subject: a string which contains the original subject
153  * @is_reply: whether the derived subject is for a reply or a forward message
154  *
155  * create a 'derived' subject line for eg. replies and forwards. Note
156  * that this function will use the localized versions of "Re" and
157  * "Fw", unless one of these two versions was already included. For
158  * example replying to an email in Finish would work as:
159  *
160  * "some subject"     -> "VS: some subject"
161  * "VS: some subject" -> "VS: some subject"
162  * "Re: some subject" -> "Re: some subject"
163  * "Fw: some subject" -> "VS: Fw: some subject"
164  *
165  * Returns: a newly allocated string containing the resulting subject
166  */
167 gchar* modest_text_utils_derived_subject (const gchar *subject,
168                                           gboolean is_reply);
169
170
171 /**
172  * modest_text_utils_quote:
173  * @text: a non-NULL string which contains the message to quote
174  * @from: a non-NULL  sender of the original message
175  * @content_type: the non-NULL content type for the quoting, e.g. "text/html"
176  * @signature: NULL or the signature to add
177  * @sent_date: sent date/time of the original message
178  * @attachments: a #GList of the attachments
179  * @limit: specifies the maximum characters per line in the quoted text
180  * 
181  * quote an existing message
182  * 
183  * Returns: a newly allocated string containing the quoted message
184  */
185 gchar* modest_text_utils_quote (const gchar *text, 
186                                 const gchar *content_type,
187                                 const gchar *signature,
188                                 const gchar *from,
189                                 const time_t sent_date, 
190                                 GList *attachments,
191                                 int limit);
192
193
194 /**
195  * modest_text_utils_cited_text:
196  * @from: sender of the message
197  * @sent_date: the sent date of the original message
198  * @text: the text of the original message
199  *
200  * cite the text in a message
201  * 
202  * Returns: a newly allocated string containing the cited text
203  */
204 gchar* modest_text_utils_cite (const gchar *text,
205                                const gchar *content_type,
206                                const gchar *signature,
207                                const gchar *from,
208                                time_t sent_date);
209
210 /**
211  * modest_text_utils_inlined_text
212  * @from: the non-NULL sender of the original message
213  * @sent_date: sent date/time of the original message
214  * @to: 
215  * @subject: 
216  * @text: 
217  *
218  * creates a new string with the "Original message" text prepended to
219  * the text passed as argument and some data of the header
220  * 
221  * Returns: a newly allocated string containing the quoted message
222  */
223 gchar*   modest_text_utils_inline (const gchar *text,
224                                    const gchar *content_type,
225                                    const gchar *signature,
226                                    const gchar *from,
227                                    time_t sent_date,
228                                    const gchar *to,
229                                    const gchar *subject);
230
231 /**
232  * modest_text_utils_remove_address
233  * @address_list: non-NULL string with a comma-separated list of email addresses
234  * @address: an specific e-mail address 
235  *
236  * remove a specific address from a list of email addresses; if @address
237  * is NULL, returns an unchanged (but newly allocated) @address_list
238  * 
239  * Returns: a newly allocated string containing the new list, or NULL
240  * in case of error or the original @address_list was NULL
241  */
242 gchar*   modest_text_utils_remove_address (const gchar *address_list, 
243                                            const gchar *address);
244
245
246 /**
247  * modest_text_utils_remove_duplicate_addresses
248  * @address_list: non-NULL string with a comma-separated list of email addresses
249  *
250  * remove duplicate addresses from a list of email addresses
251  * 
252  * Returns: a newly allocated string containing the new list, or NULL
253  * in case of error or the original @address_list was NULL
254  */
255 gchar*   modest_text_utils_remove_duplicate_addresses (const gchar *address_list); 
256
257
258 /**
259  * modest_text_utils_address_range_at_position:
260  * @address_list: non-NULL utf8 string containing a list of addresses
261  * @position: a gint
262  * @start: a gint pointer
263  * @end: a gint pointer
264  *
265  * Finds the start and end positions of the address at @position,
266  * in @recipients_list, a list of addresses in the format of a 
267  * recipient list in email. It stores the results in @start and
268  * @end
269  */
270 void     modest_text_utils_address_range_at_position (const gchar *recipients_list,
271                                                       guint position,
272                                                       guint *start,
273                                                       guint *end);
274
275 /**
276  * modest_text_utils_hyperlinkify_begin:
277  *
278  * begin a linkify block, compiling the caches to be reused. Use it in mainloop.
279  */
280 void modest_text_utils_hyperlinkify_begin (void);
281
282 /**
283  * modest_text_utils_hyperlinkify_end:
284  *
285  * end a linkify block, freeing the caches to be reused. Use it in mainloop.
286  */
287 void modest_text_utils_hyperlinkify_end (void);
288
289 /**
290  * modest_text_utils_convert_to_html:
291  * @txt: a string
292  *
293  * convert plain text (utf8) into html
294  * 
295  * Returns: a newly allocated string containing the html
296  */
297 gchar*  modest_text_utils_convert_to_html (const gchar *txt);
298
299 /**
300  * modest_text_utils_convert_to_html_body:
301  * @txt: a string
302  *
303  * convert plain text (utf8) into html without adding html headers.
304  * 
305  * Returns: a newly allocated string containing the html
306  */
307 gchar*  modest_text_utils_convert_to_html_body (const gchar *data, gssize n, gboolean hyperlinkify);
308
309
310 /**
311  * modest_text_utils_strftime:
312  * @s:
313  * @max:
314  * @fmt:
315  * @timet:
316  *
317  * this is just an alias for strftime(3), so we can use that without
318  * getting warning from gcc
319  * 
320  * Returns: a formatted string of max length @max in @s
321  */
322 size_t modest_text_utils_strftime(char *s, size_t max, const char  *fmt, time_t timet);
323
324 /**
325  * modest_text_utils_hyperlinkify:
326  * @string_buffer: buffer where we replace uri strings with links
327  *
328  * Replace uri's with links in the buffer. This is required that the document
329  * do not contain linkified links already.
330  */
331 void modest_text_utils_hyperlinkify (GString *string_buffer);
332
333 /**
334  * modest_text_utils_get_display_address:
335  * @address: original address (UTF8 string)
336  *
337  * make a 'display address' from an address:
338  * "Foo Bar &lt;foo@bar.cx&gt;" --&gt; "Foo Bar"
339  * ie. removes "&lt;...&gt;" parts
340  * the change is in-place; removes leading whitespace
341  * 
342  * NOTE: for optimization reasons, this function changes @address
343  * in-place
344  */
345 void modest_text_utils_get_display_address (gchar *address);
346
347 /**
348  * modest_text_utils_get_display_addresses:
349  * @addresses: a list of comma-separated addresses
350  *
351  * Transforms a list of email addresses in a list of recipients,
352  * replacing each plain email address by the correspondent display
353  * address.
354  *
355  * Returns: a newly allocated string, that must be freed by the caller
356  **/
357 gchar *modest_text_utils_get_display_addresses (const gchar *addresses);
358
359
360 /**
361  * modest_text_utils_get_email_address:
362  * @full_address: original address (UTF8 string)
363  *
364  * make a 'foo@bar.cx' from an address:
365  * "Foo Bar <foo@bar.cx> (Bla)" --> "foo@bar.cx"
366  * If no "<...>" is found, then it returns the full
367  * strings.
368  * 
369  * Returns: a newly allocated string with the copy.
370  * 
371  * NULL in case of error or if address == NULL
372  */
373 gchar* modest_text_utils_get_email_address (const gchar *email_address);
374
375
376 /**
377  * modest_text_utils_get_subject_prefix_len:
378  * @subject: original subject (UTF8 string)
379  *
380  * determine the length of the "Re:/RE:/Fwd:" prefix in an e-mail address
381  * 
382  * Returns: the length of the  prefix, or 0 if there is none
383  */
384 gint modest_text_utils_get_subject_prefix_len (const gchar *subject);
385
386
387 /**
388  * modest_text_utils_utf8_strcmp:
389  * @s1: the first string
390  * @s2: the second string
391  * @insensitive: should the comparison be case-insensitive?
392  *
393  * a strcmp that is NULL-safe, can deal with UTF8 and case-insensitive comparison 
394  *
395  * Returns: an integer less than, equal to, or greater than zero if s1 is found,
396  * respectively, to be less than, to match, or be greater than s2.
397  */
398 gint modest_text_utils_utf8_strcmp (const gchar* s1, const gchar *s2, gboolean insensitive);
399
400
401
402 /**
403  * modest_text_utils_get_display_date:
404  * @date: the date to display
405  *
406  * get a string representation for a date.
407  * 
408  * Returns: the new display date, as a *static* string.
409  * This string should not be modified, and will change
410  * upon recalling this function. g_strdup it if you to
411  * do so.
412  * 
413  */
414 const gchar* modest_text_utils_get_display_date (time_t date);
415
416
417 /**
418  * modest_text_utils_get_display_size:
419  * @size: size in bytes
420  *
421  * get a string representation for a size in bytes.
422  * 
423  * Returns: the newly allocated display string for the
424  * size in bytes. must be freed.
425  */
426 gchar * modest_text_utils_get_display_size (guint64 size);
427
428
429
430 /**
431  * modest_text_utils_validate_domain_name:
432  * @email_address: a NULL-terminated string
433  * 
434  * validates the domain name passed as argument
435  * 
436  * Returns: TRUE if the domain name is valid, FALSE otherwise
437  **/
438 gboolean modest_text_utils_validate_domain_name (const gchar *domain);
439
440 /**
441  * modest_text_utils_validate_email_address:
442  * @email_address: a string
443  * @invalid_char_position: pointer to the position of the invalid
444  * character in case validation failed because of this, or %NULL.
445  * 
446  * validates the email address passed as argument
447  * 
448  * Returns: TRUE if the address is valid, FALSE otherwise
449  **/
450 gboolean     modest_text_utils_validate_email_address (const gchar *email_address, 
451                                                        const gchar **invalid_char_position);
452
453
454 /**
455  * modest_text_utils_validate_folder_name:
456  * @folder_name: a string
457  * 
458  * validates the folder name passed as argument. a 'valid folder name'
459  * is a name which should be valid on both Unix and Windows file systems.
460  * of course, this might be stricter than strictly needed in some cases,
461  * but it's better to err on the safe side.
462  * 
463  * Returns: TRUE if the folder name is valid, FALSE otherwise
464  **/
465 gboolean modest_text_utils_validate_folder_name (const gchar *folder_name);
466
467 /**
468  * modest_text_utils_validate_recipient:
469  * @recipient: a string
470  * @invalid_char_position: pointer to the position of the invalid char,
471  * if validation failed because there's an invalid char there, or %NULL.
472  *
473  * validates @recipient as a valid recipient field for header.
474  * It's different from modest_text_utils_validate_email_address()
475  * as it validates a whole recipient, and not only the part between
476  * the &lt; and &gt; symbols.
477  *
478  * Returns: %TRUE if the recipient is valid, FALSE otherwise
479  **/
480 gboolean     modest_text_utils_validate_recipient (const gchar *recipient,
481                                                    const gchar **invalid_char_position);
482
483 /**
484  * modest_text_utils_split_addresses_list:
485  * @addresses: a string
486  *
487  * obtains a GSList of addresses from a string of addresses
488  * in the format understood by email protocols
489  *
490  * Returns: a newly allocated GSList of strings
491  **/
492 GSList      *modest_text_utils_split_addresses_list (const gchar *addresses);
493
494 /**
495  * modest_text_utils_join_addresses:
496  * @from: comma separated string of addresses
497  * @to: comma separated string of addresses
498  * @cc: comma separated string of addresses
499  * @bcc: comma separated string of addresses
500  *
501  * joins all the addresses in a single comma-separated string
502  *
503  * Returns: a newly allocated string with a list of addresses
504  **/
505 gchar       *modest_text_utils_join_addresses (const gchar *from,
506                                                const gchar *to,
507                                                const gchar *cc,
508                                                const gchar *bcc);
509
510 /**
511  * modest_text_utils_get_addresses_indexes:
512  * @addresses: a string
513  * @start_indexes: a #GSList pointer
514  * @end_indexes: a #GSList pointer
515  *
516  * obtains two #GSList of @addresses with the range offsets of the addresses in
517  * the string
518  *
519  * Returns: a GSList of strings
520  **/
521 void         modest_text_utils_get_addresses_indexes (const gchar *addresses, GSList **start_indexes, GSList **end_indexes);
522
523 /**
524  * modest_text_utils_address_with_standard_length:
525  * @recipients_list: a string
526  *
527  * obtains the list of recipients, but making sure that lines are not longer than 1000 chars
528  *
529  * Returns: a newly allocated string
530  */
531 gchar *      modest_text_utils_address_with_standard_length (const gchar *recipients_list);
532
533 /**
534  * modest_text_utils_get_color_string:
535  * @color: a #GdkColor
536  *
537  * Obtains a proper markup string for @color, in the format used
538  * by Pango and HTML.
539  *
540  * Returns: a newly allocated string
541  */
542 gchar *      modest_text_utils_get_color_string (GdkColor *color);
543
544 /**
545  * modest_text_utils_text_buffer_get_text:
546  * @buffer: a #GtkTextBuffer
547  *
548  * Obtains the contents of a @buffer in a string, replacing image
549  * pixbufs with blank spaces.
550  *
551  * Returns: a newly allocated UTF-8 string
552  */
553 gchar *      modest_text_utils_text_buffer_get_text (GtkTextBuffer *buffer);
554
555 typedef enum {
556         ACCOUNT_TITLE_FORBIDDEN_CHARS,
557         FOLDER_NAME_FORBIDDEN_CHARS,
558         USER_NAME_FORBIDDEN_NAMES,
559 } ModestTextUtilsForbiddenCharType;
560
561 /**
562  * modest_text_utils_label_get_selection:
563  * @label: a #GtkLabel
564  *
565  * Obtain the current selection of @label
566  *
567  * Returns: a string with current selection, or %NULL if no selection in @label
568  */
569 gchar *      modest_text_utils_label_get_selection (GtkLabel *label);
570
571 /**
572  * modest_text_utils_is_forbidden_char:
573  * @character: some character
574  * @type: the type of forbidden char (see #ModestTextUtilsForbiddenCharType)
575  * 
576  * check whether the given character is 'forbidden'
577  *
578  * Returns: TRUE if it's forbidden, FALSE otherwise
579  */
580 gboolean     modest_text_utils_is_forbidden_char (const gchar character,
581                                                   ModestTextUtilsForbiddenCharType type);
582
583 /**
584  * modest_text_utils_buffer_selection_is_valid:
585  * @buffer: a #GtkTextBuffer
586  *
587  * Checks if @buffer contains a valid selection for cut/copy. This means it's
588  * not empty, and no images are in the selection.
589  *
590  * Returns: %TRUE if there's a valid selection, false otherwise.
591  */
592 gboolean     modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer);
593
594 /**
595  * modest_text_utils_escape_mnemonics:
596  * @text: a string
597  *
598  * obtains the representation of text, but escaping mnemonics (we duplicate _)
599  *
600  * Returns: a newly allocated string
601  */
602 gchar *modest_text_utils_escape_mnemonics (const gchar *text);
603
604 /**
605  * modest_text_utils_simplify_recipients:
606  * @recipients: a list of recipients
607  *
608  * returns a list of simplified recipients:
609  *   * a@b <a@b> converted to a@b
610  *   * NULL converted to ""
611  *
612  * It's mainly intended for printing in screen addresses, but it can
613  * also be used for reply/forward.
614  */
615 gchar *modest_text_utils_simplify_recipients (const gchar *recipient);
616
617 /**
618  * modest_text_utils_remove_duplicate_addresses_list
619  * @address_list: non-NULL #GSList of email addresses
620  *
621  * remove duplicate addresses from a list of email addresses
622  *
623  * Returns: a list without the duplicate addresses or NULL in case of
624  * error or the original @address_list was NULL
625  */
626 GSList *modest_text_utils_remove_duplicate_addresses_list (GSList *address_list);
627
628 /**
629  * modest_text_utils_get_secure_header:
630  * @value: the value of a mail header
631  * @header: the header that we're evaluating
632  *
633  * This function returns the secure value for a header. Basically it
634  * avoids DoS attacks caused by specially malformed headers like for
635  * example. From:From:From...From: some@mail.com
636  *
637  * Returns: returns the secured header
638  **/
639 gchar * modest_text_utils_get_secure_header (const gchar *value, const gchar *header);
640
641 /**
642  * modest_text_utils_quote_names:
643  * @recipients: a list of valid email addresses separated by ',' or ';'
644  *
645  * This function quotes the name part of an email address if it's not
646  * quoted and if it exists. For example
647  * aaa@bbb.com -> aaa@bbb.com
648  * "my name" <aaa@bbb.com> -> "my name" <aaa@bbb.com>
649  * my name aaa@bbb.com -> "my name" aaa@bbb.com
650  *
651  * It even supports things like
652  * my, name <aaa@bbb.com>, aaa@ccc.com -> "my, name" <aaa@bbb.com>; aaa@ccc.com
653  *
654  * Returns: a newly allocated string with the quoted email addresses
655  **/
656 gchar * modest_text_utils_quote_names (const gchar *recipients);
657
658 #endif /* __MODEST_TEXT_UTILS_H__ */