some fixes
authorJiri Srain <jsrain@suse.cz>
Wed, 19 Oct 2005 11:34:44 +0000 (11:34 +0000)
committerJiri Srain <jsrain@suse.cz>
Wed, 19 Oct 2005 11:34:44 +0000 (11:34 +0000)
odded test programs

test/Makefile.am
test/Msg.cc [new file with mode: 0644]
test/Patch.cc [new file with mode: 0644]
test/Script.cc [new file with mode: 0644]
zypp/Message.cc
zypp/Message.h
zypp/Patch.cc
zypp/Patch.h
zypp/Script.cc
zypp/Script.h
zypp/detail/PatchImpl.cc

index 93866d5..3980618 100644 (file)
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 ## ##################################################
 
-noinst_PROGRAMS =      Main Main.debug
+noinst_PROGRAMS =      Main Main.debug Msg Msg.debug Patch Patch.debug Script Script.debug
 
 ## ##################################################
 
@@ -20,6 +20,21 @@ Main_SOURCES =               Main.cc
 Main_debug_SOURCES =   $(Main_SOURCES)
 Main_debug_LDFLAGS =   -static
 
+Msg_SOURCES =          Msg.cc
+
+Msg_debug_SOURCES =    $(Msg_SOURCES)
+Msg_debug_LDFLAGS =    -static
+
+Patch_SOURCES =        Patch.cc
+
+Patch_debug_SOURCES =  $(Patch_SOURCES)
+Patch_debug_LDFLAGS =  -static
+
+Script_SOURCES =       Script.cc
+
+Script_debug_SOURCES =         $(Script_SOURCES)
+Script_debug_LDFLAGS = -static
+
 ## ##################################################
 
 .PHONY:        always
diff --git a/test/Msg.cc b/test/Msg.cc
new file mode 100644 (file)
index 0000000..454155d
--- /dev/null
@@ -0,0 +1,56 @@
+#include <iostream>
+#include <fstream>
+#include <iterator>
+#include <algorithm>
+#include <set>
+#include <map>
+#include <list>
+#include <vector>
+#include <ext/hash_set>
+#include <ext/hash_map>
+#include <ext/rope>
+
+#include <zypp/base/Logger.h>
+#include <zypp/base/String.h>
+
+///////////////////////////////////////////////////////////////////
+
+#include <zypp/Message.h>
+#include <zypp/detail/MessageImpl.h>
+
+
+using namespace std;
+using namespace zypp;
+
+class MyMessageImpl : public detail::MessageImpl
+{
+  public:
+    MyMessageImpl (std::string text) 
+    : MessageImpl (ResName ("message1"),
+                  Edition (),
+                  Arch ("noarch"))
+    {
+      _text = text;
+    }
+};
+
+/******************************************************************
+**
+**
+**     FUNCTION NAME : main
+**     FUNCTION TYPE : int
+**
+**     DESCRIPTION :
+*/
+int main( int argc, char * argv[] )
+{
+  INT << "===[START]==========================================" << endl;
+
+  MyMessageImpl p ("My message to be shown to user");
+
+  DBG << p << endl;
+  DBG << "  \"" << p.text() << "\"" << endl;
+
+  INT << "===[END]============================================" << endl;
+  return 0;
+}
diff --git a/test/Patch.cc b/test/Patch.cc
new file mode 100644 (file)
index 0000000..735cd19
--- /dev/null
@@ -0,0 +1,88 @@
+#include <iostream>
+#include <fstream>
+#include <iterator>
+#include <algorithm>
+#include <set>
+#include <map>
+#include <list>
+#include <vector>
+#include <ext/hash_set>
+#include <ext/hash_map>
+#include <ext/rope>
+
+#include <zypp/base/Logger.h>
+#include <zypp/base/String.h>
+
+///////////////////////////////////////////////////////////////////
+
+#include <zypp/Message.h>
+#include <zypp/detail/MessageImpl.h>
+#include <zypp/Patch.h>
+#include <zypp/detail/PatchImpl.h>
+#include <zypp/Package.h>
+#include <zypp/detail/PackageImpl.h>
+
+
+using namespace std;
+using namespace zypp;
+
+class MyPatchImpl : public detail::PatchImpl
+{
+  public:
+    MyPatchImpl (std::string name, std::list<ResolvablePtr> atoms) 
+    : PatchImpl (ResName (name),
+                Edition (),
+                Arch ("noarch"))
+    {
+      _reboot_needed = false;
+      _atoms = atoms;
+    }
+};
+
+/******************************************************************
+**
+**
+**     FUNCTION NAME : main
+**     FUNCTION TYPE : int
+**
+**     DESCRIPTION :
+*/
+int main( int argc, char * argv[] )
+{
+  INT << "===[START]==========================================" << endl;
+
+  std::list<ResolvablePtr> atoms;
+
+  ResName _name( "foo" );
+  Edition _edition( "1.0", "42" );
+  Arch    _arch( "i386" );
+  detail::PackageImplPtr pi( new detail::PackageImpl(_name,_edition,_arch) );
+  PackagePtr p (new Package (pi));
+  atoms.push_back (p);
+
+  ResName _name2( "bar" );
+  Edition _edition2( "1.0", "43" );
+  Arch    _arch2( "noarch" );
+  detail::PackageImplPtr pi2( new detail::PackageImpl(_name,_edition,_arch) );
+  PackagePtr p2 (new Package (pi2));
+  atoms.push_back (p2);
+
+  MyPatchImpl q ("patch1", atoms);
+  DBG << q << endl;
+  DBG << q.interactive () << endl;
+
+  INT << "====================================================" << endl;
+
+  ResName _name3( "msg" );
+  Arch    _arch3( "noarch" );
+  detail::MessageImplPtr mi( new detail::MessageImpl(_name,Edition (),_arch3));
+  MessagePtr m (new Message (mi));
+  atoms.push_back (m);
+
+  MyPatchImpl q2 ("patch2", atoms);
+  DBG << q2 << endl;
+  DBG << q2.interactive () << endl;
+
+  INT << "===[END]============================================" << endl;
+  return 0;
+}
diff --git a/test/Script.cc b/test/Script.cc
new file mode 100644 (file)
index 0000000..e801e50
--- /dev/null
@@ -0,0 +1,68 @@
+#include <iostream>
+#include <fstream>
+#include <iterator>
+#include <algorithm>
+#include <set>
+#include <map>
+#include <list>
+#include <vector>
+#include <ext/hash_set>
+#include <ext/hash_map>
+#include <ext/rope>
+
+#include <zypp/base/Logger.h>
+#include <zypp/base/String.h>
+
+///////////////////////////////////////////////////////////////////
+
+#include <zypp/Script.h>
+#include <zypp/detail/ScriptImpl.h>
+
+
+using namespace std;
+using namespace zypp;
+
+class MyScriptImpl : public detail::ScriptImpl
+{
+  public:
+    MyScriptImpl (std::string do_script, std::string undo_script = "") 
+    : ScriptImpl (ResName ("script1"),
+                 Edition (),
+                 Arch ("noarch"))
+    {
+      _do_script = do_script;
+      _undo_script = undo_script;
+    }
+};
+
+/******************************************************************
+**
+**
+**     FUNCTION NAME : main
+**     FUNCTION TYPE : int
+**
+**     DESCRIPTION :
+*/
+int main( int argc, char * argv[] )
+{
+  INT << "===[START]==========================================" << endl;
+
+  MyScriptImpl p ("#!/bin/bash\ndo_script");
+
+  DBG << p << endl;
+  DBG << "  \"" << p.do_script() << "\"" << endl;
+  DBG << "  \"" << p.undo_script() << "\"" << endl;
+  DBG << "  " << p.undo_available() << endl;
+
+  INT << "====================================================" << endl;
+
+  MyScriptImpl q ("#!/bin/bash\ndo_script", "#!/bin/bash\nundo_script");
+
+  DBG << q << endl;
+  DBG << "  \"" << q.do_script() << "\"" << endl;
+  DBG << "  \"" << q.undo_script() << "\"" << endl;
+  DBG << "  " << q.undo_available() << endl;
+
+  INT << "===[END]============================================" << endl;
+  return 0;
+}
index 4c8323c..34ed077 100644 (file)
@@ -13,8 +13,7 @@
 
 #include "zypp/base/Logger.h"
 #include "zypp/Message.h"
