]> sjero.net Git - linphone/blob - java/impl/org/linphone/core/LinphoneProxyConfigImpl.java
JNI method to extract country code from e164 phone number
[linphone] / java / impl / org / linphone / core / LinphoneProxyConfigImpl.java
1 /*
2 LinphoneProxyConfigImpl.java
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4
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.
9
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.
14
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.
18 */
19 package org.linphone.core;
20
21 import org.linphone.core.LinphoneCore.RegistrationState;
22
23
24
25
26
27 class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
28
29         protected final long nativePtr;
30         
31         private native int getState(long nativePtr);
32         private native void setExpires(long nativePtr, int delay);
33
34         boolean ownPtr = false;
35         protected LinphoneProxyConfigImpl(String identity,String proxy,String route, boolean enableRegister) throws LinphoneCoreException {
36                 nativePtr = newLinphoneProxyConfig();
37                 setIdentity(identity);
38                 setProxy(proxy);
39                 enableRegister(enableRegister);
40                 ownPtr=true;
41         }
42         protected LinphoneProxyConfigImpl(long aNativePtr)  {
43                 nativePtr = aNativePtr;
44                 ownPtr=false;
45         }
46         protected void finalize() throws Throwable {
47                 //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config");
48                 if (ownPtr) delete(nativePtr);
49         }
50         private native long newLinphoneProxyConfig();
51         private native void  delete(long ptr);
52
53         private native void edit(long ptr);
54         private native void done(long ptr);
55         
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);
60         
61
62         private native void enableRegister(long ptr,boolean value);
63         private native boolean isRegisterEnabled(long ptr);
64         
65         private native boolean isRegistered(long ptr);
66         private native void setDialPrefix(long ptr, String prefix);
67         
68         private native String normalizePhoneNumber(long ptr,String number);
69         
70         private native String getDomain(long ptr);
71         
72         private native void setDialEscapePlus(long ptr, boolean value);
73         
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);
78         private native void setContactParameters(long ptr, String params);
79         
80         private native int lookupCCCFromIso(long nativePtr, String iso);
81         private native int lookupCCCFromE164(long nativePtr, String e164);
82         
83         public void enableRegister(boolean value) {
84                 enableRegister(nativePtr,value);
85         }
86
87         public void done() {
88                 done(nativePtr);
89         }
90
91         public void edit() {
92                 edit(nativePtr);
93         }
94
95         public void setIdentity(String identity) throws LinphoneCoreException {
96                 setIdentity(nativePtr,identity);
97         }
98
99         public void setProxy(String proxyUri) throws LinphoneCoreException {
100                 if (setProxy(nativePtr,proxyUri)!=0) {
101                         throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]");
102                 }
103         }
104         public String normalizePhoneNumber(String number) {
105                 return normalizePhoneNumber(nativePtr,number);
106         }
107         public void setDialPrefix(String prefix) {
108                 setDialPrefix(nativePtr, prefix);
109         }
110         public String getDomain() {
111                 return getDomain(nativePtr);
112         }
113         public void setDialEscapePlus(boolean value) {
114                  setDialEscapePlus(nativePtr,value);
115         }
116         public String getIdentity() {
117                 return getIdentity(nativePtr);
118         }
119         public String getProxy() {
120                 return getProxy(nativePtr);
121         }
122         public boolean isRegistered() {
123                 return isRegistered(nativePtr);
124         }
125         public boolean registerEnabled() {
126                 return isRegisterEnabled(nativePtr);
127         }
128         public String getRoute() {
129                 return getRoute(nativePtr);
130         }
131         public void setRoute(String routeUri) throws LinphoneCoreException {
132                 if (setRoute(nativePtr, routeUri) != 0) {
133                         throw new LinphoneCoreException("cannot set route ["+routeUri+"]");
134                 }
135         }
136         public void enablePublish(boolean enable) {
137                 enablePublish(nativePtr,enable);
138         }
139         public RegistrationState getState() {
140                 return RegistrationState.fromInt(getState(nativePtr));
141         }
142
143         public void setExpires(int delay) {
144                 setExpires(nativePtr, delay);
145         }
146         public boolean publishEnabled() {
147                 return publishEnabled(nativePtr); 
148         }
149         @Override
150         public void setContactParameters(String params) {
151                 setContactParameters(nativePtr, params);
152         }
153         @Override
154         public int lookupCCCFromIso(String iso) {
155                 return lookupCCCFromIso(nativePtr, iso);
156         }
157         @Override
158         public int lookupCCCFromE164(String e164) {
159                 return lookupCCCFromE164(nativePtr, e164);
160         }
161 }