gtk-dialog.c 102 KB
Newer Older
cypherpunk's avatar
cypherpunk committed
1
/*
cypherpunk's avatar
   
cypherpunk committed
2
 *  Off-the-Record Messaging plugin for pidgin
Rob Smits's avatar
Rob Smits committed
3
 *  Copyright (C) 2004-2012  Ian Goldberg, Rob Smits,
cypherpunk's avatar
   
cypherpunk committed
4
 *                           Chris Alexander, Willy Lew,
Rob Smits's avatar
Rob Smits committed
5
 *                           Lisa Du, Nikita Borisov
cypherpunk's avatar
cypherpunk committed
6
7
8
9
10
11
12
13
14
15
16
17
18
 *                           <otr@cypherpunks.ca>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of version 2 of the GNU General Public License as
 *  published by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
Rob Smits's avatar
Rob Smits committed
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cypherpunk's avatar
cypherpunk committed
20
21
 */

cypherpunk's avatar
cypherpunk committed
22
23
24
25
26
/* config.h */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

cypherpunk's avatar
cypherpunk committed
27
28
29
30
31
32
33
34
/* system headers */
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>

/* gcrypt headers */
#include <gcrypt.h>

cypherpunk's avatar
   
cypherpunk committed
35
/* purple headers */
cypherpunk's avatar
   
cypherpunk committed
36
#include "version.h"
cypherpunk's avatar
   
cypherpunk committed
37
#include "pidginstock.h"
cypherpunk's avatar
cypherpunk committed
38
39
40
#include "plugin.h"
#include "notify.h"
#include "gtkconv.h"
cypherpunk's avatar
   
cypherpunk committed
41
42
#include "gtkutils.h"
#include "gtkimhtml.h"
cypherpunk's avatar
cypherpunk committed
43
#include "util.h"
cypherpunk's avatar
   
cypherpunk committed
44
45
46
#include "core.h"
#include "gtkmenutray.h"
#include "tooltipmenu.h"
cypherpunk's avatar
cypherpunk committed
47

cypherpunk's avatar
cypherpunk committed
48
49
50
51
52
#ifdef ENABLE_NLS
/* internationalisation headers */
#include <glib/gi18n-lib.h>
#endif

cypherpunk's avatar
cypherpunk committed
53
54
55
56
57
58
/* libotr headers */
#include <libotr/dh.h>
#include <libotr/privkey.h>
#include <libotr/proto.h>
#include <libotr/message.h>
#include <libotr/userstate.h>
Rob Smits's avatar
Rob Smits committed
59
#include <libotr/instag.h>
cypherpunk's avatar
cypherpunk committed
60

cypherpunk's avatar
   
cypherpunk committed
61
/* purple-otr headers */
cypherpunk's avatar
cypherpunk committed
62
63
#include "otr-plugin.h"
#include "dialogs.h"
cypherpunk's avatar
cypherpunk committed
64
#include "gtk-dialog.h"
cypherpunk's avatar
cypherpunk committed
65
#include "ui.h"
cypherpunk's avatar
   
cypherpunk committed
66
67
68
69
70
71
72
73
74
#include "otr-icons.h"

static GHashTable * otr_win_menus = 0;
static GHashTable * otr_win_status = 0;

static int img_id_not_private = 0;
static int img_id_unverified = 0;
static int img_id_private = 0;
static int img_id_finished = 0;
cypherpunk's avatar
cypherpunk committed
75

cypherpunk's avatar
   
cypherpunk committed
76

cypherpunk's avatar
cypherpunk committed
77
typedef struct {
cypherpunk's avatar
   
cypherpunk committed
78
    ConnContext *context;       /* The context used to fire library code */
Rob Smits's avatar
Rob Smits committed
79
80
    GtkEntry* question_entry;   /* The text entry field containing the user
				 * question */
cypherpunk's avatar
   
cypherpunk committed
81
    GtkEntry *entry;	        /* The text entry field containing the secret */
Rob Smits's avatar
Rob Smits committed
82
83
    int smp_type;               /* Whether the SMP type is based on question
				 * challenge (0) or shared secret (1) */
cypherpunk's avatar
   
cypherpunk committed
84
    gboolean responder;	        /* Whether or not this is the first side to give
Rob Smits's avatar
Rob Smits committed
85
				 * their secret */
cypherpunk's avatar
cypherpunk committed
86
87
88
89
90
91
92
93
94
95
} SmpResponsePair;

/* Information used by the plugin that is specific to both the
 * application and connection. */
typedef struct dialog_context_data {
    GtkWidget       *smp_secret_dialog;
    SmpResponsePair *smp_secret_smppair;
    GtkWidget       *smp_progress_dialog;
    GtkWidget       *smp_progress_bar;
    GtkWidget       *smp_progress_label;
Rob Smits's avatar
Rob Smits committed
96
    otrl_instag_t   their_instance;
cypherpunk's avatar
cypherpunk committed
97
98
} SMPData;

cypherpunk's avatar
   
cypherpunk committed
99
100
typedef struct {
    SmpResponsePair *smppair;
cypherpunk's avatar
   
cypherpunk committed
101
    GtkEntry        *one_way_entry;
cypherpunk's avatar
   
cypherpunk committed
102
103
104
105
    GtkEntry        *two_way_entry;
    GtkWidget       *notebook;
} AuthSignalData;

Rob Smits's avatar
Rob Smits committed
106
107
108
109
110
111
112
113
114
115
typedef struct {
    enum {
	convctx_none,
	convctx_conv,
	convctx_ctx
    } convctx_type;
    PurpleConversation *conv;
    ConnContext *context;
} ConvOrContext;

Rob Smits's avatar
Rob Smits committed
116
static gint get_new_instance_index(PurpleConversation *conv) {
Rob Smits's avatar
Rob Smits committed
117
118
119
120
    gint * max_index = (gint *)
	    purple_conversation_get_data(conv, "otr-max_idx");
    *max_index = (*max_index) + 1;
    return *max_index;
Rob Smits's avatar
Rob Smits committed
121
122
}

Rob Smits's avatar
Rob Smits committed
123
static gint get_context_instance_to_index(PurpleConversation *conv,
Rob Smits's avatar
Rob Smits committed
124
125
126
	ConnContext *context) {
    GHashTable * conv_to_idx_map =
	    purple_conversation_get_data(conv, "otr-conv_to_idx");
Rob Smits's avatar
Rob Smits committed
127
    gpointer index = NULL;
Rob Smits's avatar
Rob Smits committed
128

Rob Smits's avatar
Rob Smits committed
129
    if (!g_hash_table_lookup_extended(conv_to_idx_map, context, NULL, &index)) {
Rob Smits's avatar
Rob Smits committed
130
	index = g_malloc(sizeof(gint));
Rob Smits's avatar
Rob Smits committed
131
132
	*(gint *)index = get_new_instance_index(conv);
	g_hash_table_replace(conv_to_idx_map, context, index);
Rob Smits's avatar
Rob Smits committed
133
134
    }

Rob Smits's avatar
Rob Smits committed
135
    return *(gint *)index;
Rob Smits's avatar
Rob Smits committed
136
137
}

cypherpunk's avatar
cypherpunk committed
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
static void close_progress_window(SMPData *smp_data)
{
    if (smp_data->smp_progress_dialog) {
	gtk_dialog_response(GTK_DIALOG(smp_data->smp_progress_dialog),
		GTK_RESPONSE_REJECT);
    }
    smp_data->smp_progress_dialog = NULL;
    smp_data->smp_progress_bar = NULL;
    smp_data->smp_progress_label = NULL;
}

static void otrg_gtk_dialog_free_smp_data(PurpleConversation *conv)
{
    SMPData *smp_data = purple_conversation_get_data(conv, "otr-smpdata");
    if (!smp_data) return;

    if (smp_data->smp_secret_dialog) {
	gtk_dialog_response(GTK_DIALOG(smp_data->smp_secret_dialog),
		GTK_RESPONSE_REJECT);
    }
    smp_data->smp_secret_dialog = NULL;
    smp_data->smp_secret_smppair = NULL;

    close_progress_window(smp_data);

    free(smp_data);

    g_hash_table_remove(conv->data, "otr-smpdata");
}

