The value will be used as transaction id and will be passed to e.g.
the history file and commit plugins.
--- /dev/null
+/**
+\page zypp-userdata User data as transaction id
+
+\author Michael Andres <ma@suse.de>
+
+<HR><!-- ====================================================================== -->
+\section userdata-introduction Introduction
+
+It is possible to store a user defined data string via \ref zypp::ZConfig::setUserData inside libzypp for use as a transaction id. \c Zypper e.g. supports this via its global <tt>'--userdata <string>'</tt> option.
+
+\li Setting a new user data string, a line will be written to the log file. So you can \c grep for it, or for <tt>'(setUserData)'</tt> to find all locations where user data strings were set.
+
+*/
Pathname credentials_global_dir_path;
Pathname credentials_global_file_path;
+ std::string userData;
+
Option<Pathname> pluginsPath;
private:
}
///////////////////////////////////////////////////////////////////
+ // user data
+ ///////////////////////////////////////////////////////////////////
+
+ bool ZConfig::hasUserData() const
+ { return !_pimpl->userData.empty(); }
+
+ std::string ZConfig::userData() const
+ { return _pimpl->userData; }
+
+ bool ZConfig::setUserData( const std::string & str_r )
+ {
+ for_( ch, str_r.begin(), str_r.end() )
+ {
+ if ( *ch < ' ' && *ch != '\t' )
+ {
+ ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
+ return false;
+ }
+ }
+ MIL << "Set user data string to '" << str_r << "'" << endl;
+ _pimpl->userData = str_r;
+ return true;
+ }
+
+ ///////////////////////////////////////////////////////////////////
Pathname ZConfig::repoCachePath() const
{
{ setTextLocale( defaultTextLocale() ); }
public:
+ /** \name Maintain user data
+ * \see \ref zypp-userdata
+ */
+ //@{
+ /** Whether a (non empty) user data sting is defined. */
+ bool hasUserData() const;
+
+ /** User defined string value to be passed to log, history, plugins... */
+ std::string userData() const;
+
+ /** Set a new \ref userData string.
+ * \returns \c TRUE if the string was accepted; \c FALSE if the
+ * string was rejected due to nonprintable characters or newlines.
+ */
+ bool setUserData( const std::string & str_r );
+ //@}
+
+ public:
/**
* Path where the caches are kept (/var/cache/zypp)
* \ingroup g_ZC_REPOCACHE