Esempio n. 1
0
void CPlugins::startPlugin(const char * const name)
{
	int pluginnr = find_plugin(name);
	if (pluginnr > -1)
		startPlugin(pluginnr,0);
	else
		printf("[CPlugins] could not find %s\n", name);

}
Esempio n. 2
0
void CPlugins::start_plugin_by_name(const std::string & filename)
{
	for (int i = 0; i <  (int) plugin_list.size(); i++)
	{
		if (filename.compare(g_PluginList->getName(i))==0)
		{
			startPlugin(i);
			return;
		}
	}
}
Esempio n. 3
0
void CPlugins::startPlugin(const char * const name)
{
	int pluginnr = find_plugin(name);
	if (pluginnr > -1)
		startPlugin(pluginnr);
	else
	{
		dprintf(DEBUG_NORMAL, "[CPlugins] could not find %s\n", name);
		
		std::string hint = name;
		hint += " ";
		hint += g_Locale->getText(LOCALE_PLUGINS_NOT_INSTALLED);
		
		HintBox(LOCALE_MESSAGEBOX_INFO, hint.c_str());
	}

}
Esempio n. 4
0
int Vst::loadPlugin(std::string pathOnDisk)
{
    int error = 0;
    
    plugin = nullptr;
    
    CFStringRef pluginPathReference = CFStringCreateWithCString(nullptr, pathOnDisk.c_str(), kCFStringEncodingASCII);
    CFURLRef bundleUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pluginPathReference, kCFURLPOSIXPathStyle, true);
    
    if(bundleUrl == nullptr)
    {
        std::cout<<"Could't find reference to VST URL. It might not exist, or the path is wrong."<<std::endl;
        return -1;
    }
    
    CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, bundleUrl);
    if(bundle == nullptr)
    {
        std::cout<<"Couldn't create VST Bundle reference. It might not be a VST, or corrupted"<<std::endl;
        CFRelease(bundleUrl);
        CFRelease(bundle);
        return -1;
    }
    
    VSTPlugin = (vstPluginFuncPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("VSTPluginMain"));
    
    plugin = VSTPlugin(hostCallback);
    
    if(plugin == nullptr)
    {
        std::cout<<"Couldn't create VST Main Entry Point"<<std::endl;
        CFBundleUnloadExecutable(bundle);
        CFRelease(bundle);
        return -1;
    }
    
    CFRelease(pluginPathReference);
    CFRelease(bundleUrl);
    
    error = configureCallbacks();
    error = startPlugin();
    
    return error;
}
Esempio n. 5
0
/*!
  Processes the command line arguments.  It first checks to make sure the
  GRASPIT environment variable is set, then if this is run under X11 it
  examines the command line.  The usage is the following:
\p graspit \p [-w worldname] \p [-r robotname] \p [-o objectname]
\p [-b obstaclename]
*/
int
GraspItGUI::processArgs(int argc, char** argv)
{
  QString filename;
  int errflag=0; 
  errflag = errflag;
  QString graspitRoot = QString(getenv("GRASPIT"));
  if (graspitRoot.isNull() ) {
    std::cerr << "Please set the GRASPIT environment variable to the root directory of graspIt." << std::endl;
    return FAILURE;
  }

  //look for plugins of the form plugin:name in the arguments
  for (int i=1; i<argc; i++) {
    QString arg(argv[i]);
    if (arg.section(',',0,0)=="plugin") {
      QString libName = arg.section(',',1,1);
	  std::cout << "Processing arguments \n ";
      PluginCreator* creator = PluginCreator::loadFromLibrary(libName.toStdString());	  
      if (creator) {
        mPluginCreators.push_back(creator);
      } else {
        DBGA("Failed to load plugin: " << libName.latin1());
      }
    }
  }
  
  //start any plugins with auto start enabled
  mPluginSensor = new SoIdleSensor(GraspItGUI::sensorCB, (void*)this);
  for (size_t i=0; i<mPluginCreators.size(); i++) {
	  std::cout << "plugin creator autostart " << mPluginCreators[i]->autoStart() << std::endl;
    if (mPluginCreators[i]->autoStart()) {
      startPlugin(mPluginCreators[i], mPluginCreators[i]->defaultArgs());
    }    
  }
  
  if(argc > 1){
#ifdef CGDB_ENABLED
	  if(!strcmp(argv[1],"dbase")){
		  DBaseBatchPlanner *dbp = new DBaseBatchPlanner(graspItGUI->getIVmgr(), this);
		  dbp->processArguments(argc, argv);
		  dbp->startPlanner();
	  }
	  if (!strcmp(argv[1],"db_dispatch")) {
		  mDispatch = new TaskDispatcher();
		  if (mDispatch->connect("wgs36",5432,"willow","willow","household_objects")) {
			  std::cerr << "DBase dispatch failed to connect to database\n";
			  return TERMINAL_FAILURE;
		  }
		  std::cerr << "DBase dispatch connected to database\n";
		  mDispatch->mainLoop();
		  if (mDispatch->getStatus() != TaskDispatcher::RUNNING) {
			  mExitCode = mDispatch->getStatus();
			  return TERMINAL_FAILURE;
		  }
	  }
#endif
  }
 
#ifdef Q_WS_X11
  char c;
  while((c=getopt(argc, argv, "r:w:o:b:")) != EOF) {
    switch(c) {
    case 'r':
      filename = graspitRoot + QString("/models/robots/")+
	QString(optarg) + QString("/") + QString(optarg) + QString(".cfg");
      if (ivmgr->getWorld()->importRobot(filename)==NULL)
	++errflag;
      break;
    case 'w':
      filename = graspitRoot + QString("/worlds/")+ QString(optarg) +
	QString(".wld");
      if (ivmgr->getWorld()->load(filename)==FAILURE)
	++errflag;
      else
	mainWindow->mUI->worldBox->setTitle(filename);
      break;
    case 'o':
      filename = graspitRoot + QString("/models/objects/")+ QString(optarg) +
	QString(".iv");
      if (!ivmgr->getWorld()->importBody("GraspableBody",filename))
	++errflag;
      break;
    case 'b':
      filename = graspitRoot + QString("/models/obstacles/")+ QString(optarg) +
	QString(".iv");
      if (!ivmgr->getWorld()->importBody("Body",filename))
	++errflag;
      break;
    default: 
      ++errflag;
      break;
    }
  }
  if (errflag) {
    std::cerr << "Usage: graspit [-w worldname] [-r robotname] [-o objectname] [-b obstaclename]" << std::endl;
    return FAILURE;
  }
#endif
  return SUCCESS;
}
Esempio n. 6
0
ctkPluginBrowser::ctkPluginBrowser(ctkPluginFramework* framework)
    : framework(framework)
{
    pluginEventTypeToString[ctkPluginEvent::INSTALLED] = "Installed";
    pluginEventTypeToString[ctkPluginEvent::LAZY_ACTIVATION] = "Lazy Activation";
    pluginEventTypeToString[ctkPluginEvent::RESOLVED] = "Resolved";
    pluginEventTypeToString[ctkPluginEvent::STARTED] = "Started";
    pluginEventTypeToString[ctkPluginEvent::STARTING] = "Starting";
    pluginEventTypeToString[ctkPluginEvent::STOPPED] = "Stopped";
    pluginEventTypeToString[ctkPluginEvent::STOPPING] = "Stopping";
    pluginEventTypeToString[ctkPluginEvent::UNINSTALLED] = "Uninstalled";
    pluginEventTypeToString[ctkPluginEvent::UNRESOLVED] = "Unresolved";
    pluginEventTypeToString[ctkPluginEvent::UPDATED] = "Updated";

    framework->getPluginContext()->connectFrameworkListener(this, SLOT(frameworkEvent(ctkPluginFrameworkEvent)));
    framework->getPluginContext()->connectPluginListener(this, SLOT(pluginEvent(ctkPluginEvent)));
    framework->getPluginContext()->connectServiceListener(this, "serviceEvent");

    QStringList pluginDirs;
#ifdef CMAKE_INTDIR
    pluginDirs << CTK_PLUGIN_DIR CMAKE_INTDIR "/";
#else
    pluginDirs << CTK_PLUGIN_DIR;
#endif

    QStringListIterator dirIt(pluginDirs);
    while (dirIt.hasNext())
    {
        QApplication::addLibraryPath(dirIt.next());
    }

    QStringList libFilter;
    libFilter << "*.dll" << "*.so" << "*.dylib";
    QDirIterator dirIter(pluginDirs.at(0), libFilter, QDir::Files);
    while(dirIter.hasNext())
    {
        try
        {
            framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(dirIter.next()).toString());
            //plugin->start(ctkPlugin::START_ACTIVATION_POLICY);
        }
        catch (const ctkPluginException& e)
        {
            qCritical() << e.what();
        }
    }

    framework->start();

    ui.setupUi(this);

    tabifyDockWidget(ui.qtResourcesDockWidget, ui.pluginResourcesDockWidget);

    editors = new ctkPluginBrowserEditors(ui.centralwidget);

    QAbstractItemModel* pluginTableModel = new ctkPluginTableModel(framework->getPluginContext(), this);
    ui.pluginsTableView->setModel(pluginTableModel);

    QAbstractItemModel* qtresourcesTreeModel = new ctkQtResourcesTreeModel(this);
    ui.qtResourcesTreeView->setModel(qtresourcesTreeModel);

    connect(ui.pluginsTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(pluginSelected(QModelIndex)));
    connect(ui.pluginsTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(pluginDoubleClicked(QModelIndex)));
    connect(ui.pluginResourcesTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(dbResourceDoubleClicked(QModelIndex)));
    connect(ui.qtResourcesTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(qtResourceDoubleClicked(QModelIndex)));

    startPluginNowAction = new QAction(QIcon(":/pluginbrowser/images/run-now.png"), "Start Plugin (ignore activation policy)", this);
    startPluginAction = new QAction(QIcon(":/pluginbrowser/images/run.png"), "Start Plugin", this);
    stopPluginAction = new QAction(QIcon(":/pluginbrowser/images/stop.png"), "Stop Plugin", this);

    connect(startPluginNowAction, SIGNAL(triggered()), this, SLOT(startPluginNow()));
    connect(startPluginAction, SIGNAL(triggered()), this, SLOT(startPlugin()));
    connect(stopPluginAction, SIGNAL(triggered()), this, SLOT(stopPlugin()));

    startPluginNowAction->setEnabled(false);
    startPluginAction->setEnabled(false);
    stopPluginAction->setEnabled(false);

    ui.pluginToolBar->addAction(startPluginNowAction);
    ui.pluginToolBar->addAction(startPluginAction);
    ui.pluginToolBar->addAction(stopPluginAction);

    QSettings settings;
    if(settings.contains(SETTINGS_WND_GEOM))
    {
        this->restoreGeometry(settings.value(SETTINGS_WND_GEOM).toByteArray());
    }
    if (settings.contains(SETTINGS_WND_STATE))
    {
        this->restoreState(settings.value(SETTINGS_WND_STATE).toByteArray());
    }
}
Esempio n. 7
0
void ctkPluginBrowser::startPluginNow()
{
    startPlugin(ctkPlugin::START_TRANSIENT);
}
Esempio n. 8
0
void ctkPluginBrowser::startPlugin()
{
    startPlugin(ctkPlugin::START_TRANSIENT | ctkPlugin::START_ACTIVATION_POLICY);
}