Code cleanup
This commit is contained in:
parent
445f933a88
commit
a0bb15d08a
@ -36,14 +36,14 @@
|
|||||||
/* wpa_supplicant */
|
/* wpa_supplicant */
|
||||||
/* private */
|
/* private */
|
||||||
/* types */
|
/* types */
|
||||||
typedef enum _WpaCommand { WC_LIST_NETWORKS, WC_STATUS } WpaCommand;
|
typedef enum _WPACommand { WC_LIST_NETWORKS, WC_STATUS } WPACommand;
|
||||||
|
|
||||||
typedef struct _WpaEntry
|
typedef struct _WPAEntry
|
||||||
{
|
{
|
||||||
WpaCommand command;
|
WPACommand command;
|
||||||
char * buf;
|
char * buf;
|
||||||
size_t buf_cnt;
|
size_t buf_cnt;
|
||||||
} WpaEntry;
|
} WPAEntry;
|
||||||
|
|
||||||
typedef struct _PanelApplet
|
typedef struct _PanelApplet
|
||||||
{
|
{
|
||||||
@ -56,24 +56,24 @@ typedef struct _PanelApplet
|
|||||||
guint rd_source;
|
guint rd_source;
|
||||||
guint wr_source;
|
guint wr_source;
|
||||||
|
|
||||||
WpaEntry * queue;
|
WPAEntry * queue;
|
||||||
size_t queue_cnt;
|
size_t queue_cnt;
|
||||||
|
|
||||||
/* widgets */
|
/* widgets */
|
||||||
GtkWidget * image;
|
GtkWidget * image;
|
||||||
GtkWidget * label;
|
GtkWidget * label;
|
||||||
} Wpa;
|
} WPA;
|
||||||
|
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static Wpa * _wpa_init(PanelAppletHelper * helper, GtkWidget ** widget);
|
static WPA * _wpa_init(PanelAppletHelper * helper, GtkWidget ** widget);
|
||||||
static void _wpa_destroy(Wpa * wpa);
|
static void _wpa_destroy(WPA * wpa);
|
||||||
|
|
||||||
static int _wpa_error(Wpa * wpa, char const * message, int ret);
|
static int _wpa_error(WPA * wpa, char const * message, int ret);
|
||||||
static int _wpa_queue(Wpa * wpa, WpaCommand command, ...);
|
static int _wpa_queue(WPA * wpa, WPACommand command, ...);
|
||||||
static int _wpa_reset(Wpa * wpa);
|
static int _wpa_reset(WPA * wpa);
|
||||||
static int _wpa_start(Wpa * wpa);
|
static int _wpa_start(WPA * wpa);
|
||||||
static void _wpa_stop(Wpa * wpa);
|
static void _wpa_stop(WPA * wpa);
|
||||||
|
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
static gboolean _on_timeout(gpointer data);
|
static gboolean _on_timeout(gpointer data);
|
||||||
@ -103,9 +103,9 @@ PanelAppletDefinition applet =
|
|||||||
/* wpa_init */
|
/* wpa_init */
|
||||||
static gboolean _init_timeout(gpointer data);
|
static gboolean _init_timeout(gpointer data);
|
||||||
|
|
||||||
static Wpa * _wpa_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
static WPA * _wpa_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
||||||
{
|
{
|
||||||
Wpa * wpa;
|
WPA * wpa;
|
||||||
PangoFontDescription * bold;
|
PangoFontDescription * bold;
|
||||||
GtkWidget * hbox;
|
GtkWidget * hbox;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ static Wpa * _wpa_init(PanelAppletHelper * helper, GtkWidget ** widget)
|
|||||||
static gboolean _init_timeout(gpointer data)
|
static gboolean _init_timeout(gpointer data)
|
||||||
{
|
{
|
||||||
int ret = TRUE;
|
int ret = TRUE;
|
||||||
Wpa * wpa = data;
|
WPA * wpa = data;
|
||||||
char const path[] = "/var/run/wpa_supplicant";
|
char const path[] = "/var/run/wpa_supplicant";
|
||||||
DIR * dir;
|
DIR * dir;
|
||||||
struct dirent * de;
|
struct dirent * de;
|
||||||
@ -221,7 +221,7 @@ static gboolean _init_timeout(gpointer data)
|
|||||||
|
|
||||||
|
|
||||||
/* wpa_destroy */
|
/* wpa_destroy */
|
||||||
static void _wpa_destroy(Wpa * wpa)
|
static void _wpa_destroy(WPA * wpa)
|
||||||
{
|
{
|
||||||
_wpa_stop(wpa);
|
_wpa_stop(wpa);
|
||||||
object_delete(wpa);
|
object_delete(wpa);
|
||||||
@ -229,7 +229,7 @@ static void _wpa_destroy(Wpa * wpa)
|
|||||||
|
|
||||||
|
|
||||||
/* wpa_error */
|
/* wpa_error */
|
||||||
static int _wpa_error(Wpa * wpa, char const * message, int ret)
|
static int _wpa_error(WPA * wpa, char const * message, int ret)
|
||||||
{
|
{
|
||||||
gtk_image_set_from_icon_name(GTK_IMAGE(wpa->image), "error",
|
gtk_image_set_from_icon_name(GTK_IMAGE(wpa->image), "error",
|
||||||
wpa->helper->icon_size);
|
wpa->helper->icon_size);
|
||||||
@ -239,10 +239,10 @@ static int _wpa_error(Wpa * wpa, char const * message, int ret)
|
|||||||
|
|
||||||
|
|
||||||
/* wpa_queue */
|
/* wpa_queue */
|
||||||
static int _wpa_queue(Wpa * wpa, WpaCommand command, ...)
|
static int _wpa_queue(WPA * wpa, WPACommand command, ...)
|
||||||
{
|
{
|
||||||
char const * cmd = NULL;
|
char const * cmd = NULL;
|
||||||
WpaEntry * p;
|
WPAEntry * p;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(%u, ...)\n", __func__, command);
|
fprintf(stderr, "DEBUG: %s(%u, ...)\n", __func__, command);
|
||||||
@ -277,7 +277,7 @@ static int _wpa_queue(Wpa * wpa, WpaCommand command, ...)
|
|||||||
|
|
||||||
|
|
||||||
/* wpa_reset */
|
/* wpa_reset */
|
||||||
static int _wpa_reset(Wpa * wpa)
|
static int _wpa_reset(WPA * wpa)
|
||||||
{
|
{
|
||||||
_wpa_stop(wpa);
|
_wpa_stop(wpa);
|
||||||
return _wpa_start(wpa);
|
return _wpa_start(wpa);
|
||||||
@ -285,7 +285,7 @@ static int _wpa_reset(Wpa * wpa)
|
|||||||
|
|
||||||
|
|
||||||
/* wpa_start */
|
/* wpa_start */
|
||||||
static int _wpa_start(Wpa * wpa)
|
static int _wpa_start(WPA * wpa)
|
||||||
{
|
{
|
||||||
/* reconnect to the daemon */
|
/* reconnect to the daemon */
|
||||||
if(_init_timeout(wpa) == FALSE)
|
if(_init_timeout(wpa) == FALSE)
|
||||||
@ -296,7 +296,7 @@ static int _wpa_start(Wpa * wpa)
|
|||||||
|
|
||||||
|
|
||||||
/* wpa_stop */
|
/* wpa_stop */
|
||||||
static void _wpa_stop(Wpa * wpa)
|
static void _wpa_stop(WPA * wpa)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ static void _wpa_stop(Wpa * wpa)
|
|||||||
/* on_timeout */
|
/* on_timeout */
|
||||||
static gboolean _on_timeout(gpointer data)
|
static gboolean _on_timeout(gpointer data)
|
||||||
{
|
{
|
||||||
Wpa * wpa = data;
|
WPA * wpa = data;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
@ -347,15 +347,15 @@ static gboolean _on_timeout(gpointer data)
|
|||||||
|
|
||||||
|
|
||||||
/* on_watch_can_read */
|
/* on_watch_can_read */
|
||||||
static gboolean _read_status(Wpa * wpa, char const * buf, size_t cnt);
|
static gboolean _read_status(WPA * wpa, char const * buf, size_t cnt);
|
||||||
static gboolean _read_list_networks(Wpa * wpa, char const * buf, size_t cnt);
|
static gboolean _read_list_networks(WPA * wpa, char const * buf, size_t cnt);
|
||||||
|
|
||||||
static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
int ret = FALSE;
|
int ret = FALSE;
|
||||||
Wpa * wpa = data;
|
WPA * wpa = data;
|
||||||
WpaEntry * entry = &wpa->queue[0];
|
WPAEntry * entry = &wpa->queue[0];
|
||||||
char buf[256]; /* XXX in wpa */
|
char buf[256]; /* XXX in wpa */
|
||||||
gsize cnt;
|
gsize cnt;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
@ -399,7 +399,7 @@ static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean _read_list_networks(Wpa * wpa, char const * buf, size_t cnt)
|
static gboolean _read_list_networks(WPA * wpa, char const * buf, size_t cnt)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t j;
|
size_t j;
|
||||||
@ -440,7 +440,7 @@ static gboolean _read_list_networks(Wpa * wpa, char const * buf, size_t cnt)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean _read_status(Wpa * wpa, char const * buf, size_t cnt)
|
static gboolean _read_status(WPA * wpa, char const * buf, size_t cnt)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t j;
|
size_t j;
|
||||||
@ -483,8 +483,8 @@ static gboolean _read_status(Wpa * wpa, char const * buf, size_t cnt)
|
|||||||
static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
Wpa * wpa = data;
|
WPA * wpa = data;
|
||||||
WpaEntry * entry = &wpa->queue[0];
|
WPAEntry * entry = &wpa->queue[0];
|
||||||
gsize cnt = 0;
|
gsize cnt = 0;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
GIOStatus status;
|
GIOStatus status;
|
||||||
|
Loading…
Reference in New Issue
Block a user