Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.DefaultPacketExtension


  }

  private void showResults(SearchIQ result) {
       
    Enumeration e = result.getJids();
    DefaultPacketExtension dpe = null;
    Hashtable<String,String> columns = new Hashtable<String,String>();
    // TableColumn tColumn = new TableColumn( searchResults, SWT.CENTER );
    // tColumn.setText( "Jabber ID" );

    while (e.hasMoreElements()) {
      dpe = result.getItem((String) e.nextElement());
      Iterator i = dpe.getNames();
      while (i.hasNext()) {
        // TableColumn col = new TableColumn( searchResults, SWT.CENTER
        // );
        String colName = i.next().toString();
        // col.setText( colName );
        columns.put(colName, colName);
      }
    }
    e = result.getJids();
    Enumeration columnNames = columns.keys();
    String name = null;

    while (columnNames.hasMoreElements()) {
      name = (String) columnNames.nextElement();
      name = "form_" + name.trim().toLowerCase();
      getContents(name);
    }

    // searchResults.setHeaderVisible( true );
    // data now....
    String data = "";
    String jid = "";
    Vector<String> row = null;
    Vector<Object> rowData = new Vector<Object>();

    while (e.hasMoreElements()) {
      columnNames = columns.keys();
      jid = (String) e.nextElement();
      dpe = result.getItem(jid);
      row = new Vector<String>();
      String[] strArray = new String[4];
      row.add(jid);
      int i = 0;
      while (columnNames.hasMoreElements()) {
        try {
          data = dpe.getValue((String) columnNames.nextElement());
        } catch (Exception ex) {
          data = "";
        }
        System.out.println("+++" + data);
        row.add(data);
View Full Code Here


   *                If theres a problem with the parsing.
   * @see SearchIQ
   */
  public IQ parseIQ(XmlPullParser parser) throws Exception {
    SearchIQ result = new SearchIQ();
    DefaultPacketExtension item = null;
    String currentTag = null;
    String key = null;
    int event = parser.getEventType();
    /*
     * while (!(event==XmlPullParser.END_TAG &&
     * parser.getName().equals("query"))){
     * if(event==XmlPullParser.START_TAG){ if(item==null &&
     * parser.getName().equals("item") && (!parser.isEmptyElementTag())){
     * item=new DefaultPacketExtension("item","");
     * key=parser.getAttributeValue(0); currentTag=null; } else{
     * currentTag=parser.getName(); if(item==null &&
     * parser.isEmptyElementTag()){ if(!currentTag.equals("instructions")){
     * result.addField(currentTag); currentTag=null; } } } }
     * if(event==XmlPullParser.TEXT && currentTag!=null){ if(item!=null){
     * item.setValue(currentTag,parser.getText()); } else{
     * if(!currentTag.equals("instructions")){
     * result.setField(currentTag,parser.getText()); } else{
     * result.setInstructions(parser.getText()); } } currentTag=null; }
     * if(event==XmlPullParser.END_TAG && parser.getName().equals("item") &&
     * item!=null){ result.addItem(key,item); item=null; }
     * event=parser.next(); }
     */
    while (!(event == XmlPullParser.END_TAG && parser.getName().equals(
        "query"))) {
      if (event == XmlPullParser.START_TAG) {
        if (item == null && parser.getName().equals("item")
            && (!parser.isEmptyElementTag())) {
          item = new DefaultPacketExtension("item", "");
          key = parser.getAttributeValue(0);
          currentTag = null;
        } else {
          currentTag = parser.getName();
          if (item == null && parser.isEmptyElementTag()) {
            if (!currentTag.equals("instructions")) {
              result.addField(currentTag);
              currentTag = null;
            }
          }
        }
        if (currentTag != null && currentTag.equals("x")) {
          result.addExtension(PacketParserUtils.parsePacketExtension(
              parser.getName(), parser.getNamespace(), parser));
        }
      }
      if (event == XmlPullParser.TEXT && currentTag != null) {
        if (item != null) {
          item.setValue(currentTag, parser.getText());
        } else {
          if (!currentTag.equals("instructions")) {
            result.setField(currentTag, parser.getText());
          } else {
            result.setInstructions(parser.getText());
View Full Code Here

    public UserListExtension(SessionIDObservable sessionIDObservable) {
        super(sessionIDObservable, "userList");
    }

    public PacketExtension create(Collection<User> userList) {
        DefaultPacketExtension extension = create();

        int count = 0;
        extension.setValue(COUNT_KEY, String.valueOf(userList.size()));
        for (User participant : userList) {
            String id = USER_KEY + count;
            String permission = USER_PERMISSION_KEY + count;
            String color = USER_COLOR_KEY + count;
            extension.setValue(id, participant.getJID().toString());
            extension.setValue(permission, participant.getPermission().toString());
            extension.setValue(color, String.valueOf(participant.getColorID()));
            count++;
        }

        return extension;
    }
View Full Code Here

    }

    @Override
    public void processMessage(JID sender, Message message) {

        DefaultPacketExtension userlistExtension = getExtension(message);

        List<UserListEntry> users = new LinkedList<UserListEntry>();

        int n = Integer.parseInt(userlistExtension.getValue(COUNT_KEY));

        for (int i = 0; i < n; i++) {
            JID jid = new JID(userlistExtension.getValue(USER_KEY + i));
            int colorID = Integer.parseInt(userlistExtension
                .getValue(USER_COLOR_KEY + i));
            Permission permission = Permission.valueOf(userlistExtension
                .getValue(USER_PERMISSION_KEY + i));

            users.add(new UserListEntry(jid, colorID, permission));
        }
View Full Code Here

    public CancelProjectSharingExtension(SessionIDObservable sessionID) {
        super(sessionID, "cancelProjectSharing");
    }

    public DefaultPacketExtension create(String sessionID, String error) {
        DefaultPacketExtension extension = create();

        extension.setValue(PacketExtensionUtils.SESSION_ID, sessionID);

        if ((error != null) && (error.length() > 0)) {
            extension.setValue(ERROR, error);
        }
        return extension;
    }
View Full Code Here

    }

    @Override
    public void processMessage(JID sender, Message message) {

        DefaultPacketExtension cancelInviteExtension = getExtension(message);

        String errorMsg = cancelInviteExtension.getValue(ERROR);

        projectSharingCanceledReceived(sender, errorMsg);
    }
View Full Code Here

    public CancelInviteExtension(SessionIDObservable sessionID) {
        super(sessionID, "cancelInvite");
    }

    public DefaultPacketExtension create(String sessionID, String error) {
        DefaultPacketExtension extension = create();

        extension.setValue(PacketExtensionUtils.SESSION_ID, sessionID);

        if ((error != null) && (error.length() > 0)) {
            extension.setValue(ERROR, error);
        }
        return extension;
    }
View Full Code Here

    }

    @Override
    public void processMessage(JID sender, Message message) {

        DefaultPacketExtension cancelInviteExtension = getExtension(message);

        String errorMsg = cancelInviteExtension.getValue(ERROR);

        invitationCanceledReceived(sender, errorMsg);
    }
View Full Code Here

        this.sessionID = sessionID;
    }

    @Override
    public DefaultPacketExtension create() {
        DefaultPacketExtension extension = super.create();

        extension.setValue(PacketExtensionUtils.SESSION_ID, sessionID
            .getValue());

        return extension;
    }
View Full Code Here

    public RequestActivityExtension(SessionIDObservable sessionIDObservable) {
        super(sessionIDObservable, "requestActivity");
    }

    public PacketExtension create(int timestamp, boolean andup) {
        DefaultPacketExtension extension = create();

        // TODO create string constants for the used keys
        extension.setValue("ID", String.valueOf(timestamp));

        if (andup) {
            extension.setValue("ANDUP", "true");
        }

        return extension;
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.DefaultPacketExtension

Copyright © 2018 www.massapicom. 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.