[Goodies-commits] r2079 - in xfce4-cellmodem-plugin/trunk: . panel-plugin
Alvaro Lopes
alvieboy at xfce.org
Sun Oct 1 14:34:48 CEST 2006
Author: alvieboy
Date: 2006-10-01 12:34:31 +0000 (Sun, 01 Oct 2006)
New Revision: 2079
Modified:
xfce4-cellmodem-plugin/trunk/ChangeLog
xfce4-cellmodem-plugin/trunk/configure.ac
xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c
xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h
xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c
xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c
xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c
xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.h
Log:
Version 0.0.2
Modified: xfce4-cellmodem-plugin/trunk/ChangeLog
===================================================================
--- xfce4-cellmodem-plugin/trunk/ChangeLog 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/ChangeLog 2006-10-01 12:34:31 UTC (rev 2079)
@@ -1,3 +1,10 @@
-No changelog here yet.
+0.0.2
+ Fixed error handling.
+ Disabled the ask for pin. You can click on the plugin to enter
+ the pin, if it is required.
+ Fixed initialization of IO channel in modem_driver_generic.
+
+0.0.1
+ Initial version
Modified: xfce4-cellmodem-plugin/trunk/configure.ac
===================================================================
--- xfce4-cellmodem-plugin/trunk/configure.ac 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/configure.ac 2006-10-01 12:34:31 UTC (rev 2079)
@@ -1,4 +1,4 @@
-m4_define([cellmodem_version], [0.0.1])
+m4_define([cellmodem_version], [0.0.2])
AC_INIT([xfce4-cellmodem-plugin], [cellmodem_version()],[alvieboy at alvie.com])
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c 2006-10-01 12:34:31 UTC (rev 2079)
@@ -38,6 +38,8 @@
static void cellmodem_t_get_pin_status( cellmodem_t *monitor );
static void cellmodem_t_send_pin( cellmodem_t *monitor, const gchar *pin );
static void cellmodem_t_set_tooltip_info( cellmodem_t *monitor );
+static gboolean cellmodem_button_event(GtkEventBox *box, GdkEventButton *button, cellmodem_t *monitor);
+static gboolean cellmodem_t_open_modem(cellmodem_t *monitor);
@@ -73,16 +75,12 @@
switch ( status ) {
case MODEM_ERROR:
cellmodem_t_set_error( monitor );
- reschedule_open( monitor /*, TRUE*/ );
break;
case MODEM_WAIT_CSQ_RESPONSE:
case MODEM_WAIT_CPIN_RESPONSE:
case MODEM_WAIT_COPS_RESPONSE:
case MODEM_CLOSED:
- //if ( cellmodem_t_in_error_status( monitor ) ) {
- cellmodem_t_set_ok( monitor );
- //}
- /* Else skip */
+ cellmodem_t_set_ok( monitor );
break;
case MODEM_WAIT_CREG_RESPONSE:
case MODEM_WAIT_REGISTRATION:
@@ -105,6 +103,10 @@
led_t_set_flashing( monitor->network_led, TRUE );
break;
case REGISTRATION_REGISTERING:
+ led_t_set_color( monitor->network_led, LED_GREEN );
+ led_t_set_flashing( monitor->network_led, TRUE );
+ break;
+ case REGISTRATION_NEEDS_PIN:
led_t_set_color( monitor->network_led, LED_YELLOW );
led_t_set_flashing( monitor->network_led, TRUE );
break;
@@ -114,49 +116,10 @@
}
monitor->registration_status = status;
-}
-
-/*
-static void cellmodem_t_switch_status_i( cellmodem_t *monitor, modem_status_t status )
-{
- monitor->modem_status = status;
-
- if ( monitor->status_led == NULL )
- return;
-
- switch (status) {
-case MODEM_IDLE:
- case MODEM_CLOSED:
- case MODEM_OFFLINE:
- led_t_set_color( monitor->status_led, LED_GREEN );
- led_t_set_flashing( monitor->status_led, FALSE);
-
- switch ( monitor->registration_status )
- {
- case REGISTRATION_REGISTERING:
- case REGISTRATION_NOT_REGISTERED:
- led_t_set_color( monitor->network_led, LED_RED );
- led_t_set_flashing( monitor->network_led, TRUE);
- break;
- default:
- led_t_set_color( monitor->network_led, LED_GREEN );
- led_t_set_flashing( monitor->network_led, FALSE);
- }
-
- break;
- case MODEM_ERROR:
- led_t_set_color( monitor->status_led, LED_RED );
- led_t_set_flashing( monitor->status_led, TRUE);
- led_t_set_color( monitor->network_led, LED_OFF );
- led_t_set_flashing( monitor->network_led, FALSE);
-
-
- break;
- }
cellmodem_t_set_tooltip_info( monitor );
}
-*/
+
/**
* @brief Check if buffer is an error reply from modem
*
@@ -168,7 +131,22 @@
static gboolean
is_AT_error_reply( const gchar *c )
{
- return strcmp(c,"ERROR") == 0;
+ if ( strcmp(c,"ERROR") == 0 )
+ return TRUE;
+
+ /* This is sometimes issued when
+ the card is still initializing */
+
+ if ( strcmp(c,"+CME ERROR") == 0 )
+ return TRUE;
+ if ( strcmp(c,"NO CARRIER") == 0 )
+ return TRUE;
+ if ( strcmp(c,"BUSY") == 0 )
+ return TRUE;
+ if ( strcmp(c,"NO DIALTONE") == 0 )
+ return TRUE;
+
+ return FALSE;
}
/**
@@ -276,6 +254,8 @@
);
}
+
+
*/
/**
@@ -286,6 +266,7 @@
static gboolean
cellmodem_set_size(XfcePanelPlugin *plugin, int size, cellmodem_t *monitor)
{
+ DEBUG("Set size request");
if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL)
{
gtk_widget_set_size_request(GTK_WIDGET( monitor->qualpbar ),
@@ -297,7 +278,7 @@
size - 4, BORDER);
}
//setup_monitor(global, TRUE);
-
+ DEBUG("Done set size request");
return TRUE;
}
@@ -401,6 +382,8 @@
gtk_widget_show(monitor->eventbox);
gtk_widget_set_size_request(monitor->eventbox, -1, -1);
+ gtk_signal_connect( GTK_OBJECT(monitor->eventbox), "button-press-event", G_CALLBACK (cellmodem_button_event), monitor );
+
}
/**
* @brief [cellmodem_t CTOR] Create a new cellmodem object
@@ -466,6 +449,9 @@
case REGISTRATION_NOT_REGISTERED:
g_snprintf(buffer, 512, _("Not registered"));
break;
+ case REGISTRATION_NEEDS_PIN:
+ g_snprintf(buffer, 512, _("Modem needs PIN"));
+ break;
case REGISTRATION_REGISTERING:
g_snprintf(buffer, 512, _("Registering"));
break;
@@ -587,15 +573,8 @@
if (NULL == monitor->driver)
return FALSE;
- DEBUG("Closing modem, driver at %p\n", monitor->driver);
-
monitor->driver->close(monitor->modem_instance);
- DEBUG("Modem closed");
- /*
- if ( failure )
- cellmodem_t_switch_status( monitor, MODEM_ERROR );
- */
return TRUE;
}
@@ -609,17 +588,18 @@
static void
cellmodem_t_request_pin( cellmodem_t *monitor )
{
- if ( monitor->options.ask_for_pin )
+ /*
+ if ( monitor->options.ask_for_pin )
pin_helper_launch( GTK_WIDGET(monitor->plugin), pin_callback, monitor );
- else {
- cellmodem_t_switch_status( monitor, MODEM_CLOSED );
+ else {
+ */
+ cellmodem_t_switch_status( monitor, MODEM_CLOSED );
+ cellmodem_t_switch_network_status( monitor, REGISTRATION_NEEDS_PIN );
- reschedule_open( monitor /*, FALSE*/ );
- /*
- led_t_set_color( monitor->status_led, LED_YELLOW );
- led_t_set_flashing( monitor->status_led, TRUE );
- */
- }
+ /* End here */
+
+ cellmodem_t_close_modem( monitor );
+
}
@@ -719,7 +699,7 @@
/* Error */
DEBUG("Modem error detected (%p)", pvt);
cellmodem_t_switch_status( monitor, MODEM_ERROR );
- reschedule_open( monitor );
+ //reschedule_open( monitor );
return;
}
@@ -764,7 +744,7 @@
cellmodem_t_switch_network_status( monitor, REGISTRATION_NOT_REGISTERED );
cellmodem_t_switch_status( monitor, MODEM_ERROR );
- reschedule_open( monitor /*, TRUE*/ );
+ //reschedule_open( monitor /*, TRUE*/ );
return;
}
@@ -793,7 +773,7 @@
/* Error */
DEBUG("Modem error detected (%p)", pvt);
cellmodem_t_switch_status( monitor, MODEM_ERROR );
- reschedule_open( monitor );
+ //reschedule_open( monitor );
return;
}
@@ -807,12 +787,12 @@
if ( strncmp( start, "SIM PIN", 7) == 0) {
/* If we can ask for pin, we do */
- if ( monitor->options.ask_for_pin ) {
- cellmodem_t_request_pin( monitor );
- return ;
- }
+ // if ( monitor->options.ask_for_pin ) {
+ cellmodem_t_request_pin( monitor );
+ return;
+ // }
}
- if ( strncmp( start, "OK", 2) == 0 )
+ if ( strncmp( start, "READY", 2) == 0 )
{
/* If we got here, we are registering. Do nothing, just
reschedule open */
@@ -821,13 +801,15 @@
}
/* Errors found ?? . */
+ } else {
+ cellmodem_t_switch_status( monitor, MODEM_ERROR );
-
+ reschedule_open( monitor );
}
if ( failure )
cellmodem_t_switch_status( monitor, MODEM_ERROR );
-
- reschedule_open( monitor /*, failure */);
+ else
+ reschedule_open( monitor /*, failure */);
}
@@ -840,7 +822,7 @@
/* Error */
DEBUG("Modem error detected (%p)", pvt);
cellmodem_t_switch_status( monitor, MODEM_ERROR );
- reschedule_open( monitor );
+ //reschedule_open( monitor );
return;
}
@@ -984,11 +966,20 @@
{
GString *g = g_string_new("+CPIN=");
g_string_append( g, pin );
- cellmodem_t_send_at_command(monitor, &cellmodem_t_setpin_callback, g->str );
- g_string_free( g, TRUE );
- cellmodem_t_switch_status( monitor, MODEM_WAIT_REGISTRATION );
+ if (cellmodem_t_open_modem( monitor ) == TRUE) {
+ cellmodem_t_send_at_command(monitor, &cellmodem_t_setpin_callback, g->str );
+ g_string_free( g, TRUE );
+
+ cellmodem_t_switch_status( monitor, MODEM_WAIT_REGISTRATION );
+
+ cellmodem_t_is_registered( monitor );
+ } else {
+ cellmodem_t_switch_status( monitor, MODEM_ERROR );
+ reschedule_open( monitor );
+ }
+
}
@@ -1229,7 +1220,7 @@
monitor->at_timeout_id = -1;
DEBUG("Modem failed to reply");
cellmodem_t_switch_status( monitor, MODEM_ERROR );
- reschedule_open( monitor /*, TRUE*/ );
+ //reschedule_open( monitor /*, TRUE*/ );
return FALSE;
}
@@ -1277,6 +1268,7 @@
static gboolean
reschedule_open( cellmodem_t *monitor /*, gboolean failure*/ )
{
+ DEBUG("RESCHEDULING OPEN");
cellmodem_t_close_modem( monitor /*, failure*/ );
if ( monitor->info_timeout_id > 0 )
@@ -1308,9 +1300,12 @@
//}
}
DEBUG("Cannot open modem");
+
cellmodem_t_switch_status( monitor, MODEM_ERROR );
- return reschedule_open(monitor /*, FALSE*/ );
+ reschedule_open(monitor /*, FALSE*/ );
+
+ return FALSE;
}
@@ -1417,7 +1412,7 @@
void
cellmodem_t_initialize_modem( cellmodem_t *monitor )
{
- DEBUG("Initializing modem");
+ DEBUG(" ---- Initializing modem ---- ");
cellmodem_t_switch_status( monitor, MODEM_ERROR );
@@ -1431,12 +1426,13 @@
if ( monitor->driver != NULL && monitor->modem_instance != NULL ) {
DEBUG("Closing already created driver/instance");
monitor->driver->close( monitor->modem_instance );
+ DEBUG("Destroying the modem instance");
monitor->driver->destroy( monitor->modem_instance );
monitor->modem_instance = NULL;
}
monitor->driver = NULL;
-
+ DEBUG("Locating driver");
monitor->driver = find_driver_by_name( monitor->options.modem_driver );
if (monitor->driver==NULL) {
@@ -1453,10 +1449,27 @@
cellmodem_t_switch_status( monitor, MODEM_WAIT_CREG_RESPONSE );
+ DEBUG("Calling get network info");
+
get_network_info(monitor);
}
+static gboolean
+cellmodem_button_event(GtkEventBox *box, GdkEventButton *button, cellmodem_t *monitor)
+{
+ if (button->type != GDK_BUTTON_PRESS || button->button != 1) {
+ return FALSE;
+ }
+
+ if ( monitor->registration_status == REGISTRATION_NEEDS_PIN )
+ {
+ pin_helper_launch( GTK_WIDGET(monitor->plugin), pin_callback, monitor );
+ }
+ return TRUE;
+}
+
+
#ifdef DEBUG_ENABLED
int init_logging()
@@ -1492,11 +1505,11 @@
cellmodem_t_update_monitors( monitor );
g_signal_connect (plugin, "free-data", G_CALLBACK (cellmodem_t_delete), monitor);
-
g_signal_connect (plugin, "save", G_CALLBACK (cellmodem_write_config), monitor);
g_signal_connect (plugin, "size-changed", G_CALLBACK (cellmodem_set_size), monitor);
xfce_panel_plugin_menu_show_configure (plugin);
+
g_signal_connect (plugin, "configure-plugin", G_CALLBACK (cellmodem_create_options), monitor);
gtk_container_add(GTK_CONTAINER(plugin), monitor->eventbox);
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h 2006-10-01 12:34:31 UTC (rev 2079)
@@ -40,7 +40,7 @@
#include "leds.h"
-#undef DEBUG_ENABLED
+#define DEBUG_ENABLED
#ifdef DEBUG_ENABLED
#include <syslog.h>
@@ -99,7 +99,8 @@
REGISTRATION_REGISTERING,
REGISTRATION_GPRS,
REGISTRATION_UMTS,
- REGISTRATION_HSDPA
+ REGISTRATION_HSDPA,
+ REGISTRATION_NEEDS_PIN
} registration_type_t;
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h 2006-10-01 12:34:31 UTC (rev 2079)
@@ -27,7 +27,7 @@
gchar *modem_device;
gchar *modem_driver;
gchar *ppp_peer;
- gboolean ask_for_pin;
+/* gboolean ask_for_pin;*/
gint low_threshold;
gint critical_threshold;
gint max_quality;
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c 2006-10-01 12:34:31 UTC (rev 2079)
@@ -203,11 +203,13 @@
DEBUG("Modem opened (pipe)");
- if ( ! options->ask_for_pin ) {
+ /*
+ if ( ! options->ask_for_pin ) {
modem->valid_pin = TRUE;
if ( modem->pin_time == 0 )
- modem->pin_time = get_current_time(); /* So we can "register" */
- }
+ modem->pin_time = get_current_time();
+ }
+ */
return TRUE;
}
@@ -217,15 +219,12 @@
struct fake_modem_t *modem = (struct fake_modem_t*)instance;
if ( modem == NULL ) {
- DEBUG("Closing a NULL instance????");
return;
}
if ( modem->channel != NULL ) {
g_io_channel_unref( modem->channel );
modem->channel = NULL;
- } else {
- DEBUG("Modem channel already closed!");
- }
+ }
}
static gboolean fake_writeln( modem_instance_t instance, const gchar *data )
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c 2006-10-01 12:34:31 UTC (rev 2079)
@@ -73,21 +73,21 @@
{
struct generic_modem_t *modem = (struct generic_modem_t*)instance;
+ DEBUG("Closing modem");
+
if ( modem == NULL ) {
- DEBUG("Closing a NULL instance????");
- return;
+ return;
}
if ( modem->channel != NULL ) {
if ( modem->reader >= 0 ) {
g_source_remove( modem->reader );
modem->reader = -1;
}
-
+ DEBUG( "Closing channel %p", modem->channel );
g_io_channel_unref( modem->channel );
modem->channel = NULL;
- } else {
- DEBUG("Modem channel already closed!");
}
+ DEBUG("all done");
}
static gboolean generic_writeln( modem_instance_t instance, const gchar *data )
@@ -142,8 +142,8 @@
if ( status != G_IO_STATUS_NORMAL )
{
+ /* Close channel */
- /* Close channel */
DEBUG("Error writing ro modem, closing modem channel");
if (error && error->message ) {
DEBUG("Error message: '%s'", error->message );
@@ -190,11 +190,13 @@
{
struct generic_modem_t *modem = g_new( struct generic_modem_t , 1);
modem->reader = -1;
+ modem->channel = NULL;
return (modem_instance_t)modem;
}
static void generic_destroy( modem_instance_t modem )
{
+ DEBUG("Destroying instance %p", modem);
g_free( modem );
}
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c 2006-10-01 12:34:31 UTC (rev 2079)
@@ -24,6 +24,10 @@
{
/* Set default driver if none is still defined */
+
+ DEBUG("Got dialog response");
+
+
if (monitor->options.modem_driver == NULL) {
monitor->options.modem_driver =
g_strdup( find_driver_by_index( 0 )->name );
@@ -74,9 +78,10 @@
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->maxqual_entry),
monitor->options.max_quality);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->ask_pin_entry),
+ /*
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->ask_pin_entry),
monitor->options.ask_for_pin);
-
+ */
}
@@ -97,13 +102,13 @@
}
}
-
+/*
static void
cb_pin_entry_toggled(GtkToggleButton *entry, cellmodem_dialog_t *dialog)
{
dialog->monitor->options.ask_for_pin = gtk_toggle_button_get_active(entry);
}
-
+*/
static void
cb_driver_entry_changed(GtkComboBox *combo, cellmodem_dialog_t *dialog)
{
@@ -156,7 +161,7 @@
GtkWidget *dlg;
GtkWidget *header;
GtkWidget *vbox;
- GtkWidget *vbox2;
+/* GtkWidget *vbox2;*/
GtkSizeGroup *sizegr;
GtkWidget *hbox;
GtkWidget *label;
@@ -280,6 +285,7 @@
/* Toggle buttons. */
+ /*
MAKEHBOX( hbox );
@@ -287,15 +293,16 @@
gtk_widget_show(vbox2);
gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
- dialog->ask_pin_entry = gtk_check_button_new_with_mnemonic( _("Ask for PIN if needed") );
+
+ dialog->ask_pin_entry = gtk_check_button_new_with_mnemonic( _("Ask for PIN if needed") );
gtk_box_pack_start( GTK_BOX(hbox), dialog->ask_pin_entry, 0, FALSE, FALSE );
gtk_widget_show( dialog->ask_pin_entry );
g_signal_connect(dialog->ask_pin_entry, "toggled", G_CALLBACK(cb_pin_entry_toggled), dialog);
+ */
-
update_dialog( dialog );
Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.h 2006-10-01 10:25:56 UTC (rev 2078)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.h 2006-10-01 12:34:31 UTC (rev 2079)
@@ -28,7 +28,7 @@
GtkWidget *low_entry;
GtkWidget *critical_entry;
GtkWidget *maxqual_entry;
- GtkWidget *ask_pin_entry;
+/* GtkWidget *ask_pin_entry;*/
cellmodem_t *monitor;
} cellmodem_dialog_t;
More information about the Goodies-commits
mailing list