Commit 34edd8ac authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added a way to get/set organization field in vCard from API

parent 9b6ebbc0
......@@ -3431,6 +3431,31 @@ 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_getOrganization(JNIEnv* env,
jobject thiz,
jlong ptr) {
LinphoneFriend *lf = (LinphoneFriend *)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char *org = linphone_vcard_get_organization(lvc);
return org ? env->NewStringUTF(org) : NULL;
}
return NULL;
}
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setOrganization(JNIEnv* env,
jobject thiz,
jlong ptr,
jstring jorg) {
LinphoneFriend *lf = (LinphoneFriend *)ptr;
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
if (lvc) {
const char* org = env->GetStringUTFChars(jorg, NULL);
linphone_vcard_set_organization(lvc, org);
env->ReleaseStringUTFChars(jorg, org);
}
}
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
,jobject thiz
,jlong ptr
......
......@@ -163,6 +163,28 @@ MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
return result;
}
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
if (!vCard) return;
if (vCard->belCard->getOrganizations().size() > 0) {
const shared_ptr<belcard::BelCardOrganization> org = vCard->belCard->getOrganizations().front();
org->setValue(organization);
} else {
shared_ptr<belcard::BelCardOrganization> org = belcard::BelCardGeneric::create<belcard::BelCardOrganization>();
org->setValue(organization);
vCard->belCard->addOrganization(org);
}
}
const char* linphone_vcard_get_organization(const LinphoneVcard *vCard) {
if (vCard && vCard->belCard->getOrganizations().size() > 0) {
const shared_ptr<belcard::BelCardOrganization> org = vCard->belCard->getOrganizations().front();
return org->getValue().c_str();
}
return NULL;
}
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
char uuid[64];
......
......@@ -122,6 +122,20 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_
*/
LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard);
/**
* Fills the Organization field of the vCard
* @param[in] vCard the LinphoneVcard
* @param[in] url the Organization
*/
LINPHONE_PUBLIC void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization);
/**
* Gets the Organization of the vCard
* @param[in] vCard the LinphoneVcard
* @return the Organization of the vCard or NULL
*/
LINPHONE_PUBLIC const char* linphone_vcard_get_organization(const LinphoneVcard *vCard);
/**
* Generates a random unique id for the vCard.
* If is required to be able to synchronize the vCard with a CardDAV server
......@@ -163,7 +177,7 @@ LINPHONE_PUBLIC const char* linphone_vcard_get_etag(const LinphoneVcard *vCard);
* @param[in] vCard the LinphoneVcard
* @param[in] url the URL
*/
LINPHONE_PUBLIC void linphone_vcard_set_url(LinphoneVcard *vCard, const char * url);
LINPHONE_PUBLIC void linphone_vcard_set_url(LinphoneVcard *vCard, const char *url);
/**
* Gets the URL of the vCard
......
......@@ -71,6 +71,14 @@ MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) {
return NULL;
}
void linphone_vcard_set_organization(LinphoneVcard *vCard, const char *organization) {
}
const char* linphone_vcard_get_organization(const LinphoneVcard *vCard) {
return NULL;
}
bool_t linphone_vcard_generate_unique_id(LinphoneVcard *vCard) {
return FALSE;
}
......
......@@ -155,4 +155,14 @@ public interface LinphoneFriend {
* @return
*/
String getName();
/**
* Set an organization for this friend
* @param organization
*/
void setOrganization(String organization);
/**
* Get organization of this friend
* @return
*/
String getOrganization();
}
......@@ -130,4 +130,16 @@ class LinphoneFriendImpl implements LinphoneFriend, Serializable {
public String getName() {
return getName(nativePtr);
}
private native void setOrganization(long nativePtr, String organization);
@Override
public void setOrganization(String organization) {
setOrganization(nativePtr, organization);
}
private native String getOrganization(long nativePtr);
@Override
public String getOrganization() {
return getOrganization(nativePtr);
}
}
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