mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-01 18:01:06 +02:00
COPKGManager: add member to handle line of shell lines
prepared for use as callback in shell window class, currently
it is not possible to get line output from shellwindow object, this
should help soon
also added ne locales
Origin commit data
------------------
Commit: 4909844ad6
Author: Thilo Graf <dbt@novatux.de>
Date: 2014-12-10 (Wed, 10 Dec 2014)
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
#include <errno.h>
|
||||
#include <system/debug.h>
|
||||
|
||||
CShellWindow::CShellWindow(const std::string &Command, const int Mode, int *Res)
|
||||
CShellWindow::CShellWindow(const std::string &Command, const int Mode, int *Res, bool auto_exec)
|
||||
{
|
||||
textBox = NULL;
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
@@ -55,7 +55,8 @@ CShellWindow::CShellWindow(const std::string &Command, const int Mode, int *Res)
|
||||
mode = Mode;
|
||||
res = Res;
|
||||
|
||||
exec();
|
||||
if (auto_exec)
|
||||
exec();
|
||||
}
|
||||
|
||||
void CShellWindow::exec()
|
||||
@@ -152,6 +153,10 @@ void CShellWindow::exec()
|
||||
lines.push_back(line);
|
||||
incomplete = true;
|
||||
}
|
||||
|
||||
//callback for line handler
|
||||
std::string s_output = std::string((output));
|
||||
OnShellOutputLoop(s_output);
|
||||
if (lines.size() > lines_max)
|
||||
lines.pop_front();
|
||||
txt = "";
|
||||
|
@@ -32,9 +32,18 @@
|
||||
|
||||
#include <string>
|
||||
#include <gui/widget/textbox.h>
|
||||
#include <sigc++/signal.h>
|
||||
|
||||
class CShellWindow
|
||||
class CShellWindow : public sigc::trackable
|
||||
{
|
||||
private:
|
||||
int mode;
|
||||
std::string command;
|
||||
int* res;
|
||||
CFrameBuffer *frameBuffer;
|
||||
CTextBox *textBox;
|
||||
void showResult();
|
||||
|
||||
public:
|
||||
enum shellwindow_modes
|
||||
{
|
||||
@@ -42,16 +51,35 @@ class CShellWindow
|
||||
ACKNOWLEDGE = 2,
|
||||
ACKNOWLEDGE_MSG = 4
|
||||
};
|
||||
CShellWindow(const std::string &Command, const int Mode = 0, int* Res = NULL);
|
||||
CShellWindow(const std::string &Command, const int Mode = 0, int* Res = NULL, bool auto_exec = true);
|
||||
~CShellWindow();
|
||||
private:
|
||||
int mode;
|
||||
std::string command;
|
||||
int* res;
|
||||
CFrameBuffer *frameBuffer;
|
||||
CTextBox *textBox;
|
||||
void exec();
|
||||
void showResult();
|
||||
|
||||
/*!
|
||||
signal/event handler runs on loop in exec method
|
||||
this allows to use the shell output lines in other objects eg. for evaluation of error or status data
|
||||
example for implamentation in your class:
|
||||
...your code...
|
||||
//assuming in your class is declared a member function named YourMemberFunction(std::string& arg), parameter is a string as rev:
|
||||
//Tis function should handle the shell output!
|
||||
|
||||
//declare a slot with return value as 'void' and parameter as 'string', here by rev!
|
||||
sigc::slot1<void, string&> sl;
|
||||
|
||||
//fill the slot with your member function in your class that do evaluate the output lines
|
||||
sl = sigc::mem_fun(*this, &CYourClass::YourMemberFunction);
|
||||
|
||||
//create the CShellWindow object in verbose mode, important: parameter 'auto_exec' must be set to 'false', so it is possible to connect the slot before engages the exec() methode
|
||||
CShellWindow shell(cmd, (verbose ? CShellWindow::VERBOSE : 0) | (acknowledge ? CShellWindow::ACKNOWLEDGE_MSG : 0), &res, false);
|
||||
|
||||
//connect slot
|
||||
shell.OnShellOutputLoop.connect(sl);
|
||||
|
||||
//now exec...
|
||||
shell.exec();
|
||||
...other code...
|
||||
*/
|
||||
sigc::signal<void, std::string&> OnShellOutputLoop;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user