summaryrefslogtreecommitdiffstats
path: root/plugins/push-notification.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-11-01 09:51:57 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-11-02 12:15:53 -0500
commitdf5339bf895f5f1f21520aab3f0496b21bb89864 (patch)
treed67112f33dee2653e4997637f4bf1aee6350ab7b /plugins/push-notification.c
parent55a61c3a63e62ebf6233428b17c9574cadc124c1 (diff)
downloadofono-df5339bf895f5f1f21520aab3f0496b21bb89864.tar.bz2
push-notification: Implement register agent
Diffstat (limited to 'plugins/push-notification.c')
-rw-r--r--plugins/push-notification.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/plugins/push-notification.c b/plugins/push-notification.c
index d209fa1c..e324c0cb 100644
--- a/plugins/push-notification.c
+++ b/plugins/push-notification.c
@@ -36,19 +36,53 @@
#include <ofono/modem.h>
#include <ofono/dbus.h>
+#include "smsagent.h"
+
#define PUSH_NOTIFICATION_INTERFACE "org.ofono.PushNotification"
+#define AGENT_INTERFACE "org.ofono.PushNotificationAgent"
static unsigned int modemwatch_id;
struct push_notification {
struct ofono_modem *modem;
struct ofono_sms *sms;
+ struct sms_agent *agent;
};
+static void agent_exited(void *userdata)
+{
+ struct push_notification *pn = userdata;
+
+ pn->agent = NULL;
+}
+
static DBusMessage *push_notification_register_agent(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- return __ofono_error_not_implemented(msg);
+ struct push_notification *pn = data;
+ const char *agent_path;
+
+ if (pn->agent)
+ return __ofono_error_busy(msg);
+
+ if (dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_OBJECT_PATH, &agent_path,
+ DBUS_TYPE_INVALID) == FALSE)
+ return __ofono_error_invalid_args(msg);
+
+ if (!__ofono_dbus_valid_object_path(agent_path))
+ return __ofono_error_invalid_format(msg);
+
+ pn->agent = sms_agent_new(AGENT_INTERFACE,
+ dbus_message_get_sender(msg),
+ agent_path);
+
+ if (pn->agent == NULL)
+ return __ofono_error_failed(msg);
+
+ sms_agent_set_removed_notify(pn->agent, agent_exited, pn);
+
+ return dbus_message_new_method_return(msg);
}
static DBusMessage *push_notification_unregister_agent(DBusConnection *conn,