public MyInfoSession(MySipStack sipStack, string toUri) : base(sipStack) { this.m_Session = new InfoSession(sipStack.WrappedStack); base.init(); base.ToUri = UriUtils.GetValidSipUri(toUri); base.SigCompId = sipStack.SigCompId; }
private Person EntryToContact(entryType entry, Group g) { string strDispName = (entry.displayname == null) ? null : entry.displayname.Value; string strUil = UriUtils.GetValidSipUri(entry.uri); return(new Person(strDispName, strDispName, strUil, false, g)); }
private void GetGroupContact(listType listGroup, ContactItem contctParent) { IContactService cntService = this.serviceManager.ContactService; Group group = null; if (listGroup != null && listGroup.name != null) { string strGroupDisName = listGroup.name; if (listGroup.displayname != null) { strGroupDisName = listGroup.displayname.Value; } string strUil = UriUtils.GetValidSipUri(listGroup.name); group = new Group(listGroup.name, strGroupDisName, strUil, false, contctParent); cntService.AddGroup(group, contctParent); foreach (entryType entry in listGroup.EntryTypes) { Person psContact = this.EntryToContact(entry, group); cntService.AddPerson2Group(group, psContact); } } foreach (listType list in listGroup.ListTypeLists) { if (list != null && list.name != null) { if (group != null) { this.GetGroupContact(list, group); } } } }
public MyMessageSession(MySipStack sipStack, MessagingSession session, string toUri) : base(sipStack) { this.session = ((session == null) ? new MessagingSession(sipStack.WrappedStack) : session); base.init(); base.ToUri = UriUtils.GetValidSipUri(toUri); base.StartTime = System.DateTime.Now; base.SigCompId = sipStack.SigCompId; }
private void buttonTransfer_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(this.textBoxNumber.Text)) { this.transferUri = UriUtils.GetValidSipUri(this.textBoxNumber.Text); } this.Close(); }
private void menuItemSendSMS_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(this.textBoxFreeContact.Text)) { String remoteUri = UriUtils.GetValidSipUri(this.textBoxFreeContact.Text); if (!String.IsNullOrEmpty(remoteUri)) { MediaActionHanler.SendSMS(remoteUri); } } }
private void buttonMessaging_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(this.textBoxFreeContact.Text)) { String remoteUri = UriUtils.GetValidSipUri(this.textBoxFreeContact.Text); if (!String.IsNullOrEmpty(remoteUri)) { MediaActionHanler.StartChat(remoteUri); } } }
private void buttonVisio_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(this.textBoxFreeContact.Text)) { String remoteUri = UriUtils.GetValidSipUri(this.textBoxFreeContact.Text); if (!String.IsNullOrEmpty(remoteUri)) { MediaActionHanler.MakeVideoCall(remoteUri); } } }
private void buttonMessaging_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(this.textBoxFreeContact.Text)) { String remoteUri = UriUtils.GetValidSipUri(this.textBoxFreeContact.Text); if (!String.IsNullOrEmpty(remoteUri)) { MediaActionHanler.StartChat(remoteUri); this.textBoxFreeContact.Text = String.Empty; } } else { HistoryEvent @event = this.historyService.Events.FirstOrDefault((x) => { return((x.MediaType & MediaType.Messaging) != MediaType.None); }); if (@event != null && !String.IsNullOrEmpty(@event.RemoteParty)) { this.textBoxFreeContact.Text = UriUtils.GetUserName(@event.RemoteParty); } } }
public void Mykiven() { //播放MP3 H2.Text = "正在呼叫中,请稍等..."; Common.CallStartTime = DateTime.Now; timer.IsEnabled = true; timer.Start(); IsCall = true; Common.MP3Play = new clsMCI { FileName = "sound/ring.mp3" }; Common.MP3Play.play(); //呼叫或者挂断 Hj.Visibility = Visibility.Collapsed; Gj.Visibility = Visibility.Visible; if (!String.IsNullOrEmpty(this.textBoxTelNum.Text)) { // 根据服务器规则,拨叫的号码前,自动添加0 string strTel = "tel:0"; strTel += this.textBoxTelNum.Text; String remoteUri = UriUtils.GetValidSipUri(strTel); View1.Visibility = Visibility.Hidden; //显示号码 H0.Text = this.textBoxTelNum.Text; //获取归属地 string gsd = ""; string htm; if (textBoxTelNum.Text.Substring(0, 1) != "1")//固定电话 { htm = new HttpHelper().GetHtml(new HttpItem { URL = "http://www.ip138.com/post/search.asp?zone=" + strTel.Substring(4, 3) + "&action=zone2area", Encoding = System.Text.Encoding.GetEncoding("gbk") }).Html; MatchCollection q = new Regex("<td style=\"padding-left:5%\" noswap class=tdc2>◎ ([\\u4e00-\\u9fa5]+) ([\\u4e00-\\u9fa5]+) 邮编:\\d+ 区号:(\\d+)").Matches(htm); foreach (Match item in q) { if (item.Groups[3].Value == strTel.Substring(4, 4)) { gsd = item.Groups[1].Value + " " + item.Groups[2].Value; } } if (gsd.Length == 0) { foreach (Match item in q) { if (item.Groups[4].Value == strTel.Substring(4, 3)) { gsd = item.Groups[1].Value; } } } } else if (textBoxTelNum.Text.Length == 11) { htm = new HttpHelper().GetHtml(new HttpItem { URL = "http://www.ip138.com:8080/search.asp?action=mobile&mobile=" + textBoxTelNum.Text }).Html; Match q = new Regex(">(\\D\\S+) (\\S+)</TD>").Match(htm); gsd = q.Groups[1].Value + " " + q.Groups[2].Value; } else { //new M1("您输入的号码有误!").Show(); //textBoxTelNum.Text = ""; //View1.Visibility = Visibility.Visible; //return; } H1.Text = gsd.Replace("-", "").Replace(">", ""); H0.Text = textBoxTelNum.Text; View2.Visibility = Visibility.Visible; if (!String.IsNullOrEmpty(remoteUri)) { if (Common.CurrSession == null) { Common.CurrSession = new SessionWindow(remoteUri); Common.CurrSession.MakeAudioCall(remoteUri); } else { Common.CurrSession.MakeAudioCall(remoteUri); } //MediaActionHanler.MakeAudioCall(remoteUri); } } }
public MySubscriptionSession(MySipStack sipStack, string toUri, MySubscriptionSession.EVENT_PACKAGE_TYPE eventPackage) : base(sipStack) { this.session = new SubscriptionSession(sipStack.WrappedStack); this.eventPackage = eventPackage; base.init(); base.SigCompId = sipStack.SigCompId; switch (eventPackage) { case MySubscriptionSession.EVENT_PACKAGE_TYPE.CONFERENCE: this.session.addHeader("Event", "conference"); this.session.addHeader("Accept", "application/conference-info+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.DIALOG: this.session.addHeader("Event", "dialog"); this.session.addHeader("Accept", "application/dialog-info+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.MESSAGE_SUMMARY: this.session.addHeader("Event", "message-summary"); this.session.addHeader("Accept", "application/simple-message-summary"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE: case MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE_LIST: this.session.addHeader("Event", "presence"); if (eventPackage == MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE_LIST) { this.session.addHeader("Supported", "eventlist"); } this.session.addHeader("Accept", string.Format("{0}, {1}, {2}, {3}", new object[] { "multipart/related", "application/pidf+xml", "application/rlmi+xml", "application/rpid+xml" })); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.REG: this.session.addHeader("Event", "reg"); this.session.addHeader("Accept", "application/reginfo+xml"); this.session.setSilentHangup(true); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.SIP_PROFILE: this.session.addHeader("Event", "sip-profile"); this.session.addHeader("Accept", "application/vnd.oma.im.deferred-list+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.UA_PROFILE: this.session.addHeader("Event", "ua-profile"); this.session.addHeader("Accept", "application/xcap-diff+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.WINFO: this.session.addHeader("Event", "presence.winfo"); this.session.addHeader("Accept", "application/watcherinfo+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.XCAP_DIFF: this.session.addHeader("Event", "xcap-diff"); this.session.addHeader("Accept", "application/xcap-diff+xml"); break; } base.ToUri = UriUtils.GetValidSipUri(toUri); this.fromUri = UriUtils.GetValidSipUri(this.fromUri); this.session.addHeader("Allow-Events", "refer, presence, presence.winfo, xcap-diff, conference"); }
public MySubscriptionSession(MySipStack sipStack, string toUri, MySubscriptionSession.EVENT_PACKAGE_TYPE eventPackage) : base(sipStack) { this.session = new SubscriptionSession(sipStack.WrappedStack); this.eventPackage = eventPackage; base.init(); base.SigCompId = sipStack.SigCompId; switch (eventPackage) { case MySubscriptionSession.EVENT_PACKAGE_TYPE.CONFERENCE: this.session.addHeader("Event", "conference"); this.session.addHeader("Accept", "application/conference-info+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.DIALOG: this.session.addHeader("Event", "dialog"); this.session.addHeader("Accept", "application/dialog-info+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.MESSAGE_SUMMARY: this.session.addHeader("Event", "message-summary"); this.session.addHeader("Accept", "application/simple-message-summary"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE: case MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE_LIST: this.session.addHeader("Event", "presence"); if (eventPackage == MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE_LIST) { this.session.addHeader("Supported", "eventlist"); } this.session.addHeader("Accept", string.Format("{0}, {1}, {2}, {3}", new object[] { "multipart/related", "application/pidf+xml", "application/rlmi+xml", "application/rpid+xml" })); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.REG: this.session.addHeader("Event", "reg"); this.session.addHeader("Accept", "application/reginfo+xml"); this.session.setSilentHangup(true); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.SIP_PROFILE: this.session.addHeader("Event", "sip-profile"); this.session.addHeader("Accept", "application/vnd.oma.im.deferred-list+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.UA_PROFILE: this.session.addHeader("Event", "ua-profile"); this.session.addHeader("Accept", "application/xcap-diff+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.WINFO: this.session.addHeader("Event", "presence.winfo"); this.session.addHeader("Accept", "application/watcherinfo+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.XCAP_DIFF: this.session.addHeader("Event", "xcap-diff"); this.session.addHeader("Accept", "application/xcap-diff+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_MEMBRELATION_SUB: this.session.addHeader("Event", "MembershipAttributes"); this.session.addHeader("Accept", "application/pttmembershipinfo+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_REG_SUB: this.session.addHeader("Event", "UERegisterStatus"); this.session.addHeader("Accept", "application/pttuereginfo+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_UECALL_SUB: this.session.addHeader("Event", "UECallStatus"); this.session.addHeader("Accept", "application/pttuecallinfo+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_GRCALL_SUB: this.session.addHeader("Event", "GroupCallStatus"); this.session.addHeader("Accept", "application/pttgroupcallinfo+xml"); break; case MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_ONLINECALL_SUB: this.session.addHeader("Event", "OnLineCallStatus"); this.session.addHeader("Accept", "application/pttsysonlinecallinfo+xml"); break; } base.ToUri = UriUtils.GetValidSipUri(toUri); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); SipService sipService = BackgroundProcessController.Instance.SipService; // Register for the Obscured/Unobscured events PhoneApplicationFrame rootFrame = ((App)Application.Current).RootFrame; rootFrame.Obscured += ((CallStatusViewModel)this.ViewModel).RootFrame_Obscured; rootFrame.Unobscured += ((CallStatusViewModel)this.ViewModel).RootFrame_Unobscured; NavigationUriCall navigationUri = NavigationUri.Build(e.Uri) as NavigationUriCall; // navigationUri could be null if the app was put on the background Debug.Assert(navigationUri != null || sipService.SipActiveAVCall != null); if (navigationUri != null) { switch (navigationUri.Type) { case NavigationUriType.MakeCall: { Debug.Assert(!String.IsNullOrEmpty(navigationUri.RemoteParty)); base.ViewModel.RemotePartyDisplayName = base.ViewModel.RemotePartyNumber = navigationUri.RemoteParty; rtSipUri toUri = BackgroundProcessController.Instance.rtSipUriNew(UriUtils.GetValidSipUri(navigationUri.RemoteParty), navigationUri.RemoteParty); bool bSuccess = navigationUri.WithVideo ? (rtServiceManager.Instance.SipService.MakeCallAudioVideo(toUri, null) != null) : (rtServiceManager.Instance.SipService.MakeCallAudio(toUri, null) != null); if (!bSuccess) { base.ViewModel.CallState = SipAVCallState.Terminated; } break; } case NavigationUriType.ReceiveCall: { break; } default: { Debug.Assert(false); break; } } } // Re-bind MediaElements explictly, so video will play after app has been resumed bigHead.SetBinding(MediaElement.SourceProperty, new System.Windows.Data.Binding("BigHeadPreviewUri")); littleHead.SetBinding(MediaElement.SourceProperty, new System.Windows.Data.Binding("LittleHeadPreviewUri")); ((CallStatusViewModel)this.ViewModel).Update(); }
/// <summary> /// Messaging events /// </summary> /// <param name="e"></param> /// <returns></returns> public override int OnMessagingEvent(MessagingEvent e) { tsip_message_event_type_t type = e.getType(); switch (type) { case tsip_message_event_type_t.tsip_ao_message: break; case tsip_message_event_type_t.tsip_i_message: { SipMessage message = e.getSipMessage(); MessagingSession session = e.getSession(); uint sessionId; if (session == null) { /* "Server-side-session" e.g. Initial MESSAGE sent by the remote party */ session = e.takeSessionOwnership(); } if (session == null) { LOG.Error("Failed to take session ownership"); } if (message == null) { LOG.Error("Invalid message"); session.reject(); session.Dispose(); return(0); } sessionId = session.getId(); String from = message.getSipHeaderValue("f"); String contentType = message.getSipHeaderValue("c"); byte[] bytes = message.getSipContent(); byte[] content = null; if (bytes == null || bytes.Length == 0) { LOG.Error("Invalid MESSAGE"); session.reject(); session.Dispose(); return(0); } // Send 200 OK session.accept(); session.Dispose(); if (String.Equals(contentType, ContentType.SMS_3GPP, StringComparison.InvariantCultureIgnoreCase)) { /* ==== 3GPP SMSIP === */ byte[] buffer = (bytes.Clone() as byte[]); SMSData smsData = SMSEncoder.decode(buffer, (uint)buffer.Length, false); if (smsData != null) { twrap_sms_type_t smsType = smsData.getType(); if (smsType == twrap_sms_type_t.twrap_sms_type_rpdata) { /* === We have received a RP-DATA message === */ long payLength = smsData.getPayloadLength(); String SMSC = message.getSipHeaderValue("P-Asserted-Identity"); String SMSCPhoneNumber; String origPhoneNumber = smsData.getOA(); /* Destination address */ if (origPhoneNumber != null) { from = UriUtils.GetValidSipUri(origPhoneNumber); } else if ((origPhoneNumber = UriUtils.GetValidPhoneNumber(from)) == null) { LOG.Error("Invalid destination address"); return(0); } /* SMS Center * 3GPP TS 24.341 - 5.3.2.4 Sending a delivery report * The address of the IP-SM-GW is received in the P-Asserted-Identity header in the SIP MESSAGE * request including the delivered short message. * */ if ((SMSCPhoneNumber = UriUtils.GetValidPhoneNumber(SMSC)) == null) { SMSC = this.sipService.manager.ConfigurationService.Get(Configuration.ConfFolder.RCS, Configuration.ConfEntry.SMSC, Configuration.DEFAULT_RCS_SMSC); if ((SMSCPhoneNumber = UriUtils.GetValidPhoneNumber(SMSC)) == null) { LOG.Error("Invalid IP-SM-GW address"); return(0); } } if (payLength > 0) { /* Send RP-ACK */ RPMessage rpACK = SMSEncoder.encodeACK(smsData.getMR(), SMSCPhoneNumber, origPhoneNumber, false); if (rpACK != null) { long ack_len = rpACK.getPayloadLength(); if (ack_len > 0) { buffer = new byte[(int)ack_len]; long len = rpACK.getPayload(buffer, (uint)buffer.Length); MessagingSession m = new MessagingSession(this.sipService.SipStack); m.setToUri(SMSC); m.addHeader("Content-Type", ContentType.SMS_3GPP); m.addHeader("Content-Transfer-Encoding", "binary"); m.addCaps("+g.3gpp.smsip"); m.send(buffer, (uint)len); m.Dispose(); } rpACK.Dispose(); } /* Get ascii content */ content = new byte[(int)payLength]; smsData.getPayload(content, (uint)content.Length); } else { /* Send RP-ERROR */ RPMessage rpError = SMSEncoder.encodeError(smsData.getMR(), SMSCPhoneNumber, origPhoneNumber, false); if (rpError != null) { long err_len = rpError.getPayloadLength(); if (err_len > 0) { buffer = new byte[(int)err_len]; long len = rpError.getPayload(buffer, (uint)buffer.Length); MessagingSession m = new MessagingSession(this.sipService.SipStack); m.setToUri(SMSC); m.addHeader("Content-Type", ContentType.SMS_3GPP); m.addHeader("Transfer-Encoding", "binary"); m.addCaps("+g.3gpp.smsip"); m.send(buffer, (uint)len); m.Dispose(); } rpError.Dispose(); } } } else { /* === We have received any non-RP-DATA message === */ if (smsType == twrap_sms_type_t.twrap_sms_type_ack) { /* Find message from the history (by MR) an update it's status */ LOG.Debug("RP-ACK"); } else if (smsType == twrap_sms_type_t.twrap_sms_type_error) { /* Find message from the history (by MR) an update it's status */ LOG.Debug("RP-ERROR"); } } } } else { /* ==== text/plain or any other === */ content = bytes; } /* Alert the user a,d add the message to the history */ if (content != null) { MessagingEventArgs eargs = new MessagingEventArgs(sessionId, MessagingEventTypes.INCOMING, e.getPhrase(), content); eargs .AddExtra(MessagingEventArgs.EXTRA_CODE, e.getCode()) .AddExtra(MessagingEventArgs.EXTRA_REMOTE_PARTY, from) .AddExtra(MessagingEventArgs.EXTRA_CONTENT_TYPE, contentType == null ? ContentType.UNKNOWN : contentType); EventHandlerTrigger.TriggerEvent <MessagingEventArgs>(this.sipService.onMessagingEvent, this.sipService, eargs); } break; } } return(0); }