wtanaka.praya.yahoo
Class YahooClient

java.lang.Object
  |
  +--wtanaka.praya.Protocol
        |
        +--wtanaka.praya.yahoo.YahooClient
All Implemented Interfaces:
Constants, java.io.Serializable

public class YahooClient
extends Protocol
implements java.io.Serializable, Constants

Yahoo Pager Client Library adapted from gtkyahoo

 Yahoo Pager Client Library

 This code is based on code by Douglas Winslow. The original info
 from his code is listed below. This code has taken his code and has
 been altered to my naming and coding conventions and has been made
 more usable as a library of routines.

 -- Nathan Neulinger 
 
 Yahoo Pager Client Emulator Pro - yppro.c
 A basic reference implementation
 Douglas Winslow 
 Tue Sep  1 02:28:21 EDT 1998
 Version 2, Revision 2
 Known to compile on Linux 2.0, FreeBSD 2.2, and BSDi 3.0.
 hi to aap bdc drw jfn jrc mm mcd [cejn]b #cz and rootshell

 Finally!
 Yahoo finally patched their server-side, and things will be getting
 back to "normal".  I will continue to maintain this code as long as
 there is interest for it.  Since Yahoo will be discontinuing YPNS1.1
 login support shortly, I've upgraded this client to do YPNS1.2.  You
 *must* have a password to pass authentication to the pager server.
 This authentication is done by a weird HTTP cookie method.

 This code is distributed under the GNU General Public License (GPL)
 
Configuration items include:

Sample Code for getting "new mail" messages

 Protocol proto = new YahooClient();

 // Add a listener to receive incoming messages.
 proto.addListener(new Pushable()
                   {
                      public void receiveMessage (Message m)
                      {
                         if (m instanceof MailMessage)
                         {
                            MailMessage newmail = (MailMessage) m;
                            System.out.println (newmail.getUser()
                               + " has "
                               + newmail.getNumMessages()
                               + " new messages.");
                         }
                      }
                   });
 

Return to Sourceforge or the Praya Homepage

Version:
$Name: $ $Date: 2002/07/14 23:04:01 $
Author:
$Author: wtanaka $
See Also:
Serialized Form

Field Summary
static int CONF_ID
           
static int CONF_ITEM_COUNT
           
static int CONF_PASSWD
           
static int CONF_STATUS
           
(package private) static java.lang.String current_config
           
private  ConfigItem[] m_configItems
           
private  GTKYEvents m_events
           
private  boolean m_firstConnect
           
private  GTKYStatus m_status
           
private  YahooReadThread m_thread
           
private  YahooContext m_yahooContext
           
static int SO_TIMEOUT
           
static java.lang.String[] statusList
          List of visible strings, in any order, corresponding to the status configuration pulldown menu.
 
Fields inherited from class wtanaka.praya.Protocol
descriptionListeners, iAmGarbage, m_buddyList, m_configPanel, m_currentDescription, m_messageListeners, recipientListeners
 
