fixing #1895, plus cleaning up some search/browse code

This commit is contained in:
fgerlits 2006-10-31 14:12:56 +00:00
parent b0f60b4a4a
commit 07d057b69b
12 changed files with 136 additions and 143 deletions

View File

@ -351,7 +351,7 @@ class StorageClientInterface
/**
* Search for audio clips or playlists. The results can be read
* using getSearchResults().
* using getLocalSearchResults().
*
* @param sessionId the session ID from the authentication client
* @param searchCriteria an object containing the search criteria
@ -410,7 +410,7 @@ class StorageClientInterface
*
* If this search is in the finishedState, it will be moved to the
* closedState, the transport token will be invalidated, and the
* search results can be read using getSearchResults().
* search results can be read using getRemoteSearchResults().
*
* If the search is in any other state, an exception is raised.
*
@ -435,18 +435,27 @@ class StorageClientInterface
SearchResultsType;
/**
* Return the list of items found by the latest search.
* Return the list of items found by the latest local search.
*
* (Or the list of items returned by reset() -- used for testing.)
*
* @return a vector of Playable objects.
*/
virtual Ptr<SearchResultsType>::Ref
getSearchResults(void) throw () = 0;
getLocalSearchResults(void) throw () = 0;
/**
* Return the list of items found by the latest remote search.
*
* @return a vector of Playable objects.
*/
virtual Ptr<SearchResultsType>::Ref
getRemoteSearchResults(void) throw () = 0;
/**
* Reset the storage to its initial state.
* The contents of the storage can be read using getSearchResults().
* The contents of the storage can be read using
* getLocalSearchResults().
* Used for testing.
*
* @exception XmlRpcException if the server returns an error.

View File

@ -250,7 +250,7 @@ TestStorageClient :: reset(void)
= nodes.begin();
playlistMap.clear();
editedPlaylists.clear();
searchResults.reset(new SearchResultsType);
localSearchResults.reset(new SearchResultsType);
while (it != nodes.end()) {
Ptr<Playlist>::Ref playlist(new Playlist);
@ -258,7 +258,7 @@ TestStorageClient :: reset(void)
dynamic_cast<const xmlpp::Element*> (*it);
playlist->configure(*element);
playlistMap[playlist->getId()->getId()] = playlist;
searchResults->push_back(playlist);
localSearchResults->push_back(playlist);
++it;
}
@ -279,7 +279,7 @@ TestStorageClient :: reset(void)
audioClip->setUri(nullPointer);
}
audioClipMap[audioClip->getId()->getId()] = audioClip;
searchResults->push_back(audioClip);
localSearchResults->push_back(audioClip);
++it;
}
}
@ -801,14 +801,14 @@ TestStorageClient :: search(Ptr<SessionId>::Ref sessionId,
last = 0;
}
searchResults.reset(new SearchResultsType);
localSearchResults.reset(new SearchResultsType);
if (searchCriteria->type == "audioclip" || searchCriteria->type == "all") {
AudioClipMapType::const_iterator it = audioClipMap.begin();
while (it != audioClipMap.end()) {
if (matchesCriteria(it->second, searchCriteria)) {
if (counter >= first && (!last || counter < last)) {
searchResults->push_back(it->second);
localSearchResults->push_back(it->second);
}
++counter;
}
@ -821,7 +821,7 @@ TestStorageClient :: search(Ptr<SessionId>::Ref sessionId,
while (it != playlistMap.end()) {
if (matchesCriteria(it->second, searchCriteria)) {
if (counter >= first && (!last || counter < last)) {
searchResults->push_back(it->second);
localSearchResults->push_back(it->second);
}
++counter;
}
@ -975,7 +975,8 @@ TestStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId,
new std::vector<Ptr<Playlist>::Ref>);
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
for (it = localSearchResults->begin();
it != localSearchResults->end(); ++it) {
Ptr<Playlist>::Ref playlist = (*it)->getPlaylist();
if (playlist) {
playlists->push_back(playlist);
@ -1005,7 +1006,8 @@ TestStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId,
new std::vector<Ptr<AudioClip>::Ref>);
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
for (it = localSearchResults->begin();
it != localSearchResults->end(); ++it) {
Ptr<AudioClip>::Ref audioClip = (*it)->getAudioClip();
if (audioClip) {
audioClips->push_back(audioClip);

View File

@ -160,7 +160,7 @@ class TestStorageClient :
/**
* A vector containing the items returned by search() or by reset().
*/
Ptr<SearchResultsType>::Ref searchResults;
Ptr<SearchResultsType>::Ref localSearchResults;
/**
* Auxilliary method used by search().
@ -467,7 +467,7 @@ class TestStorageClient :
* Reset the storage to its initial state.
* Re-initializes the storage based on the xml element which was
* passed to configure() earlier; the new contents of the storage
* can be read using getSearchResults().
* can be read using getLocalSearchResults().
* Used for testing.
*
* @exception XmlRpcException if the server returns an error.
@ -479,7 +479,7 @@ class TestStorageClient :
/**
* Search for audio clips or playlists. The results can be read
* using getSearchResults().
* using getLocalSearchResults().
*
* If an audio clip or playlist does not have a metadata field X,
* it does not match any condition about field X. In particular,
@ -544,7 +544,7 @@ class TestStorageClient :
*
* If this search is in the finishedState, it will be moved to the
* closedState, the transport token will be invalidated, and the
* search results can be read using getSearchResults().
* search results can be read using getRemoteSearchResults().
*
* If the search is in any other state, an exception is raised.
*
@ -562,16 +562,29 @@ class TestStorageClient :
throw (XmlRpcException);
/**
* Return the list of items found by the search method.
* Return the list of items found by the local search method.
*
* (Or the list of items returned by reset() -- used for testing.)
*
* @return a vector of Playable objects.
*/
virtual Ptr<SearchResultsType>::Ref
getSearchResults(void) throw ()
getLocalSearchResults(void) throw ()
{
return searchResults;
return localSearchResults;
}
/**
* Return the list of items found by the remote search method.
* NOT IMPLEMENTED, always returns 0.
*
* @return a vector of Playable objects.
*/
virtual Ptr<SearchResultsType>::Ref
getRemoteSearchResults(void) throw ()
{
Ptr<SearchResultsType>::Ref nullPointer;
return nullPointer;
}

