diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index a3acc1ec2..74d62cb0a 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3287,6 +3287,46 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_unref(JNIEnv *en linphone_event_unref(ev); } +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: newPresenceModelImpl + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__(JNIEnv *env, jobject jobj) { + return (jlong)linphone_presence_model_new(); +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: newPresenceModelImpl + * Signature: (ILjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__ILjava_lang_String_2(JNIEnv *env, jobject jobj, jint type, jstring description) { + LinphonePresenceModel *model; + const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + model = linphone_presence_model_new_with_activity((LinphonePresenceActivityType)type, cdescription); + if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + return (jlong)model; +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: newPresenceModelImpl + * Signature: (ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__ILjava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2( + JNIEnv *env, jobject jobj, jint type, jstring description, jstring note, jstring lang) { + LinphonePresenceModel *model; + const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cnote = note ? env->GetStringUTFChars(note, NULL) : NULL; + const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + model = linphone_presence_model_new_with_activity_and_note((LinphonePresenceActivityType)type, cdescription, cnote, clang); + if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + if (cnote) env->ReleaseStringUTFChars(note, cnote); + if (clang) env->ReleaseStringUTFChars(lang, clang); + return (jlong)model; +} + /* * Class: org_linphone_core_PresenceModelImpl * Method: unref @@ -3353,28 +3393,6 @@ JNIEXPORT void JNICALL Java_org_linphone_core_PresenceModelImpl_setContact(JNIEn if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); } -/* - * Class: org_linphone_core_PresenceModelImpl - * Method: nbActivities - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_nbActivities(JNIEnv *env, jobject jobj, jlong ptr) { - LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - return (jlong)linphone_presence_model_nb_activities(model); -} - -/* - * Class: org_linphone_core_PresenceModelImpl - * Method: getNthActivity - * Signature: (JJ)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNthActivity(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) { - LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - LinphonePresenceActivity *activity = linphone_presence_model_get_nth_activity(model, (unsigned int)idx); - if (activity == NULL) return NULL; - RETURN_USER_DATA_OBJECT("PresenceActivityImpl", linphone_presence_activity, activity) -} - /* * Class: org_linphone_core_PresenceModelImpl * Method: getActivity @@ -3400,17 +3418,35 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_setActivity(JNIE return res; } +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: nbActivities + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_nbActivities(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + return (jlong)linphone_presence_model_nb_activities(model); +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: getNthActivity + * Signature: (JJ)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNthActivity(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + LinphonePresenceActivity *activity = linphone_presence_model_get_nth_activity(model, (unsigned int)idx); + if (activity == NULL) return NULL; + RETURN_USER_DATA_OBJECT("PresenceActivityImpl", linphone_presence_activity, activity) +} + /* * Class: org_linphone_core_PresenceModelImpl * Method: addActivity * Signature: (JILjava/lang/String;)I */ -JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addActivity(JNIEnv *env, jobject jobj, jlong ptr, jint acttype, jstring description) { - LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; - jint res = (jint)linphone_presence_model_add_activity(model, (LinphonePresenceActivityType)acttype, cdescription); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); - return res; +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addActivity(JNIEnv *env, jobject jobj, jlong ptr, jlong activityPtr) { + return (jint)linphone_presence_model_add_activity((LinphonePresenceModel *)ptr, (LinphonePresenceActivity *)activityPtr); } /* @@ -3463,6 +3499,60 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearNotes(JNIEn } /* + * Class: org_linphone_core_PresenceModelImpl + * Method: nbServices + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_nbServices(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + return (jlong)linphone_presence_model_nb_services(model); +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: getNthService + * Signature: (JJ)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNthService(JNIEnv *env, jobject jobj, jlong ptr, jlong idx) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + LinphonePresenceService *service = linphone_presence_model_get_nth_service(model, (unsigned int)idx); + if (service == NULL) return NULL; + RETURN_USER_DATA_OBJECT("PresenceServiceImpl", linphone_presence_service, service) +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: addService + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addService(JNIEnv *env, jobject jobj, jlong ptr, jlong servicePtr) { + return (jint)linphone_presence_model_add_service((LinphonePresenceModel *)ptr, (LinphonePresenceService *)servicePtr); +} + +/* + * Class: org_linphone_core_PresenceModelImpl + * Method: clearServices + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearServices(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; + return (jint)linphone_presence_model_clear_services(model); +} + +/* + * Class: org_linphone_core_PresenceActivityImpl + * Method: newPresenceActivityImpl + * Signature: (ILjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceActivityImpl_newPresenceActivityImpl(JNIEnv *env, jobject jobj, jint type, jstring description) { + LinphonePresenceActivity *activity; + const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + activity = linphone_presence_activity_new((LinphonePresenceActivityType)type, cdescription); + if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + return (jlong)activity; +} + + /* * Class: org_linphone_core_PresenceActivityImpl * Method: unref * Signature: (J)V @@ -3495,6 +3585,16 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_getType(JNIEn return (jint)linphone_presence_activity_get_type(activity); } +/* + * Class: org_linphone_core_PresenceActivityImpl + * Method: setType + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_setType(JNIEnv *env, jobject jobj, jlong ptr, jint type) { + LinphonePresenceActivity *activity = (LinphonePresenceActivity *)ptr; + return (jint)linphone_presence_activity_set_type(activity, (LinphonePresenceActivityType)type); +} + /* * Class: org_linphone_core_PresenceActivityImpl * Method: getDescription @@ -3506,6 +3606,80 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceActivityImpl_getDescrip return cdescription ? env->NewStringUTF(cdescription) : NULL; } +/* + * Class: org_linphone_core_PresenceActivityImpl + * Method: setDescription + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_setDescription(JNIEnv *env, jobject jobj, jlong ptr, jstring description) { + LinphonePresenceActivity *activity = (LinphonePresenceActivity *)ptr; + const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + linphone_presence_activity_set_description(activity, cdescription); + if (cdescription) env->ReleaseStringUTFChars(description, cdescription); +} + +/* + * Class: org_linphone_core_PresenceServiceImpl + * Method: newPresenceServiceImpl + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceServiceImpl_newPresenceServiceImpl(JNIEnv *env, jobject jobj) { + return (jlong)linphone_presence_service_new(); +} + +/* + * Class: org_linphone_core_PresenceServiceImpl + * Method: unref + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_PresenceServiceImpl_unref(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceService *service = (LinphonePresenceService *)ptr; + linphone_presence_service_unref(service); +} + +/* + * Class: org_linphone_core_PresenceServiceImpl + * Method: getBasicStatus + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_getBasicStatus(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceService *service = (LinphonePresenceService *)ptr; + return (jint)linphone_presence_service_get_basic_status(service); +} + +/* + * Class: org_linphone_core_PresenceServiceImpl + * Method: setBasicStatus + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setBasicStatus(JNIEnv *env, jobject jobj, jlong ptr, jint basic_status) { + LinphonePresenceService *service = (LinphonePresenceService *)ptr; + return (jint)linphone_presence_service_set_basic_status(service, (LinphonePresenceBasicStatus)basic_status); +} + +/* + * Class: org_linphone_core_PresenceServiceImpl + * Method: getContact + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceServiceImpl_getContact(JNIEnv *env, jobject jobj, jlong ptr) { + LinphonePresenceService *service = (LinphonePresenceService *)ptr; + const char *ccontact = linphone_presence_service_get_contact(service); + return ccontact ? env->NewStringUTF(ccontact) : NULL; +} + +/* + * Class: org_linphone_core_PresenceServiceImpl + * Method: setContact + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setContact(JNIEnv *env, jobject jobj, jlong ptr, jstring contact) { + LinphonePresenceService *service = (LinphonePresenceService *)ptr; + const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + linphone_presence_service_set_contact(service, ccontact); + if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); +} + /* * Class: org_linphone_core_PresenceNoteImpl * Method: unref diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index 281d89e46..c0513e514 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -111,4 +111,21 @@ abstract public class LinphoneCoreFactory { * Create a LinphoneContent object */ abstract public LinphoneContent createLinphoneContent(String type, String subType, String data); + + /** + * Create a PresenceActivity object. + */ + abstract public PresenceActivity createPresenceActivity(PresenceActivityType type, String description); + + /** + * Create a PresenceService object. + */ + abstract public PresenceService createPresenceService(); + + /** + * Create a PresenceModel object. + */ + abstract public PresenceModel createPresenceModel(); + abstract public PresenceModel createPresenceModel(PresenceActivityType type, String description); + abstract public PresenceModel createPresenceModel(PresenceActivityType type, String description, String note, String lang); } diff --git a/java/common/org/linphone/core/PresenceActivity.java b/java/common/org/linphone/core/PresenceActivity.java index 4f116c43c..b965b526b 100644 --- a/java/common/org/linphone/core/PresenceActivity.java +++ b/java/common/org/linphone/core/PresenceActivity.java @@ -33,10 +33,29 @@ public interface PresenceActivity { */ PresenceActivityType getType(); + /** + * @brief Sets the type of activity of a presence activity. + * @param[in] acttype The activity type to set for the activity. + * @return 0 if successful, a value < 0 in case of error. + */ + int setType(PresenceActivityType type); + /** * @brief Gets the description of a presence activity. * @return A String containing the description of the presence activity, or null if no description is specified. */ String getDescription(); + /** + * @brief Sets the description of a presence activity. + * @param[in] description An additional description of the activity. Can be null if no additional description is to be added. + * @return 0 if successful, a value < 0 in case of error. + */ + int setDescription(String description); + + /** + * @brief Gets the native pointer for this object. + */ + long getNativePtr(); + } diff --git a/java/common/org/linphone/core/PresenceModel.java b/java/common/org/linphone/core/PresenceModel.java index 8f4d3716d..44f232c77 100644 --- a/java/common/org/linphone/core/PresenceModel.java +++ b/java/common/org/linphone/core/PresenceModel.java @@ -52,19 +52,6 @@ public interface PresenceModel { */ void setContact(String contact); - /** - * @brief Gets the number of activities included in the presence model. - * @return The number of activities included in the #PresenceModel object. - */ - long nbActivities(); - - /** - * @brief Gets the nth activity of a presence model. - * @param 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 Gets the first activity of a presence model (there is usually only one). * @return A #PresenceActivity object if successful, null otherwise. @@ -82,13 +69,25 @@ public interface PresenceModel { */ int setActivity(PresenceActivityType activity, String description); + /** + * @brief Gets the number of activities included in the presence model. + * @return The number of activities included in the #PresenceModel object. + */ + long nbActivities(); + + /** + * @brief Gets the nth activity of a presence model. + * @param 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 model. - * @param[in] activity The #PresenceActivityType to add to the model. - * @param[in] description An additional description of the activity to add to the model. Can be null if no additional description is to be added. + * @param[in] activity The #PresenceActivity to add to the model. * @return 0 if successful, a value < 0 in case of error. */ - int addActivity(PresenceActivityType activity, String description); + int addActivity(PresenceActivity activity); /** * @brief Clears the activities of a presence model. @@ -119,4 +118,30 @@ public interface PresenceModel { */ int clearNotes(); + /** + * @brief Gets the number of services included in the presence model. + * @return The number of services included in the #PresenceModel object. + */ + long nbServices(); + + /** + * @brief Gets the nth service of a presence model. + * @param[in] idx The index of the service to get (the first service having the index 0). + * @return A #PresenceService object if successful, null otherwise. + */ + PresenceService getNthService(long idx); + + /** + * @brief Adds a service to a presence model. + * @param[in] service The #PresenceService object to add to the model. + * @return 0 if successful, a value < 0 in case of error. + */ + int addService(PresenceService service); + + /** + * @brief Clears the services of a presence model. + * @return 0 if successful, a value < 0 in case of error. + */ + int clearServices(); + } diff --git a/java/common/org/linphone/core/PresenceNote.java b/java/common/org/linphone/core/PresenceNote.java index a89cde1df..638985fc1 100644 --- a/java/common/org/linphone/core/PresenceNote.java +++ b/java/common/org/linphone/core/PresenceNote.java @@ -33,4 +33,9 @@ public interface PresenceNote { */ String getLang(); + /** + * @brief Gets the native pointer for this object. + */ + long getNativePtr(); + } diff --git a/java/common/org/linphone/core/PresenceService.java b/java/common/org/linphone/core/PresenceService.java new file mode 100644 index 000000000..779073476 --- /dev/null +++ b/java/common/org/linphone/core/PresenceService.java @@ -0,0 +1,55 @@ +/* +PresenceService.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 PresenceService { + + /** + * @brief Gets the basic status of a presence service. + * @return The #PresenceBasicStatus of the #PresenceService object. + */ + PresenceBasicStatus getBasicStatus(); + + /** + * @brief Sets the basic status of a presence service. + * @param[in] status The #PresenceBasicStatus to set for the #PresenceService object. + * @return 0 if successful, a value < 0 in case of error. + */ + int setBasicStatus(PresenceBasicStatus status); + + /** + * @brief Gets the contact of a presence service. + * @return A string containing the contact, or null if no contact is found. + */ + String getContact(); + + /** + * @brief Sets the contact of a presence model. + * @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 native pointer for this object. + */ + long getNativePtr(); + +} diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index e757389c9..b424728d2 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -179,4 +179,30 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { String data) { return new LinphoneContentImpl(type,subType,data); } + + @Override + public PresenceActivity createPresenceActivity(PresenceActivityType type, String description) { + return new PresenceActivityImpl(type, description); + } + + @Override + public PresenceService createPresenceService() { + return new PresenceServiceImpl(); + } + + @Override + public PresenceModel createPresenceModel() { + return new PresenceModelImpl(); + } + + @Override + public PresenceModel createPresenceModel(PresenceActivityType type, String description) { + return new PresenceModelImpl(type, description); + } + + @Override + public PresenceModel createPresenceModel(PresenceActivityType type, String description, String note, String lang) { + return new PresenceModelImpl(type, description, note, lang); + } + } diff --git a/java/impl/org/linphone/core/PresenceActivityImpl.java b/java/impl/org/linphone/core/PresenceActivityImpl.java index fc63c4114..281ecc9f2 100644 --- a/java/impl/org/linphone/core/PresenceActivityImpl.java +++ b/java/impl/org/linphone/core/PresenceActivityImpl.java @@ -26,6 +26,11 @@ public class PresenceActivityImpl implements PresenceActivity { mNativePtr = nativePtr; } + private native long newPresenceActivityImpl(int type, String description); + protected PresenceActivityImpl(PresenceActivityType type, String description) { + mNativePtr = newPresenceActivityImpl(type.toInt(), description); + } + private native void unref(long nativePtr); protected void finalize() { unref(mNativePtr); @@ -43,9 +48,25 @@ public class PresenceActivityImpl implements PresenceActivity { return PresenceActivityType.fromInt(getType(mNativePtr)); } + private native int setType(long nativePtr, int type); + @Override + public int setType(PresenceActivityType type) { + return setType(mNativePtr, type.toInt()); + } + private native String getDescription(long nativePtr); @Override public String getDescription() { return getDescription(mNativePtr); } + + private native int setDescription(long nativePtr, String description); + @Override + public int setDescription(String description) { + return setDescription(mNativePtr, description); + } + + public long getNativePtr() { + return mNativePtr; + } } diff --git a/java/impl/org/linphone/core/PresenceModelImpl.java b/java/impl/org/linphone/core/PresenceModelImpl.java index 3cafe3cd7..7250fe3ac 100644 --- a/java/impl/org/linphone/core/PresenceModelImpl.java +++ b/java/impl/org/linphone/core/PresenceModelImpl.java @@ -26,15 +26,26 @@ public class PresenceModelImpl implements PresenceModel { mNativePtr = nativePtr; } + private native long newPresenceModelImpl(); + protected PresenceModelImpl() { + mNativePtr = newPresenceModelImpl(); + } + + private native long newPresenceModelImpl(int type, String description); + protected PresenceModelImpl(PresenceActivityType type, String description) { + mNativePtr = newPresenceModelImpl(type.toInt(), description); + } + + private native long newPresenceModelImpl(int type, String description, String note, String lang); + protected PresenceModelImpl(PresenceActivityType type, String description, String note, String lang) { + mNativePtr = newPresenceModelImpl(type.toInt(), description, note, lang); + } + private native void unref(long nativePtr); protected void finalize() { unref(mNativePtr); } - public long getNativePtr() { - return mNativePtr; - } - private native int getBasicStatus(long nativePtr); @Override public PresenceBasicStatus getBasicStatus() { @@ -65,18 +76,6 @@ public class PresenceModelImpl implements PresenceModel { setContact(mNativePtr, contact); } - 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); - } - private native Object getActivity(long nativePtr); @Override public PresenceActivity getActivity() { @@ -89,10 +88,22 @@ public class PresenceModelImpl implements PresenceModel { return setActivity(mNativePtr, activity.toInt(), description); } - private native int addActivity(long nativePtr, int activity, String description); + private native long nbActivities(long nativePtr); @Override - public int addActivity(PresenceActivityType activity, String description) { - return addActivity(mNativePtr, activity.toInt(), description); + 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); + } + + private native int addActivity(long nativePtr, long activityPtr); + @Override + public int addActivity(PresenceActivity activity) { + return addActivity(mNativePtr, activity.getNativePtr()); } private native int clearActivities(long nativePtr); @@ -118,4 +129,33 @@ public class PresenceModelImpl implements PresenceModel { public int clearNotes() { return clearNotes(mNativePtr); } + + private native long nbServices(long nativePtr); + @Override + public long nbServices() { + return nbServices(mNativePtr); + } + + private native Object getNthService(long nativePtr, long idx); + @Override + public PresenceService getNthService(long idx) { + return (PresenceService)getNthService(mNativePtr, idx); + } + + private native int addService(long nativePtr, long servicePtr); + @Override + public int addService(PresenceService service) { + return addService(mNativePtr, service.getNativePtr()); + } + + private native int clearServices(long nativePtr); + @Override + public int clearServices() { + return clearServices(mNativePtr); + } + + public long getNativePtr() { + return mNativePtr; + } + } diff --git a/java/impl/org/linphone/core/PresenceNoteImpl.java b/java/impl/org/linphone/core/PresenceNoteImpl.java index 38c541cf2..c5857eec5 100644 --- a/java/impl/org/linphone/core/PresenceNoteImpl.java +++ b/java/impl/org/linphone/core/PresenceNoteImpl.java @@ -42,4 +42,8 @@ public class PresenceNoteImpl implements PresenceNote { public String getLang() { return getLang(mNativePtr); } + + public long getNativePtr() { + return mNativePtr; + } } diff --git a/java/impl/org/linphone/core/PresenceServiceImpl.java b/java/impl/org/linphone/core/PresenceServiceImpl.java new file mode 100644 index 000000000..fe1d80ce2 --- /dev/null +++ b/java/impl/org/linphone/core/PresenceServiceImpl.java @@ -0,0 +1,66 @@ +/* +PresenceServiceImpl.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 PresenceServiceImpl implements PresenceService { + private long mNativePtr; + + protected PresenceServiceImpl(long nativePtr) { + mNativePtr = nativePtr; + } + + private native long newPresenceServiceImpl(); + protected PresenceServiceImpl() { + mNativePtr = newPresenceServiceImpl(); + } + + private native void unref(long nativePtr); + protected void finalize() { + unref(mNativePtr); + } + + private native int getBasicStatus(long nativePtr); + @Override + public PresenceBasicStatus getBasicStatus() { + return PresenceBasicStatus.fromInt(getBasicStatus(mNativePtr)); + } + + private native int setBasicStatus(long nativePtr, int status); + @Override + public int setBasicStatus(PresenceBasicStatus status) { + return setBasicStatus(mNativePtr, status.toInt()); + } + + private native String getContact(long nativePtr); + @Override + public String getContact() { + return getContact(mNativePtr); + } + + private native int setContact(long nativePtr, String contact); + @Override + public int setContact(String contact) { + return setContact(mNativePtr, contact); + } + + public long getNativePtr() { + return mNativePtr; + } +}