fixing #1697, step 2 of 2

This commit is contained in:
fgerlits 2006-06-22 12:36:14 +00:00
parent 939172830f
commit a337906f94
12 changed files with 50 additions and 88 deletions

View file

@ -439,6 +439,12 @@ class StorageClientInterface
throw (XmlRpcException)
= 0;
/**
* The type for the list of playlists returned by the search method
*/
typedef std::vector<Ptr<Playable>::Ref>
SearchResultsType;
/**
* Return the list of items found by the latest search.
*
@ -446,7 +452,7 @@ class StorageClientInterface
*
* @return a vector of Playable objects.
*/
virtual Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
virtual Ptr<SearchResultsType>::Ref
getSearchResults(void) throw () = 0;
/**

View file

@ -250,7 +250,7 @@ TestStorageClient :: reset(void)
= nodes.begin();
playlistMap.clear();
editedPlaylists.clear();
searchResults.reset(new std::vector<Ptr<Playable>::Ref>);
searchResults.reset(new SearchResultsType);
while (it != nodes.end()) {
Ptr<Playlist>::Ref playlist(new Playlist);
@ -801,7 +801,7 @@ TestStorageClient :: search(Ptr<SessionId>::Ref sessionId,
last = 0;
}
searchResults.reset(new std::vector<Ptr<Playable>::Ref>);
searchResults.reset(new SearchResultsType);
if (searchCriteria->type == "audioclip" || searchCriteria->type == "all") {
AudioClipMapType::const_iterator it = audioClipMap.begin();
@ -974,7 +974,7 @@ TestStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId,
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlists(
new std::vector<Ptr<Playlist>::Ref>);
std::vector<Ptr<Playable>::Ref>::const_iterator it;
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
Ptr<Playlist>::Ref playlist = (*it)->getPlaylist();
if (playlist) {
@ -1004,7 +1004,7 @@ TestStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId,
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClips(
new std::vector<Ptr<AudioClip>::Ref>);
std::vector<Ptr<Playable>::Ref>::const_iterator it;
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
Ptr<AudioClip>::Ref audioClip = (*it)->getAudioClip();
if (audioClip) {

View file

@ -160,7 +160,7 @@ class TestStorageClient :
/**
* A vector containing the items returned by search() or by reset().
*/
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults;
Ptr<SearchResultsType>::Ref searchResults;
/**
* Auxilliary method used by search().
@ -568,7 +568,7 @@ class TestStorageClient :
*
* @return a vector of Playable objects.
*/
virtual Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
virtual Ptr<SearchResultsType>::Ref
getSearchResults(void) throw ()
{
return searchResults;

View file

@ -298,8 +298,10 @@ TestStorageClientTest :: acquireAudioClipTest(void)
CPPUNIT_FAIL(eMsg);
}
string audioClipUri("file://");
audioClipUri += get_current_dir_name();
char * currentDirName = get_current_dir_name();
audioClipUri += currentDirName;
audioClipUri += "/var/test10002.mp3";
free(currentDirName);
CPPUNIT_ASSERT(*(audioClip->getUri()) == audioClipUri);
try {

View file

@ -2142,7 +2142,7 @@ WebStorageClient :: extractSearchResults(const std::string & methodName,
XmlRpcValue resultArray = xmlRpcStruct[searchResultParamName];
searchResults.reset(new std::vector<Ptr<Playable>::Ref>);
searchResults.reset(new SearchResultsType);
Ptr<Playable>::Ref playable;
for (int i=0; i < resultArray.size(); i++) {
@ -2330,7 +2330,7 @@ WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId,
Ptr<std::vector<Ptr<Playlist>::Ref> >::Ref playlists(
new std::vector<Ptr<Playlist>::Ref>);
std::vector<Ptr<Playable>::Ref>::const_iterator it;
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
Ptr<Playlist>::Ref playlist = (*it)->getPlaylist();
if (playlist) {
@ -2360,7 +2360,7 @@ WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId,
Ptr<std::vector<Ptr<AudioClip>::Ref> >::Ref audioClips(
new std::vector<Ptr<AudioClip>::Ref>);
std::vector<Ptr<Playable>::Ref>::const_iterator it;
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
Ptr<AudioClip>::Ref audioClip = (*it)->getAudioClip();
if (audioClip) {

View file

@ -147,7 +147,7 @@ class WebStorageClient :
/**
* A vector containing the items returned by search() or by reset().
*/
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults;
Ptr<SearchResultsType>::Ref searchResults;
/**
* Execute an XML-RPC function call.
@ -682,7 +682,7 @@ class WebStorageClient :
*
* @return a vector of Playable objects.
*/
virtual Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
virtual Ptr<SearchResultsType>::Ref
getSearchResults(void) throw ()
{
return searchResults;

View file

@ -906,8 +906,12 @@ WebStorageClientTest :: restoreBackupTest(void)
wsc->existsAudioClip(sessionId, oldAudioClipId)
);
Ptr<Glib::ustring>::Ref path(new Glib::ustring(
"var/cowbell_backup.tar"));
Ptr<Glib::ustring>::Ref path(new Glib::ustring());
char * currentDirName = get_current_dir_name();
path->append(currentDirName);
path->append("var/cowbell_backup.tar");
free(currentDirName);
Ptr<Glib::ustring>::Ref token;
CPPUNIT_ASSERT_NO_THROW(
token = wsc->restoreBackupOpen(sessionId, path);

View file

@ -1329,7 +1329,7 @@ GLiveSupport :: search(Ptr<SearchCriteria>::Ref criteria)
{
storage->search(sessionId, criteria);
return readSearchResults();
return getSearchResults();
}
@ -1338,35 +1338,9 @@ GLiveSupport :: search(Ptr<SearchCriteria>::Ref criteria)
*----------------------------------------------------------------------------*/
Ptr<LiveSupport::GLiveSupport::GLiveSupport::PlayableList>::Ref
LiveSupport :: GLiveSupport ::
GLiveSupport :: readSearchResults(void) throw (XmlRpcException)
GLiveSupport :: getSearchResults(void) throw (XmlRpcException)
{
Ptr<LiveSupport::GLiveSupport::GLiveSupport::PlayableList>::Ref
results(new PlayableList);
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref audioClipIds = getAudioClipIds();
std::vector<Ptr<UniqueId>::Ref>::const_iterator it;
for (it = audioClipIds->begin(); it != audioClipIds->end(); ++it) {
try {
Ptr<AudioClip>::Ref audioClip = getAudioClip(*it);
results->push_back(audioClip);
} catch (XmlRpcInvalidDataException &e) {
std::cerr << "invalid audio clip in search(): " << e.what()
<< std::endl;
}
}
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref playlistIds = getPlaylistIds();
for (it = playlistIds->begin(); it != playlistIds->end(); ++it) {
try {
Ptr<Playlist>::Ref playlist = getPlaylist(*it);
results->push_back(playlist);
} catch (XmlRpcInvalidDataException &e) {
std::cerr << "invalid playlist in search(): " << e.what()
<< std::endl;
}
}
return results;
return storage->getSearchResults();
}

View file

@ -131,9 +131,9 @@ class GLiveSupport : public LocalizedConfigurable,
/**
* The type of the list of search results.
* This is a list holding Ptr<Playable>::Ref references.
*/
typedef std::list<Ptr<Playable>::Ref> PlayableList;
typedef StorageClientInterface::SearchResultsType
PlayableList;
/**
* A type for having a map of AudioClip objects, with using
@ -582,18 +582,6 @@ class GLiveSupport : public LocalizedConfigurable,
storage->reset();
}
/**
* Return the full range of audio clip ids in the storage.
* Mostly used for testing.
*
* @return a vector of UniqueId object references.
*/
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
getAudioClipIds(void) throw ()
{
return storage->getAudioClipIds();
}
/**
* Tell if an audio clip specified by an id exists.
*
@ -639,18 +627,6 @@ class GLiveSupport : public LocalizedConfigurable,
acquireAudioClip(Ptr<const UniqueId>::Ref id)
throw (XmlRpcException);
/**
* Return the full range of playlist ids in the storage.
* Mostly used for testing.
*
* @return a vector of UniqueId object references.
*/
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref
getPlaylistIds(void) throw ()
{
return storage->getPlaylistIds();
}
/**
* Tell if a playlist specified by an id exists.
*
@ -973,7 +949,7 @@ class GLiveSupport : public LocalizedConfigurable,
* getPlaylist().
*/
Ptr<PlayableList>::Ref
readSearchResults(void) throw (XmlRpcException);
getSearchResults(void) throw (XmlRpcException);
/**
* Browse in the local storage.

View file

@ -192,8 +192,8 @@ GLiveSupportTest :: openAudioClipTest(void)
Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref clip;
CPPUNIT_ASSERT(gLiveSupport->getAudioClipIds()->size() >= 4);
id = gLiveSupport->getAudioClipIds()->at(3);
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 7);
id = gLiveSupport->getSearchResults()->at(6)->getId();
try {
clip = gLiveSupport->getAudioClip(id);
@ -226,8 +226,8 @@ GLiveSupportTest :: acquireAudioClipTest(void)
Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref clip;
CPPUNIT_ASSERT(gLiveSupport->getAudioClipIds()->size() >= 4);
id = gLiveSupport->getAudioClipIds()->at(3);
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 7);
id = gLiveSupport->getSearchResults()->at(6)->getId();
try {
clip = gLiveSupport->acquireAudioClip(id);
@ -263,8 +263,8 @@ GLiveSupportTest :: openPlaylistTest(void)
Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref playlist;
CPPUNIT_ASSERT(gLiveSupport->getPlaylistIds()->size() >= 2);
id = gLiveSupport->getPlaylistIds()->at(1);
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 2);
id = gLiveSupport->getSearchResults()->at(1)->getId();
try {
playlist = gLiveSupport->getPlaylist(id);
@ -297,8 +297,8 @@ GLiveSupportTest :: acquirePlaylistTest(void)
Ptr<UniqueId>::Ref id;
Ptr<Playable>::Ref playlist;
CPPUNIT_ASSERT(gLiveSupport->getPlaylistIds()->size() >= 2);
id = gLiveSupport->getPlaylistIds()->at(1);
CPPUNIT_ASSERT(gLiveSupport->getSearchResults()->size() >= 2);
id = gLiveSupport->getSearchResults()->at(1)->getId();
try {
playlist = gLiveSupport->acquirePlaylist(id);

View file

@ -446,7 +446,7 @@ void
SearchWindow :: localSearch(Ptr<SearchCriteria>::Ref criteria)
throw ()
{
Ptr<std::list<Ptr<Playable>::Ref> >::Ref searchResults;
Ptr<GLiveSupport::PlayableList>::Ref searchResults;
try {
searchResults = gLiveSupport->search(criteria);
} catch (XmlRpcException &e) {
@ -463,7 +463,7 @@ SearchWindow :: localSearch(Ptr<SearchCriteria>::Ref criteria)
*----------------------------------------------------------------------------*/
void
SearchWindow :: displaySearchResults(
Ptr<std::list<Ptr<Playable>::Ref> >::Ref searchResults,
Ptr<GLiveSupport::PlayableList>::Ref searchResults,
Glib::RefPtr<Gtk::ListStore> treeModel)
throw ()
{
@ -472,7 +472,7 @@ SearchWindow :: displaySearchResults(
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
std::list<Ptr<Playable>::Ref>::const_iterator it;
GLiveSupport::PlayableList::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
Ptr<Playable>::Ref playable = *it;
@ -569,7 +569,7 @@ SearchWindow :: remoteSearchClose(void)
return;
}
Ptr<std::list<Ptr<Playable>::Ref> >::Ref results;
Ptr<GLiveSupport::PlayableList>::Ref results;
switch (state) {
case StorageClientInterface::initState :
@ -590,7 +590,7 @@ SearchWindow :: remoteSearchClose(void)
remoteSearchToken.reset();
try {
results = gLiveSupport->readSearchResults();
results = gLiveSupport->getSearchResults();
} catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage(
"remoteSearchErrorMsg",

View file

@ -256,7 +256,7 @@ class SearchWindow : public GuiWindow
*/
void
displaySearchResults(
Ptr<std::list<Ptr<Playable>::Ref> >::Ref searchResults,
Ptr<GLiveSupport::PlayableList>::Ref searchResults,
Glib::RefPtr<Gtk::ListStore> treeModel)
throw ();