projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git://valera-ext.nynaeve.net/silc into silc.1.1.branch
[silc.git]
/
apps
/
irssi
/
src
/
silc
/
core
/
silc-queries.c
diff --git
a/apps/irssi/src/silc/core/silc-queries.c
b/apps/irssi/src/silc/core/silc-queries.c
index 1e7f75132230b18e746d7825f4ed9b32c89f8883..ec29a2f32df8ffb85509834b69c010520d23139e 100644
(file)
--- a/
apps/irssi/src/silc/core/silc-queries.c
+++ b/
apps/irssi/src/silc/core/silc-queries.c
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2002 - 200
7
Pekka Riikonen
+ Copyright (C) 2002 - 200
8
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-26,14
+26,16
@@
#include "modules.h"
#include "commands.h"
#include "misc.h"
#include "modules.h"
#include "commands.h"
#include "misc.h"
+#include "clientutil.h"
#include "fe-common/core/printtext.h"
#include "fe-common/core/fe-channels.h"
#include "fe-common/core/keyboard.h"
#include "fe-common/silc/module-formats.h"
#include "fe-common/core/printtext.h"
#include "fe-common/core/fe-channels.h"
#include "fe-common/core/keyboard.h"
#include "fe-common/silc/module-formats.h"
-static void silc_query_attributes_print_final(bool success, void *context);
-static void silc_query_attributes_accept(const char *line, void *context);
+static void silc_query_attributes_print_final(SilcBool success, void *context);
+static void silc_query_attributes_accept(const char *line, void *context,
+ SilcKeyboardPromptStatus reason);
QUERY_REC *silc_query_create(const char *server_tag,
const char *nick, int automatic)
QUERY_REC *silc_query_create(const char *server_tag,
const char *nick, int automatic)
@@
-68,7
+70,7
@@
void command_attr(const char *data, SILC_SERVER_REC *server,
SilcUInt32 argc;
SilcUInt32 *argv_lens, *argv_types;
const char *sv;
SilcUInt32 argc;
SilcUInt32 *argv_lens, *argv_types;
const char *sv;
-
b
ool allowed;
+
SilcB
ool allowed;
/* Now parse all arguments */
tmp = g_strconcat("ATTR", " ", data, NULL);
/* Now parse all arguments */
tmp = g_strconcat("ATTR", " ", data, NULL);
@@
-252,7
+254,7
@@
void silc_query_attributes_default(SilcClient client,
SilcAttributeObjDevice dev;
SilcAttributeObjPk pk;
SilcVCardStruct vcard;
SilcAttributeObjDevice dev;
SilcAttributeObjPk pk;
SilcVCardStruct vcard;
-
b
ool allowed;
+
SilcB
ool allowed;
memset(&service, 0, sizeof(service));
memset(&geo, 0, sizeof(geo));
memset(&service, 0, sizeof(service));
memset(&geo, 0, sizeof(geo));
@@
-557,7
+559,8
@@
typedef struct {
SilcVCardStruct vcard;
SilcMime message;
SilcMime extension;
SilcVCardStruct vcard;
SilcMime message;
SilcMime extension;
- bool nopk;
+ SilcBool nopk;
+ SilcBool autoaccept;
} *AttrVerify;
void silc_query_attributes_print(SILC_SERVER_REC *server,
} *AttrVerify;
void silc_query_attributes_print(SILC_SERVER_REC *server,
@@
-917,7
+920,7
@@
void silc_query_attributes_print(SILC_SERVER_REC *server,
}
}
}
}
-static void silc_query_attributes_print_final(
b
ool success, void *context)
+static void silc_query_attributes_print_final(
SilcB
ool success, void *context)
{
AttrVerify verify = context;
SILC_SERVER_REC *server = verify->server;
{
AttrVerify verify = context;
SILC_SERVER_REC *server = verify->server;
@@
-925,6
+928,7
@@
static void silc_query_attributes_print_final(bool success, void *context)
unsigned char filename[256], *fingerprint = NULL, *tmp;
struct stat st;
int i;
unsigned char filename[256], *fingerprint = NULL, *tmp;
struct stat st;
int i;
+ size_t len;
if (!verify->nopk) {
if (success) {
if (!verify->nopk) {
if (success) {
@@
-945,7
+949,10
@@
static void silc_query_attributes_print_final(bool success, void *context)
fingerprint = silc_hash_fingerprint(sha1hash,
verify->userpk.data,
verify->userpk.data_len);
fingerprint = silc_hash_fingerprint(sha1hash,
verify->userpk.data,
verify->userpk.data_len);
- for (i = 0; i < strlen(fingerprint); i++)
+
+ len = strlen(fingerprint);
+
+ for (i = 0; i < len; i++)
if (fingerprint[i] == ' ')
fingerprint[i] = '_';
if (fingerprint[i] == ' ')
fingerprint[i] = '_';
@@
-959,17
+966,19
@@
static void silc_query_attributes_print_final(bool success, void *context)
/* Ask to accept save requested attributes */
format = format_get_text("fe-common/silc", NULL, NULL, NULL,
SILCTXT_ATTR_SAVE);
/* Ask to accept save requested attributes */
format = format_get_text("fe-common/silc", NULL, NULL, NULL,
SILCTXT_ATTR_SAVE);
-
keyboard_entry_redirect((SIGNAL_FUNC)
silc_query_attributes_accept,
- format, 0, verify);
+
silc_keyboard_entry_redirect(
silc_query_attributes_accept,
+ format, 0, verify
, &server->prompt_op
);
} else {
/* Save new data to existing directory */
} else {
/* Save new data to existing directory */
- silc_query_attributes_accept("Y", verify);
+ verify->autoaccept = TRUE; /* Ensure we don't twiddle the async context */
+ silc_query_attributes_accept("Y", verify, KeyboardCompletionSuccess);
}
g_free(format);
}
}
g_free(format);
}
-static void silc_query_attributes_accept(const char *line, void *context)
+static void silc_query_attributes_accept(const char *line, void *context,
+ SilcKeyboardPromptStatus reason)
{
AttrVerify verify = context;
SILC_SERVER_REC *server = verify->server;
{
AttrVerify verify = context;
SILC_SERVER_REC *server = verify->server;
@@
-978,8
+987,9
@@
static void silc_query_attributes_accept(const char *line, void *context)
unsigned char filename[256], filename2[256], *fingerprint = NULL, *tmp;
SilcUInt32 len;
int i;
unsigned char filename[256], filename2[256], *fingerprint = NULL, *tmp;
SilcUInt32 len;
int i;
+ SilcBool success = (reason == KeyboardCompletionSuccess);
- if (
line[0] == 'Y' || line[0] == 'y'
) {
+ if (
success && (line[0] == 'Y' || line[0] == 'y')
) {
/* Save the attributes */
memset(filename, 0, sizeof(filename));
memset(filename2, 0, sizeof(filename2));
/* Save the attributes */
memset(filename, 0, sizeof(filename));
memset(filename2, 0, sizeof(filename2));
@@
-1066,6
+1076,8
@@
static void silc_query_attributes_accept(const char *line, void *context)
}
out:
}
out:
+ if((!verify->autoaccept) && (reason != KeyboardCompletionFailed))
+ verify->server->prompt_op = NULL;
silc_free(fingerprint);
silc_free(verify->name);
silc_vcard_free(&verify->vcard);
silc_free(fingerprint);
silc_free(verify->name);
silc_vcard_free(&verify->vcard);