4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Affero General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. Look for COPYING file in the top folder.
16 | * If not, see http://www.gnu.org/licenses/.
17 | *
18 | * $Rev$
19 | * Last modified by $Author$
20 | * $Date$
21 | */
22 | package tigase.db;
23 |
24 | /**
25 | * The UserNotFoundException exception is thrown when application
26 | * tries to access data for user which does not exist in repository.
27 | *
28 | * Created: Wed Oct 27 14:17:44 2004
29 | *
30 | * @author Artur Hefczyc
31 | * @version $Rev$
32 | */
33 | public class UserNotFoundException extends TigaseDBException {
34 |
35 | private static final long serialVersionUID = 1L;
36 |
37 | /**
38 | * Creates a new UserNotFoundException instance.
39 | *
40 | */
41 | public UserNotFoundException(String message) { super(message); }
42 |
43 | /**
44 | * Creates a new UserNotFoundException instance.
45 | *
46 | */
47 | public UserNotFoundException(String message, Throwable cause) {
48 | super(message, cause);
49 | }
50 |
51 | } // UserNotFoundException
--------------------------------------------------------------------------------
/src/main/java/tigase/db/DataOverwriteException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tigase Jabber/XMPP Server
3 | * Copyright (C) 2004-2012 "Artur Hefczyc"
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Affero General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. Look for COPYING file in the top folder.
16 | * If not, see http://www.gnu.org/licenses/.
17 | *
18 | * $Rev$
19 | * Last modified by $Author$
20 | * $Date$
21 | */
22 | package tigase.db;
23 |
24 | /**
25 | * The DataOverwriteException exception is thrown when application
26 | * tries to ovrewrite data in repository but does not have permission to do so.
27 | *
28 | * Created: Wed Oct 27 14:17:44 2004
29 | *
30 | * @author Artur Hefczyc
31 | * @version $Rev$
32 | */
33 | public class DataOverwriteException extends TigaseDBException {
34 |
35 | private static final long serialVersionUID = 1L;
36 |
37 | /**
38 | * Creates a new DataOverwriteException instance.
39 | *
40 | */
41 | public DataOverwriteException(String message) { super(message); }
42 |
43 | /**
44 | * Creates a new DataOverwriteException instance.
45 | *
46 | */
47 | public DataOverwriteException(String message, Throwable cause) {
48 | super(message, cause);
49 | }
50 |
51 | } // DataOverwriteException
--------------------------------------------------------------------------------
/src/main/java/tigase/util/IntHistoryCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tigase Jabber/XMPP Server
3 | * Copyright (C) 2004-2012 "Artur Hefczyc"
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Affero General Public License as published by
7 | * the Free Software Foundation, version 3 of the License.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. Look for COPYING file in the top folder.
16 | * If not, see http://www.gnu.org/licenses/.
17 | *
18 | * $Rev$
19 | * Last modified by $Author$
20 | * $Date$
21 | */
22 |
23 | package tigase.util;
24 |
25 | /**
26 | * Created: Sep 8, 2009 7:39:27 PM
27 | *
28 | * @author Artur Hefczyc
29 | * @version $Rev$
30 | */
31 | public class IntHistoryCache {
32 |
33 | private int[] buffer = null;
34 | private int start = 0;
35 | private int count = 0;
36 |
37 | public IntHistoryCache(int limit) {
38 | buffer = new int[limit];
39 | }
40 |
41 | public synchronized void addItem(int item) {
42 | int ix = (start + count) % buffer.length;
43 | buffer[ix] = item;
44 | if (count < buffer.length) {
45 | count++;
46 | } else {
47 | start++;
48 | start %= buffer.length;
49 | }
50 | }
51 |
52 | public synchronized int[] getCurrentHistory() {
53 | int[] result = new int[count];
54 | for (int i = 0; i < count; i++) {
55 | int ix = (start + i) % buffer.length;
56 | result[i] = buffer[ix];
57 | }
58 | return result;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/tigase/xmpp/XMPPStopListenerIfc.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tigase Jabber/XMPP Server
3 | * Copyright (C) 2004-2012 "Artur Hefczyc"
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Affero General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. Look for COPYING file in the top folder.
16 | * If not, see http://www.gnu.org/licenses/.
17 | *
18 | * $Rev$
19 | * Last modified by $Author$
20 | * $Date$
21 | */
22 |
23 | package tigase.xmpp;
24 |
25 | //~--- non-JDK imports --------------------------------------------------------
26 |
27 | import tigase.server.Packet;
28 |
29 | //~--- JDK imports ------------------------------------------------------------
30 |
31 | import java.util.Map;
32 | import java.util.Queue;
33 |
34 | //~--- interfaces -------------------------------------------------------------
35 |
36 | /**
37 | * Describe interface XMPPStopListener here.
38 | *
39 | *
40 | * Created: Sat Oct 14 16:14:18 2006
41 | *
42 | * @author Artur Hefczyc
43 | * @version $Rev$
44 | */
45 | public interface XMPPStopListenerIfc extends XMPPImplIfc {
46 | void stopped(XMPPResourceConnection session, Queue results, Map settings);
47 | } // XMPPStopListener
48 |
49 |
50 | //~ Formatted in Sun Code Convention
51 |
52 |
53 | //~ Formatted by Jindent --- http://www.jindent.com
54 |
--------------------------------------------------------------------------------
/database/mysql-schema-upgrade-to-5-1.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Tigase Jabber/XMPP Server
3 | -- Copyright (C) 2004-2012 "Artur Hefczyc"
4 | --
5 | -- This program is free software: you can redistribute it and/or modify
6 | -- it under the terms of the GNU Affero General Public License as published by
7 | -- the Free Software Foundation, either version 3 of the License.
8 | --
9 | -- This program is distributed in the hope that it will be useful,
10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | -- GNU Affero General Public License for more details.
13 | --
14 | -- You should have received a copy of the GNU Affero General Public License
15 | -- along with this program. Look for COPYING file in the top folder.
16 | -- If not, see http://www.gnu.org/licenses/.
17 | --
18 | -- $Rev: $
19 | -- Last modified by $Author: $
20 | -- $Date: $
21 | --
22 |
23 | select NOW(), ' - Installing missing stored procedures';
24 |
25 | -- QUERY START:
26 | drop procedure if exists TigUpdatePairs;
27 | -- QUERY END:
28 |
29 | delimiter //
30 |
31 | -- QUERY START:
32 | -- Procedure to efficiently and safely update data in tig_pairs table
33 | create procedure TigUpdatePairs(_nid bigint, _uid bigint, _tkey varchar(255) CHARSET utf8, _tval mediumtext CHARSET utf8)
34 | begin
35 | if exists(SELECT 1 FROM tig_pairs WHERE nid = _nid AND uid = _uid AND pkey = _tkey)
36 | then
37 | UPDATE tig_pairs SET pval = _tval WHERE nid = _nid AND uid = _uid AND pkey = _tkey;
38 | ELSE
39 | INSERT INTO tig_pairs (nid, uid, pkey, pval) VALUES (_nid, _uid, _tkey, _tval);
40 | END IF;
41 | end //
42 | -- QUERY END:
43 |
44 | delimiter ;
45 |
46 |
47 | -- QUERY START:
48 | call TigPutDBProperty('schema-version', '5.1');
49 | -- QUERY END:
50 |
51 | select NOW(), ' - All done, database ver 5.1 ready to use!';
--------------------------------------------------------------------------------
/src/main/java/tigase/util/FloatHistoryCache.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Tigase Jabber/XMPP Server
3 | * Copyright (C) 2004-2012 "Artur Hefczyc"
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU Affero General Public License as published by
7 | * the Free Software Foundation, version 3 of the License.
8 | *
9 | * This program is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU Affero General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Affero General Public License
15 | * along with this program. Look for COPYING file in the top folder.
16 | * If not, see http://www.gnu.org/licenses/.
17 | *
18 | * $Rev$
19 | * Last modified by $Author$
20 | * $Date$
21 | */
22 |
23 | package tigase.util;
24 |
25 | /**
26 | * Created: Sep 8, 2009 7:32:09 PM
27 | *
28 | * @author Artur Hefczyc
29 | * @version $Rev$
30 | */
31 | public class FloatHistoryCache {
32 |
33 | private float[] buffer = null;
34 | private int start = 0;
35 | private int count = 0;
36 |
37 | public FloatHistoryCache(int limit) {
38 | buffer = new float[limit];
39 | }
40 |
41 | public synchronized void addItem(float item) {
42 | int ix = (start + count) % buffer.length;
43 | buffer[ix] = item;
44 | if (count < buffer.length) {
45 | count++;
46 | } else {
47 | start++;
48 | start %= buffer.length;
49 | }
50 | }
51 |
52 | public synchronized float[] getCurrentHistory() {
53 | float[] result = new float[count];
54 | for (int i = 0; i < count; i++) {
55 | int ix = (start + i) % buffer.length;
56 | result[i] = buffer[ix];
57 | }
58 | return result;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------