Permalink
Browse files

Merge branch 'master' of github.com:jkallunki/grtot-2012

Conflicts:
	Swirc/src/swirc/SwircController.java
  • Loading branch information...
jkallunki committed Mar 13, 2012
2 parents 7b13811 + e36fff4 commit 6b9d24d8f9ead5964fc9f618d0362ae80b6344d4
@@ -18,8 +18,8 @@
/**
* Constructor
* @param name Name of channel
- * @param name Server address
- * @param gw IrcGateway for the channel
+ * @param server Server address
+ * @param model SwircModel of this channel
*/
public Channel(String name, String server, SwircModel model) {
this.name = name;
@@ -18,7 +18,7 @@
private JSpinner portNumber;
private JPasswordField serverPsw;
private JCheckBox showPsw;
- private JTextField nick;
+ //private JTextField nick;
private boolean confirmed;
/**
@@ -61,10 +61,10 @@ public ConnectDialog(JFrame parent, SwircModel model) {
inputPane.add(showPsw);
//TODO remember to remove nick from this dialog
- inputPane.add(new JLabel("Nick"));
- nick = new JTextField(20);
- nick.setText(this.model.getUserData("nick"));
- inputPane.add(nick);
+// inputPane.add(new JLabel("Nick"));
+// nick = new JTextField(20);
+// nick.setText(this.model.getUserData("nick"));
+// inputPane.add(nick);
formPane.add(inputPane);
@@ -104,9 +104,9 @@ public String getServerAddress() {
* Method gets user's nickname.
* @return User's nickname
*/
- public String getNick() {
- return nick.getText();
- }
+// public String getNick() {
+// return nick.getText();
+// }
/**
* Returns the password of the server
@@ -21,7 +21,11 @@
/**
* Constructor.
* @param model SwircModel of this IrcGateway
+ * @param serverAddress Server of this IrcGateway
* @param nick Nickname of the user
+ * @param port Port of this IrcGateway
+ * @param password Password of server
+ * @throws Exception
*/
public IrcGateway(SwircModel model, String serverAddress, String nick, String port, String password) throws Exception {
this.model = model;
@@ -29,6 +29,10 @@ public ServerTab(String serverAddress) {
this.add(msgPane, BorderLayout.CENTER);
}
+ /**
+ * Adds message to messages panel.
+ * @param msg message to be added
+ */
public void addMsg(String msg) {
this.messages.setText(this.messages.getText() + "\n" + msg);
}
@@ -42,8 +42,13 @@ private void initServerProperties() {
input.close();
}
catch(FileNotFoundException e) {
- System.out.println(e.toString());
- File makefile = new File("src/properties/usedServers");
+ try {
+ FileOutputStream out = new FileOutputStream("src/properties/usedServers");
+ out.close();
+ }
+ catch(Exception ex) {
+
+ }
}
catch(Exception e) {
System.out.println(e.toString());
@@ -57,8 +62,13 @@ private void initUserData() {
dataIn.close();
}
catch(FileNotFoundException e) {
- System.out.println(e.toString());
- File makefile = new File("src/properties/userData");
+ try {
+ FileOutputStream out = new FileOutputStream("src/properties/userData");
+ out.close();
+ }
+ catch(Exception ex) {
+
+ }
}
catch(Exception e) {
//TODO properties not found
@@ -33,12 +33,12 @@ public void actionPerformed(ActionEvent e) {
if(code.equals("connectServer")) {
HashMap<String,String> con = view.connectPrompt();
if(con != null) {
- if(!con.get("serverAddress").equals("") && !con.get("nick").equals("")) {
+ if(!con.get("serverAddress").equals("")) {
this.view.addServerView(con.get("serverAddress"));
- this.model.connect(con.get("serverAddress"), con.get("nick"), con.get("port"), con.get("pasword"));
+ this.model.connect(con.get("serverAddress"), con.get("port"), con.get("password"));
}
else {
- view.showWarning("Your server address or nick was empty!");
+ view.showWarning("Your server address was empty!");
}
}
}
@@ -52,10 +52,10 @@ public void sendMsg(String msg, String channel) {
* @param port Server's port
* @param password Server's password
*/
- public void connect(String serverAddress, String nick, String port, String password) {
+ public void connect(String serverAddress, String port, String password) {
IrcGateway igw;
try {
- igw = new IrcGateway(this, serverAddress, nick, port, password);
+ igw = new IrcGateway(this, serverAddress, confs.getUserData("nick"), port, password);
new Thread(igw).start();
connections.add(igw);
if(!confs.findServer(serverAddress)) {
@@ -173,8 +173,7 @@ public void leaveChannel(String channel) {
/**
* Sets user data to confs
- * @param key Key to user's data
- * @param value User's data
+ * @param userData User's data
*/
public void setUserData(HashMap<String, String> userData) {
HashMap<String, String> data = new HashMap<String, String>();
@@ -241,7 +240,7 @@ public IrcGateway getGateway(String serverName) {
* Kicks user with given nick out of the given channel in given server
* @param server Server of the wanted channel
* @param channel Channel from where user will be kicked
- * @param nick U
+ * @param nick User's nick
*/
public void kick(String server, String channel, String nick) {
// Get the correct connection
@@ -256,6 +255,12 @@ public void kick(String server, String channel, String nick) {
}
}
+ /**
+ * Bans user with given nick out of the given channel in given server
+ * @param server Server of the wanted channel
+ * @param channel Channel from where user will be kicked
+ * @param nick User's nick
+ */
public void ban(String server, String channel, String nick) {
// Get the correct connection
IrcGateway gw = this.getGateway(server);
@@ -330,11 +335,18 @@ public SwircConfs getConfs() {
return confs;
}
+ /**
+ * Notifies observers that can't connect to server
+ */
public void cantConnect() {
this.setChanged();
this.notifyObservers("cant connect");
}
+ /**
+ * Notifies observers that has connected to server
+ * @param serverAddress server where is connected
+ */
public void connectedServer(String serverAddress) {
this.setChanged();
this.notifyObservers("ConnectedServer:" + serverAddress);
@@ -270,7 +270,7 @@ public void addServerView(String serverAddress) {
HashMap<String,String> connectDetails = new HashMap<String,String>();
if(cd.isConfirmed()) {
connectDetails.put("serverAddress", cd.getServerAddress());
- connectDetails.put("nick", cd.getNick());
+ //connectDetails.put("nick", cd.getNick());
connectDetails.put("port", cd.getPort());
connectDetails.put("password", cd.getPassword());
return connectDetails;

0 comments on commit 6b9d24d

Please sign in to comment.