Use qr_to_png to generate qr

This commit is contained in:
Lakindu Akash 2021-10-18 03:56:38 +05:30
parent 359a6adf80
commit f12203befa
No known key found for this signature in database
GPG Key ID: 6FB0085A614E0AC2
2 changed files with 17 additions and 13 deletions

View File

@ -35,6 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "h_prop.h"
#include "read_config.h"
#include "qrgen.h"
#define BUFSIZE 2048
@ -431,28 +432,32 @@ char* generate_qr_image(char* ssid,char* type,char *password){
qr_image_path = "/tmp/wihotspot_qr.png";
snprintf(cmd, BUFSIZE, "%s -V -s 10 -d 256 -o %s 'WIFI:S:%s;T:%s;P:%s;;' ","qrencode",qr_image_path, ssid,type,password);
// snprintf(cmd, BUFSIZE, "%s -s 10 -d 256 -o %s 'WIFI:S:%s;T:%s;P:%s;;' ","qrencode",qr_image_path, ssid,type,password);
FILE *fp;
// FILE *fp;
char temp_buff[1048];
// char temp_buff[1048];
if ((fp = popen(cmd, "r")) == NULL) {
printf("Error opening pipe!\n");
// if ((fp = popen(cmd, "r")) == NULL) {
// printf("Error opening pipe!\n");
}
// }
while (fgets(temp_buff, sizeof(temp_buff), fp) != NULL) {
// while (fgets(temp_buff, sizeof(temp_buff), fp) != NULL) {
printf("%s", temp_buff);
}
// printf("%s", temp_buff);
// }
if (pclose(fp)) {
printf("Error executing qrencode\n");
// if (pclose(fp)) {
// printf("Error executing qrencode\n");
}
// }
snprintf(cmd, BUFSIZE, "WIFI:S:%s;T:%s;P:%s;;",ssid,type,password);
qr_to_png(cmd,qr_image_path);
return qr_image_path;
}

View File

@ -166,7 +166,6 @@ static void on_about_open_click(GtkWidget *widget, gpointer data){
static void on_qr_open_click(GtkWidget *widget, gpointer data){
char* image_path = generate_qr_image(configValues.ssid,"WPA",configValues.pass);
open_qr(widget,data,image_path);
}