/* (non-Javadoc) * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) */ public void mouseDoubleClick(MouseEvent e) { // 如果当前提示窗口处于显示状态,隐藏之 main.getTipHelper().closeFriendTipShell(); // 得到源model,如果是好友,则开发好友消息窗口或者短消息窗口 // 如果是群,则打开群消息窗口 QTree tree = (QTree) e.getSource(); QItem item = tree.getItemUnderMouse(); if (item == null) return; Model model = (Model) item.getData(); switch (model.type) { case USER: User u = (User) model; // 首先判断是否双击在手机图标上 if (item.getMouseOnAttachment() == 3) { // 如果u是在最近联系人中,不使用这个model if (u.group.isLatest()) { u = ModelRegistry.getUser(u.qq); if (u == null) return; } SMSWindow window = main.getShellLauncher().openSMSWindow(u); window.setReceiver(String.valueOf(u.qq)); } else if (u.isContactable()) { // 如果u是在最近联系人中,不使用这个model // 假如不做这个操作,那么当真正的model有消息时,动画 // 将不会正常停止 if (u.group.isLatest()) { u = ModelRegistry.getUser(u.qq); if (u == null) return; } // 是好友,是陌生人,是最近联系人,则打开消息窗口 if (main.getMessageQueue().isNextTempSessionMessage(u.qq)) main.getShellLauncher().openTempSessionIMWindow(u.qq); else main.getShellLauncher().openNormalIMWindow(u); main.getBlindHelper().refreshGroup(u.group); } else { // 如果是群内成员,缺省显示群名片页,否则显示缺省页 if (u.group.isCluster()) { if (u.qq == main.getMyModel().qq) u.info = main.getMyModel().info; UserInfoWindow uiw = main.getShellLauncher() .openUserInfoWindow( u, (u.qq == main.getMyModel().qq) ? UserInfoWindow.EDITABLE : UserInfoWindow.READ_ONLY); uiw.setCurrentPage(UserInfoWindow.CARD); } else main.getShellLauncher().openUserInfoWindow(u, UserInfoWindow.READ_ONLY); } break; case CLUSTER: Cluster c = ModelRegistry.getCluster(((Cluster) model).clusterId); if (c == null) return; else main.getShellLauncher().openClusterIMWindow(c); break; default: break; } }
@Override protected boolean canRun() { // 创建一个port try { conn = QQPort.CUSTOM_HEAD_INFO.create( main.getClient(), new InetSocketAddress(QQ.QQ_SERVER_DOWNLOAD_CUSTOM_HEAD, 4000), null, true); } catch (IOException e) { log.error("无法连接到自定义头像下载服务器"); return false; } // 得到有自定义头像好友的列表 friends = new ArrayList<Integer>(); Iterator<User> iter = ModelRegistry.getUserIterator(); while (iter.hasNext()) { User u = iter.next(); if (u.hasCustomHead) friends.add(u.qq); } // 判断列表是否大于0 if (friends.isEmpty()) return false; return true; }
/** * 处理得到自定义头像信息成功事件 * * @param e */ private synchronized void processGetCustomHeadInfoSuccess(QQEvent e) { GetCustomHeadInfoReplyPacket packet = (GetCustomHeadInfoReplyPacket) e.getSource(); FaceRegistry reg = FaceRegistry.getInstance(); for (CustomHead head : packet.heads) { User u = ModelRegistry.getUser(head.qq); if (u.customHeadTimestamp < head.timestamp || !reg.hasFace(reg.getMd5ById(u.customHeadId))) headInfo.add(head); } postGetCustomHeadInfo(); }
/* (non-Javadoc) * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) */ public void mouseUp(MouseEvent e) { // 如果当前提示窗口处于显示状态,隐藏之 main.getTipHelper().closeFriendTipShell(); // 如果是右键,弹出菜单 if ((e.stateMask & SWT.BUTTON3) != 0) { MenuHelper helper = main.getMenuHelper(); QTree tree = (QTree) e.getSource(); QItem item = tree.getItemUnderMouse(); if (item == null || item.isMouseOnBlank()) { // item为null或者鼠标在item的空白区域,则显示组菜单 Group g = main.getBlindHelper().getCurrentGroup(); if (g == null) return; switch (g.groupType) { default: helper.setGroupMenuLocation(tree.toDisplay(e.x, e.y)); helper.setGroupMenuData(g); helper.setGroupMenuVisible(true); break; } return; } // 判断model类型,显示不同菜单 Model model = (Model) item.getData(); switch (model.type) { case USER: User u = (User) model; if (u.group.isCluster()) { helper.setMemberMenuData(model); helper.setMemberMenuLocation(tree.toDisplay(e.x, e.y)); helper.setMemberMenuVisible(true); } else { helper.setFriendMenuLocation(tree.toDisplay(e.x, e.y)); helper.setFriendMenuData(model); helper.setFriendMenuVisible(true); } break; case CLUSTER: Cluster c = ModelRegistry.getCluster(((Cluster) model).clusterId); if (c == null) return; switch (c.clusterType) { case DIALOG_CONTAINER: helper.setDialogContainerMenuData(c); helper.setDialogContainerMenuLocation(tree.toDisplay(e.x, e.y)); helper.setDialogContainerMenuVisible(true); break; default: helper.setClusterMenuLocation(tree.toDisplay(e.x, e.y)); helper.setClusterMenuData(c); helper.setClusterMenuVisible(true); break; } break; case ORGANIZATION: helper.setOrganizationMenuData(model); helper.setOrganizationMenuLocation(tree.toDisplay(e.x, e.y)); helper.setOrganizationMenuVisible(true); break; case GROUP: helper.setGroupMenuLocation(tree.toDisplay(e.x, e.y)); helper.setGroupMenuData(model); helper.setGroupMenuVisible(true); break; case DUMMY: Dummy dummy = (Dummy) model; switch (dummy.dummyType) { case CLUSTER_ORGANIZATION: helper.setOrganizationContainerMenuData(model); helper.setOrganizationContainerMenuLocation(tree.toDisplay(e.x, e.y)); helper.setOrganizationContainerMenuVisible(true); break; case SUBJECTS: helper.setSubjectMenuData(model); helper.setSubjectMenuLocation(tree.toDisplay(e.x, e.y)); helper.setSubjectMenuVisible(true); break; } default: break; } } }