From d2480484547d19a18a2b0285040bc1f8cfd26af1 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Mon, 2 Mar 2009 23:02:54 +0100 Subject: [PATCH] jabber/user honors FRIEND_AVAILABILITY and more --- CHANGESTODO | 29 +++++-------- world/default/en/jabber.textdb | 8 +++- world/net/group/master.c | 5 ++- world/net/jabber/jabber.h | 2 - world/net/jabber/server.c | 14 +++---- world/net/jabber/user.c | 75 ++++++++++++++++++---------------- world/net/person.c | 15 ++++++- world/net/psyc/library.i | 8 ++-- world/net/user.c | 5 ++- world/net/usercmd.i | 6 ++- 10 files changed, 93 insertions(+), 74 deletions(-) diff --git a/CHANGESTODO b/CHANGESTODO index f8142a7..f09be18 100644 --- a/CHANGESTODO +++ b/CHANGESTODO @@ -750,6 +750,13 @@ remoteMUC: ________________________________________________________________________ == JABBER CLIENT ISSUES (...experimental is justified...) ============== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +- accurate availability values from friends aren't stored and delivered + +- re-subscribe isn't properly handled (so we do friend(0) earlier instead) + +- when unsubscribing a user, no proper ack is sent to client + (but relogin helps ;)) + - v("place") isn't automatically set when actively joining a chat - the /me command ist not properly treated @@ -770,16 +777,6 @@ ________________________________________________________________________ - elmex: fippo: psyced.org failt soweit ichs seh bei mir alle tests bis auf den IQ auth test. ... Net::XMPP2 installieren und damit den muve testen? -- - - - - - - - elmex: der error muss aussen in den iq error - - - elmex: ausserdem geht das unregister wohl net richtig, denn beim registrieren bekomme ich halt den conflict da. @@ -825,8 +822,6 @@ ________________________________________________________________________ fiPP: wir mögen resourcen überhaupt nicht fiPP: das wird alles gefiltert und vom server beantwortet -- elmex: fippo: von subscription prozedur brauch ich garnicht anfangen oder? - - elmex: disco geht auch nicht fiPP: dass wir auf iq teilweise mit message antworten ist nen uralter bug end<< 2nd_testxmpp@beta.ve.example.com/x @@ -898,9 +893,6 @@ ________________________________________________________________________ - aimgate sendeoptimierung auf #if 0 -? ouch.. wir haben immernoch psyctext fehler: - net/jabber/user#example - - niekie entered #welcome both by telnet and xmpp. when the telnet logged out, his xmpp client thought he had left the muc also. ok, so the psyced did correctly handle both your identities.. only that your client interpreted the other you leaving as you leaving.. kind of logical @@ -911,6 +903,8 @@ ________________________________________________________________________ erscheint er also immernoch online) + In welcome spricht mb: is there a way to turn off the welcome messages everytime someone gets connected to psyc, it is a bit irritating when you use clients like ichat who do not filter those messages into a seperate channel +? ouch.. wir haben immernoch psyctext fehler: + net/jabber/user#example - @@ -987,9 +981,6 @@ ________________________________________________________________________ buddymachen, dann geht der im laufe der transaktion verloren und man muss ihn später nochmal setzen! -- "00:05 ... Ich bin gerade nicht hier." - net/jabber/user maps away messages to mottoaction instead of presencetext - ________________________________________________________________________ == JABBER FILE TRANSFERS =============================================== ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ @@ -3923,5 +3914,7 @@ net/user jabber/user - fixed major bug in output of presence state (showFriends) - fixed outgoing presence support (announce) +jabber/server +- fixed various iq errors as elmex noted: pkggen + ported from cvs to git diff --git a/world/default/en/jabber.textdb b/world/default/en/jabber.textdb index e2bbee7..339a603 100644 --- a/world/default/en/jabber.textdb +++ b/world/default/en/jabber.textdb @@ -500,5 +500,11 @@ _status_person_absent_offline _status_friendship_established | +_warning_duplicate_friendship +|## useless information + +_warning_pending_friendship +|## useless information + _warning_usage_set_language -|## +|## doesn't look good on jabber diff --git a/world/net/group/master.c b/world/net/group/master.c index 340be40..9bc9d65 100644 --- a/world/net/group/master.c +++ b/world/net/group/master.c @@ -236,8 +236,9 @@ jabberisten die freundschaft zum user#fippo entfernte: ME, t, source, _routes)) } } else { - // happens when doing /unfr. must be a bug in user.c - P0(("%O encountered unnecessary remove of %O from %O\n", + // happens when doing /unfr. it's when the implied unfriend + // comes back from the other side. + P2(("%O encountered unnecessary remove of %O from %O\n", ME, source, _routes)) } } diff --git a/world/net/jabber/jabber.h b/world/net/jabber/jabber.h index 8c5bedd..ad431c5 100644 --- a/world/net/jabber/jabber.h +++ b/world/net/jabber/jabber.h @@ -38,8 +38,6 @@ virtual inherit JABBER_PATH "common"; #define XMPP "xmpp:" -#define IQ_OFF "" - #define NS_XMPP "urn:ietf:params:xml:ns:" #define IMPLODE_XML(list, tag) pointerp(list) ? tag + implode(list, "" diff --git a/world/net/jabber/server.c b/world/net/jabber/server.c index 9935b7a..6f88c28 100644 --- a/world/net/jabber/server.c +++ b/world/net/jabber/server.c @@ -193,14 +193,14 @@ jabberMsg(XMLNode node) { // super dirty.. this should all be in textdb packet = sprintf("" "" - "Registration by XMPP not permitted.", id); #else packet = sprintf("" "" "You dont even need to register, " "this is psyced. Manual at http://help.pages.de" - "" IQ_OFF, + "", id); #endif emit(packet); @@ -219,20 +219,18 @@ jabberMsg(XMLNode node) { } unless (user -> isNewbie()) { // already registered to someone else - packet += "" + packet += "" "" - "" - IQ_OFF; + ""; emit(packet); QUIT } else unless ((t = helper["/username"]) && t[Cdata] && (t = helper["/password"]) && t[Cdata]) { - packet += "" + packet += "" "" - "" - IQ_OFF; + ""; emit(packet); QUIT } else { diff --git a/world/net/jabber/user.c b/world/net/jabber/user.c index 1ab8e5b..2e5e510 100644 --- a/world/net/jabber/user.c +++ b/world/net/jabber/user.c @@ -19,8 +19,8 @@ volatile int isplacemsg; volatile int hasroster = 0; // client has requested roster -volatile mapping jabber2avail, - affiliations = ([ ]); // hack to support affiliations +volatile mapping affiliations = ([ ]); // hack to support affiliations +volatile mapping jabber2avail; #include JABBER_PATH "disco.c" // #include NET_PATH "members.i" // isn't this include redundant? @@ -238,21 +238,23 @@ msg(source, mc, data, mapping vars, showingLog) { showFriends() { // send presence for online friends - string template = T("_notice_presence_here_plain", - ""); string packet = ""; + mixed person; + int av; - foreach(mixed friend : m_indices(friends)) { - if (friend) - packet += psyctext(template, ([ - "_INTERNAL_target_jabber" : myjid, - "_INTERNAL_source_jabber" : mkjid(friend), - "_INTERNAL_mood_jabber" : "neutral" - ])); + foreach(person: m_indices(friends)) if (person) { + av = friends[person, FRIEND_AVAILABILITY]; + packet += psyctext(T("_status_presence"+ avail2mc[av], + ""), ([ + "_INTERNAL_target_jabber" : myjid, + "_INTERNAL_source_jabber" : mkjid(person), + "_description_presence" : "", // TODO: get these from state + "_INTERNAL_mood_jabber" : "neutral" + ])); } if (strlen(packet)) emit(packet); - P2(("%O jabberish showFriends: %O outputs as %O\n", ME, friends, packet)) + PT(("%O jabberish showFriends: %O outputs as %O\n", ME, friends, packet)) } logon() { @@ -312,7 +314,7 @@ presence(XMLNode node) { } #ifndef _flag_disable_presence_directed_XMPP if (node["@to"]) { - target = jid2unl(node["@to"]); + target = jid2ppl(node["@to"]); if (isplacemsg) { mixed *u = parse_uniform(XMPP + node["@to"]); P2(("some kind of place stuff\n")) @@ -358,10 +360,9 @@ presence(XMLNode node) { } # ifndef _flag_disable_module_friendship } else if (node["@type"] == "subscribe") { - // was: friend(({ jid2unl(node["@to"]) }), 0); - friend(0, jid2unl(node["@to"])); + friend(0, 0, jid2ppl(node["@to"])); } else if (node["@type"] == "unsubscribe") { - friend(1, jid2unl(node["@to"])); + friend(1, 0, jid2ppl(node["@to"])); # endif // _flag_disable_module_friendship } else if (abbrev(XMPP, target)) { // if the person is not on our buddylist, @@ -436,7 +437,7 @@ message(XMLNode node) { P0(("%O jabber message() without 'to'-attribute\n")) return; } - target = jid2unl(node["@to"]); + target = jid2ppl(node["@to"]); unless (u = parse_uniform(XMPP + node["@to"])) { D("impossible!\n"); } isplacemsg = ISPLACEMSG(node["@to"]); @@ -538,7 +539,7 @@ message(XMLNode node) { } // _message_private - nick = jid2unl(node["@to"]); + nick = jid2ppl(node["@to"]); // P2(("nick: %s\n", nick)) // TODO: vars["_time_INTERNAL"] => jabber:x:delay, JEP-0091 #if 0 @@ -565,7 +566,7 @@ iq(XMLNode node) { mixed *vars; vars = ([ "_nick": MYNICK ]); - target = jid2unl(node["@to"]); + target = jid2ppl(node["@to"]); isplacemsg = stringp(target) && strlen(target) && ISPLACEMSG(target); P3(("%O IQ node %O\n", ME, node)) @@ -721,7 +722,7 @@ iq(XMLNode node) { ME, "_list_acquaintance_notification" + variant + "_roster", friend)) } } - emit(packet + IQ_OFF); + emit(packet +""); // here we should redisplay requests skipped above // oder kann man die einfach reinmixen - nein // foreach skipped @@ -732,10 +733,10 @@ iq(XMLNode node) { case "set": helper = helper["/item"]; if (helper && helper["@subscription"] == "remove") { - string buddy = jid2unl(helper["@jid"]); + string buddy = jid2ppl(helper["@jid"]); #ifndef _flag_disable_module_friendship P2(("remove %O from roster\n", helper["@jid"])) - friend(1, buddy); + friend(1, 0, buddy); #endif m_delete(xbuddylist, buddy); emit(sprintf("", tag)); @@ -747,7 +748,11 @@ iq(XMLNode node) { string name; jid = helper["@jid"]; - buddy = jid2unl(jid); + unless (stringp(jid)) { + P0(("invalid jid for %O in %O\n", name, ME)) + break; + } + buddy = jid2ppl(jid); unless (xbuddylist[buddy]) subscription = "none"; else @@ -776,14 +781,6 @@ iq(XMLNode node) { // // roster push // maybe we can just implode the former "groups" here - unless (stringp(jid)) { - P0(("invalid jid for %O in %O\n", name, ME)) - break; - } - unless (stringp(subscription)) { - P0(("invalid subscription for %O in %O\n", jid, ME)) - break; - } unless (stringp(name)) { // nicht schlimm.. hat der user das alias-feld // einfach leergelassen @@ -798,7 +795,14 @@ iq(XMLNode node) { IMPLODE_XML(xbuddylist[buddy], ""))); if (stringp(tag)) emit(sprintf("", tag)); +#ifndef _flag_disable_module_friendship + // client will send presence subscribe in opposite direction + // so we shouldn't need this. alas, there seems to be a bug + // with re-subscribe + friend(0, 0, buddy); +#else save(); +#endif } break; case "result": @@ -1075,12 +1079,13 @@ iq(XMLNode node) { } } -// this isn't really used consistently... -string jid2unl(string jid) { +// this converts a user@host into a local nick or uniform +// in a potentially not too consistent way +string jid2ppl(string jid) { string node, host, resource; string t; - P3(("jid2unl saw %O\n", jid)) + P3(("jid2ppl saw %O\n", jid)) unless(jid) return 0; // // TODO: what if jid == SERVER_HOST? diff --git a/world/net/person.c b/world/net/person.c index 94c938d..1458729 100644 --- a/world/net/person.c +++ b/world/net/person.c @@ -73,7 +73,16 @@ volatile mapping lastaway; volatile mixed availability; #endif // _flag_disable_module_presence +// complex data structure of peers. see peer.h volatile mapping ppl; + +// friends contains the currently available peers. +// technically, friends is a multi-dimensional mapping: +// uniforms or objects pointing to nick and availability. +// it should be 0-dimensional instead, only containing objects: +// local entities vs. context slaves for remote entities. +// in both cases providing the typical state information: +// availability, mood, presence text, icons and photos... volatile mapping friends; #ifdef RELAY @@ -2094,7 +2103,9 @@ case "_request_friendship_implied": // but the other side may be confused or have lost its // state, so we let it know once more default: -// if (mc != "_notice_friendship_established") { + // this stops loops of _status_friendship_established + // but maybe we should just never act on that mc + if (mc != t2) { sendmsg(source, t2, data, ([ "_nick": MYNICK ]) ); // friendship with oneself.. @@ -2117,7 +2128,7 @@ case "_request_friendship_implied": // why did we want to filter this? // weil das zeug nervt. //display = 0; -// } + } myLogAppend(source, mc, data, vars); // display sollte hier gleich 0 sein wenn man // schon mit der person befreundet ist... diff --git a/world/net/psyc/library.i b/world/net/psyc/library.i index 66b2f6b..b93fed5 100644 --- a/world/net/psyc/library.i +++ b/world/net/psyc/library.i @@ -251,13 +251,13 @@ int psyc_sendmsg(mixed target, string mc, mixed data, mapping vars, } host = lower_case(u[UHost]); if (query_udp_port() == port && is_localhost(host)) { + // this happens when a psyc client sends to a local + // target that hasn't been incarnated yet... o = find_psyc_object(u); // cache the resulting object for the url if (o) { - // currently find_psyc_object returns 0 for the - // local root, thus register_target messes up next. ouch. - P1(("psyc_sendmsg registering target %O for %O found through %O\n", - target, o, u)) + P2(("psyc_sendmsg registering %O for %O found by parsing uniform\n", + target, o)) register_target(target, o); } #ifndef __PIKE__ // TPD diff --git a/world/net/user.c b/world/net/user.c index bd1a9a1..95aeaf4 100644 --- a/world/net/user.c +++ b/world/net/user.c @@ -1640,7 +1640,10 @@ disconnected(remainder) { // actually - we could show all messages since last activity // from user. TODO #ifdef AVAILABILITY_OFFLINE - if (availability == AVAILABILITY_OFFLINE) return; + if (availability == AVAILABILITY_OFFLINE) { + P1(("i think i am already offline, so i won't quit (%O)\n", ME)) + return; + } #endif if (find_call_out(#'quit) != -1) return; // if (place) sendmsg(place, "_notice_place_leave_disconnect", diff --git a/world/net/usercmd.i b/world/net/usercmd.i index 03377cb..31b2995 100644 --- a/world/net/usercmd.i +++ b/world/net/usercmd.i @@ -2232,9 +2232,10 @@ protected invite(nick, vars) { // two ways to call this: // the gui style is friend(deleteflag, entity, optlNick)) // the cmdline style is friend(deleteflag, 0, nickname) -protected friend(rm, entity, ni, trustee) { +friend(rm, entity, ni, trustee) { mixed t; + P0(("friend(%O, %O, %O, %O) in %O\n", rm, entity, ni, trustee, ME)) if (IS_NEWBIE) { #ifdef VOLATILE w("_error_unavailable_function_here", @@ -2287,6 +2288,7 @@ protected friend(rm, entity, ni, trustee) { "All contact data for [_nick_target] deleted.", ([ "_nick_target": ni ]) ); m_delete(ppl, t); + m_delete(friends, entity); return 1; } w("_error_unknown_acquaintance", @@ -2318,6 +2320,8 @@ protected friend(rm, entity, ni, trustee) { // TODO: gender support ([ "_nick": MYNICK, "_possessive": "the" ]) ); m_delete(friends, entity); + PT(("entity %O (%O) removed from friends %O\n", + entity, t, friends)) //} return 1; }