int _pz_mod_check_version (int otherver) { int myver = PZ_API_VERSION; PzModule *module = current_module; /* version completely equal - OK */ if (myver == otherver) return 1; /* version less - some stuff may be missing, won't work */ if (myver < otherver) { pz_error ("Module %s compiled for a newer version of podzilla. Please upgrade.", module->name); goto remove; } /* minor version more - only stuff added, OK */ if (((myver & ~0xff) == (otherver & ~0xff)) && ((myver & 0xff) >= (otherver & 0xff))) { pz_warning ("Module %s compiled for a slightly older version of podzilla. " "It will still probably work, but you should upgrade the module soon.", module->name); return 1; } /* major version more - won't work */ pz_error ("Module %s compiled for a significantly older version of podzilla; " "it will not work. Please upgrade the module.", module->name); remove: module->to_free = 1; return 0; }
static PzWindow *fastlaunch() { pz_warning("%s only works on some monochrome iPods. It may or may not work on your iPod model.", "The podfather demo"); pz_exec_kill("/opt/Media/Podfather/Launch/Launch.sh"); return NULL; }
static PzWindow *set_Header() { PzWindow * ret; TWidget * wid; char headername[256]; snprintf(headername, 256, pz_get_string_setting(pz_global_config, HEADERNAME)); if(text_available()){ ret = pz_new_window(_("Set Header Name"), PZ_WINDOW_NORMAL); wid = textw(10, 40, ret->w-20, 10+ttk_text_height(ttk_textfont), 0, headername, pz_set_header); ttk_add_widget(ret, wid); textwstart(wid); return pz_finish_window(ret); } else { pz_warning("Install module text input"); return TTK_MENU_UPONE; } }
PzWindow *new_mymodule_window() { static int calledyet = 0; PzWindow *ret; FILE *fp; if (!calledyet) { calledyet++; pz_message ("Select again to see the fun stuff."); return TTK_MENU_DONOTHING; } image = ttk_load_image (pz_module_get_datapath (module, "image.png")); if (!image) { pz_error ("Could not load %s: %s", pz_module_get_datapath (module, "image.png"), strerror (errno)); return TTK_MENU_DONOTHING; } ttk_surface_get_dimen (image, &imgw, &imgh); fp = fopen (pz_module_get_datapath (module, "message.txt"), "r"); if (!fp) { pz_warning ("Could not read from %s: %s.", pz_module_get_datapath (module, "message.txt"), strerror (errno)); text = (char *)strdup ("Hi! I forgot to supply a message!"); } else { long len; fseek (fp, 0, SEEK_END); len = ftell (fp); fseek (fp, 0, SEEK_SET); text = malloc (len + 1); fread (text, 1, len, fp); text[len] = 0; } ret = pz_new_window ("MyModule", PZ_WINDOW_NORMAL); pz_add_widget (ret, draw_mymodule, event_mymodule); return pz_finish_window (ret); }
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); }