From: Felix Paul Kühne Date: Sun, 14 May 2006 12:41:40 +0000 (+0000) Subject: * first implementation of a widget-free authentication-dialogue (core and OSX only... X-Git-Tag: 0.9.0-test0~11258 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4db8257a88e991b8d84d1bdce3119eaa3558b544;p=vlc * first implementation of a widget-free authentication-dialogue (core and OSX only, refs #553) --- diff --git a/extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib index 25c8f22925..1c88a82d03 100644 --- a/extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib +++ b/extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib @@ -2,10 +2,19 @@ IBClasses = ( {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, { - ACTIONS = {cancelAndClose = id; }; + ACTIONS = {cancelAndClose = id; okayAndClose = id; }; CLASS = VLCInteraction; LANGUAGE = ObjC; OUTLETS = { + "o_auth_cancel_btn" = id; + "o_auth_description" = id; + "o_auth_login_fld" = id; + "o_auth_login_txt" = id; + "o_auth_ok_btn" = id; + "o_auth_pw_fld" = id; + "o_auth_pw_txt" = id; + "o_auth_title" = id; + "o_auth_win" = id; "o_prog_bar" = id; "o_prog_cancel_btn" = id; "o_prog_description" = id; diff --git a/extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib b/extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib index 8ebe9a6103..1948872518 100644 --- a/extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib +++ b/extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib @@ -3,14 +3,14 @@ IBDocumentLocation - 103 27 356 240 0 0 1440 878 + 97 142 356 240 0 0 1440 878 IBFramework Version 443.0 IBOpenObjects - 5 + 55 IBSystem Version - 8H14 + 8I127 diff --git a/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib index caa145399b..6d5426a777 100644 Binary files a/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib differ diff --git a/include/vlc_interaction.h b/include/vlc_interaction.h index 1085cfdc64..d77c80bae7 100644 --- a/include/vlc_interaction.h +++ b/include/vlc_interaction.h @@ -5,6 +5,7 @@ * $Id$ * * Authors: Clément Stenac + * Felix Kühne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +53,8 @@ struct interaction_dialog_t char *psz_title; ///< Title char *psz_description; ///< Descriptor string + char *psz_returned[1]; ///< returned responses from the user + int i_widgets; ///< Number of dialog widgets user_widget_t **pp_widgets; ///< Dialog widgets @@ -70,12 +73,13 @@ struct interaction_dialog_t /** * Possible flags . Reusable and button types */ -#define DIALOG_REUSABLE 0x01 -#define DIALOG_OK_CANCEL 0x02 -#define DIALOG_YES_NO 0x04 -#define DIALOG_YES_NO_CANCEL 0x04 -#define DIALOG_CLEAR_NOSHOW 0x08 -#define DIALOG_GOT_ANSWER 0x10 +#define DIALOG_REUSABLE 0x01 +#define DIALOG_OK_CANCEL 0x02 +#define DIALOG_YES_NO 0x04 +#define DIALOG_YES_NO_CANCEL 0x04 +#define DIALOG_CLEAR_NOSHOW 0x08 +#define DIALOG_GOT_ANSWER 0x10 +#define DIALOG_LOGIN_PW_OK_CANCEL 0x20 /** * Possible return codes diff --git a/modules/access/http.c b/modules/access/http.c index 8eed919201..71bdcb011a 100644 --- a/modules/access/http.c +++ b/modules/access/http.c @@ -290,8 +290,9 @@ connect: char *psz_login = NULL; char *psz_password = NULL; int i_ret; msg_Dbg( p_access, "authentication failed" ); - i_ret = intf_UserLoginPassword( p_access, "HTTP authentication", - "Please enter a valid login and password.", &psz_login, &psz_password ); + i_ret = intf_UserLoginPassword( p_access, _("HTTP authentication"), + _("Please enter a valid login name and a password."), + &psz_login, &psz_password ); if( i_ret == DIALOG_OK_YES ) { msg_Dbg( p_access, "retrying with user=%s, pwd=%s", diff --git a/modules/gui/macosx/interaction.h b/modules/gui/macosx/interaction.h index 018af7330a..444b130015 100644 --- a/modules/gui/macosx/interaction.h +++ b/modules/gui/macosx/interaction.h @@ -38,12 +38,24 @@ IBOutlet id o_prog_title; IBOutlet id o_prog_win; + /* authentication dialogue */ + IBOutlet id o_auth_cancel_btn; + IBOutlet id o_auth_description; + IBOutlet id o_auth_login_fld; + IBOutlet id o_auth_login_txt; + IBOutlet id o_auth_ok_btn; + IBOutlet id o_auth_pw_fld; + IBOutlet id o_auth_pw_txt; + IBOutlet id o_auth_title; + IBOutlet id o_auth_win; + interaction_dialog_t * p_dialog; intf_thread_t * p_intf; BOOL nib_interact_loaded; } - (IBAction)cancelAndClose:(id)sender; +- (IBAction)okayAndClose:(id)sender; -(id)initDialog: (interaction_dialog_t *)_p_dialog; -(void)runDialog; diff --git a/modules/gui/macosx/interaction.m b/modules/gui/macosx/interaction.m index ce694b4dcf..a65d8fe2e6 100644 --- a/modules/gui/macosx/interaction.m +++ b/modules/gui/macosx/interaction.m @@ -120,6 +120,10 @@ nib_interact_loaded = [NSBundle loadNibNamed:@"Interaction" owner:self]; [o_prog_cancel_btn setTitle: _NS("Cancel")]; [o_prog_bar setUsesThreadedAnimation: YES]; + [o_auth_login_txt setStringValue: _NS("Login:")]; + [o_auth_pw_txt setStringValue: _NS("Password:")]; + [o_auth_cancel_btn setTitle: _NS("Cancel")]; + [o_auth_ok_btn setTitle: _NS("OK")]; } NSString *o_title = [NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : "title"]; @@ -177,6 +181,17 @@ o_window, self,@selector(sheetDidEnd: returnCode: contextInfo:),\ NULL, nil, o_description ); } + else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) + { + msg_Dbg( p_intf, "requested flag: DIALOG_LOGIN_PW_OK_CANCEL" ); + [o_auth_title setStringValue: o_title]; + [o_auth_description setStringValue: o_description]; + [o_auth_login_fld setStringValue: @""]; + [o_auth_pw_fld setStringValue: @""]; + [NSApp beginSheet: o_auth_win modalForWindow: o_window \ + modalDelegate: self didEndSelector: nil contextInfo: nil]; + [o_auth_win makeKeyWindow]; + } else if( p_dialog->i_type & WIDGET_PROGRESS ) { msg_Dbg( p_intf, "requested type: WIDGET_PROGRESS" ); @@ -244,6 +259,11 @@ [NSApp endSheet: o_prog_win]; [o_prog_win close]; } + if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL ) + { + [NSApp endSheet: o_auth_win]; + [o_auth_win close]; + } } -(void)destroyDialog @@ -261,4 +281,18 @@ msg_Dbg( p_intf, "dialog cancelled" ); } +- (IBAction)okayAndClose:(id)sender +{ + msg_Dbg( p_intf, "dialog's okay btn pressed, returning values" ); + vlc_mutex_lock( &p_dialog->p_interaction->object_lock ); + if( p_dialog->i_flags == DIALOG_LOGIN_PW_OK_CANCEL ) + { + p_dialog->psz_returned[0] = strdup( [[o_auth_login_fld stringValue] UTF8String] ); + p_dialog->psz_returned[1] = strdup( [[o_auth_pw_fld stringValue] UTF8String] ); + } + p_dialog->i_return = DIALOG_OK_YES; + p_dialog->i_status = ANSWERED_DIALOG; + vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); +} + @end diff --git a/src/interface/interaction.c b/src/interface/interaction.c index 78ab63ab98..7647211002 100644 --- a/src/interface/interaction.c +++ b/src/interface/interaction.c @@ -5,6 +5,7 @@ * $Id$ * * Authors: Clément Stenac + * Felix Kühne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -406,47 +407,24 @@ int __intf_UserLoginPassword( vlc_object_t *p_this, char **ppsz_login, char **ppsz_password ) { + int i_ret; interaction_dialog_t *p_new = NULL; - user_widget_t *p_widget = NULL; INTERACT_INIT( p_new ); p_new->i_type = INTERACT_DIALOG_TWOWAY; p_new->psz_title = strdup( psz_title ); + p_new->psz_description = strdup( psz_description ); - /* Text */ - p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); - p_widget->i_type = WIDGET_TEXT; - p_widget->psz_text = strdup( psz_description ); - p_widget->val.psz_string = NULL; - INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, - p_new->i_widgets, p_widget ); - - /* Login */ - p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); - p_widget->i_type = WIDGET_INPUT_TEXT; - p_widget->psz_text = strdup( _("Login") ); - p_widget->val.psz_string = NULL; - INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, - p_new->i_widgets, p_widget ); - - /* Password */ - p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); - p_widget->i_type = WIDGET_INPUT_TEXT; - p_widget->psz_text = strdup( _("Password") ); - p_widget->val.psz_string = NULL; - INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, - p_new->i_widgets, p_widget ); - - p_new->i_flags = DIALOG_OK_CANCEL; + p_new->i_flags = DIALOG_LOGIN_PW_OK_CANCEL; i_ret = intf_Interact( p_this, p_new ); if( i_ret != DIALOG_CANCELLED ) { - *ppsz_login = strdup( p_new->pp_widgets[1]->val.psz_string ); - *ppsz_password = strdup( p_new->pp_widgets[2]->val.psz_string ); + *ppsz_login = strdup( p_new->psz_returned[0] ); + *ppsz_password = strdup( p_new->psz_returned[1] ); } return i_ret; } @@ -671,6 +649,9 @@ static void intf_InteractionDialogDestroy( interaction_dialog_t *p_dialog ) } FREE( p_dialog->psz_title ); FREE( p_dialog->psz_description ); + + FREE( p_dialog->psz_returned[0] ); + FREE( p_dialog->psz_returned[1] ); free( p_dialog ); }