i3mclient.i3m
Class I3M

java.lang.Object
  |
  +--i3mclient.i3m.I3M
All Implemented Interfaces:
ErrorListener, EventListener, LoginGUIListener, MessageListener, Runnable, SelectionListener, ServerMethodListener, ShellListener, SMGetDailyComicListener, SMGetOfflineMessagesListener, SMLoginAccountListener, SMLogoutAccountListener, SMSetStatusListener, SMSetUserDataListener, org.eclipse.swt.internal.SWTEventListener

public class I3M
extends Object
implements SelectionListener, ShellListener, ErrorListener, MessageListener, Runnable, SMGetDailyComicListener, SMSetStatusListener, SMGetOfflineMessagesListener, SMLoginAccountListener, SMLogoutAccountListener, LoginGUIListener, SMSetUserDataListener

The logic of the main window of I3M.

Author:
Dirk Plate
See Also:
I3MGUI

Field Summary
static int ADDDISCUSSIONMEMBERMESSAGE
          Identifies a add discussion member message.
static int AWAY
          The away status.
static int AWAYBIRTHDAY0
          The away with birthday today status.
static int AWAYBIRTHDAY1
          The away with birthday in one day status.
static int AWAYBIRTHDAY2
          The away with birthday in two days status.
static int BUDDYCHANGEDMESSAGE
          Identifies a buddy changed message.
static int DISCUSSIONLEFT
          Identifies that the current user left a discussion completely.
static int DISCUSSIONMEMBERCHANGEDMESSAGE
          Identifies a discussion member changed message.
static int DISCUSSIONWINDOWCLOSED
          Identifies that the current user only closed the discussion window.
static String[] EMAILPROTOCOLPORT
          Contains all email protocol ports.
static String[] EMAILPROTOCOLTEXT
          Contains all email protocol strings.
static int IMAP4
          Identifies POP3 email protocol.
static int INVISIBLE
          The invisible status.
static String[] LANGUAGESHORT
          The short language strings for communciation with I3M-Server.
static int OFFLINE
          The offline status.
static int OFFLINEBIRTHDAY0
          The offline with birthday today status.
static int OFFLINEBIRTHDAY1
          The offline with birthday in one day status.
static int OFFLINEBIRTHDAY2
          The offline with birthday in two days status.
static int ONLINE
          The online status.
static int ONLINEBIRTHDAY0
          The online with birthday today status.
static int ONLINEBIRTHDAY1
          The online with birthday in one day status.
static int ONLINEBIRTHDAY2
          The online with birthday in two days status.
static int POP3
          Identifies POP3 email protocol.
static int REALSTATUSCOUNT
          How many status exist, which the user really could choose.
static int REMOVEDISCUSSIONMEMBERMESSAGE
          Identifies a remove discussion member message.
static int SHAPEMESSAGE
          Identifies a shape (circle, rectangle etc.) message.
static String[] STATUSTEXT
          Defines strings for all available user status.
static int TEXTMESSAGE
          Identifies a plaintext message.
static int TRAYICONCLOSE
          Identifies that the user choosed "close" from trayicon context menu.
static int TRAYICONLEFTCLICK
          Identifies that the user clicked with left mouse button on the trayicon.
static int TRAYICONRESTORE
          Identifies that the user choosed "restore" from trayicon context menu.
 
Constructor Summary
I3M()
          Constructor.
 
Method Summary
 void addStatusListener(StatusListener listener)
          Add a status listener.
 void dailyComicReceived(byte[] comicBytes)
          Called if getDailyComic was successfull.
 void errorMessage(String message)
          Call it, to bring up a message box.
static String getPassword()
          Static function to return the current password (needed from Config).
static String getResourcePath(String resource)
          Static function to get absolute path of a resource.
