public CallbackDataConverter(CallbackInfo cbInfo) { this.callbackFactory = CallbackManager.getInstance().getCallbackFactory(cbInfo.getRuntime(), cbInfo); this.functionInfo = new NativeFunctionInfo( cbInfo.getRuntime(), cbInfo.getReturnType(), cbInfo.getParameterTypes(), cbInfo.isStdcall() ? CallingConvention.STDCALL : CallingConvention.DEFAULT); }
public void runCommandLoop() { while (true) { int cmd = readInt(); if (cmd == -1) { loader.init(); // init intercom_return(); } else if (cmd == -2) { // shutdown intercom_return(); return; } else // callback { CallbackInfo cb = callbacks.get(cmd); ArrayList<Object> args = new ArrayList<Object>(); for (InterprocType type : cb.getTypes()) { switch (type) { case boolType: args.add(readBool()); break; case int8: args.add(readByte()); break; case int16: args.add(readShort()); break; case int32: args.add(readInt()); break; case int64: args.add(readLong()); break; case floatType: args.add(readFloat()); break; case string: args.add(readString()); break; } } boolean retval = false; try { retval = (Boolean) cb.getMethod().invoke(cb.getObject(), args.toArray()); } catch (Throwable e) { logger_log( LogType.LOG_CRITICAL, "msJavaPlugin-java", "An unhandled exception was thrown in a callback function."); PrintWriter pw = new PrintWriter(new StringWriter()); e.printStackTrace(pw); logger_log(LogType.LOG_CRITICAL, "msJavaPlugin-java", pw.toString()); } intercom_return(retval); } } }
public void plugin_addCallback(String hookID, Object obj, Method method) { /* string HookID int32 function id int32 argument count int8 type of arg1 ... int8 type of argn */ CallbackInfo cb = new CallbackInfo(obj, method); writeInt(ClientCommand.plugin_addCallback.ordinal()); writeString(hookID); writeInt(cb.getIndex()); // function id writeInt(method.getParameterTypes().length); // argument count // argument types writeArgTypes(cb.getTypes()); callbacks.add(cb); }
/** * Synchronous upload a gpx file, used by the worker thread (actually by the posted request) * * @param username * @param pwHash * @param trackName * @param gpxData * @return * @throws CWException */ public ServerMessage UploadGpx(UploadGPXRequest request) throws CWException { if (request.getCallback() != null) this.publishProgress( new CallbackInfo( request.getCallback(), RequestProgressInfo.CreateStartingInfo(), request)); try { Vector<PropertyInfo> properties = new Vector<PropertyInfo>(); properties.add(CreatePrimitivePropertyInfo("username", request.getUsername())); properties.add(CreatePrimitivePropertyInfo("password", request.getPwHash())); properties.add(CreatePrimitivePropertyInfo("trackname", request.getTrackname())); properties.add(CreatePrimitivePropertyInfo("gpx", request.getGPXData())); String serverMessage = PerformSOAPCall("UploadGPX", properties.toArray(new PropertyInfo[0]), null).toString(); ServerMessage msg = new ServerMessage(serverMessage); if (request.getCallback() != null) this.publishProgress( new CallbackInfo( request.getCallback(), RequestProgressInfo.CreateCompletionInfo(), request)); return msg; } catch (CWException e) { if (request.getCallback() != null) { // Post the execution callback and wait till it's executed by the ui thread CallbackInfo ci = new CallbackInfo( request.getCallback(), RequestProgressInfo.CreateErrorInfo(e.toString()), request); try { ci.AcquireExecutionLock(); this.publishProgress(ci); ci.WaitForExecution(); } finally { ci.ReleaseExecutionLock(); } throw new CWWithCallbackInfoException(e.getMessage(), ci); } throw e; } }
/** * Registers FFI ruby classes/modules * * @param module the module to register the classes under */ public void init(Ruby runtime, RubyModule ffi) { synchronized (ffi) { if (ffi.getClass("Type") == null) { Type.createTypeClass(runtime, ffi); } DataConverter.createDataConverterModule(runtime, ffi); if (ffi.getClass(AbstractMemory.ABSTRACT_MEMORY_RUBY_CLASS) == null) { AbstractMemory.createAbstractMemoryClass(runtime, ffi); } if (ffi.getClass("Buffer") == null) { Buffer.createBufferClass(runtime, ffi); } if (ffi.getClass("Pointer") == null) { Pointer.createPointerClass(runtime, ffi); } if (ffi.getClass("AutoPointer") == null) { AutoPointer.createAutoPointerClass(runtime, ffi); } if (ffi.getClass("MemoryPointer") == null) { MemoryPointer.createMemoryPointerClass(runtime, ffi); } if (ffi.getClass("Struct") == null) { Struct.createStructClass(runtime, ffi); } if (ffi.getClass(StructLayout.CLASS_NAME) == null) { StructLayout.createStructLayoutClass(runtime, ffi); } if (ffi.getClass("StructByValue") == null) { StructByValue.createStructByValueClass(runtime, ffi); } if (ffi.getClass(AbstractInvoker.CLASS_NAME) == null) { AbstractInvoker.createAbstractInvokerClass(runtime, ffi); } if (ffi.getClass(CallbackInfo.CLASS_NAME) == null) { CallbackInfo.createCallbackInfoClass(runtime, ffi); } if (ffi.getClass("Enum") == null) { Enum.createEnumClass(runtime, ffi); } if (ffi.getClass("Type").getClass("Mapped") == null) { MappedType.createConverterTypeClass(runtime, ffi); } if (ffi.getClass(FileDescriptorIO.CLASS_NAME) == null) { FileDescriptorIO.createFileDescriptorIOClass(runtime, ffi); } ffi.setConstant("TypeDefs", RubyHash.newHash(runtime)); Platform.createPlatformModule(runtime, ffi); IOModule.createIOModule(runtime, ffi); StructByReference.createStructByReferenceClass(runtime, ffi); } }
@Override public void setWifiIndicators( boolean enabled, IconState statusIcon, IconState qsIcon, boolean activityIn, boolean activityOut, String description) { if (DEBUG) Log.d(TAG, "onWifiSignalChanged enabled=" + enabled); mInfo.enabled = enabled; mInfo.connected = qsIcon.visible; mInfo.wifiSignalIconId = qsIcon.icon; mInfo.enabledDesc = description; mInfo.activityIn = activityIn; mInfo.activityOut = activityOut; mInfo.wifiSignalContentDescription = qsIcon.contentDescription; refreshState(mInfo); }