[vlc-devel] [PATCH 2/2] Introduce vlc://shutdown to power off the computer

Ludovic Fauvet etix at videolan.org
Tue Apr 16 20:19:30 CEST 2013


---
 modules/access/idummy.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/modules/access/idummy.c b/modules/access/idummy.c
index c888595..2c6761d 100644
--- a/modules/access/idummy.c
+++ b/modules/access/idummy.c
@@ -34,6 +34,8 @@
 #include <vlc_interface.h>
 #include <vlc_demux.h>
 #include <vlc_charset.h>
+#include <vlc_os.h>
+#include <vlc_dialog.h>
 
 static int OpenDemux( vlc_object_t * );
 static void CloseDemux( vlc_object_t * );
@@ -166,6 +168,24 @@ nop:
         return VLC_SUCCESS;
     }
 
+    /* Check for a "vlc://shutdown" command */
+    if( !strcasecmp( psz_name, "shutdown" ) )
+    {
+        msg_Info( p_demux, "command `shutdown'" );
+        p_demux->pf_demux = DemuxNoOp;
+        p_demux->pf_control = DemuxControl;
+        if( !vlc_power_off() )
+        {
+            const char *msg = N_(
+            "VLC is unable to automatically shutdown your computer "
+            "because you do not have sufficient privileges or because "
+            "your operating system is currently not supported.");
+            dialog_VFatal( p_this, true, _("Unable to shutdown"), vlc_gettext( msg ), NULL );
+        }
+        libvlc_Quit( p_demux->p_libvlc );
+        return VLC_SUCCESS;
+    }
+
     if( !strcasecmp( psz_name, "pause" ) )
     {
         msg_Info( p_demux, "command `pause'" );
-- 
1.7.10.4




More information about the vlc-devel mailing list