Example #1
0
        public MyMsrpSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
            : base(sipStack)
        {
            this.mCallback = new MyMsrpCallback(this);
            base.mMediaType = mediaType;
            base.remotePartyUri = remoteUri;

            if (session == null)
            {
                base.outgoing = true;
            #if WINDOWS_PHONE
                mSession = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtMsrpSessionNew(sipStack.WrappedStack, mCallback);
            #else
                mSession = new MsrpSession(sipStack.WrappedStack, mCallback);
            #endif
            }
            else
            {
                base.outgoing = false;
                mSession = session;
                mSession.setCallback(mCallback);
            }

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;
            mSession.addHeader("Subject", "FIXME");
        }
Example #2
0
        public MyMsrpSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
            : base(sipStack)
        {
            this.mCallback      = new MyMsrpCallback(this);
            base.mMediaType     = mediaType;
            base.remotePartyUri = remoteUri;

            if (session == null)
            {
                base.outgoing = true;
#if WINDOWS_PHONE
                mSession = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtMsrpSessionNew(sipStack.WrappedStack, mCallback);
#else
                mSession = new MsrpSession(sipStack.WrappedStack, mCallback);
#endif
            }
            else
            {
                base.outgoing = false;
                mSession      = session;
                mSession.setCallback(mCallback);
            }

            // commons
            base.init();

            // SigComp
            base.SigCompId = sipStack.SigCompId;
            mSession.addHeader("Subject", "FIXME");
        }
Example #3
0
        public static MyMsrpSession CreateIncomingSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
        {
            if (mediaType == MediaType.FileTransfer || mediaType == MediaType.Chat)
            {
                MyMsrpSession msrpSession = new MyMsrpSession(sipStack, session, mediaType, remoteUri);
                sSessions.Add(msrpSession.Id, msrpSession);

                return(msrpSession);
            }
            return(null);
        }
Example #4
0
        public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message)
        {
            MyMsrpSession msrpSession = null;
            MediaType mediaType;
            SdpMessage sdp = message.getSdpMessage();
            String fromUri = message.getSipHeaderValue("f");

            if (String.IsNullOrEmpty(fromUri))
            {
                LOG.Error("Invalid fromUri");
                return null;
            }

            if (sdp == null)
            {
                LOG.Error("Invalid Sdp content");
                return null;
            }

            String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");
            mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer;

            if (mediaType == MediaType.Chat)
            {
                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
            }
            else
            {
                String name = null;
                String type = null;
                int nameIndexStart = fileSelector.IndexOf("name:\"");
                if (nameIndexStart == -1)
                {
                    LOG.Error("No name attribute");
                    return null;
                }
                int nameIndexEnd = fileSelector.IndexOf("\"", nameIndexStart + 6);
                if (nameIndexEnd == -1)
                {
                    LOG.Error("Invalid name attribute");
                    return null;
                }
                name = fileSelector.Substring(nameIndexStart + 6, (nameIndexEnd - nameIndexStart - 6)).Trim();
                fileSelector = fileSelector.Substring(0, nameIndexStart) + fileSelector.Substring(nameIndexEnd + 1, (fileSelector.Length - nameIndexEnd) - 1);

                String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String attribute in attributes)
                {
                    String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (avp.Length >= 2)
                    {
                        if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null)
                        {
                            type = avp[1];
                        }
                    }
                }

                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
                msrpSession.mFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name));
                msrpSession.mFileType = type;
            }

            return msrpSession;
        }
Example #5
0
        public static MyMsrpSession CreateIncomingSession(MySipStack sipStack, MsrpSession session, MediaType mediaType, String remoteUri)
        {
            if (mediaType == MediaType.FileTransfer || mediaType == MediaType.Chat)
            {
                MyMsrpSession msrpSession = new MyMsrpSession(sipStack, session, mediaType, remoteUri);
                sSessions.Add(msrpSession.Id, msrpSession);

                return msrpSession;
            }
            return null;
        }
Example #6
0
        public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message)
        {
            MyMsrpSession msrpSession = null;
            MediaType     mediaType;
            SdpMessage    sdp     = message.getSdpMessage();
            String        fromUri = message.getSipHeaderValue("f");

            if (String.IsNullOrEmpty(fromUri))
            {
                LOG.Error("Invalid fromUri");
                return(null);
            }

            if (sdp == null)
            {
                LOG.Error("Invalid Sdp content");
                return(null);
            }

            String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");

            mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer;

            if (mediaType == MediaType.Chat)
            {
                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
            }
            else
            {
                String name           = null;
                String type           = null;
                int    nameIndexStart = fileSelector.IndexOf("name:\"");
                if (nameIndexStart == -1)
                {
                    LOG.Error("No name attribute");
                    return(null);
                }
                int nameIndexEnd = fileSelector.IndexOf("\"", nameIndexStart + 6);
                if (nameIndexEnd == -1)
                {
                    LOG.Error("Invalid name attribute");
                    return(null);
                }
                name         = fileSelector.Substring(nameIndexStart + 6, (nameIndexEnd - nameIndexStart - 6)).Trim();
                fileSelector = fileSelector.Substring(0, nameIndexStart) + fileSelector.Substring(nameIndexEnd + 1, (fileSelector.Length - nameIndexEnd) - 1);

                String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String attribute in attributes)
                {
                    String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (avp.Length >= 2)
                    {
                        if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null)
                        {
                            type = avp[1];
                        }
                    }
                }

                msrpSession           = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
                msrpSession.mFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name));
                msrpSession.mFileType = type;
            }

            return(msrpSession);
        }