cec: display an alert message in case the connection couldn't be opened because of...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 14 May 2012 13:57:43 +0000 (15:57 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 14 May 2012 13:57:43 +0000 (15:57 +0200)
include/cectypes.h
src/lib/adapter/USBCECAdapterCommunication.cpp

index a8ff6f604872f77bf96a5458fb3ff005eb8ed839..77b9927d3dca42823779cd844c95339cee2bfb29 100644 (file)
@@ -1090,7 +1090,9 @@ typedef struct cec_logical_addresses
 typedef enum libcec_alert
 {
   CEC_ALERT_SERVICE_DEVICE,
-  CEC_ALERT_CONNECTION_LOST
+  CEC_ALERT_CONNECTION_LOST,
+  CEC_ALERT_PERMISSION_ERROR,
+  CEC_ALERT_PORT_BUSY
 } libcec_alert;
 
 typedef enum libcec_parameter_type
index a68cfd3732aa9689dff517069d278c0374f96ad2..08ae62c701e681250a4948d59b16ccd908269ddc 100644 (file)
@@ -122,6 +122,21 @@ bool CUSBCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONN
     if (!bConnectionOpened)
     {
       LIB_CEC->AddLog(CEC_LOG_ERROR, strError);
+
+      if (m_port->GetErrorNumber() == EACCES)
+      {
+        libcec_parameter param;
+        param.paramType = CEC_PARAMETER_TYPE_STRING;
+        param.paramData = (void*)"No permission to open the device";
+        LIB_CEC->Alert(CEC_ALERT_PERMISSION_ERROR, param);
+      }
+      else if (m_port->GetErrorNumber() == EBUSY)
+      {
+        libcec_parameter param;
+        param.paramType = CEC_PARAMETER_TYPE_STRING;
+        param.paramData = (void*)"The serial port is busy. Only one program can access the device directly.";
+        LIB_CEC->Alert(CEC_ALERT_PORT_BUSY, param);
+      }
       return false;
     }