Ejemplo n.º 1
0
bool BeHappy::CheckAddOn(const char *path,bool alert,BString *pName)
{
	image_id addOnImage = load_add_on(path);
	void *instFunc;
	const char **projName;
	const uint16 *BHVersion,*BHVLastCompatible;
	bool ok = false;
	BPath aoPath(path);
	
	BString alTxt(aoPath.Leaf());		// chaîne utilisée pour générer des alertes d'erreur

	if ((addOnImage>=0) &&
		(get_image_symbol(addOnImage,"InstantiateProject",B_SYMBOL_TYPE_ANY,&instFunc) == B_OK) &&
		(get_image_symbol(addOnImage,"projectName",B_SYMBOL_TYPE_ANY,(void**)&projName) == B_OK) &&
		(get_image_symbol(addOnImage,"BHVersion",B_SYMBOL_TYPE_ANY,(void**)&BHVersion) == B_OK) &&
		(get_image_symbol(addOnImage,"BHVLastCompatible",B_SYMBOL_TYPE_ANY,(void**)&BHVLastCompatible) == B_OK))
	{
		if ((*BHVLastCompatible) > bhv_application)
		{
			if (alert)
			{
				alTxt << " " << T("isn't compatible with this (old) version of BeHappy. Please download a more recent version of BeHappy.");
				BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK",
					NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT);
				myAlert->Go();
			}
		}
		else if ((*BHVersion) < bhv_last_addon)
		{
			if (alert)
			{
				alTxt << " " << T("is too old, and isn't compatible with this version of BeHappy. Please find a more recent version of the add-on.");
				BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK",
					NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT);
				myAlert->Go();
			}
		}
		else
		{
			ok = true;
			if (pName != NULL)
				*pName=*projName;
		}					
	}
	else	
	{
		if (alert)
		{
			alTxt << " " << T("is an invalid BeHappy add-on.");
			BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK",
				NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT);
			myAlert->Go();
		}
	}
	
	if (addOnImage>=0)
		unload_add_on(addOnImage);

	return ok;
}
Ejemplo n.º 2
0
void
CayaProtocolAddOn::_Init()
{
    const char* (*signature)();
    const char* (*friendly_signature)();

    fStatus = B_OK;

    if (get_image_symbol(fImage, "protocol", B_SYMBOL_TYPE_TEXT,
                         (void**)&fGetProtocol) != B_OK) {
        unload_add_on(fImage);
        fStatus = B_ERROR;
        return;
    }

    if (get_image_symbol(fImage, "signature", B_SYMBOL_TYPE_TEXT,
                         (void**)&signature) != B_OK) {
        unload_add_on(fImage);
        fStatus = B_ERROR;
        return;
    }

    if (get_image_symbol(fImage, "friendly_signature", B_SYMBOL_TYPE_TEXT,
                         (void**)&friendly_signature) != B_OK) {
        unload_add_on(fImage);
        fStatus = B_ERROR;
        return;
    }

    fSignature = signature();
    fFriendlySignature = friendly_signature();
}
Ejemplo n.º 3
0
status_t PrintTransport::Open(BNode* printerFolder)
{
	// already opened?
	if (fDataIO != NULL) {
		return B_ERROR;
	}

	// retrieve transport add-on name from printer folder attribute
	BString transportName;
	if (printerFolder->ReadAttrString("transport", &transportName) != B_OK) {
		return B_ERROR;
	}

	// try first in user add-ons directory
	BPath path;
	find_directory(B_USER_ADDONS_DIRECTORY, &path);
	path.Append("Print/transport");
	path.Append(transportName.String());
	fAddOnID = load_add_on(path.Path());

	if (fAddOnID < 0) {
		// on failure try in system add-ons directory
		find_directory(B_BEOS_ADDONS_DIRECTORY, &path);
		path.Append("Print/transport");
		path.Append(transportName.String());
		fAddOnID = load_add_on(path.Path());
	}

	if (fAddOnID < 0) {
		// failed to load transport add-on
		return B_ERROR;
	}

	// get init & exit proc
	BDataIO* (*initProc)(BMessage*);
	get_image_symbol(fAddOnID, "init_transport", B_SYMBOL_TYPE_TEXT, (void **) &initProc);
	get_image_symbol(fAddOnID, "exit_transport", B_SYMBOL_TYPE_TEXT, (void **) &fExitProc);

	if (initProc == NULL || fExitProc == NULL) {
		// transport add-on has not the proper interface
		return B_ERROR;
	}

	// now, initialize the transport add-on
	node_ref   ref;
	BDirectory dir;

	printerFolder->GetNodeRef(&ref);
	dir.SetTo(&ref);

	if (path.SetTo(&dir, NULL) != B_OK) {
		return B_ERROR;
	}

	// request BDataIO object from transport add-on
	BMessage input('TRIN');
	input.AddString("printer_file", path.Path());
	fDataIO = (*initProc)(&input);
	return B_OK;
}
status_t TEncoderAddonManager::LoadAddons(const char *addondDir)
{
	fp_text_convert_t fp_text_convert;
	image_id id;
	BDirectory dir(addondDir);
	BEntry entry;
	
	// load encoders add-on
	while (dir.GetNextEntry(&entry) == B_OK) {
		BPath addonPath(&entry);
		if ((id = load_add_on(addonPath.Path())) < 0) continue;
		if (get_image_symbol(id, "fp_text_convert", B_SYMBOL_TYPE_TEXT, (void **)&fp_text_convert)) {
			unload_add_on(id);
			continue;
		}
		encoder_addon_t *addon = (encoder_addon_t *)malloc(sizeof(encoder_addon_t));
		if (!addon) {
			fprintf(stderr, "%s\n", strerror(ENOMEM));
			unload_add_on(id);
			return ENOMEM;
		}
		addon->id = id;
		addon->fp_text_convert = fp_text_convert;
		strncpy(addon->name, addonPath.Leaf(), sizeof(addon->name));
		fEncoderAddonList.AddItem(addon);
		fprintf(stderr, "load: %s\n", addon->name);
	}
	return B_OK;
}
Ejemplo n.º 5
0
bool
BTranslatorRoster::IsTranslator(entry_ref* ref)
{
	if (ref == NULL)
		return false;

	BPath path(ref);
	image_id image = load_add_on(path.Path());
	if (image < B_OK)
		return false;

	// Function pointer used to create post R4.5 style translators
	BTranslator* (*makeNthTranslator)(int32 n, image_id you, uint32 flags, ...);

	status_t status = get_image_symbol(image, "make_nth_translator",
		B_SYMBOL_TYPE_TEXT, (void**)&makeNthTranslator);
	if (status < B_OK) {
		// If this is a translator add-on, it is in the C format
		translator_data translatorData;
		status = fPrivate->GetTranslatorData(image, translatorData);
	}

	unload_add_on(image);
	return status == B_OK;
}
status_t
PrinterDriverAddOn::TakeJob(const char* spoolFile, BDirectory* spoolFolder)
{
	if (!IsLoaded())
		return B_ERROR;

	BFile file(spoolFile, B_READ_WRITE);
	take_job_func_t func;
	status_t result = get_image_symbol(fAddOnID, "take_job", B_SYMBOL_TYPE_TEXT,
		(void**)&func);
	if (result != B_OK)
		return result;

	// This seems to be required for legacy?
	// HP PCL3 add-on crashes without it!
	BMessage parameters(B_REFS_RECEIVED);
	parameters.AddInt32("file", (int32)&file);
	parameters.AddInt32("printer", (int32)spoolFolder);

	BMessage* message = (*func)(&file, spoolFolder, &parameters);
	if (message == NULL || message->what != 'okok')
		result = B_ERROR;
	delete message;

	return result;
}
Ejemplo n.º 7
0
// ---------------------------------------------------------------
// PrintSpooledJob
//
// Loads the printer add-on and calls its take_job function with
// the spool file as argument.
//
// Parameters:
//    spoolFile - the spool file.
//
// Returns:
//    B_OK if successful.
// ---------------------------------------------------------------
status_t Printer::PrintSpooledJob(BFile* spoolFile)
{
	status_t rc;
	image_id id;
	if ((rc = LoadPrinterAddon(id)) == B_OK) {
		take_job_func_t func;
		// Addon was loaded, so try and get the take_job symbol
		if ((rc = get_image_symbol(id, "take_job", B_SYMBOL_TYPE_TEXT,
			(void**)&func)) == B_OK) {
			// This seems to be required for legacy?
			// HP PCL3 add-on crashes without it!
			BMessage params(B_REFS_RECEIVED);
			params.AddInt32("file", (int32)spoolFile);
			params.AddInt32("printer", (int32)SpoolDir());
				// call the function and check its result
			BMessage* result = (*func)(spoolFile, SpoolDir(), &params);

			if (result == NULL || result->what != 'okok')
				rc = B_ERROR;
			delete result;
		}

		::unload_add_on(id);
	}
	return rc;
}
Ejemplo n.º 8
0
// ---------------------------------------------------------------
// GetDefaultSettings
//
// Retrieve the default configuration message from printer add-on
//
// Parameters:
//   settings, output paramter.
//
// Returns:
//    B_OK if successful or errorcode otherwise.
// ---------------------------------------------------------------
status_t Printer::GetDefaultSettings(BMessage& settings)
{
	status_t rc;
	image_id id;
	if ((rc = LoadPrinterAddon(id)) == B_OK) {
			// Addon was loaded, so try and get the default_settings symbol
		default_settings_t func;
		if ((rc = get_image_symbol(id, "default_settings", B_SYMBOL_TYPE_TEXT,
			(void**)&func)) == B_OK) {
				// call the function and check its result
			BMessage* new_settings = (*func)(SpoolDir());
			if (new_settings) {
				settings = *new_settings;
				settings.what = 'okok';
				AddCurrentPrinter(settings);
			} else {
				rc = B_ERROR;
			}
			delete new_settings;
		}

		::unload_add_on(id);
	}
	return rc;
}
Ejemplo n.º 9
0
// ---------------------------------------------------------------
// ConfigureJob
//
// Handles calling the printer addon's config_job function.
//
// Parameters:
//    settings - Job settings to display. The contents of this
//               message will be replaced with the new settings
//               if the function returns success.
//
// Returns:
//    B_OK if successful or errorcode otherwise.
// ---------------------------------------------------------------
status_t Printer::ConfigureJob(BMessage& settings)
{
	status_t rc;
	image_id id;
	if ((rc = LoadPrinterAddon(id)) == B_OK) {
			// Addon was loaded, so try and get the config_job symbol
		config_func_t func;
		if ((rc = get_image_symbol(id, "config_job", B_SYMBOL_TYPE_TEXT,
			(void**)&func)) == B_OK) {
			// call the function and check its result
			BMessage* new_settings = (*func)(SpoolDir(), &settings);
			if ((new_settings != NULL) && (new_settings->what != 'baad')) {
				settings = *new_settings;
				settings.what = 'okok';
				AddCurrentPrinter(settings);
			} else {
				rc = B_ERROR;
			}
			delete new_settings;
		}

		::unload_add_on(id);
	}

	return rc;
}
Ejemplo n.º 10
0
void *
get_symbol (void *handle, char *symbol_name)
{
    void *symptr;
#ifdef  DJGPP
    st_symbol_t *sym = map_get (dxe_map, handle);
    if (sym == NULL)
    {
        fprintf (stderr, "ERROR: Invalid handle: %x\n", (int) handle);
        exit (1);
    }

    symptr = sym->dxe_symbol (symbol_name);
    if (symptr == NULL)
    {
        fprintf (stderr, "ERROR: Could not find symbol: %s\n", symbol_name);
        exit (1);
    }
#elif   defined __unix__ || defined __APPLE__   // Mac OS X actually, see
    char *strptr;                                 //  comment in open_module()

    symptr = dlsym (handle, symbol_name);
    if ((strptr = dlerror ()) != NULL)            // this is "the correct way"
    {   //  according to the info page
        fputs ("ERROR: ", stderr);
        fputs (strptr, stderr);
        fputc ('\n', stderr);
        exit (1);
    }
#elif   defined _WIN32
    u_func_ptr_t sym;
    sym.func_ptr = (void (*) (void)) GetProcAddress ((HINSTANCE) handle, symbol_name);
    symptr = sym.void_ptr;
    if (symptr == NULL)
    {
        LPTSTR strptr;

        fputs ("ERROR: ", stderr);
        FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
                       FORMAT_MESSAGE_FROM_SYSTEM |
                       FORMAT_MESSAGE_IGNORE_INSERTS,
                       NULL, GetLastError (),
                       MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
                       (LPTSTR) &strptr, 0, NULL);
        fputs (strptr, stderr);
        LocalFree (strptr);
        exit (1);
    }
