static void
chatroom_changed_cb (EmpathyChatroom *chatroom,
    GParamSpec *spec,
    EmpathyChatroomManager *self)
{
  reset_save_timeout (self);
}
Beispiel #2
0
gboolean
empathy_chatroom_manager_add (EmpathyChatroomManager *manager,
			     EmpathyChatroom        *chatroom)
{
  EmpathyChatroomManagerPriv *priv;

  g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), FALSE);
  g_return_val_if_fail (EMPATHY_IS_CHATROOM (chatroom), FALSE);

  priv = GET_PRIV (manager);

  /* don't add more than once */
  if (!empathy_chatroom_manager_find (manager,
      empathy_chatroom_get_account (chatroom),
      empathy_chatroom_get_room (chatroom)))
    {
      add_chatroom (manager, chatroom);

      if (empathy_chatroom_is_favorite (chatroom))
        reset_save_timeout (manager);

      g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom);
      return TRUE;
    }

  return FALSE;
}
static void
network_modified (EmpathyIrcNetwork *network,
                  EmpathyIrcNetworkManager *self)
{
  EmpathyIrcNetworkManagerPriv *priv = GET_PRIV (self);

  network->user_defined = TRUE;

  if (!priv->loading)
    {
      priv->have_to_save = TRUE;
      reset_save_timeout (self);
    }
}
/**
 * empathy_irc_network_manager_remove:
 * @manager: an #EmpathyIrcNetworkManager
 * @network: the #EmpathyIrcNetwork to remove
 *
 * Remove an #EmpathyIrcNetwork from the given #EmpathyIrcNetworkManager.
 *
 */
void
empathy_irc_network_manager_remove (EmpathyIrcNetworkManager *self,
                                    EmpathyIrcNetwork *network)
{
  EmpathyIrcNetworkManagerPriv *priv;

  g_return_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self));
  g_return_if_fail (EMPATHY_IS_IRC_NETWORK (network));

  priv = GET_PRIV (self);

  network->user_defined = TRUE;
  network->dropped = TRUE;

  priv->have_to_save = TRUE;
  reset_save_timeout (self);
}
static void
chatroom_manager_remove_link (EmpathyChatroomManager *manager,
    GList *l)
{
  EmpathyChatroomManagerPriv *priv;
  EmpathyChatroom *chatroom;

  priv = GET_PRIV (manager);

  chatroom = l->data;

  if (empathy_chatroom_is_favorite (chatroom))
    reset_save_timeout (manager);

  priv->chatrooms = g_list_delete_link (priv->chatrooms, l);

  g_signal_emit (manager, signals[CHATROOM_REMOVED], 0, chatroom);
  g_signal_handlers_disconnect_by_func (chatroom, chatroom_changed_cb, manager);

  g_object_unref (chatroom);
}
/**
 * empathy_irc_network_manager_add:
 * @manager: an #EmpathyIrcNetworkManager
 * @network: the #EmpathyIrcNetwork to add
 *
 * Add an #EmpathyIrcNetwork to the given #EmpathyIrcNetworkManager.
 *
 */
void
empathy_irc_network_manager_add (EmpathyIrcNetworkManager *self,
                                 EmpathyIrcNetwork *network)
{
  EmpathyIrcNetworkManagerPriv *priv;
  gchar *id = NULL;

  g_return_if_fail (EMPATHY_IS_IRC_NETWORK_MANAGER (self));
  g_return_if_fail (EMPATHY_IS_IRC_NETWORK (network));

  priv = GET_PRIV (self);

  /* generate an id for this network */
  do
    {
      g_free (id);
      id = g_strdup_printf ("id%u", ++priv->last_id);
    } while (g_hash_table_lookup (priv->networks, id) != NULL &&
        priv->last_id < G_MAXUINT);

  if (priv->last_id == G_MAXUINT)
    {
      DEBUG ("Can't add network: too many networks using a similiar ID");
      return;
    }

  DEBUG ("add server with \"%s\" as ID", id);

  network->user_defined = TRUE;
  add_network (self, network, id);

  priv->have_to_save = TRUE;
  reset_save_timeout (self);

  g_free (id);
}