void do_tracks() { /* Empty function to test stuff */ if (pz_get_int_setting(pp_config, PPCONFIG_AUTOMOUNT)) printf("Automount on\n"); else printf("Automount off\n"); }
static TWindow *new_settings_slider_window (char *title, int setting, int slider_min, int slider_max) { int tval = pz_get_int_setting (pz_global_config, setting); TWindow *win = ttk_new_window(); TWidget *slider = ttk_new_slider_widget (0, 0, ttk_screen->w * 3 / 5, slider_min, slider_max, &tval, 0); ttk_slider_set_callback (slider, slider_set_setting, setting); ttk_window_set_title (win, title); ttk_add_widget (win, slider); win->data = 0x12345678; ttk_set_popup (win); return win; }
static void init_launch() { module = pz_register_module("Podzilla2-SVN", cleanup); path = "/opt/Zillae/Podzilla2-SVN/Launch/Launch.sh"; config = pz_load_config("/opt/Zillae/Podzilla2-SVN/Conf/Hide.conf"); if (!pz_get_setting(config, HIDE_ALL)) pz_set_int_setting (config, HIDE_ALL, 0); if (!pz_get_setting(config, HIDE_ARCADE)) pz_set_int_setting (config, HIDE_ARCADE, 0); if (!pz_get_setting(config, HIDE_DEV)) pz_set_int_setting (config, HIDE_DEV, 0); if (!pz_get_setting(config, HIDE_MEDIA)) pz_set_int_setting (config, HIDE_MEDIA, 0); if (!pz_get_setting(config, HIDE_MISC)) pz_set_int_setting (config, HIDE_MISC, 0); if (!pz_get_setting(config, HIDE_TOOLS)) pz_set_int_setting (config, HIDE_TOOLS, 0); if (!pz_get_setting(config, HIDE_UNSORTED)) pz_set_int_setting (config, HIDE_UNSORTED, 0); pz_menu_add_stub_group("/Zillae/Podzilla2-SVN", "#PZ2 Based"); pz_menu_add_action_group("/Zillae/Podzilla2-SVN/#Fastlaunch", "#Normal", fastlaunch); pz_menu_add_action_group("/Zillae/Podzilla2-SVN/~ReadMe", "#Normal", readme); if (pz_get_int_setting(config, HIDE_ALL) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/All Modules", "#Normal", launch_all); if (pz_get_int_setting(config, HIDE_ARCADE) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/Arcade", "Lite", launch_arcade); if (pz_get_int_setting(config, HIDE_DEV) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/Dev", "Lite", launch_dev); if (pz_get_int_setting(config, HIDE_MEDIA) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/Media", "Lite", launch_media); if (pz_get_int_setting(config, HIDE_MISC) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/Misc", "Lite", launch_misc); if (pz_get_int_setting(config, HIDE_TOOLS) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/Tools", "Lite", launch_tools); if (pz_get_int_setting(config, HIDE_UNSORTED) == 0) pz_menu_add_action_group("/Zillae/Podzilla2-SVN/Unsorted","Lite", launch_unsorted); pz_menu_add_stub_group("/Zillae/Podzilla2-SVN/Hide Settings", "~Settings"); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide All Modules", "#Normal", HIDE_ALL, config, on_off_options); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide Arcade", "Lite", HIDE_ARCADE, config, on_off_options); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide Dev", "Lite", HIDE_DEV, config, on_off_options); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide Media", "Lite", HIDE_MEDIA, config, on_off_options); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide Misc", "Lite", HIDE_MISC, config, on_off_options); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide Tools", "Lite", HIDE_TOOLS, config, on_off_options); pz_menu_add_setting_group("/Zillae/Podzilla2-SVN/Hide Settings/Hide Unsorted", "Lite", HIDE_UNSORTED, config, on_off_options); pz_menu_sort("/Zillae/Podzilla2-SVN"); }
void pz_modules_init(char *path) { #ifdef IPOD #define MODULEDIR "/opt/Base:/opt/Emulators:/opt/Media:/opt/Tools:/opt/Zillae" #else #define MODULEDIR "modules" #endif /* Used for the progress bar */ TWindow * sliderwin; TWidget * slider; int sliderVal=0; int verbosity = pz_get_int_setting( pz_global_config, VERBOSITY ); #define MAXSLIDERVAL (100) #define SETUPSECTIONS (6) PzModule *last, *cur; int i; int modCount=0; if (module_head) { pz_error (_("modules_init called more than once")); return; } /* set up the screen to show a pretty progress bar */ sliderwin = ttk_new_window(); ttk_window_hide_header(sliderwin); sliderwin->x = sliderwin->y = 0; slider = ttk_new_slider_widget(2, ttk_screen->h/3, ttk_screen->w - 8, 0, MAXSLIDERVAL, &sliderVal, 0); slider->x = (sliderwin->w - slider->w)/2; ttk_add_widget(sliderwin, slider); sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 1; updateprogress(sliderwin, slider, sliderVal, _("Scanning For Modules"), NULL); if (!path) path = MODULEDIR; path = strtok(strdupa(path), ":"); while (path) { find_modules (path); path = strtok(NULL, ":"); } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 2; updateprogress(sliderwin, slider, sliderVal, _("Reading Modules"), NULL); for (i = 0; i < __pz_builtin_number_of_init_functions; i++) { int found = 0; const char *name = __pz_builtin_names[i]; cur = module_head; while (cur) { char *p = strrchr (cur->podpath, '/'); if (!p) p = cur->podpath; else p++; if (!strncmp (p, name, strlen (name)) && !isalpha (p[strlen (name)])) { found = 1; break; } cur = cur->next; } if (!found) { if (module_head) { cur = module_head; while (cur->next) cur = cur->next; cur->next = calloc (1, sizeof(PzModule)); cur = cur->next; } else { cur = module_head = calloc (1, sizeof(PzModule)); } cur->podpath = 0; cur->name = strdup (__pz_builtin_names[i]); cur->init = __pz_builtin_init_functions[i]; cur->to_load = -1; cur->ordered = 0; cur->next = 0; } } if (!module_head) { pz_message_title (_("Warning"), _("No modules. podzilla will probably be very boring.")); return; } /* Used to initialize the window + progressbar used in loading the modules*/ cur = module_head; while (cur) { modCount++; cur = cur->next; } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 3; updateprogress(sliderwin, slider, sliderVal, _("Mounting Modules"), NULL); // Mount 'em cur = module_head; last = 0; while (cur) { if (cur->podpath && cur->extracted) { cur->mountpt = strdup (cur->podpath); last = cur; cur = cur->next; } else if (cur->podpath && mount_pod (cur) == -1) { if (last) last->next = cur->next; else module_head = cur->next; free (cur->podpath); free (cur); cur = last? last->next : module_head; } else { last = cur; cur = cur->next; } } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 4; updateprogress(sliderwin, slider, sliderVal, _("Scanning Module Info"), NULL); // Load the module.inf's cur = module_head; while (cur) { load_modinf (cur); cur = cur->next; } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 5; updateprogress(sliderwin, slider, sliderVal, _("Module Dependencies"), NULL); // Figure out the dependencies cur = module_head; last = 0; while (cur) { if (fix_dependencies (cur, 1, SOFTDEP) == -1 || fix_dependencies(cur, 1, HARDDEP) == -1) { if (last) last->next = cur->next; else module_head = cur->next; free_module (cur); cur = last? last->next : module_head; } else { last = cur; cur = cur->next; } } // Check which ones are linked in cur = module_head; last = 0; while (cur) { for (i = 0; i < __pz_builtin_number_of_init_functions; i++) { if (!strcmp (__pz_builtin_names[i], cur->name)) { cur->init = __pz_builtin_init_functions[i]; cur->to_load = -1; cur->ordered = 0; } } cur = cur->next; } // XXX. For now, we use a slow method for deps, and it'll crash // for circular deps. davidc__ is working on a // better solution. cur = module_head; while (cur) { add_deps (cur); cur = cur->next; } sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 6; updateprogress(sliderwin, slider, sliderVal, _("Loading Modules"), NULL); struct dep *c = load_order; while (c) { if (c->mod->to_load > 0) { do_load (c->mod); } if( verbosity < VERBOSITY_ERRORS && c->mod->longname ) { updateprogress(sliderwin, slider, sliderVal, _("Loading Modules"), c->mod->longname ); } c = c->next; } c = load_order; sliderVal = 0; updateprogress(sliderwin, slider, sliderVal, _("Initializing Modules"), NULL); /* trigger the sliders to switch to init mode, restting the slider */ sliderVal = 0; /* initialize the modules */ while (c) { sliderVal += MAXSLIDERVAL / modCount; current_module = c->mod; updateprogress(sliderwin, slider, sliderVal, _("Initializing Modules"), (verbosity < 2)? c->mod->longname : NULL ); do_init (c->mod); c = c->next; } sliderVal = MAXSLIDERVAL; updateprogress(sliderwin, slider, sliderVal, _("Finishing Up..."), NULL); // Any modules with unrecoverable errors on loading set mod->to_free. // Oblige them. cur = module_head; last = 0; while (cur) { if (cur->to_free) { if (last) last->next = cur->next; else module_head = cur->next; free_module (cur); cur = last? last->next : module_head; } else { last = cur; cur = cur->next; } } ttk_free_window (sliderwin); }
static void load_modinf (PzModule *mod) { char *buf = malloc (512); #ifdef IPOD char *confdir = "/sandbox"; char *moddir = "/sandbox/packs"; #else char *confdir = malloc( MAXPATHLEN + 10 ); char *moddir = malloc( MAXPATHLEN + 20 ); #endif FILE *fp; if (!mod->podpath) { // static mod, no POD // mod->name already set mod->longname = strdup (mod->name); mod->author = strdup ("podzilla Team"); free (buf); return; } sprintf (buf, "%s/" MODULE_INF_FILE, mod->mountpt); fp = fopen (buf, "r"); if (!fp) { pz_perror (buf); } else { while (fgets (buf, 511, fp)) { char *key, *value; if (buf[strlen (buf) - 1] == '\n') buf[strlen (buf) - 1] = 0; if (strchr (buf, '#')) *strchr (buf, '#') = 0; if (strlen (buf) < 1) continue; if (!strchr (buf, ':')) { pz_error (_("Line without colon in Module file for %s, ignored"), strrchr (mod->podpath, '/')); continue; } key = buf; value = strchr (buf, ':') + 1; while (isspace (*value)) value++; while (isspace (*(value + strlen (value) - 1))) value[strlen (value) - 1] = 0; *strchr (key, ':') = 0; if (strcmp (key, "Module") == 0) { mod->name = malloc (strlen (value) + 1); strcpy (mod->name, value); } else if (strcmp (key, "Display-name") == 0) { mod->longname = malloc (strlen (value) + 1); strcpy (mod->longname, value); } else if (strcmp (key, "Author") == 0) { mod->author = malloc (strlen (value) + 1); strcpy (mod->author, value); } else if (strcmp (key, "Dependencies") == 0) { mod->depsstr = malloc (strlen (value) + 1); strcpy (mod->depsstr, value); } else if (strcmp (key, "Soft-Dependencies") == 0) { mod->sdepsstr = malloc (strlen (value) + 1); strcpy (mod->sdepsstr, value); } else if (strcmp (key, "Provides") == 0) { mod->providesstr = malloc (strlen (value) + 1); strcpy (mod->providesstr, value); } else if (strcmp (key, "Contact") == 0) { // nothing } else if (strcmp (key, "Category") == 0) { // nothing /* if( mod->group == NULL ) { if( strrchr( value, '/' ) ) { // copy the last bit over ie "Games/Arcade" -> "Arcade" mod->group = malloc (strlen (strrchr(value,'/')) + 1); strcpy (mod->group, strrchr( value,'/')+1 ); } else { // copy the entire string over mod->group = malloc (strlen (value) + 1); strcpy (mod->group, value); } } } else if (strcmp (key, "Group") == 0) { if( mod->group ) free( mod->group ); mod->group = malloc (strlen (value) + 1); strcpy (mod->group, value); */ } else if (strcmp (key, "Description") == 0) { // nothing } else if (strcmp (key, "License") == 0) { // nothing } else if (strcmp (key, "Unstable") == 0) { // You can override "beta" with Advanced > Beta Testing but you can't // override other things, e.g. "alpha" or "does not work". if (strcmp (value, "beta") == 0 && !pz_get_int_setting (pz_global_config, MODULE_TESTING)) pz_warning (_("Module %s is in beta. Use at your own risk."), mod->name); else pz_warning (_("Module %s is unstable: %s. Use at your own risk."), mod->name, value); } else { pz_error (_("Unrecognized key <%s> in Module file for %s, ignored"), key, mod->name? mod->name : strrchr (mod->podpath, '/')); } } } if (!mod->name) { pz_error (_("Module %s's module file provides no name! Using podfile name without the extension."), strrchr (mod->podpath, '/')); mod->name = malloc (strlen (strrchr (mod->podpath, '/') + 1) + 1); strcpy (mod->name, strrchr (mod->podpath, '/') + 1); if (strchr (mod->name, '.')) *strchr (mod->name, '.') = 0; } if (!mod->longname) { mod->longname = malloc (strlen (mod->name) + 1); strcpy (mod->longname, mod->name); } if (!mod->author) { mod->author = malloc (strlen (_("Anonymous")) + 1); strcpy (mod->author, _("Anonymous")); } // Get the config path, now that we know the name. #ifndef IPOD mod->cfgpath = malloc( MAXPATHLEN + 8 ); confdir = getcwd( mod->cfgpath, MAXPATHLEN ); confdir = strcat( confdir, "/config" ); sprintf( moddir, "%s/modules", confdir ); #else mod->cfgpath = malloc( strlen( moddir ) + strlen( mod->name ) + 1); #endif sprintf (mod->cfgpath, "%s/%s", moddir, mod->name); mkdir( confdir, 0755 ); /* make the main directory */ mkdir( moddir, 0755 ); /* make the modules directory */ if (mkdir (mod->cfgpath, 0755) < 0 && errno != EEXIST) { /* make the module subdir */ pz_warning (_("Unable to create %s's config dir %s: %s"), mod->name, mod->cfgpath, strerror (errno)); } #ifndef IPOD free( moddir ); #endif free (buf); }