Beispiel #1
0
bool save_prefs()
{
  char *prefs;
  prefs = pluginPath("Xchecklist.prf");
  if(!prefs){
    xcDebug("Can't save prefs (NULL plugin path received).\n");
    return false;
  }
  std::fstream fout;
  fout.open(prefs, std::ios::out);
  if(fout.is_open()){
    //Store prefs version first
    fout<<"1"<<std::endl;
    XPGetWidgetGeometry(xCheckListWidget, &win_pos_x1, &win_pos_x2, &win_pos_y1, &win_pos_y2);
    fout<<win_pos_x1<<" "<<win_pos_x2<<" "<<win_pos_y1<<" "<<win_pos_y2<<std::endl;
    fout<<state[TRANSLUCENT]<<" "<<state[SHOW_CHECKLIST]<<" "<<state[COPILOT_ON]<<" "
        <<state[VOICE]<<" "<<state[AUTO_HIDE]<<std::endl;
    fout.close();
  }else{
    xcDebug("Can't open prefs for writing.\n");
    free(prefs);
    return false;
  }
  free(prefs);
  return true;
}
Beispiel #2
0
bool init_setup()
{
  char *prefs = NULL;
  std::fstream fin;
  state[TRANSLUCENT] = true;
  state[SHOW_CHECKLIST] = true;
  state[COPILOT_ON] = true;
  state[VOICE] = true;
  voice_state = true;
  state[AUTO_HIDE] = true;
  prefs = pluginPath("Xchecklist.prf");
  if(try_open(prefs, fin)){
    //read new prefs from the fin
    int version = -1;
    fin>>version;
    switch(version){
      case 1:
	//Read the window position
	fin>>win_pos_x1>>win_pos_x2>>win_pos_y1>>win_pos_y2;
	//Read the rest of setup
        fin>>state[TRANSLUCENT]>>state[SHOW_CHECKLIST]>>state[COPILOT_ON]>>state[VOICE]>>state[AUTO_HIDE];
	break;
      default:
	xcDebug("Unknown preferences version, using defaults.\n");
	break;
    }
    safe_window_defaults(); 
    // Set the upper left corner from the prefs file
    // Not sure if this is the corect place but it is working
    x = win_pos_x1;
    y = win_pos_x2;
  }else{
static
void _cutLastPathSeparator(wchar_t * _strPath)
{
#ifdef ANDROID
	const u32 bufSize = 512;
	char cbuf[bufSize];
	wcstombs(cbuf, _strPath, bufSize);
	std::string pluginPath(cbuf);
	std::string::size_type pos = pluginPath.find_last_of("/");
	mbstowcs(_strPath, pluginPath.c_str(), PLUGIN_PATH_SIZE);
#else
	std::wstring pluginPath(_strPath);
	std::replace(pluginPath.begin(), pluginPath.end(), L'\\', L'/');
	std::wstring::size_type pos = pluginPath.find_last_of(L"/");
	wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
#endif
}
bool StandardServerCoreBuilder::loadPlugins() {
	
	shared_ptr<ComponentRegistry> component_registry = 
									ComponentRegistry::getSharedRegistry();
	
	readPlugins(pluginPath());
    return true;
}
void QgsApplication::initQgis()
{
  // set the provider plugin path (this creates provider registry)
  QgsProviderRegistry::instance( pluginPath() );

  // create map layer registry if doesn't exist
  QgsMapLayerRegistry::instance();
}
void PluginAPI::FindPluginPath(wchar_t * _strPath)
{
	if (_strPath == NULL)
		return;
	::GetModuleFileName((HINSTANCE)&__ImageBase, _strPath, PLUGIN_PATH_SIZE);
	std::wstring pluginPath(_strPath);
	std::replace(pluginPath.begin(), pluginPath.end(), L'\\', L'/');
	std::wstring::size_type pos = pluginPath.find_last_of(L"/");
	wcscpy(_strPath, pluginPath.substr(0, pos).c_str());
}
Beispiel #7
0
bool
GMPChild::LoadPluginLibrary(const std::string& aPluginPath)
{
  nsDependentCString pluginPath(aPluginPath.c_str());

  nsCOMPtr<nsIFile> libFile;
  nsresult rv = NS_NewNativeLocalFile(pluginPath, true, getter_AddRefs(libFile));
  if (NS_FAILED(rv)) {
    return false;
  }

  nsAutoString leafName;
  if (NS_FAILED(libFile->GetLeafName(leafName))) {
    return false;
  }
  nsAutoString baseName(Substring(leafName, 4, leafName.Length() - 1));

#if defined(XP_MACOSX)
  nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
#elif defined(OS_POSIX)
  nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so");
#elif defined(XP_WIN)
  nsAutoString binaryName =                            baseName + NS_LITERAL_STRING(".dll");
#else
#error not defined
#endif
  libFile->AppendRelativePath(binaryName);

  nsAutoCString nativePath;
  libFile->GetNativePath(nativePath);
  mLib = PR_LoadLibrary(nativePath.get());
  if (!mLib) {
    return false;
  }

  GMPInitFunc initFunc = reinterpret_cast<GMPInitFunc>(PR_FindFunctionSymbol(mLib, "GMPInit"));
  if (!initFunc) {
    return false;
  }

  auto platformAPI = new GMPPlatformAPI();
  InitPlatformAPI(*platformAPI);

  if (initFunc(platformAPI) != GMPNoErr) {
    return false;
  }

  mGetAPIFunc = reinterpret_cast<GMPGetAPIFunc>(PR_FindFunctionSymbol(mLib, "GMPGetAPI"));
  if (!mGetAPIFunc) {
    return false;
  }

  return true;
}
void
AutomaticIPod::PlayCountsDatabase::bootstrap()
{
    qDebug() << "Starting bootstrapping...";
    
    static_cast<TwiddlyApplication*>(qApp)->sendBusMessage( "container://Notification/Twiddly/Bootstrap/Started" );

    beginTransaction();    
    
    QSqlQuery query( m_db );
    // this will fail if the metadata table doesn't exist, which is fine
    query.exec( "DELETE FROM metadata WHERE key='bootstrap_complete'" );
    query.exec( "DELETE FROM metadata WHERE key='plugin_ctime'" );
    query.exec( "DELETE FROM " TABLE_NAME_OLD );
    query.exec( "DELETE FROM " TABLE_NAME );

    ITunesLibrary lib;
    
    // for wizard progress screen
    std::cout << lib.trackCount() << std::endl;
    
    int i = 0;

    while (lib.hasTracks())
    {
        try
        {
            ITunesLibrary::Track const t = lib.nextTrack();
            QString const plays = QString::number( t.playCount() );

            query.exec( "INSERT OR IGNORE INTO " TABLE_NAME " ( persistent_id, play_count ) "
                        "VALUES ( '" + t.uniqueId() + "', '" + plays + "' )" );

        }
        catch ( ... )
        {
            // Move on...
        }

        std::cout << ++i << std::endl;
    }

    // if either INSERTS fail we'll rebootstrap next time
    query.exec( "CREATE TABLE metadata (key VARCHAR( 32 ), value VARCHAR( 32 ))" );
    query.exec( "INSERT INTO metadata (key, value) VALUES ('bootstrap_complete', 'true')" );
    
    QString const t = QString::number( common::fileCreationTime( pluginPath() ) );
    query.exec( "INSERT INTO metadata (key, value) VALUES ('plugin_ctime', '"+t+"')" );


    endTransaction();

    static_cast<TwiddlyApplication*>(qApp)->sendBusMessage( "container://Notification/Twiddly/Bootstrap/Finished" );
}
WK_EXPORT int PluginProcessMainUnix(int argc, char* argv[])
{
#if PLUGIN_ARCHITECTURE(X11)
    bool scanPlugin = !strcmp(argv[1], "-scanPlugin");
#endif
    ASSERT_UNUSED(argc, argc == 3);

#if PLATFORM(GTK)
    gtk_init(&argc, &argv);
#elif PLATFORM(EFL)
#ifdef HAVE_ECORE_X
    if (!ecore_x_init(0))
#endif
        return 1;
#endif

    InitializeWebKit2();

#if PLUGIN_ARCHITECTURE(X11)
    if (scanPlugin) {
        String pluginPath(argv[2]);
        if (!NetscapePluginModule::scanPlugin(pluginPath))
            return EXIT_FAILURE;
        return EXIT_SUCCESS;
    }
#endif

    // Plugins can produce X errors that are handled by the GDK X error handler, which
    // exits the process. Since we don't want to crash due to plugin bugs, we install a
    // custom error handler to show a warning when a X error happens without aborting.
#if defined(XP_UNIX)
    programName = basename(argv[0]);
    XSetErrorHandler(webkitXError);
#endif

    int socket = atoi(argv[1]);

    WebKit::ChildProcessInitializationParameters parameters;
    parameters.connectionIdentifier = socket;
    parameters.extraInitializationData.add("plugin-path", argv[2]);

    WebKit::PluginProcess::shared().initialize(parameters);

    RunLoop::run();

    return 0;
}
bool GameStateLoadPlugin::enter()
{
    he::Path pluginPath(he::Path::getBinPath());
    he::pl::IPlugin* const plugin(PluginManager::getInstance()->loadPlugin(pluginPath, "HappyPluginTest"));
    Sandbox* const sandbox(Sandbox::getInstance());
    sandbox->setGamePlugin(plugin);

    SelectionManger::getInstance()->init();

    EntityManager* const entityMan(sandbox->getEntityManager());
    entityMan->init();
    if (plugin != nullptr)
    {
        plugin->init(sandbox->getGameWindow(), he::RectF(0, 0, 1, 1));
    }

    return true;
}
Beispiel #11
0
int run(int /*argc*/, char** argv)
{
    std::string pluginPath(argv[1]);
    std::deque<MyPlugin> plugins;
    
    std::unique_ptr<load_plugins::PluginServiceInterface> service(new load_plugins::ConcreteService());
    MyPluginFactory factory(pluginPath, *service);
    factory.load();
    
    auto availablePlugins = factory.availablePlugins();
    printPluginNames(availablePlugins);
    createPlugins(factory, availablePlugins, plugins);
    
    callPlugins(plugins);
    service->report();
    
    return 0;
}
QString QgsApplication::showSettings()
{
  QString myState = tr( "Application state:\n"
                        "Prefix:\t\t%1\n"
                        "Plugin Path:\t\t%2\n"
                        "Package Data Path:\t%3\n"
                        "Active Theme Name:\t%4\n"
                        "Active Theme Path:\t%5\n"
                        "Default Theme Path:\t%6\n"
                        "SVG Search Paths:\t%7\n"
                        "User DB Path:\t%8\n" )
                    .arg( prefixPath() )
                    .arg( pluginPath() )
                    .arg( pkgDataPath() )
                    .arg( themeName() )
                    .arg( activeThemePath() )
                    .arg( defaultThemePath() )
                    .arg( svgPaths().join( tr( "\n\t\t", "match indentation of application state" ) ) )
                    .arg( qgisMasterDbFilePath() );
  return myState;
}
static void testWebContextGetPlugins(PluginsTest* test, gconstpointer)
{
    GList* plugins = test->getPlugins();
    g_assert(plugins);

    GRefPtr<WebKitPlugin> testPlugin;
    for (GList* item = plugins; item; item = g_list_next(item)) {
        WebKitPlugin* plugin = WEBKIT_PLUGIN(item->data);
        test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(plugin));
        if (!g_strcmp0(webkit_plugin_get_name(plugin), "WebKit Test PlugIn")) {
            testPlugin = plugin;
            break;
        }
    }
    g_assert(WEBKIT_IS_PLUGIN(testPlugin.get()));

    char normalizedPath[PATH_MAX];
    g_assert(realpath(WEBKIT_TEST_PLUGIN_DIR, normalizedPath));
    GUniquePtr<char> pluginPath(g_build_filename(normalizedPath, "libTestNetscapePlugin.so", nullptr));
    g_assert_cmpstr(webkit_plugin_get_path(testPlugin.get()), ==, pluginPath.get());
    g_assert_cmpstr(webkit_plugin_get_description(testPlugin.get()), ==, "Simple Netscape® plug-in that handles test content for WebKit");
    GList* mimeInfoList = webkit_plugin_get_mime_info_list(testPlugin.get());
    g_assert(mimeInfoList);
    g_assert_cmpuint(g_list_length(mimeInfoList), ==, 2);

    WebKitMimeInfo* mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
    g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "image/png");
    g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "png image");
    const gchar* const* extensions = webkit_mime_info_get_extensions(mimeInfo);
    g_assert(extensions);
    g_assert_cmpstr(extensions[0], ==, "png");

    mimeInfoList = g_list_next(mimeInfoList);
    mimeInfo = static_cast<WebKitMimeInfo*>(mimeInfoList->data);
    g_assert_cmpstr(webkit_mime_info_get_mime_type(mimeInfo), ==, "application/x-webkit-test-netscape");
    g_assert_cmpstr(webkit_mime_info_get_description(mimeInfo), ==, "test netscape content");
    extensions = webkit_mime_info_get_extensions(mimeInfo);
    g_assert(extensions);
    g_assert_cmpstr(extensions[0], ==, "testnetscape");
}
WK_EXPORT int PluginProcessMainUnix(int argc, char* argv[])
{
    ASSERT_UNUSED(argc, argc == 2 || argc == 3);
    bool scanPlugin = !strcmp(argv[1], "-scanPlugin");
    ASSERT_UNUSED(argc, argc == 2 || (argc == 3 && scanPlugin));

#if PLATFORM(GTK)
    gtk_init(&argc, &argv);
#elif PLATFORM(EFL)
#ifdef HAVE_ECORE_X
    if (!ecore_x_init(0))
#endif
        return 1;
#endif

    ScriptController::initializeThreading();

    if (scanPlugin) {
        String pluginPath(argv[2]);
        if (!NetscapePluginModule::scanPlugin(pluginPath))
            return EXIT_FAILURE;
        return EXIT_SUCCESS;
    }

    RunLoop::initializeMainRunLoop();

    // Plugins can produce X errors that are handled by the GDK X error handler, which
    // exits the process. Since we don't want to crash due to plugin bugs, we install a
    // custom error handler to show a warning when a X error happens without aborting.
#if defined(XP_UNIX)
    programName = basename(argv[0]);
    XSetErrorHandler(webkitXError);
#endif

    int socket = atoi(argv[1]);
    WebKit::PluginProcess::shared().initialize(socket, RunLoop::main());
    RunLoop::run();

    return 0;
}
Beispiel #15
0
Q_DECL_EXPORT int PluginProcessMain(int argc, char** argv)
{
    QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT");
    if (!suppressOutput.isEmpty() && suppressOutput != "0")
        qInstallMessageHandler(messageHandler);

    QGuiApplication app(argc, argv);

    // Workaround the issue that some versions of flash does not initialize Gtk properly.
    if (!initializeGtk())
        return EXIT_FAILURE;

    JSC::initializeThreading();
    WTF::initializeMainThread();

    if (argc <= 1)
        return EXIT_FAILURE;

    if (app.arguments().at(1) == QLatin1String("-scanPlugin")) {
        if (argc != 3)
            return EXIT_FAILURE;
        String pluginPath(app.arguments().at(2));
        if (!NetscapePluginModule::scanPlugin(pluginPath))
            return EXIT_FAILURE;
        return EXIT_SUCCESS;
    }

    RunLoop::initializeMainRunLoop();

    // Create the connection.
    bool isNumber = false;
    int identifier = app.arguments().at(1).toInt(&isNumber, 10);
    if (!isNumber)
        return EXIT_FAILURE;
    WebKit::PluginProcess::shared().initialize(identifier, RunLoop::main());

    RunLoop::run();

    return 0;
}
Beispiel #16
0
int main(int argc, char* argv[])
{
    bx::enableLogToFileHandle(stdout, stderr);
    bx::setLogTag("Termite");

    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        BX_FATAL("SDL Init failed");
        return -1;
    }

    termite::Config conf;
    bx::Path pluginPath(argv[0]);
    strcpy(conf.pluginPath, pluginPath.getDirectory().cstr());

