mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-06-01 16:42:34 +02:00
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
* Refactored rdclilogedit(1) to use synchronous input.
This commit is contained in:
parent
985eb461f3
commit
fb5010fa98
@ -15356,3 +15356,5 @@
|
||||
* Moved enforcement of user permissions to the
|
||||
'MainObject::DispatchCommand()' method in
|
||||
'utils/rdclilogedit/parser.cpp'.
|
||||
2016-07-21 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored rdclilogedit(1) to use synchronous input.
|
||||
|
@ -94,7 +94,7 @@ void MainObject::ListLogs() const
|
||||
sql=QString("select NAME from LOGS order by NAME");
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
Print(QString().sprintf("%s\n",(const char *)q->value(0).toString()));
|
||||
printf("%s\n",(const char *)q->value(0).toString());
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
@ -127,8 +127,7 @@ void MainObject::Load(const QString &logname)
|
||||
void MainObject::List()
|
||||
{
|
||||
for(int i=0;i<edit_log_event->size();i++) {
|
||||
Print(QString().sprintf("%4d %s\n",i,
|
||||
(const char *)ListLine(edit_log_event,i)));
|
||||
printf("%4d %s\n",i,(const char *)ListLine(edit_log_event,i));
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@ -82,16 +82,17 @@ MainObject::MainObject(QObject *parent)
|
||||
// RIPC Connection
|
||||
//
|
||||
edit_user=NULL;
|
||||
edit_input_notifier=NULL;
|
||||
edit_ripc=new RDRipc(edit_config->stationName());
|
||||
connect(edit_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
|
||||
edit_ripc->
|
||||
connectHost("localhost",RIPCD_TCP_PORT,edit_config->password());
|
||||
edit_ripc->connectHost("localhost",RIPCD_TCP_PORT,edit_config->password());
|
||||
}
|
||||
|
||||
|
||||
void MainObject::userData()
|
||||
{
|
||||
char data[1024];
|
||||
int n;
|
||||
|
||||
//
|
||||
// Get User Context
|
||||
//
|
||||
@ -104,24 +105,8 @@ void MainObject::userData()
|
||||
//
|
||||
// Start up command processor
|
||||
//
|
||||
if(edit_input_notifier==NULL) {
|
||||
int flags=fcntl(0,F_GETFL,NULL);
|
||||
flags|=O_NONBLOCK;
|
||||
fcntl(0,F_SETFL,flags);
|
||||
edit_input_notifier=new QSocketNotifier(0,QSocketNotifier::Read,this);
|
||||
connect(edit_input_notifier,SIGNAL(activated(int)),
|
||||
this,SLOT(inputActivatedData(int)));
|
||||
PrintPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainObject::inputActivatedData(int sock)
|
||||
{
|
||||
char data[1024];
|
||||
int n;
|
||||
|
||||
while((n=read(sock,data,1024))>0) {
|
||||
PrintPrompt();
|
||||
while((n=read(0,data,1024))>0) {
|
||||
for(int i=0;i<n;i++) {
|
||||
switch(0xFF&data[i]) {
|
||||
case 10:
|
||||
@ -137,6 +122,8 @@ void MainObject::inputActivatedData(int sock)
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@ -147,25 +134,17 @@ void MainObject::OverwriteError(const QString &cmd) const
|
||||
}
|
||||
|
||||
|
||||
void MainObject::Print(const QString &str) const
|
||||
{
|
||||
printf("%s",(const char *)str);
|
||||
usleep(100);
|
||||
}
|
||||
|
||||
|
||||
void MainObject::PrintPrompt() const
|
||||
{
|
||||
if(edit_log==NULL) {
|
||||
Print("logedit> ");
|
||||
printf("logedit> ");
|
||||
}
|
||||
else {
|
||||
if(edit_modified) {
|
||||
Print(QString().sprintf("logedit[%s*]> ",
|
||||
(const char *)edit_log->name()));
|
||||
printf("logedit[%s*]> ",(const char *)edit_log->name());
|
||||
}
|
||||
else {
|
||||
Print(QString().sprintf("logedit[%s]> ",(const char *)edit_log->name()));
|
||||
printf("logedit[%s]> ",(const char *)edit_log->name());
|
||||
}
|
||||
}
|
||||
fflush(stdout);
|
||||
|
@ -22,7 +22,6 @@
|
||||
#define RDCLILOGEDIT_H
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qsocketnotifier.h>
|
||||
|
||||
#include <rdairplay_conf.h>
|
||||
#include <rdconfig.h>
|
||||
@ -43,7 +42,6 @@ class MainObject : public QObject
|
||||
|
||||
private slots:
|
||||
void userData();
|
||||
void inputActivatedData(int sock);
|
||||
|
||||
private:
|
||||
void Addcart(int line,unsigned cartnum);
|
||||
@ -64,11 +62,9 @@ class MainObject : public QObject
|
||||
void Settrans(int line,RDLogLine::TransType type);
|
||||
void Unload();
|
||||
void OverwriteError(const QString &cmd) const;
|
||||
void Print(const QString &str) const;
|
||||
void DispatchCommand(QString cmd);
|
||||
QString ListLine(RDLogEvent *evt,int line) const;
|
||||
void PrintPrompt() const;
|
||||
QSocketNotifier *edit_input_notifier;
|
||||
QString edit_accum;
|
||||
bool edit_modified;
|
||||
RDLog *edit_log;
|
||||
|
Loading…
x
Reference in New Issue
Block a user