aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-individual-dialogs.c94
-rw-r--r--libempathy-gtk/empathy-individual-dialogs.h2
-rw-r--r--libempathy-gtk/empathy-individual-view.c16
-rw-r--r--libempathy/empathy-individual-manager.c2
-rw-r--r--libempathy/empathy-individual-manager.h1
5 files changed, 112 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-individual-dialogs.c b/libempathy-gtk/empathy-individual-dialogs.c
index 2c9801059..f7ca788c1 100644
--- a/libempathy-gtk/empathy-individual-dialogs.c
+++ b/libempathy-gtk/empathy-individual-dialogs.c
@@ -29,6 +29,7 @@
#include <telepathy-glib/util.h>
#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
#include <libempathy/empathy-individual-manager.h>
#include <libempathy/empathy-utils.h>
@@ -156,3 +157,96 @@ empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
tp_clear_object (&contact);
}
+
+/*
+ * Block contact dialog
+ */
+gboolean
+empathy_block_individual_dialog_show (GtkWindow *parent,
+ FolksIndividual *individual,
+ gboolean *abusive)
+{
+ EmpathyIndividualManager *manager =
+ empathy_individual_manager_dup_singleton ();
+ GtkWidget *dialog;
+ GtkWidget *abusive_check = NULL;
+ GList *personas, *l;
+ GString *str = g_string_new ("");
+ guint npersonas = 0;
+ gboolean can_report_abuse = FALSE;
+ int res;
+
+ dialog = gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+ _("Block %s?"),
+ folks_aliasable_get_alias (FOLKS_ALIASABLE (individual)));
+
+ /* build a list of personas that support blocking */
+ personas = folks_individual_get_personas (individual);
+
+ for (l = personas; l != NULL; l = l->next)
+ {
+ TpfPersona *persona = l->data;
+ TpContact *contact;
+ EmpathyIndividualManagerFlags flags;
+
+ if (!TPF_IS_PERSONA (persona))
+ continue;
+
+ contact = tpf_persona_get_contact (persona);
+ flags = empathy_individual_manager_get_flags_for_connection (manager,
+ tp_contact_get_connection (contact));
+
+ if (!(flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK))
+ continue;
+ else if (flags & EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE)
+ can_report_abuse = TRUE;
+
+ g_string_append_printf (str, "\n \342\200\242 %s",
+ tp_contact_get_identifier (contact));
+ npersonas++;
+ }
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s\n%s",
+ ngettext ("Are you sure you want to block the following contact?",
+ "Are you sure you want to block the following contacts?",
+ npersonas),
+ str->str);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("_Block"), GTK_RESPONSE_REJECT,
+ NULL);
+
+ if (can_report_abuse)
+ {
+ GtkWidget *vbox;
+
+ vbox = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
+ abusive_check = gtk_check_button_new_with_mnemonic (
+ ngettext ("_Report this contact as abusive",
+ "_Report these contacts as abusive",
+ npersonas));
+
+ gtk_box_pack_start (GTK_BOX (vbox), abusive_check, FALSE, TRUE, 0);
+ gtk_widget_show (abusive_check);
+ }
+
+ g_object_unref (manager);
+ g_string_free (str, TRUE);
+
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (abusive != NULL)
+ {
+ if (abusive_check != NULL)
+ *abusive = gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (abusive_check));
+ else
+ *abusive = FALSE;
+ }
+
+ return res == GTK_RESPONSE_REJECT;
+}
diff --git a/libempathy-gtk/empathy-individual-dialogs.h b/libempathy-gtk/empathy-individual-dialogs.h
index b34a7ab18..f6c402014 100644
--- a/libempathy-gtk/empathy-individual-dialogs.h
+++ b/libempathy-gtk/empathy-individual-dialogs.h
@@ -32,6 +32,8 @@ G_BEGIN_DECLS
void empathy_new_individual_dialog_show (GtkWindow *parent);
void empathy_new_individual_dialog_show_with_individual (GtkWindow *parent,
FolksIndividual *individual);
+gboolean empathy_block_individual_dialog_show (GtkWindow *parent,
+ FolksIndividual *individual, gboolean *abusive);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 4cb8a76f4..cea55a200 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -47,6 +47,7 @@
#include "empathy-individual-menu.h"
#include "empathy-individual-store.h"
#include "empathy-contact-dialogs.h"
+#include "empathy-individual-dialogs.h"
#include "empathy-images.h"
#include "empathy-linking-dialog.h"
#include "empathy-cell-renderer-expander.h"
@@ -2447,12 +2448,21 @@ individual_view_remove_activate_cb (GtkMenuItem *menuitem,
if (res == GTK_RESPONSE_YES || res == GTK_RESPONSE_REJECT)
{
- empathy_individual_manager_remove (manager, individual, "");
+ if (res == GTK_RESPONSE_REJECT &&
+ empathy_block_individual_dialog_show (parent, individual, NULL))
+ {
+ empathy_individual_manager_set_blocked (manager, individual,
+ TRUE);
+ }
+ else
+ {
+ goto finally;
+ }
- if (res == GTK_RESPONSE_REJECT)
- empathy_individual_manager_set_blocked (manager, individual, TRUE);
+ empathy_individual_manager_remove (manager, individual, "");
}
+finally:
g_free (text);
g_object_unref (individual);
g_object_unref (manager);
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index 01eb51951..fd74e4bbe 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -628,6 +628,8 @@ empathy_individual_manager_get_flags_for_connection (
flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP;
if (list_flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_REPORT_ABUSIVE)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE;
return flags;
}
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index daa7ec86a..12f8ccdb0 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -44,6 +44,7 @@ typedef enum
EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS = 1 << 2,
EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP = 1 << 3,
EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK = 1 << 4,
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_REPORT_ABUSIVE = 1 << 5,
} EmpathyIndividualManagerFlags;
typedef struct _EmpathyIndividualManager EmpathyIndividualManager;