Author: dmacvicar
Date: Mon Jul 14 23:30:55 2008
New Revision: 10581
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10581&view=rev
Log:
- dumping some stuff I had uncommitted
- parser for webpin web service
(example at: http://api.opensuse-community.org/searchservice/Search/Simple/openSUSE_103/k... )
- testcases
- only missing adding the architectures data
- this is the basis to implement a network search interface for locating packages.
- adding some modalias indexing may be we can even search for drivers
Added:
trunk/libzypp/tests/parser/ws/
trunk/libzypp/tests/parser/ws/CMakeLists.txt
trunk/libzypp/tests/parser/ws/WebpinResultFileReader_test.cc
trunk/libzypp/tests/parser/ws/data/
trunk/libzypp/tests/parser/ws/data/search-kopete.xml
trunk/libzypp/zypp/parser/ws/
trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.cc
trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.h
trunk/libzypp/zypp/ws/
trunk/libzypp/zypp/ws/WebpinResult.cc
trunk/libzypp/zypp/ws/WebpinResult.h
Modified:
trunk/libzypp/tests/parser/CMakeLists.txt
trunk/libzypp/zypp/CMakeLists.txt
Modified: trunk/libzypp/tests/parser/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/CMakeLists.txt?rev=10581&r1=10580&r2=10581&view=diff
==============================================================================
--- trunk/libzypp/tests/parser/CMakeLists.txt (original)
+++ trunk/libzypp/tests/parser/CMakeLists.txt Mon Jul 14 23:30:55 2008
@@ -1,2 +1,3 @@
ADD_SUBDIRECTORY( yum )
-ADD_SUBDIRECTORY( inifile )
\ No newline at end of file
+ADD_SUBDIRECTORY( inifile )
+ADD_SUBDIRECTORY(ws)
Added: trunk/libzypp/tests/parser/ws/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/ws/CMakeLists.txt?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/tests/parser/ws/CMakeLists.txt (added)
+++ trunk/libzypp/tests/parser/ws/CMakeLists.txt Mon Jul 14 23:30:55 2008
@@ -0,0 +1 @@
+ADD_TESTS(WebpinResultFileReader)
Added: trunk/libzypp/tests/parser/ws/WebpinResultFileReader_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/ws/WebpinResultFileReader_test.cc?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/tests/parser/ws/WebpinResultFileReader_test.cc (added)
+++ trunk/libzypp/tests/parser/ws/WebpinResultFileReader_test.cc Mon Jul 14 23:30:55 2008
@@ -0,0 +1,64 @@
+#include
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <list>
+#include
+
+#include "zypp/parser/ws/WebpinResultFileReader.h"
+#include "zypp/ws/WebpinResult.h"
+
+#include "zypp/Url.h"
+#include "zypp/PathInfo.h"
+
+using namespace std;
+using namespace zypp;
+using namespace boost::unit_test;
+
+using namespace zypp::ws;
+using namespace zypp::parser::ws;
+
+#define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/ws/data")
+
+class Collector
+{
+public:
+ Collector()
+ {}
+
+ bool callback( const WebpinResult &result )
+ {
+ items.push_back(result);
+ //items.push_back(loc);
+ //cout << items.size() << endl;
+ return true;
+ }
+
+ vector<WebpinResult> items;
+};
+
+BOOST_AUTO_TEST_CASE(result_read)
+{
+ Collector collect;
+ Pathname file;
+
+ // this testcase represents this search:
+ // http://api.opensuse-community.org/searchservice/Search/Simple/openSUSE_103/k...
+
+ file = DATADIR + "/search-kopete.xml";
+
+ WebpinResultFileReader reader( file, bind( &Collector::callback, &collect, _1));
+ BOOST_CHECK_EQUAL( collect.items.size(), 17);
+
+ WebpinResult first = collect.items[0];
+ BOOST_CHECK_EQUAL( first.name(), "kopete-otr");
+ BOOST_CHECK_EQUAL( first.edition(), "0.6");
+ BOOST_CHECK_EQUAL( first.repositoryUrl(), Url("http://download.opensuse.org/repositories/home:/burnickl_andreas/openSUSE_10..."));
+ BOOST_CHECK_EQUAL( first.distribution(), "openSUSE_103");
+ BOOST_CHECK_EQUAL( first.checksum(), CheckSum::sha1("2a4d9e95f87abe16c28e4aefa0b3a0ae52220429"));
+ BOOST_CHECK_EQUAL( first.priority(), 0);
+ BOOST_CHECK_EQUAL( first.summary(), "OTR Plugin for Kopete");
+}
+
+
+// vim: set ts=2 sts=2 sw=2 ai et:
Added: trunk/libzypp/tests/parser/ws/data/search-kopete.xml
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/parser/ws/data/search-kopete.xml?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/tests/parser/ws/data/search-kopete.xml (added)
+++ trunk/libzypp/tests/parser/ws/data/search-kopete.xml Mon Jul 14 23:30:55 2008
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+http://datastructures.pkgsearch.benjiweber.co.uk">
+ <package>
+ <name>kopete-otr</name>
+ <version>0.6</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/burnickl_andreas/openSUSE_10...</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>2a4d9e95f87abe16c28e4aefa0b3a0ae52220429</checksum>
+ <summary>OTR Plugin for Kopete</summary>
+ </package>
+ <package>
+ <name>kopete-otr</name>
+ <version>0.7</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/burnickl_andreas/openSUSE_10...</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>b413eb994360c8285f021e69aab2fa006adfcd1e</checksum>
+ <summary>OTR Plugin for Kopete</summary>
+ </package>
+ <package>
+ <name>kopete-floor</name>
+ <version>0.1.0</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/dmacvicar/openSUSE_10.3</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>3c2a1f903106e4f804b811b8f22cb407225a93dd</checksum>
+ <summary>Send your Kopete status to SUSE Floor tool</summary>
+ </package>
+ <package>
+ <name>kopete-anyremote</name>
+ <version>0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/dsbhayangkara/openSUSE_10.3</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>f6d0db3322d75ff51628d59897d5a895d00b2e95</checksum>
+ <summary>anyRemote Plugin for Kopete</summary>
+ </package>
+ <package>
+ <name>kopete-anyremote-debuginfo</name>
+ <version>0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/dsbhayangkara/openSUSE_10.3</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>6716db855c2e6f13436b1f1bc3ac2d9c807da8f8</checksum>
+ <summary>Debug information for package kopete-anyremote</summary>
+ </package>
+ <package>
+ <name>kopete-anyremote</name>
+ <version>0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/dsbhayangkara/openSUSE_10.3_...</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>8d5210aa7cd048ff572edf5c68687ddc06e08cda</checksum>
+ <summary>anyRemote Plugin for Kopete</summary>
+ </package>
+ <package>
+ <name>kopete-anyremote-debuginfo</name>
+ <version>0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/home:/dsbhayangkara/openSUSE_10.3_...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>87a6b154f660b8eb91539f932c7567fabd2bf914</checksum>
+ <summary>Debug information for package kopete-anyremote</summary>
+ </package>
+ <package>
+ <name>extragear-network-kopete</name>
+ <version>4.0.81.svn816196</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/UNSTABLE:/Extra-Apps/op...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>7297c1ab95569bc2db635ea046390d3eba43f510</checksum>
+ <summary>Instant Messenger</summary>
+ </package>
+ <package>
+ <name>kopete-anyremote</name>
+ <version>0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/Community/openSUSE_10.3</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>edb649f5ff1908cbc5fb33c96c19994ca6375e90</checksum>
+ <summary>anyRemote Plugin for Kopete</summary>
+ </package>
+ <package>
+ <name>kopete-otr</name>
+ <version>0.6</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/Community/openSUSE_10.3</repoURL>
+ <archs>
+ <arch>src</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>48f011d09d2f5d06d570383106f7ea630a04f704</checksum>
+ <summary>OTR Plugin for Kopete</summary>
+ </package>
+ <package>
+ <name>kopete-anyremote-debuginfo</name>
+ <version>0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/Community/openSUSE_10.3</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>ba9a0a3e438b7a032514db2abbe1235e5511fdc9</checksum>
+ <summary>Debug information for package kopete-anyremote</summary>
+ </package>
+ <package>
+ <name>kde4-kopete-devel</name>
+ <version>4.0.83</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/UNSTABLE:/Desktop/openS...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>a42adacc32abbb0af41620f1aed1cb071ca20406</checksum>
+ <summary>Instant Messenger - Development Files</summary>
+ </package>
+ <package>
+ <name>kde4-kopete</name>
+ <version>4.0.83</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/UNSTABLE:/Desktop/openS...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>e6a3481e960ebd4400fc6783774a1553ffc83f13</checksum>
+ <summary>Instant Messenger</summary>
+ </package>
+ <package>
+ <name>kde4-kopete</name>
+ <version>4.0.84</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/Factory:/Desktop/openSU...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>11f952a8c8f72fa96507509a9c15e1a322729f7d</checksum>
+ <summary>Instant Messenger</summary>
+ </package>
+ <package>
+ <name>kde4-kopete-devel</name>
+ <version>4.0.84</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/Factory:/Desktop/openSU...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>f213abb894d16d76c3598a54bc55ca58e88c1483</checksum>
+ <summary>Instant Messenger - Development Files</summary>
+ </package>
+ <package>
+ <name>kde4-kopete-devel</name>
+ <version>4.0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/STABLE:/Desktop/openSUS...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>71b6461f35fe255cb70881d415577a5cd573e096</checksum>
+ <summary>Instant Messenger - Development Files</summary>
+ </package>
+ <package>
+ <name>kde4-kopete</name>
+ <version>4.0.4</version>
+ <repoURL>http://download.opensuse.org/repositories/KDE:/KDE4:/STABLE:/Desktop/openSUS...</repoURL>
+ <archs>
+ <arch>i586</arch>
+ </archs>
+ <distro>openSUSE_103</distro>
+ <priority>10</priority>
+ <checksum>c761db2406163ab025cfb4005fe5b05e83bbb78a</checksum>
+ <summary>Instant Messenger</summary>
+ </package>
+
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=10581&r1=10580&r2=10581&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Mon Jul 14 23:30:55 2008
@@ -54,6 +54,7 @@
Rel.cc
RepoInfo.cc
RepoManager.cc
+ Repository.cc
RepoStatus.cc
ResKind.cc
ResObject.cc
@@ -78,7 +79,6 @@
ZYppCommitPolicy.cc
ZYppCommitResult.cc
ZYppFactory.cc
- Repository.cc
)
SET( zypp_EARLY_SRCS
ZConfig.cc
@@ -149,6 +149,7 @@
Rel.h
RepoInfo.h
RepoManager.h
+ Repository.h
RepoStatus.h
Filter.h
ResFilters.h
@@ -181,7 +182,6 @@
ZYppCommitResult.h
ZYppFactory.h
ZYpp.h
- Repository.h
)
INSTALL( FILES ${zypp_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/zypp" )
@@ -467,6 +467,21 @@
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/parser/yum
)
+SET( zypp_parser_ws_SRCS
+ parser/ws/WebpinResultFileReader.cc
+
+)
+
+SET( zypp_parser_ws_HEADERS
+ parser/ws/WebpinResultFileReader.h
+)
+
+INSTALL( FILES
+ ${zypp_parser_ws_HEADERS}
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/parser/ws
+)
+
+
SET( zypp_pool_SRCS
pool/GetResolvablesToInsDel.cc
pool/PoolImpl.cc
@@ -787,12 +802,22 @@
repo/susetags/Downloader.h
)
+SET( zypp_ws_SRCS
+ ws/WebpinResult.cc
+)
+
+SET( zypp_ws_HEADERS
+ ws/WebpinResult.h
+)
+
+
SET( zypp_lib_SRCS
${zypp_pool_SRCS}
${zypp_parser_susetags_SRCS}
${zypp_parser_xml_SRCS}
${zypp_parser_yum_SRCS}
${zypp_parser_plaindir_SRCS}
+${zypp_parser_ws_SRCS}
${zypp_parser_SRCS}
${zypp_data_SRCS}
${zypp_media_proxyinfo_SRCS}
@@ -809,6 +834,7 @@
${zypp_solver_detail_SRCS}
${zypp_ui_SRCS}
${zypp_thread_SRCS}
+${zypp_ws_SRCS}
${zypp_SRCS}
${zypp_zypp_detail_SRCS}
${zypp_sat_SRCS}
@@ -824,6 +850,7 @@
${zypp_parser_yum_HEADERS}
${zypp_parser_plaindir_HEADERS}
${zypp_parser_xml_HEADERS}
+${zypp_parser_ws_HEADERS}
${zypp_parser_HEADERS}
${zypp_data_HEADERS}
${zypp_ui_HEADERS}
@@ -835,6 +862,7 @@
${zypp_sat_HEADERS}
${zypp_sat_detail_HEADERS}
${zypp_url_HEADERS}
+${zypp_ws_HEADERS}
${zypp_HEADERS}
${zypp_zypp_detail_HEADERS}
${zypp_thread_HEADERS}
Added: trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.cc?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.cc (added)
+++ trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.cc Mon Jul 14 23:30:55 2008
@@ -0,0 +1,128 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/WebpinResultFileReader.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/base/InputStream.h"
+#include "zypp/base/UserRequestException.h"
+
+#include "zypp/parser/xml/Reader.h"
+#include "zypp/parser/ws/WebpinResultFileReader.h"
+#include "zypp/ws/WebpinResult.h"
+
+using std::endl;
+using namespace zypp::xml;
+using namespace zypp::ws;
+
+namespace zypp
+{
+namespace parser
+{
+namespace ws
+{
+
+class WebpinResultFileReader::Impl
+{
+public:
+ Impl( const Pathname &result_file,
+ const ProcessWebpinResult &callback );
+
+ /**
+ * Callback provided to the XML parser.
+ */
+ bool consumeNode( Reader & reader_r );
+private:
+ shared_ptr<WebpinResult> _result;
+ ProcessWebpinResult _callback;
+};
+
+bool WebpinResultFileReader::Impl::consumeNode(Reader & reader_r)
+{
+ if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT )
+ {
+ // xpath: /packages
+ if ( reader_r->name() == "packages" )
+ {
+ return true;
+ }
+
+ // xpath: /packages/package (+)
+ if ( reader_r->name() == "package" )
+ { _result.reset( new WebpinResult() ); }
+
+ // xpath: /packages/name
+ if ( reader_r->name() == "name" )
+ { _result->setName(reader_r.nodeText().asString());}
+
+ // xpath: /packages/version
+ if ( reader_r->name() == "version" )
+ { _result->setEdition(Edition(reader_r.nodeText().asString())); }
+
+ // xpath: /packages/summary
+ if ( reader_r->name() == "summary" )
+ { _result->setSummary(reader_r.nodeText().asString()); }
+
+ // xpath: /packages/repoURL
+ if ( reader_r->name() == "repoURL" )
+ { _result->setRepositoryUrl(Url(reader_r.nodeText().asString())); }
+
+ // xpath: /packages/checksum
+ if ( reader_r->name() == "checksum" )
+ { _result->setChecksum(CheckSum::sha1(reader_r.nodeText().asString())); }
+ // xpath: /packages/distro
+ if ( reader_r->name() == "distro" )
+ { _result->setDistribution(reader_r.nodeText().asString());}
+
+ return true;
+ }
+ else if ( reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT )
+ {
+ // xpath: /packages/package (+)
+ if ( reader_r->name() == "package" )
+ {
+ _callback(*_result);
+ }
+ }
+
+ return true;
+}
+
+
+WebpinResultFileReader::Impl::Impl( const Pathname &result_file,
+ const ProcessWebpinResult &callback )
+ : _callback(callback)
+{
+ Reader reader( result_file );
+ MIL << "Reading " << result_file << endl;
+ reader.foreachNode( bind( &WebpinResultFileReader::Impl::consumeNode, this, _1 ) );
+}
+
+
+WebpinResultFileReader::WebpinResultFileReader( const Pathname & result_file,
+ const ProcessWebpinResult & callback )
+ : _pimpl(new WebpinResultFileReader::Impl(result_file, callback))
+{
+}
+
+WebpinResultFileReader::~WebpinResultFileReader()
+{}
+
+std::ostream & operator<<( std::ostream & str, const WebpinResultFileReader & obj )
+{
+ return str;
+}
+
+
+} // namespace ws
+} // namespace parser
+} // namespace zypp
+
Added: trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.h?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.h (added)
+++ trunk/libzypp/zypp/parser/ws/WebpinResultFileReader.h Mon Jul 14 23:30:55 2008
@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/WebpinResultFileReader.h
+ *
+*/
+#ifndef ZYPP_PARSER_WEBPINRESULTFILEREADER_H
+#define ZYPP_PARSER_WEBPINRESULTFILEREADER_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include "zypp/ProgressData.h"
+#include "zypp/Pathname.h"
+#include "zypp/ws/WebpinResult.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ namespace parser
+ { /////////////////////////////////////////////////////////////////
+
+ namespace ws
+ {
+
+ /**
+ * \short Read packages and repository search result data from
+ * from webpin web search results.
+ *
+ * For each result, a \ref WebpinResult is prepared and \ref _callback
+ * is called with the object passed in.
+ *
+ * The \ref _callback is provided on construction.
+ *
+ * \code
+ * WebpinResultFileReader reader(repo_file,
+ * bind( &SomeClass::callbackfunc, &SomeClassInstance, _1, _2 ) );
+ * \endcode
+ */
+ class WebpinResultFileReader
+ {
+ friend std::ostream & operator<<( std::ostream & str, const WebpinResultFileReader & obj );
+ public:
+
+ /**
+ * Callback definition.
+ * First parameter is a \ref WebpinResult object.
+ *
+ * Return false from the callback to get a \ref AbortRequestException
+ * to be thrown and the processing to be cancelled.
+ */
+ typedef function< bool( const zypp::ws::WebpinResult & )> ProcessWebpinResult;
+
+ public:
+ /**
+ * \short Constructor. Creates the reader and start reading.
+ *
+ * \param result_file Valid result XML file from Webpin
+ * \param callback Callback that will be called for each repository.
+ * \param progress Optional progress function. \see ProgressData
+ *
+ * \throws AbortRequestException If the callback returns false
+ * \throws Exception If a error occurs at reading / parsing
+ *
+ */
+ WebpinResultFileReader( const Pathname &result_file,
+ const ProcessWebpinResult & callback/*,
+ const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc()*/);
+
+ /**
+ * Dtor
+ */
+ ~WebpinResultFileReader();
+ private:
+ class Impl;
+ RW_pointer _pimpl;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates WebpinResultFileReader Stream output */
+ std::ostream & operator<<( std::ostream & str, const WebpinResultFileReader & obj );
+
+ } //namespace ws
+ /////////////////////////////////////////////////////////////////
+ } // namespace parser
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_WEBPINRESULTFILEREADER_H
Added: trunk/libzypp/zypp/ws/WebpinResult.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ws/WebpinResult.cc?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/zypp/ws/WebpinResult.cc (added)
+++ trunk/libzypp/zypp/ws/WebpinResult.cc Mon Jul 14 23:30:55 2008
@@ -0,0 +1,166 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/WebpinResult.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/base/Logger.h"
+#include "zypp/ws/WebpinResult.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace ws
+{
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : WebpinResult::Impl
+ //
+ /** WebpinResult implementation. */
+ struct WebpinResult::Impl
+ {
+ Impl()
+ : priority(0)
+ {}
+
+ ~Impl()
+ {
+ //MIL << std::endl;
+ }
+ public:
+ std::string name;
+ Edition edition;
+ CheckSum checksum;
+ Url repourl;
+ string summary;
+ string distro;
+ int priority;
+
+ private:
+ friend Impl * rwcowClone<Impl>( const Impl * rhs );
+ /** clone for RWCOW_pointer */
+ Impl * clone() const
+ { return new Impl( *this ); }
+ };
+
+ /** \relates WebpinResult::Impl Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const WebpinResult::Impl & obj )
+ {
+ return str << "WebpinResult::Impl";
+ }
+
+ WebpinResult::WebpinResult()
+ : _pimpl( new Impl() )
+ {}
+
+ WebpinResult::~WebpinResult()
+ {
+ //MIL << std::endl;
+ }
+
+ WebpinResult & WebpinResult::setName( const std::string &name )
+ {
+ _pimpl->name = name;
+ return *this;
+ }
+
+ std::string WebpinResult::name() const
+ {
+ return _pimpl->name;
+ }
+
+
+ zypp::Url WebpinResult::repositoryUrl() const
+ {
+ return _pimpl->repourl;
+ }
+
+ WebpinResult & WebpinResult::setRepositoryUrl( const zypp::Url &url )
+ {
+ _pimpl->repourl = url;
+ return *this;
+ }
+
+ WebpinResult & WebpinResult::setDistribution( const std::string &distro )
+ {
+ _pimpl->distro = distro;
+ return *this;
+ }
+
+ std::string WebpinResult::distribution() const
+ {
+ return _pimpl->distro;
+ }
+
+ WebpinResult & WebpinResult::setSummary( const std::string &summary )
+ {
+ _pimpl->summary = summary;
+ return *this;
+ }
+
+ std::string WebpinResult::summary() const
+ {
+ return _pimpl->summary;
+ }
+
+ WebpinResult & WebpinResult::setPriority( int priority )
+ {
+ _pimpl->priority = priority;
+ return *this;
+ }
+
+ int WebpinResult::priority() const
+ {
+ return _pimpl->priority;
+ }
+
+
+ WebpinResult & WebpinResult::setEdition( const Edition &edition )
+ {
+ _pimpl->edition = edition;
+ return *this;
+ }
+
+ Edition WebpinResult::edition() const
+ {
+ return _pimpl->edition;
+ }
+
+ WebpinResult & WebpinResult::setChecksum( const CheckSum &checksum )
+ {
+ _pimpl->checksum = checksum;
+ return *this;
+ }
+
+ CheckSum WebpinResult::checksum() const
+ {
+ return _pimpl->checksum;
+ }
+
+
+ std::ostream & WebpinResult::dumpOn( std::ostream & str ) const
+ {
+ str << "- name : " << name() << std::endl;
+ return str;
+ }
+
+ std::ostream & operator<<( std::ostream & str, const WebpinResult & obj )
+ {
+ return obj.dumpOn(str);
+ }
+
+} // namespace ws
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/ws/WebpinResult.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ws/WebpinResult.h?rev=10581&view=auto
==============================================================================
--- trunk/libzypp/zypp/ws/WebpinResult.h (added)
+++ trunk/libzypp/zypp/ws/WebpinResult.h Mon Jul 14 23:30:55 2008
@@ -0,0 +1,147 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/WebpinResult.h
+ *
+*/
+#ifndef ZYPP_WEBPINRESULT_H
+#define ZYPP_WEBPINRESULT_H
+
+#include <iosfwd>
+#include <list>
+#include <set>
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/Iterator.h"
+#include "zypp/base/Deprecated.h"
+
+#include "zypp/CheckSum.h"
+#include "zypp/Edition.h"
+#include "zypp/Pathname.h"
+#include "zypp/Url.h"
+#include "zypp/repo/RepoType.h"
+#include "zypp/repo/RepoVariables.h"
+
+namespace zypp
+{
+namespace ws
+{
+ /**
+ * \short Represents a result from
+ * http://api.opensuse-community.org/searchservice/Search
+ * web service
+ *
+ */
+ class WebpinResult
+ {
+ friend std::ostream & operator<<( std::ostream & str, const WebpinResult & obj );
+
+ public:
+ WebpinResult();
+ ~WebpinResult();
+
+ /**
+ * package name
+ */
+ std::string name() const;
+
+ /**
+ * set the package name \see name
+ * \param name
+ */
+ WebpinResult & setName( const std::string &name );
+
+ /**
+ * package edition
+ */
+ zypp::Edition edition() const;
+
+ /**
+ * set the package edition \see edition
+ * \param edition
+ */
+ WebpinResult & setEdition( const zypp::Edition &name );
+
+ /**
+ * repository's url
+ * The url of the repository where this package
+ * is located
+ */
+ zypp::Url repositoryUrl() const;
+
+ /**
+ * set the repository url where this package comes from
+ * \see repositoryUrl
+ * \param url
+ */
+ WebpinResult & setRepositoryUrl( const zypp::Url &url );
+
+ /**
+ * package priority
+ */
+ int priority() const;
+
+ /**
+ * set the package priority \see priority
+ * \param priority
+ */
+ WebpinResult & setPriority( int priority );
+
+
+ /**
+ * package summary
+ */
+ std::string summary() const;
+
+ /**
+ * set the package summary \see summary
+ * \param summary
+ */
+ WebpinResult & setSummary( const std::string &summary );
+
+ /**
+ * package distribution
+ * Example: openSUSE 10.3
+ */
+ std::string distribution() const;
+
+ /**
+ * set the package distribution \see distribution
+ * \param distribution
+ */
+ WebpinResult & setDistribution( const std::string &distribution );
+
+ /**
+ * package checksum
+ * Example: a md5sum or sha1sum
+ */
+ zypp::CheckSum checksum() const;
+
+ /**
+ * set the package checksum \see checksum
+ * \param checksum
+ */
+ WebpinResult & setChecksum( const zypp::CheckSum &checksum );
+
+
+ std::ostream & dumpOn( std::ostream & str ) const;
+
+ class Impl;
+ private:
+ /** Pointer to implementation */
+ RWCOW_pointer<Impl> _pimpl;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates RepoInfo Stream output */
+ std::ostream & operator<<( std::ostream & str, const WebpinResult & obj );
+
+} // namespace ws
+} // namespace zypp
+
+
+#endif // ZYPP_WEBPINRESULT_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org