aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-12-18 12:33:29 +0800
committerTor Lillqvist <tml@src.gnome.org>2005-12-18 12:33:29 +0800
commite89c27826741334b35d8952c769f66d11eaedce8 (patch)
treee64b437a818686edcb8457691ea369f4f7719e0b
parentf3e001990b61a336c1f30c5bae8065c15e320aec (diff)
downloadgsoc2013-evolution-e89c27826741334b35d8952c769f66d11eaedce8.tar.gz
gsoc2013-evolution-e89c27826741334b35d8952c769f66d11eaedce8.tar.zst
gsoc2013-evolution-e89c27826741334b35d8952c769f66d11eaedce8.zip
Use libedataserver's e_xml_parse_file() instead of xmlParseFile()
2005-12-17 Tor Lillqvist <tml@novell.com> * e-config-upgrade.c: Use libedataserver's e_xml_parse_file() instead of xmlParseFile() directly. * e-shell.c * e-shell-importer.c: Use GLib API when applicable. * e-shell-importer.c * e-shell-window.c: Construct pathname of glade file at run-time. * e-shell-window-commands.c: Include e-util-private.h for Win32 redefinition of EVOLUTION_DATADIR. * main.c: No SIGSEGV handling on Win32. (main): Drop unused evolution_directory variable. svn path=/trunk/; revision=30849
-rw-r--r--shell/ChangeLog17
-rw-r--r--shell/e-config-upgrade.c14
-rw-r--r--shell/e-shell-importer.c33
-rw-r--r--shell/e-shell-window-commands.c31
-rw-r--r--shell/e-shell-window.c5
-rw-r--r--shell/e-shell.c96
-rw-r--r--shell/main.c28
7 files changed, 128 insertions, 96 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index bee390c3a1..c89628c529 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,20 @@
+2005-12-17 Tor Lillqvist <tml@novell.com>
+
+ * e-config-upgrade.c: Use libedataserver's e_xml_parse_file()
+ instead of xmlParseFile() directly.
+
+ * e-shell.c
+ * e-shell-importer.c: Use GLib API when applicable.
+
+ * e-shell-importer.c
+ * e-shell-window.c: Construct pathname of glade file at run-time.
+
+ * e-shell-window-commands.c: Include e-util-private.h for Win32
+ redefinition of EVOLUTION_DATADIR.
+
+ * main.c: No SIGSEGV handling on Win32.
+ (main): Drop unused evolution_directory variable.
+
2005-12-12 David Malcolm <dmalcolm@redhat.com>
* e-shell-window.c (setup_widgets): escape the string when generating
diff --git a/shell/e-config-upgrade.c b/shell/e-config-upgrade.c
index 8fb6674a3a..d71f12ad09 100644
--- a/shell/e-config-upgrade.c
+++ b/shell/e-config-upgrade.c
@@ -22,17 +22,22 @@
*
*/
+#include <config.h>
+
#include <sys/types.h>
#include <sys/stat.h>
-
#include <stdio.h>
#include <ctype.h>
#include <glib.h>
+
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
+#include <libedataserver/e-xml-utils.h>
+
#include "e-util/e-bconf-map.h"
+
#include "e-config-upgrade.h"
/* ********************************************************************** */
@@ -129,15 +134,12 @@ e_gconf_map_list_t remap_list[] = {
int
e_config_upgrade(int major, int minor, int revision)
{
- xmlDocPtr config_doc = NULL;
+ xmlDocPtr config_doc;
char *conf_file;
- struct stat st;
int res = 0;
-
conf_file = g_build_filename (g_get_home_dir (), "evolution", "config.xmldb", NULL);
- if (lstat (conf_file, &st) == 0 && S_ISREG (st.st_mode))
- config_doc = xmlParseFile (conf_file);
+ config_doc = e_xml_parse_file (conf_file);
g_free (conf_file);
if (config_doc && major <=1 && minor < 3) {
diff --git a/shell/e-shell-importer.c b/shell/e-shell-importer.c
index 39216cb5b9..f38a74e175 100644
--- a/shell/e-shell-importer.c
+++ b/shell/e-shell-importer.c
@@ -20,37 +20,39 @@
* Author: Iain Holmes <iain@ximian.com>
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-
#include <string.h>
#include <glib.h>
+
#include <gdk/gdkkeysyms.h>
+
+#include <glade/glade.h>
+
#include <libgnome/gnome-i18n.h>
+
#include <libgnomeui/gnome-druid.h>
#include <libgnomeui/gnome-druid-page-edge.h>
#include <libgnomeui/gnome-druid-page-standard.h>
#include <libgnomeui/gnome-file-entry.h>
+#include "misc/e-gui-utils.h"
+
+#include "e-util/e-dialog-utils.h"
+#include "e-util/e-error.h"
+#include "e-util/e-gtk-utils.h"
+#include "e-util/e-icon-factory.h"
+#include "e-util/e-import.h"
+#include "e-util/e-util-private.h"
+
#include "e-shell.h"
#include "e-shell-window.h"
#include "e-shell-constants.h"
-#include <glade/glade.h>
-#include <misc/e-gui-utils.h>
-
-#include <e-util/e-gtk-utils.h>
-#include <e-util/e-dialog-utils.h>
-#include <e-util/e-icon-factory.h>
-#include <e-util/e-import.h>
-#include <e-util/e-error.h>
-
#include "e-shell-importer.h"
typedef struct _ImportDialogFilePage {
@@ -193,7 +195,7 @@ filename_changed (GtkEntry *entry,
int i=0, firstitem=0;
g_free(page->target->uri_src);
- page->target->uri_src = g_strdup_printf("file://%s", filename);
+ page->target->uri_src = g_filename_to_uri(filename, NULL, NULL);
l = e_import_get_importers(data->import, (EImportTarget *)page->target);
item = page->items;
@@ -667,6 +669,7 @@ e_shell_importer_start_import (EShellWindow *shell_window)
GtkWidget *html;
static gboolean dialog_open = FALSE;
GdkPixbuf *icon;
+ char *gladefile;
if (dialog_open) {
return;
@@ -680,7 +683,9 @@ e_shell_importer_start_import (EShellWindow *shell_window)
data->window = shell_window;
data->shell = e_shell_window_peek_shell (data->window);
- data->wizard = glade_xml_new (EVOLUTION_GLADEDIR "/import.glade", NULL, NULL);
+ gladefile = g_build_filename (EVOLUTION_GLADEDIR, "import.glade", NULL);
+ data->wizard = glade_xml_new (gladefile, NULL, NULL);
+ g_free (gladefile);
data->dialog = glade_xml_get_widget (data->wizard, "importwizard");
gtk_window_set_default_size (GTK_WINDOW (data->dialog), 480, 320);
gtk_window_set_wmclass (GTK_WINDOW (data->dialog), "importdruid",
diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c
index 51619a09aa..fc6b482b72 100644
--- a/shell/e-shell-window-commands.c
+++ b/shell/e-shell-window-commands.c
@@ -20,26 +20,16 @@
* Author: Ettore Perazzoli <ettore@ximian.com>
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
-#include "e-shell-window-commands.h"
-
-#include "e-shell-importer.h"
-#include "e-shell-window.h"
-
-#include "evolution-shell-component-utils.h"
-#include "e-util/e-icon-factory.h"
-#include "e-util/e-dialog-utils.h"
-#include "e-util/e-error.h"
+#include <string.h>
#include <glib/gprintf.h>
#include <libgnome/gnome-exec.h>
-#include <libgnome/gnome-url.h>
#include <libgnome/gnome-i18n.h>
+#include <libgnome/gnome-url.h>
+
#include <libgnomeui/gnome-about.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
@@ -51,7 +41,17 @@
#include <libedataserverui/e-passwords.h>
#include <gconf/gconf-client.h>
-#include <string.h>
+
+#include "e-util/e-icon-factory.h"
+#include "e-util/e-dialog-utils.h"
+#include "e-util/e-error.h"
+#include "e-util/e-util-private.h"
+
+#include "e-shell-window-commands.h"
+#include "e-shell-window.h"
+#include "evolution-shell-component-utils.h"
+
+#include "e-shell-importer.h"
/* Utility functions. */
@@ -577,6 +577,8 @@ command_about_box (BonoboUIComponent *uih,
gtk_widget_show (about_box_window);
}
+#if 0
+/* Unused */
static void
command_help_faq (BonoboUIComponent *uih,
EShellWindow *window,
@@ -586,6 +588,7 @@ command_help_faq (BonoboUIComponent *uih,
/* FIXME use the error */
gnome_url_show ("http://gnome.org/projects/evolution/faq.shtml", NULL);
}
+#endif
static void
command_quick_reference (BonoboUIComponent *uih,
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 9bfc225fa6..0fd5fe3dca 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -866,6 +866,7 @@ e_shell_window_new (EShell *shell,
GConfClient *gconf_client = gconf_client_get_default ();
BonoboUIContainer *ui_container;
char *default_component_id = NULL;
+ char *xmlfile;
if (bonobo_window_construct (BONOBO_WINDOW (window),
bonobo_ui_container_new (),
@@ -888,10 +889,12 @@ e_shell_window_new (EShell *shell,
bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)),
NULL);
+ xmlfile = g_build_filename (EVOLUTION_UIDIR, "evolution.xml", NULL);
bonobo_ui_util_set_ui (priv->ui_component,
PREFIX,
- EVOLUTION_UIDIR "/evolution.xml",
+ xmlfile,
"evolution-" BASE_VERSION, NULL);
+ g_free (xmlfile);
e_shell_window_commands_setup (window);
e_menu_activate((EMenu *)priv->menu, priv->ui_component, TRUE);
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 125cd3848e..99277b1cf6 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -20,57 +20,56 @@
* Author: Ettore Perazzoli
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
+#include <string.h>
#include <sys/types.h>
-#include <dirent.h>
-
-#include "e-shell.h"
-
-#include "e-util/e-dialog-utils.h"
-#include "e-util/e-bconf-map.h"
-#include "e-util/e-fsutils.h"
-#include "e-util/e-error.h"
-
-#include "e-shell-constants.h"
-#include "e-shell-settings-dialog.h"
-
-#include "e-shell-marshal.h"
-#include "es-event.h"
-
-#include "evolution-shell-component-utils.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
-#include <gdk/gdkx.h>
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#elif defined (GDK_WINDOWING_WIN32)
+/* gdkwin32.h includes <windows.h> which stomps over the namespace */
+#undef DATADIR
+#define interface windows_interface
+#include <gdk/gdkwin32.h>
+#undef interface
+#endif
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
-/* (For the displayName stuff.) */
-#include <gdk/gdkprivate.h>
-#include <X11/Xlib.h>
+#include <gconf/gconf-client.h>
#include <bonobo-activation/bonobo-activation.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
+#include <libedataserver/e-xml-utils.h>
#include <libedataserverui/e-passwords.h>
-#include <e-util/e-util.h>
-
-#include <gconf/gconf-client.h>
-
-#include <string.h>
+#include "e-util/e-bconf-map.h"
+#include "e-util/e-dialog-utils.h"
+#include "e-util/e-error.h"
+#include "e-util/e-fsutils.h"
+#include "e-util/e-util.h"
#include "Evolution.h"
+#include "e-shell-constants.h"
+#include "e-shell-marshal.h"
+#include "e-shell-settings-dialog.h"
+#include "e-shell.h"
+#include "es-event.h"
#include "evolution-listener.h"
+#include "evolution-shell-component-utils.h"
static void set_line_status_complete(EvolutionListener *el, void *data);
@@ -182,7 +181,13 @@ set_interactive (EShell *shell,
CORBA_exception_init (&ev);
+#ifdef GDK_WINDOWING_X11
GNOME_Evolution_Component_interactive (info->iface, interactive,GPOINTER_TO_INT (GDK_WINDOW_XWINDOW (view->window)), &ev);
+#elif defined (GDK_WINDOWING_WIN32)
+ GNOME_Evolution_Component_interactive (info->iface, interactive,GPOINTER_TO_INT (GDK_WINDOW_HWND (view->window)), &ev);
+#else
+#error Port this to your windowing system
+#endif
/* Ignore errors, the components can decide to not implement
this interface. */
@@ -544,23 +549,21 @@ detect_version (GConfClient *gconf, int *major, int *minor, int *revision)
/* Since 1.4.0 We've been keeping the version key in gconf */
sscanf(val, "%u.%u.%u", major, minor, revision);
g_free(val);
- } else if (lstat (evolution_dir, &st) != 0 || !S_ISDIR (st.st_mode)) {
+ } else if (g_lstat (evolution_dir, &st) != 0 || !S_ISDIR (st.st_mode)) {
/* If ~/evolution does not exit or is not a directory it must be a new installation */
*major = 0;
*minor = 0;
*revision = 0;
} else {
- xmlDocPtr config_doc = NULL;
+ xmlDocPtr config_doc;
xmlNodePtr source;
char *tmp;
tmp = g_build_filename (evolution_dir, "config.xmldb", NULL);
- if (lstat(tmp, &st) == 0
- && S_ISREG(st.st_mode))
- config_doc = xmlParseFile (tmp);
+ config_doc = e_xml_parse_file (tmp);
g_free (tmp);
-
tmp = NULL;
+
if (config_doc
&& (source = e_bconf_get_path (config_doc, "/Shell"))
&& (tmp = e_bconf_get_value (source, "upgrade_from_1_0_to_1_2_performed"))
@@ -573,8 +576,7 @@ detect_version (GConfClient *gconf, int *major, int *minor, int *revision)
*minor = 0;
*revision = 0;
}
- if (tmp)
- xmlFree(tmp);
+ g_free (tmp);
if (config_doc)
xmlFreeDoc (config_doc);
}
@@ -739,23 +741,19 @@ e_shell_new (EShellStartupLineMode startup_line_mode,
static int
remove_dir(const char *root, const char *path)
{
- DIR *dir;
- struct dirent *d;
+ GDir *dir;
+ const char *dname;
int res = -1;
char *new = NULL;
struct stat st;
- dir = opendir(path);
+ dir = g_dir_open(path, 0, NULL);
if (dir == NULL)
return -1;
- while ( (d = readdir(dir)) ) {
- if (!strcmp(d->d_name, ".")
- || !strcmp(d->d_name, ".."))
- continue;
-
- new = g_build_filename(path, d->d_name, NULL);
- if (stat(new, &st) == -1)
+ while ( (dname = g_dir_read_name(dir)) ) {
+ new = g_build_filename(path, dname, NULL);
+ if (g_stat(new, &st) == -1)
goto fail;
/* make sure we're really removing something from evolution dir */
@@ -766,17 +764,17 @@ remove_dir(const char *root, const char *path)
if (remove_dir(root, new) == -1)
goto fail;
} else {
- if (unlink(new) == -1)
+ if (g_unlink(new) == -1)
goto fail;
}
g_free(new);
new = NULL;
}
- res = rmdir(path);
+ res = g_rmdir(path);
fail:
g_free(new);
- closedir(dir);
+ g_dir_close(dir);
return res;
}
@@ -852,7 +850,7 @@ check_old:
g_free(last_version);
if (lmajor == 1 && lminor < 5
- && stat(oldpath, &st) == 0
+ && g_stat(oldpath, &st) == 0
&& S_ISDIR(st.st_mode)) {
int res;
diff --git a/shell/main.c b/shell/main.c
index 0117a626f5..5b3968237d 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -20,9 +20,10 @@
* Author: Ettore Perazzoli
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
+
+#include <glib.h>
+#include <glib/gstdio.h>
#include "e-util/e-dialog-utils.h"
#include "e-util/e-gtk-utils.h"
@@ -36,6 +37,8 @@
#include "es-menu.h"
#include "es-event.h"
+#include "e-util/e-util-private.h"
+
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
@@ -52,9 +55,6 @@
#include <gtk/gtkdialog.h>
#include <gtk/gtkstock.h>
-#include <gdk/gdkx.h>
-#include <X11/Xlib.h>
-
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-sound.h>
@@ -406,6 +406,7 @@ idle_cb (void *data)
return FALSE;
}
+#ifndef G_OS_WIN32
/* SIGSEGV handling.
@@ -458,6 +459,10 @@ setup_segv_redirect (void)
g_static_mutex_lock (&segv_mutex);
}
+#else
+#define setup_segv_redirect() 0
+#endif
+
int
main (int argc, char **argv)
{
@@ -493,8 +498,8 @@ main (int argc, char **argv)
GnomeProgram *program;
poptContext popt_context;
const char **args;
- char *evolution_directory;
GList *icon_list;
+ char *filename;
/* Make ElectricFence work. */
free (malloc (10));
@@ -516,7 +521,10 @@ main (int argc, char **argv)
}
if (killev) {
- execl (EVOLUTION_TOOLSDIR "/killev", "killev", NULL);
+ filename = g_build_filename (EVOLUTION_TOOLSDIR,
+ "killev",
+ NULL);
+ execl (filename, "killev", NULL);
/* Not reached */
exit (0);
}
@@ -532,7 +540,7 @@ main (int argc, char **argv)
if (evolution_debug_log) {
int fd;
- fd = open (evolution_debug_log, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ fd = g_open (evolution_debug_log, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd) {
dup2 (fd, STDOUT_FILENO);
dup2 (fd, STDERR_FILENO);
@@ -553,13 +561,9 @@ main (int argc, char **argv)
g_list_free (icon_list);
}
- /* FIXME We shouldn't be using the old directory at all I think */
- evolution_directory = g_build_filename (g_get_home_dir (), "evolution", NULL);
if (setup_only)
exit (0);
- g_free (evolution_directory);
-
uri_list = NULL;
g_value_init (&popt_context_value, G_TYPE_POINTER);