static void
account_widget_checkbutton_toggled_cb (GtkWidget *widget,
    EmpathyAccountWidget *self)
{
  gboolean     value;
  gboolean     default_value;
  const gchar *param_name;
  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);

  value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
  param_name = g_object_get_data (G_OBJECT (widget), "param_name");

  /* FIXME: This is ugly! checkbox don't have a "not-set" value so we
   * always unset the param and set the value if different from the
   * default value. */
  empathy_account_settings_unset (priv->settings, param_name);
  default_value = empathy_account_settings_get_boolean (priv->settings,
      param_name);

  if (default_value == value)
    {
      DEBUG ("Unset %s and restore to %d", param_name, default_value);
    }
  else
    {
      DEBUG ("Setting %s to %d", param_name, value);
      empathy_account_settings_set_boolean (priv->settings, param_name, value);
    }

  account_widget_handle_control_buttons_sensitivity (self);
}
static void
update_server_params (EmpathyIrcNetworkChooser *self)
{
  EmpathyIrcNetworkChooserPriv *priv = GET_PRIV (self);
  GSList *servers;
  const gchar *charset;

  g_assert (priv->network != NULL);

  charset = empathy_irc_network_get_charset (priv->network);
  DEBUG ("Setting charset to %s", charset);
  empathy_account_settings_set_string (priv->settings, "charset", charset);

  servers = empathy_irc_network_get_servers (priv->network);
  if (g_slist_length (servers) > 0)
    {
      /* set the first server as CM server */
      EmpathyIrcServer *server = servers->data;
      gchar *address;
      guint port;
      gboolean ssl;
      gchar *service;

      g_object_get (server,
          "address", &address,
          "port", &port,
          "ssl", &ssl,
          NULL);

      DEBUG ("Setting server to %s", address);
      empathy_account_settings_set_string (priv->settings, "server", address);
      DEBUG ("Setting port to %u", port);
      empathy_account_settings_set_uint32 (priv->settings, "port", port);
      DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
      empathy_account_settings_set_boolean (priv->settings, "use-ssl", ssl);

      /* Set Account.Service */
      service = dup_network_service (priv->network);
      DEBUG ("Setting Service to %s", service);
      empathy_account_settings_set_service (priv->settings, service);

      g_free (address);
      g_free (service);
    }
  else
    {
      /* No server. Unset values */
      unset_server_params (self);
    }

  g_slist_foreach (servers, (GFunc) g_object_unref, NULL);
  g_slist_free (servers);
}
/**
 * set_password_prompt_if_needed:
 *
 * If @password is not empty, this function sets the 'password-prompt' param
 * on @ac_settings. This will ensure that Idle actually asks for the password
 * when connecting.
 *
 * Return: %TRUE if the password-prompt param has been changed
 */
