[Goodies-commits] r2091 - in xfce4-cellmodem-plugin/trunk: . panel-plugin

Alvaro Lopes alvieboy at xfce.org
Thu Oct 5 13:56:29 CEST 2006


Author: alvieboy
Date: 2006-10-05 11:56:23 +0000 (Thu, 05 Oct 2006)
New Revision: 2091

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/leds.c
   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/modem_driver_generic.h
   xfce4-cellmodem-plugin/trunk/panel-plugin/pin_helper.c
   xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c
Log:
Boosted version to 0.0.3
        Better error handling - Error messages included
        Fixed bugs in remove_leading_chars and remove_trailing_chars
        Fixed modem pin reply in fake driver.
        Added vasprintf - needed for error messages
        Moved some prototypes into cellmodem.h
        Removed C++ style comments
        Enforce pin '1234' on fake driver.
        Cancel pending timers when reinitializing modem.



Modified: xfce4-cellmodem-plugin/trunk/ChangeLog
===================================================================
--- xfce4-cellmodem-plugin/trunk/ChangeLog	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/ChangeLog	2006-10-05 11:56:23 UTC (rev 2091)
@@ -1,3 +1,13 @@
+0.0.3
+	Better error handling - Error messages included
+        Fixed bugs in remove_leading_chars and remove_trailing_chars
+        Fixed modem pin reply in fake driver.
+        Added vasprintf - needed for error messages
+        Moved some prototypes into cellmodem.h
+        Removed C++ style comments
+        Enforce pin '1234' on fake driver.
+        Cancel pending timers when reinitializing modem.
+        
 0.0.2
 	Fixed error handling.
         Disabled the ask for pin. You can click on the plugin to enter

Modified: xfce4-cellmodem-plugin/trunk/configure.ac
===================================================================
--- xfce4-cellmodem-plugin/trunk/configure.ac	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/configure.ac	2006-10-05 11:56:23 UTC (rev 2091)
@@ -1,4 +1,4 @@
-m4_define([cellmodem_version], [0.0.2])
+m4_define([cellmodem_version], [0.0.3])
 
 AC_INIT([xfce4-cellmodem-plugin], [cellmodem_version()],[alvieboy at alvie.com])
 
@@ -12,9 +12,11 @@
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_INTLTOOL
-
+AC_GNU_SOURCE
 AC_HEADER_STDC
 
+AC_CHECK_FUNCS([vasprintf])
+
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.20])
 XDT_I18N([])
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c	2006-10-05 11:56:23 UTC (rev 2091)
@@ -29,7 +29,6 @@
 static gboolean get_network_info( cellmodem_t *monitor );
 
 static void cellmodem_t_identify_network( cellmodem_t *monitor );
-void cellmodem_write_config(XfcePanelPlugin *plugin, cellmodem_t *monitor);
 static gboolean cellmodem_t_close_modem(cellmodem_t *monitor /*, gboolean failure */);
 static gboolean reschedule_open( cellmodem_t *monitor /*, gboolean failure */);
 static gboolean cellmodem_t_at_command_timeout( cellmodem_t *monitor );
@@ -40,11 +39,19 @@
 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);
+static void cellmodem_t_switch_status( cellmodem_t *monitor, modem_status_t status );
 
 
 
 /* End Proto */
 
+/**
+ * @brief [cellmodem_t method] Set display modem error
+ *
+ * @param monitor The monitor object
+ *
+ * @return TRUE if c starts with 'ERROR', FALSE otherwise
+ */
 
 
 static void cellmodem_t_set_error( cellmodem_t *monitor )
@@ -66,6 +73,44 @@
     return monitor->modem_status == MODEM_ERROR;
 }
 
