]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-contact-list.c
Import tools from telepathy-glib 0.7.3 and build a static libemp-extensions.la.
[empathy.git] / libempathy / empathy-contact-list.c
index c55d0abf9ca954e4ca89357f5e5b1c6549523f27..c34dc533491fa76df4e9d583023baa8a0b81223c 100644 (file)
@@ -2,20 +2,19 @@
 /*
  * Copyright (C) 2007 Collabora Ltd.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * Authors: Xavier Claessens <xclaesse@gmail.com>
  */
@@ -42,6 +41,8 @@ empathy_contact_list_get_type (void)
                type = g_type_register_static (G_TYPE_INTERFACE,
                                               "EmpathyContactList",
                                               &type_info, 0);
+
+               g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
        }
 
        return type;
@@ -53,135 +54,166 @@ contact_list_base_init (gpointer klass)
        static gboolean initialized = FALSE;
 
        if (!initialized) {
-               g_signal_new ("contact-added",
+               g_signal_new ("members-changed",
                              G_TYPE_FROM_CLASS (klass),
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             g_cclosure_marshal_VOID__OBJECT,
+                             _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
                              G_TYPE_NONE,
-                             1, GOSSIP_TYPE_CONTACT);
+                             5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
+                             G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
-               g_signal_new ("contact-removed",
+               g_signal_new ("pendings-changed",
                              G_TYPE_FROM_CLASS (klass),
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             g_cclosure_marshal_VOID__OBJECT,
+                             _empathy_marshal_VOID__OBJECT_OBJECT_UINT_STRING_BOOLEAN,
                              G_TYPE_NONE,
-                             1, GOSSIP_TYPE_CONTACT);
+                             5, EMPATHY_TYPE_CONTACT, EMPATHY_TYPE_CONTACT,
+                             G_TYPE_UINT, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
-               g_signal_new ("local-pending",
+               g_signal_new ("groups-changed",
                              G_TYPE_FROM_CLASS (klass),
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             empathy_marshal_VOID__OBJECT_STRING,
+                             _empathy_marshal_VOID__OBJECT_STRING_BOOLEAN,
                              G_TYPE_NONE,
-                             2, GOSSIP_TYPE_CONTACT, G_TYPE_STRING);
+                             3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_BOOLEAN);
 
                initialized = TRUE;
        }
 }
 
-EmpathyContactListInfo *
-empathy_contact_list_info_new (GossipContact *contact,
-                              const gchar   *message)
+void
+empathy_contact_list_add (EmpathyContactList *list,
+                         EmpathyContact     *contact,
+                         const gchar        *message)
 {
-       EmpathyContactListInfo *info;
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
-       g_return_val_if_fail (GOSSIP_IS_CONTACT (contact), NULL);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
+       }
+}
 
-       info = g_slice_new0 (EmpathyContactListInfo);
-       info->contact = g_object_ref (contact);
-       info->message = g_strdup (message);
+void
+empathy_contact_list_remove (EmpathyContactList *list,
+                            EmpathyContact     *contact,
+                            const gchar        *message)
+{
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
-       return info;
-}                             
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
+       }
+}
 
-void
-empathy_contact_list_info_free (EmpathyContactListInfo *info)
+GList *
+empathy_contact_list_get_members (EmpathyContactList *list)
 {
-       if (!info) {
-               return;
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
+
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
+               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
        }
 
-       if (info->contact) {
-               g_object_unref (info->contact);
+       return NULL;
+}
+
+GList *
+empathy_contact_list_get_pendings (EmpathyContactList *list)
+{
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
+
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings) {
+               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_pendings (list);
        }
-       g_free (info->message);
 
-       g_slice_free (EmpathyContactListInfo, info);
+       return NULL;
 }
 
-void
-empathy_contact_list_setup (EmpathyContactList *list)
+GList *
+empathy_contact_list_get_all_groups (EmpathyContactList *list)
 {
-       g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
 
-       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->setup) {
-               EMPATHY_CONTACT_LIST_GET_IFACE (list)->setup (list);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups) {
+               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_all_groups (list);
        }
+
+       return NULL;
 }
 
-GossipContact *
-empathy_contact_list_find (EmpathyContactList *list,
-                          const gchar        *id)
+GList *
+empathy_contact_list_get_groups (EmpathyContactList *list,
+                                EmpathyContact     *contact)
 {
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
+       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->find) {
-               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->find (list, id);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups) {
+               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_groups (list, contact);
        }
 
        return NULL;
 }
 
 void
-empathy_contact_list_add (EmpathyContactList *list,
-                         GossipContact      *contact,
-                         const gchar        *message)
+empathy_contact_list_add_to_group (EmpathyContactList *list,
+                                  EmpathyContact     *contact,
+                                  const gchar        *group)
 {
        g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+       g_return_if_fail (group != NULL);
 
-       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add) {
-               EMPATHY_CONTACT_LIST_GET_IFACE (list)->add (list, contact, message);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->add_to_group (list, contact, group);
        }
 }
 
 void
-empathy_contact_list_remove (EmpathyContactList *list,
-                            GossipContact      *contact,
-                            const gchar        *message)
+empathy_contact_list_remove_from_group (EmpathyContactList *list,
+                                       EmpathyContact     *contact,
+                                       const gchar        *group)
 {
        g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+       g_return_if_fail (group != NULL);
 
-       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove) {
-               EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove (list, contact, message);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_from_group (list, contact, group);
        }
 }
 
-GList *
-empathy_contact_list_get_members (EmpathyContactList *list)
+void
+empathy_contact_list_rename_group (EmpathyContactList *list,
+                                  const gchar        *old_group,
+                                  const gchar        *new_group)
 {
-       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (old_group != NULL);
+       g_return_if_fail (new_group != NULL);
 
-       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members) {
-               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_members (list);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->rename_group (list, old_group, new_group);
        }
-
-       return NULL;
 }
 
-GList *
-empathy_contact_list_get_local_pending (EmpathyContactList *list)
+void
+empathy_contact_list_remove_group (EmpathyContactList *list,
+                                  const gchar *group)
 {
-       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST (list), NULL);
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST (list));
+       g_return_if_fail (group != NULL);
 
-       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_local_pending) {
-               return EMPATHY_CONTACT_LIST_GET_IFACE (list)->get_local_pending (list);
+       if (EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group) {
+               EMPATHY_CONTACT_LIST_GET_IFACE (list)->remove_group (list, group);
        }
-
-       return NULL;
 }