Пример #1
0
 public override void HandlePushNotification(string func, object args)
 {
     try
     {
         if (Application.Current == null)
         {
             return; // not ready yet
         }
         if (func == "ActivityNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 ActivityNotification?.Invoke(this, (Priv10Engine.FwEventArgs)args);
             }));
         }
         else if (func == "ChangeNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 ChangeNotification?.Invoke(this, (Priv10Engine.ChangeArgs)args);
             }));
         }
         else
         {
             throw new Exception("Unknown Notificacion");
         }
     }
     catch (Exception err)
     {
         AppLog.Exception(err);
     }
 }
Пример #2
0
 public void NotifyChange(Guid guid)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         ChangeNotification?.Invoke(this, new ProgramList.ChangeArgs()
         {
             guid = guid
         });
     }));
 }
Пример #3
0
 public override void HandlePushNotification(string func, List <byte[]> args)
 {
     //try
     {
         if (Application.Current == null)
         {
             return; // not ready yet
         }
         if (func == "ActivityNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 ActivityNotification?.Invoke(this, new Priv10Engine.FwEventArgs()
                 {
                     guid     = GetGuid(args[0]),
                     entry    = GetLogEntry(args[1]),
                     progID   = GetProgID(args[2]),
                     services = GetStrList(args[3]),
                     update   = GetBool(args[4])
                 });
             }));
         }
         else if (func == "ChangeNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 ChangeNotification?.Invoke(this, new Priv10Engine.ChangeArgs()
                 {
                     prog   = GetProg(args[0]),
                     rule   = GetRule(args[1]),
                     type   = GetEnum <Priv10Engine.RuleEventType>(args[2]),
                     action = GetEnum <Priv10Engine.RuleFixAction>(args[3])
                 });
             }));
         }
         else if (func == "UpdateNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 UpdateNotification?.Invoke(this, new Priv10Engine.UpdateArgs()
                 {
                     guid = GetGuid(args[0]),
                     type = GetEnum <Priv10Engine.UpdateArgs.Types>(args[1])
                 });
             }));
         }
         else
         {
             throw new Exception("Unknown Notificacion");
         }
     }
     //catch (Exception err)
     //{
     //    AppLog.Exception(err);
     //}
 }
Пример #4
0
        private void SetCallback(ChangeNotificationEventArgs.Notification n)
        {
            Interop.Telephony.NotificationCallback NotificationDelegate = (IntPtr handle, ChangeNotificationEventArgs.Notification notiId, IntPtr data, IntPtr userData) =>
            {
                SlotHandle simHandle = Manager.FindHandle(handle);
                object     notiData  = null;
                switch (notiId)
                {
                case ChangeNotificationEventArgs.Notification.SimStatus:
                {
                    notiData = (Sim.State)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.SimCallForwardingIndicatorState:
                {
                    notiData = ((Marshal.ReadInt32(data) == 0) ? false : true);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkServiceState:
                {
                    notiData = (Network.ServiceState)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkCellid:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkRoamingStatus:
                {
                    notiData = (Marshal.ReadInt32(data) == 0) ? false : true;
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkSignalstrengthLevel:
                {
                    notiData = (Network.Rssi)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkNetworkName:
                {
                    notiData = Marshal.PtrToStringAnsi(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkPsType:
                {
                    notiData = (Network.PsType)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkDefaultDataSubscription:
                {
                    notiData = (Network.DefaultDataSubscription)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkDefaultSubscription:
                {
                    notiData = (Network.DefaultSubscription)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkLac:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkTac:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkSystemId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsId:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsLatitude:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.NetworkBsLongitude:
                {
                    notiData = Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusIdle:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusActive:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusHeld:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusDialing:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusAlerting:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VoiceCallStatusIncoming:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusIdle:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusActive:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusDialing:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusAlerting:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.VideoCallStatusIncoming:
                {
                    notiData = (uint)Marshal.ReadInt32(data);
                    break;
                }

                case ChangeNotificationEventArgs.Notification.CallPreferredVoiceSubscription:
                {
                    notiData = (CallPreferredVoiceSubscription)Marshal.ReadInt32(data);
                    break;
                }
                }

                ChangeNotificationEventArgs args = new ChangeNotificationEventArgs(notiId, notiData);
                ChangeNotification?.Invoke(simHandle, args);
            };
            _changeNotificationList.Add(NotificationDelegate);

            Interop.Telephony.TelephonyError error = Interop.Telephony.TelephonySetNotiCb(_handle, n, NotificationDelegate, IntPtr.Zero);
            if (error != Interop.Telephony.TelephonyError.None)
            {
                Exception e = ExceptionFactory.CreateException(error);
                // Check if error is Invalid Parameter then hide the error
                if (e is ArgumentException)
                {
                    e = new InvalidOperationException("Internal Error Occured");
                }

                throw e;
            }
        }