Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] How could I obtain the hostname ?

>> the challenge is to discover which interface adapter could be used and where... :)

Platform.getAdapterManager() contains some information if the adapter was registered. The adapter mechanism must be programmed like this


SomeObject implements IAdaptable{

Object getAdapter(Class){

  if(Class == xyz)

       return new xyzimpl(this);

  else

   return Platform.getAdapterManager().getAdapter(this, Class);

}}

Like you said, this makes it nearly invisible that "SomeObject" can be converted to xyz. 

Is there a valid reason to directly implement IAdaptable?

Regards,

Wim



On Thu, Jul 28, 2011 at 7:19 PM, Cristiano Gavião <cvgaviao@xxxxxxxxx> wrote:
Hi Scott,

Very powerful this adapter approach.. I liked that...  the challenge is to discover which interface adapter could be used and where... :)

But I think that now I have enough information to play a lot with ECF examples for days...

Have nice days without internet :D  and thanks a lot for your support...

cheers

Cristiano


On 28/07/11 12:35, Scott Lewis wrote:
Hi Cristiano,

On 7/28/2011 5:54 AM, Cristiano Gavião wrote:
Hi,

I'm digging a little bit on the presence api...

Now I could get the list of all contacts of my user using Adapter... very interesting...:

XMPPContainer containerXMPP = (XMPPContainer) client.getContainer().getAdapter(XMPPContainer.class);
       IRoster roster = containerXMPP.getRosterManager().getRoster();
       Collection rosterList = roster.getItems();
       for (Iterator iterator = rosterList.iterator(); iterator.hasNext();) {
           RosterItem roster_item = (RosterItem) iterator.next();
           System.out.println(roster_item.getRoster().getUser().getID());
       }


Actually, it's preferred that you use the presence API to use the roster...e.g.

IPresenceContainerAdapter containerAdapter = (IPresenceContainerAdapter) client.getContainer().getAdapter(IPresenceContainerAdapter.class);

IRosterManager rosterManager = containerAdapter.getRosterManager();
IRoster roster = rosterManager.getRoster();
etc.

The reason this is preferable is that the presence API is separate from XMPP...and can/is implemented by other presence protocols.  So clients can use this presence API without regard to the underlying protocol that implements it.

But I couldn't find the hostname of the contacts.

How could I obtain the hostname of a contact user ?

For any contact user's ID (contactUserID), you can do this:

IFQID fullyQualifiedID = (IFQID) contactUserID.getAdapter(IFQID.class);

String fullyQualifiedName = fullyQualifiedID.getFQName();

I'm going out of reach of the Internet for a couple of days, so I may not respond as fast as I typically do.

Thanks,

Scott




cheers



Back to the top