Example #1
0
        private void SendMmsSample()
        {
            // First instantiate the SendReq PDU we will be turning into a byte array that
            // will be ultimately sent to the MMS service provider.
            SendReq sendRequestPdu = new SendReq();

            // Set the recipient number of our MMS
            sendRequestPdu.AddTo(new EncodedStringValue("555-555-5555"));
            // Instantiate the body of our MMS
            PduBody pduBody = new PduBody();
            // Attach a sample image to our MMS body
            Stream       sampleImageStream = this.Assets.Open(SampleImageFileName);
            MemoryStream imageMemoryStream = new MemoryStream();

            sampleImageStream.CopyTo(imageMemoryStream);
            byte[]  sampleImageData    = imageMemoryStream.ToArray();
            PduPart sampleImagePduPart = new PduPart();

            sampleImagePduPart.SetData(sampleImageData);
            sampleImagePduPart.SetContentType(new EncodedStringValue("image/png").GetTextString());
            sampleImagePduPart.SetFilename(new EncodedStringValue(SampleImageFileName).GetTextString());
            pduBody.AddPart(sampleImagePduPart);
            // Set the body of our MMS
            sendRequestPdu.Body = pduBody;
            // Finally, generate the byte array to send to the MMS provider
            PduComposer composer = new PduComposer(sendRequestPdu);

            byte[] pduData       = composer.Make();
            int    pduDataLength = pduData.Length;

            Toast.MakeText(this, $"Successfully composed a PDU byte array of size: {pduDataLength.ToString("N0")} bytes", ToastLength.Long).Show();
        }
        public byte[] GetMMSPduData(string phone, string imgFilePath, string txtMessage)
        {
            Context ctx = AndroidGlobals.MainActivity;

            byte[] pduData = null;

            try
            {
                if (!string.IsNullOrEmpty(phone) && (!string.IsNullOrEmpty(imgFilePath) || !string.IsNullOrEmpty(txtMessage)))
                {
                    ///////////////////PDU Management Method///////////////////////////////////////////////////////

                    // First instantiate the PDU we will be turning into a byte array that
                    // will be ultimately sent to the MMS service provider.
                    // In this case, we are using a SendReq PDU type.
                    SendReq sendReqPdu = new SendReq();
                    // Set the recipient number of our MMS
                    sendReqPdu.AddTo(new EncodedStringValue(phone));
                    // Instantiate the body of our MMS
                    PduBody pduBody = new PduBody();

                    // Add any text message data
                    if (!string.IsNullOrEmpty(txtMessage))
                    {
                        PduPart txtPart = new PduPart();
                        txtPart.SetData(Encoding.ASCII.GetBytes(txtMessage));
                        txtPart.SetContentType(new EncodedStringValue("text/plain").GetTextString());
                        txtPart.SetName(new EncodedStringValue("Message").GetTextString());
                        pduBody.AddPart(txtPart);
                    }

                    // add any image data
                    if (!string.IsNullOrEmpty(imgFilePath))
                    {
                        PduPart imgPart = new PduPart();

                        byte[] sampleImageData = GetFileBytes(imgFilePath);

                        imgPart.SetData(sampleImageData);
                        imgPart.SetContentType(new EncodedStringValue("image/png").GetTextString());
                        imgPart.SetFilename(new EncodedStringValue(System.IO.Path.GetFileName(imgFilePath)).GetTextString());
                        pduBody.AddPart(imgPart);
                    }

                    // Set the body of our MMS
                    sendReqPdu.Body = pduBody;
                    // Finally, generate the byte array to send to the MMS provider
                    PduComposer composer = new PduComposer(sendReqPdu);
                    pduData = composer.Make();
                }
            }
            catch (Exception ex)
            {
                MobileGlobals.AddNewException(ex);
                MobileGlobals.WriteExceptionLog();
            }

            return(pduData);
        }
Example #3
0
        internal void MyRentalSendReq()
        {
            SendReq.Click();
            bool Bpage = Driver.driver.PageSource.Contains("Rental Request Form");

            if (!Bpage)
            {
                Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Validation against Page having *Rental request form* failed");
            }
        }
Example #4
0
        private void ReadMmsSample()
        {
            // First, load the bytes of our sample PDU that we usually get from the service
            // provider when receiving an MMS
            Stream       samplePduStream       = this.Assets.Open(SamplePduFileName);
            MemoryStream samplePduMemoryStream = new MemoryStream();

            samplePduStream.CopyTo(samplePduMemoryStream);
            byte[] samplePduData = samplePduMemoryStream.ToArray();
            // Parse the byte array into a PDU object we can process
            PduParser  pduParser  = new PduParser(samplePduData);
            GenericPdu genericPdu = pduParser.Parse();
            // In this case we know that our sample PDU is of type SendReq, so we can cast
            // it to that.
            // Note that in this case we are loading the same SendReq PDU from the
            // SendMmsSample() method, but normally what we get from MMS service providers
            // are NotificationInd PDUs, RetrieveConf PDUs, and so on.
            SendReq            sendRequestPdu = (SendReq)genericPdu;
            EncodedStringValue transactionId  = new EncodedStringValue(sendRequestPdu.GetTransactionId());

            Toast.MakeText(this, $"Successfully parsed a PDU with transaction ID: {transactionId.String}", ToastLength.Long).Show();
        }