Fields inherited from interface wtanaka.praya.yahoo.Constants
PROXY_AUTH_HEADER, VERSION, YAHOO_ADDRESS_HOST, YAHOO_ADDRESS_PORT, YAHOO_AUTH_HOST, YAHOO_AUTH_PORT, YAHOO_COLOR_BLACK, YAHOO_COLOR_BLUE, YAHOO_COLOR_GRAY, YAHOO_COLOR_GREEN, YAHOO_COLOR_LIGHTBLUE, YAHOO_COLOR_OLIVE, YAHOO_COLOR_ORANGE, YAHOO_COLOR_PINK, YAHOO_COLOR_PURPLE, YAHOO_COLOR_RED, YAHOO_CONNECT_HTTP, YAHOO_CONNECT_HTTPPROXY, YAHOO_CONNECT_NORMAL, YAHOO_CONNECT_SOCKS4, YAHOO_CONNECT_SOCKS5, YAHOO_DATA_HOST, YAHOO_DATA_PORT, YAHOO_EVENT_APPOINTMENT, YAHOO_EVENT_BILLPAY, YAHOO_EVENT_BIRTHDAY, YAHOO_EVENT_CALL, YAHOO_EVENT_CHAT, YAHOO_EVENT_GRADUATION, YAHOO_EVENT_HOLIDAY, YAHOO_EVENT_INTERVIEW, YAHOO_EVENT_MEETING, YAHOO_EVENT_NETEVENT, YAHOO_EVENT_OTHER, YAHOO_EVENT_TVSHOW, YAHOO_MSGTYPE_BOUNCE, YAHOO_MSGTYPE_DENY_BUDDY, YAHOO_MSGTYPE_ERROR, YAHOO_MSGTYPE_INVISIBLE, YAHOO_MSGTYPE_KNOWN_USER, YAHOO_MSGTYPE_NONE, YAHOO_MSGTYPE_NORMAL, YAHOO_MSGTYPE_OFFLINE, YAHOO_MSGTYPE_SESSION_EXPIRED, YAHOO_MSGTYPE_STATUS, YAHOO_MSGTYPE_UNKNOWN_USER, YAHOO_PACKET_HEADER_SIZE, YAHOO_PAGER_HOST, YAHOO_PAGER_HTTP_HOST, YAHOO_PAGER_HTTP_PORT, YAHOO_PAGER_PORT, YAHOO_PROTOCOL_HEADER, YAHOO_SERVICE_ADDIDENT, YAHOO_SERVICE_ADDIGNORE, YAHOO_SERVICE_CALENDAR, YAHOO_SERVICE_CHATINVITE, YAHOO_SERVICE_CHATLOGOFF, YAHOO_SERVICE_CHATLOGON, YAHOO_SERVICE_CHATMSG, YAHOO_SERVICE_CONFADDINVITE, YAHOO_SERVICE_CONFDECLINE, YAHOO_SERVICE_CONFINVITE, YAHOO_SERVICE_CONFLOGOFF, YAHOO_SERVICE_CONFLOGON, YAHOO_SERVICE_CONFMSG, YAHOO_SERVICE_FILETRANSFER, YAHOO_SERVICE_GAMELOGOFF, YAHOO_SERVICE_GAMELOGON, YAHOO_SERVICE_GROUPRENAME, YAHOO_SERVICE_IDACT, YAHOO_SERVICE_IDDEACT, YAHOO_SERVICE_IDLE, YAHOO_SERVICE_ISAWAY, YAHOO_SERVICE_ISBACK, YAHOO_SERVICE_LOGOFF, YAHOO_SERVICE_LOGON, YAHOO_SERVICE_MAILSTAT, YAHOO_SERVICE_MESSAGE, YAHOO_SERVICE_NEWCONTACT, YAHOO_SERVICE_NEWMAIL, YAHOO_SERVICE_NEWPERSONALMAIL, YAHOO_SERVICE_PASSTHROUGH2, YAHOO_SERVICE_PING, YAHOO_SERVICE_SYSMESSAGE, YAHOO_SERVICE_USERSTAT, YAHOO_STATUS_AVAILABLE, YAHOO_STATUS_BRB, YAHOO_STATUS_BUSY, YAHOO_STATUS_CUSTOM, YAHOO_STATUS_DISCONNECTED, YAHOO_STATUS_IDLE, YAHOO_STATUS_INVISIBLE, YAHOO_STATUS_NOTATDESK, YAHOO_STATUS_NOTATHOME, YAHOO_STATUS_NOTINOFFICE, YAHOO_STATUS_ONPHONE, YAHOO_STATUS_ONVACATION, YAHOO_STATUS_OUTTOLUNCH, YAHOO_STATUS_STEPPEDOUT, YAHOO_STYLE_BOLDOFF, YAHOO_STYLE_BOLDON, YAHOO_STYLE_ITALICOFF, YAHOO_STYLE_ITALICON, YAHOO_STYLE_UNDERLINEOFF, YAHOO_STYLE_UNDERLINEON, YAHOO_STYLE_URLOFF, YAHOO_STYLE_URLON, YAHOO_USER_AGENT
 
Constructor Summary
YahooClient()
          Constructor
 
Method Summary
private  void append_notify_msg(java.lang.String msg)
          Conditionally inform everybody that wants to know about the notify message
