diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-11-02 14:46:46 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-11-02 14:58:21 -0500 |
commit | 429dcb6ef5f72abd43f2b1255b71aae04d6eff87 (patch) | |
tree | 1c94d2986fe02e2b3dd39e61b80b0bfd3e74ddec /plugins/smart-messaging.c | |
parent | 6e6409ff421f86c5b6cd96a9cfe825d7bdcb6891 (diff) | |
download | ofono-429dcb6ef5f72abd43f2b1255b71aae04d6eff87.tar.bz2 |
smart-messaging: Register for vCard notifications
Diffstat (limited to 'plugins/smart-messaging.c')
-rw-r--r-- | plugins/smart-messaging.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/smart-messaging.c b/plugins/smart-messaging.c index 114e24b3..9ba0cbac 100644 --- a/plugins/smart-messaging.c +++ b/plugins/smart-messaging.c @@ -40,21 +40,45 @@ #define SMART_MESSAGING_INTERFACE "org.ofono.SmartMessaging" #define AGENT_INTERFACE "org.ofono.SmartMessagingAgent" +#define VCARD_SRC_PORT -1 +#define VCARD_DST_PORT 9204 + static unsigned int modemwatch_id; struct smart_messaging { struct ofono_modem *modem; struct ofono_sms *sms; struct sms_agent *agent; + unsigned int vcard_watch; }; static void agent_exited(void *userdata) { struct smart_messaging *sm = userdata; + if (sm->vcard_watch > 0) { + __ofono_sms_datagram_watch_remove(sm->sms, sm->vcard_watch); + sm->vcard_watch = 0; + } + sm->agent = NULL; } +static void vcard_received(const char *from, const struct tm *remote, + const struct tm *local, int dst, int src, + const unsigned char *buffer, + unsigned int len, void *data) +{ + struct smart_messaging *sm = data; + + if (sm->agent == NULL) + return; + + sms_agent_dispatch_datagram(sm->agent, "ReceiveBusinessCard", + from, remote, local, buffer, len, + NULL, NULL, NULL); +} + static DBusMessage *smart_messaging_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -81,6 +105,12 @@ static DBusMessage *smart_messaging_register_agent(DBusConnection *conn, sms_agent_set_removed_notify(sm->agent, agent_exited, sm); + sm->vcard_watch = __ofono_sms_datagram_watch_add(sm->sms, + vcard_received, + VCARD_DST_PORT, + VCARD_SRC_PORT, + sm, NULL); + return dbus_message_new_method_return(msg); } @@ -135,6 +165,7 @@ static void smart_messaging_cleanup(gpointer user) DBG("%p", sm); + sm->vcard_watch = 0; sm->sms = NULL; sms_agent_free(sm->agent); |