[Merge] lp:~sergiusens/nuntium/1330917 into lp:nuntium
Martti Piirainen
martti.piirainen at canonical.com
Thu Jun 19 04:08:47 UTC 2014
Tested the fix in mako - works fine now.
Setting HeaderLength to 7
ContentType: application/vnd.wap.mms-message
Setting ApplicationId to 4
Setting TransactionId to A2iBdUt4k7QDnp1Xk
Setting Version to 0x12 == 18
Setting From to +358407694484/TYPE=PLMN
Setting DeliveryReport to 0x81 == 129
Setting Class to 0x80 == 128
Setting Size to 296192
Expiry token: 81
Message Expiry 197620, 7f
Setting ContentLocation to http://mmsc51:10021/mmsc/5_1?A2iBdUt4k7QDnp1Xk
2014/06/19 04:03:59 Context type: internet MessageCenter: MessageProxy: Active
: true
2014/06/19 04:03:59 Context type: mms MessageCenter: http://mms.sonera.fi:8002 M
essageProxy: 195.156.25.33:80 Active: false
2014/06/19 04:04:10 Starting download
Diff comments:
> === modified file 'mms/contenttype.go'
> --- mms/contenttype.go 2014-05-29 12:41:27 +0000
> +++ mms/contenttype.go 2014-06-18 19:27:13 +0000
> @@ -135,9 +135,9 @@
> }
> // These call the same function
> if next := dec.Data[dec.Offset+1]; next&SHORT_FILTER != 0 {
> - return dec.ReadMediaType(ctMember)
> + return dec.ReadMediaType(ctMember, "MediaType")
> } else if next >= TEXT_MIN && next <= TEXT_MAX {
> - return dec.ReadMediaType(ctMember)
> + return dec.ReadMediaType(ctMember, "MediaType")
> }
>
> var err error
> @@ -148,7 +148,7 @@
> fmt.Println("Content Type Length:", length)
> endOffset := int(length) + dec.Offset
>
> - if err := dec.ReadMediaType(ctMember); err != nil {
> + if err := dec.ReadMediaType(ctMember, "MediaType"); err != nil {
> return err
> }
>
>
> === modified file 'mms/decoder.go'
> --- mms/decoder.go 2014-05-09 18:30:00 +0000
> +++ mms/decoder.go 2014-06-18 19:27:13 +0000
> @@ -117,23 +117,25 @@
>
> }
>
> -func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value) (err error) {
> +func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value, hdr string) (err error) {
> var mediaType string
> origOffset := dec.Offset
>
> - if mt, err := dec.ReadInteger(nil, ""); err == nil && len(CONTENT_TYPES) > int(mt) {
> - mediaType = CONTENT_TYPES[mt]
> - } else {
> + if dec.Data[dec.Offset] >= TEXT_MIN && dec.Data[dec.Offset] <= TEXT_MAX {
> err = nil
> dec.Offset = origOffset
> mediaType, err = dec.ReadString(nil, "")
> if err != nil {
> return err
> }
> + } else if mt, err := dec.ReadInteger(nil, ""); err == nil && len(CONTENT_TYPES) > int(mt) {
> + mediaType = CONTENT_TYPES[mt]
> + } else {
> + return fmt.Errorf("cannot decode media type for field beginning with %x", dec.Data[dec.Offset])
> }
>
> - reflectedPdu.FieldByName("MediaType").SetString(mediaType)
> - fmt.Println("Media Type:", mediaType)
> + reflectedPdu.FieldByName(hdr).SetString(mediaType)
> + fmt.Print(hdr, ": ", mediaType, "\n")
> return nil
> }
>
>
> === modified file 'mms/mms.go'
> --- mms/mms.go 2014-05-07 13:22:18 +0000
> +++ mms/mms.go 2014-06-18 19:27:13 +0000
> @@ -26,7 +26,7 @@
> "os"
> )
>
> -// MMS Field names from OMA-WAP-MMS section 7.3
> +// MMS Field names from OMA-WAP-MMS section 7.3 Table 12
> const (
> BCC = 0x01
> CC = 0x02
> @@ -63,6 +63,12 @@
> X_MMS_PREVIOUSLY_SENT_DATE = 0x21
> )
>
> +// MMS Content Type Assignments OMA-WAP-MMS section 7.3 Table 13
> +const (
> + PUSH_APPLICATION_ID = 4
> + VND_WAP_MMS_MESSAGE = "application/vnd.wap.mms-message"
> +)
> +
> const (
> TYPE_SEND_REQ = 0x80
> TYPE_SEND_CONF = 0x81
>
> === modified file 'ofono/push.go'
> --- ofono/push.go 2014-04-24 21:33:38 +0000
> +++ ofono/push.go 2014-06-18 19:27:13 +0000
> @@ -66,11 +66,12 @@
> if _, err = dec.ReadUintVar(&rValue, "HeaderLength"); err != nil {
> return err
> }
> - if _, err = dec.ReadString(&rValue, "ContentType"); err != nil {
> + if err = dec.ReadMediaType(&rValue, "ContentType"); err != nil {
> return err
> }
> dec.Offset++
> - if err = dec.decodeHeaders(pdu, int(pdu.HeaderLength)-(len(pdu.ContentType)+1)); err != nil {
> + remainHeaders := int(pdu.HeaderLength) - dec.Offset + 3
> + if err = dec.decodeHeaders(pdu, remainHeaders); err != nil {
> return err
> }
> pdu.Data = dec.Data[(pdu.HeaderLength + 3):]
>
> === added file 'ofono/push_decode_test.go'
> --- ofono/push_decode_test.go 1970-01-01 00:00:00 +0000
> +++ ofono/push_decode_test.go 2014-06-18 19:27:13 +0000
> @@ -0,0 +1,149 @@
> +/*
> + * Copyright 2014 Canonical Ltd.
> + *
> + * Authors:
> + * Sergio Schvezov: sergio.schvezov at cannical.com
Typo: 'canonical.com'
> + *
> + * This file is part of mms.
> + *
> + * mms is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 3.
> + *
> + * mms is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +package ofono
> +
> +import (
> + "errors"
> + "testing"
> + . "launchpad.net/gocheck"
> + "launchpad.net/nuntium/mms"
> +)
> +
> +type PushDecodeTestSuite struct {
> + pdu *PushPDU
> +}
> +
> +var _ = Suite(&PushDecodeTestSuite{})
> +
> +func Test(t *testing.T) { TestingT(t) }
> +
> +func (s *PushDecodeTestSuite) SetUpTest(c *C) {
> + s.pdu = new(PushPDU)
> +}
> +
> +func (s *PushDecodeTestSuite) TestDecodeVodaphoneSpain(c *C) {
> + inputBytes := []byte{
> + 0x00, 0x06, 0x26, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
> + 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x6d, 0x73,
> + 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0xaf, 0x84, 0xb4, 0x81,
> + 0x8d, 0xdf, 0x8c, 0x82, 0x98, 0x4e, 0x4f, 0x4b, 0x35, 0x43, 0x64, 0x7a, 0x30,
> + 0x38, 0x42, 0x41, 0x73, 0x77, 0x61, 0x62, 0x77, 0x55, 0x48, 0x00, 0x8d, 0x90,
> + 0x89, 0x18, 0x80, 0x2b, 0x33, 0x34, 0x36, 0x30, 0x30, 0x39, 0x34, 0x34, 0x34,
> + 0x36, 0x33, 0x2f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00,
> + 0x8a, 0x80, 0x8e, 0x02, 0x74, 0x00, 0x88, 0x05, 0x81, 0x03, 0x02, 0xa3, 0x00,
> + 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6d, 0x6d, 0x31, 0x66, 0x65,
> + 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x6c, 0x65, 0x74, 0x73, 0x2f, 0x4e, 0x4f,
> + 0x4b, 0x35, 0x43, 0x64, 0x7a, 0x30, 0x38, 0x42, 0x41, 0x73, 0x77, 0x61, 0x62,
> + 0x77, 0x55, 0x48, 0x00,
> + }
> + dec := NewDecoder(inputBytes)
> + c.Assert(dec.Decode(s.pdu), IsNil)
> +
> + c.Check(int(s.pdu.HeaderLength), Equals, 38)
> + c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID)
> + c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE)
> + c.Check(len(s.pdu.Data), Equals, 106)
> +}
> +
> +func (s *PushDecodeTestSuite) TestDecodeTelecomPersonal(c *C) {
> + inputBytes := []byte{
> + 0x01, 0x06, 0x26, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
> + 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x6d, 0x73,
> + 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0xaf, 0x84, 0xb4, 0x86,
> + 0xc3, 0x95, 0x8c, 0x82, 0x98, 0x6d, 0x30, 0x34, 0x42, 0x4b, 0x6b, 0x73, 0x69,
> + 0x6d, 0x30, 0x35, 0x40, 0x6d, 0x6d, 0x73, 0x2e, 0x70, 0x65, 0x72, 0x73, 0x6f,
> + 0x6e, 0x61, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x72, 0x00, 0x8d, 0x90,
> + 0x89, 0x19, 0x80, 0x2b, 0x35, 0x34, 0x33, 0x35, 0x31, 0x35, 0x39, 0x32, 0x34,
> + 0x39, 0x30, 0x36, 0x2f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e,
> + 0x00, 0x8a, 0x80, 0x8e, 0x02, 0x74, 0x00, 0x88, 0x05, 0x81, 0x03, 0x02, 0xa2,
> + 0xff, 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x37, 0x32, 0x2e,
> + 0x32, 0x35, 0x2e, 0x37, 0x2e, 0x31, 0x33, 0x31, 0x2f, 0x3f, 0x6d, 0x65, 0x73,
> + 0x73, 0x61, 0x67, 0x65, 0x2d, 0x69, 0x64, 0x3d, 0x6d, 0x30, 0x34, 0x42, 0x4b,
> + 0x68, 0x34, 0x33, 0x65, 0x30, 0x33, 0x00,
> + }
> + dec := NewDecoder(inputBytes)
> + c.Assert(dec.Decode(s.pdu), IsNil)
> +
> + c.Check(int(s.pdu.HeaderLength), Equals, 38)
> + c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID)
> + c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE)
> + c.Check(len(s.pdu.Data), Equals, 122)
> +}
> +
> +func (s *PushDecodeTestSuite) TestDecodeATTUSA(c *C) {
> + inputBytes := []byte{
> + 0x01, 0x06, 0x27, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
> + 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x6d, 0x73,
> + 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0xaf, 0x84, 0x8d, 0x01,
> + 0x82, 0xb4, 0x84, 0x8c, 0x82, 0x98, 0x44, 0x32, 0x30, 0x34, 0x30, 0x37, 0x31,
> + 0x36, 0x35, 0x36, 0x32, 0x34, 0x36, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30,
> + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x8d, 0x90, 0x89, 0x18, 0x80,
> + 0x2b, 0x31, 0x37, 0x37, 0x34, 0x32, 0x37, 0x30, 0x30, 0x36, 0x35, 0x39, 0x2f,
> + 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, 0x96, 0x02, 0xea,
> + 0x00, 0x8a, 0x80, 0x8e, 0x02, 0x80, 0x00, 0x88, 0x05, 0x81, 0x03, 0x05, 0x46,
> + 0x00, 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x36, 0x36, 0x2e,
> + 0x32, 0x31, 0x36, 0x2e, 0x31, 0x36, 0x36, 0x2e, 0x36, 0x37, 0x3a, 0x38, 0x30,
> + 0x30, 0x34, 0x2f, 0x30, 0x34, 0x30, 0x37, 0x31, 0x36, 0x35, 0x36, 0x32, 0x34,
> + 0x36, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
> + 0x30, 0x30, 0x00,
> + }
> + dec := NewDecoder(inputBytes)
> + c.Assert(dec.Decode(s.pdu), IsNil)
> +
> + c.Check(int(s.pdu.HeaderLength), Equals, 39)
> + c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID)
> + c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE)
> + c.Check(len(s.pdu.Data), Equals, 130)
> +}
> +
> +func (s *PushDecodeTestSuite) TestDecodeSonaraFinland(c *C) {
Typo: 'Sonera'
> + inputBytes := []byte{
> + 0x00, 0x06, 0x07, 0xbe, 0xaf, 0x84, 0x8d, 0xf2, 0xb4, 0x81, 0x8c, 0x82, 0x98,
> + 0x41, 0x42, 0x73, 0x54, 0x4c, 0x4e, 0x41, 0x4c, 0x41, 0x6d, 0x6d, 0x4e, 0x33,
> + 0x77, 0x72, 0x38, 0x32, 0x00, 0x8d, 0x92, 0x89, 0x19, 0x80, 0x2b, 0x33, 0x35,
> + 0x38, 0x34, 0x30, 0x37, 0x36, 0x39, 0x34, 0x34, 0x38, 0x34, 0x2f, 0x54, 0x59,
> + 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, 0x86, 0x81, 0x8a, 0x80, 0x8e,
> + 0x03, 0x03, 0x15, 0x85, 0x88, 0x05, 0x81, 0x03, 0x03, 0xf4, 0x7f, 0x83, 0x68,
> + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6d, 0x6d, 0x73, 0x63, 0x36, 0x31, 0x3a,
> + 0x31, 0x30, 0x30, 0x32, 0x31, 0x2f, 0x6d, 0x6d, 0x73, 0x63, 0x2f, 0x36, 0x5f,
> + 0x31, 0x3f, 0x41, 0x42, 0x73, 0x54, 0x4c, 0x4e, 0x41, 0x4c, 0x41, 0x6d, 0x6d,
> + 0x4e, 0x33, 0x77, 0x72, 0x38, 0x32, 0x00,
> + }
> + dec := NewDecoder(inputBytes)
> + c.Assert(dec.Decode(s.pdu), IsNil)
> + err := dec.Decode(s.pdu)
> +
> + c.Assert(err, IsNil)
> +
> + c.Check(int(s.pdu.HeaderLength), Equals, 7)
> + c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID)
> + c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE)
> + c.Check(len(s.pdu.Data), Equals, 114)
> +}
> +
> +func (s *PushDecodeTestSuite) TestDecodeNonPushPDU(c *C) {
> + inputBytes := []byte{
> + 0x00, 0x07, 0x07, 0xbe, 0xaf, 0x84, 0x8d, 0xf2, 0xb4, 0x81, 0x8c,
> + }
> + dec := NewDecoder(inputBytes)
> + c.Assert(dec.Decode(s.pdu), DeepEquals, errors.New("7 != 6 is not a push PDU"))
> +}
>
> === modified file 'ofono/pushagent.go'
> --- ofono/pushagent.go 2014-05-12 13:47:34 +0000
> +++ ofono/pushagent.go 2014-06-18 19:27:13 +0000
> @@ -28,6 +28,7 @@
> "sync"
>
> "launchpad.net/go-dbus/v1"
> + "launchpad.net/nuntium/mms"
> )
>
> /*
> @@ -142,7 +143,7 @@
> return dbus.NewErrorMessage(msg, "org.freedesktop.DBus.Error", "DecodeError")
> }
> // TODO later switch on ApplicationId and ContentType to different channels
> - if pdu.ApplicationId == 0x04 && pdu.ContentType == "application/vnd.wap.mms-message" {
> + if pdu.ApplicationId == mms.PUSH_APPLICATION_ID && pdu.ContentType == mms.VND_WAP_MMS_MESSAGE {
> agent.Push <- pdu
> } else {
> log.Print("Unhandled push pdu", pdu)
>
--
https://code.launchpad.net/~sergiusens/nuntium/1330917/+merge/223640
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~sergiusens/nuntium/1330917 into lp:nuntium.
More information about the Ubuntu-reviews
mailing list