From 853ab1b93688df82d1be83ddbbe0af9ec911e725 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Mon, 27 Feb 2023 13:32:53 -0800 Subject: [PATCH] Fix Delete Profile / Experiment Setup / ACN Setup --- go.mod | 2 +- go.sum | 8 ++++++++ spec | 2 +- templates/lib_template.go | 16 ++++++++++++++-- utils/eventHandler.go | 13 +++++++++---- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 448bbd9..c5e3bf7 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 822bb5e..cb757c8 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/spec b/spec index cfd8768..1fb0330 100644 --- a/spec +++ b/spec @@ -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 diff --git a/templates/lib_template.go b/templates/lib_template.go index 76396cb..d8235f3 100644 --- a/templates/lib_template.go +++ b/templates/lib_template.go @@ -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 diff --git a/utils/eventHandler.go b/utils/eventHandler.go index 5607a5e..a0e4f26 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -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) } } }