예제 #1
0
Plugin *PluginFactory::getPlugin( Plugin::Type type )
{
    PluginList * list = getPluginList( type );
    if ( !list ) return 0;

    return list->first();
}
void
BlogPositiveMainView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kRemoveCurrentBlog:
			RemoveBlog();
			break;
		case kBlogSelected:
		{
			int32 current = fListView->CurrentSelection();
			if (current == -1)
				break;
			BlogPositiveBlogListItem* blit =
				static_cast<BlogPositiveBlogListItem*>(fListView->ItemAt(current));
			BlogPositiveBlog* blog = blit->Blog();
			BlogPositivePluginLoader::FindPlugin(blog);
			fDelegate->OpenPostList(blog);
			break;
		}
		case kCreateNewBlog:
		{
			int32 index = message->GetInt32("ding", 0);
			PluginList* pluginList = BlogPositivePluginLoader::List();
			BlogPositiveBlogPlugin* plugin
				= dynamic_cast<BlogPositiveBlogPlugin*>(pluginList->ItemAt(index));
			if(plugin)
				plugin->OpenNewBlogWindow(this);
			break;
		}
		default:
			BView::MessageReceived(message);
			break;
	}
}
예제 #3
0
FIMULTIBITMAP * DLL_CALLCONV
FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags) {
	try {
		BOOL read_only = FALSE;	// modifications (if any) will be stored into the memory cache

		if (io && handle) {

			// retrieve the plugin list to find the node belonging to this plugin
			PluginList *list = FreeImage_GetPluginList();

			if (list) {
				PluginNode *node = list->FindNodeFromFIF(fif);

				if (node) {
					std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
					std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
					std::auto_ptr<FreeImageIO> tmp_io (new FreeImageIO (*io));
					header->io = tmp_io.get();
					header->m_filename = NULL;
					header->node = node;
					header->fif = fif;
					header->handle = handle;
					header->changed = FALSE;
					header->read_only = read_only;	
					header->m_cachefile = NULL;
					header->cache_fif = fif;
					header->load_flags = flags;

					// store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure

					bitmap->data = header.get();

					// cache the page count

					header->page_count = FreeImage_InternalGetPageCount(bitmap.get());

					// allocate a continueus block to describe the bitmap

					header->m_blocks.push_back((BlockTypeS *)new BlockContinueus(0, header->page_count - 1));

					if (!read_only) {
						// set up the cache
						std::auto_ptr<CacheFile> cache_file (new CacheFile("", TRUE));
						
						if (cache_file->open()) {
							header->m_cachefile = cache_file.release();
						}
					}
					tmp_io.release();
					header.release();
					return bitmap.release();
				}
			}
		}
	} catch (std::bad_alloc &) {
		/** @todo report error */
	}
	return NULL;
}
예제 #4
0
FIMULTIBITMAP * DLL_CALLCONV
FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags) {
	// retrieve the plugin list to find the node belonging to this plugin

	PluginList *list = FreeImage_GetPluginList();

	if (list) {
		PluginNode *node = list->FindNodeFromFIF(fif);

		if (node) {
			FreeImageIO *io = new FreeImageIO;

			if (io) {
				SetMemoryIO(io);

				FIMULTIBITMAP *bitmap = new FIMULTIBITMAP;

				if (bitmap) {
					MULTIBITMAPHEADER *header = new MULTIBITMAPHEADER;

					header->m_filename = NULL;
					header->node = node;
					header->fif = fif;
					header->io = io;
					header->handle = (fi_handle)stream;						
					header->changed = FALSE;						
					header->read_only = TRUE;
					header->m_cachefile = NULL;
					header->cache_fif = fif;
					header->load_flags = flags;

					if (header) {
						// store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure

						bitmap->data = header;

						// cache the page count

						header->page_count = FreeImage_InternalGetPageCount(bitmap);

						// allocate a continueus block to describe the bitmap

						header->m_blocks.push_back((BlockTypeS *)new BlockContinueus(0, header->page_count - 1));

						// set up the cache

						return bitmap;
					}
					
					return NULL;
				}
			}

			delete io;
		}
	}

	return NULL;
}
// Calls OnShutdown() on all plugins.
void PluginRegistry::NotifyShutdown()
{
	while (!basic_plugins.empty())
	{
		basic_plugins.back()->OnShutdown();
		basic_plugins.pop_back();
	}
	document_plugins.clear();
	element_plugins.clear();
}
void PluginRegistry::RegisterPlugin(Plugin* plugin)
{
	int event_classes = plugin->GetEventClasses();
	
	if (event_classes & Plugin::EVT_BASIC)
		basic_plugins.push_back(plugin);
	if (event_classes & Plugin::EVT_DOCUMENT)
		document_plugins.push_back(plugin);
	if (event_classes & Plugin::EVT_ELEMENT)
		element_plugins.push_back(plugin);
}
예제 #7
0
FIMULTIBITMAP * DLL_CALLCONV
FreeImage_LoadMultiBitmapFromMemory(FREE_IMAGE_FORMAT fif, FIMEMORY *stream, int flags) {
	BOOL read_only = FALSE;	// modifications (if any) will be stored into the memory cache

	// retrieve the plugin list to find the node belonging to this plugin

	PluginList *list = FreeImage_GetPluginList();

	if (list) {
		PluginNode *node = list->FindNodeFromFIF(fif);

		if (node) {

				FIMULTIBITMAP *bitmap = new(std::nothrow) FIMULTIBITMAP;

				if (bitmap) {
					MULTIBITMAPHEADER *header = new(std::nothrow) MULTIBITMAPHEADER;

					if (header) {
						header->node = node;
						header->fif = fif;
						SetMemoryIO(&header->io);
						header->handle = (fi_handle)stream;						
						header->read_only = read_only;
						header->cache_fif = fif;
						header->load_flags = flags;

						// store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure

						bitmap->data = header;

						// cache the page count

						header->page_count = FreeImage_InternalGetPageCount(bitmap);

						// allocate a continueus block to describe the bitmap
						
						header->m_blocks.push_back(PageBlock(BLOCK_CONTINUEUS, 0, header->page_count - 1));
						
						// no need to open cache - it is in-memory by default

						return bitmap;
					}
					
					delete bitmap;
				}

		}
	}

	return NULL;
}
예제 #8
0
PluginList PluginManager::loadedPlugins( const QString &category ) const
{
    PluginList result;

    for ( PluginManagerPrivate::InfoToPluginMap::ConstIterator it = _kpmp->loadedPlugins.constBegin();
          it != _kpmp->loadedPlugins.constEnd(); ++it )
    {
        if ( category.isEmpty() || it.key().category() == category )
            result.append( it.value() );
    }

    return result;
}
예제 #9
0
PluginManager::PluginList PluginManager::getPlugins ()
{
	PluginList retval;

	std::list<PythonPlugin>::iterator it = pythonPlugins_.begin();
	std::list<PythonPlugin>::iterator end = pythonPlugins_.end();
	for (; it != end; ++it) {
		retval.push_back (&(*it));
	}

	retval.push_back (&crossref_);
	retval.push_back (&arxiv_);

	return retval;
}
예제 #10
0
FIMULTIBITMAP * DLL_CALLCONV
FreeImage_OpenMultiBitmapFromHandle(FREE_IMAGE_FORMAT fif, FreeImageIO *io, fi_handle handle, int flags) {
	try {
		BOOL read_only = FALSE;	// modifications (if any) will be stored into the memory cache

		if (io && handle) {
		
			// retrieve the plugin list to find the node belonging to this plugin
			PluginList *list = FreeImage_GetPluginList();
		
			if (list) {
				PluginNode *node = list->FindNodeFromFIF(fif);
			
				if (node) {
					std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
					std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
					header->io = *io;
					header->node = node;
					header->fif = fif;
					header->handle = handle;						
					header->read_only = read_only;	
					header->cache_fif = fif;
					header->load_flags = flags;
							
					// store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure

					bitmap->data = header.get();

					// cache the page count

					header->page_count = FreeImage_InternalGetPageCount(bitmap.get());

					// allocate a continueus block to describe the bitmap
					
					header->m_blocks.push_back(PageBlock(BLOCK_CONTINUEUS, 0, header->page_count - 1));
					
					// no need to open cache - it is in-memory by default

					header.release();
					return bitmap.release();
				}
			}
		}
	} catch (std::bad_alloc &) {
		/** @todo report error */
	}
	return NULL;
}
  void PluginRegistry::add_path (std::string const& path)
  {
      visual_log (VISUAL_LOG_INFO, "Adding to plugin search path: %s", path.c_str());

      m_impl->plugin_paths.push_back (path);

      PluginList plugins;
      m_impl->get_plugins_from_dir (plugins, path);

      for (PluginList::iterator plugin = plugins.begin (), plugin_end = plugins.end ();
           plugin != plugin_end;
           ++plugin)
      {
          PluginList& list = m_impl->plugin_list_map[(*plugin)->info->type];
          list.push_back (*plugin);
      }
  }
예제 #12
0
    bool Session::sessionAccept( const PluginList& plugins )
    {
      if( plugins.empty() || m_state != Pending )
        return false;

      m_state = Active;
      return doAction( SessionAccept, plugins );
    }
예제 #13
0
 /**
  * We override this function in FilePluginProvider to allow the single
  * plugin method to create a non-fragmenting memory allocation. We take
  * the plugins found and tell the memory manager to allocate space for
  * them.
  */
PluginList ELFPluginProvider::getPlugins() {
	PluginList pl = FilePluginProvider::getPlugins();

#if defined(UNCACHED_PLUGINS) && !defined(ELF_NO_MEM_MANAGER)
	// This static downcast is safe because all of the plugins must
	// be ELF plugins
	for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) {
		(static_cast<ELFPlugin *>(*p))->trackSize();
	}

	// The Memory Manager should now allocate space based on the information
	// it collected
	ELFMemMan.allocateHeap();
#endif

	return pl;
}
예제 #14
0
    bool Session::sessionInitiate( const PluginList& plugins )
    {
      if( plugins.empty() || !m_initiator || m_state >= Pending )
        return false;

      m_state = Pending;
      return doAction( SessionInitiate, plugins );
    }
        void Application::Terminate()
        {
            BOOST_ASSERT( m_IsInitialized == true );

            // Terminate the subsystems in the opposite order as they were registered.
            SubsystemList::reverse_iterator iter = m_Subsystems.rbegin();
            while ( iter != m_Subsystems.rend() )
            {
                SubsystemPtr subsystem = (*iter);
                subsystem->Terminate();

                ++iter;
            }

            m_Subsystems.clear();

            // Unload any previously loaded plug-ins
            PluginList plugins = m_Plugins;
            PluginList::iterator pluginIter = plugins.begin();
            while ( pluginIter != plugins.end() )
            {
                PluginPtr plugin = (*pluginIter);
                plugin->Terminate();

                UnloadPlugin( plugin );
                ++pluginIter;
            }

            plugins.clear();
            m_PluginsByName.clear();
            m_PluginsByFileName.clear();
            m_Plugins.clear();

            // Flush all the libraries.  At this point
            // there should be no residual pointers to objects
            // created in the library.
            m_DynamicLibSubsystem->Flush();

            m_IsInitialized = false;

            OnTerminated( EventArgs( *this ) );
        }