View File

@ -171,7 +171,7 @@ TestStorageClientTest :: resetTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= tsc->getSearchResults();
= tsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults);
CPPUNIT_ASSERT(searchResults->size() >= 4);
@ -244,7 +244,7 @@ TestStorageClientTest :: audioClipTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= tsc->getSearchResults();
= tsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults);
CPPUNIT_ASSERT(searchResults->size() >= 3);
@ -388,8 +388,8 @@ TestStorageClientTest :: searchTest(void)
int numberFound = tsc->search(dummySessionId, criteria);
CPPUNIT_ASSERT(numberFound == 2);
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= tsc->getSearchResults();
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
searchResults = tsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() == 2);
CPPUNIT_ASSERT(searchResults->at(0)->getId()->getId() == 0x10001);
CPPUNIT_ASSERT(searchResults->at(1)->getId()->getId() == 0x10003);
@ -406,8 +406,8 @@ TestStorageClientTest :: searchTest(void)
criteria->addCondition("dc:title", "prefix", "Playlist");
int numberFound = tsc->search(dummySessionId, criteria);
CPPUNIT_ASSERT(numberFound == 3);
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= tsc->getSearchResults();
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
searchResults = tsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() == 3);
CPPUNIT_ASSERT(searchResults->at(0)->getId()->getId() == 0x10002);
CPPUNIT_ASSERT(searchResults->at(1)->getId()->getId() == 1);
@ -427,8 +427,8 @@ TestStorageClientTest :: searchTest(void)
criteria->setOffset(1);
int numberFound = tsc->search(dummySessionId, criteria);
CPPUNIT_ASSERT(numberFound == 4);
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= tsc->getSearchResults();
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
searchResults = tsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() == 2);
CPPUNIT_ASSERT(searchResults->at(0)->getId()->getId() == 0x10003);
CPPUNIT_ASSERT(searchResults->at(1)->getId()->getId() == 1);

View File

