libs/patch-smack-android-sasl.diff
author Nikita Kozlov <nikita@beem-project.com>
Sat, 16 Jan 2010 17:58:32 +0100
changeset 639 af35b5109f17
parent 311 2cc05187c92e
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
311
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     1
diff -Nbdru org/jivesoftware/smack/ConnectionConfiguration.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/ConnectionConfiguration.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     2
--- org/jivesoftware/smack/ConnectionConfiguration.java	2009-06-26 21:11:24.609252239 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     3
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/ConnectionConfiguration.java	2009-06-25 22:41:46.281648000 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     4
@@ -63,7 +63,7 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     5
      */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     6
     private CallbackHandler callbackHandler;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     7
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     8
-    private boolean debuggerEnabled = XMPPConnection.DEBUG_ENABLED;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
     9
+    private boolean debuggerEnabled = false;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    10
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    11
     // Flag that indicates if a reconnection should be attempted when abruptly disconnected
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    12
     private boolean reconnectionAllowed = true;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    13
diff -Nbdru org/jivesoftware/smack/debugger/LiteDebugger.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/debugger/LiteDebugger.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    14
--- org/jivesoftware/smack/debugger/LiteDebugger.java	2009-06-26 21:11:22.316252115 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    15
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/debugger/LiteDebugger.java	1970-01-01 01:00:00.000000000 +0100
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    16
@@ -1,336 +0,0 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    17
-/**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    18
- * $RCSfile$
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    19
- * $Revision: 7071 $
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    20
- * $Date: 2007-02-12 01:59:05 +0100 (Mon, 12 Feb 2007) $
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    21
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    22
- * Copyright 2003-2007 Jive Software.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    23
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    24
- * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    25
- * you may not use this file except in compliance with the License.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    26
- * You may obtain a copy of the License at
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    27
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    28
- *     http://www.apache.org/licenses/LICENSE-2.0
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    29
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    30
- * Unless required by applicable law or agreed to in writing, software
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    31
- * distributed under the License is distributed on an "AS IS" BASIS,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    32
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    33
- * See the License for the specific language governing permissions and
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    34
- * limitations under the License.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    35
- */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    36
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    37
-package org.jivesoftware.smack.debugger;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    38
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    39
-import java.awt.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    40
-import java.awt.datatransfer.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    41
-import java.awt.event.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    42
-import java.io.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    43
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    44
-import javax.swing.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    45
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    46
-import org.jivesoftware.smack.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    47
-import org.jivesoftware.smack.packet.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    48
-import org.jivesoftware.smack.util.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    49
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    50
-/**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    51
- * The LiteDebugger is a very simple debugger that allows to debug sent, received and 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    52
- * interpreted messages.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    53
- * 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    54
- * @author Gaston Dombiak
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    55
- */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    56
-public class LiteDebugger implements SmackDebugger {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    57
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    58
-    private static final String NEWLINE = "\n";
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    59
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    60
-    private JFrame frame = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    61
-    private XMPPConnection connection = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    62
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    63
-    private PacketListener listener = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    64
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    65
-    private Writer writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    66
-    private Reader reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    67
-    private ReaderListener readerListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    68
-    private WriterListener writerListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    69
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    70
-    public LiteDebugger(XMPPConnection connection, Writer writer, Reader reader) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    71
-        this.connection = connection;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    72
-        this.writer = writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    73
-        this.reader = reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    74
-        createDebug();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    75
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    76
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    77
-    /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    78
-     * Creates the debug process, which is a GUI window that displays XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    79
-     */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    80
-    private void createDebug() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    81
-        frame = new JFrame("Smack Debug Window -- " + connection.getServiceName() + ":" +
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    82
-                connection.getPort());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    83
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    84
-        // Add listener for window closing event 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    85
-        frame.addWindowListener(new WindowAdapter() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    86
-            public void windowClosing(WindowEvent evt) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    87
-                rootWindowClosing(evt);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    88
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    89
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    90
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    91
-        // We'll arrange the UI into four tabs. The first tab contains all data, the second
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    92
-        // client generated XML, the third server generated XML, and the fourth is packet
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    93
-        // data from the server as seen by Smack.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    94
-        JTabbedPane tabbedPane = new JTabbedPane();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    95
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    96
-        JPanel allPane = new JPanel();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    97
-        allPane.setLayout(new GridLayout(3, 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    98
-        tabbedPane.add("All", allPane);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
    99
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   100
-        // Create UI elements for client generated XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   101
-        final JTextArea sentText1 = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   102
-        final JTextArea sentText2 = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   103
-        sentText1.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   104
-        sentText2.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   105
-        sentText1.setForeground(new Color(112, 3, 3));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   106
-        sentText2.setForeground(new Color(112, 3, 3));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   107
-        allPane.add(new JScrollPane(sentText1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   108
-        tabbedPane.add("Sent", new JScrollPane(sentText2));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   109
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   110
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   111
-        JPopupMenu menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   112
-        JMenuItem menuItem1 = new JMenuItem("Copy");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   113
-        menuItem1.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   114
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   115
-                // Get the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   116
-                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   117
-                // Set the sent text as the new content of the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   118
-                clipboard.setContents(new StringSelection(sentText1.getText()), null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   119
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   120
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   121
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   122
-        JMenuItem menuItem2 = new JMenuItem("Clear");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   123
-        menuItem2.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   124
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   125
-                sentText1.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   126
-                sentText2.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   127
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   128
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   129
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   130
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   131
-        MouseListener popupListener = new PopupListener(menu);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   132
-        sentText1.addMouseListener(popupListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   133
-        sentText2.addMouseListener(popupListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   134
-        menu.add(menuItem1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   135
-        menu.add(menuItem2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   136
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   137
-        // Create UI elements for server generated XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   138
-        final JTextArea receivedText1 = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   139
-        final JTextArea receivedText2 = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   140
-        receivedText1.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   141
-        receivedText2.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   142
-        receivedText1.setForeground(new Color(6, 76, 133));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   143
-        receivedText2.setForeground(new Color(6, 76, 133));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   144
-        allPane.add(new JScrollPane(receivedText1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   145
-        tabbedPane.add("Received", new JScrollPane(receivedText2));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   146
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   147
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   148
-        menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   149
-        menuItem1 = new JMenuItem("Copy");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   150
-        menuItem1.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   151
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   152
-                // Get the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   153
-                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   154
-                // Set the sent text as the new content of the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   155
-                clipboard.setContents(new StringSelection(receivedText1.getText()), null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   156
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   157
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   158
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   159
-        menuItem2 = new JMenuItem("Clear");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   160
-        menuItem2.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   161
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   162
-                receivedText1.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   163
-                receivedText2.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   164
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   165
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   166
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   167
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   168
-        popupListener = new PopupListener(menu);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   169
-        receivedText1.addMouseListener(popupListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   170
-        receivedText2.addMouseListener(popupListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   171
-        menu.add(menuItem1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   172
-        menu.add(menuItem2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   173
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   174
-        // Create UI elements for interpreted XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   175
-        final JTextArea interpretedText1 = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   176
-        final JTextArea interpretedText2 = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   177
-        interpretedText1.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   178
-        interpretedText2.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   179
-        interpretedText1.setForeground(new Color(1, 94, 35));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   180
-        interpretedText2.setForeground(new Color(1, 94, 35));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   181
-        allPane.add(new JScrollPane(interpretedText1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   182
-        tabbedPane.add("Interpreted", new JScrollPane(interpretedText2));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   183
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   184
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   185
-        menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   186
-        menuItem1 = new JMenuItem("Copy");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   187
-        menuItem1.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   188
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   189
-                // Get the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   190
-                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   191
-                // Set the sent text as the new content of the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   192
-                clipboard.setContents(new StringSelection(interpretedText1.getText()), null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   193
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   194
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   195
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   196
-        menuItem2 = new JMenuItem("Clear");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   197
-        menuItem2.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   198
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   199
-                interpretedText1.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   200
-                interpretedText2.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   201
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   202
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   203
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   204
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   205
-        popupListener = new PopupListener(menu);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   206
-        interpretedText1.addMouseListener(popupListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   207
-        interpretedText2.addMouseListener(popupListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   208
-        menu.add(menuItem1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   209
-        menu.add(menuItem2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   210
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   211
-        frame.getContentPane().add(tabbedPane);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   212
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   213
-        frame.setSize(550, 400);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   214
-        frame.setVisible(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   215
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   216
-        // Create a special Reader that wraps the main Reader and logs data to the GUI.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   217
-        ObservableReader debugReader = new ObservableReader(reader);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   218
-        readerListener = new ReaderListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   219
-                    public void read(String str) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   220
-                        int index = str.lastIndexOf(">");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   221
-                        if (index != -1) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   222
-                            receivedText1.append(str.substring(0, index + 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   223
-                            receivedText2.append(str.substring(0, index + 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   224
-                            receivedText1.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   225
-                            receivedText2.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   226
-                            if (str.length() > index) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   227
-                                receivedText1.append(str.substring(index + 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   228
-                                receivedText2.append(str.substring(index + 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   229
-                            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   230
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   231
-                        else {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   232
-                            receivedText1.append(str);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   233
-                            receivedText2.append(str);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   234
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   235
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   236
-                };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   237
-        debugReader.addReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   238
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   239
-        // Create a special Writer that wraps the main Writer and logs data to the GUI.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   240
-        ObservableWriter debugWriter = new ObservableWriter(writer);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   241
-        writerListener = new WriterListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   242
-                    public void write(String str) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   243
-                        sentText1.append(str);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   244
-                        sentText2.append(str);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   245
-                        if (str.endsWith(">")) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   246
-                            sentText1.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   247
-                            sentText2.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   248
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   249
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   250
-                };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   251
-        debugWriter.addWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   252
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   253
-        // Assign the reader/writer objects to use the debug versions. The packet reader
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   254
-        // and writer will use the debug versions when they are created.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   255
-        reader = debugReader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   256
-        writer = debugWriter;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   257
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   258
-        // Create a thread that will listen for all incoming packets and write them to
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   259
-        // the GUI. This is what we call "interpreted" packet data, since it's the packet
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   260
-        // data as Smack sees it and not as it's coming in as raw XML.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   261
-        listener = new PacketListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   262
-            public void processPacket(Packet packet) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   263
-                interpretedText1.append(packet.toXML());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   264
-                interpretedText2.append(packet.toXML());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   265
-                interpretedText1.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   266
-                interpretedText2.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   267
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   268
-        };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   269
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   270
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   271
-    /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   272
-     * Notification that the root window is closing. Stop listening for received and 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   273
-     * transmitted packets.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   274
-     * 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   275
-     * @param evt the event that indicates that the root window is closing 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   276
-     */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   277
-    public void rootWindowClosing(WindowEvent evt) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   278
-        connection.removePacketListener(listener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   279
-        ((ObservableReader)reader).removeReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   280
-        ((ObservableWriter)writer).removeWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   281
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   282
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   283
-    /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   284
-     * Listens for debug window popup dialog events.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   285
-     */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   286
-    private class PopupListener extends MouseAdapter {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   287
-        JPopupMenu popup;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   288
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   289
-        PopupListener(JPopupMenu popupMenu) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   290
-            popup = popupMenu;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   291
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   292
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   293
-        public void mousePressed(MouseEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   294
-            maybeShowPopup(e);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   295
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   296
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   297
-        public void mouseReleased(MouseEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   298
-            maybeShowPopup(e);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   299
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   300
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   301
-        private void maybeShowPopup(MouseEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   302
-            if (e.isPopupTrigger()) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   303
-                popup.show(e.getComponent(), e.getX(), e.getY());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   304
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   305
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   306
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   307
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   308
-    public Reader newConnectionReader(Reader newReader) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   309
-        ((ObservableReader)reader).removeReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   310
-        ObservableReader debugReader = new ObservableReader(newReader);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   311
-        debugReader.addReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   312
-        reader = debugReader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   313
-        return reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   314
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   315
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   316
-    public Writer newConnectionWriter(Writer newWriter) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   317
-        ((ObservableWriter)writer).removeWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   318
-        ObservableWriter debugWriter = new ObservableWriter(newWriter);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   319
-        debugWriter.addWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   320
-        writer = debugWriter;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   321
-        return writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   322
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   323
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   324
-    public void userHasLogged(String user) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   325
-        boolean isAnonymous = "".equals(StringUtils.parseName(user));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   326
-        String title =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   327
-            "Smack Debug Window -- "
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   328
-                + (isAnonymous ? "" : StringUtils.parseBareAddress(user))
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   329
-                + "@"
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   330
-                + connection.getServiceName()
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   331
-                + ":"
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   332
-                + connection.getPort();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   333
-        title += "/" + StringUtils.parseResource(user);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   334
-        frame.setTitle(title);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   335
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   336
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   337
-    public Reader getReader() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   338
-        return reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   339
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   340
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   341
-    public Writer getWriter() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   342
-        return writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   343
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   344
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   345
-    public PacketListener getReaderListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   346
-        return listener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   347
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   348
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   349
-    public PacketListener getWriterListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   350
-        return null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   351
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   352
-}
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   353
diff -Nbdru org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   354
--- org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java	2009-06-26 21:11:23.436473310 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   355
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java	2009-06-26 20:56:01.656252399 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   356
@@ -25,8 +25,9 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   357
 import java.io.IOException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   358
 import java.util.Map;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   359
 import java.util.HashMap;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   360
-import javax.security.sasl.Sasl;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   361
-import javax.security.sasl.SaslClient;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   362
+
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   363
+import security.javax.security.sasl.Sasl;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   364
+
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   365
 import javax.security.auth.callback.CallbackHandler;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   366
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   367
 /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   368
@@ -63,7 +64,7 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   369
         String[] mechanisms = { getName() };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   370
         Map props = new HashMap();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   371
         props.put(Sasl.SERVER_AUTH,"TRUE");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   372
-        sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   373
+        sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, (javax.security.auth.callback.CallbackHandler)cbh);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   374
         authenticate();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   375
     }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   376
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   377
diff -Nbdru org/jivesoftware/smack/sasl/SASLMechanism.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/sasl/SASLMechanism.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   378
--- org/jivesoftware/smack/sasl/SASLMechanism.java	2009-06-26 21:11:23.436473310 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   379
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/sasl/SASLMechanism.java	2009-06-26 21:23:03.244251498 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   380
@@ -20,23 +20,25 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   381
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   382
 package org.jivesoftware.smack.sasl;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   383
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   384
-import org.jivesoftware.smack.XMPPException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   385
-import org.jivesoftware.smack.SASLAuthentication;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   386
-import org.jivesoftware.smack.util.Base64;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   387
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   388
 import java.io.IOException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   389
-import java.util.Map;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   390
 import java.util.HashMap;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   391
-import javax.security.auth.callback.CallbackHandler;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   392
-import javax.security.auth.callback.UnsupportedCallbackException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   393
+import java.util.Map;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   394
+
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   395
 import javax.security.auth.callback.Callback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   396
-import javax.security.auth.callback.NameCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   397
+import javax.security.auth.callback.CallbackHandler;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   398
 import javax.security.auth.callback.PasswordCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   399
-import javax.security.sasl.RealmCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   400
-import javax.security.sasl.RealmChoiceCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   401
-import javax.security.sasl.Sasl;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   402
-import javax.security.sasl.SaslClient;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   403
-import javax.security.sasl.SaslException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   404
+import javax.security.auth.callback.UnsupportedCallbackException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   405
+
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   406
+import org.jivesoftware.smack.SASLAuthentication;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   407
+import org.jivesoftware.smack.XMPPException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   408
+import org.jivesoftware.smack.util.Base64;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   409
+
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   410
+import security.javax.security.auth.callback.NameCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   411
+import security.javax.security.sasl.RealmCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   412
+import security.javax.security.sasl.RealmChoiceCallback;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   413
+import security.javax.security.sasl.Sasl;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   414
+import security.javax.security.sasl.SaslClient;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   415
+import security.javax.security.sasl.SaslException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   416
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   417
 /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   418
  * Base class for SASL mechanisms. Subclasses must implement these methods:
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   419
@@ -148,12 +150,13 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   420
         } else {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   421
             response = sc.evaluateChallenge(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   422
         }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   423
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   424
-        String authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   425
+        String authenticationText = "";
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   426
+        if (response != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   427
+        authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   428
         if(authenticationText.equals("")) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   429
             authenticationText = "=";
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   430
         }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   431
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   432
+        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   433
         stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   434
         stanza.append(authenticationText);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   435
         stanza.append("</response>");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   436
diff -Nbdru org/jivesoftware/smack/SASLAuthentication.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/SASLAuthentication.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   437
--- org/jivesoftware/smack/SASLAuthentication.java	2009-06-26 21:11:24.597252589 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   438
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/SASLAuthentication.java	2009-06-26 21:31:16.445251493 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   439
@@ -84,17 +84,15 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   440
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   441
         // Register SASL mechanisms supported by Smack
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   442
         registerSASLMechanism("EXTERNAL", SASLExternalMechanism.class);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   443
-        registerSASLMechanism("GSSAPI", SASLGSSAPIMechanism.class);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   444
         registerSASLMechanism("DIGEST-MD5", SASLDigestMD5Mechanism.class);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   445
         registerSASLMechanism("CRAM-MD5", SASLCramMD5Mechanism.class);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   446
         registerSASLMechanism("PLAIN", SASLPlainMechanism.class);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   447
         registerSASLMechanism("ANONYMOUS", SASLAnonymous.class);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   448
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   449
-        supportSASLMechanism("GSSAPI",0);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   450
-        supportSASLMechanism("DIGEST-MD5",1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   451
-        supportSASLMechanism("CRAM-MD5",2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   452
-        supportSASLMechanism("PLAIN",3);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   453
-        supportSASLMechanism("ANONYMOUS",4);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   454
+        supportSASLMechanism("DIGEST-MD5",0);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   455
+        supportSASLMechanism("CRAM-MD5",1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   456
+        supportSASLMechanism("PLAIN",2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   457
+        supportSASLMechanism("ANONYMOUS",3);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   458
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   459
     }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   460
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   461
diff -Nbdru org/jivesoftware/smack/util/DNSUtil.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/util/DNSUtil.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   462
--- org/jivesoftware/smack/util/DNSUtil.java	2009-06-26 21:11:24.585252398 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   463
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/util/DNSUtil.java	2009-06-26 00:41:16.932251881 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   464
@@ -22,12 +22,6 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   465
 import java.util.Hashtable;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   466
 import java.util.Map;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   467
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   468
-import javax.naming.NamingEnumeration;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   469
-import javax.naming.directory.Attribute;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   470
-import javax.naming.directory.Attributes;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   471
-import javax.naming.directory.DirContext;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   472
-import javax.naming.directory.InitialDirContext;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   473
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   474
 /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   475
  * Utilty class to perform DNS lookups for XMPP services.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   476
  *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   477
@@ -41,13 +35,13 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   478
      */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   479
     private static Map cache = new Cache(100, 1000*60*10);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   480
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   481
-    private static DirContext context;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   482
+//    private static DirContext context;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   483
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   484
     static {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   485
         try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   486
             Hashtable env = new Hashtable();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   487
             env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   488
-            context = new InitialDirContext(env);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   489
+ //           context = new InitialDirContext(env);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   490
         }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   491
         catch (Exception e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   492
             // Ignore.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   493
@@ -79,65 +73,8 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   494
      *      server can be reached at for the specified domain.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   495
      */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   496
     public static HostAddress resolveXMPPDomain(String domain) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   497
-        if (context == null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   498
             return new HostAddress(domain, 5222);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   499
         }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   500
-        String key = "c" + domain;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   501
-        // Return item from cache if it exists.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   502
-        if (cache.containsKey(key)) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   503
-            HostAddress address = (HostAddress)cache.get(key);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   504
-            if (address != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   505
-                return address;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   506
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   507
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   508
-        String bestHost = domain;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   509
-        int bestPort = 5222;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   510
-        int bestPriority = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   511
-        int bestWeight = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   512
-        try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   513
-            Attributes dnsLookup = context.getAttributes("_xmpp-client._tcp." + domain, new String[]{"SRV"});
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   514
-            Attribute srvAttribute = dnsLookup.get("SRV");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   515
-            NamingEnumeration srvRecords = srvAttribute.getAll();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   516
-            while(srvRecords.hasMore()) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   517
-				String srvRecord = (String) srvRecords.next();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   518
-	            String [] srvRecordEntries = srvRecord.split(" ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   519
-	            int priority = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 4]);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   520
-	            int port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   521
-	            int weight = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 3]);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   522
-	            String host = srvRecordEntries[srvRecordEntries.length-1];
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   523
-	            
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   524
-	            // Randomize the weight.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   525
-	            weight *= Math.random() * weight;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   526
-	            
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   527
-	            if ((bestPriority == 0) || (priority < bestPriority)) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   528
-	            	// Choose a server with the lowest priority.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   529
-	            	bestPriority = priority;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   530
-	            	bestWeight = weight;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   531
-	            	bestHost = host;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   532
-	            	bestPort = port;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   533
-	            } else if (priority == bestPriority) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   534
-	            	// When we have like priorities then randomly choose a server based on its weight
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   535
-	            	// The weights were randomized above.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   536
-	            	if (weight > bestWeight) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   537
-	            		bestWeight = weight;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   538
-	            		bestHost = host;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   539
-	            		bestPort = port;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   540
-	            	}
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   541
-	            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   542
-			}
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   543
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   544
-        catch (Exception e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   545
-            // Ignore.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   546
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   547
-        // Host entries in DNS should end with a ".".
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   548
-        if (bestHost.endsWith(".")) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   549
-        	bestHost = bestHost.substring(0, bestHost.length()-1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   550
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   551
-        HostAddress address = new HostAddress(bestHost, bestPort);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   552
-        // Add item to cache.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   553
-        cache.put(key, address);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   554
-        return address;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   555
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   556
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   557
     /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   558
      * Returns the host name and port that the specified XMPP server can be
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   559
@@ -157,50 +94,8 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   560
      *      server can be reached at for the specified domain.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   561
      */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   562
     public static HostAddress resolveXMPPServerDomain(String domain) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   563
-        if (context == null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   564
             return new HostAddress(domain, 5269);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   565
         }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   566
-        String key = "s" + domain;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   567
-        // Return item from cache if it exists.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   568
-        if (cache.containsKey(key)) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   569
-            HostAddress address = (HostAddress)cache.get(key);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   570
-            if (address != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   571
-                return address;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   572
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   573
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   574
-        String host = domain;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   575
-        int port = 5269;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   576
-        try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   577
-            Attributes dnsLookup =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   578
-                    context.getAttributes("_xmpp-server._tcp." + domain, new String[]{"SRV"});
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   579
-            String srvRecord = (String)dnsLookup.get("SRV").get();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   580
-            String [] srvRecordEntries = srvRecord.split(" ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   581
-            port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   582
-            host = srvRecordEntries[srvRecordEntries.length-1];
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   583
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   584
-        catch (Exception e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   585
-            // Attempt lookup with older "jabber" name.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   586
-            try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   587
-                Attributes dnsLookup =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   588
-                        context.getAttributes("_jabber._tcp." + domain, new String[]{"SRV"});
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   589
-                String srvRecord = (String)dnsLookup.get("SRV").get();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   590
-                String [] srvRecordEntries = srvRecord.split(" ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   591
-                port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   592
-                host = srvRecordEntries[srvRecordEntries.length-1];
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   593
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   594
-            catch (Exception e2) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   595
-                // Ignore.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   596
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   597
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   598
-        // Host entries in DNS should end with a ".".
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   599
-        if (host.endsWith(".")) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   600
-            host = host.substring(0, host.length()-1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   601
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   602
-        HostAddress address = new HostAddress(host, port);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   603
-        // Add item to cache.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   604
-        cache.put(key, address);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   605
-        return address;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   606
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   607
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   608
     /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   609
      * Encapsulates a hostname and port.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   610
diff -Nbdru org/jivesoftware/smack/util/PacketParserUtils.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/util/PacketParserUtils.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   611
--- org/jivesoftware/smack/util/PacketParserUtils.java	2009-06-26 21:11:24.585252398 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   612
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/util/PacketParserUtils.java	2009-06-25 22:34:41.252416000 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   613
@@ -25,7 +25,7 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   614
 import org.jivesoftware.smack.provider.ProviderManager;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   615
 import org.xmlpull.v1.XmlPullParser;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   616
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   617
-import java.beans.PropertyDescriptor;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   618
+//import java.beans.PropertyDescriptor;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   619
 import java.io.ByteArrayInputStream;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   620
 import java.io.ObjectInputStream;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   621
 import java.util.ArrayList;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   622
@@ -428,26 +428,26 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   623
     {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   624
         boolean done = false;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   625
         Object object = objectClass.newInstance();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   626
-        while (!done) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   627
-            int eventType = parser.next();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   628
-            if (eventType == XmlPullParser.START_TAG) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   629
-                String name = parser.getName();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   630
-                String stringValue = parser.nextText();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   631
-                PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   632
-                // Load the class type of the property.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   633
-                Class propertyType = descriptor.getPropertyType();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   634
-                // Get the value of the property by converting it from a
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   635
-                // String to the correct object type.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   636
-                Object value = decode(propertyType, stringValue);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   637
-                // Set the value of the bean.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   638
-                descriptor.getWriteMethod().invoke(object, value);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   639
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   640
-            else if (eventType == XmlPullParser.END_TAG) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   641
-                if (parser.getName().equals(elementName)) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   642
-                    done = true;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   643
-                }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   644
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   645
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   646
+//        while (!done) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   647
+//            int eventType = parser.next();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   648
+//            if (eventType == XmlPullParser.START_TAG) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   649
+//                String name = parser.getName();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   650
+//                String stringValue = parser.nextText();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   651
+//                PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   652
+//                // Load the class type of the property.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   653
+//                Class propertyType = descriptor.getPropertyType();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   654
+//                // Get the value of the property by converting it from a
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   655
+//                // String to the correct object type.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   656
+//                Object value = decode(propertyType, stringValue);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   657
+//                // Set the value of the bean.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   658
+//                descriptor.getWriteMethod().invoke(object, value);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   659
+//            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   660
+//            else if (eventType == XmlPullParser.END_TAG) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   661
+//                if (parser.getName().equals(elementName)) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   662
+//                    done = true;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   663
+//                }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   664
+//            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   665
+//        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   666
         return object;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   667
     }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   668
 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   669
diff -Nbdru org/jivesoftware/smack/XMPPConnection.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/XMPPConnection.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   670
--- org/jivesoftware/smack/XMPPConnection.java	2009-06-26 21:11:24.601252412 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   671
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smack/XMPPConnection.java	2009-06-25 22:34:41.252416000 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   672
@@ -1082,7 +1082,7 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   673
                     catch (Exception ex) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   674
                         try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   675
                             debuggerClass =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   676
-                                    Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   677
+                                    Class.forName("org.jivesoftware.smack.debugger.ConsoleDebugger");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   678
                         }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   679
                         catch (Exception ex2) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   680
                             ex2.printStackTrace();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   681
diff -Nbdru org/jivesoftware/smackx/debugger/EnhancedDebugger.java /home/nikita/devel/beem-ui/src/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   682
--- org/jivesoftware/smackx/debugger/EnhancedDebugger.java	2009-06-26 21:11:18.348252001 +0200
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   683
+++ /home/nikita/devel/beem-ui/src/org/jivesoftware/smackx/debugger/EnhancedDebugger.java	1970-01-01 01:00:00.000000000 +0100
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   684
@@ -1,1005 +0,0 @@
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   685
-/**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   686
- * $RCSfile$
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   687
- * $Revision: 11024 $
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   688
- * $Date: 2009-06-04 13:58:25 +0200 (Thu, 04 Jun 2009) $
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   689
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   690
- * Copyright 2003-2007 Jive Software.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   691
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   692
- * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   693
- * you may not use this file except in compliance with the License.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   694
- * You may obtain a copy of the License at
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   695
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   696
- *     http://www.apache.org/licenses/LICENSE-2.0
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   697
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   698
- * Unless required by applicable law or agreed to in writing, software
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   699
- * distributed under the License is distributed on an "AS IS" BASIS,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   700
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   701
- * See the License for the specific language governing permissions and
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   702
- * limitations under the License.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   703
- */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   704
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   705
-package org.jivesoftware.smackx.debugger;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   706
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   707
-import org.jivesoftware.smack.ConnectionListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   708
-import org.jivesoftware.smack.PacketListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   709
-import org.jivesoftware.smack.XMPPConnection;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   710
-import org.jivesoftware.smack.debugger.SmackDebugger;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   711
-import org.jivesoftware.smack.packet.IQ;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   712
-import org.jivesoftware.smack.packet.Message;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   713
-import org.jivesoftware.smack.packet.Packet;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   714
-import org.jivesoftware.smack.packet.Presence;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   715
-import org.jivesoftware.smack.util.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   716
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   717
-import javax.swing.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   718
-import javax.swing.event.ListSelectionEvent;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   719
-import javax.swing.event.ListSelectionListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   720
-import javax.swing.table.DefaultTableModel;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   721
-import javax.swing.text.BadLocationException;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   722
-import javax.xml.transform.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   723
-import javax.xml.transform.stream.StreamResult;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   724
-import javax.xml.transform.stream.StreamSource;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   725
-import java.awt.*;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   726
-import java.awt.datatransfer.Clipboard;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   727
-import java.awt.datatransfer.StringSelection;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   728
-import java.awt.event.ActionEvent;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   729
-import java.awt.event.ActionListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   730
-import java.awt.event.MouseAdapter;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   731
-import java.awt.event.MouseEvent;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   732
-import java.io.Reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   733
-import java.io.StringReader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   734
-import java.io.StringWriter;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   735
-import java.io.Writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   736
-import java.net.URL;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   737
-import java.text.SimpleDateFormat;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   738
-import java.util.Date;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   739
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   740
-/**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   741
- * The EnhancedDebugger is a debugger that allows to debug sent, received and interpreted messages
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   742
- * but also provides the ability to send ad-hoc messages composed by the user.<p>
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   743
- * <p/>
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   744
- * A new EnhancedDebugger will be created for each connection to debug. All the EnhancedDebuggers
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   745
- * will be shown in the same debug window provided by the class EnhancedDebuggerWindow.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   746
- *
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   747
- * @author Gaston Dombiak
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   748
- */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   749
-public class EnhancedDebugger implements SmackDebugger {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   750
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   751
-    private static final String NEWLINE = "\n";
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   752
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   753
-    private static ImageIcon packetReceivedIcon;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   754
-    private static ImageIcon packetSentIcon;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   755
-    private static ImageIcon presencePacketIcon;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   756
-    private static ImageIcon iqPacketIcon;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   757
-    private static ImageIcon messagePacketIcon;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   758
-    private static ImageIcon unknownPacketTypeIcon;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   759
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   760
-    {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   761
-        URL url;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   762
-        // Load the image icons 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   763
-        url =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   764
-                Thread.currentThread().getContextClassLoader().getResource("images/nav_left_blue.png");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   765
-        if (url != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   766
-            packetReceivedIcon = new ImageIcon(url);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   767
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   768
-        url =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   769
-                Thread.currentThread().getContextClassLoader().getResource("images/nav_right_red.png");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   770
-        if (url != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   771
-            packetSentIcon = new ImageIcon(url);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   772
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   773
-        url =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   774
-                Thread.currentThread().getContextClassLoader().getResource("images/photo_portrait.png");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   775
-        if (url != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   776
-            presencePacketIcon = new ImageIcon(url);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   777
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   778
-        url =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   779
-                Thread.currentThread().getContextClassLoader().getResource(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   780
-                        "images/question_and_answer.png");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   781
-        if (url != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   782
-            iqPacketIcon = new ImageIcon(url);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   783
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   784
-        url = Thread.currentThread().getContextClassLoader().getResource("images/message.png");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   785
-        if (url != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   786
-            messagePacketIcon = new ImageIcon(url);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   787
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   788
-        url = Thread.currentThread().getContextClassLoader().getResource("images/unknown.png");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   789
-        if (url != null) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   790
-            unknownPacketTypeIcon = new ImageIcon(url);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   791
-        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   792
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   793
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   794
-    private DefaultTableModel messagesTable = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   795
-    private JTextArea messageTextArea = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   796
-    private JFormattedTextField userField = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   797
-    private JFormattedTextField statusField = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   798
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   799
-    private XMPPConnection connection = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   800
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   801
-    private PacketListener packetReaderListener = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   802
-    private PacketListener packetWriterListener = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   803
-    private ConnectionListener connListener = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   804
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   805
-    private Writer writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   806
-    private Reader reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   807
-    private ReaderListener readerListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   808
-    private WriterListener writerListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   809
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   810
-    private Date creationTime = new Date();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   811
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   812
-    // Statistics variables
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   813
-    private DefaultTableModel statisticsTable = null;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   814
-    private int sentPackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   815
-    private int receivedPackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   816
-    private int sentIQPackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   817
-    private int receivedIQPackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   818
-    private int sentMessagePackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   819
-    private int receivedMessagePackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   820
-    private int sentPresencePackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   821
-    private int receivedPresencePackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   822
-    private int sentOtherPackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   823
-    private int receivedOtherPackets = 0;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   824
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   825
-    JTabbedPane tabbedPane;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   826
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   827
-    public EnhancedDebugger(XMPPConnection connection, Writer writer, Reader reader) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   828
-        this.connection = connection;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   829
-        this.writer = writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   830
-        this.reader = reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   831
-        createDebug();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   832
-        EnhancedDebuggerWindow.addDebugger(this);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   833
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   834
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   835
-    /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   836
-     * Creates the debug process, which is a GUI window that displays XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   837
-     */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   838
-    private void createDebug() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   839
-        // We'll arrange the UI into six tabs. The first tab contains all data, the second
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   840
-        // client generated XML, the third server generated XML, the fourth allows to send 
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   841
-        // ad-hoc messages and the fifth contains connection information.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   842
-        tabbedPane = new JTabbedPane();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   843
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   844
-        // Add the All Packets, Sent, Received and Interpreted panels
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   845
-        addBasicPanels();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   846
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   847
-        // Add the panel to send ad-hoc messages
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   848
-        addAdhocPacketPanel();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   849
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   850
-        // Add the connection information panel
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   851
-        addInformationPanel();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   852
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   853
-        // Create a thread that will listen for all incoming packets and write them to
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   854
-        // the GUI. This is what we call "interpreted" packet data, since it's the packet
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   855
-        // data as Smack sees it and not as it's coming in as raw XML.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   856
-        packetReaderListener = new PacketListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   857
-            SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   858
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   859
-            public void processPacket(final Packet packet) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   860
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   861
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   862
-                        addReadPacketToTable(dateFormatter, packet);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   863
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   864
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   865
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   866
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   867
-        };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   868
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   869
-        // Create a thread that will listen for all outgoing packets and write them to
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   870
-        // the GUI.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   871
-        packetWriterListener = new PacketListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   872
-            SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   873
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   874
-            public void processPacket(final Packet packet) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   875
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   876
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   877
-                        addSentPacketToTable(dateFormatter, packet);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   878
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   879
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   880
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   881
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   882
-        };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   883
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   884
-        // Create a thread that will listen for any connection closed event
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   885
-        connListener = new ConnectionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   886
-            public void connectionClosed() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   887
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   888
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   889
-                        statusField.setValue("Closed");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   890
-                        EnhancedDebuggerWindow.connectionClosed(EnhancedDebugger.this);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   891
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   892
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   893
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   894
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   895
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   896
-            public void connectionClosedOnError(final Exception e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   897
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   898
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   899
-                        statusField.setValue("Closed due to an exception");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   900
-                        EnhancedDebuggerWindow.connectionClosedOnError(EnhancedDebugger.this, e);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   901
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   902
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   903
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   904
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   905
-            public void reconnectingIn(final int seconds){
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   906
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   907
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   908
-                        statusField.setValue("Attempt to reconnect in " + seconds + " seconds");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   909
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   910
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   911
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   912
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   913
-            public void reconnectionSuccessful() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   914
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   915
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   916
-                        statusField.setValue("Reconnection stablished");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   917
-                        EnhancedDebuggerWindow.connectionEstablished(EnhancedDebugger.this);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   918
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   919
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   920
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   921
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   922
-            public void reconnectionFailed(Exception e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   923
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   924
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   925
-                        statusField.setValue("Reconnection failed");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   926
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   927
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   928
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   929
-        };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   930
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   931
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   932
-    private void addBasicPanels() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   933
-        JSplitPane allPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   934
-        allPane.setOneTouchExpandable(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   935
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   936
-        messagesTable =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   937
-                new DefaultTableModel(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   938
-                        new Object[]{"Hide", "Timestamp", "", "", "Message", "Id", "Type", "To", "From"},
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   939
-                        0) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   940
-        			private static final long serialVersionUID = 8136121224474217264L;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   941
-					public boolean isCellEditable(int rowIndex, int mColIndex) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   942
-                        return false;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   943
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   944
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   945
-                    public Class getColumnClass(int columnIndex) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   946
-                        if (columnIndex == 2 || columnIndex == 3) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   947
-                            return Icon.class;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   948
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   949
-                        return super.getColumnClass(columnIndex);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   950
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   951
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   952
-                };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   953
-        JTable table = new JTable(messagesTable);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   954
-        // Allow only single a selection
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   955
-        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   956
-        // Hide the first column
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   957
-        table.getColumnModel().getColumn(0).setMaxWidth(0);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   958
-        table.getColumnModel().getColumn(0).setMinWidth(0);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   959
-        table.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   960
-        table.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   961
-        // Set the column "timestamp" size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   962
-        table.getColumnModel().getColumn(1).setMaxWidth(300);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   963
-        table.getColumnModel().getColumn(1).setPreferredWidth(70);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   964
-        // Set the column "direction" icon size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   965
-        table.getColumnModel().getColumn(2).setMaxWidth(50);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   966
-        table.getColumnModel().getColumn(2).setPreferredWidth(30);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   967
-        // Set the column "packet type" icon size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   968
-        table.getColumnModel().getColumn(3).setMaxWidth(50);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   969
-        table.getColumnModel().getColumn(3).setPreferredWidth(30);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   970
-        // Set the column "Id" size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   971
-        table.getColumnModel().getColumn(5).setMaxWidth(100);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   972
-        table.getColumnModel().getColumn(5).setPreferredWidth(55);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   973
-        // Set the column "type" size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   974
-        table.getColumnModel().getColumn(6).setMaxWidth(200);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   975
-        table.getColumnModel().getColumn(6).setPreferredWidth(50);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   976
-        // Set the column "to" size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   977
-        table.getColumnModel().getColumn(7).setMaxWidth(300);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   978
-        table.getColumnModel().getColumn(7).setPreferredWidth(90);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   979
-        // Set the column "from" size
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   980
-        table.getColumnModel().getColumn(8).setMaxWidth(300);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   981
-        table.getColumnModel().getColumn(8).setPreferredWidth(90);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   982
-        // Create a table listener that listen for row selection events
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   983
-        SelectionListener selectionListener = new SelectionListener(table);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   984
-        table.getSelectionModel().addListSelectionListener(selectionListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   985
-        table.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   986
-        allPane.setTopComponent(new JScrollPane(table));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   987
-        messageTextArea = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   988
-        messageTextArea.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   989
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   990
-        JPopupMenu menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   991
-        JMenuItem menuItem1 = new JMenuItem("Copy");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   992
-        menuItem1.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   993
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   994
-                // Get the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   995
-                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   996
-                // Set the sent text as the new content of the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   997
-                clipboard.setContents(new StringSelection(messageTextArea.getText()), null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   998
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
   999
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1000
-        menu.add(menuItem1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1001
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1002
-        messageTextArea.addMouseListener(new PopupListener(menu));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1003
-        allPane.setBottomComponent(new JScrollPane(messageTextArea));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1004
-        allPane.setDividerLocation(150);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1005
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1006
-        tabbedPane.add("All Packets", allPane);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1007
-        tabbedPane.setToolTipTextAt(0, "Sent and received packets processed by Smack");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1008
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1009
-        // Create UI elements for client generated XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1010
-        final JTextArea sentText = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1011
-        sentText.setWrapStyleWord(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1012
-        sentText.setLineWrap(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1013
-        sentText.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1014
-        sentText.setForeground(new Color(112, 3, 3));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1015
-        tabbedPane.add("Raw Sent Packets", new JScrollPane(sentText));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1016
-        tabbedPane.setToolTipTextAt(1, "Raw text of the sent packets");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1017
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1018
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1019
-        menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1020
-        menuItem1 = new JMenuItem("Copy");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1021
-        menuItem1.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1022
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1023
-                // Get the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1024
-                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1025
-                // Set the sent text as the new content of the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1026
-                clipboard.setContents(new StringSelection(sentText.getText()), null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1027
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1028
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1029
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1030
-        JMenuItem menuItem2 = new JMenuItem("Clear");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1031
-        menuItem2.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1032
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1033
-                sentText.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1034
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1035
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1036
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1037
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1038
-        sentText.addMouseListener(new PopupListener(menu));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1039
-        menu.add(menuItem1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1040
-        menu.add(menuItem2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1041
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1042
-        // Create UI elements for server generated XML traffic.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1043
-        final JTextArea receivedText = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1044
-        receivedText.setWrapStyleWord(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1045
-        receivedText.setLineWrap(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1046
-        receivedText.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1047
-        receivedText.setForeground(new Color(6, 76, 133));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1048
-        tabbedPane.add("Raw Received Packets", new JScrollPane(receivedText));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1049
-        tabbedPane.setToolTipTextAt(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1050
-                2,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1051
-                "Raw text of the received packets before Smack process them");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1052
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1053
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1054
-        menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1055
-        menuItem1 = new JMenuItem("Copy");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1056
-        menuItem1.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1057
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1058
-                // Get the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1059
-                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1060
-                // Set the sent text as the new content of the clipboard
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1061
-                clipboard.setContents(new StringSelection(receivedText.getText()), null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1062
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1063
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1064
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1065
-        menuItem2 = new JMenuItem("Clear");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1066
-        menuItem2.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1067
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1068
-                receivedText.setText("");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1069
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1070
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1071
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1072
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1073
-        receivedText.addMouseListener(new PopupListener(menu));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1074
-        menu.add(menuItem1);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1075
-        menu.add(menuItem2);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1076
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1077
-        // Create a special Reader that wraps the main Reader and logs data to the GUI.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1078
-        ObservableReader debugReader = new ObservableReader(reader);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1079
-        readerListener = new ReaderListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1080
-            public void read(final String str) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1081
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1082
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1083
-                        if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER &&
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1084
-                                !EnhancedDebuggerWindow.getInstance().isVisible()) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1085
-                            // Do not add content if the parent is not visible
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1086
-                            return;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1087
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1088
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1089
-                        int index = str.lastIndexOf(">");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1090
-                        if (index != -1) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1091
-                            if (receivedText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS)
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1092
-                            {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1093
-                                try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1094
-                                    receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1095
-                                }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1096
-                                catch (BadLocationException e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1097
-                                    e.printStackTrace();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1098
-                                }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1099
-                            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1100
-                            receivedText.append(str.substring(0, index + 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1101
-                            receivedText.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1102
-                            if (str.length() > index) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1103
-                                receivedText.append(str.substring(index + 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1104
-                            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1105
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1106
-                        else {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1107
-                            receivedText.append(str);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1108
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1109
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1110
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1111
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1112
-        };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1113
-        debugReader.addReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1114
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1115
-        // Create a special Writer that wraps the main Writer and logs data to the GUI.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1116
-        ObservableWriter debugWriter = new ObservableWriter(writer);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1117
-        writerListener = new WriterListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1118
-            public void write(final String str) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1119
-                SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1120
-                    public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1121
-                        if (EnhancedDebuggerWindow.PERSISTED_DEBUGGER &&
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1122
-                                !EnhancedDebuggerWindow.getInstance().isVisible()) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1123
-                            // Do not add content if the parent is not visible
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1124
-                            return;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1125
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1126
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1127
-                        if (sentText.getLineCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1128
-                            try {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1129
-                                sentText.replaceRange("", 0, sentText.getLineEndOffset(0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1130
-                            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1131
-                            catch (BadLocationException e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1132
-                                e.printStackTrace();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1133
-                            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1134
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1135
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1136
-                        sentText.append(str);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1137
-                        if (str.endsWith(">")) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1138
-                            sentText.append(NEWLINE);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1139
-                        }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1140
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1141
-                });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1142
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1143
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1144
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1145
-        };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1146
-        debugWriter.addWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1147
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1148
-        // Assign the reader/writer objects to use the debug versions. The packet reader
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1149
-        // and writer will use the debug versions when they are created.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1150
-        reader = debugReader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1151
-        writer = debugWriter;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1152
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1153
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1154
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1155
-    private void addAdhocPacketPanel() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1156
-        // Create UI elements for sending ad-hoc messages.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1157
-        final JTextArea adhocMessages = new JTextArea();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1158
-        adhocMessages.setEditable(true);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1159
-        adhocMessages.setForeground(new Color(1, 94, 35));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1160
-        tabbedPane.add("Ad-hoc message", new JScrollPane(adhocMessages));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1161
-        tabbedPane.setToolTipTextAt(3, "Panel that allows you to send adhoc packets");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1162
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1163
-        // Add pop-up menu.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1164
-        JPopupMenu menu = new JPopupMenu();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1165
-        JMenuItem menuItem = new JMenuItem("Message");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1166
-        menuItem.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1167
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1168
-                adhocMessages.setText(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1169
-                        "<message to=\"\" id=\""
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1170
-                                + StringUtils.randomString(5)
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1171
-                                + "-X\"><body></body></message>");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1172
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1173
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1174
-        menu.add(menuItem);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1175
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1176
-        menuItem = new JMenuItem("IQ Get");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1177
-        menuItem.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1178
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1179
-                adhocMessages.setText(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1180
-                        "<iq type=\"get\" to=\"\" id=\""
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1181
-                                + StringUtils.randomString(5)
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1182
-                                + "-X\"><query xmlns=\"\"></query></iq>");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1183
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1184
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1185
-        menu.add(menuItem);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1186
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1187
-        menuItem = new JMenuItem("IQ Set");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1188
-        menuItem.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1189
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1190
-                adhocMessages.setText(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1191
-                        "<iq type=\"set\" to=\"\" id=\""
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1192
-                                + StringUtils.randomString(5)
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1193
-                                + "-X\"><query xmlns=\"\"></query></iq>");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1194
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1195
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1196
-        menu.add(menuItem);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1197
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1198
-        menuItem = new JMenuItem("Presence");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1199
-        menuItem.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1200
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1201
-                adhocMessages.setText(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1202
-                        "<presence to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"/>");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1203
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1204
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1205
-        menu.add(menuItem);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1206
-        menu.addSeparator();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1207
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1208
-        menuItem = new JMenuItem("Send");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1209
-        menuItem.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1210
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1211
-                if (!"".equals(adhocMessages.getText())) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1212
-                    AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1213
-                    connection.sendPacket(packetToSend);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1214
-                }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1215
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1216
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1217
-        menu.add(menuItem);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1218
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1219
-        menuItem = new JMenuItem("Clear");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1220
-        menuItem.addActionListener(new ActionListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1221
-            public void actionPerformed(ActionEvent e) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1222
-                adhocMessages.setText(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1223
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1224
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1225
-        menu.add(menuItem);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1226
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1227
-        // Add listener to the text area so the popup menu can come up.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1228
-        adhocMessages.addMouseListener(new PopupListener(menu));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1229
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1230
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1231
-    private void addInformationPanel() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1232
-        // Create UI elements for connection information.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1233
-        JPanel informationPanel = new JPanel();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1234
-        informationPanel.setLayout(new BorderLayout());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1235
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1236
-        // Add the Host information
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1237
-        JPanel connPanel = new JPanel();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1238
-        connPanel.setLayout(new GridBagLayout());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1239
-        connPanel.setBorder(BorderFactory.createTitledBorder("Connection information"));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1240
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1241
-        JLabel label = new JLabel("Host: ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1242
-        label.setMinimumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1243
-        label.setMaximumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1244
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1245
-                label,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1246
-                new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1247
-        JFormattedTextField field = new JFormattedTextField(connection.getServiceName());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1248
-        field.setMinimumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1249
-        field.setMaximumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1250
-        field.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1251
-        field.setBorder(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1252
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1253
-                field,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1254
-                new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1255
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1256
-        // Add the Port information
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1257
-        label = new JLabel("Port: ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1258
-        label.setMinimumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1259
-        label.setMaximumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1260
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1261
-                label,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1262
-                new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1263
-        field = new JFormattedTextField(connection.getPort());
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1264
-        field.setMinimumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1265
-        field.setMaximumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1266
-        field.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1267
-        field.setBorder(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1268
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1269
-                field,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1270
-                new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1271
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1272
-        // Add the connection's User information
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1273
-        label = new JLabel("User: ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1274
-        label.setMinimumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1275
-        label.setMaximumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1276
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1277
-                label,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1278
-                new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1279
-        userField = new JFormattedTextField();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1280
-        userField.setMinimumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1281
-        userField.setMaximumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1282
-        userField.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1283
-        userField.setBorder(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1284
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1285
-                userField,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1286
-                new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1287
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1288
-        // Add the connection's creationTime information
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1289
-        label = new JLabel("Creation time: ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1290
-        label.setMinimumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1291
-        label.setMaximumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1292
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1293
-                label,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1294
-                new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1295
-        field = new JFormattedTextField(new SimpleDateFormat("yyyy.MM.dd hh:mm:ss aaa"));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1296
-        field.setMinimumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1297
-        field.setMaximumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1298
-        field.setValue(creationTime);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1299
-        field.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1300
-        field.setBorder(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1301
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1302
-                field,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1303
-                new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1304
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1305
-        // Add the connection's creationTime information
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1306
-        label = new JLabel("Status: ");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1307
-        label.setMinimumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1308
-        label.setMaximumSize(new java.awt.Dimension(150, 14));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1309
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1310
-                label,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1311
-                new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1312
-        statusField = new JFormattedTextField();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1313
-        statusField.setMinimumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1314
-        statusField.setMaximumSize(new java.awt.Dimension(150, 20));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1315
-        statusField.setValue("Active");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1316
-        statusField.setEditable(false);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1317
-        statusField.setBorder(null);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1318
-        connPanel.add(
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1319
-                statusField,
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1320
-                new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, 10, 2, new Insets(0, 0, 0, 0), 0, 0));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1321
-        // Add the connection panel to the information panel
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1322
-        informationPanel.add(connPanel, BorderLayout.NORTH);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1323
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1324
-        // Add the Number of sent packets information
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1325
-        JPanel packetsPanel = new JPanel();
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1326
-        packetsPanel.setLayout(new GridLayout(1, 1));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1327
-        packetsPanel.setBorder(BorderFactory.createTitledBorder("Transmitted Packets"));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1328
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1329
-        statisticsTable =
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1330
-                new DefaultTableModel(new Object[][]{{"IQ", 0, 0}, {"Message", 0, 0},
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1331
-                        {"Presence", 0, 0}, {"Other", 0, 0}, {"Total", 0, 0}},
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1332
-                        new Object[]{"Type", "Received", "Sent"}) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1333
-        			private static final long serialVersionUID = -6793886085109589269L;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1334
-					public boolean isCellEditable(int rowIndex, int mColIndex) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1335
-                        return false;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1336
-                    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1337
-                };
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1338
-        JTable table = new JTable(statisticsTable);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1339
-        // Allow only single a selection
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1340
-        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1341
-        packetsPanel.add(new JScrollPane(table));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1342
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1343
-        // Add the packets panel to the information panel
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1344
-        informationPanel.add(packetsPanel, BorderLayout.CENTER);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1345
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1346
-        tabbedPane.add("Information", new JScrollPane(informationPanel));
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1347
-        tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1348
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1349
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1350
-    public Reader newConnectionReader(Reader newReader) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1351
-        ((ObservableReader) reader).removeReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1352
-        ObservableReader debugReader = new ObservableReader(newReader);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1353
-        debugReader.addReaderListener(readerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1354
-        reader = debugReader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1355
-        return reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1356
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1357
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1358
-    public Writer newConnectionWriter(Writer newWriter) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1359
-        ((ObservableWriter) writer).removeWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1360
-        ObservableWriter debugWriter = new ObservableWriter(newWriter);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1361
-        debugWriter.addWriterListener(writerListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1362
-        writer = debugWriter;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1363
-        return writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1364
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1365
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1366
-    public void userHasLogged(final String user) {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1367
-        final EnhancedDebugger debugger = this;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1368
-        SwingUtilities.invokeLater(new Runnable() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1369
-            public void run() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1370
-                userField.setText(user);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1371
-                EnhancedDebuggerWindow.userHasLogged(debugger, user);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1372
-                // Add the connection listener to the connection so that the debugger can be notified
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1373
-                // whenever the connection is closed.
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1374
-                connection.addConnectionListener(connListener);
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1375
-            }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1376
-        });
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1377
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1378
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1379
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1380
-    public Reader getReader() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1381
-        return reader;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1382
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1383
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1384
-    public Writer getWriter() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1385
-        return writer;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1386
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1387
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1388
-    public PacketListener getReaderListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1389
-        return packetReaderListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1390
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1391
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1392
-    public PacketListener getWriterListener() {
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1393
-        return packetWriterListener;
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1394
-    }
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1395
-
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1396
-    /**
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1397
-     * Updates the statistics table
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1398
-     */
2cc05187c92e ajout du sasl
nikita@localhost
parents:
diff changeset
  1399