]> git.sesse.net Git - vlc/blob - modules/services_discovery/windrive.c
input: replace ITEM_TYPE_NET by ITEM_TYPE_STREAM
[vlc] / modules / services_discovery / windrive.c
1 /**
2  * @file win_disc.c
3  * @brief List of disc drives for VLC media player for Windows
4  */
5 /*****************************************************************************
6  * Copyright © 2010 Rémi Denis-Courmont
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 static int Open (vlc_object_t *);
32
33 VLC_SD_PROBE_HELPER("disc", "Discs", SD_CAT_DEVICES)
34
35 /*
36  * Module descriptor
37  */
38 vlc_module_begin ()
39     add_submodule ()
40     set_shortname (N_("Discs"))
41     set_description (N_("Discs"))
42     set_category (CAT_PLAYLIST)
43     set_subcategory (SUBCAT_PLAYLIST_SD)
44     set_capability ("services_discovery", 0)
45     set_callbacks (Open, NULL)
46     add_shortcut ("disc")
47
48     VLC_SD_PROBE_SUBMODULE
49
50 vlc_module_end ()
51
52 /**
53  * Probes and initializes.
54  */
55 static int Open (vlc_object_t *obj)
56 {
57     services_discovery_t *sd = (services_discovery_t *)obj;
58
59     LONG drives = GetLogicalDrives ();
60     char mrl[12] = "file:///A:/", name[3] = "A:";
61     TCHAR path[4] = TEXT("A:\\");
62
63     for (char d = 0; d < 26; d++)
64     {
65         input_item_t *item;
66         char letter = 'A' + d;
67
68         /* Does this drive actually exist? */
69         if (!(drives & (1 << d)))
70             continue;
71         /* Is it a disc drive? */
72         path[0] = letter;
73         if (GetDriveType (path) != DRIVE_CDROM)
74             continue;
75
76         mrl[8] = name[0] = letter;
77         item = input_item_NewWithType (mrl, name,
78                                        0, NULL, 0, -1, ITEM_TYPE_DISC);
79         msg_Dbg (sd, "adding %s (%s)", mrl, name);
80         if (item == NULL)
81             break;
82
83         services_discovery_AddItem (sd, item, _("Local drives"));
84     }
85     return VLC_SUCCESS;
86 }