Java 类org.jivesoftware.smackx.ReportedData 实例源码

项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 查询用户
 * @param xmppConnection
 * @param userName
 * @return
 * @throws XMPPException
 */
public static List<HashMap<String, String>> searchUsers(XMPPConnection xmppConnection,String userName) {
    List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
    try {
        UserSearchManager usm = new UserSearchManager(xmppConnection);
        Form searchForm = usm.getSearchForm(xmppConnection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("userAccount", true);
        answerForm.setAnswer("userPhote", userName);
        ReportedData data = usm.getSearchResults(answerForm, "search" + xmppConnection.getServiceName());
        Iterator<ReportedData.Row> it = data.getRows();
        while (it.hasNext()) {
            HashMap<String, String> user = new HashMap<String, String>();
            ReportedData.Row row = it.next();
            user.put("userAccount", row.getValues("userAccount").next().toString());
            user.put("userPhote", row.getValues("userPhote").next().toString());
            results.add(user);
        }
    } catch (XMPPException e) {
        e.printStackTrace();
    }
    return results;
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 查询用户
 * @param xmppConnection
 * @param userName
 * @return
 * @throws XMPPException
 */
public static List<HashMap<String, String>> searchUsers(XMPPConnection xmppConnection, String userName) {
    List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
    try {
        UserSearchManager usm = new UserSearchManager(xmppConnection);
        Form searchForm = usm.getSearchForm(xmppConnection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("userAccount", true);
        answerForm.setAnswer("userPhote", userName);
        ReportedData data = usm.getSearchResults(answerForm, "search" + xmppConnection.getServiceName());
        Iterator<ReportedData.Row> it = data.getRows();
        while (it.hasNext()) {
            HashMap<String, String> user = new HashMap<String, String>();
            ReportedData.Row row = it.next();
            user.put("userAccount", row.getValues("userAccount").next().toString());
            user.put("userPhote", row.getValues("userPhote").next().toString());
            results.add(user);
        }
    } catch (XMPPException e) {
        Log.e("searchUsers", e.getMessage());
        e.printStackTrace();
    }
    return results;
}
项目:xmpp    文件:XmppTool.java   
/**
 * 查找用户
 *
 * @param
 * @param userName
 * @return
 */
public List<XmppUser> searchUsers(String userName) {
    List<XmppUser> list = new ArrayList<XmppUser>();
    UserSearchManager userSearchManager = new UserSearchManager(con);
    try {
        Form searchForm = userSearchManager.getSearchForm("search."
                + con.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("Username", true);
        answerForm.setAnswer("Name", true);
        answerForm.setAnswer("search", userName);
        ReportedData data = userSearchManager.getSearchResults(answerForm,
                "search." + con.getServiceName());
        Iterator<ReportedData.Row> rows = data.getRows();
        while (rows.hasNext()) {
            XmppUser user = new XmppUser(null, null);
            ReportedData.Row row = rows.next();
            user.setUserName(row.getValues("Username").next().toString());
            user.setName(row.getValues("Name").next().toString());
            list.add(user);
        }
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
    return list;
}
项目:AyoSunny    文件:XmppUtil.java   
/** 
   * 查询用户 
   *  
   * @param userName 
   * @return 
   * @throws XMPPException 
   */  
  public static List<Session> searchUsers(XMPPConnection mXMPPConnection,String userName) {  
    List<Session> listUser=new ArrayList<Session>();
      try{
    UserSearchManager search = new UserSearchManager(mXMPPConnection);
    //此处一定要加上 search.
    Form searchForm = search.getSearchForm("search."+mXMPPConnection.getServiceName());
    Form answerForm = searchForm.createAnswerForm();
    answerForm.setAnswer("Username", true);
    answerForm.setAnswer("search", userName);
    ReportedData data = search.getSearchResults(answerForm,"search."+mXMPPConnection.getServiceName());                 
    Iterator<Row> it = data.getRows();
    Row row=null;
    while(it.hasNext()){
        row=it.next();
        Session session=new Session();
        session.setFrom(row.getValues("Username").next().toString());
        listUser.add(session);
    }
}catch(Exception e){

}
      return listUser;  
  }
项目:EIM    文件:TranscriptSearchManager.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param serviceJID    the address of the workgroup service.
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
    return ReportedData.getReportedDataFrom(response);
}
项目:EIM    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.SET);
    search.setTo(searchService);
    search.addExtension(searchForm.getDataFormToSend());

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        return sendSimpleSearchForm(con, searchForm, searchService);
    }


    return ReportedData.getReportedDataFrom(response);
}
项目:androidPN-client.    文件:TranscriptSearchManager.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param serviceJID    the address of the workgroup service.
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
    return ReportedData.getReportedDataFrom(response);
}
项目:androidPN-client.    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.SET);
    search.setTo(searchService);
    search.addExtension(searchForm.getDataFormToSend());

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        return sendSimpleSearchForm(con, searchForm, searchService);
    }


    return ReportedData.getReportedDataFrom(response);
}
项目:xmppsupport_v2    文件:TranscriptSearchManager.java   
/**
 * Submits the completed form and returns the result of the transcript
 * search. The result will include all the data returned from the server so
 * be careful with the amount of data that the search may return.
 * 
 * @param serviceJID
 *            the address of the workgroup service.
 * @param completedForm
 *            the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException
 *             if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm)
        throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection
            .createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) collector
            .nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
    return ReportedData.getReportedDataFrom(response);
}
项目:android_chat    文件:AddContacts.java   
boolean userExist(String user, String jid) {
    if (ThreadHelper.xmppConnection.isAuthenticated()) {
        String service = "search."+ThreadHelper.xmppConnection.getServiceName();
        UserSearchManager search = new UserSearchManager(ThreadHelper.xmppConnection);
        try {
            Form queryForm = search.getSearchForm(service);
               Form searchForm = queryForm.createAnswerForm();
               searchForm.setAnswer("Username", true);
               searchForm.setAnswer("search", user);
               ReportedData data = search.getSearchResults(searchForm, service);

               Iterator<Row> rows = data.getRows();
               while (rows.hasNext()) {
                  Row row = rows.next();

                  Iterator<String> jids = row.getValues("jid");
                  while (jids.hasNext())
                   if (jids.next().equalsIgnoreCase(jid))
                       return true;
               }
        } catch (XMPPException e) {
            if (th.D) Log.e(TAG, e.getMessage(), e);
        }
    }
    return false;
}
项目:java-bells    文件:TranscriptSearchManager.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param serviceJID    the address of the workgroup service.
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
    return ReportedData.getReportedDataFrom(response);
}
项目:java-bells    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.SET);
    search.setTo(searchService);
    search.addExtension(searchForm.getDataFormToSend());

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        return sendSimpleSearchForm(con, searchForm, searchService);
    }


    return ReportedData.getReportedDataFrom(response);
}
项目:telegraph    文件:TranscriptSearchManager.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param serviceJID    the address of the workgroup service.
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
    return ReportedData.getReportedDataFrom(response);
}
项目:telegraph    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.SET);
    search.setTo(searchService);
    search.addExtension(searchForm.getDataFormToSend());

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        return sendSimpleSearchForm(con, searchForm, searchService);
    }


    return ReportedData.getReportedDataFrom(response);
}
项目:NewCommunication-Android    文件:TranscriptSearchManager.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param serviceJID    the address of the workgroup service.
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
    TranscriptSearch search = new TranscriptSearch();
    search.setType(IQ.Type.GET);
    search.setTo(serviceJID);
    search.addExtension(completedForm.getDataFormToSend());

    PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
    connection.sendPacket(search);

    TranscriptSearch response = (TranscriptSearch) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }
    return ReportedData.getReportedDataFrom(response);
}
项目:NewCommunication-Android    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.SET);
    search.setTo(searchService);
    search.addExtension(searchForm.getDataFormToSend());

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        return sendSimpleSearchForm(con, searchForm, searchService);
    }


    return ReportedData.getReportedDataFrom(response);
}
项目:EIM    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    SimpleUserSearch search = new SimpleUserSearch();
    search.setForm(searchForm);
    search.setType(IQ.Type.SET);
    search.setTo(searchService);

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }

    if (response instanceof SimpleUserSearch) {
        return ((SimpleUserSearch) response).getReportedData();
    }
    return null;
}
项目:EIM    文件:XmppConnectionManager.java   
/**
 * �����û�
 * 
 * @param serverDomain
 * @param userName
 * @return
 */
