Beispiel #1
0
json_item *get_json_object_channel(CHANNEL *chan)
{
	json_item *jstr = json_new_object();
	json_set_property_strN(jstr, "casttype", 8, "multi", 5);
	json_set_property_strN(jstr, "pubid", 5, chan->pipe->pubid, 32);

	json_item *jprop = json_new_object();
	json_set_property_strZ(jprop, "name", chan->name);

	extend *eTmp = chan->properties;
	
	while (eTmp != NULL) {
		if (eTmp->visibility == EXTEND_ISPUBLIC) {
			if (eTmp->type == EXTEND_JSON) {
				json_item *jcopy = json_item_copy(eTmp->val, NULL);
				
				json_set_property_objZ(jprop, eTmp->key, jcopy);
			} else {
				json_set_property_strZ(jprop, eTmp->key, eTmp->val);
			}
		}
		
		eTmp = eTmp->next;
	}
	json_set_property_objN(jstr, "properties", 10, jprop);
	
	//}
	
	return jstr;
}
Beispiel #2
0
json_item *get_json_object_user(USERS *user)
{
	json_item *jstr = NULL;
	
	if (user != NULL) {
		jstr = json_new_object();
		json_set_property_strN(jstr, "casttype", 8, "uni", 3);
		json_set_property_strN(jstr, "pubid", 5, user->pipe->pubid, 32);
		
		if (user->properties != NULL) {
			int has_prop = 0;
			
			json_item *jprop = NULL;
						
			extend *eTmp = user->properties;
			
			while (eTmp != NULL) {
				if (eTmp->visibility == EXTEND_ISPUBLIC) {
					if (!has_prop) {
						has_prop = 1;
						jprop = json_new_object();
					}
					if (eTmp->type == EXTEND_JSON) {
						json_item *jcopy = json_item_copy(eTmp->val, NULL);
						
						json_set_property_objZ(jprop, eTmp->key, jcopy);
					} else {
						json_set_property_strZ(jprop, eTmp->key, eTmp->val);

					}			
				}
				eTmp = eTmp->next;
			}
			if (has_prop) {
				json_set_property_objN(jstr, "properties", 10, jprop);
			}
		}

	} else {
		json_set_property_strZ(jstr, "pubid", SERVER_NAME);
	}
	return jstr;
}