Пример #1
0
void JobTest::setup()
{
    // Start with a clean base dir
    cleanup();
    QDir dir; // TT: why not a static method?
    bool ok = dir.mkdir(homeTmpDir());
    if(!ok)
        kdFatal() << "Couldn't create " << homeTmpDir() << endl;
    ok = dir.mkdir(otherTmpDir());
    if(!ok)
        kdFatal() << "Couldn't create " << otherTmpDir() << endl;
    ok = dir.mkdir(realSystemPath());
    if(!ok)
        kdFatal() << "Couldn't create " << realSystemPath() << endl;
}
Пример #2
0
void MenuMedia::mediaInsertItem(KFileItem *fileItem)
{
	// reset the mMenuId Int after 100 because I don't want to see what happens
	// when the int gets too big
	if (mMenuId > 100)
		mMenuId = 0;

	//find a valid mMenuId first
	int count = 0;
	while ((m_MenuItemMap.contains(mMenuId) == true))
	{
		if (count >= 500)
		{
			kdFatal() << "Infinite Loop found, report this please" << endl;
		}
		count++;
		mMenuId++;
	}

	if (KickerSettings::menuEntryHeight() > -1)
	{
		insertItem( SmallIconSet( fileItem->iconName(),
		                          KickerSettings::menuEntryHeight()),
		            fileItem->name(),
		            mMenuId);
	}
	else
	{
		insertItem(fileItem->name(), mMenuId);
	}
	m_MenuItemMap[mMenuId] = QString(fileItem->url().url());
	mMenuId++;
}
Пример #3
0
GpgME::KeyListResult Kleo::QGpgMEKeyListJob::exec( const QStringList & pats, bool secretOnly, std::vector<GpgME::Key> & keys ) {
  setup( pats, secretOnly );

  // The communication channel between gpgme and gpgsm is limited in
  // the number of patterns that can be transported, but they won't
  // say to how much, so we need to find out ourselves if we get a
  // LINE_TOO_LONG error back...

  // We could of course just feed them single patterns, and that would
  // probably be easier, but the performance penalty would currently
  // be noticable.

  for (;;) {
    keys.clear();
    mResult = attemptSyncKeyListing( keys );
    if ( !mResult.error() || mResult.error().code() != GPG_ERR_LINE_TOO_LONG )
      return mResult;
    // got LINE_TOO_LONG, try a smaller chunksize:
    setChunkSize( chunkSize()/2 );
    if ( chunkSize() < 1 )
      // chunks smaller than one can't be -> return the error.
      return mResult;
    kdDebug(5150) << "QGpgMEKeyListJob::exec(): retrying keylisting with chunksize " << chunkSize() << endl;
  }
  kdFatal(5150) << "QGpgMEKeyListJob::exec(): Oops, this is not supposed to happen!" << endl;
  return GpgME::KeyListResult();
}
Пример #4
0
void KAudioPlayStreamPrivate::initaRts() {
	kdDebug( 400 ) << k_funcinfo << endl;

	_effectrack = Arts::DynamicCast( _server->server().createObject( "Arts::StereoEffectStack" ) );
	if ( _effectrack.isNull() )
	{
		kdWarning( 400 ) << "Couldn't create EffectStack!" << endl;
		_effects = false;
	}

	_bs2a = Arts::DynamicCast( _server->server().createObject( "Arts::ByteStreamToAudio" ) );
	if ( _bs2a.isNull() )
		kdFatal( 400 ) << "Couldn't create ByteStreamToAudio" << endl;

	if ( _effects )
	{
		Arts::connect( _effectrack, _play->amanPlay() );
		Arts::connect( _bs2a, _effectrack );
	} else {
		Arts::connect( _bs2a, _play->amanPlay() );
	}

	_play->start();
	if ( _effects ) _effectrack.start();
}
ExtractProcess::ExtractProcess( Project *prj, bool& success, QTextCodec *codec )
 : KProcIO( codec )
{
	success = false;
	// prj mustn't be 0
	if ( !prj ) kdFatal() << "ExtractProcess constructor: prj is null\n";

	setUseShell( true );
	setWorkingDirectory( prj->directory() );
	setComm( KProcess::Stderr );
	enableReadSignals( true );

	// TODO check if cat, tcextract and subtitle2pgm are executable

	*this << "cat";

	uint n = prj->files().count();
	QString file;
	for (uint i = 0; i < n; ++i ) {
		if ( !prj->downloadVob( i, file ) ) return;
		else *this << file;
	}

	*this << "|" << "tcextract" << "-x" << "ps1" << "-t" << "vob" << "-a" << prj->codeLangSelected();
	*this << "|" << "subtitle2pgm" << "-v" << "-P" << "-C" << "1";
	*this << "-c" << prj->coloursString() << "-o" << prj->baseName();

	success = true;
}
Пример #6
0
void KCombiView::setSorting( TQDir::SortSpec sort )
{
    if ( !right )
        kdFatal() << "You need to call setRight( someview ) before!" << endl;
    right->setSorting( sort );
    left->setSorting( sort );

    KFileView::setSorting( right->sorting() );
}
Пример #7
0
static void createTestFile(const QString &path)
{
    QFile f(path);
    if(!f.open(IO_WriteOnly))
        kdFatal() << "Can't create " << path << endl;
    f.writeBlock("Hello world", 11);
    f.close();
    setTimeStamp(path);
}
Пример #8
0
void KCombiView::setSelectionMode( KFile::SelectionMode sm )
{
    // I think the left view (directories should always be in
    // Single-Mode, right?
    // left->setSelectionMode( sm );
    if ( !right )
        kdFatal() << "You need to call setRight( someview ) before!" << endl;
    right->setSelectionMode( sm );
}
Пример #9
0
void Board::setField(int x, int y, int value)
{
	if(x < 0 || y < 0 || x >= x_tiles() || y >= y_tiles())
	{
		kdFatal() << "Attempted write to invalid field position "
			"(" << x << ", " << y << ")" << endl;
	}

	field[y * x_tiles() + x] = value;
}
Пример #10
0
static void createTestDirectory(const QString &path)
{
    QDir dir;
    bool ok = dir.mkdir(path);
    if(!ok && !dir.exists())
        kdFatal() << "couldn't create " << path << endl;
    createTestFile(path + "/testfile");
    createTestSymlink(path + "/testlink");
    setTimeStamp(path);
}
Пример #11
0
/**
@brief Gets the ATMOSphere wallet
@return A pointer to the ATMOSphere wallet

This function simply checks wallet variable to check if it's not null.
In this case, it returns it, else it opens the wallet, set the variable to
the newly opened wallet, and then return it.
*/
KWallet::Wallet *getWallet()
{
	if ( wallet ) return wallet;
	
	wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet() );
	if ( ! wallet )
	{
		kdFatal() << "Unable to open Network Password Wallet " << KWallet::Wallet::NetworkWallet() << endl;
		return wallet;
	}
	
	if ( ! wallet->hasFolder("atmosphere") && ! wallet->createFolder("atmosphere") )
	{
		kdFatal() << "Unable to create 'atmosphere' folder into '" << KWallet::Wallet::NetworkWallet() << "' wallet." << endl;
	}
	
	wallet->setFolder("atmosphere");
	
	return wallet;
}
Пример #12
0
static void createTestSymlink(const QString &path)
{
    // Create symlink if it doesn't exist yet
    KDE_struct_stat buf;
    if(KDE_lstat(QFile::encodeName(path), &buf) != 0)
    {
        bool ok = symlink("/IDontExist", QFile::encodeName(path)) == 0; // broken symlink
        if(!ok)
            kdFatal() << "couldn't create symlink: " << strerror(errno) << endl;
    }
}
Пример #13
0
Kopete::MessageHandlerChain::Ptr Kopete::ChatSession::chainForDirection( Kopete::Message::MessageDirection dir )
{
	if( dir < 0 || dir > 2)
		kdFatal(14000) << k_funcinfo << "invalid message direction " << dir << endl;
	if( !d->chains[dir] )
	{
		TempFactory theTempFactory;
		d->chains[dir] = Kopete::MessageHandlerChain::create( this, dir );
	}
	return d->chains[dir];
}
Пример #14
0
  const HeaderStrategy * HeaderStrategy::create( Type type ) {
    switch ( type ) {
    case All:  return all();
    case Rich:   return rich();
    case Standard: return standard();
    case Brief:  return brief();
    case Custom:  return custom();
    }
    kdFatal( 5006 ) << "HeaderStrategy::create(): Unknown header strategy ( type == "
		    << (int)type << " ) requested!" << endl;
    return 0; // make compiler happy
  }