static void otrg_gtk_dialog_add_smp_data(PurpleConversation *conv)
{
    SMPData *smp_data = malloc(sizeof(SMPData));
    smp_data->smp_secret_dialog = NULL;
    smp_data->smp_secret_smppair = NULL;
    smp_data->smp_progress_dialog = NULL;
    smp_data->smp_progress_bar = NULL;
    smp_data->smp_progress_label = NULL;
Rob Smits's avatar
Rob Smits committed
176
177
178
    /* Chosen as initialized value since libotr should never allow
     * this as a "their_instance" value */
    smp_data->their_instance = OTRL_INSTAG_BEST;
cypherpunk's avatar
cypherpunk committed
179
180
181
182

    purple_conversation_set_data(conv, "otr-smpdata", smp_data);
}

cypherpunk's avatar
   
cypherpunk committed
183
184
static GtkWidget *otr_icon(GtkWidget *image, TrustLevel level,
	gboolean sensitivity)
cypherpunk's avatar
   
cypherpunk committed
185
186
{
    GdkPixbuf *pixbuf = NULL;
cypherpunk's avatar
   
cypherpunk committed
187
    const guint8 *data = NULL;
cypherpunk's avatar
   
cypherpunk committed
188
189
190

    switch(level) {
	case TRUST_NOT_PRIVATE:
cypherpunk's avatar
   
cypherpunk committed
191
	    data = not_private_pixbuf;
cypherpunk's avatar
   
cypherpunk committed
192
193
	    break;
	case TRUST_UNVERIFIED:
cypherpunk's avatar
   
cypherpunk committed
194
	    data = unverified_pixbuf;
cypherpunk's avatar
   
cypherpunk committed
195
196
	    break;
	case TRUST_PRIVATE:
cypherpunk's avatar
   
cypherpunk committed
197
	    data = private_pixbuf;
cypherpunk's avatar
   
cypherpunk committed
198
	    break;
cypherpunk's avatar
   
cypherpunk committed
199
	case TRUST_FINISHED:
cypherpunk's avatar
   
cypherpunk committed
200
	    data = finished_pixbuf;
cypherpunk's avatar
   
cypherpunk committed
201
	    break;
cypherpunk's avatar
   
cypherpunk committed
202
203
    }

cypherpunk's avatar
   
cypherpunk committed
204
    pixbuf = gdk_pixbuf_new_from_inline(-1, data, FALSE, NULL);
cypherpunk's avatar
   
cypherpunk committed
205
206
207
208
209
210
211
    if (image) {
	gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
    } else {
	image = gtk_image_new_from_pixbuf(pixbuf);
    }
    gdk_pixbuf_unref(pixbuf);

cypherpunk's avatar
   
cypherpunk committed
212
213
    gtk_widget_set_sensitive (image, sensitivity);

cypherpunk's avatar
   
cypherpunk committed
214
215
216
    return image;
}

cypherpunk's avatar
cypherpunk committed
217
218
219
220
221
static void message_response_cb(GtkDialog *dialog, gint id, GtkWidget *widget)
{
    gtk_widget_destroy(GTK_WIDGET(widget));
}

Rob Smits's avatar
Rob Smits committed
222
223
/* Forward declarations for the benefit of smp_message_response_cb/redraw
 * authvbox */
cypherpunk's avatar
cypherpunk committed
224
static void verify_fingerprint(GtkWindow *parent, Fingerprint *fprint);
cypherpunk's avatar
   
cypherpunk committed
225
static void add_vrfy_fingerprint(GtkWidget *vbox, void *data);
cypherpunk's avatar
   
cypherpunk committed
226
227
228
229
static struct vrfy_fingerprint_data* vrfy_fingerprint_data_new(
	Fingerprint *fprint);
static void vrfy_fingerprint_destroyed(GtkWidget *w,
	struct vrfy_fingerprint_data *vfd);
cypherpunk's avatar
   
cypherpunk committed
230
231
static void conversation_switched ( PurpleConversation *conv, void * data );

cypherpunk's avatar
cypherpunk committed
232
233
234
235
236
237
238
239
240
static GtkWidget *create_smp_progress_dialog(GtkWindow *parent,
	ConnContext *context);

/* Called when a button is pressed on the "progress bar" smp dialog */
static void smp_progress_response_cb(GtkDialog *dialog, gint response,
	ConnContext *context)
{
    PurpleConversation *conv = otrg_plugin_context_to_conv(context, 0);
    SMPData *smp_data = NULL;
Rob Smits's avatar
Rob Smits committed
241

cypherpunk's avatar
cypherpunk committed
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
    if (conv) {
	gdouble frac;

	smp_data = purple_conversation_get_data(conv, "otr-smpdata");
	frac = gtk_progress_bar_get_fraction(
		GTK_PROGRESS_BAR(smp_data->smp_progress_bar));

	if (frac != 0.0 && frac != 1.0 && response == GTK_RESPONSE_REJECT) {
	    otrg_plugin_abort_smp(context);
	}
    }
    /* In all cases, destroy the current window */
    gtk_widget_destroy(GTK_WIDGET(dialog));

    /* Clean up variables pointing to the destroyed objects */

    if (smp_data) {
	smp_data->smp_progress_bar = NULL;
	smp_data->smp_progress_label = NULL;
	smp_data->smp_progress_dialog = NULL;
    }
}

/* Called when a button is pressed on the "enter the secret" smp dialog
 * The data passed contains a pointer to the text entry field containing
 * the entered secret as well as the current context.
 */
static void smp_secret_response_cb(GtkDialog *dialog, gint response,
cypherpunk's avatar
   
cypherpunk committed
270
	AuthSignalData *auth_opt_data)
cypherpunk's avatar
cypherpunk committed
271
{
cypherpunk's avatar
   
cypherpunk committed
272
273
274
    ConnContext* context;
    PurpleConversation *conv;
    SMPData *smp_data;
cypherpunk's avatar
   
cypherpunk committed
275
    SmpResponsePair *smppair;
cypherpunk's avatar
   
cypherpunk committed
276

cypherpunk's avatar
   
cypherpunk committed
277
    if (!auth_opt_data) return;
Rob Smits's avatar
Rob Smits committed
278

cypherpunk's avatar
   
cypherpunk committed
279
    smppair = auth_opt_data->smppair;
Rob Smits's avatar
Rob Smits committed
280

cypherpunk's avatar
cypherpunk committed
281
282
    if (!smppair) return;

cypherpunk's avatar
   
cypherpunk committed
283
    context = smppair->context;
cypherpunk's avatar
cypherpunk committed
284

cypherpunk's avatar
   
cypherpunk committed
285
    if (response == GTK_RESPONSE_ACCEPT && smppair->entry) {
Rob Smits's avatar
Rob Smits committed
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
	GtkEntry* entry = smppair->entry;
	char *secret;
	size_t secret_len;

	GtkEntry* question_entry = smppair->question_entry;

	const char *user_question = NULL;


	if (context == NULL || context->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
	    return;
	}

	secret = g_strdup(gtk_entry_get_text(entry));
	secret_len = strlen(secret);

	if (smppair->responder) {
	    otrg_plugin_continue_smp(context, (const unsigned char *)secret,
		    secret_len);

	} else {

	    if (smppair->smp_type == 0) {
		if (!question_entry) {
		    return;
		}

		user_question = gtk_entry_get_text(question_entry);

		if (user_question == NULL || strlen(user_question) == 0) {
		    return;
		}
	    }

	    /* pass user question here */
	    otrg_plugin_start_smp(context, user_question,
		    (const unsigned char *)secret, secret_len);

	}

	g_free(secret);

	/* launch progress bar window */
	create_smp_progress_dialog(GTK_WINDOW(dialog), context);
cypherpunk's avatar
   
cypherpunk committed
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
    } else if (response == GTK_RESPONSE_HELP) {
	char *helpurl = g_strdup_printf("%s%s&context=%s",
		AUTHENTICATE_HELPURL, _("?lang=en"),
		auth_opt_data->smppair->smp_type == 0 ?
		    ( /* Question and Answer */
		      auth_opt_data->smppair->responder ?
		      "answer" : "question" ) :
		auth_opt_data->smppair->smp_type == 1 ?
		    ( /* Shared secret */
		      auth_opt_data->smppair->responder ?
		      "secretresp" : "secret" ) :
		    /* Fingerprint */
		    "fingerprint"
		);
	purple_notify_uri(otrg_plugin_handle, helpurl);
	g_free(helpurl);

	/* Don't destroy the window */
	return;
cypherpunk's avatar
cypherpunk committed
349
    } else {
Rob Smits's avatar
Rob Smits committed
350
	otrg_plugin_abort_smp(context);
cypherpunk's avatar
cypherpunk committed
351
    }
Rob Smits's avatar
Rob Smits committed
352

cypherpunk's avatar
   
cypherpunk committed
353
    /* In all cases except HELP, destroy the current window */
cypherpunk's avatar
cypherpunk committed
354
    gtk_widget_destroy(GTK_WIDGET(dialog));
Rob Smits's avatar
Rob Smits committed
355

cypherpunk's avatar
cypherpunk committed
356
    /* Clean up references to this window */
cypherpunk's avatar
   
cypherpunk committed
357
358
    conv = otrg_plugin_context_to_conv(smppair->context, 0);
    smp_data = purple_conversation_get_data(conv, "otr-smpdata");
Rob Smits's avatar
Rob Smits committed
359

cypherpunk's avatar
cypherpunk committed
360
    if (smp_data) {
Rob Smits's avatar
Rob Smits committed
361
362
	smp_data->smp_secret_dialog = NULL;
	smp_data->smp_secret_smppair = NULL;
cypherpunk's avatar
cypherpunk committed
363
364
    }

cypherpunk's avatar
   
cypherpunk committed
365
366
    /* Free memory */
    free(auth_opt_data);
cypherpunk's avatar
cypherpunk committed
367
368
369
370
371
372
373
374
375
376
377
378
379
380
    free(smppair);
}

