/** * Connects a callback to a signal. * <p> * This differs to {@link GObject#connect} in that it hooks up Bus signals * to the sync callback, not the generic GObject signal mechanism. * * @param signal the name of the signal to connect to. * @param listenerClass the class of the {@code listener} * @param listener the listener to associate with the {@code callback} * @param callback the callback to call when the signal is emitted. */ @Override public synchronized <T> void connect(String signal, Class<T> listenerClass, T listener, final Callback callback) { if (listenerClass.getEnclosingClass() != Bus.class) { super.connect(signal, listenerClass, listener, callback); return; } MessageType type = MessageType.forName(signal); if (type == MessageType.UNKNOWN && "message".equals(signal)) { type = MessageType.ANY; } if (type == MessageType.UNKNOWN) { throw new IllegalArgumentException("Illegal signal: " + signal); } final Map<Class<?>, Map<Object, MessageProxy>> signals = getListenerMap(); Map<Object, MessageProxy> m = signals.get(type); if (m == null) { m = new HashMap<Object, MessageProxy>(); signals.put(listenerClass, m); } MessageProxy proxy = new MessageProxy(type, (BusCallback) callback); m.put(listener, proxy); messageProxies.add(proxy); addWatch(); }
NativeLong C_OpenSession ( NativeLong slotID, /* the slot's ID */ NativeLong flags, /* from CK_SESSION_INFO */ Pointer pApplication, /* passed to callback */ Callback Notify, /* callback function */ NativeLongByReference phSession /* gets session handle */ );
public static final GlibAPI.GDestroyNotify createDestroyNotify(Callback callback) { if (callback == null) return null; final CallbackData data = new CallbackData(); GlibAPI.GDestroyNotify destroy = new GlibAPI.GDestroyNotify() { public void callback(Pointer ignored) { outstandingCallbacks.remove(data); } }; data.callback = callback; data.destroy = destroy; outstandingCallbacks.add(data); return destroy; }
public synchronized long connect(String signal, Callback closure) { NativeLong connectID = GSignalAPI.gsignal.g_signal_connect_data(GObject.this, signal, closure, null, null, 0); if (connectID.intValue() == 0) { throw new IllegalArgumentException(String.format("Failed to connect signal '%s'", signal)); } long id = connectID.longValue(); signalHandlers.put(id, closure); return id; }
public synchronized long connectNotify(final String propName, final Callback callback) { /* * FIXME - need to hold this trampoline's lifecycle to the signal * connection */ NotifyCallback trampoline = new NotifyCallback() { public void onNotify(GObject object, GParamSpec param, Pointer data) { Method[] methods = callback.getClass().getDeclaredMethods(); if (methods.length != 1) throw new RuntimeException(String.format("Callback %s must declare exactly one method", callback .getClass())); Method meth = methods[0]; meth.setAccessible(true); Class<?>[] params = meth.getParameterTypes(); if (params.length != 2) throw new RuntimeException(String.format("Callback %s entry must have exactly two parameters", callback.getClass())); Object propValue = get(propName); try { methods[0].invoke(callback, new Object[] { object, propValue }); } catch (Exception e) { throw new RuntimeException(e); } } }; return connect("notify::" + propName, trampoline); }
public synchronized void disconnect(long id) { Callback cb = signalHandlers.get(id); if (cb == null) throw new IllegalArgumentException("Invalid signal handler id:" + id); GSignalAPI.gsignal.g_signal_handler_disconnect(GObject.this, new NativeLong(id)); signalHandlers.remove(id); }
public static <C extends Callback> C pin(final C callback, final IPinListener<C> listener) { synchronized (pin_lock) { pinned.add(callback); } synchronized (listeners_lock) { if (listener != null) { listeners.put(callback, listener); } } return callback; }
@SuppressWarnings("unchecked") public static <C extends Callback> C unpin(final C callback) { if (callback == null) { return null; } final IPinListener<C> listener; synchronized (pin_lock) { pinned.remove(callback); } synchronized (listeners_lock) { listener = (IPinListener<C>)listeners.remove(callback); } if (listener != null) { if (listener.unpinned(callback)) { if (callback instanceof PinnableCallback) { ((PinnableCallback)callback).dispose(); } } //If the listener returns false, then we do not //explicitly call dispose on the callback -- the user will //need to take care of that himself. } else { if (callback instanceof PinnableCallback) { ((PinnableCallback)callback).dispose(); } } return callback; }
private static void addFoundationMethod(@NotNull ID delegate, @NotNull String selector, @NotNull Callback callback, @NotNull String types) { if (!Foundation.addMethod(delegate, Foundation.createSelector(selector), callback, types)) { throw new RuntimeException("Unable to add method " + selector + " to objective-c delegate class!"); } }
NativeLong g_signal_connect_data(GObject obj, String signal, Callback callback, Pointer data, GClosureNotify destroy_data, int connect_flags);
protected NativeLong g_signal_connect(String signal, Callback callback) { logger.entering("GObject", "g_signal_connect", new Object[] { signal, callback }); return GOBJECT_API.g_signal_connect_data(this, signal, callback, null, null, 0); }
protected GCallback(NativeLong id, Callback cb) { this.id = id != null ? id : new NativeLong(0); this.cb = cb; this.connected = this.id.intValue() != 0; }
protected SignalCallback(String signal, Callback cb) { super(g_signal_connect(signal, cb), cb); if (!connected) { throw new IllegalArgumentException(String.format("Failed to connect signal '%s'", signal)); } }
public <T> void connect(Class<T> listenerClass, T listener, Callback cb) { String signal = listenerClass.getSimpleName().toLowerCase().replaceAll("_", "-"); connect(signal, listenerClass, listener, cb); }
public synchronized <T> void connect(String signal, Class<T> listenerClass, T listener, Callback cb) { addCallback(listenerClass, listener, new SignalCallback(signal, cb)); }
public synchronized <T> void connect(String signal, Class<T> listenerClass, T listener, Callback cb) { Native.setCallbackThreadInitializer(cb, cbi); addCallback(listenerClass, listener, new SignalCallback(signal, cb)); }
public static void protectCallback(Object scope, Callback cb) { s_cbProt.protect(scope,cb); }
public static <C extends Callback> C pin(final C callback) { return pin(callback, null); }
public static <C extends Callback> void dispose(final Callback callback) { if (callback != null && (callback instanceof PinnableCallback)) { ((PinnableCallback)callback).dispose(); return; } }
public void S626_SetErrCallback (long hbd, CallbackFPTR_ERR Callback );
public int sovrin_create_pool_ledger_config(int command_handle, String config_name, String config, Callback cb);
public int sovrin_open_pool_ledger(int command_handle, String config_name, String config, Callback cb);
public int sovrin_refresh_pool_ledger(int command_handle, int handle, Callback cb);
public int sovrin_close_pool_ledger(int command_handle, int handle, Callback cb);
public int sovrin_delete_pool_ledger_config(int command_handle, String config_name, Callback cb);
public int sovrin_create_wallet(int command_handle, String pool_name, String name, String xtype, String config, String credentials, Callback cb);
public int sovrin_open_wallet(int command_handle, String name, String runtime_config, String credentials, Callback cb);
public int sovrin_close_wallet(int command_handle, int handle, Callback cb);
public int sovrin_delete_wallet(int command_handle, String name, String credentials, Callback cb);