I’'m curious how user presence is detected within the Java client. Is this done in a pure-Java manner, or is there some JNI connection to the underlying OS to detect native events? Can anyone share information on this subject? Thanks!
By presence, do you mean the IDLE feature within Spark? If so, I rely on some JNI for this and tie it in via a plugin.
Used JNI for the Linux user presence detection as well.
It talks with X and xscreensaver.
Calls two structs and checks a var in the structs that holds a long for how many milliseconds the user has been idle. The native code was written in C++ and is only a few lines long.
If you want the source let me know.
Any additional details on where this code actually runs in the Spark source? Had some questions related to security and keystroke logging, and I would like to really trace out where Spark makes its JNI calls to determine system idle time.
Sorry for the delayed reponse.
You can find where the idle timing is being handled at org.jivesoftware.spark.SessionManager.
The method of interest would be setIdleListener()
again, with Linux, It’s all being handled in a Plugn. However, it’s VERY similar as Derek wanted me to try and keep the style similar to what he had going. Just the part that is calling the jdic static method: SystemInfo.getSessionIdleTime() which I assume is letting jdic do the jni stuff, the plugin calls the Java class which wraps the C++ with jni.
I hope this helps… Let me know if you got other questions in this part of the code.
Hi, I’m noticing that the user presence doesnt work terribly well on our linux setup, which is basically a red-hat 4.2 setup with KDE. It correctly will switch to “Away due to idle”, but it wont switch back. With the debug output, I’m noticing the following error output.
Exception in thread “Timer-5” java.lang.NullPointerException
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
I’m not sure if this helps. FYI, is there any chance of getting this source into svn? It might help us diagnose what the issue is.
I have exactly the same problem.
After starting Spark my account is available as expected. After
some time it goes into away (as expected).
Then when you touch the keyboard/mouse nothing visual happens but
a nullpointer exception is thrown (in error log):
Exception in thread "Timer-4"
at java.util.TimerThread.mainLoop(Unknown Source)+
at java.util.TimerThread.run(Unknown Source)+
My system is a Linux kernel 18.104.22.168 (suse 10.x) and I’ve
tried both Spark version 2.5.7 and 2.6.8 beta 1
This is currently tracked as http://www.igniterealtime.org/issues/browse/SPARK-619
I’ll check on the source question.
Cyclone mentioned that the plugin was using: SystemInfo.getSessionIdleTime() from the jdic librarys.
On their home page https://jdic.dev.java.net/incubator/systeminfo/index.html
there is a note that says: "`` Currently we’re working on getting session lock detection to work from X11 window
managers, which is harder than it first sounded."
I dont know if this is accurate, but if so, it sounds like it might not be properly supported.
BTW, I did find some code that appears to work at: http://search.cpan.org/src/AWENDT/X11-IdleTime-0.4/IdleTime.pm
This is some C code, but I think it should be possible to do a JNI wrapper for it. I did start, but I havent gotten too far at this point.
As for that C code… it’s uhmm surprisingly very close to my C++ code which jni wraps. Var names and all. Which is how Spark is detecting a users activitiy in Linux.
But besides that lameness… let me see if I can help in some way to fix this. As for my version… it still works !http://www.igniterealtime.org/community/images/emoticons/wink.gif!.
P.S. The source is here: http://aspen.twi.gs/IdleLinux.tar.gz
Cyclone mentioned that the plugin was using: SystemInfo.getSessionIdleTime() from the jdic librarys."
no, the Plugin isn’t using jdic. It’s just using JNI. Download the source above and check it out.
That helps enormously.
I think the problem is that your plugin assumes there is a Status called “Online” where as the current version of spark has “Available”. I did a quick recompile and that worked for me (although it looks like a typo got into the code, since it doesnt build out of the box).
How are you setting your status to “Online”? Should it be using a Res.getString?
Thanks for your help.
The Plugin was written SO long ago… before he had the resources setup.
To answer your question… YES.
I can update it and send it to Derek and hope he will add it to the new build(s). However, I’m not sure how busy he will be and how long it could take. Either way I’ll post my version here and if you want go ahead and feel free to edit it and post yours as well. Just please include the source if you do that.
Thanks for looking over it Sam.
If You could recompile a version that works with Available status, that would make my day…
This is my version of the plugin with the source. Its really only one line change, and it currently doesnt work for different languages.
So at least for now, you can use this until a proper solution can be produced which handles that a little better.
I did a fix ontop of your fix Sam, I just added the Res.getString(“Available”)
Resources WERE available and I’m not sure why I didn’t use it at that spot.
I r smrt sumtimes.
Anyways… thanks a ton and I hope this helps everyone.
Let me know if you have any problems.
You made my day, thanks.
I am not sure what to do with IdleLinux_v2.tar.gz, after copying the jar file in everything seem to work.
IdleLinux_v2.tar.gz is just the source code.
If it’s just the plugin needed, you don’t have to worry about anything but the .jar.
Derek did let me know that he will include the fixed plugin with the later releases.