{
int fnact:1;
int fnchat:1;
+ int fnpeer:1;
int tract:1;
int trprog:1;
int srch:1;
char *buf;
int err;
struct fnetnode *fn;
+ struct wcspair *args;
haveargs(3);
havepriv(PERM_FNETCTL);
sq(sk, 0, L"504", L"Could not convert data to locale charset", NULL);
return;
}
- fn = fnetinitconnect(argv[1], buf);
+ args = NULL;
+ for(i = 3; i < argc - 1; i += 2)
+ newwcspair(argv[i], argv[i + 1], &args);
+ fn = fnetinitconnect(argv[1], buf, args);
err = errno;
free(buf);
if(fn == NULL)
sq(sk, 0, L"509", L"Could not parse the address", L"%%s", strerror(err), NULL);
return;
}
- for(i = 3; i < argc - 1; i += 2)
- {
- if(!wcscmp(argv[i], L"nick"))
- fnetsetnick(fn, argv[i + 1]);
- }
linkfnetnode(fn);
fnetsetname(fn, argv[2]);
putfnetnode(fn);
{
transfersethash(transfer, parsehash(argv[i + 1]));
} else {
- transferaddarg(transfer, argv[i], argv[i + 1]);
+ newwcspair(argv[i], argv[i + 1], &transfer->args);
}
}
}
data->notify.b.fnchat = val;
} else if(!wcscasecmp(argv[i], L"fn:act")) {
data->notify.b.fnact = val;
+ } else if(!wcscasecmp(argv[i], L"fn:peer")) {
+ data->notify.b.fnpeer = val;
} else if(!wcscasecmp(argv[i], L"trans:act")) {
data->notify.b.tract = val;
} else if(!wcscasecmp(argv[i], L"trans:prog")) {
static void cmd_lstrarg(struct socket *sk, struct uidata *data, int argc, wchar_t **argv)
{
struct transfer *transfer;
- struct transarg *ta;
+ struct wcspair *ta;
haveargs(2);
havepriv(PERM_TRANS);
sq(sk, 0, L"201", L"Transfer has no arguments", NULL);
} else {
for(ta = transfer->args; ta != NULL; ta = ta->next)
- sq(sk, ta->next != NULL, L"200", L"%%ls", ta->rec, L"%%ls", ta->val, NULL);
+ sq(sk, ta->next != NULL, L"200", L"%%ls", ta->key, L"%%ls", ta->val, NULL);
}
}
return(qcmd);
}
-static struct notif *newnotif(struct uidata *data, int code, ...)
+static void notifappendv(struct notif *notif, va_list args)
{
- struct notif *notif;
- va_list args;
int dt, ca;
- notif = smalloc(sizeof(*notif));
- memset(notif, 0, sizeof(*notif));
- notif->rlimit = 0.0;
- notif->ui = data;
- notif->code = code;
- va_start(args, code);
while((dt = va_arg(args, int)) != NOTIF_END)
{
ca = notif->argc;
break;
}
}
+}
+
+static void notifappend(struct notif *notif, ...)
+{
+ va_list args;
+
+ va_start(args, notif);
+ notifappendv(notif, args);
+ va_end(args);
+}
+
+static struct notif *newnotif(struct uidata *data, int code, ...)
+{
+ struct notif *notif;
+ va_list args;
+
+ notif = smalloc(sizeof(*notif));
+ memset(notif, 0, sizeof(*notif));
+ notif->rlimit = 0.0;
+ notif->ui = data;
+ notif->code = code;
+ va_start(args, code);
+ notifappendv(notif, args);
va_end(args);
notif->next = NULL;
notif->prev = data->lnotif;
if((notif = findnotif(data->fnotif, 1, NOTIF_PEND, 605, fn->id)) != NULL)
notif->argv[1].d.n = fn->numpeers;
else
- newnotif(data, 605, NOTIF_ID, fn->id, NOTIF_INT, fn->numpeers, NOTIF_END);
+ newnotif(data, 605, NOTIF_ID, fn->id, NOTIF_INT, fn->numpeers, NOTIF_END)->rlimit = 0.5;
}
}
}
return(0);
}
+static int peernew(struct fnetnode *fn, struct fnetpeer *peer, void *uudata)
+{
+ struct uidata *data;
+
+ for(data = actives; data != NULL; data = data->next)
+ {
+ if(data->notify.b.fnpeer)
+ newnotif(data, 630, NOTIF_INT, fn->id, NOTIF_STR, peer->id, NOTIF_STR, peer->nick, NOTIF_END);
+ }
+ return(0);
+}
+
+static int peerdel(struct fnetnode *fn, struct fnetpeer *peer, void *uudata)
+{
+ struct uidata *data;
+
+ for(data = actives; data != NULL; data = data->next)
+ {
+ if(data->notify.b.fnpeer)
+ newnotif(data, 631, NOTIF_INT, fn->id, NOTIF_STR, peer->id, NOTIF_END);
+ }
+ return(0);
+}
+
+static int peerchange(struct fnetnode *fn, struct fnetpeer *peer, struct fnetpeerdi *di, void *uudata)
+{
+ struct uidata *data;
+ struct notif *notif;
+ wchar_t buf[32];
+
+ for(data = actives; data != NULL; data = data->next)
+ {
+ if(data->notify.b.fnpeer)
+ {
+ for(notif = data->fnotif; notif != NULL; notif = notif->next)
+ {
+ if((notif->code == 632) && (notif->state == NOTIF_PEND) && (notif->argv[0].d.n == fn->id) && !wcscmp(notif->argv[1].d.s, peer->id))
+ break;
+ }
+ if(notif == NULL)
+ notif = newnotif(data, 632, NOTIF_INT, fn->id, NOTIF_STR, peer->id, NOTIF_STR, peer->nick, NOTIF_END);
+ notifappend(notif, NOTIF_STR, di->datum->id, NOTIF_INT, di->datum->datatype, NOTIF_END);
+ switch(di->datum->datatype)
+ {
+ case FNPD_INT:
+ notifappend(notif, NOTIF_INT, di->data.num, NOTIF_END);
+ break;
+ case FNPD_STR:
+ notifappend(notif, NOTIF_STR, di->data.str, NOTIF_END);
+ break;
+ case FNPD_LL:
+ swprintf(buf, sizeof(buf) / sizeof(*buf), L"%lli", di->data.lnum);
+ notifappend(notif, NOTIF_STR, buf, NOTIF_END);
+ break;
+ }
+ }
+ }
+ return(0);
+}
+
static int newfnetnode(struct fnetnode *fn, void *uudata)
{
struct uidata *data;
CBREG(fn, fnetnode_ac, fnactive, NULL, NULL);
CBREG(fn, fnetnode_chat, recvchat, NULL, NULL);
CBREG(fn, fnetnode_unlink, fnunlink, NULL, NULL);
+ CBREG(fn, fnetpeer_new, peernew, NULL, NULL);
+ CBREG(fn, fnetpeer_del, peerdel, NULL, NULL);
+ CBREG(fn, fnetpeer_chdi, peerchange, NULL, NULL);
return(0);
}