summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-19 15:35:19 (UTC)
committer llornkcor <llornkcor>2002-09-19 15:35:19 (UTC)
commit52fdd5cd164cf12d2a615d24497f8bb78491d0c2 (patch) (unidiff)
treedd27262e5ada8ff41b2edffb052acd494d1dfa4f
parent477a620e5745bd30222fe72d9c9b842785c285ab (diff)
downloadopie-52fdd5cd164cf12d2a615d24497f8bb78491d0c2.zip
opie-52fdd5cd164cf12d2a615d24497f8bb78491d0c2.tar.gz
opie-52fdd5cd164cf12d2a615d24497f8bb78491d0c2.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 4b398ad..2130438 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -189,201 +189,203 @@ static char * vmemo_xpm[] = {
189 "*. c #000713", 189 "*. c #000713",
190 "=. c #1F1F21", 190 "=. c #1F1F21",
191 " ", 191 " ",
192 " . + @ # ", 192 " . + @ # ",
193 " $ % & * = - ", 193 " $ % & * = - ",
194 " ; > , ' ) ! ~ ", 194 " ; > , ' ) ! ~ ",
195 " { ] ^ / ( _ : ", 195 " { ] ^ / ( _ : ",
196 " < [ } | 1 2 3 ", 196 " < [ } | 1 2 3 ",
197 " 4 5 6 7 8 9 0 a b c ", 197 " 4 5 6 7 8 9 0 a b c ",
198 " d e f g h i j 3 k l m n ", 198 " d e f g h i j 3 k l m n ",
199 " o p q r s t u v w n ", 199 " o p q r s t u v w n ",
200 " o x y z A B C D E n ", 200 " o x y z A B C D E n ",
201 " F G H I J K L M N O ", 201 " F G H I J K L M N O ",
202 " P Q R S T U V W X ", 202 " P Q R S T U V W X ",
203 " Y Z ` b ...+. ", 203 " Y Z ` b ...+. ",
204 " @.#.$.%.&. ", 204 " @.#.$.%.&. ",
205 " *.B =. ", 205 " *.B =. ",
206 " n n n n n n n n n "}; 206 " n n n n n n n n n "};
207 207
208 208
209VMemo::VMemo( QWidget *parent, const char *_name ) 209VMemo::VMemo( QWidget *parent, const char *_name )
210 : QWidget( parent, _name ) { 210 : QWidget( parent, _name ) {
211 setFixedHeight( 18 ); 211 setFixedHeight( 18 );
212 setFixedWidth( 14 ); 212 setFixedWidth( 14 );
213 213
214 recording = FALSE; 214 recording = FALSE;
215 215
216 t_timer = new QTimer( this ); 216 t_timer = new QTimer( this );
217 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 217 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
218 218
219 struct utsname name; /* check for embedix kernel running on the zaurus*/ 219 struct utsname name; /* check for embedix kernel running on the zaurus*/
220 if (uname(&name) != -1) { 220 if (uname(&name) != -1) {
221 QString release=name.release; 221 QString release=name.release;
222 222
223 Config vmCfg("Vmemo"); 223 Config vmCfg("Vmemo");
224 vmCfg.setGroup("Defaults"); 224 vmCfg.setGroup("Defaults");
225 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 225 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
226 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); 226 useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0);
227 227
228 qDebug("toggleKey %d", toggleKey); 228 qDebug("toggleKey %d", toggleKey);
229 229
230 if(release.find("embedix",0,TRUE) !=-1) 230 if(release.find("embedix",0,TRUE) !=-1)
231 systemZaurus=TRUE; 231 systemZaurus=TRUE;
232 else 232 else
233 systemZaurus=FALSE; 233 systemZaurus=FALSE;
234 234
235 myChannel = new QCopChannel( "QPE/VMemo", this ); 235 myChannel = new QCopChannel( "QPE/VMemo", this );
236 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 236 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
237 this, SLOT(receive(const QCString&, const QByteArray&)) ); 237 this, SLOT(receive(const QCString&, const QByteArray&)) );
238 238
239 if( toggleKey != -1 ) { 239 if( toggleKey != -1 ) {
240 // QPEApplication::grabKeyboard(); 240 // QPEApplication::grabKeyboard();
241 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 241 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
242 // e << 4096; // Key_Escape 242 // e << 4096; // Key_Escape
243 // e << Key_F5; //4148 243 // e << Key_F5; //4148
244 e << toggleKey; 244 e << toggleKey;
245 e << QString("QPE/VMemo"); 245 e << QString("QPE/VMemo");
246 e << QString("toggleRecord()"); 246 e << QString("toggleRecord()");
247 } 247 }
248 if(toggleKey == 1) 248 if(toggleKey == 1)
249 usingIcon=TRUE; 249 usingIcon=TRUE;
250 else 250 else
251 usingIcon=FALSE; 251 usingIcon=FALSE;
252 if( vmCfg.readNumEntry("hideIcon",0) == 1) 252 if( vmCfg.readNumEntry("hideIcon",0) == 1)
253 hide(); 253 hide();
254 } 254 }
255} 255}
256 256
257VMemo::~VMemo() { 257VMemo::~VMemo() {
258} 258}
259 259
260void VMemo::receive( const QCString &msg, const QByteArray &data ) { 260void VMemo::receive( const QCString &msg, const QByteArray &data ) {
261 qDebug("receive"); 261 qDebug("receive");
262 QDataStream stream( data, IO_ReadOnly ); 262 QDataStream stream( data, IO_ReadOnly );
263 263
264 if (msg == "toggleRecord()") { 264 if (msg == "toggleRecord()") {
265 265
266 if (recording) { 266 if (recording) {
267 fromToggle = TRUE; 267 fromToggle = TRUE;
268 mouseReleaseEvent(NULL); 268 mouseReleaseEvent(NULL);
269 stopRecording(); 269 stopRecording();
270 } else { 270 } else {
271 fromToggle = TRUE; 271 fromToggle = TRUE;
272 // mousePressEvent(NULL); 272 // mousePressEvent(NULL);
273 startRecording(); 273 startRecording();
274 } 274 }
275 } 275 }
276} 276}
277 277
278void VMemo::paintEvent( QPaintEvent* ) { 278void VMemo::paintEvent( QPaintEvent* ) {
279 QPainter p(this); 279 QPainter p(this);
280 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 280 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
281} 281}
282 282
283void VMemo::mousePressEvent( QMouseEvent * me) { 283void VMemo::mousePressEvent( QMouseEvent * me) {
284 // just to be safe 284 // just to be safe
285 if (recording) { 285 if (recording) {
286 recording = FALSE; 286 recording = FALSE;
287 return; 287 return;
288 } 288 }
289 /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions 289 /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
290 mousePressEvent and mouseReleaseEvent with a NULL parameter. */ 290 mousePressEvent and mouseReleaseEvent with a NULL parameter. */
291 if ( me->button() != LeftButton || me != NULL) 291 if ( me->button() != LeftButton && me != NULL /*&& !systemZaurus*/) {
292
292 // if (!systemZaurus && me != NULL) 293 // if (!systemZaurus && me != NULL)
293 return; 294 return;
295 }
294 296
295 if(!recording) 297 if(!recording)
296 startRecording(); 298 startRecording();
297 else 299 else
298 stopRecording(); 300 stopRecording();
299} 301}
300 302
301void VMemo::mouseReleaseEvent( QMouseEvent * ) { 303void VMemo::mouseReleaseEvent( QMouseEvent * ) {
302// if(usingIcon && !recording) 304// if(usingIcon && !recording)
303// stopRecording(); 305// stopRecording();
304} 306}
305 307
306bool VMemo::startRecording() { 308bool VMemo::startRecording() {
307 309
308 if ( recording) 310 if ( recording)
309 return FALSE; 311 return FALSE;
310 312
311 Config config( "Vmemo" ); 313 Config config( "Vmemo" );
312 config.setGroup( "System" ); 314 config.setGroup( "System" );
313 315
314 useAlerts = config.readBoolEntry("Alert",1); 316 useAlerts = config.readBoolEntry("Alert",1);
315 if(useAlerts) { 317 if(useAlerts) {
316 318
317 msgLabel = new QLabel( 0, "alertLabel" ); 319 msgLabel = new QLabel( 0, "alertLabel" );
318 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 320 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
319 msgLabel->show(); 321 msgLabel->show();
320 } 322 }
321 323
322 // if(useAlerts) 324 // if(useAlerts)
323 // QMessageBox::message("VMemo","Really Record?");//) ==1) 325 // QMessageBox::message("VMemo","Really Record?");//) ==1)
324 // return; 326 // return;
325 // } else { 327 // } else {
326 // if (!systemZaurus ) 328 // if (!systemZaurus )
327 // QSound::play(Resource::findSound("vmemob")); 329 // QSound::play(Resource::findSound("vmemob"));
328 // } 330 // }
329 qDebug("Start recording engines"); 331 qDebug("Start recording engines");
330 recording = TRUE; 332 recording = TRUE;
331 333
332 if (openDSP() == -1) { 334 if (openDSP() == -1) {
333 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 335 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
334 // delete msgLabel; 336 // delete msgLabel;
335 recording = FALSE; 337 recording = FALSE;
336 msgLabel=0; 338 msgLabel=0;
337 delete msgLabel; 339 delete msgLabel;
338 340
339 return FALSE; 341 return FALSE;
340 } 342 }
341 343
342 config.setGroup("Defaults"); 344 config.setGroup("Defaults");
343 345
344 QDateTime dt = QDateTime::currentDateTime(); 346 QDateTime dt = QDateTime::currentDateTime();
345 347
346 QString fName; 348 QString fName;
347 config.setGroup( "System" ); 349 config.setGroup( "System" );
348 fName = QPEApplication::documentDir() ; 350 fName = QPEApplication::documentDir() ;
349 fileName = config.readEntry("RecLocation", fName); 351 fileName = config.readEntry("RecLocation", fName);
350 352
351 int s; 353 int s;
352 s=fileName.find(':'); 354 s=fileName.find(':');
353 if(s) 355 if(s)
354 fileName=fileName.right(fileName.length()-s-2); 356 fileName=fileName.right(fileName.length()-s-2);
355 qDebug("pathname will be "+fileName); 357 qDebug("pathname will be "+fileName);
356 358
357 if( fileName.left(1).find('/') == -1) 359 if( fileName.left(1).find('/') == -1)
358 fileName="/"+fileName; 360 fileName="/"+fileName;
359 if( fileName.right(1).find('/') == -1) 361 if( fileName.right(1).find('/') == -1)
360 fileName+="/"; 362 fileName+="/";
361 fName = "vm_"+ dt.toString()+ ".wav"; 363 fName = "vm_"+ dt.toString()+ ".wav";
362 364
363 fileName+=fName; 365 fileName+=fName;
364 // No spaces in the filename 366 // No spaces in the filename
365 fileName.replace(QRegExp("'"),""); 367 fileName.replace(QRegExp("'"),"");
366 fileName.replace(QRegExp(" "),"_"); 368 fileName.replace(QRegExp(" "),"_");
367 fileName.replace(QRegExp(":"),"."); 369 fileName.replace(QRegExp(":"),".");
368 fileName.replace(QRegExp(","),""); 370 fileName.replace(QRegExp(","),"");
369 371
370 372
371 qDebug("filename is "+fileName); 373 qDebug("filename is "+fileName);
372// open tmp file here 374// open tmp file here
373 char *pointer; 375 char *pointer;
374 pointer=tmpnam(NULL); 376 pointer=tmpnam(NULL);
375 qDebug("Opening tmp file %s",pointer); 377 qDebug("Opening tmp file %s",pointer);
376 378
377 if(openWAV(pointer ) == -1) { 379 if(openWAV(pointer ) == -1) {
378 380
379// if(openWAV(fileName.latin1()) == -1) { 381// if(openWAV(fileName.latin1()) == -1) {
380 QString err("Could not open the temp file\n"); 382 QString err("Could not open the temp file\n");
381 err += fileName; 383 err += fileName;
382 QMessageBox::critical(0, "vmemo", err, "Abort"); 384 QMessageBox::critical(0, "vmemo", err, "Abort");
383 ::close(dsp); 385 ::close(dsp);
384 return FALSE; 386 return FALSE;
385 } 387 }
386 if( record() ) { 388 if( record() ) {
387 389
388 QString cmd; 390 QString cmd;
389 if( fileName.find(".wav",0,TRUE) == -1) 391 if( fileName.find(".wav",0,TRUE) == -1)