@ -2097,7 +2097,7 @@ WebStorageClient :: reset(void)
execute(resetStorageMethodName, parameters, result);
extractSearchResults(resetStorageMethodName, result);
extractSearchResults(resetStorageMethodName, result, localSearchResults);
editedPlaylists.clear();
}
@ -2122,7 +2122,7 @@ WebStorageClient :: search(Ptr<SessionId>::Ref sessionId,
execute(searchMethodName, parameters, result);
return extractSearchResults(searchMethodName, result);
return extractSearchResults(searchMethodName, result, localSearchResults);
}
@ -2130,8 +2130,10 @@ WebStorageClient :: search(Ptr<SessionId>::Ref sessionId,
* Extract the results returned by search() or remoteSearchClose().
*----------------------------------------------------------------------------*/
int
WebStorageClient :: extractSearchResults(const std::string & methodName,
XmlRpcValue & xmlRpcStruct)
WebStorageClient :: extractSearchResults(
const std::string & methodName,
XmlRpcValue & xmlRpcStruct,
Ptr<SearchResultsType>::Ref & searchResults)
throw (XmlRpcException)
{
checkStruct(methodName,
@ -2307,7 +2309,9 @@ WebStorageClient :: remoteSearchClose(Ptr<const Glib::ustring>::Ref token)
execute(remoteSearchCloseMethodName, parameters, result);
return extractSearchResults(remoteSearchCloseMethodName, result);
return extractSearchResults(remoteSearchCloseMethodName,
result,
remoteSearchResults);
}
@ -2330,7 +2334,8 @@ WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId,
new std::vector<Ptr<Playlist>::Ref>);
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
for (it = localSearchResults->begin();
it != localSearchResults->end(); ++it) {
Ptr<Playlist>::Ref playlist = (*it)->getPlaylist();
if (playlist) {
playlists->push_back(playlist);
@ -2360,7 +2365,8 @@ WebStorageClient :: getAllAudioClips(Ptr<SessionId>::Ref sessionId,
new std::vector<Ptr<AudioClip>::Ref>);
SearchResultsType::const_iterator it;
for (it = searchResults->begin(); it != searchResults->end(); ++it) {
for (it = localSearchResults->begin();
it != localSearchResults->end(); ++it) {
Ptr<AudioClip>::Ref audioClip = (*it)->getAudioClip();
if (audioClip) {
audioClips->push_back(audioClip);
@ -2890,17 +2896,9 @@ WebStorageClient :: createPlayable(XmlRpcValue data)
Ptr<const Glib::ustring>::Ref title(new const Glib::ustring(std::string(
data["title"] )));
checkStruct("private:createPlayable",
data,
"creator",
XmlRpcValue::TypeString);
Ptr<const Glib::ustring>::Ref creator(new const Glib::ustring(std::string(
data["creator"] )));
checkStruct("private:createPlayable",
data,
"source",
XmlRpcValue::TypeString);
Ptr<const Glib::ustring>::Ref source(new const Glib::ustring(std::string(
data["source"] )));

View File

@ -147,7 +147,12 @@ class WebStorageClient :
/**
* A vector containing the items returned by search() or by reset().
*/
Ptr<SearchResultsType>::Ref searchResults;
Ptr<SearchResultsType>::Ref localSearchResults;
/**
* A vector containing the items returned by remoteSearchClose().
*/
Ptr<SearchResultsType>::Ref remoteSearchResults;
/**
* Execute an XML-RPC function call.
@ -193,11 +198,13 @@ class WebStorageClient :
*
* @param methodName the name of the calling method.
* @param xmlRpcStruct the XML-RPC struct to be extracted.
* @param searchResults the array to store the results in.
* @exception XmlRpcException if the format of xmlRpcStruct is wrong.
*/
int
extractSearchResults(const std::string & methodName,
XmlRpcValue & xmlRpcStruct)
extractSearchResults(const std::string & methodName,
XmlRpcValue & xmlRpcStruct,
Ptr<SearchResultsType>::Ref & searchResults)
throw (XmlRpcException);
/**
@ -590,7 +597,7 @@ class WebStorageClient :
/**
* Reset the storage to its initial state.
* Calls locstor.resetStorage; the new contents of the storage
* can be read using getSearchResults().
* can be read using getLocalSearchResults().
* Used for testing.
*
* @exception XmlRpcException if the server returns an error.
@ -602,7 +609,7 @@ class WebStorageClient :
/**
* Search for audio clips or playlists. The results can be read
* using getSearchResults().
* using getLocalSearchResults().
*
* @param sessionId the session ID from the authentication client
* @param searchCriteria an object containing the search criteria
@ -658,7 +665,7 @@ class WebStorageClient :
*
* If this search is in the finishedState, it will be moved to the
* closedState, the transport token will be invalidated, and the
* search results can be read using getSearchResults().
* search results can be read using getRemoteSearchResults().
*
* If the search is in any other state, an exception is raised.
*
@ -676,16 +683,27 @@ class WebStorageClient :
throw (XmlRpcException);
/**
* Return the list of items found by the search method.
* Return the list of items found by the local search method.
*
* (Or the list of items returned by reset() -- used for testing.)
*
* @return a vector of Playable objects.
*/
virtual Ptr<SearchResultsType>::Ref
getSearchResults(void) throw ()
getLocalSearchResults(void) throw ()
{
return searchResults;
return localSearchResults;
}
/**
* Return the list of items found by the remote search method.
*
* @return a vector of Playable objects.
*/
virtual Ptr<SearchResultsType>::Ref
getRemoteSearchResults(void) throw ()
{
return remoteSearchResults;
}

View File

@ -280,10 +280,10 @@ WebStorageClientTest :: playlistTest(void)
}
CPPUNIT_ASSERT(playlist);
// searchResults was filled by reset() with a list of all items
// localSearchResults was filled by reset() with a list of all items
// in the storage
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref
searchResults = wsc->getSearchResults();
searchResults = wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 7);
Ptr<AudioClip>::Ref audioClip = searchResults->at(4)->getAudioClip();
CPPUNIT_ASSERT(audioClip);
@ -377,7 +377,7 @@ WebStorageClientTest :: embeddedPlaylistTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= wsc->getSearchResults();
= wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 7);
Ptr<AudioClip>::Ref audioClip = searchResults->at(6)->getAudioClip();
CPPUNIT_ASSERT(audioClip);
@ -432,7 +432,7 @@ WebStorageClientTest :: audioClipTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= wsc->getSearchResults();
= wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 7);
Ptr<AudioClip>::Ref audioClip = searchResults->at(6)->getAudioClip();
CPPUNIT_ASSERT(audioClip);
@ -541,7 +541,7 @@ WebStorageClientTest :: simplePlaylistTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= wsc->getSearchResults();
= wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 7);
Ptr<AudioClip>::Ref audioClip = searchResults->at(6)->getAudioClip();
CPPUNIT_ASSERT(audioClip);
@ -624,7 +624,7 @@ WebStorageClientTest :: searchTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= wsc->getSearchResults();
= wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 9);
Ptr<Playlist>::Ref playlist0 = searchResults->at(0)->getPlaylist();
Ptr<Playlist>::Ref playlist1 = searchResults->at(1)->getPlaylist();
@ -660,7 +660,7 @@ WebStorageClientTest :: searchTest(void)
"dc:title", "prefix", "File "));
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 1);
searchResults = wsc->getSearchResults();
searchResults = wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() == 1);
CPPUNIT_ASSERT(*searchResults->at(0)->getId() == *audioClip1->getId());
@ -677,7 +677,7 @@ WebStorageClientTest :: searchTest(void)
criteria->setLimit(10);
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound >= 2);
searchResults = wsc->getSearchResults();
searchResults = wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 2);
CPPUNIT_ASSERT(*searchResults->at(0)->getId() == *playlist0->getId());
CPPUNIT_ASSERT(*searchResults->at(1)->getId() == *playlist1->getId());
@ -696,7 +696,7 @@ WebStorageClientTest :: searchTest(void)
criteria->addCondition("dc:title", "partial", "Title ");
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound == 1);
searchResults = wsc->getSearchResults();
searchResults = wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() == 1);
CPPUNIT_ASSERT(*searchResults->at(0)->getId() == *audioClip0->getId());
@ -712,7 +712,7 @@ WebStorageClientTest :: searchTest(void)
criteria->addCondition("dc:title", "prefix", "My");
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound >= 5);
searchResults = wsc->getSearchResults();
searchResults = wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 5);
CPPUNIT_ASSERT(*searchResults->at(0)->getId() == *playlist0->getId());
CPPUNIT_ASSERT(*searchResults->at(3)->getId() == *audioClip0->getId());
@ -731,7 +731,7 @@ WebStorageClientTest :: searchTest(void)
criteria->setOffset(3);
int numberFound = wsc->search(sessionId, criteria);
CPPUNIT_ASSERT(numberFound >= 5);
searchResults = wsc->getSearchResults();
searchResults = wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() == 2);
CPPUNIT_ASSERT(*searchResults->at(0)->getId() == *audioClip4->getId());
CPPUNIT_ASSERT(*searchResults->at(1)->getId() == *audioClip5->getId());
@ -763,7 +763,7 @@ WebStorageClientTest :: searchUnicodeTest(void)
CPPUNIT_FAIL(e.what());
}
Ptr<std::vector<Ptr<Playable>::Ref> >::Ref searchResults
= wsc->getSearchResults();
= wsc->getLocalSearchResults();
CPPUNIT_ASSERT(searchResults->size() >= 9);
Ptr<AudioClip>::Ref audioClip1 = searchResults->at(4)->getAudioClip();
@ -1105,6 +1105,11 @@ WebStorageClientTest :: remoteSearchTest(void)
wsc->cancelTransport(sessionId, token)
);
CPPUNIT_ASSERT_NO_THROW(
token = wsc->remoteSearchOpen(sessionId, criteria);
);
CPPUNIT_ASSERT(token);
Ptr<Glib::ustring>::Ref errorMessage(new Glib::ustring);
AsyncState state;

