Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMS text attachment #21

Open
vintozver opened this issue Dec 16, 2011 · 8 comments
Open

MMS text attachment #21

vintozver opened this issue Dec 16, 2011 · 8 comments

Comments

@vintozver
Copy link

According to SMIL, src attribute value should contain attachment name not the text itself. Please fix. :)

@pmarti
Copy link
Owner

pmarti commented Dec 16, 2011

Thanks for the report will have a look
On Dec 16, 2011 6:50 PM, "Vitaly Greck" <
reply@reply.github.com>
wrote:

According to SMIL, src attribute value should contain attachment name not
the text itself. Please fix. :)


Reply to this email directly or view it on GitHub:
#21

@vintozver
Copy link
Author

Real message sniffed by tshark on Samsung Galaxy S II (text message)

Hypertext Transfer Protocol
    POST http://mmsc HTTP/1.1\r\n
        [Expert Info (Chat/Sequence): POST http://mmsc HTTP/1.1\r\n]
            [Message: POST http://mmsc HTTP/1.1\r\n]
            [Severity level: Chat]
            [Group: Sequence]
        Request Method: POST
        Request URI: http://mmsc
        Request Version: HTTP/1.1
    Accept: */*, application/vnd.wap.mms-message, application/vnd.wap.sic\r\n
    x-wap-profile: http://wap.samsungmobile.com/uaprof/GT-I9100.xml\r\n
    Accept-Language: ru-RU, en-US\r\n
    Content-Length: 449\r\n
        [Content length: 449]
    Content-Type: application/vnd.wap.mms-message\r\n
    Host: mmsc\r\n
    Connection: Keep-Alive\r\n
    User-Agent: SAMSUNG-GT-I9100-Mms/2.0\r\n
    \r\n
MMS Message Encapsulation, Type: m-send-req
    X-Mms-Message-Type: m-send-req (0x80)
    X-Mms-Transaction-ID: T134439908ce
    X-Mms-MMS-Version: 1.2
    From: <insert address>
    To: +375296637480/TYPE=PLMN
    Subject: \177\320\242\320\265\320\272\321\201\321\202
    X-Mms-Delivery-Report: Yes (0x80)
    X-Mms-Read-Report: Yes (0x80)
    Content-Type: application/vnd.wap.multipart.related; start=<smil>; type=application/smil
        Start: <smil>
        Type: application/smil
    Data (Post)
        Multipart body
            Part: 1, content-type: application/smil
                Content-Type: application/smil; name=smil.xml
                    Name: smil.xml
                Headers
                    Content-Id: "<smil>"
                    Content-Location: smil.xml
                Synchronized Multimedia Integration Language
                    <smil>
                        <head>
                            <layout>
                                <root-layout/>
                                    width="320px"
                                    height="480px"
                                <region/>
                                    id="Text"
                                    left="0"
                                    top="320"
                                    width="320px"
                                    height="160px"
                                    fit="meet"
                                </layout>
                            </head>
                        <body>
                            <par>
                                dur="5000ms"
                                <text/>
                                    src="cid:text_0.txt"
                                    region="Text"
                                </par>
                            </body>
                        </smil>
            Part: 2, content-type: text/plain
                Content-Type: text/plain; name=cid:text_0.txt; charset=utf-8
                    Name: cid:text_0.txt
                    Charset: utf-8
                Headers
                    Content-Id: "<text_0.txt>"
                    Content-Location: text_0.txt
                Line-based text data: text/plain
                    \320\242\320\265\320\272\321\201\321\202

Also, it's good idea to change mms/message.py

   areas = (('Image', '0', '0', '176', '144'),
             ('Text', '176', '144', '176', '76'))

for methods with allow to change the smil layout, as some MMSCs do not accept layouts with empty content.

Also, if I use

@staticmethod
def encode_content_general_form(media_type, parameters):

to pass parameters (I modified the lib to conform W3C SMIL 2.0 spec), I get

Traceback (most recent call last):
  File "test_mms.py", line 20, in <module>
    payload = mms.encode().tostring()
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.10-py2.7.egg/messaging/mms/message.py", line 224, in encode
    return encoder.encode(self)
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.10-py2.7.egg/messaging/mms/mms_pdu.py", line 607, in encode
    msg_data.extend(self.encode_message_body())
  File "/usr/local/lib/python2.7/dist-packages/python_messaging-0.5.10-py2.7.egg/messaging/mms/mms_pdu.py", line 798, in encode_message_body
    message_body.extend(part_content_type)

Mofidications:

==mms/message.py
            if page.text is not None:
                part, begin, end = page.text
*               src = part.headers['Content-Type'][1]['name']
                text_node = smil_doc.createElement('text')
                text_node.setAttribute('src', src)
                text_node.setAttribute('region', 'Text')

    def set_text(self, text, content_type='text/plain', ct_parameters=None):
        """
        Convenience wrapper method for set_data()

        This method sets the :class:`DataPart` object to hold the
        specified text string, with MIME content type "text/plain".

        @param text: The text to hold
        @type text: str
        """


        self.set_data(text, content_type, ct_parameters)
        time_data = DataPart()
        time_data.set_text(text, 'text/plain', {'charset': 'utf-8', 'name': 'cid:text_0.txt'})
        self.text = (time_data, time_begin, time_end)
#!/usr/bin/env python

from messaging.mms.message import MMSMessage, MMSMessagePage

mms = MMSMessage()
mms.headers['To'] = '+375296637480/TYPE=PLMN'
mms.headers['Message-Type'] = 'm-send-req'
mms.headers['Subject'] = 'Test python-messaging.mms'

slide1 = MMSMessagePage()
slide1.add_text('This is the first slide, with a static image and some text.')

slide2 = MMSMessagePage()
slide2.set_duration(4500)
slide2.add_text('This second slide has some timing effects.', 500, 3500)

mms.add_page(slide1)
mms.add_page(slide2)

payload = mms.encode().tostring()

print payload

vint@vgreck:~$ python test_mms.py
enconded_content_general_form: [3, [131], [99, 104, 97, 114, 115, 101, 116, 0, 117, 116, 102, 45, 56, 0], [110, 97, 109, 101, 0, 99, 105, 100, 58, 116, 101, 120, 116, 95, 48, 46, 116, 120, 116, 0]]

@pmarti
Copy link
Owner

pmarti commented Dec 18, 2011

Vitaly, if you have a fix for the problem, why don't you create a fork, do your thing there and send a pull request back? If it comes with tests and pep8 compliant we'll gladly accept it :)

@vintozver
Copy link
Author

Pablo, thanks for comments ;)
Already forked, working ...

@andrewbird
Copy link
Collaborator

Hi Vitaly,
Did you ever get the changes finished, it would be good to get them back upstream?

Thanks,

Andrew

@andrewbird
Copy link
Collaborator

Ping?

@TeddJohnson
Copy link

@vintozver how were you able to capture the SMS using tshark?

When I try with tcpdump on my android phone, I don't see any packets related to MMS or SMS. I've checked both the rmnet0 and wlan0 interfaces

@vintozver
Copy link
Author

rmnet1
MMS APN may be different depending on the carrier settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants