diff --git a/ChangeLog b/ChangeLog index fc0eca76e..7554c891e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,57 @@ +2001-01-22 Robey Pointer + + * components/services/install/idl/trilobite-eazel-install.idl: + * components/services/install/lib/eazel-install-corba-callback.c: + (impl_download_progress), (impl_download_failed): + * components/services/install/lib/eazel-install-corba-types.c: + (corba_packagedatastruct_from_packagedata): + * components/services/install/lib/eazel-install-object.c: + (eazel_install_fetch_remote_package_list), + (eazel_install_emit_download_progress), + (eazel_install_emit_download_progress_default), + (eazel_install_emit_download_failed), + (eazel_install_emit_download_failed_default): + * components/services/install/lib/eazel-install-protocols.c: + (http_fetch_remote_file), (ftp_fetch_remote_file), + (gnome_vfs_xfer_callback), (gnome_vfs_fetch_remote_file), + (local_fetch_remote_file), (eazel_install_fetch_file), + (eazel_install_fetch_package): + * components/services/install/lib/eazel-install-protocols.h: + * components/services/install/lib/eazel-install-public.h: + + Change the download_progress and download_failed signals to pass a + PackageData struct (and not a char*) just like every other signal, + now that we can do that. Fix a missing bytesize fill-in in one of + the corba conversion functions. Also, make the non-slim build use + the file-rename trick from the bootstrap installer, to ensure that + uncompleted downloads are never treated like valid package files. + + * components/rpmview/nautilus-rpm-view-install.c: + (nautilus_rpm_view_download_progress_signal), + (nautilus_rpm_view_download_failed): + * components/services/install/command-line/eazel-alt-install-corba. + c: (eazel_download_progress_signal), (download_failed), + (something_failed): + + Fix rpm view and command-line install to use the new download + signal signatures. + + * components/services/install/nautilus-view/nautilus-service-instal + l-view.c: (nautilus_service_install_downloading), + (nautilus_service_install_preflight_check), + (nautilus_service_install_download_failed), + (nautilus_service_install_installing), + (nautilus_service_install_done), + (nautilus_service_install_view_update_from_uri): + + Use the new download signal signatures to draw a nifty progress + bar for the overall download (where 90% of most users' time will + be spent in this view). Scale the progress bar to match the + package files' expected sizes (softcat bug to be fixed in 1.0). + Leave the throbber on during the downloads so they can be + aborted. Don't offer to erase rpms if the package was already + installed (and therefore not downloaded). + 2001-01-22 Arlo Rose A whole mess of files checked in to add a new color variation diff --git a/components/rpmview/nautilus-rpm-view-install.c b/components/rpmview/nautilus-rpm-view-install.c index 90361ea79..dc79fe14d 100644 --- a/components/rpmview/nautilus-rpm-view-install.c +++ b/components/rpmview/nautilus-rpm-view-install.c @@ -36,7 +36,7 @@ static void nautilus_rpm_view_download_progress_signal (EazelInstallCallback *service, - const char *name, + const PackageData *pack, int amount, int total, NautilusRPMView *rpm_view) @@ -88,10 +88,11 @@ nautilus_rpm_view_install_progress_signal (EazelInstallCallback *service, static void nautilus_rpm_view_download_failed (EazelInstallCallback *service, - const char *name, + const PackageData *pack, NautilusRPMView *rpm_view) { - trilobite_debug ("Download of %s FAILED", name); + g_assert (pack->name != NULL); + trilobite_debug ("Download of %s FAILED", pack->name); } static void diff --git a/components/services/install-view/nautilus-service-install-view.c b/components/services/install-view/nautilus-service-install-view.c index b5c8e264f..a5611d237 100644 --- a/components/services/install-view/nautilus-service-install-view.c +++ b/components/services/install-view/nautilus-service-install-view.c @@ -498,7 +498,7 @@ create_package (char *name, int local_file) * package-name [ "?version=" version ] ( ";" package-name [ "?version=" version ] )* * * eazel-install:xfig - * eazel-install://anonymous@freeamp + * eazel-install://anonymous@/freeamp * eazel-install://example.com:8888/nautilus?version=1.0;xpdf;sephiroth?version=0.4 */ /* returns TRUE if a hostname was parsed from the uri */ @@ -654,28 +654,26 @@ current_progress_bar_complete (NautilusServiceInstallView *view, const char *tex static void -nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name, int amount, int total, +nautilus_service_install_downloading (EazelInstallCallback *cb, const PackageData *pack, int amount, int total, NautilusServiceInstallView *view) { char *out; - const char *root_name, *tmp, *needed_by; + const char *needed_by; GList *iter; InstallMessage *im = view->details->current_im; + float fake_amount; if (view->details->installer == NULL) { g_warning ("Got download notice after unref!"); return; } - /* sometimes the "name" is annoyingly the entire path */ - root_name = name; - while ((tmp = strchr (root_name, '/')) != NULL) { - root_name = tmp+1; - } + /* install lib better damn well know the name of the package by the time we download it! */ + g_assert (pack->name != NULL); if (amount == 0) { /* could be a redundant zero-trigger for the same rpm... */ - if (view->details->current_rpm && (strcmp (view->details->current_rpm, root_name) == 0)) { + if (view->details->current_rpm && (strcmp (view->details->current_rpm, pack->name) == 0)) { /* spin_cylon (view); */ return; } @@ -684,38 +682,35 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name gtk_timeout_remove (view->details->cylon_timer); view->details->cylon_timer = 0; } - turn_cylon_off (view, 0.0); g_free (view->details->current_rpm); - view->details->current_rpm = g_strdup (root_name); - - show_overall_feedback (view, " "); + view->details->current_rpm = g_strdup (pack->name); /* figure out if this is a toplevel package, and if so, update the header */ for (iter = g_list_first (((CategoryData *)(view->details->categories->data))->packages); iter != NULL; iter = g_list_next (iter)) { - PackageData *pack = (PackageData *)(iter->data); - if ((pack->name != NULL) && (strcmp (pack->name, name) == 0)) { - out = g_strdup_printf (_("Downloading \"%s\""), name); + PackageData *pack2 = (PackageData *)(iter->data); + if ((pack2->name != NULL) && (strcmp (pack2->name, pack->name) == 0)) { + out = g_strdup_printf (_("Downloading \"%s\""), pack->name); nautilus_label_set_text (NAUTILUS_LABEL (view->details->package_name), out); g_free (out); } } /* new progress message and bar */ - im = view->details->current_im = install_message_new (view, root_name); + im = view->details->current_im = install_message_new (view, pack->name); gtk_progress_set_percentage (GTK_PROGRESS (im->progress_bar), 0.0); out = g_strdup_printf (_("0K of %dK"), total/1024); nautilus_label_set_text (NAUTILUS_LABEL (im->progress_label), out); g_free (out); view->details->last_k = 0; - needed_by = g_hash_table_lookup (view->details->deps, root_name); + needed_by = g_hash_table_lookup (view->details->deps, pack->name); if (needed_by != NULL) { out = g_strdup_printf (_("The package \"%s\" needs \"%s\" to run.\nI'm now attempting to download it."), - needed_by, root_name); + needed_by, pack->name); } else { - out = g_strdup_printf (_("I'm attempting to download package \"%s\"."), root_name); + out = g_strdup_printf (_("I'm attempting to download package \"%s\"."), pack->name); } nautilus_label_set_text (NAUTILUS_LABEL (im->label), out); g_free (out); @@ -723,12 +718,12 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name /* done! */ current_progress_bar_complete (view, _("Complete")); gtk_progress_set_percentage (GTK_PROGRESS (im->progress_bar), 1.0); - needed_by = g_hash_table_lookup (view->details->deps, root_name); + needed_by = g_hash_table_lookup (view->details->deps, pack->name); if (needed_by != NULL) { out = g_strdup_printf (_("The package \"%s\" needs \"%s\" to run.\nI've downloaded it successfully."), - needed_by, root_name); + needed_by, pack->name); } else { - out = g_strdup_printf (_("I've successfully downloaded package \"%s\"."), root_name); + out = g_strdup_printf (_("I've successfully downloaded package \"%s\"."), pack->name); } nautilus_label_set_text (NAUTILUS_LABEL (im->label), out); g_free (out); @@ -736,13 +731,11 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name view->details->current_rpm = NULL; view->details->current_im = NULL; /* update downloaded bytes */ - view->details->download_bytes_sofar += total; -#if 0 + view->details->download_bytes_sofar += pack->bytesize; /* not until we get an rpm size */ gtk_progress_set_percentage (GTK_PROGRESS (view->details->total_progress_bar), (float) view->details->download_bytes_sofar / (float) view->details->download_bytes_total); -#endif } else { /* could be a leftover event, after user hit STOP (in which case, current_im = NULL) */ if ((im != NULL) && (im->progress_bar != NULL)) { @@ -755,6 +748,16 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name view->details->last_k = (amount/1024); } } + + /* so, for PR3, we are given a "size" field in the softcat XML which is actually + * the size of the decompressed files. so this little hocus-pocus scales the + * actual size (which we know once we start downloading the file) to match the + * previously-assumed size + */ + fake_amount = (float)amount * (float)pack->bytesize / (float)total; + gtk_progress_set_percentage (GTK_PROGRESS (view->details->total_progress_bar), + ((float) view->details->download_bytes_sofar + fake_amount) / + (float) view->details->download_bytes_total); } } @@ -854,8 +857,6 @@ nautilus_service_install_preflight_check (EazelInstallCallback *cb, const GList char *out; unsigned long total_k; - /* no longer "loading" anything */ - nautilus_view_report_load_complete (view->details->nautilus_view); /* turn off the cylon and show "real" progress */ turn_cylon_off (view, 0.0); @@ -920,9 +921,9 @@ nautilus_service_install_preflight_check (EazelInstallCallback *cb, const GList } if (g_list_length (package_list) == 1) { - out = g_strdup (_("Preparing to download 1 package")); + out = g_strdup (_("Downloading 1 package")); } else { - out = g_strdup_printf (_("Preparing to download %d packages"), g_list_length (package_list)); + out = g_strdup_printf (_("Downloading %d packages"), g_list_length (package_list)); } show_overall_feedback (view, out); g_free (out); @@ -934,17 +935,19 @@ nautilus_service_install_preflight_check (EazelInstallCallback *cb, const GList static void -nautilus_service_install_download_failed (EazelInstallCallback *cb, const char *name, +nautilus_service_install_download_failed (EazelInstallCallback *cb, const PackageData *pack, NautilusServiceInstallView *view) { - char *out; + char *out, *tmp; turn_cylon_off (view, 0.0); /* no longer "loading" anything */ nautilus_view_report_load_complete (view->details->nautilus_view); - out = g_strdup_printf (_("Download of package \"%s\" failed!"), name); + tmp = packagedata_get_readable_name (pack); + out = g_strdup_printf (_("Download of package \"%s\" failed!"), tmp); + g_free (tmp); if (view->details->current_im != NULL) { nautilus_label_set_text (NAUTILUS_LABEL (view->details->current_im->label), out); } @@ -992,6 +995,9 @@ nautilus_service_install_installing (EazelInstallCallback *cb, const PackageData im = view->details->current_im; if (current_package != view->details->current_package) { + /* no longer "loading" anything */ + nautilus_view_report_load_complete (view->details->nautilus_view); + /* starting a new package -- create new progress indicator */ out = g_strdup_printf (_("Installing package %d of %d"), current_package, total_packages); show_overall_feedback (view, out); @@ -1287,7 +1293,7 @@ nautilus_service_install_done (EazelInstallCallback *cb, gboolean success, Nauti real_message = g_strdup_printf (_("%s\n%s\nErase the leftover RPM files?"), message, nautilus_install_service_locate_menu_entries (view)); - } else if (view->details->cancelled_before_downloads) { + } else if (view->details->cancelled_before_downloads || view->details->already_installed) { real_message = g_strdup (message); question_dialog = FALSE; } else { @@ -1567,8 +1573,6 @@ nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view, } GNOME_Trilobite_Eazel_Install__set_test_mode (service, FALSE, &ev); - /* attempt to create a directory we can use */ - gtk_signal_connect (GTK_OBJECT (view->details->installer), "download_progress", GTK_SIGNAL_FUNC (nautilus_service_install_downloading), view); gtk_signal_connect (GTK_OBJECT (view->details->installer), "download_failed", @@ -1589,7 +1593,7 @@ nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view, CORBA_exception_free (&ev); - show_overall_feedback (view, _("Contacting software catalog ...")); + show_overall_feedback (view, _("Contacting the software catalog ...")); /* might take a while... cylon a bit */ gtk_progress_set_activity_mode (GTK_PROGRESS (view->details->total_progress_bar), TRUE); diff --git a/components/services/install/command-line/eazel-alt-install-corba.c b/components/services/install/command-line/eazel-alt-install-corba.c index 42a784cef..523180a2f 100644 --- a/components/services/install/command-line/eazel-alt-install-corba.c +++ b/components/services/install/command-line/eazel-alt-install-corba.c @@ -270,7 +270,7 @@ set_parameters_from_command_line (GNOME_Trilobite_Eazel_Install service) static void eazel_download_progress_signal (EazelInstallCallback *service, - const char *name, + const PackageData *pack, int amount, int total, char *title) @@ -283,10 +283,12 @@ eazel_download_progress_signal (EazelInstallCallback *service, time_t diff; static float ks=0; + g_assert (pack->name != NULL); + downloaded_files = TRUE; if (amount==0) { - fprintf (stdout, "Downloading %s...", name); + fprintf (stdout, "Downloading %s...", pack->name); t = time (NULL); old_pct = pct = 0; } else if (amount != total ) { @@ -300,24 +302,24 @@ eazel_download_progress_signal (EazelInstallCallback *service, old_pct = pct; } fprintf (stdout, "\rDownloading %s... (%d/%d) = %d%% %.1f Kb/s \r", - name, + pack->name, amount, total, pct, ks); } else { fprintf (stdout, "\rDownloading %s... (%d/%d) = %d%%", - name, + pack->name, amount, total, pct); } } } else if (amount == total && total!=0) { if (arg_no_pct==0) { fprintf (stdout, "\rDownloading %s... (%d/%d) %.1f Kb/s Done \n", - name, + pack->name, amount, total, ks); } else { fprintf (stdout, "Downloading %s... %3.1f KB/s Done\n", - name, ks); + pack->name, ks); } } fflush (stdout); @@ -360,10 +362,11 @@ eazel_install_progress_signal (EazelInstallCallback *service, static void download_failed (EazelInstallCallback *service, - const char *name, + const PackageData *pack, gpointer unused) { - fprintf (stdout, "Download of %s FAILED\n", name); + g_assert (pack->name != NULL); + fprintf (stdout, "Download of %s FAILED\n", pack->name); } /* This is ridiculous... */ @@ -455,7 +458,7 @@ tree_helper (EazelInstallCallback *service, static void something_failed (EazelInstallCallback *service, - const PackageData *pd, + const PackageData *pd, EazelInstallProblem *problem, gboolean uninstall) { diff --git a/components/services/install/idl/trilobite-eazel-install.idl b/components/services/install/idl/trilobite-eazel-install.idl index 8b0853b30..43b00f225 100644 --- a/components/services/install/idl/trilobite-eazel-install.idl +++ b/components/services/install/idl/trilobite-eazel-install.idl @@ -115,7 +115,7 @@ module Trilobite { interface InstallCallback : Bonobo::Unknown { /* Called during download of a file */ /* make it 2-way so that it will process incoming corba calls */ - void download_progress (in string file, in long amount, in long total); + void download_progress (in PackageDataStruct package, in long amount, in long total); /* Called when dependency check is being handled */ oneway void dependency_check (in PackageDataStruct package, in PackageDataStruct needs); @@ -143,7 +143,7 @@ module Trilobite { /* Called whenever a package (un)install fails */ - void download_failed (in string file); + void download_failed (in PackageDataStruct package); /* FIXME bugzilla.eazel.com 1542: This is what they should be, but orbit-idl's lack of recursive structures, forces us to encode the structures diff --git a/components/services/install/lib/eazel-install-corba-callback.c b/components/services/install/lib/eazel-install-corba-callback.c index 1f0785461..bc08248ab 100644 --- a/components/services/install/lib/eazel-install-corba-callback.c +++ b/components/services/install/lib/eazel-install-corba-callback.c @@ -70,12 +70,16 @@ typedef struct { static void impl_download_progress (impl_POA_GNOME_Trilobite_Eazel_InstallCallback *servant, - const char *name, + const GNOME_Trilobite_Eazel_PackageDataStruct *corbapack, const CORBA_long amount, const CORBA_long total, CORBA_Environment * ev) { - gtk_signal_emit (GTK_OBJECT (servant->object), signals[DOWNLOAD_PROGRESS], name, amount, total); + PackageData *pack; + + pack = packagedata_from_corba_packagedatastruct (*corbapack); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[DOWNLOAD_PROGRESS], pack, amount, total); + packagedata_destroy (pack, TRUE); } static CORBA_boolean @@ -113,10 +117,14 @@ impl_preflight_check (impl_POA_GNOME_Trilobite_Eazel_InstallCallback *servant, static void impl_download_failed (impl_POA_GNOME_Trilobite_Eazel_InstallCallback *servant, - const char *name, + const GNOME_Trilobite_Eazel_PackageDataStruct *corbapack, CORBA_Environment * ev) { - gtk_signal_emit (GTK_OBJECT (servant->object), signals[DOWNLOAD_FAILED], name); + PackageData *pack; + + pack = packagedata_from_corba_packagedatastruct (*corbapack); + gtk_signal_emit (GTK_OBJECT (servant->object), signals[DOWNLOAD_FAILED], pack); + packagedata_destroy (pack, TRUE); } static void diff --git a/components/services/install/lib/eazel-install-corba-types.c b/components/services/install/lib/eazel-install-corba-types.c index d382eb823..7771d26fd 100644 --- a/components/services/install/lib/eazel-install-corba-types.c +++ b/components/services/install/lib/eazel-install-corba-types.c @@ -79,7 +79,6 @@ corba_packagedatastruct_from_packagedata (const PackageData *pack) 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; corbapack->install_root = pack->install_root ? CORBA_string_dup (pack->install_root) : CORBA_string_dup (""); corbapack->md5 = pack->md5 ? CORBA_string_dup (pack->md5) : CORBA_string_dup (""); @@ -100,6 +99,8 @@ corba_packagedatastruct_from_packagedata (const PackageData *pack) corbapack->release = pack->minor ? CORBA_string_dup (pack->minor) : CORBA_string_dup (""); corbapack->summary = pack->summary ? CORBA_string_dup (pack->summary) : CORBA_string_dup (""); corbapack->description = pack->description ? CORBA_string_dup (pack->description) : CORBA_string_dup (""); + corbapack->bytesize = pack->bytesize; + corbapack->toplevel = pack->toplevel; switch (pack->status) { case PACKAGE_UNKNOWN_STATUS: diff --git a/components/services/install/lib/eazel-install-object.c b/components/services/install/lib/eazel-install-object.c index 141794cd1..7d2230dd9 100644 --- a/components/services/install/lib/eazel-install-object.c +++ b/components/services/install/lib/eazel-install-object.c @@ -114,16 +114,16 @@ static BonoboObjectClass *eazel_install_parent_class; void eazel_install_emit_install_progress_default (EazelInstall *service, const PackageData *pack, int, int, int, int, int, int); -void eazel_install_emit_download_progress_default (EazelInstall *service, - const char *name, - int amount, - int total); +void eazel_install_emit_download_progress_default (EazelInstall *service, + const PackageData *package, + int amount, + int total); gboolean eazel_install_emit_preflight_check_default (EazelInstall *service, GList *packages, int total_bytes, int total_packages); -void eazel_install_emit_download_failed_default (EazelInstall *service, - const char *name); +void eazel_install_emit_download_failed_default (EazelInstall *service, + const PackageData *package); void eazel_install_emit_md5_check_failed_default (EazelInstall *service, const PackageData *pack, const char *actual_md5); @@ -882,17 +882,13 @@ eazel_install_fetch_remote_package_list (EazelInstall *service) eazel_install_get_server_port (service), eazel_install_get_package_list_storage_path (service)[0]=='/'?"":"/", eazel_install_get_package_list_storage_path (service)); -#ifdef EAZEL_INSTALL_SLIM destination = g_strdup (eazel_install_get_package_list (service)); -#else /* EAZEL_INSTALL_SLIM */ - destination = g_strdup_printf ("file://%s", - eazel_install_get_package_list (service)); -#endif /* EAZEL_INSTALL_SLIM */ retval = eazel_install_fetch_file (service, url, "package list", - destination); + destination, + NULL); if (!retval) { g_warning (_("Unable to retrieve package-list.xml!\n")); @@ -1285,17 +1281,17 @@ eazel_install_emit_install_progress_default (EazelInstall *service, void eazel_install_emit_download_progress (EazelInstall *service, - const char *name, + const PackageData *pack, int amount, int total) { EAZEL_INSTALL_SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_PROGRESS], name, amount, total); + gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_PROGRESS], pack, amount, total); } void eazel_install_emit_download_progress_default (EazelInstall *service, - const char *name, + const PackageData *pack, int amount, int total) { @@ -1304,11 +1300,14 @@ eazel_install_emit_download_progress_default (EazelInstall *service, CORBA_exception_init (&ev); EAZEL_INSTALL_SANITY(service); if (service->callback != CORBA_OBJECT_NIL) { - GNOME_Trilobite_Eazel_InstallCallback_download_progress (service->callback, name, amount, total, &ev); + GNOME_Trilobite_Eazel_PackageDataStruct *package; + package = corba_packagedatastruct_from_packagedata (pack); + GNOME_Trilobite_Eazel_InstallCallback_download_progress (service->callback, package, amount, total, &ev); if (ev._major != CORBA_NO_EXCEPTION) { /* user has aborted us and gone home -- tell VFS to STOP! */ service->private->cancel_download = TRUE; } + CORBA_free (package); } CORBA_exception_free (&ev); #endif /* EAZEL_INSTALL_NO_CORBA */ @@ -1408,22 +1407,29 @@ eazel_install_emit_preflight_check_default (EazelInstall *service, void eazel_install_emit_download_failed (EazelInstall *service, - const char *name) + const PackageData *pack) { EAZEL_INSTALL_SANITY(service); - gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_FAILED], name); + gtk_signal_emit (GTK_OBJECT (service), signals[DOWNLOAD_FAILED], pack); } void eazel_install_emit_download_failed_default (EazelInstall *service, - const char *name) + const PackageData *pack) { #ifndef EAZEL_INSTALL_NO_CORBA CORBA_Environment ev; CORBA_exception_init (&ev); EAZEL_INSTALL_SANITY(service); if (service->callback != CORBA_OBJECT_NIL) { - GNOME_Trilobite_Eazel_InstallCallback_download_failed (service->callback, name, &ev); + GNOME_Trilobite_Eazel_PackageDataStruct *package; + package = corba_packagedatastruct_from_packagedata (pack); + GNOME_Trilobite_Eazel_InstallCallback_download_failed (service->callback, package, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + /* user has aborted us and gone home -- tell VFS to STOP! */ + service->private->cancel_download = TRUE; + } + CORBA_free (package); } CORBA_exception_free (&ev); #endif /* EAZEL_INSTALL_NO_CORBA */ diff --git a/components/services/install/lib/eazel-install-protocols.c b/components/services/install/lib/eazel-install-protocols.c index 804931184..a007bd85c 100644 --- a/components/services/install/lib/eazel-install-protocols.c +++ b/components/services/install/lib/eazel-install-protocols.c @@ -55,13 +55,14 @@ typedef struct { EazelInstall *service; - const char *file_to_report; + const PackageData *package; } gnome_vfs_callback_struct; typedef gboolean (*eazel_install_file_fetch_function) (gpointer *obj, char *url, const char *file_to_report, - const char *target_file); + const char *target_file, + const PackageData *package); #ifdef EAZEL_INSTALL_SLIM @@ -69,21 +70,25 @@ typedef gboolean (*eazel_install_file_fetch_function) (gpointer *obj, gboolean http_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file); + const char* target_file, + const PackageData *package); gboolean ftp_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file); + const char* target_file, + const PackageData *package); #else /* EAZEL_INSTALL_SLIM */ gboolean gnome_vfs_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char *target_file); + const char *target_file, + const PackageData *package); #endif /* EAZEL_INSTALL_SLIM */ gboolean local_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file); + const char* target_file, + const PackageData *package); #ifdef EAZEL_INSTALL_SLIM @@ -91,7 +96,8 @@ gboolean http_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file) + const char* target_file, + const PackageData *package) { int length, get_failed; ghttp_request* request; @@ -159,13 +165,13 @@ http_fetch_remote_file (EazelInstall *service, total_bytes = curStat.bytes_total; /* Ensure first emit is with amount==0 */ if (first_emit && total_bytes > 0) { - eazel_install_emit_download_progress (service, report, 0, total_bytes); + eazel_install_emit_download_progress (service, package, 0, total_bytes); first_emit = FALSE; } /* And that amount==0 & amount==total only occurs once */ if (curStat.bytes_read!=0 && (curStat.bytes_read != curStat.bytes_total)) { eazel_install_emit_download_progress (service, - report, + package, curStat.bytes_read, curStat.bytes_total); } @@ -194,7 +200,7 @@ http_fetch_remote_file (EazelInstall *service, g_main_iteration (FALSE); } /* Last emit amount==total */ - eazel_install_emit_download_progress (service, report, total_bytes, total_bytes); + eazel_install_emit_download_progress (service, package, total_bytes, total_bytes); if (ghttp_status_code (request) != 200) { g_warning (_("HTTP error: %d %s"), ghttp_status_code (request), @@ -244,7 +250,8 @@ gboolean ftp_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file) + const char* target_file, + const PackageData *package) { trilobite_debug (_("Downloading %s..."), url); trilobite_debug (_("FTP not supported yet")); @@ -261,7 +268,7 @@ gnome_vfs_xfer_callback (GnomeVFSXferProgressInfo *info, static gboolean initial_emit; static gboolean last_emit; EazelInstall *service = cbstruct->service; - const char *file_to_report = cbstruct->file_to_report; + const PackageData *package = cbstruct->package; switch (info->status) { case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR: @@ -296,19 +303,19 @@ gnome_vfs_xfer_callback (GnomeVFSXferProgressInfo *info, case GNOME_VFS_XFER_PHASE_COPYING: if (initial_emit && info->file_size>0) { initial_emit = FALSE; - eazel_install_emit_download_progress (service, - file_to_report ? file_to_report : info->source_name, + eazel_install_emit_download_progress (service, + package, 0, info->file_size); } else if (!last_emit && info->bytes_copied == info->file_size) { last_emit = TRUE; eazel_install_emit_download_progress (service, - file_to_report ? file_to_report : info->source_name, + package, info->file_size, info->file_size); } else if (info->bytes_copied > 0) { eazel_install_emit_download_progress (service, - file_to_report ? file_to_report : info->source_name, + package, info->bytes_copied, info->file_size); @@ -337,7 +344,7 @@ gnome_vfs_xfer_callback (GnomeVFSXferProgressInfo *info, if (!last_emit) { last_emit = TRUE; eazel_install_emit_download_progress (service, - file_to_report ? file_to_report : info->source_name, + package, info->file_size, info->file_size); } @@ -362,22 +369,21 @@ gboolean gnome_vfs_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char *target_file) + const char *target_file, + const PackageData *package) { GnomeVFSResult result; GnomeVFSXferOptions xfer_options = 0; GnomeVFSURI *src_uri; GnomeVFSURI *dest_uri; char *t_file; + char *target_file_premove; gnome_vfs_callback_struct *cbstruct; - /* Ensure the target_file has a protocol://, - if not, prefix a file:// */ - if (strstr (target_file, "://")==NULL) { - t_file = g_strdup_printf ("file://%s", target_file); - } else { - t_file = g_strdup (target_file); - } + target_file_premove = g_strdup_printf ("%s~", target_file); + + /* this will always be a file: uri */ + t_file = g_strdup_printf ("file://%s", target_file_premove); trilobite_debug ("gnome_vfs_xfer_uri ( %s %s )", url, t_file); @@ -388,14 +394,14 @@ gnome_vfs_fetch_remote_file (EazelInstall *service, gnome_vfs_uri_set_host_name (src_uri, "localhost"); } - dest_uri = gnome_vfs_uri_new (t_file); + dest_uri = gnome_vfs_uri_new (target_file_premove); g_assert (dest_uri != NULL); /* Setup the userdata for the callback, I need both the service object to emit signals too, and the filename to report */ cbstruct = g_new0 (gnome_vfs_callback_struct, 1); cbstruct->service = service; - cbstruct->file_to_report = file_to_report; + cbstruct->package = package; /* Execute the gnome_vfs copy */ service->private->cancel_download = FALSE; @@ -408,7 +414,8 @@ gnome_vfs_fetch_remote_file (EazelInstall *service, if (result==GNOME_VFS_OK) { chmod (target_file, 0600); - trilobite_debug ("File download successfull"); + trilobite_debug ("File download successful"); + rename (target_file_premove, target_file); } else { trilobite_debug ("File download failed"); if (result == GNOME_VFS_ERROR_BAD_PARAMETERS) { @@ -418,7 +425,7 @@ gnome_vfs_fetch_remote_file (EazelInstall *service, trilobite_debug ("download was cancelled from afar"); } } - + /* Free the various stuff */ g_free (t_file); g_free (cbstruct); @@ -435,7 +442,8 @@ gboolean local_fetch_remote_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file) + const char* target_file, + const PackageData *package) { gboolean result; const char *report; @@ -447,8 +455,8 @@ local_fetch_remote_file (EazelInstall *service, struct stat sbuf; stat (target_file, &sbuf); /* Emit bogus download progress */ - eazel_install_emit_download_progress (service, report, 0, sbuf.st_size); - eazel_install_emit_download_progress (service, report, sbuf.st_size, sbuf.st_size); + eazel_install_emit_download_progress (service, package, 0, sbuf.st_size); + eazel_install_emit_download_progress (service, package, sbuf.st_size, sbuf.st_size); result = TRUE; } return result; @@ -516,7 +524,8 @@ gboolean eazel_install_fetch_file (EazelInstall *service, char *url, const char *file_to_report, - const char* target_file) + const char* target_file, + const PackageData *package) { gboolean result; GList *iter; @@ -549,21 +558,21 @@ eazel_install_fetch_file (EazelInstall *service, struct stat buf; stat (target_file, &buf); trilobite_debug ("%s already present, not downloading", target_file); - eazel_install_emit_download_progress (service, file_to_report, 0, buf.st_size); - eazel_install_emit_download_progress (service, file_to_report, buf.st_size, buf.st_size); + eazel_install_emit_download_progress (service, package, 0, buf.st_size); + eazel_install_emit_download_progress (service, package, buf.st_size, buf.st_size); result = TRUE; } else { result = (func_table [eazel_install_get_protocol (service)])((gpointer)service, url, file_to_report, - target_file); + target_file, + package); } if (!result) { g_warning (_("Failed to retrieve %s!"), file_to_report ? file_to_report : g_basename (target_file)); - eazel_install_emit_download_failed (service, - file_to_report ? file_to_report : g_basename (target_file)); + eazel_install_emit_download_failed (service, package); } return result; @@ -629,7 +638,7 @@ eazel_install_fetch_package (EazelInstall *service, targetname = g_strdup_printf ("%s/%s", eazel_install_get_tmp_dir (service), filename_from_url (url)); - result = eazel_install_fetch_file (service, url, package->name, targetname); + result = eazel_install_fetch_file (service, url, package->name, targetname, package); if (result) { package = eazel_package_system_load_package (service->private->package_system, package, diff --git a/components/services/install/lib/eazel-install-protocols.h b/components/services/install/lib/eazel-install-protocols.h index 4eb53a83c..47c5f1a00 100644 --- a/components/services/install/lib/eazel-install-protocols.h +++ b/components/services/install/lib/eazel-install-protocols.h @@ -34,7 +34,8 @@ gboolean eazel_install_fetch_file (EazelInstall *service, char *url, const char *file_to_report, - const char *target_file); + const char *target_file, + const PackageData *package); gboolean eazel_install_fetch_package (EazelInstall *service, PackageData *package); diff --git a/components/services/install/lib/eazel-install-public.h b/components/services/install/lib/eazel-install-public.h index ac9041996..89b364890 100644 --- a/components/services/install/lib/eazel-install-public.h +++ b/components/services/install/lib/eazel-install-public.h @@ -73,7 +73,7 @@ struct _EazelInstallClass BonoboObjectClass parent_class; #endif /* EAZEL_INSTALL_NO_CORBA */ /* signal prototypes */ - void (*download_progress) (EazelInstall *service, const char *file, int amount, int total); + void (*download_progress) (EazelInstall *service, const PackageData *package, int amount, int total); gboolean (*preflight_check) (EazelInstall *service, GList *packages, @@ -89,7 +89,7 @@ struct _EazelInstallClass /* if the set URLType is PROTOCOL_HTTP, info is a HTTPError struc */ - void (*download_failed) (EazelInstall *service, const char *name); + void (*download_failed) (EazelInstall *service, const PackageData *package); /* if RPM_FAIL is RPM_SRC_NOT_SUPPORTED, info is NULL RPM_DEP_FAIL, info is a GSList of required packages (PackageData objects) @@ -150,14 +150,14 @@ void eazel_install_emit_install_progress (EazelInstall *service, int package_num, int num_packages, int package_size_completed, int package_size_total, int total_size_completed, int total_size); -void eazel_install_emit_download_progress (EazelInstall *service, - const char *name, +void eazel_install_emit_download_progress (EazelInstall *service, + const PackageData *package, int amount, int total); gboolean eazel_install_emit_preflight_check (EazelInstall *service, GList *packages); void eazel_install_emit_download_failed (EazelInstall *service, - const char *name); + const PackageData *package); void eazel_install_emit_md5_check_failed (EazelInstall *service, const PackageData *pd, const char *actual_md5); diff --git a/components/services/install/nautilus-view/nautilus-service-install-view.c b/components/services/install/nautilus-view/nautilus-service-install-view.c index b5c8e264f..a5611d237 100644 --- a/components/services/install/nautilus-view/nautilus-service-install-view.c +++ b/components/services/install/nautilus-view/nautilus-service-install-view.c @@ -498,7 +498,7 @@ create_package (char *name, int local_file) * package-name [ "?version=" version ] ( ";" package-name [ "?version=" version ] )* * * eazel-install:xfig - * eazel-install://anonymous@freeamp + * eazel-install://anonymous@/freeamp * eazel-install://example.com:8888/nautilus?version=1.0;xpdf;sephiroth?version=0.4 */ /* returns TRUE if a hostname was parsed from the uri */ @@ -654,28 +654,26 @@ current_progress_bar_complete (NautilusServiceInstallView *view, const char *tex static void -nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name, int amount, int total, +nautilus_service_install_downloading (EazelInstallCallback *cb, const PackageData *pack, int amount, int total, NautilusServiceInstallView *view) { char *out; - const char *root_name, *tmp, *needed_by; + const char *needed_by; GList *iter; InstallMessage *im = view->details->current_im; + float fake_amount; if (view->details->installer == NULL) { g_warning ("Got download notice after unref!"); return; } - /* sometimes the "name" is annoyingly the entire path */ - root_name = name; - while ((tmp = strchr (root_name, '/')) != NULL) { - root_name = tmp+1; - } + /* install lib better damn well know the name of the package by the time we download it! */ + g_assert (pack->name != NULL); if (amount == 0) { /* could be a redundant zero-trigger for the same rpm... */ - if (view->details->current_rpm && (strcmp (view->details->current_rpm, root_name) == 0)) { + if (view->details->current_rpm && (strcmp (view->details->current_rpm, pack->name) == 0)) { /* spin_cylon (view); */ return; } @@ -684,38 +682,35 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name gtk_timeout_remove (view->details->cylon_timer); view->details->cylon_timer = 0; } - turn_cylon_off (view, 0.0); g_free (view->details->current_rpm); - view->details->current_rpm = g_strdup (root_name); - - show_overall_feedback (view, " "); + view->details->current_rpm = g_strdup (pack->name); /* figure out if this is a toplevel package, and if so, update the header */ for (iter = g_list_first (((CategoryData *)(view->details->categories->data))->packages); iter != NULL; iter = g_list_next (iter)) { - PackageData *pack = (PackageData *)(iter->data); - if ((pack->name != NULL) && (strcmp (pack->name, name) == 0)) { - out = g_strdup_printf (_("Downloading \"%s\""), name); + PackageData *pack2 = (PackageData *)(iter->data); + if ((pack2->name != NULL) && (strcmp (pack2->name, pack->name) == 0)) { + out = g_strdup_printf (_("Downloading \"%s\""), pack->name); nautilus_label_set_text (NAUTILUS_LABEL (view->details->package_name), out); g_free (out); } } /* new progress message and bar */ - im = view->details->current_im = install_message_new (view, root_name); + im = view->details->current_im = install_message_new (view, pack->name); gtk_progress_set_percentage (GTK_PROGRESS (im->progress_bar), 0.0); out = g_strdup_printf (_("0K of %dK"), total/1024); nautilus_label_set_text (NAUTILUS_LABEL (im->progress_label), out); g_free (out); view->details->last_k = 0; - needed_by = g_hash_table_lookup (view->details->deps, root_name); + needed_by = g_hash_table_lookup (view->details->deps, pack->name); if (needed_by != NULL) { out = g_strdup_printf (_("The package \"%s\" needs \"%s\" to run.\nI'm now attempting to download it."), - needed_by, root_name); + needed_by, pack->name); } else { - out = g_strdup_printf (_("I'm attempting to download package \"%s\"."), root_name); + out = g_strdup_printf (_("I'm attempting to download package \"%s\"."), pack->name); } nautilus_label_set_text (NAUTILUS_LABEL (im->label), out); g_free (out); @@ -723,12 +718,12 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name /* done! */ current_progress_bar_complete (view, _("Complete")); gtk_progress_set_percentage (GTK_PROGRESS (im->progress_bar), 1.0); - needed_by = g_hash_table_lookup (view->details->deps, root_name); + needed_by = g_hash_table_lookup (view->details->deps, pack->name); if (needed_by != NULL) { out = g_strdup_printf (_("The package \"%s\" needs \"%s\" to run.\nI've downloaded it successfully."), - needed_by, root_name); + needed_by, pack->name); } else { - out = g_strdup_printf (_("I've successfully downloaded package \"%s\"."), root_name); + out = g_strdup_printf (_("I've successfully downloaded package \"%s\"."), pack->name); } nautilus_label_set_text (NAUTILUS_LABEL (im->label), out); g_free (out); @@ -736,13 +731,11 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name view->details->current_rpm = NULL; view->details->current_im = NULL; /* update downloaded bytes */ - view->details->download_bytes_sofar += total; -#if 0 + view->details->download_bytes_sofar += pack->bytesize; /* not until we get an rpm size */ gtk_progress_set_percentage (GTK_PROGRESS (view->details->total_progress_bar), (float) view->details->download_bytes_sofar / (float) view->details->download_bytes_total); -#endif } else { /* could be a leftover event, after user hit STOP (in which case, current_im = NULL) */ if ((im != NULL) && (im->progress_bar != NULL)) { @@ -755,6 +748,16 @@ nautilus_service_install_downloading (EazelInstallCallback *cb, const char *name view->details->last_k = (amount/1024); } } + + /* so, for PR3, we are given a "size" field in the softcat XML which is actually + * the size of the decompressed files. so this little hocus-pocus scales the + * actual size (which we know once we start downloading the file) to match the + * previously-assumed size + */ + fake_amount = (float)amount * (float)pack->bytesize / (float)total; + gtk_progress_set_percentage (GTK_PROGRESS (view->details->total_progress_bar), + ((float) view->details->download_bytes_sofar + fake_amount) / + (float) view->details->download_bytes_total); } } @@ -854,8 +857,6 @@ nautilus_service_install_preflight_check (EazelInstallCallback *cb, const GList char *out; unsigned long total_k; - /* no longer "loading" anything */ - nautilus_view_report_load_complete (view->details->nautilus_view); /* turn off the cylon and show "real" progress */ turn_cylon_off (view, 0.0); @@ -920,9 +921,9 @@ nautilus_service_install_preflight_check (EazelInstallCallback *cb, const GList } if (g_list_length (package_list) == 1) { - out = g_strdup (_("Preparing to download 1 package")); + out = g_strdup (_("Downloading 1 package")); } else { - out = g_strdup_printf (_("Preparing to download %d packages"), g_list_length (package_list)); + out = g_strdup_printf (_("Downloading %d packages"), g_list_length (package_list)); } show_overall_feedback (view, out); g_free (out); @@ -934,17 +935,19 @@ nautilus_service_install_preflight_check (EazelInstallCallback *cb, const GList static void -nautilus_service_install_download_failed (EazelInstallCallback *cb, const char *name, +nautilus_service_install_download_failed (EazelInstallCallback *cb, const PackageData *pack, NautilusServiceInstallView *view) { - char *out; + char *out, *tmp; turn_cylon_off (view, 0.0); /* no longer "loading" anything */ nautilus_view_report_load_complete (view->details->nautilus_view); - out = g_strdup_printf (_("Download of package \"%s\" failed!"), name); + tmp = packagedata_get_readable_name (pack); + out = g_strdup_printf (_("Download of package \"%s\" failed!"), tmp); + g_free (tmp); if (view->details->current_im != NULL) { nautilus_label_set_text (NAUTILUS_LABEL (view->details->current_im->label), out); } @@ -992,6 +995,9 @@ nautilus_service_install_installing (EazelInstallCallback *cb, const PackageData im = view->details->current_im; if (current_package != view->details->current_package) { + /* no longer "loading" anything */ + nautilus_view_report_load_complete (view->details->nautilus_view); + /* starting a new package -- create new progress indicator */ out = g_strdup_printf (_("Installing package %d of %d"), current_package, total_packages); show_overall_feedback (view, out); @@ -1287,7 +1293,7 @@ nautilus_service_install_done (EazelInstallCallback *cb, gboolean success, Nauti real_message = g_strdup_printf (_("%s\n%s\nErase the leftover RPM files?"), message, nautilus_install_service_locate_menu_entries (view)); - } else if (view->details->cancelled_before_downloads) { + } else if (view->details->cancelled_before_downloads || view->details->already_installed) { real_message = g_strdup (message); question_dialog = FALSE; } else { @@ -1567,8 +1573,6 @@ nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view, } GNOME_Trilobite_Eazel_Install__set_test_mode (service, FALSE, &ev); - /* attempt to create a directory we can use */ - gtk_signal_connect (GTK_OBJECT (view->details->installer), "download_progress", GTK_SIGNAL_FUNC (nautilus_service_install_downloading), view); gtk_signal_connect (GTK_OBJECT (view->details->installer), "download_failed", @@ -1589,7 +1593,7 @@ nautilus_service_install_view_update_from_uri (NautilusServiceInstallView *view, CORBA_exception_free (&ev); - show_overall_feedback (view, _("Contacting software catalog ...")); + show_overall_feedback (view, _("Contacting the software catalog ...")); /* might take a while... cylon a bit */ gtk_progress_set_activity_mode (GTK_PROGRESS (view->details->total_progress_bar), TRUE);