#elif   defined __BEOS__
    int status = get_image_symbol ((int) handle, symbol_name,
                                   B_SYMBOL_TYPE_ANY, &symptr); // B_SYMBOL_TYPE_TEXT/B_SYMBOL_TYPE_DATA
    if (status != B_OK)
    {
        fprintf (stderr, "ERROR: Could not find symbol: %s\n", symbol_name);
        exit (1);
    }
#endif

    return symptr;
}
Ejemplo n.º 11
0
template<class T> T*
instantiate_add_on(image_id image, const char* path, const char* type)
{
	T* (*instantiateFunction)();

	BString functionName = "instantiate_input_";
	functionName += type;

	if (get_image_symbol(image, functionName.String(), B_SYMBOL_TYPE_TEXT,
			(void**)&instantiateFunction) < B_OK) {
		ERROR("AddOnManager::_RegisterAddOn(): can't find %s() in \"%s\"\n",
			functionName.String(), path);
		return NULL;
	}

	T* addOn = (*instantiateFunction)();
	if (addOn == NULL) {
		ERROR("AddOnManager::_RegisterAddOn(): %s() in \"%s\" returned "
			"NULL\n", functionName.String(), path);
		return NULL;
	}

	status_t status = addOn->InitCheck();
	if (status != B_OK) {
		ERROR("AddOnManager::_RegisterAddOn(): InitCheck() in \"%s\" "
			"returned %s\n", path, strerror(status));
		delete addOn;
		return NULL;
	}

	return addOn;
}
Ejemplo n.º 12
0
static DSO_FUNC_TYPE beos_bind_func (DSO * dso, const char *symname)
{
    image_id id;

    void *sym;

    if ((dso == NULL) || (symname == NULL))
    {
        DSOerr (DSO_F_BEOS_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER);
        return (NULL);
    }
    if (sk_num (dso->meth_data) < 1)
    {
        DSOerr (DSO_F_BEOS_BIND_FUNC, DSO_R_STACK_ERROR);
        return (NULL);
    }
    id = (image_id) sk_value (dso->meth_data, sk_num (dso->meth_data) - 1);
    if (id < 1)
    {
        DSOerr (DSO_F_BEOS_BIND_FUNC, DSO_R_NULL_HANDLE);
        return (NULL);
    }
    if (get_image_symbol (id, symname, B_SYMBOL_TYPE_TEXT, &sym) != B_OK)
    {
        DSOerr (DSO_F_BEOS_BIND_FUNC, DSO_R_SYM_FAILURE);
        ERR_add_error_data (3, "symname(", symname, ")");
        return (NULL);
    }
    return ((DSO_FUNC_TYPE) sym);
}
Ejemplo n.º 13
0
int
main(int argc, char **argv)
{
	// Parse command line arguments

	bool ignorePunctuation = false;
	char *addon = NULL;
	BCollator *collator = NULL;

	while ((++argv)[0]) {
		if (argv[0][0] == '-') {
			if (!strcmp(argv[0], "-i"))
				ignorePunctuation = true;
			else if (!strcmp(argv[0], "--help"))
				usage();
		} else {
			// this will be the add-on to be loaded
			addon = argv[0];
		}
	}

	// load the collator add-on if necessary

	if (addon != NULL) {
		image_id image = load_add_on(addon);
		if (image < B_OK)
			fprintf(stderr, "could not load add-on at \"%s\": %s.\n", addon, strerror(image));

		BCollatorAddOn *(*instantiate)(void);
		if (get_image_symbol(image, "instantiate_collator",
				B_SYMBOL_TYPE_TEXT, (void **)&instantiate) == B_OK) {
			BCollatorAddOn *collatorAddOn = instantiate();
			if (collatorAddOn != NULL)
				collator = new BCollator(collatorAddOn, B_COLLATE_PRIMARY, true);
		} else if (image >= B_OK) {
			fprintf(stderr, "could not find instantiate_collator() function in add-on!\n");
			unload_add_on(image);
		}
	}

	if (collator == NULL) {
		collator = be_locale->Collator();
		addon = (char*)"default";
	}

	// test key creation speed

	collator->SetIgnorePunctuation(ignorePunctuation);

	printf("%s:\n", addon);
	test(collator, "primary:   ", B_COLLATE_PRIMARY);
	test(collator, "secondary: ", B_COLLATE_SECONDARY);
	test(collator, "tertiary:  ", B_COLLATE_TERTIARY);
	test(collator, "quaternary:", B_COLLATE_QUATERNARY);
	test(collator, "identical: ", B_COLLATE_IDENTICAL);

	return 0;
}
Ejemplo n.º 14
0
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
    status_t rc;

    rc = get_image_symbol((image_id) handle, name, B_SYMBOL_TYPE_ANY, symbol);

    return (rc == B_OK) ? 0 : -1;
}
Ejemplo n.º 15
0
char *
AddonName(image_id id, int n)
{
	static char	name[MAX_QUA_NAME_LENGTH];
	status_t	err;
	
	char		**addon_tag_p;
	if ((err=get_image_symbol(
			id, "addon_name", B_SYMBOL_TYPE_DATA, (void**)&addon_tag_p)) >= B_NO_ERROR) {
		strcpy(name, *addon_tag_p);
	} else if ((err=get_image_symbol(
			id, "addon_name_array", B_SYMBOL_TYPE_DATA, (void**)&addon_tag_p)) >= B_NO_ERROR) {
		strcpy(name, addon_tag_p[n]);
	} else {
		strcpy(name, "boring");
	}
	return name;
}
Ejemplo n.º 16
0
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
    image_id lib = load_add_on(fname);
    void *retval = NULL;
    if ((lib < 0) || (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR)) {
        retval = NULL;
    }
    return retval;
}
Ejemplo n.º 17
0
void *
SDL_LoadFunction(void *handle, const char *name)
{
    void *sym = NULL;
    image_id library_id = (image_id) handle;
    status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
    if (rc != B_NO_ERROR) {
        SDL_SetError(strerror(rc));
    }
    return (sym);
}
Ejemplo n.º 18
0
void* CC_CALL cc_load_function(void *handle, const char_t *name)
{
    void *sym = NULL;
    image_id library_id = (image_id) handle;
    status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
    if (rc != B_NO_ERROR) {
        CC_ERROR_LOG(_T("Failed loading %s : %s"),sofile,strerror((int) rc));
        return NULL;
    }
    return (sym);
}
Ejemplo n.º 19
0
void
__haiku_term_after(image_id id)
{
    void (*after)(image_id);

    HIDDEN_FUNCTION(__haiku_term_after);

    if (get_image_symbol(id, B_TERM_AFTER_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT,
                         (void**)&after) == B_OK) {
        after(id);
    }
}
Ejemplo n.º 20
0
void
__haiku_term_before(image_id id)
{
    void (*before)(image_id);

    HIDDEN_FUNCTION(__haiku_term_before);

    if (get_image_symbol(id, B_TERM_BEFORE_FUNCTION_NAME, B_SYMBOL_TYPE_TEXT,
                         (void**)&before) == B_OK) {
        before(id);
    }
}
Ejemplo n.º 21
0
status_t
AddOnManager::_RegisterAddOn(const entry_ref& ref)
{
	BPath path(&ref);

	ImageLoader loader(path);
	status_t status = loader.InitCheck();
	if (status != B_OK)
		return status;

	MediaPlugin* (*instantiate_plugin_func)();

	if (get_image_symbol(loader.Image(), "instantiate_plugin",
			B_SYMBOL_TYPE_TEXT, (void**)&instantiate_plugin_func) < B_OK) {
		printf("AddOnManager::_RegisterAddOn(): can't find instantiate_plugin "
			"in \"%s\"\n", path.Path());
		return B_BAD_TYPE;
	}

	MediaPlugin* plugin = (*instantiate_plugin_func)();
	if (plugin == NULL) {
		printf("AddOnManager::_RegisterAddOn(): instantiate_plugin in \"%s\" "
			"returned NULL\n", path.Path());
		return B_ERROR;
	}

	ReaderPlugin* reader = dynamic_cast<ReaderPlugin*>(plugin);
	if (reader != NULL)
		_RegisterReader(reader, ref);

	DecoderPlugin* decoder = dynamic_cast<DecoderPlugin*>(plugin);
	if (decoder != NULL)
		_RegisterDecoder(decoder, ref);

	WriterPlugin* writer = dynamic_cast<WriterPlugin*>(plugin);
	if (writer != NULL)
		_RegisterWriter(writer, ref);

	EncoderPlugin* encoder = dynamic_cast<EncoderPlugin*>(plugin);
	if (encoder != NULL)
		_RegisterEncoder(encoder, ref);

	StreamerPlugin* streamer = dynamic_cast<StreamerPlugin*>(plugin);
	if (streamer != NULL)
		_RegisterStreamer(streamer, ref);

	delete plugin;

	return B_OK;
}
bool
CatalogAddOnInfo::MakeSureItsLoaded()
{
	if (!fIsEmbedded && fAddOnImage < B_OK) {
		// add-on has not been loaded yet, so we try to load it:
		BString fullAddOnPath(fPath);
		fullAddOnPath << "/" << fName;
		fAddOnImage = load_add_on(fullAddOnPath.String());
		if (fAddOnImage >= B_OK) {
			get_image_symbol(fAddOnImage, "instantiate_catalog",
				B_SYMBOL_TYPE_TEXT, (void**)&fInstantiateFunc);
			get_image_symbol(fAddOnImage, "create_catalog",
				B_SYMBOL_TYPE_TEXT, (void**)&fCreateFunc);
			get_image_symbol(fAddOnImage, "get_available_languages",
				B_SYMBOL_TYPE_TEXT, (void**)&fLanguagesFunc);
		} else
			return false;
	} else if (fIsEmbedded) {
		// The built-in catalog still has to provide this function
		fLanguagesFunc = default_catalog_get_available_languages;
	}
	return true;
}
Ejemplo n.º 23
0
/* A function called through the vtable to get the address of
   a symbol loaded from a particular module.  */