#if BX_PLATFORM_ANDROID
    SDL_DisplayMode disp;
    if (SDL_GetCurrentDisplayMode(0, &disp) == 0) {
        g_displaySize.x = disp.w;
        g_displaySize.y = disp.h;
    }    
#endif

    g_window = SDL_CreateWindow("TestSDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                                g_displaySize.x, g_displaySize.y, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
    if (!g_window) {
        BX_FATAL("SDL window creation failed");
        termite::shutdown();
        return -1;
    }

    conf.gfxWidth = g_displaySize.x;
    conf.gfxHeight = g_displaySize.y;

    termite::sdlMapImGuiKeys(&conf);

    termite::GfxPlatformData platformData;
    termite::sdlGetNativeWindowHandle(g_window, &platformData.nwh, &platformData.ndt);
    
    if (termite::initialize(conf, update, &platformData) ||
        T_FAILED(termite::registerFont("fonts/fixedsys.fnt", "fixedsys")))
    {
        BX_FATAL(termite::getErrorString());
        BX_VERBOSE(termite::getErrorCallstack());
        termite::shutdown();
        SDL_DestroyWindow(g_window);
        SDL_Quit();
        return -1;
    }

    g_vg = termite::createVectorGfxContext(101);
    g_debug = termite::createDebugDrawContext(100);
    termite::camInit(&g_cam);
    termite::camLookAt(&g_cam, termite::vec3_t(0, 1.0f, -12.0f), termite::vec3_t(0, 0, 0));

    // reset graphics driver
    termite::getGfxDriver()->reset(g_displaySize.x, g_displaySize.y, 0);
    
    SDL_Event ev;
    while (true) {
        if (termite::sdlHandleEvent(&ev)) {
            if (ev.type == SDL_QUIT)
                break;
            if (ev.type == SDL_WINDOWEVENT) {
                if (ev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
                    BX_VERBOSE("Resume");
                    termite::sdlGetNativeWindowHandle(g_window, &platformData.nwh);
                    termite::getGfxDriver()->setPlatformData(platformData);
                    termite::getGfxDriver()->reset(g_displaySize.x, g_displaySize.y, 0);
                    termite::resume();
                } else if (ev.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
                    BX_VERBOSE("Pause");
                    termite::pause();
                }
            }
        }
        termite::doFrame();
    }

    termite::destroyDebugDrawContext(g_debug);
    termite::destroyVectorGfxContext(g_vg);
    termite::shutdown();
    SDL_DestroyWindow(g_window);
    SDL_Quit();

    return 0;
}
void
AutomaticIPod::PlayCountsDatabase::bootstrap()
{
    qDebug() << "Starting bootstrapping...";
    
    static_cast<TwiddlyApplication*>(qApp)->sendBusMessage( "container://Notification/Twiddly/Bootstrap/Started" );

    beginTransaction();    
    
    QSqlQuery query( m_db );
    // this will fail if the metadata table doesn't exist, which is fine
    query.exec( "DELETE FROM metadata WHERE key='bootstrap_complete'" );
    query.exec( "DELETE FROM metadata WHERE key='plugin_ctime'" );
    query.exec( "DELETE FROM itunes_db" );

#ifdef Q_OS_MAC
    ITunesLibrary lib;
    
    // for wizard progress screen
    std::cout << lib.trackCount() << std::endl;
    
    int i = 0;
    while (lib.hasTracks())
    {
        ITunesLibrary::Track const t = lib.nextTrack();
        QString const plays = QString::number( t.playCount() );
        
        query.exec( "INSERT OR IGNORE INTO itunes_db ( persistent_id, play_count ) "
                    "VALUES ( '" + t.uniqueId() + "', '" + plays + "' )" );

        std::cout << ++i << std::endl;
    }

#else

    ITunesLibrary lib;
    int i = 0;
    
    // These cout statements are for the progress indicator in the client,
    // do not remove!
    std::cout << lib.trackCount() << std::endl;
    
    while ( lib.hasTracks() )
    {
        try
        {
            ITunesLibrary::Track t = lib.nextTrack();

            if ( !t.isNull() )
            {
                QString sql = "INSERT OR IGNORE INTO itunes_db ( persistent_id, path, play_count ) "
                              "VALUES ( :pid, :path, :plays )";
                exec( sql, t );
            }
        }
        catch ( ITunesException& )
        {
            // Move on...
        }

        std::cout << ++i << std::endl;
    }

#endif

    // if either INSERTS fail we'll rebootstrap next time
    query.exec( "CREATE TABLE metadata (key VARCHAR( 32 ), value VARCHAR( 32 ))" );
    query.exec( "INSERT INTO metadata (key, value) VALUES ('bootstrap_complete', 'true')" );
    
    QString const t = QString::number( common::fileCreationTime( pluginPath() ) );
    query.exec( "INSERT INTO metadata (key, value) VALUES ('plugin_ctime', '"+t+"')" );


    endTransaction();

    static_cast<TwiddlyApplication*>(qApp)->sendBusMessage( "container://Notification/Twiddly/Bootstrap/Finished" );
}
Beispiel #18
0
bool
GMPChild::LoadPluginLibrary(const std::string& aPluginPath)
{
  nsDependentCString pluginPath(aPluginPath.c_str());

  nsCOMPtr<nsIFile> libFile;
  nsresult rv = NS_NewNativeLocalFile(pluginPath, true, getter_AddRefs(libFile));
  if (NS_FAILED(rv)) {
    return false;
  }

  nsAutoString leafName;
  if (NS_FAILED(libFile->GetLeafName(leafName))) {
    return false;
  }
  nsAutoString baseName(Substring(leafName, 4, leafName.Length() - 1));

#if defined(XP_MACOSX)
  nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
#elif defined(OS_POSIX)
  nsAutoString binaryName = NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so");
#elif defined(XP_WIN)
  nsAutoString binaryName =                            baseName + NS_LITERAL_STRING(".dll");
#else
#error not defined
#endif
  libFile->AppendRelativePath(binaryName);

  nsAutoCString nativePath;
  libFile->GetNativePath(nativePath);

#if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
  // Enable sandboxing here -- we know the plugin file's path, but
  // this process's execution hasn't been affected by its content yet.
  mozilla::SetMediaPluginSandbox(nativePath.get());
#endif

  mLib = PR_LoadLibrary(nativePath.get());
  if (!mLib) {
    return false;
  }

  GMPInitFunc initFunc = reinterpret_cast<GMPInitFunc>(PR_FindFunctionSymbol(mLib, "GMPInit"));
  if (!initFunc) {
    return false;
  }

  auto platformAPI = new GMPPlatformAPI();
  InitPlatformAPI(*platformAPI, this);

  if (initFunc(platformAPI) != GMPNoErr) {
    return false;
  }

  mGetAPIFunc = reinterpret_cast<GMPGetAPIFunc>(PR_FindFunctionSymbol(mLib, "GMPGetAPI"));
  if (!mGetAPIFunc) {
    return false;
  }

  return true;
}