--- a/src/com/beem/project/beem/utils/PresenceType.java Fri Jun 26 17:56:44 2009 +0200
+++ b/src/com/beem/project/beem/utils/PresenceType.java Fri Jun 26 18:32:58 2009 +0200
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package com.beem.project.beem.utils;
@@ -13,28 +13,28 @@
/**
* The user is available to receive messages (default).
*/
- public static final int AVAILABLE = 100;
+ public static final int AVAILABLE = 100;
/**
* The user is unavailable to receive messages.
*/
- public static final int UNAVAILABLE = 200;
+ public static final int UNAVAILABLE = 200;
/**
* Request subscription to recipient's presence.
*/
- public static final int SUBSCRIBE = 300;
+ public static final int SUBSCRIBE = 300;
/**
* Grant subscription to sender's presence.
*/
- public static final int SUBSCRIBED = 400;
+ public static final int SUBSCRIBED = 400;
/**
* Request removal of subscription to sender's presence.
*/
- public static final int UNSUBSCRIBE = 500;
+ public static final int UNSUBSCRIBE = 500;
/**
* Grant removal of subscription to sender's presence.
@@ -44,77 +44,79 @@
/**
* The presence packet contains an error message.
*/
- public static final int ERROR = 701;
+ public static final int ERROR = 701;
/**
* Get the presence type from a presence packet.
- *
- * @param presence
- * the presence type
+ * @param presence the presence type
+ * @return an int representing the presence type
*/
public static int getPresenceType(Presence presence) {
int res = PresenceType.ERROR;
switch (presence.getType()) {
- case available:
- res = PresenceType.AVAILABLE;
- break;
- case unavailable:
- res = PresenceType.UNAVAILABLE;
- break;
- case subscribe:
- res = PresenceType.SUBSCRIBE;
- break;
- case subscribed:
- res = PresenceType.SUBSCRIBED;
- break;
- case unsubscribe:
- res = PresenceType.UNSUBSCRIBE;
- break;
- case unsubscribed:
- res = PresenceType.UNSUBSCRIBED;
- break;
- case error:
- default:
- res = PresenceType.ERROR;
+ case available:
+ res = PresenceType.AVAILABLE;
+ break;
+ case unavailable:
+ res = PresenceType.UNAVAILABLE;
+ break;
+ case subscribe:
+ res = PresenceType.SUBSCRIBE;
+ break;
+ case subscribed:
+ res = PresenceType.SUBSCRIBED;
+ break;
+ case unsubscribe:
+ res = PresenceType.UNSUBSCRIBE;
+ break;
+ case unsubscribed:
+ res = PresenceType.UNSUBSCRIBED;
+ break;
+ case error:
+ default:
+ res = PresenceType.ERROR;
}
- ;
return res;
}
/**
- * Get the smack presence mode for a status
- *
- * @param status
- * the status in beem
+ * Get the smack presence mode for a status.
+ * @param type the status type in beem
* @return the presence mode to use in presence packet or null if there is no mode to use
*/
public static Presence.Type getPresenceTypeFrom(int type) {
Presence.Type res;
switch (type) {
- case AVAILABLE:
- res = Presence.Type.available;
- break;
- case UNAVAILABLE:
- res = Presence.Type.unavailable;
- break;
- case SUBSCRIBE:
- res = Presence.Type.subscribe;
- break;
- case SUBSCRIBED:
- res = Presence.Type.subscribed;
- break;
- case UNSUBSCRIBE:
- res = Presence.Type.unsubscribe;
- break;
- case UNSUBSCRIBED:
- res = Presence.Type.unsubscribed;
- break;
- case ERROR:
- res = Presence.Type.error;
- break;
- default:
- return null;
+ case AVAILABLE:
+ res = Presence.Type.available;
+ break;
+ case UNAVAILABLE:
+ res = Presence.Type.unavailable;
+ break;
+ case SUBSCRIBE:
+ res = Presence.Type.subscribe;
+ break;
+ case SUBSCRIBED:
+ res = Presence.Type.subscribed;
+ break;
+ case UNSUBSCRIBE:
+ res = Presence.Type.unsubscribe;
+ break;
+ case UNSUBSCRIBED:
+ res = Presence.Type.unsubscribed;
+ break;
+ case ERROR:
+ res = Presence.Type.error;
+ break;
+ default:
+ return null;
}
return res;
}
+
+ /**
+ * Private default constructor
+ */
+ private PresenceType() {
+ }
}
--- a/src/com/beem/project/beem/utils/Status.java Fri Jun 26 17:56:44 2009 +0200
+++ b/src/com/beem/project/beem/utils/Status.java Fri Jun 26 18:32:58 2009 +0200
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package com.beem.project.beem.utils;
@@ -7,34 +7,34 @@
import org.jivesoftware.smack.packet.Presence.Mode;
/**
- * @author caribou
+ * @author marseille
*/
public class Status {
/**
* Status of a disconnected contact.
*/
- public static final int CONTACT_STATUS_DISCONNECT = 100;
+ public static final int CONTACT_STATUS_DISCONNECT = 100;
/**
* Status of a unavailable (long away) contact.
*/
- public static final int CONTACT_STATUS_UNAVAILABLE = 200;
+ public static final int CONTACT_STATUS_UNAVAILABLE = 200;
/**
* Status of a away contact.
*/
- public static final int CONTACT_STATUS_AWAY = 300;
+ public static final int CONTACT_STATUS_AWAY = 300;
/**
* Status of a busy contact.
*/
- public static final int CONTACT_STATUS_BUSY = 400;
+ public static final int CONTACT_STATUS_BUSY = 400;
/**
* Status of a available contact.
*/
- public static final int CONTACT_STATUS_AVAILABLE = 500;
+ public static final int CONTACT_STATUS_AVAILABLE = 500;
/**
* Status of a available for chat contact.
@@ -42,41 +42,38 @@
public static final int CONTACT_STATUS_AVAILABLE_FOR_CHAT = 600;
/**
- * Get the smack presence mode for a status
- *
- * @param status
- * the status in beem
+ * Get the smack presence mode for a status.
+ * @param status the status in beem
* @return the presence mode to use in presence packet or null if there is no mode to use
*/
public static Presence.Mode getPresenceModeFromStatus(int status) {
Presence.Mode res;
switch (status) {
- case CONTACT_STATUS_AVAILABLE:
- res = Presence.Mode.available;
- break;
- case CONTACT_STATUS_AVAILABLE_FOR_CHAT:
- res = Presence.Mode.chat;
- break;
- case CONTACT_STATUS_AWAY:
- res = Presence.Mode.away;
- break;
- case CONTACT_STATUS_BUSY:
- res = Presence.Mode.dnd;
- break;
- case CONTACT_STATUS_UNAVAILABLE:
- res = Presence.Mode.xa;
- break;
- default:
- return null;
+ case CONTACT_STATUS_AVAILABLE:
+ res = Presence.Mode.available;
+ break;
+ case CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+ res = Presence.Mode.chat;
+ break;
+ case CONTACT_STATUS_AWAY:
+ res = Presence.Mode.away;
+ break;
+ case CONTACT_STATUS_BUSY:
+ res = Presence.Mode.dnd;
+ break;
+ case CONTACT_STATUS_UNAVAILABLE:
+ res = Presence.Mode.xa;
+ break;
+ default:
+ return null;
}
return res;
}
/**
* Get the status of from a presence packet.
- *
- * @param presence
- * the presence containing status
+ * @param presence the presence containing status
+ * @return an int representing the status
*/
public static int getStatusFromPresence(Presence presence) {
int res = Status.CONTACT_STATUS_DISCONNECT;
@@ -88,28 +85,34 @@
res = Status.CONTACT_STATUS_AVAILABLE;
} else {
switch (mode) {
- case available:
- res = Status.CONTACT_STATUS_AVAILABLE;
- break;
- case away:
- res = Status.CONTACT_STATUS_AWAY;
- break;
- case chat:
- res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
- break;
- case dnd:
- res = Status.CONTACT_STATUS_BUSY;
- break;
- case xa:
- res = Status.CONTACT_STATUS_UNAVAILABLE;
- break;
- default:
- res = Status.CONTACT_STATUS_DISCONNECT;
- break;
+ case available:
+ res = Status.CONTACT_STATUS_AVAILABLE;
+ break;
+ case away:
+ res = Status.CONTACT_STATUS_AWAY;
+ break;
+ case chat:
+ res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
+ break;
+ case dnd:
+ res = Status.CONTACT_STATUS_BUSY;
+ break;
+ case xa:
+ res = Status.CONTACT_STATUS_UNAVAILABLE;
+ break;
+ default:
+ res = Status.CONTACT_STATUS_DISCONNECT;
+ break;
}
}
}
return res;
}
+ /**
+ * Default constructor masked
+ */
+ private Status() {
+ }
+
}