linphone-ios/wrappers/java/java_class.mustache

172 lines
No EOL
4.5 KiB
Text

/*
{{className}}.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package {{packageName}};
{{#imports}}
import {{import}}
{{/imports}}
{{#isLinphoneFactory}}
import org.linphone.mediastream.Version;
{{/isLinphoneFactory}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
public interface {{className}} {
{{#enums}}
enum {{className}} {
{{#values}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
{{name}}({{value}}){{commarorsemicolon}}
{{/values}}
protected final int mValue;
private {{className}} (int value) {
mValue = value;
}
static public {{className}} fromInt(int value) throws CoreException {
switch(value) {
{{#values}}
case {{value}}: return {{name}};
{{/values}}
default:
throw new CoreException("Unhandled enum value " + value + " for {{className}}");
}
}
public int toInt() {
return mValue;
}
};
{{/enums}}
{{#isLinphoneFactory}}
{{/isLinphoneFactory}}
{{#methods}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
{{#deprecated}}@Deprecated
{{/deprecated}}public {{return}} {{name}}({{params}}){{#exception}} throws CoreException{{/exception}}{{#enumCast}} throws CoreException{{/enumCast}};
{{/methods}}
/**
* Sets the object to store in this object user's data
*/
public void setUserData(Object data);
/**
* Gets the object stored in this object user's data
*/
public Object getUserData();
{{#staticMethods}}
{{#doc}}
/**
{{#lines}}
* {{line}}
{{/lines}}
*/
{{/doc}}
public {{return}} {{name}}({{params}}){{#exception}} throws CoreException{{/exception}}{{#enumCast}} throws CoreException{{/enumCast}};
{{/staticMethods}}
}
class {{classImplName}} implements {{className}} {
protected long nativePtr = 0;
protected Object userData = null;
protected {{classImplName}}(long ptr) {
nativePtr = ptr;
}
{{#isLinphoneFactory}}
private static boolean loadOptionalLibrary(String s) {
try {
System.loadLibrary(s);
return true;
} catch (Throwable e) {
android.util.Log.w("LinphoneCoreFactoryImpl", "Unable to load optional library " + s + ": " + e.getMessage());
}
return false;
}
static {
System.loadLibrary("gnustl_shared");
loadOptionalLibrary("ffmpeg-linphone");
System.loadLibrary("bctoolbox");
System.loadLibrary("ortp");
System.loadLibrary("mediastreamer_base");
System.loadLibrary("mediastreamer_voip");
System.loadLibrary("linphone");
Version.dumpCapabilities();
}
{{/isLinphoneFactory}}
{{#methods}}
private native {{return_native}} {{name}}({{native_params}});
public {{return}} {{name}}({{params}}) {{#exception}}throws CoreException{{/exception}}{{#enumCast}}throws CoreException{{/enumCast}} {
{{#exception}}int exceptionResult = {{/exception}}{{return_keyword}}{{#enumCast}}{{return}}.fromInt({{/enumCast}}{{#classCast}}({{return}}){{/classCast}}{{name}}(nativePtr{{native_params_impl}}){{#enumCast}}){{/enumCast}};{{#exception}}
if (exceptionResult != 0) throw new CoreException("{{name}} returned value " + exceptionResult){{/exception}}
}
{{/methods}}
private native void unref(long ptr);
protected void finalize() throws Throwable {
if (nativePtr != 0) {
unref(nativePtr);
nativePtr = 0;
}
super.finalize();
}
public void setUserData(Object data) {
userData = data;
}
public Object getUserData() {
return userData;
}
{{#staticMethods}}
@Override
public native {{return_native}} {{name}}({{static_native_params}});
{{/staticMethods}}
}