factotum: allow fgui to cancel needkey transaction
This commit is contained in:
parent
388e7781c2
commit
411ba896b8
4 changed files with 36 additions and 8 deletions
|
@ -186,7 +186,11 @@ needkeywrite(char *s)
|
||||||
werrstr("tag not found");
|
werrstr("tag not found");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rpcread(r);
|
if(s = _strfindattr(a, "error")){
|
||||||
|
werrstr("%s", s);
|
||||||
|
retrpc(r, RpcErrstr, (Fsstate*)r->fid->aux);
|
||||||
|
}else
|
||||||
|
rpcread(r);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ void rpcrdwrlog(Fsstate*, char*, uint, int, int);
|
||||||
void rpcstartlog(Attr*, Fsstate*, int);
|
void rpcstartlog(Attr*, Fsstate*, int);
|
||||||
void rpcread(Req*);
|
void rpcread(Req*);
|
||||||
void rpcwrite(Req*);
|
void rpcwrite(Req*);
|
||||||
|
void retrpc(Req*, int, Fsstate*);
|
||||||
|
|
||||||
/* secstore.c */
|
/* secstore.c */
|
||||||
int havesecstore(void);
|
int havesecstore(void);
|
||||||
|
|
|
@ -503,6 +503,7 @@ addmem(Attr *a, Attr *val)
|
||||||
/* controls for needkey */
|
/* controls for needkey */
|
||||||
Control *msg;
|
Control *msg;
|
||||||
Control *b_done;
|
Control *b_done;
|
||||||
|
Control *b_cancel;
|
||||||
enum {
|
enum {
|
||||||
Pprivate= 1<<0,
|
Pprivate= 1<<0,
|
||||||
Pneed= 1<<1,
|
Pneed= 1<<1,
|
||||||
|
@ -607,13 +608,21 @@ setupneedkey(Request *r)
|
||||||
b_done = createtextbutton(cs, "b_done");
|
b_done = createtextbutton(cs, "b_done");
|
||||||
chanprint(cs->ctl, "b_done border 1");
|
chanprint(cs->ctl, "b_done border 1");
|
||||||
chanprint(cs->ctl, "b_done align center");
|
chanprint(cs->ctl, "b_done align center");
|
||||||
chanprint(cs->ctl, "b_done text DONE");
|
chanprint(cs->ctl, "b_done text Done");
|
||||||
chanprint(cs->ctl, "b_done image green");
|
chanprint(cs->ctl, "b_done image green");
|
||||||
chanprint(cs->ctl, "b_done light green");
|
chanprint(cs->ctl, "b_done light green");
|
||||||
|
|
||||||
|
b_cancel = createtextbutton(cs, "b_cancel");
|
||||||
|
chanprint(cs->ctl, "b_cancel border 1");
|
||||||
|
chanprint(cs->ctl, "b_cancel align center");
|
||||||
|
chanprint(cs->ctl, "b_cancel text Cancel");
|
||||||
|
chanprint(cs->ctl, "b_cancel image i_white");
|
||||||
|
chanprint(cs->ctl, "b_cancel light i_black");
|
||||||
|
|
||||||
/* wire controls for input */
|
/* wire controls for input */
|
||||||
c = chancreate(sizeof(char*), 0);
|
c = chancreate(sizeof(char*), 0);
|
||||||
controlwire(b_done, "event", c);
|
controlwire(b_done, "event", c);
|
||||||
|
controlwire(b_cancel, "event", c);
|
||||||
for(i = 0; i < entries; i++)
|
for(i = 0; i < entries; i++)
|
||||||
if(entry[i].a->type == AttrQuery)
|
if(entry[i].a->type == AttrQuery)
|
||||||
controlwire(entry[i].val, "event", c);
|
controlwire(entry[i].val, "event", c);
|
||||||
|
@ -621,6 +630,7 @@ setupneedkey(Request *r)
|
||||||
/* make the controls interactive */
|
/* make the controls interactive */
|
||||||
activate(msg);
|
activate(msg);
|
||||||
activate(b_done);
|
activate(b_done);
|
||||||
|
activate(b_cancel);
|
||||||
for(i = 0; i < entries; i++){
|
for(i = 0; i < entries; i++){
|
||||||
if(entry[i].a->type != AttrQuery)
|
if(entry[i].a->type != AttrQuery)
|
||||||
continue;
|
continue;
|
||||||
|
@ -689,13 +699,21 @@ resizeneedkey(Controlset *cs)
|
||||||
lasty = r.max.y;
|
lasty = r.max.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* done button */
|
|
||||||
mr.min.x -= 2*font->height;
|
mr.min.x -= 2*font->height;
|
||||||
r.min.x = mr.min.x + mid - 3*font->height;
|
|
||||||
|
/* done button */
|
||||||
|
r.min.x = mr.min.x + mid - 9*font->height;
|
||||||
r.min.y = lasty+10;
|
r.min.y = lasty+10;
|
||||||
r.max.x = r.min.x + 6*font->height;
|
r.max.x = r.min.x + 6*font->height;
|
||||||
r.max.y = r.min.y + font->height + 2;
|
r.max.y = r.min.y + font->height + 2;
|
||||||
chanprint(cs->ctl, "b_done rect %R\nb_done show", r);
|
chanprint(cs->ctl, "b_done rect %R\nb_done show", r);
|
||||||
|
|
||||||
|
/* cancel button */
|
||||||
|
r.min.x = mr.min.x + mid + 3*font->height;
|
||||||
|
r.min.y = lasty+10;
|
||||||
|
r.max.x = r.min.x + 6*font->height;
|
||||||
|
r.max.y = r.min.y + font->height + 2;
|
||||||
|
chanprint(cs->ctl, "b_cancel rect %R\nb_cancel show", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -735,12 +753,17 @@ needkey(Request *r)
|
||||||
for(;;){
|
for(;;){
|
||||||
val = recvp(c);
|
val = recvp(c);
|
||||||
n = tokenize(val, args, nelem(args));
|
n = tokenize(val, args, nelem(args));
|
||||||
if(n==3 && strcmp(args[1], "value")==0){ /* user hit 'enter' */
|
if(n==3 && strcmp(args[1], "value")==0) /* user hit 'enter' */
|
||||||
free(val);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
free(val);
|
free(val);
|
||||||
}
|
}
|
||||||
|
if(strcmp(args[0], "b_cancel:") == 0){
|
||||||
|
free(val);
|
||||||
|
teardownneedkey(r);
|
||||||
|
fprint(r->rt->fd, "%A error='canceled by user'", r->tag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
free(val);
|
||||||
|
|
||||||
/* get entry values */
|
/* get entry values */
|
||||||
for(i = 0; i < entries; i++){
|
for(i = 0; i < entries; i++){
|
||||||
|
|
|
@ -112,7 +112,7 @@ retstring(Req *r, Fsstate *fss, char *s)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
retrpc(Req *r, int ret, Fsstate *fss)
|
retrpc(Req *r, int ret, Fsstate *fss)
|
||||||
{
|
{
|
||||||
switch(ret){
|
switch(ret){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue