[vlc-commits] Qt: Support disc drives probing for OS/2

KO Myung-Hun git at videolan.org
Thu Aug 16 16:23:40 CEST 2012


vlc/vlc-2.0 | branch: master | KO Myung-Hun <komh78 at gmail.com> | Sun Aug  5 23:50:53 2012 +0200| [8f0ee34d6a8ef91d6f35e12e9640c53bfb823657] | committer: Jean-Baptiste Kempf

Qt: Support disc drives probing for OS/2

(cherry picked from commit bcc966adc2519d3edcec86a7221bdefcfb4aa22c)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

With some adpation to 2.0 branch

Signed-off-by: KO Myung-Hun <komh at chollian.net>

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

 modules/gui/qt4/components/open_panels.cpp |   45 ++++++++++++++++++++++++++--
 modules/gui/qt4/components/open_panels.hpp |    2 +-
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/components/open_panels.cpp b/modules/gui/qt4/components/open_panels.cpp
index 8dbbe74..ceacf7f 100644
--- a/modules/gui/qt4/components/open_panels.cpp
+++ b/modules/gui/qt4/components/open_panels.cpp
@@ -338,7 +338,7 @@ DiscOpenPanel::DiscOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     ui.deviceCombo->setToolTip( qtr(I_DEVICE_TOOLTIP) );
     ui.deviceCombo->setInsertPolicy( QComboBox::InsertAtTop );
 
-#ifndef WIN32
+#if !defined( WIN32 ) && !defined( __OS2__ )
     char const * const ppsz_discdevices[] = {
         "sr*",
         "sg*",
@@ -404,6 +404,47 @@ void DiscOpenPanel::onFocus()
         SetErrorMode(oldMode);
     }
 }
+#elif defined( __OS2__ ) /* Disc drives probing for OS/2 */
+void DiscOpenPanel::onFocus()
+{
+
+    ui.deviceCombo->clear();
+
+#define IOCTL_CDROMDISK2        0x82
+#define CDROMDISK2_DRIVELETTERS 0x60
+
+    HFILE hcd2;
+    ULONG ulAction;
+    ULONG ulParamLen;
+    ULONG ulData;
+    ULONG ulDataLen;
+
+    if( DosOpen(( PSZ )"CD-ROM2$", ( PHFILE )&hcd2, &ulAction, 0, FILE_NORMAL,
+                OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
+                OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE,
+                NULL ))
+        return;
+
+    if( !DosDevIOCtl( hcd2, IOCTL_CDROMDISK2, CDROMDISK2_DRIVELETTERS,
+                      NULL, 0, &ulParamLen, &ulData, sizeof( ulData ), &ulDataLen ))
+    {
+        char szDriveName[] = "X:\\";
+
+        int count = LOUSHORT( ulData );
+        int drive = HIUSHORT( ulData );
+
+        for( ; count; --count, ++drive )
+        {
+            szDriveName[ 0 ] = 'A' + drive;
+
+            QString name = qfu( szDriveName );
+
+            ui.deviceCombo->addItem( name, name );
+        }
+    }
+
+    DosClose( hcd2 );
+}
 #endif
 
 DiscOpenPanel::~DiscOpenPanel()
@@ -422,7 +463,7 @@ void DiscOpenPanel::clear()
     m_discType = None;
 }
 
-#ifdef WIN32
+#if defined( WIN32 ) || defined( __OS2__ )
     #define setDrive( psz_name ) {\
     int index = ui.deviceCombo->findText( qfu( psz_name ) ); \
     if( index != -1 ) ui.deviceCombo->setCurrentIndex( index );}
diff --git a/modules/gui/qt4/components/open_panels.hpp b/modules/gui/qt4/components/open_panels.hpp
index 51c65ff..5a86ffc 100644
--- a/modules/gui/qt4/components/open_panels.hpp
+++ b/modules/gui/qt4/components/open_panels.hpp
@@ -174,7 +174,7 @@ public:
     virtual ~DiscOpenPanel();
     virtual void clear() ;
     virtual void accept() ;
-#ifdef WIN32
+#if defined( WIN32 ) || defined( __OS2__ )
     void onFocus();
 #endif
 private:



More information about the vlc-commits mailing list