Ejemplo n.º 1
0
        public static LinearGradientBrush GetStatusBrushGradient(PhoneStatusCodes status)
        {
            if (Colors == null)
            {
                Init();
            }
            if (status == PhoneStatusCodes.PHONE_EXTERNAL)
            {
                status = PhoneStatusCodes.Busy;
            }
            if (status > PhoneStatusCodes.NumberOfStatusCodes)
            {
                status = PhoneStatusCodes.PHONE_DOESNOT;
            }

            LinearGradientBrush GradientColor = new LinearGradientBrush();

            GradientColor.StartPoint = new Point(0, 0);
            GradientColor.EndPoint   = new Point(1, 1);

            GradientStop StartGS = new GradientStop();

            StartGS.Color  = Colors[(int)status].Color;
            StartGS.Offset = 0.0;
            GradientColor.GradientStops.Add(StartGS);

            GradientStop EndGS = new GradientStop();

            EndGS.Color  = Backend.StyleManager.GetGradientFadeToColor();
            EndGS.Offset = 1.0;
            GradientColor.GradientStops.Add(EndGS);

            return(GradientColor);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the color of a specific status
 /// </summary>
 /// <param name="status"></param>
 /// <returns></returns>
 public static SolidColorBrush GetStatusColor(PhoneStatusCodes status)
 {
     if (Colors == null)
     {
         Init();
     }
     return(Colors[(int)status]);
 }
Ejemplo n.º 3
0
 private void SetRangeStatus(int Index, PhoneStatusCodes NewStatus)
 {
     if (Index < 0 || Index > 9)
     {
         return;
     }
     if (NewStatus < PhoneStatusCodes.NumberOfStatusCodes)
     {
         if (Index == 0)
         {
             this.StatusText0.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 1)
         {
             this.StatusText1.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 2)
         {
             this.StatusText2.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 3)
         {
             this.StatusText3.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 4)
         {
             this.StatusText4.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 5)
         {
             this.StatusText5.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 6)
         {
             this.StatusText6.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 7)
         {
             this.StatusText7.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 8)
         {
             this.StatusText8.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
         else if (Index == 9)
         {
             this.StatusText9.Background = StatusColorEditor.GetStatusBrush(NewStatus);
         }
     }
     //unknown status ? Bail out
     else
     {
         return;
     }
     CurrentStatusRange[Index] = NewStatus;
 }
Ejemplo n.º 4
0
 public DSWinConnectionManager()
 {
     System.Windows.Interop.HwndSource.FromHwnd(new System.Windows.Interop.WindowInteropHelper(System.Windows.Application.Current.MainWindow).Handle)?.AddHook(this.WndProc);
     ExpectedBytes = 0;
     RecvedBytes   = 0;
     BytesReceived = new char[MaxPhoneNumberLength];
     PhoneStatus   = PhoneStatusCodes.PHONE_EXTERNAL; // invalid status
     UpdateTimer   = new System.Threading.Timer(PeriodicUpdate, null, 1000, 500);
     Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "Created DSWin message listener");
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Change the status of this phone.It will have different color
 /// </summary>
 /// <param name="NewStatus"></param>
 public void SetStatus(PhoneStatusCodes NewStatus)
 {
     if (NewStatus < PhoneStatusCodes.NumberOfStatusCodes)
     {
         this.StatusText.Background = StatusColorEditor.GetStatusColor(NewStatus);
     }
     //unknown status ? Bail out
     else
     {
         return;
     }
     CurrentStatus = NewStatus;
 }
Ejemplo n.º 6
0
        /*
         *      public void DeleteSave(string IndexCardName)
         *      {
         *          //we never got saved or loaded, there is no need to delete
         *          if (ConfigIndex < 0)
         *              return;
         *          Globals.Config.RemoveConfig(IndexCardName, "Phone #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Name #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Number #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Email #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Comment #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Position x #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Position y #" + ConfigIndex);
         *          Globals.Config.RemoveConfig(IndexCardName, "Font #" + ConfigIndex);
         *      }*/

        /// <summary>
        /// Change the status of this phone.It will have different color
        /// </summary>
        /// <param name="NewStatus"></param>
        public void SetStatus(PhoneStatusCodes NewStatus, string pExtension = "")
        {
            //unknown status ? Bail out
            if (NewStatus >= PhoneStatusCodes.NumberOfStatusCodes2)
            {
                return;
            }
            if (GetExtension() == "" && NewStatus == PhoneStatusCodes.PHONE_DOESNOT)
            {
                return;
            }
            //ranges and non ranges are handled differently
            if (IsRange == false)
            {
                CurrentStatus = NewStatus;
                if (StyleManager.PhoneNumberHasGradientBackground() == true)
                {
                    this.CellBorder.Background = StatusColorEditor.GetStatusBrushGradient(NewStatus);
                }
                else
                {
                    this.CellBorder.Background = StatusColorEditor.GetStatusBrush(NewStatus);
                }
                UpdateTooltipContent();
                if (NewStatus == PhoneStatusCodes.PHONE_EXTERNAL)
                {
                    img_External.Visibility = Visibility.Visible;
                }
                else
                {
                    img_External.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                if (pExtension != "")
                {
                    int LastDigit = pExtension[pExtension.Length - 1] - '0';
                    SetRangeStatus(LastDigit, NewStatus);
                }
                else
                {
                    //refresh colors
                    for (int i = 0; i < 9; i++)
                    {
                        SetRangeStatus(i, CurrentStatusRange[i]);
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public void OnConnectionLost()
 {
     LastQueryStamp          = 0; // we never queried this value
     XrefId                  = 0;
     LastStatusUpdateStamp   = 0;
     PacketStatus            = ServerPacketStatus.PacketNotSent;
     LastStatus              = PhoneStatusCodes.PHONE_DOESNOT;
     MonitorPacketStatus     = ServerPacketStatus.PacketNotSent;
     LastMonitorQueryStamp   = 0;
     CallId                  = 0;
     CallPartner             = 0;
     CallIdConsultation      = 0;
     CallPartnerConsultation = 0;
 }
Ejemplo n.º 8
0
        public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_USER = 0x0400;

            if (msg == WM_USER + 98)
            {
                if (ExpectedBytes == RecvedBytes && wParam.ToInt32() == 0)
                {
                    ExpectedBytes = lParam.ToInt32() * 4;
                    RecvedBytes   = 0;
                    for (int i = 0; i < MaxPhoneNumberLength; i++)
                    {
                        BytesReceived[i] = (char)0;
                    }
                }
                else if (RecvedBytes < MaxPhoneNumberLength)
                {
                    int NumberChars = lParam.ToInt32();
                    BytesReceived[RecvedBytes++] = (char)(NumberChars & 0xFF);
                    BytesReceived[RecvedBytes++] = (char)((NumberChars >> 8) & 0xFF);
                    BytesReceived[RecvedBytes++] = (char)((NumberChars >> 16) & 0xFF);
                    BytesReceived[RecvedBytes++] = (char)((NumberChars >> 24) & 0xFF);
                }
                if (RecvedBytes == ExpectedBytes)
                {
                    //remove old monitor
                    Globals.ExtensionManager.RemovePhantomExtension(PrevMonitoredExtension);
                    //convert the extension into a full number
                    string FullNumber = "";
                    for (int i = 0; i < MaxPhoneNumberLength; i++)
                    {
                        if (BytesReceived[i] == 0)
                        {
                            break;
                        }
                        FullNumber = FullNumber + BytesReceived[i];
                    }
                    //create a dummy ( invisible ) phone number to monitor and update status of it
                    Globals.ExtensionManager.CreatePhantomExtension(null, null, FullNumber);
                    //remmber what we should not monitor next time
                    PrevMonitoredExtension = FullNumber;
                    PhoneStatus            = PhoneStatusCodes.PHONE_EXTERNAL; // invalid status
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "DSWin selection changed to : " + PrevMonitoredExtension);
                }
                return(IntPtr.Zero);
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 9
0
        public static Color GetStatusColor(PhoneStatusCodes status, bool AsGradient = true)
        {
            if (Colors == null)
            {
                Init();
            }
            if (status == PhoneStatusCodes.PHONE_EXTERNAL)
            {
                status = PhoneStatusCodes.Busy;
            }
            if (status > PhoneStatusCodes.NumberOfStatusCodes)
            {
                status = PhoneStatusCodes.PHONE_DOESNOT;
            }

            return(Colors[(int)status].Color);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Get the color of a specific status
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        public static Brush GetStatusBrush(PhoneStatusCodes status)
        {
            if (Colors == null)
            {
                Init();
            }
            if (status == PhoneStatusCodes.PHONE_EXTERNAL)
            {
                status = PhoneStatusCodes.Busy;
            }
            if (status > PhoneStatusCodes.NumberOfStatusCodes)
            {
                status = PhoneStatusCodes.PHONE_DOESNOT;
            }

            return(Colors[(int)status]);
        }
Ejemplo n.º 11
0
 private void PeriodicUpdate(object source)
 {
     if (PrevMonitoredExtension == "")
     {
         return;
     }
     if (Monitor.TryEnter(this))
     {
         //get the monitored extension
         PhoneNumber pn = Globals.ExtensionManager.PhoneNumberGetFirst(null, null, PrevMonitoredExtension);
         //check if status changed
         if (pn != null && pn.GetStatus() != PhoneStatus)
         {
             PhoneStatus = pn.GetStatus();
             //create a window and show the new status
             System.Windows.Application.Current.Dispatcher.Invoke((Action) delegate
             {
                 new NotificationTaskBar(PrevMonitoredExtension, PhoneStatus).Show();
             });
         }
         Monitor.Exit(this);
     }
 }
Ejemplo n.º 12
0
        public PhoneNumber()
        {
            InitializeComponent();

            CurrentStatusRange = new PhoneStatusCodes[10];
            HiddenTooltip      = this.StatusText.ToolTip;

            //set some value to see how it looks like
            this.StatusText.Content        = "";
            this.StatusRange.Visibility    = Visibility.Collapsed;
            ExtensionComponentHolder.Width = new GridLength(1, GridUnitType.Star);
            RangeComponentSeparator.Width  = new GridLength(0, GridUnitType.Pixel);
            RangeComponentHolder.Width     = new GridLength(0, GridUnitType.Pixel);
            this.img_Forward.Visibility    = Visibility.Collapsed;
            this.img_External.Visibility   = Visibility.Collapsed;

            //            SetStatus(PhoneStatusCodes.PHONE_DOESNOT);    //default status
            CurrentStatus = PhoneStatusCodes.NumberOfStatusCodes2; //invalid state
            //remove border if there is no border

            //hide tooltip until we populate subscriber with data
            this.StatusText.ToolTip = null;

            IsRange = false;

            //data has not yet been loaded, this will init only a dummy look
            //UpdateContextMenu();

            // prepare the UI for the case when the forwarding query reply will take a lot of time
            OnForwardingChange(null);

            //implementation of drag and drop
            MouseLeave += new MouseEventHandler(OnMouseLeave);
            MouseEnter += new MouseEventHandler(OnMouseEnter);
            MouseUp    += new MouseButtonEventHandler(OnMouseUp);
        }
Ejemplo n.º 13
0
        public static PhoneStatusCodes PhoneStatusCodeTranslate(long ServerSideState)
        {
            PhoneStatusCodes code = PhoneStatusCodes.NumberOfStatusCodes;

            if (ServerSideState == ServerSidePhoneStatusCodes.ZS_RUF)
            {
                code = PhoneStatusCodes.Ringing;
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_GESPRAECH)
            {
                code = PhoneStatusCodes.Busy;
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_RUHE)
            {
                code = PhoneStatusCodes.Idle;
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_WAHLAUFNAHME)
            {
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_BLOCKIERT ||
                     ServerSideState == ServerSidePhoneStatusCodes.ZS_KONFERENZ ||
                     ServerSideState == ServerSidePhoneStatusCodes.ZS_BESETZT)
            {
                // m_nState = (m_nState & PHONE_UMLEITUNG) | PHONE_BESETZT;
                code = PhoneStatusCodes.Busy;
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_BLOCKIERT)
            {
                // m_nState = (m_nState & PHONE_UMLEITUNG) | PHONE_AUSSER_BETRIEB;
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_WARTE)
            {
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_DOESNOT)
            {
                code = PhoneStatusCodes.PHONE_DOESNOT;
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_DOOS)
            {
                code = PhoneStatusCodes.OutOfService;
            }
            else if (ServerSideState == 0xF0FF)
            {
                //remove forwarding
            }
            else if (ServerSideState == 0x0FFF)
            {
                //remove forwarding to external
            }
            else if (ServerSideState == 11111)
            {
                // #define PHONE_RUF				0x0002//Ringing
            }
            else if (ServerSideState == 1111111)
            {
                // #define PHONE_UMLEITUNG			0x0100//Forward
            }
            else if (ServerSideState == 11111111)
            {
                // #define PHONE_EXTERNAL			0x1000//External call
            }
            else if (ServerSideState == ServerSidePhoneStatusCodes.ZS_EXTERNAL)
            {
                code = PhoneStatusCodes.PHONE_EXTERNAL;
            }

            return(code);
        }
Ejemplo n.º 14
0
        public void InterpretMessage(byte [] ReceivedBytes2)
        {
            BLFWinNoEnvelopHeader pkt = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <BLFWinNoEnvelopHeader>(ReceivedBytes2);

            switch (pkt.Type)
            {
            case PacketTypes.ON_CONNECTED:
            {
                //update UI and say that we are online
                if (App.Current != null && App.Current.MainWindow != null)
                {
                    (App.Current.MainWindow as MainWindow).OnServerConnectionChanged(true);
                }
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, "CBLF_w32Dlg::ConnectionOpened");
            }
            break;

            case PacketTypes.ON_DISCONNECTED:
            {
                //update UI and say that we are offline
                if (App.Current != null && App.Current.MainWindow != null)
                {
                    (App.Current.MainWindow as MainWindow).OnServerConnectionChanged(false);
                }
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, "CBLF_w32Dlg::ConnectionClosed");
            }
            break;

            case PacketTypes.SYSTEMSTATUSSERVICEREQUEST:
            {
                SystemStatusServiceRequestStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <SystemStatusServiceRequestStr>(ReceivedBytes2);
                SystemStatusCodes             ssc  = (SystemStatusCodes)(pkt2.Type);
                if (ssc == SystemStatusCodes.SystemStatus_Search_DeadClient)
                {
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status System_Status_DUMMY: " + pkt2.Type + " SystemStatus_Search_DeadClient ");
                }
                else if ((ssc == SystemStatusCodes.SystemStatus_normal || ssc == SystemStatusCodes.SystemStatus_initializing))
                {
                    //Write the problem to the log
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status System_Status_OK: " + pkt2.Type + " SystemStatus_normal/SystemStatus_initializing ");

                    //notify connection manager that the server is up and running
//                            Globals.ConnectionManager.OnHeartbeatReceived();
                    Globals.ExtensionManager.OnSystemStatusOk(nclient.ServerIPAndPort);         // we presume that all monitors function correctly and no need to panic for lack of updates

//                            m_bDisconnected_From_Callbridge = FALSE;

                    //Hide the server problem window
                    //Hide the server OK window
                    //Hide the Connection problem problem window
                    //Hide the Callbridge  OK window
                    //Hide the Callbridge problem window
                    //Start a timer , but this timer will not work if the connection is ok,because
                    //we killing it before the running
                    //Starting a timer to reconnect if needed
                }

                else if (ssc == SystemStatusCodes.SystemStatus_disabled)
                {
                    //Write the problem to the log
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status System_Status_Disabled: " + pkt2.Type);
                    //Open the switch problem dialog
                    //update status bar
                }
                else
                {
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SYSTEMSTATUSSERVICEREQUEST System Status:" + pkt2.Type);
                }
                //                        m_pWnd->SystemStatusService(pStruct->Type);
                break;
            }

            case PacketTypes.UNIVERSALERRORRESPONSE:
            {
                UniversalErrorResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <UniversalErrorResponseStr>(ReceivedBytes2);
                unsafe {
                    string device        = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string errorCategory = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.ErrorCategory);
                    string errorValue    = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.ErrorValue);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : UNIVERSALERRORRESPONSE : device=" + device + ", ErrCat=" + errorCategory + ", Err=" + errorValue);
                    //make sure we set the status of this device
                    if (errorCategory == "Operation" && errorValue == "invalidDeviceID")
                    {
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodes.PHONE_DOESNOT);
                    }
                    else if (errorCategory == "System Resource Availability" && errorValue == "deviceOutOfService")
                    {
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodes.OutOfService);
                    }
                    //                            m_pWnd->UniversalErrorResponse(device, errorCategory, errorValue);
                }
                break;
            }

            case PacketTypes.SETFEATUREFORWARDINGRESPONSE:     //nothing to do here
            {
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SETFEATUREFORWARDINGRESPONSE");
                //?! missing in CSink
                break;
            }

            case PacketTypes.QUERYDEVICEFORWARDINGRESPONSE:     //nothing to do here
            {
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : QUERYDEVICEFORWARDINGRESPONSE");
                //?! missing in CSink
                break;
            }

            case PacketTypes.CONSULTATIONCALLRESPONSE:
            {
                ConsultationCallResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <ConsultationCallResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device   = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string callId   = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CallID);
                    string deviceId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DeviceID);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : CONSULTATIONCALLRESPONSE Device=" + device + " CallId=" + callId + " DeviceId=" + deviceId);

                    //                            m_pWnd->ConsultationCallResponse(device, callId, deviceId);
                    /// !!!!!!!!!!! not finished
                    if (Globals.Config.GetConfig("Options", "Optiset", "NO") == "YES")
                    {
                        string OptiSet = Globals.Config.GetConfig("Options", "OptisetExtension", "");
                        //get the extension only from a full phone number
                        string OptisetExtenstion = PhoneNumber.GetExtensionFromFullNumberStr(OptiSet);
                        long   CallId            = Globals.ExtensionManager.GetCallId(nclient.ServerIPAndPort, null, OptisetExtenstion);
                        if (OptisetExtenstion == device)
                        {
                            if (nclient != null)
                            {
                                nclient.PacketBuilder.TransferCall(OptisetExtenstion, OptisetExtenstion, CallId.ToString(), callId);
                            }
                        }
                    }
                }
                break;
            }

            case PacketTypes.TRANSFERCALLRESPONSE:     //nothing to do here
            {
                TransferCallResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <TransferCallResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : TRANSFERCALLRESPONSE for device " + device);
//                            Globals.AppVars.m_bConsultationCall = false;
//                            Globals.AppVars.m_strDeviceIDTemp = "";
//                            Globals.AppVars.m_strCallIDTemp = "";				// BP-3.0.9.0-050816: Feature 'CallID as string': Modified: long m_lCallIDTemp -> CString m_strCallIDTemp
                    //                            m_pWnd->TransferCallResponse(device);
                }
                break;
            }

            case PacketTypes.SINGLESTEPTRANSFERRESPONSE:     //nothing to do here
            {
                SingleStepTransferResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <SingleStepTransferResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SINGLESTEPTRANSFERRESPONSE " + device);
                    //                            m_pWnd->SingleStepTransferResponse(device);
                }
                break;
            }

            case PacketTypes.MAKECALLRESPONSE:     //nothing to do here
            {
                MakeCallResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MakeCallResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MAKECALLRESPONSE for device " + device);
                    //                            m_pWnd->MakeCallResponse(device);
                }
                break;
            }

            case PacketTypes.UPDATEDEVICESTATE:     //nothing to do here
            {
                UpdateDeviceStateStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <UpdateDeviceStateStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : UPDATEDEVICESTATE " + device + " " + pkt2.State.ToString());
                    PhoneStatusCodes code = PhoneStatusCodeTranslateMonitor(pkt2.State);
                    if (code < PhoneStatusCodes.NumberOfStatusCodes)
                    {
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, code);
                    }
                    //mark this extension as valid on this server. Some extensions might exist on more than 1 server
                    if (code == PhoneStatusCodes.Busy || code == PhoneStatusCodes.Idle || code == PhoneStatusCodes.PHONE_EXTERNAL || code == PhoneStatusCodes.Ringing)
                    {
                        PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device);
                    }
                    //                            m_pWnd->UpdateDeviceState(device,pkt2.state);
                }
                break;
            }

            case PacketTypes.ESTABLISHEDEVENT:
            {
                EstablishedEventStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <EstablishedEventStr>(ReceivedBytes2);
                unsafe
                {
                    string device                = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string callId                = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CallId);
                    string deviceId              = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DeviceId);
                    string answeringDevice       = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.AnsweringDevice);
                    string callingDevice         = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CallingDevice);
                    string calledDevice          = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.CalledDevice);
                    string lastRedirectionDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.LastRedirectionDevice);
                    short  isExternal            = pkt2.shExternal; //OSFOURK-6659
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : ESTABLISHEDEVENT" + " Device=" + device + " CallId=" + callId + " DeviceId=" + deviceId + " AnswerDevice=" + answeringDevice + " CallingDevice=" + callingDevice + " CalledDevice=" + calledDevice + " LastRedirectionDevice=" + lastRedirectionDevice + " IsExternal=" + isExternal.ToString());
                    Globals.ExtensionManager.OnCallIdReceived(nclient.ServerIPAndPort, null, callingDevice, callId, calledDevice);
                    //m_pWnd->EstablishedEvent(device, callId, deviceId, answeringDevice, callingDevice, calledDevice, lastRedirectionDevice, isExternal);

/*                            if (device == Globals.Config.GetConfig("Options", "OptisetExtension", ""))
 *                          {
 *                              Globals.AppVars.m_strDeviceIDTemp = deviceId;
 *                              Globals.AppVars.m_strCallIDTemp = callId;
 *                          }
 *                          if((device == Globals.Config.GetConfig("Options", "OptisetExtension", "") || device == Globals.ExtensionManager.GetLastSelectedExtension().ToString()) && Globals.AppVars.m_bConsultationCall == true)
 *                          {
 *                              Globals.AppVars.m_bConsultationCall = false;
 *                              Globals.AppVars.m_strDeviceIDTemp = "";
 *                              Globals.AppVars.m_strCallIDTemp = "";               // BP-3.0.9.0-050816: Feature 'CallID as string': Modified: long m_lCallIDTemp -> CString m_strCallIDTemp
 *                          }*/
                    if (isExternal == ServerSidePhoneStatusCodes.ZS_EXTERNVERBINDUNG)
                    {
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodeTranslate(ServerSidePhoneStatusCodes.ZS_EXTERNAL));
                    }
                    else
                    {
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodeTranslate(ServerSidePhoneStatusCodes.ZS_GESPRAECH));
                    }
                }
                break;
            }

            case PacketTypes.CONNECTIONCLEAREDEVENT:
            {
                ConnectionClearedEventStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <ConnectionClearedEventStr>(ReceivedBytes2);
                unsafe
                {
                    string device          = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string droppedCall     = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DroppedCall);
                    string droppedDevice   = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.DroppedDevice);
                    string releasingDevice = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.ReleasingDevice);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : CONNECTIONCLEAREDEVENT Device=" + device + " CallId=" + droppedCall + " DroppedDevice=" + droppedDevice + " ReleasingDevice=" + releasingDevice + " State=" + pkt2.shLocalConnectionState.ToString() + " Cause=" + pkt2.shEventCause.ToString());
                    Globals.ExtensionManager.OnCallIdClear(nclient.ServerIPAndPort, null, device, droppedCall, droppedDevice);
                    //m_pWnd->ConnectionClearedEvent(device, droppedCall, droppedDevice, releasingDevice, pStruct->shLocalConnectionState, pStruct->shEventCause);
                    PhoneStatusCodes code = PhoneStatusCodeTranslateMonitor(pkt2.shLocalConnectionState);
                    if (code < PhoneStatusCodes.NumberOfStatusCodes)
                    {
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, code);
                    }
                    else
                    {
                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " CONNECTIONCLEAREDEVENT : Ignore handling status update as not recognized state");
                    }
                }
                break;
            }

            case PacketTypes.UPDATEFORWARDSTATESTR:
            {
                UpdateForwardStateStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <UpdateForwardStateStr>(ReceivedBytes2);
                unsafe
                {
                    string device   = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string pvtFwdDn = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.pvt_fwd_dn);
                    string pvtType  = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.pvt_type);

                    string Exntension = device;
                    long   Fwd        = PhoneNumberManager.Int32Parse(pvtFwdDn, 0);

                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : UPDATEFORWARDSTATESTR, device " + device + " forward " + pvtFwdDn + " fwd type " + pvtType);

                    if (Fwd != 0)
                    {
                        Globals.ForwardManager.PhoneNumberUpdateForwarding(Exntension, CallForwardingTypes.CallForwardDestination, 0, Fwd);
                    }
                    else
                    {
                        Globals.ForwardManager.PhoneNumberUpdateForwarding(Exntension, CallForwardingTypes.CallForwardNone, 0, Fwd);
                    }

                    PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device);
                }
                break;
            }

            case PacketTypes.NETWORKREACHEDEVENT:
            {
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : NETWORKREACHEDEVENT");
                NetworkReachedEventStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <NetworkReachedEventStr>(ReceivedBytes2);
                unsafe
                {
                    string device         = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string calledDeviceId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.called_device_id);
                    //m_pWnd->NetworkReached(device, calledDeviceId);
                    //folders[i]->UpdateCell(_T((char*)bstrDevice), ZS_EXTERNAL, dc);
                    Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, PhoneStatusCodeTranslate(ServerSidePhoneStatusCodes.ZS_EXTERNAL));
                }
                break;
            }

            case PacketTypes.MONITORSTARTRESPONSE:     //nothing to do here
            {
                MonitorStartResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStartResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    string xRef   = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Xref);
                    Globals.ExtensionManager.OnMonitorStart(nclient.ServerIPAndPort, null, device, xRef);
                    //m_pWnd->MonitorStartResult(device, xRef);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MONITORSTARTRESPONSE , device " + device + ", xref " + xRef);

                    PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device);
                }
                break;
            }

            case PacketTypes.MONITORSTOPRESPONSE:     //nothing to do here
            {
                MonitorStopResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStopResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    Globals.ExtensionManager.OnMonitorStop(nclient.ServerIPAndPort, null, device);
                    //m_pWnd->MonitorStopResult();
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MONITORSTOPRESPONSE, device " + device);
                }
                break;
            }

            case PacketTypes.SNAPSHOTDEVICERESPONSE:
            {
//                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : SNAPSHOTDEVICERESPONSE");
                SnapshotDeviceResponseStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <SnapshotDeviceResponseStr>(ReceivedBytes2);
                unsafe
                {
                    string device = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.Device);
                    //m_pWnd->SnapshotDeviceResult(device, pStruct->State);

                    PhoneStatusCodes code = PhoneStatusCodeTranslate(pkt2.State);
                    if (code < PhoneStatusCodes.NumberOfStatusCodes)
                    {
                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SNAPSHOTDEVICERESPONSE : device '" + device + "', state '" + pkt2.State + "'");
                        Globals.ExtensionManager.OnStatusChange(nclient.ServerIPAndPort, null, device, code);
                        PhoneNumberManager.OnClientReceivedPacketWithExtension(nclient, device);
                    }
                    else
                    {
                        Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SNAPSHOTDEVICERESPONSE : !Ignored! : device '" + device + "', state '" + pkt2.State + "'");
                    }
                }
                break;
            }

            case PacketTypes.MONITORSTOPREQUEST:
            {
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : MONITORSTOPREQUEST");
                MonitorStopRequestStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStopRequestStr>(ReceivedBytes2);
                unsafe
                {
                    string xrefId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.XREFId);
                    //m_pWnd->MonitorStopRequest(xrefId);
                    Globals.ExtensionManager.OnMonitorStop(nclient.ServerIPAndPort, null, xrefId);
                }
                break;
            }

            case PacketTypes.DIVERTEDEVENT:
            {
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : DIVERTEDEVENT");
                MonitorStopRequestStr pkt2 = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <MonitorStopRequestStr>(ReceivedBytes2);
                unsafe
                {
                    string      xrefId = NetworkPacketTools.BytesToString_MAX_STN_CHARNO(pkt2.XREFId);
                    PhoneNumber pn     = Globals.ExtensionManager.PhoneNumberGetByXRef(nclient.ServerIPAndPort, PhoneNumberManager.Int32Parse(xrefId, 0));
                    if (pn != null)
                    {
                        if (pn.GetStatus() == PhoneStatusCodes.Ringing)
                        {
                            if (App.Current != null)
                            {
                                App.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() =>
                                    {
                                        MainWindow MainObject = (MainWindow)App.Current.MainWindow;

                                        if (MainObject == null)
                                        {
                                            return;
                                        }
                                        pn.SetStatus(PhoneStatusCodes.Idle);
                                    }));
                            }
                        }
                    }
                    else
                    {
                        // create a new store and set the state as idle
                        // this is not required for us (i think). We will query the state as soon as we have a store for it
                    }
                    //m_pWnd->DivertedEvent(xrefId);
                }
                break;
            }

            case PacketTypes.DBSENDCHK:
            {
                //OSFOURK-6654
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : DBSENDCHK");

                DbSendChkStr pkt2           = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <DbSendChkStr>(ReceivedBytes2);
                ushort       checksum       = pkt2.Xchk;
                ushort       ClientChecksum = Globals.persPortManager.GetChecksum(nclient.ServerIPAndPort);
                //m_pWnd->ValidateChksum(checksum);
                if (ClientChecksum != checksum)
                {
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " Checksum mismatch, will request a new persport");
                    if (nclient != null)
                    {
                        nclient.PacketBuilder.DBRequest((ushort)0xffff);
                    }
                }
                else
                {
                    Globals.persPortManager.ReParsePersportTXT(nclient.ServerIPAndPort);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, nclient.ServerIPAndPort + " Checksum says persport is up to date");
                }
                break;
            }

            case PacketTypes.DBCHUNK:
            {
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : DBCHUNK");
                DbChunkHdrStr pkt2       = BLFClient.Backend.NetworkPacketTools.ByteArrayToStructure <DbChunkHdrStr>(ReceivedBytes2);
                ushort        maxChunk   = pkt2.MaxChunk;
                ushort        chunk      = pkt2.Chunk;
                int           HeaderSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(DbChunkHdrStr));
                int           chunkLen   = pkt2.Size - HeaderSize + 2; // no idea from where that extra 2 comes from. As long as it works ...
                //save the chunk
                Globals.persPortManager.SaveChunkToFile(chunk, ReceivedBytes2, HeaderSize, chunkLen, nclient.ServerIPAndPort);
                //request the next chunk to be saved
                if (chunk < maxChunk)
                {
                    if (nclient != null)
                    {
                        nclient.PacketBuilder.DBRequest(chunk);
                    }
                }
                else
                {
                    Globals.persPortManager.ReParsePersportTXT(nclient.ServerIPAndPort);
                    Globals.Logger.LogString(LogManager.LogLevels.LogFlagInfo, "Fetched all " + maxChunk.ToString() + " chunks of passport.txt");
                }
                break;
            }

            default:
            {
                // unhandled packet type
                Globals.Logger.LogString(LogManager.LogLevels.LogFlagNetwork, nclient.ServerIPAndPort + " SMSG : Unknown and unhandled, type " + pkt.Type.ToString() + " length " + pkt.Length.ToString());
            }
            break;
            }
            ;
        }
