Mailinglist Archive: zypp-commit (545 mails)
| < Previous | Next > |
[zypp-commit] r8675 - in /branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media: MediaCurl.cc MediaException.cc MediaException.h
- From: jkupec@xxxxxxxxxxxxxxxx
- Date: Thu, 14 Feb 2008 11:08:21 -0000
- Message-id: <20080214110821.5287C10744C@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Thu Feb 14 12:08:20 2008
New Revision: 8675
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8675&view=rev
Log:
- show special 'registration expired' message in HTTP response 403
(fate #303284) r8670
- media exception messages marked for translation
Modified:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc?rev=8675&r1=8674&r2=8675&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc Thu Feb 14
12:08:20 2008
@@ -16,6 +16,7 @@
#include "zypp/base/Logger.h"
#include "zypp/ExternalProgram.h"
#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
#include "zypp/base/Sysconfig.h"
#include "zypp/media/MediaCurl.h"
@@ -873,6 +874,19 @@
err = " Login failed";
}
else
+ if ( httpReturnCode == 403)
+ {
+ string msg403;
+ if (url.asString().find("novell.com") != string::npos)
+ msg403 = str::form(_(
+ "Permission to access '%s' denied.\n\n"
+ "Visit the Novell Customer Center to check whether"
+ " your registration is valid and not expired."),
+ url.asString().c_str());
+
+ ZYPP_THROW(MediaForbiddenException(url, msg403));
+ }
+ else
if ( httpReturnCode == 404)
{
err_file_not_found = true;
@@ -1080,6 +1094,19 @@
err = " Login failed";
}
else
+ if ( httpReturnCode == 403)
+ {
+ string msg403;
+ if (url.asString().find("novell.com") != string::npos)
+ msg403 = str::form(_(
+ "Permission to access '%s' denied.\n\n"
+ "Visit the Novell Customer Center to check whether"
+ " your registration is valid and not expired."),
+ url.asString().c_str());
+
+ ZYPP_THROW(MediaForbiddenException(url, msg403));
+ }
+ else
if ( httpReturnCode == 404)
{
ZYPP_THROW(MediaFileNotFoundException(_url, filename));
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc?rev=8675&r1=8674&r2=8675&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc
(original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc Thu
Feb 14 12:08:20 2008
@@ -10,12 +10,15 @@
*
*/
-#include <string>
#include <iostream>
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+
#include "zypp/media/MediaException.h"
using namespace std;
+using zypp::str::form;
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -25,7 +28,7 @@
std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
{
- str << "Failed to mount " << _source << " on " << _target;
+ str << form(_("Failed to mount %s on %s"), _source.c_str(),
_target.c_str());
if( !_cmdout.empty())
str << ": " << _error << " (" << _cmdout << ")" << endl;
else
@@ -35,71 +38,81 @@
std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
{
- return str << "Failed to unmount " << _path
+ return str << form(_("Failed to unmount %s"), _path.c_str())
<< " : " << _error << endl;
}
std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str )
const
{
- return str << "Bad file name " << _filename << endl;
+ return str << form(_("Bad file name: %s"), _filename.c_str()) << endl;
}
std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
{
- return str << "Media not opened while performing action " << _action <<
endl;
+ return str << form(
+ _("Medium not opened when trying to perform action '%s'."),
_action.c_str())
+ << endl;
}
std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str)
const
{
- return str << "File " << _filename
- << " not found on media: " << _url << endl;
+ return str << form(
+ _("File '%s' not found on medium '%s'"),
+ _filename.c_str(), _url.c_str())
+ << endl;
}
std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
{
- return str << "Cannot write file " << _filename << endl;
+ return str << form(_("Cannot write file '%s'."), _filename.c_str()) <<
endl;
}
std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
{
- return str << "Media not attached: " << _url << endl;
+ return str << _("Medium not attached") << ": " << _url << endl;
}
std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str)
const
{
- return str << "Bad media attach point: " << _url << endl;
+ return str << _("Bad media attach point") << ": " << _url << endl;
}
std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
{
- return str << "Curl init failed for: " << _url << endl;
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't
translate
+ _("Download (curl) initialization failed for '%s'"), _url.c_str())
+ << endl;
}
std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
{
- return str << "System exception: " << _message
- << " on media: " << _url << endl;
+ return str << form(
+ _("System exception '%s' on medium '%s'."),
+ _message.c_str(), _url.c_str()) << endl;
}
std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
{
- return str << "Path " << _path
- << " on media: " << _url
- << " is not a file." << endl;
+ return str << form(
+ _("Path '%s' on medium '%s' is not a file."),
+ _path.c_str(), _url.c_str())
+ << endl;
}
std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
{
- return str << "Path " << _path
- << " on media: " << _url
- << " is not a directory." << endl;
+ return str << form(
+ _("Path '%s' on medium '%s' is not a directory."),
+ _path.c_str(), _url.c_str())
+ << endl;
}
std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
{
if( _msg.empty())
{
- return str << "Malformed URL: " << _url << endl;
+ return str << _("Malformed URI") << ": " << _url << endl;
}
else
{
@@ -109,58 +122,73 @@
std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str)
const
{
- return str << "Empty host name in URL: " << _url << endl;
+ return str << _("Empty host name in URI") << ": " << _url << endl;
}
std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream &
str) const
{
- return str << "Empty filesystem in URL: " << _url << endl;
+ return str << _("Empty filesystem in URI") << ": " << _url << endl;
}
std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream
& str) const
{
- return str << "Empty destination in URL: " << _url << endl;
+ return str << _("Empty destination in URI") << ": " << _url << endl;
}
std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream &
str) const
{
- return str << "Unsupported URL scheme in URL: " << _url << endl;
+ return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str())
<< endl;
}
std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str)
const
{
- return str << "Operation not supported by media: " << _url << endl;
+ return str << _("Operation not supported by medium") << ": " << _url <<
endl;
}
std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
{
- return str << "Curl error for '" << _url << "':" << endl
- << "Error code: " << _err << endl
- << "Error message: " << _msg << endl;
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ return str << form(_(
+ "Download (curl) error for '%s':\n"
+ "Error code: %s\n"
+ "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
}
std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
{
- return str << "Error occurred while setting CURL options for " << _url
- << ": " << _msg << endl;
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't
translate
+ _("Error occurred while setting download (curl) options for '%s':"),
+ _url.c_str())
+ << endl << _msg << endl;
}
std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
{
- return str << "Media source " << _url << " does not contain the desired
media" << endl;
+ return str << form(
+ _("Media source '%s' does not contain the desired medium"),
_url.c_str())
+ << endl;
}
std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
{
- return str << "Media " << _name << " is in use by another instance" <<
endl;
+ return str << form(_("Medium '%s' is in use by another instance"),
_name.c_str())
+ << endl;
}
std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
{
if( _name.empty())
- return str << "Can't eject any media" << endl;
+ return str << _("Can't eject any media") << endl;
else
- return str << "Can't eject media " << _name << endl;
+ return str << form(_("Can't eject media '%s'"), _name.c_str()) << endl;
+ }
+
+ std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
+ {
+ if (_msg.empty())
+ return str << form(_("Permission to access '%s' denied."),
_url.c_str()) << endl;
+ return str << _msg << endl;
}
/////////////////////////////////////////////////////////////////
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h?rev=8675&r1=8674&r2=8675&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h
(original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h Thu Feb
14 12:08:20 2008
@@ -421,6 +421,20 @@
std::string _name;
};
+ class MediaForbiddenException : public MediaException
+ {
+ public:
+ MediaForbiddenException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaForbiddenException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
/////////////////////////////////////////////////////////////////
} // namespace media
} // namespace zypp
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx
Date: Thu Feb 14 12:08:20 2008
New Revision: 8675
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8675&view=rev
Log:
- show special 'registration expired' message in HTTP response 403
(fate #303284) r8670
- media exception messages marked for translation
Modified:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc?rev=8675&r1=8674&r2=8675&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaCurl.cc Thu Feb 14
12:08:20 2008
@@ -16,6 +16,7 @@
#include "zypp/base/Logger.h"
#include "zypp/ExternalProgram.h"
#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
#include "zypp/base/Sysconfig.h"
#include "zypp/media/MediaCurl.h"
@@ -873,6 +874,19 @@
err = " Login failed";
}
else
+ if ( httpReturnCode == 403)
+ {
+ string msg403;
+ if (url.asString().find("novell.com") != string::npos)
+ msg403 = str::form(_(
+ "Permission to access '%s' denied.\n\n"
+ "Visit the Novell Customer Center to check whether"
+ " your registration is valid and not expired."),
+ url.asString().c_str());
+
+ ZYPP_THROW(MediaForbiddenException(url, msg403));
+ }
+ else
if ( httpReturnCode == 404)
{
err_file_not_found = true;
@@ -1080,6 +1094,19 @@
err = " Login failed";
}
else
+ if ( httpReturnCode == 403)
+ {
+ string msg403;
+ if (url.asString().find("novell.com") != string::npos)
+ msg403 = str::form(_(
+ "Permission to access '%s' denied.\n\n"
+ "Visit the Novell Customer Center to check whether"
+ " your registration is valid and not expired."),
+ url.asString().c_str());
+
+ ZYPP_THROW(MediaForbiddenException(url, msg403));
+ }
+ else
if ( httpReturnCode == 404)
{
ZYPP_THROW(MediaFileNotFoundException(_url, filename));
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc?rev=8675&r1=8674&r2=8675&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc
(original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.cc Thu
Feb 14 12:08:20 2008
@@ -10,12 +10,15 @@
*
*/
-#include <string>
#include <iostream>
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+
#include "zypp/media/MediaException.h"
using namespace std;
+using zypp::str::form;
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -25,7 +28,7 @@
std::ostream & MediaMountException::dumpOn( std::ostream & str ) const
{
- str << "Failed to mount " << _source << " on " << _target;
+ str << form(_("Failed to mount %s on %s"), _source.c_str(),
_target.c_str());
if( !_cmdout.empty())
str << ": " << _error << " (" << _cmdout << ")" << endl;
else
@@ -35,71 +38,81 @@
std::ostream & MediaUnmountException::dumpOn( std::ostream & str ) const
{
- return str << "Failed to unmount " << _path
+ return str << form(_("Failed to unmount %s"), _path.c_str())
<< " : " << _error << endl;
}
std::ostream & MediaBadFilenameException::dumpOn( std::ostream & str )
const
{
- return str << "Bad file name " << _filename << endl;
+ return str << form(_("Bad file name: %s"), _filename.c_str()) << endl;
}
std::ostream & MediaNotOpenException::dumpOn( std::ostream & str ) const
{
- return str << "Media not opened while performing action " << _action <<
endl;
+ return str << form(
+ _("Medium not opened when trying to perform action '%s'."),
_action.c_str())
+ << endl;
}
std::ostream & MediaFileNotFoundException::dumpOn( std::ostream & str)
const
{
- return str << "File " << _filename
- << " not found on media: " << _url << endl;
+ return str << form(
+ _("File '%s' not found on medium '%s'"),
+ _filename.c_str(), _url.c_str())
+ << endl;
}
std::ostream & MediaWriteException::dumpOn( std::ostream & str) const
{
- return str << "Cannot write file " << _filename << endl;
+ return str << form(_("Cannot write file '%s'."), _filename.c_str()) <<
endl;
}
std::ostream & MediaNotAttachedException::dumpOn( std::ostream & str) const
{
- return str << "Media not attached: " << _url << endl;
+ return str << _("Medium not attached") << ": " << _url << endl;
}
std::ostream & MediaBadAttachPointException::dumpOn( std::ostream & str)
const
{
- return str << "Bad media attach point: " << _url << endl;
+ return str << _("Bad media attach point") << ": " << _url << endl;
}
std::ostream & MediaCurlInitException::dumpOn( std::ostream & str) const
{
- return str << "Curl init failed for: " << _url << endl;
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't
translate
+ _("Download (curl) initialization failed for '%s'"), _url.c_str())
+ << endl;
}
std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
{
- return str << "System exception: " << _message
- << " on media: " << _url << endl;
+ return str << form(
+ _("System exception '%s' on medium '%s'."),
+ _message.c_str(), _url.c_str()) << endl;
}
std::ostream & MediaNotAFileException::dumpOn( std::ostream & str) const
{
- return str << "Path " << _path
- << " on media: " << _url
- << " is not a file." << endl;
+ return str << form(
+ _("Path '%s' on medium '%s' is not a file."),
+ _path.c_str(), _url.c_str())
+ << endl;
}
std::ostream & MediaNotADirException::dumpOn( std::ostream & str) const
{
- return str << "Path " << _path
- << " on media: " << _url
- << " is not a directory." << endl;
+ return str << form(
+ _("Path '%s' on medium '%s' is not a directory."),
+ _path.c_str(), _url.c_str())
+ << endl;
}
std::ostream & MediaBadUrlException::dumpOn( std::ostream & str) const
{
if( _msg.empty())
{
- return str << "Malformed URL: " << _url << endl;
+ return str << _("Malformed URI") << ": " << _url << endl;
}
else
{
@@ -109,58 +122,73 @@
std::ostream & MediaBadUrlEmptyHostException::dumpOn( std::ostream & str)
const
{
- return str << "Empty host name in URL: " << _url << endl;
+ return str << _("Empty host name in URI") << ": " << _url << endl;
}
std::ostream & MediaBadUrlEmptyFilesystemException::dumpOn( std::ostream &
str) const
{
- return str << "Empty filesystem in URL: " << _url << endl;
+ return str << _("Empty filesystem in URI") << ": " << _url << endl;
}
std::ostream & MediaBadUrlEmptyDestinationException::dumpOn( std::ostream
& str) const
{
- return str << "Empty destination in URL: " << _url << endl;
+ return str << _("Empty destination in URI") << ": " << _url << endl;
}
std::ostream & MediaUnsupportedUrlSchemeException::dumpOn( std::ostream &
str) const
{
- return str << "Unsupported URL scheme in URL: " << _url << endl;
+ return str << form(_("Unsupported URI scheme in '%s'."), _url.c_str())
<< endl;
}
std::ostream & MediaNotSupportedException::dumpOn( std::ostream & str)
const
{
- return str << "Operation not supported by media: " << _url << endl;
+ return str << _("Operation not supported by medium") << ": " << _url <<
endl;
}
std::ostream & MediaCurlException::dumpOn( std::ostream & str) const
{
- return str << "Curl error for '" << _url << "':" << endl
- << "Error code: " << _err << endl
- << "Error message: " << _msg << endl;
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ return str << form(_(
+ "Download (curl) error for '%s':\n"
+ "Error code: %s\n"
+ "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
}
std::ostream & MediaCurlSetOptException::dumpOn( std::ostream & str) const
{
- return str << "Error occurred while setting CURL options for " << _url
- << ": " << _msg << endl;
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't
translate
+ _("Error occurred while setting download (curl) options for '%s':"),
+ _url.c_str())
+ << endl << _msg << endl;
}
std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
{
- return str << "Media source " << _url << " does not contain the desired
media" << endl;
+ return str << form(
+ _("Media source '%s' does not contain the desired medium"),
_url.c_str())
+ << endl;
}
std::ostream & MediaIsSharedException::dumpOn( std::ostream & str ) const
{
- return str << "Media " << _name << " is in use by another instance" <<
endl;
+ return str << form(_("Medium '%s' is in use by another instance"),
_name.c_str())
+ << endl;
}
std::ostream & MediaNotEjectedException::dumpOn( std::ostream & str ) const
{
if( _name.empty())
- return str << "Can't eject any media" << endl;
+ return str << _("Can't eject any media") << endl;
else
- return str << "Can't eject media " << _name << endl;
+ return str << form(_("Can't eject media '%s'"), _name.c_str()) << endl;
+ }
+
+ std::ostream & MediaForbiddenException::dumpOn( std::ostream & str ) const
+ {
+ if (_msg.empty())
+ return str << form(_("Permission to access '%s' denied."),
_url.c_str()) << endl;
+ return str << _msg << endl;
}
/////////////////////////////////////////////////////////////////
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h?rev=8675&r1=8674&r2=8675&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h
(original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/media/MediaException.h Thu Feb
14 12:08:20 2008
@@ -421,6 +421,20 @@
std::string _name;
};
+ class MediaForbiddenException : public MediaException
+ {
+ public:
+ MediaForbiddenException(const Url & url_r, const std::string & msg = "")
+ : MediaException(msg)
+ , _url(url_r.asString()), _msg(msg)
+ {}
+ virtual ~MediaForbiddenException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
/////////////////////////////////////////////////////////////////
} // namespace media
} // namespace zypp
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx
| < Previous | Next > |