~pedronis/ubuntu-push/automatic-land-to-vivid

« back to all changes in this revision

Viewing changes to bus/windowstack/windowstack.go

  • Committer: CI bot
  • Author(s): Richard Huddie, CI bot, Roberto Alsina, Guillermo Gonzalez, John R. Lenton, Samuele Pedroni (Canonical Services Ltd.)
  • Date: 2014-07-21 14:17:24 UTC
  • mfrom: (91.1.177 trunk)
  • Revision ID: ps-jenkins@lists.canonical.com-20140721141724-zf0n470ryo5k4dmd
  [Samuele Pedroni]
  * Check in the api whether an app has pushed too many notifications.
  * Return payload of most recent notification in too many pending
    notifications API error.
  * Introduce clear_pending flag to clean everything pending for an app.
  * Refactor and cleanup.
  * Introduce replace_tag support in store and api, with acceptance test.
  * Teach a couple of trick to cmd/acceptanceclient: exit on run timeout,
    wait for event matching given regexp pattern.
  * Limit unicast data payload to 2K.
  * Payload should be json (fixes message needing to be base64-encoded in
    helper reply)
  * Implement limited mboxes
  * Refactor and cleanup of things done in haste by Chipaca.

  [Richard Huddie]
  * autopilot test framework and basic coverage of broadcast notifications.

  [Guillermo Gonzalez]
  * Add scripts to simplify setup/run of the autopilot tests in the
    device/emulator and include basic unicast tests.
  * Add autopilot test for notification using the emblem counter.
  * Adds scenarios to the autopilot tests for legacy and click (without
    version) applications.
  * Broadcast via the helpers route.
  * Basic support for actions (only default action) in the persistent
    notifications.
  * Change PostBroadcast to send the broadcast message to the software
    updates helper.

  [John R. Lenton]
  * Detangle client and postal.
  * Introduce PostalService interface, and change the client tests to use
    that as much as reasonable.
  * Async invocation of helpers.
  * Give click.Click knowledge of helpers.
  * Write ual-based helper launcher.
  * Switch to the ual-based helper launcher unless the environment
    variable UBUNTU_PUSH_USE_TRIVIAL_HELPER is set.
  * Threw together an implementation of helpers for legacy applications.
  * Hacked up an initial software updates helper, to be handed off to the
    appropriate team shortly.

  [Roberto Alsina]
  * Wrap the (dbus) WindowStack API and add endpoint to the Postal service
    to support inhibition of notifications for focused apps.
  * Inhibit notifications for focused apps
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 Copyright 2014 Canonical Ltd.
 
3
 
 
4
 This program is free software: you can redistribute it and/or modify it
 
5
 under the terms of the GNU General Public License version 3, as published
 
6
 by the Free Software Foundation.
 
7
 
 
8
 This program is distributed in the hope that it will be useful, but
 
9
 WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 PURPOSE.  See the GNU General Public License for more details.
 
12
 
 
13
 You should have received a copy of the GNU General Public License along
 
14
 with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
*/
 
16
 
 
17
// Package windowstack retrieves information about the windowstack
 
18
// using Unity's dbus interface
 
19
package windowstack
 
20
 
 
21
import (
 
22
        "launchpad.net/ubuntu-push/bus"
 
23
        "launchpad.net/ubuntu-push/click"
 
24
        "launchpad.net/ubuntu-push/logger"
 
25
)
 
26
 
 
27
// Well known address for the WindowStack API
 
28
var BusAddress bus.Address = bus.Address{
 
29
        Interface: "com.canonical.Unity.WindowStack",
 
30
        Path:      "/com/canonical/Unity/WindowStack",
 
31
        Name:      "com.canonical.Unity.WindowStack",
 
32
}
 
33
 
 
34
type WindowsInfo struct {
 
35
        WindowId uint32
 
36
        AppId    string // in the form "com.ubuntu.calendar_calendar" or "webbrowser-app"
 
37
        Focused  bool
 
38
        Stage    uint32
 
39
}
 
40
 
 
41
// WindowStack encapsulates info needed to call out to the WindowStack API
 
42
type WindowStack struct {
 
43
        bus bus.Endpoint
 
44
        log logger.Logger
 
45
}
 
46
 
 
47
// New returns a new WindowStack that'll use the provided bus.Endpoint
 
48
func New(endp bus.Endpoint, log logger.Logger) *WindowStack {
 
49
        return &WindowStack{endp, log}
 
50
}
 
51
 
 
52
// GetWindowStack returns the window stack state
 
53
func (stack *WindowStack) GetWindowStack() []WindowsInfo {
 
54
        var wstack []WindowsInfo
 
55
        err := stack.bus.Call("GetWindowStack", bus.Args(), &wstack)
 
56
        if err != nil {
 
57
                stack.log.Errorf("GetWindowStack call returned %v", err)
 
58
        }
 
59
        return wstack
 
60
}
 
61
 
 
62
func (stack *WindowStack) IsAppFocused(AppId *click.AppId) bool {
 
63
        for _, winfo := range stack.GetWindowStack() {
 
64
                if winfo.Focused && winfo.AppId == AppId.Base() {
 
65
                        return true
 
66
                }
 
67
        }
 
68
        return false
 
69
}