public List<User> searchUsers(String serverDomain, String userName) {
    List<User> list = new ArrayList<User>();
    UserSearchManager userSearchManager = new UserSearchManager(connection);
    try {
        Form searchForm = userSearchManager.getSearchForm("search."
                + serverDomain);
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("Username", true);
        answerForm.setAnswer("Name", true);
        answerForm.setAnswer("search", userName);
        ReportedData data = userSearchManager.getSearchResults(answerForm,
                "search." + serverDomain);
        Iterator<Row> rows = data.getRows();
        while (rows.hasNext()) {
            User user = new User();
            Row row = rows.next();
            user.setUserName(row.getValues("Username").next().toString());
            user.setName(row.getValues("Name").next().toString());
            SLog.i(tag, user.toString());
            list.add(user);
        }
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
    return list;
}
项目:androidPN-client.    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    SimpleUserSearch search = new SimpleUserSearch();
    search.setForm(searchForm);
    search.setType(IQ.Type.SET);
    search.setTo(searchService);

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }

    if (response instanceof SimpleUserSearch) {
        return ((SimpleUserSearch) response).getReportedData();
    }
    return null;
}
项目:xmppsupport_v2    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search
 * service.
 * 
 * @param con
 *            the current Connection.
 * @param searchForm
 *            the <code>Form</code> to send for querying.
 * @param searchService
 *            the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *             thrown if a server error has occurred.
 */
