Added:
branches/irc_chat_tab/src/chat/
branches/irc_chat_tab/src/chat/__init__.py
branches/irc_chat_tab/src/chat/chatpage.py
branches/irc_chat_tab/src/chat/constants.py
branches/irc_chat_tab/src/chat/irc_logbot.py
branches/irc_chat_tab/src/chat/irc_server.py
branches/irc_chat_tab/src/chat/page_setup.py
branches/irc_chat_tab/src/htdocs/files/pjirc/
branches/irc_chat_tab/src/htdocs/files/pjirc/IRCApplet.class
branches/irc_chat_tab/src/htdocs/files/pjirc/english.lng
branches/irc_chat_tab/src/htdocs/files/pjirc/irc.cab
branches/irc_chat_tab/src/htdocs/files/pjirc/irc.jar
branches/irc_chat_tab/src/htdocs/files/pjirc/pixx-english.lng
branches/irc_chat_tab/src/htdocs/files/pjirc/pixx.cab
branches/irc_chat_tab/src/htdocs/files/pjirc/pixx.jar
branches/irc_chat_tab/src/htdocs/files/pjirc/securedirc.cab
branches/irc_chat_tab/src/htdocs/files/snirc/
branches/irc_chat_tab/src/htdocs/files/snirc/ChannelJoinPartStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/ChannelJoinPartStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/Chat$1.class
branches/irc_chat_tab/src/htdocs/files/snirc/Chat$2.class
branches/irc_chat_tab/src/htdocs/files/snirc/Chat.class
branches/irc_chat_tab/src/htdocs/files/snirc/Chat.java
branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface$1.class
branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface.class
branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface.java
(contents, props changed)
branches/irc_chat_tab/src/htdocs/files/snirc/Command.class
branches/irc_chat_tab/src/htdocs/files/snirc/Command.java
branches/irc_chat_tab/src/htdocs/files/snirc/CommandProcessingStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/CommandProcessingStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/DefaultProcess.class
branches/irc_chat_tab/src/htdocs/files/snirc/DefaultProcess.java
branches/irc_chat_tab/src/htdocs/files/snirc/EntryDialog.class
branches/irc_chat_tab/src/htdocs/files/snirc/EntryDialog.java
branches/irc_chat_tab/src/htdocs/files/snirc/IRCConnection.class
branches/irc_chat_tab/src/htdocs/files/snirc/IRCConnection.java
branches/irc_chat_tab/src/htdocs/files/snirc/MessageStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/MessageStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/ModeStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/ModeStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/NamesNumericsStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/NamesNumericsStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/NickCommandsStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/NickCommandsStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/NoticeStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/NoticeStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/Pair.class
branches/irc_chat_tab/src/htdocs/files/snirc/Pair.java
branches/irc_chat_tab/src/htdocs/files/snirc/PrivmsgStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/PrivmsgStrategy.java
branches/irc_chat_tab/src/htdocs/files/snirc/ScrollableOutputPanel.class
branches/irc_chat_tab/src/htdocs/files/snirc/ScrollableOutputPanel.java
branches/irc_chat_tab/src/htdocs/files/snirc/SimpleNumericsStrategy.class
branches/irc_chat_tab/src/htdocs/files/snirc/SimpleNumericsStrategy.java
branches/irc_chat_tab/src/templates/chat/
branches/irc_chat_tab/src/templates/chat/chatpage.ezt
Modified:
branches/irc_chat_tab/src/demetrius/constants.py
branches/irc_chat_tab/src/demetrius/page_setup.py
branches/irc_chat_tab/src/main/codesite.py
branches/irc_chat_tab/src/main/codesiteserver.py
branches/irc_chat_tab/src/templates/demetrius/maintabs.ezt
Log:
squashed commit of all work done on irc chat tab. very basic
functionality is working
Added: branches/irc_chat_tab/src/chat/__init__.py
==============================================================================
Added: branches/irc_chat_tab/src/chat/chatpage.py
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/chat/chatpage.py Fri Jun 20 07:16:16 2008
@@ -0,0 +1,39 @@
+import sys
+
+from common import post
+from common import http
+from common import ezt_google
+
+import framework.helpers
+
+from demetrius import constants
+from demetrius import pageclasses
+from demetrius import helpers
+from demetrius import permissions
+
+import chat.constants
+
+class ChatPage(pageclasses.DemetriusPage):
+
+ _PAGE_TEMPLATE = '/chat/chatpage.ezt'
+ _MAIN_TAB_MODE = constants.MAIN_TAB_CHAT
+
+ def GatherPageData(self, request, req_info):
+ if req_info.logged_in_user_id is not None:
+
+ #number_of_projects = req_info.logged_in_user.member_of_projects_size()
+
+ page_data = {
+ # chat username for "us...@gmail.com" is "user1"
+ 'chat_username': req_info.logged_in_user.display_name.split('@')[0]
+ }
+
+ else:
+ page_data = {}
+
+ return page_data
+
+
+
+
+
\ No newline at end of file
Added: branches/irc_chat_tab/src/chat/constants.py
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/chat/constants.py Fri Jun 20 07:16:16 2008
@@ -0,0 +1,6 @@
+
+BOT_NICKNAME = 'lbot'
+
+CHANNEL = 'foobar'
+
+CHAT_PAGE_URL = '/chat'
Added: branches/irc_chat_tab/src/chat/irc_logbot.py
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/chat/irc_logbot.py Fri Jun 20 07:16:16 2008
@@ -0,0 +1,144 @@
+# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
+# See LICENSE for details.
+
+
+"""An example IRC log bot - logs a channel's events to a file.
+
+If someone says the bot's name in the channel followed by a ':',
+e.g.
+
+ <foo> logbot: hello!
+
+the bot will reply:
+
+ <logbot> foo: I am a log bot
+
+Run this script with two arguments, the channel name the bot should
+connect to, and file to log to, e.g.:
+
+ $ python ircLogBot.py test test.log
+
+will log channel #test to the file 'test.log'.
+"""
+
+import time, sys
+
+from twisted.words.protocols import irc
+from twisted.internet import reactor, protocol
+from twisted.python import log
+
+import constants
+
+class MessageLogger:
+ """
+ An independent logger class (because separation of application
+ and protocol logic is a good thing).
+ """
+ def __init__(self, file):
+ self.file = file
+
+ def log(self, message):
+ """Write a message to the file."""
+ timestamp = time.strftime("[%H:%M:%S]", time.localtime(time.time()))
+ self.file.write('%s %s\n' % (timestamp, message))
+ self.file.flush()
+
+ def close(self):
+ self.file.close()
+
+
+class LogBot(irc.IRCClient):
+ """A logging IRC bot."""
+
+ nickname = constants.BOT_NICKNAME
+
+ def connectionMade(self):
+ irc.IRCClient.connectionMade(self)
+ self.logger = MessageLogger(open(self.factory.filename, "a"))
+ self.logger.log("[connected at %s]" %
+ time.asctime(time.localtime(time.time())))
+
+ def connectionLost(self, reason):
+ irc.IRCClient.connectionLost(self, reason)
+ self.logger.log("[disconnected at %s]" %
+ time.asctime(time.localtime(time.time())))
+ self.logger.close()
+
+
+ # callbacks for events
+
+ def signedOn(self):
+ """Called when bot has succesfully signed on to server."""
+ self.join(self.factory.channel)
+
+ def joined(self, channel):
+ """This will get called when the bot joins the channel."""
+ self.logger.log("[I have joined %s]" % channel)
+
+ def privmsg(self, user, channel, msg):
+ """This will get called when the bot receives a message."""
+ user = user.split('!', 1)[0]
+ self.logger.log("<%s> %s" % (user, msg))
+
+ # Check to see if they're sending me a private message
+ if channel == self.nickname:
+ msg = "It isn't nice to whisper! Play nice with the group."
+ self.msg(user, msg)
+ return
+
+ # Otherwise check to see if it is a message directed at me
+ if msg.startswith(self.nickname + ":"):
+ msg = "%s: I am a log bot" % user
+ self.msg(channel, msg)
+ self.logger.log("<%s> %s" % (self.nickname, msg))
+
+ def action(self, user, channel, msg):
+ """This will get called when the bot sees someone do an action."""
+ user = user.split('!', 1)[0]
+ self.logger.log("* %s %s" % (user, msg))
+
+ # irc callbacks
+
+ def irc_NICK(self, prefix, params):
+ """Called when an IRC user changes their nickname."""
+ old_nick = prefix.split('!')[0]
+ new_nick = params[0]
+ self.logger.log("%s is now known as %s" % (old_nick, new_nick))
+
+
+class LogBotFactory(protocol.ClientFactory):
+ """A factory for LogBots.
+
+ A new protocol instance will be created each time we connect to
the server.
+ """
+
+ # the class of the protocol to build when new connection is made
+ protocol = LogBot
+
+ def __init__(self, channel, filename):
+ self.channel = channel
+ self.filename = filename
+
+ def clientConnectionLost(self, connector, reason):
+ """If we get disconnected, reconnect to server."""
+ connector.connect()
+
+ def clientConnectionFailed(self, connector, reason):
+ print "connection failed:", reason
+ #reactor.stop()
+
+def connect():
+
+ # initialize logging
+ #log.startLogging(sys.stdout)
+
+ # create factory protocol and application
+ f = LogBotFactory(constants.CHANNEL, '../logs/irclog.log')
+
+ # connect factory to this host and port
+ reactor.connectTCP("localhost", 6667, f)
+
+
+if __name__ == '__main__':
+ print 'This is not meant to be run as a standalone program, exiting'
+ sys.exit(1)
Added: branches/irc_chat_tab/src/chat/irc_server.py
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/chat/irc_server.py Fri Jun 20 07:16:16 2008
@@ -0,0 +1,175 @@
+#! /usr/bin/env python
+
+from time import ctime
+
+from twisted import copyright
+
+from twisted.python import failure
+
+from twisted.internet import reactor, defer
+
+from twisted.cred import checkers, portal, credentials
+from twisted.cred import credentials, error as crederror
+from twisted.cred.checkers import ICredentialsChecker
+
+from twisted import words
+from twisted.words import iwords, ewords
+from twisted.words.service import InMemoryWordsRealm, IRCFactory,
IRCUser, Group
+from twisted.words.protocols import irc
+
+from zope.interface import implements
+
+
+NICKSERV = 'NickServ!NickServ@services'
+class LonghouseIRCServer ( IRCUser ):
+
+ def connectionMade(self):
+ self.irc_PRIVMSG = self.irc_NICKSERV_PRIVMSG
+
+ def irc_NICK(self, prefix, params):
+
+ try:
+ self.logout()
+ except:
+ pass
+
+ try:
+ nickname = params[0].decode(self.encoding)
+ except UnicodeDecodeError:
+ self.privmsg(
+ NICKSERV,
+ nickname,
+ 'Your nickname is cannot be decoded. Please use ASCII
or UTF-8.')
+ self.transport.loseConnection()
+ return
+
+ if self.password is None:
+ self.password = ''
+
+ password = self.password
+
+ self.password = None
+ self.logInAs(nickname, password)
+ pass
+
+
+ def _cbLogin(self, (iface, avatar, logout)):
+ """Had to be overridden from the superclass because of a bug."""
+
+ assert iface is iwords.IUser, "Realm is buggy, got %r" % (iface,)
+
+ # Let them send messages to the world
+ try:
+ del self.irc_PRIVMSG
+ except AttributeError:
+ # they were signed in before
+ pass
+
+ self.avatar = avatar
+ self.logout = logout
+ self.realm = avatar.realm
+ self.hostname = self.realm.name
+
+ info = {
+ "serviceName": self.hostname,
+ "serviceVersion": copyright.version,
+ "creationDate": ctime(), # XXX
+ }
+ for code, text in self._welcomeMessages:
+ self.sendMessage(code, text % info)
+
+
+ def _ebLogin(self, err, nickname):
+ if err.check(ewords.AlreadyLoggedIn):
+ self.privmsg(
+ NICKSERV,
+ nickname,
+ "%s is already logged in.")
+ elif err.check(crederror.UnauthorizedLogin):
+ self.privmsg(
+ NICKSERV,
+ nickname,
+ "Login failed.")
+ else:
+ #log.msg("Unhandled error during login:")
+ #log.err(err)
+ print "Unhandled error during login:"
+ print err
+ self.privmsg(
+ NICKSERV,
+ nickname,
+ "Server error during login.")
+ #self.transport.loseConnection()
+
+
+class LonghouseIRCFactory( IRCFactory ):
+ protocol = LonghouseIRCServer
+
+def getLonghouseIRCFactory():
+ realm = LonghouseIRCRealm('longhouse_irc')
+ checker = LonghouseCredChecker()
+ p = portal.Portal(realm, [checker])
+
+ factory = LonghouseIRCFactory(realm, p)
+ return factory
+
+
+class LonghouseCredChecker:
+ implements(ICredentialsChecker)
+
+ credentialInterfaces = (credentials.IUsernamePassword,
+ credentials.IUsernameHashedPassword)
+
+ def __init__(self, **users):
+ self.users = users
+
+ def addUser(self, username, password):
+ self.users[username] = password
+
+ def _cbPasswordMatch(self, matched, username):
+ if matched:
+ return username
+ else:
+ return failure.Failure(crederror.UnauthorizedLogin())
+
+ def requestAvatarId(self, credentials):
+ #if credentials.username in self.users:
+ # print 'checking creds:', dir(credentials)
+ # print credentials.username, credentials.password
+ # return defer.maybeDeferred(
+ # credentials.checkPassword,
+ # self.users[credentials.username]).addCallback(
+ # self._cbPasswordMatch, str(credentials.username))
+ #else:
+ # #return defer.fail(error.UnauthorizedLogin())
+ # self.addUser(credentials.username, 'changeme')
+ # return credentials.username
+ return credentials.username
+
+
+
+class LonghouseIRCRealm( InMemoryWordsRealm ):
+
+ def __init__(self, *a, **kw):
+ super(LonghouseIRCRealm, self).__init__(*a, **kw)
+ self.createGroupOnRequest = True
+
+ def groupFactory(self, name):
+ group = Group(name)
+ self.groups[name] = group
+ return group
+
+
+if __name__ == '__main__':
+ print 'blah'
+ #import sys, os
+ #
+ #realm = LonghouseIRCRealm('longhouse_irc')
+ #checker = LonghouseCredChecker()
+ #
+ #portal = portal.Portal(realm, [checker])
+ #
+ #factory = LonghouseIRCFactory(realm, portal)
+ #
+ #reactor.listenTCP(6667, factory)
+ #reactor.run()
Added: branches/irc_chat_tab/src/chat/page_setup.py
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/chat/page_setup.py Fri Jun 20 07:16:16 2008
@@ -0,0 +1,49 @@
+#! /usr/bin/env python
+#
+# Copyright 2007 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+This file registers urls chat pages
+"""
+
+from twisted.python import log
+
+from common import pageclasses
+import framework.helpers
+from chat import constants
+from chat import chatpage
+
+
+class PageSetup(framework.helpers.AbstractPageSetup):
+ """This class configures the chat pages."""
+
+ # TODO: we don't need dit_persist, but we might want a chat_persist
+ def __init__(self, server, conn_pool,
+ demetrius_persist, dit_persist, worktable, universal_ezt_data):
+ self.server = server
+ self.conn_pool = conn_pool
+ self.demetrius_persist = demetrius_persist
+ self.dit_persist = dit_persist
+ self.worktable = worktable
+ self.universal_ezt_data = universal_ezt_data.copy()
+
+ def RegisterPages(self):
+
+ log.msg("REGISTERING CHAT PAGE")
+ chat_page = chatpage.ChatPage(
+ self.conn_pool, self.demetrius_persist, self.universal_ezt_data)
+ self._SetupProjectPage(
+ chat_page.Handler, constants.CHAT_PAGE_URL)
+ log.msg("CHAT PAGE READY")
Modified: branches/irc_chat_tab/src/demetrius/constants.py
==============================================================================
--- branches/irc_chat_tab/src/demetrius/constants.py (original)
+++ branches/irc_chat_tab/src/demetrius/constants.py Fri Jun 20
07:16:16 2008
@@ -42,6 +42,7 @@
MAIN_TAB_SOURCE = 't4'
MAIN_TAB_ADMIN = 't5'
MAIN_TAB_WIKI = 't6'
+MAIN_TAB_CHAT = 't7'
# CSS classes for the <body> element to make each of admin tabs highlight.
ADMIN_TAB_META = 'st1'
Modified: branches/irc_chat_tab/src/demetrius/page_setup.py
==============================================================================
--- branches/irc_chat_tab/src/demetrius/page_setup.py (original)
+++ branches/irc_chat_tab/src/demetrius/page_setup.py Fri Jun 20
07:16:16 2008
@@ -148,8 +148,6 @@
constants.ADMIN_DOWNLOADS_PAGE_URL)
self._SetupProjectPage(placeholder_page.Handler,
constants.ADMIN_WIKI_PAGE_URL)
-
- # TODO: register per project deferred pages here
def _RegisterSiteHandlers(self):
"""Register page and form handlers that aren't associated with projects."""
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/IRCApplet.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpt89HYK
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpeKLxdB differ
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/english.lng
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/pjirc/english.lng Fri Jun 20
07:16:16 2008
@@ -0,0 +1,92 @@
+#
+# This java file is a part of the
+#
+# - Plouf's Java IRC Client -
+#
+# Copyright (C) 2004 Philippe Detournay
+#
+# This file is licensed under the GPL license
+#
+# All contacts : thep...@yahoo.com
+#
+#
+# Syntax :
+# Comments begin with the # character. This character must be the
first character of the line.
+# A data line has three parts : the data id, the data id
description, the data string.
+# - Data id : An hexadecimal figure identifying the string.
+# - Data description : Begins by [ and ends by ]. The description
is not parsed and
+# can be any string.
+# - Data string : The string itself. Parameters are specified
using the %i syntax.
+#
+# Trailing spaces can be added using the \s escape character.
+
+0001 [INTERPRETOR_NOT_ON_CHANNEL] Not on a channel
+0002 [INTERPRETOR_UNKNOWN_DCC] %1 : unknown dcc subcommand
+0003 [INTERPRETOR_INSUFFICIENT_PARAMETERS] %1 : insufficient parameters
+0004 [INTERPRETOR_BAD_CONTEXT] %1 : unable to perform in current context
+0005 [INTERPRETOR_CANNOT_CTCP_IN_DCCCHAT] Cannot send CTCP codes via
DCC Chat
+0006 [INTERPRETOR_UNKNOWN_CONFIG] %1 : unknown config subcommand
+0007 [INTERPRETOR_TIMESTAMP_ON] Timestamp enabled
+0008 [INTERPRETOR_TIMESTAMP_OFF] Timestamp disabled
+0009 [INTERPRETOR_SMILEYS_ON] Graphical smileys enabled
+000a [INTERPRETOR_SMILEYS_OFF] Graphical smileys disabled
+000b [INTERPRETOR_IGNORE_ON] Now ignoring %1
+000c [INTERPRETOR_IGNORE_OFF] Not ignoring %1 anymore
+000d [INTERPRETOR_MULTISERVER_DISABLED] Multiserver support is disabled
+
+0101 [DCC_WAITING_INCOMING] Waiting for incoming connection...
+0102 [DCC_UNABLE_TO_OPEN_CONNECTION] Unable to open connection : %1
+0103 [DCC_CONNECTION_ESTABLISHED] DCC Connection established
+0104 [DCC_CONNECTION_CLOSED] Connection closed
+0105 [DCC_ERROR] Error : %1
+0106 [DCC_UNABLE_TO_SEND_TO] %1 : unable to send to %2
+0107 [DCC_BAD_CONTEXT] Unable to execute command from current context
+0108 [DCC_NOT_CONNECTED] Not connected
+0109 [DCC_UNABLE_PASSIVE_MODE] Unable to initialize passive mode
+010a [CTCP_PING_REPLY] [%1 PING reply] : %2 seconds
+010b [DCC_STREAM_CLOSED] Stream closed
+
+0201 [IDENT_FAILED_LAUNCH] Failed to launch Ident server : %1
+0202 [IDENT_REQUEST] Ident request from %1
+0203 [IDENT_ERROR] Error occurred
+0204 [IDENT_REPLIED] Replied %1
+0205 [IDENT_DEFAULT_USER] default user
+0206 [IDENT_NO_USER] No user for request
+0207 [IDENT_RUNNING_ON_PORT] Ident server running on port %1
+0208 [IDENT_LEAVING] Ident server leaving : %1
+0209 [IDENT_NONE] none
+020a [IDENT_UNKNOWN] unknown
+020b [IDENT_UNDEFINED] Undefined result
+
+0301 [FILE_SAVEAS] Save file as
+
+0401 [ABOUT_ABOUT] About
+0402 [ABOUT_PROGRAMMING] Programming
+0403 [ABOUT_DESIGN] Design
+0404 [ABOUT_THANKS] Thanks to
+0405 [ABOUT_SUPPORT] for support, ideas and testing
+0406 [ABOUT_GPL] This software is licensed under the GPL license
+
+0501 [SERVER_UNABLE_TO_CONNECT] Unable to connect : %1
+0502 [SERVER_UNABLE_TO_CONNECT_STILL] Unable to connect to %1 :
currently trying to connect to %2
+0503 [SERVER_DISCONNECTING] Disconnecting from %1
+0504 [SERVER_CONNECTING] Connecting...
+0505 [SERVER_NOT_CONNECTED] Not connected
+0506 [SERVER_LOGIN] Logging in...
+0507 [SERVER_DISCONNECTED] Disconnected from %1
+0508 [SERVER_ERROR] Error : %1
+
+
+071a [GUI_CHANGE_NICK] Change nick to
+071b [GUI_COPY_WINDOW] Copy text
+071c [GUI_DCC_CHAT_WARNING_TITLE] Warning
+071d [GUI_DCC_CHAT_WARNING_TEXT] Do you want to accept DCC chat from %1?
+
+0801 [ASL_MALE] Boy, %1 years old, %2
+0802 [ASL_FEMALE] Girl, %1 years old, %2
+0803 [ASL_UNKNOWN] %1 years old from %2
+
+0901 [REPLY_IDLE] %1 has been idle for %2
+0902 [REPLY_SIGNON] %1 connected on %2
+
+ffff [ERROR_NOT_DEFINED] Undefined string
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/irc.cab
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpHnaGVh
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpaFvmmX differ
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/irc.jar
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpGwh3IW
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpEwVlJc differ
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/pixx-english.lng
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/pjirc/pixx-english.lng Fri
Jun 20 07:16:16 2008
@@ -0,0 +1,75 @@
+#
+# This java file is a part of the
+#
+# - Plouf's Java IRC Client -
+#
+# Copyright (C) 2004 Philippe Detournay
+#
+# This file is licensed under the GPL license
+#
+# All contacts : thep...@yahoo.com
+#
+#
+# Syntax :
+# Comments begin with the # character. This character must be the
first character of the line.
+# A data line has three parts : the data id, the data id
description, the data string.
+# - Data id : An hexadecimal figure identifying the string.
+# - Data description : Begins by [ and ends by ]. The description
is not parsed and
+# can be any string.
+# - Data string : The string itself. Parameters are specified
using the %i syntax.
+#
+# Trailing spaces can be added using the \s escape character.
+
+8601 [SOURCE_YOU_KICKED] You've been kicked out of %1 by %2
+8602 [SOURCE_STATUS] Status
+8603 [SOURCE_CHANLIST] Channels for %1
+8604 [SOURCE_CHANLIST_RETREIVING] Retrieving channels...
+8605 [SOURCE_HAS_JOINED] %1 has joined %2
+8606 [SOURCE_HAS_LEFT] %1 has left %2
+8607 [SOURCE_HAS_BEEN_KICKED_BY] %1 has been kicked by %2
+8608 [SOURCE_HAS_QUIT] %1 has quit
+8609 [SOURCE_TOPIC_IS] Topic is %1
+860a [SOURCE_CHANGED_TOPIC] %1 changed topic to %2
+860b [SOURCE_CHANNEL_MODE] %1 sets channel mode to %2
+860c [SOURCE_CHANNEL_MODE_IS] Channel mode is %1
+860d [SOURCE_USER_MODE] %1 sets mode %2 on %3
+860e [SOURCE_KNOWN_AS] %1 is now known as %2
+860f [SOURCE_YOUR_MODE] Mode changed to %1
+8610 [SOURCE_YOUR_NICK] Your nick is now %1
+8611 [SOURCE_INFO] Infos
+8612 [SOURCE_AWAY] %1 is away
+8613 [SOURCE_YOU_INVITED] %1 invites you to join %2
+8614 [SOURCE_YOU_JOINED_AS] You're talking in %1 as %2
+
+8701 [GUI_WHOIS] Whois
+8702 [GUI_QUERY] Query
+8703 [GUI_KICK] Kick
+8704 [GUI_BAN] Ban
+8705 [GUI_KICKBAN] Kick + Ban
+8706 [GUI_OP] Op
+8707 [GUI_DEOP] DeOp
+8708 [GUI_VOICE] Voice
+8709 [GUI_DEVOICE] DeVoice
+870a [GUI_PING] Ping
+870b [GUI_VERSION] Version
+870c [GUI_TIME] Time
+870d [GUI_FINGER] Finger
+870e [GUI_RETREIVING_FILE] Receiving file (%1 bytes)
+870f [GUI_SENDING_FILE] Sending file (%1 bytes)
+8710 [GUI_TERMINATED] %1 terminated
+8711 [GUI_FAILED] %1 failed
+8712 [GUI_CLOSE] Close
+8713 [GUI_DISCONNECT] Disconnect
+8714 [GUI_CHANNELS] Channels
+8715 [GUI_HELP] Help
+8716 [GUI_PRIVATE] private
+8717 [GUI_PUBLIC] public
+8718 [GUI_CONNECT] Connect
+8719 [GUI_ABOUT] About
+871a [GUI_CHANGE_NICK] Change nick to
+871c [GUI_FONT] Font
+871d [GUI_FONT_WINDOW] Select font
+871e [GUI_FONT_WINDOW_OK] Ok
+871f [GUI_ENTER_TEXT_HERE] Enter text here...
+
+ffff [ERROR_NOT_DEFINED] Undefined string
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/pixx.cab
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpLfhuZy
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp1lf8Ej differ
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/pixx.jar
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpuAn1-0
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpNxala2 differ
Added: branches/irc_chat_tab/src/htdocs/files/pjirc/securedirc.cab
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpGpfzhu
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpAMrNQK differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ChannelJoinPartStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpK4j1Ij
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpix7eqX differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ChannelJoinPartStrategy.java
==============================================================================
--- (empty file)
+++
branches/irc_chat_tab/src/htdocs/files/snirc/ChannelJoinPartStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,75 @@
+
+
+/**
+ * <p>When we detect someone doing something that causes them to join or
+ * leave a channel, this strategy is invoked.
+ *
+ * @version $Id: ChannelJoinPartStrategy.java,v 1.2 2003/12/02
22:08:19 bryan_w Exp $
+ */
+public class ChannelJoinPartStrategy implements
CommandProcessingStrategy {
+ /**
+ * Overrides method in CommandProcessingStrategy
+ */
+ public void execute(Command command, Chat session) {
+ if (command.getCommand().equals("QUIT")) {
+ partChannel(
+ session,
+ command.getSource(),
+ "[Q] " + command.getSource() + " has Quit (" +
command.getArgument(0) + ")");
+ } else if (command.getCommand().equals("PART")) {
+ partChannel(
+ session,
+ command.getSource(),
+ "[P] "
+ + command.getSource()
+ + " has left channel "
+ + command.getArgument(0)
+ + ((command.getArgument(1) != null)
+ ? (" (" + command.getArgument(1) + ")")
+ : ""));
+ } else if (command.getCommand().equals("KICK")) {
+ partChannel(
+ session,
+ command.getArgument(1),
+ "[K] "
+ + command.getArgument(1)
+ + " has been kicked from channel "
+ + command.getArgument(0)
+ + " by "
+ + command.getSource()
+ + " ("
+ + command.getArgument(2)
+ + ")");
+ } else if (command.getCommand().equals("JOIN")) {
+ notifyUser(
+ session,
+ command.getSource(),
+ "[J] " + command.getSource() + " has joined
channel " + command.getArgument(0));
+ if (!session.isCurrentNick(command.getSource())) {
+ session.addToNickList(command.getSource(), Chat.MODE_NONE);
+ } else {
+ session.setChannelName(command.getArgument(0));
+ }
+ }
+ }
+
+ private void notifyUser(Chat session, String target, String
message) {
+ if (session.isCurrentNick(target) || session.showJoinsAndParts())
+ session.sendToUser(message);
+ }
+
+ private void partChannel(Chat session, String nick, String
userMessage) {
+ session.deleteFromNickList(nick);
+ notifyUser(session, nick, userMessage);
+ }
+
+ /**
+ * Overrides method in CommandProcessingStrategy
+ */
+ public void register() {
+ Command.registerStrategy("JOIN", this);
+ Command.registerStrategy("PART", this);
+ Command.registerStrategy("QUIT", this);
+ Command.registerStrategy("KICK", this);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Chat$1.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpeY3kt4
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp7AGqmt differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Chat$2.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpgZk4kk
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmptim63o differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Chat.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpCFDv4Q
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpa1i0dJ differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Chat.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/Chat.java Fri Jun 20
07:16:16 2008
@@ -0,0 +1,566 @@
+
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.StringTokenizer;
+import java.util.NoSuchElementException;
+import java.util.Vector;
+
+/**
+ * @version $Id: Chat.java,v 1.24 2004/07/27 02:38:10 halcy0n Exp $
+ */
+public class Chat extends Applet implements Runnable {
+ private final static String DEFAULT_HELP_URL = "http://cookie.sorcery.net/~ircd_/help/";
+ private final static String DEFAULT_LIST_URL = "http://www.valinor.sorcery.net/channels/";
+ private final static String DEFAULT_FONT_NAME = "Monospace";
+ private final static int DEFAULT_FONT_SIZE = 12;
+ private final static String DEFAULT_QUIT_MESSAGE = "http://snirc.sourceforge.net/";
+ private final static String DEFAULT_CHANNEL_NAME = "#help";
+ private final static int DEFAULT_IRC_PORT = 6667;
+ public static final char MODE_CHANOP = '@';
+ public static final char MODE_NONE = ' ';
+ public static final char MODE_VOICE = '+';
+ private IRCConnection connection;
+ private ChatUserInterface chat;
+ private String[] allowedNicks;
+ private String banMask;
+ private Vector IgnoreList = new Vector();
+ public final static String VERSION = "v1.0";
+
+ private ActionListener userInputListener = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ TextField inputBox = (TextField) event.getSource();
+ String s = inputBox.getText().trim();
+ String chanTopic, topicChan, jumpedChanName, chanPass;
+ if (s.length() == 0)
+ return;
+
+ if (!connection.isOpen()) {
+ sendToUser("[E] Not connected to server");
+ return;
+ }
+
+ if (s.startsWith("/")) {
+ StringTokenizer cmd = new StringTokenizer(s);
+ String command = cmd.nextToken().substring(1);
+ if (command.equalsIgnoreCase("help")) {
+ showHelp();
+ } else if (command.equalsIgnoreCase("ignore")) {
+ try {
+ String com = cmd.nextToken();
+ if(com.equalsIgnoreCase("add"))
+ addIgnore(extractEverythingAfter(s, com));
+ else if(com.equalsIgnoreCase("remove")) {
+ try {
+ int index = Integer.parseInt(cmd.nextToken());
+
+ if(index < 0 || index > (IgnoreList.size()-1)) {
+ throw new NumberFormatException();
+ }
+
+ remIgnore(index);
+ } catch(NumberFormatException ex) {
+ sendToUser("[E] You specified an invalid index. Type, /ignore, to
see valid indexes.");
+ }
+
+ } else
+ sendToUser("[E] Correct syntax for /ignore is: /ignore [add|
remove] [mask|index]");
+ }
+ catch(NoSuchElementException ex) {
+ showIgnoreList();
+ }
+ } else if (command.equalsIgnoreCase("list")) {
+ showChannelList();
+ } else if (command.equalsIgnoreCase("notice")) {
+ String target = cmd.nextToken();
+ String text = extractEverythingAfter(s, target);
+ sendToUser("-<" + target + ">- " + text);
+ sendToServer("NOTICE " + target + " :" + text);
+ } else if (command.equalsIgnoreCase("msg")) {
+ String target = cmd.nextToken();
+ String text = extractEverythingAfter(s, target);
+ sendToUser("*<" + target + ">* " + text);
+ sendToServer("PRIVMSG " + target + " :" + text);
+ } else if (command.equalsIgnoreCase("raw")) {
+ sendToServer(extractEverythingAfter(s, command));
+ } else if (command.equalsIgnoreCase("me")) {
+ sendToUser("* " + getCurrentNick() + " " +
extractEverythingAfter(s, command));
+ sendToServer(
+ "PRIVMSG "
+ + getChannelName()
+ + " :\001ACTION "
+ + extractEverythingAfter(s, command)
+ + "\001");
+ } else if (command.equalsIgnoreCase("join")) {
+
+ /* if (! ServerChat.canChanChange) {
+ sendToUser("Feature disabled by website administrator \n");
+ return;
+ } else { */
+ jumpedChanName = cmd.nextToken();
+ if (!jumpedChanName.substring(0,1).equals("#")){
+ sendToUser("Valid channel names begin with # \n");
+ return;
+ }
+ chanPass = s.substring(s.indexOf(jumpedChanName) + jumpedChanName.length());
+ sendToUser("* Joining " + jumpedChanName + "\n");
+ sendToServer( "PART " + getChannelName() + "\nJOIN "
+ jumpedChanName + chanPass);
+
+ } else if (command.equalsIgnoreCase("topic")) {
+ topicChan = cmd.nextToken();
+ if (topicChan.substring(0,1).equals("#")){
+ chanTopic = extractEverythingAfter(s, topicChan);
+ sendToServer("TOPIC " + topicChan + " :" + chanTopic);
+ } else {
+ chanTopic = extractEverythingAfter(s, topicChan);
+ sendToServer("TOPIC " + getChannelName() + " :" + chanTopic);
+ }
+ } else if (command.equalsIgnoreCase("part")) {
+ sendToUser("This command has been removed. Use /join to
enter another channel");
+ return;
+ } else {
+ sendToServer(extractEverythingAfter(s, "/"));
+ }
+ }else {
+ sendToUser("<" + getCurrentNick() + "> " + s);
+ sendToServer("PRIVMSG " + getChannelName() + " :" + s);
+ }
+ inputBox.setText("");
+ }
+ };
+
+ private ActionListener buttonsAndMenuListener = new
ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ String command = event.getActionCommand();
+ if (command.equals("Help")) {
+ showHelp();
+ } else if (command.equals("List")) {
+ showChannelList();
+ } else if (command.equals("Nick")) {
+ sendToServer("NICK " + EntryDialog.promptForNick());
+ } else if (command.equals("Channel")) {
+ String channel = EntryDialog.promptForChannel();
+ sendToServer("PART " + getChannelName());
+ sendToServer("JOIN " + channel);
+ } else {
+ String selectedNick = chat.getSelectedNick();
+ if (selectedNick == null
+ && !command.equals("About")
+ && !command.equals("Refresh")) {
+ sendToUser("[*] You must first select a nickname
by clicking on it.");
+ } else {
+ if (command.equals("Whois")) {
+ sendToServer("WHOIS " + selectedNick);
+ } else if (command.equals("Ignore")) {
+ banMask = "";
+ sendToServer("USERHOST " + selectedNick);
+ while (banMask == "") { } //We need to wait to recieve the data
+ String ignore = EntryDialog.promptForBanmask(banMask);
+ addIgnore(ignore);
+ } else if (command.equals("View Ignore List")){
+ showIgnoreList();
+ }else if (command.equals("Give Ops")) {
+ sendToServer("MODE " + getChannelName() + " +o "
+ + selectedNick);
+ } else if (command.equals("Take Ops")) {
+ sendToServer("MODE " + getChannelName() + " -o "
+ + selectedNick);
+ } else if (command.equals("Give Voice")) {
+ sendToServer("MODE " + getChannelName() + " +v "
+ + selectedNick);
+ } else if (command.equals("Take Voice")) {
+ sendToServer("MODE " + getChannelName() + " -v "
+ + selectedNick);
+ } else if (command.equals("Kick")) {
+ sendToServer("KICK " + getChannelName() + " "
+ + selectedNick + " :Bye");
+ } else if (command.equals("Ban")) {
+ banMask = "";
+ sendToServer("USERHOST " + selectedNick);
+ while (banMask == "") { } //We need to wait a minute to recieve the data
+ String ban = EntryDialog.promptForBanmask(banMask);
+ sendToServer("MODE " + getChannelName() + " +b "
+ + ban);
+ } else if (command.equals("Refresh")) {
+ sendToServer("NAMES " + getChannelName());
+ } else if (command.equals("Version")) {
+ sendToServer(
+ "PRIVMSG "
+ + selectedNick
+ + " :\001VERSION\001");
+ } else if (command.equals("Ping")) {
+ sendToServer(
+ "PRIVMSG "
+ + selectedNick
+ + " :\001PING "
+ + System.currentTimeMillis()
+ + "\001");
+ } else if (command.equals("About")) {
+ sendToUser("[*] SorceryNet IRC
ChatUserInterface Applet");
+ sendToUser("[*] Copyright (C) 1998-2000,
Anthony F. Miller");
+ sendToUser("[*] Open Source under the BSD license");
+ sendToUser("[*] Report bugs and get updates
at: http://sourceforge.net/projects/snirc/");
+ }
+ }
+ }
+ }
+ };
+
+ public Chat() {
+ Command.registerStrategies();
+ }
+
+ public void init() {
+ this.allowedNicks = createAllowedNicks();
+ setLayout(new GridLayout(1, 1));
+ this.chat = new ChatUserInterface(userInputListener,
+ buttonsAndMenuListener,
+ !isBooleanParameterSet("defaultHideJoinsAndParts"),
+ isBooleanParameterSet("Barebones"),
+ isBooleanParameterSet("AllowChannelChange"),
+ new Font(getTextParameter("FontName", DEFAULT_FONT_NAME),
+ Font.PLAIN,
+ getNumericParameter("FontSize", DEFAULT_FONT_SIZE)));
+ this.add(chat, BorderLayout.CENTER);
+ }
+
+ /**
+ * Cleanly kill the connection and terminate the applet. Inherited
from Applet and called
+ * by the Applet container.
+ */
+ public void stop() {
+ connection.close(DEFAULT_QUIT_MESSAGE);
+ }
+
+ /**
+ * Open the connection to the server. Inherited from Applet and
called by the Applet container.
+ */
+ public void start() {
+ this.connection = new IRCConnection(getTextParameter("Server", getDocumentBase().getHost()),
+ getNumericParameter("Port", DEFAULT_IRC_PORT));
+ new Thread(this).start();
+ }
+
+
+ public void clearNickList() {
+ chat.getNickList().removeAll();
+ }
+
+ public void addToNickList(String nick, char modeChar) {
+ String decoratedNick = modeChar + nick;
+ for (int i = 0; i < chat.getNickList().getItemCount(); i++) {
+ if (decoratedNick.compareTo(chat.getNickList().getItem(i))
>= 0) {
+ chat.getNickList().add(decoratedNick, i);
+ return;
+ }
+ }
+ chat.getNickList().add(decoratedNick);
+ }
+
+ public void changeNickMode(String nick, char mode, boolean
modeActive) {
+ String decoratedNick = getDecoratedNickFromNickList(nick);
+
+ if (decoratedNick == null) {
+ addToNickList(nick, MODE_NONE);
+ decoratedNick = MODE_NONE + nick;
+ }
+
+ if (modeActive) {
+ if (mode == 'o') {
+ replaceOnNickList(nick, nick, MODE_CHANOP);
+ } else {
+ if (decoratedNick.charAt(0) == MODE_NONE)
+ replaceOnNickList(nick, nick, MODE_VOICE);
+ }
+ } else {
+ if (mode == 'o') {
+ replaceOnNickList(nick, nick, MODE_NONE);
+ } else {
+ if (decoratedNick.charAt(0) != MODE_CHANOP)
+ replaceOnNickList(nick, nick, MODE_NONE);
+ }
+ }
+ }
+
+ /**
+ * Sets the banMask based on the userhost info gathered from NamesNumericsStrategy
+ */
+ public void setBanMask(String banMsk){
+ banMask = banMsk;
+
+ }
+
+ private void connectToServer() {
+ if (connection == null)
+ throw new IllegalStateException("Can't connect to server -
connection has not been initialised");
+ try {
+ /* Test for new parameter here... */
+ String nick = getTextParameter("Nick", "");
+ if (nick == "") {
+ nick = EntryDialog.promptForNick();
+ }
+ printClientIntro();
+ setNick(nick);
+ sendToUser(
+ "*** Attempting connection to "
+ + connection.getServerHostName()
+ + " on port "
+ + connection.getServerPortNumber());
+ connection.connect();
+ sendToUser(
+ "*** Connected! Attempting handshaking, please
stand by...");
+ sendToServer("NICK " + getCurrentNick() + "\n");
+ sendToServer("USER JavaClient dummy dummy :" +
getDocumentBase().toString() + "\n");
+ } catch (java.io.IOException e) {
+ System.out.println("Unable to make connection to host");
+ sendToUser("Sorry. Unable to make " + "connection to server.");
+ connection.close();
+ }
+ }
+
+ public void deleteFromNickList(String nick) {
+ for (int i = 0; i < chat.getNickList().getItemCount(); i++) {
+ if
(chat.getNickList().getItem(i).substring(1).equals(nick)) {
+ chat.getNickList().remove(i);
+ return;
+ }
+ }
+ }
+
+ public boolean denyPrivateMessagesFrom(String source) {
+ return isBooleanParameterSet("DenyPrivateMessages")
+ && !isAServer(source) && !isAllowedNick(source);
+ }
+
+ public String getChannelName() {
+ return chat.getChannelName();
+ }
+
+ public String getCurrentNick() {
+ return chat.getNick();
+ }
+
+ public String getDecoratedNickFromNickList(String nick) {
+ for (int i = 0; i < chat.getNickList().getItemCount(); i++) {
+ if
(chat.getNickList().getItem(i).substring(1).equals(nick)) {
+ return chat.getNickList().getItem(i);
+ }
+ }
+
+ return null;
+ }
+
+ public boolean isCurrentChannel(String channel) {
+ return getChannelName().equalsIgnoreCase(channel);
+ }
+
+ public boolean isCurrentNick(String nick) {
+ return getCurrentNick().equalsIgnoreCase(nick);
+ }
+
+ private void printClientIntro() {
+ sendToUser(
+ "******\n"
+ + "*** Using SNirc Java Applet version: " + VERSION + "\n"
+ + "*** Type /HELP for help on using the applet.\n"
+ + "*** This applet is beta. Address any problems to: cl0...@flame.org\n"
+ + "*** Web page authors are strongly encouraged to
join the SNirc mailing list\n"
+ + "*** By sending an e-mail to snirc-webmas...@lists.sourceforge.net\n"
+ + "*** with \"subscribe\" (w/o quotes) in the
subject, and following the instructions you are mailed.\n"
+ + "******");
+ }
+
+ public void replaceOnNickList(
+ String oldNick,
+ String newNick,
+ char newModeChar) {
+ deleteFromNickList(oldNick);
+ addToNickList(newNick, newModeChar);
+ }
+
+ public void run() {
+ connectToServer();
+ try {
+ while (connection.isOpen()) {
+ Command command = Command.parseLine(connection.readLine());
+ if (command != null)
+ command.execute(this);
+ }
+ } catch (java.io.IOException ioe) {
+ if (connection.isOpen()) {
+ sendToUser("[E] Could not receive data from server. ("
+ ioe.getMessage() + ")");
+ connection.close();
+ }
+ }
+
+ sendToUser("[M] Disconnected");
+ }
+
+ public void sendToServer(String message) {
+ try {
+ connection.sendLine(message);
+ } catch (java.io.IOException ex) {
+ sendToUser("[E] Closing connection, could not send to
server: " + ex.getMessage());
+ connection.close();
+ }
+ }
+
+ public void sendToUser(String message) {
+ chat.appendOutputLine(message);
+ }
+
+ public void serverConnectionIsActive() {
+ chat.makeReadyForCommands(isBooleanParameterSet("Barebones"));
+ setChannelName(getTextParameter("Channel", DEFAULT_CHANNEL_NAME));
+ if (getChannelName().equals(""))
+ setChannelName(EntryDialog.promptForChannel());
+
+ sendToServer("JOIN " + getChannelName());
+ }
+
+ public void setChannelName(String channelName) {
+ chat.setChannelName(channelName);
+ }
+
+ public void setChannelTopic(String channelTopic) {
+ chat.setTopic(channelTopic);
+ }
+
+ public void setNick(String nick) {
+ chat.setNick(nick);
+ }
+
+ private void showChannelList() {
+ try {
+ getAppletContext().showDocument(
+ new java.net.URL(getTextParameter("HelpURL", DEFAULT_LIST_URL)),
+ "target window");
+ } catch (java.net.MalformedURLException e) {
+ sendToUser(
+ "[E] Could not load channel list page, bad URL in configuration: "
+ + e.getMessage());
+ }
+ }
+
+ private void showHelp() {
+ try {
+ getAppletContext().showDocument(
+ new java.net.URL(getTextParameter("HelpURL", DEFAULT_HELP_URL)),
+ "target window");
+ } catch (java.net.MalformedURLException e) {
+ sendToUser(
+ "[E] Could not load help page, bad URL in
configuration: " + e.getMessage());
+ }
+ }
+
+ public boolean showJoinsAndParts() {
+ return chat.isDisplayingJoinsAndParts();
+ }
+
+ private int getNumericParameter(String parameterName, int
defaultValue) {
+ if (getParameter(parameterName) == null)
+ return defaultValue;
+
+ try {
+ return Integer.parseInt(getParameter(parameterName));
+ } catch (NumberFormatException nfe) {
+ System.err.println("Configuration error: Applet
parameter " + parameterName + " must be numeric");
+ return defaultValue;
+ }
+ }
+
+ private String getTextParameter(String parameterName, String
defaultValue) {
+ if (getParameter(parameterName) == null)
+ return defaultValue;
+
+ return getParameter(parameterName);
+ }
+
+ private boolean isBooleanParameterSet(String parameterName) {
+ return getParameter(parameterName) != null
+ && (getParameter(parameterName).equalsIgnoreCase("yes")
+ || getParameter(parameterName).equalsIgnoreCase("true")
+ || getParameter(parameterName).equalsIgnoreCase("y"));
+ }
+
+ private boolean isAServer(String source) {
+ return source.indexOf(".") != -1;
+ }
+
+ private String extractEverythingAfter(String s, String subString) {
+ return s.substring(s.indexOf(subString) + subString.length()).trim();
+ }
+
+
+ private boolean isAllowedNick(String nick) {
+ for (int i = 0; i < allowedNicks.length; i++) {
+ if (allowedNicks[i].equals(nick))
+ return true;
+ }
+ return false;
+ }
+
+ private String[] createAllowedNicks() {
+ StringTokenizer tok = new StringTokenizer(getTextParameter("AllowedNicks", ""));
+ String[] allowedNicks = new String[tok.countTokens()];
+ for (int i = 0; i < allowedNicks.length; i++) {
+ allowedNicks[i] = tok.nextToken();
+ }
+ return allowedNicks;
+ }
+
+ public void addIgnore(String ignoreMask) {
+ if(!EntryDialog.isValidBanmask(ignoreMask)) {
+ sendToUser("[E] This is an invalid mask. It should be in the
format of nick!user@host, with * as a wildcard.");
+ } else {
+ String ignoreRegexp = "(?i:";
+ ignoreRegexp = ignoreRegexp.concat(ignoreMask + ")");
+ ignoreRegexp = ignoreRegexp.replaceAll("\\.","\\\\.");
+ ignoreRegexp = ignoreRegexp.replaceAll("\\*",".*");
+ ignoreRegexp = ignoreRegexp.replaceAll("\\[","\\\\[");
+ ignoreRegexp = ignoreRegexp.replaceAll("\\]","\\\\]");
+ ignoreRegexp = ignoreRegexp.replaceAll("\\^","\\\\^");
+ Pair p = new Pair(ignoreMask,ignoreRegexp);
+ IgnoreList.addElement(p);
+ sendToUser("[I] Added ignore for: " + ignoreMask);
+ }
+ }
+
+ public void remIgnore(int index) {
+ Pair p = (Pair)IgnoreList.get(index);
+ IgnoreList.remove(index);
+ sendToUser("[I] Successfully removed ignore: " + p.first);
+ }
+
+ public boolean isIgnored(String usermask) {
+ int size = IgnoreList.size();
+
+ if(size == 0)
+ return false;
+
+ for(int i = 0; i < size; ++i) {
+ Pair p = (Pair)IgnoreList.get(i);
+ if(usermask.matches(p.second)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void showIgnoreList() {
+ if(IgnoreList.isEmpty()) {
+ sendToUser("[I]The ignore list is empty.");
+ } else {
+ sendToUser("Usage: /ignore [add|remove] [mask|Number] \n" +
+ "Ex. To remove the 1st ignore on the ignore list: /ignore remove 0");
+ sendToUser("Ignore List:\n");
+ for(int i = 0, size=IgnoreList.size(); i < size; ++i) {
+ Pair p = (Pair)IgnoreList.get(i);
+ sendToUser("[" + i + "] " + p.first);
+ }
+ }
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface$1.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpJaLvOU
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpEIxkDj differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpNvMIHO
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpQVLej_ differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/ChatUserInterface.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,286 @@
+
+
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+/**
+ * <p>Responsible for setting up and maintaining the User Interface of
the Applet.
+ *
+ * @version $Id: ChatUserInterface.java,v 1.8 2004/07/26 18:24:58
bryan_w Exp $
+ */
+
+public class ChatUserInterface extends Panel {
+ /** Default background colour of the applet's widgets */
+ public final static Color BACKGROUND_COLOUR = Color.white;
+ /** Default foreground colour of the applet's widgets */
+ public final static Color FOREGROUND_COLOUR = Color.black;
+ /** Version number for the applet, and supporting code */
+
+
+ private Panel buttonBar;
+ private Label channelLabel = new Label(" ", Label.LEFT);
+ private Label nickLabel = new Label(" ", Label.LEFT);
+ private Button nickButton;
+ private PopupMenu nickListMenu;
+ private List nickList = new List(19, false);
+ private TextField userMsg = new TextField(70);
+ private Label lblTopic = new Label("");
+ private Panel topline;
+ private CheckboxMenuItem chkJoinPart;
+ private static CheckboxMenuItem chkShowPingPong;
+ private ScrollableOutputPanel outputPanel;
+ private Button channelButton;
+ private ActionListener menusAndButtonsListener;
+ private boolean allowChannelChange = true;
+
+
+ private MouseListener mouseEventHandler = new MouseAdapter() {
+ public void mouseReleased(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ nickListMenu.show(nickList, e.getX(), e.getY());
+ }
+ }
+
+ public void mousePressed(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ nickListMenu.show(nickList, e.getX(), e.getY());
+ }
+ }
+ };
+
+ /**
+ * Initializes up the User Interface.
+ */
+ public ChatUserInterface(ActionListener userInputListener,
+ ActionListener menusAndButtonsListener,
+ boolean defaultHideJoinsAndParts,
+ boolean bareBones,
+ boolean allowChannelChange,
+ Font defaultFont) {
+ this.allowChannelChange = allowChannelChange;
+ setFont(defaultFont);
+ this.menusAndButtonsListener = menusAndButtonsListener;
+ outputPanel = new ScrollableOutputPanel();
+ setLayout(new BorderLayout());
+
+ Panel msgline = new Panel();
+ msgline.setLayout(new FlowLayout(FlowLayout.LEFT));
+ msgline.add(userMsg);
+ userMsg.addActionListener(userInputListener);
+ msgline.add(new Label(Chat.VERSION));
+
+ nickList.addMouseListener(mouseEventHandler);
+ nickList.setMultipleMode(false);
+ nickListMenu = createContextMenu();
+ this.add(nickListMenu);
+ chkJoinPart.setState(defaultHideJoinsAndParts);
+
+ // top panel controls
+ topline = new Panel();
+ topline.setLayout(new BorderLayout());
+
+ if (!bareBones) {
+ createButtonBar();
+ }
+ topline.add("Center", lblTopic);
+
+ add("North", topline);
+ add("South", msgline);
+ add("East", nickList);
+ add("Center", outputPanel);
+ }
+
+ private void createButtonBar() {
+ buttonBar = new Panel();
+ buttonBar.setLayout(new FlowLayout(FlowLayout.LEFT));
+ nickButton = createButton("Nick");
+ buttonBar.add(nickButton);
+ buttonBar.add(nickLabel);
+ channelButton = createButton("Channel");
+ buttonBar.add(channelButton);
+ buttonBar.add(channelLabel);
+ buttonBar.add(createButton("Help"));
+ buttonBar.add(createButton("List"));
+ topline.add("North", buttonBar);
+ nickButton.setEnabled(false);
+ channelButton.setEnabled(false);
+ outputPanel.setChatFont(getFont());
+ setBackground(BACKGROUND_COLOUR);
+ setForeground(FOREGROUND_COLOUR);
+ setFontAndColours(nickList);
+ setFontAndColours(userMsg);
+ setFontAndColours(nickLabel);
+ setFontAndColours(channelLabel);
+ }
+
+ /**
+ * Once the connection to the IRC server has been established,
this method is called
+ * to prepare the User Interface for user interaction.
+ */
+ public void makeReadyForCommands(boolean bareBones) {
+ if(!bareBones) {
+ nickButton.setEnabled(true);
+ channelButton.setEnabled(allowChannelChange);
+ }
+ userMsg.requestFocus();
+ }
+
+ /**
+ * Return the currently displayed channel name
+ */
+ public String getChannelName() {
+ return channelLabel.getText();
+ }
+
+ /**
+ * Return the currently displayed nick
+ */
+ public String getNick() {
+ return nickLabel.getText();
+ }
+
+ /**
+ * Return the List that contains the nicks currently on the
channel, prefixed
+ * with the appropriate "status" character, @ + or a space
depending on the
+ * status. The contents of the list are manipulated by the Chat.
+ *
+ * <p>This is deliberately bad design - the alternative would
bloat the size
+ * of the applet significantly, and the gain in code clarity
wouldn't be worth it.
+ */
+ public List getNickList() {
+ return nickList;
+ }
+
+ /**
+ * Return the currently selected nickname from the channel nick-list.
+ */
+ public String getSelectedNick() {
+ String selectedNick = nickList.getSelectedItem();
+ return selectedNick == null ? null : selectedNick.substring(1);
+ }
+
+ /**
+ * Returns the index of the currently selected nickname from the
channel nick-list
+ */
+ public int getSelectedNickIndex(){
+ // Stubby!
+ return 0;
+ }
+
+
+ /**
+ * Return whether the user has opted to display joins and
+ * parts.
+ */
+ public boolean isDisplayingJoinsAndParts() {
+ return chkJoinPart.getState();
+ }
+
+ /**
+ * Returns whether the user has opted to display ping pong
+ * events
+ */
+ public static boolean isDisplayingPingAndPong() {
+ return chkShowPingPong.getState();
+ }
+
+ /**
+ * Set the currently-displayed channel name
+ */
+ public void setChannelName(String channel) {
+ channelLabel.setText(channel);
+ }
+
+ /**
+ * Set the currently-displayed nick
+ */
+ public void setNick(String nick) {
+ nickLabel.setText(nick);
+ }
+
+ /**
+ * Set the currently displayed channel topic
+ */
+ public void setTopic(String topic) {
+ boolean reTypeTopic = true;
+ if (reTypeTopic){
+ lblTopic.setText("Topic: " + topic);
+ reTypeTopic = false;
+ }
+ else
+ lblTopic.setText(topic);
+ }
+
+
+ /**
+ * Append a line to the output area. The argument should not end
with a newline.
+ */
+ public void appendOutputLine(String line) {
+ outputPanel.appendLine(line);
+ }
+
+ private void setFontAndColours(Component c) {
+ c.setFont(getFont());
+ c.setBackground(BACKGROUND_COLOUR);
+ c.setForeground(FOREGROUND_COLOUR);
+ }
+
+ private Button createButton(String text) {
+ Button button = new Button(text);
+ button.addActionListener(menusAndButtonsListener);
+ return button;
+ }
+
+ private PopupMenu createContextMenu() {
+ MenuItem item;
+ PopupMenu menu = new PopupMenu();
+
+ menu.add(createMenuItem("Whois"));
+ menu.addSeparator();
+ menu.add(createMenuItem("Ignore"));
+ menu.add(createMenuItem("View Ignore List"));
+ menu.addSeparator();
+
+ Menu mnuOp = new Menu("Op Options");
+ mnuOp.add(createMenuItem("Give Ops"));
+ mnuOp.add(createMenuItem("Take Ops"));
+ mnuOp.addSeparator();
+ mnuOp.add(createMenuItem("Give Voice"));
+ mnuOp.add(createMenuItem("Take Voice"));
+ mnuOp.addSeparator();
+ mnuOp.add(createMenuItem("Kick"));
+ mnuOp.add(createMenuItem("Ban"));
+ menu.add(mnuOp);
+
+ Menu mnuCTCP = new Menu("CTCP");
+ mnuCTCP.add(createMenuItem("Version"));
+ mnuCTCP.add(createMenuItem("Ping"));
+ menu.add(mnuCTCP);
+
+ Menu mnuProperties = new Menu("Properties");
+ chkJoinPart = new CheckboxMenuItem("Show Joins/Parts/Quits");
+ mnuProperties.add(chkJoinPart);
+ chkShowPingPong = new CheckboxMenuItem("Show Ping? Pong! Event");
+ mnuProperties.add(chkShowPingPong);
+ chkShowPingPong.setState(true);
+
+ mnuProperties.addSeparator();
+ mnuProperties.add(createMenuItem("Refresh"));
+ menu.add(mnuProperties);
+
+ menu.addSeparator();
+ menu.add(createMenuItem("About"));
+
+ return menu;
+ }
+
+ private MenuItem createMenuItem(String title) {
+ MenuItem item = new MenuItem(title);
+ item.addActionListener(menusAndButtonsListener);
+ return item;
+ }
+
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Command.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpuXWXxN
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpC5Qfla differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Command.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/Command.java Fri Jun
20 07:16:16 2008
@@ -0,0 +1,194 @@
+
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * <p>An rfc1459 command that has been received from the IRC server.
+ *
+ * @version $Id: Command.java,v 1.4 2004/07/02 23:02:47 bryan_w Exp $
+ */
+public class Command {
+ private static Hashtable commandMap = new Hashtable();
+ private static CommandProcessingStrategy defaultStrategy = new DefaultProcess();
+ private final String source;
+ private final String command;
+ private final Vector arguments;
+ private final CommandProcessingStrategy strategy;
+
+ public static void registerStrategies() {
+ new NamesNumericsStrategy().register();
+ new SimpleNumericsStrategy().register();
+ new ChannelJoinPartStrategy().register();
+ new ModeStrategy().register();
+ new PrivmsgStrategy().register();
+ new NoticeStrategy().register();
+ new NickCommandsStrategy().register();
+ }
+
+ public static void registerStrategy(String commandName,
CommandProcessingStrategy strategy) {
+ commandMap.put(commandName, strategy);
+ }
+
+ public static Command parseLine(String line) {
+ if (line.length() == 0)
+ return null;
+
+ // Using a StringTokenizer here seems like using the corner of
+ // a flat-headed screwdriver on a phillips screw. It'd work,
+ // but it's still the Wrong Tool. So we go for ugly instead.
+
+ String nextToken = null;
+ String source = null;
+ java.util.Vector arguments = new java.util.Vector();
+
+ int pos = 0;
+ int start = -1;
+
+ if (line.charAt(0) == ':') {
+ pos = line.indexOf(' ');
+ source = line.substring(1, pos);
+ }
+
+ for (; pos < line.length(); pos++) {
+ if (line.charAt(pos) == ' ') {
+ if (start != -1)
+ break;
+ else
+ continue;
+ }
+
+ if (start == -1)
+ start = pos;
+ }
+ if (start == -1)
+ return null;
+
+ String commandName = line.substring(start, pos);
+
+ while (pos < line.length()) {
+ start = -1;
+
+ for (; pos < line.length(); pos++) {
+ if (line.charAt(pos) == ' ') {
+ if (start != -1)
+ break;
+ else
+ continue;
+ }
+
+ if ((line.charAt(pos) == ':') && (start == -1)) {
+
+ start = pos + 1;
+ pos = line.length() - 1;
+
+ while (line.charAt(pos) == ' ') {
+ pos--;
+ }
+ }
+
+ if (start == -1)
+ start = pos;
+ }
+ if (start != -1) {
+ arguments.addElement(line.substring(start, pos));
+ }
+ }
+ if (commandMap.containsKey(commandName.toUpperCase()))
+ return new Command((CommandProcessingStrategy)
commandMap.get(commandName.toUpperCase()), source, commandName, arguments);
+
+ return new Command(defaultStrategy, source, commandName, arguments);
+ }
+
+ public Command(CommandProcessingStrategy strategy, String source,
String command, Vector arguments) {
+ this.strategy = strategy;
+ this.source = source;
+ this.command = command;
+ this.arguments = arguments;
+ }
+
+ public void execute(Chat session) {
+ strategy.execute(this, session);
+ }
+
+ public String getArgument(int index) {
+ if (index >= arguments.size())
+ return null;
+
+ return (String) arguments.elementAt(index);
+ }
+
+ public String getArguments() {
+ return getArguments(0);
+ }
+
+ public String getArguments(int firstArgument) {
+ StringBuffer buf = new StringBuffer();
+ buf.append(" ");
+ for (int i = firstArgument; i < arguments.size(); i++) {
+ if (i > firstArgument)
+ buf.append(' ');
+ buf.append((String) arguments.elementAt(i));
+ }
+
+ return buf.toString();
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public String getFullSource() {
+ return source;
+ }
+
+ public String getSource() {
+ try {
+ if (source.indexOf('!') != -1)
+ return source.substring(0, source.indexOf('!'));
+ return source;
+ } catch (NullPointerException e) {
+ System.out.println("Null Pointer Excecption Ignored");
+ }
+ return "";
+ }
+
+ public void stripColoursFromLastArgument() {
+ String source = (String) arguments.lastElement();
+ StringBuffer buf = new StringBuffer(source.length());
+
+ boolean inColourCode = false;
+ int numberCount = 0;
+ int commaCount = 0;
+
+ for (int i = 0; i < source.length(); i++) {
+ if (inColourCode) {
+ if (source.charAt(i) == ',') {
+ numberCount = 0;
+ commaCount++;
+ if (commaCount <= 1)
+ continue;
+ }
+
+ if (Character.isDigit(source.charAt(i))) {
+ numberCount++;
+ if (numberCount <= 2)
+ continue;
+ }
+
+ commaCount = 0;
+ numberCount = 0;
+ inColourCode = false;
+ }
+
+ if (source.charAt(i) == '\003') {
+ inColourCode = true;
+ continue;
+ }
+
+ buf.append(source.charAt(i));
+ }
+
+ arguments.setElementAt(buf.toString(), arguments.size() - 1);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/CommandProcessingStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpdUQZPF
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmptDYCaC differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/CommandProcessingStrategy.java
==============================================================================
--- (empty file)
+++
branches/irc_chat_tab/src/htdocs/files/snirc/CommandProcessingStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,36 @@
+
+/**
+ * <p>When a command is received from the IRC Server, it is parsed
+ * by the Command object. The Command object then selects the appropriate
+ * CommandProcessingStrategy with which to process the command.
+ *
+ * <p>Only one of each CommandProcessingStrategy will be instantiated,
+ * so you should not store any state in the object that you wouldn't want
+ * shared between repeated invocations of the execute() method. On the other
+ * hand, the execute() method is only ever processed by one thread at
a time
+ * so it does not have to be reentrant.
+ *
+ * <p>Normally, you'd have one Strategy per command word, but since we are
+ * optimizing for download size, it's probably necessary to sacrifice
+ * that granularity and have a Strategy for each family of commands.
+ *
+ * <p>Uses the Strategy Pattern (Gamma et al, p315)
+ *
+ * @version $Id: CommandProcessingStrategy.java,v 1.2 2003/12/02
22:08:19 bryan_w Exp $
+ */
+public interface CommandProcessingStrategy {
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ void execute(Command command, Chat session);
+
+ /**
+ * <p>Register a Strategy with the Command object.
+ * Strategies are responsible for telling the Command object
+ * what commands they are interested in, using its registerStrategy()
+ * method.
+ */
+ void register();
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/DefaultProcess.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpylq6VP
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpRMXZAp differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/DefaultProcess.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/DefaultProcess.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,30 @@
+
+
+/**
+ * <p>The command processing strategy that we use if no other command
+ * in the list matches.
+ *
+ * <p>Currently contains all the spaghetti-code that was in the original
+ * command parser, but that will be whittled down as each new processing
+ * strategy is added.
+ *
+ * @version $Id: DefaultProcess.java,v 1.2 2003/12/02 22:08:19 bryan_w
Exp $
+ */
+public class DefaultProcess implements CommandProcessingStrategy {
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ public void execute(Command command, Chat session) {
+ if (Character.isDigit(command.getCommand().charAt(0))) {
+ session.sendToUser("-" + command.getSource() + "- " + command.getArguments(1));
+ } else {
+ session.sendToUser("-" + command.getSource() + "- " + command.getArguments(0));
+ }
+ }
+
+ public void register() {
+ //noop
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/EntryDialog.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpDIOyVV
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp0QSQro differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/EntryDialog.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/EntryDialog.java Fri
Jun 20 07:16:16 2008
@@ -0,0 +1,168 @@
+
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * <p>I feel this class should eventually go away.
+ *
+ * @version $Id: EntryDialog.java,v 1.6 2004/07/27 02:29:29 halcy0n
Exp $
+ */
+
+public class EntryDialog extends Dialog implements ActionListener {
+ private TextField entryField;
+ private String result;
+
+ public static final String VALID_NICK_CHARS =
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}|[]\\^-_";
+
+ public void actionPerformed(ActionEvent e) {
+ result = entryField.getText();
+ this.dispose();
+ }
+
+
+ private static boolean isValidChannel(String channel) {
+ if (channel.length() == 0)
+ return false;
+
+ for (int i = 0; i < channel.length(); i++) {
+ if (channel.charAt(i) == ' '
+ || channel.charAt(i) == ('\007')
+ || channel.charAt(i) == (','))
+ return false;
+ }
+
+ return true;
+ }
+
+ private static boolean isValidNick(String nick) {
+ if (nick.length() == 0)
+ return false;
+
+ if (nick.charAt(0) == '-' || Character.isDigit(nick.charAt(0)))
+ return false;
+
+ for (int i = 0; i < nick.length(); i++) {
+ if (VALID_NICK_CHARS.indexOf(nick.charAt(i)) == -1) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static String promptForChannel() {
+ String channel = "";
+ String error = "";
+
+ while (!isValidChannel(channel)) {
+ EntryDialog nickDialog = new EntryDialog("Enter a Channel
to Join", error);
+ nickDialog.show();
+ channel = nickDialog.result;
+ error = "Not a Valid Channel Name";
+ }
+
+ if (channel.charAt(0) != '#'
+ && channel.charAt(0) != '&'
+ && channel.charAt(0) != '+')
+ return "#" + channel;
+
+ return channel;
+ }
+
+ public static String promptForNick(String errorMessage) {
+ String nick = "";
+
+ while (!isValidNick(nick)) {
+ EntryDialog nickDialog = new EntryDialog("Enter a New
Nick-Name", errorMessage);
+ nickDialog.show();
+ nick = nickDialog.result;
+ errorMessage = "Not a Valid Nick Name";
+ }
+
+ return nick;
+ }
+
+ public static String promptForNick() {
+ return promptForNick("");
+ }
+
+ public static boolean isValidBanmask(String ban) {
+ if(ban.matches(".+\\!.+\\@.+"))
+ return true;
+ return false;
+ }
+
+
+ public static String promptForBanmask(String ban) {
+ ban = "*!*@" + ban;
+
+ EntryDialog banDialog = new EntryDialog("Enter a Ban Mask", "", ban);
+ banDialog.show();
+ ban = banDialog.result;
+
+ return ban;
+ }
+
+ private EntryDialog(String title, String statusText) {
+ super(new Frame(), true);
+
+ this.setTitle(title);
+ this.setModal(true);
+
+ entryField = new TextField("", 20);
+ entryField.addActionListener(this);
+ this.add("North", entryField);
+ Panel p = new Panel();
+ p.setLayout(new FlowLayout(FlowLayout.CENTER));
+ Button yes = new Button("Ok");
+ yes.addActionListener(this);
+ p.add(yes);
+
+ this.add("Center", p);
+
+ if (!statusText.equals("")) {
+ TextField statusField = new TextField(statusText, 30);
+ statusField.setEditable(false);
+ statusField.setBackground(this.getBackground());
+ this.add("South", statusField);
+ this.setSize(250, 140);
+ } else
+ this.setSize(250, 120);
+
+ this.setLocation(100, 200);
+ }
+
+ private EntryDialog(String title, String statusText, String
initalText) {
+ super(new Frame(), true);
+
+ this.setTitle(title);
+ this.setModal(true);
+
+ entryField = new TextField(initalText, 20);
+
+ entryField.addActionListener(this);
+ this.add("North", entryField);
+ Panel p = new Panel();
+ p.setLayout(new FlowLayout(FlowLayout.CENTER));
+ Button yes = new Button("Ok");
+ yes.addActionListener(this);
+ p.add(yes);
+
+ this.add("Center", p);
+
+ if (!statusText.equals("")) {
+ TextField statusField = new TextField(statusText, 30);
+ statusField.setEditable(false);
+ statusField.setBackground(this.getBackground());
+ this.add("South", statusField);
+ this.setSize(250, 140);
+
+ } else
+ this.setSize(250, 120);
+
+ this.setLocation(100, 200);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/IRCConnection.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpIWSpE6
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpSG11dr differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/IRCConnection.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/IRCConnection.java Fri
Jun 20 07:16:16 2008
@@ -0,0 +1,105 @@
+
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Socket;
+
+/**
+ * <p>Encapsulates our connection to the server, and provides convenience
+ * methods that allow us to read and write lines of data.
+ *
+ * @version $Id: IRCConnection.java,v 1.2 2003/12/02 22:08:19 bryan_w
Exp $
+ */
+public class IRCConnection {
+ public static final byte[] IRC_NEWLINE = new byte[]{ (byte) '\r',
(byte) '\n' };
+ private final String hostName;
+ private final int port;
+ private Socket socket;
+ private BufferedReader in;
+ private BufferedOutputStream out;
+ private boolean open = false;
+
+ public IRCConnection(String hostName, int port) {
+ this.hostName = hostName;
+ this.port = port;
+ }
+
+ /**
+ * <p>Close the connection.
+ */
+ public void close() {
+ if (socket != null)
+ try {
+ socket.close();
+ } catch (IOException e) {
+ System.err.println("[DEBUG] Error closing socket: " + e);
+ }
+ open = false;
+ }
+
+ /**
+ * <p>Close the connection, sending one last line before the connection
+ * is lost
+ */
+ public void close(String quitMessage) {
+ if (open)
+ try {
+ sendLine("QUIT :" + quitMessage);
+ } catch (IOException ioe) {
+ // we really don't care much if this works or not
+ }
+
+ close();
+ }
+
+ /**
+ * <p>Open the connection.
+ */
+ public void connect()
+ throws java.net.UnknownHostException, IOException {
+ if (open)
+ throw new IllegalStateException("Trying to open an already
open connection");
+
+ socket = new Socket(hostName, port);
+ in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ out = new BufferedOutputStream(socket.getOutputStream());
+ open = true;
+ }
+
+ public String getServerHostName() {
+ return hostName;
+ }
+
+ public int getServerPortNumber() {
+ return port;
+ }
+
+ public boolean isOpen() {
+ return open;
+ }
+
+ /**
+ * <p>Read a line from the connection.
+ */
+ public String readLine() throws IOException {
+ return in.readLine();
+ }
+
+ /**
+ * <p>Will send a line to a server over the connection. This
method automatically
+ * appends the IRC-standard newline (\r\n) to the message, so you
don't have to
+ * worry about sticking it in the line to be sent.
+ */
+ public void sendLine(String line) throws IOException {
+ if (!open)
+ throw new IOException("Not connected to server");
+
+ synchronized (out) {
+ out.write(line.getBytes());
+ out.write(IRC_NEWLINE);
+ }
+ out.flush();
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/MessageStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpA1Mp0a
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpBIc3sI differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/MessageStrategy.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/MessageStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,63 @@
+
+
+/**
+ * <p>Abstract superclass CommandProcessingStrategy for the NOTICE and
+ * PRIVMSG commands, which share a lot of functionality.
+ *
+ * @version $Id: MessageStrategy.java,v 1.5 2004/07/26 05:21:39
halcy0n Exp $
+ */
+public abstract class MessageStrategy implements
CommandProcessingStrategy {
+ private Chat currentSession;
+
+ public abstract String decorateChannelMessage(String source,
String message);
+
+ public abstract String decoratePrivateMessage(String source,
String message);
+
+ public void doAction(String source, String target, String message) {
+ String action = source + message.substring(7).replace('\001', ' ');
+ if (getSession().isCurrentChannel(target)) {
+ getSession().sendToUser("* " + action);
+ } else {
+ if (!getSession().denyPrivateMessagesFrom(source))
+ getSession().sendToUser("*> *" + action);
+ }
+ }
+
+ public abstract void doPing(String source, String message);
+
+ public abstract void doVersion(String source, String message);
+
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ public void execute(Command command, Chat session) {
+ this.currentSession = session;
+ command.stripColoursFromLastArgument();
+
+ try {
+ if (command.getArgument(1).startsWith("\001PING")) {
+ doPing(command.getSource(), command.getArgument(1));
+ } else if (command.getArgument(1).startsWith("\001VERSION")) {
+ doVersion(command.getSource(), command.getArgument(1));
+ } else if (command.getArgument(1).startsWith("\001ACTION")) {
+ doAction(command.getSource(), command.getArgument(0), command.getArgument(1));
+ } else {
+ if (session.isCurrentChannel(command.getArgument(0))
&& !session.isIgnored(command.getFullSource())) {
+
session.sendToUser(decorateChannelMessage(command.getSource(), command.getArgument(1)));
+ } else {
+ if
(!session.denyPrivateMessagesFrom(command.getSource()) && !session.isIgnored(command.getFullSource()))
+
session.sendToUser(decoratePrivateMessage(command.getSource(), command.getArgument(1)));
+ }
+ }
+ }
+ catch (NullPointerException e) {
+ System.out.println("NullPointerException caught in MessageStrategy.java");
+ }
+ }
+
+ protected Chat getSession() {
+ return currentSession;
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ModeStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpRNgRIY
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpnVxche differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ModeStrategy.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/ModeStrategy.java Fri
Jun 20 07:16:16 2008
@@ -0,0 +1,61 @@
+
+
+/**
+ * <p>Handles the numerics for MODE replies from the server.
+ * Currently we ignore everything but hannel modes for the
+ * currently active channel.
+ *
+ * @version $Id: ModeStrategy.java,v 1.2 2003/12/02 22:08:19 bryan_w
Exp $
+ */
+public class ModeStrategy implements CommandProcessingStrategy {
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ public void execute(Command command, Chat session) {
+ if (!session.isCurrentChannel(command.getArgument(0)))
+ return;
+
+ boolean settingMode = false;
+ String modeBlock = command.getArgument(1);
+ int currArg = 2;
+ for (int i = 0; i < modeBlock.length(); i++) {
+ switch (modeBlock.charAt(i)) {
+ case '+':
+ settingMode = true;
+ break;
+ case '-':
+ settingMode = false;
+ break;
+ case 'o':
+
session.changeNickMode(command.getArgument(currArg++), 'o', settingMode);
+ break;
+ case 'v':
+
session.changeNickMode(command.getArgument(currArg++), 'v', settingMode);
+ break;
+ case 'b': // fall through
+ case 'l': // fall through
+ case 'k': // fall through
+ currArg++;
+ } // end switch
+ } // end for
+ session.sendToUser(
+ "[M] "
+ + command.getSource()
+ + " has set mode(s) "
+ + command.getArguments(1)
+ + " on channel "
+ + command.getArgument(0));
+ }
+
+ /**
+ * <p>Register a Strategy with the Command object.
+ * Strategies are responsible for telling the Command object
+ * what commands they are interested in, using its registerStrategy()
+ * method.
+ */
+ public void register() {
+ Command.registerStrategy("MODE", this);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/NamesNumericsStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpfgOZpR
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp3mrzXQ differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/NamesNumericsStrategy.java
==============================================================================
--- (empty file)
+++
branches/irc_chat_tab/src/htdocs/files/snirc/NamesNumericsStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,82 @@
+
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ * <p>Handles the numerics for NAMES replies and END OF NAMES. Will
+ * cache the results of the NAMES replies, and then when END OF NAMES
+ * is received, will update the channel names list in one big block.
+ *
+ * @version $Id: NamesNumericsStrategy.java,v 1.3 2004/07/22 18:24:07
bryan_w Exp $
+ */
+public class NamesNumericsStrategy implements
CommandProcessingStrategy {
+ public static final String NAMES_NUMERIC = "353";
+ public static final String END_OF_NAMES_NUMERIC = "366";
+ public static final String USERHOST_NUMERIC = "302";
+ private Vector listedNicks = new java.util.Vector();
+
+
+ private void doEndOfNames(Chat session) {
+ session.clearNickList();
+ Enumeration e = listedNicks.elements();
+ while (e.hasMoreElements()) {
+ String nick = (String) e.nextElement();
+ if ((nick.charAt(0) == Chat.MODE_CHANOP)
+ || (nick.charAt(0) == Chat.MODE_VOICE))
+ session.addToNickList(nick.substring(1), nick.charAt(0));
+ else
+ session.addToNickList(nick, Chat.MODE_NONE);
+ }
+ listedNicks = new Vector();
+ }
+
+ private String getNickHost(String nk){
+ String[] userhost = nk.split("@");
+ return userhost[userhost.length-1];
+ }
+
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ public void execute(Command command, Chat session) {
+
+ if (command.getCommand().equals(NAMES_NUMERIC)) {
+ if (session.isCurrentChannel(command.getArgument(2))) {
+
+ session.sendToUser(
+ "[N] "
+ + command.getArgument(2)
+ + " Channel Members: "
+ + command.getArgument(3));
+ StringTokenizer nickList = new StringTokenizer(command.getArgument(3));
+ while (nickList.hasMoreTokens()) {
+ String nxNick = nickList.nextToken();
+ listedNicks.addElement(nxNick);
+
+ }
+
+ }
+ return;
+ }
+ if (command.getCommand().equals(USERHOST_NUMERIC)) {
+
+ session.setBanMask(getNickHost(command.getArguments()));
+ }
+
+ if (command.getCommand().equals(END_OF_NAMES_NUMERIC)) {
+ doEndOfNames(session);
+ }
+ }
+
+ /**
+ * <p>Register this strategy with the Command object
+ */
+ public void register() {
+ Command.registerStrategy(NAMES_NUMERIC, this);
+ Command.registerStrategy(END_OF_NAMES_NUMERIC, this);
+ Command.registerStrategy(USERHOST_NUMERIC, this);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/NickCommandsStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmptBw02V
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpAkp_N8 differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/NickCommandsStrategy.java
==============================================================================
--- (empty file)
+++
branches/irc_chat_tab/src/htdocs/files/snirc/NickCommandsStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,55 @@
+
+
+/**
+ * <p>Strategy for handling the NICK command and related numeric
+ * responses from the server.
+ *
+ * @version $Id: NickCommandsStrategy.java,v 1.2 2003/12/02 22:08:19
bryan_w Exp $
+ */
+public class NickCommandsStrategy implements CommandProcessingStrategy {
+ public static final String NICK_IN_USE_NUMERIC = "433";
+ public static final String BAD_NICK_NUMERIC = "432";
+
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ public void execute(Command command, Chat session) {
+ if (command.getCommand().equals("NICK")) {
+ session.sendToUser(
+ "[N] " + command.getSource() + " is now known as "
+ command.getArgument(0));
+ if (session.isCurrentNick(command.getSource()))
+ session.setNick(command.getArgument(0));
+ String decoratedNick =
+ session.getDecoratedNickFromNickList(command.getSource());
+ if (decoratedNick == null) {
+ session.addToNickList(
+ command.getArgument(0),
+ Chat.MODE_NONE);
+ } else {
+ session.replaceOnNickList(
+ command.getSource(),
+ command.getArgument(0),
+ decoratedNick.charAt(0));
+ }
+
+ } else if (
+ command.getCommand().equals(BAD_NICK_NUMERIC)
+ || command.getCommand().equals(NICK_IN_USE_NUMERIC)) {
+ session.sendToServer("NICK " +
EntryDialog.promptForNick(command.getArgument(1) + ": " + command.getArgument(2)));
+ }
+ }
+
+ /**
+ * <p>Register a Strategy with the Command object.
+ * Strategies are responsible for telling the Command object
+ * what commands they are interested in, using its registerStrategy()
+ * method.
+ */
+ public void register() {
+ Command.registerStrategy("NICK", this);
+ Command.registerStrategy(BAD_NICK_NUMERIC, this);
+ Command.registerStrategy(NICK_IN_USE_NUMERIC, this);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/NoticeStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmprxyfDO
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp6ZpTRY differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/NoticeStrategy.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/NoticeStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,43 @@
+
+
+/**
+ * @version $Id: NoticeStrategy.java,v 1.2 2003/12/02 22:08:19 bryan_w
Exp $
+ */
+public class NoticeStrategy extends MessageStrategy {
+ public java.lang.String decorateChannelMessage(java.lang.String
source, java.lang.String message) {
+ return "-" + source + ":" + getSession().getChannelName()
+ "- " + message;
+ }
+
+ public java.lang.String decoratePrivateMessage(java.lang.String
source, java.lang.String message) {
+ return "-" + source + "-" + message;
+ }
+
+ public void doPing(String source, String message) {
+ try {
+ getSession().sendToUser(
+ "[P] Ping reply from "
+ + source
+ + " is "
+ + (System.currentTimeMillis()
+ - Long.parseLong(message.substring(6,
message.length() - 1).trim()))
+ / 1000
+ + " seconds.");
+ } catch (NumberFormatException e) {
+ }
+ }
+
+ public void doVersion(String source, String message) {
+ getSession().sendToUser(
+ "[V] " + source + " is using " + message.substring(7).replace('\001', ' '));
+ }
+
+ /**
+ * <p>Register a Strategy with the Command object.
+ * Strategies are responsible for telling the Command object
+ * what commands they are interested in, using its registerStrategy()
+ * method.
+ */
+ public void register() {
+ Command.registerStrategy("NOTICE", this);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Pair.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp485ILe
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmprs0ehP differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/Pair.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/Pair.java Fri Jun 20
07:16:16 2008
@@ -0,0 +1,21 @@
+
+// For some reason, Java doesn't have a simple pair class, so here is
one to use
+
+public class Pair {
+ public String first, second;
+
+ Pair() {
+ first = new String();
+ second = new String();
+ }
+
+ Pair(String one, String two) {
+ first = one;
+ second = two;
+ }
+
+ Pair(Pair p) {
+ first = p.first;
+ second = p.second;
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/PrivmsgStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpztMRYz
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmphLrp7C differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/PrivmsgStrategy.java
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/htdocs/files/snirc/PrivmsgStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,36 @@
+
+
+/**
+ * @version $Id: PrivmsgStrategy.java,v 1.2 2003/12/02 22:08:20
bryan_w Exp $
+ */
+public class PrivmsgStrategy extends MessageStrategy {
+ public java.lang.String decorateChannelMessage(java.lang.String
source, java.lang.String message) {
+ return "<" + source + "> " + message;
+ }
+
+ public java.lang.String decoratePrivateMessage(java.lang.String
source, java.lang.String message) {
+ return "*>" + source + "<* " + message;
+ }
+
+ public void doPing(String source, String message) {
+ getSession().sendToUser("[P] " + source + " PING'ed you.");
+ getSession().sendToServer(
+ "NOTICE " + source + " :\001PING " + message.substring(6));
+ }
+
+ public void doVersion(String source, String message) {
+ getSession().sendToUser("[C] " + source + " sent you a VERSION request");
+ getSession().sendToServer("NOTICE " + source +
+ " :\001VERSION SNirc_" + Chat.VERSION + " Java" +
System.getProperty("java.version") + " cl00bie <cl0...@sorcery.net>\001");
+ }
+
+ /**
+ * <p>Register a Strategy with the Command object.
+ * Strategies are responsible for telling the Command object
+ * what commands they are interested in, using its registerStrategy()
+ * method.
+ */
+ public void register() {
+ Command.registerStrategy("PRIVMSG", this);
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ScrollableOutputPanel.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmp5Xum9a
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpuxyyXn differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/ScrollableOutputPanel.java
==============================================================================
--- (empty file)
+++
branches/irc_chat_tab/src/htdocs/files/snirc/ScrollableOutputPanel.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,88 @@
+
+
+import java.awt.*;
+
+/**
+ * @version $Id: ScrollableOutputPanel.java,v 1.3 2004/07/26 16:00:12
halcy0n Exp $
+ */
+public class ScrollableOutputPanel
+ extends java.awt.Panel
+ implements java.awt.event.AdjustmentListener {
+
+ public static final int MAXLENGTH = 5000;
+ public static final int TEXTAREA_WIDTH = 80;
+ public static final int TEXTAREA_HEIGHT = 8;
+ private int evento = 0;
+
+ private Font chatFont = new Font("Monospace", Font.PLAIN, 12);
+ private StringBuffer buffer = new StringBuffer();
+ private final TextArea textArea =
+ new TextArea("", TEXTAREA_WIDTH, TEXTAREA_HEIGHT, TextArea.SCROLLBARS_NONE);
+ private final Scrollbar verticalScrollBar = new Scrollbar(Scrollbar.VERTICAL);
+
+ public ScrollableOutputPanel() {
+ setLayout(new java.awt.BorderLayout());
+ textArea.setEditable(false);
+ verticalScrollBar.setBlockIncrement(500);
+ verticalScrollBar.setUnitIncrement(80);
+ verticalScrollBar.addAdjustmentListener(this);
+ add("Center", textArea);
+ add("East", verticalScrollBar);
+ }
+
+ public void adjustmentValueChanged(java.awt.event.AdjustmentEvent
e) {
+ if(e.getValue() < evento) {
+ textArea.select(verticalScrollBar.getValue(), verticalScrollBar.getValue());
+ }
+
+ if(e.getValue() > evento) {
+ double ftemp = (double)evento * 1.2;
+ int temp = (int)ftemp;
+ textArea.select(temp,temp);
+ }
+
+ evento = e.getValue();
+ }
+
+ /**
+ * Append a line of text to the output text area, and adjust the scrollbar
+ * to fit. The text sent to this method should not have a newline
on the end.
+ */
+ public void appendLine(String text) {
+ text += "\n";
+ // Pop old text off the top
+ if (textArea.getText().length() > 25000) {
+ textArea.replaceRange(" ", 0, 2500);
+ textArea.setCaretPosition(textArea.getText().length());
+ }
+ if (verticalScrollBar.getValue() >
verticalScrollBar.getMaximum() - 300) {
+ if (buffer.length() > 0) {
+ textArea.append(buffer.toString());
+ buffer = new StringBuffer();
+ } else {
+ textArea.append(text);
+ }
+ verticalScrollBar.setValues(
+ textArea.getText().length(),
+ 80,
+ 0,
+ textArea.getText().length());
+ } else {
+ buffer.append(text);
+ if (buffer.length() > 2500) {
+ verticalScrollBar.setValue(verticalScrollBar.getMaximum());
+ }
+ }
+ }
+
+ public void clear() {
+ buffer = new StringBuffer();
+ textArea.setText("");
+ verticalScrollBar.setValues(0, 80, 0, 0);
+ }
+
+ public void setChatFont(Font chatFont) {
+ textArea.setFont(chatFont);
+ repaint();
+ }
+}
Added: branches/irc_chat_tab/src/htdocs/files/snirc/SimpleNumericsStrategy.class
==============================================================================
Binary files
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpkajTMm
and
/export/hdc3/borgletdata/dirs/2.worktable2.workers.default.codesite.274475043/logs.2.worktable2.workers.default.codesite.274475043/tmp/tmpnLyalP differ
Added: branches/irc_chat_tab/src/htdocs/files/snirc/SimpleNumericsStrategy.java
==============================================================================
--- (empty file)
+++
branches/irc_chat_tab/src/htdocs/files/snirc/SimpleNumericsStrategy.java
Fri Jun 20 07:16:16 2008
@@ -0,0 +1,145 @@
+
+
+/**
+ * <p>Handles the numerics for anything that just requires minor text
+ * rewriting and blatting to the outputPane. Currently handles replies
+ * for:
+ *
+ * <ul>
+ * <li>PING/PONG
+ * <li>WHOIS
+ * <li>MOTD
+ * <li>TOPIC
+ * <li>ERR_BANNEDFROMCHAN
+ * </ul>
+ *
+ * @version $Id: SimpleNumericsStrategy.java,v 1.4 2004/07/26 18:24:58
bryan_w Exp $
+ */
+public class SimpleNumericsStrategy implements
CommandProcessingStrategy {
+ public static final String WHOIS_NUMERIC = "311";
+ public static final String WHOIS_SERVER_NUMERIC = "312";
+ public static final String WHOIS_IRCOP_NUMERIC = "313";
+ public static final String WHOIS_IDLE_NUMERIC = "317";
+ public static final String WHOIS_END_NUMERIC = "318";
+ public static final String WHOIS_CHANNELS_NUMERIC = "319";
+ public static final String TOPIC_IS_NUMERIC = "332";
+ public static final String MOTD_NUMERIC = "372";
+ public static final String END_OF_MOTD_NUMERIC = "376";
+ public static final String MOTD_MISSING_NUMERIC = "422";
+ public static final String UNKNOWN_COMMAND = "421";
+ public static final String BANNED_NUMERIC = "474";
+
+ /**
+ * Performs the work of command processing. It does not have to be reentrant,
+ * the framework guarantees that only one thread will enter this method
+ * at a time.
+ */
+ public void execute(Command command, Chat session) {
+ String reply = "";
+
+ if (command.getCommand().equals(WHOIS_NUMERIC)) {
+ reply = "[W] " + command.getArgument(1) + " is " +
command.getArgument(2) + "@" + command.getArgument(3) + " (" +
command.getArgument(5) + ")";
+ } else if (command.getCommand().equals(BANNED_NUMERIC)){
+ session.sendToUser("[B] Cannot Join " +
command.getArgument(1) + " address is banned");
+
+ } else if (command.getCommand().equals("PING")) {
+ session.sendToServer("PONG " + command.getArgument(0));
+ if(ChatUserInterface.isDisplayingPingAndPong()) {
+ reply = "PING? PONG!";
+ }
+ } else if (command.getCommand().equals(WHOIS_SERVER_NUMERIC)) {
+ reply = "[W] " + command.getArgument(1) + " is on server "
+ command.getArgument(2) + " (" + command.getArgument(3) + ")";
+ } else if (command.getCommand().equals(WHOIS_IRCOP_NUMERIC)) {
+ reply = "[W] " + command.getArgument(1) + " " + command.getArgument(2);
+ } else if (command.getCommand().equals(WHOIS_IDLE_NUMERIC)) {
+ reply = "[W] " + command.getArgument(1) + " has been
idle " + secondsToString(command.getArgument(2));
+ } else if (command.getCommand().equals(WHOIS_END_NUMERIC)) {
+ reply = "[W] End of " + command.getArgument(1) + "'s Whois info";
+ } else if
(command.getCommand().equals(WHOIS_CHANNELS_NUMERIC)) {
+ reply = "[W] " + command.getArgument(1) + " is on
channel(s) " + command.getArgument(2);
+ } else if (command.getCommand().equals(MOTD_NUMERIC)) {
+ reply = command.getArgument(1);
+ } else if (command.getCommand().equals("332")) {
+ session.setChannelTopic("Topic: " + command.getArgument(2));
+ reply = "[T] The topic on " + command.getArgument(1) + "
is: " + command.getArgument(2);
+ } else if (command.getCommand().equals("TOPIC")) {
+ session.setChannelTopic("Topic: " + command.getArgument(1));
+ reply = "[T] " + command.getSource() + " has changed the
topic on " +
+ command.getArgument(0) + " to: " + command.getArgument(1);
+ } else if (command.getCommand().equals(END_OF_MOTD_NUMERIC) ||
command.getCommand().equals(MOTD_MISSING_NUMERIC)) {
+ session.serverConnectionIsActive();
+ } else if (command.getCommand().equals(UNKNOWN_COMMAND)) {
+ reply = "[E] Unknown command - Type /help for instructions" ;
+ }
+ session.sendToUser(reply);
+ }
+
+ /**
+ * <p>Register a Strategy with the Command object.
+ * Strategies are responsible for telling the Command object
+ * what commands they are interested in, using its registerStrategy()
+ * method.
+ */
+ public void register() {
+ Command.registerStrategy(WHOIS_NUMERIC, this);
+ Command.registerStrategy(WHOIS_END_NUMERIC, this);
+ Command.registerStrategy(WHOIS_IDLE_NUMERIC, this);
+ Command.registerStrategy(WHOIS_IRCOP_NUMERIC, this);
+ Command.registerStrategy(WHOIS_CHANNELS_NUMERIC, this);
+ Command.registerStrategy(WHOIS_SERVER_NUMERIC, this);
+ Command.registerStrategy(MOTD_NUMERIC, this);
+ Command.registerStrategy(END_OF_MOTD_NUMERIC, this);
+ Command.registerStrategy(MOTD_MISSING_NUMERIC, this);
+ Command.registerStrategy(TOPIC_IS_NUMERIC, this);
+ Command.registerStrategy("PING", this);
+ Command.registerStrategy("TOPIC", this);
+ Command.registerStrategy(BANNED_NUMERIC, this);
+ }
+
+ private String secondsToString(String secondsString) {
+ int seconds;
+ try {
+ seconds = Integer.parseInt(secondsString);
+ } catch (NumberFormatException nfe) {
+ return secondsString;
+ }
+
+ StringBuffer response = new StringBuffer();
+ if (seconds > 24 * 60 * 60) {
+ int days = seconds / 24 * 60 * 60;
+ if (days == 1) {
+ response.append("1 day, ");
+ } else {
+ response.append(days + " days, ");
+ }
+ seconds -= days * 24 * 60 * 60;
+ }
+
+ if (seconds > 60 * 60) {
+ int hours = seconds / 60 * 60;
+ if (hours == 1) {
+ response.append("1 hour, ");
+ } else {
+ response.append(hours + " hours, ");
+ }
+ seconds -= hours * 60 * 60;
+ }
+
+ if (seconds > 60) {
+ int minutes = seconds / 60;
+ if (minutes == 1) {
+ response.append("1 minute, ");
+ } else {
+ response.append(minutes + " minutes, ");
+ }
+ seconds -= minutes * 60;
+ }
+
+ if (seconds == 1) {
+ response.append("1 second");
+ } else {
+ response.append(seconds + " seconds");
+ }
+ return response.toString();
+ }
+}
Modified: branches/irc_chat_tab/src/main/codesite.py
==============================================================================
--- branches/irc_chat_tab/src/main/codesite.py (original)
+++ branches/irc_chat_tab/src/main/codesite.py Fri Jun 20 07:16:16 2008
@@ -42,7 +42,8 @@
import demetrius.persist
import demetrius.constants
-
+from chat import irc_logbot
+import chat.page_setup
def main(port, daemonized):
@@ -81,38 +82,6 @@
dit_persist.register_demetrius_persist(demetrius_persist)
#dit_persist = None
- """
- for i in range(6):
- username = "testuser" + str(i)
- demetrius_persist.CreateUser(username + "@gmail.com", username, "testpass")
- else:
- pass
- """
-
-
- #test_project = demetrius_persist.GetProject('testproject')
- #if test_project == None:
- # print "couldn't load testproject from disk, creating it"
- # demetrius_persist.CreateProject("testproject", [1], [2, 3, 4,
5], "This is the summary for the test project.",
- # "http://www.google.com",
- # "Now we must describe the test project.",
["label1", "label2", "label3"], "asf20", conn_pool)
- # test_project = demetrius_persist.GetProject('testproject')
- # test_project.set_repository_url('https://teamfreedom-projectcode.googlecode.com/svn/')
- # test_project.set_persist_repository_url('svn://eastmont.no-ip.org/var/svn/shared/sean_longhouse_persist')
- # test_project.set_persist_repository_username('longhouse')
- # test_project.set_persist_repository_password('longhousepass')
- # link = test_project.add_linksurl()
- # link.set_url("http://www.google.com")
- # link.set_label("Google label")
- #else:
- # print 'loaded testproject from disk'
-
-
- # this causes an error because the reactor hasn't been started yet
- #test_project.setup_svn_controller()
-
- # demetrius_persist._StoreProject(test_project)
-
framework_pages = framework.page_setup.PageSetup(
server, conn_pool, demetrius_persist, dit_persist,
@@ -128,25 +97,20 @@
server, conn_pool, demetrius_persist, dit_persist,
worktable, template_data)
dit_pages.RegisterPages()
+
+ chat_pages = chat.page_setup.PageSetup(
+ server, conn_pool, demetrius_persist, dit_persist,
+ worktable, template_data)
+ chat_pages.RegisterPages()
-
-
-
- def post_reactor_methods():
- """Some things need to happen after the reactor is run.
- reactor.callWhenRunning seems to be suffering from a race
conditions bug
- (should be fixed with the next version of twisted)
- so we just wait a few seconds to call these things."""
-
- # load serialized users and projects
- demetrius_persist.GetAllUsers()
- demetrius_persist.GetAllProjects()
-
- log.msg('Ready to serve pages.')
-
- log.msg('calling two methods after reactor is run')
- reactor.callLater(2, post_reactor_methods)
+ # These things need to be called after the twisted reactor is running
+
+ server.callWhenRunning(demetrius_persist.GetAllUsers)
+
+ server.callWhenRunning(demetrius_persist.GetAllProjects)
+
+ server.callWhenRunning(irc_logbot.connect)
server.run()
Modified: branches/irc_chat_tab/src/main/codesiteserver.py
==============================================================================
--- branches/irc_chat_tab/src/main/codesiteserver.py (original)
+++ branches/irc_chat_tab/src/main/codesiteserver.py Fri Jun 20
07:16:16 2008
@@ -14,23 +14,69 @@
import resources
+from chat import irc_server
+
class CodesiteServer(object):
def __init__(self, serviceport):
self.port = serviceport
self.root_resource = resources.RootResource()
self.site = server.Site(self.root_resource)
+ self.running = False
+ self.callTheseWhenRunning = []
+ def callWhenRunning(self, callMe):
+ """Have the server execute the given callable after the twisted
+ reactor is running."""
+
+ if self.running:
+ callMe()
+ else:
+ self.callTheseWhenRunning.append(callMe)
+
+ def reactorRunning(self):
+ """Callback for once the reactor has started up.
+ Call all callbacks that were stored up with callWhenRunning"""
+
+ for callMe in self.callTheseWhenRunning:
+ callMe()
+
+ self.callTheseWhenRunning = []
+
+ log.msg('Longhouse startup complete.')
+
def run(self):
+
+ # web server
try:
+ log.msg('Listening for http requests...')
reactor.listenTCP(self.port, self.site)
+ log.msg('\tready')
except CannotListenError:
log.msg('Error: another process is already bound to port', self.port)
sys.exit(1)
+ # irc server
+ try:
+ log.msg('Listening for irc requests...')
+ reactor.listenTCP(6667, irc_server.getLonghouseIRCFactory())
+ log.msg('\tready')
+ except CannotListenError:
+ log.msg('Error: another process is already bound to port 6667')
+ sys.exit(1)
+
+
+
+
log.msg('Starting twisted reactor')
-
+
+ self.running = True
+
+ # I wish we could use reactor.callWhenRunning, but to avoid a nasty
+ # race condition we just wait a few seconds instead
+ reactor.callLater(2, self.reactorRunning)
+
reactor.run()
def RegisterStaticFiles(self, relative_uri, path):
Added: branches/irc_chat_tab/src/templates/chat/chatpage.ezt
==============================================================================
--- (empty file)
+++ branches/irc_chat_tab/src/templates/chat/chatpage.ezt Fri Jun 20
07:16:16 2008
@@ -0,0 +1,56 @@
+[define title]Longhouse Chat[end]
+
+[define breadcrumbs]
+<span class="item">Longhouse Chat</span>
+[end]
+
+[include "../demetrius/master-header.ezt" "showtabs"]
+
+
+[if-any logged_in_user]
+
+ <applet
+ code=IRCApplet.class
+ codebase=/files/pjirc
+ archive="irc.jar,pixx.jar"
+ width=640
+ height=400>
+ <param name="nick" value="[chat_username]">
+ <param name="alternatenick" value="[chat_username]???">
+ <param name="name" value="Java User">
+ <param name="host" value="localhost">
+ <param name="gui" value="pixx">
+
+ <param name="command1" value="join #foobar">
+
+ </applet>
+
+ <!--
+
+ <APPLET
+ CODEBASE=/files/snirc
+ CODE="Chat.class" WIDTH=600 HEIGHT=400>
+ <PARAM NAME="Server" VALUE="localhost">
+ <PARAM NAME="Port" VALUE="6667">
+ <PARAM NAME="Channel" VALUE="#foobar">
+ <PARAM NAME="AllowChannelChange" VALUE="Yes">
+ <PARAM NAME="FontName" VALUE="Monospaced">
+ <PARAM NAME="FontSize" VALUE="12">
+ <PARAM NAME="Barebones" VALUE="No">
+ <PARAM NAME="HelpURL" VALUE="http://www.provider.org/help/">
+ <PARAM NAME="ListURL" VALUE="http://www.provider.org/list/">
+ </APPLET>
+
+ -->
+
+[else]
+
+ You must be signed in to use this page.
+
+[end]
+
+
+
+
+
+[include "../demetrius/master-footer.ezt"]
Modified: branches/irc_chat_tab/src/templates/demetrius/maintabs.ezt
==============================================================================
--- branches/irc_chat_tab/src/templates/demetrius/maintabs.ezt (original)
+++ branches/irc_chat_tab/src/templates/demetrius/maintabs.ezt Fri Jun
20 07:16:16 2008
@@ -25,6 +25,11 @@
<div class="tT"><a onclick="cancelBubble=true;" href="/p/[projectname]/source">Source</a></div>
</th><td> </td>
+ <th class="int7" onclick="if (!cancelBubble) _go('/p/[projectname]/chat');">
+ <div class="tc1"><div class="tc2"><div class="tc3"></div></div></div>
+ <div class="tT"><a onclick="cancelBubble=true;" href="/p/[projectname]/chat">Chat</a></div>
+ </th><td> </td>
+
[if-any demetrius_perms.edit_project]
<th class="int5" onclick="if (!cancelBubble) _go('/p/[projectname]/adminPortal');">
<div class="tc1"><div class="tc2"><div class="tc3"></div></div></div>