summaryrefslogtreecommitdiffstats
path: root/plugins/smart-messaging.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-11-02 14:49:11 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-11-02 14:58:21 -0500
commit59bbdd5d080714b5b3e14f381773346109b1fd22 (patch)
tree29ba8f343491f6ffe3c6f7b7fc6bb861ca15271c /plugins/smart-messaging.c
parent429dcb6ef5f72abd43f2b1255b71aae04d6eff87 (diff)
downloadofono-59bbdd5d080714b5b3e14f381773346109b1fd22.tar.bz2
smart-messaging: Register to vCal notifications
Diffstat (limited to 'plugins/smart-messaging.c')
-rw-r--r--plugins/smart-messaging.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/smart-messaging.c b/plugins/smart-messaging.c
index 9ba0cbac..2e6a292b 100644
--- a/plugins/smart-messaging.c
+++ b/plugins/smart-messaging.c
@@ -43,6 +43,9 @@
#define VCARD_SRC_PORT -1
#define VCARD_DST_PORT 9204
+#define VCAL_SRC_PORT -1
+#define VCAL_DST_PORT 9205
+
static unsigned int modemwatch_id;
struct smart_messaging {
@@ -50,6 +53,7 @@ struct smart_messaging {
struct ofono_sms *sms;
struct sms_agent *agent;
unsigned int vcard_watch;
+ unsigned int vcal_watch;
};
static void agent_exited(void *userdata)
@@ -61,6 +65,11 @@ static void agent_exited(void *userdata)
sm->vcard_watch = 0;
}
+ if (sm->vcal_watch > 0) {
+ __ofono_sms_datagram_watch_remove(sm->sms, sm->vcal_watch);
+ sm->vcal_watch = 0;
+ }
+
sm->agent = NULL;
}
@@ -79,6 +88,21 @@ static void vcard_received(const char *from, const struct tm *remote,
NULL, NULL, NULL);
}
+static void vcal_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, "ReceiveAppointment",
+ from, remote, local, buffer, len,
+ NULL, NULL, NULL);
+}
+
static DBusMessage *smart_messaging_register_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -111,6 +135,12 @@ static DBusMessage *smart_messaging_register_agent(DBusConnection *conn,
VCARD_SRC_PORT,
sm, NULL);
+ sm->vcal_watch = __ofono_sms_datagram_watch_add(sm->sms,
+ vcal_received,
+ VCAL_DST_PORT,
+ VCAL_SRC_PORT,
+ sm, NULL);
+
return dbus_message_new_method_return(msg);
}
@@ -166,6 +196,7 @@ static void smart_messaging_cleanup(gpointer user)
DBG("%p", sm);
sm->vcard_watch = 0;
+ sm->vcal_watch = 0;
sm->sms = NULL;
sms_agent_free(sm->agent);