-#include "zypp/detail/ResolvableImpl.h"
-#include "zypp//Resolvable.h"
+#include "zypp/detail/MessageImpl.h"
 
 using namespace std;
 
index b1aee67..09b9add 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <iosfwd>
 
-#include "zypp/detail/MessageImpl.h"
 #include "zypp/Resolvable.h"
 
 ///////////////////////////////////////////////////////////////////
index 7f1c2e8..c6a5a28 100644 (file)
@@ -13,8 +13,7 @@
 
 #include "zypp/base/Logger.h"
 #include "zypp/Patch.h"
-#include "zypp/detail/ResolvableImpl.h"
-#include "zypp//Resolvable.h"
+#include "zypp/detail/PatchImpl.h"
 
 using namespace std;
 
index 29c7271..8da170f 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <iosfwd>
 
-#include "zypp/detail/PatchImpl.h"
 #include "zypp/Resolvable.h"
 
 ///////////////////////////////////////////////////////////////////
index 16499ca..ffa57f1 100644 (file)
@@ -13,8 +13,7 @@
 
 #include "zypp/base/Logger.h"
 #include "zypp/Script.h"
-#include "zypp/detail/ResolvableImpl.h"
-#include "zypp//Resolvable.h"
+#include "zypp/detail/ScriptImpl.h"
 
 using namespace std;
 
index 3231f61..9fff673 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <iosfwd>
 
-#include "zypp/detail/ScriptImpl.h"
 #include "zypp/Resolvable.h"
 
 ///////////////////////////////////////////////////////////////////
index be16f38..de2676d 100644 (file)
@@ -14,6 +14,7 @@
 #include "zypp/base/Logger.h"
 #include "zypp/detail/PatchImpl.h"
 #include "zypp/Patch.h"
+#include "zypp/Package.h"
 
 using namespace std;
 
@@ -48,17 +49,31 @@ namespace zypp
 
     bool PatchImpl::interactive () {
       if (_reboot_needed)
+      {
+       DBG << "Patch needs reboot" << endl;
        return true;
+      }
       atom_list not_installed = not_installed_atoms ();
       for (atom_list::iterator it = not_installed.begin ();
        it != not_installed.end ();
        it++)
       {
        if ((std::string)((*it)->kind ()) == "message")
-       // FIXME package with license
        {
+         DBG << "Patch contains a message" << endl;
          return true;
        }
+       if ((std::string)((*it)->kind ()) == "package")
+       {
+         ResolvablePtr r = *it;
+         // FIXME package with license
+//       if (r->licenseToConfirm() != "")
+         if (false)
+         {
+           DBG << "Package has a license to be shown to user" << endl;
+           return true;
+         }
+       }
       }
       return false;
     }
@@ -69,7 +84,7 @@ namespace zypp
        it != _atoms.end ();
        it++)
       {
-       if (false) // FIXME check if atom/resolvable is not installed
+       if (true) // FIXME check if atom/resolvable is not installed
        {
          ret.push_back (*it);
        }