[prev in list] [next in list] [prev in thread] [next in thread] 

List:       moblin-commits
Subject:    [Moblin-Commits] moblin-settings: Changes to 'master'
From:       tebrandt () moblin ! org (Todd E Brandt)
Date:       2008-06-27 20:37:34
Message-ID: 20080627203734.AEC8A92C1A4 () moblin ! org
[Download RAW message or body]

This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 ChangeLog                                        |    6 +
 moblin-system-daemon/battery/battery.c           |    2 +-
 moblin-system-daemon/lcdbacklight/lcdbacklight.c |   28 +++-
 moblin-system-daemon/moblin-system-tool.c        |   21 ++-
 moblin-system-daemon/sound/sound.c               |  204 ++++++++++++++++------
 moblin-system-daemon/touchscreen/calibrator.c    |   41 ++++-
 6 files changed, 226 insertions(+), 76 deletions(-)

New commits:
commit 22319739ac25a70b534c4437098790c4a6e6f0c5
Author: Todd Brandt <todd.e.brandt@intel.com>
Date:   Fri Jun 27 13:35:01 2008 -0700

    added error interface


Diff in this email is a maximum of 400 lines.
diff --git a/ChangeLog b/ChangeLog
index be52e34..fc7db51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+moblin-settings (2.06)
+
+  * Added error support for the API functions
+
+ -- Todd Brandt <todd.e.brandt@intel.com>  Fri Jun 27 20:33:44 UTC 2008
+
 moblin-settings (2.05)
 
   * Added the Sound Module and API
diff --git a/moblin-system-daemon/battery/battery.c \
b/moblin-system-daemon/battery/battery.c index dcd1d7b..97bd459 100644
--- a/moblin-system-daemon/battery/battery.c
+++ b/moblin-system-daemon/battery/battery.c
@@ -190,7 +190,7 @@ system_daemon_get_battery_status(MoblinSystemServer *server,
 	*ac_attached = bobj.ac_present;
 	*percent_charged = bobj.percent_charged;
 	*seconds_remaining = bobj.seconds_remaining;
-	return bobj.battery_present;
+	return TRUE;
 }
 
 char *
diff --git a/moblin-system-daemon/lcdbacklight/lcdbacklight.c \
b/moblin-system-daemon/lcdbacklight/lcdbacklight.c index e4264c5..31b8586 100644
--- a/moblin-system-daemon/lcdbacklight/lcdbacklight.c
+++ b/moblin-system-daemon/lcdbacklight/lcdbacklight.c
@@ -50,6 +50,14 @@ typedef struct _BrightnessControl {
     void (*brightness_changed_cb)(DBusGProxy*, guint, struct _BrightnessControl*);
 } BrightnessControl;
 
+static GQuark error_quark;
+enum
+{
+	BAD_HAL_CONNECT,
+	HAL_CALL_FAILED,
+	BRIGHTNESS_OUT_OF_RANGE
+};
+
 static BrightnessControl bctl;
 static MoblinSystemServer *svr = NULL;
 
