Merge lp:~alfonsosanchezbeato/nuntium/nuntium-preferred-context into lp:nuntium/packaging
- nuntium-preferred-context
- Merge into 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 |
Related bugs: |
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
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2015-04-22 00:58:08 +0000 | |||
3 | +++ debian/changelog 2015-05-21 06:23:15 +0000 | |||
4 | @@ -1,3 +1,14 @@ | |||
5 | 1 | nuntium (1.4+15.04.20150520-0ubuntu1) UNRELEASED; urgency=medium | ||
6 | 2 | |||
7 | 3 | [ Sergio Schvezov ] | ||
8 | 4 | * Decode properly content type when there are parameters | ||
9 | 5 | |||
10 | 6 | [ Alfonso Sanchez-Beato ] | ||
11 | 7 | * Fix LP: #1441135 in the event of an oFono crash | ||
12 | 8 | * Use oFono's Preferred property when selecting the mobile context | ||
13 | 9 | |||
14 | 10 | -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Wed, 20 May 2015 14:19:54 +0200 | ||
15 | 11 | |||
16 | 1 | nuntium (1.4+15.04.20150422-0ubuntu1) vivid; urgency=medium | 12 | nuntium (1.4+15.04.20150422-0ubuntu1) vivid; urgency=medium |
17 | 2 | 13 | ||
18 | 3 | [ CI Train Bot ] | 14 | [ CI Train Bot ] |
19 | 4 | 15 | ||
20 | === modified file 'mms/attachments.go' | |||
21 | --- mms/attachments.go 2014-09-23 19:58:36 +0000 | |||
22 | +++ mms/attachments.go 2015-05-21 06:23:15 +0000 | |||
23 | @@ -125,7 +125,7 @@ | |||
24 | 125 | return dataParts | 125 | return dataParts |
25 | 126 | } | 126 | } |
26 | 127 | 127 | ||
28 | 128 | func (dec *MMSDecoder) ReadContentTypeParts(reflectedPdu *reflect.Value) error { | 128 | func (dec *MMSDecoder) ReadAttachmentParts(reflectedPdu *reflect.Value) error { |
29 | 129 | var err error | 129 | var err error |
30 | 130 | var parts uint64 | 130 | var parts uint64 |
31 | 131 | if parts, err = dec.ReadUintVar(nil, ""); err != nil { | 131 | if parts, err = dec.ReadUintVar(nil, ""); err != nil { |
32 | @@ -147,7 +147,7 @@ | |||
33 | 147 | var ct Attachment | 147 | var ct Attachment |
34 | 148 | ct.Offset = headerEnd + 1 | 148 | ct.Offset = headerEnd + 1 |
35 | 149 | ctReflected := reflect.ValueOf(&ct).Elem() | 149 | ctReflected := reflect.ValueOf(&ct).Elem() |
37 | 150 | if err := dec.ReadContentType(&ctReflected); err == nil { | 150 | if err := dec.ReadAttachment(&ctReflected); err == nil { |
38 | 151 | if err := dec.ReadMMSHeaders(&ctReflected, headerEnd); err != nil { | 151 | if err := dec.ReadMMSHeaders(&ctReflected, headerEnd); err != nil { |
39 | 152 | return err | 152 | return err |
40 | 153 | } | 153 | } |
41 | @@ -191,7 +191,7 @@ | |||
42 | 191 | return nil | 191 | return nil |
43 | 192 | } | 192 | } |
44 | 193 | 193 | ||
46 | 194 | func (dec *MMSDecoder) ReadContentType(ctMember *reflect.Value) error { | 194 | func (dec *MMSDecoder) ReadAttachment(ctMember *reflect.Value) error { |
47 | 195 | if dec.Offset+1 >= len(dec.Data) { | 195 | if dec.Offset+1 >= len(dec.Data) { |
48 | 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)) |
49 | 197 | } | 197 | } |
50 | 198 | 198 | ||
51 | === modified file 'mms/decoder.go' | |||
52 | --- mms/decoder.go 2015-01-15 15:45:48 +0000 | |||
53 | +++ mms/decoder.go 2015-05-21 06:23:15 +0000 | |||
54 | @@ -132,7 +132,17 @@ | |||
55 | 132 | 132 | ||
56 | 133 | func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value, hdr string) (err error) { | 133 | func (dec *MMSDecoder) ReadMediaType(reflectedPdu *reflect.Value, hdr string) (err error) { |
57 | 134 | var mediaType string | 134 | var mediaType string |
58 | 135 | var endOffset int | ||
59 | 135 | origOffset := dec.Offset | 136 | origOffset := dec.Offset |
60 | 137 | |||
61 | 138 | if dec.Data[dec.Offset+1] <= SHORT_LENGTH_MAX || dec.Data[dec.Offset+1] == LENGTH_QUOTE { | ||
62 | 139 | if length, err := dec.ReadLength(nil); err != nil { | ||
63 | 140 | return err | ||
64 | 141 | } else { | ||
65 | 142 | endOffset = int(length) + dec.Offset | ||
66 | 143 | } | ||
67 | 144 | } | ||
68 | 145 | |||
69 | 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 { |
70 | 137 | if mediaType, err = dec.ReadString(nil, ""); err != nil { | 147 | if mediaType, err = dec.ReadString(nil, ""); err != nil { |
71 | 138 | return err | 148 | return err |
72 | @@ -143,8 +153,14 @@ | |||
73 | 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) |
74 | 144 | } | 154 | } |
75 | 145 | 155 | ||
76 | 156 | // skip the rest of the content type params | ||
77 | 157 | if endOffset > 0 { | ||
78 | 158 | dec.Offset = endOffset | ||
79 | 159 | } | ||
80 | 160 | |||
81 | 146 | reflectedPdu.FieldByName(hdr).SetString(mediaType) | 161 | reflectedPdu.FieldByName(hdr).SetString(mediaType) |
82 | 147 | dec.log = dec.log + fmt.Sprintf("%s: %s\n", hdr, mediaType) | 162 | dec.log = dec.log + fmt.Sprintf("%s: %s\n", hdr, mediaType) |
83 | 163 | |||
84 | 148 | return nil | 164 | return nil |
85 | 149 | } | 165 | } |
86 | 150 | 166 | ||
87 | @@ -371,12 +387,12 @@ | |||
88 | 371 | _, err = dec.ReadString(&reflectedPdu, "TransactionId") | 387 | _, err = dec.ReadString(&reflectedPdu, "TransactionId") |
89 | 372 | case CONTENT_TYPE: | 388 | case CONTENT_TYPE: |
90 | 373 | ctMember := reflectedPdu.FieldByName("Content") | 389 | ctMember := reflectedPdu.FieldByName("Content") |
92 | 374 | if err = dec.ReadContentType(&ctMember); err != nil { | 390 | if err = dec.ReadAttachment(&ctMember); err != nil { |
93 | 375 | return err | 391 | return err |
94 | 376 | } | 392 | } |
95 | 377 | //application/vnd.wap.multipart.related and others | 393 | //application/vnd.wap.multipart.related and others |
96 | 378 | if ctMember.FieldByName("MediaType").String() != "text/plain" { | 394 | if ctMember.FieldByName("MediaType").String() != "text/plain" { |
98 | 379 | err = dec.ReadContentTypeParts(&reflectedPdu) | 395 | err = dec.ReadAttachmentParts(&reflectedPdu) |
99 | 380 | } else { | 396 | } else { |
100 | 381 | dec.Offset++ | 397 | dec.Offset++ |
101 | 382 | _, err = dec.ReadBoundedBytes(&reflectedPdu, "Data", len(dec.Data)) | 398 | _, err = dec.ReadBoundedBytes(&reflectedPdu, "Data", len(dec.Data)) |
102 | 383 | 399 | ||
103 | === modified file 'ofono/context_test.go' | |||
104 | --- ofono/context_test.go 2014-09-30 18:01:12 +0000 | |||
105 | +++ ofono/context_test.go 2015-05-21 06:23:15 +0000 | |||
106 | @@ -38,11 +38,12 @@ | |||
107 | 38 | 38 | ||
108 | 39 | var proxy ProxyInfo | 39 | var proxy ProxyInfo |
109 | 40 | 40 | ||
111 | 41 | func makeGenericContextProperty(name, cType string, active, messageCenter, messageProxy bool) PropertiesType { | 41 | func makeGenericContextProperty(name, cType string, active, messageCenter, messageProxy, preferred bool) PropertiesType { |
112 | 42 | p := make(PropertiesType) | 42 | p := make(PropertiesType) |
113 | 43 | p["Name"] = dbus.Variant{name} | 43 | p["Name"] = dbus.Variant{name} |
114 | 44 | p["Type"] = dbus.Variant{cType} | 44 | p["Type"] = dbus.Variant{cType} |
115 | 45 | p["Active"] = dbus.Variant{active} | 45 | p["Active"] = dbus.Variant{active} |
116 | 46 | p["Preferred"] = dbus.Variant{preferred} | ||
117 | 46 | if messageCenter { | 47 | if messageCenter { |
118 | 47 | p["MessageCenter"] = dbus.Variant{"http://messagecenter.com"} | 48 | p["MessageCenter"] = dbus.Variant{"http://messagecenter.com"} |
119 | 48 | } else { | 49 | } else { |
120 | @@ -80,7 +81,7 @@ | |||
121 | 80 | func (s *ContextTestSuite) TestMMSOverInternet(c *C) { | 81 | func (s *ContextTestSuite) TestMMSOverInternet(c *C) { |
122 | 81 | context1 := OfonoContext{ | 82 | context1 := OfonoContext{ |
123 | 82 | ObjectPath: "/ril_0/context1", | 83 | ObjectPath: "/ril_0/context1", |
125 | 83 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true), | 84 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false), |
126 | 84 | } | 85 | } |
127 | 85 | s.contexts = append(s.contexts, context1) | 86 | s.contexts = append(s.contexts, context1) |
128 | 86 | 87 | ||
129 | @@ -93,7 +94,7 @@ | |||
130 | 93 | func (s *ContextTestSuite) TestMMSOverInactiveInternet(c *C) { | 94 | func (s *ContextTestSuite) TestMMSOverInactiveInternet(c *C) { |
131 | 94 | context1 := OfonoContext{ | 95 | context1 := OfonoContext{ |
132 | 95 | ObjectPath: "/ril_0/context1", | 96 | ObjectPath: "/ril_0/context1", |
134 | 96 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, true), | 97 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, true, false), |
135 | 97 | } | 98 | } |
136 | 98 | s.contexts = append(s.contexts, context1) | 99 | s.contexts = append(s.contexts, context1) |
137 | 99 | 100 | ||
138 | @@ -105,7 +106,7 @@ | |||
139 | 105 | func (s *ContextTestSuite) TestMMSOverInternetNoProxy(c *C) { | 106 | func (s *ContextTestSuite) TestMMSOverInternetNoProxy(c *C) { |
140 | 106 | context1 := OfonoContext{ | 107 | context1 := OfonoContext{ |
141 | 107 | ObjectPath: "/ril_0/context1", | 108 | ObjectPath: "/ril_0/context1", |
143 | 108 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false), | 109 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false), |
144 | 109 | } | 110 | } |
145 | 110 | s.contexts = append(s.contexts, context1) | 111 | s.contexts = append(s.contexts, context1) |
146 | 111 | 112 | ||
147 | @@ -118,13 +119,13 @@ | |||
148 | 118 | func (s *ContextTestSuite) TestMMSOverMMS(c *C) { | 119 | func (s *ContextTestSuite) TestMMSOverMMS(c *C) { |
149 | 119 | context1 := OfonoContext{ | 120 | context1 := OfonoContext{ |
150 | 120 | ObjectPath: "/ril_0/context1", | 121 | ObjectPath: "/ril_0/context1", |
152 | 121 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false), | 122 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false, false), |
153 | 122 | } | 123 | } |
154 | 123 | s.contexts = append(s.contexts, context1) | 124 | s.contexts = append(s.contexts, context1) |
155 | 124 | 125 | ||
156 | 125 | context2 := OfonoContext{ | 126 | context2 := OfonoContext{ |
157 | 126 | ObjectPath: "/ril_0/context2", | 127 | ObjectPath: "/ril_0/context2", |
159 | 127 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, true), | 128 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, true, false), |
160 | 128 | } | 129 | } |
161 | 129 | s.contexts = append(s.contexts, context2) | 130 | s.contexts = append(s.contexts, context2) |
162 | 130 | 131 | ||
163 | @@ -137,13 +138,13 @@ | |||
164 | 137 | func (s *ContextTestSuite) TestMMSOverMMSNoProxy(c *C) { | 138 | func (s *ContextTestSuite) TestMMSOverMMSNoProxy(c *C) { |
165 | 138 | context1 := OfonoContext{ | 139 | context1 := OfonoContext{ |
166 | 139 | ObjectPath: "/ril_0/context1", | 140 | ObjectPath: "/ril_0/context1", |
168 | 140 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false), | 141 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, false, false, false), |
169 | 141 | } | 142 | } |
170 | 142 | s.contexts = append(s.contexts, context1) | 143 | s.contexts = append(s.contexts, context1) |
171 | 143 | 144 | ||
172 | 144 | context2 := OfonoContext{ | 145 | context2 := OfonoContext{ |
173 | 145 | ObjectPath: "/ril_0/context2", | 146 | ObjectPath: "/ril_0/context2", |
175 | 146 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false), | 147 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), |
176 | 147 | } | 148 | } |
177 | 148 | s.contexts = append(s.contexts, context2) | 149 | s.contexts = append(s.contexts, context2) |
178 | 149 | 150 | ||
179 | @@ -156,13 +157,13 @@ | |||
180 | 156 | func (s *ContextTestSuite) TestMMSMoreThanOneValid(c *C) { | 157 | func (s *ContextTestSuite) TestMMSMoreThanOneValid(c *C) { |
181 | 157 | context1 := OfonoContext{ | 158 | context1 := OfonoContext{ |
182 | 158 | ObjectPath: "/ril_0/context1", | 159 | ObjectPath: "/ril_0/context1", |
184 | 159 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false), | 160 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false), |
185 | 160 | } | 161 | } |
186 | 161 | s.contexts = append(s.contexts, context1) | 162 | s.contexts = append(s.contexts, context1) |
187 | 162 | 163 | ||
188 | 163 | context2 := OfonoContext{ | 164 | context2 := OfonoContext{ |
189 | 164 | ObjectPath: "/ril_0/context2", | 165 | ObjectPath: "/ril_0/context2", |
191 | 165 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false), | 166 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), |
192 | 166 | } | 167 | } |
193 | 167 | s.contexts = append(s.contexts, context2) | 168 | s.contexts = append(s.contexts, context2) |
194 | 168 | 169 | ||
195 | @@ -176,19 +177,19 @@ | |||
196 | 176 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContextSelectPreferred(c *C) { | 177 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContextSelectPreferred(c *C) { |
197 | 177 | context1 := OfonoContext{ | 178 | context1 := OfonoContext{ |
198 | 178 | ObjectPath: "/ril_0/context1", | 179 | ObjectPath: "/ril_0/context1", |
200 | 179 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false), | 180 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false), |
201 | 180 | } | 181 | } |
202 | 181 | s.contexts = append(s.contexts, context1) | 182 | s.contexts = append(s.contexts, context1) |
203 | 182 | 183 | ||
204 | 183 | context2 := OfonoContext{ | 184 | context2 := OfonoContext{ |
205 | 184 | ObjectPath: "/ril_0/context2", | 185 | ObjectPath: "/ril_0/context2", |
207 | 185 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false), | 186 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), |
208 | 186 | } | 187 | } |
209 | 187 | s.contexts = append(s.contexts, context2) | 188 | s.contexts = append(s.contexts, context2) |
210 | 188 | 189 | ||
211 | 189 | context3 := OfonoContext{ | 190 | context3 := OfonoContext{ |
212 | 190 | ObjectPath: "/ril_0/context3", | 191 | ObjectPath: "/ril_0/context3", |
214 | 191 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false), | 192 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false), |
215 | 192 | } | 193 | } |
216 | 193 | s.contexts = append(s.contexts, context3) | 194 | s.contexts = append(s.contexts, context3) |
217 | 194 | 195 | ||
218 | @@ -203,19 +204,19 @@ | |||
219 | 203 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNoMatch(c *C) { | 204 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNoMatch(c *C) { |
220 | 204 | context1 := OfonoContext{ | 205 | context1 := OfonoContext{ |
221 | 205 | ObjectPath: "/ril_0/context1", | 206 | ObjectPath: "/ril_0/context1", |
223 | 206 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false), | 207 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false), |
224 | 207 | } | 208 | } |
225 | 208 | s.contexts = append(s.contexts, context1) | 209 | s.contexts = append(s.contexts, context1) |
226 | 209 | 210 | ||
227 | 210 | context2 := OfonoContext{ | 211 | context2 := OfonoContext{ |
228 | 211 | ObjectPath: "/ril_0/context2", | 212 | ObjectPath: "/ril_0/context2", |
230 | 212 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false), | 213 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), |
231 | 213 | } | 214 | } |
232 | 214 | s.contexts = append(s.contexts, context2) | 215 | s.contexts = append(s.contexts, context2) |
233 | 215 | 216 | ||
234 | 216 | context3 := OfonoContext{ | 217 | context3 := OfonoContext{ |
235 | 217 | ObjectPath: "/ril_0/context3", | 218 | ObjectPath: "/ril_0/context3", |
237 | 218 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false), | 219 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false), |
238 | 219 | } | 220 | } |
239 | 220 | s.contexts = append(s.contexts, context3) | 221 | s.contexts = append(s.contexts, context3) |
240 | 221 | 222 | ||
241 | @@ -230,25 +231,25 @@ | |||
242 | 230 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContext2Active(c *C) { | 231 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContext2Active(c *C) { |
243 | 231 | context0 := OfonoContext{ | 232 | context0 := OfonoContext{ |
244 | 232 | ObjectPath: "/ril_0/context0", | 233 | ObjectPath: "/ril_0/context0", |
246 | 233 | Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false), | 234 | Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false, false), |
247 | 234 | } | 235 | } |
248 | 235 | s.contexts = append(s.contexts, context0) | 236 | s.contexts = append(s.contexts, context0) |
249 | 236 | 237 | ||
250 | 237 | context1 := OfonoContext{ | 238 | context1 := OfonoContext{ |
251 | 238 | ObjectPath: "/ril_0/context1", | 239 | ObjectPath: "/ril_0/context1", |
253 | 239 | Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false), | 240 | Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, false), |
254 | 240 | } | 241 | } |
255 | 241 | s.contexts = append(s.contexts, context1) | 242 | s.contexts = append(s.contexts, context1) |
256 | 242 | 243 | ||
257 | 243 | context2 := OfonoContext{ | 244 | context2 := OfonoContext{ |
258 | 244 | ObjectPath: "/ril_0/context2", | 245 | ObjectPath: "/ril_0/context2", |
260 | 245 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false), | 246 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), |
261 | 246 | } | 247 | } |
262 | 247 | s.contexts = append(s.contexts, context2) | 248 | s.contexts = append(s.contexts, context2) |
263 | 248 | 249 | ||
264 | 249 | context3 := OfonoContext{ | 250 | context3 := OfonoContext{ |
265 | 250 | ObjectPath: "/ril_0/context3", | 251 | ObjectPath: "/ril_0/context3", |
267 | 251 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false), | 252 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false), |
268 | 252 | } | 253 | } |
269 | 253 | s.contexts = append(s.contexts, context3) | 254 | s.contexts = append(s.contexts, context3) |
270 | 254 | 255 | ||
271 | @@ -263,25 +264,25 @@ | |||
272 | 263 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNotActive(c *C) { | 264 | func (s *ContextTestSuite) TestMMSMoreThanOneValidContextPreferredNotActive(c *C) { |
273 | 264 | context0 := OfonoContext{ | 265 | context0 := OfonoContext{ |
274 | 265 | ObjectPath: "/ril_0/context0", | 266 | ObjectPath: "/ril_0/context0", |
276 | 266 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false), | 267 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false), |
277 | 267 | } | 268 | } |
278 | 268 | s.contexts = append(s.contexts, context0) | 269 | s.contexts = append(s.contexts, context0) |
279 | 269 | 270 | ||
280 | 270 | context1 := OfonoContext{ | 271 | context1 := OfonoContext{ |
281 | 271 | ObjectPath: "/ril_0/context1", | 272 | ObjectPath: "/ril_0/context1", |
283 | 272 | Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false), | 273 | Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, false), |
284 | 273 | } | 274 | } |
285 | 274 | s.contexts = append(s.contexts, context1) | 275 | s.contexts = append(s.contexts, context1) |
286 | 275 | 276 | ||
287 | 276 | context2 := OfonoContext{ | 277 | context2 := OfonoContext{ |
288 | 277 | ObjectPath: "/ril_0/context2", | 278 | ObjectPath: "/ril_0/context2", |
290 | 278 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false), | 279 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), |
291 | 279 | } | 280 | } |
292 | 280 | s.contexts = append(s.contexts, context2) | 281 | s.contexts = append(s.contexts, context2) |
293 | 281 | 282 | ||
294 | 282 | context3 := OfonoContext{ | 283 | context3 := OfonoContext{ |
295 | 283 | ObjectPath: "/ril_0/context3", | 284 | ObjectPath: "/ril_0/context3", |
297 | 284 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false), | 285 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, false, true, false, false), |
298 | 285 | } | 286 | } |
299 | 286 | 287 | ||
300 | 287 | s.contexts = append(s.contexts, context3) | 288 | s.contexts = append(s.contexts, context3) |
301 | @@ -295,10 +296,41 @@ | |||
302 | 295 | c.Check(contexts[3], DeepEquals, context2) | 296 | c.Check(contexts[3], DeepEquals, context2) |
303 | 296 | } | 297 | } |
304 | 297 | 298 | ||
305 | 299 | func (s *ContextTestSuite) TestOnePreferredContext(c *C) { | ||
306 | 300 | context0 := OfonoContext{ | ||
307 | 301 | ObjectPath: "/ril_0/context0", | ||
308 | 302 | Properties: makeGenericContextProperty("Context0", contextTypeInternet, true, true, false, false), | ||
309 | 303 | } | ||
310 | 304 | s.contexts = append(s.contexts, context0) | ||
311 | 305 | |||
312 | 306 | context1 := OfonoContext{ | ||
313 | 307 | ObjectPath: "/ril_0/context1", | ||
314 | 308 | Properties: makeGenericContextProperty("Context1", contextTypeMMS, false, true, false, true), | ||
315 | 309 | } | ||
316 | 310 | s.contexts = append(s.contexts, context1) | ||
317 | 311 | |||
318 | 312 | context2 := OfonoContext{ | ||
319 | 313 | ObjectPath: "/ril_0/context2", | ||
320 | 314 | Properties: makeGenericContextProperty("Context2", contextTypeMMS, false, true, false, false), | ||
321 | 315 | } | ||
322 | 316 | s.contexts = append(s.contexts, context2) | ||
323 | 317 | |||
324 | 318 | context3 := OfonoContext{ | ||
325 | 319 | ObjectPath: "/ril_0/context3", | ||
326 | 320 | Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false, false), | ||
327 | 321 | } | ||
328 | 322 | s.contexts = append(s.contexts, context3) | ||
329 | 323 | |||
330 | 324 | contexts, err := s.modem.GetMMSContexts("") | ||
331 | 325 | c.Assert(err, IsNil) | ||
332 | 326 | c.Assert(len(contexts), Equals, 1) | ||
333 | 327 | c.Check(contexts[0], DeepEquals, context1) | ||
334 | 328 | } | ||
335 | 329 | |||
336 | 298 | func (s *ContextTestSuite) TestGetProxy(c *C) { | 330 | func (s *ContextTestSuite) TestGetProxy(c *C) { |
337 | 299 | context := OfonoContext{ | 331 | context := OfonoContext{ |
338 | 300 | ObjectPath: "/ril_0/context1", | 332 | ObjectPath: "/ril_0/context1", |
340 | 301 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true), | 333 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false), |
341 | 302 | } | 334 | } |
342 | 303 | 335 | ||
343 | 304 | p, err := context.GetProxy() | 336 | p, err := context.GetProxy() |
344 | @@ -309,7 +341,7 @@ | |||
345 | 309 | func (s *ContextTestSuite) TestGetProxyNoProxy(c *C) { | 341 | func (s *ContextTestSuite) TestGetProxyNoProxy(c *C) { |
346 | 310 | context := OfonoContext{ | 342 | context := OfonoContext{ |
347 | 311 | ObjectPath: "/ril_0/context1", | 343 | ObjectPath: "/ril_0/context1", |
349 | 312 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false), | 344 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, false, false), |
350 | 313 | } | 345 | } |
351 | 314 | 346 | ||
352 | 315 | p, err := context.GetProxy() | 347 | p, err := context.GetProxy() |
353 | @@ -320,7 +352,7 @@ | |||
354 | 320 | func (s *ContextTestSuite) TestGetProxyWithHTTP(c *C) { | 352 | func (s *ContextTestSuite) TestGetProxyWithHTTP(c *C) { |
355 | 321 | context := OfonoContext{ | 353 | context := OfonoContext{ |
356 | 322 | ObjectPath: "/ril_0/context1", | 354 | ObjectPath: "/ril_0/context1", |
358 | 323 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true), | 355 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false), |
359 | 324 | } | 356 | } |
360 | 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)} |
361 | 326 | 358 | ||
362 | @@ -332,7 +364,7 @@ | |||
363 | 332 | func (s *ContextTestSuite) TestGetProxyNoPort(c *C) { | 364 | func (s *ContextTestSuite) TestGetProxyNoPort(c *C) { |
364 | 333 | context := OfonoContext{ | 365 | context := OfonoContext{ |
365 | 334 | ObjectPath: "/ril_0/context1", | 366 | ObjectPath: "/ril_0/context1", |
367 | 335 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true), | 367 | Properties: makeGenericContextProperty("Context1", contextTypeInternet, true, true, true, false), |
368 | 336 | } | 368 | } |
369 | 337 | context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s", proxy.Host)} | 369 | context.Properties["MessageProxy"] = dbus.Variant{fmt.Sprintf("http://%s", proxy.Host)} |
370 | 338 | 370 | ||
371 | 339 | 371 | ||
372 | === modified file 'ofono/manager.go' | |||
373 | --- ofono/manager.go 2014-05-08 23:23:22 +0000 | |||
374 | +++ ofono/manager.go 2015-05-21 06:23:15 +0000 | |||
375 | @@ -46,18 +46,24 @@ | |||
376 | 46 | } | 46 | } |
377 | 47 | 47 | ||
378 | 48 | func (mm *ModemManager) Init() error { | 48 | func (mm *ModemManager) Init() error { |
380 | 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 |
381 | 50 | conn, err := dbus.Connect(dbus.SystemBus) | ||
382 | 51 | if err != nil { | ||
383 | 52 | return err; | ||
384 | 53 | } | ||
385 | 54 | |||
386 | 55 | modemAddedSignal, err := connectToSignal(conn, "/", OFONO_MANAGER_INTERFACE, "ModemAdded") | ||
387 | 50 | if err != nil { | 56 | if err != nil { |
388 | 51 | return err | 57 | return err |
389 | 52 | } | 58 | } |
391 | 53 | modemRemovedSignal, err := connectToSignal(mm.conn, "/", OFONO_MANAGER_INTERFACE, "ModemRemoved") | 59 | modemRemovedSignal, err := connectToSignal(conn, "/", OFONO_MANAGER_INTERFACE, "ModemRemoved") |
392 | 54 | if err != nil { | 60 | if err != nil { |
393 | 55 | return err | 61 | return err |
394 | 56 | } | 62 | } |
395 | 57 | go mm.watchModems(modemAddedSignal, modemRemovedSignal) | 63 | go mm.watchModems(modemAddedSignal, modemRemovedSignal) |
396 | 58 | 64 | ||
397 | 59 | //Check for existing modems | 65 | //Check for existing modems |
399 | 60 | modemPaths, err := getModems(mm.conn) | 66 | modemPaths, err := getModems(conn) |
400 | 61 | if err != nil { | 67 | if err != nil { |
401 | 62 | log.Print("Cannot preemptively add modems: ", err) | 68 | log.Print("Cannot preemptively add modems: ", err) |
402 | 63 | } else { | 69 | } else { |
403 | 64 | 70 | ||
404 | === modified file 'ofono/modem.go' | |||
405 | --- ofono/modem.go 2014-10-02 01:24:13 +0000 | |||
406 | +++ ofono/modem.go 2015-05-21 06:23:15 +0000 | |||
407 | @@ -310,6 +310,10 @@ | |||
408 | 310 | return reflect.ValueOf(oContext.Properties["Active"].Value).Bool() | 310 | return reflect.ValueOf(oContext.Properties["Active"].Value).Bool() |
409 | 311 | } | 311 | } |
410 | 312 | 312 | ||
411 | 313 | func (oContext OfonoContext) isPreferred() bool { | ||
412 | 314 | return reflect.ValueOf(oContext.Properties["Preferred"].Value).Bool() | ||
413 | 315 | } | ||
414 | 316 | |||
415 | 313 | func (oContext OfonoContext) hasMessageCenter() bool { | 317 | func (oContext OfonoContext) hasMessageCenter() bool { |
416 | 314 | return oContext.messageCenter() != "" | 318 | return oContext.messageCenter() != "" |
417 | 315 | } | 319 | } |
418 | @@ -371,10 +375,11 @@ | |||
419 | 371 | //and a MessageCenter within the context. | 375 | //and a MessageCenter within the context. |
420 | 372 | // | 376 | // |
421 | 373 | //The following rules take place: | 377 | //The following rules take place: |
426 | 374 | //- check current type=internet context for MessageProxy & MessageCenter; | 378 | //- if current type=internet context, check for MessageProxy & MessageCenter; |
427 | 375 | // if they exist and aren't empty AND the context is active, select it as the | 379 | // if they exist and aren't empty AND the context is active, add it to the list |
428 | 376 | // context to use for MMS. | 380 | //- if current type=mms, add it to the list |
429 | 377 | //- otherwise search for type=mms, if found, use it and activate | 381 | //- if ofono's ConnectionManager.Preferred property is set, use only that context |
430 | 382 | //- prioritize active and recently successfully used contexts | ||
431 | 378 | // | 383 | // |
432 | 379 | //Returns either the type=internet context or the type=mms, if none is found | 384 | //Returns either the type=internet context or the type=mms, if none is found |
433 | 380 | //an error is returned. | 385 | //an error is returned. |
434 | @@ -386,7 +391,10 @@ | |||
435 | 386 | 391 | ||
436 | 387 | for _, context := range contexts { | 392 | for _, context := range contexts { |
437 | 388 | if (context.isTypeInternet() && context.isActive() && context.hasMessageCenter()) || context.isTypeMMS() { | 393 | if (context.isTypeInternet() && context.isActive() && context.hasMessageCenter()) || context.isTypeMMS() { |
439 | 389 | if context.ObjectPath == preferredContext || context.isActive() { | 394 | if context.isPreferred() { |
440 | 395 | mmsContexts = []OfonoContext{context} | ||
441 | 396 | break | ||
442 | 397 | } else if context.ObjectPath == preferredContext || context.isActive() { | ||
443 | 390 | mmsContexts = append([]OfonoContext{context}, mmsContexts...) | 398 | mmsContexts = append([]OfonoContext{context}, mmsContexts...) |
444 | 391 | } else { | 399 | } else { |
445 | 392 | mmsContexts = append(mmsContexts, context) | 400 | mmsContexts = append(mmsContexts, context) |
446 | @@ -418,7 +426,9 @@ | |||
447 | 418 | } | 426 | } |
448 | 419 | 427 | ||
449 | 420 | func (modem *Modem) Delete() { | 428 | func (modem *Modem) Delete() { |
451 | 421 | modem.IdentityRemoved <- modem.identity | 429 | if modem.identity != "" { |
452 | 430 | modem.IdentityRemoved <- modem.identity | ||
453 | 431 | } | ||
454 | 422 | modem.modemSignal.Cancel() | 432 | modem.modemSignal.Cancel() |
455 | 423 | modem.modemSignal.C = nil | 433 | modem.modemSignal.C = nil |
456 | 424 | modem.simSignal.Cancel() | 434 | modem.simSignal.Cancel() |
457 | 425 | 435 | ||
458 | === modified file 'ofono/push_decode_test.go' | |||
459 | --- ofono/push_decode_test.go 2014-10-21 13:13:11 +0000 | |||
460 | +++ ofono/push_decode_test.go 2015-05-21 06:23:15 +0000 | |||
461 | @@ -169,3 +169,33 @@ | |||
462 | 169 | dec := NewDecoder(inputBytes) | 169 | dec := NewDecoder(inputBytes) |
463 | 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")) |
464 | 171 | } | 171 | } |
465 | 172 | |||
466 | 173 | func (s *PushDecodeTestSuite) TestDecodeTMobileUSA(c *C) { | ||
467 | 174 | inputBytes := []byte{ | ||
468 | 175 | 0xc0, 0x06, 0x28, 0x1f, 0x22, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, | ||
469 | 176 | 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x6e, 0x64, 0x2e, 0x77, 0x61, 0x70, 0x2e, 0x6d, | ||
470 | 177 | 0x6d, 0x73, 0x2d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x81, 0x84, | ||
471 | 178 | 0x8d, 0x80, 0xaf, 0x84, 0x8c, 0x82, 0x98, 0x6d, 0x61, 0x76, 0x6f, 0x64, 0x69, | ||
472 | 179 | 0x2d, 0x37, 0x2d, 0x38, 0x39, 0x2d, 0x31, 0x63, 0x30, 0x2d, 0x37, 0x2d, 0x63, | ||
473 | 180 | 0x61, 0x2d, 0x35, 0x30, 0x66, 0x39, 0x33, 0x38, 0x34, 0x33, 0x2d, 0x37, 0x2d, | ||
474 | 181 | 0x31, 0x33, 0x62, 0x2d, 0x32, 0x65, 0x62, 0x2d, 0x31, 0x2d, 0x63, 0x61, 0x2d, | ||
475 | 182 | 0x33, 0x36, 0x31, 0x65, 0x33, 0x31, 0x35, 0x00, 0x8d, 0x92, 0x89, 0x1a, 0x80, | ||
476 | 183 | 0x18, 0x83, 0x2b, 0x31, 0x39, 0x31, 0x39, 0x39, 0x30, 0x33, 0x33, 0x34, 0x38, | ||
477 | 184 | 0x38, 0x2f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x50, 0x4c, 0x4d, 0x4e, 0x00, 0x8a, | ||
478 | 185 | 0x80, 0x8e, 0x03, 0x0f, 0x21, 0x9f, 0x88, 0x05, 0x81, 0x03, 0x03, 0xf4, 0x80, | ||
479 | 186 | 0x83, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x61, 0x74, 0x6c, 0x32, 0x6d, | ||
480 | 187 | 0x6f, 0x73, 0x67, 0x65, 0x74, 0x2e, 0x6d, 0x73, 0x67, 0x2e, 0x65, 0x6e, 0x67, | ||
481 | 188 | 0x2e, 0x74, 0x2d, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, | ||
482 | 189 | 0x2f, 0x6d, 0x6d, 0x73, 0x2f, 0x77, 0x61, 0x70, 0x65, 0x6e, 0x63, 0x3f, 0x54, | ||
483 | 190 | 0x3d, 0x6d, 0x61, 0x76, 0x6f, 0x64, 0x69, 0x2d, 0x37, 0x2d, 0x31, 0x33, 0x62, | ||
484 | 191 | 0x2d, 0x32, 0x65, 0x62, 0x2d, 0x31, 0x2d, 0x63, 0x61, 0x2d, 0x33, 0x36, 0x31, | ||
485 | 192 | 0x65, 0x33, 0x31, 0x35, 0x00, | ||
486 | 193 | } | ||
487 | 194 | dec := NewDecoder(inputBytes) | ||
488 | 195 | c.Assert(dec.Decode(s.pdu), IsNil) | ||
489 | 196 | |||
490 | 197 | c.Check(int(s.pdu.HeaderLength), Equals, 40) | ||
491 | 198 | c.Check(int(s.pdu.ApplicationId), Equals, mms.PUSH_APPLICATION_ID) | ||
492 | 199 | c.Check(s.pdu.ContentType, Equals, mms.VND_WAP_MMS_MESSAGE) | ||
493 | 200 | c.Check(len(s.pdu.Data), Equals, 183) | ||
494 | 201 | } |
Looks good.