View | Details | Raw Unified | Return to bug 192757 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java (-4 / +5 lines)
Lines 9-14 Link Here
9
 *    Composent, Inc. - initial API and implementation
9
 *    Composent, Inc. - initial API and implementation
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762, 197329
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 192762, 197329
11
 *    Abner Ballardo <modlost@modlost.net> - bug 192756
11
 *    Abner Ballardo <modlost@modlost.net> - bug 192756
12
 *    Cagatay Calli <ccalli@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=192757
12
 ******************************************************************************/
13
 ******************************************************************************/
13
package org.eclipse.ecf.presence.ui.chatroom;
14
package org.eclipse.ecf.presence.ui.chatroom;
14
15
Lines 1053-1059 Link Here
1053
						Messages.ChatRoomManagerView_NOT_CONNECTED_MESSAGE);
1054
						Messages.ChatRoomManagerView_NOT_CONNECTED_MESSAGE);
1054
				return;
1055
				return;
1055
			} else {
1056
			} else {
1056
				String output = processForCommand(chatRoomContainer, text);
1057
				String output = processForCommand(chatRoomContainer, localUserName, text);
1057
				if (output != null) sendMessageLine(output);
1058
				if (output != null) sendMessageLine(output);
1058
			}
1059
			}
1059
		}
1060
		}
Lines 1182-1197 Link Here
1182
					Messages.ChatRoomManagerView_NOT_CONNECTED_MESSAGE);
1183
					Messages.ChatRoomManagerView_NOT_CONNECTED_MESSAGE);
1183
			return;
1184
			return;
1184
		} else {
1185
		} else {
1185
			String output = processForCommand(null, text);
1186
			String output = processForCommand(null, localUserName, text);
1186
			if (output != null) sendMessageLine(output);
1187
			if (output != null) sendMessageLine(output);
1187
		}
1188
		}
1188
	}
1189
	}
1189
1190
1190
	protected String processForCommand(IChatRoomContainer chatRoomContainer,
1191
	protected String processForCommand(IChatRoomContainer chatRoomContainer,
1191
			String text) {
1192
			String username, String text) {
1192
		IChatRoomCommandListener l = commandListener;
1193
		IChatRoomCommandListener l = commandListener;
1193
		if (l != null)
1194
		if (l != null)
1194
			return l.handleCommand(chatRoomContainer, text);
1195
			return l.handleCommand(chatRoomContainer, username, text);
1195
		else
1196
		else
1196
			return text;
1197
			return text;
1197
	}
1198
	}
(-)src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerUI.java (-2 / +3 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Composent, Inc. - initial API and implementation
9
 *    Composent, Inc. - initial API and implementation
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329
11
 *    Cagatay Calli <ccalli@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=192757
11
 *****************************************************************************/
12
 *****************************************************************************/
12
package org.eclipse.ecf.presence.ui.chatroom;
13
package org.eclipse.ecf.presence.ui.chatroom;
13
14
Lines 84-93 Link Here
84
	 * (non-Javadoc)
85
	 * (non-Javadoc)
85
	 * 
86
	 * 
86
	 * @see org.eclipse.ecf.presence.ui.chatroom.IChatRoomCommandListener#handleCommand(org.eclipse.ecf.presence.chatroom.IChatRoomContainer,
87
	 * @see org.eclipse.ecf.presence.ui.chatroom.IChatRoomCommandListener#handleCommand(org.eclipse.ecf.presence.chatroom.IChatRoomContainer,
87
	 *      java.lang.String)
88
	 *      java.lang.String, java.lang.String)
88
	 */
89
	 */
89
	public String handleCommand(IChatRoomContainer chatRoomContainer,
90
	public String handleCommand(IChatRoomContainer chatRoomContainer,
90
			String inputLine) {
91
			String username, String inputLine) {
91
		return inputLine;
92
		return inputLine;
92
	}
93
	}
93
	
94
	
(-)src/org/eclipse/ecf/presence/ui/chatroom/IChatRoomCommandListener.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/****************************************************************************
1
/****************************************************************************
2
 * Copyright (c) 2004 Composent, Inc. and others.
2
 * Copyright (c) 2004, 2007 Composent, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Composent, Inc. - initial API and implementation
9
 *    Composent, Inc. - initial API and implementation
10
 *    Cagatay Calli <ccalli@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=192757
10
 *****************************************************************************/
