diff options
author | J Shane Culpepper <pepper@src.gnome.org> | 2000-07-07 20:15:11 +0000 |
---|---|---|
committer | J Shane Culpepper <pepper@src.gnome.org> | 2000-07-07 20:15:11 +0000 |
commit | d0b167313bec7479357b52197a3193ac4c8bc4a3 (patch) | |
tree | ab3037bbcc0646b4bc2795f81f35cefba6e8ca89 | |
parent | c717f714b4c293e19ac06ae0a46ba2b1eb5b04d7 (diff) | |
download | nautilus-d0b167313bec7479357b52197a3193ac4c8bc4a3.tar.gz |
Adding eazel install view skeleton
20 files changed, 1551 insertions, 27 deletions
@@ -1,3 +1,43 @@ +2000-07-07 J Shane Culpepper <pepper@eazel.com> + + * components/services/install/Makefile.am: + * components/services/install/nautilus-view/.cvsignore: + * components/services/install/nautilus-view/Makefile.am: + * components/services/install/nautilus-view/main.c: + (service_install_object_destroyed), (service_install_make_object), + (main): + * + components/services/install/nautilus-view/nautilus-service-install- + view.c: (generate_install_form), (generate_form_title), + (nautilus_service_install_view_initialize_class), + (nautilus_service_install_view_initialize), + (nautilus_service_install_view_destroy), + (nautilus_service_install_view_get_nautilus_view), + (nautilus_service_install_view_load_uri), + (service_install_load_location_callback): + * + components/services/install/nautilus-view/nautilus-service-install- + view.h: + * + components/services/install/nautilus-view/nautilus-service-install- + view.oafinfo: + * + components/services/install/nautilus-view/nautilus-service-install. + c: (nautilus_service_install_download_progress_signal), + (nautilus_service_install_progress_signal), + (nautilus_service_install_download_failed), + (nautilus_service_install_failed_helper), + (nautilus_service_install_failed), + (nautilus_service_install_dependency_check), + (nautilus_service_install_done), + (nautilus_service_install_view_install_package_callback), + (nautilus_service_install_view_uninstall_package_callback): + * + components/services/install/nautilus-view/nautilus-service-install. + h: + + Adding the skeleton for the eazel install view. + 2000-07-07 Darin Adler <darin@eazel.com> * components/hardware/nautilus-hardware-view.oafinfo: diff --git a/components/services/install-view/.cvsignore b/components/services/install-view/.cvsignore index 282522db0..06988e9f5 100644 --- a/components/services/install-view/.cvsignore +++ b/components/services/install-view/.cvsignore @@ -1,2 +1,5 @@ Makefile Makefile.in +.deps +.libs +nautilus-service-install-view diff --git a/components/services/install-view/Makefile.am b/components/services/install-view/Makefile.am index f25cea199..1b83aafdd 100644 --- a/components/services/install-view/Makefile.am +++ b/components/services/install-view/Makefile.am @@ -1,18 +1,52 @@ NULL = -CPPFLAGS = \ - -DPREFIX=\"$(prefix)\" \ - -DG_LOG_DOMAIN=\"Nautilus-Services\" - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(GCONF_CFLAGS) \ - $(GNOMEUI_CFLAGS) \ - $(OAF_CFLAGS) \ - $(XML_CFLAGS) \ - $(WERROR) \ +CPPFLAGS = \ + -DPREFIX=\"$(prefix)\" \ + -DG_LOG_DOMAIN=\"Nautilus-service-install\" + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/components/services/install/lib \ + -I$(top_srcdir)/components/services/trilobite \ + -I$(top_builddir) \ + -I/usr/include/rpm \ + $(GCONF_CFLAGS) \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + $(GNOMEUI_CFLAGS) \ + $(VFS_CFLAGS) \ + $(WERROR) \ + $(NULL) + +oafdir = $(datadir)/oaf + +oaf_DATA = nautilus-service-install-view.oafinfo + +bin_PROGRAMS = nautilus-service-install-view + +nautilus_service_install_view_SOURCES = \ + nautilus-service-install-view.h \ + nautilus-service-install-view.c \ + main.c \ + $(NULL) + +nautilus_service_install_view_LDADD = \ + $(RPM_LIBS) \ $(NULL) -gnorbadir = $(sysconfdir)/CORBA/servers +nautilus_service_install_view_LDFLAGS = \ + $(top_builddir)/libnautilus/libnautilus.la \ + $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ + $(top_builddir)/cut-n-paste-code/widgets/e-paned/libe-paned.la \ + $(top_builddir)/librsvg/librsvg.la \ + $(top_builddir)/components/services/install/lib/libeazelinstall.la \ + $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ + $(BONOBO_LIBS) \ + $(GCONF_LIBS) \ + $(GNOMEUI_LIBS) \ + $(OAF_LIBS) \ + $(VFS_LIBS) \ + $(RPM_LIBS) \ + $(NULL) + +EXTRA_DIST = $(oaf_DATA) diff --git a/components/services/install-view/Nautilus_View_install.oaf.in b/components/services/install-view/Nautilus_View_install.oaf.in new file mode 100644 index 000000000..0edc7fd8f --- /dev/null +++ b/components/services/install-view/Nautilus_View_install.oaf.in @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:nautilus_service_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32" type="exe" location="nautilus-service-install-view"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:GNOME/GenericFactory:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View Factory"/> +<oaf_attribute name="description" type="string" value="Service Install View Component's Factory"/> +</oaf_server> + +<oaf_server iid="OAFIID:nautilus_service_install_view:886546ca-1115-4ea4-8d30-8cefa2f5070b" type="factory" location="OAFIID:nautilus_sevice_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:Bonobo/Control:1.0"/> +<item value="IDL:Bonobo/Unknown:1.0"/> +<item value="IDL:Nautilus/ContentView:1.0"/> +<item value="IDL:Nautilus/View:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View"/> +<oaf_attribute name="description" type="string" value="Service Install View Component"/> +<oaf_attribute name="bonobo:additional_uri_schemes" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="bonobo:supported_mime_types" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="nautilus:view_as_name" type="string" value="Install"/> +</oaf_server> + +</oaf_info> diff --git a/components/services/install-view/main.c b/components/services/install-view/main.c new file mode 100644 index 000000000..c703d5c32 --- /dev/null +++ b/components/services/install-view/main.c @@ -0,0 +1,91 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Maciej Stachowiak <mjs@eazel.com> + * J Shane Culpepper <pepper@eazel.com> + */ + +/* main.c - main function and object activation function for services + content view component. */ + +#include <config.h> +#include <gnome.h> +#include <liboaf/liboaf.h> +#include <bonobo.h> +#include "nautilus-service-install-view.h" + +static int object_count =0; + +static void +service_install_object_destroyed (GtkObject *obj) { + object_count--; + if (object_count <= 0) { + gtk_main_quit (); + } +} + +static BonoboObject* +service_install_make_object (BonoboGenericFactory *factory, + const char *iid, + void *closure) { + + NautilusServiceInstallView *view; + NautilusView *nautilus_view; + + if (strcmp (iid, "OAFIID:nautilus_service_install_view:886546ca-1115-4ea4-8d30-8cefa2f5070b")) { + return NULL; + } + + view = NAUTILUS_SERVICE_INSTALL_VIEW (gtk_object_new (NAUTILUS_TYPE_SERVICE_INSTALL_VIEW, NULL)); + + object_count++; + + gtk_signal_connect (GTK_OBJECT (view), "destroy", service_install_object_destroyed, NULL); + + nautilus_view = nautilus_service_install_view_get_nautilus_view (view); + + printf ("Returning new object %p\n", nautilus_view); + + return BONOBO_OBJECT (nautilus_view); +} + +int +main (int argc, char *argv[]) { + + BonoboGenericFactory *factory; + CORBA_ORB orb; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + gnome_init_with_popt_table ("nautilus-service-install-view", VERSION, + argc, argv, + oaf_popt_options, 0, NULL); + + orb = oaf_init (argc, argv); + + bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); + factory = bonobo_generic_factory_new_multi ("OAFIID:nautilus_service_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32", service_install_make_object, NULL); + + do { + bonobo_main (); + } while (object_count > 0); + + return 0; +} diff --git a/components/services/install-view/nautilus-service-install-view.c b/components/services/install-view/nautilus-service-install-view.c new file mode 100644 index 000000000..ad0278d6e --- /dev/null +++ b/components/services/install-view/nautilus-service-install-view.c @@ -0,0 +1,201 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: J Shane Culpepper <pepper@eazel.com> + */ + +#include <config.h> + +#include <gnome-xml/tree.h> +#include <libgnomevfs/gnome-vfs-utils.h> +#include <libnautilus-extensions/nautilus-background.h> +#include <libnautilus-extensions/nautilus-gtk-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-glib-extensions.h> +#include <libnautilus-extensions/nautilus-global-preferences.h> +#include <libnautilus-extensions/nautilus-file-utilities.h> +#include <libnautilus-extensions/nautilus-string.h> +#include <libnautilus-extensions/nautilus-font-factory.h> +#include <stdio.h> +#include <unistd.h> + +#include "nautilus-service-install-view.h" + + + +/* A NautilusContentView's private information. */ +struct _NautilusServiceInstallViewDetails { + char *uri; + NautilusView *nautilus_view; + GtkWidget *form; + GtkWidget *form_title; + GtkWidget *feedback_text; +}; + +#define SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF" +#define SERVICE_DOMAIN_NAME "testmachine.eazel.com" + +static void nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass); +static void nautilus_service_install_view_initialize (NautilusServiceInstallView *view); +static void nautilus_service_install_view_destroy (GtkObject *object); +static void service_install_load_location_callback (NautilusView *nautilus_view, + const char *location, + NautilusServiceInstallView *view); +static void generate_install_form (NautilusServiceInstallView *view); +static void generate_form_title (NautilusServiceInstallView *view, + const char *title_text); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusServiceInstallView, nautilus_service_install_view, GTK_TYPE_EVENT_BOX) + +static void +generate_install_form (NautilusServiceInstallView *view) { + + GtkWidget *temp_widget; + + /* allocate the parent box to hold everything */ + view->details->form = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (view), view->details->form); + gtk_widget_show (view->details->form); + + /* setup the title */ + generate_form_title (view, "Easy Install"); + + /* put a mystery label here as a placeholder. */ + temp_widget = gtk_label_new ("I am just a view. One day I will be gone."); + gtk_box_pack_start (GTK_BOX (view->details->form), temp_widget, 0, 0, 0); + gtk_widget_show (temp_widget); + +} + +static void +generate_form_title (NautilusServiceInstallView *view, + const char *title_text) { + + GtkWidget *temp_widget; + char *file_name; + GtkWidget *temp_container; + GdkFont *font; + + temp_container = gtk_hbox_new (FALSE, 0); + + gtk_box_pack_start (GTK_BOX (view->details->form), temp_container, 0, 0, 4); + gtk_widget_show (temp_container); + + file_name = nautilus_pixmap_file ("eazel-cloud-logo.png"); + temp_widget = GTK_WIDGET (gnome_pixmap_new_from_file (file_name)); + gtk_box_pack_start (GTK_BOX(temp_container), temp_widget, 0, 0, 8); + gtk_widget_show (temp_widget); + g_free (file_name); + + view->details->form_title = gtk_label_new (title_text); + + font = nautilus_font_factory_get_font_from_preferences (18); + nautilus_gtk_widget_set_font (view->details->form_title, font); + gdk_font_unref (font); + + gtk_box_pack_start (GTK_BOX (temp_container), view->details->form_title, 0, 0, 8); + gtk_widget_show (view->details->form_title); +} + +static void +nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass) { + + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + object_class = GTK_OBJECT_CLASS (klass); + widget_class = GTK_WIDGET_CLASS (klass); + parent_class = gtk_type_class (gtk_event_box_get_type ()); + object_class->destroy = nautilus_service_install_view_destroy; +} + +static void +nautilus_service_install_view_initialize (NautilusServiceInstallView *view) { + + NautilusBackground *background; + + view->details = g_new0 (NautilusServiceInstallViewDetails, 1); + view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view)); + gtk_signal_connect (GTK_OBJECT (view->details->nautilus_view), + "load_location", + GTK_SIGNAL_FUNC (service_install_load_location_callback), + view); + + background = nautilus_get_widget_background (GTK_WIDGET (view)); + nautilus_background_set_color (background, SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR); + + gtk_widget_show (GTK_WIDGET (view)); +} + +static void +nautilus_service_install_view_destroy (GtkObject *object) { + + NautilusServiceInstallView *view; + + view = NAUTILUS_SERVICE_INSTALL_VIEW (object); + + if (view->details->uri) { + g_free (view->details->uri); + } + g_free (view->details); + + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); + +} + +NautilusView * +nautilus_service_install_view_get_nautilus_view (NautilusServiceInstallView *view) { + + return view->details->nautilus_view; + +} + +void +nautilus_service_install_view_load_uri (NautilusServiceInstallView *view, + const char *uri) { + + /* dispose of any old uri and copy in the new one */ + g_free (view->details->uri); + view->details->uri = g_strdup (uri); + + /* dispose of any old form that was installed */ + if (view->details->form != NULL) { + gtk_widget_destroy (view->details->form); + view->details->form = NULL; + } + + generate_install_form (view); +} + +static void +service_install_load_location_callback (NautilusView *nautilus_view, + const char *location, + NautilusServiceInstallView *view) { + + g_assert (nautilus_view == view->details->nautilus_view); + + nautilus_view_report_load_underway (nautilus_view); + + nautilus_service_install_view_load_uri (view, location); + + nautilus_view_report_load_complete (nautilus_view); + +} + diff --git a/components/services/install-view/nautilus-service-install-view.h b/components/services/install-view/nautilus-service-install-view.h new file mode 100644 index 000000000..87ff67a6b --- /dev/null +++ b/components/services/install-view/nautilus-service-install-view.h @@ -0,0 +1,60 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: J Shane Culpepper + */ + +#ifndef NAUTILUS_SERVICE_INSTALL_VIEW_H +#define NAUTILUS_SERVICE_INSTALL_VIEW_H + +#include <libnautilus/nautilus-view.h> +#include <gtk/gtk.h> + +typedef struct _NautilusServiceInstallView NautilusServiceInstallView; +typedef struct _NautilusServiceInstallViewClass NautilusServiceInstallViewClass; + +#define NAUTILUS_TYPE_SERVICE_INSTALL_VIEW (nautilus_service_install_view_get_type ()) +#define NAUTILUS_SERVICE_INSTALL_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW, NautilusServiceInstallView)) +#define NAUTILUS_SERVICE_INSTALL_VIEW_CLASS (klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW, NautilusServiceInstallViewClass)) +#define NAUTILUS_IS_SERVICE_INSTALL_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW)) +#define NAUTILUS_IS_SERVICE_INSTALL_VIEW_CLASS (klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW)) + +typedef struct _NautilusServiceInstallViewDetails NautilusServiceInstallViewDetails; + +struct _NautilusServiceInstallView { + GtkEventBox parent; + NautilusServiceInstallViewDetails *details; +}; + +struct _NautilusServiceInstallViewClass { + GtkVBoxClass parent_class; +}; + +/* GtkObject support */ +GtkType nautilus_service_install_view_get_type (void); + +/* Component embedding support */ +NautilusView *nautilus_service_install_view_get_nautilus_view (NautilusServiceInstallView *view); + +/* URI handling */ +void nautilus_service_install_view_load_uri (NautilusServiceInstallView *view, + const char *uri); + +#endif /* NAUTILUS_SERVICE_INSTALL_VIEW_H */ + diff --git a/components/services/install-view/nautilus-service-install-view.oafinfo b/components/services/install-view/nautilus-service-install-view.oafinfo new file mode 100644 index 000000000..0edc7fd8f --- /dev/null +++ b/components/services/install-view/nautilus-service-install-view.oafinfo @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:nautilus_service_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32" type="exe" location="nautilus-service-install-view"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:GNOME/GenericFactory:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View Factory"/> +<oaf_attribute name="description" type="string" value="Service Install View Component's Factory"/> +</oaf_server> + +<oaf_server iid="OAFIID:nautilus_service_install_view:886546ca-1115-4ea4-8d30-8cefa2f5070b" type="factory" location="OAFIID:nautilus_sevice_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:Bonobo/Control:1.0"/> +<item value="IDL:Bonobo/Unknown:1.0"/> +<item value="IDL:Nautilus/ContentView:1.0"/> +<item value="IDL:Nautilus/View:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View"/> +<oaf_attribute name="description" type="string" value="Service Install View Component"/> +<oaf_attribute name="bonobo:additional_uri_schemes" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="bonobo:supported_mime_types" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="nautilus:view_as_name" type="string" value="Install"/> +</oaf_server> + +</oaf_info> diff --git a/components/services/install-view/nautilus-service-install.c b/components/services/install-view/nautilus-service-install.c new file mode 100644 index 000000000..93c30033f --- /dev/null +++ b/components/services/install-view/nautilus-service-install.c @@ -0,0 +1,262 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Eskil Heyn Olsen <eskil@eazel.com> + */ + +#include "nautilus-service-install.h" +#include <libtrilobite/helixcode-utils.h> +#include <libeazelinstall.h> + +#define OAF_ID "OAFIID:trilobite_eazel_install_service:8ff6e815-1992-437c-9771-d932db3b4a17" + +static void +nautilus_service_install_download_progress_signal (EazelInstallCallback *service, + const char *name, + int amount, + int total, + NautilusServiceInstallView *view) +{ + fprintf (stdout, "Download progress - %s %% %f\r", name, + (total ? ((float) + ((((float) amount) / total) * 100)) + : 100.0)); + fflush (stdout); + if (amount == total && total!=0) { + fprintf (stdout, "\n"); + } +} + +static void +nautilus_service_install_progress_signal (EazelInstallCallback *service, + const PackageData *pack, + int amount, + int total, + NautilusServiceInstallView *view) +{ + fprintf (stdout, "Install progress - %s %% %f\r", pack->name, + (total ? ((float) + ((((float) amount) / total) * 100)) + : 100.0)); + fflush (stdout); + if (amount == total && total!=0) { + fprintf (stdout, "\n"); + } +} + +static void +nautilus_service_install_download_failed (EazelInstallCallback *service, + const char *name, + NautilusServiceInstallView *view) +{ + fprintf (stdout, "Download of %s FAILED\n", name); +} + +/* + This dumps the entire tree for the failed package. + */ +static void +nautilus_service_install_failed_helper (EazelInstallCallback *service, + const PackageData *pd, + gchar *indent, + NautilusServiceInstallView *view) +{ + GList *iterator; + + if (pd->toplevel) { + fprintf (stdout, "\n***The package %s failed. Here's the dep tree\n", pd->name); + } + switch (pd->status) { + case PACKAGE_DEPENDENCY_FAIL: + fprintf (stdout, "%s-%s FAILED\n", indent, rpmfilename_from_packagedata (pd)); + break; + case PACKAGE_CANNOT_OPEN: + fprintf (stdout, "%s-%s NOT FOUND\n", indent, rpmfilename_from_packagedata (pd)); + break; + case PACKAGE_SOURCE_NOT_SUPPORTED: + fprintf (stdout, "%s-%s is a source package\n", indent, rpmfilename_from_packagedata (pd)); + break; + case PACKAGE_BREAKS_DEPENDENCY: + fprintf (stdout, "%s-%s breaks\n", indent, rpmfilename_from_packagedata (pd)); + break; + default: + fprintf (stdout, "%s-%s\n", indent, rpmfilename_from_packagedata (pd)); + break; + } + for (iterator = pd->soft_depends; iterator; iterator = iterator->next) { + PackageData *pack; + char *indent2; + indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL); + pack = (PackageData*)iterator->data; + nautilus_service_install_failed_helper (service, pack, indent2, view); + g_free (indent2); + } + for (iterator = pd->breaks; iterator; iterator = iterator->next) { + PackageData *pack; + char *indent2; + indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL); + pack = (PackageData*)iterator->data; + nautilus_service_install_failed_helper (service, pack, indent2, view); + g_free (indent2); + } +} + +static void +nautilus_service_install_failed (EazelInstallCallback *service, + const PackageData *pd, + NautilusServiceInstallView *view) +{ + nautilus_service_install_failed_helper (service, pd, "", view); +} + + +static void +nautilus_service_install_dependency_check (EazelInstallCallback *service, + const PackageData *package, + const PackageData *needs, + NautilusServiceInstallView *view) +{ + g_message ("Doing dependency check for %s - need %s\n", package->name, needs->name); +} + +static void +nautilus_service_install_done (EazelInstallCallback *service, + NautilusServiceInstallView *view) +{ + char *tmp; + eazel_install_callback_destroy (GTK_OBJECT (service)); + tmp = g_strdup (view->details->uri); + nautilus_service_install_view_load_uri (view, tmp); + g_free (tmp); +} + +void +nautilus_service_install_view_install_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view) +{ + GList *packages; + GList *categories; + CORBA_Environment ev; + EazelInstallCallback *cb; + + CORBA_exception_init (&ev); + + packages = NULL; + categories = NULL; + + { + char *ptr; + CategoryData *category; + PackageData *pack; + + /* Find the :// of the url and skip to after it */ + ptr = strstr (view->details->current_uri, "file://"); + ptr += strlen ("file://"); + + /* make a package and add to it to a categorylist */ + pack = packagedata_new (); + pack->filename = g_strdup (ptr); + + category = g_new0 (CategoryData, 1); + category->packages = g_list_prepend (NULL, pack); + categories = g_list_prepend (NULL, category); + } + + /* Check that we're on a redhat system */ + if (check_for_redhat () == FALSE) { + fprintf (stderr, "*** This tool can only be used on RedHat.\n"); + } + + cb = eazel_install_callback_new (); + + Trilobite_Eazel_Install__set_protocol (eazel_install_callback_corba_objref (cb), Trilobite_Eazel_PROTOCOL_HTTP, &ev); + if (check_for_root_user() == FALSE) { + fprintf (stderr, "*** This tool requires root access, switching to test mode\n"); + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), TRUE, &ev); + } else { + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), FALSE, &ev); + } + Trilobite_Eazel_Install__set_tmp_dir (eazel_install_callback_corba_objref (cb), "/tmp/eazel-install", &ev); + Trilobite_Eazel_Install__set_server (eazel_install_callback_corba_objref (cb), "testmachine.eazel.com", &ev); + Trilobite_Eazel_Install__set_server_port (eazel_install_callback_corba_objref (cb), 80, &ev); + + gtk_signal_connect (GTK_OBJECT (cb), "download_progress", nautilus_service_install_download_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "install_progress", nautilus_service_install_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "install_failed", nautilus_service_install_failed, view); + gtk_signal_connect (GTK_OBJECT (cb), "download_failed", nautilus_service_install_download_failed, view); + gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", nautilus_service_install_dependency_check, view); + gtk_signal_connect (GTK_OBJECT (cb), "done", nautilus_service_install_done, view); + + eazel_install_callback_install_packages (cb, categories, &ev); + + CORBA_exception_free (&ev); +} + +void +nautilus_service_install_view_uninstall_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view) +{ + GList *packages; + GList *categories; + CORBA_Environment ev; + EazelInstallCallback *cb; + + CORBA_exception_init (&ev); + + packages = NULL; + categories = NULL; + + { + CategoryData *category; + PackageData *pack; + pack = gtk_object_get_data (GTK_OBJECT (view), "packagedata"); + + category = g_new0 (CategoryData, 1); + category->packages = g_list_prepend (NULL, pack); + categories = g_list_prepend (NULL, category); + } + + /* Check that we're on a redhat system */ + if (check_for_redhat () == FALSE) { + fprintf (stderr, "*** This tool can only be used on RedHat.\n"); + } + + cb = eazel_install_callback_new (); + + Trilobite_Eazel_Install__set_protocol (eazel_install_callback_corba_objref (cb), Trilobite_Eazel_PROTOCOL_HTTP, &ev); + if (check_for_root_user() == FALSE) { + fprintf (stderr, "*** This tool requires root access, switching to test mode\n"); + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), TRUE, &ev); + } else { + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), FALSE, &ev); + } + Trilobite_Eazel_Install__set_tmp_dir (eazel_install_callback_corba_objref (cb), "/tmp/eazel-install", &ev); + Trilobite_Eazel_Install__set_server (eazel_install_callback_corba_objref (cb), "testmachine.eazel.com", &ev); + Trilobite_Eazel_Install__set_server_port (eazel_install_callback_corba_objref (cb), 80, &ev); + + gtk_signal_connect (GTK_OBJECT (cb), "download_progress", nautilus_service_install_download_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "uninstall_progress", nautilus_service_install_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "uninstall_failed", nautilus_service_install_failed, view); + gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", nautilus_service_install_dependency_check, view); + gtk_signal_connect (GTK_OBJECT (cb), "done", nautilus_service_install_done, view); + + eazel_install_callback_uninstall_packages (cb, categories, &ev); + + CORBA_exception_free (&ev); +} diff --git a/components/services/install-view/nautilus-service-install.h b/components/services/install-view/nautilus-service-install.h new file mode 100644 index 000000000..c284779fb --- /dev/null +++ b/components/services/install-view/nautilus-service-install.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Eskil Heyn Olsen <eskil@eazel.com> + */ + +#ifndef NAUTILUS_SERVICE_INSTALL_H +#define NAUTILUS_SERVICE_INSTALL_H + +#include "nautilus-service-install-view.h" + +void nautilus_service_install_view_install_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view); +void nautilus_service_install_view_uninstall_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view); + +#endif /* NAUTILUS_SERVICE_INSTALL_H */ diff --git a/components/services/install/Makefile.am b/components/services/install/Makefile.am index 55ccead43..e631e0d87 100644 --- a/components/services/install/Makefile.am +++ b/components/services/install/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = idl lib server command-line +SUBDIRS = idl lib server command-line nautilus-view diff --git a/components/services/install/nautilus-view/.cvsignore b/components/services/install/nautilus-view/.cvsignore index 282522db0..06988e9f5 100644 --- a/components/services/install/nautilus-view/.cvsignore +++ b/components/services/install/nautilus-view/.cvsignore @@ -1,2 +1,5 @@ Makefile Makefile.in +.deps +.libs +nautilus-service-install-view diff --git a/components/services/install/nautilus-view/Makefile.am b/components/services/install/nautilus-view/Makefile.am index f25cea199..1b83aafdd 100644 --- a/components/services/install/nautilus-view/Makefile.am +++ b/components/services/install/nautilus-view/Makefile.am @@ -1,18 +1,52 @@ NULL = -CPPFLAGS = \ - -DPREFIX=\"$(prefix)\" \ - -DG_LOG_DOMAIN=\"Nautilus-Services\" - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(GCONF_CFLAGS) \ - $(GNOMEUI_CFLAGS) \ - $(OAF_CFLAGS) \ - $(XML_CFLAGS) \ - $(WERROR) \ +CPPFLAGS = \ + -DPREFIX=\"$(prefix)\" \ + -DG_LOG_DOMAIN=\"Nautilus-service-install\" + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/components/services/install/lib \ + -I$(top_srcdir)/components/services/trilobite \ + -I$(top_builddir) \ + -I/usr/include/rpm \ + $(GCONF_CFLAGS) \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + $(GNOMEUI_CFLAGS) \ + $(VFS_CFLAGS) \ + $(WERROR) \ + $(NULL) + +oafdir = $(datadir)/oaf + +oaf_DATA = nautilus-service-install-view.oafinfo + +bin_PROGRAMS = nautilus-service-install-view + +nautilus_service_install_view_SOURCES = \ + nautilus-service-install-view.h \ + nautilus-service-install-view.c \ + main.c \ + $(NULL) + +nautilus_service_install_view_LDADD = \ + $(RPM_LIBS) \ $(NULL) -gnorbadir = $(sysconfdir)/CORBA/servers +nautilus_service_install_view_LDFLAGS = \ + $(top_builddir)/libnautilus/libnautilus.la \ + $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ + $(top_builddir)/cut-n-paste-code/widgets/e-paned/libe-paned.la \ + $(top_builddir)/librsvg/librsvg.la \ + $(top_builddir)/components/services/install/lib/libeazelinstall.la \ + $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ + $(BONOBO_LIBS) \ + $(GCONF_LIBS) \ + $(GNOMEUI_LIBS) \ + $(OAF_LIBS) \ + $(VFS_LIBS) \ + $(RPM_LIBS) \ + $(NULL) + +EXTRA_DIST = $(oaf_DATA) diff --git a/components/services/install/nautilus-view/Nautilus_View_install.oaf.in b/components/services/install/nautilus-view/Nautilus_View_install.oaf.in new file mode 100644 index 000000000..0edc7fd8f --- /dev/null +++ b/components/services/install/nautilus-view/Nautilus_View_install.oaf.in @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:nautilus_service_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32" type="exe" location="nautilus-service-install-view"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:GNOME/GenericFactory:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View Factory"/> +<oaf_attribute name="description" type="string" value="Service Install View Component's Factory"/> +</oaf_server> + +<oaf_server iid="OAFIID:nautilus_service_install_view:886546ca-1115-4ea4-8d30-8cefa2f5070b" type="factory" location="OAFIID:nautilus_sevice_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:Bonobo/Control:1.0"/> +<item value="IDL:Bonobo/Unknown:1.0"/> +<item value="IDL:Nautilus/ContentView:1.0"/> +<item value="IDL:Nautilus/View:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View"/> +<oaf_attribute name="description" type="string" value="Service Install View Component"/> +<oaf_attribute name="bonobo:additional_uri_schemes" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="bonobo:supported_mime_types" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="nautilus:view_as_name" type="string" value="Install"/> +</oaf_server> + +</oaf_info> diff --git a/components/services/install/nautilus-view/main.c b/components/services/install/nautilus-view/main.c new file mode 100644 index 000000000..c703d5c32 --- /dev/null +++ b/components/services/install/nautilus-view/main.c @@ -0,0 +1,91 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Maciej Stachowiak <mjs@eazel.com> + * J Shane Culpepper <pepper@eazel.com> + */ + +/* main.c - main function and object activation function for services + content view component. */ + +#include <config.h> +#include <gnome.h> +#include <liboaf/liboaf.h> +#include <bonobo.h> +#include "nautilus-service-install-view.h" + +static int object_count =0; + +static void +service_install_object_destroyed (GtkObject *obj) { + object_count--; + if (object_count <= 0) { + gtk_main_quit (); + } +} + +static BonoboObject* +service_install_make_object (BonoboGenericFactory *factory, + const char *iid, + void *closure) { + + NautilusServiceInstallView *view; + NautilusView *nautilus_view; + + if (strcmp (iid, "OAFIID:nautilus_service_install_view:886546ca-1115-4ea4-8d30-8cefa2f5070b")) { + return NULL; + } + + view = NAUTILUS_SERVICE_INSTALL_VIEW (gtk_object_new (NAUTILUS_TYPE_SERVICE_INSTALL_VIEW, NULL)); + + object_count++; + + gtk_signal_connect (GTK_OBJECT (view), "destroy", service_install_object_destroyed, NULL); + + nautilus_view = nautilus_service_install_view_get_nautilus_view (view); + + printf ("Returning new object %p\n", nautilus_view); + + return BONOBO_OBJECT (nautilus_view); +} + +int +main (int argc, char *argv[]) { + + BonoboGenericFactory *factory; + CORBA_ORB orb; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + gnome_init_with_popt_table ("nautilus-service-install-view", VERSION, + argc, argv, + oaf_popt_options, 0, NULL); + + orb = oaf_init (argc, argv); + + bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); + factory = bonobo_generic_factory_new_multi ("OAFIID:nautilus_service_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32", service_install_make_object, NULL); + + do { + bonobo_main (); + } while (object_count > 0); + + return 0; +} diff --git a/components/services/install/nautilus-view/nautilus-service-install-view.c b/components/services/install/nautilus-view/nautilus-service-install-view.c new file mode 100644 index 000000000..ad0278d6e --- /dev/null +++ b/components/services/install/nautilus-view/nautilus-service-install-view.c @@ -0,0 +1,201 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: J Shane Culpepper <pepper@eazel.com> + */ + +#include <config.h> + +#include <gnome-xml/tree.h> +#include <libgnomevfs/gnome-vfs-utils.h> +#include <libnautilus-extensions/nautilus-background.h> +#include <libnautilus-extensions/nautilus-gtk-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-glib-extensions.h> +#include <libnautilus-extensions/nautilus-global-preferences.h> +#include <libnautilus-extensions/nautilus-file-utilities.h> +#include <libnautilus-extensions/nautilus-string.h> +#include <libnautilus-extensions/nautilus-font-factory.h> +#include <stdio.h> +#include <unistd.h> + +#include "nautilus-service-install-view.h" + + + +/* A NautilusContentView's private information. */ +struct _NautilusServiceInstallViewDetails { + char *uri; + NautilusView *nautilus_view; + GtkWidget *form; + GtkWidget *form_title; + GtkWidget *feedback_text; +}; + +#define SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF" +#define SERVICE_DOMAIN_NAME "testmachine.eazel.com" + +static void nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass); +static void nautilus_service_install_view_initialize (NautilusServiceInstallView *view); +static void nautilus_service_install_view_destroy (GtkObject *object); +static void service_install_load_location_callback (NautilusView *nautilus_view, + const char *location, + NautilusServiceInstallView *view); +static void generate_install_form (NautilusServiceInstallView *view); +static void generate_form_title (NautilusServiceInstallView *view, + const char *title_text); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusServiceInstallView, nautilus_service_install_view, GTK_TYPE_EVENT_BOX) + +static void +generate_install_form (NautilusServiceInstallView *view) { + + GtkWidget *temp_widget; + + /* allocate the parent box to hold everything */ + view->details->form = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (view), view->details->form); + gtk_widget_show (view->details->form); + + /* setup the title */ + generate_form_title (view, "Easy Install"); + + /* put a mystery label here as a placeholder. */ + temp_widget = gtk_label_new ("I am just a view. One day I will be gone."); + gtk_box_pack_start (GTK_BOX (view->details->form), temp_widget, 0, 0, 0); + gtk_widget_show (temp_widget); + +} + +static void +generate_form_title (NautilusServiceInstallView *view, + const char *title_text) { + + GtkWidget *temp_widget; + char *file_name; + GtkWidget *temp_container; + GdkFont *font; + + temp_container = gtk_hbox_new (FALSE, 0); + + gtk_box_pack_start (GTK_BOX (view->details->form), temp_container, 0, 0, 4); + gtk_widget_show (temp_container); + + file_name = nautilus_pixmap_file ("eazel-cloud-logo.png"); + temp_widget = GTK_WIDGET (gnome_pixmap_new_from_file (file_name)); + gtk_box_pack_start (GTK_BOX(temp_container), temp_widget, 0, 0, 8); + gtk_widget_show (temp_widget); + g_free (file_name); + + view->details->form_title = gtk_label_new (title_text); + + font = nautilus_font_factory_get_font_from_preferences (18); + nautilus_gtk_widget_set_font (view->details->form_title, font); + gdk_font_unref (font); + + gtk_box_pack_start (GTK_BOX (temp_container), view->details->form_title, 0, 0, 8); + gtk_widget_show (view->details->form_title); +} + +static void +nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass *klass) { + + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + object_class = GTK_OBJECT_CLASS (klass); + widget_class = GTK_WIDGET_CLASS (klass); + parent_class = gtk_type_class (gtk_event_box_get_type ()); + object_class->destroy = nautilus_service_install_view_destroy; +} + +static void +nautilus_service_install_view_initialize (NautilusServiceInstallView *view) { + + NautilusBackground *background; + + view->details = g_new0 (NautilusServiceInstallViewDetails, 1); + view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view)); + gtk_signal_connect (GTK_OBJECT (view->details->nautilus_view), + "load_location", + GTK_SIGNAL_FUNC (service_install_load_location_callback), + view); + + background = nautilus_get_widget_background (GTK_WIDGET (view)); + nautilus_background_set_color (background, SERVICE_VIEW_DEFAULT_BACKGROUND_COLOR); + + gtk_widget_show (GTK_WIDGET (view)); +} + +static void +nautilus_service_install_view_destroy (GtkObject *object) { + + NautilusServiceInstallView *view; + + view = NAUTILUS_SERVICE_INSTALL_VIEW (object); + + if (view->details->uri) { + g_free (view->details->uri); + } + g_free (view->details); + + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); + +} + +NautilusView * +nautilus_service_install_view_get_nautilus_view (NautilusServiceInstallView *view) { + + return view->details->nautilus_view; + +} + +void +nautilus_service_install_view_load_uri (NautilusServiceInstallView *view, + const char *uri) { + + /* dispose of any old uri and copy in the new one */ + g_free (view->details->uri); + view->details->uri = g_strdup (uri); + + /* dispose of any old form that was installed */ + if (view->details->form != NULL) { + gtk_widget_destroy (view->details->form); + view->details->form = NULL; + } + + generate_install_form (view); +} + +static void +service_install_load_location_callback (NautilusView *nautilus_view, + const char *location, + NautilusServiceInstallView *view) { + + g_assert (nautilus_view == view->details->nautilus_view); + + nautilus_view_report_load_underway (nautilus_view); + + nautilus_service_install_view_load_uri (view, location); + + nautilus_view_report_load_complete (nautilus_view); + +} + diff --git a/components/services/install/nautilus-view/nautilus-service-install-view.h b/components/services/install/nautilus-view/nautilus-service-install-view.h new file mode 100644 index 000000000..87ff67a6b --- /dev/null +++ b/components/services/install/nautilus-view/nautilus-service-install-view.h @@ -0,0 +1,60 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: J Shane Culpepper + */ + +#ifndef NAUTILUS_SERVICE_INSTALL_VIEW_H +#define NAUTILUS_SERVICE_INSTALL_VIEW_H + +#include <libnautilus/nautilus-view.h> +#include <gtk/gtk.h> + +typedef struct _NautilusServiceInstallView NautilusServiceInstallView; +typedef struct _NautilusServiceInstallViewClass NautilusServiceInstallViewClass; + +#define NAUTILUS_TYPE_SERVICE_INSTALL_VIEW (nautilus_service_install_view_get_type ()) +#define NAUTILUS_SERVICE_INSTALL_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW, NautilusServiceInstallView)) +#define NAUTILUS_SERVICE_INSTALL_VIEW_CLASS (klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW, NautilusServiceInstallViewClass)) +#define NAUTILUS_IS_SERVICE_INSTALL_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW)) +#define NAUTILUS_IS_SERVICE_INSTALL_VIEW_CLASS (klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_SERVICE_INSTALL_VIEW)) + +typedef struct _NautilusServiceInstallViewDetails NautilusServiceInstallViewDetails; + +struct _NautilusServiceInstallView { + GtkEventBox parent; + NautilusServiceInstallViewDetails *details; +}; + +struct _NautilusServiceInstallViewClass { + GtkVBoxClass parent_class; +}; + +/* GtkObject support */ +GtkType nautilus_service_install_view_get_type (void); + +/* Component embedding support */ +NautilusView *nautilus_service_install_view_get_nautilus_view (NautilusServiceInstallView *view); + +/* URI handling */ +void nautilus_service_install_view_load_uri (NautilusServiceInstallView *view, + const char *uri); + +#endif /* NAUTILUS_SERVICE_INSTALL_VIEW_H */ + diff --git a/components/services/install/nautilus-view/nautilus-service-install-view.oafinfo b/components/services/install/nautilus-view/nautilus-service-install-view.oafinfo new file mode 100644 index 000000000..0edc7fd8f --- /dev/null +++ b/components/services/install/nautilus-view/nautilus-service-install-view.oafinfo @@ -0,0 +1,29 @@ +<oaf_info> + +<oaf_server iid="OAFIID:nautilus_service_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32" type="exe" location="nautilus-service-install-view"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:GNOME/GenericFactory:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View Factory"/> +<oaf_attribute name="description" type="string" value="Service Install View Component's Factory"/> +</oaf_server> + +<oaf_server iid="OAFIID:nautilus_service_install_view:886546ca-1115-4ea4-8d30-8cefa2f5070b" type="factory" location="OAFIID:nautilus_sevice_install_view_factory:e59e53d1-e3d1-46fe-ae28-3ec5c56b7d32"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:Bonobo/Control:1.0"/> +<item value="IDL:Bonobo/Unknown:1.0"/> +<item value="IDL:Nautilus/ContentView:1.0"/> +<item value="IDL:Nautilus/View:1.0"/> +</oaf_attribute> +<oaf_attribute name="name" type="string" value="Nautilus Service Install View"/> +<oaf_attribute name="description" type="string" value="Service Install View Component"/> +<oaf_attribute name="bonobo:additional_uri_schemes" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="bonobo:supported_mime_types" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> +<oaf_attribute name="nautilus:view_as_name" type="string" value="Install"/> +</oaf_server> + +</oaf_info> diff --git a/components/services/install/nautilus-view/nautilus-service-install.c b/components/services/install/nautilus-view/nautilus-service-install.c new file mode 100644 index 000000000..93c30033f --- /dev/null +++ b/components/services/install/nautilus-view/nautilus-service-install.c @@ -0,0 +1,262 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Eskil Heyn Olsen <eskil@eazel.com> + */ + +#include "nautilus-service-install.h" +#include <libtrilobite/helixcode-utils.h> +#include <libeazelinstall.h> + +#define OAF_ID "OAFIID:trilobite_eazel_install_service:8ff6e815-1992-437c-9771-d932db3b4a17" + +static void +nautilus_service_install_download_progress_signal (EazelInstallCallback *service, + const char *name, + int amount, + int total, + NautilusServiceInstallView *view) +{ + fprintf (stdout, "Download progress - %s %% %f\r", name, + (total ? ((float) + ((((float) amount) / total) * 100)) + : 100.0)); + fflush (stdout); + if (amount == total && total!=0) { + fprintf (stdout, "\n"); + } +} + +static void +nautilus_service_install_progress_signal (EazelInstallCallback *service, + const PackageData *pack, + int amount, + int total, + NautilusServiceInstallView *view) +{ + fprintf (stdout, "Install progress - %s %% %f\r", pack->name, + (total ? ((float) + ((((float) amount) / total) * 100)) + : 100.0)); + fflush (stdout); + if (amount == total && total!=0) { + fprintf (stdout, "\n"); + } +} + +static void +nautilus_service_install_download_failed (EazelInstallCallback *service, + const char *name, + NautilusServiceInstallView *view) +{ + fprintf (stdout, "Download of %s FAILED\n", name); +} + +/* + This dumps the entire tree for the failed package. + */ +static void +nautilus_service_install_failed_helper (EazelInstallCallback *service, + const PackageData *pd, + gchar *indent, + NautilusServiceInstallView *view) +{ + GList *iterator; + + if (pd->toplevel) { + fprintf (stdout, "\n***The package %s failed. Here's the dep tree\n", pd->name); + } + switch (pd->status) { + case PACKAGE_DEPENDENCY_FAIL: + fprintf (stdout, "%s-%s FAILED\n", indent, rpmfilename_from_packagedata (pd)); + break; + case PACKAGE_CANNOT_OPEN: + fprintf (stdout, "%s-%s NOT FOUND\n", indent, rpmfilename_from_packagedata (pd)); + break; + case PACKAGE_SOURCE_NOT_SUPPORTED: + fprintf (stdout, "%s-%s is a source package\n", indent, rpmfilename_from_packagedata (pd)); + break; + case PACKAGE_BREAKS_DEPENDENCY: + fprintf (stdout, "%s-%s breaks\n", indent, rpmfilename_from_packagedata (pd)); + break; + default: + fprintf (stdout, "%s-%s\n", indent, rpmfilename_from_packagedata (pd)); + break; + } + for (iterator = pd->soft_depends; iterator; iterator = iterator->next) { + PackageData *pack; + char *indent2; + indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL); + pack = (PackageData*)iterator->data; + nautilus_service_install_failed_helper (service, pack, indent2, view); + g_free (indent2); + } + for (iterator = pd->breaks; iterator; iterator = iterator->next) { + PackageData *pack; + char *indent2; + indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL); + pack = (PackageData*)iterator->data; + nautilus_service_install_failed_helper (service, pack, indent2, view); + g_free (indent2); + } +} + +static void +nautilus_service_install_failed (EazelInstallCallback *service, + const PackageData *pd, + NautilusServiceInstallView *view) +{ + nautilus_service_install_failed_helper (service, pd, "", view); +} + + +static void +nautilus_service_install_dependency_check (EazelInstallCallback *service, + const PackageData *package, + const PackageData *needs, + NautilusServiceInstallView *view) +{ + g_message ("Doing dependency check for %s - need %s\n", package->name, needs->name); +} + +static void +nautilus_service_install_done (EazelInstallCallback *service, + NautilusServiceInstallView *view) +{ + char *tmp; + eazel_install_callback_destroy (GTK_OBJECT (service)); + tmp = g_strdup (view->details->uri); + nautilus_service_install_view_load_uri (view, tmp); + g_free (tmp); +} + +void +nautilus_service_install_view_install_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view) +{ + GList *packages; + GList *categories; + CORBA_Environment ev; + EazelInstallCallback *cb; + + CORBA_exception_init (&ev); + + packages = NULL; + categories = NULL; + + { + char *ptr; + CategoryData *category; + PackageData *pack; + + /* Find the :// of the url and skip to after it */ + ptr = strstr (view->details->current_uri, "file://"); + ptr += strlen ("file://"); + + /* make a package and add to it to a categorylist */ + pack = packagedata_new (); + pack->filename = g_strdup (ptr); + + category = g_new0 (CategoryData, 1); + category->packages = g_list_prepend (NULL, pack); + categories = g_list_prepend (NULL, category); + } + + /* Check that we're on a redhat system */ + if (check_for_redhat () == FALSE) { + fprintf (stderr, "*** This tool can only be used on RedHat.\n"); + } + + cb = eazel_install_callback_new (); + + Trilobite_Eazel_Install__set_protocol (eazel_install_callback_corba_objref (cb), Trilobite_Eazel_PROTOCOL_HTTP, &ev); + if (check_for_root_user() == FALSE) { + fprintf (stderr, "*** This tool requires root access, switching to test mode\n"); + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), TRUE, &ev); + } else { + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), FALSE, &ev); + } + Trilobite_Eazel_Install__set_tmp_dir (eazel_install_callback_corba_objref (cb), "/tmp/eazel-install", &ev); + Trilobite_Eazel_Install__set_server (eazel_install_callback_corba_objref (cb), "testmachine.eazel.com", &ev); + Trilobite_Eazel_Install__set_server_port (eazel_install_callback_corba_objref (cb), 80, &ev); + + gtk_signal_connect (GTK_OBJECT (cb), "download_progress", nautilus_service_install_download_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "install_progress", nautilus_service_install_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "install_failed", nautilus_service_install_failed, view); + gtk_signal_connect (GTK_OBJECT (cb), "download_failed", nautilus_service_install_download_failed, view); + gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", nautilus_service_install_dependency_check, view); + gtk_signal_connect (GTK_OBJECT (cb), "done", nautilus_service_install_done, view); + + eazel_install_callback_install_packages (cb, categories, &ev); + + CORBA_exception_free (&ev); +} + +void +nautilus_service_install_view_uninstall_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view) +{ + GList *packages; + GList *categories; + CORBA_Environment ev; + EazelInstallCallback *cb; + + CORBA_exception_init (&ev); + + packages = NULL; + categories = NULL; + + { + CategoryData *category; + PackageData *pack; + pack = gtk_object_get_data (GTK_OBJECT (view), "packagedata"); + + category = g_new0 (CategoryData, 1); + category->packages = g_list_prepend (NULL, pack); + categories = g_list_prepend (NULL, category); + } + + /* Check that we're on a redhat system */ + if (check_for_redhat () == FALSE) { + fprintf (stderr, "*** This tool can only be used on RedHat.\n"); + } + + cb = eazel_install_callback_new (); + + Trilobite_Eazel_Install__set_protocol (eazel_install_callback_corba_objref (cb), Trilobite_Eazel_PROTOCOL_HTTP, &ev); + if (check_for_root_user() == FALSE) { + fprintf (stderr, "*** This tool requires root access, switching to test mode\n"); + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), TRUE, &ev); + } else { + Trilobite_Eazel_Install__set_test_mode (eazel_install_callback_corba_objref (cb), FALSE, &ev); + } + Trilobite_Eazel_Install__set_tmp_dir (eazel_install_callback_corba_objref (cb), "/tmp/eazel-install", &ev); + Trilobite_Eazel_Install__set_server (eazel_install_callback_corba_objref (cb), "testmachine.eazel.com", &ev); + Trilobite_Eazel_Install__set_server_port (eazel_install_callback_corba_objref (cb), 80, &ev); + + gtk_signal_connect (GTK_OBJECT (cb), "download_progress", nautilus_service_install_download_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "uninstall_progress", nautilus_service_install_progress_signal, view); + gtk_signal_connect (GTK_OBJECT (cb), "uninstall_failed", nautilus_service_install_failed, view); + gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", nautilus_service_install_dependency_check, view); + gtk_signal_connect (GTK_OBJECT (cb), "done", nautilus_service_install_done, view); + + eazel_install_callback_uninstall_packages (cb, categories, &ev); + + CORBA_exception_free (&ev); +} diff --git a/components/services/install/nautilus-view/nautilus-service-install.h b/components/services/install/nautilus-view/nautilus-service-install.h new file mode 100644 index 000000000..c284779fb --- /dev/null +++ b/components/services/install/nautilus-view/nautilus-service-install.h @@ -0,0 +1,33 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * + * 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 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Eskil Heyn Olsen <eskil@eazel.com> + */ + +#ifndef NAUTILUS_SERVICE_INSTALL_H +#define NAUTILUS_SERVICE_INSTALL_H + +#include "nautilus-service-install-view.h" + +void nautilus_service_install_view_install_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view); +void nautilus_service_install_view_uninstall_package_callback (GtkWidget *widget, + NautilusServiceInstallView *view); + +#endif /* NAUTILUS_SERVICE_INSTALL_H */ |