+static void cellmodem_t_switch_to_error( cellmodem_t *monitor,
+					const char *fmt, ... )
+{
+    va_list ap;
+    va_start( ap, fmt );
+
+    if ( monitor->lasterror != NULL ) {
+	g_free( monitor->lasterror );
+    }
+
+    vasprintf( &monitor->lasterror, fmt, ap );
+
+    va_end( ap );
+
+    cellmodem_t_switch_status( monitor, MODEM_ERROR );
+    cellmodem_t_set_tooltip_info( monitor );
+}
+
+static void cellmodem_t_switch_to_error_and_restart( cellmodem_t *monitor,
+						    const char *fmt, ... )
+{
+    va_list ap;
+    va_start( ap, fmt );
+
+    if ( monitor->lasterror != NULL ) {
+	g_free( monitor->lasterror );
+    }
+
+    vasprintf( &monitor->lasterror, fmt, ap );
+
+    va_end( ap );
+
+    cellmodem_t_switch_status( monitor, MODEM_ERROR );
+    cellmodem_t_set_tooltip_info( monitor );
+    reschedule_open( monitor );
+}
+
+
 static void cellmodem_t_switch_status( cellmodem_t *monitor,
 				      modem_status_t status )
 {
@@ -170,18 +215,22 @@
  * @param buffer The string where to remove the characters
  * @param c The character
  *
- * @return Nothing
+ * @return A new pointer to the first valid char
  */
 
-static void
-remove_leading_chars( char *buffer, char c )
+static char *
+remove_leading_chars( char *buffer, const char *c )
 {
-    char *pos;
-    do {
-	pos = strchr( buffer, c);
-	if (pos)
-	    *pos=0;
-    } while (pos);
+    size_t position = 0;
+
+    while ( buffer[position] > 0 ) {
+	if ( strchr( c, buffer[position] ) > 0 ) {
+            position++;
+	} else {
+            break;
+	}
+    }
+    return buffer + position;
 }
 /**
  * @brief Remove trailing characters from string
@@ -189,20 +238,23 @@
  * This will remove all trailing chars in string that match the parameter.
  *
  * @param buffer The string where to remove the characters
- * @param c The character
+ * @param c The characters to remove
  *
  * @return Nothing
  */
 
 static void
-remove_trailing_chars( char *buffer, char c )
+remove_trailing_chars( char *buffer, const char *c )
 {
-    char *pos;
+    size_t position = strlen(buffer);
     do {
-	pos = strchr( buffer, c);
-	if (pos)
-	    *pos=0;
-    } while (pos);
+	if ( strchr( c, buffer[position] ) > 0 ) {
+	    buffer[ position ] = '\0';
+            position--;
+	} else {
+            break;
+	}
+    } while ( position > 0 );
 }
 
 /**
@@ -240,24 +292,6 @@
 }
 
 
-/*
-static void
-cellmodem_t_start_fetch_info( cellmodem_t *monitor )
-{
-    if (monitor->info_timeout_id >0 ) {
-        g_source_remove( monitor->info_timeout_id );
-        monitor->info_timeout_id=-1;
-    }
-    monitor->info_timeout_id = g_timeout_add(2 * 1000,
-					     (GSourceFunc) get_network_info,
-					     monitor
-					    );
-}
-
-
-
-*/
-
 /**
  * @brief Set the plugin size
  * DOCUMENT ME PLEASE
@@ -277,7 +311,6 @@
 	gtk_widget_set_size_request(GTK_WIDGET( monitor->qualpbar ),
 				    size - 4, BORDER);
     }
-    //setup_monitor(global, TRUE);
     DEBUG("Done set size request");
     return TRUE;
 }
@@ -361,7 +394,6 @@
     gtk_box_pack_start(GTK_BOX(monitor->box),
                        led_box, FALSE,FALSE,0);
 
-    //gtk_container_set_border_width(GTK_CONTAINER(led_box), BORDER/2);
     gtk_box_set_spacing(GTK_BOX(led_box), BORDER/4);
 
 
@@ -401,7 +433,7 @@
     monitor = g_new0(cellmodem_t, 1);
 
     monitor->plugin = plugin;
-
+    monitor->lasterror = NULL;
     monitor->lastcmd = g_new( gchar, 128 );
 
     monitor->options.modem_device = NULL;
@@ -418,7 +450,7 @@
 
     cellmodem_t_setup_widgets( monitor, FALSE );
 
-    cellmodem_t_switch_status( monitor, MODEM_ERROR );
+    cellmodem_t_switch_to_error( monitor, _("Initializing plugin") );
 
     cellmodem_t_switch_network_status(  monitor, REGISTRATION_UNKNOWN );
 
@@ -441,7 +473,7 @@
 
     if ( cellmodem_t_in_error_status ( monitor ) )
     {
-        g_snprintf( buffer, 512, _("Modem not detected or modem error") );
+	g_snprintf( buffer, 512, _("Error detected:\n%s"), monitor->lasterror );
     }
     else {
 	switch( monitor->registration_status )
@@ -623,16 +655,16 @@
 
     if ( !success || response==NULL || response->str==NULL ) {
 	/* Error */
