[PATCH 1/1] Allow builds to install the test scripts for debugging

2009-12-03 Thread Martin Xu
---
 Makefile.am |9 +++--
 bootstrap-configure |1 +
 configure.ac|4 
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4b0d7e8..2a140c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -231,7 +231,7 @@ doc_files = doc/overview.txt doc/ofono-paper.txt \
doc/call-meter-api.txt \
doc/dataconnectionmanager-api.txt
 
-test_files = test/test-manager test/test-modem test/test-voicecall \
+test_scripts = test/test-manager test/test-modem test/test-voicecall \
test/test-network-registration test/test-phonebook \
test/test-advice-of-charge test/test-call-settings \
test/test-call-forwarding test/test-call-barring \
@@ -244,10 +244,15 @@ test_files = test/test-manager test/test-modem 
test/test-voicecall \
test/activate-context test/deactivate-context \
test/process-context-settings
 
+if TEST
+testdir = $(pkglibdir)/test
+test_SCRIPTS = $(test_scripts)
+endif
+
 conf_files = src/ofono.conf plugins/modem.conf
 
 EXTRA_DIST = src/genbuiltin plugins/example_history.c $(doc_files) \
-   $(test_files) $(conf_files) $(udev_files)
+   $(test_scripts) $(conf_files) $(udev_files)
 
 dist_man_MANS = doc/ofonod.8
 
diff --git a/bootstrap-configure b/bootstrap-configure
index 63a689a..f665943 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -7,6 +7,7 @@ fi
 ./bootstrap  \
 ./configure --enable-maintainer-mode \
--enable-debug \
+   --enable-test \
--prefix=/usr \
--mandir=/usr/share/man \
--sysconfdir=/etc \
diff --git a/configure.ac b/configure.ac
index 5c2255a..a3b7d75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,10 @@ AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
fi
 ])
 
+AC_ARG_ENABLE(test, AC_HELP_STRING([--enable-test],
+   [enable test/example scripts]), [enable_test=${enableval}])
+AM_CONDITIONAL(TEST, test ${enable_test} = yes)
+
 AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
[enable position independent executables flag]), [
if (test ${enableval} = yes 
-- 
1.6.1.3

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH */1] Allow builds to install the test scripts for debugging

2009-12-03 Thread Xu, Martin
So I can put the test script to a separated Moblin RPM package. It is 
convenient for user to debug, and remove the huge Phyton dependency on ofono 
package,  Just like what has been done in ConnMan Moblin RPM package.
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/3] Add hfp_list_calls to get current call list

2009-12-03 Thread Zhenhua Zhang
Use AT+CLCC to get current call list.
---
 drivers/hfpmodem/voicecall.c |   59 +-
 1 files changed, 58 insertions(+), 1 deletions(-)

diff --git a/drivers/hfpmodem/voicecall.c b/drivers/hfpmodem/voicecall.c
index 2cd14b5..ee89ee0 100644
--- a/drivers/hfpmodem/voicecall.c
+++ b/drivers/hfpmodem/voicecall.c
@@ -400,6 +400,63 @@ static void hfp_hangup(struct ofono_voicecall *vc,
hfp_template(AT+CHUP, vc, generic_cb, 0x3f, cb, data);
 }
 
+static void list_calls_callback(gboolean ok, GAtResult *result,
+   gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   struct ofono_voicecall *vc = cbd-user;
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   ofono_call_list_cb_t cb = cbd-cb;
+   GSList *l;
+   struct ofono_call *list;
+   struct ofono_error error;
+   int num;
+
+   dump_response(clcc_poll_cb, ok, result);
+   decode_at_error(error, g_at_result_final_response(result));
+
+   if (!ok)
+   return;
+
+   clcc_poll_cb(ok, result, vc);
+
+   list = g_try_new0(struct ofono_call, g_slist_length(vd-calls));
+
+   if (!list) {
+   CALLBACK_WITH_FAILURE(cb, 0, NULL, cbd-data);
+   return;
+   }
+
+   for (num = 0, l = vd-calls; l; l = l-next, num++)
+   memcpy(list[num], l-data, sizeof(struct ofono_call));
+
+   cb(error, num,  list, cbd-data);
+
+   g_free(list);
+}
+
+static void hfp_list_calls(struct ofono_voicecall *vc, ofono_call_list_cb_t cb,
+   void *data)
+{
+   struct voicecall_data *vd = ofono_voicecall_get_data(vc);
+   struct cb_data *cbd = cb_data_new(cb, data);
+
+   if (!cbd)
+   goto error;
+
+   cbd-user = vc;
+
+   if (g_at_chat_send(vd-chat, AT+CLCC, clcc_prefix,
+   list_calls_callback, cbd, g_free)  0)
+   return;
+
+error:
+   if (cbd)
+   g_free(cbd);
+
+   CALLBACK_WITH_FAILURE(cb, 0, NULL, data);
+}
+
 static void hfp_hold_all_active(struct ofono_voicecall *vc,
ofono_voicecall_cb_t cb, void *data)
 {
@@ -952,7 +1009,7 @@ static struct ofono_voicecall_driver driver = {
.dial   = hfp_dial,
.answer = hfp_answer,
.hangup = hfp_hangup,
-   .list_calls = NULL,
+   .list_calls = hfp_list_calls,
.hold_all_active= hfp_hold_all_active,
.release_all_held   = hfp_release_all_held,
.set_udub   = hfp_set_udub,
-- 
1.6.5.2

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/3] Fix release clcc_source when voicecall driver is removed

2009-12-03 Thread Zhenhua Zhang
Release the timer to avoid invoking the callback function after
voicecall driver is removed.
---
 drivers/atmodem/voicecall.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/voicecall.c b/drivers/atmodem/voicecall.c
index 1f8e0d1..e210454 100644
--- a/drivers/atmodem/voicecall.c
+++ b/drivers/atmodem/voicecall.c
@@ -921,6 +921,9 @@ static void at_voicecall_remove(struct ofono_voicecall *vc)
 {
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
 
+   if (vd-clcc_source)
+   g_source_remove(vd-clcc_source);
+
g_slist_foreach(vd-calls, (GFunc) g_free, NULL);
g_slist_free(vd-calls);
 
-- 
1.6.5.2

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono