Improved error handling
This commit is contained in:
parent
0cd68bdafe
commit
28c0765495
@ -157,6 +157,9 @@ static gboolean _init_timeout(gpointer data)
|
|||||||
#endif
|
#endif
|
||||||
if((dir = opendir(path)) == NULL)
|
if((dir = opendir(path)) == NULL)
|
||||||
{
|
{
|
||||||
|
gtk_image_set_from_stock(GTK_IMAGE(wpa->image),
|
||||||
|
GTK_STOCK_DISCONNECT,
|
||||||
|
applet->helper->icon_size);
|
||||||
gtk_label_set_text(GTK_LABEL(wpa->label), "Not running");
|
gtk_label_set_text(GTK_LABEL(wpa->label), "Not running");
|
||||||
return applet->helper->error(NULL, path, TRUE);
|
return applet->helper->error(NULL, path, TRUE);
|
||||||
}
|
}
|
||||||
@ -227,6 +230,8 @@ static int _wpa_error(PanelApplet * applet, char const * message, int ret)
|
|||||||
{
|
{
|
||||||
Wpa * wpa = applet->priv;
|
Wpa * wpa = applet->priv;
|
||||||
|
|
||||||
|
gtk_image_set_from_icon_name(GTK_IMAGE(wpa->image), "error",
|
||||||
|
applet->helper->icon_size);
|
||||||
gtk_label_set_text(GTK_LABEL(wpa->label), "Error");
|
gtk_label_set_text(GTK_LABEL(wpa->label), "Error");
|
||||||
return applet->helper->error(NULL, message, ret);
|
return applet->helper->error(NULL, message, ret);
|
||||||
}
|
}
|
||||||
@ -242,6 +247,8 @@ static int _wpa_queue(PanelApplet * applet, WpaCommand command, ...)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(%u, ...)\n", __func__, command);
|
fprintf(stderr, "DEBUG: %s(%u, ...)\n", __func__, command);
|
||||||
#endif
|
#endif
|
||||||
|
if(wpa->channel == NULL)
|
||||||
|
return -1;
|
||||||
switch(command)
|
switch(command)
|
||||||
{
|
{
|
||||||
case WC_LIST_NETWORKS:
|
case WC_LIST_NETWORKS:
|
||||||
@ -333,7 +340,6 @@ static gboolean _read_status(PanelApplet * applet, Wpa * wpa, char const * buf,
|
|||||||
size_t cnt);
|
size_t cnt);
|
||||||
static gboolean _read_list_networks(PanelApplet * applet, Wpa * wpa,
|
static gboolean _read_list_networks(PanelApplet * applet, Wpa * wpa,
|
||||||
char const * buf, size_t cnt);
|
char const * buf, size_t cnt);
|
||||||
static gboolean _read_reset(gpointer data);
|
|
||||||
|
|
||||||
static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -367,12 +373,12 @@ static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
|||||||
ret = _read_status(applet, wpa, buf, cnt);
|
ret = _read_status(applet, wpa, buf, cnt);
|
||||||
break;
|
break;
|
||||||
case G_IO_STATUS_ERROR:
|
case G_IO_STATUS_ERROR:
|
||||||
applet->helper->error(applet->helper->panel,
|
_wpa_error(applet, error->message, 1);
|
||||||
error->message, 1);
|
|
||||||
case G_IO_STATUS_EOF:
|
case G_IO_STATUS_EOF:
|
||||||
default: /* should not happen */
|
default: /* should not happen */
|
||||||
wpa->source = g_idle_add(_read_reset, applet);
|
wpa->source = 0;
|
||||||
break;
|
_wpa_reset(applet, TRUE);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(ret == TRUE)
|
if(ret == TRUE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -380,6 +386,7 @@ static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
|||||||
memmove(entry, &wpa->queue[1], sizeof(*entry) * (--wpa->queue_cnt));
|
memmove(entry, &wpa->queue[1], sizeof(*entry) * (--wpa->queue_cnt));
|
||||||
if(wpa->queue_cnt == 0)
|
if(wpa->queue_cnt == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
/* FIXME maybe wrong */
|
||||||
wpa->wr_source = g_io_add_watch(wpa->channel, G_IO_OUT,
|
wpa->wr_source = g_io_add_watch(wpa->channel, G_IO_OUT,
|
||||||
_on_watch_can_write, applet);
|
_on_watch_can_write, applet);
|
||||||
return ret;
|
return ret;
|
||||||
@ -466,20 +473,8 @@ static gboolean _read_status(PanelApplet * applet, Wpa * wpa, char const * buf,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean _read_reset(gpointer data)
|
|
||||||
{
|
|
||||||
PanelApplet * applet = data;
|
|
||||||
Wpa * wpa = applet->priv;
|
|
||||||
|
|
||||||
wpa->source = 0;
|
|
||||||
_wpa_reset(applet, TRUE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* on_watch_can_write */
|
/* on_watch_can_write */
|
||||||
static gboolean _write_reset(gpointer data);
|
|
||||||
|
|
||||||
static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
@ -511,11 +506,11 @@ static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
|||||||
case G_IO_STATUS_NORMAL:
|
case G_IO_STATUS_NORMAL:
|
||||||
break;
|
break;
|
||||||
case G_IO_STATUS_ERROR:
|
case G_IO_STATUS_ERROR:
|
||||||
applet->helper->error(applet->helper->panel,
|
_wpa_error(applet, error->message, 1);
|
||||||
error->message, 1);
|
|
||||||
case G_IO_STATUS_EOF:
|
case G_IO_STATUS_EOF:
|
||||||
default: /* should not happen */
|
default: /* should not happen */
|
||||||
wpa->source = g_idle_add(_write_reset, applet);
|
wpa->source = 0;
|
||||||
|
_wpa_reset(applet, TRUE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(entry->buf_cnt != 0)
|
if(entry->buf_cnt != 0)
|
||||||
@ -525,13 +520,3 @@ static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
|||||||
wpa->wr_source = 0;
|
wpa->wr_source = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean _write_reset(gpointer data)
|
|
||||||
{
|
|
||||||
PanelApplet * applet = data;
|
|
||||||
Wpa * wpa = applet->priv;
|
|
||||||
|
|
||||||
wpa->source = 0;
|
|
||||||
_wpa_reset(applet, TRUE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user