Ejemplo n.º 1
0
        public override bool CanHandleOutputCall(uint prefix, string dst, string number, string lit = null, bool unknownResource = false)
        {
            if ((_State == TlfState.In) || (_State == TlfState.InPrio) ||
                (_State == TlfState.RemoteIn) || (_State == TlfState.Hold))
            {
                return(base.CanHandleOutputCall(prefix, dst, number, lit, unknownResource));
            }

            if (_SipCall == null)
            {
                CfgEnlaceInterno link = new CfgEnlaceInterno();

                CfgRecursoEnlaceInterno rs;
                string literal;
                TlfManager.EncapsuleIaInfo(prefix, dst, out literal, out rs);
                _UnknownResource = unknownResource;
                if (_UnknownResource)
                {
                    rs.NumeroAbonado = number;
                }
                link.Literal = lit; // literal;
                link.ListaRecursos.Add(rs);
                link.Prioridad = Top.Cfg.Priority;
                link.OrigenR2  = Top.Cfg.GetNumeroAbonado(Top.Cfg.MainId, Cd40Cfg.ATS_DST) ?? Top.Cfg.MainId;
                Reset(link);
                //Nuevo inicio de llamada saliente
                //Limpia el código recibido en la llamada anterior
                _LastCode         = 0;
                _NumberWithPrefix = number;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public void To(int id)
        {
            _FirstTransferTryKO      = false;
            _ToTransfer              = null;
            _FromTransferDisplayName = "";
            if (_State == FunctionState.Idle)
            {
                List <TlfPosition> activeCalls = Top.Tlf.ActiveCalls;
                FunctionState      st          = FunctionState.Error;

                if (activeCalls.Count == 1)
                {
                    if ((activeCalls[0].State == TlfState.Set) || (activeCalls[0].State == TlfState.Conf))
                    {
                        TlfPosition tlf = activeCalls[0];
                        TlfPosition to  = Top.Tlf[id];

                        bool transferDone = false;
                        if (Top.Tlf[id].State == TlfState.Idle)
                        {
                            string toUri = to.Uri;
                            if (TlfManager.GetDisplayName(to.Uri) == null && to.Literal.Length > 0)
                            {
                                //Si to.Uri no tiene display name se añade el Literal como display name en la transferencia directa
                                toUri = "\"" + to.Literal + "\" " + to.Uri;
                            }
                            SipAgent.TransferCall(tlf.CallId, -1, toUri, null);

                            transferDone = true;
                        }
                        else if (Top.Tlf[id].State == TlfState.Hold)
                        {
                            SipAgent.HoldCall(activeCalls[0].CallId);
                            System.Threading.Thread.Sleep(50);
                            SipAgent.TransferCall(tlf.CallId, to.CallId, null, "\"" + to.Literal + "\"");
                            transferDone             = true;
                            _ToTransfer              = to;
                            _FromTransferDisplayName = "\"" + tlf.Literal + "\"";
                        }
                        if (transferDone)
                        {
                            _Logger.Debug("Iniciando transferencia...");
                            Top.Sip.TlfTransferStatus += OnTransferStatus;
                            AssociateCall              = tlf;

                            st = FunctionState.Executing;

                            Top.WorkingThread.Enqueue("SetSnmp", delegate()
                            {
                                string snmpString = Top.Cfg.PositionId + "_" + "TRANSFER" + "_" + tlf.Literal;
                                General.SafeLaunchEvent(SetSnmpString, this, new SnmpStringMsg <string, string>(Settings.Default.TlfFacilityOid, snmpString));
                            });
                        }
                    }
                }

                State = st;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fill de data structure for an AID Position
        /// Search for resource in configuration if exist or create from scratch
        /// </summary>
        /// <param name="info"></param>
        /// <param name="inInfo"></param>
        /// <returns></returns>
        public bool FillData(CORESIP_CallInfo info, CORESIP_CallInInfo inInfo)
        {
            CfgEnlaceInterno link    = new CfgEnlaceInterno();
            string           literal = null;

            CfgRecursoEnlaceInterno rs = Top.Cfg.GetResourceFromUri(inInfo.SrcId, inInfo.SrcIp, inInfo.SrcSubId, inInfo.SrcRs);

            if (rs != null)
            {
                _UnknownResource = false;
                //El literal, es el display name que procede del SIP o el numero en su defecto
                TlfManager.ExtractIaInfo(rs, out literal, out _NumberWithPrefix);
                _Logger.Debug("Incoming: {0} {1} {2} lit {3} numbPre {4}", rs.Prefijo, rs.NumeroAbonado, rs.NombreRecurso, literal, _NumberWithPrefix);
            }
            else      // para que funcionen llamadas entrantes no configuradas de transito de un SCV
            {
                rs = Top.Cfg.GetATSResourceFromUri(inInfo.SrcId);
                if (rs != null)
                {
                    _UnknownResource = true;
                    //El literal, es el display name que procede del SIP o el numero en su defecto
                    TlfManager.ExtractIaInfo(rs, out literal, out _NumberWithPrefix);
                }
            }
            if (rs == null)
            //No encuentro configurado el recurso
            {
                rs                = new CfgRecursoEnlaceInterno();
                rs.Prefijo        = Cd40Cfg.UNKNOWN_DST;
                rs.NombreRecurso  = inInfo.SrcId;
                rs.NumeroAbonado  = string.Format("sip:{0}@{1}", inInfo.SrcId, inInfo.SrcIp);
                _UnknownResource  = true;
                _NumberWithPrefix = string.Format("{0:D2}{1}", rs.Prefijo, inInfo.SrcId);
                literal           = inInfo.SrcId;
            }
            if (!PermisoRed((uint)rs.Prefijo, true))
            {
                return(false);
            }


            if (!String.IsNullOrEmpty(inInfo.DisplayName))
            {
                literal = inInfo.DisplayName;
            }

            link.Literal = literal;
            link.ListaRecursos.Add(rs);
            link.Prioridad = Top.Cfg.Priority;
            link.OrigenR2  = Top.Cfg.GetNumeroAbonado(Top.Cfg.MainId, Cd40Cfg.ATS_DST) ?? Top.Cfg.MainId;

            Reset(link);

            return(true);
        }
Ejemplo n.º 4
0
        public TlfIaPosition(uint prefix, string dst)
            : base(1000)
        {
            CfgEnlaceInterno link = new CfgEnlaceInterno();

            CfgRecursoEnlaceInterno rs;
            string literal;

            TlfManager.EncapsuleIaInfo(prefix, dst, out literal, out rs);

            link.Literal = literal;
            link.ListaRecursos.Add(rs);
            link.Prioridad = Top.Cfg.Priority;
            link.OrigenR2  = Top.Cfg.MainId;

            base.Reset(link);
        }
Ejemplo n.º 5
0
        public void To(uint prefix, string dst, string number)
        {
            _FirstTransferTryKO      = false;
            _ToTransfer              = null;
            _FromTransferDisplayName = "";
            if (_State == FunctionState.Idle)
            {
                List <TlfPosition> activeCalls = Top.Tlf.ActiveCalls;
                FunctionState      st          = FunctionState.Error;

                if (activeCalls.Count == 1)
                {
                    TlfPosition tlf = activeCalls[0];

                    if ((tlf.State == TlfState.Set) || (tlf.State == TlfState.Conf))
                    {
                        using (TlfIaPosition to = new TlfIaPosition(prefix, dst))
                        {
                            string toUri = to.Uri;
                            if (TlfManager.GetDisplayName(to.Uri) == null && to.Literal.Length > 0)
                            {
                                //Si to.uri no tiene display name se añade el Literal como display name en la transferencia directa
                                toUri = "\"" + to.Literal + "\" " + to.Uri;
                            }
                            SipAgent.TransferCall(tlf.CallId, -1, toUri, null);

                            Top.Sip.TlfTransferStatus += OnTransferStatus;

                            AssociateCall = tlf;
                            st            = FunctionState.Executing;

                            Top.WorkingThread.Enqueue("SetSnmp", delegate()
                            {
                                string snmpString = Top.Cfg.PositionId + "_" + "TRANSFER" + "_" + tlf.Literal;
                                General.SafeLaunchEvent(SetSnmpString, this, new SnmpStringMsg <string, string>(Settings.Default.TlfFacilityOid, snmpString));
                            });
                        }
                    }
                }

                State = st;
            }
        }
Ejemplo n.º 6
0
        public static void Init()
        {
#if _NEWSTART_
            /** AGL.START Controlado */
            int Contador = 0;
            var NewList  = new List <VoidDelegate>
            {
                delegate()
                {
                    if (string.IsNullOrEmpty(_HostId) || string.IsNullOrEmpty(_SipIp))
                    {
                        List <string> ips = General.GetOperationalV4Ips();

                        if (string.IsNullOrEmpty(_SipIp))
                        {
                            _SipIp = (ips.Count > 0) ? ips[ips.Count - 1] : "127.0.0.1";
                        }

                        if (string.IsNullOrEmpty(_HostId))
                        {
                            _HostId = "PICT" + _SipIp.Substring(_SipIp.LastIndexOf('.') + 1);
                        }
                    }
                },
                delegate(){ InitSnmp(); },
                delegate(){ _WorkingThread = new EventQueue(); },
                delegate(){ _PublisherThread = new EventQueue(); },
                delegate()
                {
#if _AUDIOGENERIC_
                    // switch (Properties.Settings.Default.TipoAudioUsb)
                    switch (HwManager.AudioDeviceType)
                    {
                    case eAudioDeviceTypes.MICRONAS:
                        _HwManager = new MicronasHwManager();
                        break;

                    case eAudioDeviceTypes.CMEDIA:
                        _HwManager = new HidCMediaHwManager();
                        break;

                    case eAudioDeviceTypes.GENERIC_PTT:         // Cascos y Altavoces USB...
                        _HwManager = new HidGenericHwManager(true);
                        break;

                    case eAudioDeviceTypes.GENERIC:             // Cascos sin PTT y Altavoces USB...
                        _HwManager = new HidGenericHwManager(false);
                        break;

                    case eAudioDeviceTypes.SIMUL:               // Simulacion de Tarjetas HID
                        _HwManager = new SimCMediaHwManager();
                        break;

                    default:
                        throw new Exception("Dispositivos de Audio no Conocidos...");
                    }
#else
                    _HwManager = new HwManager();
#endif
                },
                delegate(){ _Registry = new TopRegistry(); },
                delegate(){ _CfgManager = new CfgManager(); },
                delegate(){ _SipManager = new SipManager(); },
                delegate(){ _MixerManager = new MixerManager(); },
                delegate(){ _TlfManager = new TlfManager(); },
                delegate(){ _LcManager = new LcManager(); },
                delegate(){ _RdManager = new RdManager(); },
                delegate(){ _RecorderManager = new RecorderManager(Settings.Default.GLP); },
                delegate(){ _ReplayManager = new ReplayManager(); }
            };
            var nNames = new List <string>
            {
                "_SipIp & _HostId", "InitSnmp", "_WorkingThread", "_PublisherThread", "HwManager",
                "Registry", "CfgManager", "SipManager", "MixedManager", "TlfManager", "LcManager", "RdManager", "RecorderManager", "ReplayManager"
            };
            foreach (VoidDelegate _new in NewList)
            {
                try
                {
                    _new();
                    Contador++;
                }
                catch (Exception x)
                {
                    _Logger.Fatal("Error en Rutina {1} de Creacion TOP: \n{0}", x.Message, nNames[Contador]);
                }
            }
#else
            if (string.IsNullOrEmpty(_HostId) || string.IsNullOrEmpty(_SipIp))
            {
                List <string> ips = General.GetOperationalV4Ips();

                if (string.IsNullOrEmpty(_SipIp))
                {
                    _SipIp = (ips.Count > 0) ? ips[ips.Count - 1] : "127.0.0.1";
                }

                if (string.IsNullOrEmpty(_HostId))
                {
                    _HostId = "PICT" + _SipIp.Substring(_SipIp.LastIndexOf('.') + 1);
                }
            }

            /* Inicializa la gestion SNMP */
            InitSnmp();

            _WorkingThread   = new EventQueue();
            _PublisherThread = new EventQueue();

#if _AUDIOGENERIC_
            /** AGL.CMEDIA */
            switch (Properties.Settings.Default.TipoAudioUsb)
            {
            case 0:         // IAU. Micronas.
                _HwManager = new MicronasHwManger();
                break;

            case 1:         // IAU. CMedia.
                _HwManager = new HidCMediaHwManager();
                break;

            case 2:         // Cascos y Altavoces USB...
                _HwManager = new HidGenericHwManager(true);
                break;

            case 3:         // Cascos sin PTT y Altavoces USB...
                _HwManager = new HidGenericHwManager(true);
                break;

            default:
                throw new Exception("HwManager de tipo Desconocido...");
            }
#else
            _HwManager = new HwManager();
#endif
            /** */

            _Registry     = new TopRegistry();
            _CfgManager   = new CfgManager();
            _SipManager   = new SipManager();
            _MixerManager = new MixerManager();
            _TlfManager   = new TlfManager();
            _LcManager    = new LcManager();
            _RdManager    = new RdManager();

            _RecorderManager = new RecorderManager();
            _ReplayManager   = new ReplayManager();
            /** */
#endif

#if _NEWSTART_
            /** AGL.START Controlado */
            Contador = 0;
            var InitList = new List <VoidDelegate>
            {
                delegate() { if (_HwManager != null)
                             {
                                 _HwManager.Init();
                             }
                },
                delegate() { if (_Registry != null)
                             {
                                 _Registry.Init();
                             }
                },
                delegate() { if (_CfgManager != null)
                             {
                                 _CfgManager.Init();
                             }
                },
                delegate() { if (_SipManager != null)
                             {
                                 _SipManager.Init();
                             }
                },
                delegate() { if (_MixerManager != null)
                             {
                                 _MixerManager.Init();
                             }
                },
                delegate() { if (_TlfManager != null)
                             {
                                 _TlfManager.Init();
                             }
                },
                delegate() { if (_LcManager != null)
                             {
                                 _LcManager.Init();
                             }
                },
                delegate() { if (_RdManager != null)
                             {
                                 _RdManager.Init();
                             }
                },
                delegate() { if (_RecorderManager != null)
                             {
                                 _RecorderManager.Init();
                             }
                }
            };
            var iNames = new List <string> {
                "HwManager", "Registry", "CfgManager", "SipManager", "MixedManager", "TlfManager", "LcManager", "RdManager", "RecorderManager"
            };
            foreach (VoidDelegate init in InitList)
            {
                try
                {
                    init();
                    Contador++;
                }
                catch (Exception x)
                {
                    _Logger.Fatal("Error en Rutina {1} de Inicializacion TOP: \n{0}", x.Message, iNames[Contador]);
                }
            }
#else
            _HwManager.Init();
            _Registry.Init();
            _CfgManager.Init();
            _SipManager.Init();
            _MixerManager.Init(_HwManager.ListaDispositivos);
            _TlfManager.Init();
            _LcManager.Init();
            _RdManager.Init();

            _RecorderManager.Init();
#endif
#if _NICMON_V0_
            /** */
            NetworkIFSupervisor.AutoReset = true;
            NetworkIFSupervisor.Elapsed  += NetworkChange_NetworkAvailabilityChanged;
            NetworkIFSupervisor.Enabled   = Settings.Default.SNMPEnabled == 1;
            _Logger.Info("TIMER NetworkIFSupervisor Arrancado...");
#else
            string jconfig = Properties.Settings.Default.LanTeamConfigs.Count > Properties.Settings.Default.LanTeamType ?
                             Properties.Settings.Default.LanTeamConfigs[Properties.Settings.Default.LanTeamType] : "";
            mon = new NicEventMonitor(jconfig,
                                      (lan, status) =>
            {
                string oid = lan == 0 ? Settings.Default.NetworkIF_1_Oid : Settings.Default.NetworkIF_2_Oid;
                SnmpIntObject.Get(oid).Value = (int)status;

                _Logger.Info(String.Format("Notificado cambio en LAN {0} => {1}", lan, status));
            }, (m, x) =>
            {
                _Logger.Error(String.Format("Error Message: {0}", m));
            } /*, filePath*/);
            _Logger.Info("NetworkIFSupervisor Arrancado...");
#endif

            /** 20170309. AGL. Supervision Cliente NTP. */
            NtpClientSupervisor.AutoReset = true;
            NtpClientSupervisor.Elapsed  += NtpClientSupervisor_tick;
            NtpClientSupervisor.Enabled   = Settings.Default.SNMPEnabled == 1;
            _Logger.Info("TIMER NtpClientSupervisor Arrancado...");
            /*****************/
        }