Adopt cwtch app level reload system #187
|
@ -17,6 +17,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
|
|||
the.AppBus.Subscribe(event.PeerError, q.EventChannel)
|
||||
the.AppBus.Subscribe(event.AppError, q.EventChannel)
|
||||
the.AppBus.Subscribe(event.ACNStatus, q.EventChannel)
|
||||
the.AppBus.Subscribe(event.ReloadDone, q.EventChannel)
|
||||
|
||||
for {
|
||||
e := q.Next()
|
||||
|
@ -51,9 +52,13 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
|
|||
// TODO: only an error if other profiles are not loaded
|
||||
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:
|
||||
if the.Peer != nil {
|
||||
continue
|
||||
|
@ -64,7 +69,9 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
|
|||
the.EventBus = the.CwtchApp.GetEventBus(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()
|
||||
for i := range contacts {
|
||||
|
@ -99,7 +106,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) {
|
|||
Image: cwutil.RandomGroupImage(group.GroupID),
|
||||
Server: group.GroupServer,
|
||||
Trusted: group.Accepted,
|
||||
Loading: true,
|
||||
Loading: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ func IncomingListener(uiState *gothings.InterfaceState) {
|
|||
the.EventBus.Subscribe(event.SendMessageToGroupError, q.EventChannel)
|
||||
the.EventBus.Subscribe(event.SendMessageToPeerError, 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.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])
|
||||
case event.SendMessageToPeerError:
|
||||
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:
|
||||
cxnState := connections.ConnectionStateType[e.Data[event.ConnectionState]]
|
||||
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)
|
||||
if group != nil && group.GroupServer == serverOnion {
|
||||
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)
|
||||
} else {
|
||||
log.Errorf("grouppoller found a group that is nil :/")
|
||||
log.Errorf("found group that is nil :/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,12 +175,3 @@ func (this *InterfaceState) UpdateContact(handle string) {
|
|||
func (this *InterfaceState) UpdateContactAttribute(handle, key, value string) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ import (
|
|||
"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 CwtchService app.ApplicationService
|
||||
var EventBus event.Manager
|
||||
|
|
12
main.go
12
main.go
|
@ -177,7 +177,6 @@ func mainUi(flagLocal bool, flagClientUI bool) {
|
|||
|
||||
log.Infoln("Cwtch App starting app.Exec")
|
||||
app.Exec()
|
||||
|
||||
}
|
||||
|
||||
func loadACN() {
|
||||
|
@ -214,11 +213,7 @@ func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool,
|
|||
serviceIn := path.Join(the.CwtchDir, "serviceIn")
|
||||
if service {
|
||||
loadACN()
|
||||
serviceBridge, err := bridge.NewPipeBridgeService(serviceIn, clientIn)
|
||||
if err != nil {
|
||||
log.Errorf("Could not create service bridge: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
serviceBridge := bridge.NewPipeBridgeService(serviceIn, clientIn)
|
||||
log.Infoln("Creating New App Service")
|
||||
the.CwtchService = libapp.NewAppService(the.ACN, the.CwtchDir, serviceBridge)
|
||||
} else {
|
||||
|
@ -235,6 +230,9 @@ func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool,
|
|||
if !service {
|
||||
the.AppBus = the.CwtchApp.GetPrimaryBus()
|
||||
go characters.AppEventListener(gcd)
|
||||
the.CwtchApp.LoadProfiles("be gay do crime")
|
||||
}
|
||||
|
||||
if !service && !clientUI {
|
||||
the.CwtchApp.LoadProfiles(the.AppPassword)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,12 +112,13 @@ ColumnLayout {
|
|||
|
||||
onUpdateContact: function(_handle, _displayName, _image, _server, _badge, _status, _trusted, _loading) {
|
||||
if (gcd.currentOpenConversation == _handle) {
|
||||
if (_loading == true) {
|
||||
txtMessage.enabled = false
|
||||
btnSend.enabled = false
|
||||
} else {
|
||||
// Group is Synced OR p2p is Authenticated
|
||||
if ( (_handle.length == 32 && _status == 4) || _status == 3) {
|
||||
txtMessage.enabled = true
|
||||
btnSend.enabled = true
|
||||
} else {
|
||||
txtMessage.enabled = false
|
||||
btnSend.enabled = false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ Item {
|
|||
anchors.margins: 4 * logscale
|
||||
|
||||
|
||||
Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Failed,5:Killed
|
||||
color: status == 3 ? "green" : status == -1 ? "blue" : status == 1 ? "orange" : status == 2 ? "orange" : "red"
|
||||
Rectangle { //-2:WtfCodeError,-1:Untrusted,0:Disconnected,1:Connecting,2:Connected,3:Authenticated,4:Synced,5:Failed,6:Killed
|
||||
color: status == 4 ? "green" : status == 3 ? "green" : status == -1 ? "blue" : status == 1 ? "orange" : status == 2 ? "orange" : "red"
|
||||
width: 5 * logscale
|
||||
height: 5 * logscale
|
||||
radius: 2 * logscale
|
||||
|
|
|
@ -91,6 +91,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|||
id: loadingProgress
|
||||
property bool running
|
||||
running: loading
|
||||
visible: loading
|
||||
|
||||
anchors.right: rectUnread.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
@ -104,7 +105,6 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|||
|
||||
|
||||
indeterminate: true
|
||||
visible: loading
|
||||
|
||||
style: ProgressBarStyle {
|
||||
progress: CwtchProgress { running: loadingProgress.running}
|
||||
|
|
Reference in New Issue