⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 environment.java

📁 一个类似QQ的在线通讯聊天软件原码,适合初学者参考学习。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    return securityLevel;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#getSoundFileNames()
   */
  public String[] getSoundFileNames()
  {
    return soundFileNames;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#getSoundFlags()
   */
  public boolean[] getSoundFlags()
  {
    return soundFlags;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#getUnknownList()
   */
  public ContactList getUnknownList()
  {
    return unknownList;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#isSoundEnabled()
   */
  public boolean isSoundEnabled()
  {
    return soundEnabled;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#loadContactList(java.lang.String)
   */
  public ContactList loadContactList(String path) throws Exception
  {
    ContactList contactList = new ContactList();
    Object[] contactData = CryptFile.read(path);
    boolean value;
    for (int index = 0; index < contactData.length; index++)
    {
      if (!contactList.contains(contactData[index].toString()))
      {
        Contact contact = new Contact(contactData[index++].toString());
        contact.setNickName(contactData[index++].toString());
        contact.setFirstName(contactData[index++].toString());
        contact.setLastName(contactData[index++].toString());
        contact.setEmail(contactData[index++].toString());
        value = Boolean.valueOf(contactData[index++].toString()).booleanValue();
        contact.setIsInVisibleList(value);
        value = Boolean.valueOf(contactData[index].toString()).booleanValue();
        contact.setIsInInvisibleList(value);
        contactList.addToContactList(contact);
      }
      else
      {
        index += 7;
      }
    }
    return contactList;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#saveContactList(java.lang.String,
   *      JOscarLib.Management.ContactList)
   */
  public void saveContactList(String path, ContactList contactList)
    throws Exception
  {
    ArrayList data = new ArrayList();
    int size = contactList.getContactListSize();
    Contact contact;
    for (int index = 0; index < size; index++)
    {
      contact = contactList.get(index);
      data.add(contact.getContactId());
      data.add(contact.getNickName());
      data.add(contact.getFirstName());
      data.add(contact.getLastName());
      data.add(contact.getEmail());
      data.add(String.valueOf(contact.getIsInVisibleList()));
      data.add(String.valueOf(contact.getIsInInvisibleList()));
    }
    CryptFile.write(path, data.toArray());
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#sendKnownList()
   */
  public void sendKnownList()
  {
    if (connection != null && connection.isLogged())
    {
      OscarInterface.addUsers(connection, knownList);
    }
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setConnection(JOscarLib.Core.OscarConnection)
   */
  public void setConnection(OscarConnection connection)
  {
    this.connection = connection;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#setDenyUnknown(boolean)
   */
  public void setDenyUnknown(boolean deny)
  {
    denyUnknown = deny;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setHost(java.lang.String)
   */
  public void setHost(String host)
  {
    loginHost = host;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setKnownList(JOscarLib.Management.ContactList)
   */
  public void setKnownList(ContactList knownList)
  {
    this.knownList = knownList;
  }

  /**
   * Sets the localization for this application.
   * @param localization the localization for this application
   */
  public void setLocalization(Localization localization)
  {
    this.localization = localization;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setLoginMode(int)
   */
  public void setLoginMode(int mode)
  {
    if (mode == AUTOLOGIN || mode == AUTOSAVE)
    {
      loginMode = mode;
    }
    else
    {
      loginMode = NOAUTO;
    }
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setLoginStatus(int)
   */
  public void setLoginStatus(int status)
  {
    loginStatus = status;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setPassword(java.lang.String)
   */
  public void setPassword(String passwd)
  {
    password = passwd;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setPort(int)
   */
  public void setPort(int port)
  {
    if (port > 0 && port < 65536)
    {
      loginPort = port;
    }
    else
    {
      loginPort = -1;
    }
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#setSecurityLevel(int)
   */
  public void setSecurityLevel(int level)
  {
    if (level == LOW_SECURITY || level == MEDIUM_SECURITY
        || level == HIGH_SECURITY)
    {
      securityLevel = level;
    }
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#setSoundEnabled(boolean)
   */
  public void setSoundEnabled(boolean enabled)
  {
    soundEnabled = enabled;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Settings#setSoundFiles(java.lang.String[],
   *      boolean[])
   */
  public void setSoundFiles(String[] fileNames, boolean[] enabled)
  {
    soundFileNames = fileNames;
    soundFlags = new boolean[soundFileNames.length];
    int index;
    if (soundFlags.length > enabled.length)
    {
      index = 0;
      while (index < enabled.length)
      {
        soundFlags[index] = enabled[index];
        index++;
      }
      while (index < soundFlags.length)
      {
        soundFlags[index] = true;
        index++;
      }
    }
    else
    {
      index = 0;
      while (index < soundFlags.length)
      {
        soundFlags[index] = enabled[index];
        index++;
      }
    }
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#setUnknownList(JOscarLib.Management.ContactList)
   */
  public void setUnknownList(ContactList unknownList)
  {
    this.unknownList = unknownList;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#sortContactList(JOscarLib.Management.ContactList)
   */
  public ContactList sortContactList(ContactList contactList)
  {
    int outer, inner, size;
    Contact contact;
    ContactList sortedList;
    Object[] displayNames = new Object[contactList.getContactListSize()];
    size = contactList.getContactListSize();
    for (int index = 0; index < size; index++)
    {
      displayNames[index] = getDisplayName(contactList.get(index));
    }
    Arrays.sort(displayNames);
    sortedList = new ContactList();
    size = contactList.getContactListSize();
    for (outer = 0; outer < displayNames.length; outer++)
    {
      for (inner = 0; inner < size; inner++)
      {
        contact = contactList.get(inner);
        if (displayNames[outer].equals(getDisplayName(contact)))
        {
          sortedList.addToContactList(contact);
          break;
        }
      }
    }
    return sortedList;
  }

  /**
   * (non-Javadoc)
   * @see openicq.management.Oscar#synchronizeServerContacts()
   */
  public void synchronizeServerContacts()
  {
    Contact knownContact, serverContact;
    if (connection != null && connection.isLogged())
    {
      int size, innerSize;
      ContactList serverList = new ContactList();
      // TODO: GET THE SERVERS CONTACT LIST
      size = serverList.getContactListSize();
      for (int outer = 0; outer < size; outer++)
      {
        serverContact = serverList.get(outer);
        innerSize = knownList.getContactListSize();
        for (int inner = 0; inner < innerSize; inner++)
        {
          knownContact = knownList.get(inner);
          if (knownContact.getContactId().equals(serverContact.getContactId()))
          {
            knownList.removeFromContactList(knownContact);
            inner--;
            break;
          }
        }
      }
      size = serverList.getContactListSize();
      for (int index = 0; index < size; index++)
      {
        knownList.addToContactList(serverList.get(index));
      }
      cleanUnknownList();
      // TODO: SET THE SERVERS CONTACT LIST
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -