forked from cwtch.im/ui
Merge branch 'textfix' of cwtch.im/ui into master
This commit is contained in:
commit
01a473175b
|
@ -15,7 +15,8 @@ func GroupPoller(getContact func(string) *gobjects.Contact, updateContact func(s
|
||||||
groups := the.Peer.GetGroups()
|
groups := the.Peer.GetGroups()
|
||||||
for i := range groups {
|
for i := range groups {
|
||||||
group := the.Peer.GetGroup(groups[i])
|
group := the.Peer.GetGroup(groups[i])
|
||||||
if group != nil {
|
if group != nil && group.GroupID != "" {
|
||||||
|
log.Debugf("Found a Group: %v %v", group.GroupID, group.GroupServer)
|
||||||
getContact(group.GroupID).Status = int(servers[group.GroupServer])
|
getContact(group.GroupID).Status = int(servers[group.GroupServer])
|
||||||
updateContact(group.GroupID)
|
updateContact(group.GroupID)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/base32"
|
"encoding/base32"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,7 +13,8 @@ func RandomProfileImage(onion string) string {
|
||||||
choices := []string{"001-centaur", "002-kraken", "003-dinosaur", "004-tree-1", "005-hand", "006-echidna", "007-robot", "008-mushroom", "009-harpy", "010-phoenix", "011-dragon-1", "012-devil", "013-troll", "014-alien", "015-minotaur", "016-madre-monte", "017-satyr", "018-karakasakozou", "019-pirate", "020-werewolf", "021-scarecrow", "022-valkyrie", "023-curupira", "024-loch-ness-monster", "025-tree", "026-cerberus", "027-gryphon", "028-mermaid", "029-vampire", "030-goblin", "031-yeti", "032-leprechaun", "033-medusa", "034-chimera", "035-elf", "036-hydra", "037-cyclops", "038-pegasus", "039-narwhal", "040-woodcutter", "041-zombie", "042-dragon", "043-frankenstein", "044-witch", "045-fairy", "046-genie", "047-pinocchio", "048-ghost", "049-wizard", "050-unicorn"}
|
choices := []string{"001-centaur", "002-kraken", "003-dinosaur", "004-tree-1", "005-hand", "006-echidna", "007-robot", "008-mushroom", "009-harpy", "010-phoenix", "011-dragon-1", "012-devil", "013-troll", "014-alien", "015-minotaur", "016-madre-monte", "017-satyr", "018-karakasakozou", "019-pirate", "020-werewolf", "021-scarecrow", "022-valkyrie", "023-curupira", "024-loch-ness-monster", "025-tree", "026-cerberus", "027-gryphon", "028-mermaid", "029-vampire", "030-goblin", "031-yeti", "032-leprechaun", "033-medusa", "034-chimera", "035-elf", "036-hydra", "037-cyclops", "038-pegasus", "039-narwhal", "040-woodcutter", "041-zombie", "042-dragon", "043-frankenstein", "044-witch", "045-fairy", "046-genie", "047-pinocchio", "048-ghost", "049-wizard", "050-unicorn"}
|
||||||
barr, err := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
|
barr, err := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
|
||||||
if err != nil || len(barr) != 35 {
|
if err != nil || len(barr) != 35 {
|
||||||
fmt.Printf("error: %v %v %v\n", onion, err, barr)
|
log.Errorf("error: %v %v %v\n", onion, err, barr)
|
||||||
|
panic("lol")
|
||||||
return "qrc:/qml/images/extra/openprivacy.png"
|
return "qrc:/qml/images/extra/openprivacy.png"
|
||||||
}
|
}
|
||||||
return "qrc:/qml/images/profiles/" + choices[int(barr[33])%len(choices)] + ".png"
|
return "qrc:/qml/images/profiles/" + choices[int(barr[33])%len(choices)] + ".png"
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"cwtch.im/ui/go/gobjects"
|
"cwtch.im/ui/go/gobjects"
|
||||||
"cwtch.im/ui/go/the"
|
"cwtch.im/ui/go/the"
|
||||||
"encoding/base32"
|
"encoding/base32"
|
||||||
"fmt"
|
|
||||||
"github.com/therecipe/qt/core"
|
"github.com/therecipe/qt/core"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -165,12 +164,14 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
|
||||||
} // ELSE LOAD CONTACT
|
} // ELSE LOAD CONTACT
|
||||||
|
|
||||||
contact, _ := the.Peer.GetProfile().GetContact(handle)
|
contact, _ := the.Peer.GetProfile().GetContact(handle)
|
||||||
nick,_ := contact.GetAttribute("nick")
|
if contact != nil {
|
||||||
|
nick, _ := contact.GetAttribute("nick")
|
||||||
if nick == "" {
|
if nick == "" {
|
||||||
this.SetToolbarTitle(handle)
|
this.SetToolbarTitle(handle)
|
||||||
} else {
|
} else {
|
||||||
this.SetToolbarTitle(nick)
|
this.SetToolbarTitle(nick)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
messages := this.UIState.GetMessages(handle)
|
messages := this.UIState.GetMessages(handle)
|
||||||
for i := range messages {
|
for i := range messages {
|
||||||
|
@ -298,33 +299,11 @@ func (this *GrandCentralDispatcher) importString(str string) {
|
||||||
|
|
||||||
//eg: torv3JFDWkXExBsZLkjvfkkuAxHsiLGZBk0bvoeJID9ItYnU=EsEBCiBhOWJhZDU1OTQ0NWI3YmM2N2YxYTM5YjkzMTNmNTczNRIgpHeNaG+6jy750eDhwLO39UX4f2xs0irK/M3P6mDSYQIaOTJjM2ttb29ibnlnaGoyenc2cHd2N2Q1N3l6bGQ3NTNhdW8zdWdhdWV6enB2ZmFrM2FoYzRiZHlkCiJAdVSSVgsksceIfHe41OJu9ZFHO8Kwv3G6F5OK3Hw4qZ6hn6SiZjtmJlJezoBH0voZlCahOU7jCOg+dsENndZxAA==
|
//eg: torv3JFDWkXExBsZLkjvfkkuAxHsiLGZBk0bvoeJID9ItYnU=EsEBCiBhOWJhZDU1OTQ0NWI3YmM2N2YxYTM5YjkzMTNmNTczNRIgpHeNaG+6jy750eDhwLO39UX4f2xs0irK/M3P6mDSYQIaOTJjM2ttb29ibnlnaGoyenc2cHd2N2Q1N3l6bGQ3NTNhdW8zdWdhdWV6enB2ZmFrM2FoYzRiZHlkCiJAdVSSVgsksceIfHe41OJu9ZFHO8Kwv3G6F5OK3Hw4qZ6hn6SiZjtmJlJezoBH0voZlCahOU7jCOg+dsENndZxAA==
|
||||||
if str[0:5] == "torv3" { // GROUP INVITE
|
if str[0:5] == "torv3" { // GROUP INVITE
|
||||||
groupID, err := the.Peer.ImportGroup(str)
|
_, err := the.Peer.ImportGroup(str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.InvokePopup("not a valid group invite")
|
this.InvokePopup("not a valid group invite")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
group := the.Peer.GetGroup(groupID)
|
|
||||||
|
|
||||||
log.Debugf("group id: %s", groupID)
|
|
||||||
if group == nil {
|
|
||||||
log.Debugf("group IS nil. bad!")
|
|
||||||
} else {
|
|
||||||
log.Debugf("group is NOT nil. good!")
|
|
||||||
}
|
|
||||||
|
|
||||||
the.Peer.JoinServer(group.GroupServer)
|
|
||||||
this.UIState.AddContact(&gobjects.Contact{
|
|
||||||
groupID,
|
|
||||||
groupID[:12],
|
|
||||||
cwutil.RandomGroupImage(groupID),
|
|
||||||
group.GroupServer,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
true,
|
|
||||||
})
|
|
||||||
fmt.Printf("imported groupid=%s server=%s", groupID, group.GroupServer)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,10 @@ func NewUIState(gcd *GrandCentralDispatcher) (uis InterfaceState) {
|
||||||
|
|
||||||
func (this *InterfaceState) AddContact(c *gobjects.Contact) {
|
func (this *InterfaceState) AddContact(c *gobjects.Contact) {
|
||||||
if len(c.Handle) == 32 { // ADD GROUP
|
if len(c.Handle) == 32 { // ADD GROUP
|
||||||
//TODO: we should handle group creation here too probably? the code for groups vs individuals is weird right now ^ea
|
|
||||||
|
|
||||||
if _, found := this.contacts[c.Handle]; !found {
|
if _, found := this.contacts[c.Handle]; !found {
|
||||||
this.contacts[c.Handle] = c
|
|
||||||
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
||||||
|
this.contacts[c.Handle] = c
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
} else if len(c.Handle) != 56 {
|
} else if len(c.Handle) != 56 {
|
||||||
log.Errorf("sorry, unable to handle AddContact(%v)", c.Handle)
|
log.Errorf("sorry, unable to handle AddContact(%v)", c.Handle)
|
||||||
|
@ -38,33 +35,43 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, found := this.contacts[c.Handle]; !found {
|
||||||
|
this.contacts[c.Handle] = c
|
||||||
|
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
||||||
if the.Peer.GetContact(c.Handle) == nil {
|
if the.Peer.GetContact(c.Handle) == nil {
|
||||||
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(c.Handle))
|
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(c.Handle))
|
||||||
the.Peer.AddContact(c.DisplayName, c.Handle, decodedPub, c.Trusted)
|
the.Peer.AddContact(c.DisplayName, c.Handle, decodedPub, c.Trusted)
|
||||||
go the.Peer.PeerWithOnion(c.Handle)
|
go the.Peer.PeerWithOnion(c.Handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, found := this.contacts[c.Handle]; !found {
|
|
||||||
this.contacts[c.Handle] = c
|
|
||||||
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||||
if _, found := this.contacts[handle]; !found {
|
if _, found := this.contacts[handle]; !found {
|
||||||
c := &gobjects.Contact{
|
if len(handle) == 32 {
|
||||||
|
this.AddContact(&gobjects.Contact{
|
||||||
|
handle,
|
||||||
|
handle,
|
||||||
|
cwutil.RandomGroupImage(handle),
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
})
|
||||||
|
group := the.Peer.GetGroup(handle)
|
||||||
|
go the.Peer.JoinServer(group.GroupServer)
|
||||||
|
} else {
|
||||||
|
this.AddContact(&gobjects.Contact{
|
||||||
handle,
|
handle,
|
||||||
handle,
|
handle,
|
||||||
cwutil.RandomProfileImage(handle),
|
cwutil.RandomProfileImage(handle),
|
||||||
"",
|
"",
|
||||||
1,
|
0,
|
||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
|
})
|
||||||
|
go the.Peer.PeerWithOnion(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.contacts[handle] = c
|
|
||||||
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
|
|
||||||
go the.Peer.PeerWithOnion(c.Handle)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.contacts[handle]
|
return this.contacts[handle]
|
||||||
|
|
Loading…
Reference in New Issue