Examples of Presence


Examples of nu.fw.jeti.jabber.elements.Presence

  public void disconnect()
  {
    if(authenticated)
    {
      send(new Presence(myJID, "unavailable"));
      authenticated = false;
      output.disconnect(true);
    }
    output = null;
    for(Iterator<JETIListener> j = backend.getListeners(nu.fw.jeti.events.StatusChangeListener.class);j.hasNext();)
View Full Code Here

Examples of org.cipango.kaleo.presence.pidf.Presence

    presenceSession.sendRequest(subscribe, Response.OK); // 4

    ServerTransaction tx = presenceSession.waitForNotify(); // 5
    //System.out.println("3:\n" + tx.getRequest());
    presenceSession.sendResponse(Response.OK, tx); // 6
    Presence presence = getPresence(tx.getRequest());
    assertEquals(Basic.OPEN, presence.getTupleArray()[0].getStatus().getBasic());
   
   
    SubscribeSession winfoSession = new SubscribeSession(getBobPhone(), "presence.winfo"); // 7
    subscribe = winfoSession.newInitialSubscribe(60, getBobUri());
    winfoSession.sendRequest(subscribe, Response.OK); // 8
   
    tx = winfoSession.waitForNotify(); // 9
    Request notify = tx.getRequest();
    //System.out.println(notify);
    winfoSession.sendResponse(Response.OK, tx); // 10
    SubscriptionStateHeader subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
    assertEquals(SubscriptionStateHeader.ACTIVE.toLowerCase(), subState.getState().toLowerCase());
    assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
    Watcherinfo watcherinfo = getWatcherinfo(notify);
    assertEquals(0, watcherinfo.getVersion().intValue());
    assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(getBobUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(1, watcherList.getWatcherArray().length);
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.SUBSCRIBE, watcher.getEvent());
    assertEquals(getAliceUri(), watcher.getStringValue());
    assertEquals(Status.ACTIVE, watcher.getStatus());
   
   
    HttpClient httpClient = new HttpClient();
    PutMethod put = new PutMethod(getHttpXcapUri() + BOB_PRES_RULES_URI); // 11
   
    InputStream is = WatcherInfoTest.class.getResourceAsStream("/xcap-root/pres-rules/users/put/elementPoliteBlock.xml");
    RequestEntity entity = new InputStreamRequestEntity(is, "application/xcap-el+xml");
    put.setRequestEntity(entity);
   
    int result = httpClient.executeMethod(put);
    assertEquals(200, result); // 12
    put.releaseConnection();
   
    tx = presenceSession.waitForNotify(); // 13
    //System.out.println("11:\n" + tx.getRequest());
    presenceSession.sendResponse(Response.OK, tx); // 14
    presence = getPresence(tx.getRequest());
    assertEquals(Basic.CLOSED, presence.getTupleArray()[0].getStatus().getBasic());
   
    tx = winfoSession.waitForNotify(); // 15
    notify = tx.getRequest();
    winfoSession.sendResponse(Response.OK, tx); // 16
    System.out.println(notify);
View Full Code Here

Examples of org.cipango.kaleo.presence.pidf.Presence

    presenceSession.sendRequest(subscribe, Response.OK); // 4

    ServerTransaction tx = presenceSession.waitForNotify(); // 5
    System.out.println("5:\n" + tx.getRequest());
    presenceSession.sendResponse(Response.OK, tx); // 6
    Presence presence = getPresence(tx.getRequest());
    assertEquals(Basic.CLOSED, presence.getTupleArray()[0].getStatus().getBasic());
   
   
    SubscribeSession winfoSession = new SubscribeSession(getAlicePhone(), "presence.winfo"); // 7
    subscribe = winfoSession.newInitialSubscribe(60, getAliceUri());
    winfoSession.sendRequest(subscribe, Response.OK); // 8
   
    tx = winfoSession.waitForNotify(); // 9
    Request notify = tx.getRequest();
    System.out.println("9:\n" +notify);
    winfoSession.sendResponse(Response.OK, tx); // 10
    SubscriptionStateHeader subState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
    assertEquals(SubscriptionStateHeader.ACTIVE.toLowerCase(), subState.getState().toLowerCase());
    assertEquals(WatcherInfoEventPackage.NAME, ((EventHeader) notify.getHeader(EventHeader.NAME)).getEventType());
    Watcherinfo watcherinfo = getWatcherinfo(notify);
    assertEquals(0, watcherinfo.getVersion().intValue());
    assertEquals(Watcherinfo.State.FULL, watcherinfo.getState());
    assertEquals(1, watcherinfo.getWatcherListArray().length);
    WatcherList watcherList = watcherinfo.getWatcherListArray(0);
    assertEquals(getAliceUri(), watcherList.getResource());
    assertEquals(PresenceEventPackage.NAME, watcherList.getPackage());
    assertEquals(1, watcherList.getWatcherArray().length);
    Watcher watcher = watcherList.getWatcherArray(0);
    assertEquals(Event.TIMEOUT, watcher.getEvent());
    assertEquals(getBobUri(), watcher.getStringValue());
    assertEquals(Status.WAITING, watcher.getStatus())
   
   
    HttpClient httpClient = new HttpClient();
    PutMethod put = new PutMethod(getHttpXcapUri() + ALICE_PRES_RULES_URI); // 11
   
    InputStream is = WatcherInfoTest.class.getResourceAsStream("/xcap-root/pres-rules/users/put/elementCondAliceBob.xml");
    RequestEntity entity = new InputStreamRequestEntity(is, "application/xcap-el+xml");
    put.setRequestEntity(entity);
   
    int result = httpClient.executeMethod(put);
    assertEquals(200, result); // 12
    put.releaseConnection();
   
    presenceSession = new SubscribeSession(getBobPhone(), "presence");
    subscribe = presenceSession.newInitialSubscribe(0, getAliceUri()); // 13
    presenceSession.sendRequest(subscribe, Response.OK); // 14

    tx = presenceSession.waitForNotify(); // 15
    System.out.println("15:\n" + tx.getRequest());
    presenceSession.sendResponse(Response.OK, tx); // 16
    presence = getPresence(tx.getRequest());
    assertEquals(Basic.OPEN, presence.getTupleArray()[0].getStatus().getBasic());
   
    publish = publishSession.newUnpublish(); // 25
    publishSession.sendRequest(publish, Response.OK); // 26
  }
