Add Group now Works (with TofuBundle)
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
cfe0105992
commit
6292b5a1b9
100
go/ui/gcd.go
100
go/ui/gcd.go
|
@ -116,8 +116,8 @@ type GrandCentralDispatcher struct {
|
|||
_ func(onion string, auth string) `signal:"setPeerAuthorization,auto"`
|
||||
_ func(onion string) `signal:"loadMessagesPane,auto"`
|
||||
_ func(signal string) `signal:"broadcast,auto"` // convenience relay signal
|
||||
_ func(str string) `signal:"importString,auto"`
|
||||
_ func(name, address string) `signal:"addPeer,auto"`
|
||||
_ func(address string) `signal:"addGroup,auto"`
|
||||
_ func(str string) `signal:"createContact,auto"`
|
||||
_ func(str string) `signal:"popup,auto"`
|
||||
_ func(server, groupName string) `signal:"createGroup,auto"`
|
||||
|
@ -383,6 +383,12 @@ func (this *GrandCentralDispatcher) requestServerSettings(groupID string) {
|
|||
|
||||
serverInfo := the.Peer.GetContact(group.GroupServer)
|
||||
|
||||
if serverInfo == nil {
|
||||
// This should never happen...there is a bug....
|
||||
log.Errorf("No server info found for ", group.GroupServer)
|
||||
return
|
||||
}
|
||||
|
||||
key_types := []model.KeyType{model.KeyTypeServerOnion, model.KeyTypeTokenOnion, model.KeyTypePrivacyPass}
|
||||
var keyNames []string
|
||||
var keys []string
|
||||
|
@ -485,6 +491,25 @@ func (this *GrandCentralDispatcher) createContact(onion string) {
|
|||
the.Peer.PeerWithOnion(onion)
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) addGroup(address string) {
|
||||
log.Debugf("importing group: %s\n", address)
|
||||
address = strings.TrimSpace(address)
|
||||
|
||||
if gf, err := groups.ExperimentGate(this.GlobalSettings.Experiments); err == nil {
|
||||
if gf.ValidPrefix(address) {
|
||||
err = gf.HandleImportString(address)
|
||||
if err == nil {
|
||||
// TODO: We need a better way of signaling the success of "invisible" actions like adding server bundles
|
||||
this.InvokePopup("successfully imported")
|
||||
return
|
||||
}
|
||||
this.InvokePopup("failed import: " + err.Error())
|
||||
return
|
||||
}
|
||||
// drop through to peer import strings
|
||||
}
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) addPeer(name, address string) {
|
||||
|
||||
log.Debugf("importing peer: %s\n", address)
|
||||
|
@ -496,8 +521,6 @@ func (this *GrandCentralDispatcher) addPeer(name, address string) {
|
|||
return
|
||||
}
|
||||
|
||||
name = strings.TrimSpace(name)
|
||||
|
||||
_, err := base32.StdEncoding.DecodeString(strings.ToUpper(address[:56]))
|
||||
if err != nil {
|
||||
log.Debugln(err)
|
||||
|
@ -520,77 +543,6 @@ func (this *GrandCentralDispatcher) addPeer(name, address string) {
|
|||
this.GetUiManager(this.selectedProfile()).AddContact(address)
|
||||
}
|
||||
|
||||
// Deprecated TODO: delete when gcd.addGroup is implemented from this
|
||||
func (this *GrandCentralDispatcher) importString(str string) {
|
||||
if len(str) < 5 {
|
||||
log.Debugf("ignoring short string")
|
||||
return
|
||||
}
|
||||
|
||||
if gf, err := groups.ExperimentGate(this.GlobalSettings.Experiments); err == nil {
|
||||
if gf.ValidPrefix(str) {
|
||||
err = gf.HandleImportString(str)
|
||||
if err == nil {
|
||||
// TODO: We need a better way of signaling the success of "invisible" actions like adding server bundles
|
||||
this.InvokePopup("successfully imported")
|
||||
return
|
||||
}
|
||||
this.InvokePopup("failed import: " + err.Error())
|
||||
return
|
||||
}
|
||||
// drop through to peer import strings
|
||||
}
|
||||
|
||||
log.Debugf("importing: %s\n", str)
|
||||
onion := str
|
||||
name := onion
|
||||
str = strings.TrimSpace(str)
|
||||
|
||||
if strings.Contains(str, " ") { // usually people prepend spaces and we don't want it going into the name (use ~ for that)
|
||||
parts := strings.Split(strings.TrimSpace(str), " ")
|
||||
str = parts[len(parts)-1]
|
||||
}
|
||||
|
||||
if strings.Contains(str, "~") {
|
||||
parts := strings.Split(str, "~")
|
||||
onion = parts[len(parts)-1]
|
||||
name = strings.Join(parts[:len(parts)-1], " ")
|
||||
}
|
||||
|
||||
if len(onion) != 56 {
|
||||
this.InvokePopup("invalid format")
|
||||
return
|
||||
}
|
||||
|
||||
name = strings.TrimSpace(name)
|
||||
if name == "" {
|
||||
this.InvokePopup("empty name")
|
||||
return
|
||||
}
|
||||
|
||||
if len(name) > 32 {
|
||||
name = name[:32] //TODO: better strategy for long names?
|
||||
}
|
||||
|
||||
_, err := base32.StdEncoding.DecodeString(strings.ToUpper(onion[:56]))
|
||||
if err != nil {
|
||||
log.Debugln(err)
|
||||
this.InvokePopup("bad format. missing handlers?")
|
||||
return
|
||||
}
|
||||
|
||||
checkc := the.Peer.GetContact(onion)
|
||||
if checkc != nil {
|
||||
this.InvokePopup("already have this contact")
|
||||
return //TODO: bring them to the duplicate
|
||||
} else {
|
||||
the.Peer.AddContact(name, onion, model.AuthApproved)
|
||||
the.Peer.PeerWithOnion(onion)
|
||||
}
|
||||
|
||||
this.GetUiManager(this.selectedProfile()).AddContact(onion)
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) popup(str string) {
|
||||
this.InvokePopup(str)
|
||||
}
|
||||
|
|
|
@ -183,18 +183,6 @@ Rectangle {
|
|||
placeholderText: qsTr("group-addr")
|
||||
|
||||
}
|
||||
|
||||
Opaque.UnderlineTextField {
|
||||
visible: gcd.experimentsEnabled && Utils.checkMap(gcd.experiments, "tapir-groups-experiment")
|
||||
id: groupNameJoin
|
||||
|
||||
backgroundColor: Theme.backgroundPaneColor
|
||||
width: parent.width - (40*gcd.themeScale)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
//: Name
|
||||
placeholderText: qsTr("group-name")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,7 +206,10 @@ Rectangle {
|
|||
if (tabBar.currentIndex == 0) {
|
||||
gcd.addPeer(peerName.text, peerAddr.text)
|
||||
theStack.currentIndex = theStack.emptyPane
|
||||
} // Else Group stuff
|
||||
} else if (tabBar.currentIndex == 2) {
|
||||
gcd.addGroup(groupAddr.text)
|
||||
theStack.currentIndex = theStack.emptyPane
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue