]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
* merged fixes from otavio (thanks!)
[apt.git] / apt-pkg / acquire-worker.cc
index 3b354c9f9e58fb75d2d797a75392b7935f360988..25d40ef542f82a7f8af80c75e6284b6b2c1cf7ff 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-worker.cc,v 1.33 2001/03/23 01:47:14 jgg Exp $
+// $Id: acquire-worker.cc,v 1.34 2001/05/22 04:42:54 jgg Exp $
 /* ######################################################################
 
    Acquire Worker 
@@ -12,9 +12,6 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/acquire-worker.h"
-#endif
 #include <apt-pkg/acquire-worker.h>
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
 
 #include <apti18n.h>
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
     
 #include <sys/stat.h>
 #include <unistd.h>
@@ -32,6 +33,8 @@
 #include <errno.h>
                                                                        /*}}}*/
 
+using namespace std;
+
 // Worker::Worker - Constructor for Queue startup                      /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -128,7 +131,6 @@ bool pkgAcquire::Worker::Start()
       // Setup the FDs
       dup2(Pipes[1],STDOUT_FILENO);
       dup2(Pipes[2],STDIN_FILENO);
-      dup2(((filebuf *)clog.rdbuf())->fd(),STDERR_FILENO);
       SetCloseExec(STDOUT_FILENO,false);
       SetCloseExec(STDIN_FILENO,false);      
       SetCloseExec(STDERR_FILENO,false);
@@ -302,6 +304,13 @@ bool pkgAcquire::Worker::RunMessages()
            pkgAcquire::Item *Owner = Itm->Owner;
            pkgAcquire::ItemDesc Desc = *Itm;
            OwnerQ->ItemDone(Itm);
+
+           // set some status
+           if(LookupTag(Message,"FailReason") == "Timeout" || 
+              LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
+              LookupTag(Message,"FailReason") == "ConnectionRefused") 
+              Owner->Status = pkgAcquire::Item::StatTransientNetworkError;
+
            Owner->Failed(Message,Config);
            ItemDone();
 
@@ -363,6 +372,24 @@ bool pkgAcquire::Worker::Capabilities(string Message)
 /* */
 bool pkgAcquire::Worker::MediaChange(string Message)
 {
+   int status_fd = _config->FindI("APT::Status-Fd",-1);
+   if(status_fd > 0) 
+   {
+      string Media = LookupTag(Message,"Media");
+      string Drive = LookupTag(Message,"Drive"); 
+      ostringstream msg,status;
+      ioprintf(msg,_("Please insert the disc labeled: "
+                    "'%s' "
+                    "in the drive '%s' and press enter."),
+              Media.c_str(),Drive.c_str());
+      status << "media-change: "  // message
+            << Media  << ":"     // media
+            << Drive  << ":"     // drive
+            << msg.str()         // l10n message
+            << endl;
+      write(status_fd, status.str().c_str(), status.str().size());
+   }
+
    if (Log == 0 || Log->MediaChange(LookupTag(Message,"Media"),
                                    LookupTag(Message,"Drive")) == false)
    {
@@ -462,7 +489,7 @@ bool pkgAcquire::Worker::OutFdReady()
    int Res;
    do
    {
-      Res = write(OutFd,OutQueue.begin(),OutQueue.length());
+      Res = write(OutFd,OutQueue.c_str(),OutQueue.length());
    }
    while (Res < 0 && errno == EINTR);