int polari_room_compare (PolariRoom *room, PolariRoom *other) { TpAccount *account1, *account2; TpHandleType type1, type2; TpConnection *conn; g_return_val_if_fail (POLARI_IS_ROOM (room) && POLARI_IS_ROOM (other), 0); g_return_val_if_fail (room->priv->channel && other->priv->channel, 0); conn = tp_channel_get_connection (room->priv->channel); account1 = tp_connection_get_account (conn); conn = tp_channel_get_connection (other->priv->channel); account2 = tp_connection_get_account (conn); if (account1 != account2) return strcmp (tp_account_get_display_name (account1), tp_account_get_display_name (account2)); tp_channel_get_handle (room->priv->channel, &type1); tp_channel_get_handle (other->priv->channel, &type2); if (type1 != type2) return type1 == TP_HANDLE_TYPE_ROOM ? -1 : 1; return strcmp (room->priv->display_name, other->priv->display_name); }
static void request_channel (ChVisitor *self, TpContact *contact) { TpAccountChannelRequest *req; TpAccount *account; TpConnection *connection; connection = tp_contact_get_connection (contact); account = tp_connection_get_account (connection); req = tp_account_channel_request_new_text (account, 0); tp_account_channel_request_set_target_contact (req, contact); ch_visitor_incref (self); tp_account_channel_request_ensure_and_handle_channel_async ( req, NULL, channel_request_cb, self); }
static void chat_conversations_list_connection_prepare (GObject *source_object, GAsyncResult *res, gpointer user_data) { ChatConversationsList *self = CHAT_CONVERSATIONS_LIST (user_data); ChatConversationsListPrivate *priv = self->priv; GError *error; GList *contacts = NULL; GPtrArray *contact_list = NULL; TpAccount *account; TpConnection *conn = TP_CONNECTION (source_object); TpContactListState state; guint i; error = NULL; if (!tp_proxy_prepare_finish (source_object, res, &error)) { g_warning ("Unable to prepare the connection: %s", error->message); g_error_free (error); goto out; } state = tp_connection_get_contact_list_state (conn); if (state != TP_CONTACT_LIST_STATE_SUCCESS) { g_warning ("Value of connection:contact-list-state %p was %d", conn, state); goto out; } account = tp_connection_get_account (conn); contact_list = tp_connection_dup_contact_list (conn); for (i = 0; i < contact_list->len; i++) { ChatConversationsListGetFilteredEventsData *data; TpContact *contact; TplEntity *entity; contact = TP_CONTACT (g_ptr_array_index (contact_list, i)); entity = tpl_entity_new_from_tp_contact (contact, TPL_ENTITY_CONTACT); if (tpl_log_manager_exists (priv->lm, account, entity, TPL_EVENT_MASK_TEXT)) { g_message ("%s", tp_contact_get_alias (contact)); contacts = g_list_prepend (contacts, g_object_ref (contact)); data = chat_conversations_list_get_filtered_events_data_new (self, contact); tpl_log_manager_get_filtered_events_async (priv->lm, account, entity, TPL_EVENT_MASK_TEXT, 1, NULL, NULL, chat_conversations_list_get_filtered_events, data); } g_object_unref (entity); } g_hash_table_insert (priv->accounts, g_object_ref (account), contacts); out: if (contact_list != NULL) g_ptr_array_unref (contact_list); g_object_unref (self); }