Exemple #1
0
        private bool InitializeClient()
        {
            if (!this.mFormIsClosing)
            {
                for (; true; )
                {
                    TELEPHONY_RETURN_VALUE result;
                    DetectNetwork();

                    if (!myNetworkInfo.Online)
                    {
                        myNotifyIcon.ShowBalloonTip(10,
                            Properties.Localization.txtInfoServiceNotReachable,
                            Properties.Localization.txtInfoServiceNotReachableDesc,
                            ToolTipIcon.Warning);
#if (TRACE)
                        Console.WriteLine("Network:SIP Proxy Does not respond, network time out.");
#endif
                        return false;
                    }

                    //Initialize ChatWindow
                    if (myChatWindow != null) myChatWindow.Dispose();
                    myChatWindow = new Remwave.Client.ChatWindow(this);

                    if (myNikotalkieWindow != null) myNikotalkieWindow.Dispose();
                    myNikotalkieWindow = new NikotalkieForm(this);

                    //network detected, try authenticate at jabber
                    try
                    {
                        myServiceStateCheckTimer.Tag = DateTime.Now;
                        if (xmppControl.Connected) xmppControl.Disconnect();
                        xmppControl.InvokeThrough = this;
                        xmppControl.Timeout = 7200;
                        xmppControl.IMServer = ConfigIM.IMServer;
                        xmppControl.IMPort = ConfigIM.IMPort;
                        xmppControl.Connect(myLoginUsernameInput.Text, myLoginPasswordInput.Text);
                    }
                    catch (nsoftware.IPWorksSSL.IPWorksSSLException ex)
                    {
#if (TRACE)
                                          Console.WriteLine("IM:Connect error:" + ex.Code.ToString() + " - " + ex.Message);
#endif


                        MessageBox.Show(this,
                            Properties.Localization.txtInfoWrongUsernamePasswordDesc,
                            Properties.Localization.txtInfoWrongUsernamePassword,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                        return false;
                    }
                    if (!myStorage.Open(AppDataDir, mStorageFileName, myLoginUsernameInput.Text, false))
                    {
                        if (DialogResult.Yes == MessageBox.Show(
                            Properties.Localization.txtInfoStorageEngineErrorDesc,
                            Properties.Localization.txtInfoStorageEngineError,
                            MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error))
                        {
                            myStorage.Open(AppDataDir, mStorageFileName, myLoginUsernameInput.Text, true);
                        }
                    }
                    try
                    {
                        result = mySIPPhone.InitEngine(myMediaEngineCallback, myLoginUsernameInput.Text, myLoginPasswordInput.Text, ConfigSIP.Realm, ConfigSIP.ProxyAddress, myNetworkInfo.LocalIP, ENGINE_KEY, ConfigSIP.UserAgent);
                        if (result != TELEPHONY_RETURN_VALUE.SipSuccess)
                        {
                            xmppControl.Disconnect();
#if (TRACE)
                            Console.WriteLine("SIP:InitEngine:" + result.ToString());                 
#endif

                            switch (result)
                            {
                                case TELEPHONY_RETURN_VALUE.SipAudioInFailure:
                                    myNotifyIcon.ShowBalloonTip(10,
                                        Properties.Localization.txtInfoSipEngineAudioInError,
                                        Properties.Localization.txtInfoSipEngineAudioInErrorDesc,
                                        ToolTipIcon.Warning);
                                    break;
                                case TELEPHONY_RETURN_VALUE.SipAudioOutFailure:
                                    myNotifyIcon.ShowBalloonTip(10,
                                        Properties.Localization.txtInfoSipEngineAudioOutError,
                                        Properties.Localization.txtInfoSipEngineAudioOutErrorDesc,
                                        ToolTipIcon.Warning);
                                    break;
                                default:
                                    myNotifyIcon.ShowBalloonTip(10,
                                        Properties.Localization.txtInfoSipEngineGeneralError,
                                        String.Format(Properties.Localization.txtInfoSipEngineGeneralErrorDesc, (int)result),
                                        ToolTipIcon.Warning);
                                    break;
                            }

                            break;
                        }
                    }
                    catch (Exception ex)
                    {
#if (TRACE)
		                         Console.WriteLine("SIP:InitEngine:" + ex.InnerException.ToString());
#endif
                        myNotifyIcon.ShowBalloonTip(10,
                        Properties.Localization.txtInfoServiceNotReachable,
                        Properties.Localization.txtInfoServiceNotReachableDesc,
                        ToolTipIcon.Warning);
                        break;
                    }

                    mUserAccount.Login(myLoginUsernameInput.Text, myLoginPasswordInput.Text);
                    myNikotalkieWindow.nikotalkieControl.Login(myLoginUsernameInput.Text, myLoginPasswordInput.Text, ConfigWebLinks.RestNikotalkieUrl, AppDataDir + @"\" + myLoginUsernameInput.Text);
                    //TO DO VoicemAil Initialization
                    myNotifyIcon.ShowBalloonTip(10,
                        Properties.Localization.txtInfoServiceConnected,
                        Properties.Localization.txtInfoServiceConnectedDesc,
                        ToolTipIcon.Info
                        );
                    if (xmppControl.Connected) xmppControl.ChangePresence(1, PRESENCES[1]);
                    return true;
                }
            }
            return false;
        }
Exemple #2
0
        public ClientForm()
        {

            // Add the handlers to the NetworkChange events.
            NetworkChange.NetworkAvailabilityChanged +=
                NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged +=
                NetworkAddressChanged;

            // initialize phone lines states
            mySIPPhoneLines = new LINE_STATE[4];
            mySIPPhoneLines[0] = new LINE_STATE();
            mySIPPhoneLines[1] = new LINE_STATE();
            mySIPPhoneLines[2] = new LINE_STATE();
            mySIPPhoneLines[3] = new LINE_STATE();

            InitializeComponent();

            //preset size
            this.ClientSize = new Size(300, 466);
            this.MaximizeBox = false;
            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;


            //open login panel and process login
            myMainWindowSplitContainer.Panel1Collapsed = false;
            myMainWindowSplitContainer.Panel2Collapsed = true;

            //Media Engine Callback
            oCallback = new ClientCallBack(this.Callback);

            //Initialize ChatWindow
            myChatWindow = new Remwave.Client.ChatWindow(this);

            //link Presence Images
            myRosterListTreeView.ImageList = myChatWindow.myPresenceImagesList;

            //select Default Phone Line Tab
            myPhoneLinesTabControl.SelectedTab = myPhoneLine0Tab;
            myDialPadTabControl.SelectedTab = tabItem1;

            RegisterHotKey(this.Handle, this.GetType().GetHashCode(), 1, 0);

        }