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

Alvaro Lopes alvieboy at xfce.org
Thu Apr 5 20:49:52 CEST 2007


Author: alvieboy
Date: 2007-04-05 18:49:52 +0000 (Thu, 05 Apr 2007)
New Revision: 2669

Modified:
   xfce4-cellmodem-plugin/trunk/THANKS
   xfce4-cellmodem-plugin/trunk/autogen.sh
   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
   xfce4-cellmodem-plugin/trunk/po/ChangeLog
Log:
Translation and debug fixes

Modified: xfce4-cellmodem-plugin/trunk/THANKS
===================================================================
--- xfce4-cellmodem-plugin/trunk/THANKS	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/THANKS	2007-04-05 18:49:52 UTC (rev 2669)
@@ -5,4 +5,9 @@
 Jannis Pohlmann
 Michal Varady
 Maximilian Schleiss
-
+Tobias Kral
+Piotr Maliński
+Jeff Bailes
+Pau Rul-lan Ferragut 
+Maxim Dziumanenko
+Dmitry Nikitin

Modified: xfce4-cellmodem-plugin/trunk/autogen.sh
===================================================================
--- xfce4-cellmodem-plugin/trunk/autogen.sh	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/autogen.sh	2007-04-05 18:49:52 UTC (rev 2669)
@@ -18,6 +18,11 @@
   exit 1
 }
 
+linguas=`sed -e '/^#/d' po/LINGUAS`
+sed -e "s/@LINGUAS@/${linguas}/g" \
+    < "configure.ac.in" > "configure.ac"
+
+
 exec xdt-autogen $@
 
 # vi:set ts=2 sw=2 et ai:
