Diffstat (limited to 'noncore/apps/advancedfm/output.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 6906298..8c585f4 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -1,32 +1,35 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** outputEdit.cpp | 2 | ** outputEdit.cpp |
3 | ** | 3 | ** |
4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> | 4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | #include "output.h" | 6 | #include "output.h" |
7 | 7 | ||
8 | /* OPIE */ | ||
9 | #include <opie2/odebug.h> | ||
8 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/applnk.h> | 11 | #include <qpe/applnk.h> |
12 | using namespace Opie::Core; | ||
10 | 13 | ||
14 | /* QT */ | ||
11 | #include <qfile.h> | 15 | #include <qfile.h> |
12 | #include <qmultilineedit.h> | 16 | #include <qmultilineedit.h> |
13 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
14 | #include <qlayout.h> | 18 | #include <qlayout.h> |
15 | 19 | ||
20 | /* STD */ | ||
16 | #include <errno.h> | 21 | #include <errno.h> |
17 | 22 | ||
18 | /* XPM */ | 23 | /* XPM */ |
19 | using namespace Opie::Core; | ||
20 | using namespace Opie::Core; | ||
21 | static char * filesave_xpm[] = { | 24 | static char * filesave_xpm[] = { |
22 | "16 16 78 1", | 25 | "16 16 78 1", |
23 | " c None", | 26 | " c None", |
24 | ". c #343434", | 27 | ". c #343434", |
25 | "+ c #A0A0A0", | 28 | "+ c #A0A0A0", |
26 | "@ c #565656", | 29 | "@ c #565656", |
27 | "# c #9E9E9E", | 30 | "# c #9E9E9E", |
28 | "$ c #525252", | 31 | "$ c #525252", |
29 | "% c #929292", | 32 | "% c #929292", |
30 | "& c #676767", | 33 | "& c #676767", |
31 | "* c #848484", | 34 | "* c #848484", |
32 | "= c #666666", | 35 | "= c #666666", |
@@ -112,25 +115,25 @@ static char * filesave_xpm[] = { | |||
112 | "CzDEvEv;;DssF$ ", | 115 | "CzDEvEv;;DssF$ ", |
113 | "G.H{E{E{IxsJ$+ ", | 116 | "G.H{E{E{IxsJ$+ ", |
114 | " +...vEKxzLM ", | 117 | " +...vEKxzLM ", |
115 | " +...z]n$ ", | 118 | " +...z]n$ ", |
116 | " +... "}; | 119 | " +... "}; |
117 | 120 | ||
118 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 121 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
119 | : QDialog( parent, name, modal, fl ) | 122 | : QDialog( parent, name, modal, fl ) |
120 | { | 123 | { |
121 | QStringList cmmds; | 124 | QStringList cmmds; |
122 | // cmmds=QStringList::split( " ", commands, false); | 125 | // cmmds=QStringList::split( " ", commands, false); |
123 | cmmds=commands; | 126 | cmmds=commands; |
124 | // qDebug("count %d", cmmds.count()); | 127 | // odebug << "count " << cmmds.count() << "" << oendl; |
125 | if ( !name ) | 128 | if ( !name ) |
126 | setName( tr("Output")); | 129 | setName( tr("Output")); |
127 | resize( 196, 269 ); | 130 | resize( 196, 269 ); |
128 | setCaption( name ); | 131 | setCaption( name ); |
129 | 132 | ||
130 | OutputLayout = new QGridLayout( this ); | 133 | OutputLayout = new QGridLayout( this ); |
131 | OutputLayout->setSpacing( 2); | 134 | OutputLayout->setSpacing( 2); |
132 | OutputLayout->setMargin( 2); | 135 | OutputLayout->setMargin( 2); |
133 | 136 | ||
134 | QPushButton *docButton; | 137 | QPushButton *docButton; |
135 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 138 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
136 | docButton->setFixedSize( QSize( 20, 20 ) ); | 139 | docButton->setFixedSize( QSize( 20, 20 ) ); |
@@ -148,25 +151,25 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name, | |||
148 | 151 | ||
149 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 152 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
150 | this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); | 153 | this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); |
151 | 154 | ||
152 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 155 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
153 | this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); | 156 | this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); |
154 | 157 | ||
155 | // connect( , SIGNAL(received(const QByteArray&)), | 158 | // connect( , SIGNAL(received(const QByteArray&)), |
156 | // this, SLOT(commandStdin(const QByteArray&))); | 159 | // this, SLOT(commandStdin(const QByteArray&))); |
157 | 160 | ||
158 | // * proc << commands.latin1(); | 161 | // * proc << commands.latin1(); |
159 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 162 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
160 | qDebug( "%s", (*it).latin1() ); | 163 | odebug << "" << (*it).latin1() << "" << oendl; |
161 | * proc << (*it).latin1(); | 164 | * proc << (*it).latin1(); |
162 | } | 165 | } |
163 | 166 | ||
164 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 167 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
165 | 168 | ||
166 | OutputEdit->append(tr("Process could not start") ); | 169 | OutputEdit->append(tr("Process could not start") ); |
167 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 170 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
168 | perror("Error: "); | 171 | perror("Error: "); |
169 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); | 172 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); |
170 | OutputEdit->append( errorMsg); | 173 | OutputEdit->append( errorMsg); |
171 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 174 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
172 | } | 175 | } |
@@ -177,67 +180,67 @@ Output::~Output() { | |||
177 | 180 | ||
178 | void Output::saveOutput() { | 181 | void Output::saveOutput() { |
179 | 182 | ||
180 | InputDialog *fileDlg; | 183 | InputDialog *fileDlg; |
181 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); | 184 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); |
182 | fileDlg->exec(); | 185 | fileDlg->exec(); |
183 | if( fileDlg->result() == 1 ) { | 186 | if( fileDlg->result() == 1 ) { |
184 | QString filename = QPEApplication::documentDir(); | 187 | QString filename = QPEApplication::documentDir(); |
185 | if(filename.right(1).find('/') == -1) | 188 | if(filename.right(1).find('/') == -1) |
186 | filename+="/"; | 189 | filename+="/"; |
187 | QString name = fileDlg->LineEdit1->text(); | 190 | QString name = fileDlg->LineEdit1->text(); |
188 | filename+="text/plain/"+name; | 191 | filename+="text/plain/"+name; |
189 | qDebug(filename); | 192 | odebug << filename << oendl; |
190 | 193 | ||
191 | QFile f(filename); | 194 | QFile f(filename); |
192 | f.open( IO_WriteOnly); | 195 | f.open( IO_WriteOnly); |
193 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 196 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
194 | DocLnk lnk; | 197 | DocLnk lnk; |
195 | lnk.setName(name); //sets file name | 198 | lnk.setName(name); //sets file name |
196 | lnk.setFile(filename); //sets File property | 199 | lnk.setFile(filename); //sets File property |
197 | lnk.setType("text/plain"); | 200 | lnk.setType("text/plain"); |
198 | if(!lnk.writeLink()) { | 201 | if(!lnk.writeLink()) { |
199 | qDebug("Writing doclink did not work"); | 202 | odebug << "Writing doclink did not work" << oendl; |
200 | } | 203 | } |
201 | } else | 204 | } else |
202 | qWarning("Could not write file"); | 205 | owarn << "Could not write file" << oendl; |
203 | f.close(); | 206 | f.close(); |
204 | } | 207 | } |
205 | } | 208 | } |
206 | 209 | ||
207 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { | 210 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { |
208 | qWarning("received stdout %d bytes", buflen); | 211 | owarn << "received stdout " << buflen << " bytes" << oendl; |
209 | 212 | ||
210 | // QByteArray data(buflen); | 213 | // QByteArray data(buflen); |
211 | // data.fill(*buffer, buflen); | 214 | // data.fill(*buffer, buflen); |
212 | // for (uint i = 0; i < data.count(); i++ ) { | 215 | // for (uint i = 0; i < data.count(); i++ ) { |
213 | // printf("%c", buffer[i] ); | 216 | // printf("%c", buffer[i] ); |
214 | // } | 217 | // } |
215 | // printf("\n"); | 218 | // printf("\n"); |
216 | 219 | ||
217 | QString lineStr = buffer; | 220 | QString lineStr = buffer; |
218 | lineStr=lineStr.left(lineStr.length()-1); | 221 | lineStr=lineStr.left(lineStr.length()-1); |
219 | OutputEdit->append(lineStr); | 222 | OutputEdit->append(lineStr); |
220 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 223 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
221 | } | 224 | } |
222 | 225 | ||
223 | 226 | ||
224 | void Output::commandStdin( const QByteArray &data) { | 227 | void Output::commandStdin( const QByteArray &data) { |
225 | qWarning("received stdin %d bytes", data.size()); | 228 | owarn << "received stdin " << data.size() << " bytes" << oendl; |
226 | // recieved data from the io layer goes to sz | 229 | // recieved data from the io layer goes to sz |
227 | proc->writeStdin(data.data(), data.size()); | 230 | proc->writeStdin(data.data(), data.size()); |
228 | } | 231 | } |
229 | 232 | ||
230 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { | 233 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { |
231 | qWarning("received stderrt %d bytes", buflen); | 234 | owarn << "received stderrt " << buflen << " bytes" << oendl; |
232 | 235 | ||
233 | QString lineStr = buffer; | 236 | QString lineStr = buffer; |
234 | // lineStr=lineStr.left(lineStr.length()-1); | 237 | // lineStr=lineStr.left(lineStr.length()-1); |
235 | OutputEdit->append(lineStr); | 238 | OutputEdit->append(lineStr); |
236 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 239 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
237 | } | 240 | } |
238 | 241 | ||
239 | void Output::processFinished() { | 242 | void Output::processFinished() { |
240 | 243 | ||
241 | delete proc; | 244 | delete proc; |
242 | OutputEdit->append( tr("\nFinished\n") ); | 245 | OutputEdit->append( tr("\nFinished\n") ); |
243 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 246 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |