示例#1
0
    def test_encoding_m_sendnotifyresp_ind(self):
        message = MMSMessage()
        message.headers['Transaction-Id'] = 'NOK5AIdhfTMYSG4JeIgAAsHtp72AGAAAAAAAA'
        message.headers['Message-Type'] = 'm-notifyresp-ind'
        message.headers['Status'] = 'Retrieved'
        data = [
            140, 131, 152, 78, 79, 75, 53, 65, 73, 100, 104, 102, 84, 77,
            89, 83, 71, 52, 74, 101, 73, 103, 65, 65, 115, 72, 116, 112,
            55, 50, 65, 71, 65, 65, 65, 65, 65, 65, 65, 65, 0, 141, 144,
            149, 129, 132, 163, 1, 35, 129]

        self.assertEqual(list(message.encode()[:50]), data)
示例#2
0
    def test_encoding_m_sendnotifyresp_ind(self):
        message = MMSMessage()
        message.headers['Transaction-Id'] = 'NOK5AIdhfTMYSG4JeIgAAsHtp72AGAAAAAAAA'
        message.headers['Message-Type'] = 'm-notifyresp-ind'
        message.headers['Status'] = 'Retrieved'
        data = [
            140, 131, 152, 78, 79, 75, 53, 65, 73, 100, 104, 102, 84, 77,
            89, 83, 71, 52, 74, 101, 73, 103, 65, 65, 115, 72, 116, 112,
            55, 50, 65, 71, 65, 65, 65, 65, 65, 65, 65, 65, 0, 141, 144,
            149, 129, 132, 163, 1, 35, 129]

        self.assertEqual(list(message.encode()[:50]), data)
示例#3
0
文件: mms.py 项目: achiang/wader
def send_m_notifyresp_ind(extra_info, tx_id):
    mms = MMSMessage()
    mms.headers['Transaction-Id'] = tx_id
    mms.headers['Message-Type'] = 'm-notifyresp-ind'
    mms.headers['Status'] = 'Retrieved'

    def process_response(data):
        if data.startswith("HTTP/1.0 404"):
            # notification has expired
            try:
                text = data.split('\r\n')[0][13:]
            except IndexError:
                text = "Message not found in MMSC"

            raise ExpiredNotification(text)

    d = post_payload(extra_info, mms.encode())
    d.addCallback(process_response)
    return d
示例#4
0
def send_message():

    now = datetime.now()
    dt_string = now.strftime("%d/%m/%Y %H:%M:%S")

    mms = MMSMessage()
    mms.headers['To'] = telephone + '/TYPE=PLMN'
    mms.headers['Message-Type'] = 'm-send-req'
    mms.headers['Subject'] = 'Image Alarm'

    slide1 = MMSMessagePage()
    slide1.add_image(tmp_image)
    slide1.add_text('Image Alarm.' + dt_string)

    mms.add_page(slide1)

    payload = mms.encode()

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((MMSC, 80))
    s.send("POST / HTTP/1.0\r\n")
    s.send("Content-Type: application/vnd.wap.mms-message\r\n")
    s.send("Content-Length: %d\r\n\r\n" % len(payload))

    s.sendall(payload)

    buf = StringIO()

    while True:
        data = s.recv(4096)
        if not data:
            break

        buf.write(data)

    s.close()
    data = buf.getvalue()
    buf.close()