static gboolean
set_password_prompt_if_needed (EmpathyAccountSettings *ac_settings,
    const gchar *password)
{
  gboolean prompt;

  prompt = !tp_str_empty (password);

  if (prompt == empathy_account_settings_get_boolean (ac_settings,
        "password-prompt"))
    return FALSE;

  empathy_account_settings_set_boolean (ac_settings, "password-prompt",
      prompt);

  return TRUE;
}
Ejemplo n.º 4
0
static void
account_assistant_protocol_changed_cb (GtkComboBox *chooser,
    EmpathyAccountAssistant *self)
{
  TpConnectionManager *cm;
  TpConnectionManagerProtocol *proto;
  EmpathyAccountSettings *settings;
  EmpathyAccountAssistantPriv *priv;
  char *str;
  GtkWidget *account_widget;
  EmpathyAccountWidget *widget_object = NULL;
  gboolean is_gtalk;

  priv = GET_PRIV (self);

  cm = empathy_protocol_chooser_dup_selected (
      EMPATHY_PROTOCOL_CHOOSER (chooser), &proto, &is_gtalk);

  if (cm == NULL || proto == NULL)
    /* we are not ready yet */
    return;

  /* Create account */
  /* To translator: %s is the protocol name */
  str = g_strdup_printf (_("New %s account"),
      empathy_protocol_name_to_display_name (
          is_gtalk ? "gtalk" : proto->name));

  settings = empathy_account_settings_new (cm->name, proto->name, str);

  if (is_gtalk)
    empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
      NULL, NULL);

  if (priv->first_resp == RESPONSE_CREATE_ACCOUNT)
    empathy_account_settings_set_boolean (settings, "register", TRUE);

  widget_object = empathy_account_widget_new_for_protocol (settings, TRUE);
  account_widget = empathy_account_widget_get_widget (widget_object);

  if (priv->current_account_widget != NULL)
    {
      g_signal_handlers_disconnect_by_func (priv->current_widget_object,
          account_assistant_handle_apply_cb, self);
      gtk_widget_destroy (priv->current_account_widget);
    }

  priv->current_account_widget = account_widget;
  priv->current_widget_object = widget_object;

  if (priv->settings != NULL)
    g_object_unref (priv->settings);

  priv->settings = settings;

  g_signal_connect (priv->current_widget_object, "handle-apply",
      G_CALLBACK (account_assistant_handle_apply_cb), self);

  gtk_box_pack_start (GTK_BOX (priv->enter_or_create_page), account_widget,
      FALSE, FALSE, 0);
  gtk_widget_show (account_widget);

  g_free (str);
}
Ejemplo n.º 5
0
static void
update_server_params (EmpathyAccountWidgetIrc *settings)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  EmpathyIrcNetwork *network;
  GSList *servers;
  gchar *charset;
  EmpathyAccountSettings *ac_settings;

  g_object_get (settings->self, "settings", &ac_settings, NULL);

  if (!gtk_combo_box_get_active_iter (
        GTK_COMBO_BOX (settings->combobox_network), &iter))
    {
      unset_server_params (settings);
      return;
    }

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (settings->combobox_network));
  gtk_tree_model_get (model, &iter, COL_NETWORK_OBJ, &network, -1);

  g_assert (network != NULL);

  g_object_get (network, "charset", &charset, NULL);
  DEBUG ("Setting charset to %s", charset);
  empathy_account_settings_set_string (ac_settings, "charset", charset);
  g_free (charset);

  servers = empathy_irc_network_get_servers (network);
  if (g_slist_length (servers) > 0)
    {
      /* set the first server as CM server */
      EmpathyIrcServer *server = servers->data;
      gchar *address;
      guint port;
      gboolean ssl;

      g_object_get (server,
          "address", &address,
          "port", &port,
          "ssl", &ssl,
          NULL);

      DEBUG ("Setting server to %s", address);
      empathy_account_settings_set_string (ac_settings, "server", address);
      DEBUG ("Setting port to %u", port);
      empathy_account_settings_set_uint32 (ac_settings, "port", port);
      DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
      empathy_account_settings_set_boolean (ac_settings, "use-ssl", ssl);

      g_free (address);
    }
  else
    {
      /* No server. Unset values */
      unset_server_params (settings);
    }

  g_slist_foreach (servers, (GFunc) g_object_unref, NULL);
  g_slist_free (servers);
  g_object_unref (network);
}
EmpathyAccountSettings *
empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self)
{
  EmpathyAccountSettings *settings = NULL;
  gchar *str;
  const gchar *display_name;
  TpConnectionManager *cm;
  TpConnectionManagerProtocol *proto;
  gchar *service = NULL;

  cm = empathy_protocol_chooser_dup_selected (self, &proto, &service);
  if (cm == NULL || proto == NULL)
    goto out;

  if (service != NULL)
    display_name = empathy_service_name_to_display_name (service);
  else
    display_name = empathy_protocol_name_to_display_name (proto->name);

  /* Create account */
  /* To translator: %s is the name of the protocol, such as "Google Talk" or
   * "Yahoo!"
   */
  str = g_strdup_printf (_("New %s account"), display_name);
  settings = empathy_account_settings_new (cm->name, proto->name, service, str);

  g_free (str);

  if (!tp_strdiff (service, "google-talk"))
    {
      gchar *fallback_servers[] = {
          "talkx.l.google.com",
          "talkx.l.google.com:443,oldssl",
          "talkx.l.google.com:80",
          NULL};

      gchar *extra_certificate_identities[] = {
          "talk.google.com",
          NULL};

      empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
          NULL, NULL);
      empathy_account_settings_set_string (settings, "server",
          extra_certificate_identities[0]);
      empathy_account_settings_set_boolean (settings, "require-encryption",
          TRUE);
      empathy_account_settings_set_strv (settings, "fallback-servers",
          fallback_servers);

      if (empathy_account_settings_have_tp_param (settings,
              "extra-certificate-identities"))
        {
          empathy_account_settings_set_strv (settings,
              "extra-certificate-identities", extra_certificate_identities);
        }
    }
  else if (!tp_strdiff (service, "facebook"))
    {
      empathy_account_settings_set_icon_name_async (settings, "im-facebook",
          NULL, NULL);
      empathy_account_settings_set_boolean (settings, "require-encryption",
          TRUE);
      empathy_account_settings_set_string (settings, "server",
          "chat.facebook.com");
    }

out:
  tp_clear_object (&cm);
  g_free (service);
  return settings;
}