static void close_smp_window(PurpleConversation *conv)
{
    SMPData *smp_data = purple_conversation_get_data(conv, "otr-smpdata");
    if (smp_data && smp_data->smp_secret_dialog) {
	gtk_dialog_response(GTK_DIALOG(smp_data->smp_secret_dialog),
		GTK_RESPONSE_REJECT);
    }
}

static GtkWidget *create_dialog(GtkWindow *parent,
	PurpleNotifyMsgType type, const char *title,
cypherpunk's avatar
cypherpunk committed
381
	const char *primary, const char *secondary, int sensitive,
cypherpunk's avatar
   
cypherpunk committed
382
383
	GtkWidget **labelp, void (*add_custom)(GtkWidget *vbox, void *data),
	void *add_custom_data)
cypherpunk's avatar
cypherpunk committed
384
385
386
{
    GtkWidget *dialog;
    GtkWidget *hbox;
cypherpunk's avatar
   
cypherpunk committed
387
    GtkWidget *vbox;
cypherpunk's avatar
cypherpunk committed
388
389
390
391
392
393
    GtkWidget *label;
    GtkWidget *img = NULL;
    char *label_text;
    const char *icon_name = NULL;

    switch (type) {
cypherpunk's avatar
   
cypherpunk committed
394
395
	case PURPLE_NOTIFY_MSG_ERROR:
	    icon_name = PIDGIN_STOCK_DIALOG_ERROR;
cypherpunk's avatar
cypherpunk committed
396
397
	    break;

cypherpunk's avatar
   
cypherpunk committed
398
399
	case PURPLE_NOTIFY_MSG_WARNING:
	    icon_name = PIDGIN_STOCK_DIALOG_WARNING;
cypherpunk's avatar
cypherpunk committed
400
401
	    break;

cypherpunk's avatar
   
cypherpunk committed
402
403
	case PURPLE_NOTIFY_MSG_INFO:
	    icon_name = PIDGIN_STOCK_DIALOG_INFO;
cypherpunk's avatar
cypherpunk committed
404
405
406
407
408
409
410
411
	    break;

	default:
	    icon_name = NULL;
	    break;
    }

    if (icon_name != NULL) {
cypherpunk's avatar
cypherpunk committed
412
413
	img = gtk_image_new_from_stock(icon_name,
		gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
cypherpunk's avatar
cypherpunk committed
414
415
416
	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
    }

cypherpunk's avatar
cypherpunk committed
417
418
419
    dialog = gtk_dialog_new_with_buttons(
	    title ? title : PIDGIN_ALERT_TITLE, parent, 0,
	    GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
cypherpunk's avatar
cypherpunk committed
420

cypherpunk's avatar
cypherpunk committed
421
    gtk_window_set_focus_on_map(GTK_WINDOW(dialog), FALSE);
cypherpunk's avatar
cypherpunk committed
422
423
424
    gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog");

    g_signal_connect(G_OBJECT(dialog), "response",
Rob Smits's avatar
Rob Smits committed
425
	    G_CALLBACK(message_response_cb), dialog);
cypherpunk's avatar
cypherpunk committed
426
427
    gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT,
	    sensitive);
cypherpunk's avatar
cypherpunk committed
428
429
430
431
432
433
434
435

    gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
    gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
    gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
    gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);

    hbox = gtk_hbox_new(FALSE, 12);
cypherpunk's avatar
   
cypherpunk committed
436
    vbox = gtk_vbox_new(FALSE, 0);
cypherpunk's avatar
cypherpunk committed
437
438
439
440
441
442
443
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);

    if (img != NULL) {
	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
    }

    label_text = g_strdup_printf(
Rob Smits's avatar
Rob Smits committed
444
445
446
447
	    "<span weight=\"bold\" size=\"larger\">%s</span>%s%s",
	    (primary ? primary : ""),
	    (primary ? "\n\n" : ""),
	    (secondary ? secondary : ""));
cypherpunk's avatar
cypherpunk committed
448
449
450
451

    label = gtk_label_new(NULL);

    gtk_label_set_markup(GTK_LABEL(label), label_text);
cypherpunk's avatar
   
cypherpunk committed
452
    gtk_label_set_selectable(GTK_LABEL(label), 1);
cypherpunk's avatar
cypherpunk committed
453
454
455
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
cypherpunk's avatar
   
cypherpunk committed
456
457
458
459
460
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
    if (add_custom) {
	add_custom(vbox, add_custom_data);
    }
    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
cypherpunk's avatar
cypherpunk committed
461
462
463
464
465
466
467

    gtk_widget_show_all(dialog);

    if (labelp) *labelp = label;
    return dialog;
}

cypherpunk's avatar
   
