Example #1
0
/****************************************************************************
**
** Author: Marc Bowes
** Author: Tim Sjoberg
**
** Extracts variable information from the login packet
** FIXME: Poll data looks fishy
**
****************************************************************************/
VariableHash Login::handle(const QByteArray &packet)
{
  /*
  == PACKET FORMAT
  ***************************************************************************
  **
  **  1\0
  **  errorCode[\1errorMessage]\0
  **  sesid\0
  **  deprecated\1loginname\1dateTime\1URL\1
  **  maxSupportedVer\1pricePlan\1flags
  **  [\0Poll data]
  **
  ***************************************************************************
  
  == DEFINITIONS
  ***************************************************************************
  **
  **  sesid               the session ID (>1 for HTTP connections and 0 for
  **                      TCP connections)
  **  deprecated          deprecated functionality (expect an empty string)
  **  loginname           the user's loginname
  **  dateTime            the date and time in number of seconds since
  **                      1 January 1970 (UTC)
  **  URL                 is the URL of the proxy handling your current
  **                      session. Use this URL to reconnect to if
  **                      disconnected.
  **  maxSupportedVer     maximum protocol version supported by the server
  **                      (major*10+minor)
  **  pricePlan           the price plan the user is on:
  **                      1 - free
  **                      2 - premium
  **  flags               contains specific flags for this user. At the
  **                      moment only indicates if session is encrypted or not.
  **  poll data           if getContacts was set to 1, this will contain the
  **                      user's contacts as well as their presence information
  **                      and all new messages;
  **
  ***************************************************************************
  
  == ERRORS
  ***************************************************************************
  **
  **  3                   Invalid password
  **  16                  Redirect[1] to new proxy
  **  99                  Something went wrong
  **
  ***************************************************************************
  
  == NOTES
  ***************************************************************************
  **
  **  [1] Redirect
  **    The client is requested to redirect to the URL specified in the
  **    errorMessage field. The URL will be in the following format:
  **    protocol://host:port;type[;msg]
  **
  ***************************************************************************
  */
  
  /* setup */
  StringVec variables;
  
  /* first break up packet by \0 into variable sections */
  variables.append("sesid");                /* sesid\0 */
  variables.append("data");                 /* deprecated..flags\0 */
  
  /* extract \0 seperated values */
  VariableHash pass1 = hashVariables(packet, variables, '\0');

  /* need to expand data section */
  variables.clear();
  variables.append("deprecated");
  variables.append("loginname");
  variables.append("dateTime");
  variables.append("URL");
  variables.append("maxSuppertedVer");
  variables.append("pricePlan");
  variables.append("flags");
  
  /* extract \1 seperated values */
  VariableHash pass2 = hashVariables(pass1["data"], variables, '\1');
  
  /* no clean-up needed, just return the variables */
  return pass1.unite(pass2);
}
Example #2
0
/****************************************************************************
**
** Author: Tim Sjoberg
**
** Extracts variable information from the register packet
**
****************************************************************************/
VariableHash Register::handle(const QByteArray &packet)
{
  /*
  == PACKET FORMAT
  ***************************************************************************
  **
  **  11 \0
  **  errorCode [ \1 errorMessage ] \0
  **  sesid \0
  **  deprecated \1 loginname \1 timeStamp \1 serverIP \1 maxSupportedVer \1 pricePlan \1
  **  flags \0
  **  hiddenLoginname
  **  [ \0 Poll data ]
  **
  ***************************************************************************
  
  == DEFINITIONS
  ***************************************************************************
  **
  **  errorCode           see 1. Login
  **  deprecated          deprecated functionality (expect an empty string)
  **  loginname           is the user's loginname
  **  timeStamp           the number of seconds since 1 January 1970 (UTC)
  **  serverIP            the IP address of the server
  **  maxSupportedVer     maximum protocol version supported by the server
  **                      (major*10+minor)
  **  pricePlan           the price plan the user is on:
  **                        1 - free
  **                        2 - premium
  **  flags               specific flags for this user
  **  hiddenLoginname     specifies whether the user's loginname should be 
  **                      hidden when inviting a contact:
  **                        0 - not hidden
  **                        1 - hidden
  **  poll data           this will contain the user's contacts as well as 
  **                      their presence information and all new messages.
  **
  ***************************************************************************
  */
  
  StringVec variables;
  
  /* first break up packet by \0 into variable sections */
  variables.append("sesid");                /* sesid\0 */
  variables.append("data");                 /* deprecated..flags\0 */
  variables.append("hiddenLoginname");
  
  /* extract \0 seperated values */
  VariableHash pass1 = hashVariables(packet, variables, '\0');

  /* need to expand data section */
  variables.clear();
  variables.append("deprecated");
  variables.append("loginname");
  variables.append("dateTime");
  variables.append("URL");
  variables.append("maxSuppertedVer");
  variables.append("pricePlan");
  variables.append("flags");
  
  /* extract \1 seperated values */
  VariableHash pass2 = hashVariables(pass1["data"], variables, '\1');
  
  /* no clean-up needed, just return the variables */
  return pass1.unite(pass2);
  
  return VariableHash();
}