@@ -72,7 +80,8 @@ system_daemon_get_lcdbacklight_brightness(MoblinSystemServer \
*server,  
 	if(bc->proxy == NULL)
 	{
-		PRINTF ("WARNING: not connected\n");
+		g_set_error (error, error_quark, BAD_HAL_CONNECT,
+			_("Bad HAL connection"));
 		return FALSE;
 	}
 
@@ -88,7 +97,9 @@ system_daemon_get_lcdbacklight_brightness(MoblinSystemServer \
                *server,
 		*level = (gint)brightness;
 	} else {
 		/* abort as the DBUS method failed */
-		PRINTF("WARNING: GetBrightness failed!\n");
+		g_set_error (error, error_quark, HAL_CALL_FAILED,
+			_("HAL function call failed"));
+		return FALSE;
 	}
 
 	return ret;
@@ -105,13 +116,14 @@ system_daemon_set_lcdbacklight_brightness(MoblinSystemServer \
*server,  
 	if((level < 0)||(level >= bc->num_levels))
 	{
-		PRINTF ("WARNING: user supplied out of bounds level: %d",
-			level);
+		g_set_error (error, error_quark, BRIGHTNESS_OUT_OF_RANGE,
+			_("Brightness value out of bounds"));
 		return FALSE;
 	}
 	if (bc->proxy == NULL)
 	{
-		PRINTF ("WARNING: not connected");
+		g_set_error (error, error_quark, BAD_HAL_CONNECT,
+			_("Bad HAL connection"));
 		return FALSE;
 	}
 
@@ -120,8 +132,8 @@ system_daemon_set_lcdbacklight_brightness(MoblinSystemServer \
*server,  G_TYPE_INVALID, G_TYPE_INT, &retval, G_TYPE_INVALID);
 
 	if (derror || ret == FALSE) {
-		PRINTF("SetBrighness Failed: %s\n", 
-			  derror ? derror->message : "unknown error");
+		g_set_error (error, error_quark, HAL_CALL_FAILED,
+			_("HAL function call failed"));
 		g_error_free(derror);
 	}
 
@@ -267,6 +279,8 @@ initialize_lcdbacklight(MoblinSystemServer *server)
     bctl.brightness_changed_cb = brightness_changed_cb;
     svr = server;
 
+    error_quark = g_quark_from_string ("moblin-system-daemon-lcdbacklight");
+
     if(!brightness_dbus_connect(server, &bctl))
 	return FALSE;
 
diff --git a/moblin-system-daemon/moblin-system-tool.c \
b/moblin-system-daemon/moblin-system-tool.c index fb6217f..dfc945c 100644
--- a/moblin-system-daemon/moblin-system-tool.c
+++ b/moblin-system-daemon/moblin-system-tool.c
@@ -105,14 +105,31 @@ int main(int argc, char *argv[])
 
 	if(argc < 2)
 	{
-		printf("Usage: %s <cmd> <arg>\n", argv[0]);
+		printf("Usage: %s <cmd> <args>\n", argv[0]);
 		printf("Commands:\n");
 		printf("\tget_time\n");
 		printf("\tget_timezone\n");
-		printf("\tset_time MM/DD/YYYY_hh:mm:ss\n");
+		printf("\tset_time <MM/DD/YYYY_hh:mm:ss>\n");
 		printf("\tcapture_touch\n");
 		printf("\tread_calibration\n");
 		printf("\tget_battery_status\n");
+                printf("\tsound_num_elements\n");
+                printf("\tsound_num_channels <elemidx>\n");
+                printf("\tsound_element_name <elemidx>\n");
+                printf("\tsound_channel_name <elemidx> <chanidx>\n");
+                printf("\tsound_volume_range <elemidx>\n");
+                printf("\tsound_get_volume <elemidx> <chanidx>\n");
+                printf("\tsound_set_volume <elemidx> <chanidx> <vol>\n");
+                printf("\tsound_set_element_volume <elemidx> <vol>\n");
+                printf("\tsound_get_mute <elemidx> <chanidx>\n");
+                printf("\tsound_set_mute <elemidx> <chanidx> <0or1>\n");
+                printf("\tsound_set_element_mute <elemidx> <0or1>\n");
+                printf("\tsound_set_all_mute <0or1>\n");
+                printf("\tsound_get_playback_master\n");
+                printf("\tsound_set_playback_master <elemidx>\n");
+                printf("\tsound_get_record_master\n");
+                printf("\tsound_set_record_master <elemidx>\n");
+                printf("\tsound_capabilities <elemidx>\n");
 		return 0;
 	}
 
diff --git a/moblin-system-daemon/sound/sound.c b/moblin-system-daemon/sound/sound.c
index fd012be..981e41d 100644
--- a/moblin-system-daemon/sound/sound.c
+++ b/moblin-system-daemon/sound/sound.c
@@ -64,6 +64,15 @@ struct ptrack {
 	int *channels;
 };
 
+static GQuark error_quark;
+enum
+{
+	INVALID_ELEMENT_IDX,
+	INVALID_CHANNEL_IDX,
+	ELEMENT_HAS_NO_VOLUME,
+	ELEMENT_HAS_NO_MUTE
+};
+
 static struct snd_mixer_selem_regopt smixer_options;
 static char card[64] = "default";
 
@@ -95,7 +104,11 @@ system_daemon_sound_num_channels(
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
 	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
+	}
 
 	if(num_channels) *num_channels = t->num_channels;
 	return TRUE;
@@ -118,8 +131,11 @@ system_daemon_sound_set_playback_master(
         GError **error)
 {
 	if((e < 0)||(e >= ptnum))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
-
+	}
 	playback_master = e;
 	return TRUE;
 }
@@ -141,8 +157,11 @@ system_daemon_sound_set_record_master(
         GError **error)
 {
 	if((e < 0)||(e >= ptnum))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
-
+	}
 	record_master = e;
 	return TRUE;
 }
@@ -158,9 +177,12 @@ system_daemon_sound_element_name(
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
 	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
-
-	if(name) *name = t->name;
+	}
+	if(name) *name = g_strdup(t->name);
 	return TRUE;
 }
 
@@ -175,11 +197,19 @@ system_daemon_sound_channel_name(
 	struct ptrack *t;
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
-	    ((t=&ptlist[e]) == NULL)||(c < 0)||
-	    (c >= t->num_channels))
+	    ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
-
-	if(name) *name = (gchar *)snd_mixer_selem_channel_name(t->channels[c]);
+	}
+	if((c < 0)||(c >= t->num_channels))
+	{
+		g_set_error (error, error_quark, INVALID_CHANNEL_IDX,
+			_("Channel index is out of range"));
+		return FALSE;
+	}
+	if(name) *name = g_strdup(snd_mixer_selem_channel_name(t->channels[c]));
 	return TRUE;
 }
 
