Example #1
0
void JobRemoteTest::putAndGet()
{
    const QString filePath = remoteTmpDir() + "putAndGetFile";
    KUrl u(filePath);
    KIO::TransferJob* job = KIO::put( u, 0600, KIO::Overwrite | KIO::HideProgressInfo );
    QDateTime mtime = QDateTime::currentDateTime().addSecs( -30 ); // 30 seconds ago
    mtime.setTime_t(mtime.toTime_t()); // hack for losing the milliseconds
    job->setModificationTime(mtime);
    job->setUiDelegate( 0 );
    connect( job, SIGNAL( result(KJob*) ),
            this, SLOT( slotResult(KJob*) ) );
    connect( job, SIGNAL(dataReq(KIO::Job*, QByteArray&)),
             this, SLOT(slotDataReq(KIO::Job*, QByteArray&)) );
    m_result = -1;
    m_dataReqCount = 0;
    enterLoop();
    QVERIFY( m_result == 0 ); // no error

    m_result = -1;

    KIO::StoredTransferJob* getJob = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
    getJob->setUiDelegate( 0 );
    connect( getJob, SIGNAL( result( KJob* ) ),
            this, SLOT( slotGetResult( KJob* ) ) );
    enterLoop();
    QCOMPARE( m_result, 0 ); // no error
    QCOMPARE( m_data, QByteArray("This is a test for KIO::put()\n") );
    //QCOMPARE( m_data.size(), 11 );
}
Example #2
0
void JobRemoteTest::openFileReading()
{

    const QString filePath = remoteTmpDir() + "openFileReading";
    KUrl u(filePath);

    const QByteArray putData("test1test2test3test4test5");

    KIO::StoredTransferJob * putJob = KIO::storedPut( putData,
            u,
            0600, KIO::Overwrite | KIO::HideProgressInfo
        );

    QDateTime mtime = QDateTime::currentDateTime().addSecs( -30 ); // 30 seconds ago
    mtime.setTime_t(mtime.toTime_t()); // hack for losing the milliseconds
    putJob->setModificationTime(mtime);
    putJob->setUiDelegate( 0 );
    connect( putJob, SIGNAL( result(KJob*) ),
            this, SLOT( slotResult(KJob*) ) );
    m_result = -1;
    enterLoop();
    QVERIFY( m_result == 0 ); // no error


    m_rwCount = 4;
    m_data = QByteArray();

    fileJob = KIO::open(u, QIODevice::ReadOnly);

    fileJob->setUiDelegate( 0 );
    connect( fileJob, SIGNAL( result(KJob*) ),
            this, SLOT( slotResult(KJob*) ) );
    connect( fileJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
             this, SLOT(slotFileJob2Data(KIO::Job*, const QByteArray&)) );
    connect( fileJob, SIGNAL(open(KIO::Job*)),
             this, SLOT(slotFileJob2Open(KIO::Job*)) );
    connect( fileJob, SIGNAL(written(KIO::Job *, KIO::filesize_t)),
             this, SLOT(slotFileJob2Written (KIO::Job *, KIO::filesize_t)) );
    connect( fileJob, SIGNAL(position (KIO::Job *, KIO::filesize_t)),
             this, SLOT(slotFileJob2Position (KIO::Job *, KIO::filesize_t)) );
    connect( fileJob, SIGNAL(close(KIO::Job*)),
             this, SLOT(slotFileJob2Close(KIO::Job*)) );
    m_result = -1;

    enterLoop();
    QVERIFY( m_result == 0 ); // no error
    kDebug() << "resulting m_data: " << QString(m_data);
    QCOMPARE( m_data, QByteArray("test5test4test3test2test1"));

}
Example #3
0
File: mapper.c Project: Chryel/PINT
int main(int argc, const char **argv) {
  int i, j;
  if (parseArgs(argc, argv) < 0) {
    puts("ERROR: failure parsing args.");
    return -1;
  }

  if (initController() < 0) {
    puts("ERROR: failure in setup function.");
    return -1;
  }

  send_msg.pose_x = 0;
  send_msg.pose_y = 0;
  send_msg.obs_count = 0;
  send_msg.obs_x = (int*)malloc(sizeof(int) * 128);
  send_msg.obs_y = (int*)malloc(sizeof(int) * 128);

  // Remember, don't initialize anything in the loop! (this used to be there... problems)
  for (i = 0; i < GRID_NUM; i++) {
    for (j = 0; j < GRID_NUM; j++) {
      obstacle_map[i][j] = 0;
    }
  }

  enterLoop();

  return 0;
}
Example #4
0
File: empty.c Project: Chryel/PINT
int main(int argc, const char **argv) {
  //filler = malloc(sizeof(char) * 8896 * 1024 + (sizeof(char) * 150000 * 1024)); // for 160,000 kB
  // No filler = 1092
  // filler = malloc(sizeof(char) * 1024 * 952); // for 2048
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * 1024 * 1024)); // for 3072
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * 2048 * 1024)); // for 4096
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * 4096 * 1024)); // for 6144
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * 6144 * 1024)); // for 8192
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * (6144 + 4096) * 1024)); // for 12288
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * (6144 + 8192) * 1024)); // for 16384 
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * (6144 + 16384) * 1024)); // for 24576
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * (6144 + 24576) * 1024)); // for 32768
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * (6144 + 24576 + 16384) * 1024)); // for 49152
  // filler = malloc(sizeof(char) * 1024 * 952 + (sizeof(char) * (6144 + 24576 + 32768) * 1024)); // for 65536

  if (parseArgs(argc, argv) < 0) {
    puts("ERROR: failure parsing args.");
    return -1;
  }

  if (initController() < 0) {
    puts("ERROR: failure in setup function.");
    return -1;
  }

  enterLoop();

  return 0;
}
Example #5
0
void test_enterLoop_AfterCall_InsideLoop(void)
{
    resetChecker();
    enterLoop();

    bool result = isBreakInsideLoop();
    CU_ASSERT_EQUAL(result, true);
}
Example #6
0
void test_leaveLoop_AfterCall_NotInsideLoop(void)
{
    resetChecker();
    enterLoop();
    leaveLoop();

    bool result = isBreakInsideLoop();
    CU_ASSERT_EQUAL(result, false);
}
Example #7
0
void ZeroConfProtocol::listDir( const KUrl& url )
{
    if (!dnssdOK())
        return;

    const ZeroConfUrl zeroConfUrl( url );

    ZeroConfUrl::Type type = zeroConfUrl.type();
    switch (type)
    {
    case ZeroConfUrl::RootDir:
        serviceTypeBrowser = new ServiceTypeBrowser(zeroConfUrl.domain());
        connect( serviceTypeBrowser, SIGNAL(serviceTypeAdded(QString)),
                 SLOT(addServiceType(QString)) );
        connect( serviceTypeBrowser, SIGNAL(finished()), SLOT(onBrowserFinished()) );
        serviceTypeBrowser->startBrowse();
        enterLoop();
        break;
    case ZeroConfUrl::ServiceDir:
        if( !knownProtocols.contains(zeroConfUrl.serviceType()) )
        {
            error( ERR_SERVICE_NOT_AVAILABLE, zeroConfUrl.serviceType() );
            break;
        }
        serviceBrowser = new ServiceBrowser( zeroConfUrl.serviceType(), false, zeroConfUrl.domain() );
        connect( serviceBrowser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)),
                 SLOT(addService(DNSSD::RemoteService::Ptr)) );
        connect( serviceBrowser, SIGNAL(finished()), SLOT(onBrowserFinished()) );
        serviceBrowser->startBrowse();
        enterLoop();
        break;
    case ZeroConfUrl::Service:
        resolveAndRedirect( zeroConfUrl );
        break;
    default:
        error( ERR_MALFORMED_URL, url.prettyUrl() );
    }
}
Example #8
0
File: filter.c Project: Chryel/PINT
int main(int argc, const char **argv) {
  if (parseArgs(argc, argv) < 0) {
    puts("ERROR: failure parsing args.");
    return -1;
  }

  if (initController() < 0) {
    puts("ERROR: failure in setup function.");
    return -1;
  }

  enterLoop();
  return 0;
}
Example #9
0
void JobRemoteTest::openFileWriting()
{
    m_rwCount = 0;

    const QString filePath = remoteTmpDir() + "openFileWriting";
    KUrl u(filePath);
    fileJob = KIO::open(u, QIODevice::WriteOnly);

    fileJob->setUiDelegate( 0 );
    connect( fileJob, SIGNAL( result(KJob*) ),
            this, SLOT( slotResult(KJob*) ) );
    connect( fileJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
             this, SLOT(slotFileJobData(KIO::Job*, const QByteArray&)) );
    connect( fileJob, SIGNAL(open(KIO::Job*)),
             this, SLOT(slotFileJobOpen(KIO::Job*)) );
    connect( fileJob, SIGNAL(written(KIO::Job *, KIO::filesize_t)),
             this, SLOT(slotFileJobWritten (KIO::Job *, KIO::filesize_t)) );
    connect( fileJob, SIGNAL(position (KIO::Job *, KIO::filesize_t)),
             this, SLOT(slotFileJobPosition (KIO::Job *, KIO::filesize_t)) );
    connect( fileJob, SIGNAL(close(KIO::Job*)),
             this, SLOT(slotFileJobClose(KIO::Job*)) );
    m_result = -1;

    enterLoop();
    QEXPECT_FAIL("", "Needs fixing in kio_file", Abort);
    QVERIFY( m_result == 0 ); // no error

    KIO::StoredTransferJob* getJob = KIO::storedGet( u, KIO::NoReload, KIO::HideProgressInfo );
    getJob->setUiDelegate( 0 );
    connect( getJob, SIGNAL( result( KJob* ) ),
             this, SLOT( slotGetResult( KJob* ) ) );
    enterLoop();
    QCOMPARE( m_result, 0 ); // no error
    kDebug() << "m_data: " << m_data;
    QCOMPARE( m_data, QByteArray("test....test....test....test....test....test....end") );

}
/*!
    Enters the main event loop and waits until exit() is called, and
    returns the value that was set to exit().

    It is necessary to call this function to start event handling. The
    main event loop receives events from the window system and
    dispatches these to the application widgets.

    Generally speaking, no user interaction can take place before
    calling exec(). As a special case, modal widgets like QMessageBox
    can be used before calling exec(), because modal widgets call
    exec() to start a local event loop.

    To make your application perform idle processing, i.e. executing a
    special function whenever there are no pending events, use a
    QTimer with 0 timeout. More advanced idle processing schemes can
    be achieved using processEvents().

    \sa QApplication::quit(), exit(), processEvents()
*/
int QEventLoop::exec()
{
    d->reset();

    enterLoop();

    // cleanup
    d->looplevel = 0;
    d->quitnow  = FALSE;
    d->exitloop = FALSE;
    d->shortcut = FALSE;
    // don't reset quitcode!

    return d->quitcode;
}
Example #11
0
int main(int argc, char **argv) {

    clear_logs();

    log_info("%s\n", "- - - - - - - - - - log Start - - - - - - - - - -");

    renderer = init();
    loadScene(renderer);

    genTextures( renderer );
    enterLoop(renderer);

    terminate(renderer);

    return EXIT_SUCCESS;
}
Example #12
0
void TrashProtocol::get( const KUrl& url )
{
    INIT_IMPL;
    kDebug() << "get() : " << url;
    if ( !url.isValid() ) {
        kDebug() << kBacktrace();
        error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1", url.url() ) );
        return;
    }
    if ( url.path().length() <= 1 ) {
        error( KIO::ERR_IS_DIRECTORY, url.prettyUrl() );
        return;
    }
    int trashId;
    QString fileId;
    QString relativePath;
    bool ok = TrashImpl::parseURL( url, trashId, fileId, relativePath );
    if ( !ok ) {
        error( KIO::ERR_SLAVE_DEFINED, i18n( "Malformed URL %1", url.prettyUrl() ) );
        return;
    }
    const QString physicalPath = impl.physicalPath( trashId, fileId, relativePath );
    if ( physicalPath.isEmpty() ) {
        error( impl.lastErrorCode(), impl.lastErrorMessage() );
        return;
    }

    // Usually we run jobs in TrashImpl (for e.g. future kdedmodule)
    // But for this one we wouldn't use DCOP for every bit of data...
    KUrl fileURL;
    fileURL.setPath( physicalPath );
    KIO::Job* job = KIO::get( fileURL, KIO::NoReload, KIO::HideProgressInfo );
    connect( job, SIGNAL( data( KIO::Job*, const QByteArray& ) ),
             this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) );
    connect( job, SIGNAL( mimetype( KIO::Job*, const QString& ) ),
             this, SLOT( slotMimetype( KIO::Job*, const QString& ) ) );
    connect( job, SIGNAL( result(KJob*) ),
             this, SLOT( jobFinished(KJob*) ) );
    enterLoop();
}