powered by Jive Software

Retrieve the user's last presence mode

Hi All,

Please let me know the ideas for implementing the following scenarios using Smack API.

  1. To retrieve the user’s last presence mode.

             For example, if an user sets his presence mode to "dnd", on logging in next time  to the server, I like to retrieve his last presence mode i.e., “dnd” to be set in my client application. Its similar to how Gtalk behaves w.r.t this last presence mode.
    
  2. To retrieve the currently logged in user’s presence info using Smack. I can see methods for retrieving roster’s presence info, but I am unable to find the methods for retrieving presence of the user itself.

Thanks,

Mari

The following should help you out a bit

Roster#getPresence(string user)

You can then check their “Mode” by

Presence#getMode()

which will return the mode of the presence of null if its not been set

Hi,

Thanks for your response.

The above mentioned questions are pertaining to “my presence” not my roster presence.

-Mari

aww sorry, I get you now.

Okay I might be wrong here, but I dont think XMPP handles this by default. Pretty sure that googletalk probably handles it by storing recently used statues on their own server. You can code around this by storing this info in some local settings, and then using them again when a user logs in.

Hi,

Yes, storing in DB or local setting is a workable solution for both questions.

But for question # 2.

I assumed that XMPP supports retrieval of own presence info because Openfire’s Admin Console displays these presence info under “Sessions” tab , which is also client of XMPP.

-Mari

Well openfire is a server so I’d presume (I could be wrong) that they store recently used status’s much like google talks servers do? It might be worth digging around in the code to see how they do it

Oh !!!

Is there anything, what we could do?

I need to retrieve a user’s last presence on login and use that presence as “initial presence”.

The requirement is, that it needs to be stored on the server, not in local DB or settings file.

1.) Does Openfire store the last presence for each user?

2.) Is there an XEP that I could use, like sending an and retrieve the stored value?

Otherwise the only possibility I see, is to store it in the user’s XML Private Storage, correct?

Or do you have any other ideas?