Ejemplo n.º 1
0
        private void Added(CpDeviceDiagnosticsReportList aList, CpDeviceDiagnosticsItem aDevice)
        {
            // if we are automatically sending crash data and device is reporting crash data, send the data and don't bother to add it to the list
            if (iPreferences.SendDsCrashData && aDevice.Type == CpDeviceDiagnosticsItem.EDiagnosticsType.eCrash)
            {
                iDiagnosticsList.Send(aDevice.Id);
            }
            else
            {
                lock (iLock)
                {
                    iDeviceListDiagnostics.Add(aDevice);
                    iDeviceListDiagnostics.Sort();
                    int index = iDeviceListDiagnostics.IndexOf(aDevice);

                    AddDevice(aDevice, index);
                    aDevice.Changed += Changed;
                }

                if (NumDiagnosticsChanged != null)
                {
                    NumDiagnosticsChanged(this, EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 2
0
        private void AddDevice(CpDeviceDiagnosticsItem aDevice, int aIndex)
        {
            JsonObject info = new JsonObject();

            info.Add("Index", new JsonValueInt(aIndex));
            info.Add("Id", new JsonValueString(aDevice.Id));
            info.Add("Type", new JsonValueString(aDevice.Type.ToString()));
            info.Add("Description", aDevice.Json);
            Send("DeviceAdded", info);
        }
Ejemplo n.º 3
0
        private void Changed(object sender, EventArgs e)
        {
            lock (iLock)
            {
                CpDeviceDiagnosticsItem d = sender as CpDeviceDiagnosticsItem;

                if (d != null && iDeviceListDiagnostics.Contains(d))
                {
                    Removed(null, d);
                    Added(null, d);
                }
            }
        }
Ejemplo n.º 4
0
        private void Removed(CpDeviceDiagnosticsReportList aList, CpDeviceDiagnosticsItem aDevice)
        {
            lock (iLock)
            {
                Send("DeviceRemoved", aDevice.Id);

                aDevice.Changed -= Changed;
                iDeviceListDiagnostics.Remove(aDevice);
            }

            if (NumDiagnosticsChanged != null)
            {
                NumDiagnosticsChanged(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 5
0
        private void HandleChanged(object sender, EventArgs e)
        {
            CpDeviceDiagnosticsItem device        = sender as CpDeviceDiagnosticsItem;
            CpDeviceDiagnosticsItem removedDevice = null;

            lock (iLock)
            {
                foreach (CpDeviceDiagnosticsItem d in iDeviceListDiagnosticsItem)
                {
                    if (d.Udn == device.Udn)
                    {
                        if (device is CpDeviceDiagnosticsReport && device.Device.CrashDataStatus == CpDeviceDiagnostics.ECrashDataStatus.eAvailable ||
                            device is CpDeviceDiagnosticsProxyCdPlayer && device.Device.CdPlayerProblem ||
                            device is CpDeviceDiagnosticsProxyPreamp && device.Device.PreampProblem)
                        {
                            return;
                        }
                        else
                        {
                            removedDevice = d;
                            d.Changed    -= HandleChanged;

                            iDeviceListDiagnosticsItem.Remove(removedDevice);

                            break;
                        }
                    }
                }
            }

            if (removedDevice != null)
            {
                if (iRemoved != null)
                {
                    iRemoved(this, removedDevice);
                }

                removedDevice.Dispose();
            }
        }