Beispiel #1
0
  public boolean isSpamMessage(
      Protocol protocol, Message message, boolean isSystem, boolean isPlain) {
    if (!Options.getBoolean(JLocale.getString(R.string.pref_antispam_enable))) {
      return false;
    }
    String uin = message.getSndrUin();
    if (isChecked(uin)) {
      return false;
    }
    denyAuth(protocol, message, isSystem);
    if (!isPlain) {
      return true;
    }
    String msg = message.getText();
    if (msg.length() < 256) {
      // MagicEye.addAction(protocol, uin, "antispam", msg);
    }
    if (message.isOffline()) {
      return true;
    }
    Contact contact = protocol.createTempContact(uin, false);

    String[] msgs =
        Util.explode(Options.getString(JLocale.getString(R.string.pref_antispam_answer)), '\n');
    for (int i = 0; i < msgs.length; ++i) {
      if (msg.equalsIgnoreCase(msgs[i])) {
        sendHelloMessage(protocol, contact);
        return true;
      }
    }
    sendQuestion(protocol, contact);
    return true;
  }
Beispiel #2
0
 public void addSelector(String controlId, int label, int[] items, int index) {
   String[] all = new String[items.length];
   for (int i = 0; i < all.length; ++i) {
     all[i] = JLocale.getString(items[i]);
   }
   addSelector(controlId, label, all, index);
 }
Beispiel #3
0
 private void sendHelloMessage(Protocol protocol, Contact contact) {
   validUins.addElement(contact.getUserId());
   uncheckedUins.removeElement(contact.getUserId());
   if (protocol.isMeVisible(contact)) {
     protocol.sendMessage(
         contact, Options.getString(JLocale.getString(R.string.pref_antispam_hello)), false);
   }
 }
Beispiel #4
0
 public static boolean isSpam(
     Protocol protocol, Message message, boolean isSystem, boolean isPlain) {
   if (Options.getBoolean(JLocale.getString(R.string.pref_antispam_enable)))
     if (antiSpam.containsKeywords(message.getText())) {
       antiSpam.denyAuth(protocol, message, isSystem);
       return true;
     }
   return antiSpam.isSpamMessage(protocol, message, isSystem, isPlain);
 }
Beispiel #5
0
 private void sendQuestion(Protocol protocol, Contact contact) {
   if (uncheckedUins.contains(contact.getUserId())) {
     uncheckedUins.removeElement(contact.getUserId());
     return;
   }
   String message = Options.getString(JLocale.getString(R.string.pref_antispam_msg));
   if (protocol.isMeVisible(contact) && !StringConvertor.isEmpty(message)) {
     protocol.sendMessage(contact, "I don't like spam!\n" + message, false);
     uncheckedUins.addElement(contact.getUserId());
   }
 }
Beispiel #6
0
 public static void saveUnreadMessages() {
   for (int i = ChatHistory.instance.getTotal() - 1; 0 <= i; --i) {
     Chat chat = ChatHistory.instance.chatAt(i);
     int unreadMessageCount = chat.getAllUnreadMessageCount();
     if (unreadMessageCount == 0) {
       if (!Options.getBoolean(JLocale.getString(R.string.pref_history))) {
         HistoryStorage historyStorage = chat.getHistory();
         historyStorage.removeHistory();
       }
     }
   }
 }
Beispiel #7
0
 private boolean containsKeywords(String msg) {
   String opt = Options.getString(JLocale.getString(R.string.pref_antispam_keywords));
   if (0 == opt.length()) return false;
   if (5000 < msg.length()) {
     return true;
   }
   String[] keywords = Util.explode(opt.toLowerCase(), ' ');
   msg = msg.toLowerCase();
   for (int i = 0; i < keywords.length; ++i) {
     if (-1 != msg.indexOf(keywords[i])) {
       return true;
     }
   }
   return false;
 }
