Merge lp:~sergiusens/nuntium/1330917 into lp:nuntium
- 1330917
- Merge into trunk
Proposed by
Sergio Schvezov
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ricardo Salveti | ||||
Approved revision: | 45 | ||||
Merged at revision: | 43 | ||||
Proposed branch: | lp:~sergiusens/nuntium/1330917 | ||||
Merge into: | lp:nuntium | ||||
Diff against target: |
303 lines (+178/-18) 7 files modified
debian/rules (+8/-0) mms/contenttype.go (+3/-3) mms/decoder.go (+9/-11) mms/mms.go (+7/-1) ofono/push.go (+3/-2) ofono/push_decode_test.go (+146/-0) ofono/pushagent.go (+2/-1) |
||||
To merge this branch: | bzr merge lp:~sergiusens/nuntium/1330917 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
Review via email: mp+223640@code.launchpad.net |
Commit message
Decoding well known media types in the push notification.
Description of the change
To post a comment you must log in.
Revision history for this message
Martti Piirainen (piiramar) wrote : | # |
lp:~sergiusens/nuntium/1330917
updated
- 44. By Sergio Schvezov
-
Fixing introduced errors while decoding media type
- 45. By Sergio Schvezov
-
Fixing typos
lp:~sergiusens/nuntium/1330917
updated
- 46. By Sergio Schvezov
-
Fix test to not decode twice
- 47. By Sergio Schvezov
-
Not running tests on powerpc, the runners panic
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/rules' | |||
2 | --- debian/rules 2014-05-08 10:19:46 +0000 | |||
3 | +++ debian/rules 2014-06-21 19:40:20 +0000 | |||
4 | @@ -4,12 +4,20 @@ | |||
5 | 4 | export DH_OPTIONS | 4 | export DH_OPTIONS |
6 | 5 | export DH_GOPKG := launchpad.net/nuntium | 5 | export DH_GOPKG := launchpad.net/nuntium |
7 | 6 | 6 | ||
8 | 7 | DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH) | ||
9 | 8 | |||
10 | 7 | %: | 9 | %: |
11 | 8 | dh $@ \ | 10 | dh $@ \ |
12 | 9 | --buildsystem=golang \ | 11 | --buildsystem=golang \ |
13 | 10 | --with=golang \ | 12 | --with=golang \ |
14 | 11 | --fail-missing | 13 | --fail-missing |
15 | 12 | 14 | ||
16 | 15 | override_dh_auto_test: | ||
17 | 16 | # The test runners panic when running on powerpc64. | ||
18 | 17 | ifneq ($(DEB_HOST_ARCH),powerpc) | ||
19 | 18 | dh_auto_test | ||
20 | 19 | endif | ||
21 | 20 | |||
22 | 13 | override_dh_auto_install: | 21 | override_dh_auto_install: |
23 | 14 | dh_auto_install -O--buildsystem=golang | 22 | dh_auto_install -O--buildsystem=golang |
24 | 15 | mv ${CURDIR}/debian/tmp/usr/bin/decode-cli \ | 23 | mv ${CURDIR}/debian/tmp/usr/bin/decode-cli \ |
25 | 16 | 24 | ||
26 | === modified file 'mms/contenttype.go' | |||
27 | --- mms/contenttype.go 2014-05-29 12:41:27 +0000 | |||
28 | +++ mms/contenttype.go 2014-06-21 19:40:20 +0000 | |||
29 | @@ -135,9 +135,9 @@ | |||
30 | 135 | } | 135 | } |
31 | 136 | // These call the same function | 136 | // These call the same function |
32 | 137 | if next := dec.Data[dec.Offset+1]; next&SHORT_FILTER != 0 { | 137 | if next := dec.Data[dec.Offset+1]; next&SHORT_FILTER != 0 { |
34 | 138 | return dec.ReadMediaType(ctMember) | 138 | return dec.ReadMediaType(ctMember, "MediaType") |
35 | 139 | } else if next >= TEXT_MIN && next <= TEXT_MAX { | 139 | } else if next >= TEXT_MIN && next <= TEXT_MAX { |
37 | 140 | return dec.ReadMediaType(ctMember) | 140 | return dec.ReadMediaType(ctMember, "MediaType") |
38 | 141 | } | 141 | } |
39 | 142 | 142 | ||
40 | 143 | var err error | 143 | var err error |
41 | @@ -148,7 +148,7 @@ | |||
42 | 148 | fmt.Println("Content Type Length:", length) | 148 | fmt.Println("Content Type Length:", length) |
43 | 149 | endOffset := int(length) + dec.Offset | 149 | endOffset := int(length) + dec.Offset |
44 | 150 | 150 | ||
46 | 151 | if err := dec.ReadMediaType(ctMember); err != nil { | 151 | if err := dec.ReadMediaType(ctMember, "MediaType"); err != nil { |
47 | 152 | return err | 152 | return err |
48 | 153 | } | 153 | } |
49 | 154 | 154 | ||
50 | 155 | 155 | ||
51 | === modified file 'mms/decoder.go' | |||
52 | --- mms/decoder.go 2014-05-09 18:30:00 +0000 | |||
53 | +++ mms/decoder.go 2014-06-21 19:40:20 +0000 | |||
54 | @@ -117,23 +117,21 @@ | |||
55 | 117 | 117 | ||
56 | 118 | } | 118 | } |
57 | 119 | 119 | ||
59 | 120 | func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value) (err error) { | 120 | func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value, hdr string) (err error) { |
60 | 121 | var mediaType string | 121 | var mediaType string |
61 | 122 | origOffset := dec.Offset | 122 | origOffset := dec.Offset |
64 | 123 | 123 | if dec.Data[dec.Offset+1] >= TEXT_MIN && dec.Data[dec.Offset+1] <= TEXT_MAX { | |
65 | 124 | if mt, err := dec.ReadInteger(nil, ""); err == nil && len(CONTENT_TYPES) > int(mt) { | 124 | if mediaType, err = dec.ReadString(nil, ""); err != nil { |
66 | 125 | return err | ||
67 | 126 | } | ||
68 | 127 | } else if mt, err := dec.ReadInteger(nil, ""); err == nil && len(CONTENT_TYPES) > int(mt) { | ||
69 | 125 | mediaType = CONTENT_TYPES[mt] | 128 | mediaType = CONTENT_TYPES[mt] |
70 | 126 | } else { | 129 | } else { |
77 | 127 | err = nil | 130 | return fmt.Errorf("cannot decode media type for field beginning with %#x@%d", dec.Data[origOffset], origOffset) |
72 | 128 | dec.Offset = origOffset | ||
73 | 129 | mediaType, err = dec.ReadString(nil, "") | ||
74 | 130 | if err != nil { | ||
75 | 131 | return err | ||
76 | 132 | } | ||
78 | 133 | } | 131 | } |
79 | 134 | 132 | ||
82 | 135 | reflectedPdu.FieldByName("MediaType").SetString(mediaType) | 133 | reflectedPdu.FieldByName(hdr).SetString(mediaType) |
83 | 136 | fmt.Println("Media Type:", mediaType) | 134 | fmt.Print(hdr, ": ", mediaType, "\n") |
84 | 137 | return nil | 135 | return nil |
85 | 138 | } | 136 | } |
86 | 139 | 137 | ||
87 | 140 | 138 | ||
88 | === modified file 'mms/mms.go' | |||
89 | --- mms/mms.go 2014-05-07 13:22:18 +0000 | |||
90 | +++ mms/mms.go 2014-06-21 19:40:20 +0000 | |||
91 | @@ -26,7 +26,7 @@ | |||
92 | 26 | "os" | 26 | "os" |
93 | 27 | ) | 27 | ) |
94 | 28 | 28 | ||
96 | 29 | // MMS Field names from OMA-WAP-MMS section 7.3 | 29 | // MMS Field names from OMA-WAP-MMS section 7.3 Table 12 |
97 | 30 | const ( | 30 | const ( |
98 | 31 | BCC = 0x01 | 31 | BCC = 0x01 |
99 | 32 | CC = 0x02 | 32 | CC = 0x02 |
100 | @@ -63,6 +63,12 @@ | |||
101 | 63 | X_MMS_PREVIOUSLY_SENT_DATE = 0x21 | 63 | X_MMS_PREVIOUSLY_SENT_DATE = 0x21 |
102 | 64 | ) | 64 | ) |
103 | 65 | 65 | ||
104 | 66 | // MMS Content Type Assignments OMA-WAP-MMS section 7.3 Table 13 | ||
105 | 67 | const ( | ||
106 | 68 | PUSH_APPLICATION_ID = 4 | ||
107 | 69 | VND_WAP_MMS_MESSAGE = "application/vnd.wap.mms-message" | ||
108 | 70 | ) | ||
109 | 71 | |||
110 | 66 | const ( | 72 | const ( |
111 | 67 | TYPE_SEND_REQ = 0x80 | 73 | TYPE_SEND_REQ = 0x80 |
112 | 68 | TYPE_SEND_CONF = 0x81 | 74 | TYPE_SEND_CONF = 0x81 |
113 | 69 | 75 | ||
114 | === modified file 'ofono/push.go' | |||
115 | --- ofono/push.go 2014-04-24 21:33:38 +0000 | |||
116 | +++ ofono/push.go 2014-06-21 19:40:20 +0000 | |||
117 | @@ -66,11 +66,12 @@ | |||
118 | 66 | if _, err = dec.ReadUintVar(&rValue, "HeaderLength"); err != nil { | 66 | if _, err = dec.ReadUintVar(&rValue, "HeaderLength"); err != nil { |
119 | 67 | return err | 67 | return err |
120 | 68 | } | 68 | } |
122 | 69 | if _, err = dec.ReadString(&rValue, "ContentType"); err != nil { | 69 | if err = dec.ReadMediaType(&rValue, "ContentType"); err != nil { |
123 | 70 | return err | 70 | return err |
124 | 71 | } | 71 | } |
125 | 72 | dec.Offset++ | 72 | dec.Offset++ |
127 | 73 | if err = dec.decodeHeaders(pdu, int(pdu.HeaderLength)-(len(pdu.ContentType)+1)); err != nil { | 73 | remainHeaders := int(pdu.HeaderLength) - dec.Offset + 3 |
128 | 74 | if err = dec.decodeHeaders(pdu, remainHeaders); err != nil { | ||
129 | 74 | return err | 75 | return err |
130 | 75 | } | 76 | } |
131 | 76 | pdu.Data = dec.Data[(pdu.HeaderLength + 3):] | 77 | pdu.Data = dec.Data[(pdu.HeaderLength + 3):] |
132 | 77 | 78 | ||
133 | === added file 'ofono/push_decode_test.go' | |||
134 | --- ofono/push_decode_test.go 1970-01-01 00:00:00 +0000 | |||
135 | +++ ofono/push_decode_test.go 2014-06-21 19:40:20 +0000 | |||
136 | @@ -0,0 +1,146 @@ | |||
137 | 1 | /* | ||
138 | 2 | * Copyright 2014 Canonical Ltd. | ||
139 | 3 | * | ||
140 | 4 | * Authors: | ||
141 | 5 | * Sergio Schvezov: sergio.schvezov@canonical.com | ||
142 | 6 | * | ||
143 | 7 | * This file is part of mms. | ||
144 | 8 | * | ||
145 | 9 | * mms is free software; you can redistribute it and/or modify | ||
146 | 10 | * it under the terms of the GNU General Public License as published by | ||
147 | 11 | * the Free Software Foundation; version 3. | ||
148 | 12 | * | ||
149 | 13 | * mms is distributed in the hope that it will be useful, | ||
150 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
151 | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
152 | 16 | * GNU General Public License for more details. | ||
153 | 17 | * | ||
154 | 18 | * You should have received a copy of the GNU General Public License | ||
155 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
156 | 20 | */ | ||
157 | 21 | |||
158 | 22 | package ofono | ||
159 | 23 | |||
160 | 24 | import ( | ||
161 | 25 | "errors" | ||
162 | 26 | "testing" | ||
163 | 27 | . "launchpad.net/gocheck" | ||
164 | 28 | "launchpad.net/nuntium/mms" | ||
165 | 29 | ) | ||
166 | 30 | |||
167 | 31 | type PushDecodeTestSuite struct { | ||
168 | 32 | pdu *PushPDU | ||
169 | 33 | } | ||
170 | 34 | |||
171 | 35 | var _ = Suite(&PushDecodeTestSuite{}) | ||
172 | 36 | |||
173 | 37 | func Test(t *testing.T) { TestingT(t) } | ||
174 | 38 | |||
175 | 39 | func (s *PushDecodeTestSuite) SetUpTest(c *C) { | ||
176 | 40 | s.pdu = new(PushPDU) | ||
177 | 41 | } | ||
178 | 42 | |||
179 | 43 | func (s *PushDecodeTestSuite) TestDecodeVodaphoneSpain(c *C) { | ||
180 | 44 | inputBytes := []byte{ | ||
181 | 45 | 0x00, 0x06, 0x26, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, | ||
182 | 46 | 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x6d, 0x73, | ||
183 | 47 | 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0xaf, 0x84, 0xb4, 0x81, | ||
184 | 48 | 0x8d, 0xdf, 0x8c, 0x82, 0x98, 0x4e, 0x4f, 0x4b, 0x35, 0x43, 0x64, 0x7a, 0x30, | ||
185 | 49 | 0x38, 0x42, 0x41, 0x73, 0x77, 0x61, 0x62, 0x77, 0x55, 0x48, 0x00, 0x8d, 0x90, | ||
186 | 50 | 0x89, 0x18, 0x80, 0x2b, 0x33, 0x34, 0x36, 0x30, 0x30, 0x39, 0x34, 0x34, 0x34, | ||
187 | 51 | 0x36, 0x33, 0x2f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, | ||
188 | 52 | 0x8a, 0x80, 0x8e, 0x02, 0x74, 0x00, 0x88, 0x05, 0x81, 0x03, 0x02, 0xa3, 0x00, | ||
189 | 53 | 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6d, 0x6d, 0x31, 0x66, 0x65, | ||
190 | 54 | 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x6c, 0x65, 0x74, 0x73, 0x2f, 0x4e, 0x4f, | ||
191 | 55 | 0x4b, 0x35, 0x43, 0x64, 0x7a, 0x30, 0x38, 0x42, 0x41, 0x73, 0x77, 0x61, 0x62, | ||
192 | 56 | 0x77, 0x55, 0x48, 0x00, | ||
193 | 57 | } | ||
194 | 58 | dec := NewDecoder(inputBytes) | ||
195 | 59 | c.Assert(dec.Decode(s.pdu), IsNil) | ||
196 | 60 | |||
197 | 61 | c.Check(int(s.pdu.HeaderLength), Equals, 38) | ||
198 | 62 | c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID) | ||
199 | 63 | c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE) | ||
200 | 64 | c.Check(len(s.pdu.Data), Equals, 106) | ||
201 | 65 | } | ||
202 | 66 | |||
203 | 67 | func (s *PushDecodeTestSuite) TestDecodeTelecomPersonal(c *C) { | ||
204 | 68 | inputBytes := []byte{ | ||
205 | 69 | 0x01, 0x06, 0x26, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, | ||
206 | 70 | 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x6d, 0x73, | ||
207 | 71 | 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0xaf, 0x84, 0xb4, 0x86, | ||
208 | 72 | 0xc3, 0x95, 0x8c, 0x82, 0x98, 0x6d, 0x30, 0x34, 0x42, 0x4b, 0x6b, 0x73, 0x69, | ||
209 | 73 | 0x6d, 0x30, 0x35, 0x40, 0x6d, 0x6d, 0x73, 0x2e, 0x70, 0x65, 0x72, 0x73, 0x6f, | ||
210 | 74 | 0x6e, 0x61, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x72, 0x00, 0x8d, 0x90, | ||
211 | 75 | 0x89, 0x19, 0x80, 0x2b, 0x35, 0x34, 0x33, 0x35, 0x31, 0x35, 0x39, 0x32, 0x34, | ||
212 | 76 | 0x39, 0x30, 0x36, 0x2f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, | ||
213 | 77 | 0x00, 0x8a, 0x80, 0x8e, 0x02, 0x74, 0x00, 0x88, 0x05, 0x81, 0x03, 0x02, 0xa2, | ||
214 | 78 | 0xff, 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x37, 0x32, 0x2e, | ||
215 | 79 | 0x32, 0x35, 0x2e, 0x37, 0x2e, 0x31, 0x33, 0x31, 0x2f, 0x3f, 0x6d, 0x65, 0x73, | ||
216 | 80 | 0x73, 0x61, 0x67, 0x65, 0x2d, 0x69, 0x64, 0x3d, 0x6d, 0x30, 0x34, 0x42, 0x4b, | ||
217 | 81 | 0x68, 0x34, 0x33, 0x65, 0x30, 0x33, 0x00, | ||
218 | 82 | } | ||
219 | 83 | dec := NewDecoder(inputBytes) | ||
220 | 84 | c.Assert(dec.Decode(s.pdu), IsNil) | ||
221 | 85 | |||
222 | 86 | c.Check(int(s.pdu.HeaderLength), Equals, 38) | ||
223 | 87 | c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID) | ||
224 | 88 | c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE) | ||
225 | 89 | c.Check(len(s.pdu.Data), Equals, 122) | ||
226 | 90 | } | ||
227 | 91 | |||
228 | 92 | func (s *PushDecodeTestSuite) TestDecodeATTUSA(c *C) { | ||
229 | 93 | inputBytes := []byte{ | ||
230 | 94 | 0x01, 0x06, 0x27, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, | ||
231 | 95 | 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, 0x6d, 0x73, | ||
232 | 96 | 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0xaf, 0x84, 0x8d, 0x01, | ||
233 | 97 | 0x82, 0xb4, 0x84, 0x8c, 0x82, 0x98, 0x44, 0x32, 0x30, 0x34, 0x30, 0x37, 0x31, | ||
234 | 98 | 0x36, 0x35, 0x36, 0x32, 0x34, 0x36, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, | ||
235 | 99 | 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x8d, 0x90, 0x89, 0x18, 0x80, | ||
236 | 100 | 0x2b, 0x31, 0x37, 0x37, 0x34, 0x32, 0x37, 0x30, 0x30, 0x36, 0x35, 0x39, 0x2f, | ||
237 | 101 | 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, 0x96, 0x02, 0xea, | ||
238 | 102 | 0x00, 0x8a, 0x80, 0x8e, 0x02, 0x80, 0x00, 0x88, 0x05, 0x81, 0x03, 0x05, 0x46, | ||
239 | 103 | 0x00, 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x36, 0x36, 0x2e, | ||
240 | 104 | 0x32, 0x31, 0x36, 0x2e, 0x31, 0x36, 0x36, 0x2e, 0x36, 0x37, 0x3a, 0x38, 0x30, | ||
241 | 105 | 0x30, 0x34, 0x2f, 0x30, 0x34, 0x30, 0x37, 0x31, 0x36, 0x35, 0x36, 0x32, 0x34, | ||
242 | 106 | 0x36, 0x30, 0x30, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, | ||
243 | 107 | 0x30, 0x30, 0x00, | ||
244 | 108 | } | ||
245 | 109 | dec := NewDecoder(inputBytes) | ||
246 | 110 | c.Assert(dec.Decode(s.pdu), IsNil) | ||
247 | 111 | |||
248 | 112 | c.Check(int(s.pdu.HeaderLength), Equals, 39) | ||
249 | 113 | c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID) | ||
250 | 114 | c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE) | ||
251 | 115 | c.Check(len(s.pdu.Data), Equals, 130) | ||
252 | 116 | } | ||
253 | 117 | |||
254 | 118 | func (s *PushDecodeTestSuite) TestDecodeSoneraFinland(c *C) { | ||
255 | 119 | inputBytes := []byte{ | ||
256 | 120 | 0x00, 0x06, 0x07, 0xbe, 0xaf, 0x84, 0x8d, 0xf2, 0xb4, 0x81, 0x8c, 0x82, 0x98, | ||
257 | 121 | 0x41, 0x42, 0x73, 0x54, 0x4c, 0x4e, 0x41, 0x4c, 0x41, 0x6d, 0x6d, 0x4e, 0x33, | ||
258 | 122 | 0x77, 0x72, 0x38, 0x32, 0x00, 0x8d, 0x92, 0x89, 0x19, 0x80, 0x2b, 0x33, 0x35, | ||
259 | 123 | 0x38, 0x34, 0x30, 0x37, 0x36, 0x39, 0x34, 0x34, 0x38, 0x34, 0x2f, 0x54, 0x59, | ||
260 | 124 | 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, 0x86, 0x81, 0x8a, 0x80, 0x8e, | ||
261 | 125 | 0x03, 0x03, 0x15, 0x85, 0x88, 0x05, 0x81, 0x03, 0x03, 0xf4, 0x7f, 0x83, 0x68, | ||
262 | 126 | 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6d, 0x6d, 0x73, 0x63, 0x36, 0x31, 0x3a, | ||
263 | 127 | 0x31, 0x30, 0x30, 0x32, 0x31, 0x2f, 0x6d, 0x6d, 0x73, 0x63, 0x2f, 0x36, 0x5f, | ||
264 | 128 | 0x31, 0x3f, 0x41, 0x42, 0x73, 0x54, 0x4c, 0x4e, 0x41, 0x4c, 0x41, 0x6d, 0x6d, | ||
265 | 129 | 0x4e, 0x33, 0x77, 0x72, 0x38, 0x32, 0x00, | ||
266 | 130 | } | ||
267 | 131 | dec := NewDecoder(inputBytes) | ||
268 | 132 | c.Assert(dec.Decode(s.pdu), IsNil) | ||
269 | 133 | |||
270 | 134 | c.Check(int(s.pdu.HeaderLength), Equals, 7) | ||
271 | 135 | c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID) | ||
272 | 136 | c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE) | ||
273 | 137 | c.Check(len(s.pdu.Data), Equals, 114) | ||
274 | 138 | } | ||
275 | 139 | |||
276 | 140 | func (s *PushDecodeTestSuite) TestDecodeNonPushPDU(c *C) { | ||
277 | 141 | inputBytes := []byte{ | ||
278 | 142 | 0x00, 0x07, 0x07, 0xbe, 0xaf, 0x84, 0x8d, 0xf2, 0xb4, 0x81, 0x8c, | ||
279 | 143 | } | ||
280 | 144 | dec := NewDecoder(inputBytes) | ||
281 | 145 | c.Assert(dec.Decode(s.pdu), DeepEquals, errors.New("7 != 6 is not a push PDU")) | ||
282 | 146 | } | ||
283 | 0 | 147 | ||
284 | === modified file 'ofono/pushagent.go' | |||
285 | --- ofono/pushagent.go 2014-05-12 13:47:34 +0000 | |||
286 | +++ ofono/pushagent.go 2014-06-21 19:40:20 +0000 | |||
287 | @@ -28,6 +28,7 @@ | |||
288 | 28 | "sync" | 28 | "sync" |
289 | 29 | 29 | ||
290 | 30 | "launchpad.net/go-dbus/v1" | 30 | "launchpad.net/go-dbus/v1" |
291 | 31 | "launchpad.net/nuntium/mms" | ||
292 | 31 | ) | 32 | ) |
293 | 32 | 33 | ||
294 | 33 | /* | 34 | /* |
295 | @@ -142,7 +143,7 @@ | |||
296 | 142 | return dbus.NewErrorMessage(msg, "org.freedesktop.DBus.Error", "DecodeError") | 143 | return dbus.NewErrorMessage(msg, "org.freedesktop.DBus.Error", "DecodeError") |
297 | 143 | } | 144 | } |
298 | 144 | // TODO later switch on ApplicationId and ContentType to different channels | 145 | // TODO later switch on ApplicationId and ContentType to different channels |
300 | 145 | if pdu.ApplicationId == 0x04 && pdu.ContentType == "application/vnd.wap.mms-message" { | 146 | if pdu.ApplicationId == mms.PUSH_APPLICATION_ID && pdu.ContentType == mms.VND_WAP_MMS_MESSAGE { |
301 | 146 | agent.Push <- pdu | 147 | agent.Push <- pdu |
302 | 147 | } else { | 148 | } else { |
303 | 148 | log.Print("Unhandled push pdu", pdu) | 149 | log.Print("Unhandled push pdu", pdu) |
Tested the fix in mako - works fine now.
Setting HeaderLength to 7 vnd.wap. mms-message TYPE=PLMN mmsc51: 10021/mmsc/ 5_1?A2iBdUt4k7Q Dnp1Xk mms.sonera. fi:8002 M
ContentType: application/
Setting ApplicationId to 4
Setting TransactionId to A2iBdUt4k7QDnp1Xk
Setting Version to 0x12 == 18
Setting From to +358407694484/
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://
2014/06/19 04:03:59 Context type: internet MessageCenter: MessageProxy: Active
: true
2014/06/19 04:03:59 Context type: mms MessageCenter: http://
essageProxy: 195.156.25.33:80 Active: false
2014/06/19 04:04:10 Starting download