?? contactlist.java.svn-base
字號:
} // if set current if (setCurrent) tree.setCurrentItem(cItemNode); // unlock tree and repaint tree.unlock(); // change status for chat (if exists) item.setStatusImage(); } /* lastUnknownStatus is used for adding contact item as sometimes online messages is received before contact is added to internal list */ private static int lastUnknownStatus = STATUS_NONE; // Updates the client-side contact list (called when a contact changes status) // DO NOT CALL THIS DIRECTLY FROM OTHER THREAND THAN MAIN! // USE RunnableImpl.updateContactList INSTEAD! static public synchronized void update(String uin, int status, int xStatus, String xStatusMessage, byte[] internalIP, byte[] externalIP, int dcPort, int dcType, int icqProt, int authCookie, int signon, int online, int idle, int regdate //#sijapp cond.if target!="DEFAULT" & modules_AVATARS="true"#
, byte[] biHash //#sijapp cond.end#
) { ContactItem cItem = getItembyUIN(uin); int trueStatus = Util.translateStatusReceived(status); if (cItem == null) { lastUnknownStatus = trueStatus; return; } long oldStatus = cItem.getIntValue(ContactItem.CONTACTITEM_STATUS); long oldXStatus = cItem.getIntValue(ContactItem.CONTACTITEM_XSTATUS); boolean statusChanged = (oldStatus != trueStatus) || (xStatus != oldXStatus); boolean wasOnline = (oldStatus != STATUS_OFFLINE); boolean nowOnline = (trueStatus != STATUS_OFFLINE); if (status == STATUS_OFFLINE) { //#sijapp cond.if target isnot "DEFAULT"# cItem.BeginTyping(false); //#sijapp cond.end# } // Online counters statusChanged(cItem, wasOnline, nowOnline, 0); // Set Status cItem.setIntValue(ContactItem.CONTACTITEM_STATUS, trueStatus); // Set x-status cItem.setIntValue(ContactItem.CONTACTITEM_XSTATUS, xStatus); // Set x-status message cItem.setStringValue (ContactItem.CONTACTITEM_XSTATUSMSG, xStatusMessage); //#sijapp cond.if target!="DEFAULT" & modules_AVATARS="true"#
cItem.setBytesArray(ContactItem.CONTACTITEM_BUDDYICON_HASH, biHash); //#sijapp cond.end#
// Update DC values//#sijapp cond.if (target!="DEFAULT")&(modules_FILES="true")# if (dcType != -1) { cItem.setBytesArray(ContactItem.CONTACTITEM_INTERNAL_IP, internalIP); cItem.setBytesArray(ContactItem.CONTACTITEM_EXTERNAL_IP, externalIP); cItem.setIntValue(ContactItem.CONTACTITEM_DC_PORT, (int) dcPort); cItem.setIntValue(ContactItem.CONTACTITEM_DC_TYPE, dcType); cItem.setIntValue(ContactItem.CONTACTITEM_ICQ_PROT, icqProt); cItem.setIntValue(ContactItem.CONTACTITEM_AUTH_COOKIE, authCookie); }//#sijapp cond.end# // Update time values cItem.setIntValue(ContactItem.CONTACTITEM_SIGNON, signon); cItem.setIntValue(ContactItem.CONTACTITEM_ONLINE, online); cItem.setIntValue(ContactItem.CONTACTITEM_IDLE, idle); cItem.setIntValue(ContactItem.CONTACTITEM_REG, regdate); // Play sound notice if selected//#sijapp cond.if target isnot "DEFAULT"# if (trueStatus == STATUS_ONLINE && statusChanged) playSoundNotification(SOUND_TYPE_ONLINE);//#sijapp cond.end# // Update visual list if (statusChanged) contactChanged(cItem, false, (wasOnline && !nowOnline) || (!wasOnline && nowOnline)); Object curScr = JimmUI.getCurrentScreen(); if (tree.isActive()) { String text = null; if (oldStatus != trueStatus) { StatusInfo statInfo = JimmUI.findStatus(StatusInfo.TYPE_STATUS, trueStatus); text = (statInfo != null) ? statInfo.getText() : null; } if (xStatus != oldXStatus) { StatusInfo statInfo = JimmUI.findStatus(StatusInfo.TYPE_X_STATUS, xStatus); if (statInfo != null) text = statInfo.getText(); } if (text != null) JimmUI.showCapText(curScr, cItem.getStringValue(ContactItem.CONTACTITEM_NAME)+": "+text, TimerTasks.TYPE_FLASH); } } // Updates the client-side contact list (called when a contact changes status) static public synchronized void update(String uin, int status) { update(uin, status, -1, null, null, null, 0, 0, -1, 0, -1, -1, -1, -1 //#sijapp cond.if target!="DEFAULT" & modules_AVATARS="true"#
, null //#sijapp cond.end#
); } //#sijapp cond.if target!="DEFAULT" & modules_AVATARS="true"#
static public synchronized void update(String uin, Image image, byte[] biHashOfDone) { ContactItem cItem = getItembyUIN(uin); if (cItem == null) { return; } cItem.setImage(ContactItem.CONTACTITEM_BUDDYICON, image); cItem.setBytesArray(ContactItem.CONTACTITEM_BUDDYICON_HASH_READY, biHashOfDone); } //#sijapp cond.end#
static private void statusChanged(ContactItem cItem, boolean wasOnline, boolean nowOnline, int tolalChanges) { boolean changed = false; // which group id ? int groupId = cItem .getIntValue(ContactItem.CONTACTITEM_GROUP); // which group ? ContactListGroupItem group = getGroupById(groupId); // Calc online counters if (wasOnline && !nowOnline) { onlineCounter--; if (group != null) group.updateCounters(-1, 0); changed = true; } if (!wasOnline && nowOnline) { onlineCounter++; if (group != null) group.updateCounters(1, 0); changed = true; } if (group != null) { group.updateCounters(0, tolalChanges); changed |= (tolalChanges != 0); } if (changed) MainThread.updateContactListCaption(); } //Updates the title of the list static public void updateTitle(int traffic) { String text = onlineCounter + "/" + cItems.size(); if (traffic != 0) text += " " + traffic + ResourceBundle.getString("kb"); //#sijapp cond.if target is "SIEMENS2"# //# if( Options.getBoolean(Options.OPTION_FULL_SCREEN) ) //# { //# String accuLevel = System.getProperty("MPJC_CAP"); //# if( accuLevel != null ) //# text += " " + accuLevel + "%"; //# } //#sijapp cond.end# tree.setCaption(text); } // Removes a contact list item static public void removeContactItem(ContactItem cItem) { synchronized (_this) { // Remove given contact item ContactList.cItems.removeElement(cItem); // Update visual list contactChanged(cItem, false, false); // Update online counters statusChanged( cItem, cItem.getIntValue(ContactItem.CONTACTITEM_STATUS) != STATUS_OFFLINE, false, -1); // Save list safeSave(); } } // Adds a contact list item static public void addContactItem(ContactItem cItem) { synchronized (_this) { if (!cItem.getBooleanValue(ContactItem.CONTACTITEM_ADDED)) { // does contact already exists or temporary ? ContactItem oldItem = getItembyUIN(cItem .getStringValue(ContactItem.CONTACTITEM_UIN)); if (oldItem != null) { removeContactItem(oldItem); lastUnknownStatus = oldItem .getIntValue(ContactItem.CONTACTITEM_STATUS); } // Add given contact item cItems.addElement(cItem); cItem.setBooleanValue(ContactItem.CONTACTITEM_ADDED, true); // Check is chat availible cItem .setBooleanValue( ContactItem.CONTACTITEM_HAS_CHAT, ChatHistory .chatHistoryExists(cItem .getStringValue(ContactItem.CONTACTITEM_UIN))); // Set contact status (if already received) if (lastUnknownStatus != STATUS_NONE) { cItem.setIntValue(ContactItem.CONTACTITEM_STATUS, lastUnknownStatus); lastUnknownStatus = STATUS_NONE; } // Update visual list contactChanged(cItem, true, true); // Update online counters statusChanged( cItem, false, cItem .getIntValue(ContactItem.CONTACTITEM_STATUS) != STATUS_OFFLINE, 1); // Save list safeSave(); } } } // Adds new group static public void addGroup(ContactListGroupItem gItem) { synchronized (_this) { gItems.addElement(gItem); if (!Options.getBoolean(Options.OPTION_USE_GROUPS)) return; TreeNode groupNode = tree.addNode(null, gItem); gNodes.put(new Integer(gItem.getId()), groupNode); safeSave(); } } // removes existing group static public void removeGroup(ContactListGroupItem gItem) { synchronized (_this) { ContactItem cItem; for (int i = cItems.size()-1; i >= 0; i--) { cItem = getCItem(i); if (cItem.getIntValue(ContactItem.CONTACTITEM_GROUP) == gItem.getId()) { if (cItem.getIntValue(ContactItem.CONTACTITEM_STATUS) != STATUS_OFFLINE) onlineCounter--; cItems.removeElementAt(i); } } cItem = null; Integer groupId = new Integer(gItem.getId()); if (Options.getBoolean(Options.OPTION_USE_GROUPS)) { TreeNode node = (TreeNode) gNodes.get(groupId); tree.deleteChild(tree.getRoot(), tree.getIndexOfChild(tree.getRoot(), node)); gNodes.remove(groupId); } gItems.removeElement(gItem); safeSave(); } } static public ContactItem createTempContact(String uin) { synchronized (_this) { ContactItem cItem = getItembyUIN(uin); if (cItem != null) return cItem; try { cItem = new ContactItem(0, 0, uin, uin, false, true); } catch (Exception e) { // Message from non-icq contact return null; } cItems.addElement(cItem); cItem.setBooleanValue(ContactItem.CONTACTITEM_IS_TEMP, true); return cItem; } } /* Adds the given message to the message queue of the contact item identified by the given UIN */ static public boolean addMessage(Message message) { synchronized (_this) { String uin = message.getSndrUin(); ContactItem cItem = getItembyUIN(uin); //#sijapp cond.if modules_ANTISPAM="true"# if (cItem == null || cItem.getBooleanValue(ContactItem.CONTACTITEM_NO_AUTH|ContactItem.CONTACTITEM_IS_TEMP) // This is hack. Don't do like this || cItem.getIntValue(ContactItem.CONTACTITEM_GROUP) == 0) { if (message.needCheckForSpam()) { boolean checked = antiSpamCheckContactFor(uin, message.getText()); if (!checked) return false; } }//#sijapp cond.end# /* Create a temporary contact entry if no contact entry could be found do we have a new temp contact */ if (cItem == null) cItem = createTempContact(uin); /* Add message to chat */ ChatHistory.addMessage(cItem, message); /* Notify splash canvas */ SplashCanvas.messageAvailable(); /* Notify user */ if (!treeBuilt) needPlayMessNotif |= true;//#sijapp cond.if target isnot "DEFAULT" # else playSoundNotification(SOUND_TYPE_MESSAGE);//#sijapp cond.end # /* Flag contact as having chat */ cItem.setBooleanValue(ContactItem.CONTACTITEM_HAS_CHAT, true); /* Increment messages count for group */ ContactListGroupItem gItem = getGroupById(cItem .getIntValue(ContactItem.CONTACTITEM_GROUP)); if (gItem != null) gItem.changeMessCount(+1); /* Update tree */ contactChanged(cItem, true, false); } return true; }//#sijapp cond.if target!="DEFAULT"# //////////////////////////////////// // // // Sound Notification stuff // // // //////////////////////////////////// private static Vector soundQueue = new Vector(); private static void startPlayer(Player player) { try { if (player != null) { if (player.getState() == Player.UNREALIZED) { player.prefetch(); player.realize(); } if (player.getState() != Player.CLOSED) { Thread.sleep(0); player.start(); } } else { playerFree = true; } Thread.sleep(0); } catch (MediaException e) { discardPlayer(player); } catch (Exception e) { discardPlayer(player); } } private static void discardPlayer(Player player) { if (player != null) { player.close(); } playerFree = true; } private static void playSound_Internal(String fileName, int volume) { try { //Siemens 65-75 bugfix//#sijapp cond.if target is "SIEMENS2"# Player p1 = createPlayer("silence.wav"); setVolume(p1,100); p1.start(); p1.close(); playerFree = true;//#sijapp cond.end# Player p = createPlayer(fileName);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -