summaryrefslogtreecommitdiffstats
path: root/plugins/smart-messaging.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-11-04 10:22:32 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-11-04 10:25:42 -0500
commit7ecff9f83b27664fe71c4e07625ed0e1def8b6c5 (patch)
treeaab7525c12d6609478a5925035f638c12565d2ad /plugins/smart-messaging.c
parent4815d84789df2ac30c05103e7cba19017d3063fd (diff)
downloadofono-7ecff9f83b27664fe71c4e07625ed0e1def8b6c5.tar.bz2
smart-messaging: Implement SendBusinessCard
Diffstat (limited to 'plugins/smart-messaging.c')
-rw-r--r--plugins/smart-messaging.c53
1 files changed, 52 insertions, 1 deletions
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 <ofono/modem.h>
#include <ofono/dbus.h>
#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,