cypherpunk committed
468
469
static void add_to_vbox_init_one_way_auth(GtkWidget *vbox,
	ConnContext *context, AuthSignalData *auth_opt_data, char *question) {
cypherpunk's avatar
   
cypherpunk committed
470
471
472
473
    GtkWidget *question_entry;
    GtkWidget *entry;
    GtkWidget *label;
    GtkWidget *label2;
Rob Smits's avatar
Rob Smits committed
474
475
    char *label_text;

cypherpunk's avatar
   
cypherpunk committed
476
    SmpResponsePair* smppair = auth_opt_data->smppair;
Rob Smits's avatar
Rob Smits committed
477

cypherpunk's avatar
   
cypherpunk committed
478
    if (smppair->responder) {
Rob Smits's avatar
Rob Smits committed
479
	label_text = g_strdup_printf("<small><i>\n%s\n</i></small>",
cypherpunk's avatar
   
cypherpunk committed
480
481
482
483
484
	    _("Your buddy is attempting to determine if he or she is really "
		"talking to you, or if it's someone pretending to be you.  "
		"Your buddy has asked a question, indicated below.  "
		"To authenticate to your buddy, enter the answer and "
		"click OK."));
cypherpunk's avatar
   
cypherpunk committed
485
    } else {
Rob Smits's avatar
Rob Smits committed
486
	label_text = g_strdup_printf("<small><i>\n%s\n</i></small>",
cypherpunk's avatar
   
cypherpunk committed
487
488
489
490
491
	    _("To authenticate using a question, pick a question whose "
	    "answer is known only to you and your buddy.  Enter this "
	    "question and this answer, then wait for your buddy to "
	    "enter the answer too.  If the answers "
	    "don't match, then you may be talking to an imposter."));
cypherpunk's avatar
   
cypherpunk committed
492
    }
cypherpunk's avatar
cypherpunk committed
493

cypherpunk's avatar
   
cypherpunk committed
494
    label = gtk_label_new(NULL);
cypherpunk's avatar
cypherpunk committed
495

cypherpunk's avatar
   
cypherpunk committed
496
497
498
499
500
501
    gtk_label_set_markup(GTK_LABEL(label), label_text);
    gtk_label_set_selectable(GTK_LABEL(label), FALSE);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
502
503


cypherpunk's avatar
   
cypherpunk committed
504
    if (smppair->responder) {
Rob Smits's avatar
Rob Smits committed
505
506
	label_text = g_strdup_printf(_("This is the question asked by "
		"your buddy:"));
cypherpunk's avatar
   
cypherpunk committed
507
    } else {
Rob Smits's avatar
Rob Smits committed
508
	label_text = g_strdup_printf(_("Enter question here:"));
cypherpunk's avatar
   
cypherpunk committed
509
    }
Rob Smits's avatar
Rob Smits committed
510

cypherpunk's avatar
   
cypherpunk committed
511
512
513
514
515
516
517
    label = gtk_label_new(label_text);
    gtk_label_set_selectable(GTK_LABEL(label), FALSE);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

Rob Smits's avatar
Rob Smits committed
518
519


cypherpunk's avatar
   
cypherpunk committed
520
    if (smppair->responder && question) {
Rob Smits's avatar
Rob Smits committed
521
522
523
524
525
526
527
528
529
530
	label_text = g_markup_printf_escaped("<span background=\"white\" "
		"foreground=\"black\" weight=\"bold\">%s</span>", question);
	label = gtk_label_new(NULL);
	gtk_label_set_markup (GTK_LABEL(label), label_text);
	gtk_label_set_selectable(GTK_LABEL(label), FALSE);
	g_free(label_text);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
	smppair->question_entry = NULL;
cypherpunk's avatar
   
cypherpunk committed
531
    } else {
Rob Smits's avatar
Rob Smits committed
532
533
534
535
	/* Create the text view where the user enters their question */
	question_entry = gtk_entry_new ();
	smppair->question_entry = GTK_ENTRY(question_entry);
	gtk_box_pack_start(GTK_BOX(vbox), question_entry, FALSE, FALSE, 0);
cypherpunk's avatar
   
cypherpunk committed
536
    }
Rob Smits's avatar
Rob Smits committed
537

cypherpunk's avatar
   
cypherpunk committed
538
    if (context->active_fingerprint->trust &&
Rob Smits's avatar
Rob Smits committed
539
540
	context->active_fingerprint->trust[0] && !(smppair->responder)) {
	label2 = gtk_label_new(_("This buddy is already authenticated."));
cypherpunk's avatar
   
cypherpunk committed
541
    } else {
Rob Smits's avatar
Rob Smits committed
542
	label2 = NULL;
cypherpunk's avatar
   
cypherpunk committed
543
    }
cypherpunk's avatar
cypherpunk committed
544

Rob Smits's avatar
Rob Smits committed
545

cypherpunk's avatar
   
cypherpunk committed
546
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
547

cypherpunk's avatar
   
cypherpunk committed
548
549
    /* Leave a blank line */
    gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(NULL), FALSE,
Rob Smits's avatar
Rob Smits committed
550
	    FALSE, 0);
cypherpunk's avatar
cypherpunk committed
551

cypherpunk's avatar
   
cypherpunk committed
552
    label_text = g_strdup_printf(_("Enter secret answer here "
Rob Smits's avatar
Rob Smits committed
553
	    "(case sensitive):"));
cypherpunk's avatar
cypherpunk committed
554

cypherpunk's avatar
   
cypherpunk committed
555
    label = gtk_label_new(NULL);
cypherpunk's avatar
cypherpunk committed
556

cypherpunk's avatar
   
cypherpunk committed
557
558
559
560
561
562
    gtk_label_set_markup(GTK_LABEL(label), label_text);
    gtk_label_set_selectable(GTK_LABEL(label), FALSE);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
cypherpunk's avatar
cypherpunk committed
563

cypherpunk's avatar
   
cypherpunk committed
564
565
    /* Create the text view where the user enters their secret */
    entry = gtk_entry_new();
cypherpunk's avatar
   
cypherpunk committed
566
    gtk_entry_set_text(GTK_ENTRY(entry), "");
cypherpunk's avatar
cypherpunk committed
567

cypherpunk's avatar
   
cypherpunk committed
568
569
    auth_opt_data->one_way_entry = GTK_ENTRY(entry);
    gtk_entry_set_activates_default(GTK_ENTRY(entry), smppair->responder);
cypherpunk's avatar
cypherpunk committed
570

cypherpunk's avatar
   
cypherpunk committed
571
572
    gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
573

cypherpunk's avatar
   
cypherpunk committed
574
575
    /* Leave a blank line */
    gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(NULL), FALSE,
Rob Smits's avatar
Rob Smits committed
576
577
	    FALSE, 0);

cypherpunk's avatar
   
cypherpunk committed
578
    if (label2) {
Rob Smits's avatar
Rob Smits committed
579
580
581
	gtk_box_pack_start(GTK_BOX(vbox), label2, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(NULL), FALSE,
		FALSE, 0);
cypherpunk's avatar
   
cypherpunk committed
582
583
    }
}
cypherpunk's avatar
cypherpunk committed
584

cypherpunk's avatar
   
cypherpunk committed
585
586
587
588
589
static void add_to_vbox_init_two_way_auth(GtkWidget *vbox,
	ConnContext *context, AuthSignalData *auth_opt_data) {
    GtkWidget *entry;
    GtkWidget *label;
    GtkWidget *label2;
Rob Smits's avatar
Rob Smits committed
590
591
    char *label_text;

cypherpunk's avatar
   
cypherpunk committed
592
    label_text = g_strdup_printf("<small><i>\n%s\n</i></small>",
Rob Smits's avatar
Rob Smits committed
593
594
595
596
	_("To authenticate, pick a secret known "
	    "only to you and your buddy.  Enter this secret, then "
	    "wait for your buddy to enter it too.  If the secrets "
	    "don't match, then you may be talking to an imposter."));
cypherpunk's avatar
cypherpunk committed
597

cypherpunk's avatar
   
cypherpunk committed
598
    label = gtk_label_new(NULL);
cypherpunk's avatar
cypherpunk committed
599

cypherpunk's avatar
   
cypherpunk committed
600
601
602
603
604
605
    gtk_label_set_markup(GTK_LABEL(label), label_text);
    gtk_label_set_selectable(GTK_LABEL(label), FALSE);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
606

cypherpunk's avatar
   
cypherpunk committed
607
    label_text = g_strdup_printf(_("Enter secret here:"));
cypherpunk's avatar
   
cypherpunk committed
608
609
610
611
612
613
    label = gtk_label_new(label_text);
    gtk_label_set_selectable(GTK_LABEL(label), FALSE);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
614
615


cypherpunk's avatar
   
cypherpunk committed
616
617
    /* Create the text view where the user enters their secret */
    entry = gtk_entry_new();
cypherpunk's avatar
   
cypherpunk committed
618
    gtk_entry_set_text(GTK_ENTRY(entry), "");
cypherpunk's avatar
   
cypherpunk committed
619
620
621
622
    gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
    auth_opt_data->two_way_entry = GTK_ENTRY(entry);

    if (context->active_fingerprint->trust &&
Rob Smits's avatar
Rob Smits committed
623
624
	context->active_fingerprint->trust[0]) {
	label2 = gtk_label_new(_("This buddy is already authenticated."));
cypherpunk's avatar
cypherpunk committed
625
    } else {
Rob Smits's avatar
Rob Smits committed
626
	label2 = NULL;
cypherpunk's avatar
   
cypherpunk committed
627
628
629
630
    }

    gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
631

cypherpunk's avatar
   
cypherpunk committed
632
633
    /* Leave a blank line */
    gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(NULL), FALSE,
Rob Smits's avatar
Rob Smits committed
634
635
	FALSE, 0);

