void MainController::newMedia(QString name) { if(!medias().contains(qMakePair(m_mw->currentCategory(),name))) { MediaSPointer zeus(new Media); zeus->setName(name); zeus->setCategory(AbstractController::category(m_mw->currentCategory()).data()); category(m_mw->currentCategory())->addAssociations(zeus); addMedia(zeus); setCurrentTable(m_mw->currentCategory()); m_mw->setCurrentMedia(name); } }
ScreenTab::ScreenTab(QWidget *parent) : QWidget(parent), ui(new Ui::ScreenTab), _currentMedia(NULL), _screen(NULL), _desktopMediaPlayer(new DesktopMediaPlayer(this)) { ui->setupUi(this); setScreen(new Screen(this)); // ui->currentDisplaySpinBox->setMaximum(QApplication::desktop()->screenCount() - 1); ui->splitter->setStretchFactor(0, 1); ui->splitter->setSizes(QList<int>() << 10000 << 1); setContextMenuPolicy(Qt::PreventContextMenu); addAction(ui->actionStartStopPlaying); ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::FilePatch, QHeaderView::Stretch); ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::NumberToShow, QHeaderView::ResizeToContents); ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::RandomWeigth, QHeaderView::ResizeToContents); ui->mediaListTableView->addAction(ui->actionAddMedia); ui->mediaListTableView->addAction(ui->actionAddExtension); ui->mediaListTableView->addAction(ui->actionRemoveRow); ui->mediaListTableView->addAction(ui->actionMoveMediaUp); ui->mediaListTableView->addAction(ui->actionMoveMediaDown); ui->mediaListTableView->setContextMenuPolicy(Qt::ActionsContextMenu); connect(ui->actionAddMedia, SIGNAL(triggered()), this, SLOT(addMedia())); connect(ui->actionAddExtension, SIGNAL(triggered()), this, SLOT(addExtension())); connect(ui->actionRemoveRow, SIGNAL(triggered()), this, SLOT(removeMedia())); connect(ui->actionMoveMediaUp, SIGNAL(triggered()), this, SLOT(moveMediaUp())); connect(ui->actionMoveMediaDown, SIGNAL(triggered()), this, SLOT(moveMediaDown())); connect(ui->actionStartStopPlaying, SIGNAL(triggered()), this, SLOT(startStopPlaying())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save())); connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(load())); // connect(ui->currentDisplaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(onCurrentDisplaySpinBoxChanged(int))); connect(_desktopMediaPlayer, SIGNAL(graphicSceneChanged(QGraphicsScene*)), this, SLOT(setSceneToPreview(QGraphicsScene*))); connect(_desktopMediaPlayer, SIGNAL(escKeyPressed()), this, SLOT(stopPlaying())); mediaListSelectedChanded(QItemSelection(), QItemSelection()); //Законектим изменение данных в энжайне расширений со слотом обновления расширений connect(MDVPlayerApplication::instance(), SIGNAL(extensionEngineDataChanged()), this, SLOT(updateExtensions())); onCurrentDisplaySpinBoxChanged(1); // onCurrentDisplaySpinBoxChanged(ui->currentDisplaySpinBox->value()); }
TEST_F( DeviceFs, PartialAlbumRemoval ) { ml->discover( mock::FileSystemFactory::Root ); bool discovered = cbMock->waitDiscovery(); ASSERT_TRUE( discovered ); { auto album = ml->createAlbum( "album" ); auto media = ml->media( mock::FileSystemFactory::SubFolder + "subfile.mp4" ); auto media2 = ml->media( RemovableDeviceMountpoint + "removablefile2.mp3" ); auto newArtist = ml->createArtist( "artist" ); album->addTrack( std::static_pointer_cast<Media>( media ), 1, 1, newArtist->id(), nullptr ); album->addTrack( std::static_pointer_cast<Media>( media2 ), 2, 1, newArtist->id(), nullptr ); album->setAlbumArtist( newArtist ); newArtist->updateNbTrack( 2 ); newArtist->addMedia( static_cast<Media&>( *media ) ); newArtist->addMedia( static_cast<Media&>( *media2 ) ); } auto albums = ml->albums( nullptr )->all(); ASSERT_EQ( 1u, albums.size() ); auto artists = ml->artists( true, nullptr )->all(); ASSERT_EQ( 1u, artists.size() ); auto artist = artists[0]; ASSERT_EQ( 2u, artist->tracks( nullptr )->count() ); auto device = fsMock->removeDevice( RemovableDeviceUuid ); Reload(); albums = ml->albums( nullptr )->all(); ASSERT_EQ( 1u, albums.size() ); artists = ml->artists( true, nullptr )->all(); ASSERT_EQ( 1u, artists.size() ); ASSERT_EQ( 1u, albums[0]->tracks( nullptr )->count() ); ASSERT_EQ( 1u, artists[0]->tracks( nullptr )->count() ); }
void Settings::accept() { QMap<QString, QString> hermes; hermes["language"] = language(); hermes["seeMedia"] = seeMedia(); hermes["addMedia"] = addMedia(); hermes["removeMedia"] = removeMedia(); hermes["seeCategory"] = seeCategory(); hermes["addCategory"] = addCategory(); hermes["removeCategory"] = removeCategory(); hermes["newData"] = newData(); hermes["loadData"] = loadData(); hermes["saveData"] = saveData(); hermes["saveAsData"] = saveAsData(); hermes["quit"] = quit(); hermes["search"] = search(); hermes["users"] = users(); hermes["settings"] = settings(); emit s_setting(hermes); close(); }
void MusicPlaylist::updateMediaLists(const QStringList &list, int index) { addMedia(list); setCurrentIndex(index); }
TEST_F( DeviceFs, RemoveArtist ) { ml->discover( mock::FileSystemFactory::Root ); bool discovered = cbMock->waitDiscovery(); ASSERT_TRUE( discovered ); // Check that an artist with a track remaining but album is still present // Album artist disappearance is already tested by RemoveAlbumAndArtist test auto artist = ml->createArtist( "removable artist" ); auto album = std::static_pointer_cast<Album>( ml->createAlbum( "removable album" ) ); auto media1 = std::static_pointer_cast<Media>( ml->media( RemovableDeviceMountpoint + "removablefile.mp3" ) ); auto media2 = std::static_pointer_cast<Media>( ml->media( RemovableDeviceMountpoint + "removablefile2.mp3" ) ); auto media3 = std::static_pointer_cast<Media>( ml->media( mock::FileSystemFactory::Root + "audio.mp3" ) ); album->addTrack( std::static_pointer_cast<Media>( media1 ), 1, 1, artist->id(), 0 ); album->addTrack( std::static_pointer_cast<Media>( media2 ), 2, 1, artist->id(), 0 ); album->addTrack( std::static_pointer_cast<Media>( media3 ), 3, 1, artist->id(), 0 ); artist->addMedia( *media1 ); artist->addMedia( *media2 ); artist->addMedia( *media3 ); // This would be done by the metadata parser, but there's none during unittests artist->updateNbTrack( 3 ); auto albums = ml->albums( nullptr )->all(); ASSERT_EQ( 1u, albums.size() ); auto artists = ml->artists( true, nullptr )->all(); ASSERT_EQ( 1u, artists.size() ); QueryParameters params; params.sort = SortingCriteria::Alpha; params.desc = false; auto tracks = artist->tracks( ¶ms )->all(); ASSERT_EQ( 3u, tracks.size() ); auto device = fsMock->removeDevice( RemovableDeviceUuid ); Reload(); // nothing should have changed as far as the artist count goes albums = ml->albums( nullptr )->all(); ASSERT_EQ( 1u, albums.size() ); artists = ml->artists( true, nullptr )->all(); ASSERT_EQ( 1u, artists.size() ); // But we expect the tracks count to be down artist = std::static_pointer_cast<Artist>( ml->artist( artist->id() ) ); tracks = artist->tracks( ¶ms )->all(); ASSERT_EQ( 1u, tracks.size() ); // Now check that everything appears again when we plug the device back in fsMock->addDevice( device ); Reload(); albums = ml->albums( nullptr )->all(); ASSERT_EQ( 1u, albums.size() ); artists = ml->artists( true, nullptr )->all(); ASSERT_EQ( 1u, artists.size() ); artist = std::static_pointer_cast<Artist>( ml->artist( artist->id() ) ); tracks = artist->tracks( nullptr )->all(); ASSERT_EQ( 3u, tracks.size() ); }
void MediaController::change(QTreeWidgetItem* root, QString old) { removeMedia(m_media->category()->name(), old); *m_media = *generate(root); addMedia(m_media); }
bool SDP::build(Exception& ex, const string& text) { SDPMedia* pMedia = NULL; vector<string> lines; String::Split(text, "\r\n", lines, String::SPLIT_IGNORE_EMPTY | String::SPLIT_TRIM); for(string& line : lines) { if(line.empty() || line[1] != '=') { ex.set(Exception::FORMATTING, "SDP line ",line," malformed, second byte isn't an equal sign"); return false; } UInt8 type = line[0]; line.erase(0,2); String::Trim(line, String::TRIM_LEFT); // RFC 4566 switch(type) { case 'v': // v= (protocol version) version = String::ToNumber<UInt32>(ex, line); break; case 'o': { // o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address> vector<string> fields; String::Split(line, " ", fields, String::SPLIT_IGNORE_EMPTY | String::SPLIT_TRIM); if (fields.size()!=6) { ex.set(Exception::PROTOCOL, "fields.size()!=6"); break; } user = fields[0]; sessionId = String::ToNumber<UInt32>(ex, fields[1]); if (ex) break; sessionVersion = String::ToNumber<UInt32>(ex, fields[2]); if (ex) break; unicastAddress.set(ex,fields[5],fields[4]=="IP6" ? IPAddress::IPv6 : IPAddress::IPv4); break; } case 's': // s= (session name) sessionName = line; break; /// Optional lines case 'i': // i=* (session information) sessionInfos = line; break; case 'u': // u=* (URI of description) uri = line; break; case 'e': // e=* (email address) email = line; break; case 'p': // p=* (phone number) phone = line; break; case 'c': { // c=* (connection information -- not required if included in all media) vector<string> fields; String::Split(line, " ", fields, String::SPLIT_IGNORE_EMPTY | String::SPLIT_TRIM); if(fields.size()!=3) { ex.set(Exception::PROTOCOL, "fields.size()!=3"); break; } IPAddress defaultAddress; // TODO defaultAddress is useless for what? defaultAddress.set(ex,fields[2], fields[1] == "IP6" ? IPAddress::IPv6 : IPAddress::IPv4); break; } case 'b': // b=* (zero or more bandwidth information lines) // TODO useless? break; // One or more time descriptions ("t=" and "r=" lines; see below) // t= (time the session is active) // r=* (zero or more repeat times) case 't': // TODO useless? break; case 'r': // TODO useless? break; case 'z': // z=* (time zone adjustments) // TODO useless? break; case 'k': // k=* (encryption key) encryptKey = line; break; case 'm': { // m=<name> <port> <proto> <fmt> vector<string> values; String::Split(line, " ", values, String::SPLIT_IGNORE_EMPTY | String::SPLIT_TRIM); if (values.size()<4) { ex.set(Exception::PROTOCOL , "values.size()<4"); break; } UInt16 val = String::ToNumber<UInt16>(ex, values[1]); if (ex) break; pMedia = addMedia(values[0], val, values[2]); for(const string& st : values) { pMedia->formats.emplace_back(String::ToNumber<UInt8>(ex, st)); if (ex) break; } break; } case 'a': { // a=* (zero or more session attribute lines) vector<string>* pFields = NULL; bool isMsId = false; string fingerHash; // TODO SDPSource* pSource = NULL; // TODO list<UInt32>* pSourceGroupe = NULL; vector<string> fields; String::Split(line, " ", fields, String::SPLIT_IGNORE_EMPTY | String::SPLIT_TRIM); for(const string& st : fields) { size_t pos = st.find(':'); string key,value; if(pos!=string::npos) { key = st.substr(0,pos); value = st.substr(pos+1); } else key = st; // RFC 5576 if(pMedia) { /* TODO if(pSourceGroupe) pSourceGroupe->push_back(NumberParser::parseUnsigned(field)); else if(pSource) { if(isMsId) pSource->msData = field; else if(key=="cname") // cname:<value> pSource->cname = value; else if(key=="msid") {// draft-alvestrand-mmusic-msid-00 isMsId = true; pSource->msId = value; } else if(key=="mslabel") // draft-alvestrand-rtcweb-mid-01 pSource->msLabel = value; else if(key=="label") // draft-alvestrand-rtcweb-mid-01 pSource->label = value; else WARN("Media source attribute ",key," unknown"); } else if(key=="ssrc") // a=ssrc:<ssrc-id> pSource = &sources[NumberParser::parseUnsigned(key)];// a=ssrc:<ssrc-id> <attribute> else if(key=="rtcp-mux") pMedia->rtcpMux = true; else if(key=="mid") // RFC 3388, a=mid:<token> pMedia->mid = value; else if(key=="ssrc-group") // a=ssrc-group:<semantics> pSourceGroupe = &sourceGroupes[value]; else if(key="crypto") { // a=crypto:<tag> <crypto-suite> <key-params> [<session-params>] StringTokenizer values(value," ",StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); poco_assert(values.size()>2) pMedia->cryptoTag = } else */ WARN("Media attribute ",key," unknown"); } else if(pFields) pFields->emplace_back(st); else if(!fingerHash.empty()) int i=0; // TODO finger = talk_base::SSLFingerprint::CreateFromRfc4572(fingerHash, field); else if(key=="group") // RFC 5888 and draft-holmberg-mmusic-sdp-bundle-negotiation-00 pFields = &groups[value]; else if(key=="ice-ufrag") iceUFrag = value; else if(key=="ice-pwd") icePwd = value; else if(key=="ice-options") { pFields = &iceOptions; iceOptions.emplace_back(value); } else if(key=="fingerprint") // fingerprint:<hash> <algo> fingerHash = value; // fingerprint:<hash> else if(key=="msid-semantic") supportMsId = value=="VMS"; else if(key=="extmap") // RFC 5285 a=extmap:<value>["/"<direction>] <URI> <extensionattributes> pFields = &extensions[value]; else WARN("SDP attribute ",key," unknown"); } } // case 'a': break; } // switch(type) if (ex) { ex.set(Exception::PROTOCOL, "SDP '",type,"' value ",line," malformed, ",ex.error()); return false; } } // for(string& line : lines) return true; }
int LoadController::exec() { clean(); QFile zeus (filename()); if(!zeus.open(QIODevice::ReadOnly)) { return -1; } QDomDocument hera; if(!hera.setContent(&zeus)) { return -2; } QDomElement athena = hera.documentElement(); QDomNodeList hermes = athena.elementsByTagName("user"); for(int appolon = 0; appolon < hermes.size(); appolon++) { QDomElement gaia = hermes.at(appolon).toElement(); UserSPointer ares = UserController::user(cypher(gaia.elementsByTagName("username").at(0).toElement().text(), 57)); if(ares) ares->setType((User::UserType)cypher(gaia.elementsByTagName("type").at(0).toElement().text(), 95).toInt()); } hermes = athena.elementsByTagName("category"); for(int apollon = 0; apollon < hermes.size(); apollon++) { if(hermes.at(apollon).parentNode().toElement().tagName() != "subCategory") { CategorySPointer ares(new Category); QDomElement aphrodite = hermes.at(apollon).toElement(); ares->load(aphrodite); if(!categories().contains(ares->name())) addCategory(ares); } } hermes = athena.elementsByTagName("entry"); for(int apollon = 0; apollon < hermes.size(); apollon++) { if(hermes.at(apollon).parentNode().toElement().tagName() != "subMedia") { MediaSPointer ares(new Media); QDomElement aphrodite = hermes.at(apollon).toElement(); ares->load(aphrodite, AbstractController::categories()); if(!medias().contains(qMakePair(ares->category()->name(),ares->name()))) { ares->category()->addAssociations(ares); addMedia(ares); } } } zeus.close(); return 0; }