00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #include <iostream> 00013 00014 #include "zypp/base/Logger.h" 00015 #include "zypp/detail/PatchImpl.h" 00016 #include "zypp/Package.h" 00017 00018 using namespace std; 00019 00021 namespace zypp 00022 { 00023 00024 namespace detail 00025 { 00026 00028 // 00029 // CLASS NAME : PatchImpl 00030 // 00032 00034 PatchImpl::PatchImpl() 00035 {} 00036 00038 PatchImpl::~PatchImpl() 00039 {} 00040 00041 std::string PatchImpl::id() const 00042 { 00043 return _patch_id; 00044 } 00045 Date PatchImpl::timestamp() const 00046 { 00047 return _timestamp; 00048 } 00049 00050 TranslatedText PatchImpl::summary() const 00051 { 00052 return _summary; 00053 } 00054 00055 TranslatedText PatchImpl::description() const 00056 { 00057 return _description; 00058 } 00059 00060 std::string PatchImpl::category() const 00061 { 00062 return _category; 00063 } 00064 00065 bool PatchImpl::reboot_needed() const 00066 { 00067 return _reboot_needed; 00068 } 00069 00070 bool PatchImpl::affects_pkg_manager() const 00071 { 00072 return _affects_pkg_manager; 00073 } 00074 00075 bool PatchImpl::interactive() const { 00076 if (_reboot_needed) 00077 { 00078 DBG << "Patch needs reboot" << endl; 00079 return true; 00080 } 00081 AtomList not_installed = not_installed_atoms(); 00082 for (AtomList::const_iterator it = not_installed.begin(); 00083 it != not_installed.end(); 00084 it++) 00085 { 00086 if ((*it)->kind() == "Message") 00087 { 00088 // DBG << "Patch contains a message" << endl; 00089 return true; 00090 } 00091 if ((*it)->kind() == "Package") 00092 { 00093 // Resolvable* 00094 // Resolvable 00095 // ResolvablePtr 00096 00097 00098 // <ma> never do somthing like this!!! 00099 // Package* p = (Package*)&**it; 00100 // 00101 // (*it) is a ResolvablePtr 00102 00103 00104 00105 00106 // FIXME use the condition 00107 // if (p->licenseToConfirm() != "") 00108 if (false) 00109 { 00110 // DBG << "Package has a license to be shown to user" << endl; 00111 return true; 00112 } 00113 } 00114 } 00115 return false; 00116 } 00117 00118 PatchImpl::AtomList PatchImpl::all_atoms() const { 00119 return _atoms; 00120 } 00121 00122 PatchImpl::AtomList PatchImpl::not_installed_atoms() const { 00123 AtomList ret; 00124 for (AtomList::const_iterator it = _atoms.begin(); 00125 it != _atoms.end(); 00126 it++) 00127 { 00128 if (true) // FIXME check if atom/resolvable is not installed 00129 { 00130 ret.push_back(*it); 00131 } 00132 } 00133 return ret; 00134 } 00135 00136 // TODO check necessarity of functions below 00137 00138 bool PatchImpl::any_atom_selected() const { 00139 for (AtomList::const_iterator it = _atoms.begin(); 00140 it != _atoms.end(); 00141 it++) 00142 { 00143 if (false) // FIXME check if atom/resolvable is selected 00144 { 00145 return true; 00146 } 00147 } 00148 return false; 00149 } 00150 00151 void PatchImpl::mark_atoms_to_freshen( bool freshen ) { 00152 for (AtomList::iterator it = _atoms.begin(); 00153 it != _atoms.end(); 00154 it++) 00155 { 00156 // TODO mark the resolvable to be or not to be freshed 00157 } 00158 } 00160 } // namespace detail 00163 } // namespace zypp