mirror of
https://github.com/lakinduakash/linux-wifi-hotspot.git
synced 2024-11-10 06:00:11 +00:00
commit
34af49b462
9
Makefile
9
Makefile
@ -1,13 +1,14 @@
|
||||
PREFIX=/usr
|
||||
MANDIR=$(PREFIX)/share/man
|
||||
BINDIR=$(PREFIX)/bin
|
||||
|
||||
all:
|
||||
@echo "Run 'make install' for installation."
|
||||
@echo "Run 'make uninstall' for uninstallation."
|
||||
mkdir -p build
|
||||
cd build && cmake -G "CodeBlocks - Unix Makefiles" ../src
|
||||
$(MAKE) -C build
|
||||
|
||||
install:
|
||||
$(MAKE) -C src/scripts install
|
||||
$(MAKE) -C build install_build
|
||||
|
||||
uninstall:
|
||||
$(MAKE) -C src/scripts uninstall
|
||||
$(MAKE) -C build uninstall_build
|
||||
|
49
README.md
49
README.md
@ -1,12 +1,53 @@
|
||||
## Linux Wifi Hotspot
|
||||
|
||||
### Features
|
||||
|
||||
* Share your wifi like in Windows - Share wifi on same interface which you are connected to internet.
|
||||
* Share access point from any network interface
|
||||
* Includes Both command line and gui.
|
||||
* Support both 2.4GHz and 5GHz (Need to compatible with your wifi adapter). Ex: You have connected to 5GHz and share connection with 2.4GHz.
|
||||
* Select Channel to share.
|
||||
|
||||
* Share your wifi like in Windows - Share wifi on same interface while you are connected to a network
|
||||
### Dependencies
|
||||
|
||||
* Support both 2.4GHz and 5GHz (Need to compatible with your wifi adapter). Ex: You have connected to 5GHz and share connection with 2.4GHz
|
||||
#### General
|
||||
* bash
|
||||
* util-linux (for getopt)
|
||||
* procps or procps-ng
|
||||
* hostapd
|
||||
* iproute2
|
||||
* iw
|
||||
* iwconfig (you only need this if 'iw' can not recognize your adapter)
|
||||
* haveged (optional)
|
||||
|
||||
* Select Channel to share
|
||||
_Make sure you have those dependencies by typing them in terminal. If any of dependencies fail
|
||||
install it using your distro's package manager_
|
||||
|
||||
#### For 'NATed' or 'None' Internet sharing method
|
||||
* dnsmasq
|
||||
* iptables
|
||||
|
||||
#### For building from source
|
||||
|
||||
* cmake (https://cmake.org)
|
||||
* make
|
||||
* gcc and g++
|
||||
* build-essential
|
||||
* pkg-config
|
||||
* gtk
|
||||
|
||||
|
||||
### Installing
|
||||
|
||||
## Installation
|
||||
git clone https://github.com/lakinduakash/linux-wifi-hotspot
|
||||
cd linux-wifi-hotspot
|
||||
make
|
||||
sudo make install
|
||||
|
||||
|
||||
## Uninstallation
|
||||
sudo make uninstall
|
||||
|
||||
Tested with Ubuntu 18.10. If any issue found file a issue on github.
|
||||
|
||||
**credits** - oblique
|
@ -12,15 +12,35 @@ set (CMAKE_CXX_STANDARD 11)
|
||||
|
||||
add_executable(wihotspot ui/main.c ui/h_prop.c ui/h_prop.h ui/ui.c ui/ui.h ui/read_config.cpp ui/read_config.h ui/util.c ui/util.h)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${GTK_LIBRARIES} ${X11_LIBRARIES} config)
|
||||
target_link_libraries(${PROJECT_NAME} ${GTK_LIBRARIES} ${X11_LIBRARIES})
|
||||
|
||||
include_directories(/usr/include)
|
||||
|
||||
set (source "${CMAKE_SOURCE_DIR}/ui/glade")
|
||||
set (destination "${CMAKE_CURRENT_BINARY_DIR}/glade")
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${source} ${destination}
|
||||
DEPENDS ${destination}
|
||||
COMMENT "symbolic link resources folder from ${source} => ${destination}"
|
||||
)
|
||||
|
||||
set (appdir "/usr/share")
|
||||
set (appbin "/usr/bin")
|
||||
|
||||
add_custom_target(install_build
|
||||
COMMAND mkdir -p ${appdir}/${PROJECT_NAME}
|
||||
COMMAND mkdir -p ${appdir}/${PROJECT_NAME}/glade
|
||||
COMMAND install -Dm755 ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} ${appdir}/${PROJECT_NAME}/${PROJECT_NAME}
|
||||
COMMAND install -Dm755 ${CMAKE_CURRENT_BINARY_DIR}/glade/* ${appdir}/${PROJECT_NAME}/glade/
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${appdir}/${PROJECT_NAME}/${PROJECT_NAME} ${appbin}/${PROJECT_NAME}
|
||||
DEPENDS ${PROJECT_NAME}
|
||||
COMMENT Installing files...
|
||||
)
|
||||
|
||||
add_custom_target(uninstall_build
|
||||
COMMAND rm -r ${appdir}/${PROJECT_NAME}
|
||||
COMMAND rm -f ${appbin}/${PROJECT_NAME}
|
||||
COMMENT Unstalling files...
|
||||
)
|
@ -12,7 +12,10 @@
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
@ -149,7 +152,215 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkExpander">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">25</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="row_spacing">5</property>
|
||||
<property name="row_homogeneous">True</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_hidden">
|
||||
<property name="label" translatable="yes">Hidden</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_psk">
|
||||
<property name="label" translatable="yes">Use psk</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_mac">
|
||||
<property name="label" translatable="yes">Set MAC</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_mac">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="halign">start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_novirt">
|
||||
<property name="label" translatable="yes">No Virt</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Do not create virtual interface</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_channel">
|
||||
<property name="label" translatable="yes">Channel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_channel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="halign">start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="rb_freq_2">
|
||||
<property name="label" translatable="yes">2.4Ghz</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">rb_freq_auto</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="rb_freq_auto">
|
||||
<property name="label" translatable="yes">Auto</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">rb_freq_5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Frequency band</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="rb_freq_5">
|
||||
<property name="label" translatable="yes">5Ghz</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">rb_freq_auto</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">3</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Advance</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
|
136
src/ui/h_prop.c
136
src/ui/h_prop.c
@ -4,13 +4,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libconfig.h>
|
||||
//#include <libconfig.h>
|
||||
|
||||
#include "h_prop.h"
|
||||
#include "read_config.h"
|
||||
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define BUFSIZE 512
|
||||
|
||||
|
||||
#define SUDO "pkexec --user root"
|
||||
@ -28,11 +28,12 @@ char cmd_kill[BUFSIZE];
|
||||
|
||||
char running_info[BUFSIZE];
|
||||
char interface_list[BUFSIZE];
|
||||
char wifi_interface_list[BUFSIZE];
|
||||
|
||||
const char* g_ssid=NULL;
|
||||
const char* g_pass=NULL;
|
||||
|
||||
config_t cfg;
|
||||
//config_t cfg;
|
||||
|
||||
static int parse_output(const char *cmd) {
|
||||
|
||||
@ -93,38 +94,38 @@ const char* build_kill_create_ap_command(char* pid){
|
||||
return cmd_kill;
|
||||
}
|
||||
|
||||
int write_config(char* file){
|
||||
|
||||
config_t cfg;
|
||||
config_setting_t *root, *setting, *group, *array;
|
||||
int i;
|
||||
|
||||
config_init(&cfg);
|
||||
root = config_root_setting(&cfg);
|
||||
|
||||
/* Add some settings to the configuration. */
|
||||
|
||||
|
||||
setting = config_setting_add(root, SSID, CONFIG_TYPE_STRING);
|
||||
config_setting_set_string(setting, "myssid");
|
||||
|
||||
setting = config_setting_add(root, PASSPHRASE, CONFIG_TYPE_STRING);
|
||||
config_setting_set_string(setting, "123456789");
|
||||
|
||||
/* Write out the new configuration. */
|
||||
if(! config_write_file(&cfg, get_config_file(CONFIG_FILE_NAME)))
|
||||
{
|
||||
fprintf(stderr, "Error while writing file.\n");
|
||||
config_destroy(&cfg);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(stderr, "New configuration successfully written to: %s\n",
|
||||
get_config_file(CONFIG_FILE_NAME));
|
||||
|
||||
config_destroy(&cfg);
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
//int write_config(char* file){
|
||||
//
|
||||
// config_t cfg;
|
||||
// config_setting_t *root, *setting, *group, *array;
|
||||
// int i;
|
||||
//
|
||||
// config_init(&cfg);
|
||||
// root = config_root_setting(&cfg);
|
||||
//
|
||||
// /* Add some settings to the configuration. */
|
||||
//
|
||||
//
|
||||
// setting = config_setting_add(root, SSID, CONFIG_TYPE_STRING);
|
||||
// config_setting_set_string(setting, "myssid");
|
||||
//
|
||||
// setting = config_setting_add(root, PASSPHRASE, CONFIG_TYPE_STRING);
|
||||
// config_setting_set_string(setting, "123456789");
|
||||
//
|
||||
// /* Write out the new configuration. */
|
||||
// if(! config_write_file(&cfg, get_config_file(CONFIG_FILE_NAME)))
|
||||
// {
|
||||
// fprintf(stderr, "Error while writing file.\n");
|
||||
// config_destroy(&cfg);
|
||||
// return(EXIT_FAILURE);
|
||||
// }
|
||||
//
|
||||
// fprintf(stderr, "New configuration successfully written to: %s\n",
|
||||
// get_config_file(CONFIG_FILE_NAME));
|
||||
//
|
||||
// config_destroy(&cfg);
|
||||
// return(EXIT_SUCCESS);
|
||||
//}
|
||||
|
||||
|
||||
static int init_get_running(){
|
||||
@ -247,3 +248,68 @@ char** get_interface_list(int *length){
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int init_get_wifi_interface_list(){
|
||||
const char* cmd="iw dev | awk '$1==\"Interface\"{print $2}' ";
|
||||
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = popen(cmd, "r")) == NULL) {
|
||||
printf("Error opening pipe!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fgets(wifi_interface_list, BUFSIZE, fp) != NULL) {
|
||||
// Do whatever you want here...
|
||||
}
|
||||
|
||||
if (pclose(fp)) {
|
||||
printf("Command not found or exited with error status\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char** get_wifi_interface_list(int *length){
|
||||
|
||||
if(init_get_wifi_interface_list()==0){
|
||||
|
||||
char *a=strdup(wifi_interface_list);
|
||||
char *b=strdup(wifi_interface_list);
|
||||
|
||||
char * pch;
|
||||
pch = strtok (a,"\n");
|
||||
int i=0;
|
||||
while (pch != NULL)
|
||||
{
|
||||
pch = strtok (NULL, "\n");
|
||||
i++;
|
||||
}
|
||||
|
||||
static char** arr;
|
||||
arr =malloc(i * sizeof(char*));
|
||||
|
||||
free(a);
|
||||
|
||||
pch = strtok (b,"\n");
|
||||
i=0;
|
||||
while (pch != NULL)
|
||||
{
|
||||
|
||||
arr[i]=strdup(pch);
|
||||
pch = strtok (NULL, "\n");
|
||||
i++;
|
||||
}
|
||||
|
||||
*length= i;
|
||||
|
||||
return arr;
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
@ -23,4 +23,6 @@ static int init_get_interface_list();
|
||||
char** get_interface_list(int*);
|
||||
const char* build_kill_create_ap_command(char* pid);
|
||||
|
||||
char** get_wifi_interface_list(int *length);
|
||||
|
||||
#endif //WIHOTSPOT_H_PROP_H
|
||||
|
68
src/ui/ui.c
68
src/ui/ui.c
@ -13,19 +13,31 @@
|
||||
#include "read_config.h"
|
||||
#include "util.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define BUFSIZE 512
|
||||
#define AP_ENABLED "AP-ENABLED"
|
||||
|
||||
GtkBuilder *builder;
|
||||
GObject *window;
|
||||
GtkButton *button_create_hp;
|
||||
GtkButton *button_stop_hp;
|
||||
|
||||
GtkEntry *entry_ssd;
|
||||
GtkEntry *entry_pass;
|
||||
GtkEntry *entry_mac;
|
||||
GtkEntry *entry_channel;
|
||||
|
||||
GtkComboBox *combo_wifi;
|
||||
GtkComboBox *combo_internet;
|
||||
|
||||
GtkRadioButton *rb_freq_auto;
|
||||
GtkRadioButton *rb_freq_2;
|
||||
GtkRadioButton *rb_freq_5;
|
||||
|
||||
GtkCheckButton *cb_hidden;
|
||||
GtkCheckButton *cb_psk;
|
||||
GtkCheckButton *cb_mac;
|
||||
GtkCheckButton *cb_novirt;
|
||||
|
||||
GtkProgressBar *progress_bar;
|
||||
|
||||
GtkLabel *label_status;
|
||||
@ -34,16 +46,17 @@ GError *error = NULL;
|
||||
|
||||
|
||||
const char** iface_list;
|
||||
const char** wifi_iface_list;
|
||||
int iface_list_length;
|
||||
int wifi_iface_list_length;
|
||||
char* running_info[3];
|
||||
guint id;
|
||||
|
||||
|
||||
|
||||
void *stopHp();
|
||||
|
||||
void *stopHp() {
|
||||
static void *stopHp() {
|
||||
if(running_info[0]!=NULL){
|
||||
gtk_label_set_label(label_status,"Stopping ...");
|
||||
start_pb_pulse();
|
||||
lock_all_views(TRUE);
|
||||
startShell(build_kill_create_ap_command(running_info[0]));
|
||||
@ -93,13 +106,32 @@ int initUi(int argc, char *argv[]){
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
/* Construct a GtkBuilder instance and load our UI description */
|
||||
const char* debug_glade_file="glade/wifih.ui";
|
||||
const char* prod_glade_file="/usr/share/wihotspot/glade/wifih.ui";
|
||||
|
||||
FILE *file;
|
||||
builder = gtk_builder_new();
|
||||
if (gtk_builder_add_from_file(builder, "glade/wifih.ui", &error) == 0) {
|
||||
g_printerr("Error loading file: %s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
|
||||
if ((file = fopen(debug_glade_file, "r"))){
|
||||
fclose(file);
|
||||
if (gtk_builder_add_from_file(builder, debug_glade_file, &error) == 0) {
|
||||
g_printerr("Error loading file: %s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((file = fopen(prod_glade_file, "r"))){
|
||||
fclose(file);
|
||||
if (gtk_builder_add_from_file(builder, prod_glade_file, &error) == 0) {
|
||||
g_printerr("Error loading file: %s\n", error->message);
|
||||
g_clear_error(&error);
|
||||
return 1;
|
||||
}
|
||||
} else{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Connect signal handlers to the constructed widgets. */
|
||||
window = gtk_builder_get_object(builder, "window");
|
||||
g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
||||
@ -111,17 +143,23 @@ int initUi(int argc, char *argv[]){
|
||||
entry_ssd = (GtkEntry *) gtk_builder_get_object(builder, "entry_ssid");
|
||||
entry_pass = (GtkEntry *) gtk_builder_get_object(builder, "entry_pass");
|
||||
|
||||
entry_mac = (GtkEntry *) gtk_builder_get_object(builder, "entry_mac");
|
||||
entry_channel = (GtkEntry *) gtk_builder_get_object(builder, "entry_channel");
|
||||
|
||||
combo_wifi = (GtkComboBox *) gtk_builder_get_object(builder, "combo_wifi");
|
||||
combo_internet = (GtkComboBox *) gtk_builder_get_object(builder, "combo_internet");
|
||||
|
||||
cb_hidden = (GtkCheckButton *) gtk_builder_get_object(builder, "cb_hidden");
|
||||
cb_psk = (GtkCheckButton *) gtk_builder_get_object(builder, "cb_psk");
|
||||
cb_mac = (GtkCheckButton *) gtk_builder_get_object(builder, "cb_mac");
|
||||
cb_novirt = (GtkCheckButton *) gtk_builder_get_object(builder, "cb_novirt");
|
||||
|
||||
label_status = (GtkLabel *) gtk_builder_get_object(builder, "label_status");
|
||||
|
||||
progress_bar = (GtkProgressBar *) gtk_builder_get_object(builder, "progress_bar");
|
||||
|
||||
|
||||
|
||||
|
||||
//gtk_entry_set_visibility(entry_pass,FALSE);
|
||||
|
||||
WIData wiData = {
|
||||
.pass= entry_pass,
|
||||
@ -159,7 +197,7 @@ void init_ui_from_config(WIData* data){
|
||||
gtk_entry_set_text(data->pass,values->pass);
|
||||
|
||||
if(values->iface_wifi!=NULL){
|
||||
int idw=find_str(values->iface_wifi,iface_list,iface_list_length);
|
||||
int idw=find_str(values->iface_wifi,wifi_iface_list,wifi_iface_list_length);
|
||||
|
||||
if(idw !=-1){
|
||||
gtk_combo_box_set_active(combo_wifi,idw);
|
||||
@ -180,13 +218,19 @@ void init_ui_from_config(WIData* data){
|
||||
void init_interface_list(){
|
||||
|
||||
iface_list_length=0;
|
||||
wifi_iface_list_length=0;
|
||||
iface_list=(const char**)get_interface_list(&iface_list_length);
|
||||
wifi_iface_list=(const char**)get_wifi_interface_list(&wifi_iface_list_length);
|
||||
|
||||
for (int i = 0; i < iface_list_length; i++){
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_wifi), iface_list[i]);
|
||||
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_internet), iface_list[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < wifi_iface_list_length; i++){
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_wifi), wifi_iface_list[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -260,6 +304,8 @@ void* init_running_info(){
|
||||
clear_running_info();
|
||||
lock_all_views(TRUE);
|
||||
|
||||
gtk_label_set_label(label_status,"Getting running info...");
|
||||
|
||||
get_running_info(running_info);
|
||||
|
||||
if(running_info[0]!=NULL){
|
||||
|
@ -32,4 +32,6 @@ static guint start_pb_pulse();
|
||||
|
||||
static void on_create_hp_clicked(GtkWidget *widget,gpointer data);
|
||||
|
||||
static void *stopHp();
|
||||
|
||||
#endif //WIHOTSPOT_UI_H
|
||||
|
@ -3,6 +3,8 @@
|
||||
//
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "util.h"
|
||||
|
||||
int find_str(char *find, const char **array, int length) {
|
||||
@ -18,3 +20,16 @@ int find_str(char *find, const char **array, int length) {
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void rand_str(char *dest, size_t length) {
|
||||
char charset[] = "0123456789"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
while (length-- > 0) {
|
||||
size_t index = (size_t) ((double) rand() / RAND_MAX * (sizeof charset - 1));
|
||||
*dest++ = charset[index];
|
||||
}
|
||||
*dest = '\0';
|
||||
}
|
||||
|
@ -6,5 +6,6 @@
|
||||
#define WIHOTSPOT_UTIL_H
|
||||
|
||||
int find_str(char *find, const char **array, int length);
|
||||
void rand_str(char *dest, size_t length);
|
||||
|
||||
#endif //WIHOTSPOT_UTIL_H
|
||||
|
Loading…
Reference in New Issue
Block a user