Author: jkupec
Date: Tue Feb 19 16:23:46 2008
New Revision: 8817
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8817&view=rev
Log:
- normal download progress rewritten with Out class
Modified:
trunk/zypper/src/output/Out.h
trunk/zypper/src/output/OutNormal.cc
trunk/zypper/src/output/OutNormal.h
trunk/zypper/src/output/OutXML.cc
trunk/zypper/src/output/OutXML.h
trunk/zypper/src/zypper-media-callbacks.h
Modified: trunk/zypper/src/output/Out.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/output/Out.h?rev=8817&r1=8816&r2=8817&view=diff
==============================================================================
--- trunk/zypper/src/output/Out.h (original)
+++ trunk/zypper/src/output/Out.h Tue Feb 19 16:23:46 2008
@@ -5,6 +5,7 @@
#include "zypp/base/NonCopyable.h"
#include "zypp/base/Exception.h"
+#include "zypp/Url.h"
/**
*
@@ -98,14 +99,11 @@
const std::string & label) = 0;
// progress with download rate
- virtual void dwnldProgressStart(const std::string & id,
- const std::string & label) = 0;
- virtual void dwnldProgress(const std::string & id,
- const std::string & label,
+ virtual void dwnldProgressStart(const zypp::Url & uri) = 0;
+ virtual void dwnldProgress(const zypp::Url & uri,
int value = -1,
int rate = -1) = 0;
- virtual void dwnldProgressEnd(const std::string & id,
- const std::string & label) = 0;
+ virtual void dwnldProgressEnd(const zypp::Url & uri) = 0;
//virtual void Prompt() = 0;
public:
Modified: trunk/zypper/src/output/OutNormal.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/output/OutNormal.cc?rev=8817&r1=8816&r2=8817&view=diff
==============================================================================
--- trunk/zypper/src/output/OutNormal.cc (original)
+++ trunk/zypper/src/output/OutNormal.cc Tue Feb 19 16:23:46 2008
@@ -1,9 +1,13 @@
#include <iostream>
#include <sstream>
-#include "OutNormal.h"
+#include "zypp/Pathname.h"
+
+#include "../zypper-main.h"
#include "../AliveCursor.h"
+#include "OutNormal.h"
+
using std::cout;
using std::cerr;
using std::endl;
@@ -75,10 +79,7 @@
{
static AliveCursor cursor;
- if ( percent == 100 )
- cout << CLEARLN << cursor.done() << " " << s;
- else
- cout << CLEARLN << cursor++ << " " << s;
+ cout << CLEARLN << cursor++ << " " << s;
// dont display percents if invalid
if (percent >= 0 && percent <= 100)
cout << " [" << percent << "%]";
@@ -124,31 +125,59 @@
void OutNormal::progressEnd(const std::string & id, const string& label)
{
- static AliveCursor cursor;
-
if (progressFilter())
return;
+ static AliveCursor cursor;
cout << CLEARLN << cursor.done() << " " << label << std::flush << endl;
}
// progress with download rate
-void OutNormal::dwnldProgressStart(const std::string & id,
- const std::string & label)
+void OutNormal::dwnldProgressStart(const zypp::Url & uri)
{
+ if (verbosity() < NORMAL)
+ return;
+ static AliveCursor cursor;
+ cout << CLEARLN << cursor << " " << _("Downloading:") << " ";
+ if (verbosity() == DEBUG)
+ cout << uri; //! \todo shorten to fit the width of the terminal
+ else
+ cout << zypp::Pathname(uri.getPathName()).basename();
+ cout << " [" << _("starting") << "]"; //! \todo align to the right
+ cout << std::flush;
}
-void OutNormal::dwnldProgress(const std::string & id,
- const std::string & label,
+void OutNormal::dwnldProgress(const zypp::Url & uri,
int value,
int rate)
{
+ if (verbosity() < NORMAL)
+ return;
+ static AliveCursor cursor;
+ cout << CLEARLN << cursor++ << " " << _("Downloading:") << " ";
+ if (verbosity() == DEBUG)
+ cout << uri; //! \todo shorten to fit the width of the terminal
+ else
+ cout << zypp::Pathname(uri.getPathName()).basename();
+ // dont display percents if invalid
+ if (value >= 0 && value <= 100)
+ cout << " [" << value << "%]";
+ cout << std::flush;
}
-void OutNormal::dwnldProgressEnd(const std::string & id,
- const std::string & label)
+void OutNormal::dwnldProgressEnd(const zypp::Url & uri)
{
+ if (verbosity() < NORMAL)
+ return;
-}
\ No newline at end of file
+ static AliveCursor cursor;
+ cout << CLEARLN << cursor.done() << " " << _("Downloading:") << " ";
+ if (verbosity() == DEBUG)
+ cout << uri; //! \todo shorten to fit the width of the terminal
+ else
+ cout << zypp::Pathname(uri.getPathName()).basename();
+ cout << " [" << _("done") << "]";
+ cout << endl << std::flush;
+}
Modified: trunk/zypper/src/output/OutNormal.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/output/OutNormal.h?rev=8817&r1=8816&r2=8817&view=diff
==============================================================================
--- trunk/zypper/src/output/OutNormal.h (original)
+++ trunk/zypper/src/output/OutNormal.h Tue Feb 19 16:23:46 2008
@@ -27,14 +27,11 @@
virtual void progressEnd(const std::string & id, const std::string & label);
// progress with download rate
- virtual void dwnldProgressStart(const std::string & id,
- const std::string & label);
- virtual void dwnldProgress(const std::string & id,
- const std::string & label,
+ virtual void dwnldProgressStart(const zypp::Url & uri);
+ virtual void dwnldProgress(const zypp::Url & uri,
int value = -1,
int rate = -1);
- virtual void dwnldProgressEnd(const std::string & id,
- const std::string & label);
+ virtual void dwnldProgressEnd(const zypp::Url & uri);
protected:
virtual bool mine(Type type);
Modified: trunk/zypper/src/output/OutXML.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/output/OutXML.cc?rev=8817&r1=8816&r2=8817&view=diff
==============================================================================
--- trunk/zypper/src/output/OutXML.cc (original)
+++ trunk/zypper/src/output/OutXML.cc Tue Feb 19 16:23:46 2008
@@ -115,22 +115,19 @@
}
// progress with download rate
-void OutXML::dwnldProgressStart(const std::string & id,
- const std::string & label)
+void OutXML::dwnldProgressStart(const zypp::Url & uri)
{
cout << "