From a337906f940340d68ca005fea4e0387f46cf7f24 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Thu, 22 Jun 2006 12:36:14 +0000 Subject: [PATCH] fixing #1697, step 2 of 2 --- .../StorageClient/StorageClientInterface.h | 8 ++++- .../storageClient/src/TestStorageClient.cxx | 8 ++--- .../storageClient/src/TestStorageClient.h | 4 +-- .../src/TestStorageClientTest.cxx | 4 ++- .../storageClient/src/WebStorageClient.cxx | 6 ++-- .../storageClient/src/WebStorageClient.h | 6 ++-- .../src/WebStorageClientTest.cxx | 8 +++-- .../gLiveSupport/src/GLiveSupport.cxx | 32 ++----------------- .../products/gLiveSupport/src/GLiveSupport.h | 30 ++--------------- .../gLiveSupport/src/GLiveSupportTest.cxx | 16 +++++----- .../gLiveSupport/src/SearchWindow.cxx | 12 +++---- .../products/gLiveSupport/src/SearchWindow.h | 4 +-- 12 files changed, 50 insertions(+), 88 deletions(-) diff --git a/livesupport/src/modules/storageClient/include/LiveSupport/StorageClient/StorageClientInterface.h b/livesupport/src/modules/storageClient/include/LiveSupport/StorageClient/StorageClientInterface.h index 812aa4f31..1e2e92f49 100644 --- a/livesupport/src/modules/storageClient/include/LiveSupport/StorageClient/StorageClientInterface.h +++ b/livesupport/src/modules/storageClient/include/LiveSupport/StorageClient/StorageClientInterface.h @@ -439,6 +439,12 @@ class StorageClientInterface throw (XmlRpcException) = 0; + /** + * The type for the list of playlists returned by the search method + */ + typedef std::vector::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::Ref> >::Ref + virtual Ptr::Ref getSearchResults(void) throw () = 0; /** diff --git a/livesupport/src/modules/storageClient/src/TestStorageClient.cxx b/livesupport/src/modules/storageClient/src/TestStorageClient.cxx index a410dea30..da0fb01b1 100644 --- a/livesupport/src/modules/storageClient/src/TestStorageClient.cxx +++ b/livesupport/src/modules/storageClient/src/TestStorageClient.cxx @@ -250,7 +250,7 @@ TestStorageClient :: reset(void) = nodes.begin(); playlistMap.clear(); editedPlaylists.clear(); - searchResults.reset(new std::vector::Ref>); + searchResults.reset(new SearchResultsType); while (it != nodes.end()) { Ptr::Ref playlist(new Playlist); @@ -801,7 +801,7 @@ TestStorageClient :: search(Ptr::Ref sessionId, last = 0; } - searchResults.reset(new std::vector::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::Ref sessionId, Ptr::Ref> >::Ref playlists( new std::vector::Ref>); - std::vector::Ref>::const_iterator it; + SearchResultsType::const_iterator it; for (it = searchResults->begin(); it != searchResults->end(); ++it) { Ptr::Ref playlist = (*it)->getPlaylist(); if (playlist) { @@ -1004,7 +1004,7 @@ TestStorageClient :: getAllAudioClips(Ptr::Ref sessionId, Ptr::Ref> >::Ref audioClips( new std::vector::Ref>); - std::vector::Ref>::const_iterator it; + SearchResultsType::const_iterator it; for (it = searchResults->begin(); it != searchResults->end(); ++it) { Ptr::Ref audioClip = (*it)->getAudioClip(); if (audioClip) { diff --git a/livesupport/src/modules/storageClient/src/TestStorageClient.h b/livesupport/src/modules/storageClient/src/TestStorageClient.h index b7c4e52b7..f132b5533 100644 --- a/livesupport/src/modules/storageClient/src/TestStorageClient.h +++ b/livesupport/src/modules/storageClient/src/TestStorageClient.h @@ -160,7 +160,7 @@ class TestStorageClient : /** * A vector containing the items returned by search() or by reset(). */ - Ptr::Ref> >::Ref searchResults; + Ptr::Ref searchResults; /** * Auxilliary method used by search(). @@ -568,7 +568,7 @@ class TestStorageClient : * * @return a vector of Playable objects. */ - virtual Ptr::Ref> >::Ref + virtual Ptr::Ref getSearchResults(void) throw () { return searchResults; diff --git a/livesupport/src/modules/storageClient/src/TestStorageClientTest.cxx b/livesupport/src/modules/storageClient/src/TestStorageClientTest.cxx index 62415c754..fc14c4649 100644 --- a/livesupport/src/modules/storageClient/src/TestStorageClientTest.cxx +++ b/livesupport/src/modules/storageClient/src/TestStorageClientTest.cxx @@ -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 { diff --git a/livesupport/src/modules/storageClient/src/WebStorageClient.cxx b/livesupport/src/modules/storageClient/src/WebStorageClient.cxx index c3283e747..e5270414e 100644 --- a/livesupport/src/modules/storageClient/src/WebStorageClient.cxx +++ b/livesupport/src/modules/storageClient/src/WebStorageClient.cxx @@ -2142,7 +2142,7 @@ WebStorageClient :: extractSearchResults(const std::string & methodName, XmlRpcValue resultArray = xmlRpcStruct[searchResultParamName]; - searchResults.reset(new std::vector::Ref>); + searchResults.reset(new SearchResultsType); Ptr::Ref playable; for (int i=0; i < resultArray.size(); i++) { @@ -2330,7 +2330,7 @@ WebStorageClient :: getAllPlaylists(Ptr::Ref sessionId, Ptr::Ref> >::Ref playlists( new std::vector::Ref>); - std::vector::Ref>::const_iterator it; + SearchResultsType::const_iterator it; for (it = searchResults->begin(); it != searchResults->end(); ++it) { Ptr::Ref playlist = (*it)->getPlaylist(); if (playlist) { @@ -2360,7 +2360,7 @@ WebStorageClient :: getAllAudioClips(Ptr::Ref sessionId, Ptr::Ref> >::Ref audioClips( new std::vector::Ref>); - std::vector::Ref>::const_iterator it; + SearchResultsType::const_iterator it; for (it = searchResults->begin(); it != searchResults->end(); ++it) { Ptr::Ref audioClip = (*it)->getAudioClip(); if (audioClip) { diff --git a/livesupport/src/modules/storageClient/src/WebStorageClient.h b/livesupport/src/modules/storageClient/src/WebStorageClient.h index 48173ace9..6df20cda7 100644 --- a/livesupport/src/modules/storageClient/src/WebStorageClient.h +++ b/livesupport/src/modules/storageClient/src/WebStorageClient.h @@ -147,7 +147,7 @@ class WebStorageClient : /** * A vector containing the items returned by search() or by reset(). */ - Ptr::Ref> >::Ref searchResults; + Ptr::Ref searchResults; /** * Execute an XML-RPC function call. @@ -682,8 +682,8 @@ class WebStorageClient : * * @return a vector of Playable objects. */ - virtual Ptr::Ref> >::Ref - getSearchResults(void) throw () + virtual Ptr::Ref + getSearchResults(void) throw () { return searchResults; } diff --git a/livesupport/src/modules/storageClient/src/WebStorageClientTest.cxx b/livesupport/src/modules/storageClient/src/WebStorageClientTest.cxx index 531573baa..09dd0cbaf 100644 --- a/livesupport/src/modules/storageClient/src/WebStorageClientTest.cxx +++ b/livesupport/src/modules/storageClient/src/WebStorageClientTest.cxx @@ -906,8 +906,12 @@ WebStorageClientTest :: restoreBackupTest(void) wsc->existsAudioClip(sessionId, oldAudioClipId) ); - Ptr::Ref path(new Glib::ustring( - "var/cowbell_backup.tar")); + Ptr::Ref path(new Glib::ustring()); + char * currentDirName = get_current_dir_name(); + path->append(currentDirName); + path->append("var/cowbell_backup.tar"); + free(currentDirName); + Ptr::Ref token; CPPUNIT_ASSERT_NO_THROW( token = wsc->restoreBackupOpen(sessionId, path); diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx index 3e0b31f7e..410a62462 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -1329,7 +1329,7 @@ GLiveSupport :: search(Ptr::Ref criteria) { storage->search(sessionId, criteria); - return readSearchResults(); + return getSearchResults(); } @@ -1338,35 +1338,9 @@ GLiveSupport :: search(Ptr::Ref criteria) *----------------------------------------------------------------------------*/ Ptr::Ref LiveSupport :: GLiveSupport :: -GLiveSupport :: readSearchResults(void) throw (XmlRpcException) +GLiveSupport :: getSearchResults(void) throw (XmlRpcException) { - Ptr::Ref - results(new PlayableList); - - Ptr::Ref> >::Ref audioClipIds = getAudioClipIds(); - std::vector::Ref>::const_iterator it; - for (it = audioClipIds->begin(); it != audioClipIds->end(); ++it) { - try { - Ptr::Ref audioClip = getAudioClip(*it); - results->push_back(audioClip); - } catch (XmlRpcInvalidDataException &e) { - std::cerr << "invalid audio clip in search(): " << e.what() - << std::endl; - } - } - - Ptr::Ref> >::Ref playlistIds = getPlaylistIds(); - for (it = playlistIds->begin(); it != playlistIds->end(); ++it) { - try { - Ptr::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(); } diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h index 27722b9dd..e98d95f4a 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h @@ -131,9 +131,9 @@ class GLiveSupport : public LocalizedConfigurable, /** * The type of the list of search results. - * This is a list holding Ptr::Ref references. */ - typedef std::list::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::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::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::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::Ref - readSearchResults(void) throw (XmlRpcException); + getSearchResults(void) throw (XmlRpcException); /** * Browse in the local storage. diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx index 197e54054..cb7d5a602 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx @@ -192,8 +192,8 @@ GLiveSupportTest :: openAudioClipTest(void) Ptr::Ref id; Ptr::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::Ref id; Ptr::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::Ref id; Ptr::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::Ref id; Ptr::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); diff --git a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx index c2cc7aec3..504556e4b 100644 --- a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx @@ -446,7 +446,7 @@ void SearchWindow :: localSearch(Ptr::Ref criteria) throw () { - Ptr::Ref> >::Ref searchResults; + Ptr::Ref searchResults; try { searchResults = gLiveSupport->search(criteria); } catch (XmlRpcException &e) { @@ -463,8 +463,8 @@ SearchWindow :: localSearch(Ptr::Ref criteria) *----------------------------------------------------------------------------*/ void SearchWindow :: displaySearchResults( - Ptr::Ref> >::Ref searchResults, - Glib::RefPtr treeModel) + Ptr::Ref searchResults, + Glib::RefPtr treeModel) throw () { treeModel->clear(); @@ -472,7 +472,7 @@ SearchWindow :: displaySearchResults( Ptr::Ref widgetFactory = WidgetFactory::getInstance(); - std::list::Ref>::const_iterator it; + GLiveSupport::PlayableList::const_iterator it; for (it = searchResults->begin(); it != searchResults->end(); ++it) { Ptr::Ref playable = *it; @@ -569,7 +569,7 @@ SearchWindow :: remoteSearchClose(void) return; } - Ptr::Ref> >::Ref results; + Ptr::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", diff --git a/livesupport/src/products/gLiveSupport/src/SearchWindow.h b/livesupport/src/products/gLiveSupport/src/SearchWindow.h index 37d1aeef3..13f94ae6b 100644 --- a/livesupport/src/products/gLiveSupport/src/SearchWindow.h +++ b/livesupport/src/products/gLiveSupport/src/SearchWindow.h @@ -256,8 +256,8 @@ class SearchWindow : public GuiWindow */ void displaySearchResults( - Ptr::Ref> >::Ref searchResults, - Glib::RefPtr treeModel) + Ptr::Ref searchResults, + Glib::RefPtr treeModel) throw (); /**