public final void processPacket(Packet packet) { Message msg = (Message) packet; MultiUserChat.this.subject = msg.getSubject(null); MultiUserChat multiUserChat = MultiUserChat.this; msg.getSubject(null); String str = msg.from; MultiUserChat.access$200$42885ab1(multiUserChat); }
/** * Instantiates a new message. * * @param smackMsg the smack msg */ protected Message(final org.jivesoftware.smack.packet.Message smackMsg) { this(smackMsg.getTo()); if (smackMsg.getType().equals(org.jivesoftware.smack.packet.Message.Type.error)) { type = MSG_TYPE_ERROR; } else { type = MSG_TYPE_CHAT; } from = smackMsg.getFrom(); if (type == MSG_TYPE_ERROR) { final XMPPError er = smackMsg.getError(); final String msg = er.getMessage(); if (msg != null) { body = msg; } else { body = er.getCondition(); } } else { body = smackMsg.getBody(); subject = smackMsg.getSubject(); thread = smackMsg.getThread(); } }
@Override public void processMessage(Message message) { final String messageBody = message.getBody(); final String userNickame = message.getFrom().replace("chat_university_of_texas" + Config.MUC_HOST_NAME + "/", ""); final String newNickame = userNickame.split("@")[0]; if (Config.loggingOn) { Log.e( TAG, "Msg from " + newNickame + ": " + message.getBody() + " subj: " + message.getSubject()); } MainActivity.instance() .runOnUiThread( new Runnable() { @Override public void run() { MUCFragment.instance().updateMessage(userNickame, newNickame, messageBody); } }); }
/** * Construct a message from a smack message packet. * * @param smackMsg Smack message packet */ public Message(final org.jivesoftware.smack.packet.Message smackMsg) { mTo = smackMsg.getTo(); mType = (Integer) smackMsg.getProperty(SBMSGTYPE); /*switch (smackMsg.getType()) { case chat: mType = MSG_TYPE_CHAT; break; case groupchat: mType = MSG_TYPE_NEWUSER_BROADCAST; break; case normal: mType = MSG_TYPE_NORMAL; break; case headline: mType = MSG_TYPE_ACK; case error: mType = MSG_TYPE_ERROR; break; default: Log.w(TAG, "message type error" + smackMsg.getType()); break; }*/ this.mFrom = smackMsg.getFrom(); if (mType == MSG_TYPE_ERROR) { XMPPError er = smackMsg.getError(); String msg = er.getMessage(); if (msg != null) mBody = msg; else mBody = er.getCondition(); } else { mBody = smackMsg.getBody(); mSubject = smackMsg.getSubject(); mThread = smackMsg.getThread(); mTime = (String) smackMsg.getProperty("time"); mUniqueMsgIdentifier = (Long) smackMsg.getProperty(UNIQUEID); } }
@Override protected boolean acceptSpecific(Message message) { // Accept only messages which have a subject set return message.getSubject() != null; }
/** * Parses a message packet. * * @param parser the XML parser, positioned at the start of a message packet. * @return a Message packet. * @throws Exception if an exception occurs while parsing the packet. */ public static Packet parseMessage(XmlPullParser parser) throws Exception { Message message = new Message(); String id = parser.getAttributeValue("", "id"); message.setPacketID(id == null ? Packet.ID_NOT_AVAILABLE : id); message.setTo(parser.getAttributeValue("", "to")); message.setFrom(parser.getAttributeValue("", "from")); message.setType(Message.Type.fromString(parser.getAttributeValue("", "type"))); String language = getLanguageAttribute(parser); // determine message's default language String defaultLanguage = null; if (language != null && !"".equals(language.trim())) { message.setLanguage(language); defaultLanguage = language; } else { defaultLanguage = Packet.getDefaultLanguage(); } // Parse sub-elements. We include extra logic to make sure the values // are only read once. This is because it's possible for the names to appear // in arbitrary sub-elements. boolean done = false; String thread = null; Map<String, Object> properties = null; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { String elementName = parser.getName(); String namespace = parser.getNamespace(); if (elementName.equals("subject")) { String xmlLang = getLanguageAttribute(parser); if (xmlLang == null) { xmlLang = defaultLanguage; } String subject = parseContent(parser); if (message.getSubject(xmlLang) == null) { message.addSubject(xmlLang, subject); } } else if (elementName.equals("body")) { String xmlLang = getLanguageAttribute(parser); if (xmlLang == null) { xmlLang = defaultLanguage; } String body = parseContent(parser); if (message.getBody(xmlLang) == null) { message.addBody(xmlLang, body); } } else if (elementName.equals("thread")) { if (thread == null) { thread = parser.nextText(); } } else if (elementName.equals("error")) { message.setError(parseError(parser)); } else if (elementName.equals("properties") && namespace.equals(PROPERTIES_NAMESPACE)) { properties = parseProperties(parser); } // Otherwise, it must be a packet extension. else { message.addExtension( PacketParserUtils.parsePacketExtension(elementName, namespace, parser)); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals("message")) { done = true; } } } message.setThread(thread); // Set packet properties. if (properties != null) { for (String name : properties.keySet()) { message.setProperty(name, properties.get(name)); } } return message; }