bool pluginSetProperty (NPObject *npobj, NPIdentifier name, const NPVariant *value) { PluginObject *obj = (PluginObject *)npobj; if (name == pluginPropertyIdentifiers[ID_PORT_PROPERTY]) { if(NPVARIANT_IS_STRING(*value)) { if(obj->port.UTF8Length > 0) { free((void *)(obj->port.UTF8Characters)); obj->port.UTF8Length = 0; } NPUTF8 *s = (NPUTF8 *)malloc((value->value.stringValue.UTF8Length)+1); memcpy(s, value->value.stringValue.UTF8Characters, value->value.stringValue.UTF8Length); s[value->value.stringValue.UTF8Length] = '\0'; obj->port.UTF8Characters = s; obj->port.UTF8Length = value->value.stringValue.UTF8Length; // when user sets port, connect to it if(obj->socket >= 0) { mcpClose(obj->socket); obj->socket = -1; } if(obj->port.UTF8Length > 0) { obj->socket = mcpOpen((char *)(obj->port.UTF8Characters)); } return true; } } return false; }
void lcdClose(void) { lcdClear(); lcdBacklight(OFF); mcpClose(); }