Author: sh-sh-sh
Date: Wed Feb 6 14:20:49 2008
New Revision: 44192
URL: http://svn.opensuse.org/viewcvs/yast?rev=44192&view=rev
Log:
Separate class for macro playing and recording:
Getting YCP-related code out of the way
Added:
trunk/core/libyui/src/YMacro.cc
trunk/core/libyui/src/YMacro.h
Modified:
trunk/core/VERSION
trunk/core/libyui/src/ChangeLog
trunk/core/libyui/src/Makefile.am
trunk/core/libyui/src/Y2UINamespace.cc
trunk/core/libyui/src/YCPMacroPlayer.cc
trunk/core/libyui/src/YCPMacroPlayer.h
trunk/core/libyui/src/YCPMacroRecorder.cc
trunk/core/libyui/src/YCPMacroRecorder.h
trunk/core/libyui/src/YMacroPlayer.h
trunk/core/libyui/src/YMacroRecorder.h
trunk/core/libyui/src/YUI.h
trunk/core/libyui/src/YUI_builtins.cc
trunk/core/libyui/src/YUI_core.cc
trunk/core/package/yast2-core.changes
trunk/ncurses/src/YNCursesUI.cc
trunk/ncurses/yast2-ncurses.spec.in
trunk/qt/src/YQUI_builtins.cc
trunk/qt/yast2-qt.spec.in
Modified: trunk/core/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/VERSION?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/VERSION (original)
+++ trunk/core/VERSION Wed Feb 6 14:20:49 2008
@@ -1 +1 @@
-2.16.28
+2.16.29
Modified: trunk/core/libyui/src/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/ChangeLog?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/ChangeLog (original)
+++ trunk/core/libyui/src/ChangeLog Wed Feb 6 14:20:49 2008
@@ -505,3 +505,12 @@
- Derived classes now have to implement:
- YDialog::waitForEventInternal()
- YDialog::pollEventInternal()
+
+
+2008-02-06 sh@suse.de
+
+* Macro recording and playing ins now unified and moved out of the YUI class.
+ Use the static functions in the new YMacro class instead now:
+ - YMacro::record()
+ - YMacro::play()
+ ...
Modified: trunk/core/libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/Makefile.am?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/Makefile.am (original)
+++ trunk/core/libyui/src/Makefile.am Wed Feb 6 14:20:49 2008
@@ -47,10 +47,11 @@
YWidgetFactory.cc \
YOptionalWidgetFactory.cc \
YWidgetID.cc \
- YBusyIndicator.cc \
+ YMacro.cc \
\
YAlignment.cc \
YBarGraph.cc \
+ YBusyIndicator.cc \
YCheckBox.cc \
YCheckBoxFrame.cc \
YComboBox.cc \
@@ -152,9 +153,13 @@
YWidgetID.h \
YWidgetOpt.h \
YWidget_OptimizeChanges.h \
+ YMacro.h \
+ YMacroPlayer.h \
+ YMacroRecorder.h \
\
YAlignment.h \
YBarGraph.h \
+ YBusyIndicator.h \
YCheckBox.h \
YCheckBoxFrame.h \
YComboBox.h \
@@ -171,8 +176,6 @@
YLabel.h \
YLayoutBox.h \
YLogView.h \
- YMacroPlayer.h \
- YMacroRecorder.h \
YMenuButton.h \
YMultiLineEdit.h \
YMultiProgressMeter.h \
@@ -200,7 +203,6 @@
YTimezoneSelector.h \
YTree.h \
YWizard.h \
- YBusyIndicator.h \
\
YRpmGroupsTree.h \
YStringTree.h \
Modified: trunk/core/libyui/src/Y2UINamespace.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/Y2UINamespace.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/Y2UINamespace.cc (original)
+++ trunk/core/libyui/src/Y2UINamespace.cc Wed Feb 6 14:20:49 2008
@@ -33,6 +33,7 @@
#include "YUISymbols.h"
#include "YUIComponent.h"
#include "Y2UINamespace.h"
+#include "YMacro.h"
#define VERBOSE_UI_CALLS 0
@@ -685,9 +686,9 @@
if ( ! m_comp->ui() )
return YCPVoid(); // dummy UI component
- if ( m_play_macro_blocks && m_comp->ui()->playingMacro() )
+ if ( m_play_macro_blocks && YMacro::playing() )
{
- m_comp->ui()->playNextMacroBlock();
+ YMacro::playNextBlock();
}
YCPValue ret = YCPVoid();
Modified: trunk/core/libyui/src/YCPMacroPlayer.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPMacroPlayer.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YCPMacroPlayer.cc (original)
+++ trunk/core/libyui/src/YCPMacroPlayer.cc Wed Feb 6 14:20:49 2008
@@ -33,12 +33,13 @@
-YCPMacroPlayer::YCPMacroPlayer( const string & macroFileName )
- : YMacroPlayer( macroFileName )
+YCPMacroPlayer::YCPMacroPlayer()
+ : YMacroPlayer()
, _macro( 0 )
+ , _playing( false )
+ , _error( false )
+ , _nextBlockNo( -1 )
{
- _nextBlockNo = -1;
- readMacroFile( macroFileName );
}
@@ -48,15 +49,16 @@
}
-
-void YCPMacroPlayer::readMacroFile( const string & macroFileName )
+void YCPMacroPlayer::play( const string & macroFileName )
{
- clearError();
+ _playing = false;
+ _error = false;
+ _nextBlockNo = -1;
FILE * macroFile = fopen( macroFileName.c_str(), "r" );
if ( ! macroFile )
{
- setError();
+ _error = true;
yuiError() << "Can't open macro file " << macroFileName << endl;
return ;
}
@@ -66,18 +68,18 @@
Parser parser( macroFile, macroFileName.c_str() );
YCodePtr parsed = parser.parse();
- if ( !parsed || parsed->isError() )
+ if ( ! parsed || parsed->isError() )
{
- setError();
+ _error = true;
yuiError() << "Error parsing macro file " << macroFileName
<< " -- macro execution aborted"
<< endl;
return;
}
- if ( !parsed->isBlock() )
+ if ( ! parsed->isBlock() )
{
- setError();
+ _error = true;
yuiError() << "Macro syntax error in file " << macroFileName
<< " -- expected YCP block"
<< endl;
@@ -90,14 +92,34 @@
<< " - " << _macro->statementCount() << " macro blocks"
<< endl;
_nextBlockNo = 0;
+ _playing = true;
fclose( macroFile );
}
+void YCPMacroPlayer::playNextBlock()
+{
+ if ( error() || finished() )
+ {
+ _playing = false;
+ }
+
+ yuiMilestone() << "Evaluating macro block #" << _nextBlockNo << endl;
+
+ _macro->evaluate( _nextBlockNo++ );
+}
+
+
+bool YCPMacroPlayer::playing() const
+{
+ return _playing;
+}
+
+
bool YCPMacroPlayer::finished()
{
- if ( error() || !_macro || _nextBlockNo < 0 )
+ if ( error() || ! _macro || _nextBlockNo < 0 )
{
yuiWarning() << "Test for error() first before testing finished() !" << endl;
return true;
@@ -111,19 +133,6 @@
}
-YCPValue YCPMacroPlayer::evaluateNextBlock()
-{
- if ( error() || finished() )
- {
- return YCPNull();
- }
-
- yuiMilestone() << "Evaluating macro block #" << _nextBlockNo << endl;
-
- return _macro->evaluate( _nextBlockNo++ );
-}
-
-
void YCPMacroPlayer::rewind()
{
_nextBlockNo = 0;
Modified: trunk/core/libyui/src/YCPMacroPlayer.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPMacroPlayer.h?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YCPMacroPlayer.h (original)
+++ trunk/core/libyui/src/YCPMacroPlayer.h Wed Feb 6 14:20:49 2008
@@ -31,7 +31,7 @@
/**
* Constructor
**/
- YCPMacroPlayer( const string & macroFileName );
+ YCPMacroPlayer();
/**
* Destructor
@@ -39,6 +39,27 @@
virtual ~YCPMacroPlayer();
/**
+ * Play a macro from the specified macro file.
+ *
+ * Implemented from YMacroPlayer.
+ **/
+ virtual void play( const string & macroFile );
+
+ /**
+ * Return 'true' if a macro is currently being played.
+ *
+ * Implemented from YMacroPlayer.
+ **/
+ virtual bool playing() const;
+
+ /**
+ * Play the next block from the current macro, if there is one playing.
+ *
+ * Implemented from YMacroPlayer.
+ **/
+ virtual void playNextBlock();
+
+ /**
* Report error status
**/
bool error() const { return _error; }
@@ -50,48 +71,20 @@
bool finished();
/**
- * Return the result of the next macro block and increment the internal
- * block counter. Returns YCPNull() on any previous error or if finished.
- * Check for error() or finished() before calling this!
- **/
- YCPValue evaluateNextBlock();
-
- /**
* Rewind macro execution - prepare to redo from start
**/
void rewind();
protected:
- /**
- * Read and parse a macro file. Sets the internal "error" status.
- **/
- void readMacroFile( const string & macroFileName );
-
- /**
- * Clear error status
- **/
- void clearError() { _error = false; }
-
- /**
- * Set error status
- **/
- void setError() { _error = true; }
-
- /**
- * The parsed macro
- **/
- YBlockPtr _macro;
-
- /**
- * Error status
- **/
- bool _error;
-
- /**
- * Number of the next macro block to execute
- **/
- int _nextBlockNo;
+ //
+ // Data members
+ //
+
+ YBlockPtr _macro;
+ bool _playing;
+ bool _error;
+ int _nextBlockNo;
};
#endif // YCPMacroPlayer_h
Modified: trunk/core/libyui/src/YCPMacroRecorder.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPMacroRecorder.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YCPMacroRecorder.cc (original)
+++ trunk/core/libyui/src/YCPMacroRecorder.cc Wed Feb 6 14:20:49 2008
@@ -46,8 +46,23 @@
#define YMACRO_INDENT " " // 4 blanks
-YCPMacroRecorder::YCPMacroRecorder( const string & macroFileName )
- : YMacroRecorder( macroFileName )
+YCPMacroRecorder::YCPMacroRecorder()
+ : YMacroRecorder()
+ , _macroFile(0)
+ , _screenShotCount(0)
+ , _recording( false )
+{
+}
+
+
+YCPMacroRecorder::~YCPMacroRecorder()
+{
+ writeMacroFileFooter();
+ closeMacroFile();
+}
+
+
+void YCPMacroRecorder::record( const string & macroFileName )
{
_screenShotCount = 0;
openMacroFile( macroFileName );
@@ -55,19 +70,26 @@
}
-YCPMacroRecorder::~YCPMacroRecorder()
+void YCPMacroRecorder::endRecording()
{
writeMacroFileFooter();
closeMacroFile();
}
+bool YCPMacroRecorder::recording() const
+{
+ return _recording;
+}
+
+
void YCPMacroRecorder::openMacroFile( const string & macroFileName )
{
_macroFile = fopen( macroFileName.c_str(), "w" );
if ( _macroFile )
{
+ _recording = true;
yuiMilestone() << "Recording macro to " << macroFileName << endl;
}
else
@@ -85,6 +107,8 @@
_macroFile = 0;
yuiMilestone() << "Macro recording done." << endl;
}
+
+ _recording = false;
}
Modified: trunk/core/libyui/src/YCPMacroRecorder.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YCPMacroRecorder.h?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YCPMacroRecorder.h (original)
+++ trunk/core/libyui/src/YCPMacroRecorder.h Wed Feb 6 14:20:49 2008
@@ -33,7 +33,7 @@
/**
* Constructor
**/
- YCPMacroRecorder( const string & macroFileName );
+ YCPMacroRecorder();
/**
* Destructor
@@ -41,6 +41,27 @@
virtual ~YCPMacroRecorder();
/**
+ * Start recording a macro to the specified file.
+ *
+ * Implemented from YMacroRecorder.
+ **/
+ virtual void record( const string & macroFileName );
+
+ /**
+ * End recording and close the current macro file (if there is any).
+ *
+ * Implemented from YMacroRecorder.
+ **/
+ virtual void endRecording();
+
+ /**
+ * Return 'true' if a macro is currently being recorded.
+ *
+ * Implemented from YMacroRecorder.
+ **/
+ virtual bool recording() const;
+
+ /**
* Record one widget property.
*
* Implemented from YMacroRecorder.
@@ -58,7 +79,7 @@
* Implemented from YMacroRecorder.
**/
virtual void recordMakeScreenShot( bool enabled = false,
- const string & filename = string() );
+ const string & filename = string() );
/**
* Record one user input.
@@ -121,6 +142,7 @@
//
FILE * _macroFile;
int _screenShotCount;
+ bool _recording;
};
#endif // YCPMacroRecorder_h
Added: trunk/core/libyui/src/YMacro.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YMacro.cc?rev=44192&view=auto
==============================================================================
--- trunk/core/libyui/src/YMacro.cc (added)
+++ trunk/core/libyui/src/YMacro.cc Wed Feb 6 14:20:49 2008
@@ -0,0 +1,105 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YMacro.cc
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+
+#include "YMacro.h"
+#include "YMacroRecorder.h"
+#include "YMacroPlayer.h"
+
+
+YMacroRecorder * YMacro::_recorder = 0;
+YMacroPlayer * YMacro::_player = 0;
+
+void YMacro::setRecorder( YMacroRecorder * recorder )
+{
+ if ( _recorder )
+ delete _recorder;
+
+ _recorder = recorder;
+}
+
+
+void YMacro::setPlayer( YMacroPlayer * player )
+{
+ if ( _player )
+ delete _player;
+
+ _player = player;
+}
+
+
+void YMacro::record( const string & macroFile )
+{
+ if ( _recorder )
+ _recorder->record( macroFile );
+}
+
+
+void YMacro::endRecording()
+{
+ if ( _recorder )
+ _recorder->endRecording();
+}
+
+
+bool YMacro::recording()
+{
+ if ( _recorder )
+ return _recorder->recording();
+ else
+ return false;
+}
+
+
+void YMacro::play( const string & macroFile )
+{
+ if ( _player )
+ _player->play( macroFile );
+}
+
+
+void YMacro::playNextBlock()
+{
+ if ( _player && _player->playing() )
+ _player->playNextBlock();
+}
+
+
+bool YMacro::playing()
+{
+ if ( _player )
+ return _player->playing();
+ else
+ return false;
+}
+
+
+void YMacro::deleteRecorder()
+{
+ if ( _recorder )
+ delete _recorder;
+}
+
+
+void YMacro::deletePlayer()
+{
+ if ( _player )
+ delete _player;
+}
+
+
Added: trunk/core/libyui/src/YMacro.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YMacro.h?rev=44192&view=auto
==============================================================================
--- trunk/core/libyui/src/YMacro.h (added)
+++ trunk/core/libyui/src/YMacro.h Wed Feb 6 14:20:49 2008
@@ -0,0 +1,121 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YMacro.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YMacro_h
+#define YMacro_h
+
+#include <string>
+
+class YMacroRecorder;
+class YMacroPlayer;
+using std::string;
+
+
+/**
+ * Simple access to macro recording and playing.
+ *
+ * This class stores an instance of a macro recorder and a macro player.
+ * Since both YMacroRecorder and YMacroPlayer are abstract base classes,
+ * derived classes from either of them have to be instantiated and set
+ * (setRecorder(), setPlayer()) from the outside for anything to happen. Until
+ * that point, none of the macro operations here do anything (but also don't
+ * throw any error or exception).
+ **/
+class YMacro
+{
+private:
+ YMacro() {}
+ ~YMacro() {}
+
+public:
+
+ /**
+ * Set a macro recorder.
+ *
+ * This needs to be done from the outside since YMacroRecorder is an
+ * abstract base class, i.e., it needs to be derived to be instantiated.
+ **/
+ static void setRecorder( YMacroRecorder * recorder );
+
+ /**
+ * Set a macro player.
+ *
+ * This needs to be done from the outside since YMacroRecorder is an
+ * abstract base class, i.e., it needs to be derived to be instantiated.
+ **/
+ static void setPlayer( YMacroPlayer * player );
+
+ /**
+ * Record a macro to the specified macro file.
+ **/
+ static void record( const string & macroFile );
+
+ /**
+ * End macro recording.
+ **/
+ static void endRecording();
+
+ /**
+ * Return 'true' if a macro is currently being recorded.
+ **/
+ static bool recording();
+
+ /**
+ * Play a macro from the specified macro file.
+ **/
+ static void play( const string & macroFile );
+
+ /**
+ * Play the next block from the current macro, if there is one playing.
+ **/
+ static void playNextBlock();
+
+ /**
+ * Return 'true' if a macro is currently being played.
+ **/
+ static bool playing();
+
+ /**
+ * Return the current macro recorder or 0 if there is none.
+ **/
+ static YMacroRecorder * recorder() { return _recorder; }
+
+ /**
+ * Return the current macro player or 0 if there is none.
+ **/
+ static YMacroPlayer * player() { return _player; }
+
+ /**
+ * Delete the current macro recorder if there is one.
+ **/
+ static void deleteRecorder();
+
+ /**
+ * Delete the current macro player if there is one.
+ **/
+ static void deletePlayer();
+
+private:
+
+ static YMacroRecorder * _recorder;
+ static YMacroPlayer * _player;
+};
+
+
+
+#endif // YMacro_h
Modified: trunk/core/libyui/src/YMacroPlayer.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YMacroPlayer.h?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YMacroPlayer.h (original)
+++ trunk/core/libyui/src/YMacroPlayer.h Wed Feb 6 14:20:49 2008
@@ -23,21 +23,39 @@
/**
* Abstract base class for macro player.
+ *
+ * Applications should not use this directly, but the static methods in YMacro.
**/
class YMacroPlayer
{
+ friend class YMacro;
+
protected:
/**
* Constructor
**/
- YMacroPlayer( const string & macroFileName );
+ YMacroPlayer() {}
public:
/**
* Destructor
**/
- virtual ~YMacroPlayer();
+ virtual ~YMacroPlayer() {}
+ /**
+ * Play a macro from the specified macro file.
+ **/
+ virtual void play( const string & macroFile ) = 0;
+
+ /**
+ * Play the next block from the current macro, if there is one playing.
+ **/
+ virtual void playNextBlock() = 0;
+
+ /**
+ * Return 'true' if a macro is currently being played.
+ **/
+ virtual bool playing() const = 0;
};
#endif // YMacroPlayer_h
Modified: trunk/core/libyui/src/YMacroRecorder.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YMacroRecorder.h?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YMacroRecorder.h (original)
+++ trunk/core/libyui/src/YMacroRecorder.h Wed Feb 6 14:20:49 2008
@@ -23,24 +23,43 @@
class YWidget;
+
/**
* Abstract base class for macro recorders.
+ *
+ * Applications should not use this directly, but the static methods in YMacro.
**/
class YMacroRecorder
{
-protected:
+ friend class YMacro;
+
+protected:
/**
* Constructor
**/
- YMacroRecorder( const string & macroFileName );
+ YMacroRecorder() {}
public:
-
/**
* Destructor
**/
- virtual ~YMacroRecorder();
+ virtual ~YMacroRecorder() {}
+
+ /**
+ * Start recording a macro to the specified file.
+ **/
+ virtual void record( const string & macroFileName ) = 0;
+
+ /**
+ * End recording and close the current macro file (if there is any).
+ **/
+ virtual void endRecording() = 0;
+
+ /**
+ * Return 'true' if a macro is currently being recorded.
+ **/
+ virtual bool recording() const = 0;
/**
* Record one widget property.
@@ -53,7 +72,7 @@
*
* If 'enabled' is 'false', this statement will be commented out.
* If no file name is given, a default file name (with auto-increment) will
- * be used.
+ * be used.
**/
virtual void recordMakeScreenShot( bool enabled = false,
const string & filename = string() ) = 0;
Modified: trunk/core/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YUI.h?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YUI.h (original)
+++ trunk/core/libyui/src/YUI.h Wed Feb 6 14:20:49 2008
@@ -431,35 +431,32 @@
**/
YCPValue evaluateLocale( const YCPLocale & );
- /**
- * Start macro recording to file "filename".
- * Any previous active macro recorder will be terminated (regularly) prior
- * to this.
- **/
- virtual void recordMacro( string filename );
+
+#if 0
+ //
+ // Macro recording and playing
+ //
/**
- * Stop macro recording if this is in progress.
- * Nothing happens when no macro recording is in progress.
+ * Return whether macro recording is in progress or not.
**/
- virtual void stopRecordMacro();
+ bool recordingMacro() const { return _macroRecorder != 0; }
/**
- * Play macro in file "filename".
- * Any previous macro execution will be terminated prior to this.
+ * Return whether macro playing is in progress or not.
**/
- virtual void playMacro( string filename );
+ bool playingMacro() const { return _macroPlayer != 0; }
/**
- * Return whether macro recording is in progress or not
+ * Set the internal macro recorder and delete any previous one.
**/
- bool recordingMacro() const { return _macroRecorder != 0; }
+ void setMacroRecorder( YMacroRecorder * recorder );
/**
- * Return whether macro playing is in progress or not
+ * Set the internal macro player and delete any previous one.
**/
- bool playingMacro() const { return _macroPlayer != 0; }
-
+ void setMacroPlayer( YMacroPlayer * player );
+
/**
* Return the macro recorder if it is active (recording)
* or 0 if it is not.
@@ -472,6 +469,41 @@
**/
YMacroPlayer * macroPlayer() const { return _macroPlayer; }
+ /**
+ * Delete the internal macro recorder and set the pointer to 0.
+ **/
+ void deleteMacroRecorder();
+
+ /**
+ * Delete the internal macro player and set the pointer to 0.
+ **/
+ void deleteMacroPlayer();
+
+ /**
+ * Start macro recording to file "filename".
+ * Any previously active macro recording will be terminated (regularly)
+ * prior to this.
+ **/
+ void recordMacro( string filename );
+
+ /**
+ * Stop macro recording if this is in progress.
+ * Nothing happens when no macro recording is in progress.
+ **/
+ void stopRecordMacro();
+
+ /**
+ * Play macro in file "filename".
+ * Any previous macro execution will be terminated prior to this.
+ **/
+ void playMacro( string filename );
+
+ /**
+ * Play the next block of an active macro player.
+ **/
+ void playNextMacroBlock();
+#endif
+
protected:
/**
@@ -541,31 +573,6 @@
YCPValue evaluateCallback( const YCPTerm & term, bool to_wfm );
/**
- * Set the internal macro recorder and delete any previous one.
- **/
- void setMacroRecorder( YMacroRecorder * recorder );
-
- /**
- * Set the internal macro player and delete any previous one.
- **/
- void setMacroPlayer( YMacroPlayer * player );
-
- /**
- * Delete the internal macro recorder and set the pointer to 0.
- **/
- void deleteMacroRecorder();
-
- /**
- * Delete the internal macro player and set the pointer to 0.
- **/
- void deleteMacroPlayer();
-
- /**
- * Play the next block of an active macro player.
- **/
- void playNextMacroBlock();
-
- /**
* Check if debug logging is enabled.
**/
bool debugLoggingEnabled() const;
Modified: trunk/core/libyui/src/YUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YUI_builtins.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YUI_builtins.cc (original)
+++ trunk/core/libyui/src/YUI_builtins.cc Wed Feb 6 14:20:49 2008
@@ -50,6 +50,7 @@
#include "YUIException.h"
#include "YUISymbols.h"
#include "YDialog.h"
+#include "YMacro.h"
#include "YCPMacroRecorder.h"
#include "YCPMacroPlayer.h"
#include "YReplacePoint.h"
@@ -580,18 +581,18 @@
// Handle macro recording
- if ( recordingMacro() )
+ if ( YMacro::recording() )
{
- YCPMacroRecorder * recorder = dynamic_cast ( macroRecorder() );
+ YCPMacroRecorder * macroRecorder = dynamic_cast ( YMacro::recorder() );
- if ( recorder )
+ if ( macroRecorder )
{
if ( ! input->isVoid() || wait ) // Don't record empty PollInput() calls
{
- recorder->beginBlock();
- dialog->saveUserInput( _macroRecorder );
- recorder->recordUserInput( input );
- recorder->endBlock();
+ macroRecorder->beginBlock();
+ dialog->saveUserInput( macroRecorder );
+ macroRecorder->recordUserInput( input );
+ macroRecorder->endBlock();
}
}
}
@@ -1164,31 +1165,9 @@
*/
void YUI::evaluateRecordMacro( const YCPString & filename )
{
- recordMacro( filename->value () );
+ YMacro::record( filename->value () );
}
-
-void YUI::recordMacro( string filename )
-{
- YCPMacroRecorder * recorder = new YCPMacroRecorder( filename );
- setMacroRecorder( recorder );
-}
-
-
-void YUI::setMacroRecorder( YMacroRecorder * recorder )
-{
- if ( _macroRecorder )
- delete _macroRecorder;
-
- _macroRecorder = recorder;
-}
-
-
-void YUI::deleteMacroRecorder()
-{
- setMacroRecorder( 0 );
-}
-
/**
@@ -1202,17 +1181,10 @@
*/
void YUI::evaluateStopRecordMacro()
{
- stopRecordMacro();
+ YMacro::endRecording();
}
-void YUI::stopRecordMacro()
-{
- deleteMacroRecorder();
-}
-
-
-
/**
* @builtin PlayMacro
* @short Plays a recorded macro
@@ -1226,63 +1198,7 @@
*/
void YUI::evaluatePlayMacro( const YCPString & filename )
{
- playMacro( filename->value() );
-}
-
-
-void YUI::playMacro( string filename )
-{
- YCPMacroPlayer * player = new YCPMacroPlayer( filename );
- setMacroPlayer( player );
-}
-
-
-void YUI::playNextMacroBlock()
-{
- YCPMacroPlayer * player = 0;
-
- if ( macroPlayer() )
- player = dynamic_cast ( macroPlayer() );
-
- if ( ! player )
- {
- yuiError() << "No macro player active." << endl;
- return;
- }
-
-
- if ( player->error() || player->finished() )
- {
- deleteMacroPlayer();
- }
- else
- {
- if ( ! player->finished() )
- {
- YCPValue result = player->evaluateNextBlock();
-
- if ( player->error() || result.isNull() )
- {
- yuiError() << "Macro aborted" << endl;
- deleteMacroPlayer();
- }
- }
- }
-}
-
-
-void YUI::setMacroPlayer( YMacroPlayer * player )
-{
- if ( _macroPlayer )
- delete _macroPlayer;
-
- _macroPlayer = player;
-}
-
-
-void YUI::deleteMacroPlayer()
-{
- setMacroPlayer( 0 );
+ YMacro::play( filename->value() );
}
Modified: trunk/core/libyui/src/YUI_core.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libyui/src/YUI_core.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/libyui/src/YUI_core.cc (original)
+++ trunk/core/libyui/src/YUI_core.cc Wed Feb 6 14:20:49 2008
@@ -43,6 +43,11 @@
#include "YWidget.h"
#include "YDialog.h"
#include "YApplication.h"
+#include "YMacro.h"
+
+// FIXME: Move this to YCP-specific part
+#include "YCPMacroRecorder.h"
+#include "YCPMacroPlayer.h"
typedef YCPValue (*v2) ();
@@ -79,7 +84,12 @@
, _callback( 0 )
{
_yui = this;
+
+ // FIXME: Move this to YCP-specific part
YUILog::setLoggerFunction( yui_y2logger );
+
+ YMacro::setRecorder( new YCPMacroRecorder() );
+ YMacro::setPlayer ( new YCPMacroPlayer() );
}
@@ -97,8 +107,8 @@
YDialog::deleteAllDialogs();
- deleteMacroRecorder();
- deleteMacroPlayer();
+ YMacro::deleteRecorder();
+ YMacro::deletePlayer();
}
Modified: trunk/core/package/yast2-core.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/core/package/yast2-core.changes (original)
+++ trunk/core/package/yast2-core.changes Wed Feb 6 14:20:49 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Feb 6 14:19:47 CET 2008 - sh@suse.de
+
+- Moved macro recording and playing out of YUI class into new
+ YMacro class with static functions
+- V 2.16.29
+
+-------------------------------------------------------------------
Fri Feb 1 14:48:52 CET 2008 - sh@suse.de
- Moved UI event handling from YUI to YDialog
Modified: trunk/ncurses/src/YNCursesUI.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/YNCursesUI.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/ncurses/src/YNCursesUI.cc (original)
+++ trunk/ncurses/src/YNCursesUI.cc Wed Feb 6 14:20:49 2008
@@ -26,6 +26,7 @@
#include "Y2Log.h"
#include
#include "YDialog.h"
+#include "YMacro.h"
#include
#include
@@ -80,7 +81,7 @@
}
if ( macro_file )
- playMacro( macro_file );
+ YMacro::play( macro_file );
topmostConstructorHasFinished();
}
Modified: trunk/ncurses/yast2-ncurses.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/yast2-ncurses.spec.in?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/ncurses/yast2-ncurses.spec.in (original)
+++ trunk/ncurses/yast2-ncurses.spec.in Wed Feb 6 14:20:49 2008
@@ -17,8 +17,8 @@
Provides: y2curses
Obsoletes: y2curses
Requires: glibc-locale
-BuildRequires: yast2-core-devel >= 2.16.28
-Requires: yast2-core >= 2.16.28
+BuildRequires: yast2-core-devel >= 2.16.29
+Requires: yast2-core >= 2.16.29
#adapted to libzypp 3.11 refactoring
Requires: libzypp >= 3.11.8
%description
Modified: trunk/qt/src/YQUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_builtins.cc?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/qt/src/YQUI_builtins.cc (original)
+++ trunk/qt/src/YQUI_builtins.cc Wed Feb 6 14:20:49 2008
@@ -37,7 +37,7 @@
#include "YQUI.h"
#include "YEvent.h"
-#include "YMacroRecorder.h"
+#include "YMacro.h"
#include "YUISymbols.h"
#include "YQDialog.h"
#include "YQSignalBlocker.h"
@@ -191,14 +191,6 @@
Qt::NoButton ); // button2
}
}
-
- if ( recordingMacro() )
- {
- macroRecorder()->beginBlock();
- YDialog::currentDialog()->saveUserInput( macroRecorder() );
- macroRecorder()->recordMakeScreenShot( true, toUTF8( fileName ) );
- macroRecorder()->endBlock();
- }
}
@@ -280,9 +272,9 @@
void YQUI::toggleRecordMacro()
{
- if ( recordingMacro() )
+ if ( YMacro::recording() )
{
- stopRecordMacro();
+ YMacro::endRecording();
normalCursor();
QMessageBox::information( 0, // parent
@@ -305,7 +297,7 @@
if ( ! filename.isEmpty() ) // file selection dialog has been cancelled
{
- recordMacro( toUTF8( filename ) );
+ YMacro::record( toUTF8( filename ) );
}
}
}
@@ -324,7 +316,7 @@
if ( ! filename.isEmpty() ) // file selection dialog has been cancelled
{
- playMacro( toUTF8( filename ) );
+ YMacro::play( toUTF8( filename ) );
// Do special magic to get out of any UserInput() loop right now
// without doing any harm - otherwise this would hang until the next
Modified: trunk/qt/yast2-qt.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/yast2-qt.spec.in?rev=44192&r1=44191&r2=44192&view=diff
==============================================================================
--- trunk/qt/yast2-qt.spec.in (original)
+++ trunk/qt/yast2-qt.spec.in Wed Feb 6 14:20:49 2008
@@ -6,8 +6,8 @@
Summary: -
BuildRequires: yast2-devtools >= 2.16.3
-BuildRequires: yast2-core-devel >= 2.16.28
-Requires: yast2-core >= 2.16.28
+BuildRequires: yast2-core-devel >= 2.16.29
+Requires: yast2-core >= 2.16.29
Requires: yast2_theme >= 2.16.1
Requires: libzypp >= 3.11.8
Provides: yast2_ui
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org