cec: don't use the pid in dev_lock()/dev_unlock() calls
[deb_libcec.git] / src / cec-config-gui / actions / ShowDeviceInfo.cs
CommitLineData
a42ad439 1using CecSharp;
96fa7764
LOK
2
3namespace CecConfigGui.actions
4{
5 class ShowDeviceInfo : UpdateProcess
6 {
ece1582e 7 public ShowDeviceInfo(CecConfigGUI gui, ref LibCecSharp lib, CecLogicalAddress address)
96fa7764 8 {
ece1582e 9 Gui = gui;
96fa7764
LOK
10 Lib = lib;
11 Address = address;
12 }
13
6d866874
LOK
14 public virtual void ShowDialog(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
15 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
16 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
17 {
18 DeviceInformation di = new DeviceInformation(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
19 Gui.DisplayDialog(di, false);
20 }
21
96fa7764
LOK
22 public override void Process()
23 {
24 CecVendorId vendor = CecVendorId.Unknown;
25 bool isActiveSource = false;
26 ushort physicalAddress = 0xFFFF;
27 CecVersion version = CecVersion.Unknown;
28 CecPowerStatus power = CecPowerStatus.Unknown;
29 string osdName = "unknown";
30 string menuLanguage = "unknown";
31
32 SendEvent(UpdateEventType.StatusText, "Checking device presense...");
33 SendEvent(UpdateEventType.ProgressBar, 10);
34
35 bool devicePresent = Lib.IsActiveDevice(Address);
36 if (devicePresent)
37 {
38 SendEvent(UpdateEventType.StatusText, "Requesting the vendor ID...");
39 SendEvent(UpdateEventType.ProgressBar, 20);
40 vendor = Lib.GetDeviceVendorId(Address);
41
42 SendEvent(UpdateEventType.StatusText, "Requesting active source state...");
43 SendEvent(UpdateEventType.ProgressBar, 30);
44 isActiveSource = Lib.IsActiveSource(Address);
45
46 SendEvent(UpdateEventType.StatusText, "Requesting physical address...");
47 SendEvent(UpdateEventType.ProgressBar, 40);
48 physicalAddress = Lib.GetDevicePhysicalAddress(Address);
49
50 SendEvent(UpdateEventType.StatusText, "Requesting CEC version...");
51 SendEvent(UpdateEventType.ProgressBar, 50);
52 version = Lib.GetDeviceCecVersion(Address);
53
54 SendEvent(UpdateEventType.StatusText, "Requesting power status...");
55 SendEvent(UpdateEventType.ProgressBar, 60);
56 power = Lib.GetDevicePowerStatus(Address);
57
58 SendEvent(UpdateEventType.StatusText, "Requesting OSD name...");
59 SendEvent(UpdateEventType.ProgressBar, 70);
60 osdName = Lib.GetDeviceOSDName(Address);
61
62 SendEvent(UpdateEventType.StatusText, "Requesting menu language...");
63 SendEvent(UpdateEventType.ProgressBar, 80);
64 menuLanguage = Lib.GetDeviceMenuLanguage(Address);
65 }
66
67 SendEvent(UpdateEventType.StatusText, "Showing device information");
68 SendEvent(UpdateEventType.ProgressBar, 90);
ece1582e 69 SendEvent(UpdateEventType.ProcessCompleted, true);
96fa7764 70
6d866874 71 ShowDialog(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
96fa7764
LOK
72
73 SendEvent(UpdateEventType.StatusText, "Ready.");
74 SendEvent(UpdateEventType.ProgressBar, 100);
75 }
76
ece1582e 77 private CecConfigGUI Gui;
96fa7764
LOK
78 private LibCecSharp Lib;
79 private CecLogicalAddress Address;
80 }
81}