aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/em-utils.c')
-rw-r--r--mail/em-utils.c341
1 files changed, 144 insertions, 197 deletions
diff --git a/mail/em-utils.c b/mail/em-utils.c
index ba180e5011..9b2786904a 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -56,7 +56,6 @@
#include <gio/gio.h>
-#include "mail-component.h"
#include "mail-mt.h"
#include "mail-ops.h"
#include "mail-tools.h"
@@ -69,10 +68,10 @@
#include "e-util/e-util.h"
#include "e-util/e-util-private.h"
#include "e-util/e-mktemp.h"
-#include "libedataserver/e-account-list.h"
+#include "e-util/e-account-utils.h"
#include "e-util/e-dialog-utils.h"
#include "e-util/e-error.h"
-
+#include "widgets/misc/e-alert-activity.h"
#include "em-utils.h"
#include "em-composer-utils.h"
@@ -80,11 +79,10 @@
#include "em-format-quote.h"
#include "em-account-editor.h"
#include "e-attachment.h"
-#include "e-activity-handler.h"
-static void emu_save_part_done (CamelMimePart *part, char *name, int done, void *data);
+#include "e-mail-shell-backend.h"
-extern struct _CamelSession *session;
+static void emu_save_part_done (CamelMimePart *part, char *name, int done, void *data);
#define d(x)
@@ -194,20 +192,24 @@ druid_destroy_cb (gpointer user_data, GObject *deadbeef)
* otherwise.
**/
gboolean
-em_utils_configure_account (GtkWidget *parent)
+em_utils_configure_account (GtkWindow *parent)
{
EMAccountEditor *emae;
+ EAccountList *account_list;
+
+ g_return_val_if_fail (GTK_IS_WINDOW (parent), FALSE);
emae = em_account_editor_new(NULL, EMAE_DRUID, "org.gnome.evolution.mail.config.accountDruid");
- if (parent != NULL)
- e_dialog_set_transient_for((GtkWindow *)emae->editor, parent);
+ gtk_window_set_transient_for (GTK_WINDOW (emae->editor), parent);
g_object_weak_ref((GObject *)emae->editor, (GWeakNotify) druid_destroy_cb, NULL);
gtk_widget_show(emae->editor);
gtk_grab_add(emae->editor);
gtk_main();
- return mail_config_is_configured();
+ account_list = e_get_account_list ();
+
+ return (e_list_length ((EList *) account_list) > 0);
}
/**
@@ -224,16 +226,19 @@ em_utils_configure_account (GtkWidget *parent)
* or %FALSE otherwise.
**/
gboolean
-em_utils_check_user_can_send_mail (GtkWidget *parent)
+em_utils_check_user_can_send_mail (GtkWindow *parent)
{
+ EAccountList *account_list;
EAccount *account;
- if (!mail_config_is_configured ()) {
+ account_list = e_get_account_list ();
+
+ if (e_list_length ((EList *) account_list) == 0) {
if (!em_utils_configure_account (parent))
return FALSE;
}
- if (!(account = mail_config_get_default_account ()))
+ if (!(account = e_get_default_account ()))
return FALSE;
/* Check for a transport */
@@ -250,14 +255,18 @@ static GtkWidget *filter_editor = NULL;
static void
em_filter_editor_response (GtkWidget *dialog, int button, gpointer user_data)
{
+ EShellBackend *shell_backend;
EMFilterContext *fc;
+ shell_backend = E_SHELL_BACKEND (global_mail_shell_backend);
+
if (button == GTK_RESPONSE_OK) {
+ const gchar *data_dir;
char *user;
+ data_dir = e_shell_backend_get_data_dir (shell_backend);
fc = g_object_get_data ((GObject *) dialog, "context");
- user = g_strdup_printf ("%s/filters.xml",
- mail_component_peek_base_directory (mail_component_peek ()));
+ user = g_strdup_printf ("%s/filters.xml", data_dir);
rule_context_save ((RuleContext *) fc, user);
g_free (user);
}
@@ -284,7 +293,8 @@ static EMFilterSource em_filter_source_element_names[] = {
void
em_utils_edit_filters (GtkWidget *parent)
{
- const char *base_directory = mail_component_peek_base_directory (mail_component_peek ());
+ EShellBackend *shell_backend;
+ const gchar *data_dir;
char *user, *system;
EMFilterContext *fc;
@@ -293,8 +303,11 @@ em_utils_edit_filters (GtkWidget *parent)
return;
}
+ shell_backend = E_SHELL_BACKEND (global_mail_shell_backend);
+ data_dir = e_shell_backend_get_data_dir (shell_backend);
+
fc = em_filter_context_new ();
- user = g_strdup_printf ("%s/filters.xml", base_directory);
+ user = g_build_filename (data_dir, "filters.xml", NULL);
system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
rule_context_load ((RuleContext *) fc, system, user);
g_free (user);
@@ -385,12 +398,14 @@ emu_save_get_filename_for_part (CamelMimePart *part)
* Saves a mime part to disk (prompting the user for filename).
**/
void
-em_utils_save_part (GtkWidget *parent, const char *prompt, CamelMimePart *part)
+em_utils_save_part (GtkWindow *parent, const char *prompt, CamelMimePart *part)
{
GtkWidget *file_chooser;
const gchar *utf8_filename;
gchar *uri = NULL, *filename;
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
utf8_filename = emu_save_get_filename_for_part (part);
filename = g_filename_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
em_filename_make_safe (filename);
@@ -500,12 +515,14 @@ get_unique_file_names (GSList *parts)
}
void
-em_utils_save_parts (GtkWidget *parent, const gchar *prompt, GSList *parts)
+em_utils_save_parts (GtkWindow *parent, const gchar *prompt, GSList *parts)
{
GtkWidget *file_chooser;
gchar *path_uri;
GSList *iter, *file_names, *iter_file;
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
file_chooser = e_file_get_save_filesel (
parent, prompt, NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
@@ -556,7 +573,7 @@ exit:
* Returns %TRUE if saving succeeded, %FALSE otherwise
**/
gboolean
-em_utils_save_part_to_file(GtkWidget *parent, const char *filename, CamelMimePart *part)
+em_utils_save_part_to_file(GtkWindow *parent, const char *filename, CamelMimePart *part)
{
int done;
char *dirname;
@@ -567,7 +584,7 @@ em_utils_save_part_to_file(GtkWidget *parent, const char *filename, CamelMimePar
dirname = g_path_get_dirname(filename);
if (g_mkdir_with_parents(dirname, 0777) == -1) {
- GtkWidget *w = e_error_new((GtkWindow *)parent, "mail:no-create-path", filename, g_strerror(errno), NULL);
+ GtkWidget *w = e_error_new(parent, "mail:no-create-path", filename, g_strerror(errno), NULL);
g_free(dirname);
em_utils_show_error_silent (w);
return FALSE;
@@ -576,13 +593,13 @@ em_utils_save_part_to_file(GtkWidget *parent, const char *filename, CamelMimePar
if (g_access(filename, F_OK) == 0) {
if (g_access(filename, W_OK) != 0) {
- e_error_run((GtkWindow *)parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, filename, NULL);
+ e_error_run(parent, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, filename, NULL);
return FALSE;
}
}
if (g_stat(filename, &st) != -1 && !S_ISREG(st.st_mode)) {
- GtkWidget *w = e_error_new((GtkWindow *)parent, "mail:no-write-path-notfile", filename, NULL);
+ GtkWidget *w = e_error_new(parent, "mail:no-write-path-notfile", filename, NULL);
em_utils_show_error_silent (w);
return FALSE;
}
@@ -635,13 +652,14 @@ emu_save_messages_response(GtkWidget *filesel, int response, struct _save_messag
* user for filename).
**/
void
-em_utils_save_messages (GtkWidget *parent, CamelFolder *folder, GPtrArray *uids)
+em_utils_save_messages (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids)
{
struct _save_messages_data *data;
GtkWidget *filesel;
char *filename = NULL;
CamelMessageInfo *info = NULL;
+ g_return_if_fail (GTK_IS_WINDOW (parent));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
@@ -681,7 +699,7 @@ emu_add_address_cb(BonoboListener *listener, const char *name, const CORBA_any *
/* one of email or vcard should be always NULL, never both of them */
static void
-emu_add_address_or_vcard (struct _GtkWidget *parent, const char *email, const char *vcard)
+emu_add_address_or_vcard (GtkWindow *parent, const char *email, const char *vcard)
{
GtkWidget *win;
GtkWidget *control;
@@ -704,14 +722,7 @@ emu_add_address_or_vcard (struct _GtkWidget *parent, const char *email, const ch
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title((GtkWindow *)win, _("Add address"));
- if (parent && !GTK_IS_WINDOW (parent)) {
- parent = gtk_widget_get_toplevel (parent);
- if (!parent || !(GTK_WIDGET_TOPLEVEL (parent)))
- parent = NULL;
- }
-
- if (parent)
- gtk_window_set_transient_for((GtkWindow *)win, ((GtkWindow *)parent));
+ gtk_window_set_transient_for((GtkWindow *)win, parent);
gtk_window_set_position((GtkWindow *)win, GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_type_hint((GtkWindow *)win, GDK_WINDOW_TYPE_HINT_DIALOG);
@@ -742,8 +753,10 @@ emu_add_address_or_vcard (struct _GtkWidget *parent, const char *email, const ch
* Add address @email to the addressbook.
**/
void
-em_utils_add_address (struct _GtkWidget *parent, const char *email)
+em_utils_add_address (GtkWindow *parent, const char *email)
{
+ g_return_if_fail (GTK_IS_WINDOW (parent));
+
emu_add_address_or_vcard (parent, email, NULL);
}
@@ -752,8 +765,10 @@ em_utils_add_address (struct _GtkWidget *parent, const char *email)
* Adds whole vCard to the addressbook.
**/
void
-em_utils_add_vcard (struct _GtkWidget *parent, const char *vcard)
+em_utils_add_vcard (GtkWindow *parent, const char *vcard)
{
+ g_return_if_fail (GTK_IS_WINDOW (parent));
+
emu_add_address_or_vcard (parent, NULL, vcard);
}
@@ -820,19 +835,18 @@ tag_editor_response (GtkWidget *dialog, int button, struct ted_t *ted)
* @folder and @uids.
**/
void
-em_utils_flag_for_followup (GtkWidget *parent, CamelFolder *folder, GPtrArray *uids)
+em_utils_flag_for_followup (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids)
{
GtkWidget *editor;
struct ted_t *ted;
int i;
+ g_return_if_fail (GTK_IS_WINDOW (parent));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
editor = (GtkWidget *) message_tag_followup_new ();
-
- if (parent != NULL)
- e_dialog_set_transient_for ((GtkWindow *) editor, parent);
+ gtk_window_set_transient_for (GTK_WINDOW (editor), parent);
camel_object_ref (folder);
@@ -884,10 +898,11 @@ em_utils_flag_for_followup (GtkWidget *parent, CamelFolder *folder, GPtrArray *u
* @folder and @uids.
**/
void
-em_utils_flag_for_followup_clear (GtkWidget *parent, CamelFolder *folder, GPtrArray *uids)
+em_utils_flag_for_followup_clear (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids)
{
int i;
+ g_return_if_fail (GTK_IS_WINDOW (parent));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
@@ -918,11 +933,12 @@ em_utils_flag_for_followup_clear (GtkWidget *parent, CamelFolder *folder, GPtrAr
* Flag-for-Followup.
**/
void
-em_utils_flag_for_followup_completed (GtkWidget *parent, CamelFolder *folder, GPtrArray *uids)
+em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GPtrArray *uids)
{
char *now;
int i;
+ g_return_if_fail (GTK_IS_WINDOW (parent));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
@@ -1378,19 +1394,23 @@ em_utils_temp_save_part(GtkWidget *parent, CamelMimePart *part, gboolean mode)
gboolean
em_utils_folder_is_templates (CamelFolder *folder, const char *uri)
{
+ CamelFolder *local_templates_folder;
EAccountList *accounts;
EAccount *account;
EIterator *iter;
int is = FALSE;
char *templates_uri;
- if (folder == mail_component_get_folder (NULL, MAIL_COMPONENT_FOLDER_TEMPLATES))
+ local_templates_folder = e_mail_shell_backend_get_folder (
+ global_mail_shell_backend, E_MAIL_FOLDER_TEMPLATES);
+
+ if (folder == local_templates_folder)
return TRUE;
- if (uri == NULL)
+ if (folder == NULL || uri == NULL)
return FALSE;
- accounts = mail_config_get_accounts();
+ accounts = e_get_account_list ();
iter = e_list_get_iterator ((EList *)accounts);
while (e_iterator_is_valid (iter)) {
account = (EAccount *)e_iterator_get (iter);
@@ -1425,19 +1445,23 @@ em_utils_folder_is_templates (CamelFolder *folder, const char *uri)
gboolean
em_utils_folder_is_drafts(CamelFolder *folder, const char *uri)
{
+ CamelFolder *local_drafts_folder;
EAccountList *accounts;
EAccount *account;
EIterator *iter;
int is = FALSE;
char *drafts_uri;
- if (folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_DRAFTS))
+ local_drafts_folder = e_mail_shell_backend_get_folder (
+ global_mail_shell_backend, E_MAIL_FOLDER_DRAFTS);
+
+ if (folder == local_drafts_folder)
return TRUE;
- if (uri == NULL)
+ if (folder == NULL || uri == NULL)
return FALSE;
- accounts = mail_config_get_accounts();
+ accounts = e_get_account_list ();
iter = e_list_get_iterator((EList *)accounts);
while (e_iterator_is_valid(iter)) {
account = (EAccount *)e_iterator_get(iter);
@@ -1472,19 +1496,23 @@ em_utils_folder_is_drafts(CamelFolder *folder, const char *uri)
gboolean
em_utils_folder_is_sent(CamelFolder *folder, const char *uri)
{
+ CamelFolder *local_sent_folder;
EAccountList *accounts;
EAccount *account;
EIterator *iter;
int is = FALSE;
char *sent_uri;
- if (folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_SENT))
+ local_sent_folder = e_mail_shell_backend_get_folder (
+ global_mail_shell_backend, E_MAIL_FOLDER_SENT);
+
+ if (folder == local_sent_folder)
return TRUE;
- if (uri == NULL)
+ if (folder == NULL || uri == NULL)
return FALSE;
- accounts = mail_config_get_accounts();
+ accounts = e_get_account_list ();
iter = e_list_get_iterator((EList *)accounts);
while (e_iterator_is_valid(iter)) {
account = (EAccount *)e_iterator_get(iter);
@@ -1519,8 +1547,13 @@ em_utils_folder_is_sent(CamelFolder *folder, const char *uri)
gboolean
em_utils_folder_is_outbox(CamelFolder *folder, const char *uri)
{
+ CamelFolder *local_outbox_folder;
+
+ local_outbox_folder = e_mail_shell_backend_get_folder (
+ global_mail_shell_backend, E_MAIL_FOLDER_OUTBOX);
+
/* <Highlander>There can be only one.</Highlander> */
- return folder == mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_OUTBOX);
+ return folder == local_outbox_folder;
}
/**
@@ -1595,53 +1628,6 @@ em_utils_get_proxy_uri (const char *pUri)
}
/**
- * em_utils_part_to_html:
- * @part:
- *
- * Converts a mime part's contents into html text. If @credits is given,
- * then it will be used as an attribution string, and the
- * content will be cited. Otherwise no citation or attribution
- * will be performed.
- *
- * Return Value: The part in displayable html format.
- **/
-char *
-em_utils_part_to_html(CamelMimePart *part, ssize_t *len, EMFormat *source)
-{
- EMFormatQuote *emfq;
- CamelStreamMem *mem;
- GByteArray *buf;
- char *text;
-
- buf = g_byte_array_new ();
- mem = (CamelStreamMem *) camel_stream_mem_new ();
- camel_stream_mem_set_byte_array (mem, buf);
-
- emfq = em_format_quote_new(NULL, (CamelStream *)mem, 0);
- ((EMFormat *) emfq)->composer = TRUE;
- em_format_set_session((EMFormat *)emfq, session);
- if (source) {
- /* copy over things we can, other things are internal, perhaps need different api than 'clone' */
- if (source->default_charset)
- em_format_set_default_charset((EMFormat *)emfq, source->default_charset);
- if (source->charset)
- em_format_set_default_charset((EMFormat *)emfq, source->charset);
- }
- em_format_part((EMFormat *) emfq, (CamelStream *)mem, part);
- g_object_unref(emfq);
-
- camel_stream_write((CamelStream *) mem, "", 1);
- camel_object_unref(mem);
-
- text = (char *)buf->data;
- if (len)
- *len = buf->len-1;
- g_byte_array_free (buf, FALSE);
-
- return text;
-}
-
-/**
* em_utils_message_to_html:
* @message:
* @credits:
@@ -1669,7 +1655,6 @@ em_utils_message_to_html(CamelMimeMessage *message, const char *credits, guint32
emfq = em_format_quote_new(credits, (CamelStream *)mem, flags);
((EMFormat *) emfq)->composer = TRUE;
- em_format_set_session((EMFormat *)emfq, session);
if (!source) {
GConfClient *gconf;
@@ -1743,7 +1728,7 @@ em_utils_empty_trash (GtkWidget *parent)
camel_exception_init (&ex);
/* expunge all remote stores */
- accounts = mail_config_get_accounts ();
+ accounts = e_get_account_list ();
iter = e_list_get_iterator ((EList *) accounts);
while (e_iterator_is_valid (iter)) {
account = (EAccount *) e_iterator_get (iter);
@@ -1912,7 +1897,7 @@ char *em_uri_to_camel(const char *euri)
uid = g_strdup(eurl->host);
}
- accounts = mail_config_get_accounts();
+ accounts = e_get_account_list ();
account = e_account_list_find(accounts, E_ACCOUNT_FIND_UID, uid);
g_free(uid);
@@ -2297,94 +2282,12 @@ em_utils_contact_photo (struct _CamelInternetAddress *cia, gboolean local)
return part;
}
-/**
- * em_utils_snoop_type:
- * @part:
- *
- * Tries to snoop the mime type of a part.
- *
- * Return value: NULL if unknown (more likely application/octet-stream).
- **/
-const char *
-em_utils_snoop_type(CamelMimePart *part)
-{
- /* cache is here only to be able still return const char * */
- static GHashTable *types_cache = NULL;
-
- const char *filename;
- char *name_type = NULL, *magic_type = NULL, *res, *tmp;
- CamelDataWrapper *dw;
-
- filename = camel_mime_part_get_filename (part);
- if (filename != NULL)
- name_type = e_util_guess_mime_type (filename, FALSE);
-
- dw = camel_medium_get_content_object((CamelMedium *)part);
- if (!camel_data_wrapper_is_offline(dw)) {
- CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new();
-
- if (camel_data_wrapper_decode_to_stream(dw, (CamelStream *)mem) > 0) {
- char *ct = g_content_type_guess (filename, mem->buffer->data, mem->buffer->len, NULL);
-
- if (ct)
- magic_type = g_content_type_get_mime_type (ct);
-
- g_free (ct);
- }
- camel_object_unref(mem);
- }
-
- d(printf("snooped part, magic_type '%s' name_type '%s'\n", magic_type, name_type));
-
- /* If gvfs doesn't recognize the data by magic, but it
- * contains English words, it will call it text/plain. If the
- * filename-based check came up with something different, use
- * that instead and if it returns "application/octet-stream"
- * try to do better with the filename check.
- */
-
- if (magic_type) {
- if (name_type
- && (!strcmp(magic_type, "text/plain")
- || !strcmp(magic_type, "application/octet-stream")))
- res = name_type;
- else
- res = magic_type;
- } else
- res = name_type;
-
-
- if (res != name_type)
- g_free (name_type);
-
- if (res != magic_type)
- g_free (magic_type);
-
- if (!types_cache)
- types_cache = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) NULL);
-
- if (res) {
- tmp = g_hash_table_lookup (types_cache, res);
- if (tmp) {
- g_free (res);
- res = tmp;
- } else {
- g_hash_table_insert (types_cache, res, res);
- }
- }
-
- return res;
-
- /* We used to load parts to check their type, we dont anymore,
- see bug #11778 for some discussion */
-}
-
void
em_utils_clear_get_password_canceled_accounts_flag (void)
{
EAccountList *accounts;
- accounts = mail_config_get_accounts ();
+ accounts = e_get_account_list ();
if (accounts) {
EIterator *iter;
@@ -2405,25 +2308,69 @@ em_utils_clear_get_password_canceled_accounts_flag (void)
}
-static void error_response(GtkObject *o, int button, void *data)
-{
- gtk_widget_destroy((GtkWidget *)o);
-}
-
void
em_utils_show_error_silent (GtkWidget *widget)
{
- EActivityHandler *handler = mail_component_peek_activity_handler (mail_component_peek ());
- if(!g_object_get_data ((GObject *) widget, "response-handled"))
- g_signal_connect(widget, "response", G_CALLBACK(error_response), NULL);
- e_activity_handler_make_error (handler, "mail", E_LOG_ERROR, widget);
+ EShellBackend *shell_backend;
+ EActivity *activity;
+
+ shell_backend = E_SHELL_BACKEND (global_mail_shell_backend);
+
+ activity = e_alert_activity_new_warning (widget);
+ e_shell_backend_add_activity (shell_backend, activity);
+ g_object_unref (activity);
+
+ if (g_object_get_data (G_OBJECT (widget), "response-handled") == NULL)
+ g_signal_connect (
+ widget, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
}
void
em_utils_show_info_silent (GtkWidget *widget)
{
- EActivityHandler *handler = mail_component_peek_activity_handler (mail_component_peek ());
- if(!g_object_get_data ((GObject *) widget, "response-handled"))
- g_signal_connect(widget, "response", G_CALLBACK(error_response), NULL);
- e_activity_handler_make_error (handler, "mail", E_LOG_WARNINGS, widget);
+ EShellBackend *shell_backend;
+ EActivity *activity;
+
+ shell_backend = E_SHELL_BACKEND (global_mail_shell_backend);
+
+ activity = e_alert_activity_new_info (widget);
+ e_shell_backend_add_activity (shell_backend, activity);
+ g_object_unref (activity);
+
+ if (g_object_get_data (G_OBJECT (widget), "response-handled") == NULL)
+ g_signal_connect (
+ widget, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+}
+
+gchar *
+em_utils_url_unescape_amp (const gchar *url)
+{
+ gchar *buff;
+ int i, j, amps;
+
+ if (!url)
+ return NULL;
+
+ amps = 0;
+ for (i = 0; url [i]; i++) {
+ if (url [i] == '&' && strncmp (url + i, "&amp;", 5) == 0)
+ amps++;
+ }
+
+ buff = g_strdup (url);
+
+ if (!amps)
+ return buff;
+
+ for (i = 0, j = 0; url [i]; i++, j++) {
+ buff [j] = url [i];
+
+ if (url [i] == '&' && strncmp (url + i, "&amp;", 5) == 0)
+ i += 4;
+ }
+ buff [j] = 0;
+
+ return buff;
}