From: Santi B. <san...@us...> - 2008-01-15 00:09:41
|
Update of /cvsroot/babeldoc/babeldoc/modules/jabber/src/com/babeldoc/jabber/pipeline/stage In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19468/modules/jabber/src/com/babeldoc/jabber/pipeline/stage Modified Files: XmppWriterPipelineStage.java Log Message: Processing messages for multiple receivers when 'waitdelivery' activated. Index: XmppWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/jabber/src/com/babeldoc/jabber/pipeline/stage/XmppWriterPipelineStage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XmppWriterPipelineStage.java 14 Jan 2008 15:37:11 -0000 1.2 --- XmppWriterPipelineStage.java 15 Jan 2008 00:09:44 -0000 1.3 *************** *** 123,127 **** public String getDescription() { ! return "Pipeline stage that use XMPP (Jabber) protocol for sending messages"; } --- 123,127 ---- public String getDescription() { ! return "Pipeline stage that use XMPP (Jabber) protocol for sending messages"; } *************** *** 129,155 **** ArrayList options = new ArrayList(); ! options ! .add(new ConfigOption( ! HOST, ! IConfigOptionType.STRING, ! "jabber.org", false, "Jabber server name")); //$NON-NLS-1$ options.add(new ConfigOption(PORT, IConfigOptionType.INTEGER, "5222", false, //$NON-NLS-1$ ! "Port using for connecting. Defaults to 5222")); options.add(new ConfigOption(USERNAME, ! IConfigOptionType.STRING, null, true, "Jabber account name")); options.add(new ConfigOption(PASSWORD, ! IConfigOptionType.STRING, null, true, "Jabber account password")); ! options.add(new ConfigOption(RECIPIENTS, ! IConfigOptionType.STRING, null, false, "Comma separated list of recipients that should receive IM")); options.add(new ConfigOption(CHATROOM, ! IConfigOptionType.STRING, null, false, "Name of chatroom that should receive IM")); options.add(new ConfigOption(NICKNAME, ! IConfigOptionType.STRING, null, false, "Nickname used for chatrooms")); ! options ! .add(new ConfigOption( ! SSL, ! IConfigOptionType.BOOLEAN, ! "false", false, "Use ssl connections")); //$NON-NLS-1$ options .add(new ConfigOption( --- 129,155 ---- ArrayList options = new ArrayList(); ! options.add(new ConfigOption(HOST, IConfigOptionType.STRING, ! "jabber.org", false, "Jabber server name")); //$NON-NLS-1$ options.add(new ConfigOption(PORT, IConfigOptionType.INTEGER, "5222", false, //$NON-NLS-1$ ! "Port using for connecting. Defaults to 5222")); options.add(new ConfigOption(USERNAME, ! IConfigOptionType.STRING, null, true, ! "Jabber account name")); options.add(new ConfigOption(PASSWORD, ! IConfigOptionType.STRING, null, true, ! "Jabber account password")); ! options ! .add(new ConfigOption(RECIPIENTS, ! IConfigOptionType.STRING, null, false, ! "Comma separated list of recipients that should receive IM")); options.add(new ConfigOption(CHATROOM, ! IConfigOptionType.STRING, null, false, ! "Name of chatroom that should receive IM")); options.add(new ConfigOption(NICKNAME, ! IConfigOptionType.STRING, null, false, ! "Nickname used for chatrooms")); ! options.add(new ConfigOption(SSL, IConfigOptionType.BOOLEAN, ! "false", false, "Use ssl connections")); //$NON-NLS-1$ options .add(new ConfigOption( *************** *** 158,164 **** "false", false, "Wait until delivery event notification")); //$NON-NLS-1$ options.add(new ConfigOption(MESSAGE, IConfigOptionType.STRING, ! null, false, "Notification message to send")); options.add(new ConfigOption(ANSWER, IConfigOptionType.STRING, ! null, false, "Expected answer for send document")); return options; --- 158,164 ---- "false", false, "Wait until delivery event notification")); //$NON-NLS-1$ options.add(new ConfigOption(MESSAGE, IConfigOptionType.STRING, ! null, false, "Notification message to send")); options.add(new ConfigOption(ANSWER, IConfigOptionType.STRING, ! null, false, "Expected answer for send document")); return options; *************** *** 177,182 **** final String username = this.getInfo().getStrValue(USERNAME); final String password = this.getInfo().getStrValue(PASSWORD); ! final String[] recipients = StringUtils.split(this.getInfo().getStrValue( ! RECIPIENTS), ","); //$NON-NLS-1$ final String chatroom = this.getInfo().getStrValue(CHATROOM); final String nickname = this.getInfo().getStrValue(NICKNAME); --- 177,182 ---- final String username = this.getInfo().getStrValue(USERNAME); final String password = this.getInfo().getStrValue(PASSWORD); ! final String[] recipients = StringUtils.split(this.getInfo() ! .getStrValue(RECIPIENTS), ","); //$NON-NLS-1$ final String chatroom = this.getInfo().getStrValue(CHATROOM); final String nickname = this.getInfo().getStrValue(NICKNAME); *************** *** 191,200 **** XMPPConnection conn = null; MultiUserChat groupChat = null; ! Message message = null; try { if (useSSL) { // conn = new SSLXMPPConnection(host); ! throw new PipelineException("SSL Protocol not supported"); } else { connConfig = new ConnectionConfiguration(host, port); --- 191,201 ---- XMPPConnection conn = null; MultiUserChat groupChat = null; ! Message[] message = null; ! Message messageGroup = null; try { if (useSSL) { // conn = new SSLXMPPConnection(host); ! throw new PipelineException("SSL Protocol not supported"); } else { connConfig = new ConnectionConfiguration(host, port); *************** *** 213,224 **** Chat chat = conn.getChatManager().createChat(recipients[i], new XmppPipelineMessageListener()); ! message = new Message(); ! message.setBody(notificationMessage); ! message.setType(Message.Type.chat); ! MessageEventManager.addNotificationsRequests(message, true, true, true, true); ! deliveryStatus.setDeliveryStatus(message.getPacketID(), MessageDeliveryStatus.SENDING); ! chat.sendMessage(message); } --- 214,225 ---- Chat chat = conn.getChatManager().createChat(recipients[i], new XmppPipelineMessageListener()); ! message[i] = new Message(); ! message[i].setBody(notificationMessage); ! message[i].setType(Message.Type.chat); ! MessageEventManager.addNotificationsRequests(message[i], true, true, true, true); ! deliveryStatus.setDeliveryStatus(message[i].getPacketID(), MessageDeliveryStatus.SENDING); ! chat.sendMessage(message[i]); } *************** *** 230,263 **** waitDelivery = false; groupChat.join(nickname, password); ! message = groupChat.createMessage(); ! message.setSubject(notificationMessage); ! message.setBody(notificationMessage); ! message.setType(Message.Type.groupchat); ! // MessageEventManager.addNotificationsRequests(message, true, true, true, true); ! groupChat.sendMessage(message); } if (waitDelivery) { try { ! while (deliveryStatus.getDeliveryStatus(message ! .getPacketID()) == MessageDeliveryStatus.SENDING) { ! Thread.sleep(15); ! } ! if(deliveryStatus.getDeliveryStatus(message.getPacketID()) == MessageDeliveryStatus.ERROR || ! deliveryStatus.getDeliveryStatus(message.getPacketID()) == MessageDeliveryStatus.NOT_INITIATED){ ! throw new PipelineException("Can't determine de delivery status."); } - if(deliveryStatus.getDeliveryStatus(message.getPacketID()) == MessageDeliveryStatus.OFFLINE) - throw new PipelineException("Can't send the message, the user is offline."); - } catch (InterruptedException e) { throw new PipelineException( "Pipeline aborted while waiting for delivery."); ! } } conn.disconnect(); } catch (XMPPException xme) { ! throw new PipelineException("Error sending message", xme); // xme.printStackTrace(); } --- 231,272 ---- waitDelivery = false; groupChat.join(nickname, password); ! messageGroup = groupChat.createMessage(); ! messageGroup.setSubject(notificationMessage); ! messageGroup.setBody(notificationMessage); ! messageGroup.setType(Message.Type.groupchat); ! // MessageEventManager.addNotificationsRequests(message, true, ! // true, true, true); ! groupChat.sendMessage(messageGroup); } if (waitDelivery) { try { ! // Processing every message in the array while not completed ! for (int i = 0; i < message.length; i++) { ! while (deliveryStatus.getDeliveryStatus(message[i] ! .getPacketID()) == MessageDeliveryStatus.SENDING) { ! Thread.sleep(15); ! } ! if (deliveryStatus.getDeliveryStatus(message[i] ! .getPacketID()) == MessageDeliveryStatus.ERROR ! || deliveryStatus.getDeliveryStatus(message[i] ! .getPacketID()) == MessageDeliveryStatus.NOT_INITIATED) { ! throw new PipelineException( ! "Can't determine de delivery status."); ! } ! if (deliveryStatus.getDeliveryStatus(message[i] ! .getPacketID()) == MessageDeliveryStatus.OFFLINE) ! throw new PipelineException( ! "Can't send the message, the user is offline."); } } catch (InterruptedException e) { throw new PipelineException( "Pipeline aborted while waiting for delivery."); ! } } conn.disconnect(); } catch (XMPPException xme) { ! throw new PipelineException("Error sending message", xme); // xme.printStackTrace(); } |