Exemplo n.º 1
0
 static {
   density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
   SharedPreferences preferences =
       ApplicationLoader.applicationContext.getSharedPreferences("primes", Context.MODE_PRIVATE);
   String primes = preferences.getString("primes", null);
   if (primes == null) {
     goodPrimes.add(
         "C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B");
   } else {
     try {
       byte[] bytes = Base64.decode(primes, Base64.DEFAULT);
       if (bytes != null) {
         SerializedData data = new SerializedData(bytes);
         int count = data.readInt32();
         for (int a = 0; a < count; a++) {
           goodPrimes.add(data.readString());
         }
       }
     } catch (Exception e) {
       FileLog.e("tmessages", e);
       goodPrimes.clear();
       goodPrimes.add(
           "C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B");
     }
   }
   System.loadLibrary("tmessages");
 }
Exemplo n.º 2
0
  public Datacenter(SerializedData data, int version) {
    if (version == 0) {
      datacenterId = data.readInt32();
      String address = data.readString();
      addresses.add(address);
      int port = data.readInt32();
      ports.put(address, port);
      int len = data.readInt32();
      if (len != 0) {
        authKey = data.readData(len);
      }
      len = data.readInt32();
      if (len != 0) {
        authKeyId = data.readInt64();
      }
      authorized = data.readInt32() != 0;
      len = data.readInt32();
      for (int a = 0; a < len; a++) {
        ServerSalt salt = new ServerSalt();
        salt.validSince = data.readInt32();
        salt.validUntil = data.readInt32();
        salt.value = data.readInt64();
        if (authServerSaltSet == null) {
          authServerSaltSet = new ArrayList<ServerSalt>();
        }
        authServerSaltSet.add(salt);
      }
    } else if (version == 1) {
      int currentVersion = data.readInt32();
      if (currentVersion == 2 || currentVersion == 3 || currentVersion == 4) {
        datacenterId = data.readInt32();
        if (currentVersion >= 3) {
          lastInitVersion = data.readInt32();
        }
        int len = data.readInt32();
        for (int a = 0; a < len; a++) {
          String address = data.readString();
          addresses.add(address);
          ports.put(address, data.readInt32());
        }

        len = data.readInt32();
        if (len != 0) {
          authKey = data.readData(len);
        }
        if (currentVersion == 4) {
          authKeyId = data.readInt64();
        } else {
          len = data.readInt32();
          if (len != 0) {
            authKeyId = data.readInt64();
          }
        }
        authorized = data.readInt32() != 0;
        len = data.readInt32();
        for (int a = 0; a < len; a++) {
          ServerSalt salt = new ServerSalt();
          salt.validSince = data.readInt32();
          salt.validUntil = data.readInt32();
          salt.value = data.readInt64();
          if (authServerSaltSet == null) {
            authServerSaltSet = new ArrayList<ServerSalt>();
          }
          authServerSaltSet.add(salt);
        }
      }
    } else if (version == 2) {

    }
    readCurrentAddressAndPortNum();
  }
Exemplo n.º 3
0
  public static void loadConfig() {
    synchronized (sync) {
      final File configFile =
          new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat");
      if (configFile.exists()) {
        try {
          SerializedData data = new SerializedData(configFile);
          int ver = data.readInt32();
          if (ver == 1) {
            int constructor = data.readInt32();
            currentUser =
                (TLRPC.TL_userSelf) TLClassStore.Instance().TLdeserialize(data, constructor);
            clientUserId = currentUser.id;
            clientActivated = true;
            MessagesStorage.lastDateValue = data.readInt32();
            MessagesStorage.lastPtsValue = data.readInt32();
            MessagesStorage.lastSeqValue = data.readInt32();
            registeredForPush = data.readBool();
            pushString = data.readString();
            lastSendMessageId = data.readInt32();
            lastLocalId = data.readInt32();
            contactsHash = data.readString();
            importHash = data.readString();
            saveIncomingPhotos = data.readBool();
            if (currentUser.status != null) {
              if (currentUser.status.expires != 0) {
                currentUser.status.was_online = currentUser.status.expires;
              } else {
                currentUser.status.expires = currentUser.status.was_online;
              }
            }
            MessagesStorage.lastQtsValue = data.readInt32();
            MessagesStorage.lastSecretVersion = data.readInt32();
            int val = data.readInt32();
            if (val == 1) {
              MessagesStorage.secretPBytes = data.readByteArray();
            }
            MessagesStorage.secretG = data.readInt32();
            Utilities.stageQueue.postRunnable(
                new Runnable() {
                  @Override
                  public void run() {
                    saveConfig(true, configFile);
                  }
                });
          } else if (ver == 2) {
            int constructor = data.readInt32();
            currentUser =
                (TLRPC.TL_userSelf) TLClassStore.Instance().TLdeserialize(data, constructor);
            clientUserId = currentUser.id;
            clientActivated = true;

            SharedPreferences preferences =
                ApplicationLoader.applicationContext.getSharedPreferences(
                    "userconfing", Context.MODE_PRIVATE);
            registeredForPush = preferences.getBoolean("registeredForPush", false);
            pushString = preferences.getString("pushString", "");
            lastSendMessageId = preferences.getInt("lastSendMessageId", -210000);
            lastLocalId = preferences.getInt("lastLocalId", -210000);
            contactsHash = preferences.getString("contactsHash", "");
            importHash = preferences.getString("importHash", "");
            saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false);
          }
          if (lastLocalId > -210000) {
            lastLocalId = -210000;
          }
          if (lastSendMessageId > -210000) {
            lastSendMessageId = -210000;
          }
          Utilities.stageQueue.postRunnable(
              new Runnable() {
                @Override
                public void run() {
                  saveConfig(true, configFile);
                }
              });
        } catch (Exception e) {
          FileLog.e("tmessages", e);
        }
      } else {
        SharedPreferences preferences =
            ApplicationLoader.applicationContext.getSharedPreferences(
                "userconfing", Context.MODE_PRIVATE);
        registeredForPush = preferences.getBoolean("registeredForPush", false);
        pushString = preferences.getString("pushString", "");
        lastSendMessageId = preferences.getInt("lastSendMessageId", -210000);
        lastLocalId = preferences.getInt("lastLocalId", -210000);
        contactsHash = preferences.getString("contactsHash", "");
        importHash = preferences.getString("importHash", "");
        saveIncomingPhotos = preferences.getBoolean("saveIncomingPhotos", false);
        String user = preferences.getString("user", null);
        if (user != null) {
          byte[] userBytes = Base64.decode(user, Base64.DEFAULT);
          if (userBytes != null) {
            SerializedData data = new SerializedData(userBytes);
            currentUser =
                (TLRPC.TL_userSelf) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
            clientUserId = currentUser.id;
            clientActivated = true;
          }
        }
        if (currentUser == null) {
          clientActivated = false;
          clientUserId = 0;
        }
      }
    }
  }