error mgt in qr write
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -11,3 +11,4 @@ test
 | 
			
		||||
id.enc
 | 
			
		||||
invitation.png
 | 
			
		||||
client/test.cfg
 | 
			
		||||
.VSCodeCouter/
 | 
			
		||||
 
 | 
			
		||||
@@ -84,7 +84,6 @@ func (id *Identity) AnswerInvitation(MyName string, ContactName string, MessageS
 | 
			
		||||
		peer.Name = ReceivedContact.Name
 | 
			
		||||
	}
 | 
			
		||||
	peer.Contact = *ReceivedContact
 | 
			
		||||
 | 
			
		||||
	for _, i := range MessageServerIdxs {
 | 
			
		||||
		srv := id.MessageServers.Servers[i].ServerData
 | 
			
		||||
		myContactCard.PullServers = append(myContactCard.PullServers, &srv)
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,6 @@ func (contact *ContactCard) Compress() ([]byte, error) {
 | 
			
		||||
	if err := gz.Close(); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	fmt.Println(b.Bytes())
 | 
			
		||||
	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, _ := Contact.Compress()
 | 
			
		||||
	qwriter := qrcode.NewQRCodeWriter()
 | 
			
		||||
	code, err := qwriter.Encode(string(jsonContact), gozxing.BarcodeFormat_QR_CODE, 512, 512, nil)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		println(err.Error())
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	file, _ := os.Create(filename)
 | 
			
		||||
	defer file.Close()
 | 
			
		||||
@@ -157,7 +156,7 @@ func (Contact *ContactCard) WriteQr(filename string) {
 | 
			
		||||
	// *BitMatrix implements the image.Image interface,
 | 
			
		||||
	// so it is able to be passed to png.Encode directly.
 | 
			
		||||
	_ = png.Encode(file, code)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ReadQr(Filename string) ContactCard {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user