final String comment = (String) args[1];
final ScriptableFunction onFailure = (ScriptableFunction) args[2];
final BBMPlatformNamespace bbmpNpsc = BBMPlatformNamespace.getInstance();
final MessagingService msgService = bbmpNpsc.getMessagingService();
final MessagingServiceListenerImpl msgServiceListener = bbmpNpsc.getMessagingServiceListener();
if(args.length == 3) {
msgServiceListener.setOnFileTransferFailed(onFailure);
msgService.sendFile(fileURI, comment);
} else if(args.length == 4) {
BBMPlatformUser scriptContact = ((BBMPlatformUser) args[3]);
BBMPlatformContact contact = (BBMPlatformContact) scriptContact.getPresence();
msgServiceListener.setOnFileTransferFailed(onFailure);
msgService.sendFile(contact, fileURI, comment);
}
return UNDEFINED;
}