QString GpsimProcessor::generateSymbolFile( const QString &fileName, QObject *receiver, const char *successMember, const char * failMember ) { if ( !isValidProgramFile(fileName) ) return QString::null; QString extension = fileName.right( fileName.length() - fileName.lastIndexOf('.') - 1 ).toLower(); if ( extension == "cod" ) { QTimer::singleShot( 0, receiver, successMember ); return fileName; } if ( extension == "hex" ) { QTimer::singleShot( 0, receiver, successMember ); // We've already checked for the existance of the ".cod" file in GpsimProcessor::isValidProgramFile return QString(fileName).replace(".hex",".cod"); } else if ( extension == "basic" || extension == "microbe" ) { compileMicrobe( fileName, receiver, successMember, failMember ); return QString(fileName).replace( "."+extension, ".cod" ); } else if ( extension == "flowcode" ) { const QString hexFile = QTemporaryFile( "tmpXXXXXX.hex" ).fileName(); ProcessOptions o; o.b_addToProject = false; o.setTargetFile( hexFile ); o.setInputFiles( QStringList(fileName) ); o.setMethod( ProcessOptions::Method::Forget ); o.setProcessPath( ProcessOptions::ProcessPath::FlowCode_Program ); ProcessChain * pc = new ProcessChain(o); if (receiver) { if (successMember) connect( pc, SIGNAL(successful()), receiver, successMember ); if (failMember) connect( pc, SIGNAL(failed()), receiver, failMember ); } return QString(hexFile).replace( ".hex", ".cod" ); } else if ( extension == "asm" ) { ProcessOptions o; o.b_addToProject = false; o.setTargetFile( QString(fileName).replace(".asm",".hex")); o.setInputFiles(QStringList(fileName)); o.setMethod( ProcessOptions::Method::Forget ); o.setProcessPath( ProcessOptions::ProcessPath::path( ProcessOptions::guessMediaType(fileName), ProcessOptions::ProcessPath::Program ) ); ProcessChain *pc = new ProcessChain(o); if (receiver) { if (successMember) connect( pc, SIGNAL(successful()), receiver, successMember ); if (failMember) connect( pc, SIGNAL(failed()), receiver, failMember ); } return QString(fileName).replace(".asm",".cod"); } else if ( extension == "c" ) { ProcessOptions o; o.b_addToProject = false; o.setTargetFile( QString(fileName).replace(".c",".hex")); o.setInputFiles(QStringList(fileName)); o.setMethod( ProcessOptions::Method::Forget ); o.setProcessPath( ProcessOptions::ProcessPath::C_Program ); ProcessChain *pc = new ProcessChain(o); if (receiver) { if (successMember) connect( pc, SIGNAL(successful()), receiver, successMember ); if (failMember) connect( pc, SIGNAL(failed()), receiver, failMember ); } return QString(fileName).replace(".c",".cod"); } if ( failMember ) QTimer::singleShot( 0, receiver, failMember ); return QString::null; }
/** * mkvol_basic - simple test that checks basic volume creation capability. * * Thus function returns %0 in case of success and %-1 in case of failure. */ static int mkvol_basic(void) { struct ubi_mkvol_request req; struct ubi_vol_info vol_info; int vol_id, ret; const char *name = PROGRAM_NAME ":mkvol_basic()"; /* Create dynamic volume of maximum size */ req.vol_id = UBI_VOL_NUM_AUTO; req.alignment = 1; req.bytes = dev_info.avail_bytes; req.vol_type = UBI_DYNAMIC_VOLUME; req.name = name; if (ubi_mkvol(libubi, node, &req)) { failed("ubi_mkvol"); return -1; } vol_id = req.vol_id; if (check_volume(vol_id, &req)) goto remove; if (ubi_rmvol(libubi, node, vol_id)) { failed("ubi_rmvol"); return -1; } /* Create static volume of maximum size */ req.vol_id = UBI_VOL_NUM_AUTO; req.alignment = 1; req.bytes = dev_info.avail_bytes; req.vol_type = UBI_STATIC_VOLUME; req.name = name; if (ubi_mkvol(libubi, node, &req)) { failed("ubi_mkvol"); return -1; } vol_id = req.vol_id; if (check_volume(vol_id, &req)) goto remove; if (ubi_rmvol(libubi, node, vol_id)) { failed("ubi_rmvol"); return -1; } /* Make sure volume does not exist */ ret = ubi_get_vol_info1(libubi, dev_info.dev_num, vol_id, &vol_info); if (ret == 0) { errorm("removed volume %d exists", vol_id); goto remove; } return 0; remove: ubi_rmvol(libubi, node, vol_id); return -1; }
bool Vector4Test::test() { // ctor tests Vector4d vvector4_test( 8., 1., 6., 3. ); for ( size_t i = 0; i < 4; ++i ) { if ( vvector4_test.xyzw[i] != _vector4.xyzw[i] ) { cout << "test: Vector4::Vector4( scalars ) failed!" << endl; failed(); assert( 0 ); } } Vector4d uvector4_test( Vector3d( 8., 1., 6. ), 3. ); for ( size_t i = 0; i < 4; ++i ) { if ( uvector4_test.xyzw[i] != _vector4.xyzw[i] ) { cout << "test: Vector4::Vector4( vector3, scalar ) failed!" << endl; failed(); assert( 0 ); } } // setter test Vector4d tvector4_test( 0., 0., 0., 0. ); tvector4_test.set( 8., 1., 6., 3. ); for ( size_t i = 0; i < 4; ++i ) { if ( tvector4_test.xyzw[i] != _vector4.xyzw[i] ) { cout << "test: Vector4::set( ... ) failed!" << endl; failed(); assert( 0 ); } } // operator= test tvector4_test.set( 0., 0., 0., 0. ); tvector4_test = uvector4_test; for ( size_t i = 0; i < 4; ++i ) { if ( tvector4_test.xyzw[i] != _vector4.xyzw[i] ) { cout << "test: Vector4::operator=( ... ) failed!" << endl; failed(); assert( 0 ); } } // length() tests if ( _vector4.lengthSquared() != 110. ) { cout << "test: Vector4::length( ... ) failed!" << endl; failed(); assert( 0 ); } if ( _vector4.length() != sqrt( 110. ) ) { cout << "test: Vector4::length( ... ) failed!" << endl; failed(); assert( 0 ); } // normalise() test tvector4_test.set( 8. / sqrt( 110. ), 1. / sqrt( 110. ), 6. / sqrt( 110. ), 3. / sqrt( 110. ) ); vvector4_test.normalise(); for ( size_t i = 0; i < 4; ++i ) { if( tvector4_test.xyzw[i] - vvector4_test.xyzw[i] < -1e-13 || tvector4_test.xyzw[i] - vvector4_test.xyzw[i] > 1e-13 ) { cout << "test: Vector4::normalise( ... ) failed!" << endl; failed(); assert( 0 ); } } // vector/scalar operations vvector4_test.set( 7., 0., 5., 2. ); if ( vvector4_test + 1. != _vector4 ) { cout << "test: Vector4::operator+( scalar ) failed!" << endl; failed(); assert( 0 ); } if ( vvector4_test != _vector4 - 1. ) { cout << "test: Vector4::operator-( scalar ) failed!" << endl; failed(); assert( 0 ); } uvector4_test.set( 4., 0.5, 3., 1.5 ); if ( uvector4_test * 2 != _vector4 ) { cout << "test: Vector4::operator*( scalar ) failed!" << endl; failed(); assert( 0 ); } if ( _vector4 / 2. != uvector4_test ) { cout << "test: Vector4::operator/( scalar ) failed!" << endl; failed(); assert( 0 ); } vvector4_test += 1.; if ( vvector4_test != _vector4 ) { cout << "test: Vector4::operator+=( scalar ) failed!" << endl; failed(); assert( 0 ); } uvector4_test *= 2.; if ( uvector4_test != _vector4 ) { cout << "test: Vector4::operator*=( scalar ) failed!" << endl; failed(); assert( 0 ); } uvector4_test.set( -8., -1., -6., -3. ); if ( -uvector4_test != _vector4 ) { cout << "test: Vector4::operator-() failed!" << endl; failed(); assert( 0 ); } // vector/vector operations tvector4_test.set( 2., -1., 3., 1. ); uvector4_test.set( 6., 2., 3., 2. ); vvector4_test.set( 4., -1., 2., 3. ); if ( tvector4_test + uvector4_test != _vector4 ) { cout << "test: Vector4::operator+( vector ) failed!" << endl; failed(); assert( 0 ); } if ( _vector4 - uvector4_test != tvector4_test ) { cout << "test: Vector4::operator-( vector ) failed!" << endl; failed(); assert( 0 ); } if( tvector4_test * vvector4_test != _vector4 ) { cout << "test: Vector4::operator*( vector ) failed!" << endl; failed(); assert( 0 ); } if ( _vector4 / tvector4_test != vvector4_test ) { cout << "test: Vector4::operator/( vector ) failed!" << endl; failed(); assert( 0 ); } uvector4_test += tvector4_test; if ( uvector4_test != _vector4 ) { cout << "test: Vector4::operator+=( vector ) failed!" << endl; failed(); assert( 0 ); } vvector4_test *= tvector4_test; if ( vvector4_test != _vector4 ) { cout << "test: Vector4::operator*=( vector ) failed!" << endl; failed(); assert( 0 ); } // dot() test if ( _vector4.dot( tvector4_test ) != 36. ) { cout << "test: Vector4::dot( vector4 ) failed! " << _vector4 << " . " << tvector4_test << " = " << _vector4.dot( tvector4_test ) << endl; failed(); assert( 0 ); } // operator == / != tests if( vvector4_test != _vector4 ) { cout << "test: Vector4::operator !=( vector ) failed!" << endl; failed(); assert( 0 ); } if ( tvector4_test == _vector4 ) { cout << "test: Vector4::operator==( vector ) failed!" << endl; failed(); assert( 0 ); } // min/max component tests if ( _vector4.getMinComponent() != 1. ) { cout << "test: Vector4::getMinComponent() failed!" << endl; failed(); assert( 0 ); } if ( _vector4.getMaxComponent() != 8. ) { cout << "test: Vector4::getMaxComponent() failed!" << endl; failed(); assert( 0 ); } vec4f cmp0( 1.0, 2.5, 4.0, 1.0 ); vec4f cmp1( 3.0, 2.0, 5.0, 2.0 ); size_t smaller = cmp0.smaller( cmp1 ); size_t greater = cmp0.greater( cmp1 ); if ( smaller != 13 || greater != 2 ) { failed(); assert( 0 ); } smaller = cmp0.smaller( cmp1, 3 ); greater = cmp0.greater( cmp1, 3 ); if ( smaller != 8 || greater != 0 ) { failed(); assert( 0 ); } if ( ok ) cout << "Vector4: all tests passed!" << std::endl; return ok; }
void RPIImageDecoder::decode(bool onlySize) { unsigned int width, height; if (failed()) return; // make sure we have all the data before doing anything if (!isAllDataReceived()) return; if (onlySize) { if (readSize(width, height)); { setSize(width, height); } return; } else { readSize(width, height); clock_t start = clock(); ImageFrame& buffer = m_frameBufferCache[0]; if (m_frameBufferCache.isEmpty()) { log("decode : frameBuffercache is empty"); setFailed(); return; } if (buffer.status() == ImageFrame::FrameEmpty) { if (!buffer.setSize(width, height)) { log("decode : could not define buffer size"); setFailed(); return; } // The buffer is transparent outside the decoded area while the image is // loading. The completed image will be marked fully opaque in jpegComplete(). buffer.setHasAlpha(false); } // lock the mutex so that we only process once at a time pthread_mutex_lock(&decode_mutex); // setup decoder request information BRCMIMAGE_REQUEST_T* dec_request = getDecoderRequest(); BRCMIMAGE_T *decoder = getDecoder(); memset(dec_request, 0, sizeof(BRCMIMAGE_REQUEST_T)); dec_request->input = (unsigned char*)m_data->data(); dec_request->input_size = m_data->size(); dec_request->output = (unsigned char*)buffer.getAddr(0, 0); dec_request->output_alloc_size = width * height * 4; dec_request->output_handle = 0; dec_request->pixel_format = PIXEL_FORMAT_RGBA; dec_request->buffer_width = 0; dec_request->buffer_height = 0; brcmimage_acquire(decoder); BRCMIMAGE_STATUS_T status = brcmimage_process(decoder, dec_request); if (status == BRCMIMAGE_SUCCESS) { clock_t copy = clock(); unsigned char *ptr = (unsigned char *)buffer.getAddr(0, 0); for (unsigned int i = 0; i < dec_request->height * dec_request->width; i++) { // we swap RGBA -> BGRA unsigned char tmp = *ptr; *ptr = ptr[2]; ptr[2] = tmp; ptr += 4; } brcmimage_release(decoder); buffer.setPixelsChanged(true); buffer.setStatus(ImageFrame::FrameComplete); buffer.setHasAlpha(m_hasAlpha); clock_t end = clock(); unsigned long millis = (end - start) * 1000 / CLOCKS_PER_SEC; unsigned long copymillis = (end - copy) * 1000 / CLOCKS_PER_SEC; log("decode : image (%d x %d)(Alpha=%d) decoded in %d ms (copy in %d ms), source size = %d bytes", width, height, m_hasAlpha, millis, copymillis, m_data->size()); } else { log("decode : Decoding failed with status %d", status); } pthread_mutex_unlock(&decode_mutex); } }
bool WEBPImageDecoder::decode(bool onlySize) { if (failed()) return false; #if defined(__LB_SHELL__) // We dont want progressive decoding. if (!isAllDataReceived()) return false; #endif const uint8_t* dataBytes = reinterpret_cast<const uint8_t*>(m_data->data()); const size_t dataSize = m_data->size(); if (!ImageDecoder::isSizeAvailable()) { static const size_t imageHeaderSize = 30; if (dataSize < imageHeaderSize) return false; int width, height; #if (WEBP_DECODER_ABI_VERSION >= 0x0163) WebPBitstreamFeatures features; if (WebPGetFeatures(dataBytes, dataSize, &features) != VP8_STATUS_OK) return setFailed(); width = features.width; height = features.height; m_hasAlpha = features.has_alpha; #else // Earlier version won't be able to display WebP files with alpha. if (!WebPGetInfo(dataBytes, dataSize, &width, &height)) return setFailed(); m_hasAlpha = false; #endif if (!setSize(width, height)) return setFailed(); } ASSERT(ImageDecoder::isSizeAvailable()); if (onlySize) return true; ASSERT(!m_frameBufferCache.isEmpty()); ImageFrame& buffer = m_frameBufferCache[0]; ASSERT(buffer.status() != ImageFrame::FrameComplete); if (buffer.status() == ImageFrame::FrameEmpty) { if (!buffer.setSize(size().width(), size().height())) return setFailed(); buffer.setStatus(ImageFrame::FramePartial); buffer.setHasAlpha(m_hasAlpha); buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); } if (!m_decoder) { int rowStride = size().width() * sizeof(ImageFrame::PixelData); uint8_t* output = reinterpret_cast<uint8_t*>(buffer.getAddr(0, 0)); int outputSize = size().height() * rowStride; m_decoder = WebPINewRGB(outputMode(m_hasAlpha), output, outputSize, rowStride); if (!m_decoder) return setFailed(); } switch (WebPIUpdate(m_decoder, dataBytes, dataSize)) { case VP8_STATUS_OK: buffer.setStatus(ImageFrame::FrameComplete); WebPIDelete(m_decoder); m_decoder = 0; return true; case VP8_STATUS_SUSPENDED: return false; default: WebPIDelete(m_decoder); m_decoder = 0; return setFailed(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); QString winTitle = QString("MultiMC 5 - Version %1").arg(BuildConfig.printableVersionString()); if (!BuildConfig.BUILD_PLATFORM.isEmpty()) winTitle += " on " + BuildConfig.BUILD_PLATFORM; setWindowTitle(winTitle); // OSX magic. // setUnifiedTitleAndToolBarOnMac(true); // Global shortcuts { //FIXME: This is kinda weird. and bad. We need some kind of managed shutdown. auto q = new QShortcut(QKeySequence::Quit, this); connect(q, SIGNAL(activated()), qApp, SLOT(quit())); } // The instance action toolbar customizations { // disabled until we have an instance selected ui->instanceToolBar->setEnabled(false); // the rename label is inside the rename tool button renameButton = new LabeledToolButton(); renameButton->setText("Instance Name"); renameButton->setToolTip(ui->actionRenameInstance->toolTip()); connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered())); ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton); ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance); renameButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); } // Add the news label to the news toolbar. { newsLabel = new QToolButton(); newsLabel->setIcon(QIcon::fromTheme("news")); newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel); QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked); QObject::connect(MMC->newsChecker().get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel); updateNewsLabel(); } // Create the instance list widget { view = new GroupView(ui->centralWidget); view->setSelectionMode(QAbstractItemView::SingleSelection); // view->setCategoryDrawer(drawer); // view->setCollapsibleBlocks(true); // view->setViewMode(QListView::IconMode); // view->setFlow(QListView::LeftToRight); // view->setWordWrap(true); // view->setMouseTracking(true); // view->viewport()->setAttribute(Qt::WA_Hover); auto delegate = new ListViewDelegate(); view->setItemDelegate(delegate); // view->setSpacing(10); // view->setUniformItemWidths(true); // do not show ugly blue border on the mac view->setAttribute(Qt::WA_MacShowFocusRect, false); view->installEventFilter(this); proxymodel = new InstanceProxyModel(this); // proxymodel->setSortRole(KCategorizedSortFilterProxyModel::CategorySortRole); // proxymodel->setFilterRole(KCategorizedSortFilterProxyModel::CategorySortRole); // proxymodel->setDynamicSortFilter ( true ); // FIXME: instList should be global-ish, or at least not tied to the main window... // maybe the application itself? proxymodel->setSourceModel(MMC->instances().get()); proxymodel->sort(0); view->setFrameShape(QFrame::NoFrame); view->setModel(proxymodel); view->setContextMenuPolicy(Qt::CustomContextMenu); connect(view, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showInstanceContextMenu(const QPoint &))); ui->horizontalLayout->addWidget(view); } // The cat background { bool cat_enable = MMC->settings()->get("TheCat").toBool(); ui->actionCAT->setChecked(cat_enable); connect(ui->actionCAT, SIGNAL(toggled(bool)), SLOT(onCatToggled(bool))); setCatBackground(cat_enable); } // start instance when double-clicked connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(instanceActivated(const QModelIndex &))); // track the selection -- update the instance toolbar connect(view->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(instanceChanged(const QModelIndex &, const QModelIndex &))); // track icon changes and update the toolbar! connect(MMC->icons().get(), SIGNAL(iconUpdated(QString)), SLOT(iconUpdated(QString))); // model reset -> selection is invalid. All the instance pointers are wrong. // FIXME: stop using POINTERS everywhere connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad())); m_statusLeft = new QLabel(tr("No instance selected"), this); m_statusRight = new ServerStatus(this); statusBar()->addPermanentWidget(m_statusLeft, 1); statusBar()->addPermanentWidget(m_statusRight, 0); // Add "manage accounts" button, right align QWidget *spacer = new QWidget(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); ui->mainToolBar->addWidget(spacer); accountMenu = new QMenu(this); manageAccountsAction = new QAction(tr("Manage Accounts"), this); manageAccountsAction->setCheckable(false); connect(manageAccountsAction, SIGNAL(triggered(bool)), this, SLOT(on_actionManageAccounts_triggered())); repopulateAccountsMenu(); accountMenuButton = new QToolButton(this); accountMenuButton->setText(tr("Accounts")); accountMenuButton->setMenu(accountMenu); accountMenuButton->setPopupMode(QToolButton::InstantPopup); accountMenuButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); accountMenuButton->setIcon(QIcon::fromTheme("noaccount")); QWidgetAction *accountMenuButtonAction = new QWidgetAction(this); accountMenuButtonAction->setDefaultWidget(accountMenuButton); ui->mainToolBar->addAction(accountMenuButtonAction); // Update the menu when the active account changes. // Shouldn't have to use lambdas here like this, but if I don't, the compiler throws a fit. // Template hell sucks... connect(MMC->accounts().get(), &MojangAccountList::activeAccountChanged, [this] { activeAccountChanged(); }); connect(MMC->accounts().get(), &MojangAccountList::listChanged, [this] { repopulateAccountsMenu(); }); // Show initial account activeAccountChanged(); auto accounts = MMC->accounts(); QList<CacheDownloadPtr> skin_dls; for (int i = 0; i < accounts->count(); i++) { auto account = accounts->at(i); if (account != nullptr) { for (auto profile : account->profiles()) { auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png"); auto action = CacheDownload::make( QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), meta); skin_dls.append(action); meta->stale = true; } } } if(!skin_dls.isEmpty()) { auto job = new NetJob("Startup player skins download"); connect(job, SIGNAL(succeeded()), SLOT(skinJobFinished())); connect(job, SIGNAL(failed()), SLOT(skinJobFinished())); for(auto action: skin_dls) job->addNetAction(action); skin_download_job.reset(job); job->start(); } // run the things that load and download other things... FIXME: this is NOT the place // FIXME: invisible actions in the background = NOPE. { if (!MMC->minecraftlist()->isLoaded()) { m_versionLoadTask = MMC->minecraftlist()->getLoadTask(); startTask(m_versionLoadTask); } if (!MMC->lwjgllist()->isLoaded()) { MMC->lwjgllist()->loadList(); } MMC->newsChecker()->reloadNews(); updateNewsLabel(); // set up the updater object. auto updater = MMC->updateChecker(); connect(updater.get(), &UpdateChecker::updateAvailable, this, &MainWindow::updateAvailable); connect(updater.get(), &UpdateChecker::noUpdateFound, [this]() { CustomMessageBox::selectable( this, tr("No update found."), tr("No MultiMC update was found!\nYou are using the latest version."))->exec(); }); // if automatic update checks are allowed, start one. if (MMC->settings()->get("AutoUpdate").toBool()) on_actionCheckUpdate_triggered(); connect(MMC->notificationChecker().get(), &NotificationChecker::notificationCheckFinished, this, &MainWindow::notificationsChanged); } setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString()); // removing this looks stupid view->setFocus(); }
int WEBPImageDecoder::repetitionCount() const { return failed() ? cAnimationLoopOnce : m_repetitionCount; }
void ViCodingChain::run() { ////////////////////////////////////////////////////////////////////////////////////////////// // // Initialize // ////////////////////////////////////////////////////////////////////////////////////////////// emit progressed(0); if(mMode == ViCodingChain::Unknown) { return; } if(mMode != ViCodingChain::EncodeFile && mMode != ViCodingChain::EncodeData) { (this->*detectCoder)(); if(mInputCoder == NULL) { ViCoder::Error error = ViAudioManager::error(); if(error == ViCoder::UnsupportedCodecError) { setError(ViCoder::UnsupportedInputCodecError); } else if(error == ViCoder::UnavailableCodecError) { setError(ViCoder::UnavailableInputCodecError); } else { setError(error); } return; } else { QObject::connect(mInputCoder, SIGNAL(failed(ViCoder::Error)), this, SLOT(setError(ViCoder::Error)), Qt::DirectConnection); } } if(mError != ViCoder::NoError) return; if(mMode != ViCodingChain::DecodeFile && mMode != ViCodingChain::DecodeData) { mOutputCoder = ViAudioManager::coder(mOutputFormat); if(mOutputCoder == NULL) { ViCoder::Error error = ViAudioManager::error(); if(error == ViCoder::UnsupportedCodecError) { setError(ViCoder::UnsupportedOutputCodecError); } else if(error == ViCoder::UnavailableCodecError) { setError(ViCoder::UnavailableOutputCodecError); } else { setError(error); } return; } else { mOutputCoder->setMetadata(mMetadata); QObject::connect(mOutputCoder, SIGNAL(failed(ViCoder::Error)), this, SLOT(setError(ViCoder::Error)), Qt::DirectConnection); } } if(mError != ViCoder::NoError) return; ////////////////////////////////////////////////////////////////////////////////////////////// // // Initialize mode // ////////////////////////////////////////////////////////////////////////////////////////////// mInput->disconnect(); mDecoder.disconnect(); mEncoder.disconnect(); mOutput->disconnect(); QObject::connect(mInput, SIGNAL(failed(ViCoder::Error)), this, SLOT(setError(ViCoder::Error)), Qt::DirectConnection); QObject::connect(&mDecoder, SIGNAL(failed(ViCoder::Error)), this, SLOT(setError(ViCoder::Error)), Qt::DirectConnection); QObject::connect(&mEncoder, SIGNAL(failed(ViCoder::Error)), this, SLOT(setError(ViCoder::Error)), Qt::DirectConnection); QObject::connect(mOutput, SIGNAL(failed(ViCoder::Error)), this, SLOT(setError(ViCoder::Error)), Qt::DirectConnection); if(mMode == ViCodingChain::ConvertFileToFile || mMode == ViCodingChain::ConvertFileToData || mMode == ViCodingChain::ConvertDataToFile || mMode == ViCodingChain::ConvertDataToData) { mInput->setNext(&mDecoder); mDecoder.setNext(&mEncoder); mEncoder.setNext(mOutput); mOutputCoder->setFormat(ViAudio::AudioOutput, mOutputFormat); if(mMode == ViCodingChain::ConvertDataToFile || mMode == ViCodingChain::ConvertDataToData) { mInputCoder->setFormat(ViAudio::AudioInput, mInputFormat); } } else if(mMode == ViCodingChain::DecodeFile || mMode == ViCodingChain::DecodeData) { mInput->setNext(&mDecoder); mDecoder.setNext(mOutput); if(mMode == ViCodingChain::DecodeData) { mInputCoder->setFormat(ViAudio::AudioInput, mInputFormat); } } else if(mMode == ViCodingChain::EncodeFile || mMode == ViCodingChain::EncodeData) { mInput->setNext(&mEncoder); mEncoder.setNext(mOutput); mOutputCoder->setFormat(ViAudio::AudioOutput, mOutputFormat); } mInput->setOffsets(mFromOffset, mToOffset); mInput->initialize(); if(mError != ViCoder::NoError) return; mOutput->initialize(); if(mError != ViCoder::NoError) return; if(mMode != ViCodingChain::EncodeFile && mMode != ViCodingChain::EncodeData) { mDecoder.setCoder(mInputCoder); QObject::connect(mInputCoder, SIGNAL(formatChanged(ViAudioFormat)), this, SIGNAL(formatChanged(ViAudioFormat)), Qt::UniqueConnection); mInputCoder->load(); if(mError != ViCoder::NoError) return; mDecoder.initialize(); if(mError != ViCoder::NoError) return; } if(mMode != ViCodingChain::DecodeFile && mMode != ViCodingChain::DecodeData) { mEncoder.setCoder(mOutputCoder); mOutputCoder->load(); if(mError != ViCoder::NoError) return; mEncoder.initialize(); if(mError != ViCoder::NoError) return; if(mMode == ViCodingChain::EncodeFile || mMode == ViCodingChain::EncodeData) { mOutputCoder->setFormat(ViAudio::AudioInput, mInputFormat); mInput->setSampleSize(mInputFormat.sampleSize()); mEncoder.changeFormat(mInputFormat); } } ////////////////////////////////////////////////////////////////////////////////////////////// // // Execute // ////////////////////////////////////////////////////////////////////////////////////////////// qreal progressedData = 0; qint64 totalSize = mInput->size(); static qint32 chunkSize = mInput->chunkSize(); qreal progress = 0; while(mInput->hasData() && mError == ViCoder::NoError) { mInput->execute(); progressedData += chunkSize; progress = progressedData / totalSize * 99; // * 99 to first finalize everything before 100% is emitted emit progressed(progress); } ////////////////////////////////////////////////////////////////////////////////////////////// // // Finalize // ////////////////////////////////////////////////////////////////////////////////////////////// mInput->finalize(); if(mError != ViCoder::NoError) return; if(mMode != ViCodingChain::EncodeFile && mMode != ViCodingChain::EncodeData) { if(mMode == ViCodingChain::DecodeFile || mMode == ViCodingChain::DecodeData) { mInputFormat = mInputCoder->format(ViAudio::AudioInput); } mDecoder.finalize(); if(mError != ViCoder::NoError) return; } if(mMode != ViCodingChain::DecodeFile && mMode != ViCodingChain::DecodeData) { mEncoder.finalize(); if(mError != ViCoder::NoError) return; } mOutput->finalize(); if(mInputCoder != NULL) { mInputCoder->unload(); } if(mOutputCoder != NULL) { mOutputCoder->unload(); } progress = 100; emit progressed(progress); }
/** * the_thread - the testing thread. * * @ptr thread number */ static void * the_thread(void *ptr) { int fd, iter = iterations, vol_id = (int)ptr; unsigned char *wbuf, *rbuf; char vol_node[strlen(UBI_VOLUME_PATTERN) + 100]; wbuf = malloc(total_bytes); rbuf = malloc(total_bytes); if (!wbuf || !rbuf) { failed("malloc"); goto free; } sprintf(&vol_node[0], UBI_VOLUME_PATTERN, dev_info.dev_num, vol_id); while (iter--) { int i, ret, written = 0, rd = 0; int bytes = (random() % (total_bytes - 1)) + 1; fd = open(vol_node, O_RDWR); if (fd == -1) { failed("open"); err_msg("cannot open \"%s\"\n", node); goto free; } for (i = 0; i < bytes; i++) wbuf[i] = random() % 255; memset(rbuf, '\0', bytes); do { ret = ubi_update_start(libubi, fd, bytes); if (ret && errno != EBUSY) { failed("ubi_update_start"); err_msg("vol_id %d", vol_id); goto close; } } while (ret); while (written < bytes) { int to_write = random() % (bytes - written); if (to_write == 0) to_write = 1; ret = write(fd, wbuf, to_write); if (ret != to_write) { failed("write"); err_msg("failed to write %d bytes at offset %d " "of volume %d", to_write, written, vol_id); err_msg("update: %d bytes", bytes); goto close; } written += to_write; } close(fd); fd = open(vol_node, O_RDONLY); if (fd == -1) { failed("open"); err_msg("cannot open \"%s\"\n", node); goto free; } /* read data back and check */ while (rd < bytes) { int to_read = random() % (bytes - rd); if (to_read == 0) to_read = 1; ret = read(fd, rbuf, to_read); if (ret != to_read) { failed("read"); err_msg("failed to read %d bytes at offset %d " "of volume %d", to_read, rd, vol_id); goto close; } rd += to_read; } close(fd); } free(wbuf); free(rbuf); return NULL; close: close(fd); free: free(wbuf); free(rbuf); return NULL; }
static DBusMessage *create_proxy(DBusConnection *conn, DBusMessage *msg, void *data) { struct serial_adapter *adapter = data; char path[MAX_PATH_LENGTH + 1]; const char *pattern, *address, *ppath = path; char *uuid_str; proxy_type_t type; uuid_t uuid; int ret; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern, DBUS_TYPE_STRING, &address, DBUS_TYPE_INVALID)) return NULL; uuid_str = bt_name2string(pattern); if (!uuid_str) return invalid_arguments(msg, "Invalid UUID"); bt_string2uuid(&uuid, uuid_str); type = addr2type(address); if (type == UNKNOWN_PROXY_TYPE) { g_free(uuid_str); return invalid_arguments(msg, "Invalid address"); } /* Only one proxy per address(TTY or unix socket) is allowed */ if (g_slist_find_custom(adapter->proxies, address, proxy_addrcmp)) { g_free(uuid_str); return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyExist", "Proxy already exists"); } switch (type) { case UNIX_SOCKET_PROXY: ret = proxy_socket_register(adapter, uuid_str, address, path, sizeof(path), TRUE); break; case TTY_PROXY: ret = proxy_tty_register(adapter, uuid_str, address, NULL, path, sizeof(path), TRUE); break; case TCP_SOCKET_PROXY: ret = proxy_tcp_register(adapter, uuid_str, address, path, sizeof(path), TRUE); break; default: ret = -1; } g_free(uuid_str); if (ret < 0) return failed(msg, "Create object path failed"); g_dbus_emit_signal(adapter->conn, adapter_get_path(adapter->btd_adapter), SERIAL_MANAGER_INTERFACE, "ProxyCreated", DBUS_TYPE_STRING, &ppath, DBUS_TYPE_INVALID); return g_dbus_create_reply(msg, DBUS_TYPE_STRING, &ppath, DBUS_TYPE_INVALID); }
void LocationManager::onFinished(QNetworkReply *reply) { if (!manager) return; if (reply->error() != QNetworkReply::NoError) return onFailed(reply); QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if (statusCode.isValid()) { int status = statusCode.toInt(); if (status == 301 || status == 302) { QString loc = reply->header(QNetworkRequest::LocationHeader).toString(); if (!loc.isEmpty()) { QMap<QNetworkReply*, LocationData*>::iterator i = dataLoadings.find(reply); if (i != dataLoadings.cend()) { LocationData *d = i.value(); if (serverRedirects.constFind(d) == serverRedirects.cend()) { serverRedirects.insert(d, 1); } else if (++serverRedirects[d] > MaxHttpRedirects) { DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc)); return onFailed(reply); } dataLoadings.erase(i); dataLoadings.insert(manager->get(QNetworkRequest(loc)), d); return; } else if ((i = imageLoadings.find(reply)) != imageLoadings.cend()) { LocationData *d = i.value(); if (serverRedirects.constFind(d) == serverRedirects.cend()) { serverRedirects.insert(d, 1); } else if (++serverRedirects[d] > MaxHttpRedirects) { DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc)); return onFailed(reply); } imageLoadings.erase(i); imageLoadings.insert(manager->get(QNetworkRequest(loc)), d); return; } } } if (status != 200) { DEBUG_LOG(("Network Error: Bad HTTP status received in onFinished() for image link: %1").arg(status)); return onFailed(reply); } } LocationData *d = 0; QMap<QNetworkReply*, LocationData*>::iterator i = dataLoadings.find(reply); if (i != dataLoadings.cend()) { d = i.value(); dataLoadings.erase(i); QJsonParseError e; QJsonDocument doc = QJsonDocument::fromJson(reply->readAll(), &e); if (e.error != QJsonParseError::NoError) { DEBUG_LOG(("JSON Error: Bad json received in onFinished() for image link")); return onFailed(reply); } failed(d); if (App::main()) App::main()->update(); } else { i = imageLoadings.find(reply); if (i != imageLoadings.cend()) { d = i.value(); imageLoadings.erase(i); QPixmap thumb; QByteArray format; QByteArray data(reply->readAll()); { QBuffer buffer(&data); QImageReader reader(&buffer); #ifndef OS_MAC_OLD reader.setAutoTransform(true); #endif // OS_MAC_OLD thumb = QPixmap::fromImageReader(&reader, Qt::ColorOnly); format = reader.format(); thumb.setDevicePixelRatio(cRetinaFactor()); if (format.isEmpty()) format = QByteArray("JPG"); } d->loading = false; d->thumb = thumb.isNull() ? (*notLoadedPlaceholder) : ImagePtr(thumb, format); serverRedirects.remove(d); if (App::main()) App::main()->update(); } } }
void RpcData::emitFailed(const QString& message) { m_State = ST_Failed; emit failed(message); }
void BracketStackList::addItems(const KUrl::List& list) { if (list.count() == 0) return; KUrl::List urls; for ( KUrl::List::ConstIterator it = list.constBegin(); it != list.constEnd(); ++it ) { KUrl imageUrl = *it; // Check if the new item already exist in the list. bool found = false; QTreeWidgetItemIterator iter(this); while (*iter) { BracketStackItem* item = dynamic_cast<BracketStackItem*>(*iter); if (item->url() == imageUrl) found = true; ++iter; } if (!found) { BracketStackItem* item = new BracketStackItem(this); item->setUrl(imageUrl); item->setOn(true); urls.append(imageUrl); } } if (d->iface) { d->iface->thumbnails(urls, iconSize().width()); } else { #if KDE_IS_VERSION(4,7,0) KFileItemList items; for (KUrl::List::ConstIterator it = urls.begin() ; it != urls.end() ; ++it) { if ((*it).isValid()) items.append(KFileItem(KFileItem::Unknown, KFileItem::Unknown, *it, true)); } KIO::PreviewJob* job = KIO::filePreview(items, iconSize()); #else KIO::PreviewJob *job = KIO::filePreview(urls, iconSize().width()); #endif connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)), this, SLOT(slotKDEPreview(KFileItem,QPixmap))); connect(job, SIGNAL(failed(KFileItem)), this, SLOT(slotKDEPreviewFailed(KFileItem))); } emit signalAddItems(urls); }
static int e3(void) { int p1; register unsigned char *a; unsigned char *p2; long long ll_1, ll_2; a = nxtarg(0); if (eq(a, "(")) { p1 = sexp(); if (!eq(nxtarg(0), ")")) failed("test",") expected"); return(p1); } p2 = nxtarg(1); ap--; if ((p2 == 0) || (!eq(p2, "=") && !eq(p2, "!="))) { if (eq(a, "-r")) return(chk_access(nxtarg(0), S_IREAD, 0) == 0); if (eq(a, "-w")) return(chk_access(nxtarg(0), S_IWRITE, 0) == 0); if (eq(a, "-x")) return(chk_access(nxtarg(0), S_IEXEC, 0) == 0); #ifdef SUS if (eq(a, "-e")) return(access(nxtarg(0), F_OK) == 0); if (eq(a, "-S")) return(filtyp(nxtarg(0), S_IFSOCK)); if (eq(a, "!")) return(!e3()); #endif /* SUS */ if (eq(a, "-d")) return(filtyp(nxtarg(0), S_IFDIR)); if (eq(a, "-c")) return(filtyp(nxtarg(0), S_IFCHR)); if (eq(a, "-b")) return(filtyp(nxtarg(0), S_IFBLK)); if (eq(a, "-f")) if (ucb_builtins) { struct stat statb; return(stat((char *)nxtarg(0), &statb) >= 0 && (statb.st_mode & S_IFMT) != S_IFDIR); } else return(filtyp(nxtarg(0), S_IFREG)); if (eq(a, "-u")) return(ftype(nxtarg(0), S_ISUID)); if (eq(a, "-g")) return(ftype(nxtarg(0), S_ISGID)); if (eq(a, "-k")) return(ftype(nxtarg(0), S_ISVTX)); if (eq(a, "-p")) return(filtyp(nxtarg(0), S_IFIFO)); if (eq(a, "-h") || eq(a, "-L")) return(filtyp(nxtarg(0), S_IFLNK)); if (eq(a, "-s")) return(fsizep(nxtarg(0))); if (eq(a, "-t")) { if (ap >= ac) /* no args */ return(isatty(1)); else if (eq((a = nxtarg(0)), "-a") || eq(a, "-o")) { ap--; return(isatty(1)); } else return(isatty(atoi((char *)a))); } if (eq(a, "-n")) return(!eq(nxtarg(0), "")); if (eq(a, "-z")) return(eq(nxtarg(0), "")); } p2 = nxtarg(1); if (p2 == 0) return(!eq(a, "")); if (eq(p2, "-a") || eq(p2, "-o")) { ap--; return(!eq(a, "")); } if (eq(p2, "=")) return(eq(nxtarg(0), a)); if (eq(p2, "!=")) return(!eq(nxtarg(0), a)); ll_1 = stoifll(a); ll_2 = stoifll(nxtarg(0)); if (eq(p2, "-eq")) return (ll_1 == ll_2); if (eq(p2, "-ne")) return (ll_1 != ll_2); if (eq(p2, "-gt")) return (ll_1 > ll_2); if (eq(p2, "-lt")) return (ll_1 < ll_2); if (eq(p2, "-ge")) return (ll_1 >= ll_2); if (eq(p2, "-le")) return (ll_1 <= ll_2); bfailed(btest, badop, p2); /* NOTREACHED */ return 0; }
static void unfilter(FILE *src, FILE *dst) { int ch; int count = 0; int attrs = 0; STATES state = Default; unsigned n; begin_unfilter(dst); while ((ch = vl_getc(src)) != EOF) { ch = CharOf(ch); if (state == Default) { if (ch == CTL_A) { state = Repeat; count = 0; attrs = 0; } else { int changed = 0; write_unfilter(dst, ch, attrs); for (n = 0; n < my_length; ++n) { if (my_counts[n].length > 0) { my_counts[n].length -= 1; if (my_counts[n].length == 0) changed = 1; } } if (changed) { attrs = 0; for (n = 0; n < my_length; ++n) { if (my_counts[n].length > 0) { attrs |= my_counts[n].attrib & (ATR_BOLD | ATR_UNDERLINE | ATR_REVERSE | ATR_ITALIC); if ((attrs & ATR_COLOR) == 0) { attrs |= my_counts[n].attrib & (ATR_COLOR | 0xff); } } } markup_unfilter(dst, attrs); } } } else if (ch == ':') { if (count == 0) count = 1; if (attrs != 0) { markup_unfilter(dst, attrs); if (my_length == 0) { my_length = 10; if ((my_counts = typecallocn(COUNTS, my_length)) == 0) failed("malloc"); } for (n = 0; n < my_length; ++n) { if (my_counts[n].length == 0) { my_counts[n].length = count; my_counts[n].attrib = attrs; break; } } } state = Default; } else { switch (state) { case Repeat: if (isdigit(ch)) { count = (count * 10) + (ch - '0'); break; } else { state = Attribs; } /* FALLTHRU */ case Attribs: switch (ch) { case 'C': state = Color; attrs |= ATR_COLOR; break; case 'U': attrs |= ATR_UNDERLINE; break; case 'B': attrs |= ATR_BOLD; break; case 'R': attrs |= ATR_REVERSE; break; case 'I': attrs |= ATR_ITALIC; break; } break; case Color: if (isxdigit(ch)) { int color = 0; if (isdigit(ch)) { color = ch - '0'; } else if (isupper(ch) && ch <= 'F') { color = ch - 'A' + 10; } else if (islower(ch) && ch <= 'f') { color = ch - 'a' + 10; } attrs |= color; } state = Attribs; break; case Markup: case Default: break; } } } end_unfilter(dst); }
int main(int argc, char * const argv[]) { int i, ret; pthread_t threads[THREADS_NUM]; struct ubi_mkvol_request req; long long mem_limit; if (initial_check(argc, argv)) return 1; node = argv[1]; libubi = libubi_open(); if (libubi == NULL) { failed("libubi_open"); return 1; } if (ubi_get_dev_info(libubi, node, &dev_info)) { failed("ubi_get_dev_info"); goto close; } req.alignment = 1; mem_limit = memory_limit(); if (mem_limit && mem_limit < dev_info.avail_bytes) total_bytes = req.bytes = (mem_limit / dev_info.eb_size / THREADS_NUM) * dev_info.eb_size; else total_bytes = req.bytes = ((dev_info.avail_ebs - 3) / THREADS_NUM) * dev_info.eb_size; for (i = 0; i < THREADS_NUM; i++) { char name[100]; req.vol_id = i; sprintf(&name[0], TESTNAME":%d", i); req.name = &name[0]; req.vol_type = (i & 1) ? UBI_STATIC_VOLUME : UBI_DYNAMIC_VOLUME; if (ubi_mkvol(libubi, node, &req)) { failed("ubi_mkvol"); goto remove; } } /* Create one volume with static data to make WL work more */ req.vol_id = THREADS_NUM; req.name = TESTNAME ":static"; req.vol_type = UBI_DYNAMIC_VOLUME; req.bytes = 3*dev_info.eb_size; if (ubi_mkvol(libubi, node, &req)) { failed("ubi_mkvol"); goto remove; } for (i = 0; i < THREADS_NUM; i++) { ret = pthread_create(&threads[i], NULL, &the_thread, (void*)i); if (ret) { failed("pthread_create"); goto remove; } } for (i = 0; i < THREADS_NUM; i++) pthread_join(threads[i], NULL); for (i = 0; i <= THREADS_NUM; i++) { if (ubi_rmvol(libubi, node, i)) { failed("ubi_rmvol"); goto remove; } } libubi_close(libubi); return 0; remove: for (i = 0; i <= THREADS_NUM; i++) ubi_rmvol(libubi, node, i); close: libubi_close(libubi); return 1; }
ProcessorDlg::ProcessorDlg(const QList<QUrl>& list) : QDialog(0), d(new Private) { setModal(false); setWindowTitle(QString::fromUtf8("Convert RAW files To PNG")); d->buttons = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Close, this); d->thread = new MyActionThread(this); d->list = list; d->count = d->list.count(); qDebug() << d->list; d->page = new QWidget(this); QVBoxLayout* const vbx = new QVBoxLayout(this); vbx->addWidget(d->page); vbx->addWidget(d->buttons); setLayout(vbx); int cpu = d->thread->maximumNumberOfThreads(); QGridLayout* const grid = new QGridLayout(d->page); QLabel* const pid = new QLabel(QString::fromUtf8("Main PID: %1").arg(QCoreApplication::applicationPid()), this); QLabel* const core = new QLabel(QString::fromUtf8("CPU cores available: %1").arg(cpu), this); QWidget* const hbox = new QWidget(this); d->items = new QLabel(this); QHBoxLayout* const hlay = new QHBoxLayout(hbox); QLabel* const coresLabel = new QLabel(QString::fromUtf8("Cores to use: "), this); d->usedCore = new QSpinBox(this); d->usedCore->setRange(1, cpu); d->usedCore->setSingleStep(1); d->usedCore->setValue(cpu); hlay->addWidget(coresLabel); hlay->addWidget(d->usedCore); hlay->setContentsMargins(QMargins()); d->progressView = new QScrollArea(this); QWidget* const progressbox = new QWidget(d->progressView->viewport()); QVBoxLayout* const progressLay = new QVBoxLayout(progressbox); d->progressView->setWidget(progressbox); d->progressView->setWidgetResizable(true); grid->addWidget(pid, 0, 0, 1, 1); grid->addWidget(core, 1, 0, 1, 1); grid->addWidget(hbox, 2, 0, 1, 1); grid->addWidget(d->items, 3, 0, 1, 1); grid->addWidget(d->progressView, 4, 0, 1, 1); foreach (const QUrl& url, d->list) { QProgressBar* const bar = new QProgressBar(progressbox); QString file = url.toLocalFile(); QFileInfo fi(file); bar->setMaximum(100); bar->setMinimum(0); bar->setValue(100); bar->setObjectName(file); bar->setFormat(fi.fileName()); progressLay->addWidget(bar); } progressLay->addStretch(); QPushButton* const applyBtn = d->buttons->button(QDialogButtonBox::Apply); QPushButton* const cancelBtn = d->buttons->button(QDialogButtonBox::Close); connect(applyBtn, SIGNAL(clicked()), this, SLOT(slotStart())); connect(cancelBtn, SIGNAL(clicked()), this, SLOT(slotStop())); connect(d->thread, SIGNAL(starting(QUrl)), this, SLOT(slotStarting(QUrl))); connect(d->thread, SIGNAL(finished(QUrl)), this, SLOT(slotFinished(QUrl))); connect(d->thread, SIGNAL(failed(QUrl,QString)), this, SLOT(slotFailed(QUrl,QString))); connect(d->thread, SIGNAL(progress(QUrl,int)), this, SLOT(slotProgress(QUrl,int))); updateCount(); resize(500, 400); }
KEquityPriceUpdateDlg::KEquityPriceUpdateDlg(QWidget *parent, const QString& securityId) : KEquityPriceUpdateDlgDecl(parent), m_fUpdateAll(false) { QStringList headerList; headerList << i18n("Symbol") << i18nc("Equity name", "Name") << i18n("Price") << i18n("Date"); lvEquityList->header()->setSortIndicator(0, Qt::AscendingOrder); lvEquityList->setColumnWidth(NAME_COL, 125); // This is a "get it up and running" hack. Will replace this in the future. headerList << i18nc("Internal identifier", "ID") << i18nc("Online quote source", "Source"); lvEquityList->setColumnWidth(ID_COL, 0); lvEquityList->setHeaderLabels(headerList); lvEquityList->setSelectionMode(QAbstractItemView::MultiSelection); lvEquityList->setAllColumnsShowFocus(true); btnUpdateAll->setEnabled(false); btnOK->setGuiItem(KStandardGuiItem::ok()); btnCancel->setGuiItem(KStandardGuiItem::cancel()); MyMoneyFile* file = MyMoneyFile::instance(); // // Add each price pair that we know about // // send in securityId == "XXX YYY" to get a single-shot update for XXX to YYY. // for consistency reasons, this accepts the same delimiters as WebPriceQuote::launch() QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive); MyMoneySecurityPair currencyIds; if (splitrx.indexIn(securityId) != -1) { currencyIds = MyMoneySecurityPair(splitrx.cap(1).toUtf8(), splitrx.cap(2).toUtf8()); } MyMoneyPriceList prices = file->priceList(); for (MyMoneyPriceList::ConstIterator it_price = prices.constBegin(); it_price != prices.constEnd(); ++it_price) { const MyMoneySecurityPair& pair = it_price.key(); if (file->security(pair.first).isCurrency() && (securityId.isEmpty() || (pair == currencyIds))) { const MyMoneyPriceEntries& entries = (*it_price); if (entries.count() > 0 && entries.begin().key() <= QDate::currentDate()) { addPricePair(pair); btnUpdateAll->setEnabled(true); } } } // // Add each investment // QList<MyMoneySecurity> securities = file->securityList(); for (QList<MyMoneySecurity>::const_iterator it = securities.constBegin(); it != securities.constEnd(); ++it) { if (!(*it).isCurrency() && (securityId.isEmpty() || ((*it).id() == securityId)) && !(*it).value("kmm-online-source").isEmpty() ) { addInvestment(*it); btnUpdateAll->setEnabled(true); } } // if list is empty, add the request price pair if (lvEquityList->invisibleRootItem()->childCount() == 0) { addPricePair(currencyIds, true); } connect(btnOK, SIGNAL(clicked()), this, SLOT(accept())); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(btnUpdateSelected, SIGNAL(clicked()), this, SLOT(slotUpdateSelectedClicked())); connect(btnUpdateAll, SIGNAL(clicked()), this, SLOT(slotUpdateAllClicked())); connect(&m_webQuote, SIGNAL(quote(QString,QString,QDate,double)), this, SLOT(slotReceivedQuote(QString,QString,QDate,double))); connect(&m_webQuote, SIGNAL(failed(QString,QString)), this, SLOT(slotQuoteFailed(QString,QString))); connect(&m_webQuote, SIGNAL(status(QString)), this, SLOT(logStatusMessage(QString))); connect(&m_webQuote, SIGNAL(error(QString)), this, SLOT(logErrorMessage(QString))); connect(lvEquityList, SIGNAL(itemSelectionChanged()), this, SLOT(slotUpdateSelection())); // Not implemented yet. btnConfigure->hide(); //connect(btnConfigure, SIGNAL(clicked()), this, SLOT(slotConfigureClicked())); if (!securityId.isEmpty()) { btnUpdateSelected->hide(); btnUpdateAll->hide(); // delete layout1; QTimer::singleShot(100, this, SLOT(slotUpdateAllClicked())); } // Hide OK button until we have received the first update btnOK->setEnabled(false); slotUpdateSelection(); // previous versions of this dialog allowed to store a "Don't ask again" switch. // Since we don't support it anymore, we just get rid of it KSharedConfigPtr config = KGlobal::config(); KConfigGroup grp = config->group("Notification Messages"); grp.deleteEntry("KEquityPriceUpdateDlg::slotQuoteFailed::Price Update Failed"); }
void MainWindow::on_actionAddInstance_triggered() { #ifdef TEST_SEGV // For further testing stuff. int v = *((int*)-1); #endif if (!MMC->minecraftlist()->isLoaded() && m_versionLoadTask && m_versionLoadTask->isRunning()) { QEventLoop waitLoop; waitLoop.connect(m_versionLoadTask, SIGNAL(failed(QString)), SLOT(quit())); waitLoop.connect(m_versionLoadTask, SIGNAL(succeeded()), SLOT(quit())); waitLoop.exec(); } NewInstanceDialog newInstDlg(this); if (!newInstDlg.exec()) return; InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); QString instDirName = DirNameFromString(newInstDlg.instName(), instancesDir); QString instDir = PathCombine(instancesDir, instDirName); auto &loader = InstanceFactory::get(); auto error = loader.createInstance(newInstance, newInstDlg.selectedVersion(), instDir); QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); switch (error) { case InstanceFactory::NoCreateError: newInstance->setName(newInstDlg.instName()); newInstance->setIconKey(newInstDlg.iconKey()); MMC->instances()->add(InstancePtr(newInstance)); break; case InstanceFactory::InstExists: { errorMsg += tr("An instance with the given directory name already exists."); CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); return; } case InstanceFactory::CantCreateDir: { errorMsg += tr("Failed to create the instance directory."); CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); return; } default: { errorMsg += tr("Unknown instance loader error %1").arg(error); CustomMessageBox::selectable(this, tr("Error"), errorMsg, QMessageBox::Warning)->show(); return; } } if (MMC->accounts()->anyAccountIsValid()) { ProgressDialog loadDialog(this); auto update = newInstance->doUpdate(); connect(update.get(), &Task::failed, [this](QString reason) { QString error = QString("Instance load failed: %1").arg(reason); CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning) ->show(); }); loadDialog.exec(update.get()); } else { CustomMessageBox::selectable( this, tr("Error"), tr("MultiMC cannot download Minecraft or update instances unless you have at least " "one account added.\nPlease add your Mojang or Minecraft account."), QMessageBox::Warning)->show(); } }
const KURL& WorkerScriptLoader::responseURL() const { DCHECK(!failed()); return m_responseURL; }
ZeroCopyNSIOutputStream::~ZeroCopyNSIOutputStream() { if (!failed()) Unused << NS_WARN_IF(NS_FAILED(writeBuffer())); }
void Client::requestFinished(int id, bool error) { if ( !d->serverResponses.count(id) ) { return; } ///////////// // if (d->http->hasPendingRequests()) { // qDebug()<<"!!!!Pending requests for ID="<<id; // if (d->http->error()!=0) // qDebug()<<"Error "<<d->http->error()<<" String "<<d->http->errorString(); // } // else // qDebug()<<"!!!!No pending requests for ID="<<id; ////////////////////// #ifdef XMLRPC_DEBUG qDebug() << "request" << d->methodNames[id] << "finished, id=" << id << ", isError:" << error; #endif if ( error ) { //if ( d->serverResponses.count(id) ) QBuffer *buffer = d->serverResponses.take(id); delete buffer; if (use_big_buffer) delete(silly_buffer); emit failed(id, -32300, d->http->errorString() ); return; } if ( d->serverResponses.count(id) ) { QBuffer *buffer = d->serverResponses.take(id); QByteArray buf = buffer->buffer(); QString tmp_str = buf; // qDebug() << "xml-rpc server response:\n" << "left :\n" <<tmp_str.left(20)<<"\nright:\n"<<tmp_str.right(40)<<"\nLength:\n"<<tmp_str.length(); Response response; QString errorMessage; if ( response.setContent( buf, &errorMessage ) ) { Q_ASSERT( !response.isNull() ); if ( response.isFault() ) { qDebug() << "request failed:" << response.faultCode() << response.faultString(); emit failed(id, response.faultCode(), response.faultString() ); } else { #ifdef XMLRPC_DEBUG qDebug() << response.returnValue().pprint(); #endif emit done( id, response.returnValue() ); } } else { #ifdef XMLRPC_DEBUG qDebug() << "incorrect xmlrpc response:" << errorMessage; qDebug() << QString(buf); #endif emit failed(id, -32600, "Server error: Invalid xml-rpc. \nNot conforming to spec."); } delete buffer; } }
primitiveDirectoryLookup(void) { // FilePlugin>>#primitiveDirectoryLookup sqInt createDate; sqInt dirFlag; char entryName[256]; sqInt entryNameSize; squeakFileOffsetType fileSize; sqInt index; sqInt modifiedDate; sqInt okToList; sqInt pathName; char *pathNameIndex; sqInt pathNameSize; sqInt posixPermissions; sqInt status; sqInt symlinkFlag; index = stackIntegerValue(0); pathName = stackValue(1); if (!(isBytes(pathName))) { return primitiveFail(); } pathNameIndex = firstIndexableField(pathName); /* If the security plugin can be loaded, use it to check for permission. If not, assume it's ok */ pathNameSize = byteSizeOf(pathName); if (sCLPfn != 0) { okToList = ((sqInt (*)(char *, sqInt))sCLPfn)(pathNameIndex, pathNameSize); } else { okToList = 1; } if (okToList) { status = dir_Lookup( pathNameIndex, pathNameSize, index, entryName, &entryNameSize, &createDate, &modifiedDate, &dirFlag, &fileSize, &posixPermissions, &symlinkFlag); } else { status = DirNoMoreEntries; } if (failed()) { return null; } if (status == DirNoMoreEntries) { /* no more entries; return nil */ /* pop pathName, index, rcvr */ popthenPush(3, nilObject()); return null; } if (status == DirBadPath) { return primitiveFail(); } popthenPush(3, makeDirEntryNamesizecreateDatemodDateisDirfileSizeposixPermissionsisSymlink(entryName, entryNameSize, createDate, modifiedDate, dirFlag, fileSize, posixPermissions, symlinkFlag)); }
/* ------------------------- */ void run_test(const int dir) { static char *data; int i,maxi = 0; int j, k; int fork; int test = 0; int nowrite; off_t offset; struct async_io_req air; static char temp[MAXPATHLEN]; numrw = rwsize / (dsi->server_quantum - FPWRITE_RQST_SIZE); if (!data) data = calloc(1, dsi->server_quantum); /* --------------- */ /* Test (1) */ if (teststorun[TEST_OPENSTATREAD]) { for (i=0; i <= smallfiles; i++) { sprintf(temp, "File.small%d", i); if (ntohl(AFPERR_NOOBJ) != is_there(Conn, dir, temp)) { fatal_failed(); } if (FPGetFileDirParams(Conn, vol, dir, "", 0, (1<< DIRPBIT_DID) )) { fatal_failed(); } if (FPCreateFile(Conn, vol, 0, dir , temp)){ fatal_failed(); } if (is_there(Conn, dir, temp)) { fatal_failed(); } if (FPGetFileDirParams(Conn, vol, dir, temp, (1<<FILPBIT_FNUM )|(1<<FILPBIT_PDID)|(1<<FILPBIT_FINFO)| (1<<FILPBIT_CDATE)|(1<<FILPBIT_MDATE)|(1<<FILPBIT_DFLEN)|(1<<FILPBIT_RFLEN) , 0)) { fatal_failed(); } if (FPGetFileDirParams(Conn, vol, dir, temp, (1<<FILPBIT_FNUM )|(1<<FILPBIT_PDID)|(1<<FILPBIT_FINFO)| (1<< DIRPBIT_ATTR)|(1<<DIRPBIT_BDATE)| (1<<FILPBIT_CDATE)|(1<<FILPBIT_MDATE)|(1<<FILPBIT_DFLEN)|(1<<FILPBIT_RFLEN) , 0)) { fatal_failed(); } fork = FPOpenFork(Conn, vol, OPENFORK_DATA , (1<<FILPBIT_PDID)|(1<< DIRPBIT_LNAME)|(1<<FILPBIT_FNUM)|(1<<FILPBIT_DFLEN) , dir, temp, OPENACC_WR |OPENACC_RD| OPENACC_DWR| OPENACC_DRD); if (!fork) { fatal_failed(); } if (FPGetForkParam(Conn, fork, (1<<FILPBIT_PDID)|(1<< DIRPBIT_LNAME)|(1<<FILPBIT_DFLEN))) { fatal_failed(); } if (FPWrite(Conn, fork, 0, 20480, data, 0 )) { fatal_failed(); } if (FPCloseFork(Conn,fork)) {fatal_failed();} maxi = i; } if (FPEnumerate(Conn, vol, dir , "", (1<<FILPBIT_LNAME) | (1<<FILPBIT_FNUM ) | (1<<FILPBIT_ATTR) | (1<<FILPBIT_FINFO)| (1<<FILPBIT_CDATE) | (1<<FILPBIT_BDATE) | (1<<FILPBIT_MDATE) | (1<<FILPBIT_DFLEN) | (1<<FILPBIT_RFLEN) , (1<< DIRPBIT_ATTR) | (1<<DIRPBIT_ATTR) | (1<<DIRPBIT_FINFO) | (1<<DIRPBIT_CDATE) | (1<<DIRPBIT_BDATE) | (1<<DIRPBIT_MDATE) | (1<< DIRPBIT_LNAME) | (1<< DIRPBIT_PDID) | (1<< DIRPBIT_DID)|(1<< DIRPBIT_ACCESS) )) { fatal_failed(); } starttimer(); for (i=1; i <= maxi; i++) { sprintf(temp, "File.small%d", i); if (is_there(Conn, dir, temp)) { fatal_failed(); } if (FPGetFileDirParams(Conn, vol, dir, temp, 0x72d,0)) { fatal_failed(); } if (FPGetFileDirParams(Conn, vol, dir, temp, 0x73f, 0x133f )) { fatal_failed(); } fork = FPOpenFork(Conn, vol, OPENFORK_DATA , 0x342, dir, temp, OPENACC_RD); if (!fork) { fatal_failed(); } if (FPGetForkParam(Conn, fork, (1<<FILPBIT_DFLEN))) {fatal_failed();} if (FPRead(Conn, fork, 0, 512, data)) {fatal_failed();} if (FPCloseFork(Conn,fork)) {fatal_failed();} fork = FPOpenFork(Conn, vol, OPENFORK_DATA , 0x342 , dir, temp,OPENACC_RD| OPENACC_DWR); if (!fork) { fatal_failed(); } if (FPGetForkParam(Conn, fork, 0x242)) {fatal_failed();} if (FPGetFileDirParams(Conn, vol, dir, temp, 0x72d,0)) { fatal_failed(); } if (FPCloseFork(Conn,fork)) {fatal_failed();} } stoptimer(); addresult(TEST_OPENSTATREAD, Iterations); /* ---------------- */ for (i=0; i <= maxi; i++) { sprintf(temp, "File.small%d", i); if (is_there(Conn, dir, temp)) { fatal_failed(); } if (FPGetFileDirParams(Conn, vol, dir, temp, 0, (1<< FILPBIT_FNUM) )) { fatal_failed(); } if (FPDelete(Conn, vol, dir, temp)) {fatal_failed();} } if (FPGetVolParam(Conn, vol, (1 << VOLPBIT_MDATE )|(1 << VOLPBIT_XBFREE))) { fatal_failed(); } } /* -------- */ /* Test (2) */ if (teststorun[TEST_WRITE100MB]) { strcpy(temp, "File.big"); if (FPCreateFile(Conn, vol, 0, dir , temp)){ failed(); goto fin1; } if (FPGetFileDirParams(Conn, vol, dir, temp, 0x72d,0)) fatal_failed(); if (FPGetFileDirParams(Conn, vol, dir, temp, 0x73f, 0x133f )) fatal_failed(); fork = FPOpenFork(Conn, vol, OPENFORK_DATA , (1<<FILPBIT_PDID)|(1<<FILPBIT_FNUM)|(1<<FILPBIT_DFLEN) ,dir, temp, OPENACC_WR |OPENACC_RD| OPENACC_DWR| OPENACC_DRD); if (!fork) fatal_failed(); if (FPGetForkParam(Conn, fork, (1<<FILPBIT_PDID))) fatal_failed(); air.air_count = numrw; air.air_size = FPWRITE_RPLY_SIZE; (void)pthread_create(&tid, NULL, rply_thread, &air); starttimer(); for (i = 0, offset = 0; i < numrw; offset += (dsi->server_quantum - FPWRITE_RQST_SIZE), i++) { if (FPWrite_ext_async(Conn, fork, offset, dsi->server_quantum - FPWRITE_RQST_SIZE, data, 0)) fatal_failed(); } pthread_join(tid, NULL); if (FPCloseFork(Conn,fork)) fatal_failed(); stoptimer(); addresult(TEST_WRITE100MB, Iterations); } /* -------- */ /* Test (3) */ if (teststorun[TEST_READ100MB]) { if (!bigfilename) { if (is_there(Conn, dir, temp) != AFP_OK) fatal_failed(); fork = FPOpenFork(Conn, vol, OPENFORK_DATA, 0x342, dir, temp, OPENACC_RD|OPENACC_DWR); } else { if (is_there(Conn, DIRDID_ROOT, bigfilename) != AFP_OK) fatal_failed(); fork = FPOpenFork(Conn, vol, OPENFORK_DATA, 0x342, DIRDID_ROOT, bigfilename, OPENACC_RD|OPENACC_DWR); } if (!fork) fatal_failed(); if (FPGetForkParam(Conn, fork, 0x242)) fatal_failed(); air.air_count = numrw; air.air_size = (dsi->server_quantum - FPWRITE_RQST_SIZE) + 16; (void)pthread_create(&tid, NULL, rply_thread, &air); starttimer(); for (i=0; i < numrw ; i++) { if (FPRead_ext_async(Conn, fork, i * (dsi->server_quantum - FPWRITE_RQST_SIZE), dsi->server_quantum - FPWRITE_RQST_SIZE, data)) { fatal_failed(); } } pthread_join(tid, NULL); if (FPCloseFork(Conn,fork)) fatal_failed(); stoptimer(); addresult(TEST_READ100MB, Iterations); } /* Remove test 2+3 testfile */ if (teststorun[TEST_WRITE100MB]) FPDelete(Conn, vol, dir, "File.big"); /* -------- */ /* Test (4) */ if (teststorun[TEST_LOCKUNLOCK]) { strcpy(temp, "File.lock"); if (ntohl(AFPERR_NOOBJ) != is_there(Conn, dir, temp)) fatal_failed(); if (FPGetFileDirParams(Conn, vol, dir, "", 0, (1<< DIRPBIT_DID) )) fatal_failed(); if (FPCreateFile(Conn, vol, 0, dir , temp)) fatal_failed(); if (is_there(Conn, dir, temp)) fatal_failed(); if (FPGetFileDirParams(Conn, vol, dir, temp, (1<<FILPBIT_FNUM )|(1<<FILPBIT_PDID)|(1<<FILPBIT_FINFO)| (1<<FILPBIT_CDATE)|(1<<FILPBIT_DFLEN)|(1<<FILPBIT_RFLEN) , 0)) fatal_failed(); fork = FPOpenFork(Conn, vol, OPENFORK_DATA , (1<<FILPBIT_PDID)|(1<<FILPBIT_FNUM)|(1<<FILPBIT_DFLEN) , dir, temp, OPENACC_WR|OPENACC_RD|OPENACC_DWR|OPENACC_DRD); if (!fork) fatal_failed(); if (FPGetForkParam(Conn, fork, (1<<FILPBIT_PDID)|(1<<FILPBIT_DFLEN))) fatal_failed(); if (FPGetFileDirParams(Conn, vol, dir, temp, (1<< DIRPBIT_ATTR)|(1<<FILPBIT_CDATE)|(1<<FILPBIT_MDATE)| (1<<FILPBIT_FNUM)| (1<<FILPBIT_FINFO)|(1<<FILPBIT_DFLEN)|(1<<FILPBIT_RFLEN) , 0)) fatal_failed(); if (FPWrite(Conn, fork, 0, 40000, data, 0 )) fatal_failed(); if (FPCloseFork(Conn,fork)) fatal_failed(); if (is_there(Conn, dir, temp)) fatal_failed(); if (FPGetFileDirParams(Conn, vol, dir, temp, 0x73f, 0x133f)) fatal_failed(); fork = FPOpenFork(Conn, vol, OPENFORK_DATA , 0x342 , dir, temp,OPENACC_RD); if (!fork) fatal_failed(); if (FPGetForkParam(Conn, fork, (1<<FILPBIT_DFLEN))) {fatal_failed();} if (FPRead(Conn, fork, 0, 512, data)) {fatal_failed();} if (FPCloseFork(Conn,fork)) {fatal_failed();} fork = FPOpenFork(Conn, vol, OPENFORK_DATA, 0x342, dir, temp, OPENACC_RD|OPENACC_WR); if (!fork) fatal_failed(); if (FPGetForkParam(Conn, fork, 0x242)) fatal_failed(); if (FPGetFileDirParams(Conn, vol, dir, temp, 0x72d, 0)) fatal_failed(); starttimer(); for (j = 0; j < locking; j++) { for (i = 0;i <= 390; i += 10) { if (FPByteLock(Conn, fork, 0, 0 , i , 10)) {fatal_failed();} if (FPByteLock(Conn, fork, 0, 1 , i , 10)) {fatal_failed();} } } stoptimer(); addresult(TEST_LOCKUNLOCK, Iterations); if (is_there(Conn, dir, temp)) {fatal_failed();} if (FPCloseFork(Conn,fork)) {fatal_failed();} if (FPDelete(Conn, vol, dir, "File.lock")) {fatal_failed();} } /* -------- */ /* Test (5) */ if (teststorun[TEST_CREATE2000FILES]) { starttimer(); for (i=1; i <= create_enum_files; i++) { sprintf(temp, "File.0k%d", i); if (FPCreateFile(Conn, vol, 0, dir , temp)){ fatal_failed(); break; } if (FPGetFileDirParams(Conn, vol, dir, temp, (1<<FILPBIT_FNUM )|(1<<FILPBIT_PDID)|(1<<FILPBIT_FINFO)| (1<<FILPBIT_CDATE)|(1<<FILPBIT_DFLEN)|(1<<FILPBIT_RFLEN) , 0) != AFP_OK) fatal_failed(); } maxi = i; stoptimer(); addresult(TEST_CREATE2000FILES, Iterations); } /* -------- */ /* Test (6) */ if (teststorun[TEST_ENUM2000FILES]) { starttimer(); if (FPEnumerateFull(Conn, vol, 1, 40, DSI_DATASIZ, dir , "", (1<<FILPBIT_LNAME) | (1<<FILPBIT_FNUM ) | (1<<FILPBIT_ATTR) | (1<<FILPBIT_FINFO) | (1<<FILPBIT_CDATE) | (1<<FILPBIT_BDATE)| (1<<FILPBIT_MDATE) | (1<<FILPBIT_DFLEN) | (1<<FILPBIT_RFLEN) , (1<< DIRPBIT_ATTR) | (1<<DIRPBIT_ATTR) | (1<<DIRPBIT_FINFO)| (1<<DIRPBIT_CDATE) | (1<<DIRPBIT_BDATE) | (1<<DIRPBIT_MDATE)| (1<< DIRPBIT_LNAME) | (1<< DIRPBIT_PDID) | (1<< DIRPBIT_DID)| (1<< DIRPBIT_ACCESS))) fatal_failed(); for (i=41; (i + 40) < create_enum_files; i +=80) { if (FPEnumerateFull(Conn, vol, i + 40, 40, DSI_DATASIZ, dir , "", (1<<FILPBIT_LNAME) | (1<<FILPBIT_FNUM ) | (1<<FILPBIT_ATTR) | (1<<FILPBIT_FINFO) | (1<<FILPBIT_CDATE) | (1<<FILPBIT_BDATE)| (1<<FILPBIT_MDATE) | (1<<FILPBIT_DFLEN) | (1<<FILPBIT_RFLEN) , (1<< DIRPBIT_ATTR) | (1<<DIRPBIT_ATTR) | (1<<DIRPBIT_FINFO)| (1<<DIRPBIT_CDATE) | (1<<DIRPBIT_BDATE) | (1<<DIRPBIT_MDATE)| (1<< DIRPBIT_LNAME) | (1<< DIRPBIT_PDID) | (1<< DIRPBIT_DID)| (1<< DIRPBIT_ACCESS))) fatal_failed(); if (FPEnumerateFull(Conn, vol, i, 40, DSI_DATASIZ, dir , "", (1<<FILPBIT_LNAME) | (1<<FILPBIT_FNUM ) | (1<<FILPBIT_ATTR) | (1<<FILPBIT_FINFO) | (1<<FILPBIT_CDATE) | (1<<FILPBIT_BDATE)| (1<<FILPBIT_MDATE) | (1<<FILPBIT_DFLEN) | (1<<FILPBIT_RFLEN) , (1<< DIRPBIT_ATTR) | (1<<DIRPBIT_ATTR) | (1<<DIRPBIT_FINFO)| (1<<DIRPBIT_CDATE) | (1<<DIRPBIT_BDATE) | (1<<DIRPBIT_MDATE)| (1<< DIRPBIT_LNAME) | (1<< DIRPBIT_PDID) | (1<< DIRPBIT_DID)| (1<< DIRPBIT_ACCESS))) fatal_failed(); } stoptimer(); addresult(TEST_ENUM2000FILES, Iterations); } /* Delete files from Test (5/6) */ if (teststorun[TEST_CREATE2000FILES]) { for (i=1; i < maxi; i++) { sprintf(temp, "File.0k%d", i); if (FPDelete(Conn, vol, dir, temp)) fatal_failed(); } } /* -------- */ /* Test (7) */ if (teststorun[TEST_DIRTREE]) { uint32_t idirs[DIRNUM]; uint32_t jdirs[DIRNUM][DIRNUM]; uint32_t kdirs[DIRNUM][DIRNUM][DIRNUM]; starttimer(); for (i=0; i < DIRNUM; i++) { sprintf(temp, "dir%02u", i+1); FAILEXIT(!(idirs[i] = FPCreateDir(Conn,vol, dir, temp)), fin1); for (j=0; j < DIRNUM; j++) { sprintf(temp, "dir%02u", j+1); FAILEXIT(!(jdirs[i][j] = FPCreateDir(Conn,vol, idirs[i], temp)), fin1); for (k=0; k < DIRNUM; k++) { sprintf(temp, "dir%02u", k+1); FAILEXIT(!(kdirs[i][j][k] = FPCreateDir(Conn,vol, jdirs[i][j], temp)), fin1); } } } stoptimer(); addresult(TEST_DIRTREE, Iterations); for (i=0; i < DIRNUM; i++) { for (j=0; j < DIRNUM; j++) { for (k=0; k < DIRNUM; k++) { FAILEXIT(FPDelete(Conn,vol, kdirs[i][j][k], "") != 0, fin1); } FAILEXIT(FPDelete(Conn,vol, jdirs[i][j], "") != 0, fin1); } FAILEXIT(FPDelete(Conn,vol, idirs[i], "") != 0, fin1); } } fin1: fin: return; }
/* * Helper function for test_rsvol(). */ static int test_rsvol1(struct ubi_vol_info *vol_info) { long long bytes; struct ubi_vol_info vol_info1; char vol_node[strlen(UBI_VOLUME_PATTERN) + 100]; unsigned char buf[vol_info->rsvd_bytes]; int fd, i, ret; /* Make the volume smaller and check basic volume I/O */ bytes = vol_info->rsvd_bytes - vol_info->leb_size; if (ubi_rsvol(libubi, node, vol_info->vol_id, bytes - 1)) { failed("ubi_rsvol"); return -1; } if (ubi_get_vol_info1(libubi, vol_info->dev_num, vol_info->vol_id, &vol_info1)) { failed("ubi_get_vol_info"); return -1; } if (vol_info1.rsvd_bytes != bytes) { errorm("rsvd_bytes %lld, must be %lld", vol_info1.rsvd_bytes, bytes); return -1; } if (vol_info1.rsvd_lebs != vol_info->rsvd_lebs - 1) { errorm("rsvd_lebs %d, must be %d", vol_info1.rsvd_lebs, vol_info->rsvd_lebs - 1); return -1; } /* Write data to the volume */ sprintf(vol_node, UBI_VOLUME_PATTERN, dev_info.dev_num, vol_info->vol_id); fd = open(vol_node, O_RDWR); if (fd == -1) { failed("open"); errorm("cannot open \"%s\"\n", vol_node); return -1; } bytes = vol_info->rsvd_bytes - vol_info->leb_size - 1; if (ubi_update_start(libubi, fd, bytes)) { failed("ubi_update_start"); goto close; } for (i = 0; i < bytes; i++) buf[i] = (unsigned char)i; ret = write(fd, buf, bytes); if (ret != bytes) { failed("write"); goto close; } close(fd); if (ubi_rsvol(libubi, node, vol_info->vol_id, bytes)) { failed("ubi_rsvol"); return -1; } if (ubi_rsvol(libubi, node, vol_info->vol_id, (long long)vol_info->leb_size * dev_info.avail_lebs)) { failed("ubi_rsvol"); return -1; } fd = open(vol_node, O_RDWR); if (fd == -1) { failed("open"); errorm("cannot open \"%s\"\n", vol_node); return -1; } /* Read data back */ if (lseek(fd, 0, SEEK_SET) != 0) { failed("seek"); goto close; } memset(buf, 0, bytes); ret = read(fd, buf, bytes); if (ret != bytes) { failed("read"); goto close; } for (i = 0; i < bytes; i++) { if (buf[i] != (unsigned char)i) { errorm("bad data"); goto close; } } close(fd); return 0; close: close(fd); return -1; }
bool RemotePlugin::init(const QString &pluginExecutable, bool waitForInitDoneMsg , QStringList extraArgs) { lock(); if( m_failed ) { #ifdef SYNC_WITH_SHM_FIFO reset( new shmFifo(), new shmFifo() ); #endif m_failed = false; } QString exec = QFileInfo(QDir("plugins:"), pluginExecutable).absoluteFilePath(); #ifdef LMMS_BUILD_APPLE // search current directory first QString curDir = QCoreApplication::applicationDirPath() + "/" + pluginExecutable; if( QFile( curDir ).exists() ) { exec = curDir; } #endif #ifdef LMMS_BUILD_WIN32 if( ! exec.endsWith( ".exe", Qt::CaseInsensitive ) ) { exec += ".exe"; } #endif if( ! QFile( exec ).exists() ) { qWarning( "Remote plugin '%s' not found.", exec.toUtf8().constData() ); m_failed = true; invalidate(); unlock(); return failed(); } QStringList args; #ifdef SYNC_WITH_SHM_FIFO // swap in and out for bidirectional communication args << QString::number( out()->shmKey() ); args << QString::number( in()->shmKey() ); #else args << m_socketFile; #endif args << extraArgs; #ifndef DEBUG_REMOTE_PLUGIN m_process.setProcessChannelMode( QProcess::ForwardedChannels ); m_process.setWorkingDirectory( QCoreApplication::applicationDirPath() ); m_process.start( exec, args ); m_watcher.start( QThread::LowestPriority ); #else qDebug() << exec << args; #endif #ifndef SYNC_WITH_SHM_FIFO struct pollfd pollin; pollin.fd = m_server; pollin.events = POLLIN; switch ( poll( &pollin, 1, 30000 ) ) { case -1: qWarning( "Unexpected poll error." ); break; case 0: qWarning( "Remote plugin did not connect." ); break; default: m_socket = accept( m_server, NULL, NULL ); if ( m_socket == -1 ) { qWarning( "Unexpected socket error." ); } } #endif resizeSharedProcessingMemory(); if( waitForInitDoneMsg ) { waitForInitDone(); } unlock(); return failed(); }
void fail(char const * msg) { m_last_error = msg; throw failed(); }
/* * service routines for `execute' */ short initio(struct ionod *iop, int save) { unsigned char *ion; int iof, fd; int ioufd; short lastfd; int newmode; lastfd = topfd; while (iop) { iof = iop->iofile; ion = mactrim(iop->ioname); ioufd = iof & IOUFD; if (*ion && (flags&noexec) == 0) { if (save) { fdmap[topfd].org_fd = ioufd; fdmap[topfd++].dup_fd = savefd(ioufd); } if (iof & IODOC) { struct tempblk tb; subst(chkopen(ion, 0), (fd = tmpfil(&tb))); /* * pushed in tmpfil() -- * bug fix for problem with * in-line scripts */ poptemp(); fd = chkopen(tmpout, 0); unlink((const char *)tmpout); } else if (iof & IOMOV) { if (eq(minus, ion)) { fd = -1; close(ioufd); } else if ((fd = stoi(ion)) >= USERIO) { failed(ion, badfile); } else fd = dup(fd); } else if (((iof & IOPUT) == 0) && ((iof & IORDW) == 0)) fd = chkopen(ion, 0); else if (iof & IORDW) /* For <> */ { newmode = O_RDWR|O_CREAT; fd = chkopen(ion, newmode); } else if (flags & rshflg) { failed(ion, restricted); } else if (iof & IOAPP && (fd = open((char *)ion, 1)) >= 0) { lseek(fd, (off_t)0, SEEK_END); } else { fd = create(ion); } if (fd >= 0) renamef(fd, ioufd); } iop = iop->ionxt; } return (lastfd); }
void TestsListener::summary() { outputter->Summary(executed , failed() /*+ exceptions - exceptions are already counted in failed()*/ , failedTests); }
void LWJGLVersionList::netRequestComplete() { if (reply->error() == QNetworkReply::NoError) { QRegExp lwjglRegex("lwjgl-(([0-9]\\.?)+)\\.zip"); Q_ASSERT_X(lwjglRegex.isValid(), "load LWJGL list", "LWJGL regex is invalid"); QDomDocument doc; QString xmlErrorMsg; int errorLine; if (!doc.setContent(reply->readAll(), false, &xmlErrorMsg, &errorLine)) { failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + QString::number(errorLine)); setLoading(false); return; } QDomNodeList items = doc.elementsByTagName("item"); QList<PtrLWJGLVersion> tempList; for (int i = 0; i < items.length(); i++) { Q_ASSERT_X(items.at(i).isElement(), "load LWJGL list", "XML element isn't an element... wat?"); QDomElement linkElement = getDomElementByTagName(items.at(i).toElement(), "link"); if (linkElement.isNull()) { QLOG_INFO() << "Link element" << i << "in RSS feed doesn't exist! Skipping."; continue; } QString link = linkElement.text(); // Make sure it's a download link. if (link.endsWith("/download") && link.contains(lwjglRegex)) { QString name = link.mid(lwjglRegex.indexIn(link) + 6); // Subtract 4 here to remove the .zip file extension. name = name.left(lwjglRegex.matchedLength() - 10); QUrl url(link); if (!url.isValid()) { QLOG_INFO() << "LWJGL version URL isn't valid:" << link << "Skipping."; continue; } tempList.append(LWJGLVersion::Create(name, link)); } } beginResetModel(); m_vlist.swap(tempList); endResetModel(); QLOG_INFO() << "Loaded LWJGL list."; finished(); } else { failed("Failed to load LWJGL list. Network error: " + reply->errorString()); } setLoading(false); reply->deleteLater(); }