don't crash LibCecSharp when receiving an alert with a NULL param (like the connectio...
[deb_libcec.git] / src / LibCecSharp / CecSharpTypes.h
index a0110ad93714e16891db9a76857287d7f9328ab0..78d01a953bc7b26bfbafd0e901f7ef3d110074ab 100644 (file)
@@ -2,7 +2,7 @@
 /*
 * This file is part of the libCEC(R) library.
 *
-* libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
+* libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited.  All rights reserved.
 * libCEC(R) is an original work, containing original code.
 *
 * libCEC(R) is a trademark of Pulse-Eight Limited.
@@ -200,7 +200,27 @@ namespace CecSharp
     /// The device needs servicing. This is set when the firmware can be upgraded, or when a problem with the firmware is detected.
     /// The latest firmware flash tool can be downloaded from http://packages.pulse-eight.net/
     /// </summary>
-    ServiceDevice = 1
+    ServiceDevice = 0,
+    /// <summary>
+    /// The connection to the adapter was lost, probably because the device got unplugged.
+    /// </summary>
+    ConnectionLost,
+    /// <summary>
+    /// No permission from the OS to access the adapter.
+    /// </summary>
+    PermissionError,
+    /// <summary>
+    /// The device is being used by another program.
+    /// </summary>
+    PortBusy,
+    /// <summary>
+    /// The physical address that is assigned to the adapter is already being used.
+    /// </summary>
+    PhysicalAddressError,
+    /// <summary>
+    /// The TV does not respond to polls.
+    /// </summary>
+    TVPollFailed
   };
 
   /// <summary>
@@ -764,23 +784,31 @@ namespace CecSharp
   /// </summary>
   public enum class CecVendorId
   {
-    Samsung   = 0x0000F0,
-    LG        = 0x00E091,
-    Panasonic = 0x008045,
-    Pioneer   = 0x00E036,
-    Onkyo     = 0x0009B0,
-    Yamaha    = 0x00A0DE,
-    Philips   = 0x00903E,
-    Sony      = 0x080046,
-    Toshiba   = 0x000039,
-    Akai      = 0x0020C7,
-    Benq      = 0x8065E9,
-    Daewoo    = 0x009053,
-    Grundig   = 0x00D0D5,
-    Medion    = 0x000CB8,
-    Sharp     = 0x08001F,
-    Vizio     = 0x6B746D,
-    Unknown   = 0
+    Toshiba      = 0x000039,
+    Samsung      = 0x0000F0,
+    Denon        = 0x0005CD,
+    Marantz      = 0x000678,
+    Loewe        = 0x000982,
+    Onkyo        = 0x0009B0,
+    Medion       = 0x000CB8,
+    Toshiba2     = 0x000CE7,
+    PulseEight   = 0x001582,
+    Akai         = 0x0020C7,
+    AOC          = 0x002467,
+    Panasonic    = 0x008045,
+    Philips      = 0x00903E,
+    Daewoo       = 0x009053,
+    Yamaha       = 0x00A0DE,
+    Grundig      = 0x00D0D5,
+    Pioneer      = 0x00E036,
+    LG           = 0x00E091,
+    Sharp        = 0x08001F,
+    Sony         = 0x080046,
+    Broadcom     = 0x18C086,
+    Vizio        = 0x6B746D,
+    Benq         = 0x8065E9,
+    HarmanKardon = 0x9C645E,
+    Unknown      = 0
   };
 
   /// <summary>
@@ -917,6 +945,7 @@ namespace CecSharp
     GivePhysicalAddress           = 0x83,
     /// <summary>
     /// Request language code of the menu language of a device
+    /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
     /// </summary>
     GetMenuLanguage               = 0x91,
     /// <summary>
@@ -925,6 +954,7 @@ namespace CecSharp
     ReportPhysicalAddress         = 0x84,
     /// <summary>
     /// Report the language code of the menu language
+    /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
     /// </summary>
     SetMenuLanguage               = 0x32,
     /// <summary>
@@ -1153,7 +1183,55 @@ namespace CecSharp
     /// <summary>
     /// v1.9.0
     /// </summary>
-    Version1_9_0  = 0x1900
+    Version1_9_0  = 0x1900,
+    /// <summary>
+    /// v2.0.0-pre
+    /// </summary>
+    Version1_99_0  = 0x1990,
+    /// <summary>
+    /// v2.0.0
+    /// </summary>
+    Version2_0_0   = 0x2000,
+    /// <summary>
+    /// v2.0.1
+    /// </summary>
+    Version2_0_1   = 0x2001,
+    /// <summary>
+    /// v2.0.2
+    /// </summary>
+    Version2_0_2   = 0x2002,
+    /// <summary>
+    /// v2.0.3
+    /// </summary>
+    Version2_0_3   = 0x2003,
+    /// <summary>
+    /// v2.0.4
+    /// </summary>
+    Version2_0_4   = 0x2004,
+    /// <summary>
+    /// v2.0.5
+    /// </summary>
+    Version2_0_5   = 0x2005,
+    /// <summary>
+    /// v2.1.0
+    /// </summary>
+    Version2_1_0   = 0x2100,
+    /// <summary>
+    /// v2.1.1
+    /// </summary>
+    Version2_1_1   = 0x2101,
+    /// <summary>
+    /// v2.1.2
+    /// </summary>
+    Version2_1_2   = 0x2102,
+    /// <summary>
+    /// v2.1.3
+    /// </summary>
+    Version2_1_3   = 0x2103,
+    /// <summary>
+    /// The current version
+    /// </summary>
+    CurrentVersion = 0x2103
   };
 
   /// <summary>
@@ -1224,7 +1302,55 @@ namespace CecSharp
     /// <summary>
     /// v1.9.0
     /// </summary>
-    Version1_9_0  = 0x1900
+    Version1_9_0  = 0x1900,
+    /// <summary>
+    /// v2.0.0-pre
+    /// </summary>
+    Version1_99_0  = 0x1990,
+    /// <summary>
+    /// v2.0.0
+    /// </summary>
+    Version2_0_0   = 0x2000,
+    /// <summary>
+    /// v2.0.1
+    /// </summary>
+    Version2_0_1   = 0x2001,
+    /// <summary>
+    /// v2.0.2
+    /// </summary>
+    Version2_0_2   = 0x2002,
+    /// <summary>
+    /// v2.0.3
+    /// </summary>
+    Version2_0_3   = 0x2003,
+    /// <summary>
+    /// v2.0.4
+    /// </summary>
+    Version2_0_4   = 0x2004,
+    /// <summary>
+    /// v2.0.5
+    /// </summary>
+    Version2_0_5   = 0x2005,
+    /// <summary>
+    /// v2.1.0
+    /// </summary>
+    Version2_1_0   = 0x2100,
+    /// <summary>
+    /// v2.1.1
+    /// </summary>
+    Version2_1_1   = 0x2101,
+    /// <summary>
+    /// v2.1.2
+    /// </summary>
+    Version2_1_2   = 0x2102,
+    /// <summary>
+    /// v2.1.3
+    /// </summary>
+    Version2_1_3   = 0x2103,
+    /// <summary>
+    /// The current version
+    /// </summary>
+    CurrentVersion = 0x2103
   };
 
   /// <summary>
@@ -1247,7 +1373,11 @@ namespace CecSharp
     /// <summary>
     /// Raspberry Pi
     /// </summary>
-    RaspberryPi             = 0x100
+    RaspberryPi             = 0x100,
+    /// <summary>
+    /// TDA995x
+    /// </summary>
+    TDA995x                 = 0x200
   };
 
   /// <summary>
@@ -1611,8 +1741,8 @@ namespace CecSharp
       PhysicalAddress     = CEC_DEFAULT_PHYSICAL_ADDRESS;
       BaseDevice          = (CecLogicalAddress)CEC_DEFAULT_BASE_DEVICE;
       HDMIPort            = CEC_DEFAULT_HDMI_PORT;
-      ClientVersion       = CecClientVersion::VersionPre1_5;
-      ServerVersion       = CecServerVersion::VersionPre1_5;
+      ClientVersion       = CecClientVersion::CurrentVersion;
+      ServerVersion       = CecServerVersion::CurrentVersion;
       TvVendor            = CecVendorId::Unknown;
 
       GetSettingsFromROM  = false;
@@ -1720,6 +1850,9 @@ namespace CecSharp
 
       if (ServerVersion >= CecServerVersion::Version1_8_2)
         AdapterType = (CecAdapterType)config.adapterType;
+
+      if (ServerVersion >= CecServerVersion::Version2_1_0)
+        PowerOnScreensaver = config.bPowerOnScreensaver == 1;
     }
 
     /// <summary>
@@ -1733,22 +1866,22 @@ namespace CecSharp
     property CecDeviceTypeList ^  DeviceTypes;
 
     /// <summary>
-    /// True to try to autodetect the physical address, false otherwise
+    /// (read only) set to true by libCEC when the physical address was autodetected
     /// </summary>
     property bool                 AutodetectAddress;
 
     /// <summary>
-    /// The physical address that libCEC uses on the CEC bus
+    /// The physical address of the CEC adapter
     /// </summary>
     property uint16_t             PhysicalAddress;
 
     /// <summary>
-    /// The logical address of the device to which the CEC adapter is connected, only used when PhysicalAddress isn't set
+    /// The logical address of the device to which the adapter is connected. Only used when PhysicalAddress = 0 or when the adapter doesn't support autodetection
     /// </summary>
     property CecLogicalAddress    BaseDevice;
 
     /// <summary>
-    /// The hdmi port number on the device to which the CEC adapter is connected, only used when PhysicalAddress isn't set
+    /// The HDMI port to which the adapter is connected. Only used when iPhysicalAddress = 0 or when the adapter doesn't support autodetection
     /// </summary>
     property uint8_t              HDMIPort;
 
@@ -1763,7 +1896,7 @@ namespace CecSharp
     property CecServerVersion     ServerVersion;
 
     /// <summary>
-    /// Override the vendor ID of the TV when set (for quirks mode)
+    /// Override the vendor ID of the TV. Leave this untouched to autodetect
     /// </summary>
     property CecVendorId          TvVendor;
 
@@ -1774,6 +1907,7 @@ namespace CecSharp
 
     /// <summary>
     /// Use the language setting of the TV in the client application. Must be implemented by the client application.
+    /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
     /// </summary>
     property bool                 UseTVMenuLanguage;
 
@@ -1783,12 +1917,12 @@ namespace CecSharp
     property bool                 ActivateSource;
 
     /// <summary>
-    /// List of devices to send a power on command to when starting the client application
+    /// List of devices to wake when initialising libCEC or when calling PowerOnDevices() without any parameter.
     /// </summary>
     property CecLogicalAddresses ^WakeDevices;
 
     /// <summary>
-    /// List of devices to send a standby command to when exiting the client application
+    /// List of devices to power off when calling StandbyDevices() without any parameter.
     /// </summary>
     property CecLogicalAddresses ^PowerOffDevices;
 
@@ -1821,6 +1955,10 @@ namespace CecSharp
     /// Send standby commands when the client application activates standby mode (S3). Must be implemented by the client application.
     /// </summary>
     property bool                 PowerOffDevicesOnStandby;
+
+    /// <summary>
+    /// Shutdown this PC when the TV is switched off. only used when PowerOffOnStandby = false
+    /// </summary>
     property bool                 ShutdownOnStandby;
 
     /// <summary>
@@ -1830,6 +1968,7 @@ namespace CecSharp
 
     /// <summary>
     /// The language code of the menu language that libCEC reports to other devices.
+    /// 3 character ISO 639-2 country code. see http://http://www.loc.gov/standards/iso639-2/
     /// </summary>
     property System::String ^     DeviceLanguage;
 
@@ -1852,6 +1991,11 @@ namespace CecSharp
     /// The type of adapter that libCEC is connected to.
     /// </summary>
     property CecAdapterType       AdapterType;
+
+       /// <summary>
+    /// True to power on when quitting the screensaver.
+    /// </summary>
+       property bool                 PowerOnScreensaver;
   };
 
   // the callback methods are called by unmanaged code, so we need some delegates for this
@@ -1910,7 +2054,7 @@ namespace CecSharp
   /// <param name="cbParam">Pointer to the callback struct</param>
   /// <param name="message">The log message</param>
   /// <return>1 when handled, 0 otherwise</return>
-  int CecLogMessageCB(void *cbParam, const CEC::cec_log_message &message)
+  int CecLogMessageCB(void *cbParam, const CEC::cec_log_message message)
   {
     if (cbParam)
     {
@@ -1928,7 +2072,7 @@ namespace CecSharp
   /// <param name="cbParam">Pointer to the callback struct</param>
   /// <param name="key">The key press command that libCEC received</param>
   /// <return>1 when handled, 0 otherwise</return>
-  int CecKeyPressCB(void *cbParam, const CEC::cec_keypress &key)
+  int CecKeyPressCB(void *cbParam, const CEC::cec_keypress key)
   {
     if (cbParam)
     {
@@ -1946,7 +2090,7 @@ namespace CecSharp
   /// <param name="cbParam">Pointer to the callback struct</param>
   /// <param name="command">The raw CEC data</param>
   /// <return>1 when handled, 0 otherwise</return>
-  int CecCommandCB(void *cbParam, const CEC::cec_command &command)
+  int CecCommandCB(void *cbParam, const CEC::cec_command command)
   {
     if (cbParam)
     {
@@ -1964,7 +2108,7 @@ namespace CecSharp
   /// <param name="cbParam">Pointer to the callback struct</param>
   /// <param name="config">The new configuration</param>
   /// <return>1 when handled, 0 otherwise</return>
-  int CecConfigCB(void *cbParam, const CEC::libcec_configuration &config)
+  int CecConfigCB(void *cbParam, const CEC::libcec_configuration config)
   {
     if (cbParam)
     {
@@ -1982,7 +2126,7 @@ namespace CecSharp
   /// <param name="cbParam">Pointer to the callback struct</param>
   /// <param name="data">The alert message</param>
   /// <return>1 when handled, 0 otherwise</return>
-  int CecAlertCB(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter &data)
+  int CecAlertCB(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter data)
   {
     if (cbParam)
     {
@@ -2261,7 +2405,7 @@ namespace CecSharp
         CecParameterType newType = (CecParameterType)data.paramType;
         if (newType == CecParameterType::ParameterTypeString)
         {
-          System::String ^ newData = gcnew System::String((const char *)data.paramData, 0, 128);
+          System::String ^ newData = gcnew System::String(data.paramData ? (const char *)data.paramData : "", 0, 128);
           CecParameter ^ newParam = gcnew CecParameter(newType, newData);
           iReturn = m_callbacks->ReceiveAlert((CecAlert)alert, newParam);
         }