static void _class_event (enna_input event) { enna_log(ENNA_MSG_EVENT, ENNA_MODULE_NAME, "Key pressed Bookstore : %d", event); switch (mod->state) { /* Menu View */ case BS_MENU_VIEW: { if (event == ENNA_INPUT_BACK) enna_content_hide(); else enna_wall_input_feed(mod->menu, event); break; } /* Service View */ case BS_SERVICE_VIEW: { Eina_Bool b = ENNA_EVENT_BLOCK; if (mod->current && mod->current->event) b = (mod->current->event)(mod->o_layout, event); if ((b == ENNA_EVENT_CONTINUE) && (event == ENNA_INPUT_BACK)) bs_service_hide(mod->current); break; } default: break; } }
static Eina_Bool games_sys_event(Evas_Object *edje, enna_input event) { enna_log(ENNA_MSG_EVENT, ENNA_MODULE_NAME, "Key pressed SystemGames : %d", event); return enna_list_input_feed(mod->o_list, event); }
static int mp_pause(void) { enna_log(ENNA_MSG_INFO, NULL, "pause"); if (player_playback_get_state(mp->player) == PLAYER_PB_STATE_PLAY) player_playback_pause(mp->player); return 0; }
static void enna_mediaplayer_seek(int value , SEEK_TYPE type) { double new_time, old_time, length; enna_log(ENNA_MSG_EVENT, NULL, "Seeking to: %d%c", value, type == SEEK_ABS_PERCENT ? '%' : 's'); if (mp->play_state == PAUSE || mp->play_state == PLAYING) { Enna_Event_Mediaplayer_Seek_Data *ev; ev = calloc(1, sizeof(Enna_Event_Mediaplayer_Seek_Data)); if (!ev) return; ev->seek_value = value; ev->type = type; if(emotion_object_seekable_get(mp->player)) { if(type == SEEK_ABS_PERCENT) { length = enna_mediaplayer_length_get(); new_time = (value * length) / 100.0; } else if(type == SEEK_ABS_SECONDS) new_time = (double)value; else if(type == SEEK_REL_SECONDS) { old_time = enna_mediaplayer_position_get(); new_time = (double)(value) + old_time; } else new_time = 0; ecore_event_add(ENNA_EVENT_MEDIAPLAYER_SEEK, ev, NULL, NULL); emotion_object_position_set(mp->player, new_time); } else { enna_log(ENNA_MSG_EVENT, NULL, "No Seeking avaible"); } } }
void enna_volumes_listener_del(Enna_Volumes_Listener *vl) { if (!vl) return; enna_log(ENNA_MSG_EVENT, "volumes", "Del: %s listener", vl->name); enna_volumes_listeners = eina_list_remove(enna_volumes_listeners, vl); ENNA_STRINGSHARE_DEL(vl->name); ENNA_FREE(vl); }
static void cd_display_info (cdda_t *cd) { unsigned int i; if (!cd) return; enna_log (ENNA_MSG_INFO, MODULE_NAME, "DiscID: %lu", cd->id); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Artist: %s", cd->artist); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Title: %s", cd->title); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Ext.Data: %s", cd->ext_data); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Genre: %s", cd->genre); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Year: %d", cd->year); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Length: %d seconds", cd->length); enna_log (ENNA_MSG_INFO, MODULE_NAME, ""); enna_log (ENNA_MSG_INFO, MODULE_NAME, "Tracks:"); for (i = 0; i < cd->total_tracks; i++) enna_log (ENNA_MSG_INFO, MODULE_NAME, " %s", cd->tracks[i]->name); }
int enna_mediaplayer_select_nth(Enna_Playlist *enna_playlist,int n) { if (n < 0 || n > eina_list_count(enna_playlist->playlist) - 1) return -1; enna_log(ENNA_MSG_EVENT, NULL, "select %d", n); enna_playlist->selected = n; return 0; }
static void module_init(Enna_Module *em) { struct lirc_config *config; int fd; if (!em) return; mod = calloc(1, sizeof(Enna_Module_Lirc)); if (!mod) return; mod->em = em; em->mod = mod; // initialize lirc if ((fd = lirc_init("enna", 1)) == -1) // TODO need to close this? or ecore_fd_hand_del is enoght? { enna_log(ENNA_MSG_ERROR, ENNA_MODULE_NAME, "could not initialize LIRC support"); return; } if (lirc_readconfig(NULL, &config, NULL) != 0) { lirc_deinit(); enna_log(ENNA_MSG_ERROR, ENNA_MODULE_NAME, "could not find Lirc config file"); return; } mod->lirc_config = config; // connect to the lirc socket fcntl(fd, F_SETFL, O_NONBLOCK); fcntl(fd, F_SETFD, FD_CLOEXEC); mod->fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _lirc_code_received, NULL, NULL, NULL); #if 0 // register the configuration panel _config_panel = enna_config_panel_register(_("Remote"), "icon/music", lirc_panel_show, lirc_panel_hide, NULL); #endif }
static void enna_mediaplayer_change(Enna_Playlist *enna_playlist, int type) { Enna_File *item; item = eina_list_nth(enna_playlist->playlist, enna_playlist->selected); enna_log(ENNA_MSG_EVENT, NULL, "select %d", enna_playlist->selected); if (!item) return; enna_mediaplayer_stop(); enna_mediaplayer_play(enna_playlist); ecore_event_add(type, NULL, NULL, NULL); }
static void cfg_mediaplayer_section_load (const char *section) { const char *value = NULL; int i; enna_log(ENNA_MSG_INFO, NULL, "parameters:"); value = enna_config_string_get(section, "type"); if (value) { enna_log(ENNA_MSG_INFO, NULL, " * type: %s", value); for (i = 0; map_player_type[i].name; i++) { if (!strcmp(value, map_player_type[i].name)) { mp_cfg.engine = strdup(map_player_type[i].name); break; } } } }
static enna_input _get_input_from_event(const char *ev) { int i; for (i = 0; enna_lircmap[i].keyname; i++) { if (!strcmp(enna_lircmap[i].keyname, ev)) return enna_lircmap[i].input; } enna_log(ENNA_MSG_WARNING, NULL, "Unrecognized lirc key: '%s'", ev); // TODO here we could print a list of recognized keys return ENNA_INPUT_UNKNOWN; }
Enna_Volumes_Listener * enna_volumes_listener_add(const char *name, EnnaVolumesFunc add, EnnaVolumesFunc rmv, void *data) { Enna_Volumes_Listener *vl; vl = ENNA_NEW(Enna_Volumes_Listener, 1); vl->name = eina_stringshare_add(name); vl->add = add; vl->remove = rmv; vl->data = data; enna_log(ENNA_MSG_EVENT, "volumes", "Add: %s listener", vl->name); enna_volumes_listeners = eina_list_append(enna_volumes_listeners, vl); return vl; }
/** * @brief Disable/Free all modules registered and free the Eina_Module Array */ void enna_module_shutdown(void) { Enna_Module *m; #if ENABLE_CONFIG_PANEL enna_config_panel_unregister(_config_panel); #endif /* Disable and free all Enna_Modules */ EINA_LIST_FREE(_enna_modules, m) { enna_log(ENNA_MSG_INFO, NULL, "Disable module : %s", m->api->name); if (m->enabled) enna_module_disable(m); free(m); }
static void _event_cb(void *data, enna_mediaplayer_event_t event) { Enna_File *file; switch (event) { case ENNA_MP_EVENT_EOF: enna_log(ENNA_MSG_EVENT, NULL, "End of stream"); ecore_event_add(ENNA_EVENT_MEDIAPLAYER_EOS, NULL, NULL, NULL); file = enna_mediaplayer_current_file_get(); _info_played_set(file); break; default: break; } }
static void config_load_theme (void) { if (!enna_config->theme) goto err_theme; enna_config->theme_file = (char *) enna_config_theme_file_get(enna_config->theme); if (!enna_config->theme_file) goto err_theme; elm_theme_overlay_add(enna_config->eth, enna_config->theme_file); return; err_theme: enna_log(ENNA_MSG_CRITICAL, NULL, "couldn't load theme file!"); }
void enna_volumes_remove_emit(Enna_Volume *v) { Eina_List *l; Enna_Volumes_Listener *vl; if (!v) return; enna_log(ENNA_MSG_EVENT, "volumes","Remove: %s volume listeners: %d", v->label, eina_list_count(enna_volumes_listeners)); EINA_LIST_FOREACH(enna_volumes_listeners, l, vl) { if (!vl->remove) continue; vl->remove(vl->data, v); } _volumes = eina_list_remove(_volumes, v); }
static mrl_t * set_network_stream(const char *uri, mrl_resource_t type) { mrl_t *mrl; mrl_resource_network_args_t *args; enna_log(ENNA_MSG_INFO, NULL, "Load Network Stream : %s", uri); args = calloc(1, sizeof(mrl_resource_network_args_t)); args->url = strdup(uri); if (type == MRL_RESOURCE_NETVDR) mrl = mrl_new(mp->players[mp->tv_type], type, args); else mrl = mrl_new(mp->players[mp->default_type], type, args); return mrl; }
void enna_volumes_add_emit(Enna_Volume *v) { Eina_List *l, *l_prev; Enna_Volumes_Listener *vl; if (!v) return; enna_log(ENNA_MSG_EVENT, "volumes", "Add: %s volume listeners: %d", v->label, eina_list_count(enna_volumes_listeners)); EINA_LIST_FOREACH_SAFE(enna_volumes_listeners, l, l_prev, vl) { if (!vl->add) continue; vl->add(vl->data, v); } _volumes = eina_list_append(_volumes, v); }
static mrl_t * set_tv_stream(const char *device, const char *driver, mrl_resource_t type) { mrl_t *mrl; mrl_resource_tv_args_t *args; args = calloc(1, sizeof(mrl_resource_tv_args_t)); if (type == MRL_RESOURCE_VDR) { enna_log(ENNA_MSG_INFO, NULL, "VDR stream; device: '%s' driver: '%s'", device, driver); args->device = device ? strdup(device) : NULL; args->driver = driver ? strdup(driver) : NULL; } mrl = mrl_new(mp->players[mp->tv_type], type, args); return mrl; }
void enna_config_init (const char *file) { char filename[4096]; enna_config = calloc(1, sizeof(Enna_Config)); if (file) snprintf(filename, sizeof(filename), "%s", file); else snprintf(filename, sizeof(filename), "%s/enna.cfg", enna_util_config_home_get()); enna_config->eth = elm_theme_new(); enna_config->cfg_file = strdup(filename); enna_log(ENNA_MSG_INFO, NULL, "using config file: %s", filename); if (!cfg_ini) cfg_ini = ini_new(filename); ini_parse(cfg_ini); }
static Eina_Bool event_key_down(void *data, int type, void *event) { Ecore_Event_Key *e; e = event; /* HACK ! If e->window is the same than enna winid, don't manage this event ecore_evas_x will do this for us. But if e->window is different than enna winid event are sent to libplayer subwindow and we must broadcast this event to Evas */ if (e->window != enna->ee_winid) { enna_log(ENNA_MSG_EVENT, NULL, "Ecore_Event_Key_Down %s", e->keyname); evas_event_feed_key_down(enna->evas, e->keyname, e->key, e->compose, NULL, e->timestamp, NULL); } return 1; }
static Enna_Module * enna_module_open(Enna_Module_Api *api) { Enna_Module *m; if (!api || !api->name) return NULL; if (api->version != ENNA_MODULE_VERSION ) { /* FIXME: popup error message */ /* Module version doesn't match enna version */ enna_log(ENNA_MSG_WARNING, NULL, "Bad module version, %s module", api->name); return NULL; } m = ENNA_NEW(Enna_Module, 1); m->api = api; m->enabled = 0; _enna_modules = eina_list_append(_enna_modules, m); return m; }
static Eina_Bool event_mouse_button(void *data, int type, void *event) { mrl_resource_t res; Ecore_Event_Mouse_Button *e = event; /* Broadcast mouse position only for dvd player and only if libplayer window is on screen */ if ((e->window == enna->ee_winid) || !mp->uri) return 1; res = mrl_get_resource(mp->player, NULL); if (res != MRL_RESOURCE_DVDNAV) return 1; /* Set mouse position and send mouseclick event */ enna_log(ENNA_MSG_EVENT, NULL, "Send Mouse click %d %d, uri : %s", e->x, e->y, mp->uri); player_set_mouse_position(mp->players[mp->dvd_type], e->x, e->y); player_dvd_nav(mp->players[mp->dvd_type], PLAYER_DVDNAV_MOUSECLICK); return 1; }
static Eina_Bool bs_gocomics_event (Evas_Object *layout, enna_input event) { enna_log(ENNA_MSG_EVENT, ENNA_MODULE_NAME, "Key pressed gocomics : %d", event); switch (event) { case ENNA_INPUT_LEFT: gocomics_button_prev_clicked_cb(NULL, NULL, NULL); return ENNA_EVENT_BLOCK; case ENNA_INPUT_RIGHT: gocomics_button_next_clicked_cb(NULL, NULL, NULL); return ENNA_EVENT_BLOCK; case ENNA_INPUT_BACK: //enna_content_hide(); return ENNA_EVENT_CONTINUE; case ENNA_INPUT_OK: gocomics_select_comic(enna_list_selected_data_get(mod->list)); return ENNA_EVENT_BLOCK; default: return enna_list_input_feed(mod->list, event); } }
static cdda_t * cd_identify (const char *dev) { cdda_t *cd; int err; cd = cdda_new (); err = cd_read_toc (cd, dev); if (err) { enna_log (ENNA_MSG_ERROR, MODULE_NAME, "Unable to read CD TOC."); goto err_cd_read_toc; } cd_get_discid (cd); return cd; err_cd_read_toc: cdda_free (cd); return NULL; }
static mrl_t * set_dvd_stream(const char *uri, mrl_resource_t type) { mrl_t *mrl; mrl_resource_videodisc_args_t *args; char *meta; uint32_t prop = 0; unsigned int tmp = 0; int title = 0; char *device; enna_log(ENNA_MSG_INFO, NULL, "Load DVD Video : %s", uri); args = calloc(1, sizeof(mrl_resource_videodisc_args_t)); device = strstr(uri, "://"); if (device) args->device = strdup(device + 3); mrl = mrl_new(mp->players[mp->dvd_type], type, args); meta = mrl_get_metadata_dvd(mp->players[mp->dvd_type], mrl, (uint8_t *) &prop); if (meta) { enna_log(ENNA_MSG_INFO, NULL, "Meta DVD VolumeID: %s", meta); free(meta); } if (prop) { unsigned int i; enna_log(ENNA_MSG_INFO, NULL, "Meta DVD Titles: %i", prop); for (i = 1; i <= prop; i++) { uint32_t chapters, angles, length; chapters = mrl_get_metadata_dvd_title(mp->players[mp->dvd_type], mrl, i, MRL_METADATA_DVD_TITLE_CHAPTERS); angles = mrl_get_metadata_dvd_title(mp->players[mp->dvd_type], mrl, i, MRL_METADATA_DVD_TITLE_ANGLES); length = mrl_get_metadata_dvd_title(mp->players[mp->dvd_type], mrl, i, MRL_METADATA_DVD_TITLE_LENGTH); enna_log(ENNA_MSG_INFO, NULL, "Meta DVD Title %i (%.2f sec), " \ "Chapters: %i, Angles: %i", i, length / 1000.0, chapters, angles); if (length > tmp) { tmp = length; title = i; } } } args->title_start = title; return mrl; }
static int mp_file_set(const char *uri, const char *label) { mrl_t *mrl = NULL; player_type_t player_type = mp->default_type; enna_log(ENNA_MSG_INFO, NULL, "Try to load : %s , %s", uri, label); /* try network streams */ if (!strncmp(uri, URI_TYPE_FTP, strlen(URI_TYPE_FTP))) mrl = set_network_stream(uri, MRL_RESOURCE_FTP); else if (!strncmp(uri, URI_TYPE_HTTP, strlen(URI_TYPE_HTTP))) mrl = set_network_stream(uri, MRL_RESOURCE_HTTP); else if (!strncmp(uri, URI_TYPE_MMS, strlen(URI_TYPE_MMS))) mrl = set_network_stream(uri, MRL_RESOURCE_MMS); else if (!strncmp(uri, URI_TYPE_NETVDR, strlen(URI_TYPE_NETVDR))) { mrl = set_network_stream(uri, MRL_RESOURCE_NETVDR); player_type = mp->tv_type; } else if (!strncmp(uri, URI_TYPE_RTP, strlen(URI_TYPE_RTP))) mrl = set_network_stream(uri, MRL_RESOURCE_RTP); else if (!strncmp(uri, URI_TYPE_RTSP, strlen(URI_TYPE_RTSP))) mrl = set_network_stream(uri, MRL_RESOURCE_RTSP); else if (!strncmp(uri, URI_TYPE_SMB, strlen(URI_TYPE_SMB))) mrl = set_network_stream(uri, MRL_RESOURCE_SMB); else if (!strncmp(uri, URI_TYPE_TCP, strlen(URI_TYPE_TCP))) mrl = set_network_stream(uri, MRL_RESOURCE_TCP); else if (!strncmp(uri, URI_TYPE_UDP, strlen(URI_TYPE_UDP))) mrl = set_network_stream(uri, MRL_RESOURCE_UDP); else if (!strncmp(uri, URI_TYPE_UNSV, strlen(URI_TYPE_UNSV))) mrl = set_network_stream(uri, MRL_RESOURCE_UNSV); /* Try DVD video */ else if (!strncmp(uri, URI_TYPE_DVD, strlen(URI_TYPE_DVD))) { mrl = set_dvd_stream(uri, MRL_RESOURCE_DVD); player_type = mp->dvd_type; } else if (!strncmp(uri, URI_TYPE_DVDNAV, strlen(URI_TYPE_DVDNAV))) { mrl = set_dvd_stream(uri, MRL_RESOURCE_DVDNAV); player_type = mp->dvd_type; } /* Try TV */ else if (!strncmp(uri, URI_TYPE_VDR, strlen(URI_TYPE_VDR))) { char *device = NULL; char *driver = strstr(uri, "#"); size_t device_len = strlen(uri) - strlen(URI_TYPE_VDR); if (driver) { device_len -= strlen(driver); driver++; device = malloc(device_len); strncpy(device, uri + strlen(URI_TYPE_VDR), device_len); } else if (device_len) device = strdup(uri + strlen(URI_TYPE_VDR)); mrl = set_tv_stream(device, driver, MRL_RESOURCE_VDR); player_type = mp->tv_type; } /* Try CD Audio */ else if (!strncmp(uri, URI_TYPE_CDDA, strlen(URI_TYPE_CDDA))) { mrl = set_cdda_stream(uri, MRL_RESOURCE_CDDA); } /* Try Spotify stream */ else if (!strncmp(uri, URI_TYPE_SPOTIFY, strlen(URI_TYPE_SPOTIFY))) { mrl = set_spotify_stream(uri, MRL_RESOURCE_FILE); player_type = mp->spotify_type; } /* default is local files */ if (!mrl) { printf("MRL is NULL try local file\n"); const char *it; it = strrchr(uri, '.'); if (it && !strcmp(it, ".iso")) /* consider ISO file as DVD */ { mrl = set_dvd_stream(uri, MRL_RESOURCE_DVDNAV); player_type = mp->dvd_type; } else { mrl = set_local_stream(uri); } } if (!mrl) { printf("MRL is NULL\n"); return 1; } ENNA_FREE(mp->uri); mp->uri = strdup(uri); ENNA_FREE(mp->label); mp->label = label ? strdup(label) : NULL; mp->audio_delay = AUDIO_DELAY_DEFAULT; mp->subtitle_delay = SUB_DELAY_DEFAULT; /* Initialization of subtitles variables */ init_sub_align(); init_sub_pos(); init_sub_scale(); init_framedrop(); init_sub_visibility(); mp->player_type = player_type; mp->player = mp->players[player_type]; player_mrl_set(mp->player, mrl); if (mp->subtitle_alignment != SUB_ALIGNMENT_DEFAULT) player_subtitle_set_alignment(mp->player, mp->subtitle_alignment); if (mp->subtitle_position != SUB_POSITION_DEFAULT) player_subtitle_set_position(mp->player, mp->subtitle_position); if (mp->subtitle_scale != SUB_SCALE_DEFAULT) player_subtitle_scale(mp->player, mp->subtitle_scale, 1); player_subtitle_set_visibility(mp->player, mp->subtitle_visibility); if (mp->framedrop != FRAMEDROP_DEFAULT) player_set_framedrop(mp->player, mp->framedrop); return 0; }
/** * @brief Init the module system */ int enna_module_init(void) { Eina_Array_Iterator iterator; unsigned int i; #ifdef USE_STATIC_MODULES Enna_Module_Api *api; /* Populate the array of available plugins statically */ _plugins_array = eina_array_new(20); #ifdef BUILD_ACTIVITY_BOOKSTORE eina_array_push(_plugins_array, &enna_mod_activity_bookstore_api); #endif #ifdef BUILD_ACTIVITY_CONFIGURATION eina_array_push(_plugins_array, &enna_mod_activity_configuration_api); #endif #ifdef BUILD_ACTIVITY_GAMES eina_array_push(_plugins_array, &enna_mod_activity_games_api); #endif #ifdef BUILD_ACTIVITY_MUSIC eina_array_push(_plugins_array, &enna_mod_activity_music_api); #endif #ifdef BUILD_ACTIVITY_PHOTO eina_array_push(_plugins_array, &enna_mod_activity_photo_api); #endif #ifdef BUILD_ACTIVITY_TV eina_array_push(_plugins_array, &enna_mod_activity_tv_api); #endif #ifdef BUILD_ACTIVITY_VIDEO eina_array_push(_plugins_array, &enna_mod_activity_video_api); #endif #ifdef BUILD_ACTIVITY_WEATHER eina_array_push(_plugins_array, &enna_mod_activity_weather_api); #endif #ifdef BUILD_BROWSER_CDDA eina_array_push(_plugins_array, &enna_mod_browser_cdda_api); #endif #ifdef BUILD_BROWSER_DVD eina_array_push(_plugins_array, &enna_mod_browser_dvd_api); #endif #ifdef BUILD_BROWSER_IPOD eina_array_push(_plugins_array, &enna_mod_browser_ipod_api); #endif #ifdef BUILD_BROWSER_SPOTIFY eina_array_push(_plugins_array, &enna_mod_browser_spotify_api); #endif #ifdef BUILD_BROWSER_LOCALFILES eina_array_push(_plugins_array, &enna_mod_browser_localfiles_api); #endif #ifdef BUILD_BROWSER_NETSTREAMS eina_array_push(_plugins_array, &enna_mod_browser_netstreams_api); #endif #ifdef BUILD_BROWSER_PODCASTS eina_array_push(_plugins_array, &enna_mod_browser_podcasts_api); #endif #ifdef BUILD_BROWSER_SHOUTCAST eina_array_push(_plugins_array, &enna_mod_browser_shoutcast_api); #endif #ifdef BUILD_BROWSER_UPNP eina_array_push(_plugins_array, &enna_mod_browser_upnp_api); #endif #ifdef BUILD_BROWSER_VALHALLA eina_array_push(_plugins_array, &enna_mod_browser_valhalla_api); #endif #ifdef BUILD_GADGET_DATE eina_array_push(_plugins_array, &enna_mod_gadget_date_api); #endif #ifdef BUILD_GADGET_DUMMY eina_array_push(_plugins_array, &enna_mod_gadget_dummy_api); #endif #ifdef BUILD_GADGET_WEATHER eina_array_push(_plugins_array, &enna_mod_gadget_weather_api); #endif #ifdef BUILD_INPUT_KBD eina_array_push(_plugins_array, &enna_mod_input_kbd_api); #endif #ifdef BUILD_INPUT_LIRC eina_array_push(_plugins_array, &enna_mod_input_lirc_api); #endif #ifdef BUILD_INPUT_WIIMOTE eina_array_push(_plugins_array, &enna_mod_input_wiimote_api); #endif #ifdef BUILD_VOLUME_HAL eina_array_push(_plugins_array, &enna_mod_volume_hal_api); #endif #ifdef BUILD_VOLUME_MTAB eina_array_push(_plugins_array, &enna_mod_volume_mtab_api); #endif #ifdef BUILD_VOLUME_UDEV eina_array_push(_plugins_array, &enna_mod_volume_udev_api); #endif /* Log the array */ enna_log(ENNA_MSG_INFO, NULL, "Available Plugins (static):"); EINA_ARRAY_ITER_NEXT(_plugins_array, i, api, iterator) enna_log(ENNA_MSG_INFO, NULL, "\t * %s", api->name); #else Eina_Module *module; /* Populate the array of available plugins dinamically */ _plugins_array = eina_array_new(20); _plugins_array = eina_module_list_get(_plugins_array, PACKAGE_LIB_DIR"/enna/modules/", 0, NULL, NULL); enna_log(ENNA_MSG_INFO, NULL, "Plugin Directory: %s", PACKAGE_LIB_DIR"/enna/modules/"); /* Log the array */ enna_log(ENNA_MSG_INFO, NULL, "Available Plugins (dynamic):"); EINA_ARRAY_ITER_NEXT(_plugins_array, i, module, iterator) enna_log(ENNA_MSG_INFO, NULL, "\t * %s", eina_module_file_get(module)); #endif /* USE_STATIC_MODULES */ #if ENABLE_CONFIG_PANEL _config_panel = enna_config_panel_register(_("Modules"), "icon/module", _config_panel_show, _config_panel_hide, NULL); #endif return 0; }
static void gocomics_set_comic_strip (void) { char img_dst[1024] = { 0 }; char query[1024] = { 0 }; char tdate[16] = { 0 }; char *ptr_start, *ptr_end, *img_src = NULL; url_data_t data = { 0 }; if (!mod->comic_id) return; /* get expected destination file name */ snprintf(img_dst, sizeof(img_dst), "%s/%s_%.4d_%.2d_%.2d", mod->path, mod->comic_id, mod->year, mod->month, mod->day); /* no need to perform a web request for an already existing file */ if (ecore_file_exists(img_dst)) goto comic_strip_show; /* compute the requested URL */ snprintf (tdate, sizeof (tdate), "%.4d/%.2d/%.2d\n", mod->year, mod->month, mod->day); snprintf (query, sizeof(query), GOCOMICS_QUERY, mod->comic_id, tdate); enna_log(ENNA_MSG_EVENT, ENNA_MODULE_NAME, "Query Request: %s", query); /* perform request */ data = url_get_data(mod->url, query); if (!data.buffer) return; enna_log(ENNA_MSG_EVENT, ENNA_MODULE_NAME, "Query Result: %s", data.buffer); /* find the comic strip url */ ptr_start = strstr(data.buffer, GOCOMICS_NEEDLE_START); if (!ptr_start) goto err_url; ptr_start += strlen(GOCOMICS_NEEDLE_START); ptr_end = strstr(ptr_start, GOCOMICS_NEEDLE_END); if (!ptr_end) goto err_url; /* download and save the comic strip file */ img_src = strndup (ptr_start, strlen(ptr_start) - strlen(ptr_end)); enna_log(ENNA_MSG_EVENT, ENNA_MODULE_NAME, "Saving Comic Strip URL %s to %s", img_src, img_dst); url_save_to_disk(mod->url, img_src, img_dst); /* display the comic strip */ comic_strip_show: bs_service_page_show(img_dst); err_url: ENNA_FREE(img_src); ENNA_FREE(data.buffer); }
static int cd_read_toc (cdda_t *cd, const char *dev) { int first = 0, last = -1; int i; #if defined(__MINGW32__) || defined(__CYGWIN__) HANDLE drive; DWORD r; CDROM_TOC toc; char device[10]; if (!cd || !dev) return 1; sprintf(device, "\\\\.\\%s", dev); drive = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); if(!DeviceIoControl(drive, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(CDROM_TOC), &r, 0)) { enna_log(ENNA_MSG_ERROR, "parser_cdda", "Device IO Control Failed"); return 1; } first = toc.FirstTrack - 1; last = toc.LastTrack; cd->total_tracks = last; cd->tracks = calloc (cd->total_tracks + 1, sizeof (cdda_track_t *)); for (i = first; i <= last; i++) { cdda_track_t *track; track = cdda_track_new (); track->min = toc.TrackData[i].Address[1]; track->sec = toc.TrackData[i].Address[2]; track->frame = toc.TrackData[i].Address[3]; cd->tracks[i] = track; } CloseHandle(drive); #else /* !defined(__MINGW32__) && !defined(__CYGWIN__) */ int drive; if (!cd || !dev) return 1; drive = open (dev, O_RDONLY | O_NONBLOCK); if (drive < 0) return 1; #if defined(__linux__) || defined(__bsdi__) struct cdrom_tochdr tochdr; ioctl (drive, CDROMREADTOCHDR, &tochdr); first = tochdr.cdth_trk0 - 1; last = tochdr.cdth_trk1; cd->total_tracks = last; cd->tracks = calloc (cd->total_tracks + 1, sizeof (cdda_track_t *)); for (i = first; i <= last; i++) { struct cdrom_tocentry tocentry; cdda_track_t *track; tocentry.cdte_track = (i == last) ? 0xAA : i + 1; tocentry.cdte_format = CDROM_MSF; ioctl (drive, CDROMREADTOCENTRY, &tocentry); track = cdda_track_new (); track->min = tocentry.cdte_addr.msf.minute; track->sec = tocentry.cdte_addr.msf.second; track->frame = tocentry.cdte_addr.msf.frame; cd->tracks[i] = track; } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) struct ioc_toc_header tochdr; ioctl(drive, CDIOREADTOCHEADER, &tochdr); first = tochdr.starting_track - 1; last = tochdr.ending_track; cd->total_tracks = last; cd->tracks = calloc (cd->total_tracks + 1, sizeof (cdda_track_t *)); for (i = first; i <= last; i++) { struct ioc_read_toc_single_entry tocentry; cdda_track_t *track; tocentry.track = (i == last) ? 0xAA : i + 1; tocentry.address_format = CD_MSF_FORMAT; ioctl(drive, CDIOREADTOCENTRY, &tocentry); track = cdda_track_new (); track->min = tocentry.entry.addr.msf.minute; track->sec = tocentry.entry.addr.msf.second; track->frame = tocentry.entry.addr.msf.frame; cd->tracks[i] = track; } #elif defined(__NetBSD__) || defined(__OpenBSD__) struct ioc_toc_header tochdr; ioctl(drive, CDIOREADTOCHEADER, &tochdr); first = tochdr.starting_track - 1; last = tochdr.ending_track; cd->total_tracks = last; cd->tracks = calloc (cd->total_tracks + 1, sizeof (cdda_track_t *)); for (i = first; i <= last; i++) { struct ioc_read_toc_entry tocentry; struct cd_toc_entry toc_buffer; cdda_track_t *track; tocentry.starting_track = (i == last) ? 0xAA : i + 1; tocentry.address_format = CD_MSF_FORMAT; tocentry.data = &toc_buffer; tocentry.data_len = sizeof(toc_buffer); ioctl(drive, CDIOREADTOCENTRYS, &tocentry); track = cdda_track_new (); track->min = toc_buffer.addr.msf.minute; track->sec = toc_buffer.addr.msf.second; track->frame = toc_buffer.addr.msf.frame; cd->tracks[i] = track; } #elif defined(__APPLE__) || defined(__DARWIN__) dk_cd_read_toc_t tochdr; uint8_t buf[4]; uint8_t buf2[100 * sizeof(CDTOCDescriptor) + sizeof(CDTOC)]; memset(&tochdr, 0, sizeof(tochdr)); tochdr.bufferLength = sizeof(buf); tochdr.buffer = &buf; if (!ioctl(drive, DKIOCCDREADTOC, &tochdr) && tochdr.bufferLength == sizeof(buf)) { first = buf[2] - 1; last = buf[3]; } if (last >= 0) { memset(&tochdr, 0, sizeof(tochdr)); tochdr.bufferLength = sizeof(buf2); tochdr.buffer = &buf2; tochdr.format = kCDTOCFormatTOC; if (ioctl(drive, DKIOCCDREADTOC, &tochdr) || tochdr.bufferLength < sizeof(CDTOC)) last = -1; } if (last >= 0) { CDTOC *cdToc = (CDTOC *)buf2; CDTrackInfo lastTrack; dk_cd_read_track_info_t trackInfoParams; for (i = first; i < last; ++i) { CDMSF msf = CDConvertTrackNumberToMSF(i + 1, cdToc); cdda_track_t *track; track = cdda_track_new (); track->min = msf.minute; track->sec = msf.second; track->frame = msf.frame; cd->tracks[i] = track; } memset(&trackInfoParams, 0, sizeof(trackInfoParams)); trackInfoParams.addressType = kCDTrackInfoAddressTypeTrackNumber; trackInfoParams.bufferLength = sizeof(lastTrack); trackInfoParams.address = last; trackInfoParams.buffer = &lastTrack; if (!ioctl(drive, DKIOCCDREADTRACKINFO, &trackInfoParams)) { CDMSF msf = CDConvertLBAToMSF(be2me_32(lastTrack.trackStartAddress) + be2me_32(lastTrack.trackSize)); cdda_track_t *track; track = cdda_track_new (); track->min = msf.minute; track->sec = msf.second; track->frame = msf.frame; cd->tracks[i] = track; } } #endif /* defined(__APPLE__) || defined(__DARWIN__) */ close (drive); #endif /* defined(__MINGW32__) || defined(__CYGWIN__) */ for (i = first; i <= last; i++) cd->tracks[i]->frame += (cd->tracks[i]->min * 60 + cd->tracks[i]->sec) * 75; return 0; }