Beispiel #1
0
list<string> SinkPluginHandler::listSinkPlugins() {
    const list<string> plugin_list = listPlugins();
    list<string> sink_list;
    for (list<string>::const_iterator i = plugin_list.begin(); i != plugin_list.end(); i++)
        if (i->length() > 5 && i->substr(i->length()-5,5) == "_sink")
            sink_list.push_back(i->substr(0,i->length()-5));
    sink_list.push_back("auto");
    sink_list.push_back("void");
    return sink_list;
}
QWidget *OptionsTabPlugins::widget()
{
	if ( w )
		return 0;

	w = new OptPluginsUI();
	OptPluginsUI *d = (OptPluginsUI *)w;

	listPlugins();
	connect(d->tw_Plugins, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));

	return w;
}
QWidget *OptionsTabPlugins::widget()
{
	if ( w )
		return 0;

	w = new OptPluginsUI();
	OptPluginsUI *d = (OptPluginsUI *)w;

	d->pb_info->setIcon(QIcon(IconsetFactory::iconPixmap("psi/info")));
	d->cb_plugins->setMaxVisibleItems(50);
	d->cb_loadPlugin->setProperty("isOption", false);

	listPlugins();

	connect(d->cb_plugins,SIGNAL(currentIndexChanged(int)),SLOT(pluginSelected(int)));
	connect(d->cb_loadPlugin,SIGNAL(clicked(bool)),SLOT(loadToggled(bool)));
	connect(d->pb_info, SIGNAL(clicked()), SLOT(showPluginInfo()));

	return w;
}
Beispiel #4
0
int
main(const int iArgc, const char ** ppcArgv) {
    return listPlugins();
}
void S3D_PLUGIN_MANAGER::loadPlugins( void )
{
    std::list< wxString > searchpaths;
    std::list< wxString > pluginlist;
    wxFileName fn;

#ifndef __WXMAC__

    #ifdef DEBUG
    // set up to work from the build directory
    fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
    fn.AppendDir( wxT("..") );
    fn.AppendDir( wxT("plugins") );
    fn.AppendDir( wxT("3d") );

    std::string testpath = std::string( fn.GetPathWithSep().ToUTF8() );
    checkPluginPath( testpath, searchpaths );
    #endif

    #ifndef _WIN32  // suppress 'kicad' subdir since it is redundant on MSWin
    fn.Assign( wxStandardPaths::Get().GetPluginsDir(), "" );
    fn.RemoveLastDir();
    fn.AppendDir( wxT( "kicad" ) );
    #else
        fn.Assign( wxStandardPaths::Get().GetExecutablePath() );
    #endif

    fn.AppendDir( wxT( "plugins" ) );
    fn.AppendDir( wxT( "3d" ) );
    checkPluginPath( std::string( fn.GetPathWithSep().ToUTF8() ), searchpaths );

    checkPluginPath( wxT( "/usr/lib/kicad/plugins/3d" ), searchpaths );
    checkPluginPath( wxT( "/usr/local/lib/kicad/plugins/3d" ), searchpaths );
    checkPluginPath( wxT( "/opt/kicad/lib/kicad/plugins/3d" ), searchpaths );

    // note: GetUserDataDir() gives '.pcbnew' rather than '.kicad' since it uses the exe name;
    fn.Assign( wxStandardPaths::Get().GetUserDataDir(), "" );
    fn.RemoveLastDir();
    #ifdef _WIN32
    fn.AppendDir( wxT( "kicad" ) );
    #else
    fn.AppendDir( wxT( ".kicad" ) );
    #endif
    fn.AppendDir( wxT( "plugins" ) );
    fn.AppendDir( wxT( "3d" ) );
    checkPluginPath( fn.GetPathWithSep(), searchpaths );

#else

   // Search path on OS X is
   // (1) User     ~/Library/Application Support/kicad/PlugIns/3d
   checkPluginPath( GetOSXKicadUserDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
   // (2) Machine  /Library/Application Support/kicad/PlugIns/3d
   checkPluginPath( GetOSXKicadMachineDataDir() + wxT( "/PlugIns/3d" ), searchpaths );
   // (3) Bundle   kicad.app/Contents/PlugIns/3d
   fn.Assign( Pgm().GetExecutablePath() );
   fn.AppendDir( wxT( "Contents" ) );
   fn.AppendDir( wxT( "PlugIns" ) );
   fn.AppendDir( wxT( "3d" ) );
   checkPluginPath( fn.GetPathWithSep(), searchpaths );

#endif

    std::list< wxString >::iterator sPL = searchpaths.begin();
    std::list< wxString >::iterator ePL = searchpaths.end();

    while( sPL != ePL )
    {
#ifdef DEBUG
        do {
            std::ostringstream ostr;
            ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
            ostr << " * [DEBUG] searching path: '" << (*sPL).ToUTF8() << "'";
            wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
        } while( 0 );
#endif
        listPlugins( *sPL, pluginlist );
        ++sPL;
    }

    if( pluginlist.empty() )
        return;

    sPL = pluginlist.begin();
    ePL = pluginlist.end();

    while( sPL != ePL )
    {
        KICAD_PLUGIN_LDR_3D* pp = new KICAD_PLUGIN_LDR_3D;

        if( pp->Open( sPL->ToUTF8() ) )
        {
#ifdef DEBUG
            do {
                std::ostringstream ostr;
                ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
                ostr << "* [DEBUG] adding plugin";
                wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
            } while( 0 );
#endif
            m_Plugins.push_back( pp );
            int nf = pp->GetNFilters();

            #ifdef DEBUG
            do {
                std::ostringstream ostr;
                ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
                ostr << " * [INFO] adding " << nf << " filters";
                wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
            } while( 0 );
            #endif

            for( int i = 0; i < nf; ++i )
            {
                char const* cp = pp->GetFileFilter( i );

                if( cp )
                    addFilterString( wxString::FromUTF8Unchecked( cp ) );
            }

            addExtensionMap( pp );

            // close the loaded library
            pp->Close();
        }
        else
        {
#ifdef DEBUG
            do {
                std::ostringstream ostr;
                ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
                ostr << "* [DEBUG] deleting plugin";
                wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
            } while( 0 );
#endif
            delete pp;
        }

        ++sPL;
    }

#ifdef DEBUG
    do {
        std::ostringstream ostr;
        ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << ":\n";
        ostr << "* [DEBUG] plugins loaded";
        wxLogTrace( MASK_3D_PLUGINMGR, "%s\n", ostr.str().c_str() );
    } while( 0 );
#endif

    return;
}