Merge lp:~alfonsosanchezbeato/nuntium/nuntium-preferred-context into lp:nuntium/packaging

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 95
Merged at revision: 95
Proposed branch: lp:~alfonsosanchezbeato/nuntium/nuntium-preferred-context
Merge into: lp:nuntium/packaging
Prerequisite: lp:~alfonsosanchezbeato/nuntium/upstart-respawn
Diff against target: 494 lines (+147/-42)
7 files modified
debian/changelog (+11/-0)
mms/attachments.go (+3/-3)
mms/decoder.go (+18/-2)
ofono/context_test.go (+60/-28)
ofono/manager.go (+9/-3)
ofono/modem.go (+16/-6)
ofono/push_decode_test.go (+30/-0)
To merge this branch: bzr merge lp:~alfonsosanchezbeato/nuntium/nuntium-preferred-context
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Review via email: mp+259607@code.launchpad.net

Commit message

  [ Sergio Schvezov ]
  * Decode properly content type when there are parameters
  [ Alfonso Sanchez-Beato ]
  * Fix LP: #1441135 in the event of an oFono crash
  * Use oFono's Preferred property when selecting the mobile context

Description of the change

  [ Sergio Schvezov ]
  * Decode properly content type when there are parameters
  [ Alfonso Sanchez-Beato ]
  * Fix LP: #1441135 in the event of an oFono crash
  * Use oFono's Preferred property when selecting the mobile context

To post a comment you must log in.
95. By Alfonso Sanchez-Beato

Fix package version

