]> git.sesse.net Git - vlc/commitdiff
* first implementation of a widget-free authentication-dialogue (core and OSX only...
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 14 May 2006 12:41:40 +0000 (12:41 +0000)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 14 May 2006 12:41:40 +0000 (12:41 +0000)
extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib
extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib
extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib
include/vlc_interaction.h
modules/access/http.c
modules/gui/macosx/interaction.h
modules/gui/macosx/interaction.m
src/interface/interaction.c

index 25c8f22925fd8e6cfe68445956ee28158df118b9..1c88a82d039d908d1ff88c419e7dc200e8e92599 100644 (file)
@@ -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; 
index 8ebe9a610390004ab241e22642dd3f3c0da36dac..1948872518da02a9414fd2696b6f5f43d27c62ea 100644 (file)
@@ -3,14 +3,14 @@
 <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>
index caa145399be68f2f553bde81854ff67da0ca2ac9..6d5426a777288f7dceca048dfd0a04dc33883ad9 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib differ
index 1085cfdc64870e97e3d2426c72d23a6b9a5a2e73..d77c80bae708c5f3a1530ce77f81986571786978 100644 (file)
@@ -5,6 +5,7 @@
  * $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
@@ -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
index 8eed919201588b601085bd9e615ace3f401b2b6b..71bdcb011a4807c403bf8f85d09d8ec1b7bff897 100644 (file)
@@ -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",
index 018af7330a7a14292c961bec3d43be7364665a1f..444b1300156f69cae7ddafcd3cb6eb4a38b92c28 100644 (file)
     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;
index ce694b4dcfe2a1bec35f432f046487994d2c8c9c..a65d8fe2e632cd7eab41678467ad823c72115367 100644 (file)
         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
index 78ab63ab98dc9d8b3e1c3fabd77e64650ae8781d..76472110020ca51bf307ecb835cae27bf975d518 100644 (file)
@@ -5,6 +5,7 @@
  * $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
@@ -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 );
 }