public void OnForwardingStatusUpdate(ForwardStatusStore fs)
        {
            foreach (PhoneNumber pn in PhoneNumbers)
            {
                if (pn.GetExtension() == fs.Extension)
                {
                    App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                    {
                        if (App.Current == null)
                        {
                            return;
                        }

                        MainWindow MainObject = (MainWindow)App.Current.MainWindow;

                        if (MainObject == null)
                        {
                            return;
                        }

                        pn.OnForwardingChange(fs);
                    }));
                }
            }
        }
Exemple #2
0
        public void PhoneNumberUpdateForwarding(string Extension, CallForwardingTypes Type, long VoiceMail, long Destination)
        {
            //find the store for this extension
            ForwardStatusStore fw = GetStatusStore(Extension);

            //update it
            fw.ForwardType        = Type;
            fw.VoiceMailForward   = VoiceMail;
            fw.DestinationForward = Destination;
            fw.PacketStatus       = ServerPacketStatus.PacketReceived;

            Globals.Logger.LogString(LogManager.LogLevels.LogFlagCallForwarding, "Server : Set forwarding for extension " + Extension + " to Type " + Type + " to destination " + Destination);
            Globals.ExtensionManager.OnForwardingStatusUpdate(fw);
        }
Exemple #3
0
        /// <summary>
        /// Internal : check if we should make the query, issue a query to the server
        /// </summary>
        /// <param name="Extension"></param>
        private void PhoneNumberQueryForwarding(string Extension)
        {
            ForwardStatusStore fw = GetStatusStore(Extension);

            if (fw.ShouldQueryForwardStatus() == true)
            {
                fw.LastQueryStamp = Environment.TickCount; // if there is no reply comming for this extension, we should retry a bit later
                fw.PacketStatus   = ServerPacketStatus.PacketSent;
                if (Globals.ConnectionManager != null)
                {
                    NetworkClient nc = Globals.ConnectionManager.GetCLient(fw.ServerIPAndPort);
                    nc.PacketBuilder.QueryDeviceForwarding(Extension.ToString());
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// set call forwarding for an extension( phone number ). This is a non blocking call. Result is not guaranteed. Callback function will set the state of extansions
        /// </summary>
        /// <param name="Extension"></param>
        /// <param name="Type"></param>
        /// <param name="VoiceMail"></param>
        /// <param name="Destination"></param>
        public void CallForwardingSet(string Extension, CallForwardingTypes Type, long VoiceMail, long Destination)
        {
            ForwardStatusStore fw = GetStatusStore(Extension);
            short Enable          = 0;

            if (Type != CallForwardingTypes.CallForwardNone)
            {
                Enable = 1;
            }
            Globals.Logger.LogString(LogManager.LogLevels.LogFlagCallForwarding, "Client : Set forwarding for extension " + Extension + " to Type " + Type + " to destination " + Destination);
            if (Globals.ConnectionManager != null)
            {
                NetworkClient nc = Globals.ConnectionManager.GetCLient(fw.ServerIPAndPort);
                nc.PacketBuilder.SetFeatureForwarding(Extension.ToString(), Destination.ToString(), 0, Enable);
            }
        }
Exemple #5
0
        /// <summary>
        /// Get the store for a specific extension ( phone number )
        /// </summary>
        /// <param name="Extension"></param>
        /// <returns></returns>
        private ForwardStatusStore GetStatusStore(string Extension)
        {
            foreach (ForwardStatusStore it in Forwards)
            {
                if (it.Extension == Extension)
                {
                    return(it);
                }
            }

            //if we got here, than we need to create a new store
            ForwardStatusStore fw = new ForwardStatusStore(Extension);

            Forwards.Add(fw);

            return(fw);
        }
Exemple #6
0
        /// <summary>
        /// When a new UI extension is created, this function gets called. If we already know the forward status than we will initiate a callback to update forward status for this extension
        /// </summary>
        /// <param name="NewNumber"></param>
        public void OnExtensionCreate(PhoneNumber NewNumber)
        {
            //if we are still in the loading process, delay this query for now. We will auto query the state as soon as we are done loading
            if (Globals.ConnectionManager.HasAnyActiveConnection() == false || Globals.IndexCardsLoaded == false)
            {
                return;
            }

            // skip dummy placeholder extensions
            if (NewNumber.GetExtension().Length == 0)
            {
                return;
            }

            //if we already have a status queried for this extension than we can return the status directly. Else we will isue an async callback when server replies
            if (NewNumber.IsSubscriberRange() == false)
            {
                ForwardStatusStore fw = GetStatusStore(NewNumber.GetExtension());
                if (fw.ShouldQueryForwardStatus() == false)
                {
                    NewNumber.OnForwardingChange(fw);
                }
            }
        }