\ No newline at end of file

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.c	2007-04-05 18:49:52 UTC (rev 2669)
@@ -125,7 +125,7 @@
 static void cellmodem_t_switch_status( cellmodem_t *monitor,
 				      modem_status_t status )
 {
-    DEBUG("Switching modem status from %d to %d",
+    CELLMODEM_DEBUG(5,"Switching modem status from %d to %d",
           monitor->modem_status, status );
 
     switch ( status ) {
@@ -135,12 +135,14 @@
     case MODEM_WAIT_CSQ_RESPONSE:
     case MODEM_WAIT_CPIN_RESPONSE:
     case MODEM_WAIT_COPS_RESPONSE:
-    case MODEM_WAIT_PINE_RESPONSE:
+	case MODEM_WAIT_PINE_RESPONSE:
     case MODEM_CLOSED:
 	cellmodem_t_set_ok( monitor );
 	break;
     case MODEM_WAIT_CREG_RESPONSE:
-    case MODEM_WAIT_REGISTRATION:
+	case MODEM_WAIT_REGISTRATION:
+	case MODEM_WAIT_CMGF_RESPONSE:
+	case MODEM_WAIT_SET_CMGF_RESPONSE:
     case MODEM_WAIT_OHCIP_RESPONSE:
         break;
     }
@@ -323,7 +325,7 @@
 static gboolean
 cellmodem_set_size(XfcePanelPlugin *plugin, int size, cellmodem_t *monitor)
 {
-    DEBUG("Set size request");
+    CELLMODEM_DEBUG(8,"Set size request");
     if (xfce_panel_plugin_get_orientation (plugin) == GTK_ORIENTATION_HORIZONTAL)
     {
 	gtk_widget_set_size_request(GTK_WIDGET( monitor->qualpbar ),
@@ -334,7 +336,7 @@
 	gtk_widget_set_size_request(GTK_WIDGET( monitor->qualpbar ),
 				    size - 4, BORDER);
     }
-    DEBUG("Done set size request");
+    CELLMODEM_DEBUG(8,"Done set size request");
     return TRUE;
 }
 
@@ -463,8 +465,12 @@
     monitor->options.critical_threshold = 20;
     monitor->options.low_threshold = 40;
     monitor->options.max_quality = MAX_QUAL;
+	monitor->options.check_for_sms = FALSE;
+    monitor->options.sms_check_interval = 10;
 
 
+	monitor->no_sms_support = FALSE;
+
     /* Setup colors */
 
     gdk_color_parse("#ff0000", &(monitor->red_color));
@@ -601,7 +607,7 @@
 static void
 cellmodem_t_delete(cellmodem_t *monitor)
 {
-    DEBUG("Destroying cellmodem object");
+    CELLMODEM_DEBUG(7,"Destroying cellmodem object");
     cellmodem_t_close_modem( monitor /*, TRUE*/ );
 
     g_object_unref (monitor->tooltips);
@@ -682,7 +688,7 @@
 	return;
     }
 
-    DEBUG("Got registration callback: %s", response->str);
+    CELLMODEM_DEBUG(4,"Got registration callback: %s", response->str);
     if ( strncmp( response->str ,"+CREG: ", 7 )==0 ) {
 
 	gchar *start = response->str + 7;
@@ -694,7 +700,7 @@
 
 	int i = atoi( delim );
 
-	DEBUG("Registration reply: %d", i);
+	CELLMODEM_DEBUG(4,"Registration reply: %d", i);
 
 	switch (i) {
 	case 1:
@@ -711,7 +717,7 @@
             break;
 	}
     } else {
-	DEBUG("Modem error in reply");
+	CELLMODEM_DEBUG(2,"Modem error in reply");
 	cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid CREG reply from modem") );
         return;
     }
@@ -750,7 +756,7 @@
 
     if ( !success || response==NULL || response->str==NULL ) {
 	/* Error */
-        DEBUG("Modem error detected (%p)", pvt);
+        CELLMODEM_DEBUG(2,"Modem error detected (%p)", pvt);
 	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to COPS") );
         return;
     }
@@ -764,11 +770,11 @@
 	tok[i++] = strtok( start, ",");
 	while ( ( tok[i++]=strtok(NULL,",")) ) {};
 
-	DEBUG("Network: '%s'\n", tok[2]);
+	CELLMODEM_DEBUG(4,"Network: '%s'\n", tok[2]);
 
     /* Some modems do not reply with all fields */
 
-	DEBUG("Network Type: '%s'\n", tok[3]);
+	CELLMODEM_DEBUG(4,"Network Type: '%s'\n", tok[3]);
 
 	if ( monitor->network )
 	    g_free( monitor->network );
@@ -834,7 +840,7 @@
 
     if ( !success || response==NULL || response->str==NULL ) {
 	/* Error */
-        DEBUG("Modem error detected (%p)", pvt);
+        CELLMODEM_DEBUG(2,"Modem error detected (%p)", pvt);
 	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to CPIN") );
         return;
     }
@@ -844,7 +850,7 @@
 
     if ( strncmp(response->str,"+CPIN: ", 7 )==0 ) {
 	gchar *start = response->str + 7;
-	DEBUG("CPIN: '%s'", start);
+	CELLMODEM_DEBUG(4, "CPIN: '%s'", start);
 	if ( strncmp( start, "SIM PIN", 7) == 0) {
 	    /* If we can ask for pin, we do */
 
@@ -900,7 +906,7 @@
 
     if ( strncmp(response->str,"_OHCIP: ", 8 )==0 ) {
 	gchar *start = response->str + 8;
-	DEBUG("OHCIP: '%s'", start);
+	CELLMODEM_DEBUG(4,"OHCIP: '%s'", start);
 	if ( strncmp( start, "1", 1) == 0) {
 
             cellmodem_t_switch_network_status( monitor, REGISTRATION_HSDPA );
@@ -921,8 +927,89 @@
     cellmodem_t_get_quality( monitor );
 }
 
+/**
+ * @brief [cellmodem_t pseudo-member] Callback for CMGF status request
+ *
+ * @param success TRUE. We ignore CMGF errors, not all modem support it
+ * @param response GString with modem response
+ * @param pvt Pointer to cellmodem object
+ *
+ * pvt will be deferenced to cellmodem object upon calling. No typechecking is done.
+ *
+ * @return Nothing
+ */
 
+#if 0
 static void
+cellmodem_t_cmgf_callback(gboolean success, GString *response, void *pvt)
+{
+	cellmodem_t *monitor = (cellmodem_t*)pvt;
+	gboolean failure = FALSE;
+
+	if ( !success || response==NULL || response->str==NULL ) {
+		// Seems not to support SMS.
+		monitor->no_sms_support = TRUE;
+		return;
+	}
+
+	/* +CMGF: 0 */
+	/* +CMGF: 1 */
+
+	if ( strncmp(response->str,"+CMGF: ", 7 )==0 ) {
+		gchar *start = response->str + 7;
+		CELLMODEM_DEBUG(4, "CMGF: '%s'", start);
+
+		if ( strncmp( start, "1", 1) == 0) {
+			// We need to enter PDU mode.
+            cellmodem_t_switch_to_sms_pdu_mode( monitor );
+		}
+        if ( strncmp( start, "0", 1) == 0) {
+			// Ok, good, we're in PDU mode.
+
+		}
+
+
+	} else {
+		cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid OHCIP reply from modem") );
+		return;
+	}
+	if ( failure ) {
+		cellmodem_t_switch_to_error_and_restart( monitor, _("Unsupportted OHCIP reply from modem") );
+		return;
+	}
+ohcip_out:
+	cellmodem_t_get_quality( monitor );
+}
+
+#endif
+/**
+ * @brief [cellmodem_t pseudo-member] Callback for SET CMGF request
+ *
+ * @param success TRUE. We ignore CMGF errors, not all modem support it
+ * @param response GString with modem response
+ * @param pvt Pointer to cellmodem object
+ *
+ * pvt will be deferenced to cellmodem object upon calling. No typechecking is done.
+ *
+ * @return Nothing
+ */
+
+#if 0
+static void
+cellmodem_t_set_cmgf_callback(gboolean success, GString *response, void *pvt)
+{
+	cellmodem_t *monitor = (cellmodem_t*)pvt;
+
+	if ( !success || response==NULL || response->str==NULL ) {
+		// Seems not to support SMS, or PDU mode.
+		monitor->no_sms_support = TRUE;
+		return;
+	}
+	//
+}
+#endif
+
+static void
 cellmodem_t_setpin_callback(gboolean success, GString *response, void *pvt)
 {
     cellmodem_t *monitor = (cellmodem_t*)pvt;
@@ -964,7 +1051,7 @@
 
     if ( !success || response==NULL || response->str==NULL ) {
 	/* Error */
-        DEBUG("Modem error detected (%p)", pvt);
+        CELLMODEM_DEBUG(2,"Modem error detected (%p)", pvt);
 	cellmodem_t_switch_to_error_and_restart( monitor, _("Error in modem reply to CSQ") );
         return;
     }
@@ -975,7 +1062,7 @@
 	    return;/* FALSE;*/
 	}
 	strtok ( NULL, "," );
-	DEBUG("Qual: '%s'\n", start );
+	CELLMODEM_DEBUG(4,"Qual: '%s'\n", start );
 
 	int i = atoi( start );
 	monitor->signal_strength = i;
@@ -988,7 +1075,7 @@
         cellmodem_t_switch_to_error_and_restart( monitor, _("Invalid CSQ reply from modem") );
         return;
     }
-    DEBUG("Got quality, restarting");
+    CELLMODEM_DEBUG(3, "Got quality, restarting");
     /* cellmodem_t_close_modem( monitor, FALSE ); - reschedule will close */
     cellmodem_t_switch_status( monitor, MODEM_CLOSED );
     reschedule_open( monitor /*, FALSE*/ );
@@ -1095,6 +1182,43 @@
     cellmodem_t_switch_status( monitor, MODEM_WAIT_OHCIP_RESPONSE );
 }
 
+/**
+ * @brief [cellmodem_t member] Request SMS response type from modem
+ *
+ * @param monitor The cellmodem object
+ *
+ * This is asynchronous. Pseudo-method "cellmodem_t_cmfg_callback" will
+ * be called when modem replies.
+ *
+ * @return Nothing
+ */
+#if 0
+static void
+cellmodem_t_get_cmgf_status( cellmodem_t *monitor )
+{
+	cellmodem_t_send_at_command(monitor, &cellmodem_t_cmgf_callback, "+CMGF?","+CMGF: " );
+    cellmodem_t_switch_status( monitor, MODEM_WAIT_CMGF_RESPONSE );
+}
+#endif
+/**
+ * @brief [cellmodem_t member] Set SMS response type from modem (PDU mode).
+ * This is only called if the card supports SMS and its in text mode. See ETSI 07.05
+ *
+ * @param monitor The cellmodem object
+ *
+ * This is asynchronous. Pseudo-method "cellmodem_t_set_cmgf_callback" will
+ * be called when modem replies.
+ *
+ * @return Nothing
+ */
+#if 0
+static void
+cellmodem_t_set_cmgf( cellmodem_t *monitor )
+{
+	cellmodem_t_send_at_command(monitor, &cellmodem_t_set_cmgf_callback, "+CMGF=0", NULL );
+    cellmodem_t_switch_status( monitor, MODEM_WAIT_SET_CMGF_RESPONSE );
+}
+#endif
 
 static void
 cellmodem_t_send_pin( cellmodem_t *monitor, const gchar *pin )
@@ -1133,7 +1257,7 @@
     char *bstart;
 
     if ( monitor->resp.reply_callback == NULL ) {
-        DEBUG("No callback defined!!!!");
+        CELLMODEM_DEBUG(0, "No callback defined!!!!");
         return TRUE; /* No registered listener. */
     }
     if ( monitor->resp.reply_buffer == NULL )
@@ -1149,18 +1273,18 @@
     /* See if it is echo */
 
     if ( strcmp( monitor->lastcmd , bstart ) == 0 ) {
-	DEBUG("Echo detected, skipping");
+	CELLMODEM_DEBUG(7,"Echo detected, skipping");
 	return TRUE;
     }
 
     /* Ignore empty lines */
 
     if ( is_only_spaces( bstart ) ) {
-        DEBUG("Only spaces found in reply, skipping");
+        CELLMODEM_DEBUG(7,"Only spaces found in reply, skipping");
 	return TRUE;
     }
 
-    DEBUG("Got response: '%s' command '%s'\n", bstart, monitor->lastcmd);
+    CELLMODEM_DEBUG(5, "Got response: '%s' command '%s'\n", bstart, monitor->lastcmd);
 
     cellmodem_t_cancel_pending_at_command_timeout( monitor );
 
@@ -1169,17 +1293,15 @@
 	monitor->resp.reply_callback( FALSE,
 				     monitor->resp.reply_buffer,
 				     monitor->resp.reply_pvt );
-	DEBUG("Free reply data");
 
         g_string_free( monitor->resp.reply_buffer, TRUE );
         monitor->resp.reply_buffer = NULL;
 
-        DEBUG("Done handling error");
 	return TRUE;
     }
     
     if ( is_AT_success_reply( bstart ) ) {
-        DEBUG("Got AT OK reply");
+        CELLMODEM_DEBUG(4, "Got AT OK reply");
 	monitor->resp.reply_callback( TRUE,
 		       monitor->resp.reply_buffer,
 		       monitor->resp.reply_pvt );
@@ -1197,7 +1319,7 @@
 
     if ( monitor->resp.reply_expect ) {
 	if ( strncmp( bstart, monitor->resp.reply_expect, strlen(monitor->resp.reply_expect))!=0) {
-	    DEBUG("Ignoring reply from modem: '%s'\n", bstart);
+	    CELLMODEM_DEBUG(3, "Ignoring reply from modem: '%s'\n", bstart);
             return TRUE;
 	}
     }
@@ -1205,7 +1327,7 @@
     g_string_append( monitor->resp.reply_buffer, bstart );
     g_string_append( monitor->resp.reply_buffer, "\n" );
 
-    DEBUG("Finished handling");
+    CELLMODEM_DEBUG(6, "Finished handling");
     return TRUE;
 }
 
@@ -1235,7 +1357,7 @@
 {
     cellmodem_t *monitor = (cellmodem_t*)data;
     /* Data ready */
-    DEBUG("Data from modem ready, IO cond %d, data %p", c, data);
+    CELLMODEM_DEBUG(9, "Data from modem ready, IO cond %d, data %p", c, data);
     gsize length;
     GError *error = NULL;
     GIOStatus status;
@@ -1243,11 +1365,11 @@
 
     if ( chan == NULL )
     {
-	DEBUG("NULL channel!!!");
+		CELLMODEM_DEBUG(2,"NULL channel!!!");
         return FALSE;
     }
 
-    DEBUG("Line buffer size before reading: %d", monitor->line_buffer_size);
+    CELLMODEM_DEBUG(9,"Line buffer size before reading: %d", monitor->line_buffer_size);
 
 
     status = g_io_channel_read_chars(
@@ -1263,7 +1385,7 @@
     }
 
     if (status != G_IO_STATUS_NORMAL ) {
-	DEBUG("Error reading from modem");
+	CELLMODEM_DEBUG(1,"Error reading from modem");
         cellmodem_t_switch_to_error( monitor, _("Error reading from modem") );
 	cellmodem_t_close_modem( monitor /*, TRUE*/ );
 	return FALSE;
@@ -1273,26 +1395,26 @@
     monitor->line_buffer_size+=length;
     monitor->line_buffer[ monitor->line_buffer_size ] = 0;
 
-    DEBUG("Read %d bytes from modem: '%s'", length, monitor->line_buffer);
-    DEBUG("Buffer size now %d", monitor->line_buffer_size );
+    CELLMODEM_DEBUG(9,"Read %d bytes from modem: '%s'", length, monitor->line_buffer);
+    CELLMODEM_DEBUG(9,"Buffer size now %d", monitor->line_buffer_size );
     char *eol;
     do {
 	eol = memchr( monitor->line_buffer, '\n', monitor->line_buffer_size);
-	DEBUG("EOL: from %p -> %p",monitor->line_buffer, eol);
+	CELLMODEM_DEBUG(9,"EOL: from %p -> %p",monitor->line_buffer, eol);
 	if ( eol!=NULL ) {
-            DEBUG("Handling command from modem");
+            CELLMODEM_DEBUG(7,"Handling command from modem");
 	    size_t dist = eol-monitor->line_buffer;
 	    gchar * line = g_strndup( monitor->line_buffer, dist+1 );
 	    line[dist+1]=0;
 	    memmove(monitor->line_buffer, eol+1, (monitor->line_buffer_size)-dist-1 );
 	    monitor->line_buffer_size-=dist+1;
-	    DEBUG("Calling handle response");
+	    CELLMODEM_DEBUG(7,"Calling handle response");
 	    r = cellmodem_t_modem_handle_response( monitor, line );
 	    g_free( line );
 	    if (!r)
 		return r;
 	} else {
-	    DEBUG("No newline in modem reply, waiting");
+	    CELLMODEM_DEBUG(7,"No newline in modem reply, waiting");
 	}
     } while (eol);
     return TRUE;
@@ -1341,13 +1463,13 @@
 				  monitor->lastcmd
 				 ) == FALSE )
     {
-	DEBUG("ERROR Command: '%s'\n", monitor->lastcmd );
+	CELLMODEM_DEBUG(1,"ERROR Command: '%s'\n", monitor->lastcmd );
         cellmodem_t_switch_to_error( monitor, _("Error writing to modem") );
         cellmodem_t_close_modem( monitor /*, TRUE*/ );
         return FALSE;
     }
 
-    DEBUG("Sent command to modem: '%s'\n", monitor->lastcmd);
+    CELLMODEM_DEBUG(7,"Sent command to modem: '%s'\n", monitor->lastcmd);
     
     return TRUE;
 }
@@ -1357,7 +1479,7 @@
 cellmodem_t_at_command_timeout( cellmodem_t *monitor )
 {
     monitor->at_timeout_id = -1;
-    DEBUG("Modem failed to reply");
+    CELLMODEM_DEBUG(1,"Modem failed to reply");
     cellmodem_t_switch_to_error_and_restart( monitor, _("Modem did not reply to command") );
     return FALSE;
 }
@@ -1406,7 +1528,7 @@
 static gboolean
 reschedule_open( cellmodem_t *monitor /*, gboolean failure*/ )
 {
-    DEBUG("RESCHEDULING OPEN");
+    CELLMODEM_DEBUG(7,"RESCHEDULING OPEN");
     cellmodem_t_close_modem( monitor /*, failure*/ );
 
     if ( monitor->info_timeout_id > 0 )
@@ -1429,14 +1551,14 @@
 static gboolean
 get_network_info( cellmodem_t *monitor )
 {
-    DEBUG("Getting network info");
+    CELLMODEM_DEBUG(5, "Getting network info");
     if ( cellmodem_t_open_modem( monitor ) != FALSE ) {
         /* Check PIN first. Some modems reply error in registry check */
         /* cellmodem_t_is_registered( monitor ); */
         cellmodem_t_get_pin_status( monitor );
         return FALSE; /* Dont restart timer. */
     }
-    DEBUG("Cannot open modem");
+    CELLMODEM_DEBUG(1,"Cannot open modem");
 
     cellmodem_t_switch_to_error_and_restart( monitor, _("Cannot open modem") );
 
@@ -1456,7 +1578,7 @@
     XfceRc *rc;
 
     if (!(file = xfce_panel_plugin_lookup_rc_file (plugin))) {
-	DEBUG("No config file found\n");
+	CELLMODEM_DEBUG(1,"No config file found\n");
 	return;
     }
 
@@ -1464,7 +1586,7 @@
     g_free (file);
 
     if (!rc) {
-	DEBUG("Cannot open config file\n");
+	CELLMODEM_DEBUG(1,"Cannot open config file\n");
 
 	return;
     }
@@ -1499,6 +1621,8 @@
     monitor->options.critical_threshold = xfce_rc_read_int_entry( rc, "critical_threshold", 20 );
     monitor->options.max_quality = xfce_rc_read_int_entry( rc, "max_quality", MAX_QUAL );
     monitor->options.speed = xfce_rc_read_int_entry( rc, "speed", B230400 );
+	monitor->options.check_for_sms = xfce_rc_read_bool_entry (rc, "check_for_sms", FALSE);
+	monitor->options.sms_check_interval = xfce_rc_read_int_entry (rc, "sms_check_interval", 10);
 
 
     xfce_rc_close (rc);
@@ -1512,10 +1636,10 @@
     XfceRc *rc;
     char *file;
 
-    DEBUG("Saving configuration");
+    CELLMODEM_DEBUG(7, "Saving configuration");
 
     if (!(file = xfce_panel_plugin_save_location (plugin, TRUE))) {
-        DEBUG("Cannot save configuration!");
+        CELLMODEM_DEBUG(1,"Cannot save configuration!");
 	return;
     }
     
@@ -1524,7 +1648,7 @@
 
 
     if (!rc) {
-        DEBUG("Cannot open configuration file to save!");
+        CELLMODEM_DEBUG(1,"Cannot open configuration file to save!");
 	return;
     }
     
@@ -1540,8 +1664,10 @@
     xfce_rc_write_int_entry( rc, "critical_threshold", monitor->options.critical_threshold );
     xfce_rc_write_int_entry( rc, "max_quality", monitor->options.max_quality );
     xfce_rc_write_int_entry( rc, "speed", monitor->options.speed );
+    xfce_rc_write_bool_entry( rc, "check_for_sms",monitor->options.check_for_sms );
+    xfce_rc_write_int_entry( rc, "sms_check_interval", monitor->options.sms_check_interval );
 
-    DEBUG("Done saving configuration");
+    CELLMODEM_DEBUG(7, "Done saving configuration");
     xfce_rc_close (rc);
 }
 
@@ -1549,7 +1675,7 @@
 void
 cellmodem_t_initialize_modem( cellmodem_t *monitor )
 {
-    DEBUG(" ---- Initializing modem ---- ");
+    CELLMODEM_DEBUG(3," ---- Initializing modem ---- ");
 
     cellmodem_t_switch_to_error( monitor, _("Modem initializing") );
 
@@ -1566,39 +1692,39 @@
     }
 
     if ( monitor->options.modem_driver == NULL ) {
-        DEBUG("No driver defined, skipping");
+        CELLMODEM_DEBUG(1,"No driver defined, skipping");
 	return;
     }
 
     /* TODO: Skip if we already have this driver loaded */
 
     if ( monitor->driver != NULL && monitor->modem_instance != NULL ) {
-        DEBUG("Closing already created driver/instance");
+        CELLMODEM_DEBUG(1,"Closing already created driver/instance");
 	monitor->driver->close( monitor->modem_instance );
-        DEBUG("Destroying the modem instance");
+        CELLMODEM_DEBUG(1,"Destroying the modem instance");
 	monitor->driver->destroy( monitor->modem_instance );
         monitor->modem_instance = NULL;
     }
 
     monitor->driver = NULL;
-    DEBUG("Locating driver");
+    CELLMODEM_DEBUG(7,"Locating driver");
     monitor->driver = find_driver_by_name( monitor->options.modem_driver );
 
     if (monitor->driver==NULL) {
-	DEBUG("Cannot find that driver (%s)!!!", monitor->options.modem_driver);
+	CELLMODEM_DEBUG(0,"Cannot find that driver (%s)!!!", monitor->options.modem_driver);
 	cellmodem_t_switch_to_error( monitor, _("Invalid driver specified") );
 	return;
     }
 
-    DEBUG("Modem driver at %p", monitor->driver);
+    CELLMODEM_DEBUG(9,"Modem driver at %p", monitor->driver);
     monitor->modem_instance =
 	monitor->driver->create();
 
-    DEBUG("Modem instance created");
+    CELLMODEM_DEBUG(7,"Modem instance created");
 
     cellmodem_t_switch_status( monitor, MODEM_WAIT_CREG_RESPONSE );
 
-    DEBUG("Calling get network info");
+    CELLMODEM_DEBUG(6,"Calling get network info");
 
     get_network_info(monitor);
 }
@@ -1623,7 +1749,7 @@
 int init_logging()
 {
     openlog("cellmodem", LOG_PID, LOG_USER );
-
+    cellmodem_log_level = 9;
     return 0;
 }
 
@@ -1641,10 +1767,10 @@
     init_logging();
 #endif
 
-    DEBUG("Creating applet\n");
+    CELLMODEM_DEBUG(2,"Creating applet\n");
     monitor = cellmodem_t_new (plugin);
 
-    DEBUG("Reading config\n");
+    CELLMODEM_DEBUG(8,"Reading config\n");
     cellmodem_read_config (plugin, monitor);
     cellmodem_t_initialize_modem( monitor );
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem.h	2007-04-05 18:49:52 UTC (rev 2669)
@@ -41,8 +41,8 @@
 #include <syslog.h>
 
 extern int init_logging();
-extern char logbuf[8192];
-extern int debug_level;
+extern char cellmodem_logbuf[8192];
+extern int cellmodem_debug_level;
 
 #endif
 
@@ -53,16 +53,16 @@
 
 
 #ifdef DEBUG_ENABLED
-#define DEBUG(dl, x...) do { \
-	if ( dl >= debug_level ) { \
-	char *tmp=logbuf; tmp+=sprintf(logbuf,"%s [%d] : ", __FUNCTION__, __LINE__); \
+#define CELLMODEM_DEBUG(dl, x...) do { \
+	if ( dl <= cellmodem_debug_level ) { \
+	char *tmp=cellmodem_logbuf; tmp+=sprintf(logbuf,"%s [%d] : ", __FUNCTION__, __LINE__); \
     tmp+=sprintf(tmp,x); \
     sprintf(tmp,"\n"); \
-	syslog(LOG_DEBUG, "%s", logbuf ); \
+	syslog(LOG_DEBUG, "%s", cellmodem_logbuf ); \
 	}\
     } while (0)
 #else
-#define DEBUG(x...)
+#define CELLMODEM_DEBUG(x...)
 #endif
 
 #define MAX_QUAL 20
@@ -70,19 +70,7 @@
 
 typedef void (*modem_reply_callback_t)( gboolean success, GString *response, void  *pvt);
 
-#if 0
-
 typedef enum {
-    MODEM_OFFLINE,
-    MODEM_IDLE,
-    MODEM_CLOSED,
-    MODEM_ERROR
-} modem_status_t;
-
-#endif
-
-
-typedef enum {
     MODEM_ERROR,
     MODEM_WAIT_CPIN_RESPONSE,
     MODEM_WAIT_CREG_RESPONSE,
@@ -91,6 +79,8 @@
     MODEM_WAIT_REGISTRATION,
     MODEM_WAIT_PINE_RESPONSE,
     MODEM_WAIT_OHCIP_RESPONSE,
+    MODEM_WAIT_CMGF_RESPONSE,
+    MODEM_WAIT_SET_CMGF_RESPONSE,
     MODEM_CLOSED
 } modem_status_t;
 
@@ -144,8 +134,13 @@
     /* Network information */
     gchar *network;
     /* Last error we got */
-    gchar *lasterror;
+	gchar *lasterror;
 
+	/* Set to true if modem does not support SMS */
+	gboolean no_sms_support;
+	guint sms_read_messages;
+	guint sms_unread_messages;
+
     modem_response_data_t resp;
 
     gint info_timeout_id;

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/cellmodem_options.h	2007-04-05 18:49:52 UTC (rev 2669)
@@ -24,15 +24,17 @@
 
 typedef struct
 {
-    gboolean  display_tooltip_info;
-    gchar     *modem_device;
-    gchar     *modem_driver;
-    gchar     *ppp_peer;
-/*    gboolean  ask_for_pin;*/
-    gint      low_threshold;
-    gint      critical_threshold;
-    gint      max_quality;
+	gboolean  display_tooltip_info;
+	gchar     *modem_device;
+	gchar     *modem_driver;
+	gchar     *ppp_peer;
+	/*    gboolean  ask_for_pin;*/
+	gint      low_threshold;
+	gint      critical_threshold;
+	gint      max_quality;
 	speed_t   speed;
+	gboolean  check_for_sms;
+	guint     sms_check_interval;
 } cellmodem_options_t;
 
 #endif

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_fake.c	2007-04-05 18:49:52 UTC (rev 2669)
@@ -33,7 +33,7 @@
 {
     gsize written;
     GError *error = NULL;
-    DEBUG("Sending modem reply: %s", modem->reply->str );
+    CELLMODEM_DEBUG(8,"Sending modem reply: %s", modem->reply->str );
     if ( g_io_channel_write_chars( modem->channel,
 				  modem->reply->str,
 				  strlen(modem->reply->str),
@@ -42,7 +42,7 @@
 				 ) != G_IO_STATUS_NORMAL )
     {
 	/* Close channel */
-        DEBUG("Error writing response, closing modem channel");
+        CELLMODEM_DEBUG(1,"Error writing response, closing modem channel");
 	g_io_channel_unref( modem->channel );
         modem->channel = NULL;
 	return FALSE;
@@ -83,24 +83,24 @@
     const char *cmd;
 
     if ( strlen( data ) < 3 ) {
-        DEBUG("Short command");
+        CELLMODEM_DEBUG(1,"Short command");
         return queue_reply(modem);  /* Not AT command, too short */
     }
 
     if ( ! g_str_has_prefix( data, "AT") ) {
-        DEBUG("Not AT Command");
+        CELLMODEM_DEBUG(1,"Not AT Command");
         return queue_reply(modem); /* Not AT command */
     }
     cmd = data + 2;
 
-    DEBUG("Cmd: %s", cmd );
+    CELLMODEM_DEBUG(7, "Cmd: %s", cmd );
 
     /* Add newlines */
 
     g_string_append(modem->reply,"\r\n");
 
     if ( strncmp( cmd, "+CREG?", 6)==0) {
-	DEBUG("PIN time: %u, this time %u", modem->pin_time, get_current_time() );
+	CELLMODEM_DEBUG(7, "PIN time: %u, this time %u", modem->pin_time, get_current_time() );
 	if ( modem->valid_pin )
 
 	    if (  get_current_time() > modem->pin_time + REGISTRATION_TIME ) {
@@ -165,7 +165,7 @@
     GString *pipename;
     GError *error = NULL;
 
-    DEBUG("Opening fake modem");
+    CELLMODEM_DEBUG(2,"Opening fake modem");
 
     pid_t mypid = getpid();
 
@@ -175,7 +175,7 @@
 
     if ( mkfifo( pipename->str, 0600 ) != 0 )
     {
-        DEBUG("Cannot create pipe!!!");
+        CELLMODEM_DEBUG(1, "Cannot create pipe!!!");
         g_string_free( pipename, TRUE );
         return FALSE;
     }
@@ -184,7 +184,7 @@
 
     if (fd<0) {
 	/* Unlink fifo */
-        DEBUG("Cannot open pipe!!!");
+        CELLMODEM_DEBUG(1,"Cannot open pipe!!!");
 	unlink(pipename->str);
 	g_string_free( pipename, TRUE );
 	return FALSE;
@@ -194,7 +194,7 @@
 
     if ( modem->channel == NULL )
     {
-        DEBUG("Cannot opem modem channel!!!");
+        CELLMODEM_DEBUG(1, "Cannot opem modem channel!!!");
 	while (close( fd )<0 && errno==EINTR );
 	unlink( pipename->str );
 	g_string_free( pipename, TRUE );
@@ -209,7 +209,7 @@
     unlink( pipename->str );  /* Not needed any more. The inode will stay there */
     g_string_free( pipename, TRUE );
 
-    DEBUG("Modem opened (pipe)");
+    CELLMODEM_DEBUG(1,"Modem opened (pipe)");
 
     return TRUE;
 }
@@ -242,7 +242,7 @@
 
     modem->reply = g_string_new( data ); /* For echoing the command */
 
-    DEBUG("Got command: %s", data );
+    CELLMODEM_DEBUG(1,"Got command: %s", data );
 
     return fake_handle_command( instance , data );
 
@@ -256,7 +256,7 @@
     modem->reader = reader;
     modem->reader_pvt = data;
 
-    DEBUG("Data set to %p", data );
+    CELLMODEM_DEBUG(9,"Data set to %p", data );
 
     return TRUE;
 }

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/modem_driver_generic.c	2007-04-05 18:49:52 UTC (rev 2669)
@@ -27,16 +27,16 @@
     GError *error = NULL;
     struct termios tio;
 
-    DEBUG("Opening modem");
+    CELLMODEM_DEBUG(6,"Opening modem");
     if ( options->modem_device == NULL ) {
-        DEBUG("Modem device is null, returning");
+        CELLMODEM_DEBUG(1,"Modem device is null, returning");
 	return FALSE;
     }
 
 	int fd = open( options->modem_device, O_RDWR|O_EXCL|O_NOCTTY);
 
     if (fd<0) {
-        DEBUG("Cannot open modem!!!");
+        CELLMODEM_DEBUG(1,"Cannot open modem!!!");
 	return FALSE;
     }
 
@@ -53,7 +53,7 @@
 
     if ( modem->channel == NULL )
     {
-        DEBUG("Cannot opem modem channel!!!");
+        CELLMODEM_DEBUG(1,"Cannot opem modem channel!!!");
 	while (close( fd )<0 && errno==EINTR );
 	return FALSE;
     }
@@ -63,7 +63,7 @@
 
     g_io_channel_set_close_on_unref( modem->channel, TRUE );
 
-    DEBUG("Modem successfully opened");
+    CELLMODEM_DEBUG(6, "Modem successfully opened");
 
     return TRUE;
 }
@@ -83,7 +83,7 @@
 {
     struct generic_modem_t *modem = (struct generic_modem_t*)instance;
 
-    DEBUG("Closing modem");
+    CELLMODEM_DEBUG(6,"Closing modem");
 
     if ( modem == NULL ) {
 	return;
@@ -93,11 +93,11 @@
 	    g_source_remove( modem->reader );
             modem->reader = -1;
 	}
-        DEBUG( "Closing channel %p", modem->channel );
+        CELLMODEM_DEBUG(9, "Closing channel %p", modem->channel );
 	g_io_channel_unref( modem->channel );
         modem->channel = NULL;
     }
-    DEBUG("all done");
+    CELLMODEM_DEBUG(9,"all done");
 }
 
 static gboolean generic_writeln( modem_instance_t instance, const gchar *data )
@@ -110,12 +110,12 @@
     GIOStatus status;
 
     if (modem==NULL) {
-	DEBUG("Null modem instance!");
+	CELLMODEM_DEBUG(1,"Null modem instance!");
         return FALSE;
     }
 
     if (modem->channel==NULL) {
-	DEBUG("Null modem channel!");
+	CELLMODEM_DEBUG(1,"Null modem channel!");
         return FALSE;
     }
 
@@ -124,7 +124,7 @@
     bytes_to_write = strlen( g->str );
     written = 0;
 
-    DEBUG("Writing command to modem, size %d", bytes_to_write);
+    CELLMODEM_DEBUG(8,"Writing command to modem, size %d", bytes_to_write);
 
     do {
 	status = g_io_channel_write_chars( modem->channel,
@@ -133,7 +133,7 @@
 					  &bw,
 					  &error
 					 );
-	DEBUG("Write status: %d, written %d", status, bw);
+	CELLMODEM_DEBUG(9,"Write status: %d, written %d", status, bw);
 	if ( status == G_IO_STATUS_AGAIN ) {
             usleep(10000);
             error = NULL;
@@ -153,9 +153,9 @@
 
 	/* Close channel */
 
-	DEBUG("Error writing ro modem, closing modem channel");
+	CELLMODEM_DEBUG(1,"Error writing ro modem, closing modem channel");
 	if (error && error->message ) {
-	    DEBUG("Error message: '%s'", error->message );
+	    CELLMODEM_DEBUG(1,"Error message: '%s'", error->message );
 	}
 
         g_string_free( g, TRUE );
@@ -209,7 +209,7 @@
 
 static void generic_destroy( modem_instance_t modem )
 {
-    DEBUG("Destroying instance %p", modem);
+    CELLMODEM_DEBUG(8,"Destroying instance %p", modem);
     g_free( modem );
 }
 

Modified: xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c
===================================================================
--- xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.c	2007-04-05 18:49:52 UTC (rev 2669)
@@ -60,13 +60,13 @@
     /* Set default driver if none is still defined */
 
 
-    DEBUG("Got dialog response");
+    CELLMODEM_DEBUG(9,"Got dialog response");
 
 
     if (monitor->options.modem_driver == NULL) {
 	monitor->options.modem_driver =
 	    g_strdup( find_driver_by_index( 0 )->name );
-	DEBUG("Setting driver to default entry ('%s')",
+	CELLMODEM_DEBUG(9,"Setting driver to default entry ('%s')",
               monitor->options.modem_driver );
     }
 
@@ -121,11 +121,15 @@
 			      monitor->options.critical_threshold);
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->maxqual_entry),
 			      monitor->options.max_quality);
+    gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->sms_check_interval_entry),
+			      monitor->options.sms_check_interval);
 
-    /*
-     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->ask_pin_entry),
-				 monitor->options.ask_for_pin);
-    */
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->check_sms_entry),
+								 monitor->options.check_for_sms);
+
+	if (! monitor->options.check_for_sms ) {
+        gtk_widget_set_sensitive( GTK_WIDGET(dialog->sms_check_interval_entry), FALSE );
+	}
 }
 
 