@@ -194,9 +224,18 @@ system_daemon_sound_volume_range(
 	struct ptrack *t;
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
-	  ((t=&ptlist[e]) == NULL)||!t->has_vol_ctl)
+	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
-
+	}
+	if(!t->has_vol_ctl)
+	{
+		g_set_error (error, error_quark, ELEMENT_HAS_NO_VOLUME,
+			_("Element has no volume control"));
+		return FALSE;
+	}
 	if(min) *min = t->vmin;
 	if(max) *max = t->vmax;
 
@@ -216,7 +255,11 @@ system_daemon_sound_capabilities(
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
 	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
+	}
 
 	if(volume) *volume = (t->has_vol_ctl)?TRUE:FALSE;
 	if(mute) *mute = (t->has_switch_ctl)?TRUE:FALSE;
@@ -242,9 +285,24 @@ system_daemon_sound_get_volume(
 	struct ptrack *t;
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
-	    ((t=&ptlist[e]) == NULL)||(c < 0)||
-	    !t->has_vol_ctl||(c >= t->num_channels))
+	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
+		return FALSE;
+	}
+	if((c < 0)||(c >= t->num_channels))
+	{
+		g_set_error (error, error_quark, INVALID_CHANNEL_IDX,
+			_("Channel index is out of range"));
+		return FALSE;
+	}
+	if(!t->has_vol_ctl)
+	{
+		g_set_error (error, error_quark, ELEMENT_HAS_NO_VOLUME,
+			_("Element has no volume control"));
 		return FALSE;
+	}
 
 	if(t->has_vol_ctl == ELEM_CAPTURE) {
 	    snd_mixer_selem_get_capture_volume(t->elem,
@@ -253,12 +311,6 @@ system_daemon_sound_get_volume(
 	    snd_mixer_selem_get_playback_volume(t->elem,
 		t->channels[c], (long *)volume);
 	}
-#if 0
-	PRINTF("get vol %s: %s=%d\n", 
-		t->name,
-		snd_mixer_selem_channel_name(t->channels[c]),
-		*volume);
-#endif
 
 	return TRUE;
 }
@@ -274,9 +326,24 @@ system_daemon_sound_set_volume(
 	struct ptrack *t;
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
-	    ((t=&ptlist[e]) == NULL)||(c < 0)||
-	    !t->has_vol_ctl||(c >= t->num_channels))
+	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
+		return FALSE;
+	}
+	if((c < 0)||(c >= t->num_channels))
+	{
+		g_set_error (error, error_quark, INVALID_CHANNEL_IDX,
+			_("Channel index is out of range"));
 		return FALSE;
+	}
+	if(!t->has_vol_ctl)
+	{
+		g_set_error (error, error_quark, ELEMENT_HAS_NO_VOLUME,
+			_("Element has no volume control"));
+		return FALSE;
+	}
 
 	if(t->has_vol_ctl == ELEM_CAPTURE) {
 	    snd_mixer_selem_set_capture_volume(t->elem,
@@ -285,12 +352,6 @@ system_daemon_sound_set_volume(
 	    snd_mixer_selem_set_playback_volume(t->elem,
 		t->channels[c], volume);
 	}
-#if 0
-	PRINTF("set vol %s: %s=%d\n", 
-		t->name,
-		snd_mixer_selem_channel_name(t->channels[c]),
-		volume);
-#endif
 
 	return TRUE;
 }
@@ -305,19 +366,24 @@ system_daemon_sound_set_element_volume(
 	struct ptrack *t;
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
-	    ((t=&ptlist[e]) == NULL)||!t->has_vol_ctl)
+	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
 		return FALSE;
+	}
+	if(!t->has_vol_ctl)
+	{
+		g_set_error (error, error_quark, ELEMENT_HAS_NO_VOLUME,
+			_("Element has no volume control"));
+		return FALSE;
+	}
 
 	if(t->has_vol_ctl == ELEM_CAPTURE) {
 	    snd_mixer_selem_set_capture_volume_all(t->elem, volume);
 	} else {
 	    snd_mixer_selem_set_playback_volume_all(t->elem, volume);
 	}
-#if 0
-	PRINTF("set all vol %s: %d\n", 
-		t->name,
-		volume);
-#endif
 
 	return TRUE;
 }
@@ -334,9 +400,24 @@ system_daemon_sound_get_mute(
 	int val = 0;
 
 	if((e < 0)||(e >= ptnum)||!ptlist||!init||
-	    ((t=&ptlist[e]) == NULL)||(c < 0)||
-	    !t->has_switch_ctl||(c >= t->num_channels))
+	  ((t=&ptlist[e]) == NULL))
+	{
+		g_set_error (error, error_quark, INVALID_ELEMENT_IDX,
+			_("Element index is out of range"));
+		return FALSE;
+	}
+	if((c < 0)||(c >= t->num_channels))
+	{
+		g_set_error (error, error_quark, INVALID_CHANNEL_IDX,
+			_("Channel index is out of range"));
_______________________________________________
Commits mailing list
Commits@moblin.org
https://www.moblin.org/mailman/listinfo/commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic