MergeTreeSequentialBlockInputStream::MergeTreeSequentialBlockInputStream( const MergeTreeData & storage_, const MergeTreeData::DataPartPtr & data_part_, Names columns_to_read_, bool read_with_direct_io_, bool take_column_types_from_storage, bool quiet) : storage(storage_) , data_part(data_part_) , part_columns_lock(data_part->columns_lock) , columns_to_read(columns_to_read_) , read_with_direct_io(read_with_direct_io_) , mark_cache(storage.global_context.getMarkCache()) { if (!quiet) { std::stringstream message; message << "Reading " << data_part->marks_count << " marks from part " << data_part->name << ", total " << data_part->rows_count << " rows starting from the beginning of the part, columns: "; for (size_t i = 0, size = columns_to_read.size(); i < size; ++i) message << (i == 0 ? "" : ", ") << columns_to_read[i]; LOG_TRACE(log, message.rdbuf()); } addTotalRowsApprox(data_part->rows_count); header = storage.getSampleBlockForColumns(columns_to_read); fixHeader(header); /// Add columns because we don't want to read empty blocks injectRequiredColumns(storage, data_part, columns_to_read); NamesAndTypesList columns_for_reader; if (take_column_types_from_storage) { const NamesAndTypesList & physical_columns = storage.getColumns().getAllPhysical(); columns_for_reader = physical_columns.addTypes(columns_to_read); } else { /// take columns from data_part columns_for_reader = data_part->columns.addTypes(columns_to_read); } reader = std::make_unique<MergeTreeReader>( data_part->getFullPath(), data_part, columns_for_reader, /* uncompressed_cache = */ nullptr, mark_cache.get(), /* save_marks_in_cache = */ false, storage, MarkRanges{MarkRange(0, data_part->marks_count)}, /* bytes to use AIO (this is hack) */ read_with_direct_io ? 1UL : std::numeric_limits<size_t>::max(), DBMS_DEFAULT_BUFFER_SIZE); }
Player::Player(QWidget *parent): QMainWindow(parent), _ui(new Ui::Player), _player(new Phonon::MediaObject(this)), _audioOutput(new Phonon::AudioOutput(Phonon::MusicCategory, this)), _trayIcon(new QSystemTrayIcon(this)), _isStopped(false), _isPaused(false), _artistToPlaylistAction(new QAction(tr("Add to playlist"), this)), _artistsMenu(new QMenu(this)), _albumToPlaylistAction(new QAction(tr("Add to playlist"), this)), _albumsMenu(new QMenu(this)), _trackToPlaylistAction(new QAction(tr("Add to playlist"), this)), _tracksMenu(new QMenu(this)), _removeTrackAction(new QAction(tr("Remove track"), this)), _playlistMenu(new QMenu(this)), _playAction(new QAction(tr("Play"), this)), _pauseAction(new QAction(tr("Pause"), this)), _playNextAction(new QAction(tr("Play next"), this)), _playPrevAction(new QAction(tr("Play previous"), this)), _stopAction(new QAction(tr("Stop"), this)), _trayMenu(new QMenu(this)), _lastFMDialog(new LastFMAuthDialog(this)) { _ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); this->setWindowTitle(qApp->applicationName()); _ui->pauseButton->setHidden(true); fixHeader(_ui->tracks->horizontalHeader()); fixHeader(_ui->playlist->horizontalHeader()); _ui->tracks->verticalHeader()->setDefaultSectionSize(_ui->artists->sizeHintForRow(0) + 4); _ui->playlist->verticalHeader()->setDefaultSectionSize(_ui->artists->sizeHintForRow(0) + 4); _ui->previousButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipBackward)); _ui->playButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPlay)); _ui->pauseButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPause)); _ui->stopButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaStop)); _ui->nextButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipForward)); _playPrevAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipBackward)); _playAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPlay)); _pauseAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPause)); _pauseAction->setVisible(false); _stopAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaStop)); _playNextAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipForward)); _ui->actionQuit->setIcon(qApp->style()->standardIcon(QStyle::SP_DialogCloseButton)); _trayMenu->addAction(_playAction); _trayMenu->addAction(_pauseAction); _trayMenu->addAction(_playPrevAction); _trayMenu->addAction(_playNextAction); _trayMenu->addAction(_stopAction); _trayMenu->addAction(_ui->actionQuit); _trayIcon->setContextMenu(_trayMenu); _trayIcon->setIcon(QIcon(":/icon.png")); _trayIcon->show(); Phonon::createPath(_player, _audioOutput); _ui->seekSlider->setMediaObject(_player); _ui->volumeSlider->setAudioOutput(_audioOutput); _artistsMenu->addAction(_artistToPlaylistAction); _albumsMenu->addAction(_albumToPlaylistAction); _tracksMenu->addAction(_trackToPlaylistAction); _playlistMenu->addAction(_removeTrackAction); connect(_ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(_ui->actionAdd_directory, SIGNAL(triggered()), this, SLOT(addDirToLibrary())); connect(_ui->actionAdd_files, SIGNAL(triggered()), this, SLOT(addFilesToLibrary())); connect(_ui->actionClear_playlist, SIGNAL(triggered()), this, SLOT(clearPlaylist())); connect(_ui->actionLoad_playlist, SIGNAL(triggered()), this, SLOT(loadPlaylist())); connect(_ui->actionSave_playlist, SIGNAL(triggered()), this, SLOT(savePlaylist())); connect(_ui->nextButton, SIGNAL(clicked()), this, SLOT(playNext())); connect(_ui->playButton, SIGNAL(clicked()), this, SLOT(play())); connect(_ui->tracks, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(playSelected())); connect(_ui->playlist, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(playSelected())); connect(_ui->stopButton, SIGNAL(clicked()), this, SLOT(stop())); connect(_ui->pauseButton, SIGNAL(clicked()), this, SLOT(pause())); connect(_ui->stopButton, SIGNAL(clicked()), _player, SLOT(stop())); connect(_ui->previousButton, SIGNAL(clicked()), this, SLOT(playPrevious())); connect(_playAction, SIGNAL(triggered()), this, SLOT(play())); connect(_pauseAction, SIGNAL(triggered()), _player, SLOT(pause())); connect(_stopAction, SIGNAL(triggered()), _player, SLOT(stop())); connect(_playNextAction, SIGNAL(triggered()), this, SLOT(playNext())); connect(_playPrevAction, SIGNAL(triggered()), this, SLOT(playPrevious())); connect(_ui->artists, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showArtistsContextMenu(const QPoint &))); connect(_ui->albums, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showAlbumsContextMenu(const QPoint &))); connect(_ui->tracks, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showTracksContextMenu(const QPoint &))); connect(_ui->playlist, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showPlaylistContextMenu(const QPoint &))); connect(DataBase::instance(), SIGNAL(albumsUpdated()), this, SLOT(updateAlbums())); connect(DataBase::instance(), SIGNAL(artistsUpdated()), this, SLOT(updateArtists())); connect(DataBase::instance(), SIGNAL(tracksUpdated()), this, SLOT(updateTracks())); connect(_ui->artists, SIGNAL(currentRowChanged(int)), this, SLOT(updateAlbums())); connect(_ui->albums, SIGNAL(currentRowChanged(int)), this, SLOT(updateTracks())); connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); connect(_player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); connect(_player, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); connect(_player, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); connect(_player, SIGNAL(finished()), this, SLOT(trackFinished())); connect(_ui->actionSettings, SIGNAL(triggered()), _lastFMDialog, SLOT(show())); connect(_ui->actionScrobbling, SIGNAL(toggled(bool)), this, SLOT(scrobblingToggled(bool))); connect(Settings::instance(), SIGNAL(scrobblingChanged(bool)), _ui->actionScrobbling, SLOT(setChecked(bool))); _allArtists = _ui->artists->item(0); _allArtists->setText(ALL); _allAlbums = _ui->albums->item(0); _allAlbums->setText(ALL); loadPlaylist(RECENTPLAYLIST); _ui->actionScrobbling->setChecked(Settings::instance()->isScrobblingEnabled()); _ui->actionSettings->setEnabled(Settings::instance()->isScrobblingEnabled()); scrobblingToggled(Settings::instance()->isScrobblingEnabled()); }
void main(int argc, char *argv[]) { unsigned char buffer[bufferLength]; // data buffer unsigned char key[keyLength]; // encryption key size_t count, check; int i; FILE *crypt, *plain; // ---------------------- if( argc < 3) // file names must be present { cout << "\n Word Unprotect -- Version " << Version; cout << "\n by Marc Thibault, " << VersionDate; cout << "\n Syntax: wu infile outfile \n"; exit (1); } // Open files if( NULL == (crypt = fopen(argv[1], "rb"))) { cout << "\n wu error: can't open the input file\n"; exit (2); } if( NULL == (plain = fopen(argv[2], "wb"))) { cout << "\n wu error: can't open the output file\n"; exit (3); } // Read header from input file count = fread(buffer,1,headerLength,crypt); if(count != bufferLength) { cout << "\n wu error: Input file too short to be a Word File\n"; exit(5); } // Extract the encryption key if(findKey(buffer,key)) { cout << "\n wu error: Couldn't find a key \n"; exit(4); } #ifdef debug cout << "\n Key in hexadecimal is"; for (i=0; i<keyLength; i++) printf(" %02X", key[i]); cout << "\n"; #endif // Decrypt/fixup the header and // write it to the output file fixHeader(buffer,key); check = fwrite(buffer, 1, headerLength, plain); if (check != headerLength) { cout << "\n wu error: Problem writing to output file"; exit(6); } // decrypt the rest of the file do { count = fread(buffer,1,bufferLength,crypt); if (count != 0) { fixBuffer(buffer, key); check = fwrite(buffer, 1, count, plain); if (check != count) { cout << "\n wu error: Problem writing to output file"; exit(6); } } } while (count == bufferLength); }