Example #1
0
 private void lbAccounts_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (e.NewValue == CheckState.Checked)
     {
         for (int i = 0; i < lbAccounts.Items.Count; i++)
         {
             if (lbAccounts.GetItemChecked(i))
             {
                 lbAccounts.SetItemChecked(i, false);
             }
         }
         PjsipAccount acc = lbAccounts.Items[e.Index] as PjsipAccount;
         checkedAccount = null;
         if (acc != null)
         {
             if (!acc.IsActive)
             {
                 e.NewValue = CheckState.Unchecked;
             }
             else
             {
                 checkedAccount = acc;
             }
         }
         else
         {
             e.NewValue = CheckState.Unchecked;
         }
     }
     SetNumPadVisible(checkedAccount != null && e.NewValue == CheckState.Checked);
 }
Example #2
0
        /// <summary>
        /// Установка активности кнопок редактирования и удаления аккаунтов
        /// </summary>
        private void CheckEnableButtons()
        {
            PjsipAccount acc = lbAccounts.SelectedItem as PjsipAccount;

            miDelete.Enabled = acc != null;
            miEdit.Enabled   = acc != null;
        }
Example #3
0
        /// <summary>
        /// Установка активного аккаунта
        /// </summary>
        /// <param name="acc"></param>
        private void SelectAccount(PjsipAccount acc)
        {
            int index = lbAccounts.Items.IndexOf(acc);

            if (index != -1)
            {
                lbAccounts.SetSelected(index, true);
                lbAccounts.SetItemChecked(index, true);
            }
        }
Example #4
0
        /// <summary>
        /// Получение массива аккаунтов
        /// </summary>
        /// <returns></returns>
        private PjsipAccount[] GetAccounts()
        {
            List <PjsipAccount> accounts = new List <PjsipAccount>();

            for (int i = 0; i < lbAccounts.Items.Count; i++)
            {
                PjsipAccount acc = lbAccounts.Items[i] as PjsipAccount;
                accounts.Add(acc);
            }
            return(accounts.ToArray());
        }
Example #5
0
        /// <summary>
        /// Удаление аккаунта
        /// </summary>
        private void AccDel()
        {
            PjsipAccount acc = lbAccounts.SelectedItem as PjsipAccount;

            if (acc != null && MessageBox.Show(this, string.Format("Аккаунт {0} будет удален, Вы уверены?", acc), "Удаление аккаунта", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                lbAccounts.Items.Remove(acc);
                acc.Dispose();
                SaveConfig();
            }
        }
Example #6
0
 /// <summary>
 /// Обрабатываем изменение статуса аккаунтов
 /// </summary>
 /// <param name="acc"></param>
 private void UpdateStatus(PjsipAccount acc)
 {
     if (InvokeRequired)
     {
         AccountRegState ars = new AccountRegState(UpdateStatus);
         Invoke(ars, new object[] { acc });
     }
     else
     {
         int index = lbAccounts.Items.IndexOf(acc);
         lbAccounts.Invalidate(lbAccounts.GetItemRectangle(index));
     }
 }
Example #7
0
        /// <summary>
        /// Редактирование аккаунта
        /// </summary>
        private void AccEdit()
        {
            PjsipAccount acc = lbAccounts.SelectedItem as PjsipAccount;

            if (acc != null)
            {
                AccountForm af = new AccountForm();
                af.Account = acc;
                if (af.ShowDialog() == DialogResult.OK)
                {
                    SaveConfig();
                }
            }
        }
Example #8
0
        /// <summary>
        /// Добавление нового аккаунта
        /// </summary>
        private void AccAdd()
        {
            AccountForm af = new AccountForm();

            af.Account = new PjsipAccount();
            if (af.ShowDialog() == DialogResult.OK)
            {
                PjsipAccount acc = af.Account;
                acc.OnAccountRegState     = UpdateStatus;
                acc.OnAccountIncomingCall = IncomingCall;
                lbAccounts.Items.Add(acc);
                SaveConfig();
            }
            else
            {
                af.Account.Dispose();
            }
        }
Example #9
0
 /// <summary>
 /// Обработка входящего вызова
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="callId"></param>
 private void IncomingCall(PjsipAccount acc, PjsipCall call, int callId)
 {
     if (InvokeRequired)
     {
         AccountIncomingCall ic = new AccountIncomingCall(IncomingCall);
         Invoke(ic, new object[] { acc, call, callId });
     }
     else
     {
         try
         {
             if (currentCall != null && currentCall.IsOnline)
             {
                 CallOpParam prm = new CallOpParam();
                 prm.statusCode = pjsip_status_code.PJSIP_SC_BUSY_HERE;
                 call.answer(prm);
                 call.Dispose();
             }
             else
             {
                 SelectAccount(acc);
                 currentCall = call;
                 currentCall.OnCallIncoming     = CallIncomingInfo;
                 currentCall.OnCallDisconnected = CallDisconnect;
                 SetCallButtonState(CallButtonState.Ring);
                 ring = new PjsipRing();
             }
         }
         catch
         {
             if (currentCall != null)
             {
                 Hungup();
             }
         }
     }
 }
Example #10
0
 public PjsipCall(PjsipAccount acc, int call_id = -1)
     : base(acc, call_id)
 {
 }