From 7ecff9f83b27664fe71c4e07625ed0e1def8b6c5 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 4 Nov 2010 10:22:32 -0500 Subject: smart-messaging: Implement SendBusinessCard --- plugins/smart-messaging.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'plugins/smart-messaging.c') diff --git a/plugins/smart-messaging.c b/plugins/smart-messaging.c index 2e6a292b..314eb226 100644 --- a/plugins/smart-messaging.c +++ b/plugins/smart-messaging.c @@ -36,6 +36,8 @@ #include #include #include "smsagent.h" +#include "smsutil.h" +#include "common.h" #define SMART_MESSAGING_INTERFACE "org.ofono.SmartMessaging" #define AGENT_INTERFACE "org.ofono.SmartMessagingAgent" @@ -167,10 +169,59 @@ static DBusMessage *smart_messaging_unregister_agent(DBusConnection *conn, return dbus_message_new_method_return(msg); } +static void message_queued(struct ofono_sms *sms, + const struct ofono_uuid *uuid, void *data) +{ + DBusConnection *conn = ofono_dbus_get_connection(); + DBusMessage *msg = data; + const char *path; + + path = __ofono_sms_message_path_from_uuid(sms, uuid); + g_dbus_send_reply(conn, msg, DBUS_TYPE_OBJECT_PATH, &path, + DBUS_TYPE_INVALID); +} + static DBusMessage *smart_messaging_send_vcard(DBusConnection *conn, DBusMessage *msg, void *data) { - return __ofono_error_not_implemented(msg); + struct smart_messaging *sm = data; + const char *to; + unsigned char *bytes; + int len; + GSList *msg_list; + unsigned int flags; + gboolean use_16bit_ref = FALSE; + int err; + struct ofono_uuid uuid; + unsigned short ref; + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &to, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &bytes, &len, DBUS_TYPE_INVALID)) + return __ofono_error_invalid_args(msg); + + if (valid_phone_number_format(to) == FALSE) + return __ofono_error_invalid_format(msg); + + ref = __ofono_sms_get_next_ref(sm->sms); + msg_list = sms_datagram_prepare(to, bytes, len, ref, use_16bit_ref, + 0, VCARD_DST_PORT, TRUE, FALSE); + + if (!msg_list) + return __ofono_error_invalid_format(msg); + + flags = OFONO_SMS_SUBMIT_FLAG_RETRY | OFONO_SMS_SUBMIT_FLAG_EXPOSE_DBUS; + + err = __ofono_sms_txq_submit(sm->sms, msg_list, flags, &uuid, + message_queued, msg); + + g_slist_foreach(msg_list, (GFunc)g_free, NULL); + g_slist_free(msg_list); + + if (err < 0) + return __ofono_error_failed(msg); + + return NULL; } static DBusMessage *smart_messaging_send_vcal(DBusConnection *conn, -- cgit v1.2.3