Exemplo n.º 1
0
void subuser_restor(subuser *sub, acetables *g_ape)
{
	CHANLIST *chanl;
	CHANNEL *chan;
	
	json_item *jlist;
	RAW *newraw;
	USERS *user = sub->user;
	userslist *ulist;

	chanl = user->chan_foot;

	while (chanl != NULL) {
		chan = chanl->chaninfo;
		/*
		 * quiet channel won't be posted on subuser_restor 
		 */
		if (!(chan->flags & CHANNEL_QUIET)) {
			jlist = json_new_object();
			if ( !(chan->flags & CHANNEL_NONINTERACTIVE) && chan->head != NULL ) {
				json_item *user_list = json_new_array();
			
				ulist = chan->head;
			
				while (ulist != NULL) {
	
					json_item *juser = get_json_object_user(ulist->userinfo);
		
					if (ulist->userinfo != user) {
						//make_link(user, ulist->userinfo);
					}
				
					json_set_property_intN(juser, "level", 5, ulist->level);
				
					json_set_element_obj(user_list, juser);

					ulist = ulist->next;
				}
			
				json_set_property_objN(jlist, "users", 5, user_list);
			}
			json_set_property_objN(jlist, "pipe", 4, get_json_object_channel(chan));

			newraw = forge_raw(RAW_CHANNEL, jlist);
			newraw->priority = RAW_PRI_HI;
			post_raw_sub(newraw, sub, g_ape);
			POSTRAW_DONE(newraw);
		}
		chanl = chanl->next;
	}

	jlist = json_new_object();
	json_set_property_objN(jlist, "user", 4, get_json_object_user(user));	
	
	newraw = forge_raw("IDENT", jlist);
	newraw->priority = RAW_PRI_HI;
	post_raw_sub(newraw, sub, g_ape);
	POSTRAW_DONE(newraw);
	
}
Exemplo n.º 2
0
void join(USERS *user, CHANNEL *chan, acetables *g_ape)
{
	userslist *list, *ulist;
	
	CHANLIST *chanl;
	
	FIRE_EVENT_NULL(join, user, chan, g_ape);
	
	RAW *newraw;
	json_item *jlist = json_new_object();
	
	if (isonchannel(user, chan)) {
		return;
	}
	
	list = xmalloc(sizeof(*list)); // TODO is it free ?
	list->userinfo = user;
	list->level = 1;
	list->next = chan->head;
	
	chan->head = list;
	
	chanl = xmalloc(sizeof(*chanl)); // TODO is it free ?
	chanl->chaninfo = chan;
	chanl->next = user->chan_foot;
	
	user->chan_foot = chanl;

	if (chan->interactive) {
		json_item *user_list = json_new_array();
		json_item *uinfo = json_new_object();
		
		json_set_property_objN(uinfo, "user", 4, get_json_object_user(user));
		json_set_property_objN(uinfo, "pipe", 4, get_json_object_channel(chan));

		newraw = forge_raw(RAW_JOIN, uinfo);
		post_raw_channel_restricted(newraw, chan, user, g_ape);
		
		ulist = chan->head;
		while (ulist != NULL) {
		
			json_item *juser = get_json_object_user(ulist->userinfo);
			
			if (ulist->userinfo != user) {
				//make_link(user, ulist->userinfo);
			}
			
			json_set_property_intN(juser, "level", 5, ulist->level);
		
			json_set_element_obj(user_list, juser);

			ulist = ulist->next;
		}
		json_set_property_objN(jlist, "users", 5, user_list);
	}
	
	json_set_property_objN(jlist, "pipe", 4, get_json_object_channel(chan));
	
	newraw = forge_raw(RAW_CHANNEL, jlist);
	post_raw(newraw, user, g_ape);
	
	#if 0
	if (user->flags & FLG_AUTOOP) {
		setlevel(NULL, user, chan, 3);
	}
	#endif

}