diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/conn-mail-notif.c | 61 | ||||
-rw-r--r-- | src/conn-mail-notif.h | 5 | ||||
-rw-r--r-- | src/connection.c | 25 |
3 files changed, 81 insertions, 10 deletions
diff --git a/src/conn-mail-notif.c b/src/conn-mail-notif.c index 5a7b39d6f..e561cefee 100644 --- a/src/conn-mail-notif.c +++ b/src/conn-mail-notif.c @@ -32,6 +32,19 @@ #include "connection.h" #include "debug.h" +enum +{ + PROP_CAPABILITIES, + PROP_UNREAD_MAIL_COUNT, + PROP_INBOX_URL, + PROP_METHOD, + PROP_POST_DATA, + PROP_UNREAD_MAILS, + NUM_OF_PROP, +}; + +static GPtrArray empty_array = { 0 }; + static void gabble_mail_notification_subscribe (GabbleSvcConnectionInterfaceMailNotification *self, DBusGMethodInvocation *context) @@ -47,13 +60,6 @@ gabble_mail_notification_unsubscribe (GabbleSvcConnectionInterfaceMailNotificati } void -conn_mail_notif_class_init (GabbleConnectionClass *klass) -{ - /* TODO */ -} - - -void conn_mail_notif_init (GabbleConnection *conn) { /* TODO */ @@ -61,7 +67,7 @@ conn_mail_notif_init (GabbleConnection *conn) void -conn_mail_notif_finalize (GabbleConnection *conn) +conn_mail_notif_dispose (GabbleConnection *conn) { /* TODO */ } @@ -78,3 +84,42 @@ conn_mail_notif_iface_init (gpointer g_iface, gpointer iface_data) IMPLEMENT(unsubscribe); #undef IMPLEMENT } + +void +conn_mail_notif_properties_getter (GObject *object, + GQuark interface, + GQuark name, + GValue *value, + gpointer getter_data) +{ + static GQuark prop_quarks[NUM_OF_PROP] = {0}; + + if (G_UNLIKELY (prop_quarks[0] == 0)) + { + prop_quarks[PROP_CAPABILITIES] = g_quark_from_static_string ("Capabilities"); + prop_quarks[PROP_UNREAD_MAIL_COUNT] = g_quark_from_static_string ("UnreadMailCount"); + prop_quarks[PROP_INBOX_URL] = g_quark_from_static_string ("InboxURL"); + prop_quarks[PROP_METHOD] = g_quark_from_static_string ("Method"); + prop_quarks[PROP_POST_DATA] = g_quark_from_static_string ("PostData"); + prop_quarks[PROP_UNREAD_MAILS] = g_quark_from_static_string ("UnreadMails"); + } + + DEBUG ("MailNotification get property %s", g_quark_to_string (name)); + + if (name == prop_quarks[PROP_CAPABILITIES]) + g_value_set_uint (value, + GABBLE_MAIL_NOTIFICATION_HAS_PROP_UNREADMAILCOUNT + | GABBLE_MAIL_NOTIFICATION_HAS_PROP_UNREADMAILS); + else if (name == prop_quarks[PROP_UNREAD_MAIL_COUNT]) + g_value_set_uint (value, 0); + else if (name == prop_quarks[PROP_INBOX_URL]) + g_value_set_string (value, ""); + else if (name == prop_quarks[PROP_METHOD]) + g_value_set_uint (value, GABBLE_HTTP_METHOD_GET); + else if (name == prop_quarks[PROP_POST_DATA]) + g_value_set_static_boxed (value, &empty_array); + else if (name == prop_quarks[PROP_UNREAD_MAILS]) + g_value_set_boxed (value, &empty_array); + else + g_assert (!"Unkown mail notification property, please file a bug."); +} diff --git a/src/conn-mail-notif.h b/src/conn-mail-notif.h index 10a642fd7..cfe9f3d3a 100644 --- a/src/conn-mail-notif.h +++ b/src/conn-mail-notif.h @@ -26,10 +26,11 @@ G_BEGIN_DECLS -void conn_mail_notif_class_init (GabbleConnectionClass *klass); void conn_mail_notif_init (GabbleConnection *conn); -void conn_mail_notif_finalize (GabbleConnection *conn); +void conn_mail_notif_dispose (GabbleConnection *conn); void conn_mail_notif_iface_init (gpointer g_iface, gpointer iface_data); +void conn_mail_notif_properties_getter (GObject *object, GQuark interface, + GQuark name, GValue *value, gpointer getter_data); G_END_DECLS diff --git a/src/connection.c b/src/connection.c index 5b3993bcb..bd2b6a540 100644 --- a/src/connection.c +++ b/src/connection.c @@ -336,6 +336,7 @@ gabble_connection_constructor (GType type, conn_olpc_activity_properties_init (self); conn_location_init (self); conn_sidecars_init (self); + conn_mail_notif_init (self); tp_contacts_mixin_add_contact_attributes_iface (G_OBJECT (self), TP_IFACE_CONNECTION_INTERFACE_CAPABILITIES, @@ -727,6 +728,15 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class) { "DecloakAutomatically", TWICE ("decloak-automatically") }, { NULL } }; + static TpDBusPropertiesMixinPropImpl mail_notif_props[] = { + { "Capabilities", NULL, NULL }, + { "UnreadMailCount", NULL, NULL }, + { "InboxURL", NULL, NULL }, + { "Method", NULL, NULL }, + { "PostData", NULL, NULL }, + { "UnreadMails", NULL, NULL }, + { NULL } + }; static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = { { GABBLE_IFACE_OLPC_GADGET, conn_olpc_gadget_properties_getter, @@ -748,6 +758,11 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class) tp_dbus_properties_mixin_setter_gobject_properties, decloak_props, }, + { GABBLE_IFACE_CONNECTION_INTERFACE_MAIL_NOTIFICATION, + conn_mail_notif_properties_getter, + NULL, + mail_notif_props, + }, { NULL } }; @@ -1009,6 +1024,8 @@ gabble_connection_dispose (GObject *object) g_hash_table_destroy (self->avatar_requests); + conn_mail_notif_dispose (self); + g_assert (priv->iq_disco_cb == NULL); g_assert (priv->iq_unknown_cb == NULL); g_assert (priv->olpc_msg_cb == NULL); @@ -2564,6 +2581,14 @@ connection_disco_cb (GabbleDisco *disco, tp_base_connection_add_interfaces ((TpBaseConnection *) conn, ifaces); } + if (conn->features & GABBLE_CONNECTION_FEATURES_GOOGLE_MAIL_NOTIFY) + { + const gchar *ifaces[] = + { GABBLE_IFACE_CONNECTION_INTERFACE_MAIL_NOTIFICATION, NULL }; + + tp_base_connection_add_interfaces ((TpBaseConnection *) conn, ifaces); + } + /* send presence to the server to indicate availability */ /* TODO: some way for the user to set this */ if (!_gabble_connection_signal_own_presence (conn, NULL, &error)) |