Revision history for this message
Manuel de la Peña (mandel) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-04-22 00:58:08 +0000
+++ debian/changelog 2015-05-21 06:23:15 +0000
@@ -1,3 +1,14 @@
1nuntium (1.4+15.04.20150520-0ubuntu1) UNRELEASED; urgency=medium
2
3 [ Sergio Schvezov ]
4 * Decode properly content type when there are parameters
5
6 [ Alfonso Sanchez-Beato ]
7 * Fix LP: #1441135 in the event of an oFono crash
8 * Use oFono's Preferred property when selecting the mobile context
9
10 -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Wed, 20 May 2015 14:19:54 +0200
11
1nuntium (1.4+15.04.20150422-0ubuntu1) vivid; urgency=medium12nuntium (1.4+15.04.20150422-0ubuntu1) vivid; urgency=medium
213
3 [ CI Train Bot ]14 [ CI Train Bot ]
415
=== modified file 'mms/attachments.go'
--- mms/attachments.go 2014-09-23 19:58:36 +0000
+++ mms/attachments.go 2015-05-21 06:23:15 +0000
@@ -125,7 +125,7 @@
125 return dataParts125 return dataParts
126}126}
127127
128func (dec *MMSDecoder) ReadContentTypeParts(reflectedPdu *reflect.Value) error {128func (dec *MMSDecoder) ReadAttachmentParts(reflectedPdu *reflect.Value) error {
129 var err error129 var err error
130 var parts uint64130 var parts uint64
131 if parts, err = dec.ReadUintVar(nil, ""); err != nil {131 if parts, err = dec.ReadUintVar(nil, ""); err != nil {
@@ -147,7 +147,7 @@
147 var ct Attachment147 var ct Attachment
148 ct.Offset = headerEnd + 1148 ct.Offset = headerEnd + 1
149 ctReflected := reflect.ValueOf(&ct).Elem()149 ctReflected := reflect.ValueOf(&ct).Elem()
150 if err := dec.ReadContentType(&ctReflected); err == nil {150 if err := dec.ReadAttachment(&ctReflected); err == nil {
151 if err := dec.ReadMMSHeaders(&ctReflected, headerEnd); err != nil {151 if err := dec.ReadMMSHeaders(&ctReflected, headerEnd); err != nil {
152 return err152 return err
153 }153 }
@@ -191,7 +191,7 @@
191 return nil191 return nil
192}192}
193193
194func (dec *MMSDecoder) ReadContentType(ctMember *reflect.Value) error {194func (dec *MMSDecoder) ReadAttachment(ctMember *reflect.Value) error {
195 if dec.Offset+1 >= len(dec.Data) {195 if dec.Offset+1 >= len(dec.Data) {
196 return fmt.Errorf("message ended prematurely, offset: %d and payload length is %d", dec.Offset, len(dec.Data))196 return fmt.Errorf("message ended prematurely, offset: %d and payload length is %d", dec.Offset, len(dec.Data))
197 }197 }
198198
=== modified file 'mms/decoder.go'
--- mms/decoder.go 2015-01-15 15:45:48 +0000
+++ mms/decoder.go 2015-05-21 06:23:15 +0000
@@ -132,7 +132,17 @@
132132
133func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value, hdr string) (err error) {133func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value, hdr string) (err error) {
134 var mediaType string134 var mediaType string
135 var endOffset int
135 origOffset := dec.Offset136 origOffset := dec.Offset
137
138 if dec.Data[dec.Offset+1] <= SHORT_LENGTH_MAX || dec.Data[dec.Offset+1] == LENGTH_QUOTE {
139 if length, err := dec.ReadLength(nil); err != nil {
140 return err
141 } else {
142 endOffset = int(length) + dec.Offset
143 }
144 }
145
136 if dec.Data[dec.Offset+1] >= TEXT_MIN && dec.Data[dec.Offset+1] <= TEXT_MAX {146 if dec.Data[dec.Offset+1] >= TEXT_MIN && dec.Data[dec.Offset+1] <= TEXT_MAX {
137 if mediaType, err = dec.ReadString(nil, ""); err != nil {147 if mediaType, err = dec.ReadString(nil, ""); err != nil {
138 return err148 return err
@@ -143,8 +153,14 @@
143 return fmt.Errorf("cannot decode media type for field beginning with %#x@%d", dec.Data[origOffset], origOffset)153 return fmt.Errorf("cannot decode media type for field beginning with %#x@%d", dec.Data[origOffset], origOffset)
144 }154 }
145155
156 // skip the rest of the content type params
157 if endOffset > 0 {
158 dec.Offset = endOffset
159 }
160
146 reflectedPdu.FieldByName(hdr).SetString(mediaType)161 reflectedPdu.FieldByName(hdr).SetString(mediaType)
147 dec.log = dec.log + fmt.Sprintf("%s: %s\n", hdr, mediaType)162 dec.log = dec.log + fmt.Sprintf("%s: %s\n", hdr, mediaType)
163
148 return nil164 return nil
149}165}
150166
@@ -371,12 +387,12 @@
371 _, err = dec.ReadString(&reflectedPdu, "TransactionId")387 _, err = dec.ReadString(&reflectedPdu, "TransactionId")
372 case CONTENT_TYPE:388 case CONTENT_TYPE:
373 ctMember := reflectedPdu.FieldByName("Content")389 ctMember := reflectedPdu.FieldByName("Content")
374 if err = dec.ReadContentType(&ctMember); err != nil {390 if err = dec.ReadAttachment(&ctMember); err != nil {
375 return err391 return err
376 }392 }
377 //application/vnd.wap.multipart.related and others393 //application/vnd.wap.multipart.related and others
378 if ctMember.FieldByName("MediaType").String() != "text/plain" {394 if ctMember.FieldByName("MediaType").String() != "text/plain" {
379 err = dec.ReadContentTypeParts(&reflectedPdu)395 err = dec.ReadAttachmentParts(&reflectedPdu)
380 } else {396 } else {
381 dec.Offset++397 dec.Offset++
382 _, err = dec.ReadBoundedBytes(&reflectedPdu, "Data", len(dec.Data))398 _, err = dec.ReadBoundedBytes(&reflectedPdu, "Data", len(dec.Data))
383399
=== modified file 'ofono/context_test.go'
--- ofono/context_test.go 2014-09-30 18:01:12 +0000
+++ ofono/context_test.go 2015-05-21 06:23:15 +0000
@@ -38,11 +38,12 @@
3838
39var proxy ProxyInfo39var proxy ProxyInfo
4040
41func makeGenericContextProperty(name, cType string, active, messageCenter, messageProxy bool) PropertiesType {41func makeGenericContextProperty(name, cType string, active, messageCenter, messageProxy, preferred bool) PropertiesType {
42 p := make(PropertiesType)42 p := make(PropertiesType)
43 p["Name"] = dbus.Variant{name}43 p["Name"] = dbus.Variant{name}
44 p["Type"] = dbus.Variant{cType}44 p["Type"] = dbus.Variant{cType}
45 p["Active"] = dbus.Variant{active}45 p["Active"] = dbus.Variant{active}
46 p["Preferred"] = dbus.Variant{preferred}
46 if messageCenter {47 if messageCenter {
47 p["MessageCenter"] = dbus.Variant{"http://messagecenter.com"}48 p["MessageCenter"] = dbus.Variant{"http://messagecenter.com"}
48 } else {49 } else {
@@ -80,7 +81,7 @@
80func (s *ContextTestSuite) TestMMSOverInternet(c *C) {81func (s *ContextTestSuite) TestMMSOverInternet(c *C) {
81 context1 := OfonoContext{82 context1 := OfonoContext{
82 ObjectPath: "/ril_0/context1",83 ObjectPath: "/ril_0/context1",
83 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),84 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
84 }85 }
85 s.contexts = append(s.contexts, context1)86 s.contexts = append(s.contexts, context1)
8687
@@ -93,7 +94,7 @@
93func (s *ContextTestSuite) TestMMSOverInactiveInternet(c *C) {94func (s *ContextTestSuite) TestMMSOverInactiveInternet(c *C) {
94 context1 := OfonoContext{95 context1 := OfonoContext{
95 ObjectPath: "/ril_0/context1",96 ObjectPath: "/ril_0/context1",
96 Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, true),97 Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, true, false),
97 }98 }
98 s.contexts = append(s.contexts, context1)99 s.contexts = append(s.contexts, context1)
99100
@@ -105,7 +106,7 @@
105func (s *ContextTestSuite) TestMMSOverInternetNoProxy(c *C) {106func (s *ContextTestSuite) TestMMSOverInternetNoProxy(c *C) {
106 context1 := OfonoContext{107 context1 := OfonoContext{
107 ObjectPath: "/ril_0/context1",108 ObjectPath: "/ril_0/context1",
108 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),109 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
109 }110 }
110 s.contexts = append(s.contexts, context1)111 s.contexts = append(s.contexts, context1)
111112
@@ -118,13 +119,13 @@
118func (s *ContextTestSuite) TestMMSOverMMS(c *C) {119func (s *ContextTestSuite) TestMMSOverMMS(c *C) {
119 context1 := OfonoContext{120 context1 := OfonoContext{
120 ObjectPath: "/ril_0/context1",121 ObjectPath: "/ril_0/context1",
121 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false),122 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false, false),
122 }123 }
123 s.contexts = append(s.contexts, context1)124 s.contexts = append(s.contexts, context1)
124125
125 context2 := OfonoContext{126 context2 := OfonoContext{
126 ObjectPath: "/ril_0/context2",127 ObjectPath: "/ril_0/context2",
127 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, true),128 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, true, false),
128 }129 }
129 s.contexts = append(s.contexts, context2)130 s.contexts = append(s.contexts, context2)
130131
@@ -137,13 +138,13 @@
137func (s *ContextTestSuite) TestMMSOverMMSNoProxy(c *C) {138func (s *ContextTestSuite) TestMMSOverMMSNoProxy(c *C) {
138 context1 := OfonoContext{139 context1 := OfonoContext{
139 ObjectPath: "/ril_0/context1",140 ObjectPath: "/ril_0/context1",
140 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false),141 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false, false),
141 }142 }
142 s.contexts = append(s.contexts, context1)143 s.contexts = append(s.contexts, context1)
143144
144 context2 := OfonoContext{145 context2 := OfonoContext{
145 ObjectPath: "/ril_0/context2",146 ObjectPath: "/ril_0/context2",
146 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),147 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
147 }148 }
148 s.contexts = append(s.contexts, context2)149 s.contexts = append(s.contexts, context2)
149150
@@ -156,13 +157,13 @@
156func (s *ContextTestSuite) TestMMSMoreThanOneValid(c *C) {157func (s *ContextTestSuite) TestMMSMoreThanOneValid(c *C) {
157 context1 := OfonoContext{158 context1 := OfonoContext{
158 ObjectPath: "/ril_0/context1",159 ObjectPath: "/ril_0/context1",
159 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),160 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
160 }161 }
161 s.contexts = append(s.contexts, context1)162 s.contexts = append(s.contexts, context1)
162163
163 context2 := OfonoContext{164 context2 := OfonoContext{
164 ObjectPath: "/ril_0/context2",165 ObjectPath: "/ril_0/context2",
165 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),166 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
166 }167 }
167 s.contexts = append(s.contexts, context2)168 s.contexts = append(s.contexts, context2)
168169
@@ -176,19 +177,19 @@
176func (s *ContextTestSuite) TestMMSMoreThanOneValidContextSelectPreferred(c *C) {177func (s *ContextTestSuite) TestMMSMoreThanOneValidContextSelectPreferred(c *C) {
177 context1 := OfonoContext{178 context1 := OfonoContext{
178 ObjectPath: "/ril_0/context1",179 ObjectPath: "/ril_0/context1",
179 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),180 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
180 }181 }
181 s.contexts = append(s.contexts, context1)182 s.contexts = append(s.contexts, context1)
182183
183 context2 := OfonoContext{184 context2 := OfonoContext{
184 ObjectPath: "/ril_0/context2",185 ObjectPath: "/ril_0/context2",
185 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),186 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
186 }187 }
187 s.contexts = append(s.contexts, context2)188 s.contexts = append(s.contexts, context2)
188189
189 context3 := OfonoContext{190 context3 := OfonoContext{
190 ObjectPath: "/ril_0/context3",191 ObjectPath: "/ril_0/context3",
191 Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false),192 Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false),
192 }193 }
193 s.contexts = append(s.contexts, context3)194 s.contexts = append(s.contexts, context3)
194195
@@ -203,19 +204,19 @@
203func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNoMatch(c *C) {204func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNoMatch(c *C) {
204 context1 := OfonoContext{205 context1 := OfonoContext{
205 ObjectPath: "/ril_0/context1",206 ObjectPath: "/ril_0/context1",
206 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),207 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
207 }208 }
208 s.contexts = append(s.contexts, context1)209 s.contexts = append(s.contexts, context1)
209210
210 context2 := OfonoContext{211 context2 := OfonoContext{
211 ObjectPath: "/ril_0/context2",212 ObjectPath: "/ril_0/context2",
212 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),213 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
213 }214 }
214 s.contexts = append(s.contexts, context2)215 s.contexts = append(s.contexts, context2)
215216
216 context3 := OfonoContext{217 context3 := OfonoContext{
217 ObjectPath: "/ril_0/context3",218 ObjectPath: "/ril_0/context3",
218 Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false),219 Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false),
219 }220 }
220 s.contexts = append(s.contexts, context3)221 s.contexts = append(s.contexts, context3)
221222
@@ -230,25 +231,25 @@
230func (s *ContextTestSuite) TestMMSMoreThanOneValidContext2Active(c *C) {231func (s *ContextTestSuite) TestMMSMoreThanOneValidContext2Active(c *C) {
231 context0 := OfonoContext{232 context0 := OfonoContext{
232 ObjectPath: "/ril_0/context0",233 ObjectPath: "/ril_0/context0",
233 Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false),234 Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false, false),
234 }235 }
235 s.contexts = append(s.contexts, context0)236 s.contexts = append(s.contexts, context0)
236237
237 context1 := OfonoContext{238 context1 := OfonoContext{
238 ObjectPath: "/ril_0/context1",239 ObjectPath: "/ril_0/context1",
239 Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false),240 Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, false),
240 }241 }
241 s.contexts = append(s.contexts, context1)242 s.contexts = append(s.contexts, context1)
242243
243 context2 := OfonoContext{244 context2 := OfonoContext{
244 ObjectPath: "/ril_0/context2",245 ObjectPath: "/ril_0/context2",
245 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),246 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
246 }247 }
247 s.contexts = append(s.contexts, context2)248 s.contexts = append(s.contexts, context2)
248249
249 context3 := OfonoContext{250 context3 := OfonoContext{
250 ObjectPath: "/ril_0/context3",251 ObjectPath: "/ril_0/context3",
251 Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false),252 Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false),
252 }253 }
253 s.contexts = append(s.contexts, context3)254 s.contexts = append(s.contexts, context3)
254255
@@ -263,25 +264,25 @@
263func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNotActive(c *C) {264func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNotActive(c *C) {
264 context0 := OfonoContext{265 context0 := OfonoContext{
265 ObjectPath: "/ril_0/context0",266 ObjectPath: "/ril_0/context0",
266 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),267 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
267 }268 }
268 s.contexts = append(s.contexts, context0)269 s.contexts = append(s.contexts, context0)
269270
270 context1 := OfonoContext{271 context1 := OfonoContext{
271 ObjectPath: "/ril_0/context1",272 ObjectPath: "/ril_0/context1",
272 Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false),273 Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, false),
273 }274 }
274 s.contexts = append(s.contexts, context1)275 s.contexts = append(s.contexts, context1)
275276
276 context2 := OfonoContext{277 context2 := OfonoContext{
277 ObjectPath: "/ril_0/context2",278 ObjectPath: "/ril_0/context2",
278 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false),279 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
279 }280 }
280 s.contexts = append(s.contexts, context2)281 s.contexts = append(s.contexts, context2)
281282
282 context3 := OfonoContext{283 context3 := OfonoContext{
283 ObjectPath: "/ril_0/context3",284 ObjectPath: "/ril_0/context3",
284 Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false),285 Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false),
285 }286 }
286287
287 s.contexts = append(s.contexts, context3)288 s.contexts = append(s.contexts, context3)
@@ -295,10 +296,41 @@
295 c.Check(contexts[3], DeepEquals, context2)296 c.Check(contexts[3], DeepEquals, context2)
296}297}
297298
299func (s *ContextTestSuite) TestOnePreferredContext(c *C) {
300 context0 := OfonoContext{
301 ObjectPath: "/ril_0/context0",
302 Properties: makeGenericContextProperty("Context0", contextTypeInternet, true, true, false, false),
303 }
304 s.contexts = append(s.contexts, context0)
305
306 context1 := OfonoContext{
307 ObjectPath: "/ril_0/context1",
308 Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, true),
309 }
310 s.contexts = append(s.contexts, context1)
311
312 context2 := OfonoContext{
313 ObjectPath: "/ril_0/context2",
314 Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false),
315 }
316 s.contexts = append(s.contexts, context2)
317
318 context3 := OfonoContext{
319 ObjectPath: "/ril_0/context3",
320 Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false),
321 }
322 s.contexts = append(s.contexts, context3)
323
324 contexts, err := s.modem.GetMMSContexts("")
325 c.Assert(err, IsNil)
326 c.Assert(len(contexts), Equals, 1)
327 c.Check(contexts[0], DeepEquals, context1)
328}
329
298func (s *ContextTestSuite) TestGetProxy(c *C) {330func (s *ContextTestSuite) TestGetProxy(c *C) {
299 context := OfonoContext{331 context := OfonoContext{
300 ObjectPath: "/ril_0/context1",332 ObjectPath: "/ril_0/context1",
301 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),333 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
302 }334 }
303335
304 p, err := context.GetProxy()336 p, err := context.GetProxy()
@@ -309,7 +341,7 @@
309func (s *ContextTestSuite) TestGetProxyNoProxy(c *C) {341func (s *ContextTestSuite) TestGetProxyNoProxy(c *C) {
310 context := OfonoContext{342 context := OfonoContext{
311 ObjectPath: "/ril_0/context1",343 ObjectPath: "/ril_0/context1",
312 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false),344 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false),
313 }345 }
314346
315 p, err := context.GetProxy()347 p, err := context.GetProxy()
@@ -320,7 +352,7 @@
320func (s *ContextTestSuite) TestGetProxyWithHTTP(c *C) {352func (s *ContextTestSuite) TestGetProxyWithHTTP(c *C) {
321 context := OfonoContext{353 context := OfonoContext{
322 ObjectPath: "/ril_0/context1",354 ObjectPath: "/ril_0/context1",
323 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),355 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
324 }356 }
325 context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s:%d", proxy.Host, proxy.Port)}357 context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s:%d", proxy.Host, proxy.Port)}
326358
@@ -332,7 +364,7 @@
332func (s *ContextTestSuite) TestGetProxyNoPort(c *C) {364func (s *ContextTestSuite) TestGetProxyNoPort(c *C) {
333 context := OfonoContext{365 context := OfonoContext{
334 ObjectPath: "/ril_0/context1",366 ObjectPath: "/ril_0/context1",
335 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true),367 Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false),
336 }368 }
337 context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s", proxy.Host)}369 context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s", proxy.Host)}
338370
339371
=== modified file 'ofono/manager.go'
--- ofono/manager.go 2014-05-08 23:23:22 +0000
+++ ofono/manager.go 2015-05-21 06:23:15 +0000
@@ -46,18 +46,24 @@
46}46}
4747
48func (mm *ModemManager) Init() error {48func (mm *ModemManager) Init() error {
49 modemAddedSignal, err := connectToSignal(mm.conn, "/", OFONO_MANAGER_INTERFACE, "ModemAdded")49 //Use a different connection for the modem signals to avoid go-dbus blocking issues
50 conn, err := dbus.Connect(dbus.SystemBus)
51 if err != nil {
52 return err;
53 }
54
55 modemAddedSignal, err := connectToSignal(conn, "/", OFONO_MANAGER_INTERFACE, "ModemAdded")
50 if err != nil {56 if err != nil {
51 return err57 return err
52 }58 }
53 modemRemovedSignal, err := connectToSignal(mm.conn, "/", OFONO_MANAGER_INTERFACE, "ModemRemoved")59 modemRemovedSignal, err := connectToSignal(conn, "/", OFONO_MANAGER_INTERFACE, "ModemRemoved")
54 if err != nil {60 if err != nil {
55 return err61 return err
56 }62 }
57 go mm.watchModems(modemAddedSignal, modemRemovedSignal)63 go mm.watchModems(modemAddedSignal, modemRemovedSignal)
5864
59 //Check for existing modems65 //Check for existing modems
60 modemPaths, err := getModems(mm.conn)66 modemPaths, err := getModems(conn)
61 if err != nil {67 if err != nil {
62 log.Print("Cannot preemptively add modems: ", err)68 log.Print("Cannot preemptively add modems: ", err)
63 } else {69 } else {
6470
=== modified file 'ofono/modem.go'
--- ofono/modem.go 2014-10-02 01:24:13 +0000
+++ ofono/modem.go 2015-05-21 06:23:15 +0000
@@ -310,6 +310,10 @@
310 return reflect.ValueOf(oContext.Properties["Active"].Value).Bool()310 return reflect.ValueOf(oContext.Properties["Active"].Value).Bool()
311}311}
312312
313func (oContext OfonoContext) isPreferred() bool {
314 return reflect.ValueOf(oContext.Properties["Preferred"].Value).Bool()
315}
316
313func (oContext OfonoContext) hasMessageCenter() bool {317func (oContext OfonoContext) hasMessageCenter() bool {
314 return oContext.messageCenter() != ""318 return oContext.messageCenter() != ""
315}319}
@@ -371,10 +375,11 @@
371//and a MessageCenter within the context.375//and a MessageCenter within the context.
372//376//
373//The following rules take place:377//The following rules take place:
374//- check current type=internet context for MessageProxy & MessageCenter;378//- if current type=internet context, check for MessageProxy & MessageCenter;
375// if they exist and aren't empty AND the context is active, select it as the379// if they exist and aren't empty AND the context is active, add it to the list
376// context to use for MMS.380//- if current type=mms, add it to the list
377//- otherwise search for type=mms, if found, use it and activate381//- if ofono's ConnectionManager.Preferred property is set, use only that context
382//- prioritize active and recently successfully used contexts
378//383//
379//Returns either the type=internet context or the type=mms, if none is found384//Returns either the type=internet context or the type=mms, if none is found
380//an error is returned.385//an error is returned.
@@ -386,7 +391,10 @@
386391
387 for _, context := range contexts {392 for _, context := range contexts {
388 if (context.isTypeInternet() && context.isActive() && context.hasMessageCenter()) || context.isTypeMMS() {393 if (context.isTypeInternet() && context.isActive() && context.hasMessageCenter()) || context.isTypeMMS() {
389 if context.ObjectPath == preferredContext || context.isActive() {394 if context.isPreferred() {
395 mmsContexts = []OfonoContext{context}
396 break
397 } else if context.ObjectPath == preferredContext || context.isActive() {
390 mmsContexts = append([]OfonoContext{context}, mmsContexts...)398 mmsContexts = append([]OfonoContext{context}, mmsContexts...)
391 } else {399 } else {
392 mmsContexts = append(mmsContexts, context)400 mmsContexts = append(mmsContexts, context)
@@ -418,7 +426,9 @@
418}426}
419427
420func (modem *Modem) Delete() {428func (modem *Modem) Delete() {
421 modem.IdentityRemoved <- modem.identity429 if modem.identity != "" {
430 modem.IdentityRemoved <- modem.identity
431 }
422 modem.modemSignal.Cancel()432 modem.modemSignal.Cancel()
423 modem.modemSignal.C = nil433 modem.modemSignal.C = nil
424 modem.simSignal.Cancel()434 modem.simSignal.Cancel()
425435
=== modified file 'ofono/push_decode_test.go'
--- ofono/push_decode_test.go 2014-10-21 13:13:11 +0000
+++ ofono/push_decode_test.go 2015-05-21 06:23:15 +0000
@@ -169,3 +169,33 @@
169 dec := NewDecoder(inputBytes)169 dec := NewDecoder(inputBytes)
170 c.Assert(dec.Decode(s.pdu), DeepEquals, errors.New("7 != 6 is not a push PDU"))170 c.Assert(dec.Decode(s.pdu), DeepEquals, errors.New("7 != 6 is not a push PDU"))
171}171}
172
173func (s *PushDecodeTestSuite) TestDecodeTMobileUSA(c *C) {
174 inputBytes := []byte{
175 0xc0, 0x06, 0x28, 0x1f, 0x22, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74,
176 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d,
177 0x6d, 0x73, 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x81, 0x84,
178 0x8d, 0x80, 0xaf, 0x84, 0x8c, 0x82, 0x98, 0x6d, 0x61, 0x76, 0x6f, 0x64, 0x69,
179 0x2d, 0x37, 0x2d, 0x38, 0x39, 0x2d, 0x31, 0x63, 0x30, 0x2d, 0x37, 0x2d, 0x63,
180 0x61, 0x2d, 0x35, 0x30, 0x66, 0x39, 0x33, 0x38, 0x34, 0x33, 0x2d, 0x37, 0x2d,
181 0x31, 0x33, 0x62, 0x2d, 0x32, 0x65, 0x62, 0x2d, 0x31, 0x2d, 0x63, 0x61, 0x2d,
182 0x33, 0x36, 0x31, 0x65, 0x33, 0x31, 0x35, 0x00, 0x8d, 0x92, 0x89, 0x1a, 0x80,
183 0x18, 0x83, 0x2b, 0x31, 0x39, 0x31, 0x39, 0x39, 0x30, 0x33, 0x33, 0x34, 0x38,
184 0x38, 0x2f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, 0x8a,
185 0x80, 0x8e, 0x03, 0x0f, 0x21, 0x9f, 0x88, 0x05, 0x81, 0x03, 0x03, 0xf4, 0x80,
186 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x61, 0x74, 0x6c, 0x32, 0x6d,
187 0x6f, 0x73, 0x67, 0x65, 0x74, 0x2e, 0x6d, 0x73, 0x67, 0x2e, 0x65, 0x6e, 0x67,
188 0x2e, 0x74, 0x2d, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d,
189 0x2f, 0x6d, 0x6d, 0x73, 0x2f, 0x77, 0x61, 0x70, 0x65, 0x6e, 0x63, 0x3f, 0x54,
190 0x3d, 0x6d, 0x61, 0x76, 0x6f, 0x64, 0x69, 0x2d, 0x37, 0x2d, 0x31, 0x33, 0x62,
191 0x2d, 0x32, 0x65, 0x62, 0x2d, 0x31, 0x2d, 0x63, 0x61, 0x2d, 0x33, 0x36, 0x31,
192 0x65, 0x33, 0x31, 0x35, 0x00,
193 }
194 dec := NewDecoder(inputBytes)
195 c.Assert(dec.Decode(s.pdu), IsNil)
196
197 c.Check(int(s.pdu.HeaderLength), Equals, 40)
198 c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID)
199 c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE)
200 c.Check(len(s.pdu.Data), Equals, 183)
201}

Subscribers

People subscribed via source and target branches