X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=www%2Fapidoc%2Fhtml%2Furpoprocess_8cpp_source.html;h=5c8ad0e0dc15192d13ba8458ceac7bfe428ec244;hb=b84375f047734ac24c0bd38060d90f50255cdb98;hp=7681447660a7a193322a9ca79309348d40dddb5c;hpb=8f387a02ce4b152215a76ea4619f61e25e88a6d6;p=urpo diff --git a/www/apidoc/html/urpoprocess_8cpp_source.html b/www/apidoc/html/urpoprocess_8cpp_source.html index 7681447..5c8ad0e 100644 --- a/www/apidoc/html/urpoprocess_8cpp_source.html +++ b/www/apidoc/html/urpoprocess_8cpp_source.html @@ -1,38 +1,19 @@ -
-00001 /************************************************************************** +src/urpoprocess.cpp
00001 /************************************************************************** 00002 00003 URPO 00004 @@ -65,127 +46,117 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); 00023 #include "urpoprocess.h" 00024 #include "urpoconnection.h" 00025 #include <QTimer> -00026 -00027 -00028 int const UrpoProcess::DEFAULTTIMEOUT; +00026 #include <QInputDialog> +00027 #include <QLineEdit> +00028 00029 -00030 UrpoProcess::UrpoProcess(QObject* parent) : -00031 QObject(parent) -00032 { -00033 status_ = Ready; -00034 error_ = NoError; -00035 setTimeout( DEFAULTTIMEOUT ); -00036 } -00037 -00038 void UrpoProcess::terminate() -00039 { -00040 fail(Cancelled); -00041 } -00042 -00043 QStringList UrpoProcess::getOutput() -00044 { -00045 return output_; -00046 } -00047 -00048 void UrpoProcess::fail(UrpoError error) -00049 { -00050 status_=Failed; -00051 error_=error; -00052 qprocess_.terminate(); -00053 emit finished(false); -00054 sendDebugMessage( getErrorString() ); -00055 } -00056 -00057 -00058 void UrpoProcess::timeout() -00059 { -00060 // If process is still running, it means timeout! -00061 if( status_ == Running) -00062 fail(Timeout); -00063 } -00064 -00065 void UrpoProcess::start(const QString &command) -00066 { -00067 sendDebugMessage(QString("[Running command %1 ]").arg(command)); -00068 -00069 // Process finished handling -00070 connect( &qprocess_, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus))); -00071 -00072 // Timer for timeout -00073 // use UrpoConnection's default timeout settings -00074 QTimer::singleShot( getTimeout(), this, SLOT(timeout()) ); -00075 -00076 // Start process -00077 status_ = Running; -00078 -00079 qprocess_.start(command); +00030 int const UrpoProcess::DEFAULTTIMEOUT; +00031 +00032 UrpoProcess::UrpoProcess(QObject* parent) : +00033 QObject(parent) +00034 { +00035 status_ = Ready; +00036 error_ = NoError; +00037 setTimeout( DEFAULTTIMEOUT ); +00038 } +00039 +00040 void UrpoProcess::terminate() +00041 { +00042 fail(Cancelled); +00043 } +00044 +00045 QStringList UrpoProcess::getOutput() +00046 { +00047 return output_; +00048 } +00049 +00050 void UrpoProcess::fail(UrpoError error) +00051 { +00052 status_=Failed; +00053 error_=error; +00054 qprocess_.terminate(); +00055 emit finished(false); +00056 sendDebugMessage( getErrorString() ); +00057 } +00058 +00059 +00060 void UrpoProcess::timeout() +00061 { +00062 // If process is still running, it means timeout! +00063 if( status_ == Running) +00064 fail(Timeout); // FAILS !!! +00065 } +00066 +00067 void UrpoProcess::start(const QString &command) +00068 { +00069 sendDebugMessage(QString("[Running command %1 ]").arg(command)); +00070 +00071 // Process finished handling +00072 connect( &qprocess_, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus))); +00073 +00074 // Timer for timeout +00075 // use UrpoConnection's default timeout settings +00076 QTimer::singleShot( getTimeout(), this, SLOT(timeout()) ); +00077 +00078 // Start process +00079 status_ = Running; 00080 -00081 } +00081 qprocess_.start(command); 00082 -00083 void UrpoProcess::processFinished(int exitCode,QProcess::ExitStatus exitStatus) -00084 { -00085 if( exitCode) -00086 { -00087 sendDebugMessage( QString( tr("Process exited with code %1") ).arg(exitCode)); -00088 // Get data from ssh server -00089 QByteArray newData = qprocess_.readAllStandardError(); -00090 sendDebugMessage( QString(newData) ); -00091 -00092 fail(ConnectionError); -00093 } -00094 else if( exitStatus == QProcess::CrashExit) -00095 // Process failed -00096 fail(ProcessError); -00097 else -00098 { -00099 // Read output -00100 QByteArray bytes = qprocess_.readAllStandardOutput(); -00101 QString string(bytes); -00102 sendDebugMessage(string); -00103 // Split to lines and store to output_ -00104 output_=string.split("\n"); -00105 status_=Successed; -00106 emit finished(true); -00107 } -00108 } +00083 } +00084 +00085 void UrpoProcess::processFinished(int exitCode,QProcess::ExitStatus exitStatus) +00086 { +00087 if( exitCode) +00088 { +00089 sendDebugMessage( QString( tr("Process exited with code %1") ).arg(exitCode)); +00090 // Get data from ssh server +00091 QByteArray newData = qprocess_.readAllStandardError(); +00092 sendDebugMessage( QString(newData) ); +00093 +00094 fail(ConnectionError); +00095 } +00096 else if( exitStatus == QProcess::CrashExit) +00097 // Process failed +00098 fail(ProcessError); +00099 else +00100 { +00101 // Read output +00102 QByteArray bytes = qprocess_.readAllStandardOutput(); +00103 QString string(bytes); +00104 sendDebugMessage(string); +00105 // Split to lines and store to output_ +00106 output_=string.split("\n"); +00107 status_=Successed; +00108 emit finished(true); 00109 -00110 QString UrpoProcess::getErrorString() const -00111 { -00112 switch( getError() ) -00113 { -00114 case NoError: -00115 return QString(); -00116 case ProcessError: -00117 return tr("External program calling error"); -00118 case ConnectionError: -00119 return tr("Connection error"); -00120 case AuthError: -00121 return tr("Authentication error"); -00122 case Timeout: -00123 return tr("Time out"); -00124 case Cancelled: -00125 return tr("User cancelled"); -00126 } -00127 return QString(); -00128 } -00129 -00130 +00110 +00111 } +00112 } +00113 +00114 QString UrpoProcess::getErrorString() const +00115 { +00116 switch( getError() ) +00117 { +00118 case NoError: +00119 return QString(); +00120 case ProcessError: +00121 return tr("External program calling error"); +00122 case ConnectionError: +00123 return tr("Connection error"); +00124 case AuthError: +00125 return tr("Authentication error"); +00126 case Timeout: +00127 return tr("Time out"); +00128 case Cancelled: +00129 return tr("User cancelled"); +00130 } +00131 return QString(); +00132 } +00133 +00134