aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog47
-rw-r--r--e-util/e-dialog-utils.c27
-rw-r--r--e-util/e-error.c27
-rw-r--r--e-util/e-event.c28
-rw-r--r--e-util/e-icon-factory.c28
-rw-r--r--e-util/e-logger.c17
-rw-r--r--e-util/e-plugin.c24
-rw-r--r--e-util/e-sorter-array.c31
-rw-r--r--e-util/e-util.c81
-rw-r--r--e-util/e-util.h33
-rw-r--r--e-util/e-xml-utils.c31
11 files changed, 220 insertions, 154 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 520505af3a..4c2e1d14d6 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,50 @@
+2008-10-01 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #554418
+
+ * e-util.h: (e_util_guess_mime_type):
+ * e-util.c: (e_util_guess_mime_type): Guess mime_type based on
+ the file content only when permitted by the caller, otherwise
+ check based on the filename only, where it fallbacks if file
+ content guess fails.
+
+2008-09-29 Sankar P <psankar@novell.com>
+
+License Changes
+
+ * e-util.c:
+ * e-util.h:
+ * e-xml-utils.c:
+
+2008-09-26 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #535248
+
+ * e-logger.c: (flush_logfile), (logger_set_component),
+ (logger_finalize), (e_logger_log), (e_logger_get_logs):
+ Check if log file has been opened successfully before using it.
+
+2008-09-24 Sankar P <psankar@novell.com>
+
+License Changes
+
+ * e-event.c:
+
+2008-09-16 Sankar P <psankar@novell.com>
+
+License Changes
+
+ * e-error.c:
+ * e-icon-factory.c:
+ * e-plugin.c:
+
+2008-09-12 Sankar P <psankar@novell.com>
+
+License Changes
+
+ * e-dialog-utils.c:
+ * e-sorter-array.c:
+
2008-09-04 Sankar P <psankar@novell.com>
License Changes
diff --git a/e-util/e-dialog-utils.c b/e-util/e-dialog-utils.c
index 2bb7bc7770..ecf9e7ec1e 100644
--- a/e-util/e-dialog-utils.c
+++ b/e-util/e-dialog-utils.c
@@ -1,25 +1,24 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-dialog-utils.h
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
+/*
* This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
*
* Authors:
- * Michael Meeks <michael@ximian.com>
- * Ettore Perazzoli <ettore@ximian.com>
+ * Michael Meeks <michael@ximian.com>
+ * Ettore Perazzoli <ettore@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
*/
#ifdef HAVE_CONFIG_H
diff --git a/e-util/e-error.c b/e-util/e-error.c
index 14d94dc240..763a9ca540 100644
--- a/e-util/e-error.c
+++ b/e-util/e-error.c
@@ -1,21 +1,22 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- *
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Authors: Michael Zucchi <notzed@ximian.com>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Authors:
+ * Michael Zucchi <notzed@ximian.com>
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
diff --git a/e-util/e-event.c b/e-util/e-event.c
index f8d634feec..73111229f9 100644
--- a/e-util/e-event.c
+++ b/e-util/e-event.c
@@ -1,22 +1,22 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Authors: Michael Zucchi <notzed@ximian.com>
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * Authors:
+ * Michael Zucchi <notzed@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c
index aa053001c5..d26717e9e0 100644
--- a/e-util/e-icon-factory.c
+++ b/e-util/e-icon-factory.c
@@ -1,22 +1,22 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
- * Authors: Jeffrey Stedfast <fejj@novell.com>
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * Authors:
+ * Jeffrey Stedfast <fejj@novell.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
diff --git a/e-util/e-logger.c b/e-util/e-logger.c
index 9e46daeeaf..88f3a24327 100644
--- a/e-util/e-logger.c
+++ b/e-util/e-logger.c
@@ -60,7 +60,8 @@ static gpointer parent_class;
static gboolean
logger_flush (ELogger *logger)
{
- fflush (logger->priv->fp);
+ if (logger->priv->fp)
+ fflush (logger->priv->fp);
logger->priv->timer = 0;
return FALSE;
@@ -91,6 +92,9 @@ logger_set_name (ELogger *logger,
logger->priv->fp = g_fopen (logger->priv->logfile, "w");
logger->priv->timer = 0;
+ if (!logger->priv->fp)
+ g_warning ("%s: Failed to open log file '%s' for writing.", G_STRFUNC, logger->priv->logfile ? logger->priv->logfile : "[null]");
+
g_free (temp);
}
@@ -136,7 +140,8 @@ logger_finalize (GObject *object)
if (logger->priv->timer)
g_source_remove (logger->priv->timer);
logger_flush (logger);
- fclose (logger->priv->fp);
+ if (logger->priv->fp)
+ fclose (logger->priv->fp);
g_free (logger->priv->name);
g_free (logger->priv->logfile);
@@ -230,6 +235,9 @@ e_logger_log (ELogger *logger,
g_return_if_fail (primary != NULL);
g_return_if_fail (secondary != NULL);
+ if (!logger->priv->fp)
+ return;
+
fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, primary);
fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, secondary);
logger_set_dirty (logger);
@@ -247,11 +255,12 @@ e_logger_get_logs (ELogger *logger,
g_return_if_fail (func != NULL);
/* Flush everything before we get the logs */
- fflush (logger->priv->fp);
+ if (logger->priv->fp)
+ fflush (logger->priv->fp);
fp = g_fopen (logger->priv->logfile, "r");
if (!fp) {
- fprintf (stderr, "Cannot open log file '%s' for reading! No flush yet?\n", logger->priv->logfile ? logger->priv->logfile : "[null]");
+ g_warning ("%s: Cannot open log file '%s' for reading! No flush yet?\n", G_STRFUNC, logger->priv->logfile ? logger->priv->logfile : "[null]");
return;
}
diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c
index 85c1edb060..93ec47f3b6 100644
--- a/e-util/e-plugin.c
+++ b/e-util/e-plugin.c
@@ -1,19 +1,19 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*/
#include <config.h>
diff --git a/e-util/e-sorter-array.c b/e-util/e-sorter-array.c
index 503df30ca6..582ed959ad 100644
--- a/e-util/e-sorter-array.c
+++ b/e-util/e-sorter-array.c
@@ -1,24 +1,23 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-sorter-array.c
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License, version 2, as published by the Free Software Foundation.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
*/
#include <config.h>
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 0c737d08a3..f13fc4c452 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1,24 +1,23 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-util.c
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License, version 2, as published by the Free Software Foundation.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
*/
#include <config.h>
@@ -1229,37 +1228,51 @@ e_file_lock_exists ()
/**
* e_util_guess_mime_type:
* @filename: it's a local file name, or URI.
+ * @localfile: set to TRUE if can check the local file content, FALSE to check only based on the filename itself.
* Returns: NULL or newly allocated string with a mime_type of the given file. Free with g_free.
*
- * Guesses mime_type for the given file_name.
+ * Guesses mime_type for the given filename.
**/
char *
-e_util_guess_mime_type (const char *filename)
+e_util_guess_mime_type (const char *filename, gboolean localfile)
{
- GFile *file;
- GFileInfo *fi;
- char *mime_type;
+ char *mime_type = NULL;
g_return_val_if_fail (filename != NULL, NULL);
- if (strstr (filename, "://"))
- file = g_file_new_for_uri (filename);
- else
- file = g_file_new_for_path (filename);
+ if (localfile) {
+ GFile *file;
- if (!file)
- return NULL;
+ if (strstr (filename, "://"))
+ file = g_file_new_for_uri (filename);
+ else
+ file = g_file_new_for_path (filename);
- fi = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
- if (!fi) {
- g_object_unref (file);
- return NULL;
+ if (file) {
+ GFileInfo *fi;
+
+ fi = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ if (fi) {
+ mime_type = g_content_type_get_mime_type (g_file_info_get_content_type (fi));
+
+ g_object_unref (fi);
+ }
+
+ g_object_unref (file);
+ }
}
- mime_type = g_content_type_get_mime_type (g_file_info_get_content_type (fi));
+ if (!mime_type) {
+ /* file doesn't exists locally, thus guess based on the filename */
+ gboolean uncertain = FALSE;
+ gchar *content_type;
- g_object_unref (fi);
- g_object_unref (file);
+ content_type = g_content_type_guess (filename, NULL, 0, &uncertain);
+ if (content_type) {
+ mime_type = g_content_type_get_mime_type (content_type);
+ g_free (content_type);
+ }
+ }
return mime_type;
}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 63cdafe058..e9750176eb 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -1,24 +1,23 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-util.h
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License, version 2, as published by the Free Software Foundation.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
*/
#ifndef _E_UTIL_H_
@@ -121,7 +120,7 @@ gboolean e_file_lock_create (void);
void e_file_lock_destroy (void);
gboolean e_file_lock_exists (void);
-gchar * e_util_guess_mime_type (const gchar *filename);
+gchar * e_util_guess_mime_type (const gchar *filename, gboolean localfile);
gchar * e_util_filename_to_uri (const gchar *filename);
gchar * e_util_uri_to_filename (const gchar *uri);
diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c
index f0f5e83c86..653669b381 100644
--- a/e-util/e-xml-utils.c
+++ b/e-util/e-xml-utils.c
@@ -1,24 +1,23 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * e-xml-utils.c
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
*
- * Authors:
- * Chris Lahey <clahey@ximian.com>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License, version 2, as published by the Free Software Foundation.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
*
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
+ * Authors:
+ * Chris Lahey <clahey@ximian.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
*/
#include <config.h>