2
Copyright 2014 Canonical Ltd.
3
Authors: Sergio Schvezov <sergio.schvezov@canonical.com>
5
This program is free software: you can redistribute it and/or modify it
6
under the terms of the GNU General Public License version 3, as published
7
by the Free Software Foundation.
9
This program is distributed in the hope that it will be useful, but
10
WITHOUT ANY WARRANTY; without even the implied warranties of
11
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
PURPOSE. See the GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License along
15
with this program. If not, see <http://www.gnu.org/licenses/>.
20
// Plugin is an interface which the plugins will adhere to for the poll
21
// daemon to interact with.
23
// Register is the first method to be called after creating a New[plugin],
24
// upon register the plugin will check if it is Authorized and Installed
25
// and send it over State.
27
// Poll interacts with the backend service with the means the plugin defines
28
// and returns a list of Notifications to send to the Push service. If an
29
// error occurs and is returned the daemon can decide to throttle the service.
31
// GetType is for future use and helps the daemon determine the polling
33
type Plugin interface {
34
Register() (ApplicationId, chan (State))
35
Poll() (*[]Notification, error)
41
// ApplicationId represents the application id to direct posts to.
42
// e.g.: com.ubuntu.diaspora_diaspora or com.ubuntu.diaspora_diaspora_1.0
44
// TODO define if APP_ID can be of short form
45
// TODO find documentation where short APP_ID is defined (aka versionless APP_ID).
46
type ApplicationId string
48
// Notification represents the data pass over to the Post Office
49
type Notification struct {
50
Sound string `json:"sound"`
51
Card Card `json:"card"`
55
Summary string `json:"summary"`
56
Popup bool `json:"popup"`
57
Persist bool `json:"persist"`
60
// State represents a state change for a plugin. Installed is set to true when
61
// the package that is supposed to handle the notification is installed whilst
62
// Authorized being true means that at least one account is authorized to poll
64
Installed, Authorized bool
67
// The constanst defined here determine the polling aggressivenes with the following criteria
68
// MAXIMUM: calls, health warning
69
// HIGH: SMS, chat message, new email
70
// DEFAULT: social media updates
71
// LOW: software updates, junk email