Ejemplo n.º 15
0
        public void OnStatusChange(string ServerIPAndPort, string Prefix, string Extension, PhoneStatusCodes NewStatus)
        {
            //mark that we are alive
            MonitorStatusStore ss = GetStatusStore(ServerIPAndPort, Prefix, Extension);

            ss.LastStatusUpdateStamp = Environment.TickCount;
            ss.PacketStatus          = ServerPacketStatus.PacketReceived;
            ss.LastStatus            = NewStatus;

            //try to attach a monitor to it
            if (ss.LastStatus != PhoneStatusCodes.PHONE_DOESNOT && ss.ShouldTryAttachMonitor() == true)
            {
                ss.MonitorPacketStatus   = ServerPacketStatus.PacketSent;
                ss.LastMonitorQueryStamp = Environment.TickCount;
                if (Globals.ConnectionManager != null)
                {
                    NetworkClient nc = Globals.ConnectionManager.GetCLient(ss.ServerIPAndPort);
                    nc.PacketBuilder.MonitorStart(Extension);
                }
            }

            string ExtensionRange = Extension.Substring(0, Extension.Length - 1);

            foreach (PhoneNumber pn in PhoneNumbers)
            {
                if (pn.GetExtension() == Extension || (pn.IsSubscriberRange() == true && pn.GetExtension() == ExtensionRange))
                {
                    if (App.Current != null)
                    {
                        App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
                        {
                            if (App.Current == null)
                            {
                                return;
                            }

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

                            if (MainObject == null)
                            {
                                return;
                            }

                            pn.SetStatus(NewStatus, Extension); // extension is provided for ranges
                        }));
                    }
                }
            }
        }
Ejemplo n.º 16
0
 public NotificationTaskBar(string content, PhoneStatusCodes status)
 {
     InitializeComponent();
     this.ContentBorder.Background = StatusColorEditor.GetStatusBrush(status);
     this.PopupContent.Text        = content;
 }