fixed major bug in output of jabber presence state

This commit is contained in:
psyc://psyced.org/~lynX 2009-03-02 18:57:20 +01:00
parent ccf63004c8
commit 85c3ee031d
8 changed files with 60 additions and 47 deletions

View File

@ -9,6 +9,9 @@ ________________________________________________________________________
- when a jabber clients disconnects and reconnects quickly, before the sane - when a jabber clients disconnects and reconnects quickly, before the sane
quit delay has operated, it will not be given other people's presence again. quit delay has operated, it will not be given other people's presence again.
+ should ignored people receive an echo for the sake of not being
distinguishable from not ignored people? yes...
? marenz says, remote topic isn't working ? marenz says, remote topic isn't working
http://about.psyc.eu/?title=Talk:Bug_Report&curid=1506&diff=10174&oldid=10173 http://about.psyc.eu/?title=Talk:Bug_Report&curid=1506&diff=10174&oldid=10173
@ -3916,3 +3919,6 @@ install.sh
=== 200902 ============================================================ === 200902 ============================================================
archetype archetype
+ when joe says "/nick joe" it is understood as removing the /nick + when joe says "/nick joe" it is understood as removing the /nick
jabber/user
- fixed major bug in output of presence state (showFriends)

View File

@ -11,6 +11,12 @@
#define JABBER_TRANSPARENCY // switching this off improves parser #define JABBER_TRANSPARENCY // switching this off improves parser
// performance but kills file transfers // performance but kills file transfers
// local debug messages - turn them on by using psyclpc -DDjabber=<level>
#ifdef Djabber
# undef DEBUG
# define DEBUG Djabber
#endif
#include <net.h> #include <net.h>
#include <xml.h> #include <xml.h>
#include <sys/time.h> #include <sys/time.h>
@ -25,8 +31,6 @@ virtual inherit JABBER_PATH "common";
#endif #endif
#define COMBINE_CHARSET XML_CHARSET #define COMBINE_CHARSET XML_CHARSET
//"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 </=\"'?.:@-"
// combining > errors
// eigentlich schon ein fall für textdb // eigentlich schon ein fall für textdb
// siehe auch MISC/jabber/conference.fmt // siehe auch MISC/jabber/conference.fmt

View File

