2
* Kscd - A simple cd player for the KDE Project
4
* $Id: kscd.cpp,v 1.134 2001/07/27 11:35:28 mlaurent Exp $
6
* Copyright (c) 1997 Bernd Johannes wuebben@math.cornell.edu
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
#include <qtextstream.h>
29
#include <dcopclient.h>
30
#include <kaboutdata.h>
31
#include <kcharsets.h>
32
#include <kcmdlineargs.h>
35
#include <kemailsettings.h>
37
#include <kiconloader.h>
39
#include <kmessagebox.h>
40
#include <kprotocolmanager.h>
42
#include <krandomsequence.h>
44
#include <kstringhandler.h>
49
#include "configdlg.h"
50
#include "mgconfdlg.h"
53
// We don't have libWorkMan installed already, so get everything
54
// from within our own directory
55
#include "libwm/include/workman.h"
57
#include "libwm/include/wm_config.h"
60
#include "CDDBSetup.h"
61
#include "bitmaps/playpaus.xbm"
62
#include "bitmaps/stop.xbm"
63
#include "bitmaps/repeat.xbm"
64
#include "bitmaps/nexttrk.xbm"
65
#include "bitmaps/prevtrk.xbm"
66
#include "bitmaps/ff.xbm"
67
#include "bitmaps/rew.xbm"
68
#include "bitmaps/info.xbm"
69
#include "bitmaps/poweroff.xbm"
70
#include "bitmaps/magic.xbm"
71
#include "bitmaps/eject.xbm"
72
#include "bitmaps/db.xbm"
73
#include "bitmaps/logo.xbm"
74
#include "bitmaps/shuffle.xbm"
75
#include "bitmaps/options.xbm"
77
static const char *description = I18N_NOOP("KDE CD player");
79
DockWidget* dock_widget;
81
bool dockinginprogress = 0;
83
bool stoppedByUser = 1;
84
bool device_change = false;
88
//static void playtime (void);
89
void kcderror(const QString& title, const QString& message);
92
//void parseargs(char* buf, char** args);
93
extern QTime framestoTime(int frames);
94
extern void cddb_decode(QString& str);
95
extern void cddb_encode(QString& str, QStringList &returnlist);
96
extern void cddb_playlist_encode(QStringList& list,QString& playstr);
97
extern bool cddb_playlist_decode(QStringList& list, QString& str);
99
int random_current; /* koz: Current track in random list */
100
int *random_list; /* koz: Used in Random - once through */
102
KRandomSequence randSequence;
104
static QString formatTrack(int d1, int d2)
106
QString str = QString::fromLatin1("%1/%2")
107
.arg( QString::number(d1).rightJustify(2, '0') )
108
.arg( QString::number(d2).rightJustify(2, '0') );
114
/****************************************************************************
116
*****************************************************************************/
118
KSCD::KSCD( QWidget *parent, const char *name )
119
: QWidget( parent, name ), DCOPObject("CDPlayer")
121
// connect(kapp, SIGNAL (saveYourself() ), SLOT (doSM()));
124
background_color = black;
128
cddrive_is_ok = true;
132
magic_brightness = 3;
133
magic_pointsAreDiamonds = false;
136
cddb_remote_enabled = false;
137
cddb_auto_enabled = false;
140
time_display_mode = TRACK_SEC;
141
cddb_inexact_sentinel = false;
142
revision = 0; // The first freedb revision is "0"
147
ejectonfinish = false;
149
updateDialog = false;
150
ejectedBefore = false;
151
currentlyejected = false;
161
timer = new QTimer( this );
162
queryledtimer = new QTimer( this );
163
titlelabeltimer = new QTimer( this );
164
initimer = new QTimer( this );
165
cycletimer = new QTimer( this );
167
connect( initimer, SIGNAL(timeout()),this, SLOT(initCDROM()) );
168
connect( queryledtimer, SIGNAL(timeout()), SLOT(togglequeryled()) );
169
connect( titlelabeltimer, SIGNAL(timeout()), SLOT(titlelabeltimeout()) );
170
connect( cycletimer, SIGNAL(timeout()), SLOT(cycletimeout()) );
171
connect( timer, SIGNAL(timeout()), SLOT(cdMode()) );
172
connect( playPB, SIGNAL(clicked()), SLOT(playClicked()) );
173
connect( stopPB, SIGNAL(clicked()), SLOT(stopClicked()) );
174
connect( prevPB, SIGNAL(clicked()), SLOT(prevClicked()) );
175
connect( nextPB, SIGNAL(clicked()), SLOT(nextClicked()) );
176
connect( fwdPB, SIGNAL(clicked()), SLOT(fwdClicked()) );
177
connect( bwdPB, SIGNAL(clicked()), SLOT(bwdClicked()) );
178
connect( dockPB, SIGNAL(clicked()), SLOT(quitClicked()) );
180
connect( magicPB, SIGNAL(clicked()), SLOT(magicslot()) );
182
connect( replayPB, SIGNAL(clicked()), SLOT(loopClicked()) );
183
connect( ejectPB, SIGNAL(clicked()), SLOT(ejectClicked()) );
184
connect( songListCB, SIGNAL(activated(int)), SLOT(trackSelected(int)));
185
connect( volSB, SIGNAL(valueChanged(int)), SLOT(volChanged(int)));
186
connect( aboutPB, SIGNAL(clicked()), SLOT(cycleplaytimemode()));
187
//connect( aboutPB, SIGNAL(clicked()), SLOT(aboutClicked()));
188
connect( optionsbutton, SIGNAL(clicked()), SLOT(aboutClicked()));
189
connect( shufflebutton, SIGNAL(clicked()), SLOT(randomSelected()));
190
connect( cddbbutton, SIGNAL(clicked()), SLOT(CDDialogSelected()));
191
connect(kapp,SIGNAL(kdisplayPaletteChanged()),this,SLOT(setColors()));
199
volSB->setValue(volume);
206
dock_widget = new DockWidget( this, "dockw");
210
connect(this, SIGNAL(trackChanged(const QString&)), dock_widget, SLOT(setToolTip(const QString&)));
213
smtpMailer = new SMTP;
214
connect(smtpMailer, SIGNAL(messageSent()), this, SLOT(smtpMessageSent()));
215
connect(smtpMailer, SIGNAL(error(int)), this, SLOT(smtpError(int)));
217
setFocusPolicy ( QWidget::NoFocus );
219
initimer->start(500,TRUE);
223
KSCD::smtpMessageSent(void)
225
KMessageBox::information(this, i18n("Record submitted successfully"),
226
i18n("Record Submission"));
227
} // smtpMessageSent()
230
* Interpret error codes from the SMTP mailer.
233
KSCD::smtpError(int errornum)
239
lstr = i18n("Error connecting to server.");
242
lstr = i18n("Not connected.");
245
lstr = i18n("Connection timed out.");
248
lstr = i18n("Time out waiting for server interaction.");
251
lstr = i18n("Server said:\n\"%1\"").arg(smtpMailer->getLastLine());
253
str = i18n("Error #%1 sending message via SMTP.\n\n%2")
254
.arg(errornum).arg(lstr);
255
KMessageBox::error(this, str, i18n("Record Submission"));
260
* Initialize the variables only in WorkMan
261
* FIXME: What is needed exactly?
277
* Init CD-ROM and display
283
kapp->processEvents();
295
* Return fitting Helvetica font size for the 13 and 14 pixel widgets.
296
* @return a reasonably small font size
301
static int theSmallPtSize = 0;
303
if ( theSmallPtSize != 0 )
304
return theSmallPtSize;
306
// Find a font that fits the 13 and 14 pixel widgets
308
QFont fn( "Helvetica", theSmallPtSize, QFont::Bold );
310
while (!fits && theSmallPtSize > 1)
312
QFontMetrics metrics(fn);
313
if(metrics.height() > 13)
316
fn.setPointSize(theSmallPtSize);
321
return theSmallPtSize;
325
KSCD::makeButton( int x, int y, int w, int h, const QString& n )
327
QPushButton *pb = new QPushButton( n, this );
328
pb->setGeometry( x, y, w, h );
329
pb->setFocusPolicy ( QWidget::NoFocus );
334
* drawPanel() constructs KSCD's main window.
335
* This is oldstyle and needs to be redesigned.
337
* @author Bernd W�bben
338
* @author Dirk F�rsterling
345
const int WIDTH = 90;
346
const int HEIGHT = 27;
347
const int SBARWIDTH = 220;
349
aboutPB = makeButton( ix, iy, WIDTH, 2 * HEIGHT, i18n("About") );
354
infoPB = makeButton( ix, iy, WIDTH/2, HEIGHT, "" );
355
ejectPB = makeButton( ix + WIDTH/2, iy, WIDTH/2, HEIGHT, "" );
359
dockPB = makeButton( ix, iy, WIDTH/2, HEIGHT, i18n("Quit") );
360
magicPB = makeButton(ix+WIDTH/2, iy, WIDTH/2, HEIGHT, "" );
362
dockPB = makeButton( ix, iy, WIDTH, HEIGHT, i18n("Quit") );
367
backdrop = new QFrame(this);
368
backdrop->setGeometry(ix,iy,SBARWIDTH -2, 2* HEIGHT + HEIGHT /2 -1);
369
backdrop->setFocusPolicy ( QWidget::NoFocus );
374
for (int u = 0; u<5;u++)
376
trackTimeLED[u] = new BW_LED_Number(this );
377
trackTimeLED[u]->setGeometry( ix + u*18, iy + D, 23 , 30 );
378
trackTimeLED[u]->setLEDoffColor(background_color);
379
trackTimeLED[u]->setLEDColor(led_color,background_color);
382
QString zeros("--:--");
385
artistlabel = new QLabel(this);
386
artistlabel->setGeometry(WIDTH + 5, iy + 38 , SBARWIDTH -15, 13);
387
artistlabel->setFont( QFont( "helvetica", smallPtSize(), QFont::Bold) );
388
artistlabel->setAlignment( AlignLeft );
389
artistlabel->clear();
391
titlelabel = new QLabel(this);
392
titlelabel->setGeometry(WIDTH + 5, iy + 50 , SBARWIDTH -15, 13);
393
QFont ledfont( "Helvetica", smallPtSize()-2, QFont::Bold );
394
titlelabel->setFont( ledfont );
395
titlelabel->setAlignment( AlignLeft );
398
statuslabel = new QLabel(this);
399
statuslabel->setGeometry(WIDTH + 110, iy +D, 50, 14);
400
statuslabel->setFont( ledfont );
401
statuslabel->setAlignment( AlignLeft );
403
queryled = new LedLamp(this);
404
queryled->move(WIDTH + 200, iy +D +1 );
408
loopled = new LedLamp(this, LedLamp::Loop);
409
loopled->move(WIDTH + 200, iy +D +18 );
412
volumelabel = new QLabel(this);
413
volumelabel->setGeometry(WIDTH + 110, iy + 14 + D, 50, 14);
414
volumelabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold ) );
415
volumelabel->setAlignment( AlignLeft );
416
volumelabel->setText(i18n("Vol: --"));
418
tracklabel = new QLabel(this);
419
tracklabel->setGeometry(WIDTH + 168, iy + 14 +D, 30, 14);
420
tracklabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold ) );
421
tracklabel->setAlignment( AlignLeft );
422
tracklabel->setText("--/--");
424
totaltimelabel = new QLabel(this);
425
totaltimelabel->setGeometry(WIDTH + 168, iy +D, 50, 14);
426
totaltimelabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold ) );
427
totaltimelabel->setAlignment( AlignLeft );
428
totaltimelabel->hide();
431
iy = HEIGHT + HEIGHT + HEIGHT/2;
433
volSB = new QSlider( 0, 100, 5, 50, QSlider::Horizontal, this, "Slider" );
434
volSB->setGeometry( ix, iy, SBARWIDTH, HEIGHT/2 );
435
volSB->setFocusPolicy ( QWidget::NoFocus );
438
cddbbutton = new QPushButton( this );
439
cddbbutton->setGeometry( ix , iy, SBARWIDTH/10 *2 , HEIGHT );
440
cddbbutton->setFocusPolicy ( QWidget::NoFocus );
442
ix += SBARWIDTH/10*2;
443
shufflebutton = new QPushButton( this );
444
shufflebutton->setGeometry( ix , iy, SBARWIDTH/10 *2 , HEIGHT );
445
shufflebutton->setFocusPolicy ( QWidget::NoFocus );
447
ix += SBARWIDTH/10*2;
449
optionsbutton = new QPushButton( this );
450
optionsbutton->setGeometry( ix, iy, SBARWIDTH/10 *2 , HEIGHT );
451
optionsbutton->setFocusPolicy ( QWidget::NoFocus );
455
songListCB = new QComboBox( this );
456
songListCB->setGeometry( ix, iy, SBARWIDTH/10*18+6, HEIGHT );
457
songListCB->setFont( QFont( "helvetica", smallPtSize() ) );
458
songListCB->setFocusPolicy ( QWidget::NoFocus );
461
ix = WIDTH + SBARWIDTH + 2;
462
playPB = makeButton( ix, iy, WIDTH, HEIGHT*2, "Play/Pause" );
464
iy += HEIGHT + HEIGHT;
465
stopPB = makeButton( ix, iy, WIDTH / 2, HEIGHT, "Stop" );
468
replayPB = makeButton( ix, iy, WIDTH / 2, HEIGHT, "Replay" );
470
ix = WIDTH + SBARWIDTH/10*6;
472
bwdPB = makeButton( ix, iy, WIDTH / 2, HEIGHT, "Bwd" );
475
fwdPB = makeButton( ix, iy, WIDTH / 2, HEIGHT, "Fwd" );
477
ix = WIDTH + SBARWIDTH + 2;
478
prevPB = makeButton( ix, iy, WIDTH / 2, HEIGHT, "Prev" );
481
nextPB = makeButton( ix, iy, WIDTH / 2, HEIGHT, "Next" );
484
this->setFixedSize(this->width(),this->height());
491
QBitmap playBmp( playpause_width, playpause_height, playpause_bits,TRUE );
492
QBitmap stopBmp( stop_width, stop_height, stop_bits, TRUE );
493
QBitmap prevBmp( prevtrk_width, prevtrk_height, prevtrk_bits, TRUE );
494
QBitmap nextBmp( nexttrk_width, nexttrk_height, nexttrk_bits, TRUE );
495
QBitmap replayBmp( repeat_width, repeat_height, repeat_bits, TRUE );
496
QBitmap fwdBmp( ff_width, ff_height, ff_bits, TRUE );
497
QBitmap bwdBmp( rew_width, rew_height, rew_bits, TRUE );
498
QBitmap ejectBmp( eject_width, eject_height, eject_bits, TRUE );
499
QBitmap infoBmp( info_width, info_height,info_bits, TRUE );
500
QBitmap dockBmp( poweroff_width, poweroff_height, poweroff_bits, TRUE );
502
QBitmap magicBmp( magicxbm_width, magicxbm_height, magicxbm_bits, TRUE );
504
QBitmap shuffleBmp( shuffle_width, shuffle_height, shuffle_bits, TRUE );
505
QBitmap databaseBmp( db_width, db_height, db_bits, TRUE );
506
QBitmap aboutBmp( logo_width, logo_height, logo_bits, TRUE );
507
QBitmap optionsBmp( options_width, options_height, options_bits, TRUE );
509
playPB->setPixmap( playBmp );
510
stopPB->setPixmap( stopBmp );
511
prevPB->setPixmap( prevBmp );
512
nextPB->setPixmap( nextBmp );
513
replayPB->setPixmap( replayBmp );
514
fwdPB->setPixmap( fwdBmp );
515
bwdPB->setPixmap( bwdBmp );
516
ejectPB->setPixmap( ejectBmp );
517
infoPB->setPixmap( infoBmp );
518
dockPB->setPixmap( dockBmp );
520
magicPB->setPixmap( magicBmp );
522
// This is UGLY .... -- Bernd
523
// dockPB->setFont(QFont("helvetica", 12, QFont::Bold));
524
// dockPB->setText("DOCK");
526
aboutPB->setPixmap( aboutBmp );
527
shufflebutton->setPixmap( shuffleBmp );
528
cddbbutton->setPixmap( databaseBmp );
529
optionsbutton->setPixmap( optionsBmp );
536
mainPopup = new QPopupMenu ();
537
perfPopup = new QPopupMenu ();
538
purchPopup = new QPopupMenu ();
539
infoPopup = new QPopupMenu ();
541
purchPopup->insertItem("CD Now", 0);
542
purchPopup->insertItem("CD Universe", 1);
544
perfPopup->insertItem("Tourdates.com", 0);
546
infoPopup->insertItem("Ultimate Bandlist", 0);
547
infoPopup->insertSeparator();
548
infoPopup->insertItem("Deja News", 1);
549
infoPopup->insertItem("Excite", 2);
550
infoPopup->insertItem("HotBot", 3);
551
infoPopup->insertItem("Info Seek", 4);
552
infoPopup->insertItem("Lycos", 5);
553
infoPopup->insertItem("Magellan", 6);
554
infoPopup->insertItem("Yahoo!", 7);
556
mainPopup->insertItem (i18n("Performances"), perfPopup);
557
connect( perfPopup, SIGNAL(activated(int)), SLOT(performances(int)) );
559
mainPopup->insertItem (i18n("Purchases"), purchPopup);
560
connect( purchPopup, SIGNAL(activated(int)), SLOT(purchases(int)) );
562
mainPopup->insertItem (i18n("Information"), infoPopup);
565
mainPopup->insertSeparator(-1);
566
mainPopup->insertItem (i18n("KSCD Magic"));
567
connect( mainPopup, SIGNAL(activated(int)), SLOT(magicslot(int)) );
570
connect( infoPopup, SIGNAL(activated(int)), SLOT(information(int)) );
571
connect( infoPB, SIGNAL(clicked()), SLOT(showPopup()) );
577
QPoint point = this->mapToGlobal (QPoint(0,0));
580
mainPopup->popup(point);
589
QToolTip::add( playPB, i18n("Play/Pause") );
590
QToolTip::add( stopPB, i18n("Stop") );
591
QToolTip::add( replayPB, i18n("Loop") );
592
QToolTip::add( songListCB, i18n("Track Selection") );
593
QToolTip::add( fwdPB, i18n("30 Secs Forward") );
594
QToolTip::add( bwdPB, i18n("30 Secs Backward") );
595
QToolTip::add( nextPB, i18n("Next Track") );
596
QToolTip::add( prevPB, i18n("Previous Track") );
597
QToolTip::add( dockPB, i18n("Quit Kscd") );
599
QToolTip::add( magicPB, i18n("Run Kscd Magic") );
601
QToolTip::add( aboutPB, i18n("Cycle Time Display") );
602
QToolTip::add( optionsbutton, i18n("Configure Kscd") );
603
QToolTip::add( ejectPB, i18n("Eject CD") );
604
QToolTip::add( infoPB, i18n("The Artist on the Web") );
606
QToolTip::add( shufflebutton, i18n("Random Play") );
608
QToolTip::add( shufflebutton, i18n("Shuffle Play") );
610
QToolTip::add( cddbbutton, i18n("freedb Dialog") );
611
QToolTip::add( volSB, i18n("CD Volume Control") );
613
QToolTip::remove( playPB);
614
QToolTip::remove( stopPB);
615
QToolTip::remove( replayPB);
616
QToolTip::remove( songListCB);
617
QToolTip::remove( fwdPB );
618
QToolTip::remove( bwdPB);
619
QToolTip::remove( nextPB );
620
QToolTip::remove( prevPB );
621
QToolTip::remove( dockPB );
623
QToolTip::remove( magicPB );
625
QToolTip::remove( aboutPB );
626
QToolTip::remove( optionsbutton );
627
QToolTip::remove( ejectPB );
628
QToolTip::remove( infoPB );
629
QToolTip::remove( cddbbutton );
630
QToolTip::remove( shufflebutton );
631
QToolTip::remove( volSB );
638
if (thiscd.trk != NULL)
643
signal (SIGINT, SIG_DFL);
654
qApp->processEvents();
659
#ifdef NEW_BSD_PLAYCLICKED
660
cur_cdmode == WM_CDM_STOPPED || cur_cdmode == WM_CDM_UNKNOWN || cur_cdmode == WM_CDM_BACK
662
cur_cdmode == WM_CDM_STOPPED || cur_cdmode == WM_CDM_UNKNOWN
666
statuslabel->setText( i18n("Playing") );
671
QStringList::Iterator it = tracktitlelist.begin();
674
for ( ; it != tracktitlelist.end(); ++it )
677
QString str = QString::fromLatin1("%1: %2")
678
.arg(QString::number(i).rightJustify(2, '0'))
680
songListCB->insertItem( str );
683
// We don't know the rest, but we should still have entries
684
for( ; i < cur_ntracks; i++)
686
songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("%02d: <Unknown>").utf8(), i+1) ) );
689
qApp->processEvents();
692
if(!playlist.isEmpty())
694
if(playlistpointer >=(int) playlist.count())
696
wm_cd_play (atoi((*playlist.at(playlistpointer)).ascii()), 0,
697
atoi((*playlist.at(playlistpointer)).ascii()) + 1);
698
save_track = cur_track = atoi((*playlist.at(playlistpointer)).ascii());
700
wm_cd_play (save_track, 0, cur_ntracks + 1);
702
} else { // if (WM_CDM_STOPPED||UNKNOWN)
703
if (cur_cdmode == WM_CDM_PLAYING || cur_cdmode == WM_CDM_PAUSED)
709
statuslabel->setText( i18n("Pause") );
716
statuslabel->setText( i18n("Shuffle") );
718
statuslabel->setText( i18n("Random") );
720
statuslabel->setText( i18n("Playing") );
726
// next release: force "stop".
727
statuslabel->setText( i18n("Strange....") );
730
qApp->processEvents();
732
} // if (PLAYING||PAUSED)
733
} // if (WM_CDM_STOPPED||UNKNOWN) else
742
stoppedByUser = TRUE;
743
statuslabel->setText(i18n("Stopped"));
745
qApp->processEvents();
748
save_track = cur_track = 1;
757
qApp->processEvents();
760
if(!playlist.isEmpty())
763
if(playlistpointer < 0 )
765
playlistpointer = playlist.count() -1;
767
cur_track = atoi((*playlist.at(playlistpointer)).ascii());
769
// djoham@netscape.net suggested the real-world cd-player behaviour
770
// of only jumping to the beginning of the current track if playing
771
// advanced more than 2 seconds. I think that's good, but maybe I'll
772
// make this configurable.
773
if(!(cur_pos_rel > 2))
776
cur_track = cur_ntracks;
780
wm_cd_play (cur_track, 0, cur_track + 1);
782
wm_cd_play (cur_track, 0, cur_ntracks + 1);
790
qApp->processEvents();
795
int j = randomtrack();
798
tracklabel->setText(formatTrack(j, cd->ntracks));
800
if(j < (int)tracktitlelist.count())
802
setArtistAndTitle(tracktitlelist.first(),
803
*tracktitlelist.at(j));
805
qApp->processEvents();
808
wm_cd_play( j, 0, j + 1 );
810
} else if(!playlist.isEmpty()) {
811
if(playlistpointer < (int)playlist.count() - 1)
816
wm_cd_play (atoi((*playlist.at(playlistpointer)).ascii()),
817
0, atoi((*playlist.at(playlistpointer)).ascii()) + 1);
818
cur_track = atoi( (*playlist.at(playlistpointer)).ascii() );
820
if (cur_track == cur_ntracks)
822
wm_cd_play (cur_track + 1, 0, cur_ntracks + 1);
829
qApp->processEvents();
832
if (cur_cdmode == WM_CDM_PLAYING)
834
tmppos = cur_pos_rel + 30;
835
if (tmppos < thiscd.trk[cur_track - 1].length)
837
if(randomplay || !playlist.isEmpty())
838
wm_cd_play (cur_track, tmppos, cur_track + 1);
840
wm_cd_play (cur_track, tmppos, cur_ntracks + 1);
848
qApp->processEvents();
851
if (cur_cdmode == WM_CDM_PLAYING)
853
tmppos = cur_pos_rel - 30;
854
if(randomplay || !playlist.isEmpty())
855
wm_cd_play (cur_track, tmppos > 0 ? tmppos : 0, cur_track + 1);
857
wm_cd_play (cur_track, tmppos > 0 ? tmppos : 0, cur_ntracks + 1);
867
statuslabel->clear();
870
qApp->processEvents();
890
KSCD::closeEvent( QCloseEvent *e )
895
statuslabel->clear();
899
qApp->processEvents();
913
KSCD::event( QEvent *e )
915
return QWidget::event(e);
925
qApp->processEvents();
935
qApp->processEvents();
942
// randomplay = FALSE;
953
* Do everything needed if the user requested to eject the disc.
961
if(!currentlyejected)
965
statuslabel->setText(i18n("Ejecting"));
966
qApp->processEvents();
968
setArtistAndTitle("", "");
969
tracktitlelist.clear();
975
* new checkmount goes here
980
statuslabel->setText(i18n("Closing"));
981
qApp->processEvents();
989
KSCD::randomSelected()
991
if(randomplay == TRUE)
998
statuslabel->setText(i18n("Shuffle"));
1000
statuslabel->setText(i18n("Random"));
1003
if(tracktitlelist.count()==0)
1005
make_random_list(); /* koz: Build a unique, once, random list */
1006
int j = randomtrack();
1007
tracklabel->setText(formatTrack(j, cd->ntracks));
1008
if(tracktitlelist.count()!=0 && j < (int)tracktitlelist.count())
1010
setArtistAndTitle(tracktitlelist.first(),
1011
*tracktitlelist.at(j));
1013
qApp->processEvents();
1016
wm_cd_play( j, 0, j + 1 );
1022
* A Track was selected for playback from the drop down box.
1026
KSCD::trackSelected( int trk )
1029
tracklabel->setText( formatTrack( trk + 1, cd->ntracks ) );
1031
if(trk+1 < (int)tracktitlelist.count())
1033
setArtistAndTitle(tracktitlelist.first(),
1034
*tracktitlelist.at(trk+1));
1038
qApp->processEvents();
1041
cur_track = trk + 1;
1043
wm_cd_play( cur_track, 0, cur_ntracks + 1 );
1047
KSCD::aboutClicked()
1049
QString server_copy;
1050
server_copy = current_server;
1052
QTabDialog * tabdialog;
1054
tabdialog = new QTabDialog(this,"tabdialog",TRUE);
1055
tabdialog->setCaption( i18n("kscd Configuraton") );
1056
tabdialog->resize(559, 512);
1057
tabdialog->setCancelButton( i18n("Cancel") );
1059
QWidget *about = new QWidget(tabdialog,"about");
1060
QBoxLayout * lay1 = new QVBoxLayout ( about, 10 );
1061
QGroupBox *box = new QGroupBox(about,"box");
1062
lay1->addWidget ( box );
1063
QBoxLayout * lay2 = new QHBoxLayout ( box, 15 );
1065
QPixmap pm = UserIcon("kscdlogo");
1066
QLabel *logo = new QLabel(box);
1067
logo->setPixmap(pm);
1068
logo->setFixedSize(pm.width(), pm.height());
1069
lay2->addWidget ( logo );
1071
QString labelstring;
1072
labelstring = i18n("kscd %1\n").arg(KSCDVERSION);
1073
labelstring += i18n(
1074
"Copyright (c) 1997-2001 \nBernd Johannes Wuebben <wuebben@kde.org>\n"
1075
"Copyright (c) 1999-2001 \nDirk Försterling <milliByte@gmx.net>\n"
1076
" (current Maintainer)\n\n"
1077
"Kscd is based in part on WorkMan,\n"
1078
"Copyright (c) 1991-1996 Steven Grimm\n"
1079
"Copyright (c) 1996-2001 Dirk Försterling <milliByte@gmx.net>\n\n"
1080
"Special thanks to freedb.org for "
1081
"providing a free CDDB-like "
1083
"Visit http://www.freedb.org/ for "
1084
"more information on freedb.\n\n"
1088
labelstring += i18n(
1089
"KSCD Magic based on Synaesthesia by "
1090
"Paul Harrison <pfh@yoyo.cc.monash.edu.au>\n\n");
1092
labelstring += i18n(
1093
"Thanks to Vadim Zaliva <lord@crocodile.org>\n"
1094
"for his work on the http proxy code.\n\n") ;
1097
QLabel *label = new QLabel(box,"label");
1098
label->setAlignment(AlignLeft|WordBreak|ExpandTabs);
1099
label->setText(labelstring);
1100
lay2->addWidget ( label );
1103
struct configstruct config;
1104
config.background_color = background_color;
1105
config.led_color = led_color;
1106
config.tooltips = tooltips;
1107
config.cd_device = QFile::decodeName(cd_device);
1108
config.browsercmd = browsercmd;
1109
config.use_kfm = use_kfm;
1110
config.docking = docking;
1111
config.autoplay = autoplay;
1112
config.stopexit = stopexit;
1113
config.ejectonfinish = ejectonfinish;
1114
config.randomonce = randomonce;
1116
dlg = new ConfigDlg(tabdialog,&config,"configdialg");
1118
setup = new CDDBSetup(tabdialog,"cddbsetupdialog");
1119
connect(setup,SIGNAL(updateCDDBServers()),this,SLOT(getCDDBservers()));
1120
connect(setup,SIGNAL(updateCurrentServer()),this,SLOT(updateCurrentCDDBServer()));
1121
setup->insertData(cddbserverlist,
1127
cddb_remote_enabled,
1129
cddb.useHTTPProxy(),
1130
cddb.getHTTPProxyHost(),
1131
cddb.getHTTPProxyPort()
1135
struct mgconfigstruct mgconfig;
1136
mgconfig.width = magic_width;
1137
mgconfig.height = magic_height;
1138
mgconfig.brightness = magic_brightness;
1139
mgconfig.pointsAreDiamonds = magic_pointsAreDiamonds;
1140
mgdlg = new MGConfigDlg(tabdialog,&mgconfig,"mgconfigdialg");
1142
smtpconfig = new SMTPConfig(tabdialog, "smtpconfig", &smtpConfigData);
1144
tabdialog->addTab(setup,"freedb");
1145
tabdialog->addTab(smtpconfig, i18n("SMTP Setup"));
1146
tabdialog->addTab(dlg,i18n("Kscd Options"));
1148
tabdialog->addTab(mgdlg,i18n("Kscd Magic"));
1150
tabdialog->addTab(about,i18n("About"));
1154
if(tabdialog->exec() == QDialog::Accepted)
1156
smtpconfig->commitData();
1157
background_color = dlg->getData()->background_color;
1158
led_color = dlg->getData()->led_color;
1159
tooltips = dlg->getData()->tooltips;
1161
browsercmd = dlg->getData()->browsercmd;
1162
use_kfm = dlg->getData()->use_kfm;
1163
docking = dlg->getData()->docking;
1164
autoplay = dlg->getData()->autoplay;
1165
stopexit = dlg->getData()->stopexit;
1166
ejectonfinish = dlg->getData()->ejectonfinish;
1167
randomonce = dlg->getData()->randomonce;
1169
if( (QString)cd_device != dlg->getData()->cd_device)
1171
cd_device_str = dlg->getData()->cd_device;
1172
cd_device = (char *)qstrdup(QFile::encodeName(cd_device_str));
1173
cur_cdmode = WM_CDM_DEVICECHANGED;
1174
device_change = true;
1175
setArtistAndTitle("", "");
1176
tracktitlelist.clear();
1178
songListCB->clear();
1181
cddrive_is_ok = true;
1183
magic_width = mgdlg->getData()->width;
1184
magic_height = mgdlg->getData()->height;
1185
magic_brightness = mgdlg->getData()->brightness;
1186
magic_pointsAreDiamonds = mgdlg->getData()->pointsAreDiamonds;
1188
bool cddb_proxy_enabled;
1189
QString cddb_proxy_host;
1190
unsigned short int cddb_proxy_port;
1191
unsigned short int cddb_timeout;
1193
setup->getData(cddbserverlist,
1199
cddb_remote_enabled,
1205
cddb.setTimeout(cddb_timeout);
1206
cddb.setHTTPProxy(cddb_proxy_host,cddb_proxy_port);
1207
cddb.useHTTPProxy(cddb_proxy_enabled);
1213
dock_widget->show();
1215
dock_widget->hide();
1218
// reset the current server in case we played with it ...
1219
current_server = server_copy;
1220
kdDebug() << "RESETTING SERVER TO: " << current_server << "\n" << endl;
1223
disconnect(setup,SIGNAL(updateCDDBServers()),this,SLOT(getCDDBservers()));
1224
disconnect(setup,SIGNAL(updateCurrentServer()),this,SLOT(updateCurrentCDDBServer()));
1238
KSCD::updateCurrentCDDBServer()
1242
setup->getCurrentServer(current_server);
1243
kdDebug() << "SET SERVER TO: " << current_server << "\n" << endl;
1245
} // updateCurrentCDDBServer
1248
KSCD::volChanged( int vol )
1254
str = QString::fromUtf8( QCString().sprintf( i18n("Vol: %02d%%").utf8(),vol) );
1255
volumelabel->setText(str);
1256
cd_volume(vol, 10, 100); // 10 -> right == left balance
1264
/* koz: 15/01/00. Check to see if we want to do a randomonce. If so */
1265
/* we execute the first set of statements. Else we execute the second */
1266
/* set, the original code. */
1269
if( !playlist.isEmpty() )
1271
/* Check to see if we are at the end of the list */
1272
if( (unsigned int)random_current >= playlist.count() )
1282
int j = random_list[random_current++];
1283
playlistpointer = j;
1284
return atoi( (*playlist.at(j)).ascii() );
1285
} else { // playlist.count > 0
1286
if( random_current >= cur_ntracks )
1296
return( random_list[random_current++] );
1297
} // playlist.count > 0
1300
if( !playlist.isEmpty() )
1303
j = (int) randSequence.getLong(playlist.count());
1304
playlistpointer = j;
1305
return atoi( (*playlist.at(j)).ascii() );
1308
j = (cur_ntracks == 0) ? 0 : (1 + (int) randSequence.getLong(cur_ntracks));
1316
* - 'No disc' handling is missing
1317
* - Data discs not recognized as data discs.
1324
static char *p = new char[10];
1325
static bool damn = TRUE;
1328
sss = wm_cd_status();
1334
if(cddrive_is_ok && (sss != WM_ERR_SCSI_INQUIRY_FAILED))
1336
statuslabel->setText( i18n("Error") );
1337
cddrive_is_ok = false;
1339
i18n("CDROM read or access error (or no audio disc in drive).\n"\
1340
"Please make sure you have access permissions to:\n%1")
1342
KMessageBox::error(this, errstring, i18n("Error"));
1346
cddrive_is_ok = true; // cd drive ok
1348
if(cur_cdmode == WM_CDM_EJECTED)
1349
currentlyejected = true;
1351
currentlyejected = false;
1353
if( device_change == true )
1355
device_change = false;
1356
cur_cdmode = WM_CDM_STOPPED;
1360
switch (cur_cdmode) {
1361
case WM_CDM_UNKNOWN:
1362
cur_track = save_track = 1;
1363
statuslabel->setText( "" ); // TODO how should I properly handle this
1367
case WM_CDM_TRACK_DONE: // == WM_CDM_BACK
1370
int j = randomtrack();
1371
wm_cd_play( j, 0, j + 1 );
1374
else if (playlist.count() > 0)
1376
if(playlistpointer < (int)playlist.count() - 1)
1379
playlistpointer = 0;
1380
wm_cd_play(atoi( (*playlist.at(playlistpointer)).ascii() ),0,atoi((*playlist.at(playlistpointer)).ascii())+1);
1384
if (cur_track == cur_ntracks)
1387
wm_cd_play (1, 0, cur_ntracks + 1);
1391
cur_track = save_track = 1;
1392
statuslabel->clear(); // TODO how should I properly handle this
1397
case WM_CDM_PLAYING:
1402
statuslabel->setText( i18n("Shuffle") );
1404
statuslabel->setText( i18n("Random") );
1407
// statuslabel->setText( i18n("Loop") );
1409
statuslabel->setText( i18n("Playing") );
1411
sprintf( p, "%02d ", cur_track );
1412
if (songListCB->count() == 0)
1414
// we are in here when we start kscd and
1415
// the cdplayer is already playing.
1417
songListCB->clear();
1418
QStringList::Iterator it = tracktitlelist.begin();
1420
for ( ; it != tracktitlelist.end(); ++it )
1423
songListCB->insertItem( QString("").sprintf("%02d: %s", i, (*it).utf8().data()));
1425
for(; i < cur_ntracks; i++)
1427
songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("%02d: <Unknown>").utf8(), i+1)) );
1430
// for (int i = 0; i < cur_ntracks; i++){
1431
// songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("Track %02d").utf8(),i + 1 ) ) );
1433
songListCB->setCurrentItem( cur_track - 1 );
1434
have_new_cd = false;
1435
get_cddb_info(false); // false == do not update dialog if open
1437
songListCB->setCurrentItem( cur_track - 1 );
1439
tracklabel->setText( formatTrack(cur_track, cd->ntracks) );
1441
if((cur_track < (int)tracktitlelist.count()) && (cur_track >= 0))
1443
setArtistAndTitle(tracktitlelist.first(),
1444
*tracktitlelist.at(cur_track));
1449
stoppedByUser = false;
1452
case WM_CDM_FORWARD:
1456
statuslabel->setText( i18n("Pause") );
1460
case WM_CDM_STOPPED:
1462
if(ejectonfinish && !stoppedByUser){
1463
stoppedByUser = true;
1467
statuslabel->setText( i18n("Ready") );
1469
songListCB->clear();
1472
songListCB->clear();
1473
QStringList::Iterator it = tracktitlelist.begin();
1475
for ( ; it != tracktitlelist.end(); ++it )
1478
songListCB->insertItem( QString().sprintf("%02d: %s", i, (*it).utf8().data()));
1480
for(; i < cur_ntracks; i++){
1481
songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("%02d: <Unknown>").utf8(), i+1)) );
1484
// for (i = 0; i < cur_ntracks; i++)
1485
// songListCB->insertItem( QString( 0 ).sprintf( i18n("Track %02d"), i + 1 ) );
1487
int w = ((cur_track >= 0) ? cur_track : 1);
1489
tracklabel->setText( formatTrack( cur_track >= 0 ? cur_track : 1, cd->ntracks) );
1491
if( w < (int)tracktitlelist.count()){
1492
setArtistAndTitle(tracktitlelist.first(),
1493
*tracktitlelist.at( w ));
1500
have_new_cd = false;
1501
// timer must be restarted when we are doen
1502
// with getting the cddb info
1503
get_cddb_info(false); // false == do not update dialog if open
1504
if(autoplay && ejectedBefore)
1510
case WM_CDM_EJECTED:
1511
statuslabel->setText( i18n("Ejected") );
1512
setArtistAndTitle("", "");
1513
tracktitlelist.clear();
1515
songListCB->clear();
1517
tracklabel->setText( "--/--" );
1518
setArtistAndTitle("", "");
1519
totaltimelabel->clear();
1520
totaltimelabel->lower();
1522
ejectedBefore = TRUE;
1529
KSCD::setLEDs(const QString& symbols)
1532
// nLEDs->setText(symbols);
1534
if(symbols.length() < 5){
1538
for(int i=0;i<5;i++){
1539
trackTimeLED[i]->display(symbols[i].latin1());
1547
backdrop->setBackgroundColor(background_color);
1549
QColorGroup colgrp( led_color, background_color, led_color,led_color , led_color,
1552
titlelabel ->setPalette( QPalette(colgrp,colgrp,colgrp) );
1553
artistlabel->setPalette( QPalette(colgrp,colgrp,colgrp) );
1554
volumelabel->setPalette( QPalette(colgrp,colgrp,colgrp) );
1555
statuslabel->setPalette( QPalette(colgrp,colgrp,colgrp) );
1556
tracklabel ->setPalette( QPalette(colgrp,colgrp,colgrp) );
1557
totaltimelabel->setPalette( QPalette(colgrp,colgrp,colgrp) );
1558
// nLEDs->setPalette( QPalette(colgrp,colgrp,colgrp) );
1561
queryled->setPalette( QPalette(colgrp,colgrp,colgrp) );
1562
loopled->setPalette( QPalette(colgrp,colgrp,colgrp) );
1564
for (int u = 0; u< 5;u++){
1565
trackTimeLED[u]->setLEDoffColor(background_color);
1566
trackTimeLED[u]->setLEDColor(led_color,background_color);
1569
titlelabel ->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1570
artistlabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1571
volumelabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1572
statuslabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1573
tracklabel ->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1574
totaltimelabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1575
artistlabel->setFont( QFont( "Helvetica", smallPtSize(), QFont::Bold) );
1581
KSCD::readSettings()
1583
config = kapp->config();
1585
config->setGroup("GENERAL");
1586
volume = config->readNumEntry("Volume",40);
1587
tooltips = config->readBoolEntry("ToolTips", true);
1588
randomplay = config->readBoolEntry("RandomPlay", false);
1589
use_kfm = config->readBoolEntry("USEKFM", true);
1590
docking = config->readBoolEntry("DOCKING", true);
1591
autoplay = config->readBoolEntry("AUTOPLAY", false);
1592
stopexit = config->readBoolEntry("STOPEXIT", true);
1593
ejectonfinish = config->readBoolEntry("EJECTONFINISH", false);
1594
randomonce = (bool)config->readBoolEntry("RANDOMONCE",true);
1595
looping = config->readBoolEntry("Looping",false);
1596
browsercmd = config->readEntry("CustomBrowserCmd","kfmclient openURL %s");
1599
#ifdef DEFAULT_CD_DEVICE
1601
// sun ultrix etc have a canonical cd rom device specified in the
1602
// respective plat_xxx.c file. On those platforms you need nnot
1603
// specify the cd rom device and DEFAULT_CD_DEVICE is not defined
1606
cd_device_str = config->readEntry("CDDevice",DEFAULT_CD_DEVICE);
1608
cd_device = (char *)qstrdup(QFile::encodeName(cd_device_str));
1613
QColor defaultback = black;
1614
QColor defaultled = QColor(226,224,255);
1615
background_color = config->readColorEntry("BackColor",&defaultback);
1616
led_color = config->readColorEntry("LEDColor",&defaultled);
1618
config->setGroup("MAGIC");
1619
magic_width = config->readNumEntry("magicwidth",320);
1620
magic_height = config->readNumEntry("magicheight",200);
1621
magic_brightness = config->readNumEntry("magicbrightness", 3);
1622
magic_pointsAreDiamonds = config->readBoolEntry("magicPointsAreDiamonds", false);
1624
config->setGroup("SMTP");
1625
smtpConfigData.enabled = config->readBoolEntry("enabled", true);
1626
smtpConfigData.mailProfile = config->readEntry("mailProfile", i18n("Default"));
1628
// Same as follows happens in smtpconfig.cpp. Try to remove one.
1629
KEMailSettings *kes = new KEMailSettings();
1630
kes->setProfile( smtpConfigData.mailProfile );
1631
smtpConfigData.serverHost = kes->getSetting( KEMailSettings::OutServer );
1632
smtpConfigData.serverPort = "25";
1633
smtpConfigData.senderAddress = kes->getSetting( KEMailSettings::EmailAddress );
1634
smtpConfigData.senderReplyTo = kes->getSetting( KEMailSettings::ReplyToAddress );
1635
// Don't accept obviously bogus settings.
1636
if( (smtpConfigData.serverHost == "") || (!smtpConfigData.senderAddress.contains("@")))
1638
smtpConfigData.enabled = false;
1641
config->setGroup("CDDB");
1643
cddb.setTimeout(config->readNumEntry("CDDBTimeout",60));
1644
cddb_auto_enabled = config->readBoolEntry("CDDBLocalAutoSaveEnabled",false);
1645
cddbbasedir = config->readEntry("LocalBaseDir");
1646
if (cddbbasedir.isEmpty())
1647
cddbbasedir = KGlobal::dirs()->resourceDirs("cddb").last();
1648
KGlobal::dirs()->addResourceDir("cddb", cddbbasedir);
1650
// Set this to false by default. Look at the settings dialog source code
1651
// for the reason. - Juraj.
1652
cddb_remote_enabled = config->readBoolEntry("CDDBRemoteEnabled",
1654
cddb.useHTTPProxy(config->readBoolEntry("CDDBHTTPProxyEnabled",
1655
KProtocolManager::useProxy()));
1659
QString proxy = KProtocolManager::httpProxy();
1660
if( !proxy.isEmpty() )
1663
proxyHost = proxyURL.host();
1664
proxyPort = proxyURL.port();
1668
cddb.useHTTPProxy(false);
1670
cddb.setHTTPProxy(config->readEntry("HTTPProxyHost",proxyHost),
1671
config->readNumEntry("HTTPProxyPort",proxyPort));
1673
current_server = config->readEntry("CurrentServer",DEFAULT_CDDB_SERVER);
1674
//Let's check if it is in old format and if so, convert it to new one:
1675
if(CDDB::normalize_server_list_entry(current_server))
1677
kdDebug() << "Default freedb server entry converted to new format and saved.\n" << endl;
1678
config->writeEntry("CurrentServer",current_server);
1681
submitaddress = config->readEntry("CDDBSubmitAddress","freedb-submit@freedb.org");
1682
cddbserverlist = config->readListEntry("SeverList", ',');
1683
int num = cddbserverlist.count();
1685
cddbserverlist.append(DEFAULT_CDDB_SERVER);
1688
//Let's check if it is in old format and if so, convert it to new one:
1689
bool needtosave=false;
1692
for ( QStringList::Iterator it = cddbserverlist.begin();
1693
it != cddbserverlist.end();
1696
needtosave|=CDDB::normalize_server_list_entry(*it);
1701
// I have to recreate list because of sytange behaviour of sync()
1702
// function in configuration - it does not notice if QStringList
1703
// String contents is changed.
1704
cddbserverlist=nlist;
1705
kdDebug() << "freedb server list converted to new format and saved.\n" << endl;
1706
config->writeEntry("SeverList",cddbserverlist,',',true);
1710
cddbsubmitlist = config->readListEntry("SubmitList", ',');
1711
num = cddbsubmitlist.count();
1713
cddbsubmitlist.append(DEFAULT_SUBMIT_EMAIL);
1714
cddbsubmitlist.append(DEFAULT_TEST_EMAIL);
1719
* Write KSCD's Configuration into the kderc file.
1723
KSCD::writeSettings()
1725
config = kapp->config();
1727
config->setGroup("GENERAL");
1728
config->writeEntry("ToolTips", tooltips);
1729
config->writeEntry("RandomPlay", randomplay);
1730
config->writeEntry("USEKFM", use_kfm);
1731
config->writeEntry("DOCKING", docking);
1732
config->writeEntry("AUTOPLAY", autoplay);
1733
config->writeEntry("STOPEXIT", stopexit);
1734
config->writeEntry("EJECTONFINISH", ejectonfinish);
1735
config->writeEntry("RANDOMONCE", randomonce);
1736
config->writeEntry("CDDevice", QFile::decodeName(cd_device));
1737
config->writeEntry("CustomBrowserCmd",browsercmd);
1738
config->writeEntry("Volume", volume);
1739
config->writeEntry("BackColor",background_color);
1740
config->writeEntry("LEDColor",led_color);
1741
config->writeEntry("Looping", looping);
1743
config->setGroup("SMTP");
1744
config->writeEntry("enabled", smtpConfigData.enabled);
1745
config->writeEntry("mailProfile", smtpConfigData.mailProfile);
1747
config->setGroup("CDDB");
1748
config->writeEntry("CDDBRemoteEnabled",cddb_remote_enabled);
1749
config->writeEntry("CDDBTimeout",cddb.getTimeout());
1750
config->writeEntry("CDDBLocalAutoSaveEnabled",cddb_auto_enabled);
1752
config->writeEntry("LocalBaseDir",cddbbasedir);
1753
config->writeEntry("SeverList",cddbserverlist);
1754
config->writeEntry("SubmitList", cddbsubmitlist);
1755
config->writeEntry("CDDBSubmitAddress",submitaddress);
1756
config->writeEntry("CurrentServer",current_server);
1757
config->writeEntry("CDDBHTTPProxyEnabled",cddb.useHTTPProxy());
1758
config->writeEntry("HTTPProxyHost",cddb.getHTTPProxyHost());
1759
config->writeEntry("HTTPProxyPort",(int)cddb.getHTTPProxyPort());
1761
config->setGroup("MAGIC");
1762
config->writeEntry("magicwidth",magic_width);
1763
config->writeEntry("magicheight",magic_height);
1764
config->writeEntry("magicbrightness",magic_brightness);
1765
config->writeEntry("magicPointsAreDiamonds",magic_pointsAreDiamonds);
1768
} // writeSettings()
1771
KSCD::CDDialogSelected()
1773
kdDebug() << "CDDialogSelected" << endl;
1777
kdDebug() << "dialog was empty" << endl;
1779
cddialog = new CDDialog();
1781
cddialog->setData(cd,tracktitlelist,extlist,discidlist,xmcd_data,category,
1782
revision,playlist,pathlist,cddbbasedir,submitaddress, &smtpConfigData);
1784
connect(cddialog,SIGNAL(cddb_query_signal(bool)),this,SLOT(get_cddb_info(bool)));
1785
connect(cddialog,SIGNAL(dialog_done()),this,SLOT(CDDialogDone()));
1786
connect(cddialog,SIGNAL(play_signal(int)),this,SLOT(trackSelected(int)));
1792
KSCD::CDDialogDone()
1794
kdDebug() << "cddialog -> done" << endl;
1801
KSCD::getCDDBservers()
1805
// Get current server and proxy settings from CDDB setup dialog befoe proceed
1806
bool cddb_proxy_enabled;
1807
QString cddb_proxy_host;
1808
unsigned short int cddb_proxy_port;
1809
unsigned short int cddb_timeout;
1811
setup->getData(cddbserverlist,
1817
cddb_remote_enabled,
1823
cddb.setTimeout(cddb_timeout);
1824
cddb.setHTTPProxy(cddb_proxy_host,cddb_proxy_port);
1825
cddb.useHTTPProxy(cddb_proxy_enabled);
1827
connect(&cddb,SIGNAL(get_server_list_done()),this,SLOT(getCDDBserversDone()));
1828
connect(&cddb,SIGNAL(get_server_list_failed()),this,SLOT(getCDDBserversFailed()));
1830
// For now, just don't update if there's no current server.
1831
if(!current_server.isEmpty())
1832
cddb.cddbgetServerList(current_server);
1833
} // getCDDBservers()
1836
KSCD::getCDDBserversFailed()
1840
disconnect(&cddb,SIGNAL(get_server_list_done()),this,SLOT(getCDDBserversDone()));
1841
disconnect(&cddb,SIGNAL(get_server_list_failed()),this,SLOT(getCDDBserversFailed()));
1842
setArtistAndTitle(i18n("Unable to get freedb server list."), "");
1843
titlelabeltimer->start(10000,TRUE); // 10 secs
1847
KSCD::getCDDBserversDone()
1851
disconnect(&cddb,SIGNAL(get_server_list_done()),this,SLOT(getCDDBserversDone()));
1852
disconnect(&cddb,SIGNAL(get_server_list_failed()),this,SLOT(getCDDBserversFailed()));
1853
cddb.serverList(cddbserverlist);
1855
setup->insertServerList(cddbserverlist);
1858
#ifdef NEEDOWNCDDBDISCID
1865
long unsigned int ntemp = 0;
1866
ntemp = (long unsigned int) n;
1868
/* For backward compatibility this algorithm must not change */
1869
sprintf(buf, "%lu", ntemp);
1870
for (p = buf; *p != '\0'; p++)
1885
/* For backward compatibility this algorithm must not change */
1886
for (i = 0; i < thicd.ntracks; i++)
1889
min = thiscd.trk[i].start / (4500); // 60 * 75
1890
sec = (thiscd.trk[i].start % (4500)) / 75;
1891
n += cddb_sum((min * 60) + sec);
1893
n += cddb_sum(thiscd.trk[i].start / 75);
1897
t = ((thiscd.cddbtoc[thiscd.ntracks].min * 60)
1898
+ thiscd.cddbtoc[thiscd.ntracks].sec) -
1899
((thiscd.cddbtoc[0].min * 60) + thiscd.cddbtoc[0].sec);
1901
t = ((thiscd.trk[thiscd.ntracks].start / 75) -
1902
(thiscd.trk[0].start / 75));
1904
return ((n % 0xff) << 24 | t << 8 | thiscd.ntracks);
1910
KSCD::get_cddb_info(bool _updateDialog)
1912
static int connected = 0;
1914
updateDialog = _updateDialog;
1917
dml = dml.addSecs(cd->length);
1921
fmt.sprintf("%02d:%02d:%02d",dml.hour(),dml.minute(),dml.second());
1923
fmt.sprintf("%02d:%02d",dml.minute(),dml.second());
1925
totaltimelabel->setText(fmt);
1927
get_pathlist(pathlist);
1928
cddb.setPathList(pathlist);
1931
connect(&cddb,SIGNAL(cddb_ready()),this,SLOT(cddb_ready()));
1932
connect(&cddb,SIGNAL(cddb_failed()),this,SLOT(cddb_failed()));
1933
connect(&cddb,SIGNAL(cddb_done()),this,SLOT(cddb_done()));
1934
connect(&cddb,SIGNAL(cddb_timed_out()),this,SLOT(cddb_timed_out()));
1935
connect(&cddb,SIGNAL(cddb_inexact_read()),this,SLOT(mycddb_inexact_read()));
1936
connect(&cddb,SIGNAL(cddb_no_info()),this,SLOT(cddb_no_info()));
1941
bool res = cddb.local_query(
1951
Fetch_remote_cddb = false;
1952
if(!res && !cddb_remote_enabled){
1953
// have_new_cd = false;
1960
kdDebug() << "STARTING REMOTE QUERY\n" << endl;
1961
cddb.cddb_connect(current_server);
1962
Fetch_remote_cddb = true;
1966
kdDebug() << "FOUND RECORD LOCALLY\n" << endl;
1967
if((int)tracktitlelist.count() != (cd->ntracks + 1)){
1968
kdDebug() << "WARNING LOCAL QUERY tracktitleslist.count = " << tracktitlelist.count() << " != cd->ntracks +1 = " << cd->ntracks + 1 << "\n" << endl;
1971
if((int)extlist.count() != (cd->ntracks + 1)){
1972
kdDebug() << "WARNING LOCAL QUERYextlist.count = " << extlist.count() << " != cd->ntracks +1 = " << cd->ntracks + 1 << "\n" << endl;
1975
if(tracktitlelist.count() > 1){
1976
setArtistAndTitle(tracktitlelist.first(),
1977
*tracktitlelist.at(1));
1981
songListCB->clear();
1982
QStringList::Iterator it = tracktitlelist.begin();
1984
for ( ; it != tracktitlelist.end(); ++it )
1987
songListCB->insertItem( QString("").sprintf("%02d: %s", i, (*it).utf8().data()));
1989
for(; i < cur_ntracks; i++){
1990
songListCB->insertItem( QString::fromUtf8(QCString("").sprintf(i18n("%02d: <Unknown>").utf8(), i+1)) );
1997
if(cddialog && updateDialog)
1998
cddialog->setData(cd,tracktitlelist,extlist,discidlist,xmcd_data,category,
1999
revision,playlist,pathlist,cddbbasedir,submitaddress, &smtpConfigData);
2000
playlistpointer = 0;
2003
// have_new_cd = false;
2007
int cddb_ready_bug = 0;
2011
kdDebug() << "cddb_ready() called\n" << endl;
2015
/* if(cddb_ready_bug)
2020
tracktitlelist.clear();
2021
setArtistAndTitle("", "");
2027
for(int i = 0 ; i < cd->ntracks; i++)
2029
querylist.append(num.setNum(cd->trk[i].start));
2032
querylist.append(num.setNum(cd->trk[cd->ntracks].start/75));
2033
cddb_inexact_sentinel =false;
2034
cddb.queryCD(cddb_discid(),querylist);
2037
#define DEFINE_CDTEXT
2038
#define CDTEXT_MACRO \
2039
if(wm_cdtext_info.valid){\
2040
kdDebug() << "CDTEXT_MACRO called" << endl;\
2042
setArtistAndTitle("", ""); \
2043
tracktitlelist.clear(); \
2045
tracktitlelist.append(QString().sprintf("%s / %s", (const char*)(wm_cdtext_info.blocks[0]->name[0]),(const char*)(wm_cdtext_info.blocks[0]->performer[0])));\
2046
titlelabel->setText(QString((const char*)(wm_cdtext_info.blocks[0]->name[1])));\
2047
artistlabel->setText(tracktitlelist.first());\
2048
songListCB->clear();\
2049
for (at = 1 ; at < (wm_cdtext_info.count_of_entries); ++at ) {\
2050
songListCB->insertItem( QString().sprintf("%02d: %s", at, wm_cdtext_info.blocks[0]->name[at]));\
2051
tracktitlelist.append((const char*)(wm_cdtext_info.blocks[0]->name[at]));\
2053
for(; at < cur_ntracks; ++at){\
2054
songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("%02d: <Unknown>").utf8(), at)));\
2059
KSCD::cddb_no_info()
2062
// cddb_ready_bug = 0;
2063
kdDebug() << "cddb_no_info() called\n" << endl;
2065
setArtistAndTitle(i18n("No matching freedb entry found."), "");
2066
// artistlabel->clear();
2067
// titlelabeltimer->start(10000,TRUE); // 10 secs
2070
setArtistAndTitle("", "");
2071
tracktitlelist.clear();
2073
tracktitlelist.append(i18n("No matching freedb entry found."));
2074
#ifdef DEFINE_CDTEXT
2078
#endif /* DEFINE_CDTEXT */
2084
cddb_inexact_sentinel =false;
2087
songListCB->clear();
2088
QStringList::Iterator it = tracktitlelist.begin();
2090
for ( ; it != tracktitlelist.end(); ++it )
2093
songListCB->insertItem( QString("").sprintf("%02d: %s", i, (*it).utf8().data()));
2095
for(; i < cur_ntracks; i++)
2097
songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("%02d: <Unknown>").utf8(), i+1)) );
2105
// TODO differentiate between those casees where the communcition really
2106
// failed and those where we just couldn't find anything
2107
// cddb_ready_bug = 0;
2108
kdDebug() << "cddb_failed() called\n" << endl;
2109
setArtistAndTitle("", "");
2110
tracktitlelist.clear();
2112
tracktitlelist.append(i18n("Error getting freedb entry."));
2113
#ifdef DEFINE_CDTEXT
2116
#endif /* DEFINE_CDTEXT */
2118
for(int i = 0 ; i < cd->ntracks; i++)
2119
tracktitlelist.append("");
2122
for(int i = 0 ; i <= cd->ntracks; i++)
2127
setArtistAndTitle(i18n("Error getting freedb entry."), "");
2128
// titlelabeltimer->start(10000,TRUE); // 10 secs
2132
cddb_inexact_sentinel =false;
2137
KSCD::cddb_timed_out()
2139
// cddb_ready_bug = 0;
2140
kdDebug() << "cddb_timed_out() called\n" << endl;
2141
tracktitlelist.clear();
2142
setArtistAndTitle("", "");
2144
tracktitlelist.append(i18n("freedb query timed out."));
2145
#ifdef DEFINE_CDTEXT
2148
#endif /* DEFINE_CDTEXT */
2150
for(int i = 0 ; i <= cd->ntracks; i++)
2151
tracktitlelist.append("");
2154
for(int i = 0 ; i <= cd->ntracks; i++)
2159
setArtistAndTitle(i18n("freedb query timed out."),"");
2160
// titlelabeltimer->start(10000,TRUE); // 10 secs
2164
cddb_inexact_sentinel =false;
2166
} // cddb_timed_out()
2169
KSCD::mycddb_inexact_read()
2171
if(cddb_inexact_sentinel == true)
2176
cddb_inexact_sentinel = true;
2177
QStringList inexact_list;
2178
cddb.get_inexact_list(inexact_list);
2180
// Whatever happens, we better clear the list beforehand
2181
setArtistAndTitle("", "");
2182
tracktitlelist.clear();
2185
if( inexact_list.count() == 1)
2187
pick = inexact_list.first();
2188
cddb.query_exact("200 " + pick);
2192
InexactDialog *dialog;
2193
dialog = new InexactDialog(0,"inexactDialog",true);
2194
dialog->insertList(inexact_list);
2196
if(dialog->exec() != QDialog::Accepted)
2198
cddb.close_connection();
2204
dialog->getSelection(pick);
2215
pick = "200 " + pick;
2216
cddb.query_exact(pick);
2217
} // mycddb_inexact_read
2222
cddb_inexact_sentinel =false;
2224
kdDebug() << "cddb_done() called\n" << endl;
2225
// cddb_ready_bug = 0;
2226
cddb.getData(xmcd_data,tracktitlelist,extlist,category,discidlist,revision,playlist);
2227
playlistpointer = 0;
2229
if((int)tracktitlelist.count() != (cd->ntracks + 1)){
2230
kdDebug() << "WARNING tracktitleslist.count = " << tracktitlelist.count() << " != cd->ntracks +1 = " << cd->ntracks + 1 << "\n" << endl;
2233
if((int)extlist.count() != (cd->ntracks + 1)){
2234
kdDebug() << "WARNING extlist.count = " << extlist.count() << " != cd->ntracks +1 = " << cd->ntracks + 1 << "\n" << endl;
2237
if(tracktitlelist.count() > 1){
2238
setArtistAndTitle(tracktitlelist.first(),
2239
*tracktitlelist.at(1));
2242
if(cddialog && updateDialog)
2243
cddialog->setData(cd,tracktitlelist,extlist,discidlist,xmcd_data,category,
2244
revision,playlist,pathlist,cddbbasedir,submitaddress, &smtpConfigData);
2247
songListCB->clear();
2248
QStringList::Iterator it = tracktitlelist.begin();
2250
for ( ; it != tracktitlelist.end(); ++it )
2253
songListCB->insertItem( QString("").sprintf("%02d: %s", i, (*it).utf8().data()));
2255
for(; i < cur_ntracks; i++){
2256
songListCB->insertItem( QString::fromUtf8( QCString().sprintf(i18n("%02d: <Unknown>").utf8(), i+1)) );
2259
// for (int i = 0; i < cur_ntracks; i++){
2260
// songListCB->insertItem( QString( 0 ).sprintf( i18n("Track %02d"), i + 1 ) );
2264
if(Fetch_remote_cddb)
2266
if(cddb_auto_enabled)
2269
tmp.sprintf("/%08lx",cddb_discid());
2274
// kdDebug() << path << endl << cddbbasedir << category << cddb_discid() << endl;
2275
path.replace(QRegExp("//"),"/");
2276
edm_save_cddb_entry(path);
2285
queryledtimer->stop();
2288
totaltimelabel->raise();
2289
totaltimelabel->show();
2296
totaltimelabel->hide();
2297
totaltimelabel->lower();
2298
queryledtimer->start(800);
2301
kapp->processEvents();
2306
KSCD::togglequeryled()
2314
KSCD::titlelabeltimeout()
2316
// clear the cddb error message on the title label.
2317
titlelabeltimer->stop();
2318
titlelabel->clear();
2320
} // titlelabeltimeout
2323
KSCD::setArtistAndTitle(const QString& artist, const QString& title)
2325
QString tooltip = "";
2326
if (!artist.isEmpty()) {
2327
artistlabel->setText(artist);
2328
tooltip = KStringHandler::rsqueeze(artist, 30) + "\n";
2331
artistlabel->clear();
2334
if (!title.isEmpty()) {
2335
titlelabel->setText(title);
2336
tooltip += KStringHandler::rsqueeze(title,30);
2339
titlelabel->clear();
2342
emit trackChanged(tooltip);
2351
switch(time_display_mode){
2355
tmp = cur_tracklen - cur_pos_rel;
2362
mysec = cur_pos_abs % 60;
2363
mymin = cur_pos_abs / 60;
2368
tmp = cur_cdlen - cur_pos_abs;
2377
if (cur_pos_rel > 0 && (tmp = cur_pos_rel % 60) == mysec)
2380
mymin = cur_pos_rel / 60;
2386
sprintf( tmptime, "%02d:%02d", mymin, mysec );
2392
KSCD::cycleplaytimemode()
2396
if (++time_display_mode > 3)
2397
time_display_mode = 0;
2402
switch(time_display_mode){
2405
volumelabel->setText(i18n("Tra Rem"));
2409
volumelabel->setText(i18n("Tot Sec"));
2413
volumelabel->setText(i18n("Tot Rem"));
2418
volumelabel->setText(i18n("Tra Sec"));
2422
cycletimer->start(3000,TRUE);
2426
KSCD::cycletimeout()
2430
str = QString::fromUtf8( QCString().sprintf(i18n("Vol: %02d%%").utf8(),volume) );
2431
volumelabel->setText(str);
2437
KSCD::getArtist(QString& artist)
2439
if((int)tracktitlelist.isEmpty()){
2443
artist = tracktitlelist.first();
2446
pos = artist.find('/', 0, true);
2448
artist.truncate(pos);
2450
artist = artist.stripWhiteSpace();
2456
KSCD::performances(int i)
2458
kdDebug() << "preformances " << i << "\n" << endl;
2463
if(!getArtist(artist))
2466
// primitive incomplete http encoding TODO fix!
2467
artist = artist.replace( QRegExp(" "), "+" );
2472
QString("http://www.tourdates.com/cgi-bin/search.cgi?type=Artist&search=%1")
2485
KSCD::purchases(int i)
2487
kdDebug() << "purchases " << i << "\n" << endl;
2492
if(!getArtist(artist))
2495
// primitive incomplete http encoding TODO fix!
2496
artist = artist.replace( QRegExp(" "), "+" );
2501
QString("http://cdnow.com/switch/from=sr-288025/target=buyweb_products/artfs=%1")
2508
QString("http://www.cduniverse.com/cgi-bin/cdubin.exe/rlinka/ean=%1")
2527
KSCD::magicslot( int )
2529
if(magicproc && magicproc->isRunning())
2535
magicproc = new KProcess;
2538
b.setNum(magic_brightness);
2540
w.setNum(magic_width);
2542
h.setNum(magic_height);
2544
*magicproc << "kscdmagic" << " -b" << b << " -w"<< w << " -h" << h;
2547
SIGNAL(processExited(KProcess *)),this, SLOT(magicdone(KProcess*)));
2550
bool result = magicproc->start(KProcess::NotifyOnExit , KProcess::Stdin);
2553
KMessageBox::error(this, i18n("Cannot start kscdmagic."));
2558
KSCD::magicdone(KProcess* proc)
2560
if(proc->normalExit())
2562
// fprintf(stderr,"kscdmagic exit status %d\n",proc->exitStatus());
2563
if(proc->exitStatus()!=0)
2564
KMessageBox::error(this, i18n("KSCD Magic exited abnormally.\n"
2565
"Are you sure kscdmagic is installed?"));
2567
// printf("KSCD Magic Process Exited\n");
2575
KSCD::information(int i)
2577
kdDebug() << "Information " << i << "\n" << endl;
2582
if(!getArtist(artist))
2585
// primitive incomplete http encoding TODO fix!
2586
artist = artist.replace( QRegExp(" "), "+" );
2592
QString("http://www.ubl.com/find/form?SEARCH=%1")
2599
QString("http://x8.dejanews.com/dnquery.xp?QRY=%1&defaultOp=AND&svcclass=dncurrent&maxhits=20&ST=QS&format=terse&DBS=2")
2606
QString("http://www.excite.com/search.gw?c=web&search=%1&trace=a")
2613
QString("http://www.search.hotbot.com/hResult.html?SW=web&SM=MC&MT=%1&DC=10&DE=2&RG=NA&_v=2")
2620
QString("http://www.infoseek.com/Titles?qt=%1&col=WW&sv=IS&lk=ip-noframes&nh=10")
2627
QString("http://www.lycos.com/cgi-bin/pursuit?cat=lycos&query=%1")
2634
QString("http://www.mckinley.com/search.gw?search=%1&c=web&look=magellan")
2641
QString("http://search.yahoo.com/bin/search?p=%1")
2652
* Open an URL with the user's favourite browser.
2656
KSCD::startBrowser(const QString &querystring)
2658
if(use_kfm || browsercmd.isEmpty()) // default browser is KDE browser, no?
2660
(void) new KRun ( querystring ); // replacement for KFM::openURL (David)
2663
proc << browsercmd << querystring;
2664
proc.start(KProcess::DontCare);
2670
KSCD::get_pathlist(QStringList& _pathlist)
2674
InexactDialog *dialog;
2676
d.setFilter( QDir::Dirs);
2677
d.setSorting( QDir::Size);
2678
d.setPath(cddbbasedir);
2681
dialog = new InexactDialog(0, "dialog", false);
2682
dialog->insertText(cddbbasedir);
2683
dialog->setTitle(i18n("Enter the local freedb base Directory"));
2685
if(dialog->exec() != QDialog::Accepted)
2691
dialog->getSelection(cddbbasedir);
2692
d.setPath(cddbbasedir);
2696
if(!d.exists()) // Bogus directory, don't try to read it
2700
list = d.entryList();
2702
for ( QStringList::ConstIterator it = list.begin();
2706
if( *it != QString::fromLatin1(".") &&
2707
*it != QString::fromLatin1("..") )
2709
_pathlist.append( cddbbasedir + '/' + *it);
2718
//WABA: Session management has changed
2720
#warning Session management is broken
2723
kapp->setWmCommand(QString(kapp->argv()[0])+" -caption \""+kapp->caption()+"\"");
2725
kapp->setWmCommand(QString(kapp->argv()[0])+" -caption \""+kapp->caption()+"\" -hide ");
2731
kcderror(const QString& title, const QString& message)
2733
KMessageBox::information(0L, message, title);
2736
/* I am dropping this code for now. People seem to be having nothing
2737
but trouble with this code and it was of dubious value anyways....
2741
1) Mark Buckaway checked only if there was an iso9660 filesystem mounted,
2742
not if our device is mounted.
2743
2) Mount check only needs to be done before ejecting the disc.
2747
// check if drive is mounted (from Mark Buckaway's cdplayer code)
2753
if ((fp = setmntent (MOUNTED, "r")) == NULL)
2755
fprintf (stderr, i18n("Couldn't open %s: %s\n"),
2756
MOUNTED, strerror (errno));
2760
while ((mnt = getmntent (fp)) != NULL)
2762
if (strcmp (mnt->mnt_type, "iso9660") == 0)
2764
fputs (i18n("CDROM already mounted. Operation aborted.\n"),
2773
#elif defined (__FreeBSD__)
2780
n = getmntinfo(&mnt, MNT_WAIT);
2783
if (mnt[i].f_type == MOUNT_CD9660)
2785
fputs(i18n("CDROM already mounted. Operation aborted.\n"),
2794
// TODO Can I do this for other platforms?
2804
KSCD::make_random_list()
2806
/* koz: 15/01/00. I want a random list that does not repeat tracks. Ie, */
2807
/* a list is created in which each track is listed only once. The tracks */
2808
/* are picked off one by one until the end of the list */
2810
int selected,size,i,j;
2813
if ( playlist.isEmpty() )
2816
size = playlist.count();
2818
kdDebug() << "Playlist has " << size << " entries\n" << endl;
2819
random_list = (int *)malloc((size_t)size*sizeof(int));
2820
for( i=0; i < size; i++ )
2824
if( playlist.isEmpty() )
2825
selected = 1 + (int) randSequence.getLong(size);
2827
selected = (int) randSequence.getLong(size);
2831
if(random_list[j] == selected)
2837
} while(rejected == true);
2838
random_list[i] = selected;
2840
random_current = 0; /* Index of array we are on */
2842
} // make_random_list()
2846
KSCD::edm_save_cddb_entry(QString& path)
2849
kdDebug() << "::save_cddb_entry(): path: " << path << " edm" << "\n" << endl;
2851
QFile file(path); //open the file
2854
if( !file.open( IO_WriteOnly ))
2856
QString str = i18n("Unable to write to file:\n%1\nPlease check "
2857
"your permissions and make your category directories exist.")
2860
KMessageBox::error(this, str);
2865
QTextStream t(&file);
2867
t << "# xmcd CD database file\n";
2870
datestr = QDateTime::currentDateTime().toString();
2871
tmp = QString("# Generated: %1 by KSCD\n").arg(datestr);
2874
// Waste some disk space
2875
t << "# Copyright (C) 1997-1999 Bernd Johannes Wuebben.\n";
2876
t << "# Copyright (C) 1999-2001 Dirk Foersterling.\n";
2881
t << "# Track frame offsets:\n";
2883
for(int i = 0 ; i < cd->ntracks+1 ;i ++)
2885
tmp = QString("# %1\n").arg(cd->trk[i].start);
2890
tmp = QString("# Disc length: %1 seconds\n").arg(cd->length);
2893
tmp = QString("# Revision: %1\n").arg("8"); //if no revision put 8
2895
t << "# Submitted via: Kscd "KSCDVERSION"\n";
2903
for ( QStringList::Iterator it = discidlist.begin();
2904
it != discidlist.end();
2910
if( num < (int) discidlist.count() - 1)
2912
if( counter++ == 3 )
2925
QStringList returnlist;
2928
tmp2 = *tracktitlelist.at(0);
2929
cddb_encode(tmp2,returnlist);
2931
if(returnlist.count() == 0)
2934
tmp = QString("DTITLE=%1\n").arg("");
2937
for ( QStringList::Iterator it = returnlist.begin();
2938
it != returnlist.end();
2941
tmp = QString("DTITLE=%1\n").arg(*it);
2947
for ( QStringList::Iterator it = tracktitlelist.begin();
2948
it != tracktitlelist.end();
2952
cddb_encode(tmp2,returnlist);
2954
// no perfect solution, but it's working so far.
2955
if( it != tracktitlelist.begin() ) {
2956
if(returnlist.isEmpty())
2959
tmp = QString("TTITLE%1=%2\n").arg(num-1).arg("");
2962
tmp = QString("TTITLE%1=%2\n").arg(num-1).arg(*it);
2969
tmp2 = extlist.first();
2970
cddb_encode(tmp2,returnlist);
2972
if(returnlist.isEmpty())
2975
tmp = tmp.sprintf("EXTD=%s\n","");
2978
for ( QStringList::Iterator it = returnlist.begin();
2979
it != returnlist.end();
2982
tmp = QString("EXTD=%1\n").arg(*it);
2988
for ( QStringList::Iterator it = extlist.at(1);
2989
it != extlist.end();
2993
cddb_encode(tmp2,returnlist);
2995
if(returnlist.count() == 0)
2998
tmp = tmp.sprintf("EXTT%d=%s\n",i-1,"");
3001
for(int j = 0; j < (int) returnlist.count();j++)
3003
tmp = tmp.sprintf("EXTT%d=%s\n",i-1,(*returnlist.at(j)).utf8().data());
3009
cddb_encode(playorder,returnlist);
3011
for(int i = 0; i < (int) returnlist.count();i++)
3013
tmp = tmp.sprintf("PLAYORDER=%s\n", (*returnlist.at(i)).utf8().data());
3019
chmod(QFile::encodeName(file.name()), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
3021
} // save_cddb_entry
3028
main( int argc, char *argv[] )
3031
KAboutData aboutData( "kscd", I18N_NOOP("kscd"),
3032
KSCDVERSION, description,
3033
KAboutData::License_GPL,
3034
"(c) 2001, Dirk F�rsterling");
3035
aboutData.addAuthor("Bernd Johannes Wuebben",0, "wuebben@kde.org");
3036
aboutData.addAuthor("Dirk F�rsterling",0, "milliByte@gmx.net");
3038
KCmdLineArgs::init( argc, argv, &aboutData );
3042
kapp->dcopClient()->attach();
3043
kapp->dcopClient()->registerAs("kscd");
3044
kapp->dcopClient()->setDefaultObject("CDPlayer");
3046
KGlobal::dirs()->addResourceType("cddb",
3047
KStandardDirs::kde_default("data") +
3050
// if (a.isRestored())
3055
KSCD *k = new KSCD();
3060
for(int i = 0; i < argc; i++)
3062
if(strcmp(argv[i],"-hide") == 0)
3067
if(strcmp(argv[i],"-h") == 0)
3069
printf("KSCD "KSCDVERSION
3070
"\n Copyright 1997-99 Bernd Johannes Wuebben wuebben@kde.org\n"
3071
" Copyright 1999-2001 Dirk Foersterling milliByte@gmx.de\n");
3072
printf(i18n("-h: display commandline options\n").local8Bit());
3073
printf(i18n("-d: enable debugging output.\n").local8Bit());
3079
a.setMainWidget( k );
3080
k->setCaption(a.caption());