2 LinphoneProxyConfigImpl.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 org.linphone.core.LinphoneCore.RegistrationState;
27 class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
29 protected final long nativePtr;
31 private native int getState(long nativePtr);
32 private native void setExpires(long nativePtr, int delay);
34 boolean ownPtr = false;
35 protected LinphoneProxyConfigImpl(String identity,String proxy,String route, boolean enableRegister) throws LinphoneCoreException {
36 nativePtr = newLinphoneProxyConfig();
37 setIdentity(identity);
39 enableRegister(enableRegister);
42 protected LinphoneProxyConfigImpl(long aNativePtr) {
43 nativePtr = aNativePtr;
46 protected void finalize() throws Throwable {
47 //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config");
48 if (ownPtr) delete(nativePtr);
50 private native long newLinphoneProxyConfig();
51 private native void delete(long ptr);
53 private native void edit(long ptr);
54 private native void done(long ptr);
56 private native void setIdentity(long ptr,String identity);
57 private native String getIdentity(long ptr);
58 private native int setProxy(long ptr,String proxy);
59 private native String getProxy(long ptr);
62 private native void enableRegister(long ptr,boolean value);
63 private native boolean isRegisterEnabled(long ptr);
65 private native boolean isRegistered(long ptr);
66 private native void setDialPrefix(long ptr, String prefix);
68 private native String normalizePhoneNumber(long ptr,String number);
70 private native String getDomain(long ptr);
72 private native void setDialEscapePlus(long ptr, boolean value);
74 private native String getRoute(long ptr);
75 private native int setRoute(long ptr,String uri);
76 private native void enablePublish(long ptr,boolean enable);
77 private native boolean publishEnabled(long ptr);
80 public void enableRegister(boolean value) {
81 enableRegister(nativePtr,value);
92 public void setIdentity(String identity) throws LinphoneCoreException {
93 setIdentity(nativePtr,identity);
96 public void setProxy(String proxyUri) throws LinphoneCoreException {
97 if (setProxy(nativePtr,proxyUri)!=0) {
98 throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]");
101 public String normalizePhoneNumber(String number) {
102 return normalizePhoneNumber(nativePtr,number);
104 public void setDialPrefix(String prefix) {
105 setDialPrefix(nativePtr, prefix);
107 public String getDomain() {
108 return getDomain(nativePtr);
110 public void setDialEscapePlus(boolean value) {
111 setDialEscapePlus(nativePtr,value);
113 public String getIdentity() {
114 return getIdentity(nativePtr);
116 public String getProxy() {
117 return getProxy(nativePtr);
119 public boolean isRegistered() {
120 return isRegistered(nativePtr);
122 public boolean registerEnabled() {
123 return isRegisterEnabled(nativePtr);
125 public String getRoute() {
126 return getRoute(nativePtr);
128 public void setRoute(String routeUri) throws LinphoneCoreException {
129 if (setRoute(nativePtr, routeUri) != 0) {
130 throw new LinphoneCoreException("cannot set route ["+routeUri+"]");
133 public void enablePublish(boolean enable) {
134 enablePublish(nativePtr,enable);
136 public RegistrationState getState() {
137 return RegistrationState.fromInt(getState(nativePtr));
140 public void setExpires(int delay) {
141 setExpires(nativePtr, delay);
143 public boolean publishEnabled() {
144 return publishEnabled(nativePtr);