[PATCH 1/6] bluetooth: Move functions from hfp.c to bluetooth.c

2010-06-20 Thread Gustavo F. Padovan
The part that call device_properties_cb is commented to permit this patch
compile.
device_properties_cb() will be changed, so it will have separated patch.
---
 plugins/bluetooth.c |  122 +++
 1 files changed, 122 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 0b1b560..e27982b 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -199,6 +199,124 @@ done:
g_slist_free(prop_handlers);
 }
 
+static void parse_string(DBusMessageIter *iter, gpointer user_data)
+{
+   char **str = user_data;
+   int arg_type = dbus_message_iter_get_arg_type(iter);
+
+   if (arg_type != DBUS_TYPE_OBJECT_PATH  arg_type != DBUS_TYPE_STRING)
+   return;
+
+   dbus_message_iter_get_basic(iter, str);
+}
+
+static void parse_devices(DBusMessageIter *array, gpointer user_data)
+{
+   DBusMessageIter value;
+   GSList **device_list = user_data;
+
+   DBG();
+
+   if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+   return;
+
+   dbus_message_iter_recurse(array, value);
+
+   while (dbus_message_iter_get_arg_type(value)
+   == DBUS_TYPE_OBJECT_PATH) {
+   const char *path;
+
+   dbus_message_iter_get_basic(value, path);
+
+   *device_list = g_slist_prepend(*device_list, (gpointer) path);
+
+   dbus_message_iter_next(value);
+   }
+}
+
+static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
+{
+   const char *path = user_data;
+   DBusMessage *reply;
+   GSList *device_list = NULL;
+   GSList *l;
+   const char *addr;
+
+   reply = dbus_pending_call_steal_reply(call);
+
+   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+   DBG(Bluetooth daemon is apparently not available.);
+   goto done;
+   }
+
+   bluetooth_parse_properties(reply, Devices, parse_devices, 
device_list,
+   Address, parse_string, addr, NULL);
+
+   DBG(Adapter Address: %s, Path: %s, addr, path);
+   g_hash_table_insert(adapter_address_hash,
+   g_strdup(path), g_strdup(addr));
+
+   for (l = device_list; l; l = l-next) {
+   /*
+   const char *device = l-data;
+
+   bluetooth_send_with_reply(device, BLUEZ_DEVICE_INTERFACE,
+   GetProperties, device_properties_cb,
+   g_strdup(device), g_free, -1, 
DBUS_TYPE_INVALID);
+   */
+   }
+
+done:
+   g_slist_free(device_list);
+   dbus_message_unref(reply);
+}
+
+static void parse_adapters(DBusMessageIter *array, gpointer user_data)
+{
+   DBusMessageIter value;
+
+   DBG();
+
+   if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+   return;
+
+   dbus_message_iter_recurse(array, value);
+
+   while (dbus_message_iter_get_arg_type(value)
+   == DBUS_TYPE_OBJECT_PATH) {
+   const char *path;
+
+   dbus_message_iter_get_basic(value, path);
+
+   DBG(Calling GetProperties on %s, path);
+
+   bluetooth_send_with_reply(path, BLUEZ_ADAPTER_INTERFACE,
+   GetProperties, adapter_properties_cb,
+   g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
+
+   dbus_message_iter_next(value);
+   }
+}
+
+static void manager_properties_cb(DBusPendingCall *call, gpointer user_data)
+{
+   DBusMessage *reply;
+
+   reply = dbus_pending_call_steal_reply(call);
+
+   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+   DBG(Bluetooth daemon is apparently not available.);
+   goto done;
+   }
+
+   DBG();
+
+   bluetooth_parse_properties(reply, Adapters, parse_adapters, NULL, 
NULL);
+
+done:
+   dbus_message_unref(reply);
+}
+
 int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile 
