]> git.sesse.net Git - vlc/blob - modules/services_discovery/os2drive.c
input: replace ITEM_TYPE_NET by ITEM_TYPE_STREAM
[vlc] / modules / services_discovery / os2drive.c
1 /**
2  * @file os2drive.c
3  * @brief List of disc drives for VLC media player for OS/2
4  */
5 /*****************************************************************************
6  * Copyright (C) 2012 KO Myung-Hun <komh@chollian.net>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26
27 #include <vlc_common.h>
28 #include <vlc_services_discovery.h>
29 #include <vlc_plugin.h>
30
31 #define IOCTL_CDROMDISK2        0x82
32 #define CDROMDISK2_DRIVELETTERS 0x60
33
34 static int Open (vlc_object_t *);
35
36 VLC_SD_PROBE_HELPER("disc", "Discs", SD_CAT_DEVICES)
37
38 /*
39  * Module descriptor
40  */
41 vlc_module_begin ()
42     add_submodule ()
43     set_shortname (N_("Discs"))
44     set_description (N_("Discs"))
45     set_category (CAT_PLAYLIST)
46     set_subcategory (SUBCAT_PLAYLIST_SD)
47     set_capability ("services_discovery", 0)
48     set_callbacks (Open, NULL)
49     add_shortcut ("disc")
50
51     VLC_SD_PROBE_SUBMODULE
52
53 vlc_module_end ()
54
55 /**
56  * Probes and initializes.
57  */
58 static int Open (vlc_object_t *obj)
59 {
60     services_discovery_t *sd = (services_discovery_t *)obj;
61
62     HFILE hcd2;
63     ULONG ulAction;
64     ULONG ulParamLen;
65     ULONG ulData;
66     ULONG ulDataLen;
67     ULONG rc;
68
69     if (DosOpen ((PSZ)"CD-ROM2$", (PHFILE)&hcd2, &ulAction, 0, FILE_NORMAL,
70                  OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
71                  OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL))
72         return VLC_EGENERIC;
73
74     rc = DosDevIOCtl (hcd2, IOCTL_CDROMDISK2, CDROMDISK2_DRIVELETTERS,
75                       NULL, 0, &ulParamLen, &ulData, sizeof(ulData), &ulDataLen);
76     if (!rc)
77     {
78         char mrl[] = "file:///A:/", name[] = "A:";
79
80         int count = LOUSHORT(ulData);
81         int drive = HIUSHORT(ulData);
82
83         input_item_t *item;
84         char          letter;
85
86         for (; count; --count, ++drive)
87         {
88             letter = 'A' + drive;
89
90             mrl[8] = name[0] = letter;
91             item = input_item_NewWithType (mrl, name, 0, NULL, 0, -1, ITEM_TYPE_DISC);
92             msg_Dbg (sd, "adding %s (%s)", mrl, name);
93             if (item == NULL)
94                 break;
95
96             services_discovery_AddItem (sd, item, _("Local drives"));
97         }
98     }
99
100     DosClose (hcd2);
101
102     return rc ? VLC_EGENERIC : VLC_SUCCESS;
103 }