forked from mirrors/linphone-iphone
add java wrapper to LinphoneErrorInfo
This commit is contained in:
parent
25e3c36748
commit
9d31ca0e5d
12 changed files with 196 additions and 4 deletions
|
|
@ -1622,6 +1622,10 @@ extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getError(JNIEnv*
|
|||
return linphone_proxy_config_get_error((LinphoneProxyConfig *) ptr);
|
||||
}
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_getErrorInfo(JNIEnv* env,jobject thiz,jlong ptr) {
|
||||
return (jlong)linphone_proxy_config_get_error_info((LinphoneProxyConfig *) ptr);
|
||||
}
|
||||
|
||||
//Auth Info
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
|
||||
|
|
@ -2074,6 +2078,18 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEn
|
|||
return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getErrorInfo( JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
return (jlong)linphone_call_get_error_info((LinphoneCall*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getReason( JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
return (jint)linphone_call_get_reason((LinphoneCall*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteUserAgent(JNIEnv *env, jobject thiz, jlong ptr) {
|
||||
LinphoneCall *call = (LinphoneCall *)ptr;
|
||||
const char *value=linphone_call_get_remote_user_agent(call);
|
||||
|
|
@ -2400,6 +2416,12 @@ extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getReason(JNIEnv*
|
|||
return linphone_chat_message_get_reason((LinphoneChatMessage*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getErrorInfo(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr) {
|
||||
return (jlong)linphone_chat_message_get_error_info((LinphoneChatMessage*)ptr);
|
||||
}
|
||||
|
||||
extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr, jstring jheader_name) {
|
||||
|
|
@ -3684,6 +3706,11 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_getReason(JNIEnv
|
|||
return linphone_event_get_reason(ev);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_linphone_core_LinphoneEventImpl_getErrorInfo(JNIEnv *env, jobject jobj, jlong evptr){
|
||||
LinphoneEvent *ev=(LinphoneEvent*)evptr;
|
||||
return (jlong)linphone_event_get_error_info(ev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_LinphoneEventImpl
|
||||
* Method: getSubscriptionDir
|
||||
|
|
@ -4616,4 +4643,49 @@ JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_isSdp200AckEn
|
|||
return (jboolean)linphone_core_sdp_200_ack_enabled((const LinphoneCore*)lc);
|
||||
}
|
||||
|
||||
/* Header for class org_linphone_core_ErrorInfoImpl */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_linphone_core_ErrorInfoImpl
|
||||
* Method: getReason
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_linphone_core_ErrorInfoImpl_getReason(JNIEnv *env, jobject jobj, jlong ei){
|
||||
return linphone_error_info_get_reason((const LinphoneErrorInfo*)ei);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_ErrorInfoImpl
|
||||
* Method: getProtocolCode
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_linphone_core_ErrorInfoImpl_getProtocolCode(JNIEnv *env, jobject jobj, jlong ei){
|
||||
return linphone_error_info_get_protocol_code((const LinphoneErrorInfo*)ei);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_ErrorInfoImpl
|
||||
* Method: getPhrase
|
||||
* Signature: (J)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_linphone_core_ErrorInfoImpl_getPhrase(JNIEnv *env, jobject jobj, jlong ei){
|
||||
const char *tmp=linphone_error_info_get_phrase((const LinphoneErrorInfo*)ei);
|
||||
return tmp ? env->NewStringUTF(tmp) : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_ErrorInfoImpl
|
||||
* Method: getDetails
|
||||
* Signature: (J)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_linphone_core_ErrorInfoImpl_getDetails(JNIEnv *env, jobject jobj, jlong ei){
|
||||
const char *tmp=linphone_error_info_get_details((const LinphoneErrorInfo*)ei);
|
||||
return tmp ? env->NewStringUTF(tmp) : NULL;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
24
java/common/org/linphone/core/ErrorInfo.java
Normal file
24
java/common/org/linphone/core/ErrorInfo.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package org.linphone.core;
|
||||
|
||||
public interface ErrorInfo {
|
||||
/**
|
||||
* Return the Reason enum corresponding to the error type.
|
||||
* @return the reason.
|
||||
*/
|
||||
Reason getReason();
|
||||
/**
|
||||
* Get the protocol code corresponding to the error (typically a SIP status code).
|
||||
* @return the code.
|
||||
*/
|
||||
int getProtocolCode();
|
||||
/**
|
||||
* Get the reason-phrase provided by the protocol (typically a SIP reason-phrase).
|
||||
* @return the reason phrase.
|
||||
*/
|
||||
String getPhrase();
|
||||
/**
|
||||
* Get details about the error, if provided by the protocol. For SIP it consists of the content of a Warning or Reason header.
|
||||
* @return details about the error.
|
||||
*/
|
||||
String getDetails();
|
||||
}
|
||||
|
|
@ -315,4 +315,12 @@ public interface LinphoneCall {
|
|||
**/
|
||||
LinphoneCall getTransferTargetCall();
|
||||
|
||||
Reason getReason();
|
||||
|
||||
/**
|
||||
* Returns last error reported for the call.
|
||||
* @return an ErrorInfo.
|
||||
*/
|
||||
ErrorInfo getErrorInfo();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,8 +142,14 @@ public interface LinphoneChatMessage {
|
|||
*/
|
||||
int getStorageId();
|
||||
|
||||
/**
|
||||
* @return the reason if response received
|
||||
*/
|
||||
Reason getReason();
|
||||
/**
|
||||
* @return the reason if response received
|
||||
*/
|
||||
Reason getReason();
|
||||
|
||||
/**
|
||||
* Returns full error in case of failure when sending message.
|
||||
* @return an ErrorInfo.
|
||||
*/
|
||||
ErrorInfo getErrorInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ public interface LinphoneEvent {
|
|||
*/
|
||||
Reason getReason();
|
||||
|
||||
/**
|
||||
* In case of error notified, returns the full error details.
|
||||
* @return an ErrorInfo.
|
||||
*/
|
||||
ErrorInfo getErrorInfo();
|
||||
|
||||
/**
|
||||
* Assign an application context to the LinphoneEvent, for later use.
|
||||
* @param obj
|
||||
|
|
|
|||
|
|
@ -211,4 +211,10 @@ public interface LinphoneProxyConfig {
|
|||
* @return reason code.
|
||||
*/
|
||||
public Reason getError();
|
||||
|
||||
/**
|
||||
* Get full error information about last error occured on the proxy config.
|
||||
* @return an ErrorInfo.
|
||||
*/
|
||||
public ErrorInfo getErrorInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ public class Reason {
|
|||
* Server timeout
|
||||
*/
|
||||
static public Reason ServerTimeout = new Reason(19,"ServerTimeout");
|
||||
/**
|
||||
* Unknown
|
||||
*/
|
||||
static public Reason Unknown = new Reason(20,"Unknown");
|
||||
|
||||
protected final int mValue;
|
||||
private final String mStringValue;
|
||||
|
|
|
|||
41
java/impl/org/linphone/core/ErrorInfoImpl.java
Normal file
41
java/impl/org/linphone/core/ErrorInfoImpl.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package org.linphone.core;
|
||||
|
||||
public class ErrorInfoImpl implements ErrorInfo {
|
||||
private Reason mReason;
|
||||
private int mCode;
|
||||
private String mPhrase;
|
||||
private String mDetails;
|
||||
|
||||
private native int getReason(long nativePtr);
|
||||
private native int getProtocolCode(long nativePtr);
|
||||
private native String getPhrase(long nativePtr);
|
||||
private native String getDetails(long nativePtr);
|
||||
|
||||
public ErrorInfoImpl(long nativePtr){
|
||||
mReason=Reason.fromInt(getReason(nativePtr));
|
||||
mCode=getProtocolCode(nativePtr);
|
||||
mPhrase=getPhrase(nativePtr);
|
||||
mDetails=getDetails(nativePtr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reason getReason() {
|
||||
return mReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtocolCode() {
|
||||
return mCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPhrase() {
|
||||
return mPhrase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetails() {
|
||||
return mDetails;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -226,4 +226,14 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
public LinphoneCall getTransferTargetCall() {
|
||||
return (LinphoneCall)getTransferTargetCall(nativePtr);
|
||||
}
|
||||
@Override
|
||||
public Reason getReason() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
private native long getErrorInfo(long nativePtr);
|
||||
@Override
|
||||
public ErrorInfo getErrorInfo() {
|
||||
return new ErrorInfoImpl(getErrorInfo(nativePtr));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,4 +100,9 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
|
|||
public Reason getReason() {
|
||||
return Reason.fromInt(getReason(nativePtr));
|
||||
}
|
||||
private native long getErrorInfo(long nativePtr);
|
||||
@Override
|
||||
public ErrorInfo getErrorInfo() {
|
||||
return new ErrorInfoImpl(getErrorInfo(nativePtr));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,5 +118,10 @@ public class LinphoneEventImpl implements LinphoneEvent {
|
|||
else
|
||||
sendPublish(mNativePtr, null, null, null, null);
|
||||
}
|
||||
private native long getErrorInfo(long nativePtr);
|
||||
@Override
|
||||
public ErrorInfo getErrorInfo() {
|
||||
return new ErrorInfoImpl(getErrorInfo(mNativePtr));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,4 +207,9 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
public String getContactUriParameters() {
|
||||
return getContactUriParameters(nativePtr);
|
||||
}
|
||||
private native long getErrorInfo(long nativePtr);
|
||||
@Override
|
||||
public ErrorInfo getErrorInfo() {
|
||||
return new ErrorInfoImpl(getErrorInfo(nativePtr));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue