+ g_signal_connect_after (dialog, "response", G_CALLBACK (
+ debug_window_pastebin_response_dialog_closed_cb), buffer);
+}
+
+static void
+debug_window_message_dialog (EmpathyDebugWindow *self,
+ const gchar *primary_text,
+ const gchar *secondary_text)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (self),
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
+ "%s", _(primary_text));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _(secondary_text));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog),
+ GTK_WINDOW (self));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
+
+static void
+debug_window_send_to_pastebin (EmpathyDebugWindow *self,
+ gchar *debug_data)
+{
+ SoupSession *session;
+ SoupMessage *msg;
+ gchar *api_dev_key, *api_paste_code, *api_paste_name, *formdata;
+
+ if (tp_str_empty (debug_data))
+ {
+ debug_window_message_dialog (self, "Error", "No data to send");
+ return;
+ }
+
+ /* Constructing a valid URL for http post. See http://pastebin.com/api#2 */
+
+ /* The api_dev_key is the author's developer key to access the Pastebin API
+ * This developer key is published here with the autorization of pastebin;
+ * see PASTEBIN-API-KEY.txt */
+ api_dev_key = soup_uri_encode ("f6ccfabfdcd4b77b825ee38a30d11d52", NULL);
+ api_paste_code = soup_uri_encode (debug_data, NULL);
+ api_paste_name = soup_uri_encode ("Empathy debug data", NULL);
+ formdata = g_strdup_printf ("api_dev_key=%s&api_paste_code=%s"
+ "&api_paste_name=%s&api_paste_format=text&api_option=paste",
+ api_dev_key, api_paste_code, api_paste_name);
+
+ session = soup_session_async_new ();
+
+ msg = soup_message_new ("POST", "http://pastebin.com/api/api_post.php");
+ soup_message_set_request (msg,
+ "application/x-www-form-urlencoded;charset=UTF-8", SOUP_MEMORY_COPY,
+ formdata, strlen (formdata));
+
+ g_free (api_dev_key);
+ g_free (api_paste_code);
+ g_free (api_paste_name);
+ g_free (formdata);
+
+ soup_session_queue_message (session, msg, debug_window_pastebin_callback,
+ self);
+}
+
+static void
+debug_window_send_to_pastebin_cb (GtkToolButton *tool_button,
+ EmpathyDebugWindow *self)
+{
+ gchar *debug_data = NULL;
+
+ DEBUG ("Preparing debug data for sending to pastebin.");
+
+ gtk_tree_model_foreach (self->priv->store_filter,
+ debug_window_copy_model_foreach, &debug_data);
+
+ debug_window_send_to_pastebin (self, debug_data);
+ g_free (debug_data);