summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-07-29 15:54:09 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2016-01-14 15:38:31 (GMT)
commit72249383639858b1a7947b1afc6b9491ebd82bf8 (patch)
tree03af3e75006a133ee365116384bcc659543e183e /src/com/isode/stroke/base
parent701abcb162dfb3e7cc8c6a9ada81a16d1fc8d4ee (diff)
downloadstroke-72249383639858b1a7947b1afc6b9491ebd82bf8.zip
stroke-72249383639858b1a7947b1afc6b9491ebd82bf8.tar.bz2
Completes Jingle.
Adds Listenable, JingleSession, JingleContentID, FakeJingleSession, JingleSessionListener, JingleSessionManager, JingleResponder. NotifyListeners are not in line with Swiften and have to be corrected. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: None. Change-Id: I6533b2be02a0843277a63ca115348ff6138a0fc0
Diffstat (limited to 'src/com/isode/stroke/base')
-rwxr-xr-xsrc/com/isode/stroke/base/Listenable.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/com/isode/stroke/base/Listenable.java b/src/com/isode/stroke/base/Listenable.java
new file mode 100755
index 0000000..c0aa091
--- /dev/null
+++ b/src/com/isode/stroke/base/Listenable.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.base;
+
+import java.util.Vector;
+import com.isode.stroke.signals.Slot;
+import com.isode.stroke.signals.Slot1;
+import com.isode.stroke.signals.Slot2;
+import com.isode.stroke.signals.Slot3;
+
+public class Listenable<T> {
+
+ private Vector<T> listeners = new Vector<T>();
+
+ public void addListener(T listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(T listener) {
+ while(listeners.contains(listener)) {
+ listeners.remove(listener);
+ }
+ }
+
+ //Swiften code calls event(i), which is not yet done.
+ public void notifyListeners(Slot event) {
+ for (T i : listeners) {
+ event.call();
+ }
+ }
+
+ //Swiften code calls event(i), which is not yet done.
+ public <T1> void notifyListeners(Slot1<T1> event, T1 p1) {
+ for (T i : listeners) {
+ event.call(p1);
+ }
+ }
+
+ public <T1, T2> void notifyListeners(Slot2<T1, T2> event, T1 p1, T2 p2) {
+ for (T i : listeners) {
+ event.call(p1, p2);
+ }
+ }
+
+ public <T1, T2, T3> void notifyListeners(Slot3<T1, T2, T3> event, T1 p1, T2 p2, T3 p3) {
+ for (T i : listeners) {
+ event.call(p1, p2, p3);
+ }
+ }
+} \ No newline at end of file