BlogPositiveMainView::BlogPositiveMainView(const char* name,
	BlogPositiveMainDelegate* del)
	:
	BView(name, 0)
{
	fDelegate = del;

	fListView = new BlogPositiveBlogListView();
	fListView->SetInvocationMessage(new BMessage(kBlogSelected));

	fMenuBar = new BMenuBar("MenuBar");

	fNewMenu = new BMenu(B_TRANSLATE("Add Blog"));
	fMenuBar->AddItem(fNewMenu);

	PluginList* pluginList = BlogPositivePluginLoader::List();

	fListView->Reload(gBlogList);

	for (int i = 0; i < pluginList->CountItems(); i++) {
		BlogPositivePlugin* pl = pluginList->ItemAt(i);
		if (dynamic_cast<BlogPositiveBlogPlugin*>(pl)) {
			BMessage* msg = new BMessage(kCreateNewBlog);
			msg->SetInt32("ding", i);
			msg->SetString("sendToView", Name());
			BMenuItem* mi = new BMenuItem(pl->Name(), msg);
			fNewMenu->AddItem(mi);
		}
	}

	BMessage* aMenuItemMessage = new BMessage(kRemoveCurrentBlog);
	fRemoveMenuItem = new BMenuItem(B_TRANSLATE("Remove blog"), aMenuItemMessage);
	fMenuBar->AddItem(fRemoveMenuItem);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.Add(fMenuBar)
		.Add(new BScrollView("scroll_view", fListView, 0, false, true));
}
예제 #17
0
FIMULTIBITMAP * DLL_CALLCONV
FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory, int flags) {

	FILE *handle = NULL;
	try {
		// sanity check on the parameters

		if (create_new) {
			read_only = FALSE;
		}

		// retrieve the plugin list to find the node belonging to this plugin

		PluginList *list = FreeImage_GetPluginList();

		if (list) {
			PluginNode *node = list->FindNodeFromFIF(fif);

			if (node) {
				std::auto_ptr<FreeImageIO> io (new FreeImageIO);

				SetDefaultIO(io.get());

				if (!create_new) {
					handle = fopen(filename, "rb");
					if (handle == NULL) {
						return NULL;
					}
				}

				std::auto_ptr<FIMULTIBITMAP> bitmap (new FIMULTIBITMAP);
				std::auto_ptr<MULTIBITMAPHEADER> header (new MULTIBITMAPHEADER);
				header->m_filename = new char[strlen(filename) + 1];
				strcpy(header->m_filename, filename);
				header->node = node;
				header->fif = fif;
				header->io = io.get ();
				header->handle = handle;
				header->changed = FALSE;
				header->read_only = read_only;
				header->m_cachefile = NULL;
				header->cache_fif = fif;
				header->load_flags = flags;

				// store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure

				bitmap->data = header.get();

				// cache the page count

				header->page_count = FreeImage_InternalGetPageCount(bitmap.get());

				// allocate a continueus block to describe the bitmap

				if (!create_new) {
					header->m_blocks.push_back((BlockTypeS *)new BlockContinueus(0, header->page_count - 1));
				}

				// set up the cache

				if (!read_only) {
					std::string cache_name;
					ReplaceExtension(cache_name, filename, "ficache");

					std::auto_ptr<CacheFile> cache_file (new CacheFile(cache_name, keep_cache_in_memory));

					if (cache_file->open()) {
						// we can use release() as std::bad_alloc won't be thrown from here on
						header->m_cachefile = cache_file.release();
					} else {
						// an error occured ...
						fclose(handle);
						return NULL;
					}
				}
				// return the multibitmap
				// std::bad_alloc won't be thrown from here on
				header.release(); // now owned by bitmap
				io.release();	  // now owned by bitmap
				return bitmap.release(); // now owned by caller
			}
		}
	} catch (std::bad_alloc &) {
		/** @todo report error */
	}
	if (handle)
		fclose(handle);
	return NULL;
}
예제 #18
0
int text_cmd_plugin(ClientData cd, Tcl_Interp *interp, int argc,
                     const char *argv[]) {

  VMDApp *app = (VMDApp *)cd;
  if (!app) 
    return TCL_ERROR;

  // plugin dlopen <filename>
  if (argc == 3 && !strupncmp(argv[1], "dlopen", CMDLEN)) {
    int rc = app->plugin_dlopen(argv[2]);
    if (rc < 0) {
      Tcl_AppendResult(interp, "Unable to dlopen plugin file ", argv[2], NULL);
      return TCL_ERROR;
    } 
    Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
    return TCL_OK;
  }
  // plugin update  -- updates list of plugins
  if (argc == 2 && !strupncmp(argv[1], "update", CMDLEN)) {
    app->plugin_update();
    return TCL_OK;
  }

  // plugin list [type]: returns list of category/name pairs.  If optional
  // type is specified, return only plugins of that type.
  if ((argc == 2 || argc == 3) && !strupncmp(argv[1], "list", CMDLEN)) {
    const char *type = NULL;
    if (argc == 3)
      type = argv[2];
    
    PluginList pluginlist;
    app->list_plugins(pluginlist, type);
    const int num = pluginlist.num();
    Tcl_Obj *result = Tcl_NewListObj(0, NULL);
    for (int i=0; i<num; i++) {
      vmdplugin_t *p = pluginlist[i];
      Tcl_Obj *listelem = Tcl_NewListObj(0, NULL);
      Tcl_ListObjAppendElement(interp, listelem, Tcl_NewStringObj(p->type,-1));
      Tcl_ListObjAppendElement(interp, listelem, Tcl_NewStringObj(p->name,-1));
      Tcl_ListObjAppendElement(interp, result, listelem);
    }
    Tcl_SetObjResult(interp, result);
    return TCL_OK;
  }
  // plugin info <type> <name> <varname>
  // Puts plugin information for the specified plugin into the array variable
  // specified by varname.  The following array keys will be used: type,
  // name, author, majorversion, minorversion, reentrant.
  // returns 1 if plugin information was found, or 0 if no plugin information
  // is available for that type and name.
  if (argc == 5 && !strupncmp(argv[1], "info", CMDLEN)) {
    vmdplugin_t *p = app->get_plugin(argv[2], argv[3]);
    if (!p) {
      Tcl_SetResult(interp, (char *) "0", TCL_STATIC);
      return TCL_OK;
    }
    char major[32], minor[32], reentrant[32];
    sprintf(major, "%d", p->majorv);
    sprintf(minor, "%d", p->minorv);
    sprintf(reentrant, "%d", p->is_reentrant);

    if (!Tcl_SetVar2(interp,argv[4], "type", p->type, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "name", p->name, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "author", p->author, TCL_LEAVE_ERR_MSG)  ||
        !Tcl_SetVar2(interp,argv[4], "majorversion", major, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "minorversion", minor, TCL_LEAVE_ERR_MSG) ||
        !Tcl_SetVar2(interp,argv[4], "reentrant", reentrant, TCL_LEAVE_ERR_MSG)) {
      Tcl_AppendResult(interp, "Unable to return plugin information in variable ", argv[4], NULL);
      return TCL_ERROR;
    }
    Tcl_SetResult(interp, (char *) "1", TCL_STATIC);
    return TCL_OK;
  }
  Tcl_AppendResult(interp, "Usage: \n\tplugin dlopen <filename> -- Load plugins from a dynamic library\n",
      "\tplugin update -- Update the list of plugins in the GUI\n",
      "\tplugin list [<plugin type>] -- List all plugins of the given type\n", 
      "\tplugin info <type> <name> <arrayname> -- Store info about plugin in array\n",
      NULL);
  return TCL_ERROR;
}
// Calls OnDocumentLoad() on all plugins.
void PluginRegistry::NotifyDocumentLoad(ElementDocument* document)
{
	for (size_t i = 0; i < document_plugins.size(); ++i)
		document_plugins[i]->OnDocumentLoad(document);
}
// Calls OnDocumentOpen() on all plugins.
void PluginRegistry::NotifyDocumentOpen(Context* context, const String& document_path)
{
	for (size_t i = 0; i < document_plugins.size(); ++i)
		document_plugins[i]->OnDocumentOpen(context, document_path);
}
// Calls OnContextDestroy() on all plugins.
void PluginRegistry::NotifyContextDestroy(Context* context)
{
	for (size_t i = 0; i < basic_plugins.size(); ++i)
		basic_plugins[i]->OnContextDestroy(context);
}
예제 #22
0
 bool Session::doAction( Action action, const Plugin* plugin )
 {
   PluginList pl;
   pl.push_back( plugin );
   return doAction( action, pl );
 }
