[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH] i18n kioslave smb
From:       Toshitaka Fujioka <toshitaka () kde ! gr ! jp>
Date:       2002-06-14 14:49:15
[Download RAW message or body]

Hello,

The attached a patch is i18n patch for kio-smb.

Sorry, I know only Japanese MS Windows. Therefore I don't know
MS Windows's character encoding of other countries.

Please tell me if UNIX's character encoding is different from MS
Windows's character encoding of your country.
(e.g. Japanese UNIX(Linux. ***BSD, etc...) use eucJP, Japanese
MS Windows use Shift-JIS)

Please review.
-- 
Toshitaka Fujioka
http://www.kde.org                The K Desktop Environment Project
                                                    fujioka@kde.org
http://www.kde.gr.jp               Japan KDE User's Group
                                                    toshitaka@kde.gr.jp

-- A journey of a thousand miles must begin with a single step.  Lao-zi --  


[" " (text/x-diff)]

? kdebase-kioslave-smb-i18n-20020614.diff
Index: kio_smb.h
===================================================================
RCS file: /home/kde/kdebase/kioslave/smb/kio_smb.h,v
retrieving revision 1.16
diff -u -3 -d -p -r1.16 kio_smb.h
--- kio_smb.h	2002/04/21 21:41:45	1.16
+++ kio_smb.h	2002/06/14 14:26:14
@@ -267,12 +267,17 @@ protected:
      *                share    = a share of the server (host)
      *                path     = a path of the share
      * Parameter :    KURL the url to check
-     * Return :       new KURL if its corrected. else the same KURL 
+     * Return :       new KURL if its corrected. else the same KURL
      */
     const KURL checkURL(const KURL& kurl);
 
+    /**
+     * Change from char* (MS Windows's character encoding) to QString
+     */
+    QString toUnicode( char *_str ) const;
+
 public:
-    
+
     //-----------------------------------------------------------------------
     // smbclient authentication callback (note that this is called by  the
     // global ::auth_smbc_get_data() call.
Index: kio_smb_browse.cpp
===================================================================
RCS file: /home/kde/kdebase/kioslave/smb/kio_smb_browse.cpp,v
retrieving revision 1.10
diff -u -3 -d -p -r1.10 kio_smb_browse.cpp
--- kio_smb_browse.cpp	2002/04/19 12:19:35	1.10
+++ kio_smb_browse.cpp	2002/06/14 14:26:14
@@ -1,36 +1,40 @@
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         
+//
 // Project:     SMB kioslave for KDE2
 //
 // File:        kio_smb_browse.cpp
-//                                                                         
-// Abstract:    member function implementations for SMBSlave that deal with 
+//
+// Abstract:    member function implementations for SMBSlave that deal with
 //              SMB browsing
 //
 // Author(s):   Matthew Peterson <mpeterson@caldera.com>
 //
 //---------------------------------------------------------------------------
-//                                                                  
-// Copyright (c) 2000  Caldera Systems, Inc.                        
-//                                                                         
-// This program is free software; you can redistribute it and/or modify it 
+//
+// Copyright (c) 2000  Caldera Systems, Inc.
+//
+// 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 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 General Public License 
+// 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 General Public License
 //     along with this program; see the file COPYING.  If not, please obtain
-//     a copy from http://www.gnu.org/copyleft/gpl.html   
-//                                                                         
+//     a copy from http://www.gnu.org/copyleft/gpl.html
+//
 /////////////////////////////////////////////////////////////////////////////
 #include <pwd.h>
 #include <grp.h>
 
+#include <qtextcodec.h>
+
+#include <kglobal.h>
+
 #include "kio_smb.h"
 #include "kio_smb_internal.h"
 
@@ -270,7 +274,8 @@ void SMBSlave::listDir( const KURL& kurl
          }
          // Set name
          atom.m_uds = KIO::UDS_NAME;
-         atom.m_str = dirp->name;
+         QString dirpName = toUnicode( dirp->name );
+         atom.m_str = dirpName;
          udsentry.append( atom );
          if (((!m_showHiddenShares) && (atom.m_str.right(1)=="$"))
              || (atom.m_str=="$IPC")
@@ -288,7 +293,7 @@ void SMBSlave::listDir( const KURL& kurl
             udsentry.append( atom );
 
             // Set stat information
-            m_current_url.append(dirp->name);
+            m_current_url.append(dirpName);
             browse_stat_path(m_current_url, udsentry);
             m_current_url.truncate();
 
@@ -306,7 +311,7 @@ void SMBSlave::listDir( const KURL& kurl
             if(strcmp(dirp->name,".") &&
                strcmp(dirp->name,".."))
             {
-               m_current_url.append(dirp->name);
+               m_current_url.append(dirpName);
                browse_stat_path(m_current_url, udsentry);
                m_current_url.truncate();
             }
@@ -351,7 +356,7 @@ void SMBSlave::listDir( const KURL& kurl
          }
          else
          {
-            kdDebug(KIO_SMB) << "SMBSlave::listDir SMBC_UNKNOWN :" << dirp->name << endl;
+             kdDebug(KIO_SMB) << "SMBSlave::listDir SMBC_UNKNOWN :" << dirpName << endl;
             // TODO: we don't handle SMBC_IPC_SHARE, SMBC_PRINTER_SHARE
             //       SMBC_LINK, SMBC_COMMS_SHARE
             //SlaveBase::error(ERR_INTERNAL, TEXT_UNSUPPORTED_FILE_TYPE);
@@ -406,4 +411,20 @@ void SMBSlave::listDir( const KURL& kurl
 
    listEntry(udsentry, true);
    finished();
+}
+
+QString SMBSlave::toUnicode( char *_str ) const
+{
+    QString _string = QString::null;
+    if ( KGlobal::locale()->country() == "jp" ) {
+        // Japanese MS Windows's character encoding is Shift_JIS.
+        // Japanese UNIX's (Linux, ***BSD, etc...) character encoding is EUC-JP.
+        QTextCodec *codec = QTextCodec::codecForName( "Shift_JIS" );
+        _string = codec->toUnicode( _str );
+    }
+    else {
+        _string = QString::fromLocal8Bit( _str );
+    }
+
+    return _string;
 }
Index: kio_smb_internal.cpp
===================================================================
RCS file: /home/kde/kdebase/kioslave/smb/kio_smb_internal.cpp,v
retrieving revision 1.7
diff -u -3 -d -p -r1.7 kio_smb_internal.cpp
--- kio_smb_internal.cpp	2002/01/30 19:00:41	1.7
+++ kio_smb_internal.cpp	2002/06/14 14:26:15
@@ -1,37 +1,41 @@
 /////////////////////////////////////////////////////////////////////////////
-//                                                                         
+//
 // Project:     SMB kioslave for KDE2
 //
-// File:        kio_smb_internal.cpp  
-//                                                                         
+// File:        kio_smb_internal.cpp
+//
 // Abstract:    Utility class implementation used by SMBSlave
 //
 // Author(s):   Matthew Peterson <mpeterson@caldera.com>
 //
 //---------------------------------------------------------------------------
-//                                                                  
-// Copyright (c) 2000  Caldera Systems, Inc.                        
-//                                                                         
-// This program is free software; you can redistribute it and/or modify it 
+//
+// Copyright (c) 2000  Caldera Systems, Inc.
+//
+// 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 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 General Public License 
+// 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 General Public License
 //     along with this program; see the file COPYING.  If not, please obtain
-//     a copy from http://www.gnu.org/copyleft/gpl.html   
-//                                                                         
+//     a copy from http://www.gnu.org/copyleft/gpl.html
+//
 /////////////////////////////////////////////////////////////////////////////
 
 #include "kio_smb.h"
 #include "kio_smb_internal.h"
 
+#include <qtextcodec.h>
 
+#include <kglobal.h>
+
+
 //===========================================================================
 // SMBUrl Function Implementation
 //===========================================================================
@@ -53,7 +57,7 @@ SMBUrl::SMBUrl(const KURL& kurl)
 
 
 //-----------------------------------------------------------------------
-SMBUrl& SMBUrl::append(const char* filedir)
+SMBUrl& SMBUrl::append(const QString &filedir)
   // Appends the specified file and dir to this SMBUrl
   // "smb://server/share" --> "smb://server/share/filedir"
   //-----------------------------------------------------------------------
@@ -157,20 +161,20 @@ void SMBUrl::fromKioUrl(const KURL& kurl
 
 }
 
-//-----------------------------------------------------------------------   
+//-----------------------------------------------------------------------
 QCString SMBUrl::toSmbcUrl() const
   // Return a URL that is suitable for libsmbclient
-  //----------------------------------------------------------------------- 
+  //-----------------------------------------------------------------------
 {
-  kdDebug(KIO_SMB) << "toSmbcURL, returning: " << QString(m_smbc_url.local8Bit()) << endl;
-  return m_smbc_url.local8Bit();
+  kdDebug(KIO_SMB) << "toSmbcURL, returning: " << m_smbc_url << endl;
+  return fromUnicode( m_smbc_url );
 
 }
 
-//----------------------------------------------------------------------- 
+//-----------------------------------------------------------------------
 const QString& SMBUrl::toKioUrl() const
   // Return a URL that is suitable for kio framework
-  //----------------------------------------------------------------------- 
+  //-----------------------------------------------------------------------
 {
   return m_kio_url;
 }
@@ -247,7 +251,7 @@ void SMBUrl::truncate()
 QString SMBUrl::getWorkgroup() const
   //-----------------------------------------------------------------------
 {
-  return m_kio_url.mid(m_workgroup_index, m_workgroup_len).local8Bit();
+  return m_kio_url.mid(m_workgroup_index, m_workgroup_len);
 }
 
 
@@ -255,7 +259,7 @@ QString SMBUrl::getWorkgroup() const
 QString SMBUrl::getServerShareDir() const
   //-----------------------------------------------------------------------
 {
-  return m_kio_url.right(m_kio_url.length() - (m_workgroup_index + m_workgroup_len)).local8Bit();
+  return m_kio_url.right(m_kio_url.length() - (m_workgroup_index + m_workgroup_len));
 }
 
 //-----------------------------------------------------------------------
@@ -312,4 +316,21 @@ SMBAuthInfo SMBUrl::getAuthInfo() {
   SMBAuthInfo sa;
   getAuthInfo(sa);
   return sa;
+}
+
+QCString SMBUrl::fromUnicode( const QString &_str ) const
+{
+    QCString _string;
+
+    if ( KGlobal::locale()->country() == "jp" ) {
+        // Japanese MS Windows's character encoding is Shift_JIS.
+        // Japanese UNIX's (Linux, ***BSD, etc...) character encoding is EUC-JP.
+        QTextCodec *codec = QTextCodec::codecForName( "Shift_JIS" );
+        _string = codec->fromUnicode( _str );
+    }
+    else {
+        _string = _str.local8Bit();
+    }
+
+    return _string;
 }
Index: kio_smb_internal.h
===================================================================
RCS file: /home/kde/kdebase/kioslave/smb/kio_smb_internal.h,v
retrieving revision 1.5
diff -u -3 -d -p -r1.5 kio_smb_internal.h
--- kio_smb_internal.h	2002/01/30 19:01:13	1.5
+++ kio_smb_internal.h	2002/06/14 14:26:15
@@ -107,7 +107,7 @@ public:
      * Appends the specified file and dir to this SMBUrl
      * "smb://server/share" --> "smb://server/share/filedir"
      */
-    SMBUrl & append(const char * filedir);
+    SMBUrl & append(const QString &filedir);
 
 
     /**
@@ -182,6 +182,12 @@ public:
      * Return a SMBAuthInfo of url
      */
     SMBAuthInfo getAuthInfo();
+
+private:
+    /**
+     * Change from QString to QCString (MS Windows's character encoding)
+     */
+    QCString fromUnicode( const QString &_str ) const;
 
 };
 

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic