#include "empathy-contact-manager.h"
#include "empathy-contact-list.h"
-#include "gossip-utils.h"
-#include "gossip-debug.h"
+#include "empathy-utils.h"
+#include "empathy-debug.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
EMPATHY_TYPE_CONTACT_MANAGER, EmpathyContactManagerPriv))
} ContactManagerRenameGroupData;
typedef struct {
- GossipContact *contact;
+ EmpathyContact *contact;
const gchar *id;
} ContactManagerFindData;
static void empathy_contact_manager_init (EmpathyContactManager *manager);
static void contact_manager_finalize (GObject *object);
static void contact_manager_setup (EmpathyContactList *manager);
-static GossipContact *contact_manager_find (EmpathyContactList *manager,
+static EmpathyContact *contact_manager_find (EmpathyContactList *manager,
const gchar *id);
static void contact_manager_add (EmpathyContactList *manager,
- GossipContact *contact,
+ EmpathyContact *contact,
const gchar *message);
static void contact_manager_remove (EmpathyContactList *manager,
- GossipContact *contact,
+ EmpathyContact *contact,
const gchar *message);
-static GList * contact_manager_get_contacts (EmpathyContactList *manager);
+static GList * contact_manager_get_members (EmpathyContactList *manager);
+static GList * contact_manager_get_local_pending (EmpathyContactList *manager);
+static void contact_manager_process_pending (EmpathyContactList *manager,
+ EmpathyContact *contact,
+ gboolean accept);
static void contact_manager_setup_foreach (McAccount *account,
EmpathyTpContactList *list,
EmpathyContactManager *manager);
static void contact_manager_add_account (EmpathyContactManager *manager,
McAccount *account);
static void contact_manager_added_cb (EmpathyTpContactList *list,
- GossipContact *contact,
+ EmpathyContact *contact,
EmpathyContactManager *manager);
static void contact_manager_removed_cb (EmpathyTpContactList *list,
- GossipContact *contact,
+ EmpathyContact *contact,
+ EmpathyContactManager *manager);
+static void contact_manager_local_pending_cb (EmpathyTpContactList *list,
+ EmpathyContact *contact,
+ const gchar *message,
EmpathyContactManager *manager);
static void contact_manager_destroy_cb (EmpathyTpContactList *list,
EmpathyContactManager *manager);
static void contact_manager_get_groups_foreach (McAccount *account,
EmpathyTpContactList *list,
GList **all_groups);
-static void contact_manager_get_contacts_foreach (McAccount *account,
+static void contact_manager_get_members_foreach (McAccount *account,
+ EmpathyTpContactList *list,
+ GList **contacts);
+static void contact_manager_get_local_pending_foreach (McAccount *account,
EmpathyTpContactList *list,
GList **contacts);
static void contact_manager_status_changed_cb (MissionControl *mc,
static void
contact_manager_iface_init (EmpathyContactListIface *iface)
{
- iface->setup = contact_manager_setup;
- iface->find = contact_manager_find;
- iface->add = contact_manager_add;
- iface->remove = contact_manager_remove;
- iface->get_contacts = contact_manager_get_contacts;
+ iface->setup = contact_manager_setup;
+ iface->find = contact_manager_find;
+ iface->add = contact_manager_add;
+ iface->remove = contact_manager_remove;
+ iface->get_members = contact_manager_get_members;
+ iface->get_local_pending = contact_manager_get_local_pending;
+ iface->process_pending = contact_manager_process_pending;
}
static void
priv = GET_PRIV (manager);
- priv->lists = g_hash_table_new_full (gossip_account_hash,
- gossip_account_equal,
+ priv->lists = g_hash_table_new_full (empathy_account_hash,
+ empathy_account_equal,
(GDestroyNotify) g_object_unref,
(GDestroyNotify) g_object_unref);
- priv->mc = gossip_mission_control_new ();
+ priv->mc = empathy_mission_control_new ();
dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc),
"AccountStatusChanged",
priv->setup = TRUE;
}
-static GossipContact *
+static EmpathyContact *
contact_manager_find (EmpathyContactList *manager,
const gchar *id)
{
static void
contact_manager_add (EmpathyContactList *manager,
- GossipContact *contact,
+ EmpathyContact *contact,
const gchar *message)
{
EmpathyContactManagerPriv *priv;
McAccount *account;
g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
- g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
priv = GET_PRIV (manager);
- account = gossip_contact_get_account (contact);
+ account = empathy_contact_get_account (contact);
list = g_hash_table_lookup (priv->lists, account);
if (list) {
static void
contact_manager_remove (EmpathyContactList *manager,
- GossipContact *contact,
+ EmpathyContact *contact,
const gchar *message)
{
EmpathyContactManagerPriv *priv;
McAccount *account;
g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
- g_return_if_fail (GOSSIP_IS_CONTACT (contact));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
priv = GET_PRIV (manager);
- account = gossip_contact_get_account (contact);
+ account = empathy_contact_get_account (contact);
list = g_hash_table_lookup (priv->lists, account);
if (list) {
}
static GList *
-contact_manager_get_contacts (EmpathyContactList *manager)
+contact_manager_get_members (EmpathyContactList *manager)
{
EmpathyContactManagerPriv *priv;
GList *contacts = NULL;
priv = GET_PRIV (manager);
g_hash_table_foreach (priv->lists,
- (GHFunc) contact_manager_get_contacts_foreach,
+ (GHFunc) contact_manager_get_members_foreach,
&contacts);
return contacts;
}
+static GList *
+contact_manager_get_local_pending (EmpathyContactList *manager)
+{
+ EmpathyContactManagerPriv *priv;
+ GList *pending = NULL;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager), NULL);
+
+ priv = GET_PRIV (manager);
+
+ g_hash_table_foreach (priv->lists,
+ (GHFunc) contact_manager_get_local_pending_foreach,
+ &pending);
+
+ return pending;
+}
+
+static void
+contact_manager_process_pending (EmpathyContactList *manager,
+ EmpathyContact *contact,
+ gboolean accept)
+{
+ EmpathyContactManagerPriv *priv;
+ EmpathyContactList *list;
+ McAccount *account;
+
+ g_return_if_fail (EMPATHY_IS_CONTACT_MANAGER (manager));
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+ priv = GET_PRIV (manager);
+
+ account = empathy_contact_get_account (contact);
+ list = g_hash_table_lookup (priv->lists, account);
+
+ if (list) {
+ empathy_contact_list_process_pending (list, contact, accept);
+ }
+}
+
EmpathyTpContactList *
empathy_contact_manager_get_list (EmpathyContactManager *manager,
McAccount *account)
return g_hash_table_lookup (priv->lists, account);
}
-GossipContact *
+EmpathyContact *
empathy_contact_manager_get_user (EmpathyContactManager *manager,
McAccount *account)
{
return empathy_tp_contact_list_get_user (list);
}
-GossipContact *
+EmpathyContact *
empathy_contact_manager_create (EmpathyContactManager *manager,
McAccount *account,
const gchar *id)
return;
}
- gossip_debug (DEBUG_DOMAIN, "Adding new account: %s",
+ empathy_debug (DEBUG_DOMAIN, "Adding new account: %s",
mc_account_get_display_name (account));
list = empathy_tp_contact_list_new (account);
g_signal_connect (list, "contact-removed",
G_CALLBACK (contact_manager_removed_cb),
manager);
+ g_signal_connect (list, "local-pending",
+ G_CALLBACK (contact_manager_local_pending_cb),
+ manager);
g_signal_connect (list, "destroy",
G_CALLBACK (contact_manager_destroy_cb),
manager);
static void
contact_manager_added_cb (EmpathyTpContactList *list,
- GossipContact *contact,
+ EmpathyContact *contact,
EmpathyContactManager *manager)
{
g_signal_emit_by_name (manager, "contact-added", contact);
static void
contact_manager_removed_cb (EmpathyTpContactList *list,
- GossipContact *contact,
+ EmpathyContact *contact,
EmpathyContactManager *manager)
{
g_signal_emit_by_name (manager, "contact-removed", contact);
}
+static void
+contact_manager_local_pending_cb (EmpathyTpContactList *list,
+ EmpathyContact *contact,
+ const gchar *message,
+ EmpathyContactManager *manager)
+{
+ g_signal_emit_by_name (manager, "local-pending", contact, message);
+}
+
static void
contact_manager_destroy_cb (EmpathyTpContactList *list,
EmpathyContactManager *manager)
account = empathy_tp_contact_list_get_account (list);
- gossip_debug (DEBUG_DOMAIN, "Removing account: %s",
+ empathy_debug (DEBUG_DOMAIN, "Removing account: %s",
mc_account_get_display_name (account));
/* Disconnect signals from the list */
g_signal_handlers_disconnect_by_func (list,
contact_manager_removed_cb,
manager);
+ g_signal_handlers_disconnect_by_func (list,
+ contact_manager_local_pending_cb,
+ manager);
g_signal_handlers_disconnect_by_func (list,
contact_manager_destroy_cb,
manager);
}
static void
-contact_manager_get_contacts_foreach (McAccount *account,
- EmpathyTpContactList *list,
- GList **contacts)
+contact_manager_get_members_foreach (McAccount *account,
+ EmpathyTpContactList *list,
+ GList **contacts)
+{
+ GList *l;
+
+ l = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (list));
+ *contacts = g_list_concat (*contacts, l);
+}
+
+static void
+contact_manager_get_local_pending_foreach (McAccount *account,
+ EmpathyTpContactList *list,
+ GList **contacts)
{
GList *l;
- l = empathy_contact_list_get_contacts (EMPATHY_CONTACT_LIST (list));
+ l = empathy_contact_list_get_local_pending (EMPATHY_CONTACT_LIST (list));
*contacts = g_list_concat (*contacts, l);
}