Merge branch 'appReload' of dan/ui into master

This commit is contained in:
erinn 2019-07-23 13:57:41 -07:00 committed by Gogs
commit f4b1296aa2
8 changed files with 32 additions and 32 deletions

View File

@ -17,6 +17,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
the.AppBus.Subscribe(event.PeerError, q.EventChannel) the.AppBus.Subscribe(event.PeerError, q.EventChannel)
the.AppBus.Subscribe(event.AppError, q.EventChannel) the.AppBus.Subscribe(event.AppError, q.EventChannel)
the.AppBus.Subscribe(event.ACNStatus, q.EventChannel) the.AppBus.Subscribe(event.ACNStatus, q.EventChannel)
the.AppBus.Subscribe(event.ReloadDone, q.EventChannel)
for { for {
e := q.Next() e := q.Next()
@ -51,9 +52,13 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
// TODO: only an error if other profiles are not loaded // TODO: only an error if other profiles are not loaded
log.Infoln("couldn't load your config file. attempting to create one now") log.Infoln("couldn't load your config file. attempting to create one now")
the.CwtchApp.CreatePeer("alice", "be gay do crime") the.CwtchApp.CreatePeer("alice", the.AppPassword)
} }
case event.ReloadDone:
if the.Peer == nil {
the.CwtchApp.LoadProfiles(the.AppPassword)
}
case event.NewPeer: case event.NewPeer:
if the.Peer != nil { if the.Peer != nil {
continue continue
@ -64,7 +69,9 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
the.EventBus = the.CwtchApp.GetEventBus(onion) the.EventBus = the.CwtchApp.GetEventBus(onion)
gcd.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, cwutil.RandomProfileImage(the.Peer.GetProfile().Onion)) gcd.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, cwutil.RandomProfileImage(the.Peer.GetProfile().Onion))
the.CwtchApp.LaunchPeers() if e.Data[event.Status] != "running" {
the.CwtchApp.LaunchPeers()
}
contacts := the.Peer.GetContacts() contacts := the.Peer.GetContacts()
for i := range contacts { for i := range contacts {
@ -99,7 +106,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
Image: cwutil.RandomGroupImage(group.GroupID), Image: cwutil.RandomGroupImage(group.GroupID),
Server: group.GroupServer, Server: group.GroupServer,
Trusted: group.Accepted, Trusted: group.Accepted,
Loading: true, Loading: false,
}) })
} }
} }

View File

