~ubuntu-branches/ubuntu/trusty/ubuntu-push/trusty-proposed

« back to all changes in this revision

Viewing changes to client/client.go

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, John Lenton, Richard Huddie
  • Date: 2014-04-11 18:31:57 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140411183157-wfqzbd90wog185lu
Tags: 0.2+14.04.20140411-0ubuntu1
[ John Lenton ]
* New upstream release.

[ Richard Huddie ]
* added basic autopilot framework
* configparser and http post updates
* removed tests folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
        sessionConnectedCh chan uint32
82
82
}
83
83
 
 
84
var ACTION_ID_SNOWFLAKE = "::ubuntu-push-client::"
 
85
 
84
86
// Creates a new Ubuntu Push Notifications client-side daemon that will use
85
87
// the given configuration file.
86
88
func NewPushClient(configPath string, leveldbPath string) *PushClient {
278
280
        if !client.filterNotification(msg) {
279
281
                return nil
280
282
        }
281
 
        action_id := "dummy_id"
 
283
        action_id := ACTION_ID_SNOWFLAKE
282
284
        a := []string{action_id, "Go get it!"} // action value not visible on the phone
283
285
        h := map[string]*dbus.Variant{"x-canonical-switch-to-application": &dbus.Variant{true}}
284
286
        nots := notifications.Raw(client.notificationsEndp, client.log)
305
307
}
306
308
 
307
309
// handleClick deals with the user clicking a notification
308
 
func (client *PushClient) handleClick() error {
 
310
func (client *PushClient) handleClick(action_id string) error {
 
311
        if action_id != ACTION_ID_SNOWFLAKE {
 
312
                return nil
 
313
        }
309
314
        // it doesn't get much simpler...
310
315
        urld := urldispatcher.New(client.urlDispatcherEndp, client.log)
311
316
        return urld.DispatchURL("settings:///system/system-update")
312
317
}
313
318
 
314
319
// doLoop connects events with their handlers
315
 
func (client *PushClient) doLoop(connhandler func(bool), clickhandler func() error, notifhandler func(*session.Notification) error, errhandler func(error)) {
 
320
func (client *PushClient) doLoop(connhandler func(bool), clickhandler func(string) error, notifhandler func(*session.Notification) error, errhandler func(error)) {
316
321
        for {
317
322
                select {
318
323
                case state := <-client.connCh:
319
324
                        connhandler(state)
320
 
                case <-client.actionsCh:
321
 
                        clickhandler()
 
325
                case action := <-client.actionsCh:
 
326
                        clickhandler(action.ActionId)
322
327
                case msg := <-client.session.MsgCh:
323
328
                        notifhandler(msg)
324
329
                case err := <-client.session.ErrCh: