Commit 442cd8b9 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added getter/setter for familly/given names in vCards

parent c91eb8c1
......@@ -3484,6 +3484,32 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setName(JNIEnv* env
ReleaseStringUTFChars(env, jname, name);
}
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setFamillyName(JNIEnv* env
,jobject thiz
,jlong ptr
,jstring jname) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char* name = GetStringUTFChars(env, jname);
linphone_vcard_set_familly_name(lvc, name);
ReleaseStringUTFChars(env, jname, name);
}
}
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setGivenName(JNIEnv* env
,jobject thiz
,jlong ptr
,jstring jname) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char* name = GetStringUTFChars(env, jname);
linphone_vcard_set_given_name(lvc, name);
ReleaseStringUTFChars(env, jname, name);
}
}
extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_setRLSUri(JNIEnv* env
,jobject thiz
,jlong ptr
......@@ -3634,6 +3660,30 @@ extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getName(JNIEnv* en
return name ? env->NewStringUTF(name) : NULL;
}
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getFamillyName(JNIEnv* env
,jobject thiz
,jlong ptr) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char *name = linphone_vcard_get_familly_name(lvc);
return name ? env->NewStringUTF(name) : NULL;
}
return NULL;
}
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getGivenName(JNIEnv* env
,jobject thiz
,jlong ptr) {
LinphoneFriend *lf = (LinphoneFriend*)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char *name = linphone_vcard_get_given_name(lvc);
return name ? env->NewStringUTF(name) : NULL;
}
return NULL;
}
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getOrganization(JNIEnv* env,
jobject thiz,
jlong ptr) {
......
......@@ -143,9 +143,13 @@ const char * linphone_vcard_as_vcard4_string(LinphoneVcard *vCard) {
void linphone_vcard_set_full_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
shared_ptr<belcard::BelCardFullName> fn = belcard::BelCardGeneric::create<belcard::BelCardFullName>();
fn->setValue(name);
vCard->belCard->setFullName(fn);
if (vCard->belCard->getFullName()) {
vCard->belCard->getFullName()->setValue(name);
} else {
shared_ptr<belcard::BelCardFullName> fn = belcard::BelCardGeneric::create<belcard::BelCardFullName>();
fn->setValue(name);
vCard->belCard->setFullName(fn);
}
}
const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
......@@ -155,6 +159,44 @@ const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
return result;
}
void linphone_vcard_set_familly_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
if (vCard->belCard->getName()) {
vCard->belCard->getName()->setFamilyName(name);
} else {
shared_ptr<belcard::BelCardName> n = belcard::BelCardGeneric::create<belcard::BelCardName>();
n->setFamilyName(name);
vCard->belCard->setName(n);
}
}
const char* linphone_vcard_get_familly_name(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
const char *result = vCard->belCard->getName() ? vCard->belCard->getName()->getFamilyName().c_str() : NULL;
return result;
}
void linphone_vcard_set_given_name(LinphoneVcard *vCard, const char *name) {
if (!vCard || !name) return;
if (vCard->belCard->getName()) {
vCard->belCard->getName()->setGivenName(name);
} else {
shared_ptr<belcard::BelCardName> n = belcard::BelCardGeneric::create<belcard::BelCardName>();
n->setGivenName(name);
vCard->belCard->setName(n);
}
}
const char* linphone_vcard_get_given_name(const LinphoneVcard *vCard) {
if (!vCard) return NULL;
const char *result = vCard->belCard->getName() ? vCard->belCard->getName()->getGivenName().c_str() : NULL;
return result;
}
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard || !sip_address) return;
......
......@@ -129,6 +129,34 @@ LINPHONE_PUBLIC void linphone_vcard_set_full_name(LinphoneVcard *vCard, const ch
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard);
/**
* Sets the familly name in the N attribute of the vCard.
* @param[in] vCard the LinphoneVcard
* @param[in] name the familly name to set for the vCard
*/
LINPHONE_PUBLIC void linphone_vcard_set_familly_name(LinphoneVcard *vCard, const char *name);
/**
* Returns the familly name in the N attribute of the vCard, or NULL if it isn't set yet.
* @param[in] vCard the LinphoneVcard
* @return the familly name of the vCard, or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_familly_name(const LinphoneVcard *vCard);
/**
* Sets the given name in the N attribute of the vCard.
* @param[in] vCard the LinphoneVcard
* @param[in] name the given name to set for the vCard
*/
LINPHONE_PUBLIC void linphone_vcard_set_given_name(LinphoneVcard *vCard, const char *name);
/**
* Returns the given name in the N attribute of the vCard, or NULL if it isn't set yet.
* @param[in] vCard the LinphoneVcard
* @return the given name of the vCard, or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_given_name(const LinphoneVcard *vCard);
/**
* Adds a SIP address in the vCard, using the IMPP property
* @param[in] vCard the LinphoneVcard
......
......@@ -79,6 +79,22 @@ const char* linphone_vcard_get_full_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_familly_name(LinphoneVcard *vCard, const char *name) {
}
const char* linphone_vcard_get_familly_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_given_name(LinphoneVcard *vCard, const char *name) {
}
const char* linphone_vcard_get_given_name(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_address) {
}
......
......@@ -162,10 +162,30 @@ public interface LinphoneFriend {
*/
void setName(String name);
/**
* get name of this friend
* get a name of this friend
* @return
*/
String getName();
/**
* Set a familly name for this friend
* @param name
*/
void setFamillyName(String name);
/**
* get a familly name of this friend
* @return
*/
String getFamillyName();
/**
* Set a given name for this friend
* @param name
*/
void setGivenName(String name);
/**
* get a given name of this friend
* @return
*/
String getGivenName();
/**
* Set an organization for this friend
* @param organization
......
......@@ -142,6 +142,28 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
return getName(nativePtr);
}
private native void setFamillyName(long nativePtr, String name);
@Override
public void setFamillyName(String name) {
setFamillyName(nativePtr, name);
}
private native String getFamillyName(long nativePtr);
public String getFamillyName() {
return getFamillyName(nativePtr);
}
private native void setGivenName(long nativePtr, String name);
@Override
public void setGivenName(String name) {
setGivenName(nativePtr, name);
}
private native String getGivenName(long nativePtr);
public String getGivenName() {
return getGivenName(nativePtr);
}
private native void setOrganization(long nativePtr, String organization);
@Override
public void setOrganization(String organization) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment