~ubuntu-branches/ubuntu/lucid/pidgin-otr/lucid-security

« back to all changes in this revision

Viewing changes to ui.c

  • Committer: Bazaar Package Importer
  • Author(s): Thibaut VARENE
  • Date: 2008-07-10 17:34:32 UTC
  • mfrom: (2.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080710173432-aqx359odj7cp182a
Tags: 3.2.0-2
Make key generation use /dev/urandom (Closes: #489523)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  Off-the-Record Messaging plugin for pidgin
3
 
 *  Copyright (C) 2004-2005  Nikita Borisov and Ian Goldberg
 
3
 *  Copyright (C) 2004-2008  Ian Goldberg, Rob Smits,
 
4
 *                           Chris Alexander, Nikita Borisov
4
5
 *                           <otr@cypherpunks.ca>
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
17
18
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
 */
19
20
 
 
21
/* config.h */
 
22
#ifdef HAVE_CONFIG_H
 
23
#include "config.h"
 
24
#endif
 
25
 
20
26
/* system headers */
21
27
#include <stdlib.h>
22
28
 
24
30
#include "util.h"
25
31
#include "account.h"
26
32
 
 
33
#ifdef ENABLE_NLS
 
34
/* internationalisation header */
 
35
#include <glib/gi18n-lib.h>
 
36
#endif
 
37
 
27
38
/* libotr headers */
28
39
#include <libotr/privkey.h>
29
40
#include <libotr/proto.h>
48
59
    return ui_ops;
49
60
}
50
61
 
 
62
/* Initialize the OTR UI subsystem */
 
63
void otrg_ui_init(void)
 
64
{
 
65
    if (ui_ops != NULL) {
 
66
        ui_ops->init();
 
67
    }
 
68
}
 
69
 
 
70
/* Deinitialize the OTR UI subsystem */
 
71
void otrg_ui_cleanup(void)
 
72
{
 
73
    if (ui_ops != NULL) {
 
74
        ui_ops->cleanup();
 
75
    }
 
76
}
 
77
 
51
78
/* Call this function when the DSA key is updated; it will redraw the
52
79
 * UI, if visible. */
53
80
void otrg_ui_update_fingerprint(void)
79
106
    account = purple_accounts_find(context->accountname, context->protocol);
80
107
    if (!account) {
81
108
        PurplePlugin *p = purple_find_prpl(context->protocol);
82
 
        msg = g_strdup_printf("Account %s (%s) could not be found",
 
109
        msg = g_strdup_printf(_("Account %s (%s) could not be found"),
83
110
                  context->accountname,
84
 
                  (p && p->info->name) ? p->info->name : "Unknown");
 
111
                  (p && p->info->name) ? p->info->name : _("Unknown"));
85
112
        otrg_dialog_notify_error(context->accountname, context->protocol,
86
 
                context->username, "Account not found", msg, NULL);
 
113
                context->username, _("Account not found"), msg, NULL);
87
114
        g_free(msg);
88
115
        return;
89
116
    }
128
155
    }
129
156
}
130
157
 
131
 
/* Calculate the policy for a particular account / username */
132
 
OtrlPolicy otrg_ui_find_policy(PurpleAccount *account, const char *name)
 
158
/* Load the preferences for a particular account / username */
 
159
void otrg_ui_get_prefs(OtrgUiPrefs *prefsp, PurpleAccount *account,
 
160
        const char *name)
133
161
{
134
162
    /* Check to see if the protocol for this account supports OTR at all. */
135
163
    const char *proto = purple_account_get_protocol_id(account);
136
164
    if (!otrg_plugin_proto_supports_otr(proto)) {
137
 
        return OTRL_POLICY_NEVER;
 
165
        prefsp->policy = OTRL_POLICY_NEVER;
 
166
        prefsp->avoid_logging_otr = FALSE;
 
167
        prefsp->show_otr_button = FALSE;
 
168
        return;
138
169
    }
139
170
 
140
171
    if (ui_ops != NULL) {
141
 
        return ui_ops->find_policy(account, name);
 
172
        ui_ops->get_prefs(prefsp, account, name);
 
173
        return;
142
174
    }
143
 
    return OTRL_POLICY_DEFAULT;
 
175
    /* If we've got no other way to get the prefs, use sensible defaults */
 
176
    prefsp->policy = OTRL_POLICY_DEFAULT;
 
177
    prefsp->avoid_logging_otr = FALSE;
 
178
    prefsp->show_otr_button = FALSE;
144
179
}