static UserData getUserData()
          Static function to return the current userData.
 UserList getUserList()
          Returns the buddylist.
 void i3mServerException(I3MServerException exception)
          Called if a server exception is thrown.
 void init(Shell setWindow, com.jeans.trayicon.WindowsTrayIcon setTrayIcon)
          Inits the rest.
 void loginAccountDone(long userID)
          Called if loginAccount was successfull.
 void loginError()
          Called, when a login error (no session) occured.
 void loginGUIDone(long newUserID, String newPassword)
          Is called, if a login from gui was successfull.
 void logoutAccountDone()
          Called if logoutAccount was successfull.
 void messageReceived(MessageData message)
          Called if Polling receives a new message from Server.
 void offlineMessagesReceived(MessageData[] offlineMessages)
          Called if getOfflineMessages was successfull.
 void removeStatusListener(StatusListener listener)
          Remove a status listener.
 void run()
           
static void setPassword(String passwordSet)
          Static function to set the current password (needed from Config).
 void setStatusDone(int newStatus)
          Called if setStatus was successfull.
 void setTrayEventSource(int trayEventSourceSet)
          Set the source of the tray event.
static void setUserData(UserData userDataSet)
          Static function to set the current userData.
 void setUserDataDone(UserData userData)
          Called if setUserData was successfull.
 void shellActivated(ShellEvent event)
           
 void shellClosed(ShellEvent event)
           
 void shellDeactivated(ShellEvent event)
           
 void shellDeiconified(ShellEvent event)
           
 void shellIconified(ShellEvent event)
           
 void widgetDefaultSelected(SelectionEvent event)
           
 void widgetSelected(SelectionEvent event)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUSTEXT

public static final String[] STATUSTEXT
Defines strings for all available user status.


REALSTATUSCOUNT

public static final int REALSTATUSCOUNT
How many status exist, which the user really could choose.

See Also:
Constant Field Values

OFFLINE

public static final int OFFLINE
The offline status. The user is offline and can't receive anything.

See Also:
Constant Field Values

ONLINE

public static final int ONLINE
The online status. The user is online and receive anything.

See Also:
Constant Field Values

AWAY

public static final int AWAY
The away status. The user is away and wants inform other users about this.

See Also:
Constant Field Values

INVISIBLE

public static final int INVISIBLE
The invisible status. The user is invisible, but for other users he seems to be offline.

See Also:
Constant Field Values

OFFLINEBIRTHDAY0

public static final int OFFLINEBIRTHDAY0
The offline with birthday today status. The user is offline and has birthday today.

See Also:
Constant Field Values

OFFLINEBIRTHDAY1

public static final int OFFLINEBIRTHDAY1
The offline with birthday in one day status. The user is offline and has birthday tomorrow.

See Also:
Constant Field Values

OFFLINEBIRTHDAY2

public static final int OFFLINEBIRTHDAY2
The offline with birthday in two days status. The user is offline and has birthday in two days.

See Also:
Constant Field Values

ONLINEBIRTHDAY0

public static final int ONLINEBIRTHDAY0
The online with birthday today status. The user is online and has birthday today.

See Also:
Constant Field Values

ONLINEBIRTHDAY1

public static final int ONLINEBIRTHDAY1
The online with birthday in one day status. The user is online and has birthday tomorrow.

See Also:
Constant Field Values

ONLINEBIRTHDAY2

public static final int ONLINEBIRTHDAY2
The online with birthday in two days status. The user is online and has birthday in two days.

See Also:
Constant Field Values

AWAYBIRTHDAY0

public static final int AWAYBIRTHDAY0
The away with birthday today status. The user is away and has birthday today.

See Also:
Constant Field Values

AWAYBIRTHDAY1

public static final int AWAYBIRTHDAY1
The away with birthday in one day status. The user is away and has birthday tomorrow.

See Also:
Constant Field Values

AWAYBIRTHDAY2

public static final int AWAYBIRTHDAY2
The away with birthday in two days status. The user is away and has birthday in two days.

See Also:
Constant Field Values

TEXTMESSAGE

public static final int TEXTMESSAGE
Identifies a plaintext message.

See Also:
Constant Field Values

SHAPEMESSAGE

public static final int SHAPEMESSAGE
Identifies a shape (circle, rectangle etc.) message.

See Also:
Constant Field Values

