Merge lp:~sergiusens/nuntium/select_that into lp:nuntium

Proposed by Sergio Schvezov
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 80
Merged at revision: 76
Proposed branch: lp:~sergiusens/nuntium/select_that
Merge into: lp:nuntium
Diff against target: 526 lines (+217/-46)
8 files modified
mediator.go (+10/-2)
ofono/context_test.go (+12/-19)
ofono/modem.go (+7/-7)
storage/context.go (+113/-0)
telepathy/const.go (+10/-9)
telepathy/manager.go (+2/-2)
telepathy/message.go (+2/-2)
telepathy/service.go (+61/-5)
To merge this branch: bzr merge lp:~sergiusens/nuntium/select_that
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
PS Jenkins bot continuous-integration Approve
Antti Kaijanmäki (community) Approve
Review via email: mp+236427@code.launchpad.net

Commit message

Allow context selection over the org.ofono.mms.Service interface

Description of the change

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~sergiusens/nuntium/select_that updated
77. By Sergio Schvezov

Adding log on what is being tried for activation

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

My go-fu is bad, but I don't see the service notifying when the PreferredContext property changes.

It's also problematic that the property sometimes is available and sometimes it's not. I can work around this in the bindings, but I need two things:

1) instead of adding/removing the property, have a "not set" value (empty string would do just fine) and have the interface report PropertyChanged signal each time the property is modified
2) or add a straight signal PreferredContextChangede when you add or remove the property.

Current implementation makes it really difficult (or almost impossible) to write bindings on Qt.

review: Needs Fixing
lp:~sergiusens/nuntium/select_that updated
78. By Sergio Schvezov

Minor cleanup, always refreshed from stored context state

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~sergiusens/nuntium/select_that updated
79. By Sergio Schvezov

Emitting properties changed for preferred context and always having the property set

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This now produces messages like

phablet@ubuntu-phablet:~$ dbus-monitor interface=org.ofono.mms.Service
signal sender=org.freedesktop.DBus -> dest=:1.192 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.192"
method call sender=:1.193 -> dest=org.ofono.mms serial=2 path=/org/ofono/mms/722341240403394; interface=org.ofono.mms.Service; member=SetProperty
   string "PreferredContext"
   variant object path "/c2"
signal sender=:1.190 -> dest=(null destination) serial=9 path=/org/ofono/mms/722341240403394; interface=org.ofono.mms.Service; member=PropertyChanged
   string "PreferredContext"
   variant object path "/c2

And always has the "property" set.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

OK. looks good to me.

review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) :
review: Needs Fixing
lp:~sergiusens/nuntium/select_that updated
80. By Sergio Schvezov