*profile)
 {
if (uuid_hash)
@@ -215,6 +333,10 @@ int bluetooth_register_uuid(const char *uuid, struct 
bluetooth_profile *profile)
 done:
g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 
+   bluetooth_send_with_reply(/, BLUEZ_MANAGER_INTERFACE, GetProperties,
+   manager_properties_cb, NULL, NULL, -1,
+   DBUS_TYPE_INVALID);
+
return 0;
 }
 
-- 
1.7.1

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


[PATCH 6/6] bluetooth: make bluetooth.c not a plugin

2010-06-20 Thread Gustavo F. Padovan
---
 Makefile.am |7 ---
 plugins/bluetooth.c |2 --
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 96116a5..d51d6db 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,6 +71,9 @@ gatchat_sources = gatchat/gatchat.h gatchat/gatchat.c \
gatchat/ppp_auth.c gatchat/ppp_net.c \
gatchat/ppp_ipcp.c
 
+bluetooth_sources = plugins/bluetooth.c plugins/bluetooth.h
+
+
 udev_files = plugins/ofono.rules
 
 if UDEV
@@ -133,6 +136,7 @@ endif
 if ATMODEM
 builtin_modules += atmodem
 builtin_sources += $(gatchat_sources) \
+   $(bluetooth_sources) \
drivers/atmodem/atmodem.h \
drivers/atmodem/atmodem.c \
drivers/atmodem/call-settings.c \
@@ -238,9 +242,6 @@ builtin_sources += plugins/em770.c
 builtin_modules += novatel
 builtin_sources += plugins/novatel.c
 
-builtin_modules += bluetooth
-builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
-
 builtin_modules += hfp
 builtin_sources += plugins/hfp.c plugins/bluetooth.h
 
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index cb45b3f..12446f7 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -571,5 +571,3 @@ void bluetooth_unregister_uuid(const char *uuid)
uuid_hash = NULL;
 }
 
