forked from Elara6331/itd
		
	Reorganize and clean code
This commit is contained in:
		
							
								
								
									
										46
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								main.go
									
									
									
									
									
								
							| @@ -37,28 +37,6 @@ var ( | |||||||
| 	updateFS = false | 	updateFS = false | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func onReqPasskey() (uint32, error) { |  | ||||||
| 	var out uint32 |  | ||||||
| 	if isatty.IsTerminal(os.Stdin.Fd()) { |  | ||||||
| 		fmt.Print("Passkey: ") |  | ||||||
| 		_, err := fmt.Scanln(&out) |  | ||||||
| 		if err != nil { |  | ||||||
| 			return 0, err |  | ||||||
| 		} |  | ||||||
| 	} else { |  | ||||||
| 		passkey, ok, err := dlgs.Entry("Pairing", "Enter the passkey displayed on your watch.", "") |  | ||||||
| 		if err != nil { |  | ||||||
| 			return 0, err |  | ||||||
| 		} |  | ||||||
| 		if !ok { |  | ||||||
| 			return 0, nil |  | ||||||
| 		} |  | ||||||
| 		passkeyInt, err := strconv.Atoi(passkey) |  | ||||||
| 		return uint32(passkeyInt), err |  | ||||||
| 	} |  | ||||||
| 	return out, nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| 	infinitime.Init() | 	infinitime.Init() | ||||||
| 	// Cleanly exit after function | 	// Cleanly exit after function | ||||||
| @@ -130,7 +108,7 @@ func main() { | |||||||
| 	// Start control socket | 	// Start control socket | ||||||
| 	err = initCallNotifs(dev) | 	err = initCallNotifs(dev) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		log.Error().Err(err).Msg("Error starting socket") | 		log.Error().Err(err).Msg("Error initializing call notifications") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// Initialize notification relay | 	// Initialize notification relay | ||||||
| @@ -148,3 +126,25 @@ func main() { | |||||||
| 	// Block forever | 	// Block forever | ||||||
| 	select {} | 	select {} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func onReqPasskey() (uint32, error) { | ||||||
|  | 	var out uint32 | ||||||
|  | 	if isatty.IsTerminal(os.Stdin.Fd()) { | ||||||
|  | 		fmt.Print("Passkey: ") | ||||||
|  | 		_, err := fmt.Scanln(&out) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return 0, err | ||||||
|  | 		} | ||||||
|  | 	} else { | ||||||
|  | 		passkey, ok, err := dlgs.Entry("Pairing", "Enter the passkey displayed on your watch.", "") | ||||||
|  | 		if err != nil { | ||||||
|  | 			return 0, err | ||||||
|  | 		} | ||||||
|  | 		if !ok { | ||||||
|  | 			return 0, nil | ||||||
|  | 		} | ||||||
|  | 		passkeyInt, err := strconv.Atoi(passkey) | ||||||
|  | 		return uint32(passkeyInt), err | ||||||
|  | 	} | ||||||
|  | 	return out, nil | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user