示例#1
0
static DBusHandlerResult
request_main_get_navit(DBusConnection *connection, DBusMessage *message)
{
	DBusMessage *reply;
	DBusError error;
	struct iter *iter;
	struct navit *navit;
	char *opath;

	dbus_error_init(&error);

	if (!dbus_message_get_args(message, &error, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID)) {
		dbg(0,"Error parsing\n");
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
	}
	dbg(0,"opath=%s\n", opath);
	iter=object_get(opath);
	navit=main_get_navit(iter);
	if (navit) {
		reply = dbus_message_new_method_return(message);
		opath=object_new("navit",navit);
		dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID);
		dbus_connection_send (connection, reply, NULL);
		dbus_message_unref (reply);
		return DBUS_HANDLER_RESULT_HANDLED;
	}
	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
示例#2
0
VALUE
frt_get_bv(BitVector *bv)
{
    VALUE rbv;
    if ((rbv = object_get(bv)) == Qnil) {
        rbv = Data_Wrap_Struct(cBitVector, NULL, &frt_bv_free, bv);
        REF(bv);
        object_add(bv, rbv);
    }
    return rbv;
}
示例#3
0
static void *
object_get_from_message(DBusMessage *message, char *type)
{
	const char *opath=dbus_message_get_path(message);
	char *prefix;
	void *ret=NULL;

	prefix=g_strdup_printf("%s/%s/", object_path, type);
	if (!strncmp(prefix, opath, strlen(prefix)))
		ret=object_get(opath);
	else
		dbg(0,"wrong object type\n");
	g_free(prefix);
	return ret;
}
示例#4
0
static void *
object_get_from_message_arg(DBusMessage *message, char *type)
{
	char *opath;
	char *prefix;
	DBusError error;
	void *ret=NULL;

	dbus_error_init(&error);
	if (!dbus_message_get_args(message, &error, DBUS_TYPE_OBJECT_PATH, &opath, DBUS_TYPE_INVALID)) {
		dbus_error_free(&error);
		dbg(0,"wrong arg type\n");
		return NULL;
	}
	prefix=g_strdup_printf("%s/%s/", object_path, type);
	if (!strncmp(prefix, opath, strlen(prefix)))
		ret=object_get(opath);
	else
		dbg(0,"wrong object type\n");
	g_free(prefix);
	return ret;
}
示例#5
0
static void *
resolve_object(const char *opath, char *type)
{
	char *prefix;
	void *ret=NULL;
	char *def_navit="/default_navit";
	char *def_graphics="/default_graphics";
	struct attr attr;

	if (strncmp(opath, object_path, strlen(object_path))) {
		dbg(0,"wrong object path %s\n",opath);
		return NULL;
	}
	prefix=g_strdup_printf("%s/%s/", object_path, type);
	if (!strncmp(prefix, opath, strlen(prefix))) {
		ret=object_get(opath);
		g_free(prefix);
		return ret;
	}
	g_free(prefix);
	prefix=opath+strlen(object_path);
	if (!strncmp(prefix,def_navit,strlen(def_navit))) {
		prefix+=strlen(def_navit);
		struct navit *navit=main_get_navit(NULL);
		if (!prefix[0]) {
			dbg(0,"default_navit\n");
			return navit;
		}
		if (!strncmp(prefix,def_graphics,strlen(def_graphics))) {
			if (navit_get_attr(navit, attr_graphics, &attr, NULL)) {
				return attr.u.graphics;
			}
			return NULL;
		}
	}
	return NULL;
}
示例#6
0
STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
{
    return object_get(obj,_p_vlcvideo);
}
示例#7
0
STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj)
{
    return object_get(obj,_p_vlcsubtitle);
}
示例#8
0
STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
{
    return object_get(obj,_p_vlcplaylist);
}
示例#9
0
STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
{
    return object_get(obj,_p_vlcinput);
}
示例#10
0
STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
{
    return object_get(obj,_p_vlcaudio);
}
示例#11
0
STDMETHODIMP VLCVideo::get_deinterlace(IVLCDeinterlace** obj)
{
    return object_get(obj,_p_vlcdeint);
}
示例#12
0
文件: power.c 项目: alexeyk13/rexos
void power_set_mode(POWER_MODE mode)
{
    ack(object_get(SYS_OBJ_CORE), HAL_REQ(HAL_POWER, POWER_SET_MODE), mode, 0, 0);
}
示例#13
0
STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
{
    return object_get(obj,_p_vlcmarquee);
}
示例#14
0
文件: power.c 项目: alexeyk13/rexos
unsigned int power_get_clock(POWER_CLOCK_TYPE clock_type)
{
    return get(object_get(SYS_OBJ_CORE), HAL_REQ(HAL_POWER, POWER_GET_CLOCK), clock_type, 0, 0);
}
示例#15
0
/*  update_objects 
    Take the data in the object compress array and decompresses
    each element and adds the information to the Maze.

    parameter: num_elements    the number of elements in the player compress array
    parameter: object_compress pointer to the array that contains object compresses
    parameter: maze            pointer to client version of the maze
    return:    void
*/
void update_objects(int num_elements,int* object_compress, Maze* maze, PixelUpdate *pu)
{
    int ii,new_x,new_y,cur_x,cur_y;
    int cur_has_player;
    Object object;
    Object* object_ptr;
    Player* player;
    for(ii = 0; ii < num_elements; ii++)
    {
        bzero(&object,sizeof(Object));
        if(!decompress_is_ignoreable(&object_compress[ii])) 
        {
            decompress_object(&object,&object_compress[ii]);
            
            //Get pointer to object from object list
            object_ptr = object_get(maze,object.type,object.team);
            
            if(num_elements==4)
            {
                cur_x = object_ptr->cell->pos.x;     
                cur_y = object_ptr->cell->pos.y;
            }
            else
            {
                //Get objects current coordinates
                cur_x = object_ptr->client_position.x;
                cur_y = object_ptr->client_position.y;
            }
            //Get new coordinates for the object
            new_x = object.client_position.x;
            new_y = object.client_position.y;

            
            //Get previous state of whether object was held
            cur_has_player = object_ptr->client_has_player;
            

 	       pu->older.x = cur_x;
               pu->older.y = cur_y;
               
               //Get next position of the player
               pu->newer.x = new_x;
               pu->newer.y = new_y;
            pu->valid =1;
          
            
            //Object Dropped
            if(cur_has_player && !object.client_has_player)
            {
                //Get a pointer to the player that dropped the object
                player = &maze->players[object_ptr->client_player_team].at[object_ptr->client_player_id];

                //Set the player's object pointer to null
                if(object_ptr->type==OBJECT_SHOVEL)
                    player->shovel = NULL;
                else
                    player->flag = NULL;

                //If a player is currently in the same cell as the object then cell state is
                // CELLSTATE_OCCUPIED_HOLDING else CELLSTATE_HOLDING
                if(player->client_position.x == new_x && player->client_position.y == new_y)
                    maze->get[new_x][new_y].cell_state = CELLSTATE_OCCUPIED_HOLDING;
                else
                    maze->get[new_x][new_y].cell_state = CELLSTATE_HOLDING;

                maze->get[new_x][new_y].object = object_ptr;
            }
            //Object Picked up
            else if(!cur_has_player && object.client_has_player)
            {
                //Delete old pointer to the object
                maze->get[cur_x][cur_y].object = NULL;

                //Get the pointer to the player picking up
                player = &maze->players[object.client_player_team].at[object.client_player_id];

                //Set the player's object pointer to the object_ptr obtained from the object list
                if(object.type==OBJECT_SHOVEL)
                    player->shovel = object_ptr;
                else
                    player->flag = object_ptr;

                //Set the cell to an occupied state
                maze->get[new_x][new_y].cell_state = CELLSTATE_OCCUPIED;
                maze->get[new_x][new_y].object = NULL;
            }
            else if(!object.client_has_player)
            {
                if(maze->get[new_x][new_y].player==NULL)
                    maze->get[new_x][new_y].cell_state = CELLSTATE_HOLDING;
                else
                    maze->get[new_x][new_y].cell_state = CELLSTATE_OCCUPIED_HOLDING;
                maze->get[cur_x][cur_y].object = NULL;
                maze->get[new_x][new_y].object = object_ptr;
            }

            //Update object location and other parameters
            object_ptr->client_position.x = new_x;
            object_ptr->client_position.y = new_y;
            object_ptr->team = object.team;
            object_ptr->client_has_player = object.client_has_player;
            object_ptr->client_player_id = object.client_player_id;
            object_ptr->client_player_team = object.client_player_team;
            object_ptr->type = object.type;



            if(proto_debug())
            {
                fprintf(stderr,"Object Update x:%d y:%d\n",object_ptr->client_position.x,object_ptr->client_position.y);
            }

        }
    }
    
}
示例#16
0
STDMETHODIMP VLCVideo::get_logo(IVLCLogo** obj)
{
    return object_get(obj,_p_vlclogo);
}
示例#17
0
void test_update_objects_from_compress(TestContext* tc)
{
   int assertion;
   int red_flag_compress,blue_flag_compress,red_shovel_compress,blue_shovel_compress;
   PixelUpdate pu;
   //Create maze
   Maze maze;
   maze_build_from_file(&maze,"test.map");

   //Initialize a dummy object
   Object* red_flag = object_get(&maze,OBJECT_FLAG,TEAM_RED);
   Object* blue_flag = object_get(&maze,OBJECT_FLAG,TEAM_BLUE);
   Object* red_shovel = object_get(&maze,OBJECT_SHOVEL,TEAM_RED);
   Object* blue_shovel = object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE);
  
   //Position of each object somewhere on the map
   red_flag->cell = &maze.get[50][27];
   blue_flag->cell = &maze.get[99][20];
   red_shovel->cell = &maze.get[34][53];
   blue_shovel->cell = &maze.get[79][22];
  
   //Compress Object 
   compress_object(red_flag,&red_flag_compress);
   compress_object(blue_flag,&blue_flag_compress);
   compress_object(red_shovel,&red_shovel_compress);
   compress_object(blue_shovel,&blue_shovel_compress);

   //Update Maze based on compressed object
   update_objects(1,&red_flag_compress,&maze,&pu);
   update_objects(1,&blue_flag_compress,&maze,&pu);
   update_objects(1,&red_shovel_compress,&maze,&pu);
   update_objects(1,&blue_shovel_compress,&maze,&pu);
   
   //Check if pointer to object from object list points to same object from the cell it occupies
   assertion = (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.x == 50) &&
               (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.y == 27);
   should("correctly update (50,27): RED FLAG",assertion,tc);
   assertion = (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.x == 99) &&
               (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.y == 20);
   should("correctly update (99,20): BLUE FLAG",assertion,tc);
   assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.x == 34) &&
               (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.y == 53);
   should("correctly update (34,53): RED SHOVEL",assertion,tc);
   assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.x == 79) &&
               (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.y == 22);
   should("correctly update (79,22): BLUE SHOVEL",assertion,tc);

   //Position of each object somewhere on the map
   red_flag->cell = &maze.get[11][22];
   blue_flag->cell = &maze.get[52][61];
   red_shovel->cell = &maze.get[20][16];
   blue_shovel->cell = &maze.get[12][28];
  
   //Compress Object 
   compress_object(red_flag,&red_flag_compress);
   compress_object(blue_flag,&blue_flag_compress);
   compress_object(red_shovel,&red_shovel_compress);
   compress_object(blue_shovel,&blue_shovel_compress);

   //Update Maze based on compressed object
   update_objects(1,&red_flag_compress,&maze,&pu);
   update_objects(1,&blue_flag_compress,&maze,&pu);
   update_objects(1,&red_shovel_compress,&maze,&pu);
   update_objects(1,&blue_shovel_compress,&maze,&pu);
   
   //Check if pointer to object from object list points to same object from the cell it occupies
   assertion = (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.x == 11) &&
               (object_get(&maze,OBJECT_FLAG,TEAM_RED)->client_position.y == 22);
   should("correctly update (11,22): RED FLAG",assertion,tc);
   assertion = (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.x == 52) &&
               (object_get(&maze,OBJECT_FLAG,TEAM_BLUE)->client_position.y == 61);
   should("correctly update (52,61): BLUE FLAG",assertion,tc);
   assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.x == 20) &&
               (object_get(&maze,OBJECT_SHOVEL,TEAM_RED)->client_position.y == 16);
   should("correctly update (20,16): RED SHOVEL",assertion,tc);
   assertion = (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.x == 12) &&
               (object_get(&maze,OBJECT_SHOVEL,TEAM_BLUE)->client_position.y == 28);
   should("correctly update (12,28): BLUE SHOVEL",assertion,tc);
}