Save the entire path to files on a WMDM device

This commit is contained in:
David Sansome 2010-08-28 14:48:41 +00:00
parent 299fb16c99
commit 6990b88b0f
2 changed files with 11 additions and 7 deletions

View File

@ -55,7 +55,8 @@ void WmdmLoader::LoadDatabase() {
QString canonical_name = lister->DeviceCanonicalName(connected_device->unique_id()); QString canonical_name = lister->DeviceCanonicalName(connected_device->unique_id());
IWMDMStorage* storage = thread->GetRootStorage(canonical_name); IWMDMStorage* storage = thread->GetRootStorage(canonical_name);
RecursiveExploreStorage(storage); QStringList path_components;
RecursiveExploreStorage(storage, &path_components);
storage->Release(); storage->Release();
thread.reset(); thread.reset();
@ -70,7 +71,7 @@ void WmdmLoader::LoadDatabase() {
emit LoadFinished(); emit LoadFinished();
} }
void WmdmLoader::RecursiveExploreStorage(IWMDMStorage* parent) { void WmdmLoader::RecursiveExploreStorage(IWMDMStorage* parent, QStringList* path_components) {
IWMDMEnumStorage* child_it = NULL; IWMDMEnumStorage* child_it = NULL;
parent->EnumStorage(&child_it); parent->EnumStorage(&child_it);
@ -85,18 +86,20 @@ void WmdmLoader::RecursiveExploreStorage(IWMDMStorage* parent) {
_WAVEFORMATEX audio_format; _WAVEFORMATEX audio_format;
child->GetAttributes(&attributes, &audio_format); child->GetAttributes(&attributes, &audio_format);
path_components->append(QString::fromWCharArray(name));
if (attributes & WMDM_FILE_ATTR_FILE) { if (attributes & WMDM_FILE_ATTR_FILE) {
LoadFile(child); LoadFile(child, path_components);
} else if (attributes & WMDM_FILE_ATTR_FOLDER) { } else if (attributes & WMDM_FILE_ATTR_FOLDER) {
RecursiveExploreStorage(child); RecursiveExploreStorage(child, path_components);
} }
path_components->removeLast();
child->Release(); child->Release();
} }
child_it->Release(); child_it->Release();
} }
void WmdmLoader::LoadFile(IWMDMStorage* file) { void WmdmLoader::LoadFile(IWMDMStorage* file, const QStringList* path_components) {
// Convert to a IWMDMStorage3 so we can get metadata // Convert to a IWMDMStorage3 so we can get metadata
IWMDMStorage3* storage3 = NULL; IWMDMStorage3* storage3 = NULL;
if (file->QueryInterface(IID_IWMDMStorage3, (void**) &storage3)) if (file->QueryInterface(IID_IWMDMStorage3, (void**) &storage3))
@ -114,6 +117,7 @@ void WmdmLoader::LoadFile(IWMDMStorage* file) {
Song song; Song song;
song.InitFromWmdm(metadata); song.InitFromWmdm(metadata);
song.set_directory_id(1); song.set_directory_id(1);
song.set_filename(path_components->join("/"));
metadata->Release(); metadata->Release();

View File

@ -46,8 +46,8 @@ signals:
void LoadFinished(); void LoadFinished();
private: private:
void RecursiveExploreStorage(IWMDMStorage* parent); void RecursiveExploreStorage(IWMDMStorage* parent, QStringList* path_components);
void LoadFile(IWMDMStorage* file); void LoadFile(IWMDMStorage* file, const QStringList* path_components);
private: private:
boost::shared_ptr<ConnectedDevice> device_; boost::shared_ptr<ConnectedDevice> device_;