11
 *****************************************************************************/
11
12
12
package org.eclipse.ecf.presence.ui.chatroom;
13
package org.eclipse.ecf.presence.ui.chatroom;
Lines 29-34 Link Here
29
	 *            the IChatRoomContainer instance that is to receive the input
30
	 *            the IChatRoomContainer instance that is to receive the input
30
	 *            line. If <code>null</code> then the input line is intended
31
	 *            line. If <code>null</code> then the input line is intended
31
	 *            for the IChatRoomManager itself.
32
	 *            for the IChatRoomManager itself.
33
	 * @param username name of the command owner (local username)
32
	 * @param inputLine
34
	 * @param inputLine
33
	 *            the input line holding the prospective command.
35
	 *            the input line holding the prospective command.
34
	 * @return <code>null</code> if the command has been processed and should
36
	 * @return <code>null</code> if the command has been processed and should
Lines 36-41 Link Here
36
	 *         the inputLine should be forwarded on as chat.
38
	 *         the inputLine should be forwarded on as chat.
37
	 */
39
	 */
38
	public String handleCommand(IChatRoomContainer chatRoomContainer,
40
	public String handleCommand(IChatRoomContainer chatRoomContainer,
39
			String inputLine);
41
			String username, String inputLine);
40
42
41
}
43
}
(-)src/org/eclipse/ecf/internal/irc/ui/IRCUI.java (-4 / +82 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *    Composent, Inc. - initial API and implementation
9
 *    Composent, Inc. - initial API and implementation
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 197329
11
 *    Cagatay Calli <ccalli@gmail.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=192757
11
 *****************************************************************************/
12
 *****************************************************************************/
12
13
13
package org.eclipse.ecf.internal.irc.ui;
14
package org.eclipse.ecf.internal.irc.ui;
Lines 16-28 Link Here
16
import java.net.URISyntaxException;
17
import java.net.URISyntaxException;
17
import java.util.StringTokenizer;
18
import java.util.StringTokenizer;
18
19
20
import org.eclipse.ecf.core.ContainerFactory;
19
import org.eclipse.ecf.core.IContainer;
21
import org.eclipse.ecf.core.IContainer;
20
import org.eclipse.ecf.core.identity.ID;
22
import org.eclipse.ecf.core.identity.ID;
23
import org.eclipse.ecf.core.identity.IDFactory;
24
import org.eclipse.ecf.core.security.ConnectContextFactory;
25
import org.eclipse.ecf.core.security.IConnectContext;
21
import org.eclipse.ecf.core.util.IExceptionHandler;
26
import org.eclipse.ecf.core.util.IExceptionHandler;
22
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
27
import org.eclipse.ecf.presence.chatroom.IChatRoomContainer;
23
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
28
import org.eclipse.ecf.presence.chatroom.IChatRoomManager;
24
import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI;
29
import org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI;
25
import org.eclipse.ecf.presence.ui.chatroom.IMessageRenderer;
30
import org.eclipse.ecf.presence.ui.chatroom.IMessageRenderer;
31
import org.eclipse.ecf.ui.actions.AsynchContainerConnectAction;
32
import org.eclipse.ecf.ui.util.PasswordCacheHelper;
26
import org.eclipse.jface.dialogs.MessageDialog;
33
import org.eclipse.jface.dialogs.MessageDialog;
27
import org.eclipse.osgi.util.NLS;
34
import org.eclipse.osgi.util.NLS;
28
35
Lines 36-41 Link Here
36
	private static final String COMMAND_PREFIX = "/"; //$NON-NLS-1$
43
	private static final String COMMAND_PREFIX = "/"; //$NON-NLS-1$
37
44
38
	private static final String COMMAND_DELIM = " "; //$NON-NLS-1$
45
	private static final String COMMAND_DELIM = " "; //$NON-NLS-1$
46
	
47
	String connectID;
48
	String password;
39
49
40
	/**
50
	/**
41
	 * @param container
51
	 * @param container
Lines 80-86 Link Here
80
	 * @see org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI#handleCommand(java.lang.String)
90
	 * @see org.eclipse.ecf.presence.ui.chatroom.ChatRoomManagerUI#handleCommand(java.lang.String)
81
	 */
91
	 */
82
	public String handleCommand(IChatRoomContainer chatRoomContainer,
92
	public String handleCommand(IChatRoomContainer chatRoomContainer,
83
			String inputLine) {
93
			String username, String inputLine) {
84
		if ((inputLine != null && inputLine.startsWith(COMMAND_PREFIX))) {
94
		if ((inputLine != null && inputLine.startsWith(COMMAND_PREFIX))) {
85
			StringTokenizer st = new StringTokenizer(inputLine, COMMAND_DELIM);
95
			StringTokenizer st = new StringTokenizer(inputLine, COMMAND_DELIM);
86
			int countTokens = st.countTokens();
96
			int countTokens = st.countTokens();
Lines 91-101 Link Here
91
			while (command.startsWith(COMMAND_PREFIX))
101
			while (command.startsWith(COMMAND_PREFIX))
92
				command = command.substring(1);
102
				command = command.substring(1);
93
			// Look at first one and switch
103
			// Look at first one and switch
94
			String[] args = new String[tokens.length - 1];
104
			final String[] args = new String[tokens.length - 1];
95
			System.arraycopy(tokens, 1, args, 0, tokens.length - 1);
105
			System.arraycopy(tokens, 1, args, 0, tokens.length - 1);
106
			
107
			// SERVER can be done from root or channel
108
			if (command.equalsIgnoreCase(Messages.IRCUI_SERVER_COMMAND)) {
109
				int size = args.length;
110
				for(int i=0;i<size;i++){
111
					if(i==0){
112
						connectID = getConnectID(args[i]);
113
					}
114
					else if(i==1){
115
						password = args[i];
116
					}
117
				}
118
				
119
				if(connectID.indexOf("@") == -1){
120
					String nick = username;
121
					connectID = nick + "@" + connectID;
122
				}
123
				
124
				try {
125
					IContainer container = ContainerFactory.getDefault()
126
					.createContainer(Messages.IRCUI_ECF_IRC_CONTAINER_NAME);
127
					
128
					IConnectContext connectContext = ConnectContextFactory
129
					.createPasswordConnectContext(connectID);
130
					
131
					targetID = IDFactory.getDefault().createID(
132
							container.getConnectNamespace(), connectID);
133
					
134
					IChatRoomManager manager = (IChatRoomManager) container
135
					.getAdapter(IChatRoomManager.class);
136
137
					IRCUI ui = new IRCUI(container, manager, null);
138
					ui.showForTarget(targetID);
139
					// If it's not already connected, then we connect this new container
140
					if (!ui.isContainerConnected()) {
141
						new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {
142
							public void run() {
143
								cachePassword(getPasswordKeyFromUserName(connectID), password);
144
							}}).run();
145
					}
146
				} catch (Exception e) {
147
					e.printStackTrace();
148
				}
149
				
150
				return null;
151
			}
96
			// JOIN can be done from root or channel
152
			// JOIN can be done from root or channel
97
			if (command.equalsIgnoreCase(Messages.IRCUI_JOIN_COMMAND)) {
153
			if (command.equalsIgnoreCase(Messages.IRCUI_JOIN_COMMAND)) {
98
				chatroomview.joinRoom(manager.getChatRoomInfo(args[0]), (args.length > 1)?args[1]:"");
154
				chatroomview.joinRoom(manager.getChatRoomInfo(args[0]), (args.length > 1)?args[1]:""); //$NON-NLS-1$
99
				return null;
155
				return null;
100
			}
156
			}
101
			// QUIT can be done from root or channel
157
			// QUIT can be done from root or channel
Lines 122-129 Link Here
122
		return inputLine;
178
		return inputLine;
123
179
124
	}
180
	}
125
	
181
126
	protected IMessageRenderer getDefaultMessageRenderer() {
182
	protected IMessageRenderer getDefaultMessageRenderer() {
127
		return new IRCMessageRenderer();
183
		return new IRCMessageRenderer();
128
	}
184
	}
185
	
186
	// TODO Share these methods from a common class between IRCConnectWizardPage and IRCUI
187
	String getConnectID(String connectText) {
188
		String clean = connectText.replaceAll("#","");
189
		return clean;
190
	}
191
	
192
	String getPasswordKeyFromUserName(String username) {
193
		if (username == null || username.equals("")) return null;
194
		else {
195
			int slashIndex = username.indexOf("/");
196
			if (slashIndex == -1) return username;
197
			else return username.substring(0,username.indexOf("/"));
198
		}
199
	}
200
	
201
	protected void cachePassword(final String connectID, String password) {
202
		if (password != null && !password.equals("")) {
203
			PasswordCacheHelper pwStorage = new PasswordCacheHelper(connectID);
204
			pwStorage.savePassword(password);
205
		}
206
	}
129
}
207
}
(-)src/org/eclipse/ecf/internal/irc/ui/messages.properties (+2 lines)
Lines 1-6 Link Here
1
IRCHyperlink_EXCEPTION_IRC_HYPERLINK=Exception in IRC hyperlink open
1
IRCHyperlink_EXCEPTION_IRC_HYPERLINK=Exception in IRC hyperlink open
2
IRCConnectWizardPage_CONNECTID_LABEL=Connect ID:
2
IRCConnectWizardPage_CONNECTID_LABEL=Connect ID:
3
IRCConnectWizardPage_PASSWORD_LABEL=Password:
3
IRCConnectWizardPage_PASSWORD_LABEL=Password:
4
IRCUI_SERVER_COMMAND=SERVER
4
IRCUI_JOIN_COMMAND=JOIN
5
IRCUI_JOIN_COMMAND=JOIN
5
IRCUI_QUIT_COMMAND=QUIT
6
IRCUI_QUIT_COMMAND=QUIT
6
IRCUI_DISCONNECT_CONFIRM_TITLE=Disconnect from Server
7
IRCUI_DISCONNECT_CONFIRM_TITLE=Disconnect from Server
Lines 8-13 Link Here
8
IRCUI_PART_COMMAND=PART
9
IRCUI_PART_COMMAND=PART
9
IRCUI_DEPART_CONFIRM_TITLE=Depart from IRC Channel
10
IRCUI_DEPART_CONFIRM_TITLE=Depart from IRC Channel
10
IRCUI_DEPART_CONFIRM_MESSAGE=Depart from IRC channel {0}?
11
IRCUI_DEPART_CONFIRM_MESSAGE=Depart from IRC channel {0}?
12
IRCUI_ECF_IRC_CONTAINER_NAME=ecf.irc.irclib
11
IRCConnectWizardPage_WIZARD_PAGE_TITLE=IRC Connection Wizard
13
IRCConnectWizardPage_WIZARD_PAGE_TITLE=IRC Connection Wizard
12
IRCConnectWizardPage_WIZARD_PAGE_DESCRIPTION=Specify a user and IRC server to connect to.
14
IRCConnectWizardPage_WIZARD_PAGE_DESCRIPTION=Specify a user and IRC server to connect to.
13
IRCConnectWizardPage_STATUS_MESSAGE_EMPTY=A valid connect ID must be specified.
15
IRCConnectWizardPage_STATUS_MESSAGE_EMPTY=A valid connect ID must be specified.
(-)src/org/eclipse/ecf/internal/irc/ui/Messages.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/****************************************************************************
1
/****************************************************************************
2
 * Copyright (c) 2004 Composent, Inc. and others.
2
 * Copyright (c) 2004, 2007 Composent, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 32-37 Link Here
32
	public static String IRCUI_DEPART_CONFIRM_TITLE;
32
	public static String IRCUI_DEPART_CONFIRM_TITLE;
33
	public static String IRCUI_DISCONNECT_CONFIRM_MESSAGE;
33
	public static String IRCUI_DISCONNECT_CONFIRM_MESSAGE;
34
	public static String IRCUI_DISCONNECT_CONFIRM_TITLE;
34
	public static String IRCUI_DISCONNECT_CONFIRM_TITLE;
35
	public static String IRCUI_ECF_IRC_CONTAINER_NAME;
36
	public static String IRCUI_SERVER_COMMAND;
35
	public static String IRCUI_JOIN_COMMAND;
37
	public static String IRCUI_JOIN_COMMAND;
36
	public static String IRCUI_PART_COMMAND;
38
	public static String IRCUI_PART_COMMAND;
37
	public static String IRCUI_QUIT_COMMAND;
39
	public static String IRCUI_QUIT_COMMAND;

Return to bug 192757