private void PhoBrowTitleChanged(object sender, ContaQ.TextChangedArgs e)
 {
     SetTitle(e.Text);
 }
        void PhoBrowSipRequest(object sender, ContaQ.SipRequestArgs e)
        {
            this.BringToFront();

            e.Cancel = true;
            switch (e.Command) {
                case ContaQ.SipRequestArgs.cmdTEST:
                    MessageBox.Show("Ok, the thing is working",this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case ContaQ.SipRequestArgs.cmdSHELL:
                    //MessageBox.Show("This is the shell command: " + (string)e.Arguments["executable"] + " " + (string)e.Arguments["arguments"] ,this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    try {
                        System.Diagnostics.Process proc = new System.Diagnostics.Process();
                        proc.EnableRaisingEvents=false;
                        proc.StartInfo.FileName=(string)e.Arguments["executable"];
                        proc.StartInfo.Arguments=(string)e.Arguments["arguments"];
                        proc.Start();
                        proc.WaitForExit();
                    } catch (Exception ex){
                        MessageBox.Show(ex.Message, this.Text + " - shell execute",MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;
                case ContaQ.SipRequestArgs.cmdOPEN:
                    phoBrow.Open((string)e.Arguments["url"]);
                    break;
                case ContaQ.SipRequestArgs.cmdCALL:
                    //handles sip:call?number=raffaeleguidi
                    //		  sip:call?number=1000
                    doCall((string)e.Arguments["number"]);
                    break;
                case ContaQ.SipRequestArgs.cmdANSWER:
                    //handles sip:answer
                    BtnAnswerClick(btnAnswer, null);
                    break;
                case ContaQ.SipRequestArgs.cmdHANGUP:
                    //handles sip:hangup
                    BtnReleaseClick(btnRelease, null);
                    break;
                case ContaQ.SipRequestArgs.cmdREGISTER:
                    //handles sip:register?operatorid=contaq&pin=contaq
              			VoIPServer.Registrar.unregisterAccounts();
              			int accIndex = VoIPServer.Configurator.DefaultAccountIndex;
              			IAccount acc = VoIPServer.Configurator.Accounts[accIndex];
              			acc.AccountName = "contaq";
              			acc.UserName = (string)e.Arguments["operatorid"];
              			acc.Password = (string)e.Arguments["pin"];
              			acc.DomainName = (string)e.Arguments["domain"];
              			acc.HostName = (string)e.Arguments["registrar"];

              			if ((string)e.Arguments["displayname"] != null)
              				acc.DisplayName = (string)e.Arguments["displayname"];
              			else
              				acc.DisplayName = "Operatore " + acc.UserName;

              			if ((string)e.Arguments["proxy"] != null)
              			acc.ProxyAddress = (string)e.Arguments["proxy"];
              			else
              			acc.ProxyAddress = "";

              			VoIPServer.Registrar.registerAccounts();

                    break;
                case ContaQ.SipRequestArgs.cmdUNREGISTER:
                    //handles sip:unregister
                    //it is not perfect
                    //but it works
                    _account.UserName ="******";
                    _account.DisplayName="non disponibile";
                    _account.Password="******";
                    VoIPServer.Registrar.Config.Save();
              			VoIPServer.Registrar.registerAccounts();
                    break;
                case ContaQ.SipRequestArgs.cmdSETCALLBACK:
                    foreach (string key in e.Arguments.Keys) {
                        String url = format((string)e.Arguments[key]);
                        switch (key.ToLower()) {
                            case "onincomingcall":
                                onIncomingCallUrl = url;
                                break;
                            case "onhangup":
                                onHangupUrl = url;
                                break;
                            case "onalerting":
                                onAlertingUrl = url;
                                break;
                            case "onanswered":
                                onAnsweredUrl = url;
                                break;
                            case "onregistered":
                                onRegisteredUrl = url;
                                break;
                            case "onunregistered":
                                onUnregisteredUrl = url;
                                break;
                        }
                    }
                    break;
                case ContaQ.SipRequestArgs.cmdRECORDSESSION:
                    //handles sip:recordsession
                    // recording is implemented server side
                    // transferring the call to a recording enabled
                    // extension - has to be unique to each user
                    BtnRecordClick(btnRecord, null);
                    break;
                case ContaQ.SipRequestArgs.cmdTRANSFER:
                    //handles sip:transfer?number=123454345
                    txtNumber.Text=(string)e.Arguments["number"];
                    BtnTransferClick(btnTransfer, null);
                    break;
                case ContaQ.SipRequestArgs.cmdHOLD:
                    //handles sip:hold
                    BtnHoldClick(btnTransfer, null);
                    break;
                case ContaQ.SipRequestArgs.cmdRETRIEVE:
                    //handles sip:hold
                    BtnHoldClick(btnTransfer, null);
                    break;
                case ContaQ.SipRequestArgs.cmdHOME:
                    VaiAllaHome();
                    break;
                case ContaQ.SipRequestArgs.cmdSETAUTOROUTING:
                    mobilePrefixes = e.Arguments["mobile"].ToString().Split(';');
                    landlinePrefixes = e.Arguments["landline"].ToString().Split(';');
                    break;
                default:
                    // handles sip:132412351
                    // for compatibility with other phones
                    //e.Cancel = false;
                    doCall(e.Command);
                    break;
            }
        }
 private void PhoBrowStatusChanged(object sender, ContaQ.TextChangedArgs e)
 {
     SetBrowserStatus(e.Text);
 }
        void NotHandled(ContaQ.SipRequestArgs e)
        {
            String msg = "command not handled: " + e.Command;

            Hashtable args = e.Arguments;

            foreach (string key in e.Arguments.Keys) {
                msg += "\n\r   " + key + "=" + e.Arguments[key] + " ";
            }

            MessageBox.Show(msg, "sip request");
        }