diff options
Diffstat (limited to 'components')
29 files changed, 2338 insertions, 384 deletions
diff --git a/components/services/install/Makefile.am b/components/services/install/Makefile.am index 1244f3375..55ccead43 100644 --- a/components/services/install/Makefile.am +++ b/components/services/install/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = lib command-line idl +SUBDIRS = idl lib server command-line diff --git a/components/services/install/command-line/Makefile.am b/components/services/install/command-line/Makefile.am index 45d2f9b86..b981a3e7f 100644 --- a/components/services/install/command-line/Makefile.am +++ b/components/services/install/command-line/Makefile.am @@ -20,17 +20,18 @@ INCLUDES = \ $(WERROR) \ $(NULL) -bin_PROGRAMS = eazel-alt-install +bin_PROGRAMS = eazel-alt-install-corba -eazel_alt_install_SOURCES = \ - eazel-alt-install.c \ +eazel_alt_install_corba_SOURCES = \ + eazel-alt-install-corba.c \ $(NULL) -eazel_alt_install_LDADD = \ +eazel_alt_install_corba_LDADD = \ + $(top_builddir)/components/services/install/lib/libinstall_corba.a\ + $(top_builddir)/components/services/install/lib/libinstall_base.a \ $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ $(GNOME_LIBS) \ $(GCONF_LIBS) \ $(GHTTP_LIBS) \ $(RPM_LIBS) \ - $(top_builddir)/components/services/install/lib/libinstall.a \ $(NULL) diff --git a/components/services/install/command-line/eazel-alt-install-corba.c b/components/services/install/command-line/eazel-alt-install-corba.c new file mode 100644 index 000000000..39cdaaf6f --- /dev/null +++ b/components/services/install/command-line/eazel-alt-install-corba.c @@ -0,0 +1,377 @@ +/* -*- 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 <config.h> +#include <gnome.h> +#include <liboaf/liboaf.h> +#include <bonobo.h> +#include <sys/utsname.h> + +#include <eazel-install-types.h> +#include <eazel-install-corba-types.h> +#include <eazel-install-corba-callback.h> +#include <trilobite-eazel-install.h> + +#include <libtrilobite/libtrilobite.h> + +#define PACKAGE_FILE_NAME "package-list.xml" +#define DEFAULT_CONFIG_FILE "/var/eazel/services/eazel-services-config.xml" + +#define DEFAULT_HOSTNAME "testmachine.eazel.com" +#define DEFAULT_PORT_NUMBER 80 +#define DEFAULT_PROTOCOL PROTOCOL_HTTP +#define DEFAULT_TMP_DIR "/tmp/eazel-install" +#define DEFAULT_RPMRC "/usr/lib/rpm/rpmrc" +#define DEFAULT_REMOTE_PACKAGE_LIST "/package-list.xml" +#define DEFAULT_REMOTE_RPM_DIR "/RPMS" +#define DEFAULT_LOG_FILE "/tmp/eazel-install/log" + +/* This ensure that if the arch is detected as i[3-9]86, the + requested archtype will be set to i386 */ +#define ASSUME_ix86_IS_i386 + +#define OAF_ID "OAFIID:trilobite_eazel_install_service:8ff6e815-1992-437c-9771-d932db3b4a17" + +/* Popt stuff */ +int arg_dry_run, + arg_http, + arg_ftp, + arg_local, + arg_debug, + arg_port, + arg_delay; +char *arg_server, + *arg_config_file, + *arg_local_list, + *arg_tmp_dir, + *arg_input_list; + +CORBA_ORB orb; +CORBA_Environment ev; + +static const struct poptOption options[] = { + {"debug", '\0', POPT_ARG_NONE, &arg_debug, 0 , N_("Show debug output"), NULL}, + {"delay", '\0', POPT_ARG_NONE, &arg_delay, 0 , N_("10 sec delay after starting service"), NULL}, + {"port", '\0', POPT_ARG_NONE, &arg_port, 0 , N_("Set port numer (80)"), NULL}, + {"test", 't', POPT_ARG_NONE, &arg_dry_run, 0, N_("Test run"), NULL}, + {"tmp", '\0', POPT_ARG_STRING, &arg_tmp_dir, 0, N_("Set tmp dir (/tmp/eazel-install)"), NULL}, + {"server", '\0', POPT_ARG_STRING, &arg_server, 0, N_("Specify server"), NULL}, + {"http", 'h', POPT_ARG_NONE, &arg_http, 0, N_("Use http"), NULL}, + {"ftp", 'f', POPT_ARG_NONE, &arg_ftp, 0, N_("Use ftp"), NULL}, + {"local", 'l', POPT_ARG_NONE, &arg_local, 0, N_("Use local"), NULL}, + {"packagelist", '\0', POPT_ARG_STRING, &arg_local_list, 0, N_("Specify package list to use (/var/eazel/service/package-list.xml)"), NULL}, + {"config", '\0', POPT_ARG_STRING, &arg_config_file, 0, N_("Specify config file (/var/eazel/services/eazel-services-config.xml)"), NULL}, + {"genpkglist", '\0', POPT_ARG_STRING, &arg_input_list, 0, N_("Use specified file to generate a package list, requires --packagelist"), NULL}, + {NULL, '\0', 0, NULL, 0} +}; + +#define check_ev(s) if (ev._major!=CORBA_NO_EXCEPTION) { g_warning ("%s: Caught exception %s", s, CORBA_exception_id (&ev)); } + +static void +set_parameters_from_command_line (Trilobite_Eazel_Install service) +{ + if (!arg_debug) { + Trilobite_Eazel_Install__set_log_file (service, DEFAULT_LOG_FILE, &ev); + check_ev ("set_log_file"); + } + + /* We only want 1 protocol type */ + if (arg_http + arg_ftp + arg_local > 1) { + fprintf (stderr, "*** You cannot specify more then one protocol type.\n"); + exit (1); + } + if (arg_http) { + Trilobite_Eazel_Install__set_protocol (service, Trilobite_Eazel_PROTOCOL_HTTP, &ev); + check_ev ("set_protocol"); + } else if (arg_ftp) { + Trilobite_Eazel_Install__set_protocol (service, Trilobite_Eazel_PROTOCOL_FTP, &ev); + check_ev ("set_protocol"); + } else if (arg_local) { + Trilobite_Eazel_Install__set_protocol (service, Trilobite_Eazel_PROTOCOL_LOCAL, &ev); + check_ev ("set_protocol"); + } else { + Trilobite_Eazel_Install__set_protocol (service, Trilobite_Eazel_PROTOCOL_HTTP, &ev); + check_ev ("set_protocol"); + } + if (arg_server == NULL) { + arg_server = g_strdup (DEFAULT_HOSTNAME); + } + if (arg_tmp_dir == NULL) { + arg_tmp_dir = g_strdup (DEFAULT_TMP_DIR); + } + if (arg_port == 0) { + arg_port = DEFAULT_PORT_NUMBER; + } + if (arg_dry_run) { + Trilobite_Eazel_Install__set_test_mode (service, TRUE, &ev); + } +/* + if (arg_local_list) { + Trilobite_Eazel_Install__set_package_list (service, arg_local_list, &ev); + } + if (arg_input_list) { + if (arg_local_list == NULL) { + fprintf (stderr, "Use of --genpkglist requires --packagelist\n"); + exit (1); + } + generate_xml_package_list (arg_input_list, arg_local_list); + } +*/ +/* + + Trilobite_Eazel_Install__set_rpmrc_file (service, DEFAULT_RPMRC, &ev); + Trilobite_Eazel_Install__set_package_list_storage_path (service, DEFAULT_REMOTE_PACKAGE_LIST, &ev); + Trilobite_Eazel_Install__set_rpm_storage_path (service, DEFAULT_REMOTE_RPM_DIR, &ev); +*/ + Trilobite_Eazel_Install__set_tmp_dir (service, arg_tmp_dir, &ev); + check_ev ("set_tmp_dir"); + Trilobite_Eazel_Install__set_server (service, arg_server, &ev); + check_ev ("set_server"); + Trilobite_Eazel_Install__set_server_port (service, arg_port, &ev); + check_ev ("set_server_port"); +} + +static void +eazel_download_progress_signal (EazelInstallCallback *service, + const char *name, + int amount, + int total, + char *title) +{ + fprintf (stdout, "%s - %s %% %f\r", title, name, + (total ? ((float) + ((((float) amount) / total) * 100)) + : 100.0)); + fflush (stdout); + if (amount == total && total!=0) { + fprintf (stdout, "\n"); + } +} + +static void +eazel_install_progress_signal (EazelInstallCallback *service, + const PackageData *pack, + int amount, + int total, + char *title) +{ + fprintf (stdout, "%s - %s %% %f\r", title, pack->name, + (total ? ((float) + ((((float) amount) / total) * 100)) + : 100.0)); + fflush (stdout); + if (amount == total && total!=0) { + fprintf (stdout, "\n"); + } +} + +static void +download_failed (EazelInstallCallback *service, + const char *name, + gpointer unused) +{ + fprintf (stdout, "Download of %s FAILED\n", name); +} + +/* + This dumps the entire tree for the failed package. + */ +static void +install_failed (EazelInstallCallback *service, + const PackageData *pd, + gchar *indent) +{ + 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; + install_failed (service, pack, indent2); + 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; + install_failed (service, pack, indent2); + g_free (indent2); + } +} + +static void +dep_check (EazelInstallCallback *service, + const PackageData *package, + const PackageData *needs, + gpointer unused) +{ + fprintf (stdout, "Doing dependency check for %s - need %s\n", package->name, needs->name); +} + +static PackageData* +create_package (char *name) +{ + struct utsname buf; + PackageData *pack; + + uname (&buf); + pack = packagedata_new (); + pack->name = g_strdup (name); + pack->archtype = g_strdup (buf.machine); +#ifdef ASSUME_ix86_IS_i386 + if (strlen (pack->archtype)==4 && pack->archtype[0]=='i' && + pack->archtype[1]>='3' && pack->archtype[1]<='9' && + pack->archtype[2]=='8' && pack->archtype[3]=='6') { + g_free (pack->archtype); + pack->archtype = g_strdup ("i386"); + } +#endif + pack->distribution = trilobite_get_distribution (); + pack->toplevel = TRUE; + + return pack; +} + +static void +done (EazelInstallCallback *service, + gpointer unused) +{ + fprintf (stderr, "\nDone\n"); + gtk_main_quit (); +} + +int main(int argc, char *argv[]) { + poptContext ctxt; + Trilobite_Eazel_PackageStructList *packagelist; + GList *packages; + GList *categories; + char *str; + BonoboObjectClient *service; + Trilobite_Eazel_Install installservice; + + CORBA_exception_init (&ev); + + /* Seems that bonobo_main doens't like + not having gnome_init called, dies in a + X call, yech */ +#if 1 + gnome_init_with_popt_table ("Eazel Install", "1.0", argc, argv, options, 0, &ctxt); +#else + gtk_type_init (); + gnomelib_init ("Eazel Install", "1.0"); + gnomelib_register_popt_table (options, "Eazel Install"); + ctxt = gnomelib_parse_args (argc, argv, 0); +#endif + + packages = NULL; + categories = NULL; + /* If there are more args, get them and parse them as packages */ + while ((str = poptGetArg (ctxt)) != NULL) { + packages = g_list_prepend (packages, create_package (str)); + } + if (packages) { + packagelist = corba_packagestructlist_from_packagedata_list (packages); + } else { + g_message ("Using remote list "); + } + + /* Chech that we're root and on a redhat system */ + if (check_for_root_user() == FALSE) { + fprintf (stderr, "*** This tool requires root access.\n"); + } + if (check_for_redhat () == FALSE) { + fprintf (stderr, "*** This tool can only be used on RedHat.\n"); + } + + orb = oaf_init (argc, argv); + + if (bonobo_init (NULL, NULL, NULL) == FALSE) { + g_error ("Could not init bonobo"); + } + bonobo_activate (); + + service = bonobo_object_activate (OAF_ID, 0); + if (!service) { + g_error ("Cannot activate %s\n",OAF_ID); + } + + if (arg_delay) { + sleep (10); + } + + if (! bonobo_object_client_has_interface (service, "IDL:Trilobite/Service:1.0", &ev)) { + g_error ("Object does not support IDL:Trilobite/Service:1.0"); + } + if (! bonobo_object_client_has_interface (service, "IDL:Trilobite/Eazel/Install:1.0", &ev)) { + g_error ("Object does not support IDL:Trilobite/Eazel/Time:1.0"); + } + + installservice = bonobo_object_query_interface (BONOBO_OBJECT (service), "IDL:Trilobite/Eazel/Install:1.0"); + if (installservice != CORBA_OBJECT_NIL) { + EazelInstallCallback *cb; + set_parameters_from_command_line (installservice); + cb = eazel_install_callback_new (); + gtk_signal_connect (GTK_OBJECT (cb), "download_progress", eazel_download_progress_signal, "Download progress"); + gtk_signal_connect (GTK_OBJECT (cb), "install_progress", eazel_install_progress_signal, "Install progress"); + gtk_signal_connect (GTK_OBJECT (cb), "install_failed", install_failed, ""); + gtk_signal_connect (GTK_OBJECT (cb), "download_failed", download_failed, NULL); + gtk_signal_connect (GTK_OBJECT (cb), "dependency_check", dep_check, NULL); + gtk_signal_connect (GTK_OBJECT (cb), "done", done, NULL); + + Trilobite_Eazel_Install_install_packages (installservice, packagelist, eazel_install_callback_corba (cb), &ev); + } else { + g_error ("The bonobo object "); + } + + bonobo_main (); + Bonobo_Unknown_unref (installservice, &ev); /* for the query_interface */ + bonobo_object_unref (BONOBO_OBJECT (service)); /* for the object_activate */ + CORBA_Object_release (installservice, &ev); + + CORBA_exception_free (&ev); + + + return 0; +}; diff --git a/components/services/install/command-line/genpkg_list.example b/components/services/install/command-line/genpkg_list.example index bcf17d1f6..a57e7cfba 100644 --- a/components/services/install/command-line/genpkg_list.example +++ b/components/services/install/command-line/genpkg_list.example @@ -1,2 +1,25 @@ -Essential Packages:anaconda:7.0:1:i386:2722261:The redhat installer -Essential packages:foo:0.1:1:src:1111111:A usless source package +Essential Packages:GConf:0.5.msM31:3:i386:0:Stuff +Essential Packages:GConf-devel:0.5.msM31:3:i386:0:Stuff +Essential Packages:ORBit:0.5.1.msM31:2:i386:0:Stuff +Essential Packages:ORBit-devel:0.5.1.msM31:2:i386:0:Stuff +Essential Packages:bonobo:0.15.msM31:prw2:i386:0:Stuff +Essential Packages:bonobo-devel:0.15.msM31:prw2:i386:0:Stuff +Essential Packages:control-center:1.2.0.msM31:2:i386:0:Stuff +Essential Packages:control-center-devel:1.2.0.msM31:2:i386:0:Stuff +Essential Packages:eog:0.3.msM31:2:i386:0:Stuff +Essential Packages:gdk-pixbuf:0.8.0.msM31:3:i386:0:Stuff +Essential Packages:gdk-pixbuf-devel:0.8.0.msM31:3:i386:0:Stuff +Essential Packages:gnet:1.0.3.msM31:1:i386:0:Stuff +Essential Packages:gnet-devel:1.0.3.msM31:1:i386:0:Stuff +Essential Packages:gnome-print:0.20.msM31:1:i386:0:Stuff +Essential Packages:gnome-print-devel:0.20.msM31:1:i386:0:Stuff +Essential Packages:gnome-vfs:0.1.msM31:3:i386:0:Stuff +Essential Packages:gnome-vfs-devel:0.1.msM31:3:i386:0:Stuff +Essential Packages:gtkhtml:0.4.msM31:2:i386:0:Stuff +Essential Packages:gtkhtml-devel:0.4.msM31:2:i386:0:Stuff +Essential Packages:libghttp:1.0.7.msM31:1:i386:0:Stuff +Essential Packages:libghttp-devel:1.0.7.msM31:1:i386:0:Stuff +Essential Packages:nautilus:0.1.0:prw2:i386:0:Stuff +Essential Packages:nautilus-devel:0.1.0:prw2:i386:0:Stuff +Essential Packages:oaf:0.3.0.msM31:2:i386:0:Stuff +Essential Packages:oaf-devel:0.3.0.msM31:2:i386:0:Stuff diff --git a/components/services/install/idl/trilobite-eazel-install.idl b/components/services/install/idl/trilobite-eazel-install.idl index 8538e6192..9f458d639 100644 --- a/components/services/install/idl/trilobite-eazel-install.idl +++ b/components/services/install/idl/trilobite-eazel-install.idl @@ -3,14 +3,124 @@ module Trilobite { module Eazel { - interface InstallCallback { + enum PackageStatusEnum { + UNKNOWN_STATUS, + SOURCE_NOT_SUPPORTED, /* bad: we don't install source packages */ + DEPENDENCY_FAIL, /* bad: a dependency failed in next level */ + BREAKS_DEPENDENCY, /* bad: installing this breaks something, see PackageDataStruct.breaks */ + INVALID, /* bad: this is not a rpm, go away */ + CANNOT_OPEN, /* bad: cannot open/fetch/imagine this file */ + PARTLY_RESOLVED, /* perhaps: the immediate deps where ok, check all in PackageDataStruct.soft/hard_depends */ + RESOLVED /* good: all deps ok */ + }; + + enum ProtocolEnum { + PROTOCOL_HTTP, + PROTOCOL_FTP, + PROTOCOL_LOCAL + }; + + struct DistributionStruct { + string name; + long major; + long minor; + }; + + exception NoAccess {}; /* Raised if access to the package system wasn't allowed */ + exception PackagesFailed {}; /* Raised if some packages failed (un)install */ + + struct PackageDataStruct { + /* + These fields should be set when passed to + Eazel:Install::install () + */ + string name; + string version; + /* or set this you want to install a local file and + still use eg. protocol HTTP to do dep stuff */ + string filename; + + /* + Eazel:Install::install () + will set these if not set. + */ + string archtype; + DistributionStruct distribution; + + /* + Not needed for + Eazel:Install::install (), but will + (if available) be set when callbacks are called. + */ + string release; + string summary; + long bytesize; + boolean toplevel; + + /* When Eazel::IntallCallback::install_failed is + called, this is set. The toplevel will have + PARTLY_RESOLVED and in soft_ & hard_depends, + packages will have typically eiter + RESOLVED for the good deps, + bad deps will have one of the + bad: deps. + */ + PackageStatusEnum status; + }; + typedef sequence <PackageDataStruct> PackageDataStructList; + + struct PackageStruct { + PackageDataStruct data; + PackageDataStructList soft_depends; + PackageDataStructList hard_depends; + PackageDataStructList breaks; + }; + typedef sequence <PackageStruct> PackageStructList; + + interface InstallCallback : Bonobo::Unknown { + /* Called during download of a file */ oneway void download_progress (in string file, in long amount, in long total); - oneway void install_progress (in string name, in long amount, in long total); + + /* Called when dependency check is being handled */ + oneway void dependency_check (in PackageStruct package, in PackageDataStruct needs); + + /* Called during (un)installation of a package */ + oneway void install_progress (in PackageStruct package, in long amount, in long total); + oneway void uninstall_progress (in PackageStruct package, in long amount, in long total); + + /* Called whenever a package (un)install fails + */ + oneway void download_failed (in string file); + oneway void install_failed (in PackageStruct package); + oneway void uninstall_failed (in PackageStruct package); + + /* Called when the operation is finished */ void done (); }; - interface Install : Bonobo::Unknown { - oneway void new_packages (in InstallCallback cb); + interface Install : Bonobo::Unknown { + attribute boolean verbose; /* Mucho log output */ + attribute boolean silent; /* Minimal log output */ + attribute boolean test_mode; /* dry run, do not install, but act as if... */ + attribute boolean force; /* force install specified package (DANGER WILL ROBINSON) */ + attribute boolean update; /* enable update (default is TRUE) */ + + attribute string server; /* server to use for both file and package list download */ + attribute long server_port; /* */ + + attribute string log_file; /* where to put the logfile (otherwise it blurps to stdout */ + attribute string tmp_dir; /* directory to store tmp files in (/tmp/eazel-install) */ + + attribute ProtocolEnum protocol; /* + + /* Install/uninstall using the packagelist from the server */ + oneway void install (in string packagelist, in InstallCallback cb); + oneway void uninstall (in string packagelist, in InstallCallback cb); + + /* These are for installing/uninstalling specific packages */ + oneway void install_packages (in PackageStructList packages, in InstallCallback cb); + oneway void uninstall_packages (in PackageStructList packages, in InstallCallback cb); + }; }; }; diff --git a/components/services/install/lib/Makefile.am b/components/services/install/lib/Makefile.am index 9ef5c45c8..cd77b87b1 100644 --- a/components/services/install/lib/Makefile.am +++ b/components/services/install/lib/Makefile.am @@ -3,9 +3,11 @@ NULL = CPPFLAGS = \ -DPREFIX=\"$(prefix)\" \ -DG_LOG_DOMAIN=\"eazel-install\" \ - -DSTANDALONE \ $(NULL) +# -DEAZEL_INSTALL_NO_CORBA \ + + INCLUDES = \ -I$(top_srcdir) \ -I$(top_builddir) \ @@ -18,39 +20,50 @@ INCLUDES = \ $(WERROR) \ $(NULL) -noinst_LIBRARIES = libinstall.a libinstall_corba.a +noinst_LIBRARIES = libinstall_gtk.a libinstall_base.a libinstall_corba.a -libinstall_a_SOURCES = \ +noinst_HEADERS = \ eazel-install-types.h \ - eazel-install-types.c \ + eazel-install-corba-types.h \ eazel-install-metadata.h \ - eazel-install-metadata.c \ eazel-install-protocols.h \ eazel-install-rpm-glue.h \ - eazel-install-protocols.c \ eazel-install-rpm-glue.h \ - eazel-install-rpm-glue.c \ eazel-install-tests.h \ - eazel-install-tests.c \ eazel-install-xml-package-list.h \ + eazel-install-private.h \ + eazel-install-corba-callback.h \ + $(NULL) + +libinstall_gtk_a_SOURCES = \ + eazel-install-object.c \ + $(NULL) + + +libinstall_gtk_a_CPPFLAGS = \ + -DEAZEL_INSTALL_NO_CORBA \ + $(NULL) + +libinstall_base_a_SOURCES = \ + eazel-install-types.c \ + eazel-install-metadata.c \ + eazel-install-protocols.c \ + eazel-install-rpm-glue.c \ + eazel-install-tests.c \ eazel-install-xml-package-list.c \ eazel-install-object.c \ eazel-install-public.h \ - eazel-install-private.h \ $(NULL) ## CORBA magic -oafdir = $(datadir)/oaf -oaf_DATA = trilobite-eazel-install-service.oafinfo - CORBA_GENERATED = \ trilobite-eazel-install-common.c \ trilobite-eazel-install-skels.c \ trilobite-eazel-install-stubs.c \ $(NULL) -$(CORBA_GENERATED): trilobite-eazel-install.h +eazel-install-public.h $(CORBA_GENERATED): trilobite-eazel-install.h IDLDIR = $(top_srcdir)/components/services/install/idl IDL = $(IDLDIR)/trilobite-eazel-install.idl @@ -58,13 +71,16 @@ IDL = $(IDLDIR)/trilobite-eazel-install.idl trilobite-eazel-install.h: $(IDL) $(ORBIT_IDL) $(IDL_CFLAGS) -I$(IDLDIR) $(IDL) -eazel-install-object.c : trilobite-eazel-install.h +eazel-install-types.c : trilobite-eazel-install.h CLEANFILES+=$(CORBA_GENERATED) trilobite-eazel-install.h libinstall_corba_a_SOURCES = \ + eazel-install-corba.c \ + eazel-install-object.c \ + eazel-install-corba-types.c \ + eazel-install-corba-callback.c \ $(CORBA_GENERATED) \ $(NULL) -EXTRA_DIST = \ - $(oaf_DATA) + diff --git a/components/services/install/lib/eazel-install-corba-callback.c b/components/services/install/lib/eazel-install-corba-callback.c new file mode 100644 index 000000000..4ed6baf88 --- /dev/null +++ b/components/services/install/lib/eazel-install-corba-callback.c @@ -0,0 +1,342 @@ +/* -*- 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 <config.h> +#include "eazel-install-corba-callback.h" +#include "eazel-install-corba-types.h" +/* +#include <gnome.h> +#include <liboaf/liboaf.h> +#include <bonobo.h> +#include <libtrilobite/libtrilobite.h> +#include "trilobite-eazel-install.h" +*/ + +enum { + DOWNLOAD_PROGRESS, + INSTALL_PROGRESS, + UNINSTALL_PROGRESS, + + DOWNLOAD_FAILED, + INSTALL_FAILED, + UNINSTALL_FAILED, + + DEPENDENCY_CHECK, + + DONE, + + LAST_SIGNAL +}; + +/* The signal array, used for building the signal bindings */ + +static guint signals[LAST_SIGNAL] = { 0 }; + +static BonoboObjectClass *eazel_install_callback_parent_class; + +static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL }; + +typedef struct { + POA_Trilobite_Eazel_InstallCallback poa; + EazelInstallCallback *object; +} impl_POA_Trilobite_Eazel_InstallCallback; + +static void +impl_download_progress (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const char *name, + const CORBA_long amount, + const CORBA_long total, + CORBA_Environment * ev) +{ + gtk_signal_emit (GTK_OBJECT (servant->object), signals[DOWNLOAD_PROGRESS], name, amount, total); +} + +static void +impl_download_failed (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const char *name, + CORBA_Environment * ev) +{ + gtk_signal_emit (GTK_OBJECT (servant->object), signals[DOWNLOAD_FAILED], name); +} + +static void +impl_dep_check (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const Trilobite_Eazel_PackageStruct *corbapack, + const Trilobite_Eazel_PackageDataStruct *corbaneeds, + CORBA_Environment * ev) +{ + PackageData *pack, *needs; + pack = packagedata_from_corba_packagestruct (corbapack); + needs = packagedata_from_corba_packagedatastruct (*corbaneeds); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[DEPENDENCY_CHECK], pack, needs); +} + +static void +impl_install_progress (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const Trilobite_Eazel_PackageStruct *corbapack, + const CORBA_long amount, + const CORBA_long total, + CORBA_Environment * ev) +{ + PackageData *pack; + pack = packagedata_from_corba_packagestruct (corbapack); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[INSTALL_PROGRESS], pack, amount, total); +} + +static void +impl_uninstall_progress (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const Trilobite_Eazel_PackageStruct *corbapack, + const CORBA_long amount, + const CORBA_long total, + CORBA_Environment * ev) +{ + PackageData *pack; + pack = packagedata_from_corba_packagestruct (corbapack); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[UNINSTALL_PROGRESS], pack, amount, total); +} + +static void +impl_install_failed (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const Trilobite_Eazel_PackageStruct *corbapack, + CORBA_Environment * ev) +{ + PackageData *pack; + pack = packagedata_from_corba_packagestruct (corbapack); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[INSTALL_FAILED], pack); +} + +static void +impl_uninstall_failed (impl_POA_Trilobite_Eazel_InstallCallback *servant, + const Trilobite_Eazel_PackageStruct *corbapack, + CORBA_Environment * ev) +{ + PackageData *pack; + pack = packagedata_from_corba_packagestruct (corbapack); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[UNINSTALL_FAILED], pack); +} + +static void +impl_done (impl_POA_Trilobite_Eazel_InstallCallback *servant, + CORBA_Environment * ev) +{ + gtk_signal_emit (GTK_OBJECT (servant->object), signals[DONE]); +} + +POA_Trilobite_Eazel_InstallCallback__epv* +eazel_install_callback_get_epv () +{ + POA_Trilobite_Eazel_InstallCallback__epv *epv; + + epv = g_new0 (POA_Trilobite_Eazel_InstallCallback__epv, 1); + epv->download_progress = (gpointer)&impl_download_progress; + epv->dependency_check = (gpointer)&impl_dep_check; + epv->install_progress = (gpointer)&impl_install_progress; + epv->uninstall_progress = (gpointer)&impl_uninstall_progress; + epv->install_failed = (gpointer)&impl_install_failed; + epv->download_failed = (gpointer)&impl_download_failed; + epv->uninstall_failed = (gpointer)&impl_uninstall_failed; + epv->done = (gpointer)&impl_done; + + return epv; +}; + +Trilobite_Eazel_InstallCallback +eazel_install_callback_create_corba_object (BonoboObject *service) { + impl_POA_Trilobite_Eazel_InstallCallback *servant; + CORBA_Environment ev; + + g_assert (service != NULL); + g_assert (IS_EAZEL_INSTALL_CALLBACK (service)); + + CORBA_exception_init (&ev); + + servant = (impl_POA_Trilobite_Eazel_InstallCallback*)g_new0 (PortableServer_Servant,1); + ((POA_Trilobite_Eazel_InstallCallback*) servant)->vepv = + EAZEL_INSTALL_CALLBACK_CLASS ( GTK_OBJECT (service)->klass)->servant_vepv; + POA_Trilobite_Eazel_InstallCallback__init (servant, &ev); + ORBIT_OBJECT_KEY (((POA_Trilobite_Eazel_InstallCallback*)servant)->_private)->object = NULL; + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Cannot instantiate Eazel_InstallCallback corba object"); + g_free (servant); + CORBA_exception_free (&ev); + return CORBA_OBJECT_NIL; + } + + CORBA_exception_free (&ev); + + /* Return the bonobo activation of the servant */ + return (Trilobite_Eazel_InstallCallback) bonobo_object_activate_servant (service, servant); +} + + +/***************************************** + GTK+ object stuff +*****************************************/ + +void +eazel_install_callback_destroy (GtkObject *object) +{ + EazelInstallCallback *service; + + g_return_if_fail (object != NULL); + g_return_if_fail (EAZEL_INSTALL_CALLBACK (object)); + + service = EAZEL_INSTALL_CALLBACK (object); + + /* FIXME bugzilla.eazel.com 1282. + implement this properly */ + g_message ("in eazel_install_callback_destroy"); +} + +static void +eazel_install_callback_class_initialize (EazelInstallCallbackClass *klass) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass*)klass; + object_class->destroy = (void(*)(GtkObject*))eazel_install_callback_destroy; + + eazel_install_callback_parent_class = gtk_type_class (bonobo_object_get_type ()); + klass->servant_vepv = g_new0 (POA_Trilobite_Eazel_InstallCallback__vepv,1); + ((POA_Trilobite_Eazel_InstallCallback__vepv*)klass->servant_vepv)->_base_epv = &base_epv; + ((POA_Trilobite_Eazel_InstallCallback__vepv*)klass->servant_vepv)->Bonobo_Unknown_epv = bonobo_object_get_epv (); + ((POA_Trilobite_Eazel_InstallCallback__vepv*)klass->servant_vepv)->Trilobite_Eazel_InstallCallback_epv = + eazel_install_callback_get_epv (); + + signals[DOWNLOAD_PROGRESS] = + gtk_signal_new ("download_progress", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, download_progress), + gtk_marshal_NONE__POINTER_INT_INT, + GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_INT); + signals[INSTALL_PROGRESS] = + gtk_signal_new ("install_progress", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, install_progress), + gtk_marshal_NONE__POINTER_INT_INT, + GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_INT); + signals[UNINSTALL_PROGRESS] = + gtk_signal_new ("uninstall_progress", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, uninstall_progress), + gtk_marshal_NONE__POINTER_INT_INT, + GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_INT); + signals[DOWNLOAD_FAILED] = + gtk_signal_new ("download_failed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, download_failed), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + signals[INSTALL_FAILED] = + gtk_signal_new ("install_failed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, install_failed), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + signals[UNINSTALL_FAILED] = + gtk_signal_new ("uninstall_failed", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, uninstall_failed), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); + signals[DEPENDENCY_CHECK] = + gtk_signal_new ("dependency_check", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, dependency_check), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); + signals[DONE] = + gtk_signal_new ("done", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallCallbackClass, done), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); +} + +static void +eazel_install_callback_initialize (EazelInstallCallback *service) { + /* g_message ("in eazel_install_callback_initialize"); */ + + g_assert (service != NULL); + g_assert (IS_EAZEL_INSTALL_CALLBACK (service)); + + service->cb = eazel_install_callback_create_corba_object (BONOBO_OBJECT (service)); + + /* This sets the bonobo structures in service using the corba object */ + if (!bonobo_object_construct (BONOBO_OBJECT (service), service->cb)) { + g_warning ("bonobo_object_construct failed"); + } +} + +GtkType +eazel_install_callback_get_type() { + static GtkType service_type = 0; + + /* g_message ("into eazel_install_callback_get_type"); */ + + /* First time it's called ? */ + if (!service_type) + { + static const GtkTypeInfo service_info = + { + "EazelInstallCallback", + sizeof (EazelInstallCallback), + sizeof (EazelInstallCallbackClass), + (GtkClassInitFunc) eazel_install_callback_class_initialize, + (GtkObjectInitFunc) eazel_install_callback_initialize, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + service_type = gtk_type_unique (bonobo_object_get_type (), &service_info); + } + + return service_type; +} + +EazelInstallCallback* +eazel_install_callback_new() +{ + EazelInstallCallback *service; + + service = EAZEL_INSTALL_CALLBACK (gtk_object_new (TYPE_EAZEL_INSTALL_CALLBACK, NULL)); + + return service; +} + +Trilobite_Eazel_InstallCallback +eazel_install_callback_corba (EazelInstallCallback *service) +{ + return service->cb; +} diff --git a/components/services/install/lib/eazel-install-corba-callback.h b/components/services/install/lib/eazel-install-corba-callback.h new file mode 100644 index 000000000..e5e32ece6 --- /dev/null +++ b/components/services/install/lib/eazel-install-corba-callback.h @@ -0,0 +1,85 @@ +/* -*- 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 Library 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 Library 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 EAZEL_INSTALL_CORBA_CALLBACK_H +#define EAZEL_INSTALL_CORBA_CALLBACK_H + +#include <libgnome/gnome-defs.h> +#include "bonobo.h" +#include "trilobite-eazel-install.h" + +#include "eazel-install-types.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define TYPE_EAZEL_INSTALL_CALLBACK (eazel_install_callback_get_type ()) +#define EAZEL_INSTALL_CALLBACK(obj) (GTK_CHECK_CAST ((obj), TYPE_EAZEL_INSTALL_CALLBACK, EazelInstallCallback)) +#define EAZEL_INSTALL_CALLBACK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_EAZEL_INSTALL_CALLBACK, EazelInstallCallbackClass)) +#define IS_EAZEL_INSTALL_CALLBACK(obj) (GTK_CHECK_TYPE ((obj), TYPE_EAZEL_INSTALL_CALLBACK)) +#define IS_EAZEL_INSTALL_CALLBACK_CLASS(klass)(GTK_CHECK_CLASS_TYPE ((obj), TYPE_EAZEL_INSTALL_CALLBACK)) + +typedef struct _EazelInstallCallback EazelInstallCallback; +typedef struct _EazelInstallCallbackClass EazelInstallCallbackClass; + +struct _EazelInstallCallbackClass +{ + BonoboObjectClass parent_class; + + /* signal prototypes */ + void (*download_progress) (EazelInstallCallback *service, const char *name, int amount, int total); + void (*install_progress) (EazelInstallCallback *service, const PackageData *pack, int amount, int total); + void (*uninstall_progress) (EazelInstallCallback *service, const PackageData *pack, int amount, int total); + + void (*dependency_check) (EazelInstallCallback *service, const PackageData *package, const PackageData *needed ); + + void (*download_failed) (EazelInstallCallback *service, char *name); + void (*install_failed) (EazelInstallCallback *service, PackageData *pd); + void (*uninstall_failed) (EazelInstallCallback *service, PackageData *pd); + + void (*done) (); + + gpointer servant_vepv; +}; + +struct _EazelInstallCallback +{ + BonoboObject parent; + Trilobite_Eazel_InstallCallback cb; +}; + +EazelInstallCallback *eazel_install_callback_new (void); +GtkType eazel_install_callback_get_type (void); +void eazel_install_callback_destroy (GtkObject *object); + +POA_Trilobite_Eazel_InstallCallback__epv *eazel_install_callback_get_epv (void); +Trilobite_Eazel_InstallCallback eazel_install_callback_create_corba_object (BonoboObject *service); + +Trilobite_Eazel_InstallCallback eazel_install_callback_corba (EazelInstallCallback *service); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* EAZEL_INSTALL_CORBA_CALLBACK_H */ diff --git a/components/services/install/lib/eazel-install-corba-types.c b/components/services/install/lib/eazel-install-corba-types.c new file mode 100644 index 000000000..e8d70a6f4 --- /dev/null +++ b/components/services/install/lib/eazel-install-corba-types.c @@ -0,0 +1,238 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * Copyright (C) 2000 Helix Code, 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 "eazel-install-corba-types.h" +#include <libtrilobite/trilobite-core-distribution.h> + +Trilobite_Eazel_PackageStructList* +corba_packagestructlist_from_packagedata_list (GList *packages) +{ + Trilobite_Eazel_PackageStructList *packagelist; + int i; + + packagelist = Trilobite_Eazel_PackageStructList__alloc (); + packagelist->_length = g_list_length (packages); + packagelist->_buffer = CORBA_sequence_Trilobite_Eazel_PackageStruct_allocbuf (packagelist->_length); + for (i = 0; i < packagelist->_length; i++) { + PackageData *pack; + pack = (PackageData*)(g_list_nth (packages,i)->data); + packagelist->_buffer[i] = corba_packagestruct_from_packagedata (pack); + } + + return packagelist; +} + + +Trilobite_Eazel_PackageDataStructList +corba_packagedatastructlist_from_packagedata_list (GList *packages) +{ + Trilobite_Eazel_PackageDataStructList packagelist; + int i; + + packagelist._length = g_list_length (packages); + packagelist._buffer = CORBA_sequence_Trilobite_Eazel_PackageDataStruct_allocbuf (packagelist._length); + for (i = 0; i < packagelist._length; i++) { + PackageData *pack; + pack = (PackageData*)(g_list_nth (packages,i)->data); + packagelist._buffer[i] = corba_packagedatastruct_from_packagedata (pack); + } + + return packagelist; +} + +Trilobite_Eazel_PackageDataStruct +corba_packagedatastruct_from_packagedata (const PackageData *pack) +{ + Trilobite_Eazel_PackageDataStruct corbapack; + corbapack.name = pack->name ? CORBA_string_dup (pack->name) : CORBA_string_dup (""); + corbapack.version = pack->version ? CORBA_string_dup (pack->version) : CORBA_string_dup (""); + corbapack.archtype = pack->archtype ? CORBA_string_dup (pack->archtype) : CORBA_string_dup (""); + corbapack.filename = pack->filename ? CORBA_string_dup (pack->filename) : CORBA_string_dup (""); + corbapack.toplevel = pack->toplevel; + + if (pack->distribution.name == DISTRO_UNKNOWN) { + DistributionInfo dist; + dist = trilobite_get_distribution (); + corbapack.distribution.name = trilobite_get_distribution_name (dist, FALSE); + corbapack.distribution.major = dist.version_major; + corbapack.distribution.minor = dist.version_minor; + } else { + corbapack.distribution.name = trilobite_get_distribution_name (pack->distribution, FALSE); + corbapack.distribution.major = pack->distribution.version_major; + corbapack.distribution.minor = pack->distribution.version_minor; + } + corbapack.release = pack->minor ? CORBA_string_dup (pack->minor) : CORBA_string_dup (""); + corbapack.summary = pack->summary ? CORBA_string_dup (pack->minor) : CORBA_string_dup (""); + + switch (pack->status) { + case PACKAGE_UNKNOWN_STATUS: + corbapack.status = Trilobite_Eazel_UNKNOWN_STATUS; + break; + case PACKAGE_SOURCE_NOT_SUPPORTED: + corbapack.status = Trilobite_Eazel_SOURCE_NOT_SUPPORTED; + break; + case PACKAGE_DEPENDENCY_FAIL: + corbapack.status = Trilobite_Eazel_DEPENDENCY_FAIL; + break; + case PACKAGE_BREAKS_DEPENDENCY: + corbapack.status = Trilobite_Eazel_BREAKS_DEPENDENCY; + break; + case PACKAGE_INVALID: + corbapack.status = Trilobite_Eazel_INVALID; + break; + case PACKAGE_CANNOT_OPEN: + corbapack.status = Trilobite_Eazel_CANNOT_OPEN; + break; + case PACKAGE_PARTLY_RESOLVED: + corbapack.status = Trilobite_Eazel_PARTLY_RESOLVED; + break; + case PACKAGE_RESOLVED: + corbapack.status = Trilobite_Eazel_RESOLVED; + break; + } + + return corbapack; +} + + +Trilobite_Eazel_PackageStruct +corba_packagestruct_from_packagedata (const PackageData *pack) +{ + Trilobite_Eazel_PackageStruct corbapack; + corbapack.data = corba_packagedatastruct_from_packagedata (pack); + + if (pack->soft_depends) { + corbapack.soft_depends = corba_packagedatastructlist_from_packagedata_list (pack->soft_depends); + } else { + corbapack.soft_depends._length = 0; + } + if (pack->hard_depends) { + corbapack.hard_depends = corba_packagedatastructlist_from_packagedata_list (pack->hard_depends); + } else { + corbapack.hard_depends._length = 0; + } + if (pack->breaks) { + corbapack.breaks = corba_packagedatastructlist_from_packagedata_list (pack->breaks); + } else { + corbapack.breaks._length = 0; + } + return corbapack; +} + + + +GList* +packagedata_list_from_corba_packagestructlist (const Trilobite_Eazel_PackageStructList corbapack) +{ + GList *result; + int i; + + result = NULL; + + for (i = 0; i < corbapack._length; i++) { + PackageData *pack; + pack = packagedata_from_corba_packagestruct (&(corbapack._buffer[i])); + result = g_list_prepend (result, pack); + } + + return result; +} + +GList* +packagedata_list_from_corba_packagedatastructlist (const Trilobite_Eazel_PackageDataStructList corbapack) +{ + GList *result; + int i; + + result = NULL; + + for (i = 0; i < corbapack._length; i++) { + PackageData *pack; + pack = packagedata_from_corba_packagedatastruct (corbapack._buffer[i]); + result = g_list_prepend (result, pack); + } + + return result; +} + +PackageData* +packagedata_from_corba_packagedatastruct (const Trilobite_Eazel_PackageDataStruct corbapack) +{ + PackageData *pack; + + pack = packagedata_new(); + pack->name = strlen (corbapack.name) ? g_strdup (corbapack.name) : NULL; + pack->version = strlen (corbapack.version) ? g_strdup (corbapack.version) : NULL; + pack->minor = strlen (corbapack.release) ? g_strdup (corbapack.release) : NULL; + pack->archtype = strlen (corbapack.archtype) ? g_strdup (corbapack.archtype) : NULL; + pack->filename = strlen (corbapack.filename) ? g_strdup (corbapack.filename) : NULL; + pack->summary = strlen (corbapack.summary) ? g_strdup (corbapack.summary) : NULL; + pack->toplevel = corbapack.toplevel; + pack->bytesize = corbapack.bytesize; + + pack->distribution.name = trilobite_get_distribution_enum (corbapack.distribution.name); + pack->distribution.version_major = corbapack.distribution.major; + pack->distribution.version_minor = corbapack.distribution.minor; + + switch (corbapack.status) { + case Trilobite_Eazel_UNKNOWN_STATUS: + pack->status = PACKAGE_UNKNOWN_STATUS; + break; + case Trilobite_Eazel_SOURCE_NOT_SUPPORTED: + pack->status = PACKAGE_SOURCE_NOT_SUPPORTED; + break; + case Trilobite_Eazel_DEPENDENCY_FAIL: + pack->status = PACKAGE_DEPENDENCY_FAIL; + break; + case Trilobite_Eazel_BREAKS_DEPENDENCY: + pack->status = PACKAGE_BREAKS_DEPENDENCY; + break; + case Trilobite_Eazel_INVALID: + pack->status = PACKAGE_INVALID; + break; + case Trilobite_Eazel_CANNOT_OPEN: + pack->status = PACKAGE_CANNOT_OPEN; + break; + case Trilobite_Eazel_PARTLY_RESOLVED: + pack->status = PACKAGE_PARTLY_RESOLVED; + break; + case Trilobite_Eazel_RESOLVED: + pack->status = PACKAGE_RESOLVED; + break; + } + + return pack; +} + +PackageData* +packagedata_from_corba_packagestruct (const Trilobite_Eazel_PackageStruct *corbapack) +{ + PackageData *pack; + + pack = packagedata_from_corba_packagedatastruct (corbapack->data); + pack->soft_depends = packagedata_list_from_corba_packagedatastructlist (corbapack->soft_depends); + pack->hard_depends = packagedata_list_from_corba_packagedatastructlist (corbapack->hard_depends); + pack->breaks = packagedata_list_from_corba_packagedatastructlist (corbapack->breaks); + + return pack; +} diff --git a/components/services/install/lib/eazel-install-corba-types.h b/components/services/install/lib/eazel-install-corba-types.h new file mode 100644 index 000000000..310afc0d5 --- /dev/null +++ b/components/services/install/lib/eazel-install-corba-types.h @@ -0,0 +1,41 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Copyright (C) 2000 Eazel, Inc + * Copyright (C) 2000 Helix Code, 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 __EAZEL_INSTALL_SERVICES_CORBA_TYPES_H__ +#define __EAZEL_INSTALL_SERVICES_CORBA_TYPES_H__ + +#include <eazel-install-types.h> +#include <trilobite-eazel-install.h> +#include <glib.h> + +Trilobite_Eazel_PackageStructList *corba_packagestructlist_from_packagedata_list (GList *packages); +Trilobite_Eazel_PackageDataStructList corba_packagedatastructlist_from_packagedata_list (GList *packages); + +Trilobite_Eazel_PackageStruct corba_packagestruct_from_packagedata (const PackageData *pack); +Trilobite_Eazel_PackageDataStruct corba_packagedatastruct_from_packagedata (const PackageData *pack); + +GList* packagedata_list_from_corba_packagedatastructlist (const Trilobite_Eazel_PackageDataStructList corbapack); +GList *packagedata_list_from_corba_packagestructlist (const Trilobite_Eazel_PackageStructList corbapack); +PackageData *packagedata_from_corba_packagedatastruct (const Trilobite_Eazel_PackageDataStruct corbapack); +PackageData *packagedata_from_corba_packagestruct (const Trilobite_Eazel_PackageStruct *corbapack); +#endif /* __EAZEL_INSTALL_SERVICES_TYPES_H__ */ diff --git a/components/services/install/lib/eazel-install-corba.c b/components/services/install/lib/eazel-install-corba.c new file mode 100644 index 000000000..e87cf33ab --- /dev/null +++ b/components/services/install/lib/eazel-install-corba.c @@ -0,0 +1,372 @@ +/* -*- 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 <config.h> +#include <gnome.h> + +#ifndef EAZEL_INSTALL_NO_CORBA +#include <liboaf/liboaf.h> +#include <bonobo.h> +#include <libtrilobite/libtrilobite.h> +#include "trilobite-eazel-install.h" + +#include "eazel-install-public.h" +#include "eazel-install-private.h" + +#include "eazel-install-corba-types.h" + +/***************************************** + Corba stuff +*****************************************/ + +typedef struct { + POA_Trilobite_Eazel_Install poa; + EazelInstall *object; +} impl_POA_Trilobite_Eazel_Install; + +static void +impl_Eazel_Install_install(impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *package_list, + const Trilobite_Eazel_InstallCallback cb, + CORBA_Environment * ev) +{ + servant->object->callback = cb; + + return; +} + +static void +impl_Eazel_Install_uninstall(impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *package_list, + const Trilobite_Eazel_InstallCallback cb, + CORBA_Environment * ev) +{ + servant->object->callback = cb; + + return; +} + +static void +impl_Eazel_Install_install_packages(impl_POA_Trilobite_Eazel_Install *servant, + const Trilobite_Eazel_PackageStructList *packagelist, + const Trilobite_Eazel_InstallCallback cb, + CORBA_Environment * ev) +{ + GList *packages; + GList *categories; + CategoryData *category; + int i; + + servant->object->callback = cb; + packages = NULL; + categories = NULL; + + for (i = 0; i < packagelist->_length; i++) { + PackageData *pack; + Trilobite_Eazel_PackageStruct corbapack; + + corbapack = packagelist->_buffer [i]; + pack = packagedata_from_corba_packagestruct (&corbapack); + + g_message ("Installing %s", pack->name); + + /* FIXME bugzilla.eazel.com 1366 + need to copy distribution here as well */ + + packages = g_list_prepend (packages, pack); + } + category = g_new0 (CategoryData, 1); + category->packages = packages; + categories = g_list_prepend (categories, category); + servant->object->callback = cb; + + eazel_install_install_packages (servant->object, categories); + + categorydata_destroy (category); + g_list_free (categories); + + return; +} + +static void +impl_Eazel_Install_uninstall_packages(impl_POA_Trilobite_Eazel_Install *servant, + const Trilobite_Eazel_PackageStructList *packages, + const Trilobite_Eazel_InstallCallback cb, + CORBA_Environment * ev) +{ + servant->object->callback = cb; + + return; +} + +static void +impl_Eazel_Install__set_verbose (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_boolean value, + CORBA_Environment *ev) +{ + eazel_install_set_verbose (servant->object, value); +} + +static CORBA_boolean +impl_Eazel_Install__get_verbose (impl_POA_Trilobite_Eazel_Install *servant, + CORBA_Environment *ev) +{ + return eazel_install_get_verbose (servant->object); +} + +static void +impl_Eazel_Install__set_silent (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_boolean value, + CORBA_Environment *ev) +{ + eazel_install_set_silent (servant->object, value); +} + +static CORBA_boolean +impl_Eazel_Install__get_silent (impl_POA_Trilobite_Eazel_Install *servant, + CORBA_Environment *ev) +{ + return eazel_install_get_silent (servant->object); +} + +static void +impl_Eazel_Install__set_test_mode (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_boolean value, + CORBA_Environment *ev) +{ + eazel_install_set_test (servant->object, value); +} + +static CORBA_boolean +impl_Eazel_Install__get_test_mode (impl_POA_Trilobite_Eazel_Install *servant, + CORBA_Environment *ev) +{ + return eazel_install_get_test (servant->object); +} + +static void +impl_Eazel_Install__set_force (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_boolean value, + CORBA_Environment *ev) +{ + eazel_install_set_force (servant->object, value); +} + +static CORBA_boolean +impl_Eazel_Install__get_force (impl_POA_Trilobite_Eazel_Install *servant, + CORBA_Environment *ev) +{ + return eazel_install_get_force (servant->object); +} + +static void +impl_Eazel_Install__set_update (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_boolean value, + CORBA_Environment *ev) +{ + eazel_install_set_update (servant->object, value); +} + +static CORBA_boolean +impl_Eazel_Install__get_update (impl_POA_Trilobite_Eazel_Install *servant, + CORBA_Environment *ev) +{ + return eazel_install_get_update (servant->object); +} + +static void +impl_Eazel_Install__set_tmp_dir (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + eazel_install_set_tmp_dir (servant->object, value); +} + + +static CORBA_char* +impl_Eazel_Install__get_tmp_dir (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + return eazel_install_get_tmp_dir (servant->object); +} + +static void +impl_Eazel_Install__set_server (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + eazel_install_set_server (servant->object, value); +} + + +static CORBA_char* +impl_Eazel_Install__get_server (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + return eazel_install_get_server (servant->object); +} + +static void +impl_Eazel_Install__set_server_port (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_long value, + CORBA_Environment *ev) +{ + eazel_install_set_server_port (servant->object, value); +} + + +static CORBA_long +impl_Eazel_Install__get_server_port (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + return eazel_install_get_server_port (servant->object); +} + +static void +impl_Eazel_Install__set_log_file (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + eazel_install_open_log (servant->object, value); +} + + +static CORBA_char* +impl_Eazel_Install__get_log_file (impl_POA_Trilobite_Eazel_Install *servant, + const CORBA_char *value, + CORBA_Environment *ev) +{ + return servant->object->private->logfilename; +} + +static void +impl_Eazel_Install__set_protocol (impl_POA_Trilobite_Eazel_Install *servant, + const Trilobite_Eazel_ProtocolEnum value, + CORBA_Environment *ev) +{ + switch (value) { + case Trilobite_Eazel_PROTOCOL_HTTP: + eazel_install_set_protocol (servant->object, PROTOCOL_HTTP); + break; + case Trilobite_Eazel_PROTOCOL_FTP: + eazel_install_set_protocol (servant->object, PROTOCOL_FTP); + break; + case Trilobite_Eazel_PROTOCOL_LOCAL: + eazel_install_set_protocol (servant->object, PROTOCOL_LOCAL); + break; + } +} + + +static Trilobite_Eazel_ProtocolEnum +impl_Eazel_Install__get_protocol (impl_POA_Trilobite_Eazel_Install *servant, + CORBA_Environment *ev) +{ + switch (eazel_install_get_protocol (servant->object)) { + default: + case PROTOCOL_HTTP: + return Trilobite_Eazel_PROTOCOL_HTTP; + break; + case PROTOCOL_FTP: + return Trilobite_Eazel_PROTOCOL_FTP; + break; + case PROTOCOL_LOCAL: + return Trilobite_Eazel_PROTOCOL_LOCAL; + break; + } +} + +POA_Trilobite_Eazel_Install__epv* +eazel_install_get_epv () +{ + POA_Trilobite_Eazel_Install__epv *epv; + + epv = g_new0 (POA_Trilobite_Eazel_Install__epv, 1); + epv->install = (gpointer)&impl_Eazel_Install_install; + epv->uninstall = (gpointer)&impl_Eazel_Install_uninstall; + epv->install_packages = (gpointer)&impl_Eazel_Install_install_packages; + epv->uninstall_packages = (gpointer)&impl_Eazel_Install_uninstall_packages; + + epv->_set_verbose = (gpointer)&impl_Eazel_Install__set_verbose; + epv->_get_verbose = (gpointer)&impl_Eazel_Install__get_verbose; + + epv->_set_silent = (gpointer)&impl_Eazel_Install__set_silent; + epv->_get_silent = (gpointer)&impl_Eazel_Install__get_silent; + + epv->_set_test_mode = (gpointer)&impl_Eazel_Install__set_test_mode; + epv->_get_test_mode = (gpointer)&impl_Eazel_Install__get_test_mode; + + epv->_set_force = (gpointer)&impl_Eazel_Install__set_force; + epv->_get_force = (gpointer)&impl_Eazel_Install__get_force; + + epv->_set_update = (gpointer)&impl_Eazel_Install__set_update; + epv->_get_update = (gpointer)&impl_Eazel_Install__get_update; + + epv->_set_protocol = (gpointer)&impl_Eazel_Install__set_protocol; + epv->_get_protocol = (gpointer)&impl_Eazel_Install__get_protocol; + + epv->_set_server = (gpointer)&impl_Eazel_Install__set_server; + epv->_get_server = (gpointer)&impl_Eazel_Install__get_server; + epv->_set_server_port = (gpointer)&impl_Eazel_Install__set_server_port; + epv->_get_server_port = (gpointer)&impl_Eazel_Install__get_server_port; + + epv->_set_log_file = (gpointer)&impl_Eazel_Install__set_log_file; + epv->_get_log_file = (gpointer)&impl_Eazel_Install__get_log_file; + + epv->_set_tmp_dir = (gpointer)&impl_Eazel_Install__set_tmp_dir; + epv->_get_tmp_dir = (gpointer)&impl_Eazel_Install__get_tmp_dir; + + return epv; +}; + +Trilobite_Eazel_Install +eazel_install_create_corba_object (BonoboObject *service) { + impl_POA_Trilobite_Eazel_Install *servant; + CORBA_Environment ev; + + g_assert (service != NULL); + g_assert (IS_EAZEL_INSTALL (service)); + + CORBA_exception_init (&ev); + + servant = (impl_POA_Trilobite_Eazel_Install*)g_new0 (PortableServer_Servant,1); + ((POA_Trilobite_Eazel_Install*) servant)->vepv = EAZEL_INSTALL_CLASS ( GTK_OBJECT (service)->klass)->servant_vepv; + POA_Trilobite_Eazel_Install__init (servant, &ev); + ORBIT_OBJECT_KEY (((POA_Trilobite_Eazel_Install*)servant)->_private)->object = NULL; + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Cannot instantiate Eazel_Install corba object"); + g_free (servant); + CORBA_exception_free (&ev); + return CORBA_OBJECT_NIL; + } + + CORBA_exception_free (&ev); + + /* Return the bonobo activation of the servant */ + return (Trilobite_Eazel_Install) bonobo_object_activate_servant (service, servant); +} +#endif /* EAZEL_INSTALL_NO_CORBA */ diff --git a/components/services/install/lib/eazel-install-object.c b/components/services/install/lib/eazel-install-object.c index a5128b90c..7b1ca0a10 100644 --- a/components/services/install/lib/eazel-install-object.c +++ b/components/services/install/lib/eazel-install-object.c @@ -24,19 +24,21 @@ #include <config.h> #include <gnome.h> -#ifndef STANDALONE +#include "eazel-install-public.h" +#include "eazel-install-private.h" + +#ifndef EAZEL_INSTALL_NO_CORBA #include <liboaf/liboaf.h> #include <bonobo.h> #include <libtrilobite/libtrilobite.h> #include "trilobite-eazel-install.h" -#endif /* STANDALONE */ - -#include "eazel-install-public.h" -#include "eazel-install-private.h" +#include "eazel-install-corba-types.h" +#endif /* EAZEL_INSTALL_NO_CORBA */ #include "eazel-install-metadata.h" #include "eazel-install-protocols.h" -#include "eazel-install-rpm-glue.c" +#include "eazel-install-rpm-glue.h" +#include "eazel-install-types.h" enum { DOWNLOAD_PROGRESS, @@ -47,6 +49,7 @@ enum { UNINSTALL_FAILED, DEPENDENCY_CHECK, + DONE, LAST_SIGNAL }; @@ -65,13 +68,13 @@ enum { ARG_PROTOCOL, ARG_TMP_DIR, ARG_RPMRC_FILE, - ARG_HOSTNAME, + ARG_SERVER, ARG_RPM_STORAGE_PATH, ARG_PACKAGE_LIST_STORAGE_PATH, ARG_PACKAGE_LIST, ARG_ROOT_DIR, ARG_PACKAGE_SYSTEM, - ARG_PORT_NUMBER + ARG_SERVER_PORT }; /* The signal array, used for building the signal bindings */ @@ -80,49 +83,46 @@ static guint signals[LAST_SIGNAL] = { 0 }; /* This is the parent class pointer */ -#ifdef STANDALONE +#ifdef EAZEL_INSTALL_NO_CORBA static GtkObjectClass *eazel_install_parent_class; #else static BonoboObjectClass *eazel_install_parent_class; -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ /* prototypes */ -#ifndef STANDALONE +void eazel_install_emit_install_progress_default (EazelInstall *service, + const PackageData *pack, + int amount, + int total); -/***************************************** - Corba stuff -*****************************************/ +void eazel_install_emit_download_progress_default (EazelInstall *service, + const char *name, + int amount, + int total); -static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL }; +void eazel_install_emit_download_failed_default (EazelInstall *service, + const char *name); -typedef struct { - POA_Trilobite_Eazel_Install poa; - EazelInstall *object; -} impl_POA_Trilobite_Eazel_Install; +void eazel_install_emit_install_failed_default (EazelInstall *service, + const PackageData *pack); -static void -impl_Eazel_Install_new_packages(impl_POA_Trilobite_Eazel_Install *servant, - const Eazel_InstallCallback cb, - CORBA_Environment * ev) -{ - servant->object->callback = cb; +void eazel_install_emit_dependency_check_default (EazelInstall *service, + const PackageData *pack, + const PackageData *needs); - return; -} +void eazel_install_emit_done_default (EazelInstall *service); -POA_Trilobite_Eazel_Install__epv* -eazel_install_get_epv () -{ - POA_Trilobite_Eazel_Install__epv *epv; +#ifndef EAZEL_INSTALL_NO_CORBA - epv = g_new0 (POA_Trilobite_Eazel_Install__epv, 1); - epv->new_packages = (gpointer)&impl_Eazel_Install_new_packages; - return epv; -}; +/***************************************** + Corba stuff +*****************************************/ + +static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL }; -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ /***************************************** GTK+ object stuff @@ -189,8 +189,8 @@ eazel_install_set_arg (GtkObject *object, case ARG_RPMRC_FILE: eazel_install_set_rpmrc_file (service, (char*)GTK_VALUE_POINTER(*arg)); break; - case ARG_HOSTNAME: - eazel_install_set_hostname (service, (char*)GTK_VALUE_POINTER(*arg)); + case ARG_SERVER: + eazel_install_set_server (service, (char*)GTK_VALUE_POINTER(*arg)); break; case ARG_RPM_STORAGE_PATH: eazel_install_set_rpm_storage_path (service, (char*)GTK_VALUE_POINTER(*arg)); @@ -201,8 +201,8 @@ eazel_install_set_arg (GtkObject *object, case ARG_PACKAGE_LIST: eazel_install_set_package_list (service, (char*)GTK_VALUE_POINTER(*arg)); break; - case ARG_PORT_NUMBER: - eazel_install_set_port_number (service, GTK_VALUE_UINT(*arg)); + case ARG_SERVER_PORT: + eazel_install_set_server_port (service, GTK_VALUE_UINT(*arg)); break; case ARG_PACKAGE_SYSTEM: eazel_install_set_package_system (service, GTK_VALUE_ENUM(*arg)); @@ -222,15 +222,15 @@ eazel_install_class_initialize (EazelInstallClass *klass) object_class->destroy = (void(*)(GtkObject*))eazel_install_destroy; object_class->set_arg = eazel_install_set_arg; -#ifdef STANDALONE +#ifdef EAZEL_INSTALL_NO_CORBA eazel_install_parent_class = gtk_type_class (gtk_object_get_type ()); #else eazel_install_parent_class = gtk_type_class (bonobo_object_get_type ()); klass->servant_vepv = g_new0 (POA_Trilobite_Eazel_Install__vepv,1); ((POA_Trilobite_Eazel_Install__vepv*)klass->servant_vepv)->_base_epv = &base_epv; ((POA_Trilobite_Eazel_Install__vepv*)klass->servant_vepv)->Bonobo_Unknown_epv = bonobo_object_get_epv (); - ((POA_Trilobite_Eazel_Install__vepv*)klass->servant_vepv)->Eazel_Install_epv = eazel_install_get_epv (); -#endif /* STANDALONE */ + ((POA_Trilobite_Eazel_Install__vepv*)klass->servant_vepv)->Trilobite_Eazel_Install_epv = eazel_install_get_epv (); +#endif /* EAZEL_INSTALL_NO_CORBA */ signals[DOWNLOAD_PROGRESS] = gtk_signal_new ("download_progress", @@ -252,7 +252,7 @@ eazel_install_class_initialize (EazelInstallClass *klass) object_class->type, GTK_SIGNAL_OFFSET (EazelInstallClass, download_failed), gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); + GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); signals[INSTALL_FAILED] = gtk_signal_new ("install_failed", GTK_RUN_LAST, @@ -274,8 +274,22 @@ eazel_install_class_initialize (EazelInstallClass *klass) GTK_SIGNAL_OFFSET (EazelInstallClass, dependency_check), gtk_marshal_NONE__POINTER_POINTER, GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); + signals[DONE] = + gtk_signal_new ("done", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EazelInstallClass, done), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); + klass->install_progress = eazel_install_emit_install_progress_default; + klass->download_progress = eazel_install_emit_download_progress_default; + klass->download_failed = eazel_install_emit_download_failed_default; + klass->install_failed = eazel_install_emit_install_failed_default; + klass->dependency_check = eazel_install_emit_dependency_check_default; + klass->done = eazel_install_emit_done_default; + gtk_object_add_arg_type ("EazelInstall::verbose", GTK_TYPE_BOOL, GTK_ARG_READWRITE, @@ -324,10 +338,10 @@ eazel_install_class_initialize (EazelInstallClass *klass) GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_RPMRC_FILE); - gtk_object_add_arg_type ("EazelInstall::hostname", + gtk_object_add_arg_type ("EazelInstall::server", GTK_TYPE_POINTER, GTK_ARG_READWRITE, - ARG_HOSTNAME); + ARG_SERVER); gtk_object_add_arg_type ("EazelInstall::rpm_storage_path", GTK_TYPE_POINTER, GTK_ARG_READWRITE, @@ -344,65 +358,35 @@ eazel_install_class_initialize (EazelInstallClass *klass) GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_ROOT_DIR); - gtk_object_add_arg_type ("EazelInstall::port_number", + gtk_object_add_arg_type ("EazelInstall::server_port", GTK_TYPE_UINT, GTK_ARG_READWRITE, - ARG_PORT_NUMBER); + ARG_SERVER_PORT); gtk_object_add_arg_type ("EazelInstall::package_system", GTK_TYPE_ENUM, GTK_ARG_READWRITE, ARG_PACKAGE_SYSTEM); } -#ifndef STANDALONE -static Eazel_Install -eazel_install_create_corba_object (BonoboObject *service) { - impl_POA_Trilobite_Eazel_Install *servant; - CORBA_Environment ev; - - g_assert (service != NULL); - g_assert (IS_EAZEL_INSTALL (service)); - - CORBA_exception_init (&ev); - - servant = (impl_POA_Trilobite_Eazel_Install*)g_new0 (PortableServer_Servant,1); - ((POA_Trilobite_Eazel_Install*) servant)->vepv = EAZEL_INSTALL_CLASS ( GTK_OBJECT (service)->klass)->servant_vepv; - POA_Trilobite_Eazel_Install__init (servant, &ev); - ORBIT_OBJECT_KEY (((POA_Trilobite_Eazel_Install*)servant)->_private)->object = NULL; - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("Cannot instantiate Eazel_Install corba object"); - g_free (servant); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - - /* Return the bonobo activation of the servant */ - return (Eazel_Install) bonobo_object_activate_servant (service, servant); -} -#endif /* STANDALONE */ - static void eazel_install_initialize (EazelInstall *service) { -#ifndef STANDALONE - Eazel_Install corba_service; -#endif /* STANDALONE */ +#ifndef EAZEL_INSTALL_NO_CORBA + Trilobite_Eazel_Install corba_service; +#endif /* EAZEL_INSTALL_NO_CORBA */ /* g_message ("in eazel_install_initialize"); */ g_assert (service != NULL); g_assert (IS_EAZEL_INSTALL (service)); -#ifndef STANDALONE +#ifndef EAZEL_INSTALL_NO_CORBA corba_service = eazel_install_create_corba_object (BONOBO_OBJECT (service)); /* This sets the bonobo structures in service using the corba object */ if (!bonobo_object_construct (BONOBO_OBJECT (service), corba_service)) { g_warning ("bonobo_object_construct failed"); } -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ service->private = g_new0 (EazelInstallPrivate,1); service->private->topts = g_new0 (TransferOptions, 1); @@ -413,6 +397,7 @@ eazel_install_initialize (EazelInstall *service) { service->private->packsys.rpm.db = NULL; service->private->packsys.rpm.set = NULL; service->private->logfile = NULL; + service->private->logfilename = NULL; } GtkType @@ -436,11 +421,11 @@ eazel_install_get_type() { (GtkClassInitFunc) NULL, }; -#ifdef STANDALONE +#ifdef EAZEL_INSTALL_NO_CORBA service_type = gtk_type_unique (gtk_object_get_type (), &service_info); #else service_type = gtk_type_unique (bonobo_object_get_type (), &service_info); -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ } return service_type; @@ -483,10 +468,10 @@ eazel_install_new_with_config (const char *config_file) "protocol", iopts->protocol, "tmp_dir", topts->tmp_dir, "rpmrc_file", topts->rpmrc_file, - "hostname", topts->hostname, + "server", topts->hostname, "rpm_storage_path", topts->rpm_storage_path, "package_list_storage_path", topts->pkg_list_storage_path, - "port_number", topts->port_number, + "server_port", topts->port_number, NULL)); /* FIXME bugzilla.eazel.com 982: @@ -522,7 +507,7 @@ eazel_install_fetch_remote_package_list (EazelInstall *service) g_print (_("Getting package list from remote server ...\n")); url = g_strdup_printf ("http://%s%s", - eazel_install_get_hostname (service), + eazel_install_get_server (service), eazel_install_get_package_list_storage_path (service)); retval = eazel_install_fetch_file (service, url, eazel_install_get_package_list (service)); @@ -536,60 +521,6 @@ eazel_install_fetch_remote_package_list (EazelInstall *service) return TRUE; } -void -eazel_install_emit_install_progress (EazelInstall *service, - const char *name, - int amount, - int total) -{ - SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[INSTALL_PROGRESS], name, amount, total); -} - -void -eazel_install_emit_download_progress (EazelInstall *service, - const char *name, - int amount, - int total) -{ - SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_PROGRESS], name, amount, total); -} - -void -eazel_install_emit_download_failed (EazelInstall *service, - const char *name, - gpointer info) -{ - SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_FAILED], name, info); -} - -void -eazel_install_emit_install_failed (EazelInstall *service, - const PackageData *pd) -{ - SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[INSTALL_FAILED], pd); -} - -void -eazel_install_emit_uninstall_failed (EazelInstall *service, - const PackageData *pd) -{ - SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[UNINSTALL_FAILED], pd); -} - -void -eazel_install_emit_dependency_check (EazelInstall *service, - const PackageData *package, - const PackageData *needs) -{ - SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[DEPENDENCY_CHECK], package, needs); -} - static void eazel_install_log (const char *domain, GLogLevelFlags flags, @@ -614,7 +545,14 @@ eazel_install_open_log (EazelInstall *service, g_message ("in eazel_install_open_log"); + if (service->private->logfile) { + fclose (service->private->logfile); + } service->private->logfile = fopen (fname, "wt"); + if (service->private->logfilename) { + g_free (service->private->logfilename); + } + service->private->logfilename = g_strdup (fname); if (service->private->logfile!=NULL) { g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR, (GLogFunc)eazel_install_log, @@ -631,7 +569,7 @@ eazel_install_install_packages (EazelInstall *service, GList *categories) { SANITY (service); - g_message ("eazel_install_new_packages"); + g_message ("eazel_install_install_packages"); if (!g_file_exists (eazel_install_get_tmp_dir (service))) { create_temporary_directory (eazel_install_get_tmp_dir (service)); @@ -653,6 +591,7 @@ eazel_install_install_packages (EazelInstall *service, GList *categories) if (install_new_packages (service, categories)==FALSE) { g_warning ("*** Install failed"); } + eazel_install_emit_done (service); } void @@ -660,7 +599,7 @@ eazel_install_uninstall (EazelInstall *service) { SANITY (service); - g_message ("eazel_install_new_packages"); + g_message ("eazel_install_uninstall"); switch (service->private->iopts->protocol) { case PROTOCOL_HTTP: @@ -677,6 +616,179 @@ eazel_install_uninstall (EazelInstall *service) } } +/************************************************ + Signal emitters and default handlers. + The default handlers check for the existance of + a corba callback, and if true, do the callback +**************************************************/ + + +void +eazel_install_emit_install_progress (EazelInstall *service, + const PackageData *pack, + int amount, + int total) +{ + SANITY(service); + gtk_signal_emit (GTK_OBJECT (service), signals[INSTALL_PROGRESS], pack, amount, total); +} + +void +eazel_install_emit_install_progress_default (EazelInstall *service, + const PackageData *pack, + int amount, + int total) +{ +#ifndef EAZEL_INSTALL_NO_CORBA + CORBA_Environment ev; + CORBA_exception_init (&ev); + SANITY(service); + if (service->callback != CORBA_OBJECT_NIL) { + Trilobite_Eazel_PackageStruct package; + package = corba_packagestruct_from_packagedata (pack); + Trilobite_Eazel_InstallCallback_install_progress (service->callback, &package, amount, total, &ev); + } + CORBA_exception_free (&ev); +#endif /* EAZEL_INSTALL_NO_CORBA */ +} + +void +eazel_install_emit_download_progress (EazelInstall *service, + const char *name, + int amount, + int total) +{ + SANITY(service); + gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_PROGRESS], name, amount, total); +} + +void +eazel_install_emit_download_progress_default (EazelInstall *service, + const char *name, + int amount, + int total) +{ +#ifndef EAZEL_INSTALL_NO_CORBA + CORBA_Environment ev; + CORBA_exception_init (&ev); + SANITY(service); + if (service->callback != CORBA_OBJECT_NIL) { + Trilobite_Eazel_InstallCallback_download_progress (service->callback, name, amount, total, &ev); + } + CORBA_exception_free (&ev); +#endif /* EAZEL_INSTALL_NO_CORBA */ +} + +void +eazel_install_emit_download_failed (EazelInstall *service, + const char *name) +{ + SANITY(service); + g_message ("DOWNLOAD_FAILED %s", name); + gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_FAILED], name); +} + +void +eazel_install_emit_download_failed_default (EazelInstall *service, + const char *name) +{ +#ifndef EAZEL_INSTALL_NO_CORBA + CORBA_Environment ev; + CORBA_exception_init (&ev); + SANITY(service); + if (service->callback != CORBA_OBJECT_NIL) { + Trilobite_Eazel_InstallCallback_download_failed (service->callback, name, &ev); + } + CORBA_exception_free (&ev); +#endif /* EAZEL_INSTALL_NO_CORBA */ +} + +void +eazel_install_emit_install_failed (EazelInstall *service, + const PackageData *pd) +{ + SANITY(service); + g_message ("INSTALL_FAILED %s", pd->name); + gtk_signal_emit (GTK_OBJECT (service), signals[INSTALL_FAILED], pd); +} + +void +eazel_install_emit_install_failed_default (EazelInstall *service, + const PackageData *pack) +{ +#ifndef EAZEL_INSTALL_NO_CORBA + CORBA_Environment ev; + CORBA_exception_init (&ev); + SANITY(service); + if (service->callback != CORBA_OBJECT_NIL) { + Trilobite_Eazel_PackageStruct package; + package = corba_packagestruct_from_packagedata (pack); + Trilobite_Eazel_InstallCallback_install_failed (service->callback, &package, &ev); + } + CORBA_exception_free (&ev); +#endif /* EAZEL_INSTALL_NO_CORBA */ +} + +void +eazel_install_emit_uninstall_failed (EazelInstall *service, + const PackageData *pd) +{ + SANITY(service); + gtk_signal_emit (GTK_OBJECT (service), signals[UNINSTALL_FAILED], pd); +} + +void +eazel_install_emit_dependency_check (EazelInstall *service, + const PackageData *package, + const PackageData *needs) +{ + SANITY(service); + gtk_signal_emit (GTK_OBJECT (service), signals[DEPENDENCY_CHECK], package, needs); +} + +void +eazel_install_emit_dependency_check_default (EazelInstall *service, + const PackageData *pack, + const PackageData *needs) +{ +#ifndef EAZEL_INSTALL_NO_CORBA + CORBA_Environment ev; + CORBA_exception_init (&ev); + SANITY(service); + if (service->callback != CORBA_OBJECT_NIL) { + Trilobite_Eazel_PackageStruct corbapack; + Trilobite_Eazel_PackageDataStruct corbaneeds; + + corbapack = corba_packagestruct_from_packagedata (pack); + corbaneeds = corba_packagedatastruct_from_packagedata (needs); + + Trilobite_Eazel_InstallCallback_dependency_check (service->callback, &corbapack, &corbaneeds, &ev); + } + CORBA_exception_free (&ev); +#endif /* EAZEL_INSTALL_NO_CORBA */ +} + +void +eazel_install_emit_done (EazelInstall *service) +{ + SANITY(service); + gtk_signal_emit (GTK_OBJECT (service), signals[DONE]); +} + +void +eazel_install_emit_done_default (EazelInstall *service) +{ +#ifndef EAZEL_INSTALL_NO_CORBA + CORBA_Environment ev; + CORBA_exception_init (&ev); + SANITY(service); + if (service->callback != CORBA_OBJECT_NIL) { + Trilobite_Eazel_InstallCallback_done (service->callback, &ev); + } + CORBA_exception_free (&ev); +#endif /* EAZEL_INSTALL_NO_CORBA */ +} + /* Welcome to define madness. These are all the get/set methods. There is nothing of interest beyond this point, except for a fucking big dragon*/ @@ -691,14 +803,14 @@ ei_mutator_impl (update, gboolean, iopts->mode_update); ei_mutator_impl (uninstall, gboolean, iopts->mode_uninstall); ei_mutator_impl (downgrade, gboolean, iopts->mode_downgrade); ei_mutator_impl (protocol, URLType, iopts->protocol); -ei_mutator_impl_string (tmp_dir, char*, topts->tmp_dir); -ei_mutator_impl_string (rpmrc_file, char*, topts->rpmrc_file); -ei_mutator_impl_string (hostname, char*, topts->hostname); -ei_mutator_impl_string (rpm_storage_path, char*, topts->rpm_storage_path); -ei_mutator_impl_string (package_list_storage_path, char*, topts->pkg_list_storage_path); -ei_mutator_impl_string (package_list, char*, iopts->pkg_list); -ei_mutator_impl_string (root_dir, char*, root_dir); -ei_mutator_impl (port_number, guint, topts->port_number); +ei_mutator_impl_copy (tmp_dir, char*, topts->tmp_dir, g_strdup); +ei_mutator_impl_copy (rpmrc_file, char*, topts->rpmrc_file, g_strdup); +ei_mutator_impl_copy (server, char*, topts->hostname, g_strdup); +ei_mutator_impl_copy (rpm_storage_path, char*, topts->rpm_storage_path, g_strdup); +ei_mutator_impl_copy (package_list_storage_path, char*, topts->pkg_list_storage_path, g_strdup); +ei_mutator_impl_copy (package_list, char*, iopts->pkg_list, g_strdup); +ei_mutator_impl_copy (root_dir, char*, root_dir, g_strdup); +ei_mutator_impl (server_port, guint, topts->port_number); ei_mutator_impl (install_flags, int, install_flags); ei_mutator_impl (interface_flags, int, interface_flags); @@ -716,14 +828,14 @@ ei_access_impl (update, gboolean, iopts->mode_update, FALSE); ei_access_impl (uninstall, gboolean, iopts->mode_uninstall, FALSE); ei_access_impl (downgrade, gboolean, iopts->mode_downgrade, FALSE); ei_access_impl (protocol, URLType , iopts->protocol, PROTOCOL_LOCAL); -ei_access_impl (tmp_dir, const char*, topts->tmp_dir, NULL); -ei_access_impl (rpmrc_file, const char*, topts->rpmrc_file, NULL); -ei_access_impl (hostname, const char*, topts->hostname, NULL); -ei_access_impl (rpm_storage_path, const char*, topts->rpm_storage_path, NULL); -ei_access_impl (package_list_storage_path, const char*, topts->pkg_list_storage_path, NULL); -ei_access_impl (package_list, const char*, iopts->pkg_list, NULL); -ei_access_impl (root_dir, const char*, root_dir, NULL); -ei_access_impl (port_number, guint, topts->port_number, 0); +ei_access_impl (tmp_dir, char*, topts->tmp_dir, NULL); +ei_access_impl (rpmrc_file, char*, topts->rpmrc_file, NULL); +ei_access_impl (server, char*, topts->hostname, NULL); +ei_access_impl (rpm_storage_path, char*, topts->rpm_storage_path, NULL); +ei_access_impl (package_list_storage_path, char*, topts->pkg_list_storage_path, NULL); +ei_access_impl (package_list, char*, iopts->pkg_list, NULL); +ei_access_impl (root_dir, char*, root_dir, NULL); +ei_access_impl (server_port, guint, topts->port_number, 0); ei_access_impl (install_flags, int, install_flags, 0); ei_access_impl (interface_flags, int, interface_flags, 0); diff --git a/components/services/install/lib/eazel-install-private.h b/components/services/install/lib/eazel-install-private.h index 8c13eefc1..fb6570619 100644 --- a/components/services/install/lib/eazel-install-private.h +++ b/components/services/install/lib/eazel-install-private.h @@ -49,6 +49,7 @@ struct _EazelInstallPrivate { } packsys; FILE *logfile; + char *logfilename; }; #endif /* EAZEL_INSTALL_PRIVATE_H */ diff --git a/components/services/install/lib/eazel-install-protocols.c b/components/services/install/lib/eazel-install-protocols.c index e6a8015b1..09198f4cc 100644 --- a/components/services/install/lib/eazel-install-protocols.c +++ b/components/services/install/lib/eazel-install-protocols.c @@ -295,11 +295,13 @@ get_url_for_package (EazelInstall *service, case ghttp_done: if (ghttp_status_code (request) != 404) { url = g_strdup (ghttp_get_body (request)); - url [ ghttp_get_body_len (request)] = 0; + if (url) { + url [ ghttp_get_body_len (request)] = 0; + } } else { /* url = g_strdup_printf("http://%s%s/%s", - eazel_install_get_hostname (service), + eazel_install_get_server (service), eazel_install_get_rpm_storage_path (service), rpmfilename_from_packagedata (package)); */ @@ -322,8 +324,9 @@ char* get_search_url_for_package (EazelInstall *service, PackageData *pack) { char *url; - url = g_strdup_printf ("http://%s/cgi-bin/rpmsearch.cgi", - eazel_install_get_hostname (service)); + url = g_strdup_printf ("http://%s:%d/cgi-bin/rpmsearch.cgi", + eazel_install_get_server (service), + eazel_install_get_server_port (service)); add_to_url (&url, "?name=", pack->name); add_to_url (&url, "&arch=", pack->archtype); /* add_to_url (&url, "&version>=", pack->version); */ @@ -339,6 +342,8 @@ char* get_search_url_for_package (EazelInstall *service, break; } /* + FIXME: bugzilla.eazel.com 1333 + We need to sent distro name at some point. Depends on the rpmsearch cgi script if (pack->name != DISTRO_UNKNOWN) { char *distro; distro = g_strconcat ("\"", trilobite_get_distribution_name (pack->distribution, TRUE), "\"", NULL); diff --git a/components/services/install/lib/eazel-install-public.h b/components/services/install/lib/eazel-install-public.h index 4e9e4ed9e..2d927a8dd 100644 --- a/components/services/install/lib/eazel-install-public.h +++ b/components/services/install/lib/eazel-install-public.h @@ -22,7 +22,7 @@ */ /* - If compiled with STANDALONE, + If compiled with EAZEL_INSTALL_NO_CORBA, the object should _NOT_ use Bonobo, OAF, ORBIT and whatnot. This is to facilite the statically linked nautilus bootstrap thingy */ @@ -31,10 +31,10 @@ #define EAZEL_INSTALL_PUBLIC_H #include <libgnome/gnome-defs.h> -#ifndef STANDALONE +#ifndef EAZEL_INSTALL_NO_CORBA #include "bonobo.h" #include "trilobite-eazel-install.h" -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ #include "eazel-install-types.h" @@ -57,41 +57,43 @@ typedef struct _EazelInstallClass EazelInstallClass; struct _EazelInstallClass { -#ifdef STANDALONE +#ifdef EAZEL_INSTALL_NO_CORBA GtkObjectClass parent_class; #else BonoboObjectClass parent_class; -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ /* signal prototypes */ - void (*download_progress) (char *file, int amount, int total); - void (*install_progress) (char *name, int amount, int total); - void (*dependency_check) (const PackageData *package, const PackageData *needed ); + void (*download_progress) (EazelInstall *service, const char *file, int amount, int total); + void (*install_progress) (EazelInstall *service, const PackageData *pack, int amount, int total); + void (*dependency_check) (EazelInstall *service, const PackageData *pack, const PackageData *needed); /* if the set URLType is PROTOCOL_HTTP, info is a HTTPError struc */ - void (*download_failed) (char *name, gpointer info); + void (*download_failed) (EazelInstall *service, const char *name); /* if RPM_FAIL is RPM_SRC_NOT_SUPPORTED, info is NULL RPM_DEP_FAIL, info is a GSList of required packages (PackageData objects) RPM_NOT_AN_RPM, info is NULL */ - void (*install_failed) (PackageData *pd); - void (*uninstall_failed) (PackageData *pd); -#ifndef STANDALONE + void (*install_failed) (EazelInstall *service, const PackageData *pd); + void (*uninstall_failed) (EazelInstall *service, const PackageData *pd); + + void (*done) (EazelInstall *service); +#ifndef EAZEL_INSTALL_NO_CORBA gpointer servant_vepv; -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ }; typedef struct _EazelInstallPrivate EazelInstallPrivate; struct _EazelInstall { -#ifdef STANDALONE +#ifdef EAZEL_INSTALL_NO_CORBA GtkObject parent; #else BonoboObject parent; Trilobite_Eazel_InstallCallback callback; -#endif /* STANDALONE */ +#endif /* EAZEL_INSTALL_NO_CORBA */ EazelInstallPrivate *private; }; @@ -100,15 +102,16 @@ EazelInstall *eazel_install_new_with_config (const char *config GtkType eazel_install_get_type (void); void eazel_install_destroy (GtkObject *object); -#ifndef STANDALONE +#ifndef EAZEL_INSTALL_NO_CORBA POA_Trilobite_Eazel_Install__epv *eazel_install_get_epv (void); -#endif /* STANDALONE */ +Trilobite_Eazel_Install eazel_install_create_corba_object (BonoboObject *service); +#endif /* EAZEL_INSTALL_NO_CORBA */ void eazel_install_open_log (EazelInstall *service, const char *fname); void eazel_install_emit_install_progress (EazelInstall *service, - const char *name, + const PackageData *pack, int amount, int total); void eazel_install_emit_download_progress (EazelInstall *service, @@ -116,8 +119,7 @@ void eazel_install_emit_download_progress (EazelInstall *service, int amount, int total); void eazel_install_emit_download_failed (EazelInstall *service, - const char *name, - const gpointer info); + const char *name); void eazel_install_emit_install_failed (EazelInstall *service, const PackageData *pd); void eazel_install_emit_uninstall_failed (EazelInstall *service, @@ -125,6 +127,7 @@ void eazel_install_emit_uninstall_failed (EazelInstall *service, void eazel_install_emit_dependency_check (EazelInstall *service, const PackageData *package, const PackageData *needed ); +void eazel_install_emit_done (EazelInstall *service); /* This is in flux */ void eazel_install_fetch_pockage_list (EazelInstall *service); @@ -160,7 +163,7 @@ type eazel_install_get_##name (EazelInstall *service) { \ #define ei_mutator_decl(name, type) \ void eazel_install_set_##name (EazelInstall *service, \ - type name) + const type name) #define ei_mutator_impl(name, type,var) \ void eazel_install_set_##name (EazelInstall *service, \ @@ -169,12 +172,12 @@ void eazel_install_set_##name (EazelInstall *service, \ service->private->var = name; \ } -#define ei_mutator_impl_string(name, type, var) \ +#define ei_mutator_impl_copy(name, type, var, copyfunc) \ void eazel_install_set_##name (EazelInstall *service, \ - type name) { \ + const type name) { \ SANITY (service); \ g_free (service->private->var); \ - service->private->var = g_strdup ( name ); \ + service->private->var = copyfunc ( name ); \ } ei_mutator_decl (verbose, gboolean); @@ -189,12 +192,12 @@ ei_mutator_decl (downgrade, gboolean); ei_mutator_decl (protocol, URLType); ei_mutator_decl (tmp_dir, char*); ei_mutator_decl (rpmrc_file, char*); -ei_mutator_decl (hostname, char*); +ei_mutator_decl (server, char*); ei_mutator_decl (rpm_storage_path, char*); ei_mutator_decl (package_list_storage_path, char*); ei_mutator_decl (package_list, char*); ei_mutator_decl (root_dir, char*); -ei_mutator_decl (port_number, guint); +ei_mutator_decl (server_port, guint); ei_mutator_decl (install_flags, int); ei_mutator_decl (interface_flags, int); @@ -212,14 +215,14 @@ ei_access_decl (update, gboolean); ei_access_decl (uninstall, gboolean); ei_access_decl (downgrade, gboolean); ei_access_decl (protocol, URLType ); -ei_access_decl (tmp_dir, const char*); -ei_access_decl (rpmrc_file, const char*); -ei_access_decl (hostname, const char*); -ei_access_decl (rpm_storage_path, const char*); -ei_access_decl (package_list_storage_path, const char*); -ei_access_decl (package_list, const char*); -ei_access_decl (root_dir, const char*); -ei_access_decl (port_number, guint); +ei_access_decl (tmp_dir, char*); +ei_access_decl (rpmrc_file, char*); +ei_access_decl (server, char*); +ei_access_decl (rpm_storage_path, char*); +ei_access_decl (package_list_storage_path, char*); +ei_access_decl (package_list, char*); +ei_access_decl (root_dir, char*); +ei_access_decl (server_port, guint); ei_access_decl (install_flags, int); ei_access_decl (interface_flags, int); diff --git a/components/services/install/lib/eazel-install-rpm-glue.c b/components/services/install/lib/eazel-install-rpm-glue.c index 5af245b6e..012dc61ca 100644 --- a/components/services/install/lib/eazel-install-rpm-glue.c +++ b/components/services/install/lib/eazel-install-rpm-glue.c @@ -98,6 +98,12 @@ static gboolean eazel_install_ensure_deps (EazelInstall *service, GList **filenames, GList **fails); +static int eazel_install_package_name_compare (PackageData *pack, + char *name); + +static int eazel_install_package_conflict_compare (PackageData *pack, + struct rpmDependencyConflict *conflict); + gboolean install_new_packages (EazelInstall *service, GList *categories) { @@ -126,9 +132,9 @@ install_new_packages (EazelInstall *service, GList *categories) { if (eazel_install_get_force (service) == TRUE) { problem_filters |= RPMPROB_FILTER_REPLACEPKG | - RPMPROB_FILTER_REPLACEOLDFILES | - RPMPROB_FILTER_REPLACENEWFILES | - RPMPROB_FILTER_OLDPACKAGE; + RPMPROB_FILTER_REPLACEOLDFILES | + RPMPROB_FILTER_REPLACENEWFILES | + RPMPROB_FILTER_OLDPACKAGE; } eazel_install_set_install_flags (service, install_flags); @@ -180,7 +186,7 @@ download_all_packages (EazelInstall *service, if (eazel_install_fetch_package (service, package) == FALSE) { g_warning ("*** Failed to retreive %s! ***", package->name); - eazel_install_emit_download_failed (service, package->name, NULL); + eazel_install_emit_download_failed (service, package->name); remove = g_list_prepend (remove, package); } @@ -217,7 +223,7 @@ install_all_packages (EazelInstall *service, if (pkgs) { eazel_install_ensure_deps (service, &pkgs, &failedfiles); } - + g_message ("Category = %s, %d packages", cat->name, g_list_length (pkgs)); /* if (pkgs == NULL) { @@ -387,70 +393,42 @@ rpm_show_progress (const Header h, filename = pkgKey; switch (callback_type) { - case RPMCALLBACK_INST_OPEN_FILE: - name = ""; - size = 0; - fd = fdOpen (filename, O_RDONLY, 0); - headerGetEntry (h, - RPMTAG_SIZE, - NULL, - (void **)&sizep, - NULL); - headerGetEntry (h, - RPMTAG_NAME, - NULL, - (void **)&name, - NULL); - size = *sizep; - - return fd; - - case RPMCALLBACK_INST_CLOSE_FILE: - fdClose (fd); - break; - - case RPMCALLBACK_INST_PROGRESS: - eazel_install_emit_install_progress (service, filename, amount, total); - break; - - default: - break; - } - return NULL; -} /* end rpm_show_progress */ - -static GList* -build_packagedata_list_from_deps (struct rpmDependencyConflict* conflicts, - int num_conflicts) -{ - GList *result; - int i; - - g_return_val_if_fail (num_conflicts >= 1, NULL); - g_return_val_if_fail (conflicts != NULL, NULL); - - result = NULL; - - for (i = 0; i < num_conflicts; i++) { - struct rpmDependencyConflict c; - PackageData *pd; + case RPMCALLBACK_INST_OPEN_FILE: + name = ""; + size = 0; + fd = fdOpen (filename, O_RDONLY, 0); + headerGetEntry (h, + RPMTAG_SIZE, + NULL, + (void **)&sizep, + NULL); + headerGetEntry (h, + RPMTAG_NAME, + NULL, + (void **)&name, + NULL); + size = *sizep; - c = conflicts [i]; + return fd; - pd = packagedata_new (); - pd->name = g_strdup (c.needsName); - pd->version = g_strdup (c.needsVersion); - pd->minor = NULL; - pd->archtype = NULL; - pd->bytesize = 0; - pd->summary = NULL; - pd->soft_depends = NULL; - pd->hard_depends = NULL; + case RPMCALLBACK_INST_CLOSE_FILE: + fdClose (fd); + break; + + case RPMCALLBACK_INST_PROGRESS: { + PackageData *pack; + pack = packagedata_new (); + pack->name = g_strdup (filename); + eazel_install_emit_install_progress (service, pack, amount, total); + packagedata_destroy (pack); + } + break; - result = g_list_prepend (result, pd); + default: + break; } - return result; -} + return NULL; + } /* end rpm_show_progress */ int do_rpm_install (EazelInstall *service, @@ -579,29 +557,35 @@ do_rpm_install (EazelInstall *service, if (!(eazel_install_get_interface_flags (service) & INSTALL_NODEPS)) { /* Check the dependencies */ - if (rpmdepCheck (rpmdep, &conflicts, &num_conflicts)) { - num_failed = num_packages; - stop_install = 1; - } - /* Deps failed ? */ - if (!stop_install && conflicts) { - PackageData *pd; - GList *deps; - - deps = build_packagedata_list_from_deps (conflicts, num_conflicts); - pd = packagedata_new(); - pd->name = g_strdup (conflicts[0].byName); - - g_message ("Dep failed for %s",pd->name); - pd->status = PACKAGE_DEPENDENCY_FAIL; - pd->soft_depends = deps; - eazel_install_emit_install_failed (service, pd); - - num_failed = num_packages; - stop_install = 1; + rpmdepCheck (rpmdep, &conflicts, &num_conflicts); + if (!stop_install && num_conflicts) { + if (!eazel_install_get_force (service)) { + PackageData *pack, *dep; + GList *pack_entry; + int cnt; + + for (cnt = 0; cnt < num_conflicts; cnt++) { + pack_entry = g_list_find_custom (packages, + (gpointer)&conflicts[cnt], + (GCompareFunc)eazel_install_package_conflict_compare); + + if (pack_entry) { + pack = (PackageData*)(pack_entry->data); + dep = packagedata_new_from_rpm_conflict (conflicts[cnt]); + dep->status = PACKAGE_CANNOT_OPEN; + pack->status = PACKAGE_DEPENDENCY_FAIL; + g_assert (dep->name != NULL); + pack->soft_depends = g_list_prepend (pack->soft_depends, dep); + eazel_install_emit_install_failed (service, pack); + } else { + g_error ("I did not expect the package to not appear in the packages list"); + } + } + + num_failed = num_packages; + stop_install = 1; + } - packagedata_destroy (pd); - g_list_foreach (deps, (GFunc)packagedata_destroy_foreach, NULL); rpmdepFreeConflicts (conflicts, num_conflicts); } } @@ -781,7 +765,7 @@ eazel_install_prune_packages_helper (EazelInstall *service, if (g_list_find (*pruned, pack) || pack->name==NULL) { return; } - g_message ("Stripping package %s", pack->name); + g_message ("Stripping package %s (%s)", pack->name, pack->toplevel ? "top" : ""); if (pack->toplevel) { /* We only emit signal for the toplevel packages, and only delete them. They _destroy function destroys @@ -998,7 +982,7 @@ eazel_install_free_rpm_system (EazelInstall *service) } static gboolean -eazel_install_prepare_rpm_system (EazelInstall *service) +eazel_install_prepare_rpm_system(EazelInstall *service) { int mode; const char *root_dir; @@ -1011,11 +995,14 @@ eazel_install_prepare_rpm_system (EazelInstall *service) root_dir = eazel_install_get_root_dir (service) ? eazel_install_get_root_dir (service) : ""; if (eazel_install_get_install_flags (service) & RPMTRANS_FLAG_TEST) { + g_message ("rpmdbOpen with mode rdonly"); mode = O_RDONLY; } else { + g_message ("rpmdbOpen with mode rdwr"); mode = O_RDWR | O_EXCL; } + g_message ("rpmdbOpen with mode %d", mode); if (rpmdbOpen (root_dir, db, mode, 0644)) { const char* dn; dn = rpmGetPath (root_dir, "%{_dbpath}", NULL); @@ -1026,7 +1013,7 @@ eazel_install_prepare_rpm_system (EazelInstall *service) } if (set) { (*set) = rpmtransCreateSet (*db, root_dir); - if (*set == NULL) { + if (set == NULL) { g_message ("Create set failed"); return FALSE; } @@ -1076,7 +1063,7 @@ eazel_install_add_headers_to_rpm_set (EazelInstall *service, PackageData *pack; int err; pack = (PackageData*)iterator->data; - g_message ("adding %s", pack->name); + g_message ("adding %s (%s)", pack->name, pack->toplevel ? "true" : ""); err = rpmtransAddPackage (service->private->packsys.rpm.set, *((Header*)pack->packsys_struc), NULL, @@ -1111,7 +1098,6 @@ eazel_install_package_conflict_compare (PackageData *pack, return eazel_install_package_name_compare (pack, conflict->byName); } - static void eazel_install_add_to_extras_foreach (char *key, GList *list, GList **extrapackages) { @@ -1148,9 +1134,13 @@ eazel_install_fetch_rpm_dependencies (EazelInstall *service, /* FIXME bugzilla.eazel.com 1316 Need to find a solid way to capture file dependencies, and once they do not appear at this point anymore, remove them. And in the end, check the list is - empty. */ + empty. + + Perhaps the smartest thing is to check at the final install. We can't resolve + these deps anyway, as we have on idea as to where the file is from. + + */ if (strncmp (conflict.needsName, "lib",3)==0 && strstr (conflict.needsName, ".so")) { - g_warning ("LIB dependency"); continue; } @@ -1158,9 +1148,6 @@ eazel_install_fetch_rpm_dependencies (EazelInstall *service, (gpointer)&conflict, (GCompareFunc)eazel_install_package_conflict_compare); if (pack_entry == NULL) { - /* If we end here, it's a conflict is going to break something */ - /* FIXME: bugzilla.eazel.com - Need to handle this */ switch (conflict.sense) { case RPMDEP_SENSE_REQUIRES: g_warning ("%s needs %s %s", conflict.byName, conflict.needsName, conflict.needsVersion); @@ -1168,16 +1155,27 @@ eazel_install_fetch_rpm_dependencies (EazelInstall *service, (gpointer)conflict.needsName, (GCompareFunc)eazel_install_package_name_compare); dep = packagedata_new_from_rpm_conflict_reversed (conflict); + dep->archtype = g_strdup (pack->archtype); pack = (PackageData*)(pack_entry->data); pack->status = PACKAGE_BREAKS_DEPENDENCY; - pack->breaks = g_list_prepend (pack->breaks, dep); - if (g_list_find (*failedpackages, pack) == NULL) { - (*failedpackages) = g_list_prepend (*failedpackages, pack); + g_assert (dep!=NULL); + /* FIXME: bugzilla.eazel.com 1363 + Here, it'd be cool to compare dep->name to pack->name to see if + dep is pack's devel package. And if so, replace dep->version with + pack->version and not fail pack, but continue */ + if (!eazel_install_get_force (service)) { + pack->breaks = g_list_prepend (pack->breaks, dep); + if (g_list_find (*failedpackages, pack) == NULL) { + (*failedpackages) = g_list_prepend (*failedpackages, pack); + } + to_remove = g_list_remove (to_remove, pack); } - to_remove = g_list_remove (to_remove, pack); continue; break; case RPMDEP_SENSE_CONFLICTS: + /* If we end here, it's a conflict is going to break something */ + /* FIXME: bugzilla.eazel.com + Need to handle this more intelligently */ g_warning ("%s conflicts %s-%s", conflict.byName, conflict.needsName, conflict.needsVersion); continue; break; @@ -1185,18 +1183,13 @@ eazel_install_fetch_rpm_dependencies (EazelInstall *service, } else { pack = (PackageData*)(pack_entry->data); dep = packagedata_new_from_rpm_conflict (conflict); + dep->archtype = g_strdup (pack->archtype); } + g_assert (dep->name != NULL); eazel_install_emit_dependency_check (service, pack, dep); - dep->archtype = g_strdup (pack->archtype); - - /* - FIXME: bugzilla.eazel.com 1300 - We need the service to accept a url of a format - that specifies, that this package is to be resolved, - as in - "get package name=pack->name && version>=pack->version && arch=pack->archtype && highest release-number" - */ - + dep->archtype = g_strdup (pack->archtype); + pack->soft_depends = g_list_prepend (pack->soft_depends, dep); + g_message ("Processing dep for %s : requires %s", pack->name, dep->name); if (eazel_install_fetch_package (service, dep)) { @@ -1210,7 +1203,6 @@ eazel_install_fetch_rpm_dependencies (EazelInstall *service, g_hash_table_insert (extras, pack->name, extralist); pack->status = PACKAGE_PARTLY_RESOLVED; - pack->soft_depends = g_list_prepend (pack->soft_depends, dep); } else { /* If it fails @@ -1222,24 +1214,28 @@ eazel_install_fetch_rpm_dependencies (EazelInstall *service, to return zero. This is fine if we then just do a continue, but this way, we get all the missing deps into pack->soft_depends 3) add to list of failed packages - */ + */ GList *extralist; - - eazel_install_emit_download_failed (service, dep->name, NULL); - + + eazel_install_emit_download_failed (service, dep->name); + pack->status = PACKAGE_DEPENDENCY_FAIL; dep->status = PACKAGE_CANNOT_OPEN; - pack->soft_depends = g_list_prepend (pack->soft_depends, dep); - - extralist = g_hash_table_lookup (extras, pack->name); - g_list_foreach (extralist, (GFunc)packagedata_destroy_foreach, NULL); - g_hash_table_remove (extras, pack->name); - - /* Don't add it to failedpackages more then once */ - if (g_list_find (*failedpackages, pack) == NULL) { - (*failedpackages) = g_list_prepend (*failedpackages, pack); + + if (!eazel_install_get_force (service)) { + extralist = g_hash_table_lookup (extras, pack->name); + g_list_foreach (extralist, (GFunc)packagedata_destroy_foreach, NULL); + g_hash_table_remove (extras, pack->name); + + /* Don't add it to failedpackages more then once */ + if (g_list_find (*failedpackages, pack) == NULL) { + (*failedpackages) = g_list_prepend (*failedpackages, pack); + } + to_remove = g_list_prepend (to_remove, pack); + + /* Don't process anymore */ + break; } - to_remove = g_list_remove (to_remove, pack); } } @@ -1317,7 +1313,10 @@ print_package_list (char *str, GList *packages, gboolean show_deps) it2 = it2->next; } } - g_message ("* %s%s", rpmfilename_from_packagedata (pack), (strlen (tmp) > strlen (dep)) ? tmp : ""); + g_message ("* %s (%s) %s", + rpmfilename_from_packagedata (pack), + pack->toplevel ? "true" : "", + (strlen (tmp) > strlen (dep)) ? tmp : ""); } } @@ -1350,7 +1349,15 @@ eazel_install_ensure_deps (EazelInstall *service, and are places in service->private->packsys. */ eazel_install_load_headers (service, packages); - eazel_install_prepare_package_system (service); + if (eazel_install_prepare_package_system (service) == FALSE) { + GList *iterator; + for (iterator = *packages; iterator; iterator = iterator->next) { + (*packages) = g_list_prepend (*packages, iterator->data); + } + g_list_free (*packages); + (*packages) = NULL; + return FALSE; + } eazel_install_add_headers_to_set (service, *packages); /* Weak attempt at making it easy to extend to other @@ -1505,3 +1512,93 @@ rpm_uninstall (EazelInstall *service, return result; } /* end rpm_uninstall */ +/*****************************************************************************/ +/* Query mechanisms */ +/*****************************************************************************/ + +/* + + query syntax : + " '<package>'.[<attr><op>'<arg>']* + + attr and op pairs : + ------------------- + version = < > <= >= + arch = + + query examples: + "'gnome-core'" check for package gnome-core + "'nautilus'.version>='0.1'.arch=i386" Check for nautilus, i386 binary version >= 0.1 + "'popt'.version='1.5'" check for popt version 1.5 (no more, no less) + +*/ + +typedef enum { + EI_Q_VERSION, + EI_Q_ARCH +} AttributeEnum; + +typedef enum { + EI_OP_EQ = 0x01, + EI_OP_LT = 0x02, + EI_OP_GT = 0x04, + EI_OP_NEG = 0x08, +} AttributeOpEnum; + +typedef struct { + AttributeEnum attrib; + AttributeOpEnum op; + char *arg; +} AttributeOpArg; + + +/* + return codes + 0 - ok + 1 - same attribute occured twice or more + 2 - bad bad bad parameters; + */ +static int +ei_extract_attributes (char *query, GList **result) +{ + int i; + /* these should be in the correct order according to the enum */ + char *query_attribs[] = {".version", ".arch", NULL}; + + g_return_val_if_fail (query!=NULL, 2); + (*result) = NULL; + + for (i = 0; query_attribs[i]; i++) { + char *location; + char *op; + char *arg; + AttributeOpArg *argument; + + /* Check for the i'th attribute in the query */ + if ((location = strstr (query, query_attribs[i]))!=NULL) { + argument = g_new0 (AttributeOpArg, 1); + + /* Does it occur again ? */ + if (strstr (location, query_attribs[i])) { + g_free (argument); + return 1; + } + arg = op = location + strlen (query_attribs[i]); + while (*arg && *arg!='\'') { arg ++; } + if (strcasecmp (location, ".version")==0) { + argument->attrib = EI_Q_VERSION; + } + (*result) = g_list_prepend (*result, argument); + } + } + + return 0; +} + +GList* +eazel_install_query_package_system (char *query, int flags) +{ + GList *attribs; + ei_extract_attributes (query, &attribs); + return NULL; +} diff --git a/components/services/install/lib/eazel-install-rpm-glue.h b/components/services/install/lib/eazel-install-rpm-glue.h index 852fc5a47..d9a7b02ca 100644 --- a/components/services/install/lib/eazel-install-rpm-glue.h +++ b/components/services/install/lib/eazel-install-rpm-glue.h @@ -34,6 +34,7 @@ gboolean install_new_packages (EazelInstall *service, GList *categories); gboolean uninstall_packages (EazelInstall *service); +GList* eazel_install_query_package_system (char *query, int flags); #endif /* EAZEL_INSTALL_RPM_GLUE_H */ diff --git a/components/services/install/lib/eazel-install-types.c b/components/services/install/lib/eazel-install-types.c index 8ef23343a..e9e097240 100644 --- a/components/services/install/lib/eazel-install-types.c +++ b/components/services/install/lib/eazel-install-types.c @@ -205,7 +205,7 @@ rpmfilename_from_packagedata (const PackageData *pack) pack->name, pack->archtype); } else { - filename = g_strconcat (pack->name,".rpm", NULL); + filename = g_strconcat (pack->name, NULL); } } diff --git a/components/services/install/lib/eazel-install-types.h b/components/services/install/lib/eazel-install-types.h index c4b1def3c..82f6072d6 100644 --- a/components/services/install/lib/eazel-install-types.h +++ b/components/services/install/lib/eazel-install-types.h @@ -27,8 +27,8 @@ * file and install a services generated package-list.xml. */ -#ifndef EAZEL_INSTALL_TYPES_H -#define EAZEL_INSTALL_TYPES_H +#ifndef EAZEL_INSTALL_SERVICES_TYPES_H +#define EAZEL_INSTALL_SERVICES_TYPES_H #include <gnome.h> #include <stdio.h> @@ -45,6 +45,11 @@ typedef struct _CategoryData CategoryData; typedef struct _PackageData PackageData; typedef enum _PackageSystemStatus PackageSystemStatus; +/* + Adding here requires editing in + trilobite-eazel-install.idl + eazel-install-corba-types.c (packagedata_from_corba_packagedatastruct) (corba_packagedatastruct_from_packagedata) + */ enum _PackageSystemStatus { PACKAGE_UNKNOWN_STATUS=0, PACKAGE_SOURCE_NOT_SUPPORTED, @@ -150,4 +155,4 @@ void packagedata_destroy (PackageData *pd); int packagedata_hash (PackageData *pd); int packagedata_equal (PackageData *a, PackageData *b); -#endif /* EAZEL_INSTALL_TYPES_H */ +#endif /* EAZEL_INSTALL_SERVICES_TYPES_H */ diff --git a/components/services/install/server/Makefile.am b/components/services/install/server/Makefile.am new file mode 100644 index 000000000..8244b976f --- /dev/null +++ b/components/services/install/server/Makefile.am @@ -0,0 +1,63 @@ +NULL = + +CPPFLAGS = \ + -DPREFIX=\"$(prefix)\" \ + -DG_LOG_DOMAIN=\"trilobite-eazel-install-service\" \ + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + $(NULL) + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_srcdir)/components/services/install/lib \ + -I$(top_srcdir)/components/services/trilobite \ + -I/usr/include/rpm \ + $(GHTTP_CFLAGS) \ + $(GCONF_CFLAGS) \ + $(GNOME_CFLAGS) \ + $(GNOME_INCLUDEDIR) \ + $(OAF_CFLAGS) \ + $(XML_CFLAGS) \ + $(WERROR) \ + $(NULL) + +LDFLAGS = \ + $(OAF_LIBS) \ + $(GHTTP_LIBS) \ + $(NULL) + + + +pixmapdir = $(datadir)/pixmaps +pixmap_DATA = trilobite-eazel-install-service.png + +# CORBA magic + +oafdir = $(datadir)/oaf +oaf_DATA = trilobite-eazel-install-service.oafinfo + +# make the auto-generated files depend on a installstamp file. +# this is to ensure the individual files wait for each other before +# proceeding which is needed in parallel makes + +## Binaries + +bin_PROGRAMS = trilobite-eazel-install-service + +trilobite_eazel_install_service_SOURCES = \ + main.c \ + $(NULL) + +trilobite_eazel_install_service_LDADD = \ + $(top_builddir)/components/services/trilobite/libtrilobite/libtrilobite.la \ + $(top_builddir)/components/services/install/lib/libinstall_corba.a \ + $(top_builddir)/components/services/install/lib/libinstall_base.a \ + $(NULL) + + +## Extra stuff + +EXTRA_DIST = \ + $(oaf_DATA) \ + $(pixmap_DATA) \ + $(NULL) diff --git a/components/services/install/lib/trilobite-eazel-install-service.oafinfo b/components/services/install/server/Trilobite_Service_install.oaf.in index 892280ed1..892280ed1 100644 --- a/components/services/install/lib/trilobite-eazel-install-service.oafinfo +++ b/components/services/install/server/Trilobite_Service_install.oaf.in diff --git a/components/services/install/server/trilobite-eazel-install-service.oafinfo b/components/services/install/server/trilobite-eazel-install-service.oafinfo new file mode 100644 index 000000000..892280ed1 --- /dev/null +++ b/components/services/install/server/trilobite-eazel-install-service.oafinfo @@ -0,0 +1,30 @@ +<oaf_info> + +<oaf_server iid="OAFIID:trilobite_eazel_install_service_factory:b423ff3f-1941-4b0d-bd45-6542f64abbfc" type="exe" location="trilobite-eazel-install-service"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:GNOME/GenericFactory:1.0"/> +</oaf_attribute> +<oaf_attribute name="description" type="string" value="Factory for the install service"/> +</oaf_server> + +<oaf_server iid="OAFIID:trilobite_eazel_install_service:8ff6e815-1992-437c-9771-d932db3b4a17" type="factory" location="OAFIID:trilobite_eazel_install_service_factory:b423ff3f-1941-4b0d-bd45-6542f64abbfc"> +<oaf_attribute name="repo_ids" type="stringv"> +<item value="IDL:Bonobo/Unknown:1.0"/> +<item value="IDL:Trilobite/Service:1.0"/> +<item value="IDL:Trilobite/Eazel/Install:1.0"/> +</oaf_attribute> + +<oaf_attribute name="trilobite:name" type="string" value="Install"/> +<oaf_attribute name="trilobite:version" type="string" value="0.1"/> +<oaf_attribute name="trilobite:vendor_name" type="string" value="Eazel, inc."/> +<oaf_attribute name="trilobite:vendor_url" type="string" value="http://www.eazel.com"/> +<oaf_attribute name="trilobite:info_url" type="string" value="http://www.eazel.com/install/"/> +<oaf_attribute name="trilobite:icon" type="string" value="trilobite-install-service.png"/> +<oaf_attribute name="trilobite:uri_scheme" type="string" value="eazel-install:"/> +<oaf_attribute name="bonobo:supported_uri_schemes" type="stringv"> +<item value="eazel-install"/> +</oaf_attribute> + +</oaf_server> + +</oaf_info> diff --git a/components/services/install/server/trilobite-eazel-install-service.png b/components/services/install/server/trilobite-eazel-install-service.png Binary files differnew file mode 100644 index 000000000..01f611262 --- /dev/null +++ b/components/services/install/server/trilobite-eazel-install-service.png diff --git a/components/services/time/service/Makefile.am b/components/services/time/service/Makefile.am index e4c547ae5..9ceead287 100644 --- a/components/services/time/service/Makefile.am +++ b/components/services/time/service/Makefile.am @@ -37,7 +37,6 @@ oaf_DATA = trilobite-eazel-time-service.oafinfo CORBA_GENERATED = \ trilobite-eazel-time-service.h \ - trilobite-eazel-sample-service-common.c \ trilobite-eazel-time-service-skels.c \ trilobite-eazel-time-service-stubs.c \ trilobite-eazel-time-service-common.c \ diff --git a/components/services/time/service/trilobite-eazel-time-service.c b/components/services/time/service/trilobite-eazel-time-service.c index 1df6f9662..22dadcbc1 100644 --- a/components/services/time/service/trilobite-eazel-time-service.c +++ b/components/services/time/service/trilobite-eazel-time-service.c @@ -260,7 +260,7 @@ trilobite_eazel_time_service_initialize (TrilobiteEazelTimeService *service) { These defaults should probably be read from somewhere */ /* Default to the eazel test time server */ - service->private->time_url = g_strdup ("http://eazel24.eazel.com/time.pl"); + service->private->time_url = g_strdup ("http://testmachine.eazel.com:8888/examples/time/current"); /* Default to 180 seconds allowed diff */ service->private->maxd = 180; diff --git a/components/services/trilobite/libtrilobite/trilobite-core-distribution.c b/components/services/trilobite/libtrilobite/trilobite-core-distribution.c index 4d6cf6261..d143034dd 100644 --- a/components/services/trilobite/libtrilobite/trilobite-core-distribution.c +++ b/components/services/trilobite/libtrilobite/trilobite-core-distribution.c @@ -34,6 +34,18 @@ #include <stdlib.h> #include <unistd.h> +#include <string.h> + +#define RHAT "Red Hat Linux" +#define DEBI "Debian GNU/Linux" +#define CALD "Caldera" +#define SUSE "S.u.S.E" +#define LPPC "LinuxPPC" +#define TURB "TurboLinux" +#define CORL "CorelLinux" +#define MAND "Mandrake" +#define UNKW "unkown" + /* FIXME bugzilla.eazel.com 908 need to implement the rest of the determine_FOO_version */ @@ -165,31 +177,31 @@ trilobite_get_distribution_name (DistributionInfo distinfo, switch (distinfo.name) { case DISTRO_REDHAT: - name = g_strdup ("Red Hat Linux"); + name = g_strdup (RHAT); break; case DISTRO_DEBIAN: - name = g_strdup ("Debian"); + name = g_strdup (DEBI); break; case DISTRO_CALDERA: - name = g_strdup ("Caldera"); + name = g_strdup (CALD); break; case DISTRO_SUSE: - name = g_strdup ("S.u.S.E."); + name = g_strdup (SUSE); break; case DISTRO_LINUXPPC: - name = g_strdup ("LinuxPPC"); + name = g_strdup (LPPC); break; case DISTRO_TURBOLINUX: - name = g_strdup ("TurboLinux"); + name = g_strdup (TURB); break; case DISTRO_COREL: - name = g_strdup ("Corel"); + name = g_strdup (CORL); break; case DISTRO_MANDRAKE: - name = g_strdup ("Mandrake"); + name = g_strdup (MAND); break; default: - name = g_strdup ("Unknown"); + name = g_strdup (UNKW); break; } @@ -216,3 +228,27 @@ trilobite_get_distribution_name (DistributionInfo distinfo, return result; } + +DistributionName +trilobite_get_distribution_enum (const char *name) +{ + g_return_val_if_fail (name!=NULL, DISTRO_UNKNOWN); + if (strncmp (name, RHAT, strlen (RHAT)) == 0) { + return DISTRO_REDHAT; + } else if (strncmp (name, DEBI, strlen (DEBI)) == 0) { + return DISTRO_DEBIAN; + } else if (strncmp (name, CALD, strlen (CALD)) == 0) { + return DISTRO_CALDERA; + } else if (strncmp (name, SUSE, strlen (SUSE)) == 0) { + return DISTRO_SUSE; + } else if (strncmp (name, LPPC, strlen (LPPC)) == 0) { + return DISTRO_LINUXPPC; + } else if (strncmp (name, TURB, strlen (TURB)) == 0) { + return DISTRO_TURBOLINUX; + } else if (strncmp (name, CORL, strlen (CORL)) == 0) { + return DISTRO_COREL; + } else if (strncmp (name, MAND, strlen (MAND)) == 0) { + return DISTRO_MANDRAKE; + } + return DISTRO_UNKNOWN; +} diff --git a/components/services/trilobite/libtrilobite/trilobite-core-distribution.h b/components/services/trilobite/libtrilobite/trilobite-core-distribution.h index b465c2598..8e2586bad 100644 --- a/components/services/trilobite/libtrilobite/trilobite-core-distribution.h +++ b/components/services/trilobite/libtrilobite/trilobite-core-distribution.h @@ -59,4 +59,13 @@ DistributionInfo trilobite_get_distribution (void); char* trilobite_get_distribution_name (DistributionInfo distinfo, gboolean show_version); +/* + Returns the enum corresponding to the given string, + which should be one of the strings that trilobite_get_distribution_name + returns. The version part (if show_version = TRUE was used) is + _not_ parsed */ + +DistributionName trilobite_get_distribution_enum (const char *name); + #endif /* EAZEL_SERVICES_DISTRIBUTION_H */ + diff --git a/components/services/trilobite/sample/command-line/main.c b/components/services/trilobite/sample/command-line/main.c index 62594b9a4..c62b81387 100644 --- a/components/services/trilobite/sample/command-line/main.c +++ b/components/services/trilobite/sample/command-line/main.c @@ -95,9 +95,11 @@ int main(int argc, char *argv[]) { Trilobite_Eazel_Sample_remember (sample_service, "horsedung", &ev); Trilobite_Eazel_Sample_say_it (sample_service, &ev); + CORBA_Object_release (sample_service, &ev); } - Trilobite_Service_unref (trilobite, &ev); + Bonobo_Unknown_unref (trilobite, &ev); + bonobo_object_unref (BONOBO_OBJECT (service)); CORBA_exception_free (&ev); return 0; diff --git a/components/services/trilobite/sample/service/main.c b/components/services/trilobite/sample/service/main.c index 434080d3d..c084d6fae 100644 --- a/components/services/trilobite/sample/service/main.c +++ b/components/services/trilobite/sample/service/main.c @@ -114,20 +114,6 @@ int main(int argc, char *argv[]) { g_error ("Could not register factory"); } - if (0) { - TrilobiteService *test; - test = trilobite_service_new (); - g_assert (test); - trilobite_service_set_name (test, "roevbanan"); - g_message ("name is %s",trilobite_service_get_name (test)); - trilobite_service_destroy (GTK_OBJECT (test)); - } - if (0) { - SampleService *test; - test = sample_service_new (); - sample_service_destroy (GTK_OBJECT (test)); - } - bonobo_activate(); g_message ("%s ready", argv[0]); |