linphone-LinphoneFriendImpl文件对应的JNI层文件分析
来源:互联网 发布:上课玩手机神器淘宝 编辑:程序博客网 时间:2024/06/05 05:14
说明
native函数
private native void finalize(long nativePtr); private native long newLinphoneFriend(String friendUri); private native void setAddress(long nativePtr,long friend); private native long getAddress(long nativePtr); private native void setIncSubscribePolicy(long nativePtr,int enumValue); private native int getIncSubscribePolicy(long nativePtr); private native void enableSubscribes(long nativePtr,boolean value); private native boolean isSubscribesEnabled(long nativePtr); private native int getStatus(long nativePtr); private native Object getPresenceModel(long nativePtr); private native void setPresenceModel(long nativePtr, long presencePtr); private native void edit(long nativePtr); private native void done(long nativePtr); private native Object getCore(long ptr); private native void setRefKey(long nativePtr, String key); private native String getRefKey(long nativePtr); private native void setName(long nativePtr, String name); private native String getName(long nativePtr);
具体函数分析
finalize
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_finalize(JNIEnv* env ,jobject thiz ,jlong ptr) { LinphoneFriend *lfriend=(LinphoneFriend*)ptr; linphone_friend_set_user_data(lfriend,NULL); linphone_friend_unref(lfriend);}
LinphoneFriend
submodules/linphone/coreapi/private.h:struct _LinphoneFriend{
struct _LinphoneFriend{ belle_sip_object_t base; void *user_data; LinphoneAddress *uri; MSList *insubs; /*list of SalOp. There can be multiple instances of a same Friend that subscribe to our presence*/ SalOp *outsub; LinphoneSubscribePolicy pol; LinphonePresenceModel *presence; struct _LinphoneCore *lc; BuddyInfo *info; char *refkey; bool_t subscribe; bool_t subscribe_active; bool_t inc_subscribe_pending; bool_t commit; bool_t initial_subscribes_sent; /*used to know if initial subscribe message was sent or not*/ bool_t presence_received; LinphoneVcard *vcard; unsigned int storage_id; LinphoneFriendList *friend_list;};
我隐隐约约的明白了, 只要明白LinphoneFriend 就可以明白这个类型是干什么工作的了。
LinphoneSubscribePolicy
submodules/linphone/coreapi/linphonefriend.h:typedef enum _LinphoneSubscribePolicy {
/** * @addtogroup buddy_list * @{ *//** * Enum controlling behavior for incoming subscription request. * <br> Use by linphone_friend_set_inc_subscribe_policy() */typedef enum _LinphoneSubscribePolicy { /** * Does not automatically accept an incoming subscription request. * This policy implies that a decision has to be taken for each incoming subscription request notified by callback LinphoneCoreVTable.new_subscription_requested * */ LinphoneSPWait, /** * Rejects incoming subscription request. */ LinphoneSPDeny, /** * Automatically accepts a subscription request. */ LinphoneSPAccept} LinphoneSubscribePolicy;
LinphonePresenceModel
submodules/linphone/coreapi/presence.c:struct _LinphonePresenceModel {
/** * Represents the presence model as defined in RFC 4479 and RFC 4480. * This model is not complete. For example, it does not handle devices. */struct _LinphonePresenceModel { LinphoneAddress *presentity; /* "The model seeks to describe the presentity, identified by a presentity URI.*/ void *user_data; int refcnt; MSList *services; /**< A list of _LinphonePresenceService structures. Also named tuples in the RFC. */ MSList *persons; /**< A list of _LinphonePresencePerson structures. */ MSList *notes; /**< A list of _LinphonePresenceNote structures. */};
LinphoneVcard
submodules/linphone/coreapi/vcard.cc:struct _LinphoneVcard {submodules/linphone/coreapi/vcard_stubs.c:struct _LinphoneVcard {submodules/linphone/coreapi/vcard.h:typedef struct _LinphoneVcard LinphoneVcard;
struct _LinphoneVcard { shared_ptr<belcard::BelCard> belCard; char *etag; char *url; unsigned char *md5;};
LinphoneFriendList
submodules/linphone/coreapi/private.h:struct _LinphoneFriendList {
struct _LinphoneFriendList { belle_sip_object_t base; void *user_data; LinphoneCore *lc; LinphoneEvent *event; char *display_name; char *rls_uri; MSList *friends; unsigned char *content_digest; int expected_notification_version; unsigned int storage_id; char *uri; MSList *dirty_friends_to_update; int revision; LinphoneFriendListCbs *cbs;};
linphone_friend_set_user_data
submodules/linphone/coreapi/linphonefriend.h:LINPHONE_PUBLIC void linphone_friend_set_user_data(LinphoneFriend *lf, void *data);submodules/linphone/coreapi/friend.c:void linphone_friend_set_user_data(LinphoneFriend *lf, void *data){
void linphone_friend_set_user_data(LinphoneFriend *lf, void *data){ lf->user_data=data;}
linphone_friend_unref
void linphone_friend_unref(LinphoneFriend *lf) { belle_sip_object_unref(lf);}
newLinphoneFriend
//LinphoneFriendextern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env ,jobject thiz ,jstring jFriendUri) { LinphoneFriend* lResult; if (jFriendUri) { const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL); lResult = linphone_friend_new_with_address(friendUri); linphone_friend_set_user_data(lResult,env->NewWeakGlobalRef(thiz)); env->ReleaseStringUTFChars(jFriendUri, friendUri); } else { lResult = linphone_friend_new(); linphone_friend_set_user_data(lResult,env->NewWeakGlobalRef(thiz)); } return (jlong)lResult;}
linphone_friend_set_user_data
submodules/linphone/coreapi/linphonefriend.h:LINPHONE_PUBLIC void linphone_friend_set_user_data(LinphoneFriend *lf, void *data);submodules/linphone/coreapi/friend.c:void linphone_friend_set_user_data(LinphoneFriend *lf, void *data){
void linphone_friend_set_user_data(LinphoneFriend *lf, void *data){ lf->user_data=data;}
setAddress
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env ,jobject thiz ,jlong ptr ,jlong linphoneAddress) { linphone_friend_set_address((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);}
linphone_friend_set_address
int linphone_friend_set_address(LinphoneFriend *lf, const LinphoneAddress *addr){ LinphoneAddress *fr = linphone_address_clone(addr); LinphoneVcard *vcard = NULL; linphone_address_clean(fr); if (lf->uri != NULL) linphone_address_unref(lf->uri); lf->uri = fr; vcard = linphone_friend_get_vcard(lf); if (vcard) { linphone_vcard_edit_main_sip_address(vcard, linphone_address_as_string_uri_only(fr)); } return 0;}
linphone_address_clone
submodules/linphone/coreapi/address.c:LinphoneAddress * linphone_address_clone(const LinphoneAddress *addr){
/** * Clones a LinphoneAddress object.**/LinphoneAddress * linphone_address_clone(const LinphoneAddress *addr){ return sal_address_clone(addr);}
sal_address_clone
submodules/linphone/coreapi/bellesip_sal/sal_address_impl.c:SalAddress * sal_address_clone(const SalAddress *addr){
SalAddress * sal_address_clone(const SalAddress *addr){ return (SalAddress *) belle_sip_object_ref(belle_sip_object_clone(BELLE_SIP_OBJECT(addr)));}
linphone_address_clean
submodules/linphone/coreapi/address.c:void linphone_address_clean(LinphoneAddress *uri){submodules/linphone/coreapi/linphonecore.h:LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri);
/** * Removes address's tags and uri headers so that it is displayable to the user.**/void linphone_address_clean(LinphoneAddress *uri){ sal_address_clean(uri);}
linphone_friend_get_vcard
LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr) { if (fr) { return fr->vcard; } return NULL;}
linphone_vcard_edit_main_sip_address
submodules/linphone/coreapi/vcard.cc:void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {submodules/linphone/coreapi/vcard_stubs.c:void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) { if (!vCard || !sip_address) return; if (vCard->belCard->getImpp().size() > 0) { const shared_ptr<belcard::BelCardImpp> impp = vCard->belCard->getImpp().front(); impp->setValue(sip_address); } else { shared_ptr<belcard::BelCardImpp> impp = belcard::BelCardGeneric::create<belcard::BelCardImpp>(); impp->setValue(sip_address); vCard->belCard->addImpp(impp); }}
linphone_address_as_string_uri_only
/** * Returns the SIP uri only as a string, that is display name is removed. * The returned char * must be freed by the application. Use ms_free().**/char *linphone_address_as_string_uri_only(const LinphoneAddress *u){ return sal_address_as_string_uri_only(u);}
sal_address_as_string_uri_only
char *sal_address_as_string_uri_only(const SalAddress *addr){ belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr); belle_sip_uri_t* sip_uri = belle_sip_header_address_get_uri(header_addr); belle_generic_uri_t* absolute_uri = belle_sip_header_address_get_absolute_uri(header_addr); char tmp[1024]={0}; size_t off=0; belle_sip_object_t* uri; if (sip_uri) { uri=(belle_sip_object_t*)sip_uri; } else if (absolute_uri) { uri=(belle_sip_object_t*)absolute_uri; } else { ms_error("Cannot generate string for addr [%p] with null uri",addr); return NULL; } belle_sip_object_marshal(uri,tmp,sizeof(tmp),&off); return ms_strdup(tmp);}
getAddress
extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env ,jobject thiz ,jlong ptr) { return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);}
linphone_friend_get_address
const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf){ return lf->uri;}
setIncSubscribePolicy
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env ,jobject thiz ,jlong ptr ,jint policy) { linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);}
linphone_friend_set_inc_subscribe_policy
int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol) { fr->pol=pol; return 0;}
getIncSubscribePolicy
extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env ,jobject thiz ,jlong ptr) { return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);}
linphone_friend_get_inc_subscribe_policy
LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf){ return lf->pol;}
enableSubscribes
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env ,jobject thiz ,jlong ptr ,jboolean value) { linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);}
linphone_friend_enable_subscribes
int linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val){ fr->subscribe=val; return 0;}
isSubscribesEnabled
extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env ,jobject thiz ,jlong ptr) { return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);}
linphone_friend_subscribes_enabled
submodules/linphone/coreapi/linphonefriend.h:LINPHONE_PUBLIC bool_t linphone_friend_subscribes_enabled(const LinphoneFriend *lf);submodules/linphone/coreapi/linphonefriend.h:#define linphone_friend_get_send_subscribe linphone_friend_subscribes_enabledsubmodules/linphone/coreapi/linphonecore_jni.cc: return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
getStatus
extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env ,jobject thiz ,jlong ptr) { return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);}
LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf){ LinphoneOnlineStatus online_status = LinphoneStatusOffline; LinphonePresenceBasicStatus basic_status = LinphonePresenceBasicStatusClosed; LinphonePresenceActivity *activity = NULL; unsigned int nb_activities = 0; if (lf->presence != NULL) { basic_status = linphone_presence_model_get_basic_status(lf->presence); nb_activities = linphone_presence_model_get_nb_activities(lf->presence); online_status = (basic_status == LinphonePresenceBasicStatusOpen) ? LinphoneStatusOnline : LinphoneStatusOffline; if (nb_activities > 1) { char *tmp = NULL; const LinphoneAddress *addr = linphone_friend_get_address(lf); if (addr) tmp = linphone_address_as_string(addr); ms_warning("Friend %s has several activities, get status from the first one", tmp ? tmp : "unknown"); if (tmp) ms_free(tmp); nb_activities = 1; } if (nb_activities == 1) { activity = linphone_presence_model_get_activity(lf->presence); switch (linphone_presence_activity_get_type(activity)) { case LinphonePresenceActivityBreakfast: case LinphonePresenceActivityDinner: case LinphonePresenceActivityLunch: case LinphonePresenceActivityMeal: online_status = LinphoneStatusOutToLunch; break; case LinphonePresenceActivityAppointment: case LinphonePresenceActivityMeeting: case LinphonePresenceActivityPerformance: case LinphonePresenceActivityPresentation: case LinphonePresenceActivitySpectator: case LinphonePresenceActivityWorking: case LinphonePresenceActivityWorship: online_status = LinphoneStatusDoNotDisturb; break; case LinphonePresenceActivityAway: case LinphonePresenceActivitySleeping: online_status = LinphoneStatusAway; break; case LinphonePresenceActivityHoliday: case LinphonePresenceActivityTravel: case LinphonePresenceActivityVacation: online_status = LinphoneStatusVacation; break; case LinphonePresenceActivityBusy: case LinphonePresenceActivityLookingForWork: case LinphonePresenceActivityPlaying: case LinphonePresenceActivityShopping: case LinphonePresenceActivityTV: online_status = LinphoneStatusBusy; break; case LinphonePresenceActivityInTransit: case LinphonePresenceActivitySteering: online_status = LinphoneStatusBeRightBack; break; case LinphonePresenceActivityOnThePhone: online_status = LinphoneStatusOnThePhone; break; case LinphonePresenceActivityOther: case LinphonePresenceActivityPermanentAbsence: online_status = LinphoneStatusMoved; break; case LinphonePresenceActivityUnknown: /* Rely on the basic status information. */ break; case LinphonePresenceActivityOnline: /* Should not happen! */ /*ms_warning("LinphonePresenceActivityOnline should not happen here!");*/ break; case LinphonePresenceActivityOffline: online_status = LinphoneStatusOffline; break; } } } return online_status;}
getPresenceModel
/* * Class: org_linphone_core_LinphoneFriendImpl * Method: getPresenceModel * Signature: (J)Ljava/lang/Object; */JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneFriendImpl_getPresenceModel(JNIEnv *env, jobject jobj, jlong ptr) { LinphoneFriend *lf = (LinphoneFriend *)ptr; LinphonePresenceModel *model = (LinphonePresenceModel *)linphone_friend_get_presence_model(lf); if (model == NULL) return NULL; RETURN_USER_DATA_OBJECT("PresenceModelImpl", linphone_presence_model, model);}
linphone_friend_get_presence_model
const LinphonePresenceModel * linphone_friend_get_presence_model(LinphoneFriend *lf) { return lf->presence;}
setPresenceModel
/* * Class: org_linphone_core_LinphoneCoreImpl * Method: setPresenceModel * Signature: (JILjava/lang/String;J)V */JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setPresenceModel(JNIEnv *env, jobject jobj, jlong ptr, jlong modelPtr) { LinphoneCore *lc = (LinphoneCore *)ptr; LinphonePresenceModel *model = (LinphonePresenceModel *)modelPtr; linphone_core_set_presence_model(lc, model);}
edit
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env ,jobject thiz ,jlong ptr) { return linphone_friend_edit((LinphoneFriend*)ptr);}
linphone_friend_edit
void linphone_friend_edit(LinphoneFriend *fr) { if (fr && fr->vcard) { linphone_vcard_compute_md5_hash(fr->vcard); }}
done
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env ,jobject thiz ,jlong ptr) { linphone_friend_done((LinphoneFriend*)ptr);}
linphone_friend_done
void linphone_friend_done(LinphoneFriend *fr) { ms_return_if_fail(fr); if (!fr->lc || !fr->friend_list) return; linphone_friend_apply(fr, fr->lc); linphone_friend_save(fr, fr->lc); if (fr && fr->vcard) { if (linphone_vcard_compare_md5_hash(fr->vcard) != 0) { ms_debug("vCard's md5 has changed, mark friend as dirty"); fr->friend_list->dirty_friends_to_update = ms_list_append(fr->friend_list->dirty_friends_to_update, linphone_friend_ref(fr)); } }}
getCore
extern "C" jobject Java_org_linphone_core_LinphoneChatRoomImpl_getCore(JNIEnv* env ,jobject thiz ,jlong chatroom_ptr){ LinphoneCore *lc=linphone_chat_room_get_core((LinphoneChatRoom*)chatroom_ptr); LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc); jobject core = ljb->getCore(); return core;}
setRefKey
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setRefKey(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jkey) { const char* key = env->GetStringUTFChars(jkey, NULL); linphone_friend_set_ref_key((LinphoneFriend*)ptr,key); env->ReleaseStringUTFChars(jkey, key);}
linphone_friend_set_ref_key
void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key){ if (lf->refkey != NULL) { ms_free(lf->refkey); lf->refkey = NULL; } if (key) { lf->refkey = ms_strdup(key); } if (lf->lc) { linphone_friend_save(lf, lf->lc); }}
getRefKey
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getRefKey(JNIEnv* env ,jobject thiz ,jlong ptr) { const char * key = linphone_friend_get_ref_key((LinphoneFriend *)ptr); return key ? env->NewStringUTF(key) : NULL;}
setName
extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setName(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jname) { const char* name = env->GetStringUTFChars(jname, NULL); linphone_friend_set_name((LinphoneFriend*)ptr, name); env->ReleaseStringUTFChars(jname, name);}
getName
extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getName(JNIEnv* env ,jobject thiz ,jlong ptr) { const char *name = linphone_friend_get_name((LinphoneFriend*)ptr); return name ? env->NewStringUTF(name) : NULL;}
0 0
- linphone-LinphoneFriendImpl文件对应的JNI层文件分析
- linphone-LinphoneAddressImpl文件对应的JNI层文件分析
- linphone-LinphoneProxyConfigImpl文件对应的JNI层文件分析
- linphone-LinphoneCallLogImpl文件对应的JNI层文件分析
- linphone-LinphoneCallParamsImpl文件对应的JNI层文件分析
- linphone-LinphoneChatMessageImpl文件对应的JNI层文件分析
- linphone-LinphoneChatRoomImpl文件对应的JNI层文件分析
- linphone-LinphoneCoreFactoryImpl文件对应的JNI层文件分析
- linphone-PayloadTypeImpl文件对应的JNI层文件分析
- linphone-LpConfigImpl文件对应的JNI层文件分析
- linphone-LinphoneInfoMessageImpl文件对应的JNI层文件分析
- linphone-LinphoneEventImpl文件对应的JNI层文件分析
- linphone-PresenceActivityImpl文件对应的JNI层文件分析
- linphone-PresenceModelImpl文件对应的JNI层文件分析
- linphone-PresenceNoteImpl文件对应的JNI层文件分析
- linphone-PresencePersonImpl文件对应的JNI层文件分析
- linphone-PresenceServiceImpl文件对应的JNI层文件分析
- linphone-ErrorInfoImpl文件对应的JNI层文件分析
- 杭电2647Reward
- cdoj 1322 柱爷把妹(吃惊高清重制版)
- ZooKeeper实现分布式队列Queue
- ListView/RecyclerView的item中有进度条的处理
- poj 1426 Find The Multiple(bfs+同余定理)
- linphone-LinphoneFriendImpl文件对应的JNI层文件分析
- 1.2.3.1 ISO/OSI参考模型
- poj3041
- android之SharedPreferences简介
- (三)、转义字符
- HDU 5800 To My Girlfriend
- A class file was not written解决方法
- hdu 1226(bfs+同余剪枝)
- 图,谱,马尔可夫过程,聚类结构[by林达华]