-OFONO_PLUGIN_DEFINE(bluetooth, Bluetooth Utils Plugins, VERSION,
-   OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
-- 
1.7.1

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


[PATCH 5/6] hfp: use bluetooth helpers and remove similar code.

2010-06-20 Thread Gustavo F. Padovan
---
 plugins/hfp.c |  379 ++---
 1 files changed, 36 insertions(+), 343 deletions(-)

diff --git a/plugins/hfp.c b/plugins/hfp.c
index 3297358..137e948 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -62,8 +62,7 @@ static const char *cmer_prefix[] = { +CMER:, NULL };
 static const char *chld_prefix[] = { +CHLD:, NULL };
 
 static DBusConnection *connection;
-static GHashTable *uuid_hash = NULL;
-static GHashTable *adapter_address_hash;
+static GHashTable *modem_hash = NULL;
 
 static void hfp_debug(const char *str, void *user_data)
 {
@@ -179,17 +178,6 @@ static void cmer_cb(gboolean ok, GAtResult *result, 
gpointer user_data)
sevice_level_conn_established(modem);
 }
 
-static void parse_string(DBusMessageIter *iter, gpointer user_data)
-{
-   char **str = user_data;
-   int arg_type = dbus_message_iter_get_arg_type(iter);
-
-   if (arg_type != DBUS_TYPE_OBJECT_PATH  arg_type != DBUS_TYPE_STRING)
-   return;
-
-   dbus_message_iter_get_basic(iter, str);
-}
-
 static void cind_status_cb(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -409,6 +397,10 @@ static int hfp_create_modem(const char *device, const char 
*dev_addr,
struct hfp_data *data;
char buf[256];
 
+   /* We already have this device in our hash, ignore */
+   if (g_hash_table_lookup(modem_hash, device) != NULL)
+   return -EALREADY;
+
ofono_info(Using device: %s, devaddr: %s, adapter: %s,
device, dev_addr, adapter_addr);
 
@@ -437,7 +429,7 @@ static int hfp_create_modem(const char *device, const char 
*dev_addr,
ofono_modem_set_name(modem, alias);
ofono_modem_register(modem);
 
-   g_hash_table_insert(uuid_hash, g_strdup(device), modem);
+   g_hash_table_insert(modem_hash, g_strdup(device), modem);
 
return 0;
 
@@ -448,292 +440,35 @@ free:
return -ENOMEM;
 }
 
-static void has_hfp_uuid(DBusMessageIter *array, gpointer user_data)
-{
-   gboolean *hfp = user_data;
-   DBusMessageIter value;
-
-   if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
-   return;
-
-   dbus_message_iter_recurse(array, value);
-
-   while (dbus_message_iter_get_arg_type(value) == DBUS_TYPE_STRING) {
-   const char *uuid;
-
-   dbus_message_iter_get_basic(value, uuid);
-
-   if (!strcasecmp(uuid, HFP_AG_UUID)) {
-   *hfp = TRUE;
-   return;
-   }
-
-   dbus_message_iter_next(value);
-   }
-}
-
-static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
-{
-   DBusMessage *reply;
-   char *path = user_data;
-   gboolean have_hfp = FALSE;
-   const char *adapter = NULL;
-   const char *adapter_addr = NULL;
-   const char *device_addr = NULL;
-   const char *alias = NULL;
-
-   reply = dbus_pending_call_steal_reply(call);
-
-   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
-   DBG(Bluetooth daemon is apparently not available.);
-   goto done;
-   }
-
-   if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
-   if (!dbus_message_is_error(reply, DBUS_ERROR_UNKNOWN_METHOD))
-   ofono_info(Error from GetProperties reply: %s,
-   dbus_message_get_error_name(reply));
-
-   goto done;
-   }
-
-   bluetooth_parse_properties(reply, UUIDs, has_hfp_uuid, have_hfp,
-   Adapter, parse_string, adapter,
-   Address, parse_string, device_addr,
-   Alias, parse_string, alias,
-   NULL);
-
-   if (adapter)
-   adapter_addr = g_hash_table_lookup(adapter_address_hash,
-   adapter);
-
-   if (have_hfp  device_addr  adapter_addr)
-   hfp_create_modem(path, device_addr, adapter_addr, alias);
-
-done:
-   dbus_message_unref(reply);
-}
-
-static void parse_devices(DBusMessageIter *array, gpointer user_data)
-{
-   DBusMessageIter value;
-   GSList **device_list = user_data;
-
-   DBG();
-
-   if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
-   return;
-
-   dbus_message_iter_recurse(array, value);
-
-   while (dbus_message_iter_get_arg_type(value)
-   == DBUS_TYPE_OBJECT_PATH) {
-   const char *path;
-
-   dbus_message_iter_get_basic(value, path);
-
-   *device_list = g_slist_prepend(*device_list, (gpointer) path);
-
-   dbus_message_iter_next(value);
-   }
-}
-
-static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
-{
-   const char 

RE: [PATCH 1/5] stk: Add parser for send ussd commands

2010-06-20 Thread Gu, Yang
Hi Denis,



-Original Message-
From: Denis Kenzior [mailto:denk...@gmail.com]
Sent: Saturday, June 19, 2010 3:04 AM
To: ofono@ofono.org
Cc: Gu, Yang
Subject: Re: [PATCH 1/5] stk: Add parser for send ussd commands

Hi Yang,

 ---
  src/stkutil.c |   61
  +
src/stkutil.h |
9 
  2 files changed, 70 insertions(+), 0 deletions(-)

Patches 1, 2 and 5 have been applied.  As discussed previously we're skipping
patches 3 and 4 for now.  Please note that I broke Patch 2 into two patches (1
for decode_ussd in smsutil.[ch] and one for the unit test), but did not do any
modifications beyond that.

Again, please watch out for this.  If your patch touches something in two or
more directories of oFono, please send multiple patches.

Thank you for applying the patches. But I have a question on this: Should we 
keep the code compile-able after each patch? Due to this consideration, I put 
those changes all in patch 2. This would sometimes be helpful when we want to 
investigate a regression after a bunch of patches. If this is not a requirement 
for this project, I will pay more attention on how to split the patches 
reasonably.


Regards,
-Denis


Regards,
-Yang
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/5] stk: Add parser for send ussd commands

2010-06-20 Thread Denis Kenzior
Hi Yang,

 Again, please watch out for this.  If your patch touches something in two
  or more directories of oFono, please send multiple patches.
 
 Thank you for applying the patches. But I have a question on this: Should
  we keep the code compile-able after each patch? Due to this consideration,
  I put those changes all in patch 2. This would sometimes be helpful when
  we want to investigate a regression after a bunch of patches. If this is
  not a requirement for this project, I will pay more attention on how to
  split the patches reasonably.

Keeping the code compilable is always preferable.  For instance, if you're 
adding a function to smsutil to use elsewhere, it is always preferable to have 
a commit with this function and then commit(s) using this function.

However, there are cases when you're moving code around and breaking compile 
in transient commits is unavoidable.  In that case I still prefer clean, 
logical patches.  I will apply them all or not at all, so as long as the code 
compiles  works cleanly afterward, it is fine.

Regards,
-Denis

 
 Regards,
 -Denis
 
 Regards,
 -Yang
 
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] TODO: PPP server support owner