cypherpunk's avatar
   
cypherpunk committed
636
    if (label2) {
Rob Smits's avatar
Rob Smits committed
637
638
639
	gtk_box_pack_start(GTK_BOX(vbox), label2, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(NULL), FALSE,
		FALSE, 0);
cypherpunk's avatar
   
cypherpunk committed
640
641
642
    }
}

Rob Smits's avatar
Rob Smits committed
643
644
static void add_to_vbox_verify_fingerprint(GtkWidget *vbox,
	ConnContext *context, SmpResponsePair* smppair) {
cypherpunk's avatar
   
cypherpunk committed
645
646
647
648
649
650
651
652
653
654
655
    char our_hash[45], their_hash[45];
    GtkWidget *label;
    char *label_text;
    struct vrfy_fingerprint_data *vfd;
    PurplePlugin *p;
    char *proto_name;
    Fingerprint *fprint = context->active_fingerprint;

    if (fprint == NULL) return;
    if (fprint->fingerprint == NULL) return;

cypherpunk's avatar
   
cypherpunk committed
656
657
658
659
660
    label_text = g_strdup_printf("<small><i>\n%s %s\n</i></small>",
	    _("To verify the fingerprint, contact your buddy via some "
	    "<i>other</i> authenticated channel, such as the telephone "
	    "or GPG-signed email.  Each of you should tell your fingerprint "
	    "to the other."),
Rob Smits's avatar
Rob Smits committed
661
662
	    _("If everything matches up, you should chose <b>I have</b> "
	    "in the menu below."));
cypherpunk's avatar
   
cypherpunk committed
663
664
665
666
667
668
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), label_text);
    gtk_label_set_selectable(GTK_LABEL(label), FALSE);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
cypherpunk's avatar
   
cypherpunk committed
669
670
671

    vfd = vrfy_fingerprint_data_new(fprint);

672
673
    strncpy(our_hash, _("[none]"), 44);
    our_hash[44] = '\0';
cypherpunk's avatar
   
cypherpunk committed
674
    otrl_privkey_fingerprint(otrg_plugin_userstate, our_hash,
Rob Smits's avatar
Rob Smits committed
675
	    context->accountname, context->protocol);
cypherpunk's avatar
   
cypherpunk committed
676
677
678
679
680
681

    otrl_privkey_hash_to_human(their_hash, fprint->fingerprint);

    p = purple_find_prpl(context->protocol);
    proto_name = (p && p->info->name) ? p->info->name : _("Unknown");
    label_text = g_strdup_printf(_("Fingerprint for you, %s (%s):\n%s\n\n"
Rob Smits's avatar
Rob Smits committed
682
683
684
	    "Purported fingerprint for %s:\n%s\n"), context->accountname,
	    proto_name, our_hash, context->username, their_hash);

cypherpunk's avatar
   
cypherpunk committed
685
    label = gtk_label_new(NULL);
Rob Smits's avatar
Rob Smits committed
686

cypherpunk's avatar
   
cypherpunk committed
687
    gtk_label_set_markup(GTK_LABEL(label), label_text);
cypherpunk's avatar
   
cypherpunk committed
688
689
690
691
692
    /* Make the label containing the fingerprints selectable, but
     * not auto-selected. */
    gtk_label_set_selectable(GTK_LABEL(label), TRUE);
    g_object_set(label, "can-focus", FALSE, NULL);

cypherpunk's avatar
   
cypherpunk committed
693
694
695
696
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
697

cypherpunk's avatar
   
cypherpunk committed
698
699
700
    add_vrfy_fingerprint(vbox, vfd);
    g_signal_connect(G_OBJECT(vbox), "destroy",
	    G_CALLBACK(vrfy_fingerprint_destroyed), vfd);
cypherpunk's avatar
   
cypherpunk committed
701
702
}

cypherpunk's avatar
   
cypherpunk committed
703
static void redraw_auth_vbox(GtkComboBox *combo, void *data) {
cypherpunk's avatar
   
cypherpunk committed
704
705
    AuthSignalData *auth_data = (AuthSignalData*) data;

cypherpunk's avatar
   
cypherpunk committed
706
707
708
    GtkWidget *notebook = auth_data ? auth_data->notebook : NULL;

    int selected;
Rob Smits's avatar
Rob Smits committed
709

cypherpunk's avatar
   
cypherpunk committed
710
    if (auth_data == NULL) return;
cypherpunk's avatar
   
cypherpunk committed
711
712

    selected = gtk_combo_box_get_active(combo);
Rob Smits's avatar
Rob Smits committed
713

cypherpunk's avatar
   
cypherpunk committed
714
    if (selected == 0) {
Rob Smits's avatar
Rob Smits committed
715
716
717
	gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 0);
	auth_data->smppair->entry = auth_data->one_way_entry;
	auth_data->smppair->smp_type = 0;
cypherpunk's avatar
   
cypherpunk committed
718
    } else if (selected == 1) {
Rob Smits's avatar
Rob Smits committed
719
720
721
	gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 1);
	auth_data->smppair->entry = auth_data->two_way_entry;
	auth_data->smppair->smp_type = 1;
cypherpunk's avatar
   
cypherpunk committed
722
    } else if (selected == 2) {
Rob Smits's avatar
Rob Smits committed
723
724
725
	auth_data->smppair->entry = NULL;
	gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 2);
	auth_data->smppair->smp_type = -1;
cypherpunk's avatar
   
cypherpunk committed
726
    }
Rob Smits's avatar
Rob Smits committed
727

cypherpunk's avatar
   
cypherpunk committed
728
729
}

cypherpunk's avatar
   
cypherpunk committed
730
static void add_other_authentication_options(GtkWidget *vbox,
cypherpunk's avatar
   
cypherpunk committed
731
	GtkWidget *notebook, ConnContext *context, AuthSignalData *data) {
cypherpunk's avatar
   
cypherpunk committed
732
733
734
735
736
    GtkWidget *label;
    GtkWidget *combo;
    char *labeltext;

    labeltext = g_strdup_printf("\n%s",
Rob Smits's avatar
Rob Smits committed
737
	    _("How would you like to authenticate your buddy?"));
cypherpunk's avatar
   
cypherpunk committed
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
    label = gtk_label_new(labeltext);
    g_free(labeltext);
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

    combo = gtk_combo_box_new_text();

    gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
	    _("Question and answer"));

    gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
	    _("Shared secret"));

    gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
	    _("Manual fingerprint verification"));

    gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
    gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);

    data->notebook = notebook;
Rob Smits's avatar
Rob Smits committed
758

cypherpunk's avatar
   
cypherpunk committed
759
    g_signal_connect (combo, "changed",
Rob Smits's avatar
Rob Smits committed
760
	    G_CALLBACK (redraw_auth_vbox), data);
cypherpunk's avatar
   
cypherpunk committed
761
762
763
}


cypherpunk's avatar
   
cypherpunk committed
764
765
static GtkWidget *create_smp_dialog(const char *title, const char *primary,
	ConnContext *context, gboolean responder, char *question)
cypherpunk's avatar
   
