From 6fd2423ff91fb58492e05ce5670b6d871b892ae9 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Wed, 4 Mar 2009 11:27:19 +0100 Subject: [PATCH] use the UNick --- CHANGESTODO | 2 -- world/default/de/plain.textdb | 6 ++++++ world/default/en/plain.textdb | 6 ++++++ world/net/entity.c | 4 +--- world/net/gateway/aim.c | 2 +- world/net/include/uniform.h | 1 - world/net/irc/gatebot.c | 9 ++------- world/net/irc/user.c | 16 ++++++++-------- world/net/jabber/common.c | 2 +- world/net/jabber/mixin_render.c | 2 +- world/net/jabber/user.c | 6 +++--- world/net/library/text.c | 15 ++++++++++----- world/net/person.c | 2 +- world/net/place/archetype.gen | 7 +------ world/net/psyc/library.i | 9 +-------- world/net/psyc/parse.i | 2 +- world/net/user.c | 17 +++++++++-------- 17 files changed, 52 insertions(+), 56 deletions(-) diff --git a/CHANGESTODO b/CHANGESTODO index e0c5138..2e5ccc7 100644 --- a/CHANGESTODO +++ b/CHANGESTODO @@ -7,8 +7,6 @@ ________________________________________________________________________ == NEXT RELEASE ======================================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ? support tls multiplexing on all suitable ports - -- change UResource and UUser usage to the new UNick ________________________________________________________________________ == currently being inspected =========================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ diff --git a/world/default/de/plain.textdb b/world/default/de/plain.textdb index 8e16d4f..00ebead 100644 --- a/world/default/de/plain.textdb +++ b/world/default/de/plain.textdb @@ -1,6 +1,12 @@ ## vim:syntax=mail ## Check utf-8: Praise Atatürk! +_failure_unavailable_alias +|Kein Name für [_uniform_new]: [_nick_old] gehört bereits [_uniform_old]. + +_notice_add_alias_temporary +|[_uniform_entity] wird als [_nick_entity] dargestellt. + _message |[_nick] sendet Dir: [_data] diff --git a/world/default/en/plain.textdb b/world/default/en/plain.textdb index a9002ce..7ec5fba 100644 --- a/world/default/en/plain.textdb +++ b/world/default/en/plain.textdb @@ -1,6 +1,12 @@ ## vim:syntax=mail ## Check utf-8: Praise Atatürk! +_failure_unavailable_alias +|No alias for [_uniform_new]: [_nick_old] already belongs to [_uniform_old]. + +_notice_add_alias_temporary +|[_uniform_entity] is shown as [_nick_entity]. + _message |[_nick] sends you: [_data] diff --git a/world/net/entity.c b/world/net/entity.c index 4561fd7..6b6ed2b 100644 --- a/world/net/entity.c +++ b/world/net/entity.c @@ -422,9 +422,7 @@ msg(source, mc, data, vars) { // and have it replaced by object.. but that's not the case // we _could_ however do that by using _uniform_trustee // and doing is_localhost on all _uniform's at parsing time - if (is_localhost(u[UHost])) { - trustee_nick = u[UResource][1..]; - } + if (is_localhost(u[UHost])) trustee_nick = u[UNick]; } if (get_trust(trustee_nick, 0) < MINIMUM_TRUST) return 1; // entweder trustee ist ein local nick, dann kriegen wir den diff --git a/world/net/gateway/aim.c b/world/net/gateway/aim.c index fe33dd7..219f3f6 100644 --- a/world/net/gateway/aim.c +++ b/world/net/gateway/aim.c @@ -82,7 +82,7 @@ msg(source, mc, data, mapping vars, showingLog, target) { // if (u[UPort] && u[UPort] == query_imp_port()) { // vergleichen mit bisheriger logik in parse.i TODO if (u[UResource][0] == '~') - target = find_person(u[UResource][1..]); + target = find_person(u[UNick]); else if (u[UUser]) target = find_person(u[UUser]); else target = find_object(u[UResource]); // } diff --git a/world/net/include/uniform.h b/world/net/include/uniform.h index ad706f0..d6c4f8f 100644 --- a/world/net/include/uniform.h +++ b/world/net/include/uniform.h @@ -24,5 +24,4 @@ // (not provided by parse_uniform) #define USize 16 -#define UName(uniform) (uniform[UUser] || uniform[UResource][1 ..]) #endif diff --git a/world/net/irc/gatebot.c b/world/net/irc/gatebot.c index 3cd2126..487dfef 100644 --- a/world/net/irc/gatebot.c +++ b/world/net/irc/gatebot.c @@ -182,12 +182,7 @@ advertise(source) { gated[source] = 1; } #endif - } else { - // maybe this kind of logic should be in parse_uniform? - // or is it too rarely needed thus inefficient? - login = u[UResource]; - if (stringp(login) && strlen(login) > 1) - login = login[1 ..]; + } else login = u[UNick]; } unless (login && strlen(login)) return; // introduce the federation user into the ircnet @@ -226,7 +221,7 @@ render(mc, data, vars, source) { // return; // } // string ircsrc = (u[UScheme] || "xmpp") +";"+ -// (UName(u) +"|"+ +// (u[UNick] +"|"+ // replace(u[UHost], ".", "_"); if (source) { advertise(source); diff --git a/world/net/irc/user.c b/world/net/irc/user.c index c9fa4d9..341e3e5 100644 --- a/world/net/irc/user.c +++ b/world/net/irc/user.c @@ -204,7 +204,7 @@ static int _status_place_members(mixed source, string mc, # else "_nick" : n, # endif - "_nick_login" : u[UResource], + "_nick_login" : u[UNick], "_identification_host" : u[UHost], "_IRC_away" : "H", "_IRC_hops" : "1", @@ -412,12 +412,12 @@ w(string mc, string data, mapping vars, mixed source) { # ifdef ALIASES if (raliases[source]) { nick2 = raliases[source]; - vars["_source_hack"] = nick2 + ((u[UUser] || - (u[UResource] && u[UResource][0])) - ? "!"+ UName(u) +"@"+ u[UHost] - : "!"+ (vars["_nick_long"] || vars["_INTERNAL_nick_plain"] - || vars["_nick"]) - +"@alias.undefined"); + vars["_source_hack"] = nick2 +"!"+ + u[UNick]? u[UNick] +"@"+ u[UHost] + : (vars["_nick_long"] + || vars["_INTERNAL_nick_plain"] + || vars["_nick"]) + +"@alias.undefined"; } unless (nick2) { @@ -426,7 +426,7 @@ w(string mc, string data, mapping vars, mixed source) { case "psyc": if (u[UUser] || (u[UResource] && strlen(u[UResource]) && u[UResource][0] == '~')) { - string tmp = UName(u); + string tmp = u[UNick]; vars["_source_hack"] = u[UScheme] + "://" + u[UHostPort] +"/~"+ tmp +"!"+ tmp +"@" + u[UHostPort]; diff --git a/world/net/jabber/common.c b/world/net/jabber/common.c index 3b1f047..4b558c9 100644 --- a/world/net/jabber/common.c +++ b/world/net/jabber/common.c @@ -150,7 +150,7 @@ varargs string mkjid(mixed who, mixed vars, mixed ignore_context, string target t = PLACEPREFIX + NODEPREP(vars["_nick_place"]) +"@"+ NAMEPREP(jabberhost); } else if (u = parse_uniform(vars["_context"])) { if (u[UScheme] == "psyc") - t = PLACEPREFIX + NODEPREP(u[UResource][1..]) + "@" + NAMEPREP(u[UHost]); + t = PLACEPREFIX + NODEPREP(u[UNick]) + "@" + NAMEPREP(u[UHost]); else // here we presume we have a u@h or xmpp: t = NODEPREP(u[UUser]) + "@" + NAMEPREP(u[UHost]); } else { diff --git a/world/net/jabber/mixin_render.c b/world/net/jabber/mixin_render.c index b7d8818..482aee4 100644 --- a/world/net/jabber/mixin_render.c +++ b/world/net/jabber/mixin_render.c @@ -404,7 +404,7 @@ int msg(string source, string mc, string data, break; case "kick": // TODO: we could add a callback for this mc = "_request_execute_kick"; - vars["_nick_target"] = is_formal(args[1]) ? parse_uniform(args[1])[UResource] : args[1]; + vars["_nick_target"] = is_formal(args[1]) ? parse_uniform(args[1])[UNick] : args[1]; vars["_reason"] = ARGS(2); break; case "ban": // TODO: we could add a callback for this diff --git a/world/net/jabber/user.c b/world/net/jabber/user.c index ecfcf8a..8961af0 100644 --- a/world/net/jabber/user.c +++ b/world/net/jabber/user.c @@ -532,7 +532,7 @@ message(XMLNode node) { P0(("private message in place.. from %O to %O\n", ME, o)) sendmsg(o, "_message_public_whisper", - node["/body"][Cdata], ([ "_nick_target": u[UResource] || u[UUser]])); + node["/body"][Cdata], ([ "_nick_target": u[UNick]])); } #endif return 1; @@ -1164,9 +1164,9 @@ varargs string mkjid(mixed who, mixed vars, mixed ignore_nick, mixed ignore_cont // or let psyc users be the same person as on xmpp? // YES we want transparent upgrades from xmpp to psyc! if (t[0] == '@') - t = PLACEPREFIX+ t[1..] +"@"+ u[UHost]; + t = PLACEPREFIX+ u[UNick] +"@"+ u[UHost]; else - t = t[1..] +"@"+ u[UHost]; + t = u[UNick] +"@"+ u[UHost]; } else { // the usual "shouldn't happen" case which however does t = u[UHost]; diff --git a/world/net/library/text.c b/world/net/library/text.c index fad1337..6b936a9 100644 --- a/world/net/library/text.c +++ b/world/net/library/text.c @@ -62,7 +62,8 @@ varargs string psyctext(string s, mapping m, vastring data, // no _nick? okay, then it has to be this one q = UNIFORM(source) || "?"; } - if (previous_object()) q = previous_object()->uni2nick(q) || q; + if (previous_object()) + q = previous_object()->uni2nick(q, m) || q; r += p + q; #endif break; @@ -72,7 +73,8 @@ varargs string psyctext(string s, mapping m, vastring data, r += p + (nick || m["_nick"] || m["_source"] || UNIFORM(source) || "?"); #else q = m["_source"] || UNIFORM(source) || "?"; - if (previous_object()) q = previous_object()->uni2nick(q) || q; + if (previous_object()) + q = previous_object()->uni2nick(q, m) || q; r += p + q; #endif break; @@ -81,7 +83,8 @@ varargs string psyctext(string s, mapping m, vastring data, r += p + (nick || m["_nick"] || m["_source_relay"] || "?"); #else q = m["_source_relay"] || "?"; - if (previous_object()) q = previous_object()->uni2nick(q) || q; + if (previous_object()) + q = previous_object()->uni2nick(q, m) || q; r += p + q; #endif break; @@ -90,7 +93,8 @@ varargs string psyctext(string s, mapping m, vastring data, r += p + (m["_nick_target"] || m["_target"] || "?"); #else q = m["_target"] || "?"; - if (previous_object()) q = previous_object()->uni2nick(q) || q; + if (previous_object()) + q = previous_object()->uni2nick(q, m) || q; r += p + q; #endif break; @@ -99,7 +103,8 @@ varargs string psyctext(string s, mapping m, vastring data, r += p + (m["_nick_place"] || m["_context"] || "?"); #else q = m["_context"] || "?"; - if (previous_object()) q = previous_object()->uni2nick(q) || q; + if (previous_object()) + q = previous_object()->uni2nick(q, m) || q; r += p + q; #endif break; diff --git a/world/net/person.c b/world/net/person.c index 3c9446f..4efd882 100644 --- a/world/net/person.c +++ b/world/net/person.c @@ -2541,7 +2541,7 @@ logon(host) { if (u = parse_uniform(ni)) { // first we change the ppl, then we need this code // if (is_localhost(u[UHost])) { -// o = summon_person(u[UResource][1..]); +// o = summon_person(u[UNick]); // insert_member(o); // } else { o = ni; diff --git a/world/net/place/archetype.gen b/world/net/place/archetype.gen index d745fd6..01617dc 100644 --- a/world/net/place/archetype.gen +++ b/world/net/place/archetype.gen @@ -1078,12 +1078,7 @@ P1(("ident: %O is really %O\n", t, source)) // und nicht bei jeder remote suorce generell? TODO mixed *u = parse_uniform(source); if (u) { - string n = u[UUser]; - - if (!n && u[UResource] - && u[UResource][0] == '~') { - n = u[UResource][1..]; - } + n = u[UNick]; unless (n) return 0; // not n? hm... unless (vars["_nick"] diff --git a/world/net/psyc/library.i b/world/net/psyc/library.i index b93fed5..be4a104 100644 --- a/world/net/psyc/library.i +++ b/world/net/psyc/library.i @@ -120,7 +120,7 @@ object find_psyc_object(array(mixed) u) { string t, r, svc, user; object o; - user = u[UUser]; + user = u[UNick]; r = u[UResource]; if (r && strlen(r)) { #if __EFUN_DEFINED__(trim) @@ -132,13 +132,6 @@ object find_psyc_object(array(mixed) u) { if (strlen(r)) switch(r[0]) { case '^': case '~': - if (user) { -// croak("_error_invalid_uniform_user_duplicate", -// "Two users in uniform not allowed here."); -// QUIT - return 0; // TODO! - } - user = r[1..]; break; case '$': // target wird auf serv/args gesetzt diff --git a/world/net/psyc/parse.i b/world/net/psyc/parse.i index 70f2032..2040724 100644 --- a/world/net/psyc/parse.i +++ b/world/net/psyc/parse.i @@ -988,7 +988,7 @@ protected int deliver(mixed ip, string host, string mc, string buffer, mapping c } #ifdef NONIX if (strlen(u[UResource]) > 1) - cvars["_INTERNAL_nick_target"] = u[UResource][1..]; + cvars["_INTERNAL_nick_target"] = u[UNick]; #endif P3(("DEBUG: is_localhost is %O for %O of %O\n", is_localhost(u[UHost]), u[UHost], u)) diff --git a/world/net/user.c b/world/net/user.c index 41e4c55..70840e4 100644 --- a/world/net/user.c +++ b/world/net/user.c @@ -31,20 +31,22 @@ volatile mixed beQuiet; // my nickspace. used by psyctext(). could be passed as closure, but then // it wouldn't be available for *any* psyctext call in user objects. -uni2nick(n) { - PT(("uni2nick(%O) in %O\n", n, ME)) +uni2nick(n, vars) { + P3(("uni2nick(%O) in %O\n", n, ME)) #ifdef USE_AUTOALIAS string ln = lower_case(n); string al = raliases[ln]; if (al) return al; if (member(raliases, ln)) return n; // marked dead mixed u = parse_uniform(n); + // unfortunately UNick already comes lowercased.. + // using qName() for objectp would help here + // or we start using mixed case uniforms.. TODO al = lower_case(u[UNick]); if (aliases[al]) { raliases[ln] = 0; // mark dead - PT(("uni2nick: already belongs to %O\n", aliases[al])) - w("_failure_unavailable_alias", -"No alias for [_uniform_new]: [_nick_old] already belongs to [_uniform_old].", + P2(("uni2nick: already belongs to %O\n", aliases[al])) + w("_failure_unavailable_alias", 0, ([ "_uniform_new": n, "_uniform_old": aliases[al], "_nick_old": al ]) ); @@ -52,9 +54,8 @@ uni2nick(n) { } aliases[al] = n; raliases[ln] = al = u[UNick]; - PT(("uni2nick: autoaliased %O to %O\n", n, al)) - w("_notice_add_alias_automatic", - "[_uniform_entity] is known as [_nick_entity].", + P2(("uni2nick: autoaliased %O to %O\n", n, al)) + w("_notice_add_alias_temporary", 0, ([ "_uniform_entity": n, "_nick_entity": al ]) ); return al;