summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-02-10 16:12:43 +0000
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-02-10 17:03:37 +0000
commitcd67dfe40b307f1294b8fc1e7e1bfb5c75f8d934 (patch)
tree91e09eb98fb768afcd5467dd7bc58a2d38093f90
parent316f4e9fefe3a9fa2501ac9e1eb94a7889f4a323 (diff)
downloadtelepathy-logger-cd67dfe40b307f1294b8fc1e7e1bfb5c75f8d934.tar.gz
Implement DBus method for clear_entity
-rw-r--r--extensions/Logger.xml25
-rw-r--r--telepathy-logger/dbus-service.c53
2 files changed, 78 insertions, 0 deletions
diff --git a/extensions/Logger.xml b/extensions/Logger.xml
index b6de7dc..479f226 100644
--- a/extensions/Logger.xml
+++ b/extensions/Logger.xml
@@ -173,6 +173,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</
</tp:docstring>
</method>
+ <method name="ClearEntity"
+ tp:name-for-bindings="Clear_Entity">
+ <arg direction="in" name="Account" type="o" tp:type="Account">
+ <tp:docstring>
+ The object path for the TpAccount in which logs will be cleared.
+ </tp:docstring>
+ </arg>
+
+ <arg direction="in" name="Identifier" type="s">
+ <tp:docstring>
+ The entity identifier.
+ </tp:docstring>
+ </arg>
+
+ <arg direction="in" name="Type" type="i">
+ <tp:docstring>
+ The entity type, should be one of TPL_ENTITY_CONTACT (1) or TPL_ENTITY_ROOM (2).
+ </tp:docstring>
+ </arg>
+
+ <tp:docstring>
+ Clear all logs stored for discussions with entity in account.
+ </tp:docstring>
+ </method>
+
<signal name="FavouriteContactsChanged"
tp:name-for-bindings="Favourite_Contacts_Changed">
<tp:docstring>
diff --git a/telepathy-logger/dbus-service.c b/telepathy-logger/dbus-service.c
index 3b95950..c32eac2 100644
--- a/telepathy-logger/dbus-service.c
+++ b/telepathy-logger/dbus-service.c
@@ -984,6 +984,58 @@ out:
static void
+tpl_dbus_service_clear_entity (TplSvcLogger *logger,
+ const gchar *account_path,
+ const gchar *identifier,
+ gint type,
+ DBusGMethodInvocation *context)
+{
+ TplDBusService *self = TPL_DBUS_SERVICE (logger);
+ TpDBusDaemon *bus;
+ TpAccount *account;
+ TplEntity *entity;
+ GError *error = NULL;
+
+ g_return_if_fail (TPL_IS_DBUS_SERVICE (self));
+ g_return_if_fail (context != NULL);
+ g_return_if_fail (!TPL_STR_EMPTY (identifier));
+
+ bus = tp_dbus_daemon_dup (&error);
+ if (bus == NULL)
+ {
+ DEBUG ("Unable to acquire the bus daemon: %s", error->message);
+ dbus_g_method_return_error (context, error);
+ goto out;
+ }
+
+ account = tp_account_new (bus, account_path, &error);
+ if (account == NULL)
+ {
+ DEBUG ("Unable to acquire the account for %s: %s", account_path,
+ error->message);
+ dbus_g_method_return_error (context, error);
+ goto out;
+ }
+
+ entity = g_object_new (TPL_TYPE_ENTITY,
+ "type", type,
+ "identifier", identifier,
+ NULL);
+
+ /* We want to clear synchronously to avoid concurent write */
+ _tpl_log_manager_clear_entity (self->priv->manager, account, entity);
+ g_object_unref (account);
+
+ tpl_svc_logger_return_from_clear_account (context);
+
+out:
+ if (bus != NULL)
+ g_object_unref (bus);
+
+ g_clear_error (&error);
+}
+
+static void
tpl_logger_iface_init (gpointer iface,
gpointer iface_data)
{
@@ -996,5 +1048,6 @@ tpl_logger_iface_init (gpointer iface,
IMPLEMENT (remove_favourite_contact);
IMPLEMENT (clear);
IMPLEMENT (clear_account);
+ IMPLEMENT (clear_entity);
#undef IMPLEMENT
}