cypherpunk committed
766
767
768
769
770
771
772
{
    GtkWidget *dialog;

    PurpleConversation *conv = otrg_plugin_context_to_conv(context, 1);
    SMPData *smp_data = purple_conversation_get_data(conv, "otr-smpdata");

    close_progress_window(smp_data);
Rob Smits's avatar
Rob Smits committed
773

Rob Smits's avatar
Rob Smits committed
774
775
    /* If you start SMP authentication on a different context, it
     * will kill any existing SMP */
Rob Smits's avatar
Rob Smits committed
776
777
778
779
780
    if (smp_data->their_instance != context->their_instance) {
	otrg_gtk_dialog_free_smp_data(conv);
	otrg_gtk_dialog_add_smp_data(conv);
    }

cypherpunk's avatar
   
cypherpunk committed
781
    if (!(smp_data->smp_secret_dialog)) {
Rob Smits's avatar
Rob Smits committed
782
783
784
785
786
787
788
789
790
791
792
793
794
795
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *auth_vbox;
	GtkWidget *label;
	GtkWidget *img = NULL;
	char *label_text;
	const char *icon_name = NULL;
	SmpResponsePair* smppair;
	GtkWidget *notebook;
	AuthSignalData *auth_opt_data;

	smp_data->their_instance = context->their_instance;
	icon_name = PIDGIN_STOCK_DIALOG_INFO;
	img = gtk_image_new_from_stock(icon_name,
cypherpunk's avatar
   
cypherpunk committed
796
		gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
Rob Smits's avatar
Rob Smits committed
797
798
799
	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);

	dialog = gtk_dialog_new_with_buttons(title ? title :
cypherpunk's avatar
   
cypherpunk committed
800
		PIDGIN_ALERT_TITLE, NULL, 0,
Rob Smits's avatar
Rob Smits committed
801
802
803
804
		 GTK_STOCK_HELP, GTK_RESPONSE_HELP,
		 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
		 _("_Authenticate"), GTK_RESPONSE_ACCEPT, NULL);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog),
cypherpunk's avatar
   
cypherpunk committed
805
		GTK_RESPONSE_ACCEPT);
Rob Smits's avatar
Rob Smits committed
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836

	auth_vbox = gtk_vbox_new(FALSE, 0);
	hbox = gtk_hbox_new(FALSE, 15);
	vbox = gtk_vbox_new(FALSE, 0);

	smppair = malloc(sizeof(SmpResponsePair));
	smppair->responder = responder;
	smppair->context = context;


	notebook = gtk_notebook_new();
	auth_opt_data = malloc(sizeof(AuthSignalData));
	auth_opt_data->smppair = smppair;

	gtk_window_set_focus_on_map(GTK_WINDOW(dialog), !responder);
	gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog");

	gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
	gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
	gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),
		6);

	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);

	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);

	label_text = g_strdup_printf(
		"<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
		(primary ? primary : ""),
cypherpunk's avatar
   
cypherpunk committed
837
		_("Authenticating a buddy helps ensure that the person "
Rob Smits's avatar
Rob Smits committed
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
		"you are talking to is who he or she claims to be."));

	label = gtk_label_new(NULL);

	gtk_label_set_markup(GTK_LABEL(label), label_text);
	gtk_label_set_selectable(GTK_LABEL(label), FALSE);
	g_free(label_text);
	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
	gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

	if (!responder) {
	    add_other_authentication_options(vbox, notebook, context,
		    auth_opt_data);
	}

	g_signal_connect(G_OBJECT(dialog), "response",
		G_CALLBACK(smp_secret_response_cb),
		auth_opt_data);

	if (!responder || (responder && question != NULL)) {
	    GtkWidget *one_way_vbox = gtk_vbox_new(FALSE, 0);
	    add_to_vbox_init_one_way_auth(one_way_vbox, context,
cypherpunk's avatar
   
cypherpunk committed
861
		    auth_opt_data, question);
Rob Smits's avatar
Rob Smits committed
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
	    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), one_way_vbox,
		    gtk_label_new("0"));
	    smppair->entry = auth_opt_data->one_way_entry;
	    smppair->smp_type = 0;
	}

	if (!responder || (responder && question == NULL)) {
	    GtkWidget *two_way_vbox = gtk_vbox_new(FALSE, 0);
	    add_to_vbox_init_two_way_auth(two_way_vbox, context, auth_opt_data);
	    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), two_way_vbox,
		    gtk_label_new("1"));

	    if (responder && question == NULL) {
		smppair->entry = auth_opt_data->two_way_entry;
		smppair->smp_type = 1;
	    }
	}

	if (!responder) {
	    GtkWidget *fingerprint_vbox = gtk_vbox_new(FALSE, 0);
	    add_to_vbox_verify_fingerprint(fingerprint_vbox, context, smppair);
	    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), fingerprint_vbox,
		    gtk_label_new("2"));
	}

	gtk_notebook_set_show_tabs (GTK_NOTEBOOK(notebook), FALSE);

	gtk_notebook_set_show_border (GTK_NOTEBOOK(notebook), FALSE);
	gtk_box_pack_start(GTK_BOX(auth_vbox), notebook, FALSE, FALSE, 0);
	gtk_widget_show(notebook);


	gtk_box_pack_start(GTK_BOX(vbox), auth_vbox, FALSE, FALSE, 0);

	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);

	gtk_widget_show_all(dialog);

	gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook), 0);
cypherpunk's avatar
   
cypherpunk committed
901
902
903
904
905
906
907
908

	if (!responder) {
	    gtk_window_set_focus(GTK_WINDOW(dialog),
		    GTK_WIDGET(smppair->question_entry));
	} else {
	    gtk_window_set_focus(GTK_WINDOW(dialog),
		    GTK_WIDGET(smppair->entry));
	}
Rob Smits's avatar
Rob Smits committed
909
910
911
912

	smp_data->smp_secret_dialog = dialog;
	smp_data->smp_secret_smppair = smppair;

cypherpunk's avatar
   
cypherpunk committed
913
    } else {
Rob Smits's avatar
Rob Smits committed
914
915
916
917
918
	/* Set the responder field to TRUE if we were passed that value,
	 * even if the window was already up. */
	if (responder) {
	    smp_data->smp_secret_smppair->responder = responder;
	}
cypherpunk's avatar
cypherpunk committed
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
    }

    return smp_data->smp_secret_dialog;
}

static GtkWidget *create_smp_progress_dialog(GtkWindow *parent,
	ConnContext *context)
{
    GtkWidget *dialog;
    GtkWidget *hbox;
    GtkWidget *vbox;
    GtkWidget *label;
    GtkWidget *proglabel;
    GtkWidget *bar;
    GtkWidget *img = NULL;
cypherpunk's avatar
   
cypherpunk committed
934
    char *label_text, *label_pat;
cypherpunk's avatar
cypherpunk committed
935
    const char *icon_name = NULL;
cypherpunk's avatar
   
cypherpunk committed
936
937
    PurpleConversation *conv;
    SMPData *smp_data;
cypherpunk's avatar
cypherpunk committed
938
939
940
941
942
943

    icon_name = PIDGIN_STOCK_DIALOG_INFO;
    img = gtk_image_new_from_stock(icon_name,
	    gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
    gtk_misc_set_alignment(GTK_MISC(img), 0, 0);

cypherpunk's avatar
   
cypherpunk committed
944
945
    dialog = gtk_dialog_new_with_buttons(
	    context->smstate->received_question ?
Rob Smits's avatar
Rob Smits committed
946
	    /* Translators: you are asked to authenticate yourself */
cypherpunk's avatar
   
cypherpunk committed
947
	    _("Authenticating to Buddy") :
Rob Smits's avatar
Rob Smits committed
948
	    /* Translators: you asked your buddy to authenticate him/herself */
cypherpunk's avatar
   
cypherpunk committed
949
	    _("Authenticating Buddy"),
cypherpunk's avatar
cypherpunk committed
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
	    parent, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
	    GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog),
	    GTK_RESPONSE_ACCEPT);
    gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
	    GTK_RESPONSE_REJECT, 1);
    gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
	    GTK_RESPONSE_ACCEPT, 0);

    gtk_window_set_focus_on_map(GTK_WINDOW(dialog), FALSE);
    gtk_window_set_role(GTK_WINDOW(dialog), "notify_dialog");

    gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
    gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
    gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
    gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);

    hbox = gtk_hbox_new(FALSE, 12);
    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);

    gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);

cypherpunk's avatar
   
cypherpunk committed
974
975
    label_pat = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
	    "%s</span>\n", context->smstate->received_question ?
Rob Smits's avatar
Rob Smits committed
976
977
	    _("Authenticating to %s") :
	    _("Authenticating %s"));
cypherpunk's avatar
   
cypherpunk committed
978
979
    label_text = g_strdup_printf(label_pat, context->username);
    g_free(label_pat);
