Merge branch 'master' of git://valera-ext.nynaeve.net/silc into silc.1.1.branch
[silc.git] / apps / irssi / src / silc / core / clientutil.h
1 /*
2
3   client.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000, 2008 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef CLIENTUTIL_H
22 #define CLIENTUTIL_H
23
24 #include "signals.h"
25
26 /* Prototypes */
27 void silc_client_list_ciphers();
28 void silc_client_list_hash_funcs();
29 void silc_client_list_hmacs();
30 void silc_client_list_pkcs();
31 int silc_client_check_silc_dir();
32 int silc_client_load_keys(SilcClient client);
33
34 typedef enum {
35   KeyboardCompletionSuccess, /* Success; keyboard data returned to callback. */
36   KeyboardCompletionAborted, /* Operation was aborted after starting successfully. */
37   KeyboardCompletionFailed /* Operation was not started successfully. */
38 } SilcKeyboardPromptStatus;
39
40 typedef void (*SILC_KEYBOARD_PROMPT_PROC)(const char *line,
41                                           void *context,
42                                           SilcKeyboardPromptStatus reason);
43
44 /*
45  * Prompt for keyboard input.
46  *
47  * If the function returns FALSE, then the prompt operation could not be
48  * initiated and the user supplied callback is called to indicate that the
49  * operation was not started (reason KeyboardCompletionFailed).  This can be
50  * used to centralize all cleanup work in the callback function.
51  *
52  * If the function returns TRUE, then the operation was initiated successfully
53  * and the prompt callback is guaranteed to be called sometime in the future.
54  * Note that it is posssible for the completion callback to have been already
55  * called by the time the function returns TRUE.  In this instance, the
56  * callback will eventually be called with KeyboardCompletionSuccess, unless
57  * the operation is aborted before then.
58  *
59  * If the function returns TRUE, then a SilcAsyncOperation context may be
60  * returned.  If an async operation context is returned, then the operation has
61  * not been completed immediately, and may be canceled with a call to
62  * silc_async_abort(*async).
63  *
64  * Note that the SilcAsyncOperation object's lifetime is managed internally.  A
65  * user may call silc_async_abort exactly once, after which it can never touch
66  * the async context again.  Additionally, the async context may not be
67  * referenced after the user callback returns.  The recommended way to handle
68  * the async operation context is to remove the reference to it when the user
69  * callback is called, either for an abort or regular completion.  If the
70  * callback is called with a KeyboardCompletionFailed reason, then no async
71  * context object was allocated.
72  *
73  * If an abort is requested, then the user callback is called with reason code
74  * KeyboardCompletionAborted.  In this case, the user should clean up all
75  * associated callback data and perform the handling expected in the abort case,
76  * such as the associated server connection going away while the operation was
77  * in progress.
78  *
79  * There can only be one keyboard redirect operation in progress.  If a
80  * keyboard redirect operation is aborted while we are still waiting for data,
81  * then we abort all callbacks until that callback returns.
82  */
83 SilcBool silc_keyboard_entry_redirect(SILC_KEYBOARD_PROMPT_PROC prompt_func,
84                                       const char *entry,
85                                       int flags,
86                                       void *data,
87                                       SilcAsyncOperation *async);
88
89 #ifdef SILC_PLUGIN
90 typedef struct {
91   char *old, *passphrase, *file, *pkcs;
92   int bits;
93 } CREATE_KEY_REC;
94
95 void create_key_passphrase(const char *answer, CREATE_KEY_REC *rec);
96 void change_private_key_passphrase(const char *answer, CREATE_KEY_REC *rec);
97 #endif
98
99 #endif