BUDDYCHANGEDMESSAGE

public static final int BUDDYCHANGEDMESSAGE
Identifies a buddy changed message. Received if a status of a user in buddylist has changed.

See Also:
Constant Field Values

DISCUSSIONMEMBERCHANGEDMESSAGE

public static final int DISCUSSIONMEMBERCHANGEDMESSAGE
Identifies a discussion member changed message. Received if a status of a user in a discussion has changed.

See Also:
Constant Field Values

ADDDISCUSSIONMEMBERMESSAGE

public static final int ADDDISCUSSIONMEMBERMESSAGE
Identifies a add discussion member message. Received if a new user joins in a discussion.

See Also:
Constant Field Values

REMOVEDISCUSSIONMEMBERMESSAGE

public static final int REMOVEDISCUSSIONMEMBERMESSAGE
Identifies a remove discussion member message. Received if a user left a discussion.

See Also:
Constant Field Values

LANGUAGESHORT

public static final String[] LANGUAGESHORT
The short language strings for communciation with I3M-Server.


DISCUSSIONLEFT

public static final int DISCUSSIONLEFT
Identifies that the current user left a discussion completely.

See Also:
Constant Field Values

DISCUSSIONWINDOWCLOSED

public static final int DISCUSSIONWINDOWCLOSED
Identifies that the current user only closed the discussion window.

See Also:
Constant Field Values

TRAYICONLEFTCLICK

public static final int TRAYICONLEFTCLICK
Identifies that the user clicked with left mouse button on the trayicon.

See Also:
Constant Field Values

TRAYICONRESTORE

public static final int TRAYICONRESTORE
Identifies that the user choosed "restore" from trayicon context menu.

See Also:
Constant Field Values

TRAYICONCLOSE

public static final int TRAYICONCLOSE
Identifies that the user choosed "close" from trayicon context menu.

See Also:
Constant Field Values

EMAILPROTOCOLTEXT

public static final String[] EMAILPROTOCOLTEXT
Contains all email protocol strings.


EMAILPROTOCOLPORT

public static final String[] EMAILPROTOCOLPORT
Contains all email protocol ports.


POP3

public static final int POP3
Identifies POP3 email protocol.

See Also:
Constant Field Values

IMAP4

public static final int IMAP4
Identifies POP3 email protocol.

See Also:
Constant Field Values
Constructor Detail

I3M

public I3M()
Constructor. Init variables and register object as listener to other classes.

Method Detail

init

public void init(Shell setWindow,
                 com.jeans.trayicon.WindowsTrayIcon setTrayIcon)
Inits the rest. Needs an open window.

Parameters:
setWindow - the main shell of i3m
setTrayIcon - the small icon in the lower right edge of windows (null if linux)

addStatusListener

public void addStatusListener(StatusListener listener)
Add a status listener. The listener will be saved in a intern list and informed at every change of the user status.

Parameters:
listener - the listener to register

removeStatusListener

public void removeStatusListener(StatusListener listener)
Remove a status listener. The listener will be removed from a intern list.

Parameters:
listener - the listener to unregister

getUserList

public UserList getUserList()
Returns the buddylist.

Returns:
the buddylist

widgetSelected

public void widgetSelected(SelectionEvent event)
Specified by:
widgetSelected in interface SelectionListener

widgetDefaultSelected

public void widgetDefaultSelected(SelectionEvent event)
Specified by:
widgetDefaultSelected in interface SelectionListener

shellActivated

public void shellActivated(ShellEvent event)
Specified by:
shellActivated in interface ShellListener

shellClosed

public void shellClosed(ShellEvent event)
Specified by:
shellClosed in interface ShellListener

shellDeactivated

public void shellDeactivated(ShellEvent event)
Specified by:
shellDeactivated in interface ShellListener

shellDeiconified

public void shellDeiconified(ShellEvent event)
Specified by:
shellDeiconified in interface ShellListener

shellIconified

public void shellIconified(ShellEvent event)
Specified by:
shellIconified in interface ShellListener

loginError

