goStart #53
1
lib.go
1
lib.go
|
@ -167,7 +167,6 @@ func ReconnectCwtchForeground() {
|
|||
}
|
||||
}
|
||||
|
||||
//export c_SendAppEvent
|
||||
//export c_SendAppEvent
|
||||
// A generic method for Rebroadcasting App Events from a UI
|
||||
dan marked this conversation as resolved
|
||||
func c_SendAppEvent(json_ptr *C.char, json_len C.int) {
|
||||
|
|
|
@ -34,7 +34,6 @@ func NewEventHandler() *EventHandler {
|
|||
// PublishAppEvent is a way for libCwtch-go to publish an event for consumption by a UI before a Cwtch app has been initalized
|
||||
// Main use: to signal an error before a cwtch app could be created
|
||||
func (eh *EventHandler) PublishAppEvent(event event.Event) {
|
||||
log.Infof("PublishAppEvent %v\n", event)
|
||||
eh.appBusQueue.Publish(event)
|
||||
dan marked this conversation as resolved
sarah
commented
this shouldn't be info this shouldn't be info
|
||||
}
|
||||
|
||||
|
@ -222,7 +221,9 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
log.Debugf("New Profile Event to Handle: %v", ev)
|
||||
switch ev.Event.EventType {
|
||||
|
||||
/*case event.NetworkStatus:
|
||||
/*
|
||||
TODO: still handle this somewhere - network info from plugin Network check
|
||||
case event.NetworkStatus:
|
||||
online, _ := peer.GetAttribute(attr.GetLocalScope(constants.PeerOnline))
|
||||
if e.Data[event.Status] == plugins.NetworkCheckSuccess && online == event.False {
|
||||
peer.SetAttribute(attr.GetLocalScope(constants.PeerOnline), event.True)
|
||||
|
@ -239,31 +240,12 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
ev.Event.Data["Picture"] = ph.GetProfilePic(ev.Event.Data["RemotePeer"])
|
||||
case event.PeerAcknowledgement:
|
||||
// No enrichement required
|
||||
//Acknowledge(ev.Event.Data[event.RemotePeer], ev.Event.Data[event.EventID])
|
||||
/*
|
||||
case event.NewMessageFromGroup: //event.TimestampReceived, event.TimestampSent, event.Data, event.GroupID, event.RemotePeer
|
||||
ts, _ := time.Parse(time.RFC3339Nano, e.Data[event.TimestampSent])
|
||||
uiManager.AddMessage(e.Data[event.GroupID], e.Data[event.RemotePeer], e.Data[event.Data], e.Data[event.RemotePeer] == peer.GetOnion(), hex.EncodeToString([]byte(e.Data[event.Signature])), ts, true)
|
||||
|
||||
case event.NewGroupInvite:
|
||||
gid, err := peer.ProcessInvite(e.Data[event.GroupInvite], e.Data[event.RemotePeer])
|
||||
group := peer.GetGroup(gid)
|
||||
if err == nil && group != nil {
|
||||
uiManager.AddContact(gid)
|
||||
}
|
||||
*/
|
||||
case event.PeerCreated:
|
||||
handle := ev.Event.Data[event.RemotePeer]
|
||||
err := EnrichNewPeer(handle, ph, ev)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
/*
|
||||
case event.SendMessageToGroupError:
|
||||
uiManager.AddSendMessageError(e.Data[event.GroupServer], e.Data[event.Signature], e.Data[event.Error])
|
||||
case event.SendMessageToPeerError:
|
||||
uiManager.AddSendMessageError(e.Data[event.RemotePeer], e.Data[event.EventID], e.Data[event.Error])
|
||||
*/
|
||||
case event.GroupCreated:
|
||||
// This event should only happen after we have validated the invite, as such the error
|
||||
// condition *should* never happen.
|
||||
|
@ -302,45 +284,20 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
|||
}
|
||||
}
|
||||
|
||||
/*case event.NewRetValMessageFromPeer:
|
||||
onion := e.Data[event.RemotePeer]
|
||||
scope := e.Data[event.Scope]
|
||||
path := e.Data[event.Path]
|
||||
val := e.Data[event.Data]
|
||||
exists, _ := strconv.ParseBool(e.Data[event.Exists])
|
||||
case event.NewRetValMessageFromPeer:
|
||||
// auto handled event means the setting is already done, we're just deciding if we need to tell the UI
|
||||
onion := ev.Event.Data[event.RemotePeer]
|
||||
scope := ev.Event.Data[event.Scope]
|
||||
path := ev.Event.Data[event.Path]
|
||||
//val := ev.Event.Data[event.Data]
|
||||
exists, _ := strconv.ParseBool(ev.Event.Data[event.Exists])
|
||||
|
||||
if exists && scope == attr.PublicScope {
|
||||
switch path {
|
||||
case constants.Name:
|
||||
peer.SetContactAttribute(onion, attr.GetPeerScope(constants.Name), val)
|
||||
uiManager.UpdateContactDisplayName(onion)
|
||||
case constants.Picture:
|
||||
peer.SetContactAttribute(onion, attr.GetPeerScope(constants.Picture), val)
|
||||
uiManager.UpdateContactPicture(onion)
|
||||
if _, exists := peer.GetContactAttribute(onion, attr.GetLocalScope(path)); exists {
|
||||
// we have a locally set ovverride, don't pass this remote set public scope update to UI
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
case event.ServerStateChange:
|
||||
serverOnion := e.Data[event.GroupServer]
|
||||
state := connections.ConnectionStateToType[e.Data[event.ConnectionState]]
|
||||
groups := peer.GetGroups()
|
||||
for _, groupID := range groups {
|
||||
group := peer.GetGroup(groupID)
|
||||
if group != nil && group.GroupServer == serverOnion {
|
||||
group.State = e.Data[event.ConnectionState]
|
||||
loading := false
|
||||
if state == connections.AUTHENTICATED {
|
||||
loading = true
|
||||
}
|
||||
uiManager.UpdateContactStatus(groupID, int(state), loading)
|
||||
uiManager.UpdateContactStatus(serverOnion, int(state), loading)
|
||||
}
|
||||
}
|
||||
case event.DeletePeer:
|
||||
log.Infof("PeerHandler got DeletePeer, SHUTTING down!\n")
|
||||
uiManager.ReloadProfiles()
|
||||
return
|
||||
*/
|
||||
}
|
||||
|
||||
json, _ := json.Marshal(unwrap(ev))
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
CwtchStarted = event.Type("CwtchStarted")
|
||||
CwtchStartError = event.Type("CwtchStartError")
|
||||
CwtchStarted = event.Type("CwtchStarted")
|
||||
CwtchStartError = event.Type("CwtchStartError")
|
||||
UpdateGlobalSettings = event.Type("UpdateGlobalSettings")
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
duplicate?