]> git.saurik.com Git - apt.git/blobdiff - cmdline/acqprogress.cc
Fixed another oops
[apt.git] / cmdline / acqprogress.cc
index ccc322084e5674fc261fd6dc991ee78216b0da7c..99e8fd9c3ea4e8a68bff216ad94f9db84110d8af 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acqprogress.cc,v 1.2 1998/11/12 05:30:07 jgg Exp $
+// $Id: acqprogress.cc,v 1.7 1999/01/27 02:48:53 jgg Exp $
 /* ######################################################################
 
    Acquire Progress - Command line progress meter 
 /* ######################################################################
 
    Acquire Progress - Command line progress meter 
@@ -11,8 +11,8 @@
 #include "acqprogress.h"
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-worker.h>
 #include "acqprogress.h"
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-worker.h>
+#include <apt-pkg/strutl.h>
 #include <stdio.h>
 #include <stdio.h>
-#include <strutl.h>
                                                                        /*}}}*/
 
 // AcqTextStatus::AcqTextStatus - Constructor                          /*{{{*/
                                                                        /*}}}*/
 
 // AcqTextStatus::AcqTextStatus - Constructor                          /*{{{*/
@@ -136,8 +136,9 @@ void AcqTextStatus::Pulse(pkgAcquire *Owner)
    char *S = Buffer;
    
    // Put in the percent done
    char *S = Buffer;
    
    // Put in the percent done
-   sprintf(S,"%ld%%",long(double(CurrentBytes*100.0)/double(TotalBytes)));   
-   
+   sprintf(S,"%ld%%",long(double((CurrentBytes + CurrentItems)*100.0)/double(TotalBytes+TotalItems)));
+
+   bool Shown = false;
    for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
        I = Owner->WorkerStep(I))
    {
    for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
        I = Owner->WorkerStep(I))
    {
@@ -147,10 +148,16 @@ void AcqTextStatus::Pulse(pkgAcquire *Owner)
       if (I->CurrentItem == 0)
       {
         if (I->Status.empty() == false)
       if (I->CurrentItem == 0)
       {
         if (I->Status.empty() == false)
+        {
            snprintf(S,End-S," [%s]",I->Status.c_str());
            snprintf(S,End-S," [%s]",I->Status.c_str());
+           Shown = true;
+        }
+        
         continue;
       }
 
         continue;
       }
 
+      Shown = true;
+      
       // Add in the short description
       if (I->CurrentItem->Owner->ID != 0)
         snprintf(S,End-S," [%x %s",I->CurrentItem->Owner->ID,
       // Add in the short description
       if (I->CurrentItem->Owner->ID != 0)
         snprintf(S,End-S," [%x %s",I->CurrentItem->Owner->ID,
@@ -190,6 +197,10 @@ void AcqTextStatus::Pulse(pkgAcquire *Owner)
       snprintf(S,End-S,"]");
    }
 
       snprintf(S,End-S,"]");
    }
 
+   // Show something..
+   if (Shown == false)
+      snprintf(S,End-S," [Working]");
+      
    // Put in the ETA and cps meter
    if (CurrentCPS != 0)
    {      
    // Put in the ETA and cps meter
    if (CurrentCPS != 0)
    {      
@@ -217,3 +228,21 @@ void AcqTextStatus::Pulse(pkgAcquire *Owner)
    Update = false;
 }
                                                                        /*}}}*/
    Update = false;
 }
                                                                        /*}}}*/
+// AcqTextStatus::MediaChange - Media need to be swapped               /*{{{*/
+// ---------------------------------------------------------------------
+/* Prompt for a media swap */
+bool AcqTextStatus::MediaChange(string Media,string Drive)
+{
+   if (Quiet <= 0)
+      cout << '\r' << BlankLine << '\r';   
+   cout << "Media Change: Please insert the disc labeled '" << Media << "' in "\
+           "the drive '" << Drive << "' and press enter" << endl;
+
+   char C = 0;
+   while (C != '\n' && C != '\r')
+      read(STDIN_FILENO,&C,1);
+   
+   Update = true;
+   return true;
+}
+                                                                       /*}}}*/