Exemple #1
0
static void
empathy_tls_dialog_constructed (GObject *object)
{
  GtkWidget *content_area, *expander, *details, *checkbox;
  gchar *text;
  EmpathyTLSDialog *self = EMPATHY_TLS_DIALOG (object);
  GtkMessageDialog *message_dialog = GTK_MESSAGE_DIALOG (self);
  GtkDialog *dialog = GTK_DIALOG (self);
  EmpathyTLSDialogPriv *priv = GET_PRIV (self);

  gtk_dialog_add_buttons (dialog,
      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      _("C_ontinue"), GTK_RESPONSE_YES,
      NULL);

  text = reason_to_string (self);

  g_object_set (message_dialog,
      "title", _("Untrusted connection"),
      "text", _("This connection is untrusted. Would you like to "
          "continue anyway?"),
      "secondary-text", text,
      NULL);

  g_free (text);

  content_area = gtk_dialog_get_content_area (dialog);

  checkbox = gtk_check_button_new_with_label (
      _("Remember this choice for future connections"));
  gtk_box_pack_end (GTK_BOX (content_area), checkbox, FALSE, FALSE, 0);
  gtk_widget_show (checkbox);
  g_signal_connect (checkbox, "toggled", G_CALLBACK (checkbox_toggled_cb),
      self);

  text = g_strdup_printf ("<b>%s</b>", _("Certificate Details"));
  expander = gtk_expander_new (text);
  gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE);
  gtk_box_pack_end (GTK_BOX (content_area), expander, TRUE, TRUE, 0);
  gtk_widget_show (expander);

  g_free (text);

  details = build_gcr_widget (self);
  gtk_container_add (GTK_CONTAINER (expander), details);
  gtk_widget_show (details);

  gtk_window_set_keep_above (GTK_WINDOW (self), TRUE);

  tp_g_signal_connect_object (priv->certificate, "invalidated",
      G_CALLBACK (certificate_invalidated_cb), self, 0);
}
Exemple #2
0
static void
tls_dialog_response_cb (GtkDialog *dialog,
    gint response_id,
    gpointer user_data)
{
  TpTLSCertificate *certificate = NULL;
  TpTLSCertificateRejectReason reason = 0;
  GHashTable *details = NULL;
  EmpathyTLSDialog *tls_dialog = EMPATHY_TLS_DIALOG (dialog);
  gboolean remember = FALSE;
  EmpathyTLSVerifier *verifier = EMPATHY_TLS_VERIFIER (user_data);

  g_object_get (tls_dialog,
      "certificate", &certificate,
      "reason", &reason,
      "remember", &remember,
      "details", &details,
      NULL);

  DEBUG ("Response %d (remember: %d)", response_id, remember);

  gtk_widget_destroy (GTK_WIDGET (dialog));

  if (response_id == GTK_RESPONSE_YES)
    {
      tp_tls_certificate_accept_async (certificate, NULL, NULL);
    }
  else
    {
      tp_asv_set_boolean (details, "user-requested", TRUE);
      tp_tls_certificate_add_rejection (certificate, reason, NULL,
          g_variant_new_parsed ("{ 'user-requested': <%b> }", TRUE));

      tp_tls_certificate_reject_async (certificate, NULL, NULL);
    }

  if (remember)
    empathy_tls_verifier_store_exception (verifier);

  g_object_unref (certificate);
  g_hash_table_unref (details);

  /* restart the timeout */
  num_windows--;

  if (num_windows > 0)
    return;

  start_timer ();
}