cypherpunk's avatar
cypherpunk committed
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994

    label = gtk_label_new(NULL);

    gtk_label_set_markup(GTK_LABEL(label), label_text);
    gtk_label_set_selectable(GTK_LABEL(label), 1);
    g_free(label_text);
    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
    gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

    proglabel = gtk_label_new(NULL);
    gtk_label_set_selectable(GTK_LABEL(proglabel), 1);
    gtk_label_set_line_wrap(GTK_LABEL(proglabel), TRUE);
    gtk_misc_set_alignment(GTK_MISC(proglabel), 0, 0);
    gtk_box_pack_start(GTK_BOX(vbox), proglabel, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
995

cypherpunk's avatar
cypherpunk committed
996
997
998
999
    /* Create the progress bar */
    bar = gtk_progress_bar_new();
    gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar), 0.1);
    gtk_box_pack_start(GTK_BOX(vbox), bar, FALSE, FALSE, 0);
Rob Smits's avatar
Rob Smits committed
1000

cypherpunk's avatar
cypherpunk committed
1001
1002
    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);

cypherpunk's avatar
   
cypherpunk committed
1003
1004
1005
1006
1007
1008
1009
    conv = otrg_plugin_context_to_conv(context, 0);
    smp_data = purple_conversation_get_data(conv, "otr-smpdata");
    if (smp_data) {
	smp_data->smp_progress_dialog = dialog;
	smp_data->smp_progress_bar = bar;
	smp_data->smp_progress_label = proglabel;
    }
cypherpunk's avatar
   
cypherpunk committed
1010
    gtk_label_set_text(GTK_LABEL(proglabel), _("Waiting for buddy..."));
cypherpunk's avatar
cypherpunk committed
1011
1012

    g_signal_connect(G_OBJECT(dialog), "response",
Rob Smits's avatar
Rob Smits committed
1013
1014
	     G_CALLBACK(smp_progress_response_cb),
	     context);
cypherpunk's avatar
cypherpunk committed
1015
1016
1017
1018
1019
1020

    gtk_widget_show_all(dialog);

    return dialog;
}

cypherpunk's avatar
   
cypherpunk committed
1021
/* This is just like purple_notify_message, except: (a) it doesn't grab
cypherpunk's avatar
cypherpunk committed
1022
1023
 * keyboard focus, (b) the button is "OK" instead of "Close", and (c)
 * the labels aren't limited to 2K. */
cypherpunk's avatar
   
cypherpunk committed
1024
static void otrg_gtk_dialog_notify_message(PurpleNotifyMsgType type,
cypherpunk's avatar
cypherpunk committed
1025
1026
1027
	const char *accountname, const char *protocol, const char *username,
	const char *title, const char *primary, const char *secondary)
{
cypherpunk's avatar
cypherpunk committed
1028
    create_dialog(NULL, type, title, primary, secondary, 1, NULL, NULL, NULL);
cypherpunk's avatar
cypherpunk committed
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
}

struct s_OtrgDialogWait {
    GtkWidget *dialog;
    GtkWidget *label;
};

/* Put up a Please Wait dialog, with the "OK" button desensitized.
 * Return a handle that must eventually be passed to
 * otrg_dialog_private_key_wait_done. */
static OtrgDialogWaitHandle otrg_gtk_dialog_private_key_wait_start(
	const char *account, const char *protocol)
{
cypherpunk's avatar
   
cypherpunk committed
1042
    PurplePlugin *p;
cypherpunk's avatar
cypherpunk committed
1043
1044
    const char *title = _("Generating private key");
    const char *primary = _("Please wait");
cypherpunk's avatar
cypherpunk committed
1045
1046
1047
1048
1049
1050
    char *secondary;
    const char *protocol_print;
    GtkWidget *label;
    GtkWidget *dialog;
    OtrgDialogWaitHandle handle;

cypherpunk's avatar
   
cypherpunk committed
1051
    p = purple_find_prpl(protocol);
cypherpunk's avatar
cypherpunk committed
1052
    protocol_print = (p ? p->info->name : _("Unknown"));
Rob Smits's avatar
Rob Smits committed
1053

cypherpunk's avatar
cypherpunk committed
1054
    /* Create the Please Wait... dialog */
cypherpunk's avatar
cypherpunk committed
1055
    secondary = g_strdup_printf(_("Generating private key for %s (%s)..."),
cypherpunk's avatar
cypherpunk committed
1056
	    account, protocol_print);
Rob Smits's avatar
Rob Smits committed
1057

cypherpunk's avatar
cypherpunk committed
1058
1059
    dialog = create_dialog(NULL, PURPLE_NOTIFY_MSG_INFO, title, primary,
	    secondary, 0, &label, NULL, NULL);
cypherpunk's avatar
cypherpunk committed
1060
1061
1062
1063
1064
1065
1066
1067
1068
    handle = malloc(sizeof(struct s_OtrgDialogWait));
    handle->dialog = dialog;
    handle->label = label;

    /* Make sure the dialog is actually displayed before doing any
     * compute-intensive stuff. */
    while (gtk_events_pending ()) {
	gtk_main_iteration ();
    }
Rob Smits's avatar
Rob Smits committed
1069

cypherpunk's avatar
cypherpunk committed
1070
1071
1072
1073
1074
1075
    g_free(secondary);

    return handle;
}

static int otrg_gtk_dialog_display_otr_message(const char *accountname,
cypherpunk's avatar
   
cypherpunk committed
1076
1077
	const char *protocol, const char *username, const char *msg,
	int force_create)
cypherpunk's avatar
cypherpunk committed
1078
1079
{
    /* See if there's a conversation window we can put this in. */
Rob Smits's avatar
Rob Smits committed
1080
1081
1082
    PurpleConversation *conv = otrg_plugin_userinfo_to_conv(accountname,
	    protocol, username, force_create);

cypherpunk's avatar
cypherpunk committed
1083
1084
1085

    if (!conv) return -1;

Rob Smits's avatar
Rob Smits committed
1086
1087
1088

    purple_conversation_write(conv, NULL, msg, PURPLE_MESSAGE_SYSTEM,
	    time(NULL));
cypherpunk's avatar
cypherpunk committed
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099

    return 0;
}

/* End a Please Wait dialog. */
static void otrg_gtk_dialog_private_key_wait_done(OtrgDialogWaitHandle handle)
{
    const char *oldmarkup;
    char *newmarkup;

    oldmarkup = gtk_label_get_label(GTK_LABEL(handle->label));
cypherpunk's avatar
cypherpunk committed
1100
    newmarkup = g_strdup_printf(_("%s Done."), oldmarkup);
cypherpunk's avatar
cypherpunk committed
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110

    gtk_label_set_markup(GTK_LABEL(handle->label), newmarkup);
    gtk_widget_show(handle->label);
    gtk_dialog_set_response_sensitive(GTK_DIALOG(handle->dialog),
	    GTK_RESPONSE_ACCEPT, 1);

    g_free(newmarkup);
    free(handle);
}

cypherpunk's avatar
cypherpunk committed
1111
/* Inform the user that an unknown fingerprint was received. */
cypherpunk's avatar
cypherpunk committed
1112
1113
static void otrg_gtk_dialog_unknown_fingerprint(OtrlUserState us,
	const char *accountname, const char *protocol, const char *who,
cypherpunk's avatar
   
cypherpunk committed
1114
	unsigned char fingerprint[20])
