Ejemplo n.º 1
0
        public bool SendInfo(byte[] payload, String contentType)
        {
#if WINDOWS_PHONE
            if (payload != null && !String.IsNullOrEmpty(contentType))
            {
                String       payloadStr = Encoding.UTF8.GetString(payload, 0, payload.Length);
                ActionConfig config     = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
                config.addHeader("Content-Type", contentType);
                return(mSession.sendInfo(payloadStr, (uint)payloadStr.Length, config));
            }
            return(mSession.sendInfo(BogheCore.Utils.StringUtils.nullptr, 0, null));
#else
            if (payload != null && !String.IsNullOrEmpty(contentType))
            {
                IntPtr       payloadPtr = Marshal.AllocHGlobal(payload.Length);
                ActionConfig config     = new ActionConfig();
                config.addHeader("Content-Type", contentType);
                Marshal.Copy(payload, 0, payloadPtr, payload.Length);
                bool ret = mSession.sendInfo(payloadPtr, (uint)payload.Length, config);
                Marshal.FreeHGlobal(payloadPtr);
                return(ret);
            }
            return(mSession.sendInfo(IntPtr.Zero, 0));
#endif
        }
Ejemplo n.º 2
0
        public bool Send(byte[] payload, String contentType)
        {
            if (payload != null && !String.IsNullOrEmpty(contentType))
            {
                ActionConfig config =
#if WINDOWS_PHONE
                    org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
#else
                    new ActionConfig();
#endif
                config.addHeader("Content-Type", contentType);
#if WINRT
#if WINDOWS_PHONE
                m_Session.send(Encoding.UTF8.GetString(payload, 0, payload.Length), config);
#else
                IntPtr payloadPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(payload.Length);
                System.Runtime.InteropServices.Marshal.Copy(payload, 0, payloadPtr, payload.Length);
                bool ret = m_Session.send(payloadPtr, (uint)payload.Length, config);
                System.Runtime.InteropServices.Marshal.FreeHGlobal(payloadPtr);
                return(ret);
#endif
#else
                return(m_Session.send(payload, config));
#endif
            }
#if WINDOWS_PHONE
            return(m_Session.send(String.Empty));
#else
            return(m_Session.send(IntPtr.Zero, 0));
#endif
        }
Ejemplo n.º 3
0
        public bool MakeVideoSharingCall(String remoteUri)
        {
            bool ret;

            base.outgoing = true;

            ActionConfig config =
#if WINDOWS_PHONE
                org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
#else
                new ActionConfig();
#endif
            ret = mSession.call(remoteUri, MediaTypeUtils.ConvertToNative(MediaType.Video), config);
            config.Dispose();

            return(ret);
        }
Ejemplo n.º 4
0
        public bool SendFile(String path)
        {
            if (String.IsNullOrEmpty(path) || !File.Exists(path))
            {
                LOG.Error(String.Format("File ({0}) doesn't exist", path));
                return(false);
            }

            if (this.mMediaType != MediaType.FileTransfer)
            {
                LOG.Error("Invalid media type");
                return(false);
            }

            FileInfo finfo = new FileInfo(path);

            this.mFilePath = mFilePath = finfo.FullName;
            this.mFileType = this.GetFileType(finfo.Extension);
            String fileSelector = String.Format("name:\"{0}\" type:{1} size:{2}",
                                                finfo.Name, this.mFileType, finfo.Length);

            ActionConfig config =
#if WINDOWS_PHONE
                org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
#else
                new ActionConfig();
#endif
            config
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", this.mFilePath)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-selector", fileSelector)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", MyMsrpSession.FILE_ACCEPT_TYPES)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-wrapped-types", MyMsrpSession.FILE_ACCEPT_WRAPPED_TYPES)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-disposition", "attachment")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-icon", "cid:[email protected]")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "Failure-Report", this.FailureReport ? "yes" : "no")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "Success-Report", this.SuccessReport ? "yes" : "no")
            .setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", MyMsrpSession.CHUNK_DURATION)
            ;

            bool ret = mSession.callMsrp(this.RemotePartyUri, config);
            config.Dispose();
            return(ret);
        }
