Commit c7ba1b8e authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Update JNI according to latest presence API changes.

parent 879bb3f6
......@@ -3572,6 +3572,47 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearServices(JN
return (jint)linphone_presence_model_clear_services(model);
}
/*
* Class: org_linphone_core_PresenceModelImpl
* Method: nbPersons
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_nbPersons(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresenceModel *model = (LinphonePresenceModel *)ptr;
return (jlong)linphone_presence_model_nb_persons(model);
}
/*
* Class: org_linphone_core_PresenceModelImpl
* Method: getNthPerson
* Signature: (JJ)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNthPerson(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) {
LinphonePresenceModel *model = (LinphonePresenceModel *)ptr;
LinphonePresencePerson *person = linphone_presence_model_get_nth_person(model, (unsigned int)idx);
if (person == NULL) return NULL;
RETURN_USER_DATA_OBJECT("PresencePersonImpl", linphone_presence_person, person)
}
/*
* Class: org_linphone_core_PresenceModelImpl
* Method: addPerson
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addPerson(JNIEnv *env, jobject jobj, jlong ptr, jlong personPtr) {
return (jint)linphone_presence_model_add_person((LinphonePresenceModel *)ptr, (LinphonePresencePerson *)personPtr);
}
/*
* Class: org_linphone_core_PresenceModelImpl
* Method: clearPersons
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearPersons(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresenceModel *model = (LinphonePresenceModel *)ptr;
return (jint)linphone_presence_model_clear_persons(model);
}
/*
* Class: org_linphone_core_PresenceActivityImpl
* Method: newPresenceActivityImpl
......@@ -3676,6 +3717,29 @@ JNIEXPORT void JNICALL Java_org_linphone_core_PresenceServiceImpl_unref(JNIEnv *
linphone_presence_service_unref(service);
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: getId
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceServiceImpl_getId(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresenceService *service = (LinphonePresenceService *)ptr;
const char *cid = linphone_presence_service_get_id(service);
return cid ? env->NewStringUTF(cid) : NULL;
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: setId
* Signature: (JLjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setId(JNIEnv *env, jobject jobj, jlong ptr, jstring id) {
LinphonePresenceService *service = (LinphonePresenceService *)ptr;
const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL;
linphone_presence_service_set_id(service, cid);
if (cid) env->ReleaseStringUTFChars(id, cid);
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: getBasicStatus
......@@ -3719,6 +3783,216 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setContact(JNI
if (ccontact) env->ReleaseStringUTFChars(contact, ccontact);
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: nbNotes
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceServiceImpl_nbNotes(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresenceService *service = (LinphonePresenceService *)ptr;
return (jlong)linphone_presence_service_nb_notes(service);
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: getNthNote
* Signature: (JJ)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceServiceImpl_getNthNote(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) {
LinphonePresenceService *service = (LinphonePresenceService *)ptr;
LinphonePresenceNote *note = linphone_presence_service_get_nth_note(service, (unsigned int)idx);
if (note == NULL) return NULL;
RETURN_USER_DATA_OBJECT("PresenceNoteImpl", linphone_presence_note, note)
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: addNote
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_addNote(JNIEnv *env, jobject jobj, jlong ptr, jlong notePtr) {
return (jint)linphone_presence_service_add_note((LinphonePresenceService *)ptr, (LinphonePresenceNote *)notePtr);
}
/*
* Class: org_linphone_core_PresenceServiceImpl
* Method: clearNotes
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_clearNotes(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresenceService *service = (LinphonePresenceService *)ptr;
return (jint)linphone_presence_service_clear_notes(service);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: newPresencePersonImpl
* Signature: (Ljava/lang/String;)J
*/
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresencePersonImpl_newPresencePersonImpl(JNIEnv *env, jobject jobj, jstring id) {
LinphonePresencePerson *person;
const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL;
person = linphone_presence_person_new(cid);
if (cid) env->ReleaseStringUTFChars(id, cid);
return (jlong)person;
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: unref
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_linphone_core_PresencePersonImpl_unref(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
linphone_presence_person_unref(person);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: getId
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_linphone_core_PresencePersonImpl_getId(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
const char *cid = linphone_presence_person_get_id(person);
return cid ? env->NewStringUTF(cid) : NULL;
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: setId
* Signature: (JLjava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_setId(JNIEnv *env, jobject jobj, jlong ptr, jstring id) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL;
linphone_presence_person_set_id(person, cid);
if (cid) env->ReleaseStringUTFChars(id, cid);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: nbActivities
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresencePersonImpl_nbActivities(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
return (jlong)linphone_presence_person_nb_activities(person);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: getNthActivity
* Signature: (JJ)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_org_linphone_core_PresencePersonImpl_getNthActivity(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
LinphonePresenceActivity *activity = linphone_presence_person_get_nth_activity(person, (unsigned int)idx);
if (activity == NULL) return NULL;
RETURN_USER_DATA_OBJECT("PresenceActivityImpl", linphone_presence_activity, activity)
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: addActivity
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_addActivity(JNIEnv *env, jobject jobj, jlong ptr, jlong activityPtr) {
return (jint)linphone_presence_person_add_activity((LinphonePresencePerson *)ptr, (LinphonePresenceActivity *)activityPtr);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: clearActivities
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_clearActivities(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
return (jint)linphone_presence_person_clear_activities(person);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: nbNotes
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresencePersonImpl_nbNotes(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
return (jlong)linphone_presence_person_nb_notes(person);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: getNthNote
* Signature: (JJ)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_org_linphone_core_PresencePersonImpl_getNthNote(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
LinphonePresenceNote *note = linphone_presence_person_get_nth_note(person, (unsigned int)idx);
if (note == NULL) return NULL;
RETURN_USER_DATA_OBJECT("PresenceNoteImpl", linphone_presence_note, note)
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: addNote
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_addNote(JNIEnv *env, jobject jobj, jlong ptr, jlong notePtr) {
return (jint)linphone_presence_person_add_note((LinphonePresencePerson *)ptr, (LinphonePresenceNote *)notePtr);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: clearNotes
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_clearNotes(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
return (jint)linphone_presence_person_clear_notes(person);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: nbActivitiesNotes
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_linphone_core_PresencePersonImpl_nbActivitiesNotes(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
return (jlong)linphone_presence_person_nb_activities_notes(person);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: getNthActivitiesNote
* Signature: (JJ)Ljava/lang/Object;
*/
JNIEXPORT jobject JNICALL Java_org_linphone_core_PresencePersonImpl_getNthActivitiesNote(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
LinphonePresenceNote *note = linphone_presence_person_get_nth_activities_note(person, (unsigned int)idx);
if (note == NULL) return NULL;
RETURN_USER_DATA_OBJECT("PresenceNoteImpl", linphone_presence_note, note)
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: addActivitiesNote
* Signature: (JJ)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_addActivitiesNote(JNIEnv *env, jobject jobj, jlong ptr, jlong notePtr) {
return (jint)linphone_presence_person_add_activities_note((LinphonePresencePerson *)ptr, (LinphonePresenceNote *)notePtr);
}
/*
* Class: org_linphone_core_PresencePersonImpl
* Method: clearActivitesNotes
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_clearActivitesNotes(JNIEnv *env, jobject jobj, jlong ptr) {
LinphonePresencePerson *person = (LinphonePresencePerson *)ptr;
return (jint)linphone_presence_person_clear_activities_notes(person);
}
/*
* Class: org_linphone_core_PresenceNoteImpl
* Method: unref
......
......@@ -144,4 +144,30 @@ public interface PresenceModel {
*/
int clearServices();
/**
* @brief Gets the number of persons included in the presence model.
* @return The number of persons included in the #PresenceModel object.
*/
long nbPersons();
/**
* @brief Gets the nth person of a presence model.
* @param[in] idx The index of the person to get (the first person having the index 0).
* @return A pointer to a #PresencePerson object if successful, null otherwise.
*/
PresencePerson getNthPerson(long idx);
/**
* @brief Adds a person to a presence model.
* @param[in] person The #PresencePerson object to add to the model.
* @return 0 if successful, a value < 0 in case of error.
*/
int addPerson(PresencePerson person);
/**
* @brief Clears the persons of a presence model.
* @return 0 if successful, a value < 0 in case of error.
*/
int clearPersons();
}
/*
PresencePerson.java
Copyright (C) 2010-2013 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public interface PresencePerson {
/**
* @brief Gets the id of a presence person.
* @return A string containing the id.
*/
String getId();
/**
* @brief Sets the id of a presence person.
* @param[in] id The id string to set. Can be null to generate it automatically.
* @return 0 if successful, a value < 0 in case of error.
*/
int setId(String id);
/**
* @brief Gets the number of activities included in the presence person.
* @return The number of activities included in the #PresencePerson object.
*/
long nbActivities();
/**
* @brief Gets the nth activity of a presence person.
* @param[in] idx The index of the activity to get (the first activity having the index 0).
* @return A #PresenceActivity object if successful, null otherwise.
*/
PresenceActivity getNthActivity(long idx);
/**
* @brief Adds an activity to a presence person.
* @param[in] activity The #PresenceActivity object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
*/
int addActivity(PresenceActivity activity);
/**
* @brief Clears the activities of a presence person.
* @return 0 if successful, a value < 0 in case of error.
*/
int clearActivities();
/**
* @brief Gets the number of notes included in the presence person.
* @return The number of notes included in the #PresencePerson object.
*/
long nbNotes();
/**
* @brief Gets the nth note of a presence person.
* @param[in] idx The index of the note to get (the first note having the index 0).
* @return A pointer to a #PresenceNote object if successful, null otherwise.
*/
PresenceNote getNthNote(long idx);
/**
* @brief Adds a note to a presence person.
* @param[in] note The #PresenceNote object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
*/
int addNote(PresenceNote note);
/**
* @brief Clears the notes of a presence person.
* @return 0 if successful, a value < 0 in case of error.
*/
int clearNotes();
/**
* @brief Gets the number of activities notes included in the presence person.
* @return The number of activities notes included in the #PresencePerson object.
*/
long nbActivitiesNotes();
/**
* @brief Gets the nth activities note of a presence person.
* @param[in] idx The index of the activities note to get (the first note having the index 0).
* @return A pointer to a #PresenceNote object if successful, null otherwise.
*/
PresenceNote getNthActivitiesNote(long idx);
/**
* @brief Adds an activities note to a presence person.
* @param[in] note The #PresenceNote object to add to the person.
* @return 0 if successful, a value < 0 in case of error.
*/
int addActivitiesNote(PresenceNote note);
/**
* @brief Clears the activities notes of a presence person.
* @return 0 if successful, a value < 0 in case of error.
*/
int clearActivitesNotes();
/**
* @brief Gets the native pointer for this object.
*/
long getNativePtr();
}
......@@ -21,6 +21,19 @@ package org.linphone.core;
public interface PresenceService {
/**
* @brief Gets the id of a presence service.
* @return A string containing the id.
*/
String getId();
/**
* @brief Sets the id of a presence service.
* @param[in] id The id string to set. Can be null to generate it automatically.
* @return 0 if successful, a value < 0 in case of error.
*/
int setId(String id);
/**
* @brief Gets the basic status of a presence service.
* @return The #PresenceBasicStatus of the #PresenceService object.
......@@ -41,12 +54,38 @@ public interface PresenceService {
String getContact();
/**
* @brief Sets the contact of a presence model.
* @brief Sets the contact of a presence service.
* @param[in] contact The contact string to set.
* @return 0 if successful, a value < 0 in case of error.
*/
int setContact(String contact);
/**
* @brief Gets the number of notes included in the presence service.
* @return The number of notes included in the #PresenceService object.
*/
long nbNotes();
/**
* @brief Gets the nth note of a presence service.
* @param[in] idx The index of the note to get (the first note having the index 0).
* @return A pointer to a #PresenceNote object if successful, null otherwise.
*/
PresenceNote getNthNote(long idx);
/**
* @brief Adds a note to a presence service.
* @param[in] note The #PresenceNote object to add to the service.
* @return 0 if successful, a value < 0 in case of error.
*/
int addNote(PresenceNote note);
/**
* @brief Clears the notes of a presence service.
* @return 0 if successful, a value < 0 in case of error.
*/
int clearNotes();
/**
* @brief Gets the native pointer for this object.
*/
......
......@@ -154,6 +154,30 @@ public class PresenceModelImpl implements PresenceModel {
return clearServices(mNativePtr);
}
private native long nbPersons(long nativePtr);
@Override
public long nbPersons() {
return nbPersons(mNativePtr);
}
private native Object getNthPerson(long nativePtr, long idx);
@Override
public PresencePerson getNthPerson(long idx) {
return (PresencePerson)getNthPerson(mNativePtr, idx);
}
private native int addPerson(long nativePtr, long personPtr);
@Override
public int addPerson(PresencePerson person) {
return addPerson(mNativePtr, person.getNativePtr());
}
private native int clearPersons(long nativePtr);
@Override
public int clearPersons() {
return clearPersons(mNativePtr);
}
public long getNativePtr() {
return mNativePtr;
}
......
/*
PresencePersonImpl.java
Copyright (C) 2010-2013 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
public class PresencePersonImpl implements PresencePerson {
private long mNativePtr;
protected PresencePersonImpl(long nativePtr) {
mNativePtr = nativePtr;
}
private native long newPresencePersonImpl(String id);
protected PresencePersonImpl(String id) {
mNativePtr = newPresencePersonImpl(id);
}
private native void unref(long nativePtr);
protected void finalize() {
unref(mNativePtr);
}
private native String getId(long nativePtr);
@Override
public String getId() {
return getId(mNativePtr);
}
private native int setId(long nativePtr, String id);
@Override
public int setId(String id) {
return setId(mNativePtr, id);
}
private native long nbActivities(long nativePtr);
@Override
public long nbActivities() {
return nbActivities(mNativePtr);
}
private native Object getNthActivity(long nativePtr, long idx);
@Override
public PresenceActivity getNthActivity(long idx) {
return (PresenceActivity)getNthActivity(mNativePtr, idx);
}