public ReportedData sendSearchForm(Connection con, Form searchForm,
        String searchService) throws XMPPException {
    UserSearch search = new UserSearch();
    search.setType(IQ.Type.SET);
    search.setTo(searchService);
    search.addExtension(searchForm.getDataFormToSend());

    PacketCollector collector = con
            .createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration
            .getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        return sendSimpleSearchForm(con, searchForm, searchService);
    }

    return ReportedData.getReportedDataFrom(response);
}
项目:xmppsupport_v2    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search
 * service.
 * 
 * @param con
 *            the current Connection.
 * @param searchForm
 *            the <code>Form</code> to send for querying.
 * @param searchService
 *            the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *             thrown if a server error has occurred.
 */
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm,
        String searchService) throws XMPPException {
    SimpleUserSearch search = new SimpleUserSearch();
    search.setForm(searchForm);
    search.setType(IQ.Type.SET);
    search.setTo(searchService);

    PacketCollector collector = con
            .createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration
            .getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }

    if (response instanceof SimpleUserSearch) {
        return ((SimpleUserSearch) response).getReportedData();
    }
    return null;
}
项目:java-bells    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    SimpleUserSearch search = new SimpleUserSearch();
    search.setForm(searchForm);
    search.setType(IQ.Type.SET);
    search.setTo(searchService);

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }

    if (response instanceof SimpleUserSearch) {
        return ((SimpleUserSearch) response).getReportedData();
    }
    return null;
}
项目:telegraph    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    SimpleUserSearch search = new SimpleUserSearch();
    search.setForm(searchForm);
    search.setType(IQ.Type.SET);
    search.setTo(searchService);

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }

    if (response instanceof SimpleUserSearch) {
        return ((SimpleUserSearch) response).getReportedData();
    }
    return null;
}
项目:NewCommunication-Android    文件:UserSearch.java   
/**
 * Sends the filled out answer form to be sent and queried by the search service.
 *
 * @param con           the current Connection.
 * @param searchForm    the <code>Form</code> to send for querying.
 * @param searchService the search service to use. (ex. search.jivesoftware.com)
 * @return ReportedData the data found from the query.
 * @throws org.jivesoftware.smack.XMPPException
 *          thrown if a server error has occurred.
 */
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
    SimpleUserSearch search = new SimpleUserSearch();
    search.setForm(searchForm);
    search.setType(IQ.Type.SET);
    search.setTo(searchService);

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));

    con.sendPacket(search);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

    // Cancel the collector.
    collector.cancel();
    if (response == null) {
        throw new XMPPException("No response from server on status set.");
    }
    if (response.getError() != null) {
        throw new XMPPException(response.getError());
    }

    if (response instanceof SimpleUserSearch) {
        return ((SimpleUserSearch) response).getReportedData();
    }
    return null;
}
项目:spark-svn-mirror    文件:SearchForm.java   
/**
 * Starts a search based on the Answered form.
 */