Removing stale log line

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mediator.go'
2--- mediator.go 2014-09-23 19:58:36 +0000
3+++ mediator.go 2014-10-01 13:57:00 +0000
4@@ -164,11 +164,15 @@
5 }
6
7 func (mediator *Mediator) getMRetrieveConf(mNotificationInd *mms.MNotificationInd) {
8- mmsContext, err := mediator.modem.ActivateMMSContext()
9+ preferredContext, _ := mediator.telepathyService.GetPreferredContext()
10+ mmsContext, err := mediator.modem.ActivateMMSContext(preferredContext)
11 if err != nil {
12 log.Print("Cannot activate ofono context: ", err)
13 return
14 }
15+ if err := mediator.telepathyService.SetPreferredContext(mmsContext.ObjectPath); err != nil {
16+ log.Println("Unable to store the preferred context for MMS:", err)
17+ }
18 proxy, err := mmsContext.GetProxy()
19 if err != nil {
20 log.Print("Error retrieving proxy: ", err)
21@@ -356,10 +360,14 @@
22 }
23
24 func (mediator *Mediator) uploadFile(filePath string) (string, error) {
25- mmsContext, err := mediator.modem.ActivateMMSContext()
26+ preferredContext, _ := mediator.telepathyService.GetPreferredContext()
27+ mmsContext, err := mediator.modem.ActivateMMSContext(preferredContext)
28 if err != nil {
29 return "", err
30 }
31+ if err := mediator.telepathyService.SetPreferredContext(mmsContext.ObjectPath); err != nil {
32+ log.Println("Unable to store the preferred context for MMS:", err)
33+ }
34 proxy, err := mmsContext.GetProxy()
35 if err != nil {
36 return "", err
37
38=== modified file 'ofono/context_test.go'
39--- ofono/context_test.go 2014-09-18 01:47:59 +0000
40+++ ofono/context_test.go 2014-10-01 13:57:00 +0000
41@@ -72,7 +72,7 @@
42 }
43
44 func (s *ContextTestSuite) TestNoContext(c *C) {
45- context, err := s.modem.GetMMSContexts()
46+ context, err := s.modem.GetMMSContexts("")
47 c.Check(context, IsNil)
48 c.Assert(err, DeepEquals, errors.New("No mms contexts found"))
49 }
50@@ -84,7 +84,7 @@
51 }
52 s.contexts = append(s.contexts, context1)
53
54- contexts, err := s.modem.GetMMSContexts()
55+ contexts, err := s.modem.GetMMSContexts("")
56 c.Assert(err, IsNil)
57 c.Assert(len(contexts), Equals, 1)
58 c.Check(contexts[0], DeepEquals, context1)
59@@ -97,7 +97,7 @@
60 }
61 s.contexts = append(s.contexts, context1)
62
63- context, err := s.modem.GetMMSContexts()
64+ context, err := s.modem.GetMMSContexts("")
65 c.Check(context, IsNil)
66 c.Assert(err, DeepEquals, errors.New("No mms contexts found"))
67 }
68@@ -109,7 +109,7 @@
69 }
70 s.contexts = append(s.contexts, context1)
71
72- contexts, err := s.modem.GetMMSContexts()
73+ contexts, err := s.modem.GetMMSContexts("")
74 c.Assert(err, IsNil)
75 c.Assert(len(contexts), Equals, 1)
76 c.Check(contexts[0], DeepEquals, context1)
77@@ -128,7 +128,7 @@
78 }
79 s.contexts = append(s.contexts, context2)
80
81- contexts, err := s.modem.GetMMSContexts()
82+ contexts, err := s.modem.GetMMSContexts("")
83 c.Assert(err, IsNil)
84 c.Assert(len(contexts), Equals, 1)
85 c.Check(contexts[0], DeepEquals, context2)
86@@ -147,7 +147,7 @@
87 }
88 s.contexts = append(s.contexts, context2)
89
90- contexts, err := s.modem.GetMMSContexts()
91+ contexts, err := s.modem.GetMMSContexts("")
92 c.Assert(err, IsNil)
93 c.Assert(len(contexts), Equals, 1)
94 c.Check(contexts[0], DeepEquals, context2)
95@@ -166,7 +166,7 @@
96 }
97 s.contexts = append(s.contexts, context2)
98
99- contexts, err := s.modem.GetMMSContexts()
100+ contexts, err := s.modem.GetMMSContexts("")
101 c.Assert(err, IsNil)
102 c.Assert(len(contexts), Equals, 2)
103 c.Check(contexts[0], DeepEquals, context1)
104@@ -192,9 +192,7 @@
105 }
106 s.contexts = append(s.contexts, context3)
107
108- s.modem.preferredContext = "/ril_0/context2"
109-
110- contexts, err := s.modem.GetMMSContexts()
111+ contexts, err := s.modem.GetMMSContexts("/ril_0/context2")
112 c.Assert(err, IsNil)
113 c.Assert(len(contexts), Equals, 3)
114 c.Check(contexts[0], DeepEquals, context2)
115@@ -221,9 +219,7 @@
116 }
117 s.contexts = append(s.contexts, context3)
118
119- s.modem.preferredContext = "/ril_0/context25"
120-
121- contexts, err := s.modem.GetMMSContexts()
122+ contexts, err := s.modem.GetMMSContexts("/ril_0/context25")
123 c.Assert(err, IsNil)
124 c.Assert(len(contexts), Equals, 3)
125 c.Check(contexts[0], DeepEquals, context1)
126@@ -234,7 +230,7 @@
127 func (s *ContextTestSuite) TestMMSMoreThanOneValidContext2Active(c *C) {
128 context0 := OfonoContext{
129 ObjectPath: "/ril_0/context0",
130- Properties: makeGenericContextProperty("Context1", contextTypeInternet, false, true, false),
131+ Properties: makeGenericContextProperty("Context0", contextTypeInternet, false, true, false),
132 }
133 s.contexts = append(s.contexts, context0)
134
135@@ -254,10 +250,9 @@
136 ObjectPath: "/ril_0/context3",
137 Properties: makeGenericContextProperty("Context3", contextTypeMMS, true, true, false),
138 }
139-
140 s.contexts = append(s.contexts, context3)
141
142- contexts, err := s.modem.GetMMSContexts()
143+ contexts, err := s.modem.GetMMSContexts("")
144 c.Assert(err, IsNil)
145 c.Assert(len(contexts), Equals, 3)
146 c.Check(contexts[0], DeepEquals, context3)
147@@ -291,9 +286,7 @@
148
149 s.contexts = append(s.contexts, context3)
150
151- s.modem.preferredContext = "/ril_0/context3"
152-
153- contexts, err := s.modem.GetMMSContexts()
154+ contexts, err := s.modem.GetMMSContexts("/ril_0/context3")
155 c.Assert(err, IsNil)
156 c.Assert(len(contexts), Equals, 4)
157 c.Check(contexts[0], DeepEquals, context3)
158
159=== modified file 'ofono/modem.go'
160--- ofono/modem.go 2014-09-18 01:47:59 +0000
161+++ ofono/modem.go 2014-10-01 13:57:00 +0000
162@@ -48,7 +48,6 @@
163 Modem dbus.ObjectPath
164 PushAgent *PushAgent
165 identity string
166- preferredContext dbus.ObjectPath
167 IdentityAdded chan string
168 IdentityRemoved chan string
169 endWatch chan bool
170@@ -235,8 +234,8 @@
171 //If the context is already active it's a nop.
172 //Returns either the type=internet context or the type=mms, if none is found
173 //an error is returned.
174-func (modem *Modem) ActivateMMSContext() (OfonoContext, error) {
175- contexts, err := modem.GetMMSContexts()
176+func (modem *Modem) ActivateMMSContext(preferredContext dbus.ObjectPath) (OfonoContext, error) {
177+ contexts, err := modem.GetMMSContexts(preferredContext)
178 if err != nil {
179 return OfonoContext{}, err
180 }
181@@ -244,12 +243,12 @@
182 if context.isActive() {
183 return context, nil
184 }
185+ log.Println("Trying to activate context on", context.ObjectPath)
186 obj := modem.conn.Object("org.ofono", context.ObjectPath)
187 _, err = obj.Call(CONNECTION_CONTEXT_INTERFACE, "SetProperty", "Active", dbus.Variant{true})
188 if err != nil {
189- log.Println("Cannot Activate interface on %s: %s", context.ObjectPath, err)
190+ log.Printf("Cannot Activate interface on %s: %s", context.ObjectPath, err)
191 } else {
192- modem.preferredContext = context.ObjectPath
193 return context, nil
194 }
195 }
196@@ -303,11 +302,12 @@
197 //
198 //Returns either the type=internet context or the type=mms, if none is found
199 //an error is returned.
200-func (modem *Modem) GetMMSContexts() (mmsContexts []OfonoContext, err error) {
201+func (modem *Modem) GetMMSContexts(preferredContext dbus.ObjectPath) (mmsContexts []OfonoContext, err error) {
202 contexts, err := getOfonoProps(modem.conn, modem.Modem, OFONO_SENDER, CONNECTION_MANAGER_INTERFACE, "GetContexts")
203 if err != nil {
204 return mmsContexts, err
205 }
206+
207 for _, context := range contexts {
208 var name, contextType, msgCenter, msgProxy string
209 var active bool
210@@ -335,7 +335,7 @@
211 "| MessageProxy:", msgProxy,
212 "| Active:", active)
213 if (contextType == contextTypeInternet && active && msgCenter != "") || contextType == contextTypeMMS {
214- if context.ObjectPath == modem.preferredContext || active {
215+ if context.ObjectPath == preferredContext || active {
216 mmsContexts = append([]OfonoContext{context}, mmsContexts...)
217 } else {
218 mmsContexts = append(mmsContexts, context)
219
220=== added file 'storage/context.go'
221--- storage/context.go 1970-01-01 00:00:00 +0000
222+++ storage/context.go 2014-10-01 13:57:00 +0000
223@@ -0,0 +1,113 @@
224+/*
225+ * Copyright 2014 Canonical Ltd.
226+ *
227+ * Authors:
228+ * Sergio Schvezov: sergio.schvezov@cannical.com
229+ *
230+ * This file is part of telepathy.
231+ *
232+ * mms is free software; you can redistribute it and/or modify
233+ * it under the terms of the GNU General Public License as published by
234+ * the Free Software Foundation; version 3.
235+ *
236+ * mms is distributed in the hope that it will be useful,
237+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
238+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
239+ * GNU General Public License for more details.
240+ *
241+ * You should have received a copy of the GNU General Public License
242+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
243+ */
244+
245+package storage
246+
247+import (
248+ "bufio"
249+ "encoding/json"
250+ "errors"
251+ "os"
252+ "path/filepath"
253+ "sync"
254+
255+ "log"
256+
257+ "launchpad.net/go-dbus/v1"
258+ "launchpad.net/go-xdg/v0"
259+)
260+
261+var preferredContextPath string = filepath.Join(filepath.Base(os.Args[0]), "preferredContext")
262+
263+var contextMutex sync.Mutex
264+
265+type contextSettingMap map[string]dbus.ObjectPath
266+
267+func SetPreferredContext(identity string, pcObjectPath dbus.ObjectPath) error {
268+ contextMutex.Lock()
269+ defer contextMutex.Unlock()
270+
271+ pcFilePath, err := xdg.Cache.Ensure(preferredContextPath)
272+ if err != nil {
273+ return err
274+ }
275+ return writeContext(identity, pcObjectPath, pcFilePath)
276+}
277+
278+func GetPreferredContext(identity string) (pcObjectPath dbus.ObjectPath, err error) {
279+ contextMutex.Lock()
280+ defer contextMutex.Unlock()
281+
282+ pcFilePath, err := xdg.Cache.Find(preferredContextPath)
283+ if err != nil {
284+ return pcObjectPath, err
285+ }
286+ cs, err := readContext(pcFilePath)
287+ if err != nil {
288+ return pcObjectPath, err
289+ }
290+ if p, ok := cs[identity]; ok {
291+ return p, nil
292+ }
293+
294+ return pcObjectPath, errors.New("path for identity not found")
295+}
296+
297+func readContext(storePath string) (cs contextSettingMap, err error) {
298+ file, err := os.Open(storePath)
299+ if err != nil {
300+ cs = make(contextSettingMap)
301+ return cs, err
302+ }
303+ jsonReader := json.NewDecoder(file)
304+ if err = jsonReader.Decode(&cs); err != nil {
305+ cs = make(contextSettingMap)
306+ }
307+ return cs, err
308+}
309+
310+func writeContext(identity string, pc dbus.ObjectPath, storePath string) error {
311+ cs, readErr := readContext(storePath)
312+ if readErr != nil {
313+ log.Println("Cannot read previous context state")
314+ }
315+
316+ file, err := os.Create(storePath)
317+ if err != nil {
318+ log.Println(err)
319+ return err
320+ }
321+ defer func() {
322+ file.Close()
323+ if err != nil {
324+ os.Remove(storePath)
325+ }
326+ }()
327+ w := bufio.NewWriter(file)
328+ defer w.Flush()
329+ cs[identity] = pc
330+ jsonWriter := json.NewEncoder(w)
331+ if err := jsonWriter.Encode(cs); err != nil {
332+ log.Println(err)
333+ return err
334+ }
335+ return nil
336+}
337
338=== modified file 'telepathy/const.go'
339--- telepathy/const.go 2014-08-12 20:50:25 +0000
340+++ telepathy/const.go 2014-10-01 13:57:00 +0000
341@@ -30,15 +30,16 @@
342 )
343
344 const (
345- IDENTITY = "Identity"
346- USE_DELIVERY_REPORTS = "UseDeliveryReports"
347- MODEM_OBJECT_PATH = "ModemObjectPath"
348- MESSAGE_ADDED = "MessageAdded"
349- MESSAGE_REMOVED = "MessageRemoved"
350- SERVICE_ADDED = "ServiceAdded"
351- SERVICE_REMOVED = "ServiceRemoved"
352- PROPERTY_CHANGED = "PropertyChanged"
353- STATUS = "Status"
354+ identityProperty string = "Identity"
355+ useDeliveryReportsProperty string = "UseDeliveryReports"
356+ modemObjectPathProperty string = "ModemObjectPath"
357+ messageAddedSignal string = "MessageAdded"
358+ messageRemovedSignal string = "MessageRemoved"
359+ serviceAddedSignal string = "ServiceAdded"
360+ serviceRemovedSignal string = "ServiceRemoved"
361+ preferredContextProperty string = "PreferredContext"
362+ propertyChangedSignal string = "PropertyChanged"
363+ statusProperty string = "Status"
364 )
365
366 const (
367
368=== modified file 'telepathy/manager.go'
369--- telepathy/manager.go 2014-08-12 20:50:25 +0000
370+++ telepathy/manager.go 2014-10-01 13:57:00 +0000
371@@ -82,7 +82,7 @@
372
373 func (manager *MMSManager) serviceAdded(payload *Payload) error {
374 log.Print("Service added ", payload.Path)
375- signal := dbus.NewSignalMessage(MMS_DBUS_PATH, MMS_MANAGER_DBUS_IFACE, SERVICE_ADDED)
376+ signal := dbus.NewSignalMessage(MMS_DBUS_PATH, MMS_MANAGER_DBUS_IFACE, serviceAddedSignal)
377 if err := signal.AppendArgs(payload.Path, payload.Properties); err != nil {
378 return err
379 }
380@@ -108,7 +108,7 @@
381
382 func (manager *MMSManager) serviceRemoved(payload *Payload) error {
383 log.Print("Service removed ", payload.Path)
384- signal := dbus.NewSignalMessage(MMS_DBUS_PATH, MMS_MANAGER_DBUS_IFACE, SERVICE_REMOVED)
385+ signal := dbus.NewSignalMessage(MMS_DBUS_PATH, MMS_MANAGER_DBUS_IFACE, serviceRemovedSignal)
386 if err := signal.AppendArgs(payload.Path); err != nil {
387 return err
388 }
389
390=== modified file 'telepathy/message.go'
391--- telepathy/message.go 2014-07-02 21:06:14 +0000
392+++ telepathy/message.go 2014-10-01 13:57:00 +0000
393@@ -94,8 +94,8 @@
394 i := validStatus.Search(status)
395 if i < validStatus.Len() && validStatus[i] == status {
396 msgInterface.status = status
397- signal := dbus.NewSignalMessage(msgInterface.objectPath, MMS_MESSAGE_DBUS_IFACE, PROPERTY_CHANGED)
398- if err := signal.AppendArgs(STATUS, dbus.Variant{status}); err != nil {
399+ signal := dbus.NewSignalMessage(msgInterface.objectPath, MMS_MESSAGE_DBUS_IFACE, propertyChangedSignal)
400+ if err := signal.AppendArgs(statusProperty, dbus.Variant{status}); err != nil {
401 return err
402 }
403 if err := msgInterface.conn.Send(signal); err != nil {
404
405=== modified file 'telepathy/service.go'
406--- telepathy/service.go 2014-08-12 20:50:25 +0000
407+++ telepathy/service.go 2014-10-01 13:57:00 +0000
408@@ -22,9 +22,11 @@
409 package telepathy
410
411 import (
412+ "errors"
413 "fmt"
414 "log"
415 "path/filepath"
416+ "reflect"
417 "strings"
418 "time"
419
420@@ -73,10 +75,10 @@
421
422 func NewMMSService(conn *dbus.Connection, modemObjPath dbus.ObjectPath, identity string, outgoingChannel chan *OutgoingMessage, useDeliveryReports bool) *MMSService {
423 properties := make(map[string]dbus.Variant)
424- properties[IDENTITY] = dbus.Variant{identity}
425+ properties[identityProperty] = dbus.Variant{identity}
426 serviceProperties := make(map[string]dbus.Variant)
427- serviceProperties[USE_DELIVERY_REPORTS] = dbus.Variant{useDeliveryReports}
428- serviceProperties[MODEM_OBJECT_PATH] = dbus.Variant{modemObjPath}
429+ serviceProperties[useDeliveryReportsProperty] = dbus.Variant{useDeliveryReports}
430+ serviceProperties[modemObjectPathProperty] = dbus.Variant{modemObjPath}
431 payload := Payload{
432 Path: dbus.ObjectPath(MMS_DBUS_PATH + "/" + identity),
433 Properties: properties,
434@@ -130,6 +132,12 @@
435 }
436 case "GetProperties":
437 reply = dbus.NewMethodReturnMessage(msg)
438+ if pc, err := service.GetPreferredContext(); err == nil {
439+ service.Properties[preferredContextProperty] = dbus.Variant{pc}
440+ } else {
441+ // Using "/" as an invalid 'path' even though it could be considered 'incorrect'
442+ service.Properties[preferredContextProperty] = dbus.Variant{dbus.ObjectPath("/")}
443+ }
444 if err := reply.AppendArgs(service.Properties); err != nil {
445 log.Print("Cannot parse payload data from services")
446 reply = dbus.NewErrorMessage(msg, "Error.InvalidArguments", "Cannot parse services")
447@@ -137,6 +145,16 @@
448 if err := service.conn.Send(reply); err != nil {
449 log.Println("Could not send reply:", err)
450 }
451+ case "SetProperty":
452+ if err := service.setProperty(msg); err != nil {
453+ log.Println("Property set failed:", err)
454+ reply = dbus.NewErrorMessage(msg, "Error.InvalidArguments", err.Error())
455+ } else {
456+ reply = dbus.NewMethodReturnMessage(msg)
457+ }
458+ if err := service.conn.Send(reply); err != nil {
459+ log.Println("Could not send reply:", err)
460+ }
461 case "SendMessage":
462 var outMessage OutgoingMessage
463 outMessage.Reply = dbus.NewMethodReturnMessage(msg)
464@@ -175,6 +193,44 @@
465 return uuid, nil
466 }
467
468+func (service *MMSService) SetPreferredContext(context dbus.ObjectPath) error {
469+ // make set a noop if we are setting the same thing
470+ if pc, err := service.GetPreferredContext(); err != nil && context == pc {
471+ return nil
472+ }
473+
474+ if err := storage.SetPreferredContext(service.identity, context); err != nil {
475+ return err
476+ }
477+ signal := dbus.NewSignalMessage(service.payload.Path, MMS_SERVICE_DBUS_IFACE, propertyChangedSignal)
478+ if err := signal.AppendArgs(preferredContextProperty, dbus.Variant{context}); err != nil {
479+ return err
480+ }
481+ return service.conn.Send(signal)
482+}
483+
484+func (service *MMSService) GetPreferredContext() (dbus.ObjectPath, error) {
485+ return storage.GetPreferredContext(service.identity)
486+}
487+
488+func (service *MMSService) setProperty(msg *dbus.Message) error {
489+ var propertyName string
490+ var propertyValue dbus.Variant
491+ if err := msg.Args(&propertyName, &propertyValue); err != nil {
492+ return err
493+ }
494+
495+ switch propertyName {
496+ case preferredContextProperty:
497+ preferredContextObjectPath := dbus.ObjectPath(reflect.ValueOf(propertyValue.Value).String())
498+ service.Properties[preferredContextProperty] = dbus.Variant{preferredContextObjectPath}
499+ return service.SetPreferredContext(preferredContextObjectPath)
500+ default:
501+ errors.New("property cannot be set")
502+ }
503+ return errors.New("unhandled property")
504+}
505+
506 //MessageRemoved emits the MessageRemoved signal with the path of the removed
507 //message.
508 //It also actually removes the message from storage.
509@@ -190,7 +246,7 @@
510 return err
511 }
512
513- signal := dbus.NewSignalMessage(service.payload.Path, MMS_SERVICE_DBUS_IFACE, MESSAGE_REMOVED)
514+ signal := dbus.NewSignalMessage(service.payload.Path, MMS_SERVICE_DBUS_IFACE, messageRemovedSignal)
515 if err := signal.AppendArgs(objectPath); err != nil {
516 return err
517 }
518@@ -214,7 +270,7 @@
519 //MessageAdded emits a MessageAdded with the path to the added message which
520 //is taken as a parameter
521 func (service *MMSService) MessageAdded(msgPayload *Payload) error {
522- signal := dbus.NewSignalMessage(service.payload.Path, MMS_SERVICE_DBUS_IFACE, MESSAGE_ADDED)
523+ signal := dbus.NewSignalMessage(service.payload.Path, MMS_SERVICE_DBUS_IFACE, messageAddedSignal)
524 if err := signal.AppendArgs(msgPayload.Path, msgPayload.Properties); err != nil {
525 return err
526 }

Subscribers

People subscribed via source and target branches