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 class LinphoneFriendImpl implements LinphoneFriend {
22 protected final long nativePtr;
23 private native long newLinphoneFriend(String friendUri);
24 private native void setAddress(long nativePtr,long friend);
25 private native long getAddress(long nativePtr);
26 private native void setIncSubscribePolicy(long nativePtr,int enumValue);
27 private native int getIncSubscribePolicy(long nativePtr);
28 private native void enableSubscribes(long nativePtr,boolean value);
29 private native boolean isSubscribesEnabled(long nativePtr);
30 private native int getStatus(long nativePtr);
31 private native void edit(long nativePtr);
32 private native void done(long nativePtr);
34 private native void delete(long ptr);
35 boolean ownPtr = false;
36 protected LinphoneFriendImpl() {
37 nativePtr = newLinphoneFriend(null);
39 protected LinphoneFriendImpl(String friendUri) {
40 nativePtr = newLinphoneFriend(friendUri);
42 protected LinphoneFriendImpl(long aNativePtr) {
43 nativePtr = aNativePtr;
46 protected void finalize() throws Throwable {
47 if (ownPtr) delete(nativePtr);
49 public void setAddress(LinphoneAddress anAddress) {
50 this.setAddress(nativePtr, ((LinphoneAddressImpl)anAddress).nativePtr);
53 public LinphoneAddress getAddress() {
54 return new LinphoneAddressImpl(getAddress(nativePtr));
56 public void setIncSubscribePolicy(SubscribePolicy policy) {
57 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);
70 public OnlineStatus getStatus() {
71 return OnlineStatus.fromInt(getStatus(nativePtr));