Boolean getArtistExists(int idNumber) { if (getArtist(idNumber) == NULL) { return FALSE; } return TRUE; }
static int editSongAlbumArtist(command_t *sel, command_t *act){ char query[300]; int artistid,albumid; struct dbitem dbi; dbiInit(&dbi); if(act->args->next==NULL){ fprintf(stderr,"albumartist: Two arguments required for this action.\n"); return HARP_RET_ERR; } if(act->args->next->words->flag==WORD_DEFAULT) artistid=strtol(act->args->next->words->word,NULL,10); else artistid=getArtist(act->args->next->words->word); if(act->args->words->flag==WORD_DEFAULT) albumid=strtol(act->args->words->word,NULL,10); else albumid=getAlbum(act->args->words->word,artistid); snprintf(query,300,"UPDATE Song SET AlbumID=%d WHERE SongID IN (SELECT SelectID FROM TempSelect WHERE TempID=%d)",albumid,sel->tlid); harp_sqlite3_exec(conn,query,NULL,NULL,NULL); return HARP_RET_OK; }
HRESULT PlaybackControls::LoadFile() { QPixmap picture; picture = getPicture(mFile); if (!picture.isNull()) { mpParentWindow->id3Art->setPixmap(picture.scaledToHeight(128)); } HRESULT hr = 0; if (!mpGraph) { if (FAILED(hr = InitialiseFilterGraph())) return hr; } if (!mGraphValid) { hr = mpGraph->RenderFile(mFile.toStdWString().c_str(), NULL); if (SUCCEEDED(hr)) { QString metadata = getArtist(mFile); mpParentWindow->artistLabel->setText("Artist : " + metadata); metadata = getAlbum(mFile); mpParentWindow->albumLabel->setText("Album : " + metadata); metadata = getTitle(mFile); mpParentWindow->titleLabel->setText("Title : " + metadata); mGraphValid = true; setVolume(mVolume); emit volumeChanged(mVolume); } return hr; } return S_OK; }
void MusicLibraryItemRoot::groupSingleTracks() { if (!supportsAlbumArtist || isFlat) { return; } QList<MusicLibraryItem *>::iterator it=m_childItems.begin(); MusicLibraryItemArtist *various=0; bool created=false; for (; it!=m_childItems.end(); ) { if (various!=(*it) && static_cast<MusicLibraryItemArtist *>(*it)->allSingleTrack()) { if (!various) { various=getArtist(Song::variousArtists()); if (!various) { various=new MusicLibraryItemArtist(Song::variousArtists(), QString(), QString(), this); created=true; } } various->addToSingleTracks(static_cast<MusicLibraryItemArtist *>(*it)); delete (*it); it=m_childItems.erase(it); } else { ++it; } } if (various) { if (created) { m_childItems.append(various); } refreshIndexes(); } }
bool MusicLibraryItemRoot::isFromSingleTracks(const Song &s) const { if (!isFlat && (supportsAlbumArtist && !s.file.isEmpty())) { MusicLibraryItemArtist *various=getArtist(Song::variousArtists()); return various && various->isFromSingleTracks(s); } return false; }
Meta::TrackPtr UpnpCache::getTrack( const KIO::UDSEntry &entry, bool refresh ) { QMutexLocker lock( &m_cacheMutex ); // a little indirection to get the nicely formatted track uidUrl Meta::UpnpTrackPtr track( new Meta::UpnpTrack( m_collection ) ); track->setUidUrl( entry.stringValue( KIO::UPNP_ID ) ); // if we have a reference ID search for that // in either case the original ID (refID) becomes our UID URL instead of the UPNP_ID if( entry.contains( KIO::UPNP_REF_ID ) ) { track->setUidUrl( entry.stringValue( KIO::UPNP_REF_ID ) ); } QString uidUrl = track->uidUrl(); if( m_trackMap.contains( uidUrl ) && !refresh ) { return m_trackMap[uidUrl]; } // UDS_NAME is the plain ASCII, relative path prefixed name // but UDS_DISPLAY_NAME is the unicode, 'file' name. track->setTitle( entry.stringValue( KIO::UDSEntry::UDS_DISPLAY_NAME ) ); track->setPlayableUrl( entry.stringValue(KIO::UDSEntry::UDS_TARGET_URL) ); track->setTrackNumber( entry.stringValue(KIO::UPNP_TRACK_NUMBER).toInt() ); // TODO validate and then convert to kbps track->setBitrate( entry.stringValue( KIO::UPNP_BITRATE ).toInt() / 1024 ); track->setLength( duration( entry.stringValue( KIO::UPNP_DURATION ) ) ); Meta::UpnpArtistPtr artist = Meta::UpnpArtistPtr::staticCast( getArtist( entry.stringValue( KIO::UPNP_ARTIST ) ) ); artist->addTrack( track ); track->setArtist( artist ); Meta::UpnpAlbumPtr album = Meta::UpnpAlbumPtr::staticCast( getAlbum( entry.stringValue( KIO::UPNP_ALBUM ), artist->name() ) ); album->setAlbumArtist( artist ); album->addTrack( track ); track->setAlbum( album ); // album art if( ! album->imageLocation().isValid() ) album->setAlbumArtUrl( entry.stringValue( KIO::UPNP_ALBUMART_URI ) ); Meta::UpnpGenrePtr genre = Meta::UpnpGenrePtr::staticCast( getGenre( entry.stringValue( KIO::UPNP_GENRE ) ) ); genre->addTrack( track ); track->setGenre( genre ); // TODO this is plain WRONG! the UPNP_DATE will not have year of the album // it will have year of addition to the collection //QString yearStr = yearForDate( entry.stringValue( KIO::UPNP_DATE ) ); // //Meta::UpnpYearPtr year = Meta::UpnpYearPtr::staticCast( getYear( yearStr ) ); //year->addTrack( track ); //track->setYear( year ); m_trackMap.insert( uidUrl, Meta::TrackPtr::staticCast( track ) ); return Meta::TrackPtr::staticCast( track ); }
Meta::AlbumPtr UpnpCache::getAlbum(const QString& name, const QString &artist ) { if( m_albumMap.contains( name, artist ) ) return m_albumMap.value( name, artist ); Meta::UpnpAlbumPtr album( new Meta::UpnpAlbum( name ) ); album->setAlbumArtist( Meta::UpnpArtistPtr::staticCast( getArtist( artist ) ) ); m_albumMap.insert( Meta::AlbumPtr::staticCast( album ) ); return Meta::AlbumPtr::staticCast( album ); }
/* Function: getArtistName * Params: int idNumber * Returns: char*. * * This function retrieves the name of an artist with the specified id. * It returns NULL if the artistdoes not exist in the database. */ char *getArtistName(int idNumber) { artistNode_t *a; a = getArtist(idNumber); if (a != NULL) { return htmlEscape(a->name, TRUE); } return NULL; }
/*============================ MAKE SONG ============================*/ Song make_song() { Song song; getTitle(song.title); getArtist(song.artist); song.year = getYear(); return song; }
CMP3Info CMP3ID3::getMP3Info(){ CMP3Info mp3; mp3.setTitle(getTitle()); mp3.setArtist(getArtist()); mp3.setAlbum(getAlbum()); mp3.setYear(getYear()); mp3.setTrack(getTrack()); mp3.setGenre(getGenre()); mp3.setComment(getComment()); return mp3; }
/** Redefined from MiamSortFilterProxyModel. */ bool UniqueLibraryFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QStandardItem *item = _model->itemFromIndex(_model->index(sourceRow, 1, sourceParent)); if (!item) { return false; } bool result = false; switch (item->type()) { case Miam::IT_Artist: if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) { result = true; } else { QSqlQuery getArtist(*SqlDatabase::instance()); getArtist.prepare("SELECT * FROM tracks WHERE title LIKE ? AND artistId = ?"); getArtist.addBindValue("%" + filterRegExp().pattern() + "%"); getArtist.addBindValue(item->data(Miam::DF_ID).toUInt()); result = getArtist.exec() && getArtist.next(); } break; case Miam::IT_Album: if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) { result = true; } else if (filterRegExp().indexIn(item->data(Miam::DF_Artist).toString()) != -1) { result = true; } else { QSqlQuery getAlbum(*SqlDatabase::instance()); getAlbum.prepare("SELECT * FROM tracks WHERE title LIKE ? AND albumId = ?"); getAlbum.addBindValue("%" + filterRegExp().pattern() + "%"); getAlbum.addBindValue(item->data(Miam::DF_ID).toUInt()); result = getAlbum.exec() && getAlbum.next(); } break; case Miam::IT_Track: if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) { result = true; } else { result = filterRegExp().indexIn(item->data(Miam::DF_Artist).toString()) != -1 || filterRegExp().indexIn(item->data(Miam::DF_Album).toString()) != -1; } break; case Miam::IT_Separator: for (QModelIndex index : _topLevelItems.values(static_cast<SeparatorItem*>(item))) { if (filterAcceptsRow(index.row(), sourceParent)) { result = true; } } break; default: break; } return result; }
void MusicData::setSong(const skrillex::Song& song) { m_song = song; if (!getSong().empty()) m_tier = Tier_S; if (!getArtist().empty()) m_tier = static_cast<Tier>(m_tier + Tier_A); if (!getGenre().empty()) m_tier = static_cast<Tier>(m_tier + Tier_G); }
static int editAlbumArtist(command_t *sel, command_t *act){ char query[300]; int artistid; if(act->args->words->flag==WORD_DEFAULT) artistid=strtol(act->args->words->word,NULL,10); else artistid=getArtist(act->args->words->word); snprintf(query,300,"UPDATE AlbumArtist SET ArtistID=%d WHERE AlbumID IN (SELECT SelectID FROM TempSelect WHERE TempID=%d)",artistid,sel->tlid); harp_sqlite3_exec(conn,query,NULL,NULL,NULL); return HARP_RET_OK; }
void MainWindow::setupMusicsView() { QStringList headers; auto app = (Application*) qApp; headers << "Musica" << "Artista" << "Album" << "Tempo" << "Genero"; ui->musicsView->setColumnCount(5); ui->musicsView->setRowCount(app->library->count()); ui->musicsView->setHorizontalHeaderLabels(headers); // Lista todas as músicas da biblioteca. for (int i = 0; i < app->library->count(); ++i) { auto music = app->library->music(i); ui->musicsView->setItem(i, 0, new QTableWidgetItem(music.getName())); ui->musicsView->setItem(i, 1, new QTableWidgetItem(music.getArtist())); ui->musicsView->setItem(i, 2, new QTableWidgetItem(music.getAlbum())); ui->musicsView->setItem(i, 3, new QTableWidgetItem(music.getDuration().toString())); ui->musicsView->setItem(i, 4, new QTableWidgetItem(music.getGenre())); } }
HRESULT PlaybackControls::LoadFile() { mMediaObject.stop(); // Phonon::State state = mMediaObject.state(); QPixmap picture; picture = getPicture(mFile); if (!picture.isNull()) { mpParentWindow->id3Art->setPixmap(picture.scaledToHeight(128)); } QString metadata = getArtist(mFile); mpParentWindow->artistLabel->setText("Artist : " + metadata); metadata = getAlbum(mFile); mpParentWindow->albumLabel->setText("Album : " + metadata); metadata = getTitle(mFile); mpParentWindow->titleLabel->setText("Title : " + metadata); mMediaObject.setCurrentSource(mFile); QStringList list = mMediaObject.metaData(Phonon::TitleMetaData); // bool test = list.isEmpty(); mAudioOutput.setVolume(mVolume / 100.0); volumeChanged(mVolume); return 0; }
bool Album::sync() { Album* album = findById(id); if (!album) { if (!basicGenreId && basicGenre) { basicGenre->sync(); basicGenreId = basicGenre->getId(); } } if (!album) album = findByNameAndArtist(getName(), getArtist()); if (!album) return true; // check fields bool needsUpdate = false; boost::regex decimal("(-?\\d+)\\.?\\d*"); boost::smatch match1; boost::smatch match2; if (id != album->getId()) { if (id) { LOG(INFO) << "updating album " << id << " id from " << album->getId() << " to " << id; needsUpdate = true; } else { id = album->getId(); } } if (name.compare(album->getName()) && (!boost::regex_match(name, match1, decimal) || !boost::regex_match(album->getName(), match2, decimal) || match1[1].str().compare(match2[1].str()))) { if (!name.empty()) { LOG(INFO) << "updating album " << id << " name from " << album->getName() << " to " << name; needsUpdate = true; } else { name = album->getName(); } } if (artist.compare(album->getArtist()) && (!boost::regex_match(artist, match1, decimal) || !boost::regex_match(album->getArtist(), match2, decimal) || match1[1].str().compare(match2[1].str()))) { if (!artist.empty()) { LOG(INFO) << "updating album " << id << " artist from " << album->getArtist() << " to " << artist; needsUpdate = true; } else { artist = album->getArtist(); } } if (coverFilepath.compare(album->getCoverFilepath()) && (!boost::regex_match(coverFilepath, match1, decimal) || !boost::regex_match(album->getCoverFilepath(), match2, decimal) || match1[1].str().compare(match2[1].str()))) { if (!coverFilepath.empty()) { LOG(INFO) << "updating album " << id << " coverFilepath from " << album->getCoverFilepath() << " to " << coverFilepath; needsUpdate = true; } else { coverFilepath = album->getCoverFilepath(); } } if (mixed != album->getMixed()) { if (mixed) { LOG(INFO) << "updating album " << id << " mixed from " << album->getMixed() << " to " << mixed; needsUpdate = true; } else { mixed = album->getMixed(); } } if (label.compare(album->getLabel()) && (!boost::regex_match(label, match1, decimal) || !boost::regex_match(album->getLabel(), match2, decimal) || match1[1].str().compare(match2[1].str()))) { if (!label.empty()) { LOG(INFO) << "updating album " << id << " label from " << album->getLabel() << " to " << label; needsUpdate = true; } else { label = album->getLabel(); } } if (catalogId.compare(album->getCatalogId()) && (!boost::regex_match(catalogId, match1, decimal) || !boost::regex_match(album->getCatalogId(), match2, decimal) || match1[1].str().compare(match2[1].str()))) { if (!catalogId.empty()) { LOG(INFO) << "updating album " << id << " catalogId from " << album->getCatalogId() << " to " << catalogId; needsUpdate = true; } else { catalogId = album->getCatalogId(); } } if (releaseDateYear != album->getReleaseDateYear()) { if (releaseDateYear) { LOG(INFO) << "updating album " << id << " releaseDateYear from " << album->getReleaseDateYear() << " to " << releaseDateYear; needsUpdate = true; } else { releaseDateYear = album->getReleaseDateYear(); } } if (releaseDateMonth != album->getReleaseDateMonth()) { if (releaseDateMonth) { LOG(INFO) << "updating album " << id << " releaseDateMonth from " << album->getReleaseDateMonth() << " to " << releaseDateMonth; needsUpdate = true; } else { releaseDateMonth = album->getReleaseDateMonth(); } } if (releaseDateDay != album->getReleaseDateDay()) { if (releaseDateDay) { LOG(INFO) << "updating album " << id << " releaseDateDay from " << album->getReleaseDateDay() << " to " << releaseDateDay; needsUpdate = true; } else { releaseDateDay = album->getReleaseDateDay(); } } if (basicGenreId != album->getBasicGenreId()) { if (basicGenreId) { LOG(INFO) << "updating album " << id << " basicGenreId from " << album->getBasicGenreId() << " to " << basicGenreId; needsUpdate = true; } else { basicGenreId = album->getBasicGenreId(); } } if (basicGenre) needsUpdate |= basicGenre->sync(); return needsUpdate; }
MusicLibraryItemArtist * MusicLibraryItemRoot::artist(const Song &s, bool create) { QString aa=songArtist(s); MusicLibraryItemArtist *artistItem=getArtist(aa); return artistItem ? artistItem : (create ? createArtist(s) : 0); }
void BrowseThread::populateModel() { m_path_mutex.lock(); MDir thisPath = m_path; BrowseTableModel* thisModelObserver = m_model_observer; m_path_mutex.unlock(); // Refresh the name filters in case we loaded new SoundSource plugins. QStringList nameFilters(SoundSourceProxy::getSupportedFileNamePatterns()); QDirIterator fileIt(thisPath.dir().absolutePath(), nameFilters, QDir::Files | QDir::NoDotAndDotDot); // remove all rows // This is a blocking operation // see signal/slot connection in BrowseTableModel emit(clearModel(thisModelObserver)); QList< QList<QStandardItem*> > rows; int row = 0; // Iterate over the files while (fileIt.hasNext()) { // If a user quickly jumps through the folders // the current task becomes "dirty" m_path_mutex.lock(); MDir newPath = m_path; m_path_mutex.unlock(); if (thisPath.dir() != newPath.dir()) { qDebug() << "Abort populateModel()"; return populateModel(); } QString filepath = fileIt.next(); auto pTrack = Track::newTemporary(filepath, thisPath.token()); SoundSourceProxy(pTrack).updateTrackFromSource(); QList<QStandardItem*> row_data; QStandardItem* item = new QStandardItem("0"); item->setData("0", Qt::UserRole); row_data.insert(COLUMN_PREVIEW, item); item = new QStandardItem(pTrack->getFileName()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_FILENAME, item); item = new QStandardItem(pTrack->getArtist()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_ARTIST, item); item = new QStandardItem(pTrack->getTitle()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_TITLE, item); item = new QStandardItem(pTrack->getAlbum()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_ALBUM, item); item = new QStandardItem(pTrack->getAlbumArtist()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_ALBUMARTIST, item); item = new QStandardItem(pTrack->getTrackNumber()); item->setToolTip(item->text()); item->setData(item->text().toInt(), Qt::UserRole); row_data.insert(COLUMN_TRACK_NUMBER, item); const QString year(pTrack->getYear()); item = new YearItem(year); item->setToolTip(year); // The year column is sorted according to the numeric calendar year item->setData(mixxx::TrackMetadata::parseCalendarYear(year), Qt::UserRole); row_data.insert(COLUMN_YEAR, item); item = new QStandardItem(pTrack->getGenre()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_GENRE, item); item = new QStandardItem(pTrack->getComposer()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_COMPOSER, item); item = new QStandardItem(pTrack->getGrouping()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_GROUPING, item); item = new QStandardItem(pTrack->getComment()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_COMMENT, item); QString duration = pTrack->getDurationText(mixxx::Duration::Precision::SECONDS); item = new QStandardItem(duration); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_DURATION, item); item = new QStandardItem(pTrack->getBpmText()); item->setToolTip(item->text()); item->setData(pTrack->getBpm(), Qt::UserRole); row_data.insert(COLUMN_BPM, item); item = new QStandardItem(pTrack->getKeyText()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_KEY, item); item = new QStandardItem(pTrack->getType()); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_TYPE, item); item = new QStandardItem(pTrack->getBitrateText()); item->setToolTip(item->text()); item->setData(pTrack->getBitrate(), Qt::UserRole); row_data.insert(COLUMN_BITRATE, item); QString location = pTrack->getLocation(); QString nativeLocation = QDir::toNativeSeparators(location); item = new QStandardItem(nativeLocation); item->setToolTip(nativeLocation); item->setData(location, Qt::UserRole); row_data.insert(COLUMN_NATIVELOCATION, item); QDateTime modifiedTime = pTrack->getFileModifiedTime().toLocalTime(); item = new QStandardItem(modifiedTime.toString(Qt::DefaultLocaleShortDate)); item->setToolTip(item->text()); item->setData(modifiedTime, Qt::UserRole); row_data.insert(COLUMN_FILE_MODIFIED_TIME, item); QDateTime creationTime = pTrack->getFileCreationTime().toLocalTime(); item = new QStandardItem(creationTime.toString(Qt::DefaultLocaleShortDate)); item->setToolTip(item->text()); item->setData(creationTime, Qt::UserRole); row_data.insert(COLUMN_FILE_CREATION_TIME, item); const mixxx::ReplayGain replayGain(pTrack->getReplayGain()); item = new QStandardItem( mixxx::ReplayGain::ratioToString(replayGain.getRatio())); item->setToolTip(item->text()); item->setData(item->text(), Qt::UserRole); row_data.insert(COLUMN_REPLAYGAIN, item); rows.append(row_data); ++row; // If 10 tracks have been analyzed, send it to GUI // Will limit GUI freezing if (row % 10 == 0) { // this is a blocking operation emit(rowsAppended(rows, thisModelObserver)); qDebug() << "Append " << rows.count() << " from " << filepath; rows.clear(); } // Sleep additionally for 10ms which prevents us from GUI freezes msleep(20); } emit(rowsAppended(rows, thisModelObserver)); qDebug() << "Append last " << rows.count(); }
int CProxy::SubstituteTags(CString *buf, int skAccept, int searchflag, char *searchstring, int startswithflag, char *startswithstring, char *errorcode, int adminFlag) { int ret = 0; int iError = 0; char *pszSongTitle = (char *)1; char szArtist[255] = ""; int playlistpos = 0; CString substituted; char tmpbuf[1024] = ""; int replaceflag = 0; CString tempArtist; int foundit = 0; int loop = 1; int errorCode = 0; errorCode = atoi(errorcode); ret = buf->Find("%%ARTISTSELECT%%"); if (ret != -1) { while(loop) { memset(szArtist, '\000', sizeof(szArtist)); loop = getArtist(playlistpos, szArtist); if(loop) { tempArtist = szArtist; foundit = 0; for(int i=0;i <= ArtistList.GetUpperBound();i++) { if (ArtistList.GetAt(i) == tempArtist) { foundit = 1; } } if (!foundit) { if (strlen(tempArtist) > 0) { ArtistList.Add(tempArtist); } } } playlistpos++; } CArray<CString, CString &> ArtistListSorted; for(int j=0;j <= ArtistList.GetUpperBound();j++) { int added = 0; for (int k=0;k <= ArtistListSorted.GetUpperBound();k++) { if (ArtistList.GetAt(j) < ArtistListSorted.GetAt(k)) { ArtistListSorted.InsertAt(k, ArtistList.GetAt(j)); added = 1; break; } } if (!added) { ArtistListSorted.Add(ArtistList.GetAt(j)); } } for(int i=0;i <= ArtistListSorted.GetUpperBound();i++) { substituted = *buf; substituted.Replace("%%ARTISTSELECT%%", ArtistListSorted.GetAt(i)); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); } return 1; } ret = buf->Find("%%ADMINWINAMPCONTROL%%"); if (ret != -1) { substituted = *buf; if (adminFlag) { char hiddenfield[1024] = ""; sprintf(hiddenfield, "<table bordercolor=white border=1><tr><td colspan=5>Winamp Admin Control</td></tr><tr><td><a href=\"admin.cgi?pass=%s&action=prev\">Prev</td><td><a href=\"admin.cgi?pass=%s&action=play\">Play</td><td><a href=\"admin.cgi?pass=%s&action=pause\">Pause</td><td><a href=\"admin.cgi?pass=%s&action=stop\">Stop</td><td><a href=\"admin.cgi?pass=%s&action=next\">Next</td><tr><td colspan=5><a href=\"admin.cgi?pass=%s&action=refreshcache\">Refresh Playlist Cache</td></tr></table>", g_AdminPassword, g_AdminPassword, g_AdminPassword, g_AdminPassword, g_AdminPassword, g_AdminPassword); substituted.Replace("%%ADMINWINAMPCONTROL%%", hiddenfield); } else { substituted.Replace("%%ADMINWINAMPCONTROL%%", ""); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%ADMINHIDDENFIELD%%"); if (ret != -1) { substituted = *buf; if (adminFlag) { char hiddenfield[1024] = ""; sprintf(hiddenfield, "<input type=hidden name=pass value=\"%s\">", g_AdminPassword); substituted.Replace("%%ADMINHIDDENFIELD%%", hiddenfield); } else { substituted.Replace("%%ADMINHIDDENFIELD%%", ""); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%ADMINPASSWORD%%"); if (ret != -1) { substituted = *buf; if (adminFlag) { char hiddenfield[1024] = ""; sprintf(hiddenfield, "&pass=%s", g_AdminPassword); substituted.Replace("%%ADMINPASSWORD%%", hiddenfield); } else { substituted.Replace("%%ADMINPASSWORD%%", ""); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%ERROR%%"); if (ret != -1) { substituted = *buf; if (errorCode != 0) { substituted.Replace("%%ERROR%%", errorTable[errorCode]); } else { substituted.Replace("%%ERROR%%", ""); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%HTTP_REFERRER%%"); if (ret != -1) { substituted = *buf; if (errorCode != 0) { substituted.Replace("%%HTTP_REFERRER%%", m_Referrer); } else { substituted.Replace("URL=%%HTTP_REFERRER%%", ""); substituted.Replace("%%HTTP_REFERRER%%", ""); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } playlistpos = 0; ret = buf->Find("%%PLAYLISTENTRY%%"); if (ret != -1) { int startingPos = 0; if (strlen(m_Current) > 0) { startingPos = atoi(m_Current); } int currentPos = 0; numDisplayed = 0; maxEntries = atoi(g_MaxEntries); while(pszSongTitle) { pszSongTitle = getSongTitle(playlistpos); if(pszSongTitle) { replaceflag = 1; if (searchflag) { if (CompareNonCase(pszSongTitle, searchstring, strlen(searchstring))) { replaceflag = 1; } else { replaceflag = 0; } } if (startswithflag) { if (CompareNonCaseBeginning(pszSongTitle, startswithstring, strlen(startswithstring))) { replaceflag = 1; } else { replaceflag = 0; } } if (replaceflag) { if ((currentPos >= startingPos) && (numDisplayed < maxEntries)) { substituted = *buf; substituted.Replace("%%PLAYLISTENTRY%%", pszSongTitle); memset(tmpbuf, '\000', sizeof(tmpbuf)); if (adminFlag) { sprintf(tmpbuf, "%d&pass=%s", playlistpos, g_AdminPassword); } else { sprintf(tmpbuf, "%d", playlistpos); } substituted.Replace("%%PLAYLISTPOS%%", tmpbuf); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); numDisplayed++; } currentPos++; } } playlistpos++; } return 1; } ret = buf->Find("%%QUEUELISTENTRY%%"); pszSongTitle = (char *)1; playlistpos = RequestQueue.GetUpperBound(); int queuepos = 1; if (ret != -1) { while(pszSongTitle) { pszSongTitle = GetQueueTitle(playlistpos); if(pszSongTitle) { substituted = *buf; substituted.Replace("%%QUEUELISTENTRY%%", pszSongTitle); memset(tmpbuf, '\000', sizeof(tmpbuf)); if (adminFlag) { sprintf(tmpbuf, "<a href=\"admin.cgi?pass=%s&action=delete&listpos=%d\">Delete</a> %d", g_AdminPassword, queuepos, queuepos); } else { sprintf(tmpbuf, "%d", queuepos); } substituted.Replace("%%QUEUELISTPOS%%", tmpbuf); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); } playlistpos--; queuepos++; } return 1; } ret = buf->Find("%%NAV_NEXT%%"); if (ret != -1) { substituted = *buf; char buff[255] = ""; if (strchr(g_choppedrequest, '?')) { sprintf(buff, "<a href=\"%s¤t=%d\">Next..></a>", g_choppedrequest, atoi(m_Current) + atoi(g_MaxEntries)); } else { char params[255] = ""; if (startswithflag) { sprintf(params, "startswith=%s¤t=%d", startswithstring, atoi(m_Current) + atoi(g_MaxEntries)); } if (searchflag) { sprintf(params, "psearch=%s¤t=%d", searchstring, atoi(m_Current) + atoi(g_MaxEntries)); } if (strlen(params) == 0) { sprintf(params, "current=%d", atoi(m_Current) + atoi(g_MaxEntries)); } if (adminFlag) { sprintf(buff, "<a href=\"admin.cgi?pass=%s&%s\">Next..></a>", g_AdminPassword, params); } else { sprintf(buff, "<a href=\"playlist.cgi?%s\">Next..></a>", params); } } if (numDisplayed < maxEntries) { substituted.Replace("%%NAV_NEXT%%", ""); } else { substituted.Replace("%%NAV_NEXT%%", buff); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%NAV_PREV%%"); if (ret != -1) { substituted = *buf; char buff[255] = ""; if (strchr(g_choppedrequest, '?')) { sprintf(buff, "<a href=\"%s¤t=%d\"><..Prev</a>", g_choppedrequest, atoi(m_Current) - atoi(g_MaxEntries)); } else { char params[255] = ""; if (startswithflag) { sprintf(params, "startswith=%s¤t=%d", startswithstring, atoi(m_Current) - atoi(g_MaxEntries)); } if (searchflag) { sprintf(params, "psearch=%s¤t=%d", searchstring, atoi(m_Current) - atoi(g_MaxEntries)); } if (strlen(params) == 0) { sprintf(params, "current=%d", atoi(m_Current) - atoi(g_MaxEntries)); } if (adminFlag) { sprintf(buff, "<a href=\"admin.cgi?pass=%s&%s\"><...Prev</a>", g_AdminPassword, params); } else { sprintf(buff, "<a href=\"playlist.cgi?%s\"><...Prev</a>", params); } } if ((atoi(m_Current) - atoi(g_MaxEntries)) < 0) { substituted.Replace("%%NAV_PREV%%", ""); } else { substituted.Replace("%%NAV_PREV%%", buff); } iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%CURRENTSONG%%"); if (ret != -1) { pszSongTitle = getCurrentSong(); if(pszSongTitle) { substituted = *buf; substituted.Replace("%%CURRENTSONG%%", pszSongTitle); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); } return 1; } ret = buf->Find("%%CONTENT_REFRESH%%"); if (ret != -1) { substituted = *buf; GetSecondsLeft(); char tmp[25] = ""; sprintf(tmp, "%d", g_CurrentSongLeft + 5); substituted.Replace("%%CONTENT_REFRESH%%", tmp); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%PCT_LEFT%%"); if (ret != -1) { substituted = *buf; GetSecondsLeft(); char tmp[25] = ""; sprintf(tmp, "%d", g_CurrentPctLeft); substituted.Replace("%%PCT_LEFT%%", tmp); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } ret = buf->Find("%%SONG_LENGTH%%"); if (ret != -1) { substituted = *buf; GetSecondsLeft(); char tmp[25] = ""; sprintf(tmp, "%d", g_CurrentSongLength); substituted.Replace("%%SONG_LENGTH%%", tmp); iError = send(skAccept, substituted.GetBuffer(substituted.GetLength()), substituted.GetLength(), 0); iError = send(skAccept, "\r\n", strlen("\r\n"), 0); return 1; } return 0; }
string Art::prettyPrint() { string pretty = getName() + ", " + getArtist() + ", " + getDescription(); return pretty; }