Skip to content

Commit

Permalink
Preparing for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuerp committed Dec 27, 2024
1 parent 0663b4b commit 01fb737
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 11 deletions.
5 changes: 4 additions & 1 deletion HostObject.idl
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ library HostObjectLibrary
HRESULT searchLibrary([in, defaultvalue("")] BSTR query, [out, retval] __int64 * tracks);

HRESULT getMetaDBHandleListCount([in] __int64 list, [out, retval] __int64 * count);
HRESULT getMetaDBHandleListItem([in] __int64 list, [in] size_t index, [out, retval] __int64 * metaDBHandle);
HRESULT getMetaDBHandleListItem([in] __int64 list, [in] __int64 index, [out, retval] __int64 * metaDBHandle);
HRESULT releaseMetaDBHandleList([in] __int64 list);

HRESULT getMetaDBHandlePath([in] __int64 handle, [out, retval] BSTR * path);
HRESULT getMetaDBHandleRelativePath([in] __int64 handle, [out, retval] BSTR * path);
HRESULT getMetaDBHandleLength([in] __int64 handle, [out, retval] double * length);

HRESULT formatTitleMetaDBHandle([in] __int64 handle, [in] BSTR text, [out, retval] BSTR * formattedText);

// Permissions
[propget] HRESULT canReadFiles([out, retval] VARIANT_BOOL * value);
Expand Down
11 changes: 10 additions & 1 deletion HostObjectImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ STDMETHODIMP HostObject::put_playbackOrder(int playlistIndex)
#pragma region OS

