Java Code Examples for org.jivesoftware.smack.packet.Message#getSubject()
The following examples show how to use
org.jivesoftware.smack.packet.Message#getSubject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BroadcastPlugin.java From Spark with Apache License 2.0 | 6 votes |
/** * Displays the Serverbroadcast like all other messages * in its on chatcontainer with transcript history * @param message * @param from */ private void broadcastInChat(Message message) { String from = message.getFrom() != null ? message.getFrom().toString() : ""; ChatManager chatManager = SparkManager.getChatManager(); ChatContainer container = chatManager.getChatContainer(); ChatRoomImpl chatRoom; try { chatRoom = (ChatRoomImpl)container.getChatRoom(from); } catch (ChatRoomNotFoundException e) { String windowtitle = message.getSubject()!=null ? message.getSubject() : Res.getString("administrator"); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked("serveralert@" + from); Resourcepart resourcepart = Resourcepart.fromOrThrowUnchecked(Res.getString("broadcast")); chatRoom = new ChatRoomImpl(jid, resourcepart, windowtitle); chatRoom.getBottomPanel().setVisible(false); chatRoom.hideToolbar(); SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom); } chatRoom.getTranscriptWindow().insertNotificationMessage(message.getBody(), ChatManager.NOTIFICATION_COLOR); broadcastRooms.add(chatRoom); }
Example 2
Source File: MucChatService.java From xyTalk-pc with GNU Affero General Public License v3.0 | 5 votes |
private static void dbMessagePersistence(Message message) { xysoft.im.db.model.Message dbMessage = null; String from; Jid fromJID; String datetime; String subject; String body; String id; String threadId; String barejid; String fromUsername; fromJID = message.getFrom(); body = message.getBody(); subject = message.getSubject(); id = message.getStanzaId(); threadId = message.getThread(); from = fromJID.asEntityFullJidIfPossible().toString(); barejid = fromJID.asEntityBareJidIfPossible().toString(); fromUsername = JID.usernameByMuc(from); if (id == null) { DebugUtil.debug("新消息无编号"); } else { if (body == null || body.equals("")) { return; } dbMessage = new xysoft.im.db.model.Message(); dbMessage.setId(id); dbMessage.setMessageContent(body); dbMessage.setRoomId(barejid);// 注意:roomID是barejid dbMessage.setSenderId(from);// SenderId是fulljid dbMessage.setSenderUsername(fromUsername); dbMessage.setTimestamp(System.currentTimeMillis()); dbMessage.setNeedToResend(false); Launcher.messageService.insert(dbMessage); } }
Example 3
Source File: MessageWithSubjectFilter.java From Smack with Apache License 2.0 | 4 votes |
@Override protected boolean acceptSpecific(Message message) { // Accept only messages which have a subject set return message.getSubject() != null; }
Example 4
Source File: BroadcastPlugin.java From Spark with Apache License 2.0 | 4 votes |
/** * Show Server Alert. * * @param message the message to show. * @param type */ private void showAlert(Message message) { Type type = message.getType(); // Do not show alert if the message is an error. if (message.getError() != null) { return; } final String body = message.getBody(); String subject = message.getSubject(); StringBuilder buf = new StringBuilder(); if (subject != null) { buf.append(Res.getString("subject")).append(": ").append(subject); buf.append("\n\n"); } buf.append(body); Jid from = message.getFrom(); final TranscriptWindow window = new TranscriptWindow(); window.insertNotificationMessage(buf.toString(), ChatManager.TO_COLOR); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.add(window, BorderLayout.CENTER); p.setBorder(BorderFactory.createLineBorder(Color.lightGray)); // Count the number of linebreaks <br> and \n String s = message.getBody(); s = s.replace("<br/>", "\n"); s = s.replace("<br>", "\n"); int linebreaks = org.jivesoftware.spark.util.StringUtils. countNumberOfOccurences(s,'\n'); // Currently Serverbroadcasts dont contain Subjects, so this might be a MOTD message boolean mightbeMOTD = message.getSubject()!=null; if (!from.hasLocalpart()) { // if theres no "@" it means the message came from the server if (Default.getBoolean(Default.BROADCAST_IN_CHATWINDOW) || linebreaks > 20 || message.getBody().length() > 1000 || mightbeMOTD) { // if we have more than 20 linebreaks or the message is longer // than 1000characters we should broadcast // in a normal chatwindow broadcastInChat(message); } else { broadcastWithPanel(message); } } else if (message.getFrom() != null) { userToUserBroadcast(message, type, from); } }