View Full Code Here

Examples of org.cipango.kaleo.presence.pidf.Presence

  }

  public State getNeutralState()
  {
    PresenceDocument document = PresenceDocument.Factory.newInstance();
    Presence presence = document.addNewPresence();
    presence.setEntity(getUri());
    Tuple tuple = document.getPresence().addNewTuple();
    tuple.setId("123");
    tuple.addNewStatus().setBasic(Basic.CLOSED);
    return new State(PresenceEventPackage.PIDF, document);
  }
View Full Code Here

Examples of org.cipango.kaleo.presence.pidf.Presence

        presentity.getState().getContent().toString());
    PresenceDocument doc1 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/org/cipango/kaleo/sipunit/publish1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    PresenceDocument doc2 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/pidf1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc2, 60);
    Presence presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    assertEquals(2, presence.getTupleArray().length);
    assertEquals(doc1.getPresence().getTupleArray(0).getId(), presence.getTupleArray(0).getId());
    assertEquals(doc2.getPresence().getTupleArray(0).getId(), presence.getTupleArray(1).getId());
   
    PresenceDocument doc3 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/org/cipango/kaleo/sipunit/publish2.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc3, 60);
    presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    assertEquals(3, presence.getTupleArray().length);
   
    //System.out.println(presentity.getState().getContent());
  }
View Full Code Here

Examples of org.cipango.kaleo.presence.pidf.Presence

 
    PresenceDocument doc1 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/pidfNamespace.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    PresenceDocument doc2 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/pidf1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc2, 60);
    Presence presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    //System.out.println(presentity.getState().getContent());
  }
View Full Code Here

Examples of org.cipango.kaleo.presence.pidf.Presence

  {   
    Presentity presentity = new Presentity("sip:alice@cipango.org");
    PresenceDocument doc1 = PresenceDocument.Factory.parse(getClass().getResourceAsStream("/org/cipango/kaleo/sipunit/publish1.xml"));
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    presentity.addState(PresenceEventPackage.PIDF, doc1, 60);
    Presence presence =  ((PresenceDocument) presentity.getState().getContent()).getPresence();
    assertEquals(1, presence.getTupleArray().length);
  }
