Examples of MessagingNetworkException


Examples of org.openmim.mn.MessagingNetworkException

            //contactListUinInt2cli = null;
            synchronized (lastErrorLock)
            {
              if (lastError == null)
              {
                setLastError(new MessagingNetworkException(reasonMessage, reasonLogger, endUserReasonCode));
              }
            }
          }
          fireSessionStatusChangeMim_Uncond(newStatus_Mim, ctx, reasonLogger, reasonMessage, endUserReasonCode);
        }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

              }
              else
                ++setStatusTotal;
            }
            if (endUserReasonCode != MessagingNetworkException.ENDUSER_NO_ERROR)
              CAT.error("logged off", new MessagingNetworkException(reasonMessage, reasonLogger, endUserReasonCode));
          }
         
          public void setStatusFailed(byte networkId, long operationId, String originalSrcLoginId,
            MessagingNetworkException ex)
          {
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

      //Integer.MAX_VALUE==2147483647
      //2147483646
      //11111111111
      int dstUin = IcqUinUtil.parseUin(dstLoginId, "dstLoginId", MessagingNetworkException.CATEGORY_STILL_CONNECTED);
      if (this.uin == dstUin)
        throw new MessagingNetworkException(
          "cannot add yourself to a contact list",
          MessagingNetworkException.CATEGORY_STILL_CONNECTED,
          MessagingNetworkException.ENDUSER_CANNOT_ADD_YOURSELF_TO_CONTACT_LIST);
      Integer dstUin_ = new Integer(dstUin);
      if (getContactListItem(dstUin_) != null)
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

        port = Integer.parseInt(destination.substring(colon + 1));
        host = destination.substring(0, colon);
      }
      catch (NumberFormatException ex)
      {
        throw new MessagingNetworkException(
          "invalid port value, must be integer: \"" + destination + "\"",
          MessagingNetworkException.CATEGORY_NOT_CATEGORIZED, //it is unknown where is this port value specified
          MessagingNetworkException.ENDUSER_LOGGED_OFF_DUE_TO_PROTOCOL_ERROR);
      }
    }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

  public final void handleException(
    Throwable tr, String processName, PluginContext ctx,
    boolean convertAndRethrow, boolean reconnecting)
  throws MessagingNetworkException
  {
    MessagingNetworkException ex = getLastError();
    if (ex == null)
    {
      if (Defines.DEBUG && CAT.isEnabledFor(org.apache.log4j.Level.ERROR)) CAT.error("le0", tr);

      if (tr instanceof MessagingNetworkException)
      {
        ex = (MessagingNetworkException) tr;
      }
      else
      if (tr instanceof UnknownHostException)
        ex = new MessagingNetworkException(
          "DNS error resolving "+tr.getMessage(),
          MessagingNetworkException.CATEGORY_LOGGED_OFF_DUE_TO_NETWORK_ERROR,
          MessagingNetworkException.ENDUSER_LOGGED_OFF_DUE_TO_NETWORK_ERROR);
      else
      if (tr instanceof InterruptedIOException)
        ex = new MessagingNetworkException(
          "mim admin restarts the mim server.",
          MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_PLUGIN_ADMIN,
          MessagingNetworkException.ENDUSER_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_PLUGIN_ADMIN);
      else
      if (tr instanceof InterruptedException)
        ex = new MessagingNetworkException(
          "mim admin restarts the mim server.",
          MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_PLUGIN_ADMIN,
          MessagingNetworkException.ENDUSER_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_PLUGIN_ADMIN);
      else
      if (tr instanceof IOException)
        ex = new MessagingNetworkException(
          "I/O error: "+tr.getMessage(),
          MessagingNetworkException.CATEGORY_LOGGED_OFF_DUE_TO_NETWORK_ERROR,
          MessagingNetworkException.ENDUSER_LOGGED_OFF_DUE_TO_NETWORK_ERROR);
      else
      if (tr instanceof AssertException)
        ex = new MessagingNetworkException(
          "bug found: "+tr.getMessage(),
          MessagingNetworkException.CATEGORY_NOT_CATEGORIZED,
          MessagingNetworkException.ENDUSER_MIM_BUG);
      else
      if (tr instanceof ArrayIndexOutOfBoundsException)
        ex = new MessagingNetworkException(
          tr.toString(),
          MessagingNetworkException.CATEGORY_STILL_CONNECTED,
          MessagingNetworkException.ENDUSER_PROTOCOL_ERROR_NOT_LOGGED_OFF);
      else
        ex = new MessagingNetworkException(
          "unknown error: "+tr.getMessage(),
          MessagingNetworkException.CATEGORY_NOT_CATEGORIZED,
          MessagingNetworkException.ENDUSER_MIM_BUG_UNKNOWN_ERROR);

      if (ex.getLogger() != MessagingNetworkException.CATEGORY_STILL_CONNECTED)
      {
        setLastError(ex);
        try
        {
          MessagingNetworkException ex1 = convertErrorAfterShutdown(ex, ctx, reconnecting);
          if (ex != ex1)
          {
            ex = ex1;
            if (ex1.getLogger() != ex1.CATEGORY_STILL_CONNECTED)
              replaceLastError(ex1);
            else
              replaceLastError(null);
          }
        }
        catch (Exception excc)
        {
          if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("ex ignored", excc);
        }       
        shutdown(ctx, ex.getLogger(), ex.getMessage(), ex.getEndUserReasonCode());
      }
     
      Stats.report(ex.getEndUserReasonCode());
    }

    if (convertAndRethrow)
    {
      throw new MessagingNetworkException(ex.getMessage(), ex.getLogger(), ex.getEndUserReasonCode());
    }
  }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

  void setLastError(String exceptionMessage, int reasonLogger, int endUserReasonCode)
  {
    synchronized (lastErrorLock)
    {
      if (lastError == null)
        lastError = new MessagingNetworkException(exceptionMessage, reasonLogger, endUserReasonCode);
    }
  }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

  throws MessagingNetworkException
  {
    synchronized (lastErrorLock)
    {
      if (lastError == null)
        lastError = new MessagingNetworkException(exceptionMessage, reasonLogger, endUserReasonCode);
      throw cloneLastError();
    }
  }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

  public MessagingNetworkException cloneLastError()
  {
    synchronized (lastErrorLock)
    {
      if (lastError == null) Lang.ASSERT_NOT_NULL(lastError, "lastError");
      return new MessagingNetworkException(lastError.getMessage(), lastError.getLogger(), lastError.getEndUserReasonCode());
    }
  }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

        PluginContext ctx)
  throws MessagingNetworkException
  {
    if (flapChannel != 4)

      throw new MessagingNetworkException(
        "auth response on unknown channel=" + flapChannel,
        MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_SERVER_OR_PROTOCOL_ERROR,
        MessagingNetworkException.ENDUSER_LOGGED_OFF_DUE_TO_PROTOCOL_ERROR);

    int errCode = -1;
    String errUrl = null;
    String screenName = null;
    Aim_tlvlist_t tlvlist = new Aim_tlvlist_t(this, flapDataField, ofs, len);
    screenName = tlvlist.getNthTlvOfTypeAsString(1, 1);
    if (tlvlist.getNthTlvOfType(1, 8) != null)
      errCode = tlvlist.getNthTlvOfTypeAs16Bit(1, 8);
    errUrl = tlvlist.getNthTlvOfTypeAsString(1, 4);
    if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("rx_handleAuthorizationError: channel 4: shutting down, errUrl=\"" + errUrl + "\", errCode=" + errCode);
    String reason = "Unknown authorization error";
    int endUserReasonCode;
    switch (errCode)
    {
      case 0x0001 :
        reason = "Invalid or not registered ICQ number.";
        endUserReasonCode = MessagingNetworkException.ENDUSER_CANNOT_LOGIN_INVALID_OR_NOT_REGISTERED_UIN;
        break;
      case 0x0005 :
        reason = "Invalid password or ICQ number.";
        endUserReasonCode = MessagingNetworkException.ENDUSER_CANNOT_LOGIN_INVALID_PASSWORD_OR_UIN;
        break;
      case 0x0018 :
        reason = "ICQ server reports: connect rate exceeded.  You are reconnecting too often.  Try to connect again 10 or 20 minutes later.";
        endUserReasonCode = MessagingNetworkException.ENDUSER_CANNOT_LOGIN_CONNECT_RATE_EXCEEDED_TRY_10_OR_20_MINUTES_LATER;
        break;
      case 0x001D :
        reason = "ICQ server reports: connect rate exceeded.  Try to connect again 1 or 2 minutes later.";
        endUserReasonCode = MessagingNetworkException.ENDUSER_CANNOT_LOGIN_CONNECT_RATE_EXCEEDED_TRY_1_OR_2_MINUTES_LATER;
        break;
      case 0x0014:
        Stats.STAT_UNKAUTH14_ERRORS.inc();
      default :
        reason += ": channel=4, errCode=" + HexUtil.toHexString0x(errCode);
        endUserReasonCode = MessagingNetworkException.ENDUSER_CANNOT_LOGIN_MESSAGING_SERVER_REPORTS_UNKNOWN_ERROR;
        if (errUrl != null)
          reason += ", " + errUrl;
        break;
    }
    throw new MessagingNetworkException(
      "Cannot login: " + reason,
      MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_SERVER_OR_PROTOCOL_ERROR,
      endUserReasonCode);
  }