cypherpunk's avatar
cypherpunk committed
1115
{
cypherpunk's avatar
cypherpunk committed
1116
1117
1118
1119
1120
1121
1122
    PurpleConversation *conv;
    char *buf;
    ConnContext *context;
    int seenbefore = FALSE;

    /* Figure out if this is the first fingerprint we've seen for this
     * user. */
Rob Smits's avatar
Rob Smits committed
1123
1124
1125
    context = otrl_context_find(us, who, accountname, protocol,
	    OTRL_INSTAG_MASTER, 0, NULL, NULL, NULL);

cypherpunk's avatar
cypherpunk committed
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
    if (context) {
	Fingerprint *fp = context->fingerprint_root.next;
	while(fp) {
	    if (memcmp(fingerprint, fp->fingerprint, 20)) {
		/* This is a previously seen fingerprint for this user,
		 * different from the one we were passed. */
		seenbefore = TRUE;
		break;
	    }
	    fp = fp->next;
	}
    }
cypherpunk's avatar
cypherpunk committed
1138

cypherpunk's avatar
cypherpunk committed
1139
1140
1141
1142
1143
1144
1145
1146
1147
    if (seenbefore) {
	buf = g_strdup_printf(_("%s is contacting you from an unrecognized "
		    "computer.  You should <a href=\"%s%s\">authenticate</a> "
		    "this buddy."), who, AUTHENTICATE_HELPURL, _("?lang=en"));
    } else {
	buf = g_strdup_printf(_("%s has not been authenticated yet.  You "
		    "should <a href=\"%s%s\">authenticate</a> this buddy."),
		who, AUTHENTICATE_HELPURL, _("?lang=en"));
    }
cypherpunk's avatar
cypherpunk committed
1148

cypherpunk's avatar
cypherpunk committed
1149
1150
    conv = otrg_plugin_userinfo_to_conv(accountname, protocol, who, TRUE);

Rob Smits's avatar
Rob Smits committed
1151
1152
1153
    purple_conversation_write(conv, NULL, buf, PURPLE_MESSAGE_SYSTEM,
	    time(NULL));

cypherpunk's avatar
cypherpunk committed
1154
    g_free(buf);
cypherpunk's avatar
cypherpunk committed
1155
1156
}

cypherpunk's avatar
   
cypherpunk committed
1157
1158
static void otrg_gtk_dialog_clicked_connect(GtkWidget *widget, gpointer data);

Rob Smits's avatar
Rob Smits committed
1159
static void build_otr_menu(ConvOrContext *convctx, GtkWidget *menu,
cypherpunk's avatar
   
cypherpunk committed
1160
	TrustLevel level);
cypherpunk's avatar
   
cypherpunk committed
1161
1162
1163
1164
static void otr_refresh_otr_buttons(PurpleConversation *conv);
static void otr_destroy_top_menu_objects(PurpleConversation *conv);
static void otr_add_top_otr_menu(PurpleConversation *conv);
static void otr_add_buddy_top_menus(PurpleConversation *conv);
Rob Smits's avatar
Rob Smits committed
1165
static void otr_check_conv_status_change(PurpleConversation *conv);
cypherpunk's avatar
   
cypherpunk committed
1166

cypherpunk's avatar
   
cypherpunk committed
1167
1168
1169
1170
1171
static void destroy_menuitem(GtkWidget *widget, gpointer data)
{
    gtk_widget_destroy(widget);
}

Rob Smits's avatar
Rob Smits committed
1172
1173
1174
static void otr_build_status_submenu(PidginWindow *win,
	ConvOrContext *convctx, GtkWidget *menu, TrustLevel level);

cypherpunk's avatar
   
cypherpunk committed
1175
static void dialog_update_label_conv(PurpleConversation *conv, TrustLevel level)
cypherpunk's avatar
cypherpunk committed
1176
1177
{
    GtkWidget *label;
cypherpunk's avatar
   
cypherpunk committed
1178
    GtkWidget *icon;
cypherpunk's avatar
cypherpunk committed
1179
    GtkWidget *button;
cypherpunk's avatar
   
cypherpunk committed
1180
    GtkWidget *menu;
Rob Smits's avatar
Rob Smits committed
1181
1182
    ConvOrContext *convctx;
    GHashTable * conv_or_ctx_map;
Rob Smits's avatar
Rob Smits committed
1183
    char *markup;
cypherpunk's avatar
   
cypherpunk committed
1184
1185
1186
1187
    PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
    label = purple_conversation_get_data(conv, "otr-label");
    icon = purple_conversation_get_data(conv, "otr-icon");
    button = purple_conversation_get_data(conv, "otr-button");
cypherpunk's avatar
   
cypherpunk committed
1188
    menu = purple_conversation_get_data(conv, "otr-menu");
cypherpunk's avatar
   
cypherpunk committed
1189

cypherpunk's avatar
   
cypherpunk committed
1190
    otr_icon(icon, level, 1);
Rob Smits's avatar
Rob Smits committed
1191
1192
1193
1194
1195
    markup = g_strdup_printf(" <span color=\"%s\">%s</span>",
	    level == TRUST_FINISHED ? "#000000" :
	    level == TRUST_PRIVATE ? "#00a000" :
	    level == TRUST_UNVERIFIED ? "#a06000" :
	    "#ff0000",
cypherpunk's avatar
cypherpunk committed
1196
1197
1198
1199
	    level == TRUST_FINISHED ? _("Finished") :
	    level == TRUST_PRIVATE ? _("Private") :
	    level == TRUST_UNVERIFIED ? _("Unverified") :
	    _("Not private"));
Rob Smits's avatar
Rob Smits committed
1200
1201
1202
    gtk_label_set_markup(GTK_LABEL(label), markup);
    g_free(markup);
    gtk_tooltips_set_tip(gtkconv->tooltips, button, _("OTR"), NULL);
cypherpunk's avatar
   
cypherpunk committed
1203

cypherpunk's avatar
   
cypherpunk committed
1204

cypherpunk's avatar
cypherpunk committed
1205
    /* Use any non-NULL value for "private", NULL for "not private" */
cypherpunk's avatar
   
cypherpunk committed
1206
    purple_conversation_set_data(conv, "otr-private",
cypherpunk's avatar
   
cypherpunk committed
1207
1208
1209
	    (level == TRUST_NOT_PRIVATE || level == TRUST_FINISHED) ?
		    NULL : conv);

cypherpunk's avatar
   
cypherpunk committed
1210
1211
1212
1213
1214
    /* Use any non-NULL value for "unauthenticated", NULL for
     * "authenticated" */
    purple_conversation_set_data(conv, "otr-authenticated",
	    (level == TRUST_PRIVATE) ? conv : NULL);

cypherpunk's avatar
   
cypherpunk committed
1215
1216
1217
    /* Use any non-NULL value for "finished", NULL for "not finished" */
    purple_conversation_set_data(conv, "otr-finished",
	    level == TRUST_FINISHED ? conv : NULL);
cypherpunk's avatar
   
cypherpunk committed
1218

Rob Smits's avatar
Rob Smits committed
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
    conv_or_ctx_map = purple_conversation_get_data(conv, "otr-convorctx");
    convctx = g_hash_table_lookup(conv_or_ctx_map, conv);

    if (!convctx) {
	convctx = malloc(sizeof(ConvOrContext));
	g_hash_table_insert(conv_or_ctx_map, conv, (gpointer)convctx);
    }

    convctx->convctx_type = convctx_conv;
    convctx->conv = conv;
    build_otr_menu(convctx, menu, level);
    otr_build_status_submenu(pidgin_conv_get_window(gtkconv), convctx, menu,
	    level);
cypherpunk's avatar
   
cypherpunk committed
1232
1233
1234

    conv = gtkconv->active_conv;
    otr_check_conv_status_change(conv);
cypherpunk's avatar
   
cypherpunk committed
1235
1236
1237

    /* Update other widgets */
    if (gtkconv != pidgin_conv_window_get_active_gtkconv(gtkconv->win)) {
Rob Smits's avatar
Rob Smits committed
1238
	return;
cypherpunk's avatar
   
cypherpunk committed
1239
1240
1241
1242
1243
1244
    }

    otr_destroy_top_menu_objects(conv);
    otr_add_top_otr_menu(conv);
    otr_refresh_otr_buttons(conv);
    otr_add_buddy_top_menus(conv);
cypherpunk's avatar
cypherpunk committed
1245
1246
}

cypherpunk's avatar
   
cypherpunk committed
1247
static void dialog_update_label(ConnContext *context)
cypherpunk's avatar
cypherpunk committed
1248
{
cypherpunk's avatar
   
cypherpunk committed
1249
1250
    PurpleAccount *account;
    PurpleConversation *conv;
cypherpunk's avatar
   
cypherpunk committed
1251
    TrustLevel level = otrg_plugin_context_to_trust(context);
cypherpunk's avatar
cypherpunk committed
1