Ejemplo n.º 5
0
        public bool SendMessage(String message, String contentType, String wContentType)
        {
            if (String.IsNullOrEmpty(message))
            {
                LOG.Error("Null or empty message");
                return(false);
            }

            if (this.mMediaType != MediaType.Chat)
            {
                LOG.Error("Invalid media type");
                return(false);
            }

            if (base.IsConnected)
            {
                ActionConfig config =
#if WINDOWS_PHONE
                    org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
#else
                    new ActionConfig();
#endif
                if (!String.IsNullOrEmpty(contentType))
                {
                    config.setMediaString(twrap_media_type_t.twrap_media_msrp, "content-type", "text/plain");
                }
                if (!String.IsNullOrEmpty(wContentType))
                {
                    config.setMediaString(twrap_media_type_t.twrap_media_msrp, "w-content-type", wContentType);
                }
                //config.setMediaString(twrap_media_type_t.twrap_media_msrp, "content-type", contentType);
                // == OR ==
                //config.setMediaString(twrap_media_type_t.twrap_media_msrp,
                //    "content-type", "message/CPIM")
                //    .setMediaString(twrap_media_type_t.twrap_media_msrp, "w-content-type", "text/plain");
#if WINDOWS_PHONE
                return(mSession.sendMessage(message, config));
#else
                byte[] payload = Encoding.UTF8.GetBytes(message);
                IntPtr ptr     = Marshal.AllocHGlobal(payload.Length);
                Marshal.Copy(payload, 0, ptr, payload.Length);
                bool ret = mSession.sendMessage(ptr, (uint)payload.Length, config);
                Marshal.FreeHGlobal(ptr);
                config.Dispose();
                return(ret);
#endif
            }
            else
            {
                if (this.mPendingMessages == null)
                {
                    this.mPendingMessages = new List <PendingMessage>();
                }
                this.mPendingMessages.Add(new PendingMessage(message, contentType, wContentType));

                ActionConfig config =
#if WINDOWS_PHONE
                    org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
#else
                    new ActionConfig();
#endif
                config.setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", MyMsrpSession.CHAT_ACCEPT_TYPES)
                .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-wrapped-types", MyMsrpSession.CHAT_ACCEPT_WRAPPED_TYPES)
                .setMediaString(twrap_media_type_t.twrap_media_msrp, "Failure-Report", this.FailureReport ? "yes" : "no")
                .setMediaString(twrap_media_type_t.twrap_media_msrp, "Success-Report", this.SuccessReport ? "yes" : "no")
                .setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", 50);

                bool ret = mSession.callMsrp(base.RemotePartyUri, config);
                config.Dispose();

                return(ret);
            }
        }
Ejemplo n.º 6
0
 public bool SendInfo(byte[] payload, String contentType)
 {
     #if WINDOWS_PHONE
     if (payload != null && !String.IsNullOrEmpty(contentType))
     {
         String payloadStr = Encoding.UTF8.GetString(payload, 0, payload.Length);
         ActionConfig config = org.doubango.WindowsPhone.BackgroundProcessController.Instance.rtActionConfigNew();
         config.addHeader("Content-Type", contentType);
         return mSession.sendInfo(payloadStr, (uint)payloadStr.Length, config);
     }
     return mSession.sendInfo(BogheCore.Utils.StringUtils.nullptr, 0, null);
     #else
     if (payload != null && !String.IsNullOrEmpty(contentType))
     {
         IntPtr payloadPtr = Marshal.AllocHGlobal(payload.Length);
         ActionConfig config = new ActionConfig();
         config.addHeader("Content-Type", contentType);
         Marshal.Copy(payload, 0, payloadPtr, payload.Length);
         bool ret = mSession.sendInfo(payloadPtr, (uint)payload.Length, config);
         Marshal.FreeHGlobal(payloadPtr);
         return ret;
     }
     return mSession.sendInfo(IntPtr.Zero, 0);
     #endif
 }