aboutsummaryrefslogtreecommitdiff
path: root/src/com/juick/server/PMQueries.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/juick/server/PMQueries.java')
-rw-r--r--src/com/juick/server/PMQueries.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/com/juick/server/PMQueries.java b/src/com/juick/server/PMQueries.java
index 42f3aefd..91ebbee2 100644
--- a/src/com/juick/server/PMQueries.java
+++ b/src/com/juick/server/PMQueries.java
@@ -61,6 +61,80 @@ public class PMQueries {
return ret;
}
+ public static boolean addPMinRoster(Connection sql, int uid, String jid) {
+ boolean ret = false;
+ PreparedStatement stmt = null;
+ try {
+ stmt = sql.prepareStatement("INSERT INTO pm_inroster(user_id,jid) VALUES (?,?)");
+ stmt.setInt(1, uid);
+ stmt.setString(2, jid);
+ ret = stmt.executeUpdate() > 0;
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(null, stmt);
+ }
+ return ret;
+ }
+
+ public static boolean removePMinRoster(Connection sql, int uid, String jid) {
+ boolean ret = false;
+ PreparedStatement stmt = null;
+ try {
+ stmt = sql.prepareStatement("DELETE FROM pm_inroster WHERE user_id=? AND jid=?");
+ stmt.setInt(1, uid);
+ stmt.setString(2, jid);
+ ret = stmt.executeUpdate() > 0;
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(null, stmt);
+ }
+ return ret;
+ }
+
+ public static boolean havePMinRoster(Connection sql, int uid, String jid) {
+ boolean ret = false;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT 1 FROM pm_inroster WHERE user_id=? AND jid=?");
+ stmt.setInt(1, uid);
+ stmt.setString(2, jid);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ ret = true;
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return ret;
+ }
+
+ public static String getLastView(Connection sql, int uid_from, int uid_to) {
+ String ret = null;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT lastview FROM pm_streams WHERE user_id=? AND user_id_to=?");
+ stmt.setInt(1, uid_from);
+ stmt.setInt(2, uid_to);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ ret = rs.getString(1);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return ret;
+ }
+
public static ArrayList<com.juick.User> getPMLastConversationsUsers(Connection sql, int uid, int cnt) {
ArrayList<com.juick.User> users = new ArrayList<com.juick.User>();