(package private)  java.lang.String byteArrayToString(byte[] array)
           
 void checkForNewMessages(boolean isAutomatic)
          Checks for new messages on the protocol.
 void connect()
          Connects to the network, if that makes any sense.
 CommandInterface[] consoleCommands()
          Returns a list of commands available through this console.
 void disconnect()
          Disconnects from the network, if that makes any sense.
 java.lang.String getBuddyGroup(java.lang.String buddyID)
          Given a Yahoo ID, return its corresponding group name if it is a buddy of the currently logged in user.
 ConfigItem[] getConfiguration()
           
 Recipient getDefaultRecipient()
           
static java.awt.Image getIcon()
           
static java.lang.String getProtocolDescription()
          Used to describe the class of this protocol, before any instances have been created.
 YahooContext getYahooContext()
          Gets the context for this instance of YahooClient.
(package private)  void gtkyahoo_userlist_refresh()
           
(package private)  void gtkyahoo_userlist_update(java.lang.String user_to_update)
           
 boolean isConnected()
          Returns if the protocol is connected right now.
 void process_calendar_message(YahooPacket pkt)
           
(package private)  void process_packet_chatinvite(YahooPacket pkt)
           
(package private)  void process_packet_conference(YahooPacket pkt)
           
(package private)  void process_packet_filetransfer(YahooPacket pkt)
           
 void process_packet_message(YahooPacket pkt)
           
 void process_packet_newmail(YahooPacket pkt)
           
(package private)  void process_packet_ping(YahooPacket pkt)
           
(package private)  void process_packet_status(YahooPacket pkt)
           
private  void retryInit()
           
private  void set_status_line(YahooIDStatus rec)
           
 void setStatus(int status)
           
 void setStatus(Status status)
          Sets the status.
private static Status statusFromYahooIDStatus(YahooIDStatus rec, int packetService)
           
private static char y_pp_st_get(java.lang.String content, int itmpc)
           
private  void yahoo_cmd_activate_id(YahooContext ctx, java.lang.String newid)
           
private  void yahoo_cmd_logoff(YahooContext ctx)
           
private  void yahoo_cmd_logon(YahooContext ctx, int initial_status)
          Log in, optionally activating other secondary identities
(package private)  void yahoo_cmd_msg(YahooContext ctx, java.lang.String active_user, java.lang.String toUser, java.lang.String msg)
           
private  void yahoo_cmd_user_status(YahooContext ctx)
           
(package private) static void yahoo_free_buddies(YahooContext ctx)
          Free a buddy list
(package private) static void yahoo_free_identities(YahooContext ctx)
           
(package private)  int yahoo_getdata(YahooContext ctx)
           
private  void yahoo_parsepacket_calendar(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  void yahoo_parsepacket_chatinvite(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  void yahoo_parsepacket_conference_invite(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
          Packet format: id^host^invited-users^msg^0or1
private  void yahoo_parsepacket_conference_msg(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  void yahoo_parsepacket_conference_user(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  void yahoo_parsepacket_filetransfer(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  void yahoo_parsepacket_grouprename(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  void yahoo_parsepacket_newcontact(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
private  int yahoo_parsepacket_newmail(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
(package private)  int yahoo_parsepacket_ping(YahooContext ctx, YahooPacket pkt, YahooRawPacket inpkt)
           
(package private)  YahooPacket yahoo_parsepacket(YahooContext ctx, YahooRawPacket inpkt)
           
 
Methods inherited from class wtanaka.praya.Protocol
addDescriptionListener, addListener, addRecipient, addRecipientListener, changeRecipientStatus, clearBuddyList, console, fireDescriptionChanged, fireRecipientAppeared, fireRecipientChanged, fireRecipientDisappeared, getBuddies, getConfigPanelInstance, getCurrentDescription, getObjInstance, getStatusForBuddy, initialize, isGarbage, markAsGarbage, pushMessage, readObject, removeDescriptionListener, removeListener, removeRecipient, removeRecipientListener, setCurrentDescription, writeObject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SO_TIMEOUT

public static final int SO_TIMEOUT

CONF_ID

public static final int CONF_ID

CONF_PASSWD

public static final int CONF_PASSWD

CONF_STATUS

public static final int CONF_STATUS

CONF_ITEM_COUNT

public static final int CONF_ITEM_COUNT

m_configItems

private ConfigItem[] m_configItems

m_firstConnect

private boolean m_firstConnect

statusList

public static final java.lang.String[] statusList
List of visible strings, in any order, corresponding to the status configuration pulldown menu.

m_yahooContext

private YahooContext m_yahooContext

m_thread

private YahooReadThread m_thread

m_status

private GTKYStatus m_status

m_events

private GTKYEvents m_events

current_config

static java.lang.String current_config
Constructor Detail

YahooClient

public YahooClient()
Constructor
Method Detail

getIcon

public static java.awt.Image getIcon()

getProtocolDescription

public static java.lang.String getProtocolDescription()
Used to describe the class of this protocol, before any instances have been created.

getConfiguration

public ConfigItem[] getConfiguration()
Overrides:
getConfiguration in class Protocol
Following copied from class: wtanaka.praya.Protocol
Returns:
(self != null) list of configuration items for this protocol.

getDefaultRecipient

public Recipient getDefaultRecipient()
Overrides:
getDefaultRecipient in class Protocol

retryInit

private void retryInit()
                throws java.net.UnknownHostException,
                       java.io.IOException,
                       AuthException

connect

public void connect()
             throws java.io.IOException
Description copied from class: Protocol
Connects to the network, if that makes any sense. skip if it does not.
Overrides:
connect in class Protocol
Following copied from class: wtanaka.praya.Protocol
Throws:
java.io.IOException - if the connection fails due to an I/O error.
java.lang.InterruptedException - todo, why does it throw this?

disconnect

public void disconnect()
Description copied from class: Protocol
Disconnects from the network, if that makes any sense. skip if it does not.
Overrides:
disconnect in class Protocol

setStatus

public void setStatus(Status status)
               throws java.io.IOException
Sets the status.
Overrides:
setStatus in class Protocol

isConnected

public boolean isConnected()
Description copied from class: Protocol
Returns if the protocol is connected right now. Good for telling if you need to call connect() again after the connection dies.
Overrides:
isConnected in class Protocol

byteArrayToString

java.lang.String byteArrayToString(byte[] array)

setStatus

public void setStatus(int status)
               throws java.io.IOException

checkForNewMessages

public void checkForNewMessages(boolean isAutomatic)
Description copied from class: Protocol
Checks for new messages on the protocol. This might make sense for nntp/usenet, email, etc. but not for irc, gale, zephyr, icq. If any new messages are found, push them.
Overrides:
checkForNewMessages in class Protocol
Following copied from class: wtanaka.praya.Protocol
Parameters:
isAutomatic - true if the check is generated automatically with a timer. false if the check is generated manually by the user.

getBuddyGroup

public java.lang.String getBuddyGroup(java.lang.String buddyID)
Given a Yahoo ID, return its corresponding group name if it is a buddy of the currently logged in user. Otherwise, return null.
Parameters:
buddyID - a non-null yahoo id whose group name to return.

consoleCommands

public CommandInterface[] consoleCommands()
Description copied from class: Protocol
Returns a list of commands available through this console.
Overrides:
consoleCommands in class Protocol

yahoo_cmd_logon

private void yahoo_cmd_logon(YahooContext ctx,
                             int initial_status)
                      throws AuthException,
                             java.io.IOException
Log in, optionally activating other secondary identities
Throws:
AuthException - if we hae the wrong username or password.
java.io.IOException - if a network error is encountered.

yahoo_cmd_msg

void yahoo_cmd_msg(YahooContext ctx,
                   java.lang.String active_user,
                   java.lang.String toUser,
                   java.lang.String msg)
             throws java.io.IOException

yahoo_cmd_activate_id

private void yahoo_cmd_activate_id(YahooContext ctx,
                                   java.lang.String newid)
                            throws java.io.IOException

yahoo_cmd_user_status

private void yahoo_cmd_user_status(YahooContext ctx)
                            throws java.io.IOException

yahoo_cmd_logoff

private void yahoo_cmd_logoff(YahooContext ctx)
                       throws java.io.IOException

yahoo_parsepacket

YahooPacket yahoo_parsepacket(YahooContext ctx,
                              YahooRawPacket inpkt)

yahoo_parsepacket_ping

int yahoo_parsepacket_ping(YahooContext ctx,
                           YahooPacket pkt,
                           YahooRawPacket inpkt)

yahoo_parsepacket_conference_invite

private void yahoo_parsepacket_conference_invite(YahooContext ctx,
                                                 YahooPacket pkt,
                                                 YahooRawPacket inpkt)
Packet format: id^host^invited-users^msg^0or1
Parameters:
conf_id - The conference id -- usually of the form name-number, though it doesn't seem to matter much. ex: jaylubo-123
conf_host - The person inviting you to conference.
userlist - Everyone else invited to conference. Null terminated array of strings.
msg - Invitation message.
conf_type - Type of conference ( 0 = text, 1 = voice )

yahoo_parsepacket_conference_msg

private void yahoo_parsepacket_conference_msg(YahooContext ctx,
                                              YahooPacket pkt,
                                              YahooRawPacket inpkt)

yahoo_parsepacket_conference_user

private void yahoo_parsepacket_conference_user(YahooContext ctx,
                                               YahooPacket pkt,
                                               YahooRawPacket inpkt)

yahoo_parsepacket_filetransfer

private void yahoo_parsepacket_filetransfer(YahooContext ctx,
                                            YahooPacket pkt,
                                            YahooRawPacket inpkt)

yahoo_parsepacket_calendar

private void yahoo_parsepacket_calendar(YahooContext ctx,
                                        YahooPacket pkt,
                                        YahooRawPacket inpkt)

yahoo_parsepacket_chatinvite

private void yahoo_parsepacket_chatinvite(YahooContext ctx,
                                          YahooPacket pkt,
                                          YahooRawPacket inpkt)

yahoo_parsepacket_newcontact

private void yahoo_parsepacket_newcontact(YahooContext ctx,
                                          YahooPacket pkt,
                                          YahooRawPacket inpkt)

yahoo_parsepacket_newmail

private int yahoo_parsepacket_newmail(YahooContext ctx,
                                      YahooPacket pkt,
                                      YahooRawPacket inpkt)

yahoo_parsepacket_grouprename

private void yahoo_parsepacket_grouprename(YahooContext ctx,
                                           YahooPacket pkt,
                                           YahooRawPacket inpkt)

yahoo_getdata

int yahoo_getdata(YahooContext ctx)
            throws java.io.IOException

y_pp_st_get

private static final char y_pp_st_get(java.lang.String content,
                                      int itmpc)

append_notify_msg

private void append_notify_msg(java.lang.String msg)
Conditionally inform everybody that wants to know about the notify message

process_calendar_message

public void process_calendar_message(YahooPacket pkt)

process_packet_message

public void process_packet_message(YahooPacket pkt)

process_packet_ping

void process_packet_ping(YahooPacket pkt)

process_packet_filetransfer

void process_packet_filetransfer(YahooPacket pkt)

process_packet_conference

void process_packet_conference(YahooPacket pkt)

set_status_line

private void set_status_line(YahooIDStatus rec)

statusFromYahooIDStatus

private static Status statusFromYahooIDStatus(YahooIDStatus rec,
                                              int packetService)

process_packet_status

void process_packet_status(YahooPacket pkt)

process_packet_newmail

public void process_packet_newmail(YahooPacket pkt)

process_packet_chatinvite

void process_packet_chatinvite(YahooPacket pkt)

yahoo_free_buddies

static void yahoo_free_buddies(YahooContext ctx)
Free a buddy list

yahoo_free_identities

static void yahoo_free_identities(YahooContext ctx)

getYahooContext

public YahooContext getYahooContext()
Gets the context for this instance of YahooClient. You should treat this as a featureless object that you need in order to pass to YahooLib methods. Since this is the actual YahooContext reference in use by this YahooClient, you should _not_ modify anything through the reference you are returned here.

gtkyahoo_userlist_refresh

void gtkyahoo_userlist_refresh()

gtkyahoo_userlist_update

void gtkyahoo_userlist_update(java.lang.String user_to_update)