Check whether underlying chat transport supports html content type before send the text to it.

cusax-fix
Damian Minkov 16 years ago
parent d230b1ae2f
commit 59ab4e62f7

@ -1209,13 +1209,16 @@ public void sendSmsMessage()
*/
protected void sendInstantMessage()
{
String htmlText = getTextFromWriteArea("text/html");
String htmlText = getTextFromWriteArea(
OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
String plainText = getTextFromWriteArea(
OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
String messageText;
String mimeType;
if ( (htmlText.indexOf("<b") > -1
if (chatSession.getCurrentChatTransport().isContentTypeSupported(
OperationSetBasicInstantMessaging.HTML_MIME_TYPE)
&& (htmlText.indexOf("<b") > -1
|| htmlText.indexOf("<i") > -1
|| htmlText.indexOf("<u") > -1
|| htmlText.indexOf("<font") > -1))

@ -101,6 +101,15 @@ public void sendInstantMessage( String message,
String mimeType)
throws Exception;
/**
* Determines whether this chat transport supports the supplied content type
*
* @param contentType the type we want to check
* @return <tt>true</tt> if the chat transport supports it and
* <tt>false</tt> otherwise.
*/
public boolean isContentTypeSupported(String contentType);
/**
* Sends the given SMS message trough this chat transport.
*

@ -241,6 +241,26 @@ public void sendInstantMessage( String message,
imOpSet.sendInstantMessage(contact, msg);
}
/**
* Determines whether this chat transport supports the supplied content type
*
* @param contentType the type we want to check
* @return <tt>true</tt> if the chat transport supports it and
* <tt>false</tt> otherwise.
*/
public boolean isContentTypeSupported(String contentType)
{
OperationSetBasicInstantMessaging imOpSet
= contact
.getProtocolProvider()
.getOperationSet(OperationSetBasicInstantMessaging.class);
if(imOpSet != null)
return imOpSet.isContentTypeSupported(contentType);
else
return false;
}
/**
* Sends the given sms message trough this chat transport.
*

@ -152,6 +152,20 @@ public void sendInstantMessage(String messageText, String mimeType)
adHocChatRoom.sendMessage(message);
}
/**
* Determines whether this chat transport supports the supplied content type
*
* @param contentType the type we want to check
* @return <tt>true</tt> if the chat transport supports it and
* <tt>false</tt> otherwise.
*/
public boolean isContentTypeSupported(String contentType)
{
// we only support plain text for chat rooms for now
return OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE
.equals(contentType);
}
/**
* Sending sms messages is not supported by this chat transport
* implementation.

@ -151,6 +151,20 @@ public void sendInstantMessage(String messageText, String mimeType)
chatRoom.sendMessage(message);
}
/**
* Determines whether this chat transport supports the supplied content type
*
* @param contentType the type we want to check
* @return <tt>true</tt> if the chat transport supports it and
* <tt>false</tt> otherwise.
*/
public boolean isContentTypeSupported(String contentType)
{
// we only support plain text for chat rooms for now
return OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE
.equals(contentType);
}
/**
* Sending sms messages is not supported by this chat transport
* implementation.

Loading…
Cancel
Save