-	DEBUG("Modem error detected (%p)", pvt);
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to CREG") );
 	return;
     }
+
     DEBUG("Got registration callback: %s", response->str);
     if ( strncmp( response->str ,"+CREG: ", 7 )==0 ) {
 
 	gchar *start = response->str + 7;
 	if ( strtok( start, ",") == NULL) {
-	    cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	    cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid reply to +CREG") );
 	    return;
 	}
 	gchar *delim = strtok ( NULL, "," );
@@ -657,10 +689,10 @@
 	}
     } else {
 	DEBUG("Modem error in reply");
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid CREG reply from modem") );
+        return;
     }
 
-    //cellmodem_t_set_tooltip_info( monitor );
 
     if ( monitor->registration_status != REGISTRATION_NOT_REGISTERED  &&
          monitor->registration_status != REGISTRATION_REGISTERING ) {
@@ -669,9 +701,6 @@
 
     } else {
 	/* Check for PIN ????? */
-	// Ask pin.
-
-	//if (monitor->options.ask_for_pin)
 	cellmodem_t_get_pin_status( monitor );
 	/*else
 	 reschedule_open( monitor, FALSE );
@@ -698,14 +727,12 @@
     if ( !success || response==NULL || response->str==NULL ) {
 	/* Error */
         DEBUG("Modem error detected (%p)", pvt);
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
-        //reschedule_open( monitor );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to COPS") );
         return;
     }
 
     /* +COPS: 0,0,"Provider",2 */
     if ( strncmp(response->str,"+COPS: ", 7 )==0 ) {
-	// Extract info
 	gchar *start = response->str + 7;
 	gchar *tok[64];
 	int i=0;
@@ -743,8 +770,7 @@
     } else {
 	cellmodem_t_switch_network_status( monitor, REGISTRATION_NOT_REGISTERED );
 
-        cellmodem_t_switch_status( monitor, MODEM_ERROR );
-	//reschedule_open( monitor /*, TRUE*/ );
+        cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid COPS reply from modem") );
         return;
     }
 
@@ -772,8 +798,7 @@
     if ( !success || response==NULL || response->str==NULL ) {
 	/* Error */
         DEBUG("Modem error detected (%p)", pvt);
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
-        //reschedule_open( monitor );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to CPIN") );
         return;
     }
 
@@ -781,16 +806,13 @@
     /* +CPIN: OK */
 
     if ( strncmp(response->str,"+CPIN: ", 7 )==0 ) {
-	// Extract info
 	gchar *start = response->str + 7;
 	DEBUG("CPIN: '%s'", start);
 	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 ( strncmp( start, "READY", 2) == 0 )
 	{
@@ -802,14 +824,14 @@
 
         /* Errors found ?? . */
     } else {
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid CPIN reply from modem") );
 
         reschedule_open( monitor );
     }
     if ( failure )
-        cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Unsupportted CPIN reply from modem") );
     else
-	reschedule_open( monitor /*, failure */);
+	reschedule_open( monitor );
 }
 
 
@@ -820,9 +842,7 @@
 
     if ( !success ) {
 	/* Error */
-        DEBUG("Modem error detected (%p)", pvt);
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
-        //reschedule_open( monitor );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Cannot send PIN to modem") );
         return;
     }
 
@@ -853,11 +873,16 @@
 {
     cellmodem_t *monitor = (cellmodem_t*)pvt;
 
+    if ( !success || response==NULL || response->str==NULL ) {
+	/* Error */
+        DEBUG("Modem error detected (%p)", pvt);
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to CSQ") );
+        return;
+    }
+
     if ( strncmp( response->str ,"+CSQ: ", 6 )==0 ) {
-	// Extract info
 	gchar *start = response->str + 6;
 	if ( strtok( start, ",") == NULL) {
-	    // Error
 	    return;/* FALSE;*/
 	}
 	strtok ( NULL, "," );
@@ -870,6 +895,9 @@
 	    monitor->quality=1.0;
 
         cellmodem_t_update_monitors( monitor );
+    } else {
+        cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid CSQ reply from modem") );
+        return;
     }
     DEBUG("Got quality, restarting");
     /* cellmodem_t_close_modem( monitor, FALSE ); - reschedule will close */
@@ -976,10 +1004,8 @@
 
         cellmodem_t_is_registered( monitor );
     } else {
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
-        reschedule_open( monitor );
+	cellmodem_t_switch_to_error_and_restart( monitor, _("Cannot open modem") );
     }
