mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Add auth dialog
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
14896492f5
commit
b7ec1db5ae
@ -3,6 +3,7 @@ AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
|
||||
noinst_LTLIBRARIES = libvfs-smbfs.la
|
||||
|
||||
libvfs_smbfs_la_SOURCES = \
|
||||
auth_dialog.c \
|
||||
dir.c \
|
||||
init.c init.h \
|
||||
internal.c internal.h \
|
||||
|
99
src/vfs/smbfs/auth_dialog.c
Normal file
99
src/vfs/smbfs/auth_dialog.c
Normal file
@ -0,0 +1,99 @@
|
||||
/* Virtual File System: Samba file system.
|
||||
Show authentication dialog
|
||||
|
||||
Copyright (C) 2013
|
||||
The Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2013
|
||||
|
||||
This file is part of the Midnight Commander.
|
||||
|
||||
The Midnight Commander is free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
The Midnight Commander is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "lib/global.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
/*** file scope variables ************************************************************************/
|
||||
|
||||
/*** file scope functions ************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
smbfs_auth_dialog (const char *server, const char *share,
|
||||
char *workgroup, int wgmaxlen, char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen)
|
||||
{
|
||||
char *smb_path;
|
||||
|
||||
smb_path =
|
||||
g_strconcat (_("Samba share: "), PATH_SEP_STR, PATH_SEP_STR, server, PATH_SEP_STR, share,
|
||||
NULL);
|
||||
|
||||
{
|
||||
char *new_workgroup = NULL;
|
||||
char *new_username = NULL;
|
||||
char *new_password = NULL;
|
||||
quick_widget_t quick_widgets[] = {
|
||||
/* *INDENT-OFF* */
|
||||
QUICK_LABEL (smb_path, NULL),
|
||||
QUICK_SEPARATOR (TRUE),
|
||||
QUICK_LABELED_INPUT (N_("Workgroup:"), input_label_above,
|
||||
workgroup, "input-3", &new_workgroup, NULL, FALSE, FALSE, INPUT_COMPLETE_NONE),
|
||||
QUICK_LABELED_INPUT (N_("User name:"), input_label_above,
|
||||
username, "input-2", &new_username, NULL, FALSE, FALSE, INPUT_COMPLETE_USERNAMES),
|
||||
QUICK_LABELED_INPUT (N_("Password:"), input_label_above,
|
||||
password, "input-1", &new_password, NULL, TRUE, FALSE, INPUT_COMPLETE_NONE),
|
||||
QUICK_BUTTONS_OK_CANCEL,
|
||||
QUICK_END
|
||||
/* *INDENT-ON* */
|
||||
};
|
||||
|
||||
quick_dialog_t qdlg = {
|
||||
-1, -1, 64,
|
||||
N_("Samba credentials"), "[Samba credentials]",
|
||||
quick_widgets, NULL, NULL
|
||||
};
|
||||
|
||||
if (quick_dialog (&qdlg) != B_CANCEL)
|
||||
{
|
||||
if (new_workgroup != NULL)
|
||||
g_strlcpy (workgroup, new_workgroup, wgmaxlen);
|
||||
|
||||
if (new_username != NULL)
|
||||
g_strlcpy (username, new_username, unmaxlen);
|
||||
|
||||
if (new_password != NULL)
|
||||
g_strlcpy (password, new_password, pwmaxlen);
|
||||
}
|
||||
g_free (new_password);
|
||||
g_free (new_username);
|
||||
g_free (new_workgroup);
|
||||
}
|
||||
g_free (smb_path);
|
||||
}
|
@ -53,14 +53,7 @@ smbfs_cb_authdata_provider (const char *server, const char *share,
|
||||
char *workgroup, int wgmaxlen, char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen)
|
||||
{
|
||||
(void) server;
|
||||
(void) share;
|
||||
(void) workgroup;
|
||||
(void) wgmaxlen;
|
||||
(void) username;
|
||||
(void) unmaxlen;
|
||||
(void) password;
|
||||
(void) pwmaxlen;
|
||||
smbfs_auth_dialog (server, share, workgroup, wgmaxlen, username, unmaxlen, password, pwmaxlen);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -38,6 +38,11 @@ void
|
||||
smbfs_cb_authdata_provider (const char *server, const char *share,
|
||||
char *workgroup, int wgmaxlen, char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen);
|
||||
void
|
||||
smbfs_auth_dialog (const char *server, const char *share,
|
||||
char *workgroup, int wgmaxlen, char *username, int unmaxlen,
|
||||
char *password, int pwmaxlen);
|
||||
|
||||
const char *smbfs_strerror (int err_no);
|
||||
|
||||
char *smbfs_make_url (const vfs_path_element_t * element, gboolean with_path);
|
||||
|
Loading…
Reference in New Issue
Block a user