--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include <iostream>
+#include "zypp/base/Logger.h"
+
+#include "zypp2/source/cached/CachedSourceImpl.h"
+
+using std::endl;
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace source
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+namespace cached
+{ /////////////////////////////////////////////////////////////////
+
+CachedSourceImpl::CachedSourceImpl()
+{
+
+}
+
+CachedSourceImpl::~CachedSourceImpl()
+{
+
+}
+
+
+void CachedSourceImpl::factoryInit()
+{
+ if ( ! ( (url().getScheme() == "file") || (url().getScheme() == "dir") ) )
+ {
+ ZYPP_THROW( Exception( "Plaindir only supports local paths, scheme [" + url().getScheme() + "] is not local" ) );
+ }
+
+ MIL << "Plaindir source initialized." << std::endl;
+ MIL << " Url : " << url() << std::endl;
+ MIL << " Path : " << path() << std::endl;
+}
+
+void CachedSourceImpl::createResolvables(Source_Ref source_r)
+{
+ Pathname thePath = Pathname(url().getPathName()) + path();
+ MIL << "Going to read dir " << thePath << std::endl;
+
+ //extract_packages_from_directory( _store, thePath, selfSourceRef(), true );
+}
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace plaindir
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_CachedSourceImpl_H
+#define ZYPP_CachedSourceImpl_H
+
+#include <iosfwd>
+
+#include "zypp/source/SourceImpl.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace cached
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CachedSourceImpl
+ //
+ /** */
+ class CachedSourceImpl : public source::SourceImpl
+ {
+ public:
+ typedef intrusive_ptr<CachedSourceImpl> Ptr;
+ typedef intrusive_ptr<const CachedSourceImpl> constPtr;
+
+ public:
+ /** Default ctor */
+ CachedSourceImpl();
+ /** Dtor */
+ ~CachedSourceImpl();
+
+ public:
+ /** String identifying the type of the source. */
+ static std::string typeString()
+ { return "CachedSource"; }
+
+ /** String identifying the type of the source. */
+ virtual std::string type() const
+ { return typeString(); }
+
+ private:
+ /** Ctor substitute.
+ * Actually get the metadata.
+ * \throw EXCEPTION on fail
+ */
+ virtual void factoryInit();
+ virtual void createResolvables(Source_Ref source_r);
+
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace cached
+ ///////////////////////////////////////////////////////////////////
+
+ using cached::CachedSourceImpl;
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_PLAINDIR_PLAINDIRIMPL_H
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/SqlitePackageImpl.h
+ *
+*/
+
+#include "SqlitePackageImpl.h"
+#include "zypp/source/SourceImpl.h"
+#include "zypp/TranslatedText.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+
+#include "schema.h"
+
+using namespace std;
+using namespace zypp::detail;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : SqlitePackageImpl
+//
+///////////////////////////////////////////////////////////////////
+
+/** Default ctor
+*/
+SqlitePackageImpl::SqlitePackageImpl (Source_Ref source_r)
+ : _source (source_r)
+ , _install_only(false)
+ , _size_installed(0)
+ , _size_archive(0)
+ , _data_loaded(false)
+{}
+
+/**
+ * read package specific data from handle
+ * (see SqliteSourceImpl, create_package_handle(), the handle is for the package_details table)
+ * throw() on error
+ */
+
+void
+SqlitePackageImpl::readHandle( sqlite_int64 id, sqlite3_stmt *handle )
+{
+ if ( _data_loaded )
+ return;
+
+ _zmdid = id;
+
+ // 1-5: nvra, see SqliteSourceImpl
+ _size_installed = sqlite3_column_int( handle, PACKAGES_TABLE_COLUMN_SIZE_INSTALLED );
+ // 7: catalog
+ // 8: installed
+ // 9: local
+ const char * text = ((const char *) sqlite3_column_text( handle, PACKAGES_TABLE_COLUMN_GROUP ));
+ if (text != NULL)
+ _group = text;
+ _size_archive = sqlite3_column_int( handle, PACKAGES_TABLE_COLUMN_SIZE_ARCHIVE );
+ text = (const char *) sqlite3_column_text( handle, PACKAGES_TABLE_COLUMN_SUMMARY );
+ if (text != NULL)
+ _summary = TranslatedText( string( text ) );
+ text = (const char *) sqlite3_column_text( handle, PACKAGES_TABLE_COLUMN_DESCRIPTION );
+ if (text != NULL)
+ _description = TranslatedText( string( text ) );
+ text = (const char *) sqlite3_column_text( handle, PACKAGES_TABLE_COLUMN_PACKAGE_FILENAME ); // package_filename
+
+ if (text != NULL && *text != 0)
+ {
+ _location = Pathname( text ); // if set, use this (zmd owned source)
+ }
+ else
+ {
+ text = (const char *)sqlite3_column_text( handle, PACKAGES_TABLE_COLUMN_PACKAGE_URL ); // else use package_url
+ if (text == NULL)
+ ERR << "package_url NULL for id " << id << endl;
+ else
+ _location = Pathname( text );
+ }
+ _install_only = (sqlite3_column_int( handle, PACKAGES_TABLE_COLUMN_INSTALL_ONLY ) != 0);
+ _media_nr = sqlite3_column_int( handle, PACKAGES_TABLE_COLUMN_MEDIA_NR );
+
+ _data_loaded = true;
+
+ return;
+}
+
+
+Source_Ref
+SqlitePackageImpl::source() const
+{
+ return _source;
+}
+
+/** Package summary */
+TranslatedText SqlitePackageImpl::summary() const
+{
+ return _summary;
+}
+
+/** Package description */
+TranslatedText SqlitePackageImpl::description() const
+{
+ return _description;
+}
+
+PackageGroup SqlitePackageImpl::group() const
+{
+ return _group;
+}
+
+Pathname SqlitePackageImpl::location() const
+{
+ return _location;
+}
+
+ByteCount SqlitePackageImpl::size() const
+{
+ return _size_installed;
+}
+
+ZmdId SqlitePackageImpl::zmdid() const
+{
+ return _zmdid;
+}
+
+/** */
+ByteCount SqlitePackageImpl::archivesize() const
+{
+ return _size_archive;
+}
+
+bool SqlitePackageImpl::installOnly() const
+{
+ return _install_only;
+}
+
+unsigned SqlitePackageImpl::sourceMediaNr() const
+{
+ return _media_nr;
+}
+
+Vendor SqlitePackageImpl::vendor() const
+{
+ return "suse";
+}
+
+/////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zmd/backend/dbsource/SqlitePackageImpl.h
+ *
+*/
+#ifndef ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H
+#define ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H
+
+#include "zypp/detail/PackageImpl.h"
+#include "zypp/Source.h"
+#include <sqlite3.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SqlitePackageImpl
+ //
+ class SqlitePackageImpl : public detail::PackageImplIf
+ {
+ public:
+
+ SqlitePackageImpl( Source_Ref source_r );
+ void readHandle( sqlite_int64 id, sqlite3_stmt *handle );
+
+ virtual TranslatedText summary() const;
+ virtual TranslatedText description() const;
+ virtual ByteCount size() const;
+ virtual PackageGroup group() const;
+ virtual ByteCount archivesize() const;
+ virtual Pathname location() const;
+ virtual bool installOnly() const;
+ virtual Source_Ref source() const;
+ virtual ZmdId zmdid() const;
+ virtual unsigned sourceMediaNr() const;
+ virtual Vendor vendor() const;
+
+ protected:
+ Source_Ref _source;
+ TranslatedText _summary;
+ TranslatedText _description;
+ PackageGroup _group;
+ Pathname _location;
+ bool _install_only;
+ ZmdId _zmdid;
+ unsigned _media_nr;
+
+ ByteCount _size_installed;
+ ByteCount _size_archive;
+
+ bool _data_loaded;
+ };
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H