static void *
vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name)
{
  void *address = 0;
  image_id image = (image_id) module;

  if (get_image_symbol (image, name, B_SYMBOL_TYPE_ANY, address) != B_OK)
    {
      LT__SETERROR (SYMBOL_NOT_FOUND);
      address = 0;
    }

  return address;
}
Ejemplo n.º 24
0
void AmFilterAddOnHandle::ImageLoaded(image_id image)
{
	if (!IsStatic()) {
		ImageUnloading(image);
		
		void *factory;
		status_t err = get_image_symbol(image, "make_nth_filter",
										B_SYMBOL_TYPE_TEXT, &factory);
		if (err >= B_OK) {
			mAddOn = (*((make_nth_filter_type)factory))(0, image, this, 0);
			if (!mAddOn) err = B_ERROR;
		}
	}
}
status_t
PrinterDriverAddOn::AddPrinter(const char* spoolFolderName)
{
	if (!IsLoaded())
		return B_ERROR;

	add_printer_func_t func;
	status_t result = get_image_symbol(fAddOnID, "add_printer",
		B_SYMBOL_TYPE_TEXT, (void**)&func);
	if (result != B_OK)
		return result;

	if ((*func)(spoolFolderName) == NULL)
		return B_ERROR;
	return B_OK;
}
Ejemplo n.º 26
0
void
DecorManager::RescanDecorators()
{
	BDirectory dir(DECORATORS_DIR);

	if (dir.InitCheck() != B_OK)
		return;

	entry_ref ref;
	while (dir.GetNextRef(&ref) == B_OK) {
		BPath path;
		path.SetTo(DECORATORS_DIR);
		path.Append(ref.name);

		// Because this function is used for both initialization and for keeping
		// the list up to date, check for existence in the list. Note that we
		// do not check to see if a decorator has been removed. This is for
		// stability. If there is a decorator in memory already whose file has
		// been deleted, it is still available until the next boot, at which point
		// it will obviously not be loaded.

		if (_FindDecor(ref.name))
			continue;

		image_id image = load_add_on(path.Path());
		if (image < 0)
			continue;

		// As of now, we do nothing with decorator versions, but the possibility
		// exists that the API will change even though I cannot forsee any reason
		// to do so. If we *did* do anything with decorator versions, the 
		// assignment would go here.

		create_decorator* createFunc;

		// Get the instantiation function
		status_t status = get_image_symbol(image, "instantiate_decorator",
								B_SYMBOL_TYPE_TEXT, (void**)&createFunc);
		if (status != B_OK) {
			unload_add_on(image);
			continue;
		}

		// TODO: unload images until they are actually used!
		fDecorList.AddItem(new DecorInfo(image, ref.name, createFunc));
	}
}
void					
BF_GUI_FilesPanel::Action_Tracker_Addons_Run(const char *pc_AddOn)
{
	ASSERT(pc_AddOn);
		
	image_id 	uImage;	
	uImage = load_add_on(pc_AddOn);
	if(0==uImage) return;
	
	BEntry 		oEntry(oPath.Path());
	entry_ref	uEntryRef;
	
	if(B_OK!=oEntry.GetRef(&uEntryRef)) return;
	
	void (*Func_AddOn)(entry_ref dir_ref, BMessage *msg, void *);
	if(B_OK!=get_image_symbol(uImage, "process_refs", B_SYMBOL_TYPE_TEXT, (void**)&Func_AddOn)) return;
	
	BMessage 			*poMessage = new BMessage();	
	BF_NodeCollection	loSelNode;
	loNode.GetSelecting(loSelNode);
	if(loSelNode.CountItems()==0) loSelNode.AddItem(Nodes_Focus());
	if(loSelNode.CountItems()==0) return;
	ASSERT(poMessage);
	
	BF_Node 	*poNode=NULL;
	entry_ref	uNodeRef;	
	BL_String	s;
	for(int iNode=0;iNode<loSelNode.CountItems();iNode++){
		poNode = loSelNode.NodeAt(iNode);
		s=oPath.Path();
		s<<"/";
		s<<poNode->sName;
		if(B_OK!=oEntry.SetTo(s.String()) || B_OK!=oEntry.GetRef(&uNodeRef)) continue;
		poMessage->AddRef("refs",&uNodeRef);
	}
	
	
	poMessage->AddRef("folder_ref",&uEntryRef);
	poMessage->AddPointer("func",(void*)Func_AddOn);
	
	// run thread //
	thread_id idThread = spawn_thread(BF_GUI_FilesPanel_Action_Tracker_Addons_Run_Thread,"tracker_addon_thread",B_THREAD_SUSPENDED,(void*)poMessage);	
	ASSERT(idThread>0,"can`t start thread\n");	
	ASSERT(B_OK==resume_thread(idThread));		
	set_thread_priority(idThread,1);				
}
Ejemplo n.º 28
0
CGraphWindow::CGraphWindow(CCellWindow *inOwner, BRect inRect, image_id inAddOn)
	: BWindow(inRect, "Graph", B_DOCUMENT_WINDOW, 0)
{
	fOwner  = inOwner;
	fAddOnImage = inAddOn;
	
	inOwner->GetCellView()->GetSelection(&fSelection);
	fContainer = inOwner->GetCellView()->GetContainer();
	
	CGraphPlugIn* (*createGraph)(BRect frame, range selection, CContainer *container); 
	if (get_image_symbol(fAddOnImage, "NewGraphPlugIn__F5BRect5rangeP10CContainer",
		B_SYMBOL_TYPE_TEXT, &createGraph) != B_NO_ERROR)
		THROW((errCreatingGraph));
	
	BRect r(Bounds());
	r.bottom = GetMBarHeight();
	BMenuBar *mbar = new BMenuBar(r, "mbar");
	AddChild(mbar);

	BMenu *file = new BMenu("File");
	file->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W'));
	mbar->AddItem(file);
	
	BMenu *edit = new BMenu("Edit");
	edit->AddItem(new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
	mbar->AddItem(edit);
	
	r = Bounds();
	r.top += GetMBarHeight();
	
	BView *background = new BView(r, "background", B_FOLLOW_ALL_SIDES,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
	AddChild(background);
	
	r.OffsetTo(0, 0);
	r.InsetBy(B_V_SCROLL_BAR_WIDTH, B_H_SCROLL_BAR_HEIGHT);
	fMainView = (*createGraph)(r, fSelection, fContainer);
	if (fMainView == NULL)
		THROW((errCreatingGraphView));

	background->AddChild(fMainView);
	fMainView->DataChanged();

	Show();
} /* CGraphWindow::CGraphWindow */
Ejemplo n.º 29
0
status_t
BTranslatorRoster::Private::GetTranslatorData(image_id image,
	translator_data& data)
{
	// If this is a translator add-on, it is in the C format
	memset(&data, 0, sizeof(translator_data));

	// find all the symbols

	int32* version;
	if (get_image_symbol(image, "translatorName", B_SYMBOL_TYPE_DATA,
			(void**)&data.name) < B_OK
		|| get_image_symbol(image, "translatorInfo", B_SYMBOL_TYPE_DATA,
			(void**)&data.info) < B_OK
		|| get_image_symbol(image, "translatorVersion", B_SYMBOL_TYPE_DATA,
			(void**)&version) < B_OK || version == NULL
		|| get_image_symbol(image, "inputFormats", B_SYMBOL_TYPE_DATA,
			(void**)&data.input_formats) < B_OK
		|| get_image_symbol(image, "outputFormats", B_SYMBOL_TYPE_DATA,
			(void**)&data.output_formats) < B_OK
		|| get_image_symbol(image, "Identify", B_SYMBOL_TYPE_TEXT,
			(void**)&data.identify_hook) < B_OK
		|| get_image_symbol(image, "Translate", B_SYMBOL_TYPE_TEXT,
			(void**)&data.translate_hook) < B_OK) {
		return B_BAD_TYPE;
	}

	data.version = *version;

	// those calls are optional
	get_image_symbol(image, "MakeConfig", B_SYMBOL_TYPE_TEXT,
		(void**)&data.make_config_hook);
	get_image_symbol(image, "GetConfigMessage", B_SYMBOL_TYPE_TEXT,
		(void**)&data.get_config_message_hook);

	return B_OK;
}
status_t
PrinterDriverAddOn::ConfigJob(BDirectory* spoolFolder, BMessage* settings)
{
	if (!IsLoaded())
		return B_ERROR;

	config_func_t func;
	status_t result = get_image_symbol(fAddOnID, "config_job",
		B_SYMBOL_TYPE_TEXT, (void**)&func);
	if (result != B_OK)
		return result;

	BMessage* newSettings = (*func)(spoolFolder, settings);
	result = CopyValidSettings(settings, newSettings);
	delete newSettings;

	return result;
}