- decoupling zypper and zypp-checkpatches code
authorJan Kupec <jkupec@suse.cz>
Sun, 4 Nov 2007 10:05:27 +0000 (10:05 +0000)
committerJan Kupec <jkupec@suse.cz>
Sun, 4 Nov 2007 10:05:27 +0000 (10:05 +0000)
src/zypp-checkpatches.cc
src/zypper-updates.cc
src/zypper-updates.h
src/zypper.h

index fad7bad..824e722 100644 (file)
@@ -37,6 +37,7 @@ using namespace boost;
 ZYpp::Ptr God;
 RuntimeData gData;
 Settings gSettings;
+std::list<Error> errors;
 
 ostream no_stream(NULL);
 
@@ -89,7 +90,7 @@ namespace utils
 
 int exit_with_error( const std::string &error_str )
 {
-  gData.errors.push_back(Error(error_str));
+  errors.push_back(Error(error_str));
     
   std::ofstream os(RESULT_FILE);
   if ( os.good() )
@@ -181,7 +182,7 @@ int main(int argc, char **argv)
     {
       // TranslatorExplanation %s = detailed low level (unstranslated) error message
       string error = excpt_r.msg();
-      gData.errors.push_back(str::form(_("Couldn't restore repository.\nDetail: %s"), error.c_str()));
+      errors.push_back(str::form(_("Couldn't restore repository.\nDetail: %s"), error.c_str()));
     }
   }
 
@@ -231,7 +232,7 @@ int main(int argc, char **argv)
 
   if ( gData.repos.size() == 0 )
   {
-    gData.errors.push_back( str::form( _( "There are no update repositories defined. Please add one or more update repositories in order to be notified of updates.") ) );
+    errors.push_back( str::form( _( "There are no update repositories defined. Please add one or more update repositories in order to be notified of updates.") ) );
   }
 
   God->addResolvables( God->target()->resolvables(), true);
index 17c06b9..bf93d6c 100644 (file)
@@ -25,6 +25,7 @@ using namespace zypp;
 extern ZYpp::Ptr God;
 extern RuntimeData gData;
 extern Settings gSettings;
+extern std::list<Error> errors;
 
 Edition read_old_version()
 {
@@ -59,7 +60,7 @@ void render_error( const Edition &version, std::ostream &out )
   out << "<?xml version='1.0'?>" << std::endl;
   out << "<update-status version=\"" << version.asString() << "\">" << std::endl;
   out << " <errors>" << std::endl;
-  for ( std::list<Error>::const_iterator it = gData.errors.begin(); it != gData.errors.end(); ++it )
+  for ( std::list<Error>::const_iterator it = errors.begin(); it != errors.end(); ++it )
   {
     out << "   <error>" << xml_escape(it->description) << "</error>" << endl;
   }
@@ -77,7 +78,7 @@ void render_result( const Edition &version, std::ostream &out, const zypp::ResPo
   
   //out << " <metadata token=\"" << token << "\"/>" << std::endl;
   out << " <errors>" << std::endl;
-  for ( std::list<Error>::const_iterator it = gData.errors.begin(); it != gData.errors.end(); ++it )
+  for ( std::list<Error>::const_iterator it = errors.begin(); it != errors.end(); ++it )
   {
     out << " <error>" << xml_escape(it->description) << "</error>" << endl;
   }
index 9f24142..ebe9023 100644 (file)
 #define XML_FILE_VERSION "/var/lib/zypp/cache/updates_xml_version"
 #define RESULT_FILE "/var/lib/zypp/cache/updates_result.xml"
 
+struct Error
+{
+  Error( const std::string &desc )
+  : description(desc)
+  {}
+  std::string description;
+};
+
+extern std::list<Error> errors;
+
 std::string read_old_token();
 void save_token( const std::string &token );
 zypp::Edition read_old_version();
index 6946829..6bd928a 100644 (file)
@@ -21,7 +21,6 @@
 #define ZYPP_CHECKPATCHES_LOG "/var/log/zypper.log"
 #undef  ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "zypper"
-#define RANDOM_TOKEN "sad987432JJDJD948394DDDxxx22"
 
 // ===== exit codes ======
 
@@ -46,7 +45,7 @@
 struct Settings
 {
   Settings()
-  : previous_token(RANDOM_TOKEN),
+  :
   verbosity(0),  
   previous_code(-1),
   disable_system_sources(false),
@@ -60,7 +59,6 @@ struct Settings
   {}
 
   std::list<zypp::Url> additional_sources;
-  std::string previous_token;
 
   /**
    * Level of the amount of output.
@@ -86,21 +84,12 @@ struct Settings
   zypp::RepoManagerOptions rm_options;
 };
 
-struct Error
-{
-  Error( const std::string &desc )
-  : description(desc)
-  {}
-  std::string description;
-};
-
 struct RuntimeData
 {
   RuntimeData()
     : patches_count(0), security_patches_count(0), show_media_progress_hack(false)
   {}
 
-  std::list<Error> errors;
   std::list<zypp::RepoInfo> repos;
   int patches_count;
   int security_patches_count;