Example #1
0
void KstJS::createBindings() {
  _jsPart->factory()->addType("KstJSUIBuilder");
  _jsPart->factory()->addType("KActionCollection");
  if (_merge) {
    _jsPart->addObject(_merge, _merge->name());
  }

  KJS::ExecState *exec = _jsPart->globalExec();
  KJS::Object globalObj = _jsPart->globalObject();

  new KstBindPoint(exec, &globalObj);
  new KstBindSize(exec, &globalObj);

  new KstBindVector(exec, &globalObj);
  new KstBindScalar(exec, &globalObj);
  new KstBindString(exec, &globalObj);
  new KstBindDataSource(exec, &globalObj);
  new KstBindDataVector(exec, &globalObj);
  new KstBindMatrix(exec, &globalObj);
  new KstBindDataMatrix(exec, &globalObj);
  new KstBindVectorView(exec, &globalObj);

  new KstBindBinnedMap(exec, &globalObj);
  new KstBindCSD(exec, &globalObj);
  new KstBindCrossPowerSpectrum(exec, &globalObj);
  new KstBindEquation(exec, &globalObj);
  new KstBindPlugin(exec, &globalObj);
  new KstBindPowerSpectrum(exec, &globalObj);
  new KstBindHistogram(exec, &globalObj);

  new KstBindCurve(exec, &globalObj);
  new KstBindImage(exec, &globalObj);

  new KstBindGroup(exec, &globalObj);
  new KstBindPlot(exec, &globalObj);
  new KstBindLine(exec, &globalObj);
  new KstBindLabel(exec, &globalObj);
  new KstBindLegend(exec, &globalObj);
  new KstBindBox(exec, &globalObj);
  new KstBindEllipse(exec, &globalObj);
  new KstBindPicture(exec, &globalObj);
  new KstBindArrow(exec, &globalObj);

  new KstBindWindow(exec, &globalObj);
  new KstBindDebug(exec, &globalObj);
  new KstBindKst(exec, &globalObj, this);

  new KstBindFile(exec, &globalObj);
  new KstBindELOG(exec, &globalObj);

  globalObj.put(exec, "loadScript", KJS::Object(new LoadScript(this)));

  createRegistry();
}
Example #2
0
void WINAPI _export SetStartupInfo(const struct PluginStartupInfo *Info)
{
	::Info=*Info;
	HKEY hKey;
	DWORD Disposition, DataSize;
	int ExitCode;

	wsprintf(PluginRootKey,"%s\\Desktop",::Info.RootKey);
	char ValueData[456];

	if (RegOpenKeyEx(HKEY_CURRENT_USER,PluginRootKey,0,KEY_READ,&hKey) == ERROR_SUCCESS)
	{
		// if нема, то создадим...
		DataSize=sizeof(Opt.AddToDisksMenu);

		if (RegQueryValueEx(hKey,AddToDisksMenu,0,&Disposition,ValueData,&DataSize) != ERROR_SUCCESS)
		{
			RegCloseKey(hKey);
			createRegistry(PluginRootKey);
		}
		else
		{
			DataSize=sizeof(Opt.AddToDisksMenu);
			Opt.AddToDisksMenu=1;
			RegQueryValueEx(hKey,AddToDisksMenu,0,&Disposition,(BYTE *)&Opt.AddToDisksMenu,&DataSize);

			DataSize=sizeof(Opt.DisksMenuDigit);
			Opt.DisksMenuDigit=9;
			RegQueryValueEx(hKey,DisksMenuDigit,0,&Disposition,(BYTE *)&Opt.DisksMenuDigit,&DataSize);

			DataSize=511;
			RegQueryValueEx(hKey,DefaultFolder,0,&Disposition,Opt.DefaultFolder,&DataSize);
		}

		RegCloseKey(hKey);
	}
	else
		createRegistry(PluginRootKey);
}
Example #3
0
KstJS::KstJS(QObject *parent, const char *name, const QStringList& l) : KstExtension(parent, name, l), KXMLGUIClient() {
  KJSEmbed::JSSecurityPolicy::setDefaultPolicy(KJSEmbed::JSSecurityPolicy::CapabilityAll);
  _jsPart = new KJSEmbed::KJSEmbedPart(0L, "javascript", this, "kjsembedpart");
  createBindings();

#ifdef KST_HAVE_READLINE
  _showAction = new KToggleAction(i18n("Show &JavaScript Console"), 0, 0, 0, 0, actionCollection(), "js_console_show");
  connect(_showAction, SIGNAL(toggled(bool)), this, SLOT(doShow(bool)));
#endif
  new KAction(i18n("Load JavaScript..."), 0, 0, this, SLOT(loadScript()), actionCollection(), "js_load");
  new KAction(i18n("Clear JavaScript &Interpreter"), 0, 0, this, SLOT(resetInterpreter()), actionCollection(), "js_reset");
  setInstance(app()->instance());
  setXMLFile("kstextension_js.rc", true);
  app()->guiFactory()->addClient(this);

  _merge = new KstUIMerge(this, "KstUIMerge");
  _jsPart->addObject(_merge, _merge->name());

  createRegistry();
  _iface = new JSIfaceImpl(_jsPart);
  _splitter = 0L;
  _konsolePart = 0L;
}
Example #4
0
/*
 * Returns:
 *      0       Success
 *      1       Incorrect usage (i.e., command-line syntax error).
 *      2       No such parameter or node.  Error message written.
 *      3       System error.  Error message written.
 */
