1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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.
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.
31 /* modest-text-utils.h */
33 #ifndef __MODEST_TEXT_UTILS_H__
34 #define __MODEST_TEXT_UTILS_H__
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)
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")
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")
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")
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")
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")
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 GTK_STOCK_GO_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")
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;
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 "-- "
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
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:
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"
203 * Returns: a newly allocated string containing the resulting subject
205 gchar* modest_text_utils_derived_subject (const gchar *subject,
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
219 * quote an existing message
221 * Returns: a newly allocated string containing the quoted message
223 gchar* modest_text_utils_quote (const gchar *text,
224 const gchar *content_type,
225 const gchar *signature,
227 const time_t sent_date,
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
238 * cite the text in a message
240 * Returns: a newly allocated string containing the cited text
242 gchar* modest_text_utils_cite (const gchar *text,
243 const gchar *content_type,
244 const gchar *signature,
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
256 * creates a new string with the "Original message" text prepended to
257 * the text passed as argument and some data of the header
259 * Returns: a newly allocated string containing the quoted message
261 gchar* modest_text_utils_inline (const gchar *text,
262 const gchar *content_type,
263 const gchar *signature,
267 const gchar *subject);
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
274 * remove a specific address from a list of email addresses; if @address
275 * is NULL, returns an unchanged (but newly allocated) @address_list
277 * Returns: a newly allocated string containing the new list, or NULL
278 * in case of error or the original @address_list was NULL
280 gchar* modest_text_utils_remove_address (const gchar *address_list,
281 const gchar *address);
285 * modest_text_utils_remove_duplicate_addresses
286 * @address_list: non-NULL string with a comma-separated list of email addresses
288 * remove duplicate addresses from a list of email addresses
290 * Returns: a newly allocated string containing the new list, or NULL
291 * in case of error or the original @address_list was NULL
293 gchar* modest_text_utils_remove_duplicate_addresses (const gchar *address_list);
297 * modest_text_utils_address_range_at_position:
298 * @address_list: non-NULL utf8 string containing a list of addresses
300 * @start: a gint pointer
301 * @end: a gint pointer
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
308 void modest_text_utils_address_range_at_position (const gchar *recipients_list,
314 * modest_text_utils_hyperlinkify_begin:
316 * begin a linkify block, compiling the caches to be reused. Use it in mainloop.
318 void modest_text_utils_hyperlinkify_begin (void);
321 * modest_text_utils_hyperlinkify_end:
323 * end a linkify block, freeing the caches to be reused. Use it in mainloop.
325 void modest_text_utils_hyperlinkify_end (void);
328 * modest_text_utils_convert_to_html:
331 * convert plain text (utf8) into html
333 * Returns: a newly allocated string containing the html
335 gchar* modest_text_utils_convert_to_html (const gchar *txt);
338 * modest_text_utils_convert_to_html_body:
341 * convert plain text (utf8) into html without adding html headers.
343 * Returns: a newly allocated string containing the html
345 gchar* modest_text_utils_convert_to_html_body (const gchar *data, gssize n, gboolean hyperlinkify);
349 * modest_text_utils_strftime:
355 * this is just an alias for strftime(3), so we can use that without
356 * getting warning from gcc
358 * Returns: a formatted string of max length @max in @s
360 size_t modest_text_utils_strftime(char *s, size_t max, const char *fmt, time_t timet);
363 * modest_text_utils_hyperlinkify:
364 * @string_buffer: buffer where we replace uri strings with links
366 * Replace uri's with links in the buffer. This is required that the document
367 * do not contain linkified links already.
369 void modest_text_utils_hyperlinkify (GString *string_buffer);
372 * modest_text_utils_get_display_address:
373 * @address: original address (UTF8 string)
375 * make a 'display address' from an address:
376 * "Foo Bar <foo@bar.cx>" --> "Foo Bar"
377 * ie. removes "<...>" parts
378 * the change is in-place; removes leading whitespace
380 * NOTE: for optimization reasons, this function changes @address
383 void modest_text_utils_get_display_address (gchar *address);
386 * modest_text_utils_get_display_addresses:
387 * @addresses: a list of comma-separated addresses
389 * Transforms a list of email addresses in a list of recipients,
390 * replacing each plain email address by the correspondent display
393 * Returns: a newly allocated string, that must be freed by the caller
395 gchar *modest_text_utils_get_display_addresses (const gchar *addresses);
399 * modest_text_utils_get_email_address:
400 * @full_address: original address (UTF8 string)
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
407 * Returns: a newly allocated string with the copy.
409 * NULL in case of error or if address == NULL
411 gchar* modest_text_utils_get_email_address (const gchar *email_address);
415 * modest_text_utils_get_subject_prefix_len:
416 * @subject: original subject (UTF8 string)
418 * determine the length of the "Re:/RE:/Fwd:" prefix in an e-mail address
420 * Returns: the length of the prefix, or 0 if there is none
422 gint modest_text_utils_get_subject_prefix_len (const gchar *subject);
426 * modest_text_utils_utf8_strcmp:
427 * @s1: the first string
428 * @s2: the second string
429 * @insensitive: should the comparison be case-insensitive?
431 * a strcmp that is NULL-safe, can deal with UTF8 and case-insensitive comparison
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.
436 gint modest_text_utils_utf8_strcmp (const gchar* s1, const gchar *s2, gboolean insensitive);
441 * modest_text_utils_get_display_date:
442 * @date: the date to display
444 * get a string representation for a date.
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
452 const gchar* modest_text_utils_get_display_date (time_t date);
456 * modest_text_utils_get_display_size:
457 * @size: size in bytes
459 * get a string representation for a size in bytes.
461 * Returns: the newly allocated display string for the
462 * size in bytes. must be freed.
464 gchar * modest_text_utils_get_display_size (guint64 size);
469 * modest_text_utils_validate_domain_name:
470 * @email_address: a NULL-terminated string
472 * validates the domain name passed as argument
474 * Returns: TRUE if the domain name is valid, FALSE otherwise
476 gboolean modest_text_utils_validate_domain_name (const gchar *domain);
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.
484 * validates the email address passed as argument
486 * Returns: TRUE if the address is valid, FALSE otherwise
488 gboolean modest_text_utils_validate_email_address (const gchar *email_address,
489 const gchar **invalid_char_position);
493 * modest_text_utils_validate_folder_name:
494 * @folder_name: a string
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.
501 * Returns: TRUE if the folder name is valid, FALSE otherwise
503 gboolean modest_text_utils_validate_folder_name (const gchar *folder_name);
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.
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 < and > symbols.
516 * Returns: %TRUE if the recipient is valid, FALSE otherwise
518 gboolean modest_text_utils_validate_recipient (const gchar *recipient,
519 const gchar **invalid_char_position);
522 * modest_text_utils_split_addresses_list:
523 * @addresses: a string
525 * obtains a GSList of addresses from a string of addresses
526 * in the format understood by email protocols
528 * Returns: a newly allocated GSList of strings
530 GSList *modest_text_utils_split_addresses_list (const gchar *addresses);
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
539 * joins all the addresses in a single comma-separated string
541 * Returns: a newly allocated string with a list of addresses
543 gchar *modest_text_utils_join_addresses (const gchar *from,
549 * modest_text_utils_get_addresses_indexes:
550 * @addresses: a string
551 * @start_indexes: a #GSList pointer
552 * @end_indexes: a #GSList pointer
554 * obtains two #GSList of @addresses with the range offsets of the addresses in
557 * Returns: a GSList of strings
559 void modest_text_utils_get_addresses_indexes (const gchar *addresses, GSList **start_indexes, GSList **end_indexes);
562 * modest_text_utils_address_with_standard_length:
563 * @recipients_list: a string
565 * obtains the list of recipients, but making sure that lines are not longer than 1000 chars
567 * Returns: a newly allocated string
569 gchar * modest_text_utils_address_with_standard_length (const gchar *recipients_list);
572 * modest_text_utils_get_color_string:
573 * @color: a #GdkColor
575 * Obtains a proper markup string for @color, in the format used
578 * Returns: a newly allocated string
580 gchar * modest_text_utils_get_color_string (GdkColor *color);
583 * modest_text_utils_text_buffer_get_text:
584 * @buffer: a #GtkTextBuffer
586 * Obtains the contents of a @buffer in a string, replacing image
587 * pixbufs with blank spaces.
589 * Returns: a newly allocated UTF-8 string
591 gchar * modest_text_utils_text_buffer_get_text (GtkTextBuffer *buffer);
594 ACCOUNT_TITLE_FORBIDDEN_CHARS,
595 FOLDER_NAME_FORBIDDEN_CHARS,
596 USER_NAME_FORBIDDEN_NAMES,
597 } ModestTextUtilsForbiddenCharType;
600 * modest_text_utils_label_get_selection:
601 * @label: a #GtkLabel
603 * Obtain the current selection of @label
605 * Returns: a string with current selection, or %NULL if no selection in @label
607 gchar * modest_text_utils_label_get_selection (GtkLabel *label);
610 * modest_text_utils_is_forbidden_char:
611 * @character: some character
612 * @type: the type of forbidden char (see #ModestTextUtilsForbiddenCharType)
614 * check whether the given character is 'forbidden'
616 * Returns: TRUE if it's forbidden, FALSE otherwise
618 gboolean modest_text_utils_is_forbidden_char (const gchar character,
619 ModestTextUtilsForbiddenCharType type);
622 * modest_text_utils_buffer_selection_is_valid:
623 * @buffer: a #GtkTextBuffer
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.
628 * Returns: %TRUE if there's a valid selection, false otherwise.
630 gboolean modest_text_utils_buffer_selection_is_valid (GtkTextBuffer *buffer);
633 * modest_text_utils_escape_mnemonics:
636 * obtains the representation of text, but escaping mnemonics (we duplicate _)
638 * Returns: a newly allocated string
640 gchar *modest_text_utils_escape_mnemonics (const gchar *text);
643 * modest_text_utils_simplify_recipients:
644 * @recipients: a list of recipients
646 * returns a list of simplified recipients:
647 * * a@b <a@b> converted to a@b
648 * * NULL converted to ""
650 * It's mainly intended for printing in screen addresses, but it can
651 * also be used for reply/forward.
653 gchar *modest_text_utils_simplify_recipients (const gchar *recipient);
656 * modest_text_utils_remove_duplicate_addresses_list
657 * @address_list: non-NULL #GSList of email addresses
659 * remove duplicate addresses from a list of email addresses
661 * Returns: a list without the duplicate addresses or NULL in case of
662 * error or the original @address_list was NULL
664 GSList *modest_text_utils_remove_duplicate_addresses_list (GSList *address_list);
667 * modest_text_utils_get_secure_header:
668 * @value: the value of a mail header
669 * @header: the header that we're evaluating
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
675 * Returns: returns the secured header
677 gchar * modest_text_utils_get_secure_header (const gchar *value, const gchar *header);
680 * modest_text_utils_quote_names:
681 * @recipients: a list of valid email addresses separated by ',' or ';'
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
689 * It even supports things like
690 * my, name <aaa@bbb.com>, aaa@ccc.com -> "my, name" <aaa@bbb.com>; aaa@ccc.com
692 * Returns: a newly allocated string with the quoted email addresses
694 gchar * modest_text_utils_quote_names (const gchar *recipients);
696 gboolean modest_text_utils_no_recipient (GtkTextBuffer *buffer);
698 gchar * modest_text_utils_create_colored_signature (const gchar *signature);
700 gboolean modest_text_utils_live_search_find (const gchar *haystack, const gchar *needles);
702 #endif /* __MODEST_TEXT_UTILS_H__ */