@ -444,7 +444,7 @@ open_stream(XMLNode node) {
string features; string features;
string header; string header;
P2(("jabber/server open_stream\n")) P2(("%O open_stream from %O\n", ME, query_ip_name()))
streamid = RANDHEXSTRING; streamid = RANDHEXSTRING;
unless(node["@xmlns"] == "jabber:client") { unless(node["@xmlns"] == "jabber:client") {

View File

@ -30,8 +30,6 @@ qResource() { return resource; }
qHasCurrentPlace() { return 0; } qHasCurrentPlace() { return 0; }
showFriends() {}
/* it should be posible to do some things in a way that can be shared between /* it should be posible to do some things in a way that can be shared between
* user and active/gateway... mostly stuff like MUC-support, version requests * user and active/gateway... mostly stuff like MUC-support, version requests
* and such -- TODO * and such -- TODO
@ -129,14 +127,14 @@ msg(source, mc, data, mapping vars, showingLog) {
case "_status_person_present_implied": case "_status_person_present_implied":
case "_status_person_absent": case "_status_person_absent":
case "_status_person_absent_recorded": case "_status_person_absent_recorded":
PT(("%O got %O\n", ME, mc)) P2(("%O got %O\n", ME, mc))
// actually.. we never send _time_idle with this // actually.. we never send _time_idle with this
if (member(vars, "_time_idle")) { if (member(vars, "_time_idle")) {
t = vars["_time_idle"]; t = vars["_time_idle"];
if (stringp(t)) { if (stringp(t)) {
t = to_int(t); t = to_int(t);
PT(("_time_idle %O == %O, right?\n", vars["_time_idle"], t)) P2(("_time_idle %O == %O, right?\n", vars["_time_idle"], t))
} }
t = gmtime(time() - t); t = gmtime(time() - t);
vars["_INTERNAL_time_jabber"] = JABBERTIME(t); vars["_INTERNAL_time_jabber"] = JABBERTIME(t);
@ -232,6 +230,25 @@ msg(source, mc, data, mapping vars, showingLog) {
return ::msg(source, mc, data, vars, showingLog); return ::msg(source, mc, data, vars, showingLog);
} }
showFriends() {
// send presence for online friends
string template = T("_notice_presence_here_plain",
"<presence to='[_INTERNAL_target_jabber]' "
"from='[_INTERNAL_source_jabber]'/>");
string packet = "";
foreach(mixed friend : m_indices(friends)) {
if (friend)
packet += psyctext(template, ([
"_INTERNAL_target_jabber" : myjid,
"_INTERNAL_source_jabber" : mkjid(friend),
"_INTERNAL_mood_jabber" : "neutral"
]));
}
if (strlen(packet)) emit(packet);
P2(("%O jabberish showFriends: %O outputs as %O\n", ME, friends, packet))
}
logon() { logon() {
// language support is in server.c // language support is in server.c
vSet("scheme", "jabber"); vSet("scheme", "jabber");
@ -250,6 +267,8 @@ logon() {
myjid = NODEPREP(MYLOWERNICK) +"@" + NAMEPREP(SERVER_HOST); myjid = NODEPREP(MYLOWERNICK) +"@" + NAMEPREP(SERVER_HOST);
myjidresource = myjid +"/"+ RESOURCEPREP(resource); myjidresource = myjid +"/"+ RESOURCEPREP(resource);
P2(("%O ready to rumble (%O)\n", myjidresource, ME)) P2(("%O ready to rumble (%O)\n", myjidresource, ME))
// reicht auch aufzurufen, wenn announce 0 returned..
showFriends();
return ::logon(); return ::logon();
} }
@ -708,7 +727,7 @@ iq(XMLNode node) {
])); ]));
if (ro) packet += ro; if (ro) packet += ro;
else { else {
PT(("%O empty result for %O with buddy %O\n", P2(("%O empty result for %O with buddy %O\n",
ME, "_list_acquaintance_notification" + variant + "_roster", friend)) ME, "_list_acquaintance_notification" + variant + "_roster", friend))
} }
} }
@ -718,21 +737,8 @@ iq(XMLNode node) {
// foreach skipped // foreach skipped
// _list_acquaintance_notification_pending // _list_acquaintance_notification_pending
// _list_acquaintance_notification_offered // _list_acquaintance_notification_offered
packet = ""; showFriends();
// send presence for online friends break;
// P2(("friends: %O\n", friends))
template = T("_notice_presence_here_plain",
"<presence to='[_INTERNAL_target_jabber]' "
"from='[_INTERNAL_source_jabber]'/>");
foreach(friend : m_values(friends)) {
if (friend)
packet += psyctext(template, ([
"_INTERNAL_target_jabber" : myjid,
"_INTERNAL_source_jabber" : mkjid(friend),
"_INTERNAL_mood_jabber" : "neutral"
]));
}
break; // showFriends() ?
case "set": case "set":
helper = helper["/item"]; helper = helper["/item"];
if (helper && helper["@subscription"] == "remove") { if (helper && helper["@subscription"] == "remove") {
@ -936,7 +942,7 @@ iq(XMLNode node) {
// this one is public while v("email") is more // this one is public while v("email") is more
// private // private
mvars = convert_profile(node["/vCard"], "jCard"); mvars = convert_profile(node["/vCard"], "jCard");
PT(("%O received vCard from client (%O)\n", ME, sizeof(mvars))) P2(("%O received vCard from client (%O)\n", ME, sizeof(mvars)))
emit("<iq type='result' id='" + tag + "'/>"); emit("<iq type='result' id='" + tag + "'/>");
request(ME, "_store", mvars); request(ME, "_store", mvars);
return; return;
@ -1220,7 +1226,7 @@ w(string mc, string data, mapping vars, mixed source) {
// (they already closed the connection when we get here) // (they already closed the connection when we get here)
return; return;
case "_error_status_place_matches": case "_error_status_place_matches":
PT(("still _error_status_place_matches?\n")) P2(("still _error_status_place_matches?\n"))
return; return;
case "_echo_request_friendship": case "_echo_request_friendship":
vars["_list_groups"] = xbuddylist[vars["_nick"]] || ""; vars["_list_groups"] = xbuddylist[vars["_nick"]] || "";

View File

@ -2479,7 +2479,9 @@ logon(host) {
#endif #endif
host = "?"; host = "?";
P2(("%O person:logon %O\n", ME, IS_NEWBIE? "(newbie)": "(registered)" )) P2(("%O person:logon %s, logged_on = %O\n", ME,
IS_NEWBIE? "(newbie)": "(registered)",
logged_on ))
log_file("LOGON", "[%s] %s %s %s(%s) %s/%s/%s \"%s\"\n", ctime(), log_file("LOGON", "[%s] %s %s %s(%s) %s/%s/%s \"%s\"\n", ctime(),
logged_on ? "O" : IS_NEWBIE ? "*" : "+", MYNICK, logged_on ? "O" : IS_NEWBIE ? "*" : "+", MYNICK,
#ifdef _flag_log_hosts #ifdef _flag_log_hosts
@ -2543,9 +2545,7 @@ logon(host) {
// check by raising a version counter // check by raising a version counter
} }
} }
# ifdef XMPPERIMENTAL P3(("smarticast distribution structure in %O: %O\n", ME, _routes))
PT(("smarticast distribution structure: %O\n", _routes))
# endif
#endif #endif
#ifndef _flag_disable_module_presence #ifndef _flag_disable_module_presence
switch(v("scheme")) { switch(v("scheme")) {
@ -2780,6 +2780,7 @@ announce(level, manual, verbose, text) {
text = text ? (MYNICK +" "+ text +".") : ""; text = text ? (MYNICK +" "+ text +".") : "";
// fun: "Reclaim your chat. Use PSYC. PSYC delivers."; // fun: "Reclaim your chat. Use PSYC. PSYC delivers.";
} }
// can this "optimization" cause async presence effects..?
if (!changed && availability == level) return 0; if (!changed && availability == level) return 0;
if (level) vSet("availability", availability = level); if (level) vSet("availability", availability = level);
else level = availability; // sending EXPIRED not permitted here else level = availability; // sending EXPIRED not permitted here

View File

@ -46,8 +46,7 @@ void create() {
// supercede this in inheriting server class // supercede this in inheriting server class
createUser(nick) { createUser(nick) {
PT(("net/server:createUser() called in %O\n", ME)) P3(("%O net/server:createUser(%O)\n", ME, nick))
// this is pretty unlikely to work
return named_clone(NET_PATH "user", nick); return named_clone(NET_PATH "user", nick);
} }
@ -82,7 +81,7 @@ hello(ni, elm, try, method, salt) {
ni, try, elm); ni, try, elm);
} }
#ifdef REGISTERED_USERS_ONLY #ifdef REGISTERED_USERS_ONLY // TODO: rename into a _flag
ohYeah(whatever) { ohYeah(whatever) {
input_to(#'ohYeah, input_to_settings); input_to(#'ohYeah, input_to_settings);
// input ignore warning? inverting mc's is really a good idea! // input ignore warning? inverting mc's is really a good idea!
@ -177,8 +176,8 @@ authChecked(int result, ni, try, elm) {
password(try, method, salt) { password(try, method, salt) {
mixed authCb; mixed authCb;
unless (user) { unless (user) {
pr("_failure_object_destructed", w("_failure_object_destructed", // never happens
"Huh? Your user object has disappeared!\n"); "Huh? Your user object has disappeared!");
QUIT QUIT
} }
// nick, guesses needed? // nick, guesses needed?
@ -212,8 +211,8 @@ morph() {
if (user) destruct(user); if (user) destruct(user);
unless (user = createUser(nick)) { unless (user = createUser(nick)) {
pr("_failure_object_creation", w("_failure_object_creation",
"Cannot create new user object.\n"); "Cannot create new user object.");
QUIT QUIT
} }
} }
@ -249,12 +248,6 @@ disconnected(remaining) {
logon() { logon() {
if (nick) { if (nick) {
// authlocal support! // authlocal support!
#if 0
// replace former interactive of nick
user = find_person(nick) || createUser(nick);
morph();
return 0;
#else
// only auto-login the first instance of nick // only auto-login the first instance of nick
user = find_person(nick); user = find_person(nick);
unless (user) { unless (user) {
@ -268,18 +261,15 @@ logon() {
} }
// otherwise prompt regularely // otherwise prompt regularely
nick = user = 0; nick = user = 0;
#endif
} }
#ifdef LIMIT_USERS #ifdef LIMIT_USERS
// TODO: admins MUST be able to login! // TODO: admins MUST be able to login!
// hmm.. what does 'nick &&' do here?
if (AMOUNT_SOCKETS >= LIMIT_USERS) { if (AMOUNT_SOCKETS >= LIMIT_USERS) {
w("_failure_exceeded_limit_users", "Extremely sorry, but " w("_failure_exceeded_limit_users", "Extremely sorry, but "
"the maximum possible amount of people has been reached."); "the maximum possible amount of people has been reached.");
QUIT QUIT
} }
#endif #endif
// bei jabber.. input_to(): Change in CHARMODE mode requested for object 'net/jabber/server#2107' with telnet disabled.
input_to(#'hello, input_to_settings); input_to(#'hello, input_to_settings);
call_out(#'quit, TIME_LOGIN_IDLE); call_out(#'quit, TIME_LOGIN_IDLE);
guesses = 0; guesses = 0;

View File

@ -1675,7 +1675,7 @@ static showFriends(verbose) {
array(mixed) k; array(mixed) k;
mixed o, n, *fmt; mixed o, n, *fmt;
P3(("showFriends: %O\n", friends)) P3(("showFriends in %O: %O\n", ME, friends))
k = m_indices(friends); k = m_indices(friends);
unless(k && sizeof(k)) return; unless(k && sizeof(k)) return;

View File

@ -1557,8 +1557,14 @@ request(source, mc, vars, data) {
mixed t, s; mixed t, s;
int glyph; int glyph;
P2(("»»> request(%O) %O from %O in %O (%O)\n", #if DEBUG > 3
// in case of _store from jabber client vars may contain photo data
P4(("»»> request(%O) %O from %O in %O (%O)\n",
mc, data, source, ME, vars)) mc, data, source, ME, vars))
#else
P2(("»»> request(%O) %O from %O in %O\n",
mc, data, source, ME))
#endif
PSYC_TRY(mc) { PSYC_TRY(mc) {
// quite dubious choice of method names.. sigh // quite dubious choice of method names.. sigh
case "_message_private": case "_message_private":