[PATCH] voicecall.c: use swap_without_accept method, if present
by Pekka Pessi
From: Pekka Pessi <Pekka.Pessi(a)nokia.com>
---
src/voicecall.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index eff6321..1be907a 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -835,11 +835,31 @@ static DBusMessage *manager_transfer(DBusConnection *conn,
return NULL;
}
+static DBusMessage *manager_swap_without_accept(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ struct ofono_voicecall *vc = data;
+
+ if (vc->flags & VOICECALLS_FLAG_PENDING)
+ return __ofono_error_busy(msg);
+
+ vc->flags |= VOICECALLS_FLAG_PENDING;
+ vc->pending = dbus_message_ref(msg);
+
+ vc->driver->swap_without_accept(vc, generic_callback, vc);
+
+ return NULL;
+}
+
+
static DBusMessage *manager_swap_calls(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct ofono_voicecall *vc = data;
+ if (vc->driver->swap_without_accept)
+ return manager_swap_without_accept(conn, msg, data);
+
if (vc->flags & VOICECALLS_FLAG_PENDING)
return __ofono_error_busy(msg);
--
1.6.0.4
12 years, 7 months
Subject: RFC Migrate from RFC2822 to ISO8601 for time representations
by Olivier Le Thanh Duong
Hi,
the format used to represent time in ofono is currently RFC2822 which is
complex and a bit deprecated. I think it would be better to move to
ISO8601 which is a well used and supported [1] format and simpler to parse.
RFC2822 date example: Mon, 05 Oct 2009 19:31:32 +0200
ISO8601 date example: 2009-10-05T19:31:26+0200
The proposed patch makes this transition.
Any comments?
Regards,
Olivier
[1] for example Glib has a g_time_val_from_iso8601 which understand
timezone compared to strptime which doesn't support %z
From 16359eccfcb4a7a5444e6f87729008192edefc5e Mon Sep 17 00:00:00 2001
From: Olivier Le Thanh Duong <olivier.le.thanh(a)collabora.co.uk>
Date: Mon, 5 Oct 2009 19:10:25 +0200
Subject: [PATCH] Migrate from RFC2822 to ISO8601 for time representations
---
plugins/example_history.c | 6 +++---
src/sms.c | 4 ++--
src/voicecall.c | 2 +-
unit/test-sms.c | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/plugins/example_history.c b/plugins/example_history.c
index 384c88d..d923a8e 100644
--- a/plugins/example_history.c
+++ b/plugins/example_history.c
@@ -68,11 +68,11 @@ static void example_history_call_ended(struct
ofono_history_context *context,
else
ofono_debug("From: %s", from);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&start));
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&start));
buf[127] = '\0';
ofono_debug("StartTime: %s", buf);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&end));
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&end));
buf[127] = '\0';
ofono_debug("EndTime: %s", buf);
}
@@ -96,7 +96,7 @@ static void example_history_call_missed(struct
ofono_history_context *context,
from = phone_number_to_string(&call->phone_number);
ofono_debug("From: %s", from);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&when));
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&when));
buf[127] = '\0';
ofono_debug("When: %s", buf);
}
diff --git a/src/sms.c b/src/sms.c
index 141f288..e02ac85 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -467,11 +467,11 @@ static void dispatch_text_message(struct ofono_sms
*sms,
ts = sms_scts_to_time(scts, &remote);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&ts));
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&ts));
buf[127] = '\0';
ofono_dbus_dict_append(&dict, "LocalSentTime", DBUS_TYPE_STRING, &str);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", &remote);
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &remote);
buf[127] = '\0';
ofono_dbus_dict_append(&dict, "SentTime", DBUS_TYPE_STRING, &str);
diff --git a/src/voicecall.c b/src/voicecall.c
index eff6321..3f70f9e 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -164,7 +164,7 @@ static const char *time_to_str(const time_t *t)
{
static char buf[128];
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(t));
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(t));
buf[127] = '\0';
return buf;
diff --git a/unit/test-sms.c b/unit/test-sms.c
index ac4f1ff..9c1528c 100644
--- a/unit/test-sms.c
+++ b/unit/test-sms.c
@@ -59,12 +59,12 @@ static void print_scts(struct sms_scts *scts, const
char *prefix)
ts = sms_scts_to_time(scts, &remote);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&ts));
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", localtime(&ts));
buf[127] = '\0';
g_print("local time: %s\n", buf);
- strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", &remote);
+ strftime(buf, 127, "%Y-%m-%dT%H:%M:%S%z", &remote);
buf[127] = '\0';
g_print("remote time: %s\n", buf);
--
1.6.3.3
12 years, 7 months
[PATCH] modemconf: default to grabbing the "Device" entry from the config file
by Andres Salomon
Previously, we manually listed every driver entry that needed Device;
this meant that we needed to edit modemconf.c every time we added
a new modem plugin. Sjoerd Simons discovered that mbm doesn't work
because it wasn't listed in modemconf, therefore Device was being
ignored. This patch makes modemconf default to setting Device, with
exceptions made for certain plugin drivers.
A better way to fix this that I started working on would be to have
each driver plugin have a table of desired/required strings, and to
keep any knowledge of drivers out of udev.c and modemconf.c. This
may be a bit of a challenge for udev.c, though. Is this something
that people would like to see?
Signed-off-by: Andres Salomon <dilinger(a)collabora.co.uk>
---
plugins/modemconf.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/plugins/modemconf.c b/plugins/modemconf.c
index 4795749..dce31e2 100644
--- a/plugins/modemconf.c
+++ b/plugins/modemconf.c
@@ -98,9 +98,7 @@ static struct ofono_modem *create_modem(GKeyFile *keyfile, const char *group)
if (!g_strcmp0(driver, "phonesim"))
set_address(modem, keyfile, group);
-
- if (!g_strcmp0(driver, "atgen") || !g_strcmp0(driver, "g1") ||
- !g_strcmp0(driver, "calypso"))
+ else
set_device(modem, keyfile, group);
g_free(driver);
--
1.6.4.3
12 years, 7 months
[PATCH] Check if unpacking of an sms buffer succeeds
by Andres Salomon
And here's one from a coworker that was necessary in order for him to
make use of oFono..
From: Sjoerd Simons <sjoerd.simons(a)collabora.co.uk>
Date: Fri, 2 Oct 2009 23:32:37 +0000 (+0100)
Subject: Check if unpacking of an sms buffer succeeds
X-Git-Url: http://git.collabora.co.uk/?p=user%2Fsjoerd%2Fofono.git;a=commitdiff_plai...
Check if unpacking of an sms buffer succeeds
There are cases in which sms unpack_7bit_own_buf can fail (for example when
receiving an empty sms), in that case bail out instead of crashing...
---
diff --git a/src/smsutil.c b/src/smsutil.c
index 106a39a..f389d29 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -2140,9 +2140,10 @@ char *sms_decode_text(GSList *sms_list)
guint8 single_shift = 0;
int max_chars = sms_text_capacity_gsm(udl, taken);
- unpack_7bit_own_buf(ud + taken, udl_in_bytes - taken,
+ if (unpack_7bit_own_buf(ud + taken, udl_in_bytes - taken,
taken, FALSE, max_chars,
- &written, 0, buf);
+ &written, 0, buf) == NULL)
+ break;
/* Take care of improperly split fragments */
if (buf[written-1] == 0x1b)
12 years, 7 months
[PATCH] G1: move chat handling into enable callback
by Andres Salomon
This updates the g1 code to create the GAtChat object in the enable() callback,
and to unref it in the disable() callback. This is more in line with what
the other plugins do, and as a bonus fixes a segfault when powering down
the G1 modem..
Signed-off-by: Andres Salomon <dilinger(a)collabora.co.uk>
---
plugins/g1.c | 48 ++++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/plugins/g1.c b/plugins/g1.c
index 5c53a12..0414f49 100644
--- a/plugins/g1.c
+++ b/plugins/g1.c
@@ -57,39 +57,14 @@ static void g1_debug(const char *str, void *data)
/* Detect hardware, and initialize if found */
static int g1_probe(struct ofono_modem *modem)
{
- GAtSyntax *syntax;
- GAtChat *chat;
- const char *device;
-
DBG("");
- device = ofono_modem_get_string(modem, "Device");
- if (device == NULL)
- return -EINVAL;
-
- syntax = g_at_syntax_new_gsm_permissive();
- chat = g_at_chat_new_from_tty(device, syntax);
- g_at_syntax_unref(syntax);
-
- if (chat == NULL)
- return -EIO;
-
- if (getenv("OFONO_AT_DEBUG") != NULL)
- g_at_chat_set_debug(chat, g1_debug, NULL);
-
- ofono_modem_set_data(modem, chat);
-
return 0;
}
static void g1_remove(struct ofono_modem *modem)
{
- GAtChat *chat = ofono_modem_get_data(modem);
-
DBG("");
-
- ofono_modem_set_data(modem, NULL);
- g_at_chat_unref(chat);
}
static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -105,10 +80,28 @@ static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
/* power up hardware */
static int g1_enable(struct ofono_modem *modem)
{
- GAtChat *chat = ofono_modem_get_data(modem);
+ GAtSyntax *syntax;
+ GAtChat *chat;
+ const char *device;
DBG("");
+ device = ofono_modem_get_string(modem, "Device");
+ if (device == NULL)
+ return -EINVAL;
+
+ syntax = g_at_syntax_new_gsm_permissive();
+ chat = g_at_chat_new_from_tty(device, syntax);
+ g_at_syntax_unref(syntax);
+
+ if (chat == NULL)
+ return -EIO;
+
+ if (getenv("OFONO_AT_DEBUG") != NULL)
+ g_at_chat_set_debug(chat, g1_debug, NULL);
+
+ ofono_modem_set_data(modem, chat);
+
/* ensure modem is in a known state; verbose on, echo/quiet off */
g_at_chat_send(chat, "ATE0Q0V1", NULL, NULL, NULL, NULL);
@@ -137,6 +130,9 @@ static int g1_disable(struct ofono_modem *modem)
/* power down modem */
g_at_chat_send(chat, "AT+CFUN=0", NULL, cfun_set_off_cb, modem, NULL);
+ g_at_chat_unref(chat);
+ ofono_modem_set_data(modem, NULL);
+
return 0;
}
--
1.6.4.3
12 years, 7 months
Using oFono on a G1 (with Debian)
by Andres Salomon
Hi,
It was pointed out that I never made this public, so I'm correcting
that now. The hardest parts of this involve rooting the phone and
messing around with various images, but.. that's something you want to
do anyways, right? :)
First, the bootstrap steps:
1. Root your phone (if you've purchased an ADP phone, you can skip
this). Instructions are here:
http://androidcommunity.com/forums/f12/rooting-your-g1-made-easy-11825/
2. Install a decent image on the phone. I'm using TF 1.5 for this:
http://jf.andblogs.net/2009/05/24/jfv151-images-are-out/.
3. If you've upgraded from an older image, you'll probably want to reset
the data back to factory defaults, otherwise you'll waste a few days
flailing at random things that don't work as expected, or regularly
crash (*cough*). This can be done via
Settings -> SD card & phone storage -> Factory data reset.
4. Next, install a Debian chroot (http://www.saurik.com/id/10). The
unionfs overlay stuff is completely optional; I didn't bother.
Instead, I just chroot into the proper directory on a regular basis.
Enter the chroot, set a password ("passwd"). Install dbus, ssh, and
oFono ("apt-get install openssh-server dbus ofono").
5. Edit /etc/ofono/modem.conf, uncommenting out the G1 lines. It
should look something like this:
# Sample for Android/HTC G1
[g1]
Driver=g1
Device=/dev/smd0
The following steps need to be run after every reboot of the phone:
6. /dev/smd0 is the serial device that oFono will use. However,
Android's rild needs to not use it at the same time, otherwise the
phone will crash hard. So, run "stop ril-daemon". "ps |grep ril"
should not show rild running.
7. Get the phone connected to wireless (Settings -> Wireless
controls). Android on the G1 regularly disconnects from wireless when
idle to save power; this is pretty damned annoying if you're ssh'd in.
I run Sipdroid on the phone precisely to work around this, as it keeps
the wifi enabled even when the phone is idle. Sipdroid can be
installed via market, if you find the wireless power save feature as
irritating as I did.
8. Enter your Debian chroot. Start sshd ("/etc/init.d/ssh
start"). Check the phone's IP address ("/sbin/ifconfig tiwlan0").
Start dbus ("/etc/init.d/dbus start").
9. You should now be able ssh into the phone (which will deposit you
into the Debian chroot, with a sane TERM and various other settings).
If you don't care to see the oFono debugging stuff, just start oFono
normally ("/etc/init.d/ofono start"). If you do want to see debugging
information, start it with the appropriate arguments and variables
("OFONO_AT_DEBUG=1 /usr/sbin/ofonod -n -d"). The modem's path should
be "/g10".
10. Power up the modem:
dbus-send --system --type=method_call --print-reply \
--dest=org.ofono /g10 org.ofono.Modem.SetProperty string:"Powered" \
variant:boolean:true
11. Send an SMS:
dbus-send --system --print-reply --dest=org.ofono /g10 \
org.ofono.SmsManager.SendMessage array:string:"6175010000" \
string:"Moooooooooo"
12. Place a voice call:
dbus-send --system --print-reply --dest=org.ofono /g10 \
org.ofono.VoiceCallManager.Dial string:"6175010000" \
string:"default"
Note that ril initialization is still required for the modem; I haven't
tried completely getting rid of rild. At some point it would be good
to try it and reverse engineer the binary ril blob to get a completely
free gsm stack, but that's not yet a priority of mine.
12 years, 7 months