Fix Delete Profile / Experiment Setup / ACN Setup

This commit is contained in:
Sarah Jamie Lewis 2023-02-27 13:32:53 -08:00
parent 9cbd7d47a4
commit 853ab1b936
5 changed files with 33 additions and 8 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module git.openprivacy.ca/cwtch.im/cwtch-autobindings
go 1.19
require (
cwtch.im/cwtch v0.18.10-0.20230221235514-49e0d849fa3e
cwtch.im/cwtch v0.18.10-0.20230227213132-dfaed356c491
git.openprivacy.ca/cwtch.im/server v1.4.5
git.openprivacy.ca/openprivacy/connectivity v1.8.6
git.openprivacy.ca/openprivacy/log v1.0.3

8
go.sum
View File

@ -1,6 +1,14 @@
cwtch.im/cwtch v0.18.0/go.mod h1:StheazFFY7PKqBbEyDVLhzWW6WOat41zV0ckC240c5Y=
cwtch.im/cwtch v0.18.10-0.20230221235514-49e0d849fa3e h1:5Gu6fKJNcTR7zzNj/JBtdrZqtkGh4eP/FQPwrF6sY5A=
cwtch.im/cwtch v0.18.10-0.20230221235514-49e0d849fa3e/go.mod h1:h8S7EgEM+8pE1k+XLB5jAFdIPlOzwoXEY0GH5mQye5A=
cwtch.im/cwtch v0.18.10-0.20230225151912-b22b8f329771 h1:Rc+3E0FGDbia35//hI/dH4feTww/w2gz4/2nHYI8sq0=
cwtch.im/cwtch v0.18.10-0.20230225151912-b22b8f329771/go.mod h1:h8S7EgEM+8pE1k+XLB5jAFdIPlOzwoXEY0GH5mQye5A=
cwtch.im/cwtch v0.18.10-0.20230227200154-03da50b85054 h1:PeEVr0+KSqJlL41UkCRLKIo8DJRTWKlbxsvXacp/Z+U=
cwtch.im/cwtch v0.18.10-0.20230227200154-03da50b85054/go.mod h1:h8S7EgEM+8pE1k+XLB5jAFdIPlOzwoXEY0GH5mQye5A=
cwtch.im/cwtch v0.18.10-0.20230227200719-c90301bb4cfa h1:U+zbOAapOb1SAaoFuBywi9wb3e8/xcpZSNBry6EPfj4=
cwtch.im/cwtch v0.18.10-0.20230227200719-c90301bb4cfa/go.mod h1:h8S7EgEM+8pE1k+XLB5jAFdIPlOzwoXEY0GH5mQye5A=
cwtch.im/cwtch v0.18.10-0.20230227213132-dfaed356c491 h1:pzzWnyXQHsnKDNHhG+JRTlDg3Eit62grfkM6KeUiv8g=
cwtch.im/cwtch v0.18.10-0.20230227213132-dfaed356c491/go.mod h1:h8S7EgEM+8pE1k+XLB5jAFdIPlOzwoXEY0GH5mQye5A=
cwtch.im/cwtch v0.18.10 h1:iTzLzlms1mgn8kLfClU/yAWIVWVRRT8UmfbDNli9dzE=
cwtch.im/cwtch v0.18.10/go.mod h1:h8S7EgEM+8pE1k+XLB5jAFdIPlOzwoXEY0GH5mQye5A=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=

2
spec
View File

@ -13,7 +13,7 @@ profile ChangePassword string:current string:newPassword string:newPasswordAgain
profile ExportProfile string:file
# Conversation Management
profile ImportBundle string:bundle
(json)profile EnhancedImportBundle string:bundle
profile ArchiveConversation conversation
profile AcceptConversation conversation
profile BlockConversation conversation

View File

@ -162,7 +162,7 @@ func _startCwtch(appDir string, torPath string) {
globalTorPath = torPath
settingsFile := app.InitApp(appDir)
newACN, settings := buildACN(settingsFile.ReadGlobalSettings(), globalTorPath, globalAppDir)
globalACN := connectivity.NewProxyACN(newACN)
globalACN = connectivity.NewProxyACN(newACN)
settingsFile.WriteGlobalSettings(settings)
application = app.NewApp(&globalACN, appDir, settingsFile)
@ -181,12 +181,12 @@ func _startCwtch(appDir string, torPath string) {
return
}
// Send global settings to the UI...
application.UpdateSettings(application.ReadSettings())
application.GetPrimaryBus().Publish(event.NewEvent(app.UpdateGlobalSettings, map[event.Field]string{event.Data: string(settingsJson)}))
log.Infof("libcwtch-go application launched")
application.GetPrimaryBus().Publish(event.NewEvent(app.CwtchStarted, map[event.Field]string{}))
application.QueryACNVersion()
application.LoadProfiles(app.DefactoPasswordForUnencryptedProfiles)
application.UpdateSettings(application.ReadSettings())
}
// the pointer returned from this function **must** be freed using c_Free
@ -277,6 +277,18 @@ func ResetTor() {
log.Infof("Restarted")
}
//export c_UpdateSettings
func c_UpdateSettings(json_ptr *C.char, json_len C.int) {
settingsJson := C.GoStringN(json_ptr, json_len)
UpdateSettings(settingsJson)
}
func UpdateSettings(settingsJson string) {
var newSettings app.GlobalSettings
json.Unmarshal([]byte(settingsJson), &newSettings)
application.UpdateSettings(newSettings)
}
{{BINDINGS}}
// Leave as is, needed by ffi

View File

@ -100,9 +100,11 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
if acnStatus != 100 {
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)
if profile != nil {
autostart, exists := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerAutostart)
if !exists || autostart == "true" {
eh.app.ActivatePeerEngine(onion)
}
}
}
//eh.api.LaunchServers()
@ -615,12 +617,15 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
// reset the share timestamp, currently file shares are hardcoded to expire after 30 days...
// we reset the profile image here so that it is always available.
profile.SetScopedZonedAttribute(attr.LocalScope, attr.FilesharingZone, fmt.Sprintf("%s.ts", key), strconv.FormatInt(time.Now().Unix(), 10))
log.Debugf("Custom Profile Image: %v %s", key, serializedManifest)
log.Infof("Custom Profile Image: %v %s", key, serializedManifest)
}
// If file sharing is enabled then reshare all active files...
fsf, err := filesharing.FunctionalityGate(settings.Experiments)
if err == nil {
fsf.ReShareFiles(profile)
info, _ := fsf.GetFileShareInfo(profile, key)
log.Infof("Custom Profile Image: %v %v", key, info)
}
}
}