int main(
    int         argc,
    char*       argv[])
{
    int                 status;
    const char* const   progname = basename(argv[0]);

    (void)log_init(progname);

    if ((status = sb_new(&_valuePath, 80))) {
        log_error("Couldn't initialize utility");
        status = SYSTEM_ERROR;
    }
    else {
        enum {
            UNKNOWN,
            CREATE,
            PRINT,
            PUT_BOOL,
            PUT_STRING,
            PUT_UINT,
            PUT_SIGNATURE,
            PUT_TIME,
            RESET,
            REMOVE
        }               action = UNKNOWN;
        const char*     string;
        signaturet      signature;
        timestampt      timestamp;
        unsigned long   uint;
        int             boolean;
        int             ch;
        int             quiet = 0;

        opterr = 0;                     /* supress getopt(3) error messages */

        while (0 == status && (ch = getopt(argc, argv, ":b:cd:h:qRrs:t:u:vx"))
                != -1) {
            switch (ch) {
            case 'b': {
                if (strcasecmp(optarg, "TRUE") == 0) {
                    boolean = 1;
                }
                else if (strcasecmp(optarg, "FALSE") == 0) {
                    boolean = 0;
                }
                else {
                    log_add("Not a boolean value: \"%s\"", optarg);
                    status = COMMAND_SYNTAX;
                }

                if (status == 0) {
                    if (CREATE == action) {
                        log_error("Create option ignored");
                    }
                    action = PUT_BOOL;
                }
                break;
            }
            case 'c': {
                if (UNKNOWN != action) {
                    log_add("Can't mix create action with other actions");
                    status = COMMAND_SYNTAX;
                }
                else {
                    action = CREATE;
                }
                break;
            }
            case 'd': {
                if ((status = reg_setDirectory(optarg)))
                    status = SYSTEM_ERROR;
                break;
            }
            case 'h': {
                status = sigParse(optarg, &signature);

                if (0 > status || 0 != optarg[status]) {
                    log_add("Not a signature: \"%s\"", optarg);
                    status = COMMAND_SYNTAX;
                }
                else {
                    if (CREATE == action) {
                        log_info("Create action ignored");
                    }
                    action = PUT_SIGNATURE;
                    status = 0;
                }
                break;
            }
            case 'q': {
                quiet = 1;
                break;
            }
            case 'R': {
                if (UNKNOWN != action) {
                    log_add("Can't mix reset action with other actions");
                    status = COMMAND_SYNTAX;
                }
                else {
                    action = RESET;
                }
                break;
            }
            case 'r': {
                if (UNKNOWN != action) {
                    log_add("Can't mix remove action with other actions");
                    status = COMMAND_SYNTAX;
                }
                else {
                    action = REMOVE;
                }
                break;
            }
            case 's': {
                if (CREATE == action) {
                    log_info("Create action  ignored");
                }
                string = optarg;
                action = PUT_STRING;
                break;
            }
            case 't': {
                status = tsParse(optarg, &timestamp);

                if (0 > status || 0 != optarg[status]) {
                    log_add("Not a timestamp: \"%s\"", optarg);
                    status = COMMAND_SYNTAX;
                }
                else {
                    if (CREATE == action) {
                        log_info("Create action ignored");
                    }
                    action = PUT_TIME;
                    status = 0;
                }
                break;
            }
            case 'u': {
                char*   end;

                errno = 0;
                uint = strtoul(optarg, &end, 0);

                if (0 != *end || (0 == uint && 0 != errno)) {
                    log_add("Not an unsigned integer: \"%s\"", optarg);
                    status = COMMAND_SYNTAX;
                }
                else {
                    if (CREATE == action) {
                        log_info("Create option ignored");
                    }
                    action = PUT_UINT;
                }
                break;
            }
            case 'v': {
                if (!log_is_enabled_info)
                    (void)log_set_level(LOG_LEVEL_INFO);
                break;
            }
            case 'x': {
                (void)log_set_level(LOG_LEVEL_DEBUG);
                break;
            }
            case ':': {
                log_add("Option \"-%c\" requires an operand", optopt);
                status = COMMAND_SYNTAX;
                break;
            }
            default:
                log_add("Unknown option: \"%c\"", optopt);
                status = COMMAND_SYNTAX;
                /* no break */
            }
        }                               /* options loop */

        if (status) {
            log_flush_error();

            if (COMMAND_SYNTAX == status)
                usage(progname);
        }
        else {
            const int     argCount = argc - optind;

            if (UNKNOWN == action)
                action = PRINT;

            switch (action) {
                case CREATE: {
                    if (0 < argCount) {
                        log_error("Too many arguments");
                        usage(progname);
                        status = COMMAND_SYNTAX;
                    }
                    else {
                        status = createRegistry();
                    }
                    break;
                }
                case RESET: {
                    if (0 < argCount) {
                        log_error("Too many arguments");
                        usage(progname);
                        status = COMMAND_SYNTAX;
                    }
                    else {
                        status = resetRegistry();
                    }
                    break;
                }
                case REMOVE: {
                    if (0 == argCount) {
                        log_error(
                            "Removal action requires absolute pathname(s)");
                        usage(progname);
                        status = COMMAND_SYNTAX;
                    }
                    else {
                        log_debug("Removing registry");
                        status = actUponPathList(argv + optind, deletePath,
                            quiet);
                    }
                    break;
                }
                case PRINT: {
                    log_debug("Printing registry");
                    status = (0 == argCount)
                        ? printPath("/", quiet)
                        : actUponPathList(argv + optind, printPath, quiet);
                    break;
                }
                default: {
                    /*
                     * Must be some kind of "put".
                     */
                    if (0 == argCount) {
                        log_error("Put action requires value pathname");
                        usage(progname);
                        status = COMMAND_SYNTAX;
                    }
                    else {
                        switch (action) {
                        case PUT_BOOL:
                            status = reg_putBool(argv[optind], boolean);
                            break;
                        case PUT_UINT:
                            status = reg_putUint(argv[optind], uint);
                            break;
                        case PUT_STRING:
                            status = reg_putString(argv[optind], string);
                            break;
                        case PUT_TIME:
                            status = reg_putTime(argv[optind], &timestamp);
                            break;
                        case PUT_SIGNATURE:
                            status = reg_putSignature(argv[optind], signature);
                            break;
                        default:
                            abort();
                        }
                        if (status) {
                            log_flush_error();
                            status = SYSTEM_ERROR;
                        }
                    }
                }                       /* put switch */
                /* no break */
            }                           /* "action" switch */
        }                               /* decoded options */

        sb_free(_valuePath);
    }                                   /* "_valuePath" allocated */

    return status;
}
Example #5
0
void initialize(){
	createRegistry();
	createPC();
	createInstructionMemory();
}