-
 }
 
 
@@ -999,6 +1025,7 @@
 static gboolean
 cellmodem_t_modem_handle_response( cellmodem_t *monitor, char *buffer )
 {
+    char *bstart;
     DEBUG("In handle response");
 
     if ( monitor->resp.reply_callback == NULL ) {
@@ -1007,35 +1034,33 @@
     }
     if ( monitor->resp.reply_buffer == NULL )
     {
-	monitor->resp.reply_buffer = g_string_new( NULL ); // Initialize to NULL
+	monitor->resp.reply_buffer = g_string_new( NULL ); /* Initialize to NULL */
     }
 
     /* Remove trailing \r and \n */
 
-    remove_leading_chars(buffer,'\n');
-    remove_leading_chars(buffer,'\r');
-    remove_trailing_chars(buffer,'\r');
-    remove_trailing_chars(buffer,'\n');
+    bstart = remove_leading_chars(buffer,"\n\r");
+    remove_trailing_chars(bstart,"\r\n");
 
     /* See if it is echo */
 
-    if ( strcmp( monitor->lastcmd , buffer ) == 0 ) {
+    if ( strcmp( monitor->lastcmd , bstart ) == 0 ) {
 	DEBUG("Echo detected, skipping");
 	return TRUE;
     }
 
     /* Ignore empty lines */
 
-    if ( is_only_spaces( buffer ) ) {
+    if ( is_only_spaces( bstart ) ) {
         DEBUG("Only spaces found in reply, skipping");
 	return TRUE;
     }
 
-    DEBUG("Got response: '%s' command '%s'\n", buffer, monitor->lastcmd);
+    DEBUG("Got response: '%s' command '%s'\n", bstart, monitor->lastcmd);
 
     cellmodem_t_cancel_pending_at_command_timeout( monitor );
 
-    if ( is_AT_error_reply( buffer ) ) {
+    if ( is_AT_error_reply( bstart ) ) {
 
 	monitor->resp.reply_callback( FALSE,
 				     monitor->resp.reply_buffer,
@@ -1045,12 +1070,11 @@
         g_string_free( monitor->resp.reply_buffer, TRUE );
         monitor->resp.reply_buffer = NULL;
 
-	//monitor->resp.reply_callback = NULL;
         DEBUG("Done handling error");
 	return TRUE;
     }
 
-    if ( is_AT_success_reply( buffer ) ) {
+    if ( is_AT_success_reply( bstart ) ) {
         DEBUG("Got AT OK reply");
 	monitor->resp.reply_callback( TRUE,
 		       monitor->resp.reply_buffer,
@@ -1059,12 +1083,10 @@
 	g_string_free( monitor->resp.reply_buffer, TRUE );
         monitor->resp.reply_buffer = NULL;
 
-	//monitor->resp.reply_callback = NULL;
-        
 	return TRUE;
     }
 
-    g_string_append( monitor->resp.reply_buffer, buffer );
+    g_string_append( monitor->resp.reply_buffer, bstart );
     g_string_append( monitor->resp.reply_buffer, "\n" );
 
     DEBUG("Finished handling");
@@ -1126,8 +1148,7 @@
 
     if (status != G_IO_STATUS_NORMAL ) {
 	DEBUG("Error reading from modem");
-	//: '%s'\n",error->message );
-        cellmodem_t_switch_status( monitor, MODEM_ERROR );
+        cellmodem_t_switch_to_error( monitor, _("Error reading from modem") );
 	cellmodem_t_close_modem( monitor /*, TRUE*/ );
 	return FALSE;
     }
@@ -1190,6 +1211,9 @@
 
     /* TODO - check if we already have a timeout */
 
+    if ( monitor->at_timeout_id > 0 )
+        g_source_remove( monitor->at_timeout_id );
+
     monitor->at_timeout_id =
 	g_timeout_add( 1000,
 		      (GSourceFunc) cellmodem_t_at_command_timeout,
@@ -1201,12 +1225,10 @@
 				 ) == FALSE )
     {
 	DEBUG("ERROR Command: '%s'\n", monitor->lastcmd );
-        cellmodem_t_switch_status( monitor, MODEM_ERROR );
+        cellmodem_t_switch_to_error( monitor, _("Error writing to modem") );
         cellmodem_t_close_modem( monitor /*, TRUE*/ );
         return FALSE;
     }
-    /* Remove CR LF */
-     //monitor->lastcmd[ strlen(monitor->lastcmd) - 2 ] = 0;
 
     DEBUG("Sent command to modem: '%s'\n", monitor->lastcmd);
     
@@ -1219,8 +1241,7 @@
 {
     monitor->at_timeout_id = -1;
     DEBUG("Modem failed to reply");
-    cellmodem_t_switch_status( monitor, MODEM_ERROR );
-    //reschedule_open( monitor /*, TRUE*/ );
+    cellmodem_t_switch_to_error_and_restart( monitor, _("Modem did not reply to command") );
     return FALSE;
 }
 
@@ -1238,20 +1259,18 @@
 cellmodem_t_open_modem(cellmodem_t *monitor)
 {
     if ( NULL == monitor->driver ) {
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	cellmodem_t_switch_to_error( monitor, _("No driver defined") );
 	return FALSE;
     }
 
     if ( NULL == monitor->modem_instance ) {
-        cellmodem_t_switch_status( monitor, MODEM_ERROR );
+        cellmodem_t_switch_to_error( monitor, _("No modem instance") );
 	return FALSE;
     }
 
     if ( monitor->driver->open( monitor->modem_instance,
 			        &monitor->options ) == FALSE )
     {
-        DEBUG("Cannot open modem");
-        cellmodem_t_switch_status( monitor, MODEM_ERROR );
 	return FALSE;
     }
     /* cellmodem_t_switch_status( monitor, MODEM_IDLE ); */
@@ -1294,17 +1313,13 @@
     DEBUG("Getting network info");
     if ( cellmodem_t_open_modem( monitor ) != FALSE ) {
 
-	//    if ( monitor->modem_status == MODEM_IDLE ) {
 	cellmodem_t_is_registered( monitor );
 	return FALSE; /* Dont restart timer. */
-	//}
     }
     DEBUG("Cannot open modem");
 
-    cellmodem_t_switch_status( monitor, MODEM_ERROR );
+    cellmodem_t_switch_to_error_and_restart( monitor, _("Cannot open modem") );
 
-    reschedule_open(monitor /*, FALSE*/ );
-
     return FALSE;
 }
 
@@ -1414,8 +1429,20 @@
 {
     DEBUG(" ---- Initializing modem ---- ");
 
-    cellmodem_t_switch_status( monitor, MODEM_ERROR );
+    cellmodem_t_switch_to_error( monitor, _("Modem initializing") );
 
+    /*
+     Cancel any pending timers
+     */
+
+    if (monitor->at_timeout_id > 0) {
+        g_source_remove( monitor->at_timeout_id );
+    }
+    if ( monitor->info_timeout_id > 0 )
+    {
+        g_source_remove( monitor->info_timeout_id );
+    }
+
     if ( monitor->options.modem_driver == NULL ) {
         DEBUG("No driver defined, skipping");
 	return;
@@ -1437,7 +1464,7 @@
 
     if (monitor->driver==NULL) {
 	DEBUG("Cannot find that driver (%s)!!!", monitor->options.modem_driver);
-	cellmodem_t_switch_status( monitor, MODEM_ERROR );
+	cellmodem_t_switch_to_error( monitor, _("Invalid driver specified") );
 	return;
     }
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h	2006-10-05 11:56:23 UTC (rev 2091)
@@ -123,25 +123,26 @@
     /* Colors */
     GdkColor        red_color, yellow_color, green_color;
     /* IO Stuff */
-    /*gint            modem_watcher_cb_id;*/
-//    GIOChannel      *modem_channel;
+
     modem_driver_t  *driver;
     modem_instance_t  *modem_instance;
     gchar           line_buffer[8192];
     size_t          line_buffer_size;
 
-
     /* User options */
     cellmodem_options_t options;
 
-
     /* Modem stuff */
     modem_status_t modem_status;
     registration_type_t registration_status;
     gfloat quality;
     gint signal_strength;
+    /* Last command we sent to the modem */
     gchar *lastcmd;
+    /* Network information */
     gchar *network;
+    /* Last error we got */
+    gchar *lasterror;
 
     modem_response_data_t resp;
 
@@ -150,6 +151,12 @@
 } cellmodem_t;
 
 
+/*
+ Prototypes
+ */
+void cellmodem_write_config(XfcePanelPlugin *plugin, cellmodem_t *monitor);
+void cellmodem_t_initialize_modem( cellmodem_t *monitor );
 
+
 #endif
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/leds.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/leds.c	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/leds.c	2006-10-05 11:56:23 UTC (rev 2091)
@@ -42,7 +42,7 @@
     if (whole_leds == NULL)
 	return FALSE;
 
-    // cut individual leds.
+    /* cut individual leds. */
 
     for (i=0; i<NUMBER_OF_LEDS; i++) {
 	pixleds[i] =

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c	2006-10-05 11:56:23 UTC (rev 2091)
@@ -23,7 +23,7 @@
 
 static guint32 get_current_time()
 {
-    // we should use g_date_get_julian();
+    /* we should use g_date_get_julian();*/
     struct timeval tv;
     gettimeofday( &tv,NULL );
     return tv.tv_sec;
@@ -95,7 +95,7 @@
 
     DEBUG("Cmd: %s", cmd );
 
-    // Add newlines
+    /* Add newlines */
 
     g_string_append(modem->reply,"\r\n");
 
@@ -124,20 +124,28 @@
 
     if ( strncmp( cmd, "+CPIN?", 6)==0) {
         if ( modem->valid_pin )
-	    reply_ok( modem,  "+CPIN: OK" );
+	    reply_ok( modem,  "+CPIN: READY" );
 	else
             reply_ok( modem,  "+CPIN: SIM PIN" );
         return TRUE;
     }
 
     if ( strncmp( cmd, "+CPIN=", 6)==0) {
-	if (! modem->valid_pin) {
-            modem->pin_time = get_current_time();
+	const char *pin = cmd+6;
+	if (strncmp( pin, "1234", 4)==0) {
+	    if (! modem->valid_pin) {
+		modem->pin_time = get_current_time();
+	    }
+	    modem->valid_pin = TRUE;
+	    g_string_append( modem->reply, "OK\r\n" );
+	    queue_reply( modem );
+	    return TRUE;
+	} else {
+	    /* What to return here? */
+	    g_string_append( modem->reply, "OK\r\n" );
+	    queue_reply( modem );
+            return TRUE;
 	}
-        modem->valid_pin = TRUE;
-	g_string_append( modem->reply, "OK\r\n" );
-	queue_reply( modem );
-	return TRUE;
     }
 
     /* Queue error for now */
@@ -203,14 +211,6 @@
 
     DEBUG("Modem opened (pipe)");
 
-    /*
-     if ( ! options->ask_for_pin ) {
-	modem->valid_pin = TRUE;
-	if ( modem->pin_time == 0 )
-	    modem->pin_time = get_current_time(); 
-	    }
-            */
-
     return TRUE;
 }
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c	2006-10-05 11:56:23 UTC (rev 2091)
@@ -130,7 +130,6 @@
 	} else {
 	    if (status == G_IO_STATUS_NORMAL) {
 		written += bw;
-                //bytes_to_write;
 	    } else {
                 break;
 	    }

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.h	2006-10-05 11:56:23 UTC (rev 2091)
@@ -24,7 +24,6 @@
 struct generic_modem_t
 {
     gint reader;
-//    void *reader_pvt;
     GIOChannel *channel;
 };
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/pin_helper.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/pin_helper.c	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/pin_helper.c	2006-10-05 11:56:23 UTC (rev 2091)
@@ -27,7 +27,7 @@
 
 	if (!pin || strlen(pin)!=4 )
 	{
-	    // Error.
+	    /* Error. */
 	    xfce_warn(_("Invalid PIN entered. PIN has 4 digits"));
 
             return;

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c	2006-10-05 10:55:36 UTC (rev 2090)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c	2006-10-05 11:56:23 UTC (rev 2091)
@@ -60,7 +60,7 @@
 	idx = find_driver_index_by_name( monitor->options.modem_driver );
     } else {
 	idx=0;
-    //    monitor->options.modem_driver = find_driver_by_index( idx );
+	/*  monitor->options.modem_driver = find_driver_by_index( idx );*/
 
     }
 




More information about the Goodies-commits mailing list