2010-06-20 Thread Zhenhua Zhang
---
 TODO |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO
index 4a12b6f..95a9fcc 100644
--- a/TODO
+++ b/TODO
@@ -220,6 +220,7 @@ GPRS
 
   Priority: High
   Complexity: C2
+  Owner: Zhenhua Zhang zhenhua.zh...@intel.com
 
 - On-demand SOCKS5 proxy support for MMS contexts.  When an MMS context type
   is created, oFono should create a SOCKS5 proxy.  When a client connects to
-- 
1.6.3.3

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


RE: [PATCH 03/11] gatppp: Add PPP server extension

2010-06-20 Thread Zhang, Zhenhua
Hi Denis,

Denis Kenzior wrote:
 Hi Zhenhua,
 
 1. Add interface to set PPP server info by g_at_ppp_set_server_info.
 2. Pass local and peer address through IPCP handshaking.
 ---
 
 Its great that you're working on the PPP Server extensions.
 Can I get you to
 submit a patch taking ownership of this task?  See ofono/TODO 'PPP
 Server support'.
 
 +static void ipcp_generate_peer_config_options(struct ipcp_data
 *ipcp) +{ +  guint16 len = 0;
 +
 +FILL_IP(ipcp-req_options  REQ_OPTION_IPADDR,
 +IP_ADDRESS, ipcp-peer_addr);
 +FILL_IP(ipcp-req_options  REQ_OPTION_DNS1,
 +PRIMARY_DNS_SERVER,
 ipcp-dns1);
 +FILL_IP(ipcp-req_options  REQ_OPTION_DNS2,
 +SECONDARY_DNS_SERVER,
 ipcp-dns2);
 +FILL_IP(ipcp-req_options  REQ_OPTION_NBNS1,
 +PRIMARY_NBNS_SERVER,
 ipcp-nbns1);
 +FILL_IP(ipcp-req_options  REQ_OPTION_NBNS2,
 +SECONDARY_NBNS_SERVER,
 ipcp-nbns2);
 +
 
 Using ipcp-req_options is the wrong thing here.  That is used
 for options
 sent in a Configure-Req.  Here you're filling in options to be
 sent in a
 Configure-Nak, Configure-Reject or a Configure-Ack.  You
 should simply be filling
 these in ipcp_rcr.  Feel free to modify the FILL_IP macro to take an
 additional destination parameter.

Okay. I will do that.

 +ipcp-options_len = len;
 +}
 +
 +void ipcp_set_server_info(struct pppcp_data *pppcp, guint32
 local_addr, +guint32 peer_addr, +
 guint32 dns1, guint32 dns2,
 +guint32 nbns1, guint32 nbns2)
 +{
 +struct ipcp_data *ipcp = pppcp_get_data(pppcp);
 +
 +ipcp-req_options = REQ_OPTION_IPADDR | REQ_OPTION_DNS1 |
 +REQ_OPTION_DNS2 | REQ_OPTION_NBNS1 |
 +REQ_OPTION_NBNS2;
 +
 +ipcp-local_addr = local_addr;
 +ipcp-peer_addr = peer_addr;
 +ipcp-dns1 = dns1;
 +ipcp-dns2 = dns2;
 +ipcp-nbns1 = nbns1;
 +ipcp-nbns2 = nbns2;
 +
 +ipcp_generate_config_options(ipcp);
 
 Please note that this function is currently having no effect,
 you're missing a
 call to pppcp_set_local_options.  However, in the case of a server, we
 actually do not want to request DNS or NBNS, and we should
 only send our local
 address to the peer if it is non-zero.  Please note that all
 PPP modems we
 have encountered so far, do not send their local IP address in
 a Configure-
 Request.  Thus calling ipcp_set_server_info should end up
 generating an empty
 Configure-Request or with only the local IP address present.

It's confused me a little. Please correct me if I am wrong. I think PPP modem 
should send their local IP address to peer in a Configure-Request. So client 
could accept the peer address in ipcp_rcr.

In the case of a server, ipcp_set_server_info() should set local, peer, DNS and 
NBNS info and call pppcp_set_local_options(). And server only send our local 
address to peer in a Configure-Request.

 +}
 +
  static void ipcp_reset_config_options(struct ipcp_data *ipcp)  {
  ipcp-req_options = REQ_OPTION_IPADDR | REQ_OPTION_DNS1 |
  REQ_OPTION_DNS2 | REQ_OPTION_NBNS1 |
  REQ_OPTION_NBNS2;
 -ipcp-ipaddr = 0;
 +ipcp-local_addr = 0;
 
 In the case of a server, the local_address should not be reset.

It seems we need to add a flag in ipcp_data to indicate whether it's server or 
not. Does it make sense?

 +ipcp-peer_addr = 0;
  ipcp-dns1 = 0;
  ipcp-dns2 = 0;
  ipcp-nbns1 = 0;
 @@ -274,11 +321,54 @@ static enum rcr_result ipcp_rcr(struct
  pppcp_data *pppcp, guint8 **new_options, guint16 *new_len)
  {
  struct ppp_option_iter iter;
 +struct ipcp_data *ipcp = pppcp_get_data(pppcp);
 +guint32 peer_addr;
 +guint32 dns1;
 +guint32 dns2;
 
  ppp_option_iter_init(iter, packet);
 
 -if (ppp_option_iter_next(iter) == FALSE)
 -return RCR_ACCEPT;
 
 Again, be careful here.  In the case of a client we should
 only accept the
 Server's IP-Address, nothing else.
 
 +while (ppp_option_iter_next(iter) == TRUE) {
 +const guint8 *data = ppp_option_iter_get_data(iter); +
 +switch (ppp_option_iter_get_type(iter)) {
 +case IP_ADDRESS:
 +memcpy(peer_addr, data, 4);
 +break;
 +case PRIMARY_DNS_SERVER:
 +memcpy(dns1, data, 4);
 +break;
 +case SECONDARY_DNS_SERVER:
 +memcpy(dns2, data, 4);
 +break;
 +default:
 +break;
 +}
 +}
 +
 +if (peer_addr  dns1  dns2) {
 +if (ipcp-peer_addr == 0) {
 +/* RFC 1332 Section 3.3
 + * Accept the value of IP address as
 peer IP address
 +

Reg. How client receives SMS PUD

2010-06-20 Thread సత్య కిషోర్
Hi all,

oFono stack decodes the incoming PDU. Is there any option that client can
receive the direct PDU from oFono with out processing (i.e. decoding).

If such option available, how can I achieve this.

Similarly in case sending message oFono will form (encode) the PDU based on
the data passed to it. Instead is there any possibility that client can form
the PDU and send it to oFono stack ?


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