From d6f3812c8d969a673b420beca2482804177704fb Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 24 Jan 2013 14:05:19 -0600 Subject: Rename KGlobal, KProcess, and KClipboard to avoid conflicts with KDE4 --- lskat/lskat/KProcessConnect.cpp | 192 -------------------------------------- lskat/lskat/KProcessConnect.h | 58 ------------ lskat/lskat/TDEProcessConnect.cpp | 192 ++++++++++++++++++++++++++++++++++++++ lskat/lskat/TDEProcessConnect.h | 58 ++++++++++++ 4 files changed, 250 insertions(+), 250 deletions(-) delete mode 100644 lskat/lskat/KProcessConnect.cpp delete mode 100644 lskat/lskat/KProcessConnect.h create mode 100644 lskat/lskat/TDEProcessConnect.cpp create mode 100644 lskat/lskat/TDEProcessConnect.h (limited to 'lskat') diff --git a/lskat/lskat/KProcessConnect.cpp b/lskat/lskat/KProcessConnect.cpp deleted file mode 100644 index b2038b4f..00000000 --- a/lskat/lskat/KProcessConnect.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/*************************************************************************** - TDEProcessConnect.cpp - description - ------------------- - begin : Tue May 2 2000 - copyright : (C) 2000 by Martin Heni - email : martin@heni-online.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/*************************************************************************** - FILENAME| - description - ------------------- - begin : Tue Apr 4 2000 - copyright : (C) |1995-2000 by Martin Heni - email : martin@heni-online.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#include -#include "TDEProcessConnect.h" - -#include "TDEProcessConnect.moc" - -TDEProcessConnect::TDEProcessConnect() - : KChildConnect() -{ - running=false; - process=0; -} - -TDEProcessConnect::~TDEProcessConnect() -{ - Exit(); - delete process; -// printf("DESTRUCTRING KPROCESSCONNECT\n"); -} - -bool TDEProcessConnect::Init(int id,KEMessage *msg) -{ - int size; - char *p; - - SetID(id); - if (msg) - { - if (!msg->GetData(TQCString("ProcessName"),p,size)) return false; // no process name - processname=p; - /* - printf("Found processname '%s' size %d size=%u\n", - p,size,msg->QueryNumberOfKeys()); - */ - msg->Remove(TQCString("ProcessName")); - } - if (processname.length()<1) return false; - - inputbuffer=""; - - // Delete first on multiple init - if (running) Exit(); - - // create process - process=new TDEProcess; - *process << processname; - connect(process, TQT_SIGNAL(receivedStdout(TDEProcess *, char *, int )), - this, TQT_SLOT(slotReceivedStdout(TDEProcess *, char * , int ))); - connect(process, TQT_SIGNAL(processExited(TDEProcess *)), - this, TQT_SLOT(slotProcessExited(TDEProcess *))); - /* - connect(process, TQT_SIGNAL(wroteStdin(TDEProcess *)), - this, TQT_SLOT(slotWroteStdin(TDEProcess *))); - */ - - // TRUE if ok - running=process->start(TDEProcess::NotifyOnExit,TDEProcess::All); - - if (running && msg && msg->QueryNumberOfKeys()>0) - { - SendMsg(msg); - } - - return running; -} - -void TDEProcessConnect::slotReceivedStdout(TDEProcess *, char *buffer, int buflen) -{ - TQString s; - char c; - int pos; - - if (buflen<1) return ; - if (buffer[buflen-1]!=0) // shit..we got a not null terminated string - { - c=buffer[buflen-1]; - buffer[buflen-1]=0; - s=buffer; - s+=c; - } - else - { - s=buffer; - } - // Append old unresolved input - s=inputbuffer+s; - pos=s.findRev(KEMESSAGE_CR); - // printf("String '%s' pos=%d len=%d\n",(const char *)s,pos,s.length()); - if (pos<0) - { - inputbuffer=s; - } - else if (pos+KEMESSAGE_CR.length()==s.length()) - { - // CR at the end...calling receive - Receive(s); - } - else - { - inputbuffer=s.right(s.length()-pos-KEMESSAGE_CR.length()); - s=s.left(pos+KEMESSAGE_CR.length()); - // printf("s='%s' in='%s'\n",(const char *)s,(const char *)inputbuffer); - Receive(s); - } -} -void TDEProcessConnect::slotProcessExited(TDEProcess *) -{ - running=false; - delete process; - process=0; - Init(QueryID()); -} -void TDEProcessConnect::slotWroteStdin(TDEProcess *) -{ - printf("slotWroteStdin:: IS NEVER CALLED\n"); -} - -bool TDEProcessConnect::Exit() -{ - // kill process if running - if (running) - { - running=false; - if (process) process->kill(); - delete process; - process=0; - } - return true; -} - -bool TDEProcessConnect::Next() -{ - bool result; - if (!running) return false; - // create and send message - // printf("+- TDEProcessConnect::ProcessNext\n"); - KEMessage *msg=new KEMessage; - // User fills message - emit signalPrepareMove(msg,KG_INPUTTYPE_PROCESS); - result=SendMsg(msg); - delete msg; - return result; -} - -// Send string to child -bool TDEProcessConnect::Send(TQString str) -{ - bool result; - // printf("****** PROCESS:SEND\n"); - if (!running || !process) return false; - if (!str || str.length()<1) return true; // no need to send crap - // TODO ..why? - TQString s; - s=KEMESSAGE_CR+KEMESSAGE_CR; - str=s+str; - // printf("+++ Sending to child '%s'!!!\n",(const char *)str); - result=process->writeStdin(str.latin1(),str.length()+1); - if (!result) printf("ERROR in PROCESS SEND\n"); - return result; -} - diff --git a/lskat/lskat/KProcessConnect.h b/lskat/lskat/KProcessConnect.h deleted file mode 100644 index 3a38e23b..00000000 --- a/lskat/lskat/KProcessConnect.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - TDEProcessConnect.h - description - ------------------- - begin : Tue May 2 2000 - copyright : (C) 2000 by Martin Heni - email : martin@heni-online.de - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifndef _KPROCESSCONNECT_H_ -#define _KPROCESSCONNECT_H_ - -#include -//#include -// #include "KEInput.h" -#include "KEMessage.h" -#include "KChildConnect.h" - - -class TDEProcessConnect: public KChildConnect -{ - Q_OBJECT - - - private: - TDEProcess *process; - TQString processname; - bool running; - - public: - TDEProcessConnect(); - ~TDEProcessConnect(); - bool Init(int id=0,KEMessage *msg=0); - bool Exit(); - bool Next(); - // bool SendMsg(KEMessage *msg); - virtual bool Send(TQString str); - // void Receive(TQString input); - - public slots: - void slotReceivedStdout(TDEProcess *proc, char *buffer, int buflen); - void slotProcessExited(TDEProcess *p); - void slotWroteStdin(TDEProcess *p); - - - signals: - void signalPrepareMove(KEMessage *msg,KG_INPUTTYPE type); -// void signalReceiveMsg(KEMessage *msg); -}; - -#endif diff --git a/lskat/lskat/TDEProcessConnect.cpp b/lskat/lskat/TDEProcessConnect.cpp new file mode 100644 index 00000000..b2038b4f --- /dev/null +++ b/lskat/lskat/TDEProcessConnect.cpp @@ -0,0 +1,192 @@ +/*************************************************************************** + TDEProcessConnect.cpp - description + ------------------- + begin : Tue May 2 2000 + copyright : (C) 2000 by Martin Heni + email : martin@heni-online.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/*************************************************************************** + FILENAME| - description + ------------------- + begin : Tue Apr 4 2000 + copyright : (C) |1995-2000 by Martin Heni + email : martin@heni-online.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include +#include "TDEProcessConnect.h" + +#include "TDEProcessConnect.moc" + +TDEProcessConnect::TDEProcessConnect() + : KChildConnect() +{ + running=false; + process=0; +} + +TDEProcessConnect::~TDEProcessConnect() +{ + Exit(); + delete process; +// printf("DESTRUCTRING KPROCESSCONNECT\n"); +} + +bool TDEProcessConnect::Init(int id,KEMessage *msg) +{ + int size; + char *p; + + SetID(id); + if (msg) + { + if (!msg->GetData(TQCString("ProcessName"),p,size)) return false; // no process name + processname=p; + /* + printf("Found processname '%s' size %d size=%u\n", + p,size,msg->QueryNumberOfKeys()); + */ + msg->Remove(TQCString("ProcessName")); + } + if (processname.length()<1) return false; + + inputbuffer=""; + + // Delete first on multiple init + if (running) Exit(); + + // create process + process=new TDEProcess; + *process << processname; + connect(process, TQT_SIGNAL(receivedStdout(TDEProcess *, char *, int )), + this, TQT_SLOT(slotReceivedStdout(TDEProcess *, char * , int ))); + connect(process, TQT_SIGNAL(processExited(TDEProcess *)), + this, TQT_SLOT(slotProcessExited(TDEProcess *))); + /* + connect(process, TQT_SIGNAL(wroteStdin(TDEProcess *)), + this, TQT_SLOT(slotWroteStdin(TDEProcess *))); + */ + + // TRUE if ok + running=process->start(TDEProcess::NotifyOnExit,TDEProcess::All); + + if (running && msg && msg->QueryNumberOfKeys()>0) + { + SendMsg(msg); + } + + return running; +} + +void TDEProcessConnect::slotReceivedStdout(TDEProcess *, char *buffer, int buflen) +{ + TQString s; + char c; + int pos; + + if (buflen<1) return ; + if (buffer[buflen-1]!=0) // shit..we got a not null terminated string + { + c=buffer[buflen-1]; + buffer[buflen-1]=0; + s=buffer; + s+=c; + } + else + { + s=buffer; + } + // Append old unresolved input + s=inputbuffer+s; + pos=s.findRev(KEMESSAGE_CR); + // printf("String '%s' pos=%d len=%d\n",(const char *)s,pos,s.length()); + if (pos<0) + { + inputbuffer=s; + } + else if (pos+KEMESSAGE_CR.length()==s.length()) + { + // CR at the end...calling receive + Receive(s); + } + else + { + inputbuffer=s.right(s.length()-pos-KEMESSAGE_CR.length()); + s=s.left(pos+KEMESSAGE_CR.length()); + // printf("s='%s' in='%s'\n",(const char *)s,(const char *)inputbuffer); + Receive(s); + } +} +void TDEProcessConnect::slotProcessExited(TDEProcess *) +{ + running=false; + delete process; + process=0; + Init(QueryID()); +} +void TDEProcessConnect::slotWroteStdin(TDEProcess *) +{ + printf("slotWroteStdin:: IS NEVER CALLED\n"); +} + +bool TDEProcessConnect::Exit() +{ + // kill process if running + if (running) + { + running=false; + if (process) process->kill(); + delete process; + process=0; + } + return true; +} + +bool TDEProcessConnect::Next() +{ + bool result; + if (!running) return false; + // create and send message + // printf("+- TDEProcessConnect::ProcessNext\n"); + KEMessage *msg=new KEMessage; + // User fills message + emit signalPrepareMove(msg,KG_INPUTTYPE_PROCESS); + result=SendMsg(msg); + delete msg; + return result; +} + +// Send string to child +bool TDEProcessConnect::Send(TQString str) +{ + bool result; + // printf("****** PROCESS:SEND\n"); + if (!running || !process) return false; + if (!str || str.length()<1) return true; // no need to send crap + // TODO ..why? + TQString s; + s=KEMESSAGE_CR+KEMESSAGE_CR; + str=s+str; + // printf("+++ Sending to child '%s'!!!\n",(const char *)str); + result=process->writeStdin(str.latin1(),str.length()+1); + if (!result) printf("ERROR in PROCESS SEND\n"); + return result; +} + diff --git a/lskat/lskat/TDEProcessConnect.h b/lskat/lskat/TDEProcessConnect.h new file mode 100644 index 00000000..3a38e23b --- /dev/null +++ b/lskat/lskat/TDEProcessConnect.h @@ -0,0 +1,58 @@ +/*************************************************************************** + TDEProcessConnect.h - description + ------------------- + begin : Tue May 2 2000 + copyright : (C) 2000 by Martin Heni + email : martin@heni-online.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef _KPROCESSCONNECT_H_ +#define _KPROCESSCONNECT_H_ + +#include +//#include +// #include "KEInput.h" +#include "KEMessage.h" +#include "KChildConnect.h" + + +class TDEProcessConnect: public KChildConnect +{ + Q_OBJECT + + + private: + TDEProcess *process; + TQString processname; + bool running; + + public: + TDEProcessConnect(); + ~TDEProcessConnect(); + bool Init(int id=0,KEMessage *msg=0); + bool Exit(); + bool Next(); + // bool SendMsg(KEMessage *msg); + virtual bool Send(TQString str); + // void Receive(TQString input); + + public slots: + void slotReceivedStdout(TDEProcess *proc, char *buffer, int buflen); + void slotProcessExited(TDEProcess *p); + void slotWroteStdin(TDEProcess *p); + + + signals: + void signalPrepareMove(KEMessage *msg,KG_INPUTTYPE type); +// void signalReceiveMsg(KEMessage *msg); +}; + +#endif -- cgit v1.2.3