Commit df2c2ef8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

dialog cluster: update to revised libvlc API

(cherry picked from commit 16e5bdad)
parent d647284e
......@@ -132,8 +132,8 @@ typedef NS_ENUM(NSUInteger, VLCDialogQuestionType) {
* \param reference to the dialog you respond to
* \param shall VLC store the login securely?
* \note This method does not have any effect if you don't use custom UI mode */
- (void)postUsername:(NSString * _Nullable)username
andPassword:(NSString * _Nullable)password
- (void)postUsername:(NSString * _Nonnull)username
andPassword:(NSString * _Nonnull)password
forDialogReference:(NSValue * _Nonnull)dialogReference
store:(BOOL)store;
......
......@@ -208,9 +208,14 @@ static void updateProgressCallback(libvlc_dialog_id *p_id,
- (void)postUsername:(NSString *)username andPassword:(NSString *)password forDialogReference:(NSValue *)dialogReference store:(BOOL)store
{
if (username == nil || password == nil) {
libvlc_dialog_dismiss([dialogReference pointerValue]);
return;
}
libvlc_dialog_post_login([dialogReference pointerValue],
username != nil ? [username UTF8String] : NULL,
password != nil ? [password UTF8String] : NULL,
[username UTF8String],
[password UTF8String],
store);
}
......
......@@ -33,24 +33,20 @@
- (instancetype)initWithLibrary:(VLCLibrary *)library customUI:(BOOL)customUI
{
#if TARGET_OS_IPHONE
#if( __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0)
#if !TARGET_OS_TV
if (customUI)
return [[VLCCustomDialogProvider alloc] initWithLibrary:library];
return [[VLCiOSLegacyDialogProvider alloc] initWithLibrary:library];
if (!SYSTEM_RUNS_IOS8_OR_LATER) {
return [[VLCEmbeddedDialogProvider alloc] initWithLibrary:library];
} else {
return [[VLCiOSLegacyDialogProvider alloc] initWithLibrary:library];
}
#else
#if !TARGET_OS_TV
if (customUI)
return [[VLCCustomDialogProvider alloc] initWithLibrary:library];
if (customUI)
return [[VLCCustomDialogProvider alloc] initWithLibrary:library];
if (SYSTEM_RUNS_IOS8_OR_LATER) {
return [[VLCEmbeddedDialogProvider alloc] initWithLibrary:library];
} else {
return [[VLCiOSLegacyDialogProvider alloc] initWithLibrary:library];
}
#else
return [[VLCEmbeddedDialogProvider alloc] initWithLibrary:library];
#endif
return [[VLCEmbeddedDialogProvider alloc] initWithLibrary:library];
#endif
#else
if (customUI)
......
......@@ -39,9 +39,9 @@
@end
static void displayErrorCallback(const char *psz_title,
const char *psz_text,
void *p_data)
static void displayErrorCallback(void *p_data,
const char *psz_title,
const char *psz_text)
{
@autoreleasepool {
VLCEmbeddedDialogProvider *dialogProvider = (__bridge VLCEmbeddedDialogProvider *)p_data;
......@@ -52,12 +52,12 @@ static void displayErrorCallback(const char *psz_title,
}
}
static void displayLoginCallback(libvlc_dialog_id *p_id,
static void displayLoginCallback(void *p_data,
libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
const char *psz_default_username,
bool b_ask_store,
void *p_data)
bool b_ask_store)
{
@autoreleasepool {
VLCEmbeddedDialogProvider *dialogProvider = (__bridge VLCEmbeddedDialogProvider *)p_data;
......@@ -71,14 +71,14 @@ static void displayLoginCallback(libvlc_dialog_id *p_id,
}
}
static void displayQuestionCallback(libvlc_dialog_id *p_id,
static void displayQuestionCallback(void *p_data,
libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
libvlc_dialog_question_type i_type,
const char *psz_cancel,
const char *psz_action1,
const char *psz_action2,
void *p_data)
const char *psz_action2)
{
@autoreleasepool {
VLCEmbeddedDialogProvider *dialogProvider = (__bridge VLCEmbeddedDialogProvider *)p_data;
......@@ -94,13 +94,13 @@ static void displayQuestionCallback(libvlc_dialog_id *p_id,
}
}
static void displayProgressCallback(libvlc_dialog_id *p_id,
static void displayProgressCallback(void *p_data,
libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
bool b_indeterminate,
float f_position,
const char *psz_cancel,
void *p_data)
const char *psz_cancel)
{
@autoreleasepool {
VLCEmbeddedDialogProvider *dialogProvider = (__bridge VLCEmbeddedDialogProvider *)p_data;
......@@ -115,24 +115,24 @@ static void displayProgressCallback(libvlc_dialog_id *p_id,
}
}
static void cancelCallback(libvlc_dialog_id *p_id,
void *p_data)
static void cancelCallback(void *p_data,
libvlc_dialog_id *p_id)
{
@autoreleasepool {
[[[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] dismissViewControllerAnimated:YES completion:nil];
}
}
static void updateProgressCallback(libvlc_dialog_id *p_id,
float f_value,
const char *psz_text,
void *p_data)
static void updateProgressCallback(void *p_data,
libvlc_dialog_id *p_id,
float f_position,
const char *psz_text)
{
@autoreleasepool {
VLCEmbeddedDialogProvider *dialogProvider = (__bridge VLCEmbeddedDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(updateDisplayedProgressDialog:)
withObject:@[[NSValue valueWithPointer:p_id],
@(f_value),
@(f_position),
toNSStr(psz_text)]
waitUntilDone:NO];
}
......@@ -219,8 +219,8 @@ static void updateProgressCallback(libvlc_dialog_id *p_id,
NSString *password = passwordField.text;
libvlc_dialog_post_login([dialogData[0] pointerValue],
username ? [username UTF8String] : NULL,
password ? [password UTF8String] : NULL,
username ? [username UTF8String] : "",
password ? [password UTF8String] : "",
NO);
}];
[alertController addAction:loginAction];
......@@ -229,10 +229,7 @@ static void updateProgressCallback(libvlc_dialog_id *p_id,
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * _Nonnull action) {
libvlc_dialog_post_login([dialogData[0] pointerValue],
NULL,
NULL,
NO);
libvlc_dialog_dismiss([dialogData[0] pointerValue]);
}]];
if ([dialogData[4] boolValue]) {
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Save", nil)
......
......@@ -44,9 +44,9 @@
@end
static void displayErrorCallback(const char *psz_title,
const char *psz_text,
void *p_data)
static void displayErrorCallback(void *p_data,
const char *psz_title,
const char *psz_text)
{
@autoreleasepool {
VLCiOSLegacyDialogProvider *dialogProvider = (__bridge VLCiOSLegacyDialogProvider *)p_data;
......@@ -57,12 +57,12 @@ static void displayErrorCallback(const char *psz_title,
}
}
static void displayLoginCallback(libvlc_dialog_id *p_id,
static void displayLoginCallback(void *p_data,
libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
const char *psz_default_username,
bool b_ask_store,
void *p_data)
bool b_ask_store)
{
@autoreleasepool {
VLCiOSLegacyDialogProvider *dialogProvider = (__bridge VLCiOSLegacyDialogProvider *)p_data;
......@@ -76,14 +76,14 @@ static void displayLoginCallback(libvlc_dialog_id *p_id,
}
}
static void displayQuestionCallback(libvlc_dialog_id *p_id,
static void displayQuestionCallback(void *p_data,
libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
libvlc_dialog_question_type i_type,
const char *psz_cancel,
const char *psz_action1,
const char *psz_action2,
void *p_data)
const char *psz_action2)
{
@autoreleasepool {
VLCiOSLegacyDialogProvider *dialogProvider = (__bridge VLCiOSLegacyDialogProvider *)p_data;
......@@ -99,13 +99,13 @@ static void displayQuestionCallback(libvlc_dialog_id *p_id,
}
}
static void displayProgressCallback(libvlc_dialog_id *p_id,
static void displayProgressCallback(void *p_data,
libvlc_dialog_id *p_id,
const char *psz_title,
const char *psz_text,
bool b_indeterminate,
float f_position,
const char *psz_cancel,
void *p_data)
const char *psz_cancel)
{
@autoreleasepool {
VLCiOSLegacyDialogProvider *dialogProvider = (__bridge VLCiOSLegacyDialogProvider *)p_data;
......@@ -120,8 +120,8 @@ static void displayProgressCallback(libvlc_dialog_id *p_id,
}
}
static void cancelCallback(libvlc_dialog_id *p_id,
void *p_data)
static void cancelCallback(void *p_data,
libvlc_dialog_id *p_id)
{
@autoreleasepool {
// FIXME: the saddest NO-OP
......@@ -129,16 +129,16 @@ static void cancelCallback(libvlc_dialog_id *p_id,
}
}
static void updateProgressCallback(libvlc_dialog_id *p_id,
float f_value,
const char *psz_text,
void *p_data)
static void updateProgressCallback(void *p_data,
libvlc_dialog_id *p_id,
float f_position,
const char *psz_text)
{
@autoreleasepool {
VLCiOSLegacyDialogProvider *dialogProvider = (__bridge VLCiOSLegacyDialogProvider *)p_data;
[dialogProvider performSelectorOnMainThread:@selector(updateDisplayedProgressDialog:)
withObject:@[[NSValue valueWithPointer:p_id],
@(f_value),
@(f_position),
toNSStr(psz_text)]
waitUntilDone:NO];
}
......@@ -184,8 +184,8 @@ static void updateProgressCallback(libvlc_dialog_id *p_id,
- (void)displayError:(NSArray * _Nonnull)dialogData
{
VLCBlockingAlertView *alert = [[VLCBlockingAlertView alloc] initWithTitle:dialogData[1]
message:dialogData[2]
VLCBlockingAlertView *alert = [[VLCBlockingAlertView alloc] initWithTitle:dialogData[0]
message:dialogData[1]
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil];
......@@ -207,14 +207,11 @@ static void updateProgressCallback(libvlc_dialog_id *p_id,
NSString *username = [weakAlert textFieldAtIndex:0].text;
NSString *password = [weakAlert textFieldAtIndex:1].text;
libvlc_dialog_post_login([dialogData[0] pointerValue],
username ? [username UTF8String] : NULL,
password ? [password UTF8String] : NULL,
username ? [username UTF8String] : "",
password ? [password UTF8String] : "",
buttonIndex != alert.firstOtherButtonIndex);
} else {
libvlc_dialog_post_login([dialogData[0] pointerValue],
NULL,
NULL,
NO);
libvlc_dialog_dismiss([dialogData[0] pointerValue]);
}
};
alert.delegate = alert;
......
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