error mgt in qr write

This commit is contained in:
ycc 2022-12-01 22:47:17 +01:00
parent 3066d48b3e
commit 7ed8ff9982
3 changed files with 4 additions and 5 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ test
id.enc id.enc
invitation.png invitation.png
client/test.cfg client/test.cfg
.VSCodeCouter/

View File

@ -84,7 +84,6 @@ func (id *Identity) AnswerInvitation(MyName string, ContactName string, MessageS
peer.Name = ReceivedContact.Name peer.Name = ReceivedContact.Name
} }
peer.Contact = *ReceivedContact peer.Contact = *ReceivedContact
for _, i := range MessageServerIdxs { for _, i := range MessageServerIdxs {
srv := id.MessageServers.Servers[i].ServerData srv := id.MessageServers.Servers[i].ServerData
myContactCard.PullServers = append(myContactCard.PullServers, &srv) myContactCard.PullServers = append(myContactCard.PullServers, &srv)

View File

@ -53,7 +53,6 @@ func (contact *ContactCard) Compress() ([]byte, error) {
if err := gz.Close(); err != nil { if err := gz.Close(); err != nil {
return nil, err return nil, err
} }
fmt.Println(b.Bytes())
return b.Bytes(), nil return b.Bytes(), nil
} }
@ -143,13 +142,13 @@ func (contact *ContactCard) WritePng(filename string) {
} }
func (Contact *ContactCard) WriteQr(filename string) { func (Contact *ContactCard) WriteQr(filename string) error {
//jsonContact, _ := json.Marshal(Contact) //jsonContact, _ := json.Marshal(Contact)
jsonContact, _ := Contact.Compress() jsonContact, _ := Contact.Compress()
qwriter := qrcode.NewQRCodeWriter() qwriter := qrcode.NewQRCodeWriter()
code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil) code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil)
if err != nil { if err != nil {
println(err.Error()) return err
} }
file, _ := os.Create(filename) file, _ := os.Create(filename)
defer file.Close() defer file.Close()
@ -157,7 +156,7 @@ func (Contact *ContactCard) WriteQr(filename string) {
// *BitMatrix implements the image.Image interface, // *BitMatrix implements the image.Image interface,
// so it is able to be passed to png.Encode directly. // so it is able to be passed to png.Encode directly.
_ = png.Encode(file, code) _ = png.Encode(file, code)
return nil
} }
func ReadQr(Filename string) ContactCard { func ReadQr(Filename string) ContactCard {