View Full Code Here

Examples of org.openmim.mn.MessagingNetworkException

          {
            if (Defines.DEBUG && CAT.isEnabledFor(org.apache.log4j.Level.ERROR)) CAT.error("invalid contact list entry uin ignored, exception ignored", ex11);
            continue;
          }
          if (this.uin == dstUin)
            throw new MessagingNetworkException(
              "cannot login with your own uin in a contact list",
              MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_SERVER_OR_PROTOCOL_ERROR,
              MessagingNetworkException.ENDUSER_CANNOT_LOGIN_WITH_YOURSELF_ON_CONTACT_LIST);
          Integer dstUin_ = new Integer(dstUin);
          if (contactListUinInt2cli.put(dstUin_, makeContactListItem(dstLoginId)) != null)
          {
            if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("" + dstLoginId + " already in a contact list, cl entry ignored");
            continue;
          }
        }
      }

      synchronized (logoutLock)
      {
        if ((loginId) == null) Lang.ASSERT_NOT_NULL(loginId, "loginId");
        if ((password) == null) Lang.ASSERT_NOT_NULL(password, "password");
        snac_nextid = 1;
        loggingIn = true;
      }

      setReconnectData(status_Oscar, contactListUinInt2cli);

      FlapConsumer authServerFC = new FlapConsumer()
      {
        private int state = 10;

        public boolean isBosConn()
        {
          return false;
        }

        public void parse(final int flapChannel, final byte[] flapBody, int ofs, int len) throws Exception
        {
            final int datalen = len;

            switch (state)
            {
              case 10:
              {
                if (datalen < 4)
                  MLang.EXPECT(
                    datalen >= 4, "hello length must be >= 4, but it is " + datalen,
                    MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_SERVER_OR_PROTOCOL_ERROR,
                    MessagingNetworkException.ENDUSER_LOGGED_OFF_DUE_TO_PROTOCOL_ERROR);
                long hello = aimutil_get32(flapBody, ofs);
                ofs+=4; len-=4;
                if (hello != 1)
                  MLang.EXPECT_EQUAL(
                    hello, 1, "flap version", "00 00 00 01",
                    MessagingNetworkException.CATEGORY_LOGGED_OFF_ON_BEHALF_OF_MESSAGING_SERVER_OR_PROTOCOL_ERROR,
                    MessagingNetworkException.ENDUSER_LOGGED_OFF_DUE_TO_PROTOCOL_ERROR);
                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("server hello received, sending login request");
                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("entered loginSequence_10sendLogin()"); //, password="+StringUtil.toPrintableString(password));
                if (StringUtil.isNullOrEmpty(password)) Lang.ASSERT_NOT_NULL_NOR_EMPTY(password, "icq password");
                if (StringUtil.isNullOrEmpty(loginId)) Lang.ASSERT_NOT_NULL_NOR_EMPTY(loginId, "loginId");
                final byte[] password_b = string2byteArray(password);
                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("login, stage 10: password length = " + password_b.length);
                int xorindex = 0;
                for (int i = 0; i < password_b.length; i++)
                {
                  password_b[i] ^= xor_table[xorindex++];
                  if (xorindex >= xor_table.length)
                    xorindex = 0;
                }
                final byte[] sn = string2byteArray(loginId);

                {
                  byte[] pak = new byte[0x7e + password_b.length - 1 + sn.length - 8];
                  int ofs1 = 0;
                  ofs1 += aimutil_put32(pak, ofs1, 0x00000001);
                  ofs1 += aim_puttlv_str_(pak, ofs1, 1, sn);
                  ofs1 += aim_puttlv_str_(pak, ofs1, 2, password_b);
                  ofs1 += aim_puttlv_str_(pak, ofs1, 3, string2byteArray("ICQ Inc. - Product of ICQ (TM).2000b.4.63.1.3279.85"));
                  final byte[] trail = {//
                    (byte) 0x00, (byte) 0x16,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x01, (byte) 0x0A,//
                    //
                    (byte) 0x00, (byte) 0x17,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x00, (byte) 0x04,//
                    //
                    (byte) 0x00, (byte) 0x18,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x00, (byte) 0x3F,//
                    //
                    (byte) 0x00, (byte) 0x19,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x00, (byte) 0x01,//
                    //
                    (byte) 0x00, (byte) 0x1A,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x0C, (byte) 0xCF,//
                    //
                    (byte) 0x00, (byte) 0x14,//
                    (byte) 0x00, (byte) 0x04,//
                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x55,//
                    //
                    (byte) 0x00, (byte) 0x0F,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x65, (byte) 0x6E,// "en"
                    //
                    (byte) 0x00, (byte) 0x0E,//
                    (byte) 0x00, (byte) 0x02,//
                    (byte) 0x75, (byte) 0x73//  "us"
                    };
                  System.arraycopy(trail, 0, pak, ofs1, trail.length);

                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("login/10: sending uin/password packet");

                  state = 20;

                  getAuthConnNotNull().send(pak, 1, opLogin);
                }
                break;
              }

              case 20:
              {
                //flap channel
                if (flapChannel != 4)
                {
                  handleAuthorizationError_alwaysThrowEx(flapBody, ofs, len, flapChannel, ctx);
                  //unreachable code
                  return;
                }

                Aim_tlvlist_t resp = new Aim_tlvlist_t(Session.this, flapBody, ofs, len);
                bos_hostport = resp.getNthTlvOfTypeAsString(1, 5);
                cookie = resp.getNthTlvOfTypeAsByteArray(1, 6);

                if (cookie == null || bos_hostport == null)
                {
                  cookie = null;
                  bos_hostport = null;
                  handleAuthorizationError_alwaysThrowEx(flapBody, ofs, len, flapChannel, ctx);
                }
               
                state = 30;

                opLogin.runNow(
                  new MessagingTask("login/20", opLogin)
                  {
                    public void run() throws Exception
                    {
                      if (Defines.DEBUG && CAT.isDebugEnabled())
                        CAT.debug("aim_send_login(): cookie received, closing auth connection...");
                      {
                        Aim_conn_t oldconn;
                        synchronized (logoutLock)
                        {
                          oldconn = authconn;
                          authconn = null;
                        }
                        closeConnectionIfNotNull(oldconn);
                      }

                      checkShuttingdown();

                      if (Defines.DEBUG && CAT.isDebugEnabled())
                        CAT.debug("aim_send_login(): auth connection closed, connecting to bos...");

                      {
                        Aim_conn_t conn = aim_newconn(AIMConstants.AIM_CONN_TYPE_BOS, bos_hostport, bosFc, ctx);
                        bos_hostport = null;

                        synchronized (shuttingDownLock)
                        {
                          messageQueue = new OutgoingMessageQueue(conn, Session.this, ctx);
                        }

                        Aim_conn_t oldconn;
                        synchronized (logoutLock)
                        {
                          oldconn = bosconn;
                          bosconn = conn;
                        }
                        closeConnectionIfNotNull(oldconn);
                        if (isShuttingDown()) conn.closeSocket();
                      }

                    }
                  }
                );
                break;
              } //end of case
            } //end of switch(state)
            ofs += datalen; len -= datalen;
        } //end of parse()
      }; //end of authServerFC

      bosFc = new FlapConsumer()
      {
        private int state = 25;

        public boolean isBosConn()
        {
          return true;
        }

        public void parse(final int flapChannel, final byte[] flapBody, final int ofs, final int len) throws Exception
        {
            final int datalen = len;

            switch (state)
            {
              case 25:
              {
                checkShuttingdown();

                byte[] xxx = new byte[8];
                int offset = 0;
                offset += aimutil_put16(xxx, offset, 0x0000);
                offset += aimutil_put16(xxx, offset, 0x0001);
                offset += aimutil_put16(xxx, offset, 0x0006);
                offset += aimutil_put16(xxx, offset, cookie.length);

                state = 30;

                ByteArrayOutputStream ba = new ByteArrayOutputStream(8+cookie.length);
                ba.write(xxx);
                ba.write(cookie);
                cookie = null;
                getBosConnNotNull().send(ba.toByteArray(), 1, opLogin);

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("login/30 waiting for serverready");
                break;
              }

              case 30:
              {
                //if (Thread.currentThread().isInterrupted())
                //  throw new InterruptedException();
                //shutdownAt(stopTime, "waitForServerReady", ctx);
                //byte[] flap_header = new byte[6];
                //getBosConnNotNull().read(flap_header);
                //int len = flap_header.length;
                //FLAPHeader flap = new FLAPHeader(flap_header);

                //byte[] flap_data_field = AllocUtil.createByteArray(this, flap.data_field_length);
                //getBosConnNotNull().read(flap_data_field);
                //len = flap_data_field.length;
                if (flapChannel == 4)
                {
                  rx_handleConnectionError(flapBody, ofs, len, ctx);
                  break; //continue waiting //not executed if the error is "logged on from another pc".
                }
                if (flapChannel != 2 && len < 4)
                  break; //continue waiting
                int family = aimutil_get16(flapBody, ofs);
                int subtype = aimutil_get16(flapBody, ofs+2);
                if ((family != 0 && subtype == 1) || (family == 9 && subtype == 9))
                {
                  rx_handleGenericServiceError(flapBody, ofs, len, ctx);
                  break;
                }
                if (family != AIM_CB_FAM_GEN /*1*/|| subtype != AIM_CB_GEN_SERVERREADY /*3*/)
                  break;

                state = 40;

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("exited waitForServerReady, entered login/40 sendContactList()");

                if (status_Oscar == StatusUtil.OSCAR_STATUS_ONLINE)
                  setStatus_Oscar_Internal(opLogin, status_Oscar, false, ctx, MessagingNetworkException.CATEGORY_NOT_CATEGORIZED, null, MessagingNetworkException.ENDUSER_NO_ERROR);
                else
                  setStatus_Oscar_Internal(opLogin, status_Oscar, true, ctx, MessagingNetworkException.CATEGORY_NOT_CATEGORIZED, null, MessagingNetworkException.ENDUSER_NO_ERROR);

                synchronized (logoutLock)
                {
                  crAttempted = false;
                }
               
                SNAC p = null;

                if (!FETCH_OFFLINE_MESSAGES)
                {
                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug("fetch offline messages: disabled.");
                }
                else
                {
                  noIncomingOfflineMessages = true;
                }

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 1/0x17, generic service controls/unknown");
                p = new SNAC(0x0001, 0x0017);
                p.addByteArray(new byte[] {
                  00, 01, 00, 03,
                  00, 02, 00, 01,
                  00, 03, 00, 01,
                  00, 0x15, 00, 01,

                  00, 04, 00, 01,
                  00, 06, 00, 01,
                  00, 0x09, 00, 01,
                  00, 0x0A, 00, 01
                });
                //this packet was exactly like in &rq (incl. snac reqids).
                p.send(getBosConnNotNull(), opLogin);

                /*
                ignored: //NADO WAITAT' HERE FOR 1/0x18

                server sends                   // got it, ack to 1,17

                SERVER seq:61B5 size:48 service:01/18 ref:00008580 flags:0000

                00 01 00 03 00 02 00 01 00 03 00 01 00 04 00 01 00 06 00 01
                00 08 00 01 00 09 00 01 00 0A 00 01 00 0B 00 01 00 0C 00 01
                00 13 00 02 00 15 00 01
                */

                if (!REQUEST_RATEINFO)
                {
                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                      ("request rate info: disabled.");
                }
                /*
                else
                {
                  rateInfoResponseReceived = false;

                  getBosConnNotNull().addHandler(new Rx HandlerImpl()
                  {
                    public boolean triggered(Session sess, final int flapChannel, final byte[] flapBody, final int ofs, final int len, final SNAC snac)
                    throws IOException, MessagingNetworkException, InterruptedException
                    {
                      getBosConnNotNull().removeHandler(getThis());
                      synchronized (rateResponseWaitLock)
                      {
                        rateInfoResponseReceived = true;
                        rateResponseWaitLock.notify();
                      }
                      return true;
                    }
                  }, 1, 7); //rate info response

                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                 ("login/40 sendContactList(): sending 1/6, rate info request");
                  p = new SNAC(0x0001, 0x0006);
                  p.send(getBosConnNotNull());
                  //this packet was exactly like in &rq (incl. snac reqids).

                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                 ("login/40 sendContactList(): waiting for rate info response...");
                  long stopTime = System.currentTimeMillis() + 1000 * ICQ2KMessagingNetwork.REQPARAM_SERVER_RESPONSE_TIMEOUT1_SECONDS;
                  for (;;)
                  {
                    synchronized (rateResponseWaitLock)
                    {
                      if (rateInfoResponseReceived) break;
                    }
                    shutdownAt(stopTime, "rate info response wait", ctx);
                    t ick(ctx);
                    Thread.currentThread().sleep(10);
                  }

                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                 ("got rate info response, sending 1/8 rate info ack");
                  p = new SNAC(1, 8);
                  p.addByteArray(new byte[] {00, 01, 00, 02, 00, 03, 00, 04, 00, 05});
                  p.send(getBosConnNotNull());
                  //this packet was exactly like in &rq (incl. snac reqids).
                }
                */

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 1/0xe, generic service controls/request my info");
                p = new SNAC(0x0001, 0x000e);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 2/2, location/Request rights information");
                p = new SNAC(0x0002, 0x0002);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 3/2, buddylist/Request rights information");
                p = new SNAC(0x0003, 0x0002);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 4/4, messaging/Request parameter information");
                p = new SNAC(0x0004, 0x0004);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 9/2, bos-specific/Request BOS Rights");
                p = new SNAC(0x0009, 0x0002);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                /*
                ignored:
                //NADO WAIT HERE FOR 1/0xf

                server sends                   //  response to 1,0E

                SERVER seq:61B7 size:92 service:01/0F ref:00000000 flags:0000
                 45454734         _   %                                         ��             ;��m    ;��n
                08 34 35 34 35 34 37 33 34 00 00 00 06 00 01 00 02 00 80 00
                0C 00 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                00 0A 00 04 C2 95 E0 03 00 0F 00 04 00 00 00 00 00 02 00 04
                3B A1 D9 6D 00 03 00 04 3B A1 D9 6E


                //NADO WAIT HERE FOR 2/3

                SERVER seq:61B8 size:18 service:02/03 ref:00000000 flags:0000

                00 01 00 02 04 00 00 02 00 02 00 10 00 03 00 02 00 0A


                //NADO WAIT HERE FOR 3/3

                SERVER seq:61B9 size:18 service:03/03 ref:00000000 flags:0000
                     X     �
                00 01 00 02 02 58 00 02 00 02 02 EE 00 03 00 02 02 00


                //NADO WAIT HERE FOR 4/5

                SERVER seq:61BA size:16 service:04/05 ref:00000000 flags:0000
                         � �   �
                00 02 00 00 00 03 02 00 03 E7 03 E7 00 00 03 E8


                //NADO WAIT HERE FOR 0x9/3

                SERVER seq:61BB size:12 service:09/03 ref:00000000 flags:0000
                     �     �
                00 02 00 02 00 A0 00 01 00 02 00 A0
                */

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 4/2, Messaging/Add ICBM parameter");
                p = new SNAC(0x0004, 0x0002);
                p.addByteArray(new byte[] {
                  00, 00,
                  00, 00,
                  00, 03,
                  0x1F, 0x40,
                  03, (byte) 0xE7,
                  03, (byte) 0xE7,
                  00, 00,
                  00, 00
                });
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 2/4, Location Services/Set user information");
                p = new SNAC(0x0002, 0x0004);
                p.addDWord(0x00050020);//TLV(5)
                p.addDWord(0x09461349);//capability1 //direct-message capability?
                p.addDWord(0x4C7F11D1);//capability1 //licq doesn't send the capability1
                p.addDWord(0x82224445);//capability1 //icq2k sends both cap1 and cap2
                p.addDWord(0x53540000);//capability1

                p.addDWord(0x09461344);//capability2
                p.addDWord(0x4C7F11D1);//capability2
                p.addDWord(0x82224445);//capability2
                p.addDWord(0x53540000);//capability2
                p.send(getBosConnNotNull(), opLogin);
                p = null;
                //this packet was exactly like in &rq (incl. snac reqids).

                //send the buddy list and profile (required, even if empty)
                //aim_bos_setbuddylist(sess, command->getBosConnNotNull(), buddies);
                //
                //Add buddy [Source: User_]
                //Adds a number of buddies to your buddy list, causing AIM to send
                //us on/off events for the given users. Len/buddy combinations can be
                //repeated as many times as you have buddies to add.
                //
                //SNAC Information:
                //
                //Family 0x0003
                //SubType 0x0004
                //Flags {0x00, 0x00}
                //
                //--------------------------------------------------------------------------------
                //
                //RAW / Buddy name length (byte)
                //RAW / Buddy name
                java.io.ByteArrayOutputStream ba = new java.io.ByteArrayOutputStream();
                for (int i = 0; i < contactList.length; i++)
                {
                  String s15 = String.valueOf(IcqUinUtil.parseUin(contactList[i], "contactList[i]", MessagingNetworkException.CATEGORY_NOT_CATEGORIZED));
                  byte[] buddyName = string2byteArray(s15);
                  ba.write((byte) buddyName.length);
                  ba.write(buddyName);
                }
                ba.flush();
                byte[] baa = ba.toByteArray();
                ba.close();

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 3/4, send contact list");
                p = new SNAC(0x0003, 0x0004);
                p.addByteArray(baa);
                p.send(getBosConnNotNull(), opLogin);
                ba = null;
                baa = null;

                //this packet was exactly like in &rq (incl. snac reqids).

                boolean webAware = true;

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 1/0x1e setInitialStatus");
                p = new SNAC(0x0001, 0x001e);

                // TLV(6) status-code
                p.addDWord(0x00060004);
                p.addWord(0x1000 | (webAware ? 1 : 0) ); //joxy: i used 0x0003 earlier
                p.addWord(status_Oscar);          //joxy: i used 0x0000 earlier

                // TLV(8) unknown, usually 0000
                p.addDWord(0x00080002);
                p.addWord(0);

                // TLV(C) direct-connection-info
                p.addByteArray(new byte[] {
                  (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x25, (byte) 0x7F, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0x58, (byte) 0x58, (byte) 0x58, (byte) 0x58, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x3A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x3A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x3A, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
                });

                /*
                  joxy: for TLV(C), i used earlier:
                  (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x25,
                  (byte) 0xC0, (byte) 0xA8, (byte) 0x04, (byte) 0x6B,
                  (byte) 0x00, (byte) 0x00, (byte) 0x73, (byte) 0x74,
                  (byte) 0x04, (byte) 0x00, (byte) 0x07, (byte) 0x1D,
                  (byte) 0xAE, (byte) 0xF0, (byte) 0x9E, (byte) 0x00,
                  (byte) 0x00, (byte) 0x00, (byte) 0x50, (byte) 0x00,
                  (byte) 0x00, (byte) 0x00, (byte) 0x03, (byte) 0x3B,
                  (byte) 0x17, (byte) 0x6B, (byte) 0x57, (byte) 0x3B,
                  (byte) 0x18, (byte) 0xAC, (byte) 0xE9, (byte) 0x3B,
                  (byte) 0x17, (byte) 0x6B, (byte) 0x4E, (byte) 0x00,
                  (byte) 0x00
                */
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 1/0x11, generic service controls/unknown");
                p = new SNAC(0x0001, 0x0011);
                p.addDWord(0);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 9/7, BOS-specific/Add deny list entries");
                p = new SNAC(0x0009, 0x0007);
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login/40 sendContactList(): sending 1/2, client ready");
                p = new SNAC(0x0001, 0x0002);
                p.addDWord(0x00010003);  p.addDWord(0x0110028A);
                p.addDWord(0x00020001);  p.addDWord(0x0101028A);
                p.addDWord(0x00030001);  p.addDWord(0x0110028A);
                p.addDWord(0x00150001);  p.addDWord(0x0110028A);
                p.addDWord(0x00040001);  p.addDWord(0x0110028A);
                p.addDWord(0x00060001);  p.addDWord(0x0110028A);
                p.addDWord(0x00090001);  p.addDWord(0x0110028A);
                p.addDWord(0x000A0001);  p.addDWord(0x0110028A);
                /*
                p.addByteArray(new byte[] {//
                  (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x06, (byte) 0x86,
                  (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x0a, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01,
                  (byte) 0x00, (byte) 0x0b, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x01
                };
                */
                p.send(getBosConnNotNull(), opLogin);
                //this packet was exactly like in &rq (incl. snac reqids).

                //2A 02 0A B8 00 18 //clt snds
                //00 15 00 02 //sf 5, unknown/unknown
                //00 00
                //00 01 00 02 //snac reqid
                //00 01 00 0A
                //  08
                //    00 BE 5C 94 01 3C 00 02 00
                //  ..............._\".<...

                //2a 02 5da1 0018  0015 0002 0000 00010002  0001 000a 0800 1b374d07 3c 00 02 00
                if (FETCH_OFFLINE_MESSAGES)
                {
                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                      ("sending: get offline messages");
                  p = new SNAC(0x0015, 0x0002);
                  //"BE 5C 94 01"  aka  0x01 94 5C BE == 26500286
                  p.addByteArray(new byte[] {//
                    0x00, 0x01, 0x00, 0x0a, 0x08, 0x00, //
                    (byte) (uin & 0xff), //
                    (byte) ((uin >> 8)& 0xff), //
                    (byte) ((uin >> 16)& 0xff), //
                    (byte) ((uin >> 24)& 0xff), //
                    (byte) 0x3C, (byte) 0x00, //
                    0, // <-- joxy: i used 2 in this byte earlier
                    (byte) 0x00});
                  p.send(getBosConnNotNull(), opLogin);
                  p = null;
                  //this packet was exactly like in &rq (incl. snac reqids).
                }

                /*
                  //2a 02 5da2 0033  0015 0002 0000 00020002  0001 0025 2300 1b374d07 d0 07 03 00 98 08 17 00 3c 6b 65 79 3e 44 61 74 61 46 69 6c 65 73 49 50 3c 2f 6b 65 79 3e 00
                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                 ("login/40 sendContactList(): sending 0x15/2, reqid 2/2");
                  p = new SNAC(0x0015, 0x0002, 0, 0, 0x00020002);
                  //"BE 5C 94 01"  aka  0x01 94 5C BE == 26500286
                  p.addByteArray(new byte[] {//
                    0x00, 0x01, 0x00,       0x25, 0x23, 0x00, //
                    (byte) (uin & 0xff), //
                    (byte) ((uin >> 8)& 0xff), //
                    (byte) ((uin >> 16)& 0xff), //
                    (byte) ((uin >> 24)& 0xff), //
                    (byte) 0xd0, (byte) 0x07, (byte) 0x03, (byte) 0x00, (byte) 0x98, (byte) 0x08, (byte) 0x17, (byte) 0x00, (byte) 0x3c, (byte) 0x6b, (byte) 0x65, (byte) 0x79, (byte) 0x3e, (byte) 0x44, (byte) 0x61, (byte) 0x74, (byte) 0x61, (byte) 0x46, (byte) 0x69, (byte) 0x6c, (byte) 0x65, (byte) 0x73, (byte) 0x49, (byte) 0x50, (byte) 0x3c, (byte) 0x2f, (byte) 0x6b, (byte) 0x65, (byte) 0x79, (byte) 0x3e, (byte) 0x00});
                  p.send(getBosConnNotNull());
                  p = null;

                  //2a 02 5da3 0031  0015 0002 0000 00030002  0001 0023 2100 1b374d07 d0 07 04 00 98 08 15 00 3c 6b 65 79 3e 42 61 6e 6e 65 72 73 49 50 3c 2f 6b 65 79 3e 00
                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                 ("login/40 sendContactList(): sending 0x15/2, reqid 3/2");
                  p = new SNAC(0x0015, 0x0002, 0, 0, 0x00030002);
                  //"BE 5C 94 01"  aka  0x01 94 5C BE == 26500286
                  p.addByteArray(new byte[] {//
                    0x00, 0x01, 0x00,       0x23, 0x21, 0x00, //
                    (byte) (uin & 0xff), //
                    (byte) ((uin >> 8)& 0xff), //
                    (byte) ((uin >> 16)& 0xff), //
                    (byte) ((uin >> 24)& 0xff), //
                    (byte) 0xd0, (byte) 0x07, (byte) 0x04, (byte) 0x00, (byte) 0x98, (byte) 0x08, (byte) 0x15, (byte) 0x00, (byte) 0x3c, (byte) 0x6b, (byte) 0x65, (byte) 0x79, (byte) 0x3e, (byte) 0x42, (byte) 0x61, (byte) 0x6e, (byte) 0x6e, (byte) 0x65, (byte) 0x72, (byte) 0x73, (byte) 0x49, (byte) 0x50, (byte) 0x3c, (byte) 0x2f, (byte) 0x6b, (byte) 0x65, (byte) 0x79, (byte) 0x3e, (byte) 0x00});
                  p.send(getBosConnNotNull());
                  p = null;

                  //2a 02 5da4 0032  0015 0002 0000 00040002  0001 0024 2200 1b374d07 d0 07 05 00 98 08 16 00 3c 6b 65 79 3e 43 68 61 6e 6e 65 6c 73 49 50 3c 2f 6b 65 79 3e 00
                  if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                 ("login/40 sendContactList(): sending 0x15/2, reqid 4/2");
                  p = new SNAC(0x0015, 0x0002, 0, 0, 0x00040002);
                  //"BE 5C 94 01"  aka  0x01 94 5C BE == 26500286
                  p.addByteArray(new byte[] {//
                    0x00, 0x01, 0x00,       0x24, 0x22, 0x00, //
                    (byte) (uin & 0xff), //
                    (byte) ((uin >> 8)& 0xff), //
                    (byte) ((uin >> 16)& 0xff), //
                    (byte) ((uin >> 24)& 0xff), //
                    (byte) 0xd0, (byte) 0x07, (byte) 0x05, (byte) 0x00, (byte) 0x98, (byte) 0x08, (byte) 0x16, (byte) 0x00, (byte) 0x3c, (byte) 0x6b, (byte) 0x65, (byte) 0x79, (byte) 0x3e, (byte) 0x43, (byte) 0x68, (byte) 0x61, (byte) 0x6e, (byte) 0x6e, (byte) 0x65, (byte) 0x6c, (byte) 0x73, (byte) 0x49, (byte) 0x50, (byte) 0x3c, (byte) 0x2f, (byte) 0x6b, (byte) 0x65, (byte) 0x79, (byte) 0x3e, (byte) 0x00});
                  p.send(getBosConnNotNull());
                  p = null;
                */
                //"offl msg ack" start
                ////2a 02 5da5 0018  0015 0002 0000 00050002  0001 000a 0800 1b374d07 3e 00 06 00
                //if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                //login/40 sendContactList(): sending 0x15/2, reqid 5/2");
                //p = new SNAC(0x0015, 0x0002, 0, 0, 0x00050002);
                ////"BE 5C 94 01"  aka  0x01 94 5C BE == 26500286
                //p.addByteArray(new byte[] {//
                //0x00, 0x01, 0x00,     0x0a, 0x08, 0x00, //
                //(byte) (uin & 0xff), //
                //(byte) ((uin >> 8)& 0xff), //
                //(byte) ((uin >> 16)& 0xff), //
                //(byte) ((uin >> 24)& 0xff), //
                //(byte) 0x3e, (byte) 0x00, (byte) 0x06, (byte) 0x00});
                //p.send(getBosConnNotNull());
                //p = null;
                //"offl msg ack" end

                ////AIM/Oscar Protocol Specification:
                ////Section 3: BOS Signon: Set Initial ICBM Parameter
                ////--------------------------------------------------------------------------------
                ////Set ICBM Paramter[Source: User_]
                ////Not sure what this one does, but it can't hurt to send it.
                ////SNAC Information:
                ////Family 0x0004
                ////SubType 0x0002
                ////Flags {0x00, 0x00}
                ////--------------------------------------------------------------------------------
                ////RAW SNAC Header
                ////RAW 0x0000
                ////RAW 0x00000003
                ////RAW 0x1f40
                ////RAW 0x03e7
                ////RAW 0x03e7
                ////RAW 0x0000
                ////RAW 0x0000
                //
                //SNAC p = new SNAC(4, 2);
                //p.addWord(0);
                //p.addDWord(3);
                //p.addWord(0x1f40);
                //p.addWord(0x03e7);
                //p.addWord(0x03e7);
                //p.addWord(0);
                //p.addWord(0);
                //p.send(getBosConnNotNull());

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("exited login/40 sendContactList()");

                //loginSequence_50waitForWwwAolComPacket(ctx);
                getBosConnNotNull().setRateControlOn(true);

                if (Defines.DEBUG && CAT.isDebugEnabled()) CAT.debug
                    ("login(): fetching my authorizationRequired flag from server...");

                //long startGetUserDetailsInternal(String srcLoginId, String dstLoginId) adds an interna operation;
                //events from this operationId are never delivered to a external listeners
                //they are delivered to internal listeners only.
                //addInternalMessagingNetworkListener() adds an internal listener.
                //removeInternalMessagingNetworkListener() removes an internal listener.
                MessagingNetworkListener l =
                  new MessagingNetworkAdapter()
                  {
                    public final void getUserDetailsFailed(byte networkId, long operationId,
                      String originalSrcLoginId, String originalDstLoginId,
                      MessagingNetworkException ex)
                    {
                      if (loginId.equals(originalSrcLoginId) && loginId.equals(originalDstLoginId))
                        authReq(false, ex);
                    }

                    public final void getUserDetailsSuccess(byte networkId, long operationId,
                      String originalSrcLoginId, String originalDstLoginId,
                      UserDetails userDetails)
                    {
                      if (loginId.equals(originalSrcLoginId) && loginId.equals(originalDstLoginId))
                      {
                        boolean ar = false;
                        try
                        {
                          ar = userDetails.isAuthorizationRequired();
                        }
                        catch (MessagingNetworkException exar)
                        {
                          ar = false;
                        }
                        authReq(ar, null);
                      }
                    }

                    private final void authReq(boolean authorizationRequired, MessagingNetworkException mex)
                    {
                      Session.this.authorizationRequired = authorizationRequired;

                      if (mex == null
                      || mex.getLogger() == MessagingNetworkException.CATEGORY_STILL_CONNECTED)
                      {
                        if (Defines.DEBUG && CAT.isDebugEnabled())
                          CAT.debug("login(): fetching my authorizationRequired flag done.");

                        setupSessionTasks();

                        opLogin.success();
                        opLogin = null;
                      }
                    }
                  }
                ;

//                try
//                {
//                  ctx.getGal().addForcedAop();
//                  AsyncOperationImpl aop = null;
//                  try
//                  {
//                    Session.this.enqueue(aop = new AsyncOperations.
//                      OpGetUserDetails(loginId, Session.this, false, ctx), l);
//                  }
//                  catch (MessagingNetworkException mex)
//                  {
//                    ctx.getPlug().handleEarlyException(aop, mex);
//                    throw mex;
//                  }
//                }
//                catch (MessagingNetworkException mex1)
//                {
//                  l.getUserDetailsFailed((byte) -1, -1L, loginId, loginId, mex1);
//                }
                l.getUserDetailsFailed((byte) -1, -1L, loginId, loginId, new MessagingNetworkException(MessagingNetworkException.CATEGORY_STILL_CONNECTED,MessagingNetworkException.ENDUSER_NO_ERROR));
                break;
              }

              case 40: //mainloop state case; must deliver events to Rx handlers etc etc etc
              {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.