public void loginError()
Description copied from interface: ErrorListener
Called, when a login error (no session) occured.

Specified by:
loginError in interface ErrorListener

errorMessage

public void errorMessage(String message)
Description copied from interface: ErrorListener
Call it, to bring up a message box.

Specified by:
errorMessage in interface ErrorListener
Parameters:
message - The message which should apear in the message box.

messageReceived

public void messageReceived(MessageData message)
Description copied from interface: MessageListener
Called if Polling receives a new message from Server.

Specified by:
messageReceived in interface MessageListener
Parameters:
message - The new received message

getUserData

public static final UserData getUserData()
Static function to return the current userData.

Returns:
the UserData of current user
See Also:
setUserData(UserData)

setUserData

public static void setUserData(UserData userDataSet)
Static function to set the current userData. Updates all other object, which depends on values of userData.

Parameters:
userDataSet - The new userData
See Also:
getUserData()

getPassword

public static final String getPassword()
Static function to return the current password (needed from Config).

Returns:
The password of current user in plain text
See Also:
setPassword(String)

setPassword

public static final void setPassword(String passwordSet)
Static function to set the current password (needed from Config).

Parameters:
passwordSet - The new password of current user in plain text
See Also:
getPassword()

getResourcePath

public static String getResourcePath(String resource)
Static function to get absolute path of a resource.

Parameters:
resource - The relative path to a file.
Returns:
The absolute path to a file. If not found, this value is the relative path again.

setTrayEventSource

public void setTrayEventSource(int trayEventSourceSet)
Set the source of the tray event. This function is needed because run has no parameter and this class must know, who do the run call.

Parameters:
trayEventSourceSet - Set the source of the tray event. Must be one of this consts: TRAYICONLEFTCLICK, TRAYICONRESTORE, TRAYICONCLOSE

run

public void run()
Specified by:
run in interface Runnable

dailyComicReceived

public void dailyComicReceived(byte[] comicBytes)
Description copied from interface: SMGetDailyComicListener
Called if getDailyComic was successfull.

Specified by:
dailyComicReceived in interface SMGetDailyComicListener
Parameters:
comicBytes - The received daily comic as byte array

i3mServerException

public void i3mServerException(I3MServerException exception)
Description copied from interface: ServerMethodListener
Called if a server exception is thrown.

Specified by:
i3mServerException in interface ServerMethodListener
Parameters:
exception - The converted I3M-server exception

setStatusDone

public void setStatusDone(int newStatus)
Description copied from interface: SMSetStatusListener
Called if setStatus was successfull.

Specified by:
setStatusDone in interface SMSetStatusListener
Parameters:
newStatus - The status which was set

offlineMessagesReceived

public void offlineMessagesReceived(MessageData[] offlineMessages)
Description copied from interface: SMGetOfflineMessagesListener
Called if getOfflineMessages was successfull.

Specified by:
offlineMessagesReceived in interface SMGetOfflineMessagesListener
Parameters:
offlineMessages - The received offline messages

loginAccountDone

public void loginAccountDone(long userID)
Description copied from interface: SMLoginAccountListener
Called if loginAccount was successfull.

Specified by:
loginAccountDone in interface SMLoginAccountListener
Parameters:
userID - The userID of the user who logged in

logoutAccountDone

public void logoutAccountDone()
Description copied from interface: SMLogoutAccountListener
Called if logoutAccount was successfull.

Specified by:
logoutAccountDone in interface SMLogoutAccountListener

loginGUIDone

public void loginGUIDone(long newUserID,
                         String newPassword)
Description copied from interface: LoginGUIListener
Is called, if a login from gui was successfull.

Specified by:
loginGUIDone in interface LoginGUIListener
Parameters:
newUserID - The new accepted userID
newPassword - The new accepted password

setUserDataDone

public void setUserDataDone(UserData userData)
Description copied from interface: SMSetUserDataListener
Called if setUserData was successfull.

Specified by:
setUserDataDone in interface SMSetUserDataListener
Parameters:
userData - The userData which was set.