public void performSearch() {
    searchResults.clearTable();

    SwingWorker worker = new SwingWorker() {
        ReportedData data;

        public Object construct() {
            try {
                Form answerForm = questionForm.getFilledForm();
                data = searchManager.getSearchResults(answerForm, serviceName);
            }
            catch (XMPPException e) {
                Log.error("Unable to load search service.", e);
            }

            return data;
        }

        public void finished() {
            if (data != null) {
                searchResults.showUsersFound(data);
                searchResults.invalidate();
                searchResults.validate();
                searchResults.repaint();
            }
            else {
                JOptionPane.showMessageDialog(searchResults, Res.getString("message.no.results.found"), Res.getString("title.notification"), JOptionPane.ERROR_MESSAGE);
            }
        }
    };

    worker.start();


}
项目:spark-svn-mirror    文件:UserSearchResults.java   
/**
 * Returns the first value found in the ReportedData.Row.
 *
 * @param row the ReportedData.Row.
 * @param key the specified key in the ReportedData.Row.
 * @return the first value found in the ReportedData.Row
 */
public String getFirstValue(ReportedData.Row row, String key) {
    try {
        final Iterator<String> rows = row.getValues(key);
        while (rows.hasNext()) {
            return rows.next();
        }
    }
    catch (Exception e) {
        Log.error("Error retrieving the first value.", e);
    }
    return null;
}
项目:spark-svn-mirror    文件:ChatSearchResult.java   
public ChatSearchResult(ReportedData.Row row, String query) {
    UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));

    String startDate = getFirstValue(row, "startDate");

    try {
        creationDate = UTC_FORMAT.parse(startDate);
    }
    catch (ParseException e) {
        Log.error(e);
    }


    sessionID = getFirstValue(row, "sessionID");

    StringBuffer authors = new StringBuffer();
    Iterator athrs = row.getValues("agentJIDs");
    while (athrs.hasNext()) {
        authors.append((String)athrs.next());
        authors.append(" ");
    }

    String rell = getFirstValue(row, "relevance");
    Double o = Double.valueOf(rell);

    relevance = ((int)o.doubleValue() * 100);

    question = getFirstValue(row, "question");
    customerName = getFirstValue(row, "username");
    email = getFirstValue(row, "email");

    fields.add(customerName);
    fields.add(question);
    fields.add(email);
    fields.add(authors.toString());
    fields.add(creationDate);
}
项目:spark-svn-mirror    文件:ChatSearchResult.java   
public String getFirstValue(ReportedData.Row row, String key) {
    try {
        final Iterator iter = row.getValues(key);
        while (iter.hasNext()) {
            return (String)iter.next();
        }
    }
    catch (Exception e) {
    }
    return null;
}
项目:EIM    文件:SimpleUserSearch.java   
public ReportedData getReportedData() {
    return data;
}
项目:androidPN-client.    文件:SimpleUserSearch.java   
public ReportedData getReportedData() {
    return data;
}
项目:xmppsupport_v2    文件:SimpleUserSearch.java   
public ReportedData getReportedData() {
    return data;
}
项目:yiim_v2    文件:FriendAddActivity.java   
private void searchEjaaberd() {
    // 此处一定要加上 search.
    try {
        Connection connection = getXmppBinder().getXmppConnection();
        UserSearchManager search = new UserSearchManager(connection);
        Form searchForm = search.getSearchForm("vjud."
                + connection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        // answerForm.setAnswer("nick", mSearchEditText.getText()
        // .toString().trim() + "*");
        answerForm.setAnswer("user", mSearchEditText.getText().toString()
                .trim() + "*");
        // answerForm.setAnswer("search", mSearchEditText.getText()
        // .toString().trim());
        ReportedData data = search.getSearchResults(answerForm, "vjud."
                + connection.getServiceName());
        Iterator<Row> it = data.getRows();
        Row row = null;

        ArrayList<FriendAddModel> list = new ArrayList<FriendAddModel>();
        while (it.hasNext()) {
            row = it.next();
            String userId = StringUtils.escapeUserResource(row
                    .getValues("jid").next().toString());
            FriendAddModel model = new FriendAddModel(userId);
            model.setMsg(userId);
            String nick = row.getValues("nick").next().toString();
            if (!YiUtils.isStringInvalid(nick)) {
                model.setName(nick);
            }

            XmppVcard vCard = new XmppVcard(getXmppBinder()
                    .getServiceContext());
            vCard.load(connection, model.getMsg());

            // 加载用户的个性签名
            String sign = vCard.getSign();
            if (sign != null && sign.length() > 0) {
                if (model.getSubMsg().length() > 1) {
                    sign = ' ' + sign;
                }
                model.setSubMsg(model.getSubMsg() + sign);
            }
            list.add(model);
        }
        Message message = getHandler().obtainMessage(MSG_ON_SEARCH_SUCCESS,
                list);
        message.sendToTarget();
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}
项目:yiim_v2    文件:FriendAddActivity.java   
private void searchOpenfire() {
    // 此处一定要加上 search.
    try {
        Connection connection = getXmppBinder().getXmppConnection();
        UserSearchManager search = new UserSearchManager(connection);
        Form searchForm = search.getSearchForm("search."
                + connection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("Username", true);
        answerForm.setAnswer("search", mSearchEditText.getText().toString()
                .trim());
        ReportedData data = search.getSearchResults(answerForm, "search."
                + connection.getServiceName());
        Iterator<Row> it = data.getRows();
        Row row = null;

        ArrayList<FriendAddModel> list = new ArrayList<FriendAddModel>();
        while (it.hasNext()) {
            row = it.next();
            String userId = row.getValues("Username").next().toString()
                    + "@" + XmppConnectionUtils.getXmppHost();
            FriendAddModel model = new FriendAddModel(userId);
            model.setMsg(userId);
            model.setName(row.getValues("Name").next().toString());

            XmppVcard vCard = new XmppVcard(getXmppBinder()
                    .getServiceContext());
            vCard.load(connection, userId);

            // 加载用户的个性签名
            String sign = vCard.getSign();
            if (sign != null && sign.length() > 0) {
                if (model.getSubMsg().length() > 1) {
                    sign = ' ' + sign;
                }
                model.setSubMsg(model.getSubMsg() + sign);
            }
            list.add(model);
        }
        Message message = getHandler().obtainMessage(MSG_ON_SEARCH_SUCCESS,
                list);
        message.sendToTarget();
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}
项目:java-bells    文件:SimpleUserSearch.java   
public ReportedData getReportedData() {
    return data;
}
项目:telegraph    文件:SimpleUserSearch.java   
public ReportedData getReportedData() {
    return data;
}
项目:NewCommunication-Android    文件:SimpleUserSearch.java   
public ReportedData getReportedData() {
    return data;
}
项目:EIM    文件:AgentSession.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData searchTranscripts(Form completedForm) throws XMPPException {
    return transcriptSearchManager.submitSearch(StringUtils.parseServer(workgroupJID),
            completedForm);
}
项目:EIM    文件:UserSearchManager.java   
/**
 * Submits a search form to the server and returns the resulting information
 * in the form of <code>ReportedData</code>
 *
 * @param searchForm    the <code>Form</code> to submit for searching.
 * @param searchService the name of the search service to use.
 * @return the ReportedData returned by the server.
 * @throws XMPPException thrown if a server error has occurred.
 */
public ReportedData getSearchResults(Form searchForm, String searchService) throws XMPPException {
    return userSearch.sendSearchForm(con, searchForm, searchService);
}
项目:androidPN-client.    文件:AgentSession.java   
/**
 * Submits the completed form and returns the result of the transcript search. The result
 * will include all the data returned from the server so be careful with the amount of
 * data that the search may return.
 *
 * @param completedForm the filled out search form.
 * @return the result of the transcript search.
 * @throws XMPPException if an error occurs while submiting the search to the server.
 */
public ReportedData searchTranscripts(Form completedForm) throws XMPPException {
    return transcriptSearchManager.submitSearch(StringUtils.parseServer(workgroupJID),
            completedForm);
}
项目:androidPN-client.    文件:UserSearchManager.java   
/**
 * Submits a search form to the server and returns the resulting information
 * in the form of <code>ReportedData</code>
 *
 * @param searchForm    the <code>Form</code> to submit for searching.
 * @param searchService the name of the search service to use.
 * @return the ReportedData returned by the server.
 * @throws XMPPException thrown if a server error has occurred.
 */
public ReportedData getSearchResults(Form searchForm, String searchService) throws XMPPException {
    return userSearch.sendSearchForm(con, searchForm, searchService);
}