Commit 3be308d9 authored by Bastien Penavayre's avatar Bastien Penavayre Committed by Hugo Beauzée-Luyssen

Translate to C++/Cx the newly implemented Dialog Module

-Updates InstanceCX.(cpp/hpp)
   -add setDialogHandlers() and unsetDialogHandlers()
   -create a delegate type for each callback
-Cppcx: Add Dialog API
Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 50f07380
#include "InstanceCX.hpp"
libVLCX::Dialog::Dialog(VLC::Dialog &&other) : _dialog(std::move(other))
{
}
bool libVLCX::Dialog::postLogin(Platform::String^ username, Platform::String^ password, bool store)
{
return _dialog.postLogin(FromPlatformString(username), FromPlatformString(password), store);
}
bool libVLCX::Dialog::postAction(int actionIndex)
{
return _dialog.postAction(actionIndex);
}
bool libVLCX::Dialog::dismiss()
{
return _dialog.dismiss();
}
\ No newline at end of file
#pragma once
namespace libVLCX
{
public ref class Dialog sealed
{
VLC::Dialog _dialog;
friend ref class Instance;
/**
* The standard constructor.
*
* Used only by setDialogHandlers in Instance.hpp.
* \param other native C++ instance of Dialog
*/
Dialog(VLC::Dialog &&other);
public:
/**
* Post a login answer.
*
* After this call, the instance won't be valid anymore
*
* \param username valid non-empty string
* \param password valid string
* \param store if true stores the credentials
* \return true if success, false otherwise
*/
bool postLogin(Platform::String^ username, Platform::String^ password, bool store);
/**
* Post a question answer.
*
* After this call, this instance won't be valid anymore
*
* \see QuestionCb
* \param actionIndex 1 for action1, 2 for action2
* \return true on success, false otherwise
*/
bool postAction(int actionIndex);
/**
* Dismiss a dialog.
*
* After this call, this instance won't be valid anymore
*
* \see CancelCb
*/
bool dismiss();
};
}
\ No newline at end of file
......@@ -131,6 +131,34 @@ namespace libVLCX
});
}
void Instance::setDialogHandlers(DialogCallback::Error ^ error, DialogCallback::Login ^ login, DialogCallback::Question ^ question, DialogCallback::DisplayProgress ^ dspProgress, DialogCallback::Cancel ^ cancel, DialogCallback::UpdateProgress ^ updtProgress)
{
m_instance.setDialogHandlers(
[error](std::string &&title, std::string &&txt) {
error(ToPlatformString(title), ToPlatformString(txt));
},
[login](VLC::Dialog&& dialog, std::string &&title, std::string &&text, std::string &&defaultUserName, bool askToStore) {
login(ref new Dialog(std::move(dialog)), ToPlatformString(std::move(title)), ToPlatformString(std::move(text)), ToPlatformString(std::move(defaultUserName)), askToStore);
},
[question](VLC::Dialog &&dialog, std::string &&title, std::string &&text, VLC::Question qType, std::string &&cancel, std::string &&action1, std::string &&action2) {
question(ref new Dialog(std::move(dialog)), ToPlatformString(std::move(title)), ToPlatformString(std::move(text)), (unsigned)qType, ToPlatformString(std::move(cancel)), ToPlatformString(std::move(action1)), ToPlatformString(std::move(action2)));
},
[dspProgress](VLC::Dialog &&dialog, std::string &&title, std::string &&text, bool intermediate, float position, std::string &&cancel) {
dspProgress(ref new Dialog(std::move(dialog)), ToPlatformString(std::move(title)), ToPlatformString(std::move(text)), intermediate, position, ToPlatformString(std::move(cancel)));
},
[cancel](VLC::Dialog &&dialog) {
cancel(ref new Dialog(std::move(dialog)));
},
[updtProgress](VLC::Dialog &&dialog, float position, std::string &&text) {
updtProgress(ref new Dialog(std::move(dialog)), position, ToPlatformString(std::move(text)));
});
}
void Instance::unsetDialogHandlers()
{
m_instance.unsetDialogHandlers();
}
Windows::Foundation::Collections::IVector<ModuleDescription^>^ Instance::audioFilterList()
{
return MarshallVector<ModuleDescription, VLC::ModuleDescription>(m_instance.audioFilterList());
......
......@@ -25,6 +25,7 @@
#include "StructuresCX.hpp"
#include <collection.h>
#include <vlcpp/vlc.hpp>
#include "DialogCX.hpp"
//<ugly>
#include "DirectXManager.h"
......@@ -33,6 +34,101 @@
namespace libVLCX
{
public delegate void LogCallback(int, Platform::String^);
/**
* Use unsigned to replace the VLC::Question type because enum type are
* forbiden in delegate's argument list
*/
using Question = unsigned;
using DialogType = VLC::DialogType;
namespace DialogCallback
{
/**
* Called when an error message needs to be displayed.
*
* \param title title of the dialog
* \param text text of the dialog
*/
public delegate void Error(Platform::String^ title, Platform::String^ text);
/**
*Called when a login dialog needs to be displayed.
*
*You can interact with this dialog by using the postLogin method on dialog to post an answer or the dismiss method to cancel this dialog.
*
*\note to receive this callack, CancelCb should not be NULL.
*\param dialog used to interact with the dialog
*\param title title of the dialog
*\param text text of the dialog
*\param defaultUserName user name that should be set on the user form
*\param askToStore if true, ask the user if he wants to save the credentials
*/
public delegate void Login(Dialog^ dialog, Platform::String^ title, Platform::String^ text, Platform::String^ defaultUserName, bool askToStore);
/**
* Called when a question dialog needs to be displayed
*
* You can interact with this dialog by using the postAction method on dialog
* to post an answer or dismiss method to cancel this dialog.
*
* \note to receive this callack, CancelCb should not be
* NULL.
*
* \param dialog used to interact with the dialog
* \param title title of the diaog
* \param text text of the dialog
* \param qtype question type (or severity) of the dialog (\see DialogType)
* \param cancel text of the cancel button
* \param action1 text of the first button, if NULL, don't display this
* button
* \param action2 text of the second button, if NULL, don't display
* this button
*/
public delegate void Question(Dialog^ dialog, Platform::String^ title, Platform::String^ text, libVLCX::Question qType, Platform::String^ cancel, Platform::String^ action1, Platform::String^ action2);
/**
* Called when a progress dialog needs to be displayed
*
* If cancellable (cancel != NULL), you can cancel this dialog by
* calling the dismiss method on dialog
*
* \note to receive this callack, CancelCb and
* UpdtProgressCb should not be NULL.
*
* \param dialog used to interact with the dialog
* \param title title of the diaog
* \param text text of the dialog
* \param indeterminate true if the progress dialog is indeterminate
* \param position initial position of the progress bar (between 0.0 and
* 1.0)
* \param cancel text of the cancel button, if NULL the dialog is not
* cancellable
*/
public delegate void DisplayProgress(Dialog^ dialog, Platform::String^ title, Platform::String^ text, bool intermediate, float position, Platform::String^ cancel);
/**
* Called when a displayed dialog needs to be cancelled
*
* The implementation must call the method dismiss on dialog to really release
* the dialog.
*
* \param dialog used to interact with the dialog
*/
public delegate void Cancel(Dialog^ dialog);
/**
* Called when a progress dialog needs to be updated
*
* \param dialog used to interact with the dialog
* \param position osition of the progress bar (between 0.0 and 1.0)
* \param text new text of the progress dialog
*/
public delegate void UpdateProgress(Dialog^ dialog, float position, Platform::String^ text);
}
public ref class Instance sealed
{
public:
......@@ -130,6 +226,23 @@ namespace libVLCX
*/
void logSet(LogCallback^ logCb);
/**
* Replaces all the dialog callbacks for this Instance instance
*
* \param error callback that will get called when an error message needs to be displayed. \see DialogCallback::Error
* \param login callback that will get called when a login dialog needs to be displayed. \see DialogCallback::Login
* \param question callback that will get called when a question dialog needs to be displayed. \see DialogCallback::Question
* \param dspProgress callback that will get called when a progress dialog needs to be displayed. \see DialogCallback::DisplayProgress
* \param cancel callback that will get called when a displayed dialog needs to be cancelled. \see DialogCallback::Cancel
* \param updtProgress callback that will get called when a progress dialog needs to be updated. \see DialogCallback::UpdateProgress
*/
void setDialogHandlers(DialogCallback::Error^ error, DialogCallback::Login^ login, DialogCallback::Question^ question, DialogCallback::DisplayProgress^ dspProgress, DialogCallback::Cancel^ cancel, DialogCallback::UpdateProgress^ updtProgress);
/**
* Unset all dialog callbacks
*/
void unsetDialogHandlers();
/**
* Returns a list of audio filters that are available.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment