2 LinphoneFriendImpl.java
3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package org.linphone.core;
21 import java.io.Serializable;
23 class LinphoneFriendImpl implements LinphoneFriend, Serializable {
24 protected final long nativePtr;
25 private native long newLinphoneFriend(String friendUri);
26 private native void setAddress(long nativePtr,long friend);
27 private native long getAddress(long nativePtr);
28 private native void setIncSubscribePolicy(long nativePtr,int enumValue);
29 private native int getIncSubscribePolicy(long nativePtr);
30 private native void enableSubscribes(long nativePtr,boolean value);
31 private native boolean isSubscribesEnabled(long nativePtr);
32 private native int getStatus(long nativePtr);
33 private native void edit(long nativePtr);
34 private native void done(long nativePtr);
36 private native void delete(long ptr);
37 boolean ownPtr = false;
38 protected LinphoneFriendImpl() {
39 nativePtr = newLinphoneFriend(null);
41 protected LinphoneFriendImpl(String friendUri) {
42 nativePtr = newLinphoneFriend(friendUri);
44 protected LinphoneFriendImpl(long aNativePtr) {
45 nativePtr = aNativePtr;
48 protected void finalize() throws Throwable {
49 if (ownPtr) delete(nativePtr);
51 public void setAddress(LinphoneAddress anAddress) {
52 this.setAddress(nativePtr, ((LinphoneAddressImpl)anAddress).nativePtr);
54 public LinphoneAddress getAddress() {
55 return new LinphoneAddressImpl(getAddress(nativePtr));
57 public void setIncSubscribePolicy(SubscribePolicy policy) {
58 setIncSubscribePolicy(nativePtr,policy.mValue);
60 public SubscribePolicy getIncSubscribePolicy() {
61 return SubscribePolicy.fromInt(getIncSubscribePolicy(nativePtr)) ;
63 public void enableSubscribes(boolean enable) {
64 enableSubscribes(nativePtr, enable);
66 public boolean isSubscribesEnabled() {
67 return isSubscribesEnabled(nativePtr);
69 public OnlineStatus getStatus() {
70 return OnlineStatus.fromInt(getStatus(nativePtr));
78 public long getNativePtr() {