This commit is contained in:
Sarah Jamie Lewis 2023-02-23 10:14:27 -08:00
parent 0ecda3d3d5
commit a4bbda2556
4 changed files with 38 additions and 35 deletions

35
README.md Normal file
View File

@ -0,0 +1,35 @@
# Cwtch Autobindings
## Building
go mod download
go run generate/generate_bindings.go
make linux // alternatively windows, android, macos
## Spec File Format
The current Cwtch Bindings Specification is defined in [spec](./spec)
Supported function prototypes:
* `app <Function Name> <Args>` - an application-level function, called on global `Application`
* `profile <Function Name> <Args>` - a profile-level function, takes `profile` as an implicit first argument
* `json(profile) <Function Name> <Args>` - a profile-level function, takes `profile` as an implicit first argument and returns a json blob that must be freed by the calling library
* `@profile-experiment <Function Name> <Experiment> <Args>`- an experimental profile-level function, takes `profile` as an implicit first argument, experiment must implement cwtch Functionality interface
* `@(json)profile-experiment <Function Name> <Experiment> <Args>` - am experimental profile-level function, takes `profile` as an implicit first argument and returns a json blob that must be freed by the calling library, , experiment must implement cwtch Functionality interface
Supported argument prototypes:
* `profile` - a cwtch profile identifier
* `conversation` - a cwtch conversation identifier
* `message` - a cwtch message identifier
* `int:<name>` - a generic integer argument (with optional name)
* `bool:<name>` - a generic boolean argument (with optional name)
* `string:<name>` - a generic string argument (with optional name)
All arguments must be defined in the order they are specified by the underlying Cwtch library function.
Other directives:
* `import <go pkg>` - includes an additional go importin the compiled lib.go (needed for experiments)
* Functions that start with `Enhanced` are automatically stripped of that prefix for their binding names e.g. `EnhancedGetMessage` generated a binding `c_GetMessage` - for certain functions Cwtch has two potential calling options `<Function>` and `Enhanced<Function>`. "Enhanced" in this case means that the response is optimised for calling by a user-facing application by e.g. directly making a number of calls under the hood and returning a json blob of the results.

View File

@ -1,37 +1,17 @@
package constants
const SchemaVersion = "schemaVersion"
const Name = "name"
const LastRead = "last-read"
const Picture = "picture"
const DefaultProfilePicture = "defaultPicture"
const ShowBlocked = "show-blocked"
const Archived = "archived"
const LastSeenTime = "lastMessageSeenTime"
const ProfileTypeV1DefaultPassword = "v1-defaultPassword"
const ProfileTypeV1Password = "v1-userPassword"
// PeerOnline stores state on if the peer believes it is online
const PeerOnline = "peer-online"
const PeerAutostart = "autostart"
// Description is used on server contacts,
const Description = "description"
// ConversationNotificationPolicy is the attribute label for conversations. When App NotificationPolicy is OptIn a true value here opts in
const ConversationNotificationPolicy = "notification-policy"
const StateProfilePane = "state-profile-pane"
const StateSelectedConversation = "state-selected-conversation"
const StateSelectedProfileTime = "state-selected-profile-time"
// Settings
const BlockUnknownPeersSetting = "blockunknownpeers"
const LocaleSetting = "locale"
const ZoomSetting = "zoom"
// App Experiments
const MessageFormattingExperiment = "message-formatting"

View File

@ -1,17 +1,5 @@
package constants
// We offer "un-passworded" profiles but our storage encrypts everything with a password. We need an agreed upon
// password to use in that case, that the app case use behind the scenes to password and unlock with
// https://docs.openprivacy.ca/cwtch-security-handbook/profile_encryption_and_storage.html
const DefactoPasswordForUnencryptedProfiles = "be gay do crime"
const (
// StatusSuccess is an event response for event.Status signifying a call succeeded
StatusSuccess = "success"
// StatusError is an event response for event.Status signifying a call failed in error, ideally accompanied by a event.Error
StatusError = "error"
)
type NotificationType string
const (

View File

@ -4,7 +4,7 @@ import (
"cwtch.im/cwtch/app"
"cwtch.im/cwtch/model"
"cwtch.im/cwtch/model/attr"
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
"git.openprivacy.ca/cwtch.im/cwtch-autobindings/constants"
)
func determineNotification(ci *model.Conversation, settings app.GlobalSettings) constants.NotificationType {