Replace hildon-common-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
93 #define _FM_CHANGE_FOLDER _FM("ckdg_ti_change_folder")
94 #define _FM_NEW_FOLDER_NAME_STUB _FM("ckdg_va_new_folder_name_stub")
95 #define _FM_NEW_FOLDER_DIALOG_OK _FM("ckdg_bd_new_folder_dialog_ok")
96 #define _FM_NEW_FOLDER_LOCATION _FM("ckdg_fi_new_folder_location")
97 #define _FM_NEW_FOLDER_NAME _FM("ckdg_fi_new_folder_name")
98 #define _FM_FOLDER_UP _FM("filemanager_folder_up")
99 #define _FM_SIZE_KB _FM("sfil_li_size_kb")
100 #define _FM_SIZE_1KB_99KB _FM("sfil_li_size_1kb_99kb")
101 #define _FM_SIZE_100KB_1MB _FM("sfil_li_size_100kb_1mb")
102 #define _FM_SIZE_1MB_10MB _FM("sfil_li_size_1mb_10mb")
103 #define _FM_SIZE_10MB_1GB _FM("sfil_li_size_10mb_1gb")
104 #define _FM_SIZE_1GB_OR_GREATER _FM("sfil_li_size_1gb_or_greater")
105 #define _FM_OPENING_NOT_ALLOWED _FM("sfil_ib_opening_not_allowed")
106 #define _FM_REPLACE_FILE _FM("docm_nc_replace_file")
107 #define _FM_REPLACE_MULTIPLE _FM("docm_nc_replace_multiple")
108 #define _FM_READ_ONLY_LOCATION _FM("sfil_ib_readonly_location")
109 #define _FM_SAVE_OBJECT_FILES _FM("sfil_ti_save_object_files")
110 #define _FM_CHANGE_FOLDER_NEW_FOLDER ("ckdg_bd_change_folder_new_folder")
111 #else
112 #define _HL_SAVE _("Save")
113 #define _HL_YES _("Yes")
114 #define _HL_NO _("Yes")
115 #define _HL_VIEW _("View")
116 #define _HL_TITLE_SORT _("Sort")
117 #define _HL_TITLE_NEW_FOLDER _("New folder")
118 #define _HL_TITLE_RENAME_FOLDER _HL("Rename folder")
119 #define _HL_RENAME_NAME _("Name")
120 #define _HL_24H_TIME _("%H:%M")
121 #define _HL_DATE _("%m/%d/%Y")
122 #define _HL_WEEK _("%A")
123 #define _HL_DATE_MEDIUM _("%e %B %Y")
124 #define _HL_12H_TIME_PM _("%l:%M pm")
125 #define _HL_12H_TIME_AM _("%l:%M am")
126 #define _HL_DONE _("Done")
127 #define _HL_DELETE _("Delete")
128 #define _HL_MOVE _("Move")
129 #define _HL_RENAME _("Rename")
130 #define _HL_IB_FIND_COMPLETE _("Search complete")
131 #define _HL_IB_FIND_NO_MATCHES _("No matches")
132 #define _HL_IB_ZOOM _("Zoom %d")
133
134 #define _CS_ILLEGAL_CHARACTERS_ENTERED _("Illegal characters entered")
135 #define _CS_CANNOT_ZOOM_HERE _("Cannot zoom here")
136 #define _CS_MAX_ZOOM_LEVEL_REACHED _("Max. zoom level reached")
137 #define _CS_MIN_ZOOM_LEVEL_REACHED _("Min. zoom level reached")
138 #define _CS_MAXIMUM_CHARACTERS_REACHED _("Maximum characters reached")
139 #define _CS_FOLDER_ALREADY_EXISTS _("Folder already exists")
140 #define _CS_SET_PASSWORD_INCORRECT _("Password incorrect")
141 #define _CS_UNABLE_TO_PASTE_HERE _("Unable to paste here")
142 #define _CS_UNABLE_TO_OPEN_FILE_NOT_FOUND _("File not found")
143 #define _CS_UNABLE_TO_RENAME _("Unable to rename")
144 #define _CS_UNABLE_TO_DELETE _("Unable to delete")
145 #define _CS_NOTHING_TO_SORT _("Nothing to sort")
146 #define _CS_NOT_ENOUGH_MEMORY _("Not enough memory")
147 #define _CS_FOLDER_ALREADY_EXISTS _("Folder already exists")
148 #define _CS_PASTING _("Pasting")
149 #define _CS_GETTING_ITEMS _("Getting items")
150 #define _CS_COPIED _("Copied")
151 #define _CS_UNABLE_TO_SEND _("Unable to send")
152 #define _CS_FIND_REP_ENTER_TEXT _("Enter text to search")
153 #define _CS_UPDATING _("Updating...")
154 #define _CS_SAVED _("Saved")
155
156 #define _FM_CHANGE_FOLDER _("Change folder")
157 #define _FM_NEW_FOLDER_NAME_STUB _("Folder")
158 #define _FM_NEW_FOLDER_DIALOG_OK _("Save")
159 #define _FM_NEW_FOLDER_LOCATION _("Location")
160 #define _FM_NEW_FOLDER_NAME _("Name")
161 #define _FM_FOLDER_UP "stock_up"
162 #define _FM_SIZE_KB _("%d KB")
163 #define _FM_SIZE_1KB_99KB _("%d KB")
164 #define _FM_SIZE_100KB_1MB _("%d KB")
165 #define _FM_SIZE_1MB_10MB _("%.2f MB")
166 #define _FM_SIZE_10MB_1GB _("%.1f MB")
167 #define _FM_SIZE_1GB_OR_GREATER _("%.2f GB")
168 #define _FM_OPENING_NOT_ALLOWED _("Opening not allowed")
169 #define _FM_REPLACE_FILE _("Replace the existing file with another with the same name?")
170 #define _FM_REPLACE_MULTIPLE _("Replace existing contents in folder with the same name?")
171 #define _FM_READ_ONLY_LOCATION _("Selected location is read only")
172 #define _FM_SAVE_OBJECT_FILES _("Save files")
173 #define _FM_CHANGE_FOLDER_NEW_FOLDER ("New folder")
174 #endif
175
176 /* Forbidden char arrays */
177 extern const gchar account_title_forbidden_chars[];
178 extern const gchar folder_name_forbidden_chars[];
179 extern const gchar user_name_forbidden_chars[];
180 extern const guint ACCOUNT_TITLE_FORBIDDEN_CHARS_LENGTH;
181 extern const guint FOLDER_NAME_FORBIDDEN_CHARS_LENGTH;
182 extern const guint USER_NAME_FORBIDDEN_CHARS_LENGTH;
183
184 /* It includes a white space as RFC 3676 Section 4.3 about usenet
185    message signatures defines */
186 #define MODEST_TEXT_UTILS_SIGNATURE_MARKER "-- "
187
188 /**
189  * modest_text_utils_derived_subject:
190  * @subject: a string which contains the original subject
191  * @is_reply: whether the derived subject is for a reply or a forward message
192  *
193  * create a 'derived' subject line for eg. replies and forwards. Note
194  * that this function will use the localized versions of "Re" and
195  * "Fw", unless one of these two versions was already included. For
196  * example replying to an email in Finish would work as:
197  *
198  * "some subject"     -> "VS: some subject"
199  * "VS: some subject" -> "VS: some subject"
200  * "Re: some subject" -> "Re: some subject"
201  * "Fw: some subject" -> "VS: Fw: some subject"
202  *
203  * Returns: a newly allocated string containing the resulting subject
204  */
205 gchar* modest_text_utils_derived_subject (const gchar *subject,
206                                           gboolean is_reply);
207
208
209 /**
210  * modest_text_utils_quote:
211  * @text: a non-NULL string which contains the message to quote
212  * @from: a non-NULL  sender of the original message
213  * @content_type: the non-NULL content type for the quoting, e.g. "text/html"
214  * @signature: NULL or the signature to add
215  * @sent_date: sent date/time of the original message
216  * @attachments: a #GList of the attachments
217  * @limit: specifies the maximum characters per line in the quoted text
218  * 
219  * quote an existing message
220  * 
221  * Returns: a newly allocated string containing the quoted message
222  */
223 gchar* modest_text_utils_quote (const gchar *text, 
224                                 const gchar *content_type,
225                                 const gchar *signature,
226                                 const gchar *from,
227                                 const time_t sent_date, 
228                                 GList *attachments,
229                                 int limit);
230
231
232 /**
233  * modest_text_utils_cited_text:
234  * @from: sender of the message
235  * @sent_date: the sent date of the original message
236  * @text: the text of the original message
237  *
238  * cite the text in a message
239  * 
240  * Returns: a newly allocated string containing the cited text
241  */
242 gchar* modest_text_utils_cite (const gchar *text,
243                                const gchar *content_type,
244                                const gchar *signature,
245                                const gchar *from,
246                                time_t sent_date);
247
248 /**
249  * modest_text_utils_inlined_text
250  * @from: the non-NULL sender of the original message
251  * @sent_date: sent date/time of the original message
252  * @to: 
253  * @subject: 
254  * @text: 
255  *
256  * creates a new string with the "Original message" text prepended to
257  * the text passed as argument and some data of the header
258  * 
259  * Returns: a newly allocated string containing the quoted message
260  */
261 gchar*   modest_text_utils_inline (const gchar *text,
262                                    const gchar *content_type,
263                                    const gchar *signature,
264                                    const gchar *from,
265                                    time_t sent_date,
266                                    const gchar *to,
267                                    const gchar *subject);
268
269 /**
270  * modest_text_utils_remove_address
271  * @address_list: non-NULL string with a comma-separated list of email addresses
272  * @address: an specific e-mail address 
273  *
274  * remove a specific address from a list of email addresses; if @address
275  * is NULL, returns an unchanged (but newly allocated) @address_list
276  * 
277  * Returns: a newly allocated string containing the new list, or NULL
278  * in case of error or the original @address_list was NULL
279  */
280 gchar*   modest_text_utils_remove_address (const gchar *address_list, 
281                                            const gchar *address);
282
283
284 /**
285  * modest_text_utils_remove_duplicate_addresses
286  * @address_list: non-NULL string with a comma-separated list of email addresses
287  *
288  * remove duplicate addresses from a list of email addresses
289  * 
290  * Returns: a newly allocated string containing the new list, or NULL
291  * in case of error or the original @address_list was NULL
292  */
293 gchar*   modest_text_utils_remove_duplicate_addresses (const gchar *address_list); 
294
295
296 /**
297  * modest_text_utils_address_range_at_position:
298  * @address_list: non-NULL utf8 string containing a list of addresses
299  * @position: a gint
300  * @start: a gint pointer
301  * @end: a gint pointer
302  *
303  * Finds the start and end positions of the address at @position,
304  * in @recipients_list, a list of addresses in the format of a 
305  * recipient list in email. It stores the results in @start and
306  * @end
307  */
308 void     modest_text_utils_address_range_at_position (const gchar *recipients_list,
309                                                       guint position,
310                                                       guint *start,
311                                                       guint *end);
312
313 /**
314  * modest_text_utils_hyperlinkify_begin:
315  *
316  * begin a linkify block, compiling the caches to be reused. Use it in mainloop.
317  */
318 void modest_text_utils_hyperlinkify_begin (void);
319
320 /**
321  * modest_text_utils_hyperlinkify_end:
322  *
323  * end a linkify block, freeing the caches to be reused. Use it in mainloop.
324  */
325 void modest_text_utils_hyperlinkify_end (void);
326
327 /**
328  * modest_text_utils_convert_to_html:
329  * @txt: a string
330  *
331  * convert plain text (utf8) into html
332  * 
333  * Returns: a newly allocated string containing the html
334  */
335 gchar*  modest_text_utils_convert_to_html (const gchar *txt);
336
337 /**
338  * modest_text_utils_convert_to_html_body:
339  * @txt: a string
340  *
341  * convert plain text (utf8) into html without adding html headers.
342  * 
343  * Returns: a newly allocated string containing the html
344  */
345 gchar*  modest_text_utils_convert_to_html_body (const gchar *data, gssize n, gboolean hyperlinkify);
346
347
348 /**
349  * modest_text_utils_strftime:
350  * @s:
351  * @max:
352  * @fmt:
353  * @timet:
354  *
355  * this is just an alias for strftime(3), so we can use that without
356  * getting warning from gcc
357  * 
358  * Returns: a formatted string of max length @max in @s
359  */
360 size_t modest_text_utils_strftime(char *s, size_t max, const char  *fmt, time_t timet);
361
362 /**
363  * modest_text_utils_hyperlinkify:
364  * @string_buffer: buffer where we replace uri strings with links
365  *
366  * Replace uri's with links in the buffer. This is required that the document
367  * do not contain linkified links already.
368  */
369 void modest_text_utils_hyperlinkify (GString *string_buffer);
370
371 /**
372  * modest_text_utils_get_display_address:
373  * @address: original address (UTF8 string)
374  *
375  * make a 'display address' from an address:
376  * "Foo Bar &lt;foo@bar.cx&gt;" --&gt; "Foo Bar"
377  * ie. removes "&lt;...&gt;" parts
378  * the change is in-place; removes leading whitespace
379  * 
380  * NOTE: for optimization reasons, this function changes @address
381  * in-place
382  */
383 void modest_text_utils_get_display_address (gchar *address);
384
385 /**
386  * modest_text_utils_get_display_addresses:
387  * @addresses: a list of comma-separated addresses
388  *
389  * Transforms a list of email addresses in a list of recipients,
390  * replacing each plain email address by the correspondent display
391  * address.
392  *
393  * Returns: a newly allocated string, that must be freed by the caller
394  **/
395 gchar *modest_text_utils_get_display_addresses (const gchar *addresses);
396
397
398 /**
399  * modest_text_utils_get_email_address:
400  * @full_address: original address (UTF8 string)
401  *
402  * make a 'foo@bar.cx' from an address:
403  * "Foo Bar <foo@bar.cx> (Bla)" --> "foo@bar.cx"
404  * If no "<...>" is found, then it returns the full
405  * strings.
406  * 
407  * Returns: a newly allocated string with the copy.
408  * 
409  * NULL in case of error or if address == NULL
410  */
411 gchar* modest_text_utils_get_email_address (const gchar *email_address);
412
413
414 /**
415  * modest_text_utils_get_subject_prefix_len:
416  * @subject: original subject (UTF8 string)
417  *
418  * determine the length of the "Re:/RE:/Fwd:" prefix in an e-mail address
419  * 
420  * Returns: the length of the  prefix, or 0 if there is none
421  */
422 gint modest_text_utils_get_subject_prefix_len (const gchar *subject);
423
424
425 /**
426  * modest_text_utils_utf8_strcmp:
427  * @s1: the first string
428  * @s2: the second string
429  * @insensitive: should the comparison be case-insensitive?
430  *
431  * a strcmp that is NULL-safe, can deal with UTF8 and case-insensitive comparison 
432  *
433  * Returns: an integer less than, equal to, or greater than zero if s1 is found,
434  * respectively, to be less than, to match, or be greater than s2.
435  */
436 gint modest_text_utils_utf8_strcmp (const gchar* s1, const gchar *s2, gboolean insensitive);
437
438
439
440 /**
441  * modest_text_utils_get_display_date:
442  * @date: the date to display
443  *
444  * get a string representation for a date.
445  * 
446  * Returns: the new display date, as a *static* string.
447  * This string should not be modified, and will change
448  * upon recalling this function. g_strdup it if you to
449  * do so.
450  * 
451  */
452 const gchar* modest_text_utils_get_display_date (time_t date);
453
454
455 /**
456  * modest_text_utils_get_display_size:
457  * @size: size in bytes
458  *
459  * get a string representation for a size in bytes.
460  * 
461  * Returns: the newly allocated display string for the
462  * size in bytes. must be freed.
463  */
464 gchar * modest_text_utils_get_display_size (guint64 size);
465
466
467
468 /**
469  * modest_text_utils_validate_domain_name:
470  * @email_address: a NULL-terminated string
471  * 
472  * validates the domain name passed as argument
473  * 
474  * Returns: TRUE if the domain name is valid, FALSE otherwise
475  **/
476 gboolean modest_text_utils_validate_domain_name (const gchar *domain);
477
478 /**
479  * modest_text_utils_validate_email_address:
480  * @email_address: a string
481  * @invalid_char_position: pointer to the position of the invalid
482  * character in case validation failed because of this, or %NULL.
483  * 
484  * validates the email address passed as argument
485  * 
486  * Returns: TRUE if the address is valid, FALSE otherwise
487  **/
488 gboolean     modest_text_utils_validate_email_address (const gchar *email_address, 
489                                                        const gchar **invalid_char_position);
490
491
492 /**
493  * modest_text_utils_validate_folder_name:
494  * @folder_name: a string
495  * 
496  * validates the folder name passed as argument. a 'valid folder name'
497  * is a name which should be valid on both Unix and Windows file systems.
498  * of course, this might be stricter than strictly needed in some cases,
499  * but it's better to err on the safe side.
500  * 
501  * Returns: TRUE if the folder name is valid, FALSE otherwise
502  **/
503 gboolean modest_text_utils_validate_folder_name (const gchar *folder_name);
504
505 /**
506  * modest_text_utils_validate_recipient:
507  * @recipient: a string
508  * @invalid_char_position: pointer to the position of the invalid char,
509  * if validation failed because there's an invalid char there, or %NULL.
510  *
511  * validates @recipient as a valid recipient field for header.
512  * It's different from modest_text_utils_validate_email_address()
513  * as it validates a whole recipient, and not only the part between
514  * the &lt; and &gt; symbols.
515  *
516  * Returns: %TRUE if the recipient is valid, FALSE otherwise
517  **/
518 gboolean     modest_text_utils_validate_recipient (const gchar *recipient,
519                                                    const gchar **invalid_char_position);
520
521 /**
522  * modest_text_utils_split_addresses_list:
523  * @addresses: a string
524  *
525  * obtains a GSList of addresses from a string of addresses
526  * in the format understood by email protocols
527  *
528  * Returns: a newly allocated GSList of strings
529  **/
530 GSList      *modest_text_utils_split_addresses_list (const gchar *addresses);
531
532 /**
533  * modest_text_utils_join_addresses:
534  * @from: comma separated string of addresses
535  * @to: comma separated string of addresses
536  * @cc: comma separated string of addresses
537  * @bcc: comma separated string of addresses
538  *
539  * joins all the addresses in a single comma-separated string
540  *
541  * Returns: a newly allocated string with a list of addresses
542  **/
543 gchar       *modest_text_utils_join_addresses (const gchar *from,
544                                                const gchar *to,
545                                                const gchar *cc,
546                                                const gchar *bcc);
547
548 /**
549  * modest_text_utils_get_addresses_indexes:
550  * @addresses: a string
551  * @start_indexes: a #GSList pointer
552  * @end_indexes: a #GSList pointer
553  *
554  * obtains two #GSList of @addresses with the range offsets of the addresses in
555  * the string
556  *
557  * Returns: a GSList of strings
558  **/
559 void         modest_text_utils_get_addresses_indexes (const gchar *addresses, GSList **start_indexes, GSList **end_indexes);
560
561 /**
562  * modest_text_utils_address_with_standard_length:
563  * @recipients_list: a string
564  *
565  * obtains the list of recipients, but making sure that lines are not longer than 1000 chars
566  *
567  * Returns: a newly allocated string
568  */
569 gchar *      modest_text_utils_address_with_standard_length (const gchar *recipients_list);
570
571 /**
572  * modest_text_utils_get_color_string:
573  * @color: a #GdkColor
574  *
575  * Obtains a proper markup string for @color, in the format used
576  * by Pango and HTML.
577  *
578  * Returns: a newly allocated string
579  */
580 gchar *      modest_text_utils_get_color_string (GdkColor *color);
581
582 /**
583  * modest_text_utils_text_buffer_get_text:
584  * @buffer: a #GtkTextBuffer
585  *
586  * Obtains the contents of a @buffer in a string, replacing image
587  * pixbufs with blank spaces.
588  *
589  * Returns: a newly allocated UTF-8 string
590  */
591 gchar *      modest_text_utils_text_buffer_get_text (GtkTextBuffer *buffer);
592
593 typedef enum {
594         ACCOUNT_TITLE_FORBIDDEN_CHARS,
595         FOLDER_NAME_FORBIDDEN_CHARS,
596         USER_NAME_FORBIDDEN_NAMES,
597 } ModestTextUtilsForbiddenCharType;
598
599 /**
600  * modest_text_utils_label_get_selection:
601  * @label: a #GtkLabel
602  *
603  * Obtain the current selection of @label
604  *
605  * Returns: a string with current selection, or %NULL if no selection in @label
606  */
607 gchar *      modest_text_utils_label_get_selection (GtkLabel *label);
608
609 /**
610  * modest_text_utils_is_forbidden_char:
611  * @character: some character
612  * @type: the type of forbidden char (see #ModestTextUtilsForbiddenCharType)
613  * 
614  * check whether the given character is 'forbidden'
615  *
616  * Returns: TRUE if it's forbidden, FALSE otherwise
617  */
618 gboolean     modest_text_utils_is_forbidden_char (const gchar character,
619                                                   ModestTextUtilsForbiddenCharType type);
620
621 /**
622  * modest_text_utils_buffer_selection_is_valid:
623  * @buffer: a #GtkTextBuffer
624  *
625  * Checks if @buffer contains a valid selection for cut/copy. This means it's
626  * not empty, and no images are in the selection.
627  *
628  * Returns: %TRUE if there's a valid selection, false otherwise.
629  */
630 gboolean     modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer);
631
632 /**
633  * modest_text_utils_escape_mnemonics:
634  * @text: a string
635  *
636  * obtains the representation of text, but escaping mnemonics (we duplicate _)
637  *
638  * Returns: a newly allocated string
639  */
640 gchar *modest_text_utils_escape_mnemonics (const gchar *text);
641
642 /**
643  * modest_text_utils_simplify_recipients:
644  * @recipients: a list of recipients
645  *
646  * returns a list of simplified recipients:
647  *   * a@b <a@b> converted to a@b
648  *   * NULL converted to ""
649  *
650  * It's mainly intended for printing in screen addresses, but it can
651  * also be used for reply/forward.
652  */
653 gchar *modest_text_utils_simplify_recipients (const gchar *recipient);
654
655 /**
656  * modest_text_utils_remove_duplicate_addresses_list
657  * @address_list: non-NULL #GSList of email addresses
658  *
659  * remove duplicate addresses from a list of email addresses
660  *
661  * Returns: a list without the duplicate addresses or NULL in case of
662  * error or the original @address_list was NULL
663  */
664 GSList *modest_text_utils_remove_duplicate_addresses_list (GSList *address_list);
665
666 /**
667  * modest_text_utils_get_secure_header:
668  * @value: the value of a mail header
669  * @header: the header that we're evaluating
670  *
671  * This function returns the secure value for a header. Basically it
672  * avoids DoS attacks caused by specially malformed headers like for
673  * example. From:From:From...From: some@mail.com
674  *
675  * Returns: returns the secured header
676  **/
677 gchar * modest_text_utils_get_secure_header (const gchar *value, const gchar *header);
678
679 /**
680  * modest_text_utils_quote_names:
681  * @recipients: a list of valid email addresses separated by ',' or ';'
682  *
683  * This function quotes the name part of an email address if it's not
684  * quoted and if it exists. For example
685  * aaa@bbb.com -> aaa@bbb.com
686  * "my name" <aaa@bbb.com> -> "my name" <aaa@bbb.com>
687  * my name aaa@bbb.com -> "my name" aaa@bbb.com
688  *
689  * It even supports things like
690  * my, name <aaa@bbb.com>, aaa@ccc.com -> "my, name" <aaa@bbb.com>; aaa@ccc.com
691  *
692  * Returns: a newly allocated string with the quoted email addresses
693  **/
694 gchar * modest_text_utils_quote_names (const gchar *recipients);
695
696 #endif /* __MODEST_TEXT_UTILS_H__ */