summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 7965b59..cb3e45e 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -158,257 +158,257 @@ static char * vmemo_xpm[] = {
158 "P c #2D3137", 158 "P c #2D3137",
159 "Q c #B0B1BC", 159 "Q c #B0B1BC",
160 "R c #3B3C40", 160 "R c #3B3C40",
161 "S c #6E6E74", 161 "S c #6E6E74",
162 "T c #95959C", 162 "T c #95959C",
163 "U c #74747A", 163 "U c #74747A",
164 "V c #1D1D1E", 164 "V c #1D1D1E",
165 "W c #91929A", 165 "W c #91929A",
166 "X c #42444A", 166 "X c #42444A",
167 "Y c #22282E", 167 "Y c #22282E",
168 "Z c #B0B2BC", 168 "Z c #B0B2BC",
169 "` c #898A90", 169 "` c #898A90",
170 " . c #65656A", 170 " . c #65656A",
171 ".. c #999AA2", 171 ".. c #999AA2",
172 "+. c #52535A", 172 "+. c #52535A",
173 "@. c #151B21", 173 "@. c #151B21",
174 "#. c #515257", 174 "#. c #515257",
175 "$. c #B5B5BE", 175 "$. c #B5B5BE",
176 "%. c #616167", 176 "%. c #616167",
177 "&. c #1A1D22", 177 "&. c #1A1D22",
178 "*. c #000713", 178 "*. c #000713",
179 "=. c #1F1F21", 179 "=. c #1F1F21",
180 " ", 180 " ",
181 " . + @ # ", 181 " . + @ # ",
182 " $ % & * = - ", 182 " $ % & * = - ",
183 " ; > , ' ) ! ~ ", 183 " ; > , ' ) ! ~ ",
184 " { ] ^ / ( _ : ", 184 " { ] ^ / ( _ : ",
185 " < [ } | 1 2 3 ", 185 " < [ } | 1 2 3 ",
186 " 4 5 6 7 8 9 0 a b c ", 186 " 4 5 6 7 8 9 0 a b c ",
187 " d e f g h i j 3 k l m n ", 187 " d e f g h i j 3 k l m n ",
188 " o p q r s t u v w n ", 188 " o p q r s t u v w n ",
189 " o x y z A B C D E n ", 189 " o x y z A B C D E n ",
190 " F G H I J K L M N O ", 190 " F G H I J K L M N O ",
191 " P Q R S T U V W X ", 191 " P Q R S T U V W X ",
192 " Y Z ` b ...+. ", 192 " Y Z ` b ...+. ",
193 " @.#.$.%.&. ", 193 " @.#.$.%.&. ",
194 " *.B =. ", 194 " *.B =. ",
195 " n n n n n n n n n "}; 195 " n n n n n n n n n "};
196 196
197 197
198VMemo::VMemo( QWidget *parent, const char *_name ) 198VMemo::VMemo( QWidget *parent, const char *_name )
199 : QWidget( parent, _name ) 199 : QWidget( parent, _name )
200{ 200{
201 setFixedHeight( 18 ); 201 setFixedHeight( 18 );
202 setFixedWidth( 14 ); 202 setFixedWidth( 14 );
203 203
204 recording = FALSE; 204 recording = FALSE;
205 205
206 t_timer = new QTimer( this ); 206 t_timer = new QTimer( this );
207 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); 207 connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) );
208 208
209 struct utsname name; /* check for embedix kernel running on the zaurus*/ 209 struct utsname name; /* check for embedix kernel running on the zaurus*/
210 if (uname(&name) != -1) { 210 if (uname(&name) != -1) {
211 QString release=name.release; 211 QString release=name.release;
212 212
213 Config vmCfg("Vmemo"); 213 Config vmCfg("Vmemo");
214 vmCfg.setGroup("Defaults"); 214 vmCfg.setGroup("Defaults");
215 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); 215 int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
216 216
217 qDebug("toggleKey %d", toggleKey); 217 qDebug("toggleKey %d", toggleKey);
218 218
219 if(release.find("embedix",0,TRUE) !=-1) 219 if(release.find("embedix",0,TRUE) !=-1)
220 systemZaurus=TRUE; 220 systemZaurus=TRUE;
221 else 221 else
222 systemZaurus=FALSE; 222 systemZaurus=FALSE;
223 223
224 myChannel = new QCopChannel( "QPE/VMemo", this ); 224 myChannel = new QCopChannel( "QPE/VMemo", this );
225 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 225 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
226 this, SLOT(receive(const QCString&, const QByteArray&)) ); 226 this, SLOT(receive(const QCString&, const QByteArray&)) );
227 227
228 if( toggleKey != -1 ) { 228 if( toggleKey != -1 ) {
229 // QPEApplication::grabKeyboard(); 229 // QPEApplication::grabKeyboard();
230 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 230 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
231 // e << 4096; // Key_Escape 231 // e << 4096; // Key_Escape
232 // e << Key_F5; //4148 232 // e << Key_F5; //4148
233 e << toggleKey; 233 e << toggleKey;
234 e << QString("QPE/VMemo"); 234 e << QString("QPE/VMemo");
235 e << QString("toggleRecord()"); 235 e << QString("toggleRecord()");
236 } 236 }
237 237
238 if( vmCfg.readNumEntry("hideIcon",0) == 1) 238 if( vmCfg.readNumEntry("hideIcon",0) == 1)
239 hide(); 239 hide();
240 } 240 }
241} 241}
242 242
243VMemo::~VMemo() 243VMemo::~VMemo()
244{ 244{
245} 245}
246 246
247void VMemo::receive( const QCString &msg, const QByteArray &data ) 247void VMemo::receive( const QCString &msg, const QByteArray &data )
248{ 248{
249 qDebug("receive"); 249 qDebug("receive");
250 QDataStream stream( data, IO_ReadOnly ); 250 QDataStream stream( data, IO_ReadOnly );
251 if (msg == "toggleRecord()") { 251 if (msg == "toggleRecord()") {
252 if (recording) { 252 if (recording) {
253 fromToggle = TRUE; 253 fromToggle = TRUE;
254 stopRecording(); 254 stopRecording();
255 } else { 255 } else {
256 fromToggle = TRUE; 256 fromToggle = TRUE;
257 startRecording(); 257 startRecording();
258 } 258 }
259 } 259 }
260} 260}
261 261
262void VMemo::paintEvent( QPaintEvent* ) 262void VMemo::paintEvent( QPaintEvent* )
263{ 263{
264 QPainter p(this); 264 QPainter p(this);
265 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 265 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
266} 266}
267 267
268void VMemo::mousePressEvent( QMouseEvent * ) 268void VMemo::mousePressEvent( QMouseEvent * )
269{ 269{
270 startRecording(); 270 startRecording();
271} 271}
272 272
273void VMemo::mouseReleaseEvent( QMouseEvent * ) 273void VMemo::mouseReleaseEvent( QMouseEvent * )
274{ 274{
275 stopRecording(); 275 stopRecording();
276} 276}
277 277
278bool VMemo::startRecording() { 278bool VMemo::startRecording() {
279 279
280 if ( recording) 280 if ( recording)
281 return FALSE; 281 return FALSE;
282 282
283 Config config( "Vmemo" ); 283 Config config( "Vmemo" );
284 config.setGroup( "System" ); 284 config.setGroup( "System" );
285 285
286 useAlerts = config.readBoolEntry("Alert"); 286 useAlerts = config.readBoolEntry("Alert",1);
287 if(useAlerts) { 287 if(useAlerts) {
288 288
289 msgLabel = new QLabel( 0, "alertLabel" ); 289 msgLabel = new QLabel( 0, "alertLabel" );
290 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); 290 msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
291 msgLabel->show(); 291 msgLabel->show();
292 } 292 }
293 293
294 // if(useAlerts) 294 // if(useAlerts)
295 // QMessageBox::message("VMemo","Really Record?");//) ==1) 295 // QMessageBox::message("VMemo","Really Record?");//) ==1)
296 // return; 296 // return;
297 // } else { 297 // } else {
298 // if (!systemZaurus ) 298 // if (!systemZaurus )
299 // QSound::play(Resource::findSound("vmemob")); 299 // QSound::play(Resource::findSound("vmemob"));
300 // } 300 // }
301 qDebug("Start recording engines"); 301 qDebug("Start recording engines");
302 recording = TRUE; 302 recording = TRUE;
303 303
304 if (openDSP() == -1) { 304 if (openDSP() == -1) {
305 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 305 // QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
306 // delete msgLabel; 306 // delete msgLabel;
307 recording = FALSE; 307 recording = FALSE;
308 msgLabel=0; 308 msgLabel=0;
309 delete msgLabel; 309 delete msgLabel;
310 310
311 return FALSE; 311 return FALSE;
312 } 312 }
313 313
314 config.setGroup("Defaults"); 314 config.setGroup("Defaults");
315 315
316 QDateTime dt = QDateTime::currentDateTime(); 316 QDateTime dt = QDateTime::currentDateTime();
317 317
318 QString fName; 318 QString fName;
319 config.setGroup( "System" ); 319 config.setGroup( "System" );
320 fName = QPEApplication::documentDir() ; 320 fName = QPEApplication::documentDir() ;
321 fileName = config.readEntry("RecLocation", fName); 321 fileName = config.readEntry("RecLocation", fName);
322 322
323 int s; 323 int s;
324 s=fileName.find(':'); 324 s=fileName.find(':');
325 if(s) 325 if(s)
326 fileName=fileName.right(fileName.length()-s-2); 326 fileName=fileName.right(fileName.length()-s-2);
327 qDebug("pathname will be "+fileName); 327 qDebug("pathname will be "+fileName);
328 328
329 if( fileName.left(1).find('/') == -1) 329 if( fileName.left(1).find('/') == -1)
330 fileName="/"+fileName; 330 fileName="/"+fileName;
331 if( fileName.right(1).find('/') == -1) 331 if( fileName.right(1).find('/') == -1)
332 fileName+="/"; 332 fileName+="/";
333 fName = "vm_"+ dt.toString()+ ".wav"; 333 fName = "vm_"+ dt.toString()+ ".wav";
334 334
335 fileName+=fName; 335 fileName+=fName;
336 qDebug("filename is "+fileName); 336 qDebug("filename is "+fileName);
337 // No spaces in the filename 337 // No spaces in the filename
338 fileName.replace(QRegExp("'"),""); 338 fileName.replace(QRegExp("'"),"");
339 fileName.replace(QRegExp(" "),"_"); 339 fileName.replace(QRegExp(" "),"_");
340 fileName.replace(QRegExp(":"),"."); 340 fileName.replace(QRegExp(":"),".");
341 fileName.replace(QRegExp(","),""); 341 fileName.replace(QRegExp(","),"");
342 342
343 if(openWAV(fileName.latin1()) == -1) { 343 if(openWAV(fileName.latin1()) == -1) {
344 // QString err("Could not open the output file\n"); 344 // QString err("Could not open the output file\n");
345 // err += fileName; 345 // err += fileName;
346 // QMessageBox::critical(0, "vmemo", err, "Abort"); 346 // QMessageBox::critical(0, "vmemo", err, "Abort");
347 close(dsp); 347 close(dsp);
348 return FALSE; 348 return FALSE;
349 } 349 }
350 350
351 QArray<int> cats(1); 351 QArray<int> cats(1);
352 cats[0] = config.readNumEntry("Category", 0); 352 cats[0] = config.readNumEntry("Category", 0);
353 353
354 QString dlName("vm_"); 354 QString dlName("vm_");
355 dlName += dt.toString(); 355 dlName += dt.toString();
356 DocLnk l; 356 DocLnk l;
357 l.setFile(fileName); 357 l.setFile(fileName);
358 l.setName(dlName); 358 l.setName(dlName);
359 l.setType("audio/x-wav"); 359 l.setType("audio/x-wav");
360 l.setCategories(cats); 360 l.setCategories(cats);
361 l.writeLink(); 361 l.writeLink();
362 362
363 363
364 record(); 364 record();
365 // delete msgLabel; 365 // delete msgLabel;
366 return TRUE; 366 return TRUE;
367} 367}
368 368
369void VMemo::stopRecording() { 369void VMemo::stopRecording() {
370show(); 370show();
371 qDebug("Stopped recording"); 371 qDebug("Stopped recording");
372 recording = FALSE; 372 recording = FALSE;
373 if(useAlerts) 373 if(useAlerts)
374 if( msgLabel) delete msgLabel; 374 if( msgLabel) delete msgLabel;
375 t_timer->stop(); 375 t_timer->stop();
376 Config cfg("Vmemo"); 376 Config cfg("Vmemo");
377 cfg.setGroup("Defaults"); 377 cfg.setGroup("Defaults");
378 if( cfg.readNumEntry("hideIcon",0) == 1 ) 378 if( cfg.readNumEntry("hideIcon",0) == 1 )
379 hide(); 379 hide();
380} 380}
381 381
382int VMemo::openDSP() 382int VMemo::openDSP()
383{ 383{
384 Config cfg("Vmemo"); 384 Config cfg("Vmemo");
385 cfg.setGroup("Record"); 385 cfg.setGroup("Record");
386 386
387 speed = cfg.readNumEntry("SampleRate", 22050); 387 speed = cfg.readNumEntry("SampleRate", 22050);
388 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) 388 channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1)
389 if (cfg.readNumEntry("SixteenBit", 1)==1) { 389 if (cfg.readNumEntry("SixteenBit", 1)==1) {
390 format = AFMT_S16_LE; 390 format = AFMT_S16_LE;
391 resolution = 16; 391 resolution = 16;
392 } else { 392 } else {
393 format = AFMT_U8; 393 format = AFMT_U8;
394 resolution = 8; 394 resolution = 8;
395 } 395 }
396 396
397 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); 397 qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution);
398 398
399 if(systemZaurus) { 399 if(systemZaurus) {
400 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 400 dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1
401 channels=1; //zaurus has one input channel 401 channels=1; //zaurus has one input channel
402 } else { 402 } else {
403 dsp = open("/dev/dsp", O_RDONLY); 403 dsp = open("/dev/dsp", O_RDONLY);
404 } 404 }
405 405
406 if(dsp == -1) { 406 if(dsp == -1) {
407 perror("open(\"/dev/dsp\")"); 407 perror("open(\"/dev/dsp\")");
408 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); 408 errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno);
409 QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); 409 QMessageBox::critical(0, "vmemo", errorMsg, "Abort");
410 return -1; 410 return -1;
411 } 411 }
412 412
413 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { 413 if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) {
414 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 414 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");