/// <summary>
/// Executes an operation on the specified file.
/// Executes a shell operation on the specified file.
/// </summary>
STDMETHODIMP HostObject::execute(BSTR filePath, BSTR parameters, BSTR directoryPath, BSTR operation, int showMode)
{
Expand Down Expand Up @@ -549,6 +549,9 @@ STDMETHODIMP HostObject::execute(BSTR filePath, BSTR parameters, BSTR directoryP

#pragma region Permissions

/// <summary>
/// Returns true if the component has permission to read files.
/// </summary>
STDMETHODIMP HostObject::get_canReadFiles(VARIANT_BOOL * result)
{
if (result == nullptr)
Expand All @@ -559,6 +562,9 @@ STDMETHODIMP HostObject::get_canReadFiles(VARIANT_BOOL * result)
return S_OK;
}

/// <summary>
/// Returns true if the component has permission to read directories.
/// </summary>
STDMETHODIMP HostObject::get_canReadDirectories(VARIANT_BOOL * result)
{
if (result == nullptr)
Expand All @@ -569,6 +575,9 @@ STDMETHODIMP HostObject::get_canReadDirectories(VARIANT_BOOL * result)
return S_OK;
}

/// <summary>
/// Returns true if the component has permission to execute shell operations.
/// </summary>
STDMETHODIMP HostObject::get_canExecuteShellOperations(VARIANT_BOOL * result)
{
if (result == nullptr)
Expand Down
5 changes: 4 additions & 1 deletion HostObjectImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,14 @@ class HostObject : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeCl
STDMETHODIMP searchLibrary(BSTR query, __int64 * tracks) override;

STDMETHODIMP getMetaDBHandleListCount(__int64 list, __int64 * count) override;
STDMETHODIMP getMetaDBHandleListItem(__int64 list, size_t index, __int64 * metaDBHandle) override;
STDMETHODIMP getMetaDBHandleListItem(__int64 list, __int64 index, __int64 * metaDBHandle) override;
STDMETHODIMP releaseMetaDBHandleList(__int64 list) override;

STDMETHODIMP getMetaDBHandlePath(__int64 metaDBHandle, BSTR * path) override;
STDMETHODIMP getMetaDBHandleRelativePath(__int64 metaDBHandle, BSTR * path) override;
STDMETHODIMP getMetaDBHandleLength(__int64 metaDBHandle, double * length) override;

STDMETHODIMP formatTitleMetaDBHandle(__int64 metaDBHandle, BSTR script, BSTR * path) override;

/* Permissions */

Expand Down
67 changes: 64 additions & 3 deletions HostObjectImplLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ STDMETHODIMP HostObject::showLibraryPreferences()
/// </summary>
STDMETHODIMP HostObject::searchLibrary(BSTR query, __int64 * tracks)
{
if (tracks == nullptr)
return E_INVALIDARG;

*tracks = 0;

auto List = new metadb_handle_list();
Expand Down Expand Up @@ -77,7 +80,7 @@ STDMETHODIMP HostObject::searchLibrary(BSTR query, __int64 * tracks)
}
}

*tracks = (__int64) List;
*tracks = (__int64) (size_t) List;

return S_OK;
}
Expand All @@ -87,6 +90,9 @@ STDMETHODIMP HostObject::searchLibrary(BSTR query, __int64 * tracks)
/// </summary>
STDMETHODIMP HostObject::getMetaDBHandleListCount(__int64 list, __int64 * count)
{
if (count == nullptr)
return E_INVALIDARG;

auto List = (const metadb_handle_list *) list;

*count = (__int64) List->get_count();
Expand All @@ -97,11 +103,14 @@ STDMETHODIMP HostObject::getMetaDBHandleListCount(__int64 list, __int64 * count)
/// <summary>
/// Gets the list item at the specified index.
/// </summary>
STDMETHODIMP HostObject::getMetaDBHandleListItem(__int64 list, size_t index, __int64 * metaDBHandle)
STDMETHODIMP HostObject::getMetaDBHandleListItem(__int64 list, __int64 index, __int64 * metaDBHandle)
{
if (metaDBHandle == nullptr)
return E_INVALIDARG;

auto List = (const metadb_handle_list *) list;

*metaDBHandle = (__int64) List->get_item(index).get_ptr();
*metaDBHandle = (__int64) (size_t) List->get_item((t_size) index).get_ptr();

return S_OK;
}
Expand All @@ -123,6 +132,9 @@ STDMETHODIMP HostObject::releaseMetaDBHandleList(__int64 list)
/// </summary>
STDMETHODIMP HostObject::getMetaDBHandlePath(__int64 metaDBHandle, BSTR * path)
{
if (path == nullptr)
return E_INVALIDARG;

auto Handle = (metadb_handle *) metaDBHandle;

const playable_location & Location = Handle->get_location();
Expand All @@ -137,6 +149,9 @@ STDMETHODIMP HostObject::getMetaDBHandlePath(__int64 metaDBHandle, BSTR * path)
/// </summary>
STDMETHODIMP HostObject::getMetaDBHandleRelativePath(__int64 metaDBHandle, BSTR * path)
{
if (path == nullptr)
return E_INVALIDARG;

auto Handle = (metadb_handle *) metaDBHandle;

pfc::string Path;
Expand All @@ -149,4 +164,50 @@ STDMETHODIMP HostObject::getMetaDBHandleRelativePath(__int64 metaDBHandle, BSTR
return S_OK;
}

/// <summary>
/// Gets the length of the specified metadb handle.
/// </summary>
STDMETHODIMP HostObject::getMetaDBHandleLength(__int64 metaDBHandle, double * length)
{
if (length == nullptr)
return E_INVALIDARG;

auto Handle = (metadb_handle *) metaDBHandle;

*length = Handle->get_length();

return S_OK;
}

/// <summary>
/// Formats the title of a Media Library item.
/// </summary>
STDMETHODIMP HostObject::formatTitleMetaDBHandle(__int64 metaDBHandle, BSTR text, BSTR * formattedText)
{
if ((text == nullptr) || (formattedText == nullptr))
return E_INVALIDARG;

auto Handle = (metadb_handle *) metaDBHandle;

titleformat_object::ptr FormatObject;
pfc::string8 Text = pfc::utf8FromWide(text);

bool Success = titleformat_compiler::get()->compile(FormatObject, Text);

if (!Success)
{
*formattedText = ::SysAllocString(L"");

return E_INVALIDARG;
}

pfc::string8 FormattedText;

Success = Handle->format_title(nullptr, FormattedText, FormatObject, nullptr);

*formattedText = ::SysAllocString(pfc::wideFromUTF8(FormattedText).c_str());

return S_OK;
}

#pragma endregion
2 changes: 1 addition & 1 deletion LibraryTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{
const Track = new MetaDBHandle(Tracks[i]);

Text += Track.path + "<br/>";
Text += Track.length + "ms, " + Track.FormatTitle("%filesize%") + " bytes, (" + Track.path + ")<br/>";
}
/* Enumeration does not work yet.
forEach (Tracks, Track =>
Expand Down
1 change: 1 addition & 0 deletions Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class Preferences : public CDialogImpl<Preferences>, public preferences_page_ins
COMMAND_HANDLER_EX(IDC_USER_DATA_FOLDER_PATH_SELECT, BN_CLICKED, OnButtonClicked)

COMMAND_HANDLER_EX(IDC_FILE_PATH, EN_CHANGE, OnEditChange)
COMMAND_HANDLER_EX(IDC_FILE_PATH_SELECT, BN_CLICKED, OnButtonClicked)

COMMAND_HANDLER_EX(IDC_WINDOW_SIZE, EN_CHANGE, OnEditChange)
COMMAND_HANDLER_EX(IDC_REACTION_ALIGNMENT, EN_CHANGE, OnEditChange)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,20 @@ To create the component first build the x86 configuration and next the x64 confi

## Change Log

v0.3.0.0-alpha1, 2024-12-xx
v0.3.0.0-alpha1, 2024-12-27

* New:
* Included foobar2000.js wraps the API to make JavaScript development easier. (alpha1)
* Set permissions in the Preferences dialog. (alpha1)

* Properties
* isLibraryEnabled: Returns true if the Media Library is enabled. (alpha1)
* canReadFiles: Returns true if the component can read local files. (alpha1)
* canReadDirectories: Returns true if the component can read local directories. (alpha1)
* canExecuteShellOperations: Returns true if the component can execute shell operations. (alpha1)

* Methods
* execute(filePath, arguments, directoryPath, operation, showMode): Performs the specified shell operation on a file. Mostly used to run applications. Check the [SHELLEXECUTEINFOW](https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow) documentation for the possible values of the parameters. (alpha1)
* execute(filePath, arguments, directoryPath, operation, showMode): Execites a shell operation on a file. Mostly used to run applications. Check the [SHELLEXECUTEINFOW](https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfow) documentation for the possible values of the parameters. (alpha1)

* showLibraryPreferences(): Shows the Media Library preferences dialog. (alpha1)
* searchLibrary(query): Searches the Media Library for matching tracks. Returns a metadb handle list. (alpha1)
Expand All @@ -118,6 +120,8 @@ v0.3.0.0-alpha1, 2024-12-xx

* getMetaDBHandlePath(handle): Gets the path of the specified metadb handle. (alpha1)
* getMetaDBHandleRelativePath(handle): Gets the path of the specified metadb handle relative to the Media Library folder it is in. (alpha1)
* getMetaDBHandleLength(handle): Gets the length of the specified metadb handle (in ms). (alpha1)

* Callbacks
* onLibraryItemsAdded(items): Called when items have been added to the Media Library. (alpha1)
* onLibraryItemsModified(items): Called when Media Library items have been modified. (alpha1)
Expand Down
2 changes: 1 addition & 1 deletion Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define NUM_PRODUCT_PATCH 0
#define NUM_PRODUCT_PRERELEASE 0

#define STR_PRERELEASE "alpha1"
#define STR_PRERELEASE "-alpha1"

/** Component specific **/

Expand Down
19 changes: 18 additions & 1 deletion foobar2000.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ function MetaDBHandle(arg)

/**
Gets the path.
@name path
@returns {string}
**/
Object.defineProperty(this, 'path',
Expand All @@ -113,6 +112,24 @@ function MetaDBHandle(arg)
{
get() { return chrome.webview.hostObjects.sync.foo_uie_webview.getMetaDBHandleRelativePath(this.Source); }
});

/**
Gets the length.
@returns {double}
**/
Object.defineProperty(this, 'length',
{
get() { return chrome.webview.hostObjects.sync.foo_uie_webview.getMetaDBHandleLength(this.Source); }
});

/**
Releases the metadb handle list.
@returns {void}
**/
this.FormatTitle = function(text)
{
return chrome.webview.hostObjects.sync.foo_uie_webview.formatTitleMetaDBHandle(this.Source, text);
};
}

/**
Expand Down

0 comments on commit 01fb737

Please sign in to comment.