static JSBool
netscape_security_setCanEnablePrivilege(JSContext *cx, JSObject *obj, uintN argc,
                                        jsval *argv, jsval *rval)
{
    if (argc < 2) return JS_FALSE;
    nsCAutoString principalFingerprint;
    getUTF8StringArgument(cx, obj, 0, argc, argv, principalFingerprint);
    char *cap = getStringArgument(cx, obj, 1, argc, argv);
    if (principalFingerprint.IsEmpty() || !cap)
        return JS_FALSE;

    nsresult rv;
    nsCOMPtr<nsIScriptSecurityManager> securityManager = 
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
    if (NS_FAILED(rv)) 
        return JS_FALSE;

    //    NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");

    rv = securityManager->SetCanEnableCapability(principalFingerprint, cap, 
                                                 nsIPrincipal::ENABLE_GRANTED);
    if (NS_FAILED(rv))
        return JS_FALSE;
    return JS_TRUE;
}
Beispiel #2
0
 bool getDoubleArgument(const Arguments& arguments, const std::string& argument, http::server::reply& reply, double& value) const
 {
     std::string str;
     if (!getStringArgument(arguments, argument, reply, str))
         return false;
     value = strtod(str.c_str(), NULL);
     return true;
 }
Beispiel #3
0
 bool getIntArgument(const Arguments& arguments, const std::string& argument, http::server::reply& reply, int& value) const
 {
     std::string str;
     if (!getStringArgument(arguments, argument, reply, str))
         return false;
     value = strtol(str.c_str(), NULL, 10);
     return true;
 }
Beispiel #4
0
 bool getHexArgument(const Arguments& arguments, const std::string& argument, http::server::reply& reply, int& value) const
 {
     std::string hex_str;
     if (!getStringArgument(arguments, argument, reply, hex_str))
         return false;
     value = strtoul(hex_str.c_str(), NULL, 16);
     return true;
 }
netscape_security_revertPrivilege(JSContext *cx, JSObject *obj, uintN argc,
                                  jsval *argv, jsval *rval)
{
    char *cap = getStringArgument(cx, obj, 0, argc, argv);
    if (!cap)
        return JS_FALSE;

    nsresult rv;
    nsCOMPtr<nsIScriptSecurityManager> securityManager = 
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
    if (NS_FAILED(rv)) 
        return JS_FALSE;

    //    NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");

    rv = securityManager->RevertCapability(cap);
    if (NS_FAILED(rv))
        return JS_FALSE;
    return JS_TRUE;
}
netscape_security_isPrivilegeEnabled(JSContext *cx, JSObject *obj, uintN argc,
                                     jsval *argv, jsval *rval)
{
    JSBool result = JS_FALSE;
    char *cap = getStringArgument(cx, obj, 0, argc, argv);
    if (cap) {
        nsresult rv;
        nsCOMPtr<nsIScriptSecurityManager> securityManager = 
                 do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
        if (NS_SUCCEEDED(rv)) {
            //            NS_ASSERTION(cx == GetCurrentContext(), "unexpected context");

            rv = securityManager->IsCapabilityEnabled(cap, &result);
            if (NS_FAILED(rv)) 
                result = JS_FALSE;
        }
    }
    *rval = BOOLEAN_TO_JSVAL(result);
    return JS_TRUE;
}
varInst *Mission::call_omap(missionNode *node,int mode){

  //varInst *viret=new varInst;
  varInst *viret=NULL;

  if(mode==SCRIPT_PARSE){
    string cmd=node->attr_value("name");
    node->script.method_id=module_omap_map[cmd];
  }

   callback_module_omap_type method_id=(callback_module_omap_type) node->script.method_id;


  if(method_id==CMT_OMAP_new){
    
    viret=call_omap_new(node,mode);

    return viret;
  }
  else{
    varInst *ovi=getObjectArg(node,mode);
    omap_t *my_object=getOMapObject(node,mode,ovi);

    if(method_id==CMT_OMAP_delete){
      if(mode==SCRIPT_RUN){

	omap_t::iterator iter;

	for(iter=my_object->begin();iter!=my_object->end();iter++){
	  string varname=(*iter).first ;
	  varInst *vi=(*iter).second;
	  deleteVarInst(vi,true);
	}
	my_object->clear();
	delete my_object;
      }
      viret=newVarInst(VI_TEMP);
      viret->type=VAR_VOID;
    }
    else if(method_id==CMT_OMAP_set){
      missionNode *snode=getArgument(node,mode,2);
      //varInst *vi=doVariable(snode,mode); // should be getObjExpr
      varInst *var_vi=checkExpression(snode,mode); // should be getObjExpr
      
      string name=getStringArgument(node,mode,1);

      debug(3,node,mode,"omap set");

      if(mode==SCRIPT_RUN){
	varInst *push_vi=newVarInst(VI_IN_OBJECT);
	push_vi->type=var_vi->type;
	assignVariable(push_vi,var_vi);

	(*my_object)[name]=push_vi;
	//printf("setting [%s] type %d\n",name.c_str(),push_vi->type);
      }

      deleteVarInst(var_vi);
      viret=newVarInst(VI_TEMP);
      viret->type=VAR_VOID;
      //return viret;
    }
    else if(method_id==CMT_OMAP_get){
      debug(3,node,mode,"omap.get");

      string name=getStringArgument(node,mode,1);

      viret=newVarInst(VI_TEMP);
      viret->type=VAR_ANY;

      if(mode==SCRIPT_RUN){
	varInst *back_vi=(*my_object)[name];
	assignVariable(viret,back_vi);
	//	printf("viret type=%d back_vi type=%d\n",viret->type,back_vi->type);
	if(back_vi->type>10){
	  assert(0);
	}
	deleteVarInst(back_vi); // this won't delete it
      }
    }
    else if(method_id==CMT_OMAP_toxml){
      if(node->subnodes.size()!=1){
	fatalError(node,mode,"olist.toxml needs no arguments");
	assert(0);
      }

      debug(3,node,mode,"omap.toxml");

      if(mode==SCRIPT_RUN){
	//call_olist_toxml(node,mode,ovi);
      }

      viret =newVarInst(VI_TEMP);
      viret->type=VAR_VOID;
    }
    else if(method_id==CMT_OMAP_size){
      if(node->subnodes.size()!=1){
	fatalError(node,mode,"olist.size needs one arguments");
	assert(0);
      }

      debug(3,node,mode,"omap.size");

      viret=newVarInst(VI_TEMP);

      if(mode==SCRIPT_RUN){
	int len=my_object->size();
	viret->int_val=len;
      }

      viret->type=VAR_INT;
      //return viret;
    }
    else{
      fatalError(node,mode,"unknown command "+node->script.name+" for callback omap");
      assert(0);
    }
    
    deleteVarInst(ovi);
    return viret;
  } // else (objects)

  return NULL; // never reach
}