@@ -142,7 +146,7 @@
 
     if ( text && strlen( text ) > 0 ) {
 	dialog->monitor->options.modem_device = g_strdup( text );
-	DEBUG("Modem device: '%s'", text);
+	CELLMODEM_DEBUG(9,"Modem device: '%s'", text);
     }
 }
 
@@ -191,7 +195,7 @@
 {
     dialog->monitor->options.max_quality =
 	gtk_spin_button_get_value_as_int( button );
-    DEBUG("Max qual: %d",
+    CELLMODEM_DEBUG(9,"Max qual: %d",
 	  dialog->monitor->options.max_quality);
 }
 
@@ -210,6 +214,20 @@
 }
 
 static void
+cb_sms_check_interval_entry_changed(GtkSpinButton *button, cellmodem_dialog_t *dialog)
+{
+    dialog->monitor->options.sms_check_interval =
+        gtk_spin_button_get_value_as_int( button );
+}
+
+static void
+cb_check_sms_entry_toggled(GtkCheckButton *button, cellmodem_dialog_t *dialog)
+{
+    dialog->monitor->options.check_for_sms = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(button) );
+	gtk_widget_set_sensitive( GTK_WIDGET(dialog->sms_check_interval_entry), dialog->monitor->options.check_for_sms );
+}
+
+static void
 autodetect_dialog_callback( GtkDialog *dlg, int response, cellmodem_dialog_t *dialog )
 {
 
@@ -258,7 +276,7 @@
 
     dialog->device_combo = NULL;
 
-    DEBUG("Getting devices");
+    CELLMODEM_DEBUG(8,"Getting devices");
 
     dialog->devices = detect_devices();
 
@@ -266,7 +284,7 @@
 
     gtk_dialog_add_button( GTK_DIALOG( dialog->autodetect_dialog), _("Close"), GTK_RESPONSE_CLOSE);
 
-    DEBUG("Parsing devices");
+    CELLMODEM_DEBUG(8,"Parsing devices");
 
     if ( g_list_length( dialog->devices ) == 0 ) {
 	label = gtk_label_new(_("No known device found.") );
@@ -455,24 +473,24 @@
 
 
     /* Toggle buttons. */
-    /*
 
     MAKEHBOX( hbox );
 
-    vbox2 = gtk_vbox_new(FALSE, 0);
-    gtk_widget_show(vbox2);
-    gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
+	dialog->check_sms_entry = gtk_check_button_new_with_mnemonic( _("Check for SMS every") );
+	dialog->sms_check_interval_entry = gtk_spin_button_new_with_range( 0, 100,1 );
+	label = gtk_label_new(_("minutes"));
 
+	gtk_box_pack_start( GTK_BOX(hbox), dialog->check_sms_entry, 0, FALSE, FALSE );
+	gtk_box_pack_start( GTK_BOX(hbox), dialog->sms_check_interval_entry, 0, FALSE, FALSE );
+    gtk_box_pack_start( GTK_BOX(hbox), label, 0, FALSE, FALSE );
+	gtk_widget_show( dialog->check_sms_entry );
+	gtk_widget_show( dialog->sms_check_interval_entry );
+    gtk_widget_show( label );
 
-     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->check_sms_entry, "toggled", G_CALLBACK(cb_check_sms_entry_toggled), dialog);
+    g_signal_connect(dialog->sms_check_interval_entry, "value-changed", G_CALLBACK(cb_sms_check_interval_entry_changed), dialog);
 
-    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	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/panel-plugin/preferences.h	2007-04-05 18:49:52 UTC (rev 2669)
@@ -31,7 +31,9 @@
     GtkWidget *maxqual_entry;
     GtkWidget *autodetect_dialog;
     GtkWidget *device_combo;
-    GtkWidget *speed_entry;
+	GtkWidget *speed_entry;
+	GtkWidget *check_sms_entry;
+	GtkWidget *sms_check_interval_entry;
 	cellmodem_t *monitor;
 
 	GList *devices;

Modified: xfce4-cellmodem-plugin/trunk/po/ChangeLog
===================================================================
--- xfce4-cellmodem-plugin/trunk/po/ChangeLog	2007-04-05 18:48:34 UTC (rev 2668)
+++ xfce4-cellmodem-plugin/trunk/po/ChangeLog	2007-04-05 18:49:52 UTC (rev 2669)
@@ -1,3 +1,7 @@
+2007-04-03  Álvaro Lopes <alvieboy at alvie.com>
+	* de.po: Added german translation by
+        Tobias Kral 
+
 2007-04-01  Maximilian Schleiss <maxschleiss at bluewin.ch>
 
 	* pl.po: Added the Polish translation
@@ -5,7 +9,7 @@
 
 2007-03-31  Pau Rul-lan Ferragut <paurullan at bulma.net>
 
-  * gb.po: British translation by Jeff Bailes <thepizzaking at gmail.com>
+  	* gb.po: British translation by Jeff Bailes <thepizzaking at gmail.com>
 
 2007-03-13  Maxim Dziumanenko <dziumanenko at gmail.com>
 




More information about the Goodies-commits mailing list