예제 #23
0
파일: plugin.cpp 프로젝트: 87maxi/oom
void initPlugins(bool ladspa, bool lv2, bool vst)
{
    //ladspa = vst = false;

    // LADSPA
    if (ladspa)
    {
        fprintf(stderr, "Looking up LADSPA plugins...\n");

		QStringList ladspaPathList;
#ifdef __WINDOWS__
        // TODO - look for ladspa in known locations
#else
        const char* ladspaPath = getenv("LADSPA_PATH");
        if (ladspaPath == 0)
		{
			ladspaPathList = config.ladspaPaths.split(":");//"/usr/local/lib64/ladspa:/usr/lib64/ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa";
        }
		else
			ladspaPathList = QString(ladspaPath).split(":");
#endif

        foreach(QString s, ladspaPathList)
            loadPluginDir(s, PLUGIN_LADSPA);
    }

    if (lv2)
    {
        fprintf(stderr, "Looking up LV2 plugins...\n");
        initLV2();
    }

    if (vst)
    {
        // TODO
        fprintf(stderr, "Looking up VST plugins...\n");

        QStringList vstPathList;
#ifdef __WINDOWS__
        // TODO - look for vst in known locations
#else
        const char* vstPath = getenv("VST_PATH");
        if (vstPath == 0)
		{
			if(debugMsg)
				qDebug("from config VST_PATH: %s", config.vstPaths.toUtf8().constData());
			vstPathList = config.vstPaths.split(":");
		}
		else
		{
			 vstPathList = QString(vstPath).split(":");
			if(debugMsg)
				qDebug("from env VST_PATH: %s", vstPath);
		}
			//"/usr/local/lib64/vst:/usr/lib64/vst:/usr/local/lib/vst:/usr/lib/vst";
#endif

        foreach (QString s, vstPathList)
            loadPluginDir(s, PLUGIN_VST);
    }

    // Add the synth plugins to the midi-device list
    for (iPlugin i = plugins.begin(); i != plugins.end(); ++i)
    {
        if (i->hints() & PLUGIN_IS_SYNTH)
        {
            SynthPluginDevice* dev = new SynthPluginDevice(i->type(), i->filename(true), i->name(), i->label());
            midiDevices.add(dev);
        }
    }
}
namespace Core {

typedef std::vector< Plugin* > PluginList;
static PluginList basic_plugins;
static PluginList document_plugins;
static PluginList element_plugins;

PluginRegistry::PluginRegistry()
{
}

void PluginRegistry::RegisterPlugin(Plugin* plugin)
{
	int event_classes = plugin->GetEventClasses();
	
	if (event_classes & Plugin::EVT_BASIC)
		basic_plugins.push_back(plugin);
	if (event_classes & Plugin::EVT_DOCUMENT)
		document_plugins.push_back(plugin);
	if (event_classes & Plugin::EVT_ELEMENT)
		element_plugins.push_back(plugin);
}

// Calls OnInitialise() on all plugins.
void PluginRegistry::NotifyInitialise()
{
	for (size_t i = 0; i < basic_plugins.size(); ++i)
		basic_plugins[i]->OnInitialise();
}

// Calls OnShutdown() on all plugins.
void PluginRegistry::NotifyShutdown()
{
	while (!basic_plugins.empty())
	{
		basic_plugins.back()->OnShutdown();
		basic_plugins.pop_back();
	}
	document_plugins.clear();
	element_plugins.clear();
}

// Calls OnContextCreate() on all plugins.
void PluginRegistry::NotifyContextCreate(Context* context)
{
	for (size_t i = 0; i < basic_plugins.size(); ++i)
		basic_plugins[i]->OnContextCreate(context);
}

// Calls OnContextDestroy() on all plugins.
void PluginRegistry::NotifyContextDestroy(Context* context)
{
	for (size_t i = 0; i < basic_plugins.size(); ++i)
		basic_plugins[i]->OnContextDestroy(context);
}

// Calls OnDocumentOpen() on all plugins.
void PluginRegistry::NotifyDocumentOpen(Context* context, const String& document_path)
{
	for (size_t i = 0; i < document_plugins.size(); ++i)
		document_plugins[i]->OnDocumentOpen(context, document_path);
}

// Calls OnDocumentLoad() on all plugins.
void PluginRegistry::NotifyDocumentLoad(ElementDocument* document)
{
	for (size_t i = 0; i < document_plugins.size(); ++i)
		document_plugins[i]->OnDocumentLoad(document);
}

// Calls OnDocumentUnload() on all plugins.
void PluginRegistry::NotifyDocumentUnload(ElementDocument* document)
{
	for (size_t i = 0; i < document_plugins.size(); ++i)
		document_plugins[i]->OnDocumentUnload(document);
}

// Calls OnElementCreate() on all plugins.
void PluginRegistry::NotifyElementCreate(Element* element)
{
	for (size_t i = 0; i < element_plugins.size(); ++i)
		element_plugins[i]->OnElementCreate(element);
}

// Calls OnElementDestroy() on all plugins.
void PluginRegistry::NotifyElementDestroy(Element* element)
{
	for (size_t i = 0; i < element_plugins.size(); ++i)
		element_plugins[i]->OnElementDestroy(element);
}

}
// Calls OnElementDestroy() on all plugins.
void PluginRegistry::NotifyElementDestroy(Element* element)
{
	for (size_t i = 0; i < element_plugins.size(); ++i)
		element_plugins[i]->OnElementDestroy(element);
}
  void PluginRegistry::Impl::get_plugins_from_dir (PluginList& list, std::string const& dir)
  {
      list.clear ();

#if defined(VISUAL_OS_WIN32)
      std::string pattern = dir + "/*";

      WIN32_FIND_DATA file_data;
      HANDLE hList = FindFirstFile (pattern.c_str (), &file_data);

      if (hList == INVALID_HANDLE_VALUE) {
          FindClose (hList);
          return;
      }

      bool finished = false;

      while (!finished) {
          if (!(file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
              std::string full_path = dir + "/" + file_data.cFileName;

              if (str_has_suffix (full_path, ".dll")) {
                  PluginRef* ref = load_plugin_ref (full_path);

                  if (ref) {
                      list.push_back (ref);
                  }
              }
          }

          if (!FindNextFile (hList, &file_data)) {
              if (GetLastError () == ERROR_NO_MORE_FILES) {
                  finished = true;
              }
          }
      }

      FindClose (hList);
#else
      // NOTE: This typecast is needed for glibc versions that define
      // alphasort() as taking const void * arguments

      typedef int (*ScandirCompareFunc) (const struct dirent **, const struct dirent **);

      struct dirent **namelist;

      int n = scandir (dir.c_str (), &namelist, NULL, ScandirCompareFunc (alphasort));
      if (n < 0)
          return;

      // First two entries are '.' and '..'
      visual_mem_free (namelist[0]);
      visual_mem_free (namelist[1]);

      for (int i = 2; i < n; i++) {
          std::string full_path = dir + "/" + namelist[i]->d_name;

          if (str_has_suffix (full_path, ".so")) {
              PluginRef* ref = load_plugin_ref (full_path);

              if (ref) {
                  list.push_back (ref);
              }
          }

          visual_mem_free (namelist[i]);
      }

      visual_mem_free (namelist);

#endif
  }
예제 #27
0
BOOL DLL_CALLCONV
FreeImage_SaveMultiBitmapToHandle(FREE_IMAGE_FORMAT fif, FIMULTIBITMAP *bitmap, FreeImageIO *io, fi_handle handle, int flags) {
	if(!bitmap || !bitmap->data || !io || !handle) {
		return FALSE;
	}

	BOOL success = TRUE;

	// retrieve the plugin list to find the node belonging to this plugin
	PluginList *list = FreeImage_GetPluginList();
	
	if (list) {
		PluginNode *node = list->FindNodeFromFIF(fif);

		if(node) {
			MULTIBITMAPHEADER *header = FreeImage_GetMultiBitmapHeader(bitmap);
			
			// dst data
			void *data = FreeImage_Open(node, io, handle, FALSE);
			// src data
			void *data_read = NULL;
			
			if(header->handle) {
				// open src
				header->io->seek_proc(header->handle, 0, SEEK_SET);
				data_read = FreeImage_Open(header->node, header->io, header->handle, TRUE);
			}
			
			// write all the pages to the file using handle and io
			
			int count = 0;
			
			for (BlockListIterator i = header->m_blocks.begin(); i != header->m_blocks.end(); i++) {
				if (success) {
					switch((*i)->m_type) {
						case BLOCK_CONTINUEUS:
						{
							BlockContinueus *block = (BlockContinueus *)(*i);
							
							for (int j = block->m_start; j <= block->m_end; j++) {

								// load the original source data
								FIBITMAP *dib = header->node->m_plugin->load_proc(header->io, header->handle, j, header->load_flags, data_read);
								
								// save the data
								success = node->m_plugin->save_proc(io, dib, handle, count, flags, data);
								count++;
								
								FreeImage_Unload(dib);
							}
							
							break;
						}
						
						case BLOCK_REFERENCE:
						{
							BlockReference *ref = (BlockReference *)(*i);
							
							// read the compressed data
							
							BYTE *compressed_data = (BYTE*)malloc(ref->m_size * sizeof(BYTE));
							
							header->m_cachefile->readFile((BYTE *)compressed_data, ref->m_reference, ref->m_size);
							
							// uncompress the data
							
							FIMEMORY *hmem = FreeImage_OpenMemory(compressed_data, ref->m_size);
							FIBITMAP *dib = FreeImage_LoadFromMemory(header->cache_fif, hmem, 0);
							FreeImage_CloseMemory(hmem);
							
							// get rid of the buffer
							free(compressed_data);
							
							// save the data
							
							success = node->m_plugin->save_proc(io, dib, handle, count, flags, data);
							count++;
							
							// unload the dib

							FreeImage_Unload(dib);

							break;
						}
					}
				} else {
					break;
				}
			}
			
			// close the files
			
			FreeImage_Close(header->node, header->io, header->handle, data_read);

			FreeImage_Close(node, io, handle, data); 
			
			return success;
		}
	}

	return FALSE;
}
예제 #28
0
파일: plugin.cpp 프로젝트: 87maxi/oom
static void loadPluginLib(QFileInfo* fi, const PluginType t)
{
    if (debugMsg)
        qWarning("looking up %s", fi->filePath().toAscii().constData());

    void* handle = lib_open(fi->filePath().toAscii().constData());
	if (handle == 0)
	{
		fprintf(stderr, "dlopen(%s) failed: %s\n",
				fi->filePath().toAscii().constData(), dlerror());
		return;
	}

    if (t == PLUGIN_LADSPA)
	{
        LADSPA_Descriptor_Function ladspa = (LADSPA_Descriptor_Function) lib_symbol(handle, "ladspa_descriptor");
		if (!ladspa)
		{
			const char *txt = dlerror();
			if (txt)
			{
				fprintf(stderr,
						"Unable to find ladspa_descriptor() function in plugin "
						"library file \"%s\": %s.\n"
						"Are you sure this is a LADSPA plugin file?\n",
						fi->filePath().toAscii().constData(),
						txt);
			}
            lib_close(handle);
			return;
		}

		const LADSPA_Descriptor* descr;
		for (int i = 0;; ++i)
		{
			descr = ladspa(i);
			if (descr == NULL)
				break;

			// Make sure it doesn't already exist.
			if (plugins.find(fi->completeBaseName(), QString(descr->Label)) != 0)
				continue;

#ifdef PLUGIN_DEBUGIN
			fprintf(stderr, "loadPluginLib: ladspa effect name:%s inPlaceBroken:%d\n", descr->Name, LADSPA_IS_INPLACE_BROKEN(descr->Properties));
#endif
            plugins.add(PLUGIN_LADSPA, fi->absoluteFilePath(), QString(descr->Label), descr);
		}
	}
    else if (t == PLUGIN_VST)
    {
        VST_Function vstfn = (VST_Function) lib_symbol(handle, "VSTPluginMain");

        if (! vstfn)
        {
            vstfn = (VST_Function) lib_symbol(handle, "main");

    #ifdef TARGET_API_MAC_CARBON
            if (! vstfn)
                vstfn = (VST_Function)lib_symbol(lib_handle, "main_macho");
    #endif
        }

        if (! vstfn)
        {
            const char *txt = dlerror();
            if (txt)
            {
                fprintf(stderr,
                        "Unable to find vst entry function in plugin "
                        "library file \"%s\": %s.\n"
                        "Are you sure this is a VST plugin file?\n",
                        fi->filePath().toAscii().constData(),
                        txt);
            }
            lib_close(handle);
            return;
        }

        AEffect* effect = vstfn(VstHostCallback);

        if (effect && (effect->flags & effFlagsCanReplacing) > 0)
        {
            QString PluginLabel = fi->baseName();

            char buf_str[255] = { 0 };
            effect->dispatcher(effect, effOpen, 0, 0, 0, 0.0f);
            effect->dispatcher(effect, effGetProductString, 0, 0, buf_str, 0.0f);

            if (buf_str[0] != 0)
                PluginLabel = QString(buf_str);

            // Make sure it doesn't already exist.
            if (plugins.find(fi->completeBaseName(), QString(PluginLabel)) == 0)
            {
                plugins.add(PLUGIN_VST, fi->absoluteFilePath(), PluginLabel, effect);
            }

            effect->dispatcher(effect, effClose, 0, 0, 0, 0.0f);
        }
    }

    lib_close(handle);
}
예제 #29
0
FIMULTIBITMAP * DLL_CALLCONV
FreeImage_OpenMultiBitmap(FREE_IMAGE_FORMAT fif, const char *filename, BOOL create_new, BOOL read_only, BOOL keep_cache_in_memory, int flags) {
	// sanity check on the parameters

	if (create_new)
		read_only = FALSE;

	// retrieve the plugin list to find the node belonging to this plugin

	PluginList *list = FreeImage_GetPluginList();

	if (list) {
		PluginNode *node = list->FindNodeFromFIF(fif);

		if (node) {
			FreeImageIO *io = new FreeImageIO;

			if (io) {
				SetDefaultIO(io);

				BOOL cont = TRUE;

				FILE *handle = NULL;

				if (!create_new) {
					handle = fopen(filename, "rb");

					if (handle == NULL) {
						cont = FALSE;
					}
				}

				if (cont) {
					FIMULTIBITMAP *bitmap = new FIMULTIBITMAP;

					if (bitmap) {
						MULTIBITMAPHEADER *header = new MULTIBITMAPHEADER;

						header->m_filename = new char[strlen(filename) + 1];
						strcpy(header->m_filename, filename);
						header->node = node;
						header->fif = fif;
						header->io = io;
						header->handle = handle;						
						header->changed = FALSE;						
						header->read_only = read_only;
						header->m_cachefile = NULL;
						header->cache_fif = fif;
						header->load_flags = flags;

						if (header) {
							// store the MULTIBITMAPHEADER in the surrounding FIMULTIBITMAP structure

							bitmap->data = header;

							// cache the page count

							header->page_count = FreeImage_InternalGetPageCount(bitmap);

							// allocate a continueus block to describe the bitmap

							if (!create_new)
								header->m_blocks.push_back((BlockTypeS *)new BlockContinueus(0, header->page_count - 1));

							// set up the cache

							if (!read_only) {
								char cache_name[256];
								ReplaceExtension(cache_name, filename, "ficache");

								CacheFile *cache_file = new CacheFile(cache_name, keep_cache_in_memory);

								if (cache_file->open()) {
									header->m_cachefile = cache_file;

									// return the multibitmap

									return bitmap;
								}

								delete cache_file;
								delete header;
							}

							return bitmap;
						}
						
						return NULL;
					}
				}
			}

			delete io;
		}
	}

	return NULL;
}
// Calls OnInitialise() on all plugins.
void PluginRegistry::NotifyInitialise()
{
	for (size_t i = 0; i < basic_plugins.size(); ++i)
		basic_plugins[i]->OnInitialise();
}