Commit aa599c4b authored by Thomas Guillem's avatar Thomas Guillem

smb: factorize smb strings used by SMB and DSM modules

parent 5ba5b53f
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <netdb.h> #include <netdb.h>
#include <bdsm/bdsm.h> #include <bdsm/bdsm.h>
#include "../smb_common.h"
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -56,18 +57,6 @@ static void Close( vlc_object_t * ); ...@@ -56,18 +57,6 @@ static void Close( vlc_object_t * );
#define vlc_sd_probe_Open bdsm_sd_probe_Open #define vlc_sd_probe_Open bdsm_sd_probe_Open
#define USER_TEXT N_("Username")
#define USER_LONGTEXT N_("Username that will be used for the connection, " \
"if no username is set in the URL.")
#define PASS_TEXT N_("Password")
#define PASS_LONGTEXT N_("Password that will be used for the connection, " \
"if no username or password are set in URL.")
#define DOMAIN_TEXT N_("SMB domain")
#define DOMAIN_LONGTEXT N_("Domain/Workgroup that " \
"will be used for the connection. Domain of uri will also be tried.")
#define BDSM_LOGIN_DIALOG_RETRY 1
#define BDSM_HELP N_("libdsm's SMB (Windows network shares) input and browser") #define BDSM_HELP N_("libdsm's SMB (Windows network shares) input and browser")
vlc_module_begin () vlc_module_begin ()
...@@ -77,9 +66,9 @@ vlc_module_begin () ...@@ -77,9 +66,9 @@ vlc_module_begin ()
set_capability( "access", 20 ) set_capability( "access", 20 )
set_category( CAT_INPUT ) set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_ACCESS ) set_subcategory( SUBCAT_INPUT_ACCESS )
add_string( "smb-user", NULL, USER_TEXT, USER_LONGTEXT, false ) add_string( "smb-user", NULL, SMB_USER_TEXT, SMB_USER_LONGTEXT, false )
add_password( "smb-pwd", NULL, PASS_TEXT, PASS_LONGTEXT, false ) add_password( "smb-pwd", NULL, SMB_PASS_TEXT, SMB_PASS_LONGTEXT, false )
add_string( "smb-domain", NULL, DOMAIN_TEXT, DOMAIN_LONGTEXT, false ) add_string( "smb-domain", NULL, SMB_DOMAIN_TEXT, SMB_DOMAIN_LONGTEXT, false )
add_shortcut( "smb", "cifs" ) add_shortcut( "smb", "cifs" )
set_callbacks( Open, Close ) set_callbacks( Open, Close )
...@@ -131,14 +120,6 @@ struct access_sys_t ...@@ -131,14 +120,6 @@ struct access_sys_t
smb_stat_list files; smb_stat_list files;
}; };
/*****************************************************************************
* Dialog strings
*****************************************************************************/
#define BDSM_LOGIN_DIALOG_TITLE N_( "%s: Authentication required" )
#define BDSM_LOGIN_DIALOG_TEXT N_( "The computer you are trying to connect " \
"to requires authentication.\n Please provide a username (and ideally a " \
"domain name using the format DOMAIN;username)\n and a password." )
/***************************************************************************** /*****************************************************************************
* Open: Initialize module's data structures and libdsm * Open: Initialize module's data structures and libdsm
*****************************************************************************/ *****************************************************************************/
...@@ -358,24 +339,17 @@ static int login( access_t *p_access ) ...@@ -358,24 +339,17 @@ static int login( access_t *p_access )
if( smb_connect( p_access, psz_login, psz_password, psz_domain ) if( smb_connect( p_access, psz_login, psz_password, psz_domain )
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
char *psz_title;
if ( asprintf( &psz_title, BDSM_LOGIN_DIALOG_TITLE,
p_sys->netbios_name ) == -1 )
goto error;
while( vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd", while( vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd",
psz_title, BDSM_LOGIN_DIALOG_TEXT ) ) SMB_LOGIN_DIALOG_TITLE,
SMB_LOGIN_DIALOG_TEXT, p_sys->netbios_name ) )
{ {
psz_login = credential.psz_username; psz_login = credential.psz_username;
psz_password = credential.psz_password; psz_password = credential.psz_password;
psz_domain = credential.psz_realm; psz_domain = credential.psz_realm;
if( smb_connect( p_access, psz_login, psz_password, psz_domain ) if( smb_connect( p_access, psz_login, psz_password, psz_domain )
== VLC_SUCCESS ) == VLC_SUCCESS )
{
free( psz_title );
goto success; goto success;
}
} }
free( psz_title );
msg_Err( p_access, "Unable to login with username = %s, domain = %s", msg_Err( p_access, "Unable to login with username = %s, domain = %s",
p_sys->creds.login, p_sys->creds.domain ); p_sys->creds.login, p_sys->creds.domain );
......
...@@ -48,22 +48,14 @@ ...@@ -48,22 +48,14 @@
#include <vlc_access.h> #include <vlc_access.h>
#include <vlc_input_item.h> #include <vlc_input_item.h>
#include "smb_common.h"
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
static int Open ( vlc_object_t * ); static int Open ( vlc_object_t * );
static void Close( vlc_object_t * ); static void Close( vlc_object_t * );
#define USER_TEXT N_("Username")
#define USER_LONGTEXT N_("Username that will be used for the connection, " \
"if no username is set in the URL.")
#define PASS_TEXT N_("Password")
#define PASS_LONGTEXT N_("Password that will be used for the connection, " \
"if no username or password are set in URL.")
#define DOMAIN_TEXT N_("SMB domain")
#define DOMAIN_LONGTEXT N_("Domain/Workgroup that " \
"will be used for the connection.")
#define SMB_HELP N_("Samba (Windows network shares) input") #define SMB_HELP N_("Samba (Windows network shares) input")
vlc_module_begin () vlc_module_begin ()
set_shortname( "SMB" ) set_shortname( "SMB" )
...@@ -72,12 +64,12 @@ vlc_module_begin () ...@@ -72,12 +64,12 @@ vlc_module_begin ()
set_capability( "access", 0 ) set_capability( "access", 0 )
set_category( CAT_INPUT ) set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_ACCESS ) set_subcategory( SUBCAT_INPUT_ACCESS )
add_string( "smb-user", NULL, USER_TEXT, USER_LONGTEXT, add_string( "smb-user", NULL, SMB_USER_TEXT, SMB_USER_LONGTEXT,
false ) false )
add_password( "smb-pwd", NULL, PASS_TEXT, add_password( "smb-pwd", NULL, SMB_PASS_TEXT,
PASS_LONGTEXT, false ) SMB_PASS_LONGTEXT, false )
add_string( "smb-domain", NULL, DOMAIN_TEXT, add_string( "smb-domain", NULL, SMB_DOMAIN_TEXT,
DOMAIN_LONGTEXT, false ) SMB_DOMAIN_LONGTEXT, false )
add_shortcut( "smb" ) add_shortcut( "smb" )
set_callbacks( Open, Close ) set_callbacks( Open, Close )
vlc_module_end () vlc_module_end ()
......
/*****************************************************************************
* smb_common.h: common strings used by SMB and DSM modules
*****************************************************************************
* Copyright (C) 2016 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#define SMB_USER_TEXT N_("Username")
#define SMB_USER_LONGTEXT N_("Username that will be used for the connection, " \
"if no username is set in the URL.")
#define SMB_PASS_TEXT N_("Password")
#define SMB_PASS_LONGTEXT N_("Password that will be used for the connection, " \
"if no username or password are set in URL.")
#define SMB_DOMAIN_TEXT N_("SMB domain")
#define SMB_DOMAIN_LONGTEXT N_("Domain/Workgroup that " \
"will be used for the connection.")
#define SMB_LOGIN_DIALOG_TITLE N_( "SMB authentication required" )
#define SMB_LOGIN_DIALOG_TEXT N_( "The computer (%s) you are trying to connect " \
"to requires authentication.\nPlease provide a username (and ideally a " \
"domain name using the format DOMAIN;username)\n and a password" )
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