Пример #15
0
void PixServer::initBrickPixmap()
{
    QPixmap pm = QPixmap(locate("appdata", "pics/brick.png"));
    if (pm.isNull()) {
	kdFatal() << i18n("error loading %1, aborting\n").arg("brick.png");
    }
    int pw = pm.width();
    int ph = pm.height();

    offPix.resize(MAPWIDTH, MAPHEIGHT);
    for (int x = 0; x <= MAPWIDTH; x+=pw)
	for (int y = 0; y <= MAPHEIGHT; y+=ph)
	    bitBlt(&offPix, x, y, &pm);
}
Пример #16
0
int Board::getField(int x, int y) const
{
#ifdef DEBUGGING
	if(x < -1 || y < -1 || x > x_tiles() || y > y_tiles())
	{
		kdFatal() << "Attempted read from invalid field position "
			"(" << x << ", " << y << ")" << endl;
	}
#endif

	if(x < 0 || y < 0 || x >= x_tiles() || y >= y_tiles())
		return EMPTY;

	return field[y * x_tiles() + x];
}
ConvertDialog::ConvertDialog( Project *prj, QWidget *parent, const char* name )
 : KDialogBase( parent, name, true, i18n( "Converting images to text" ), Ok|Cancel|Help|User1,
 		Ok, false, KStdGuiItem::clear() ), project( prj ), sending( false ) {
	// prj mustn't be 0
	if ( !prj ) kdFatal() << "ConvertDialog constructor: prj is null\n";

	QFrame *top = makeMainWidget();
	layoutGeneral = new QVBoxLayout( top, marginGeneral, 6 );

	layoutSub = new QHBoxLayout( layoutGeneral );
    layoutSub->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding,
						QSizePolicy::Minimum ) );
    subtitle = new QLabel( top );
    layoutSub->addWidget( subtitle );
    layoutSub->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding,
						QSizePolicy::Minimum ) );

	image = new SubtitleView( top );
	image->setAutoCenterEnabled( Config().autoCenter() );
	layoutGeneral->addWidget( image );

    progress = new KProgress( project->numSub(), top );
    layoutGeneral->addWidget( progress );

	text = new QLabel( top );
	text->setAlignment( text->alignment() | Qt::WordBreak );
	text->setText( i18n( "The marked chars were not recognized. Enter correct ASCII char, \"string\" or 4 to 8 digit hex unicode." ) );
	layoutGeneral->addWidget( text );

	line = new KLineEdit( top );
	layoutGeneral->addWidget( line );

	layoutCheckBox = new QHBoxLayout( layoutGeneral );
    layoutCheckBox->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding,
						QSizePolicy::Minimum ) );
    checkbox = new QCheckBox( i18n( "Save to database" ), top );
	checkbox->setChecked( true );
    layoutCheckBox->addWidget( checkbox );
    layoutCheckBox->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding,
						QSizePolicy::Minimum ) );

	setEnabledWidgetsInput( false );
	enableButton( User1, false );

	connect( this, SIGNAL( user1Clicked() ), line, SLOT( clear() ) );
	connect( line, SIGNAL( textChanged( const QString& ) ),
			this, SLOT( editChanged( const QString& ) ) );
}
Пример #18
0
bool partNode::isFirstTextPart() const {
  if ( type() != DwMime::kTypeText )
    return false;
  const partNode * root = this;
  // go up until we reach the root node of a message (of the actual message or
  // of an attached message)
  while ( const partNode * p = root->parentNode() ) {
    if ( p->type() == DwMime::kTypeMessage )
      break;
    else
      root = p;
  }
  for ( const partNode * n = root ; n ; n = n->next() )
    if ( n->type() == DwMime::kTypeText )
      return n == this;
  kdFatal() << "partNode::isFirstTextPart(): Didn't expect to end up here..." << endl;
  return false; // make comiler happy
}
Пример #19
0
int main(int argc, char **argv)
{
  KApplication app( argc, argv, "netaccesstest", true /* it _has_ a GUI ! */);

  KURL srcURL( "ftp://ftp.kde.org/pub/kde/README" );
  KURL tmpURL( "file:/tmp/netaccesstest_README" );

  for ( uint i = 0; i < 4 ; ++i ) {
    kdDebug() << "file_copy" << endl;
    if ( !KIO::NetAccess::file_copy(srcURL, tmpURL, -1, true, false, 0) )
      kdError() << "file_copy failed: " << KIO::NetAccess::lastErrorString() << endl;
    else {
      QFile f( tmpURL.path() );
      if (!f.open(IO_ReadOnly))
        kdFatal() << "Cannot open: " << f.name() << ". The error was: " << f.errorString() << endl;
      else {
        f.close();
      }
    }
  }

  return 0;
}
Пример #20
0
bool FrameSource::init() {
    int buf[4], err = 0;

    ReadData(_filename.latin1(), "FFINFO",
             0, 0, /* 1st sframe, 1st samp */
             0, 2, /* num sframes, num samps */
             'i', (void*)buf,
             &err);

    if (err != E_OK) {
        // FIXME: BAD IDEA!!
        kdFatal() << "Problem reading FFINFO in from Frame Type File" << endl;
    }

    _bytesPerFrame = buf[0];
    _framesPerFile = buf[1];
    _frameCount = 0;

    /* split out file name and extension */
    int len = _filename.length();
    char ext[3];
    ext[0] = _filename.latin1()[len - 2];
    ext[1] = _filename.latin1()[len - 1];
    ext[2] = '\0';

    _rootFileName = _filename;

    if (isxdigit(ext[0]) && isxdigit(ext[1])) {
        char *tmpstr = 0L;
        _rootFileName.truncate(_rootFileName.length() - 2);
        _rootExt = strtol(ext, &tmpstr, 16);
        _maxExt = _rootExt;
    } else {
        _maxExt = _rootExt = -1;
    }
    return update() == KstObject::UPDATE;
}
Пример #21
0
bool Board::solvable(bool norestore)
{
	int *oldfield = 0;

	if(!norestore)
	{
		oldfield = new int [x_tiles() * y_tiles()];
		memcpy(oldfield, field, x_tiles() * y_tiles() * sizeof(int));
	}

	Path p;
	while(getHint_I(p))
	{
		kdFatal(getField(p.front().x, p.front().y) != getField(p.back().x, p.back().y))
			<< "Removing unmateched tiles: (" << p.front().x << ", " << p.front().y << ") => "
			<< getField(p.front().x, p.front().y) << " (" << p.back().x << ", " << p.back().y << ") => "
            << getField(p.back().x, p.back().y) << endl;
		setField(p.front().x, p.front().y, EMPTY);
		setField(p.back().x, p.back().y, EMPTY);
		//if(gravityFlag())
		//{
		//	gravity(p.front().x, false);
		//	gravity(p.back().x, false);
		//}
	}

	int left = tilesLeft();

	if(!norestore)
	{
		memcpy(field, oldfield, x_tiles() * y_tiles() * sizeof(int));
		delete [] oldfield;
	}

	return (bool)(left == 0);
}
Пример #22
0
void KstPsdDialogI::new_I() {
  KstPSDCurvePtr curve;
  double new_freq;
  int new_len;

  QString tag_name = Select->currentText();
  tag_name.replace(i18n("<New_PSD>"), "PSD_" + _vector->selectedVector());

  /* verify that the curve name is unique */
  if (KST::dataTagNameNotUnique(tag_name)) {
    Select->setFocus();
    return;
  }

  if (_vector->selectedVector().isEmpty()) {
    KMessageBox::sorry(0L, i18n("New PSD not made: define vectors first."));
    return;
  }

  /* find new_freq */
  new_freq = SampRate->text().toDouble();
  if (new_freq <= 0) {
      KMessageBox::sorry(0L, i18n("The sample rate must be greater than 0."));
      return;
  }

  /* find new_len */
  new_len = FFTLen->text().toInt();
  if (new_len < 2) {
      KMessageBox::sorry(0L, i18n("The FFT length must be greater than 2^2."));
      return;
  }

  {
    KST::vectorList.lock().readLock();
    KstVectorList::Iterator i = KST::vectorList.findTag(_vector->selectedVector());
    if (i == KST::vectorList.end()) {
      kdFatal() << "Bug in kst: the vector field in plotDialog (PSD) refers to "
                << "a non existant vector...." << endl;
    }

    KstVectorPtr p = *i;
    KST::vectorList.lock().readUnlock();

    /* create the psd curve */
    curve = new KstPSDCurve(tag_name, p, new_freq, new_len,
                            VectorUnits->text(), RateUnits->text(),
                            _curveAppearance->color());
  }

  curve->setHasPoints(_curveAppearance->showPoints());
  curve->setHasLines(_curveAppearance->showLines());
  curve->Point.setType(_curveAppearance->pointType());
  curve->setAppodize(Appodize->isChecked());
  curve->setRemoveMean(RemoveMean->isChecked());

  KstPlot *plot = 0L;
  if (_curvePlacement->existingPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.FindKstPlot(_curvePlacement->plotName());
    plot->addCurve(curve);
  }
  if (_curvePlacement->newPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.addPlot(QString::null, _curvePlacement->columns());
    _curvePlacement->appendPlot(plot->tagName(), true);
    plot->addCurve(curve);
    plot->GenerateDefaultLabels();
  }

  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(curve.data());
  KST::dataObjectList.lock().writeUnlock();
  curve = 0L;
  emit modified();
}
Пример #23
0
void KstCurveDialogI::new_I() {
  KstWriteLocker ml(&KST::vectorList.lock());
  KstVectorList::Iterator VX, VY;
  KstVectorList::Iterator EX, EY;
  KstVCurvePtr curve;
  KstPlot *plot;

  if (_xVector->selectedVector().isEmpty()) {
    KMessageBox::sorry(0L, i18n("New curve not made: define vectors first."));
    return;
  }

  /* find VX and VY */
  VX = KST::vectorList.findTag(_xVector->selectedVector());
  VY = KST::vectorList.findTag(_yVector->selectedVector());
  EX = KST::vectorList.findTag(_xError->selectedVector());
  EY = KST::vectorList.findTag(_yError->selectedVector());
  if (VX == KST::vectorList.end() || VY == KST::vectorList.end()) {
    kdFatal() << "Bug in kst: the XVector field in plotDialog refers to "
              << "a non existant vector...." << endl;
  }

  KstReadLocker rl1(*VX), rl2(*VY);

  QString tag_name = Select->currentText();
  tag_name.replace(i18n("<New_Curve>"), (*VY)->tagName());

  /* verify that the curve name is unique */
  if (KST::dataTagNameNotUnique(tag_name)) {
    return;
  }

  /* create the curve */
  curve = new KstVCurve(tag_name, *VX, *VY,
                        EX != KST::vectorList.end() ? *EX : KstVectorPtr(0L),
                        EY != KST::vectorList.end() ? *EY : KstVectorPtr(0L),
                        _curveAppearance->color());
  curve->setHasPoints(_curveAppearance->showPoints());
  curve->setHasLines(_curveAppearance->showLines());
  curve->Point.setType(_curveAppearance->pointType());

  if (_curvePlacement->existingPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.FindKstPlot(_curvePlacement->plotName());
    plot->addCurve(curve);
  }

  if (_curvePlacement->newPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.addPlot(QString::null, _curvePlacement->columns());
    _curvePlacement->appendPlot(plot->tagName(), true);
    plot->addCurve(curve);
    plot->GenerateDefaultLabels();
  }

  KST::dataObjectList.lock().readLock();
  KST::dataObjectList.append(curve.data());
  KST::dataObjectList.lock().writeUnlock();
  curve = 0L;
  emit modified();
}