Пример #1
0
void BasicServer::runQueue()
{  
   if (!isConnected()) {
      QLOG_DEBUG() << "BasicServer::runQueue server not connected";
      return;
   }
   int running(m_server->watchedWithStatus(Process::Running));

   qDebug() << "runQueue() jobLimit:" << m_jobLimit;
   qDebug() << "runQueue() queued:  " << m_queue.size();
   qDebug() << "runQueue() running: " << running;

   while (!m_queue.isEmpty() && running < m_jobLimit) {
      Process* process(m_queue.dequeue());
      ServerTask::Base* task = submitToHost(process);
      if (task) {
         connect(task, SIGNAL(finished()), this, SLOT(submitFinished()));
         task->start();
         ++running;
      }
   }
}
Пример #2
0
CDDBDlg::CDDBDlg( QWidget* parent, const char* name )
    : KDialogBase( parent, name, false, i18n( "CD Editor" ),
      Ok|Cancel|User1|User2, Ok, true )
{
  KGlobal::locale()->insertCatalogue("libkcddb");

  m_dlgBase = new CDInfoDialogBase( this, "m_dlgBase" );

  setMainWidget( m_dlgBase );

  setButtonText( User1, i18n( "Upload" ) );
  setButtonText( User2, i18n( "Fetch Info" ) );

  connect( this, SIGNAL( okClicked() ), SLOT( save() ) );
  connect( this, SIGNAL( user1Clicked() ), SLOT( upload() ) );
  connect( this, SIGNAL( user2Clicked() ), SIGNAL( cddbQuery() ) );
  connect( m_dlgBase, SIGNAL( play( int ) ), SIGNAL( play( int ) ) );

  cddbClient = new KCDDB::Client();
  cddbClient->setBlockingMode(false);
  connect (cddbClient, SIGNAL(finished(CDDB::Result)),
                       SLOT(submitFinished(CDDB::Result)));
}
Пример #3
0
void K3bCddbLocalSubmit::doSubmit()
{
  QString path = m_cddbDir;
  if( path.startsWith( "~" ) )
    path.replace( 0, 1, QDir::homeDirPath() + "/" );
  else if( !path.startsWith( "/" ) )
    path.prepend( QDir::homeDirPath() + "/" );
  if( path[path.length()-1] != '/' )
    path.append( "/" );

  if( !QFile::exists( path ) && !QDir().mkdir( path ) ) {
    kdDebug() << "(K3bCddbLocalSubmit) could not create directory: " << path << endl;
    setError( IO_ERROR );
    emit submitFinished( this );
    return;
  }

  if( QFile::exists( path ) ) {
    // if the category dir does not exists
    // create it

    path += resultEntry().category;

    if( !QFile::exists( path ) ) {
      if( !QDir().mkdir( path ) ) {
	kdDebug() << "(K3bCddbLocalSubmit) could not create directory: " << path << endl;
	setError( IO_ERROR );
	emit submitFinished( this );
	return;
      }
    }

    // we always overwrite existing entries
    path += "/" + resultEntry().discid;
    QFile entryFile( path );
    if( entryFile.exists() ) {
      kdDebug() << "(K3bCddbLocalSubmit) file already exists: " << path << endl;
    }
    
    if( !entryFile.open( IO_WriteOnly ) ) {
      kdDebug() << "(K3bCddbLocalSubmit) could not create file: " << path << endl;
      setError( IO_ERROR );
      emit submitFinished( this );
    }
    else {
      kdDebug() << "(K3bCddbLocalSubmit) creating file: " << path << endl;
      QTextStream entryStream( &entryFile );
      entryStream.setEncoding( QTextStream::UnicodeUTF8 );
      entryStream << resultEntry().rawData;
      entryFile.close();

      setError( SUCCESS );
      emit submitFinished( this );
    }
  }
  else {
    kdDebug() << "(K3bCddbLocalSubmit) could not find directory: " << path << endl;
    setError( IO_ERROR );
    emit infoMessage( i18n("Could not find directory: %1").arg(path) );
    emit submitFinished( this );
  }
}