Newer
Older
if((p=(private_t*)malloc(sizeof(private_t)))==NULL)
return(NULL);
p->cfg = cfg;
p->user.number = usernumber;
p->cached = FALSE;

rswindell
committed
JS_SetPrivate(cx, userobj, p);
if(!js_DefineSyncProperties(cx, userobj, js_user_properties)) {
free(p);
return(NULL);
}
#ifdef BUILD_JSDOCS
js_DescribeSyncObject(cx,userobj
,"Instance of <i>User</i> class, representing current user online"
,310);
js_DescribeSyncConstructor(cx,userobj
,"To create a new user object: <tt>var u = new User(<i>number</i>)</tt>");
js_CreateArrayOfStrings(cx, userobj
,"_property_desc_list", user_prop_desc, JSPROP_READONLY);
js_DefineSyncMethods(cx, userobj, js_user_functions, FALSE);

rswindell
committed
/* user.stats */
statsobj = JS_DefineObject(cx, userobj, "stats"
,&js_user_stats_class, NULL, JSPROP_ENUMERATE|JSPROP_READONLY);
if(statsobj==NULL) {
free(p);
}

rswindell
committed
JS_SetPrivate(cx, statsobj, p);
if(!js_DefineSyncProperties(cx, statsobj, js_user_stats_properties)) {
free(p);
return(NULL);
}
#ifdef BUILD_JSDOCS
js_DescribeSyncObject(cx,statsobj,"User statistics (all <small>READ ONLY</small>)",310);
js_CreateArrayOfStrings(cx, statsobj, "_property_desc_list", user_stats_prop_desc, JSPROP_READONLY);
#endif
/* user.limits */
limitsobj = JS_DefineObject(cx, userobj, "limits"
,&js_user_limits_class, NULL, JSPROP_ENUMERATE|JSPROP_READONLY);
if(limitsobj==NULL) {
free(p);
return(NULL);
}
JS_SetPrivate(cx, limitsobj, p);
if(!js_DefineSyncProperties(cx, limitsobj, js_user_limits_properties)) {
free(p);
return(NULL);
}
#ifdef BUILD_JSDOCS
js_DescribeSyncObject(cx,limitsobj,"User limitations based on security level (all <small>READ ONLY</small>)",311);
js_CreateArrayOfStrings(cx, limitsobj, "_property_desc_list", user_limits_prop_desc, JSPROP_READONLY);
#endif
/* user.security */
securityobj = JS_DefineObject(cx, userobj, "security"
,&js_user_security_class, NULL, JSPROP_ENUMERATE|JSPROP_READONLY);
if(securityobj==NULL) {
free(p);
}

rswindell
committed
JS_SetPrivate(cx, securityobj, p);
if(!js_DefineSyncProperties(cx, securityobj, js_user_security_properties)) {
free(p);
return(NULL);
}
#ifdef BUILD_JSDOCS
js_DescribeSyncObject(cx,securityobj,"User security settings",310);
js_CreateArrayOfStrings(cx, securityobj, "_property_desc_list", user_security_prop_desc, JSPROP_READONLY);
#endif
/****************************************************************************/
/* Creates all the user-specific objects: user, msg_area, file_area */
/****************************************************************************/
JSBool DLLCALL
js_CreateUserObjects(JSContext* cx, JSObject* parent, scfg_t* cfg, user_t* user
,char* html_index_file, subscan_t* subscan)
{
if(js_CreateUserObject(cx,parent,cfg,"user",user==NULL ? 0 : user->number)==NULL)
return(JS_FALSE);
if(js_CreateFileAreaObject(cx,parent,cfg,user,html_index_file)==NULL)
return(JS_FALSE);
if(js_CreateMsgAreaObject(cx,parent,cfg,user,subscan)==NULL)
return(JS_FALSE);
if(js_CreateXtrnAreaObject(cx,parent,cfg,user)==NULL)
return(JS_FALSE);
return(JS_TRUE);
}