/** * Send a text message * * @param msgId Message-ID * @param txt Text message */ public void sendTextMessage(String msgId, String txt) { // Send message in CPIM String from = ImsModule.IMS_USER_PROFILE.getPublicUri(); String to = getRemoteContact(); String content = ChatUtils.buildCpimMessage(from, to, StringUtils.encodeUTF8(txt), InstantMessage.MIME_TYPE); // Send data boolean result = sendDataChunks(msgId, content, CpimMessage.MIME_TYPE); // Update rich messaging history InstantMessage msg = new InstantMessage(msgId, getRemoteContact(), txt, false, new Date()); RichMessaging.getInstance().addOutgoingChatMessage(msg, this); // Check if message has been sent with success or not if (!result) { // Update rich messaging history RichMessaging.getInstance().markChatMessageFailed(msgId); // Notify listeners for (int i = 0; i < getListeners().size(); i++) { /** M: add server date for delivery status @{ */ ((ChatSessionListener) getListeners().get(i)) .handleMessageDeliveryStatus(msgId, ImdnDocument.DELIVERY_STATUS_FAILED, -1L); /** @} */ } } }
/** * Create INVITE request * * @param content Content part * @return Request * @throws SipException */ private SipRequest createInviteRequest(String content) throws SipException { SipRequest invite = SipMessageFactory.createInvite( getDialogPath(), getFeatureTags(), getAcceptContactTags(), content); // Test if there is a subject if (getSubject() != null) { // Add a subject header invite.addHeader(SubjectHeader.NAME, StringUtils.encodeUTF8(getSubject())); } // Add a contribution ID header invite.addHeader(ChatUtils.HEADER_CONTRIBUTION_ID, getContributionID()); return invite; }