add (De)ActivateEngine API calls; support profile autostart
This commit is contained in:
parent
92ec4c6667
commit
6021daeaca
|
@ -16,6 +16,8 @@ const ProfileTypeV1Password = "v1-userPassword"
|
||||||
// PeerOnline stores state on if the peer believes it is online
|
// PeerOnline stores state on if the peer believes it is online
|
||||||
const PeerOnline = "peer-online"
|
const PeerOnline = "peer-online"
|
||||||
|
|
||||||
|
const PeerAutostart = "autostart"
|
||||||
|
|
||||||
// Description is used on server contacts,
|
// Description is used on server contacts,
|
||||||
const Description = "description"
|
const Description = "description"
|
||||||
|
|
||||||
|
|
22
lib.go
22
lib.go
|
@ -520,6 +520,28 @@ func GetAppBusEvent() string {
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export c_ActivatePeerEngine
|
||||||
|
func c_ActivatePeerEngine(onion_ptr *C.char, onion_len C.int) {
|
||||||
|
ActivatePeerEngine(C.GoStringN(onion_ptr, onion_len))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ActivatePeerEngine(profile string) {
|
||||||
|
doServers := false
|
||||||
|
if _, err := groups.ExperimentGate(utils.ReadGlobalSettings().Experiments); err == nil {
|
||||||
|
doServers = true
|
||||||
|
}
|
||||||
|
application.ActivatePeerEngine(profile, true, true, doServers)
|
||||||
|
}
|
||||||
|
|
||||||
|
//export c_DeactivatePeerEngine
|
||||||
|
func c_DeactivatePeerEngine(onion_ptr *C.char, onion_len C.int) {
|
||||||
|
DeactivatePeerEngine(C.GoStringN(onion_ptr, onion_len))
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeactivatePeerEngine(profile string) {
|
||||||
|
application.DeactivatePeerEngine(profile)
|
||||||
|
}
|
||||||
|
|
||||||
//export c_CreateProfile
|
//export c_CreateProfile
|
||||||
func c_CreateProfile(nick_ptr *C.char, nick_len C.int, pass_ptr *C.char, pass_len C.int) {
|
func c_CreateProfile(nick_ptr *C.char, nick_len C.int, pass_ptr *C.char, pass_len C.int) {
|
||||||
CreateProfile(C.GoStringN(nick_ptr, nick_len), C.GoStringN(pass_ptr, pass_len))
|
CreateProfile(C.GoStringN(nick_ptr, nick_len), C.GoStringN(pass_ptr, pass_len))
|
||||||
|
|
|
@ -104,7 +104,14 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
if _, err := groups.ExperimentGate(ReadGlobalSettings().Experiments); err == nil {
|
if _, err := groups.ExperimentGate(ReadGlobalSettings().Experiments); err == nil {
|
||||||
doServers = true
|
doServers = true
|
||||||
}
|
}
|
||||||
eh.app.ActivateEngines(true, true, doServers)
|
|
||||||
|
for _, onion := range eh.app.ListProfiles() {
|
||||||
|
profile := eh.app.GetPeer(onion)
|
||||||
|
autostart, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerAutostart)
|
||||||
|
if !exists || autostart == "true" {
|
||||||
|
eh.app.ActivatePeerEngine(onion, true, true, doServers)
|
||||||
|
}
|
||||||
|
}
|
||||||
eh.api.LaunchServers()
|
eh.api.LaunchServers()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,14 +163,26 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
|
|
||||||
// Start up the Profile
|
// Start up the Profile
|
||||||
if acnStatus == 100 {
|
if acnStatus == 100 {
|
||||||
doServers := false
|
autostart, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerAutostart)
|
||||||
if _, err := groups.ExperimentGate(ReadGlobalSettings().Experiments); err == nil {
|
if !exists || autostart == "true" {
|
||||||
doServers = true
|
doServers := false
|
||||||
|
if _, err := groups.ExperimentGate(ReadGlobalSettings().Experiments); err == nil {
|
||||||
|
doServers = true
|
||||||
|
}
|
||||||
|
eh.app.ActivatePeerEngine(onion, true, true, doServers)
|
||||||
}
|
}
|
||||||
eh.app.ActivatePeerEngine(onion, true, true, doServers)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
online, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline)
|
online, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline)
|
||||||
|
e.Data["Online"] = online
|
||||||
|
|
||||||
|
autostart, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerAutostart)
|
||||||
|
// legacy profiles should autostart by default
|
||||||
|
if !exists {
|
||||||
|
autostart = "true"
|
||||||
|
}
|
||||||
|
e.Data["autostart"] = autostart
|
||||||
|
|
||||||
// Name always exists
|
// Name always exists
|
||||||
e.Data[constants.Name], _ = profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
|
e.Data[constants.Name], _ = profile.GetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants.Name)
|
||||||
e.Data[constants2.DefaultProfilePicture] = RandomProfileImage(onion)
|
e.Data[constants2.DefaultProfilePicture] = RandomProfileImage(onion)
|
||||||
|
@ -183,8 +202,6 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
|
|
||||||
// Resolve the profile image of the profile.
|
// Resolve the profile image of the profile.
|
||||||
|
|
||||||
e.Data["Online"] = online
|
|
||||||
|
|
||||||
// If file sharing is enabled then reshare all active files...
|
// If file sharing is enabled then reshare all active files...
|
||||||
fsf, err := filesharing.FunctionalityGate(settings.Experiments)
|
fsf, err := filesharing.FunctionalityGate(settings.Experiments)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
Reference in New Issue