]> sjero.net Git - linphone/blob - LinphoneProxyConfigImpl.java
replace vectores by arrays in linphone core api
[linphone] / 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         
79         
80         public void enableRegister(boolean value) {
81                 enableRegister(nativePtr,value);
82         }
83
84         public void done() {
85                 done(nativePtr);
86         }
87
88         public void edit() {
89                 edit(nativePtr);
90         }
91
92         public void setIdentity(String identity) throws LinphoneCoreException {
93                 setIdentity(nativePtr,identity);
94         }
95
96         public void setProxy(String proxyUri) throws LinphoneCoreException {
97                 if (setProxy(nativePtr,proxyUri)!=0) {
98                         throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]");
99                 }
100         }
101         public String normalizePhoneNumber(String number) {
102                 return normalizePhoneNumber(nativePtr,number);
103         }
104         public void setDialPrefix(String prefix) {
105                 setDialPrefix(nativePtr, prefix);
106         }
107         public String getDomain() {
108                 return getDomain(nativePtr);
109         }
110         public void setDialEscapePlus(boolean value) {
111                  setDialEscapePlus(nativePtr,value);
112         }
113         public String getIdentity() {
114                 return getIdentity(nativePtr);
115         }
116         public String getProxy() {
117                 return getProxy(nativePtr);
118         }
119         public boolean isRegistered() {
120                 return isRegistered(nativePtr);
121         }
122         public boolean registerEnabled() {
123                 return isRegisterEnabled(nativePtr);
124         }
125         public String getRoute() {
126                 return getRoute(nativePtr);
127         }
128         public void setRoute(String routeUri) throws LinphoneCoreException {
129                 if (setRoute(nativePtr, routeUri) != 0) {
130                         throw new LinphoneCoreException("cannot set route ["+routeUri+"]");
131                 }
132         }
133         public void enablePublish(boolean enable) {
134                 enablePublish(nativePtr,enable);
135         }
136         public RegistrationState getState() {
137                 return RegistrationState.fromInt(getState(nativePtr));
138         }
139
140         public void setExpires(int delay) {
141                 setExpires(nativePtr, delay);
142         }
143         public boolean publishEnabled() {
144                 return publishEnabled(nativePtr); 
145         }
146 }