#include "output/prompt.h"
+class Table;
+
/**
* Base class for producing common (for now) zypper output.
- *
+ *
* This is an abstract class providing interface for writing output like
* info messages, warnings, error messages, user prompts, progress reports,
* and download progress reports. See descriptions of the methods for more
* details.
- *
+ *
* The output is produced using Out derived class instances.
- *
+ *
* <code>
- *
+ *
* // create output object
* SomePointerType<Out> out;
* if (options.count("xmlout"))
* out = new OutXML();
* else
* out = new OutNormal();
- *
+ *
* out->info("output instance ready to use", Out::HIGH);
* out->info("Doing foo");
* try
public:
/**
* Show an info message.
- *
+ *
* \param msg The message to be displayed.
* \param verbosity Minimal level o verbosity in which the message will be
* shown. Out::QUIET means the message will be always be
* (-vv).
* \param mask Determines the types of output for which is this message
* intended. By default, the message will be shown in all
- * types of output.
+ * types of output.
*/
virtual void info(const std::string & msg, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL) = 0;
/**
* Show a warning.
- *
+ *
* \param msg The warning message to be displayed.
* \param verbosity Minimal level o verbosity in which the message will be
* shown. Out::QUIET means the message will be always be
* (-vv).
* \param mask Determines the types of output for which is this message
* intended. By default, the message will be shown in all
- * types of output.
+ * types of output.
*/
virtual void warning(const std::string & msg, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL) = 0;
/**
* Show an error message and an optional hint.
- *
+ *
* An error message should be shown regardless of the verbosity level.
- *
+ *
* \param problem_desc Problem description (what happend)
* \param hint Hint for the user (what to do, or explanation)
*/
/**
* Prints the problem description caused by an exception, its cause and,
* optionaly, a hint for the user.
- *
+ *
* \param e Exception which caused the problem.
* \param Problem description for the user.
* \param Hint for the user how to cope with the problem.
//@{
/**
* Start of an operation with reported progress.
- *
+ *
* \param id Identifier. Any string used to match multiple overlapping
* progress reports (doesn't happen now,
* but probably will in the future).
/**
* Progress report for an on-going operation.
- *
+ *
* \param id Identifier. Any string used to match multiple overlapping
* progress reports.
* \param label Progress description.
/**
* End of an operation with reported progress.
- *
+ *
* \param id Identifier. Any string used to match multiple overlapping
* progress reports.
* \param label Progress description.
//@{
/**
* Reoprt start of a download.
- *
- * \param uri Uri of the file to download.
+ *
+ * \param uri Uri of the file to download.
*/
virtual void dwnldProgressStart(const zypp::Url & uri) = 0;
/**
* Reports download progress.
- *
- * \param uri Uri of the file being downloaded.
+ *
+ * \param uri Uri of the file being downloaded.
* \param value Value of the progress in percents. -1 if unknown.
* \param rate Current download rate in B/s. -1 if unknown.
*/
long rate = -1) = 0;
/**
* Reports end of a download.
- *
- * \param uri Uri of the file to download.
+ *
+ * \param uri Uri of the file to download.
* \param rate Average download rate at the end. -1 if unknown.
* \param error Error flag - did the download finish with error?
*/
//@}
/**
+ * Print out a search result.
+ *
+ * Default implementation prints \a table_r on \c stdout.
+ *
+ * \param table_r Table containing the search result.
+ *
+ * \todo Using a more generic format than a Table is desired.
+ */
+ virtual void searchResult( const Table & table_r );
+
+ /**
* Prompt the user for a decision.
- *
+ *
* \param id Unique prompt identifier for use by machines.
* \param prompt Prompt text.
* \param options A PromptOptions object
* \param startdesc Initial detailed description of the prompt to be
* prepended to the \a prompt text. Should be used
* only whe prompting for the first time and left empty
- * when retrying after an invalid answer has been given.
+ * when retrying after an invalid answer has been given.
* \see prompt.h
* \see ../zypper-prompt.h
*/
/**
* Determine whether to show progress.
- *
+ *
* \return <tt>true</tt> if the progress should be filtered out,
* <tt>false</tt> if it should be shown.
*/
#include <vector>
#include "zypp/base/String.h"
+#include "zypp/base/String.h"
#include "OutXML.h"
#include "utils/misc.h"
+#include "Table.h"
using std::cout;
using std::endl;
<< "/>" << endl;
}
+void OutXML::searchResult( const Table & table_r )
+{
+ cout << "<search-result version=\"0.0\">" << endl;
+ cout << "<solvable-list>" << endl;
+
+ const Table::container & rows( table_r.rows() );
+ if ( ! rows.empty() )
+ {
+ //
+ // *** CAUTION: It's a mess, but must mtch the header list defined
+ // in FillSearchTableSolvable ctor (search.cc)
+ //
+ static const char * header[] = {
+ "status",
+ "name",
+ "kind",
+ "edition",
+ "arch",
+ "repository"
+ };
+ for_( it, rows.begin(), rows.end() )
+ {
+ cout << "<solvable";
+ const TableRow::container & cols( it->columns() );
+ unsigned cidx = 0;
+ for_( cit, cols.begin(), cols.end() )
+ {
+ cout << ' ' << (cidx < 6 ? header[cidx] : "?" ) << "=\"";
+ if ( cidx == 0 )
+ {
+ if ( *cit == "i" )
+ cout << "installed\"";
+ else if ( *cit == "v" )
+ cout << "other-version\"";
+ else
+ cout << "not-installed\"";
+ }
+ else
+ {
+ cout << *cit << '"';
+ }
+ ++cidx;
+ }
+ cout << "/>" << endl;
+ }
+ }
+ //Out::searchResult( table_r );
+
+ cout << "</solvable-list>" << endl;
+ cout << "</search-result>" << endl;
+}
+
void OutXML::prompt(PromptId id,
const string & prompt,
const PromptOptions & poptions,
install-summary-element* | # for zypper install/remove/update
repo-list-element? | # for zypper repos
service-list-element? |
- selectable-list-element? | # for zypper search
+ selectable-list-element? |
+ search-result-element? | # for zypper search
selectable-info-element? | # for zypper info
# random text can appear between tags - this text should be ignored
attribute interactive { xsd:boolean } # needs user interaction?
}
+search-result-element =
+ element search-result {
+ attribute version {xsd:string},
+ solvable-list-element
+ }
+
+solvable-list-element =
+ element solvable-list {
+ solvable-element*
+ }
+
solvable-element =
element solvable {
- attribute type { "package" | "patch" | "pattern" | "product" },
+ attribute status { "installed" | "other-version" | "not-installed" },
+ attribute kind { "package" | "patch" | "pattern" | "product" },
attribute name { xsd:string },
attribute edition { xsd:string }, # target edition
attribute edition-old { xsd:string }?, # currently installed version in case of upgrade
attribute arch { xsd:string },
attribute arch-old { xsd:string }?, # currently installed architecture
attribute summary { xsd:string }?,
+ attribute repository { xsd:string }?,
text?
}