1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-06-20 10:24:49 +02:00

SMACK-331 Changed methods to existing Smack conventions and moved interface to top level.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_0@13601 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
rcollier 2013-04-02 00:23:55 +00:00
parent 9da54ecbce
commit b28037bc79
4 changed files with 39 additions and 26 deletions

View file

@ -1,4 +1,4 @@
/*
/**
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -42,16 +42,19 @@ public class DeliveryReceipt implements PacketExtension
return id;
}
@Override
public String getElementName()
{
return ELEMENT;
}
@Override
public String getNamespace()
{
return NAMESPACE;
}
@Override
public String toXML()
{
return "<received xmlns='" + NAMESPACE + "' id='" + id + "'/>";

View file

@ -24,20 +24,16 @@ import java.util.WeakHashMap;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import org.jivesoftware.smackx.packet.DiscoverInfo;
/**
* Packet extension for XEP-0184: Message Delivery Receipts. This class implements
* Manager for XEP-0184: Message Delivery Receipts. This class implements
* the manager for {@link DeliveryReceipt} support, enabling and disabling of
* automatic DeliveryReceipt transmission.
*
@ -167,7 +163,7 @@ public class DeliveryReceiptManager implements PacketListener {
*
* @param listener the listener to be informed about new receipts
*/
public void registerReceiptReceivedListener(ReceiptReceivedListener listener) {
public void addReceiptReceivedListener(ReceiptReceivedListener listener) {
receiptReceivedListeners.add(listener);
}
@ -176,20 +172,10 @@ public class DeliveryReceiptManager implements PacketListener {
*
* @param listener the listener to be removed
*/
public void unregisterReceiptReceivedListener(ReceiptReceivedListener listener) {
public void removeReceiptReceivedListener(ReceiptReceivedListener listener) {
receiptReceivedListeners.remove(listener);
}
/**
* Interface for received receipt notifications.
*
* Implement this and add a listener to get notified.
*/
public static interface ReceiptReceivedListener {
void onReceiptReceived(String fromJid, String toJid, String receiptId);
}
/**
* Test if a packet requires a delivery receipt.
*

View file

@ -0,0 +1,26 @@
/**
* Copyright 2013 Georg Lukas
*
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.receipts;
/**
* Interface for received receipt notifications.
*
* Implement this and add a listener to get notified.
*/
public interface ReceiptReceivedListener {
void onReceiptReceived(String fromJid, String toJid, String receiptId);
}

View file

@ -13,16 +13,14 @@
*/
package org.jivesoftware.smackx.receipts;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.StringReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Properties;
import java.util.TimeZone;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.Message;
@ -76,7 +74,7 @@ public class DeliveryReceiptTest {
DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);
TestReceiptReceivedListener rrl = new TestReceiptReceivedListener();
drm.registerReceiptReceivedListener(rrl);
drm.addReceiptReceivedListener(rrl);
Message m = new Message("romeo@montague.com", Message.Type.normal);
m.setFrom("julia@capulet.com");
@ -88,7 +86,7 @@ public class DeliveryReceiptTest {
assertEquals("original-test-id", rrl.receiptId);
}
private static class TestReceiptReceivedListener implements DeliveryReceiptManager.ReceiptReceivedListener {
private static class TestReceiptReceivedListener implements ReceiptReceivedListener {
public String receiptId = null;
@Override
public void onReceiptReceived(String fromJid, String toJid, String receiptId) {