@ -19,7 +19,6 @@ func IncomingListener(uiState *gothings.InterfaceState) {
the.EventBus.Subscribe(event.SendMessageToGroupError, q.EventChannel) the.EventBus.Subscribe(event.SendMessageToGroupError, q.EventChannel)
the.EventBus.Subscribe(event.SendMessageToPeerError, q.EventChannel) the.EventBus.Subscribe(event.SendMessageToPeerError, q.EventChannel)
the.EventBus.Subscribe(event.JoinServer, q.EventChannel) the.EventBus.Subscribe(event.JoinServer, q.EventChannel)
the.EventBus.Subscribe(event.FinishedFetch, q.EventChannel)
the.EventBus.Subscribe(event.ServerStateChange, q.EventChannel) the.EventBus.Subscribe(event.ServerStateChange, q.EventChannel)
the.EventBus.Subscribe(event.PeerStateChange, q.EventChannel) the.EventBus.Subscribe(event.PeerStateChange, q.EventChannel)
@ -74,10 +73,6 @@ func IncomingListener(uiState *gothings.InterfaceState) {
uiState.AddSendMessageError(e.Data[event.GroupServer], e.Data[event.Signature], e.Data[event.Error]) uiState.AddSendMessageError(e.Data[event.GroupServer], e.Data[event.Signature], e.Data[event.Error])
case event.SendMessageToPeerError: case event.SendMessageToPeerError:
uiState.AddSendMessageError(e.Data[event.RemotePeer], e.Data[event.Signature], e.Data[event.Error]) uiState.AddSendMessageError(e.Data[event.RemotePeer], e.Data[event.Signature], e.Data[event.Error])
case event.JoinServer:
uiState.UpdateServerStatus(e.Data[event.GroupServer], true)
case event.FinishedFetch:
uiState.UpdateServerStatus(e.Data[event.GroupServer], false)
case event.PeerStateChange: case event.PeerStateChange:
cxnState := connections.ConnectionStateType[e.Data[event.ConnectionState]] cxnState := connections.ConnectionStateType[e.Data[event.ConnectionState]]
if contact, exists := the.Peer.GetProfile().Contacts[e.Data[event.RemotePeer]]; exists { if contact, exists := the.Peer.GetProfile().Contacts[e.Data[event.RemotePeer]]; exists {
@ -102,9 +97,14 @@ func IncomingListener(uiState *gothings.InterfaceState) {
group := the.Peer.GetGroup(groupID) group := the.Peer.GetGroup(groupID)
if group != nil && group.GroupServer == serverOnion { if group != nil && group.GroupServer == serverOnion {
uiState.GetContact(group.GroupID).Status = int(state) uiState.GetContact(group.GroupID).Status = int(state)
if state == connections.AUTHENTICATED {
uiState.GetContact(group.GroupID).Loading = true
} else {
uiState.GetContact(group.GroupID).Loading = false
}
uiState.UpdateContact(group.GroupID) uiState.UpdateContact(group.GroupID)
} else { } else {
log.Errorf("grouppoller found a group that is nil :/") log.Errorf("found group that is nil :/")
} }
} }
} }

View File

@ -175,12 +175,3 @@ func (this *InterfaceState) UpdateContact(handle string) {
func (this *InterfaceState) UpdateContactAttribute(handle, key, value string) { func (this *InterfaceState) UpdateContactAttribute(handle, key, value string) {
this.parentGcd.UpdateContactAttribute(handle, key, value) this.parentGcd.UpdateContactAttribute(handle, key, value)
} }
func (this *InterfaceState) UpdateServerStatus(server string, loading bool) {
for _, contact := range this.contacts {
if contact.Server == server {
contact.Loading = loading
this.UpdateContact(contact.Handle)
}
}
}

View File

@ -7,6 +7,9 @@ import (
"git.openprivacy.ca/openprivacy/libricochet-go/connectivity" "git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
) )
// Terrible, to be replaced when proper profile/password management comes in ~ 0.2
const AppPassword = "be gay do crime"
var CwtchApp app.Application var CwtchApp app.Application
var CwtchService app.ApplicationService var CwtchService app.ApplicationService
var EventBus event.Manager var EventBus event.Manager

12
main.go
View File

@ -177,7 +177,6 @@ func mainUi(flagLocal bool, flagClientUI bool) {
log.Infoln("Cwtch App starting app.Exec") log.Infoln("Cwtch App starting app.Exec")
app.Exec() app.Exec()
} }
func loadACN() { func loadACN() {
@ -214,11 +213,7 @@ func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool,
serviceIn := path.Join(the.CwtchDir, "serviceIn") serviceIn := path.Join(the.CwtchDir, "serviceIn")
if service { if service {
loadACN() loadACN()
serviceBridge, err := bridge.NewPipeBridgeService(serviceIn, clientIn) serviceBridge := bridge.NewPipeBridgeService(serviceIn, clientIn)
if err != nil {
log.Errorf("Could not create service bridge: %v\n", err)
os.Exit(1)
}
log.Infoln("Creating New App Service") log.Infoln("Creating New App Service")
the.CwtchService = libapp.NewAppService(the.ACN, the.CwtchDir, serviceBridge) the.CwtchService = libapp.NewAppService(the.ACN, the.CwtchDir, serviceBridge)
} else { } else {
@ -235,6 +230,9 @@ func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool,
if !service { if !service {
the.AppBus = the.CwtchApp.GetPrimaryBus() the.AppBus = the.CwtchApp.GetPrimaryBus()
go characters.AppEventListener(gcd) go characters.AppEventListener(gcd)
the.CwtchApp.LoadProfiles("be gay do crime") }
if !service && !clientUI {
the.CwtchApp.LoadProfiles(the.AppPassword)
} }
} }

View File

@ -112,12 +112,13 @@ ColumnLayout {
onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted, _loading) { onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted, _loading) {
if (gcd.currentOpenConversation == _handle) { if (gcd.currentOpenConversation == _handle) {
if (_loading == true) { // Group is Synced OR p2p is Authenticated
txtMessage.enabled = false if ( (_handle.length == 32 && _status == 4) || _status == 3) {
btnSend.enabled = false
} else {
txtMessage.enabled = true txtMessage.enabled = true
btnSend.enabled = true btnSend.enabled = true
} else {
txtMessage.enabled = false
btnSend.enabled = false
} }
} }

View File

@ -68,8 +68,8 @@ Item {
anchors.margins: 4 * logscale anchors.margins: 4 * logscale
Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Failed,5:Killed Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Synced,5:Failed,6:Killed
color: status == 3 ? "green" : status == -1 ? "blue" : status == 1 ? "orange" : status == 2 ? "orange" : "red" color: status == 4 ? "green" : status == 3 ? "green" : status == -1 ? "blue" : status == 1 ? "orange" : status == 2 ? "orange" : "red"
width: 5 * logscale width: 5 * logscale
height: 5 * logscale height: 5 * logscale
radius: 2 * logscale radius: 2 * logscale

View File

@ -91,6 +91,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
id: loadingProgress id: loadingProgress
property bool running property bool running
running: loading running: loading
visible: loading
anchors.right: rectUnread.left anchors.right: rectUnread.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -104,7 +105,6 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
indeterminate: true indeterminate: true
visible: loading
style: ProgressBarStyle { style: ProgressBarStyle {
progress: CwtchProgress { running: loadingProgress.running} progress: CwtchProgress { running: loadingProgress.running}