View Full Code Here

Examples of org.eclipse.ecf.presence.Presence

    IRosterEntry entry;
      try {
        userID = IDFactory.getDefault().createID(targetID.getNamespace(), userName);

        IUser child = new org.eclipse.ecf.core.user.User(userID,userName);
        IPresence presence = new Presence(IPresence.Type.AVAILABLE);
        entry = new RosterEntry(parent, child,presence);
        /*IPresence presence = presenceContainer.createPresence(userID.getName());
        entry.setPresenceState(presence);*/
        return entry;
      } catch (IDCreateException e) {
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

        }

        try{
            connection.login(user, password);
            System.out.println("Logged in as " + connection.getUser());
            Presence presence = new Presence(Presence.Type.available);
            connection.sendPacket(presence);

        } catch (XMPPException ex){
            Logger.getLogger(JabberWorkItemHandler.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("Failed to log in as " + connection.getUser());
View Full Code Here

Examples of org.jivesoftware.smack.packet.Presence

    /**
     * Processes incoming presence packets (from group chats)
     */
    public void processPacket(Packet packet) {
        final Presence presence = (Presence) packet;
        final String from = packet.getFrom();

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                boolean redraw = false;
                //right now we find out if we have already received a packet
                // from them,
                //and if not, we set up an information "account" in the system
                MUCBuddyStatus buddy = window.getBuddyStatus(from);

                window.removeBuddy(buddy.getUser());

                // get the role and affiliation information
                MUCUser user = (MUCUser) presence.getExtension("x",
                        "http://jabber.org/protocol/muc#user");
                if (user != null) {
                    buddy.setMUCUser(user);
                    MUCUser.Item item = user.getItem();
                    if (item != null) {
                        if (item.getAffiliation() != null)
                            buddy.setAffiliation(item.getAffiliation());
                        if (item.getRole() != null)
                            buddy.setRole(item.getRole());

                        if(item.getAffiliation()!=null && item.getRole()!=null)
                        {
                            if(item.getAffiliation().equals("none") && item.getRole().equals("none"))
                            {
                                presence.setType(Presence.Type.UNAVAILABLE);
                            }
                        }
                    }
                }

                // update the relavent presence information
                if (presence.getType() == Presence.Type.UNAVAILABLE ) {
                    ConversationPanel conv = buddy.getConversation();
                    if ((conv != null) && (conv instanceof ChatPanel))
                        ((ChatPanel) conv).signedOff();

                } else {
                    buddy.addResource("_no resource_", 5, presence.getMode(),
                            presence.getStatus());
                }

                //if we need to, reload the nicklist.
                if (presence.getType() == Presence.Type.AVAILABLE) {
                    window.addBuddy(buddy.getUser());
                    String name = buddy.getName();
                    if (name == null)
                        return;
                    if (nickChange == null && !buddy.getIsInRoom()) {

                        String message = buddy.getName();
                        if( buddy.getJid() != null )
                        {
                            message += " (" + buddy.getJid() + ") ";
                        }

                        message += " has entered the room";

                        window.serverNoticeMessage(message);
                        PluginChain.fireEvent(new MUCEvent(buddy.getUser(),
                                MUCEvent.EVENT_PARTICIPANT_JOINED, "",
                                new Date()));
                    } else if (nickChange != null) {
                        nickChange.setIsInRoom(false);
                        window.serverNoticeMessage(nickChange.getName()
                                + " is now known as " + buddy.getName());
                        window.removeBuddy(nickChange.getUser());
                    }

                    buddy.setIsInRoom(true);

                    nickChange = null;
                } else if (presence.getType() == Presence.Type.UNAVAILABLE) {
                    buddy.setIsInRoom(false);
                    window.getBuddyStatuses().remove(buddy);
                    String leaveMessage = buddy.getName()
                            + " has left the room";
                    PluginChain.fireEvent(new MUCEvent(buddy.getUser(),
                            MUCEvent.EVENT_PARTICIPANT_PARTED, "", new Date()));

                    if (presence.getStatus() != null
                            && !presence.getStatus().equals("")) {
                        leaveMessage += ": " + presence.getStatus();
                    }

                    if (nickChange == null)
                        window.serverNoticeMessage(leaveMessage);
                    else
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.