Beispiel #8
0
  void populateFromContact(
      final RosterItemView rosterItemView, RosterHelper roster, Protocol p, Contact item) {
    if (p == null || item == null) return;
    rosterItemView.itemNameColor = Scheme.getColor(item.getTextTheme());
    rosterItemView.itemNameFont = item.hasChat() ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT;
    rosterItemView.itemName =
        (item.subcontactsS() == 0)
            ? item.getText()
            : item.getText() + " (" + item.subcontactsS() + ")";

    String statusMessage = roster.getStatusMessage(p, item);
    rosterItemView.itemDescColor = Scheme.getColor(R.attr.contact_status);
    rosterItemView.itemDesc = statusMessage;

    if (Options.getBoolean(JLocale.getString(R.string.pref_users_avatars))) {
      AvatarCache.getInstance()
          .load(
              item.getUserId(),
              item.avatarHash,
              item.getText(),
              new AvatarCache.OnImageLoadListener() {
                @Override
                public void onLoad(Bitmap avatar) {
                  rosterItemView.itemFirstImage = avatar;
                  rosterItemView.repaint();
                }
              });
      rosterItemView.avatarBorderColor = Contact.getStatusColor(item.getStatusIndex());
    }
    // Icon icStatus = item.getLeftIcon(p);
    // if (icStatus != null)
    //    rosterItemView.itemSecondImage = icStatus.getImage().getBitmap();
    if (item.isTyping()) {
      rosterItemView.itemSecondImage = Message.getIcon(Message.ICON_TYPE);
    } else {
      Drawable icMess = ChatHistory.instance.getUnreadMessageIcon(item);
      if (icMess != null) {
        if (icMess == SawimResources.PERSONAL_MESSAGE_ICON) {
          icMess = icMess.getConstantState().newDrawable();
          icMess.setColorFilter(
              Scheme.getColor(R.attr.personal_unread_message), PorterDuff.Mode.MULTIPLY);
        } else {
          icMess = icMess.getConstantState().newDrawable();
          icMess.setColorFilter(Scheme.getColor(R.attr.unread_message), PorterDuff.Mode.MULTIPLY);
        }
        rosterItemView.itemSecondImage = icMess;
      }
    }

    if (item.getXStatusIndex() != XStatusInfo.XSTATUS_NONE) {
      XStatusInfo xStatusInfo = p.getXStatusInfo();
      if (xStatusInfo != null)
        rosterItemView.itemThirdImage =
            xStatusInfo.getIcon(item.getXStatusIndex()).getImage().getBitmap();
    }

    if (!item.isTemp()) {
      if (item.isAuth()) {
        int privacyList = -1;
        if (item.inIgnoreList()) {
          privacyList = 0;
        } else if (item.inInvisibleList()) {
          privacyList = 1;
        } else if (item.inVisibleList()) {
          privacyList = 2;
        }
        if (privacyList != -1)
          rosterItemView.itemThirdImage =
              Contact.serverListsIcons.iconAt(privacyList).getImage().getBitmap();
      } else {
        rosterItemView.itemFourthImage = SawimResources.AUTH_ICON.getBitmap();
      }
    }

    Icon icClient = (null != p.clientInfo) ? p.clientInfo.getIcon(item.clientIndex) : null;
    if (icClient != null && !SawimApplication.hideIconsClient)
      rosterItemView.itemSixthImage = icClient.getImage().getBitmap();
  }
Beispiel #9
0
 public Forms(int caption_, FormListener l, boolean isAccept) {
   this(JLocale.getString(caption_), l, isAccept);
 }
Beispiel #10
0
 private void addTextField_(String controlId, int label, String text) {
   addTextField_(controlId, JLocale.getString(label), text);
 }
Beispiel #11
0
 public void addString(int label, String text) {
   add(create("", CONTROL_TEXT, JLocale.getString(label), text));
 }
Beispiel #12
0
 public void addHeader(int label) {
   add(create("", CONTROL_TEXT, JLocale.getString(label), null));
 }
Beispiel #13
0
 public void addCheckBox(String controlId, int label, boolean selected) {
   Control c = create(controlId, CONTROL_CHECKBOX, null, JLocale.getString(label));
   c.selected = selected;
   add(c);
 }
Beispiel #14
0
 public void addFontVolumeControl(String controlId, int label, int current) {
   Control c = create(controlId, CONTROL_GAUGE_FONT, null, JLocale.getString(label));
   c.level = current;
   add(c);
 }
Beispiel #15
0
 public void addSelector(String controlId, int label, String[] items, int index) {
   Control c = create(controlId, CONTROL_SELECT, null, JLocale.getString(label));
   c.items = items;
   c.current = index % c.items.length;
   add(c);
 }