/** * Executes the <code>action</code> with the <code>form</code>. * The action could be any of the available actions. The form must * be the answer of the previous stage. It can be <tt>null</tt> if it is the first stage. * * @param action the action to execute. * @param form the form with the information. * @throws XMPPErrorException if there is a problem executing the command. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ private void executeAction(Action action, Form form) throws NoResponseException, XMPPErrorException, NotConnectedException { // TODO: Check that all the required fields of the form were filled, if // TODO: not throw the corresponding exeption. This will make a faster response, // TODO: since the request is stoped before it's sent. AdHocCommandData data = new AdHocCommandData(); data.setType(IQ.Type.set); data.setTo(getOwnerJID()); data.setNode(getNode()); data.setSessionID(sessionID); data.setAction(action); if (form != null) { data.setForm(form.getDataFormToSend()); } AdHocCommandData responseData = (AdHocCommandData) connection.createPacketCollectorAndSend( data).nextResultOrThrow(); this.sessionID = responseData.getSessionID(); super.setData(responseData); }
/** * Creates a node with specified configuration. * * Note: This is the only way to create a collection node. * * @param name The name of the node, which must be unique within the * pubsub service * @param config The configuration for the node * @return The node that was created * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Node createNode(String name, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub request = PubSub.createPubsubPacket(to, Type.set, new NodeExtension(PubSubElementType.CREATE, name), null); boolean isLeafNode = true; if (config != null) { request.addExtension(new FormNode(FormNodeType.CONFIGURE, config)); FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName()); if (nodeTypeField != null) isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString()); } // Errors will cause exceptions in getReply, so it only returns // on success. sendPubsubPacket(con, request); Node newNode = isLeafNode ? new LeafNode(con, name) : new CollectionNode(con, name); newNode.setTo(to); nodeMap.put(newNode.getId(), newNode); return newNode; }
private String getItemsToSearch() { StringBuilder buf = new StringBuilder(); if (form == null) { form = Form.getFormFrom(this); } if (form == null) { return ""; } for (FormField field : form.getFields()) { String name = field.getVariable(); String value = getSingleValue(field); if (value.trim().length() > 0) { buf.append("<").append(name).append(">").append(value).append("</").append(name).append(">"); } } return buf.toString(); }
private Stanza prepareKeyPacket() { String privatekey = Base64.encodeToString(mPrivateKeyData, Base64.NO_WRAP); Registration iq = new Registration(); iq.setType(IQ.Type.set); iq.setTo(getConnection().getServiceName()); Form form = new Form(DataForm.Type.submit); // form type: register#privatekey FormField type = new FormField("FORM_TYPE"); type.setType(FormField.Type.hidden); type.addValue("http://kontalk.org/protocol/register#privatekey"); form.addField(type); // private key FormField fieldKey = new FormField("privatekey"); fieldKey.setLabel("Private key"); fieldKey.setType(FormField.Type.text_single); fieldKey.addValue(privatekey); form.addField(fieldKey); iq.addExtension(form.getDataFormToSend()); return iq; }
private Stanza createValidationForm() throws IOException { Registration iq = new Registration(); iq.setType(IQ.Type.set); iq.setTo(mConnector.getConnection().getServiceName()); Form form = new Form(DataForm.Type.submit); FormField type = new FormField("FORM_TYPE"); type.setType(FormField.Type.hidden); type.addValue("http://kontalk.org/protocol/register#code"); form.addField(type); if (mValidationCode != null) { FormField code = new FormField("code"); code.setLabel("Validation code"); code.setType(FormField.Type.text_single); code.addValue(mValidationCode.toString()); form.addField(code); } iq.addExtension(form.getDataFormToSend()); return iq; }
private Packet createRegistrationForm() { Registration iq = new Registration(); iq.setType(IQ.Type.SET); iq.setTo(mConnector.getConnection().getServiceName()); Form form = new Form(Form.TYPE_SUBMIT); FormField type = new FormField("FORM_TYPE"); type.setType(FormField.TYPE_HIDDEN); type.addValue("jabber:iq:register"); form.addField(type); FormField phone = new FormField("phone"); phone.setLabel("Phone number"); phone.setType(FormField.TYPE_TEXT_SINGLE); phone.addValue(mPhone); form.addField(phone); iq.addExtension(form.getDataFormToSend()); return iq; }
public JoinQueuePacket(String workgroup, Form answerForm, String userID) { super("join-queue", "http://jabber.org/protocol/workgroup"); this.userID = userID; setTo(workgroup); setType(IQ.Type.set); form = answerForm.getDataFormToSend(); addExtension(form); }
/** * Create a {@link FormNode} which contains the specified form. * * @param formType The type of form being sent * @param submitForm The form */ public FormNode(FormNodeType formType, Form submitForm) { super(formType.getNodeElement()); if (submitForm == null) throw new IllegalArgumentException("Submit form cannot be null"); configForm = submitForm; }
/** * Create a {@link FormNode} which contains the specified form, which is * associated with the specified node. * * @param formType The type of form being sent * @param nodeId The node the form is associated with * @param submitForm The form */ public FormNode(FormNodeType formType, String nodeId, Form submitForm) { super(formType.getNodeElement(), nodeId); if (submitForm == null) throw new IllegalArgumentException("Submit form cannot be null"); configForm = submitForm; }
/** * Returns the number of offline messages for the user of the connection. * * @return the number of offline messages for the user of the connection. * @throws XMPPErrorException If the user is not allowed to make this request or the server does * not support offline message retrieval. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getValues().get(0); return Integer.parseInt(value); } return 0; }
/** * <p>Joins the workgroup queue to wait to be routed to an agent. After joining * the queue, queue status events will be sent to indicate the user's position and * estimated time left in the queue. Once joining the queue, there are three ways * the user can leave the queue: <ul> * <p/> * <li>The user is routed to an agent, which triggers a GroupChat invitation. * <li>The user asks to leave the queue by calling the {@link #departQueue} method. * <li>A server error occurs, or an administrator explicitly removes the user * from the queue. * </ul> * <p/> * A user cannot request to join the queue again if already in the queue. Therefore, * this method will throw an IllegalStateException if the user is already in the queue.<p> * <p/> * Some servers may be configured to require certain meta-data in order to * join the queue.<p> * <p/> * The server tracks the conversations that a user has with agents over time. By * default, that tracking is done using the user's JID. However, this is not always * possible. For example, when the user is logged in anonymously using a web client. * In that case the user ID might be a randomly generated value put into a persistent * cookie or a username obtained via the session. When specified, that userID will * be used instead of the user's JID to track conversations. The server will ignore a * manually specified userID if the user's connection to the server is not anonymous. * * @param metadata metadata to create a dataform from. * @param userID String that represents the ID of the user when using anonymous sessions * or <tt>null</tt> if a userID should not be used. * @throws XMPPException if an error occured joining the queue. An error may indicate * that a connection failure occured or that the server explicitly rejected the * request to join the queue. * @throws SmackException */ public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException, SmackException { // If already in the queue ignore the join request. if (inQueue) { throw new IllegalStateException("Already in queue " + workgroupJID); } // Build dataform from metadata Form form = new Form(DataForm.Type.submit); Iterator<String> iter = metadata.keySet().iterator(); while (iter.hasNext()) { String name = iter.next(); String value = metadata.get(name).toString(); FormField field = new FormField(name); field.setType(FormField.Type.text_single); form.addField(field); form.setAnswer(name, value); } joinQueue(form, userID); }
@Override public void complete(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException { executeAction(Action.complete, form); }
@Override public void next(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException { executeAction(Action.next, form); }
public SubscribeForm(Form subscribeOptionsForm) { super(subscribeOptionsForm.getDataFormToSend()); }
@Override protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) { return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), new Form((DataForm)content.iterator().next())); }
public void setForm(Form form) { this.form = form; }
private Stanza prepareKeyPacket() { if (mKeyRing != null) { try { String publicKey = Base64.encodeToString(mKeyRing.publicKey.getEncoded(), Base64.NO_WRAP); Registration iq = new Registration(); iq.setType(IQ.Type.set); iq.setTo(getConnection().getServiceName()); Form form = new Form(DataForm.Type.submit); // form type: register#key FormField type = new FormField("FORM_TYPE"); type.setType(FormField.Type.hidden); type.addValue("http://kontalk.org/protocol/register#key"); form.addField(type); // new (to-be-signed) public key FormField fieldKey = new FormField("publickey"); fieldKey.setLabel("Public key"); fieldKey.setType(FormField.Type.text_single); fieldKey.addValue(publicKey); form.addField(fieldKey); // old (revoked) public key if (mRevoked != null) { String revokedKey = Base64.encodeToString(mRevoked.getEncoded(), Base64.NO_WRAP); FormField fieldRevoked = new FormField("revoked"); fieldRevoked.setLabel("Revoked public key"); fieldRevoked.setType(FormField.Type.text_single); fieldRevoked.addValue(revokedKey); form.addField(fieldRevoked); } iq.addExtension(form.getDataFormToSend()); return iq; } catch (IOException e) { Log.v(MessageCenterService.TAG, "error encoding key", e); } } return null; }
private Stanza createRegistrationForm() { Registration iq = new Registration(); iq.setType(IQ.Type.set); iq.setTo(mConnector.getConnection().getServiceName()); Form form = new Form(DataForm.Type.submit); FormField type = new FormField("FORM_TYPE"); type.setType(FormField.Type.hidden); type.addValue(Registration.NAMESPACE); form.addField(type); FormField phone = new FormField("phone"); phone.setLabel("Phone number"); phone.setType(FormField.Type.text_single); phone.addValue(mPhone); form.addField(phone); if (mForce) { FormField force = new FormField("force"); force.setLabel("Force registration"); force.setType(FormField.Type.bool); force.addValue(String.valueOf(mForce)); form.addField(force); } if (mFallback) { FormField fallback = new FormField("fallback"); fallback.setLabel("Fallback"); fallback.setType(FormField.Type.bool); fallback.addValue(String.valueOf(mFallback)); form.addField(fallback); } else { // not falling back, ask for our preferred challenge FormField challenge = new FormField("challenge"); challenge.setLabel("Challenge type"); challenge.setType(FormField.Type.text_single); challenge.addValue(DEFAULT_CHALLENGE); form.addField(challenge); } iq.addExtension(form.getDataFormToSend()); return iq; }
private Packet prepareKeyPacket() { if (mKeyRing != null) { try { String publicKey = Base64.encodeToString(mKeyRing.publicKey.getEncoded(), Base64.NO_WRAP); Registration iq = new Registration(); iq.setType(IQ.Type.SET); iq.setTo(getConnection().getServiceName()); Form form = new Form(Form.TYPE_SUBMIT); // form type: register#key FormField type = new FormField("FORM_TYPE"); type.setType(FormField.TYPE_HIDDEN); type.addValue("http://kontalk.org/protocol/register#key"); form.addField(type); // new (to-be-signed) public key FormField fieldKey = new FormField("publickey"); fieldKey.setLabel("Public key"); fieldKey.setType(FormField.TYPE_TEXT_SINGLE); fieldKey.addValue(publicKey); form.addField(fieldKey); // old (revoked) public key if (mRevoked != null) { String revokedKey = Base64.encodeToString(mRevoked.getEncoded(), Base64.NO_WRAP); FormField fieldRevoked = new FormField("revoked"); fieldRevoked.setLabel("Revoked public key"); fieldRevoked.setType(FormField.TYPE_TEXT_SINGLE); fieldRevoked.addValue(revokedKey); form.addField(fieldRevoked); } iq.addExtension(form.getDataFormToSend()); return iq; } catch (IOException e) { Log.v(MessageCenterService.TAG, "error encoding key", e); } } return null; }
private Packet createValidationForm() { Registration iq = new Registration(); iq.setType(IQ.Type.SET); iq.setTo(mConnector.getConnection().getServiceName()); Form form = new Form(Form.TYPE_SUBMIT); FormField type = new FormField("FORM_TYPE"); type.setType(FormField.TYPE_HIDDEN); type.addValue("http://kontalk.org/protocol/register#code"); form.addField(type); FormField code = new FormField("code"); code.setLabel("Validation code"); code.setType(FormField.TYPE_TEXT_SINGLE); code.addValue(mValidationCode.toString()); form.addField(code); if (mKey != null || (mImportedPrivateKey != null && mImportedPublicKey != null)) { String publicKey; try { if (mKey != null) { String userId = MessageUtils.sha1(mPhone); // TODO what in name and comment fields here? mKeyRing = mKey.storeNetwork(userId, mServer.getNetwork(), mName, mPassphrase); } else { mKeyRing = PGPKeyPairRing.load(mImportedPrivateKey, mImportedPublicKey); } publicKey = Base64.encodeToString(mKeyRing.publicKey.getEncoded(), Base64.NO_WRAP); } catch (Exception e) { // TODO Log.v(TAG, "error saving key", e); publicKey = null; } if (publicKey != null) { FormField key = new FormField("publickey"); key.setLabel("Public key"); key.setType(FormField.TYPE_TEXT_SINGLE); key.addValue(publicKey); form.addField(key); } } iq.addExtension(form.getDataFormToSend()); return iq; }
/** * Returns the Form to use for searching transcripts. It is unlikely that the server * will change the form (without a restart) so it is safe to keep the returned form * for future submissions. * * @param serviceJID the address of the workgroup service. * @return the Form to use for searching transcripts. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Form getSearchForm(String serviceJID) throws NoResponseException, XMPPErrorException, NotConnectedException { TranscriptSearch search = new TranscriptSearch(); search.setType(IQ.Type.get); search.setTo(serviceJID); TranscriptSearch response = (TranscriptSearch) connection.createPacketCollectorAndSend( search).nextResultOrThrow(); return Form.getFormFrom(response); }
/** * 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 XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public ReportedData submitSearch(String serviceJID, Form completedForm) throws NoResponseException, XMPPErrorException, NotConnectedException { TranscriptSearch search = new TranscriptSearch(); search.setType(IQ.Type.get); search.setTo(serviceJID); search.addExtension(completedForm.getDataFormToSend()); TranscriptSearch response = (TranscriptSearch) connection.createPacketCollectorAndSend( search).nextResultOrThrow(); return ReportedData.getReportedDataFrom(response); }
/** * <p>Joins the workgroup queue to wait to be routed to an agent. After joining * the queue, queue status events will be sent to indicate the user's position and * estimated time left in the queue. Once joining the queue, there are three ways * the user can leave the queue: <ul> * <p/> * <li>The user is routed to an agent, which triggers a GroupChat invitation. * <li>The user asks to leave the queue by calling the {@link #departQueue} method. * <li>A server error occurs, or an administrator explicitly removes the user * from the queue. * </ul> * <p/> * A user cannot request to join the queue again if already in the queue. Therefore, * this method will throw an IllegalStateException if the user is already in the queue.<p> * <p/> * Some servers may be configured to require certain meta-data in order to * join the queue.<p> * <p/> * The server tracks the conversations that a user has with agents over time. By * default, that tracking is done using the user's JID. However, this is not always * possible. For example, when the user is logged in anonymously using a web client. * In that case the user ID might be a randomly generated value put into a persistent * cookie or a username obtained via the session. When specified, that userID will * be used instead of the user's JID to track conversations. The server will ignore a * manually specified userID if the user's connection to the server is not anonymous. * * @param answerForm the completed form associated with the join reqest. * @param userID String that represents the ID of the user when using anonymous sessions * or <tt>null</tt> if a userID should not be used. * @throws XMPPErrorException if an error occured joining the queue. An error may indicate * that a connection failure occured or that the server explicitly rejected the * request to join the queue. * @throws NoResponseException * @throws NotConnectedException */ public void joinQueue(Form answerForm, String userID) throws NoResponseException, XMPPErrorException, NotConnectedException { // If already in the queue ignore the join request. if (inQueue) { throw new IllegalStateException("Already in queue " + workgroupJID); } JoinQueuePacket joinPacket = new JoinQueuePacket(workgroupJID, answerForm, userID); connection.createPacketCollectorAndSend(joinPacket).nextResultOrThrow(); // Notify listeners that we've joined the queue. fireQueueJoinedEvent(); }
/** * Returns the Form to use for all clients of a workgroup. It is unlikely that the server * will change the form (without a restart) so it is safe to keep the returned form * for future submissions. * * @return the Form to use for searching transcripts. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Form getWorkgroupForm() throws NoResponseException, XMPPErrorException, NotConnectedException { WorkgroupForm workgroupForm = new WorkgroupForm(); workgroupForm.setType(IQ.Type.get); workgroupForm.setTo(workgroupJID); WorkgroupForm response = (WorkgroupForm) connection.createPacketCollectorAndSend( workgroupForm).nextResultOrThrow(); return Form.getFormFrom(response); }
/** * Returns the form of the current stage. Usually it is the form that must * be answered to execute the next action. If that is the case it should be * used by the requester to fill all the information that the executor needs * to continue to the next stage. It can also be the result of the * execution. * * @return the form of the current stage to fill out or the result of the * execution. */ public Form getForm() { if (data.getForm() == null) { return null; } else { return new Form(data.getForm()); } }
/** * Returns the room's configuration form that the room's owner can use or <tt>null</tt> if * no configuration is possible. The configuration form allows to set the room's language, * enable logging, specify room's type, etc.. * * @return the Form that contains the fields to complete together with the instrucions or * <tt>null</tt> if no configuration is possible. * @throws XMPPErrorException if an error occurs asking the configuration form for the room. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ public Form getConfigurationForm() throws NoResponseException, XMPPErrorException, NotConnectedException { MUCOwner iq = new MUCOwner(); iq.setTo(room); iq.setType(IQ.Type.get); IQ answer = connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); return Form.getFormFrom(answer); }
/** * Sends the completed configuration form to the server. The room will be configured * with the new settings defined in the form. If the form is empty then the server * will create an instant room (will use default configuration). * * @param form the form with the new settings. * @throws XMPPErrorException if an error occurs setting the new rooms' configuration. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException { MUCOwner iq = new MUCOwner(); iq.setTo(room); iq.setType(IQ.Type.set); iq.addExtension(form.getDataFormToSend()); connection.createPacketCollectorAndSend(iq).nextResultOrThrow(); }
/** * Returns the room's registration form that an unaffiliated user, can use to become a member * of the room or <tt>null</tt> if no registration is possible. Some rooms may restrict the * privilege to register members and allow only room admins to add new members.<p> * * If the user requesting registration requirements is not allowed to register with the room * (e.g. because that privilege has been restricted), the room will return a "Not Allowed" * error to the user (error code 405). * * @return the registration Form that contains the fields to complete together with the * instrucions or <tt>null</tt> if no registration is possible. * @throws XMPPErrorException if an error occurs asking the registration form for the room or a * 405 error if the user is not allowed to register with the room. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ public Form getRegistrationForm() throws NoResponseException, XMPPErrorException, NotConnectedException { Registration reg = new Registration(); reg.setType(IQ.Type.get); reg.setTo(room); IQ result = connection.createPacketCollectorAndSend(reg).nextResultOrThrow(); return Form.getFormFrom(result); }
/** * Sends the completed registration form to the server. After the user successfully submits * the form, the room may queue the request for review by the room admins or may immediately * add the user to the member list by changing the user's affiliation from "none" to "member.<p> * * If the desired room nickname is already reserved for that room, the room will return a * "Conflict" error to the user (error code 409). If the room does not support registration, * it will return a "Service Unavailable" error to the user (error code 503). * * @param form the completed registration form. * @throws XMPPErrorException if an error occurs submitting the registration form. In particular, a * 409 error can occur if the desired room nickname is already reserved for that room; * or a 503 error can occur if the room does not support registration. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ public void sendRegistrationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException { Registration reg = new Registration(); reg.setType(IQ.Type.set); reg.setTo(room); reg.addExtension(form.getDataFormToSend()); connection.createPacketCollectorAndSend(reg).nextResultOrThrow(); }
/** * Update the configuration with the contents of the new {@link Form} * * @param submitForm * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public void sendConfigurationForm(Form submitForm) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub packet = createPubsubPacket(Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER, getId(), submitForm), PubSubNamespace.OWNER); con.createPacketCollectorAndSend(packet).nextResultOrThrow(); }
/** * Get a {@link ConfigureForm} from a packet. * * @param packet * @param elem * @return The configuration form */ public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) { FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); Form formReply = config.getForm(); return new ConfigureForm(formReply); }
/** * Returns the form for all search fields supported by the search service. * * @param con the current XMPPConnection. * @param searchService the search service to use. (ex. search.jivesoftware.com) * @return the search form received by the server. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Form getSearchForm(XMPPConnection con, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException { UserSearch search = new UserSearch(); search.setType(IQ.Type.get); search.setTo(searchService); IQ response = (IQ) con.createPacketCollectorAndSend(search).nextResultOrThrow(); return Form.getFormFrom(response); }
/** * Sends the filled out answer form to be sent and queried by the search service. * * @param con the current XMPPConnection. * @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 XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public ReportedData sendSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException { UserSearch search = new UserSearch(); search.setType(IQ.Type.set); search.setTo(searchService); search.addExtension(searchForm.getDataFormToSend()); IQ response = (IQ) con.createPacketCollectorAndSend(search).nextResultOrThrow(); return ReportedData.getReportedDataFrom(response); }
/** * Sends the filled out answer form to be sent and queried by the search service. * * @param con the current XMPPConnection. * @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 XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public ReportedData sendSimpleSearchForm(XMPPConnection con, Form searchForm, String searchService) throws NoResponseException, XMPPErrorException, NotConnectedException { SimpleUserSearch search = new SimpleUserSearch(); search.setForm(searchForm); search.setType(IQ.Type.set); search.setTo(searchService); SimpleUserSearch response = (SimpleUserSearch) con.createPacketCollectorAndSend(search).nextResultOrThrow(); return response.getReportedData(); }
/** * Returns the Form to use for searching transcripts. It is unlikely that the server * will change the form (without a restart) so it is safe to keep the returned form * for future submissions. * * @return the Form to use for searching transcripts. * @throws XMPPException if an error occurs while sending the request to the server. * @throws SmackException */ public Form getTranscriptSearchForm() throws XMPPException, SmackException { return transcriptSearchManager.getSearchForm(XmppStringUtils.parseDomain(workgroupJID)); }
/** * 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 SmackException * @throws XMPPException */ public ReportedData searchTranscripts(Form completedForm) throws XMPPException, SmackException { return transcriptSearchManager.submitSearch(XmppStringUtils.parseDomain(workgroupJID), completedForm); }
/** * Joins the workgroup queue to wait to be routed to an agent. After joining * the queue, queue status events will be sent to indicate the user's position and * estimated time left in the queue. Once joining the queue, there are three ways * the user can leave the queue: <ul> * <p/> * <li>The user is routed to an agent, which triggers a GroupChat invitation. * <li>The user asks to leave the queue by calling the {@link #departQueue} method. * <li>A server error occurs, or an administrator explicitly removes the user * from the queue. * </ul> * <p/> * A user cannot request to join the queue again if already in the queue. Therefore, * this method will throw an IllegalStateException if the user is already in the queue.<p> * <p/> * Some servers may be configured to require certain meta-data in order to * join the queue.<p> * <p/> * The server tracks the conversations that a user has with agents over time. By * default, that tracking is done using the user's JID. However, this is not always * possible. For example, when the user is logged in anonymously using a web client. * In that case the user ID might be a randomly generated value put into a persistent * cookie or a username obtained via the session. A userID can be explicitly * passed in by using the {@link #joinQueue(Form, String)} method. When specified, * that userID will be used instead of the user's JID to track conversations. The * server will ignore a manually specified userID if the user's connection to the server * is not anonymous. * * @param answerForm the completed form the send for the join request. * @throws XMPPException if an error occured joining the queue. An error may indicate * that a connection failure occured or that the server explicitly rejected the * request to join the queue. * @throws SmackException */ public void joinQueue(Form answerForm) throws XMPPException, SmackException { joinQueue(answerForm, null); }
/** * Executes the default action of the command with the information provided * in the Form. This form must be the answer form of the previous stage. If * there is a problem executing the command it throws an XMPPException. * * @param form the form answer of the previous stage. * @throws XMPPErrorException if an error occurs. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException */ public void execute(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException { executeAction(Action.execute, form); }
/** * Sets the form of the current stage. This should be used when setting a * response. It could be a form to fill out the information needed to go to * the next stage or the result of an execution. * * @param form the form of the current stage to fill out or the result of the * execution. */ protected void setForm(Form form) { data.setForm(form.getDataFormToSend()); }
/** * Executes the next action of the command with the information provided in * the <code>response</code>. This form must be the answer form of the * previous stage. This method will be only invoked for commands that have one * or more stages. If there is a problem executing the command it throws an * XMPPException. * * @param response the form answer of the previous stage. * @throws XMPPErrorException if there is a problem executing the command. * @throws NotConnectedException */ public abstract void next(Form response) throws NoResponseException, XMPPErrorException, NotConnectedException;