View File

@ -147,9 +147,13 @@ BrowseItem :: onShow(void) throw ()
{
Ptr<const Glib::ustring>::Ref metadataKey = metadataEntry->getActiveKey();
Ptr<StorageClientInterface>::Ref
storage = gLiveSupport->getStorageClient();
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
Ptr<std::vector<Glib::ustring> >::Ref values;
try {
values = gLiveSupport->browse(metadataKey, parentCriteria);
values = storage->browse(sessionId, metadataKey, parentCriteria);
} catch (XmlRpcException &e) {
std::cerr << "Error in BrowseItem::onShow(): "
<< e.what() << std::endl;

View File

@ -1388,42 +1388,6 @@ GLiveSupport :: detachCueAudioListener(AudioPlayerEventListener * listener)
}
/*------------------------------------------------------------------------------
* Search in the local storage.
*----------------------------------------------------------------------------*/
int
LiveSupport :: GLiveSupport ::
GLiveSupport :: search(Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException)
{
return storage->search(sessionId, criteria);
}
/*------------------------------------------------------------------------------
* Return the Playable items found by the latest search (local or remote).
*----------------------------------------------------------------------------*/
Ptr<LiveSupport::GLiveSupport::GLiveSupport::PlayableList>::Ref
LiveSupport :: GLiveSupport ::
GLiveSupport :: getSearchResults(void) throw (XmlRpcException)
{
return storage->getSearchResults();
}
/*------------------------------------------------------------------------------
* Browse in the local storage.
*----------------------------------------------------------------------------*/
Ptr<std::vector<Glib::ustring> >::Ref
LiveSupport :: GLiveSupport ::
GLiveSupport :: browse(Ptr<const Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException)
{
return storage->browse(sessionId, metadata, criteria);
}
/*------------------------------------------------------------------------------
* Return an image containing the radio station logo.
*----------------------------------------------------------------------------*/

View File

@ -130,12 +130,6 @@ class GLiveSupport : public LocalizedConfigurable,
typedef std::map<const Glib::ustring,
const std::string> LanguageMap;
/**
* The type of the list of search results.
*/
typedef StorageClientInterface::SearchResultsType
PlayableList;
/**
* A type for having a map of AudioClip objects, with using
* the ids of the objects as keys.
@ -975,30 +969,6 @@ class GLiveSupport : public LocalizedConfigurable,
search(Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException);
/**
* Return the Playable items found by the latest search.
*
* @return the list of audio clips and playlists found.
* @exception XmlRpcException passed on from getAudioClip() or
* getPlaylist().
*/
Ptr<PlayableList>::Ref
getSearchResults(void) throw (XmlRpcException);
/**
* Browse in the local storage.
*
* @param metadata the type of metadata to list (e.g., "dc:title").
* @param criteria the search conditions to use.
* @return the list of metadata values found.
* @exception XmlRpcException thrown by
* StorageClientInterface::browse()
*/
Ptr<std::vector<Glib::ustring> >::Ref
browse(Ptr<const Glib::ustring>::Ref metadata,
Ptr<SearchCriteria>::Ref criteria)
throw (XmlRpcException);
/**
* Event handler for the "output audio player has stopped" event.
*/

View File

@ -508,10 +508,14 @@ SearchWindow :: localSearch(Ptr<SearchCriteria>::Ref criteria)
displayMessage("pleaseWaitMsg", localSearchResults);
gLiveSupport->runMainLoop();
Ptr<GLiveSupport::PlayableList>::Ref searchResults;
Ptr<StorageClientInterface>::Ref
storage = gLiveSupport->getStorageClient();
Ptr<SessionId>::Ref sessionId = gLiveSupport->getSessionId();
Ptr<SearchResultsType>::Ref searchResults;
try {
localSearchResultsCount = gLiveSupport->search(criteria);
searchResults = gLiveSupport->getSearchResults();
localSearchResultsCount = storage->search(sessionId, criteria);
searchResults = storage->getLocalSearchResults();
} catch (XmlRpcException &e) {
displayLocalSearchError(e);
return;
@ -528,8 +532,8 @@ SearchWindow :: localSearch(Ptr<SearchCriteria>::Ref criteria)
*----------------------------------------------------------------------------*/
void
SearchWindow :: displaySearchResults(
Ptr<GLiveSupport::PlayableList>::Ref searchResults,
Glib::RefPtr<Gtk::ListStore> treeModel)
Ptr<SearchResultsType>::Ref searchResults,
Glib::RefPtr<Gtk::ListStore> treeModel)
throw ()
{
treeModel->clear();
@ -538,7 +542,7 @@ SearchWindow :: displaySearchResults(
Ptr<WidgetFactory>::Ref widgetFactory = WidgetFactory::getInstance();
GLiveSupport::PlayableList::const_iterator it = searchResults->begin();
SearchResultsType::const_iterator it = searchResults->begin();
if (it == searchResults->end()) {
displayMessage("nothingFoundMsg", treeModel);
@ -642,11 +646,12 @@ SearchWindow :: remoteSearchClose(void)
return;
}
Ptr<GLiveSupport::PlayableList>::Ref results;
Ptr<SearchResultsType>::Ref results;
if (state == AsyncState::finishedState) {
try {
storage->remoteSearchClose(remoteSearchToken);
remoteSearchResultsCount =
storage->remoteSearchClose(remoteSearchToken);
} catch (XmlRpcException &e) {
displayRemoteSearchError(e);
return;
@ -654,13 +659,12 @@ SearchWindow :: remoteSearchClose(void)
remoteSearchToken.reset();
try {
results = gLiveSupport->getSearchResults();
results = storage->getRemoteSearchResults();
} catch (XmlRpcException &e) {
displayRemoteSearchError(e);
return;
}
remoteSearchResultsCount = results->size(); // FIXME
displaySearchResults(results, remoteSearchResults);
} else if (state == AsyncState::closedState) {

View File

@ -329,6 +329,12 @@ class SearchWindow : public GuiWindow
void
remoteSearchClose(void) throw ();
/**
* Typedef to save some typing.
*/
typedef StorageClientInterface::SearchResultsType
SearchResultsType;
/**
* Display the search results.
* The most important metadata are shown in the rows of the given
@ -336,8 +342,8 @@ class SearchWindow : public GuiWindow
*/
void
displaySearchResults(
Ptr<GLiveSupport::PlayableList>::Ref searchResults,
Glib::RefPtr<Gtk::ListStore> treeModel)
Ptr<SearchResultsType>::Ref searchResults,
Glib::RefPtr<Gtk::ListStore> treeModel)
throw ();
/**