2019-08-02 01:09:01 +00:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"cwtch.im/cwtch/event"
|
2020-02-10 22:09:24 +00:00
|
|
|
"git.openprivacy.ca/openprivacy/connectivity"
|
2019-08-02 01:09:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// PluginID is used as an ID for signaling plugin activities
|
|
|
|
type PluginID int
|
|
|
|
|
|
|
|
// These are the plugin IDs for the supplied plugins
|
|
|
|
const (
|
2019-09-26 23:43:34 +00:00
|
|
|
CONNECTIONRETRY PluginID = iota
|
2019-10-31 23:05:01 +00:00
|
|
|
NETWORKCHECK
|
2019-08-02 01:09:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Plugin is the interface for a plugin
|
|
|
|
type Plugin interface {
|
|
|
|
Start()
|
|
|
|
Shutdown()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get is a plugin factory for the requested plugin
|
2021-03-19 21:20:22 +00:00
|
|
|
func Get(id PluginID, bus event.Manager, acn connectivity.ACN, onion string) Plugin {
|
2019-08-02 01:09:01 +00:00
|
|
|
switch id {
|
2019-09-26 23:43:34 +00:00
|
|
|
case CONNECTIONRETRY:
|
2021-03-19 21:20:22 +00:00
|
|
|
return NewConnectionRetry(bus, onion)
|
2019-10-31 23:05:01 +00:00
|
|
|
case NETWORKCHECK:
|
|
|
|
return NewNetworkCheck(bus, acn)
|
2019-08-02 01:09:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|