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;
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
- <string>103 27 356 240 0 0 1440 878 </string>
+ <string>97 142 356 240 0 0 1440 878 </string>
<key>IBFramework Version</key>
<string>443.0</string>
<key>IBOpenObjects</key>
<array>
- <integer>5</integer>
+ <integer>55</integer>
</array>
<key>IBSystem Version</key>
- <string>8H14</string>
+ <string>8I127</string>
</dict>
</plist>
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
+ * Felix Kühne <fkuehne@videolan.org>
*
* 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
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
/**
* 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
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",
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;
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"];
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" );
[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
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
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
+ * Felix Kühne <fkuehne@videolan.org>
*
* 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
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;
}
}
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 );
}