[vlc-commits] smb: factorize smb strings used by SMB and DSM modules

Thomas Guillem git at videolan.org
Thu Jan 7 20:12:43 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan  7 18:22:16 2016 +0100| [aa599c4b9d1d5821b071782126aa74901e369950] | committer: Thomas Guillem

smb: factorize smb strings used by SMB and DSM modules

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aa599c4b9d1d5821b071782126aa74901e369950
---

 modules/access/dsm/access.c |   38 ++++++--------------------------------
 modules/access/smb.c        |   22 +++++++---------------
 modules/access/smb_common.h |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
index fbcb563..b91c0df 100644
--- a/modules/access/dsm/access.c
+++ b/modules/access/dsm/access.c
@@ -43,6 +43,7 @@
 #include <netdb.h>
 
 #include <bdsm/bdsm.h>
+#include "../smb_common.h"
 
 /*****************************************************************************
  * Module descriptor
@@ -56,18 +57,6 @@ static void Close( vlc_object_t * );
 
 #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")
 
 vlc_module_begin ()
@@ -77,9 +66,9 @@ vlc_module_begin ()
     set_capability( "access", 20 )
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_ACCESS )
-    add_string( "smb-user", NULL, USER_TEXT, USER_LONGTEXT, false )
-    add_password( "smb-pwd", NULL, PASS_TEXT, PASS_LONGTEXT, false )
-    add_string( "smb-domain", NULL, DOMAIN_TEXT, DOMAIN_LONGTEXT, false )
+    add_string( "smb-user", NULL, SMB_USER_TEXT, SMB_USER_LONGTEXT, false )
+    add_password( "smb-pwd", NULL, SMB_PASS_TEXT, SMB_PASS_LONGTEXT, false )
+    add_string( "smb-domain", NULL, SMB_DOMAIN_TEXT, SMB_DOMAIN_LONGTEXT, false )
     add_shortcut( "smb", "cifs" )
     set_callbacks( Open, Close )
 
@@ -132,14 +121,6 @@ struct access_sys_t
 };
 
 /*****************************************************************************
- * 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
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
@@ -358,24 +339,17 @@ static int login( access_t *p_access )
     if( smb_connect( p_access, psz_login, psz_password, psz_domain )
                      != 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",
-                                   psz_title, BDSM_LOGIN_DIALOG_TEXT ) )
+                                   SMB_LOGIN_DIALOG_TITLE,
+                                   SMB_LOGIN_DIALOG_TEXT, p_sys->netbios_name ) )
         {
             psz_login = credential.psz_username;
             psz_password = credential.psz_password;
             psz_domain = credential.psz_realm;
             if( smb_connect( p_access, psz_login, psz_password, psz_domain )
                              == VLC_SUCCESS )
-            {
-                free( psz_title );
                 goto success;
-            }
         }
-        free( psz_title );
 
         msg_Err( p_access, "Unable to login with username = %s, domain = %s",
                    p_sys->creds.login, p_sys->creds.domain );
diff --git a/modules/access/smb.c b/modules/access/smb.c
index 7f76fa7..42b5750 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -48,22 +48,14 @@
 #include <vlc_access.h>
 #include <vlc_input_item.h>
 
+#include "smb_common.h"
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
 static int  Open ( 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")
 vlc_module_begin ()
     set_shortname( "SMB" )
@@ -72,12 +64,12 @@ vlc_module_begin ()
     set_capability( "access", 0 )
     set_category( CAT_INPUT )
     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 )
-    add_password( "smb-pwd", NULL, PASS_TEXT,
-                  PASS_LONGTEXT, false )
-    add_string( "smb-domain", NULL, DOMAIN_TEXT,
-                DOMAIN_LONGTEXT, false )
+    add_password( "smb-pwd", NULL, SMB_PASS_TEXT,
+                  SMB_PASS_LONGTEXT, false )
+    add_string( "smb-domain", NULL, SMB_DOMAIN_TEXT,
+                SMB_DOMAIN_LONGTEXT, false )
     add_shortcut( "smb" )
     set_callbacks( Open, Close )
 vlc_module_end ()
diff --git a/modules/access/smb_common.h b/modules/access/smb_common.h
new file mode 100644
index 0000000..6bc9ee8
--- /dev/null
+++ b/modules/access/smb_common.h
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * 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" )



More information about the vlc-commits mailing list