Esempio n. 1
0
QLibrary* RazorPluginInfo::loadLibrary(const QString& libDir) const
{
    QString baseName, path;
    QFileInfo fi = QFileInfo(fileName());
    path = fi.canonicalPath();
    baseName = value("X-Razor-Library", fi.completeBaseName()).toString();

    QString soPath = QString("%1/lib%2.so").arg(libDir, baseName);
    QLibrary* library = new QLibrary(soPath);

    if (!library->load())
    {
        qWarning() << QString("Can't load plugin lib \"%1\"").arg(soPath) << library->errorString();
        delete library;
        return 0;
    }

    QString locale = QLocale::system().name();
    QTranslator* translator = new QTranslator(library);

    translator->load(QString("%1/%2/%2_%3.qm").arg(path, baseName, locale));
    qApp->installTranslator(translator);

    return library;
}
Esempio n. 2
0
bool load(const char* dllname)
{
    if (library(dllname)) {
        DBG("'%s' is already loaded\n", dllname);
        return true;
    }
    std::list<std::string> libnames = sLibNamesMap[dllname];
    if (libnames.empty())
        libnames.push_back(dllname);
    std::list<std::string>::const_iterator it;
    QLibrary *dll = new QLibrary();
    for (it = libnames.begin(); it != libnames.end(); ++it) {
        dll->setFileName((*it).c_str());
        if (dll->load())
            break;
        DBG("%s\n", dll->errorString().toLocal8Bit().constData()); //why qDebug use toUtf8() and printf use toLocal8Bit()?
    }
    if (it == libnames.end()) {
        DBG("No dll loaded\n");
        delete dll;
        return false;
    }
    DBG("'%s' is loaded~~~\n", dll->fileName().toUtf8().constData());
    sDllMap[dllname] = dll; //map.insert will not replace the old one
    return true;
}
Esempio n. 3
0
/**
 * \brief Load a OPluginItem for the specified interface
 * This will open the resource of the OPluginItem::path() and then will query
 * if the Interface specified in the uuid is available and then will manage the
 * resource and Interface.
 *
 * @param item The OPluginItem that should be loaded
 * @param uuid The Interface to query for
 *
 * @return Either 0 in case of failure or the Plugin as QUnknownInterface*
 */
QUnknownInterface* OGenericPluginLoader::load( const OPluginItem& item, const QUuid& uuid) {
    /*
     * Check if there could be a library
     */
    QString pa = item.path();
    if ( pa.isEmpty() )
        return 0l;

    /*
     * See if we get a library
     * return if we've none
     */
    setSafeMode( pa, true );
    QLibrary *lib = Internal::OPluginLibraryHolder::self()->ref( pa );
    if ( !lib ) {
        setSafeMode();
        return 0l;
    }

    /**
     * try to load the plugin and just in case initialize the pointer to a pointer again
     */
    QUnknownInterface*  iface=0;
    if ( lib->queryInterface(  uuid,  &iface ) == QS_OK ) {
        installTranslators( item.name() );
        m_library.insert( iface, lib );
    }else
        iface = 0;

    setSafeMode();

    return iface;
}
Esempio n. 4
0
bool
FirebirdDriver::initialize()
{
    if (_library != NULL)
	return true;

    FirebirdConfig config;
    if (!config.load())
	return error("Can't read firebird.cfg file");

    // Set firebird install directory
#ifdef WIN32
    SetEnvironmentVariable("INTERBASE", parseDir(config.installDir));
    SetEnvironmentVariable("FIREBIRD", parseDir(config.installDir));
#else
    setenv("INTERBASE", parseDir(config.installDir), true);
    setenv("FIREBIRD", parseDir(config.installDir), true);
#endif

    // Try to load the library
    QLibrary* library = new QLibrary(config.library);
    if (!library->load()) {
	libraryError();
	delete library;
	return error("Can't load firebird library: " + config.library);
    }

    _library = library;
    _procs = new FirebirdProcs(_library);

    return true;
}
Esempio n. 5
0
Garmin::IDevice * CDeviceGarmin::getDevice()
{
    Garmin::IDevice * (*func)(const char*) = 0;
    Garmin::IDevice * dev = 0;

#if defined(Q_OS_MAC)
    // MacOS X: plug-ins are stored in the bundle folder
    QString libname     = QString("%1/lib%2" XSTR(SHARED_LIB_EXT))
        .arg(QCoreApplication::applicationDirPath().replace(QRegExp("MacOS$"), "Resources/Drivers"))
        .arg(devkey);
#else
    QString libname     = QString("%1/lib%2" XSTR(SHARED_LIB_EXT)).arg(XSTR(PLUGINDIR)).arg(devkey);
#endif
    QString funcname    = QString("init%1").arg(devkey);

    QLibrary lib;
    lib.setFileName(libname);
    bool lib_loaded = lib.load();
    if (lib_loaded)
    {
        func = (Garmin::IDevice * (*)(const char*))lib.resolve(funcname.toLatin1());
    }

    if(!lib_loaded || func == 0)
    {
        QMessageBox warn;
        warn.setIcon(QMessageBox::Warning);
        warn.setWindowTitle(tr("Error ..."));
        warn.setText(tr("Failed to load driver."));
        warn.setDetailedText(lib.errorString());
        warn.setStandardButtons(QMessageBox::Ok);
        warn.exec();
        return 0;
    }

    dev = func(INTERFACE_VERSION);
    if(dev == 0)
    {
        QMessageBox warn;
        warn.setIcon(QMessageBox::Warning);
        warn.setWindowTitle(tr("Error ..."));
        warn.setText(tr("Driver version mismatch."));
        QString detail = QString(
            tr("The version of your driver plugin \"%1\" does not match the version QLandkarteGT expects (\"%2\").")
            ).arg(libname).arg(INTERFACE_VERSION);
        warn.setDetailedText(detail);
        warn.setStandardButtons(QMessageBox::Ok);
        warn.exec();
        func = 0;
    }

    if(dev)
    {
        dev->setPort(port.toLatin1());
        dev->setGuiCallback(GUICallback,this);
    }

    return dev;
}
Esempio n. 6
0
bool QgsTransaction::supportsTransaction( const QgsVectorLayer* layer )
{
  QLibrary* lib = QgsProviderRegistry::instance()->providerLibrary( layer->providerType() );
  if ( !lib )
    return false;

  return lib->resolve( "createTransaction" );
}
static T resolveFunction(QLibrary &lib, const char *name)
{
  T temp = reinterpret_cast<T>(lib.resolve(name));
  if (temp == nullptr) {
    throw std::runtime_error(QObject::tr("invalid 7-zip32.dll: %1").arg(lib.errorString()).toLatin1().constData());
  }
  return temp;
}
QHSWidgetImpl::~QHSWidgetImpl()
{
    delete iHsWidgetPublisher;

    const QObjectList& c(children());
    foreach (QObject* child, c)
    {
        QLibrary* lib = qobject_cast<QLibrary*> (child);
        if (lib) lib->unload();
    }
//eComnpass libray funcitons
void eCompass_GetVersion(int *pMajorVer, int *pMinorVer)
{
    if(eCompass.isLoaded())
    {
        pFuncGetVersion eCompass_GetVersion = (pFuncGetVersion) eCompass.resolve("eCompass_GetVersion");
        if(eCompass_GetVersion)
        {
            eCompass_GetVersion(pMajorVer, pMinorVer);
        }
    }
}
Esempio n. 10
0
BOOL SND_Stop(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool SND_Stop = (pFuncGetBool)Nordic.resolve("SND_Stop");
        if(SND_Stop)
        {
            return SND_Stop();
        }
    }
	return FALSE;
}
Esempio n. 11
0
BOOL NOR_Close(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool NOR_Close = (pFuncGetBool)Nordic.resolve("NOR_Close");
        if(NOR_Close)
        {
            return NOR_Close();
        }
    }
	return FALSE;
}
Esempio n. 12
0
BOOL SND_Start(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool SND_Start = (pFuncGetBool)Nordic.resolve("SND_Start");
        if(SND_Start)
        {
            return SND_Start();
        }
    }
	return FALSE;
}
Esempio n. 13
0
BOOL SND_SendTxBuf(UCHAR *ucTxBuf)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBoolParamUCharPt SND_SendTxBuf = (pFuncGetBoolParamUCharPt)Nordic.resolve("SND_SendTxBuf");
        if(SND_SendTxBuf)
        {
            return SND_SendTxBuf(ucTxBuf);
        }
    }
	return FALSE;
}
Esempio n. 14
0
UCHAR* RTK_GetRxBuf(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetUCHARPt RTK_GetRxBuf = (pFuncGetUCHARPt)Nordic.resolve("RTK_GetRxBuf");
        if(RTK_GetRxBuf)
        {
            return RTK_GetRxBuf();
        }
    }
	return NULL;
}
Esempio n. 15
0
BOOL RTK_Stop(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool RTK_Stop = (pFuncGetBool)Nordic.resolve("RTK_Stop");
        if(RTK_Stop)
        {
            return RTK_Stop();
        }
    }
	return FALSE;
}
Esempio n. 16
0
BOOL NOR_Open(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool NOR_Open = (pFuncGetBool)Nordic.resolve("NOR_Open");
        if(NOR_Open)
        {
            return NOR_Open();
        }
    }
	return FALSE;
}
Esempio n. 17
0
    bool load()
    {
        m_libUdev.setLoadHints(QLibrary::ResolveAllSymbolsHint);
        m_libUdev.setFileNameAndVersion(QStringLiteral("udev"), 1);
        m_loaded = m_libUdev.load();
        if (resolveMethods())
            return true;

        m_libUdev.setFileNameAndVersion(QStringLiteral("udev"), 0);
        m_loaded = m_libUdev.load();
        return resolveMethods();
    }
Esempio n. 18
0
UCHAR HRS_GetHeartRate(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetUCHAR HRS_GetHeartRate = (pFuncGetUCHAR)Nordic.resolve("HRS_GetHeartRate");
        if(HRS_GetHeartRate)
        {
            return HRS_GetHeartRate();
        }
    }
	return NULL;
}
Esempio n. 19
0
BOOL NOR_GetChID(UCHAR ucChannel, UCHAR *ucManufact, USHORT *usDeviceNum)
{
    if(Nordic.isLoaded())
    {
        pFuncGetId NOR_GetChID = (pFuncGetId)Nordic.resolve("NOR_GetChID");
        if(NOR_GetChID)
        {
            return NOR_GetChID(ucChannel,ucManufact,usDeviceNum);
        }
    }
	return FALSE;
}
Esempio n. 20
0
BOOL NOR_Reset(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool NOR_Reset = (pFuncGetBool)Nordic.resolve("NOR_Reset");
        if(NOR_Reset)
        {
            return NOR_Reset();
        }
    }
	return FALSE;
}
Esempio n. 21
0
BOOL eCompass_Stop()
{
    if(eCompass.isLoaded())
    {
        pFuncGetInt eCompass_Stop = (pFuncGetInt) eCompass.resolve("eCompass_Stop");
        if(eCompass_Stop)
        {
            return eCompass_Stop();
        }
    }
	return FALSE;
}
Esempio n. 22
0
BOOL eCompass_Init()
{
    if(eCompass.isLoaded())
    {
        pFuncGetInt eCompass_Init = (pFuncGetInt) eCompass.resolve("eCompass_Init");
        if(eCompass_Init)
        {
            return eCompass_Init();
        }
    }
	return FALSE;
}
Esempio n. 23
0
UCHAR NOR_GetChStatus(UCHAR ucChannel)
{
    if(Nordic.isLoaded())
    {
        pFuncGetUCHARParamUCHAR NOR_GetChStatus = (pFuncGetUCHARParamUCHAR)Nordic.resolve("NOR_GetChStatus");
        if(NOR_GetChStatus)
        {
            return NOR_GetChStatus(ucChannel);
        }
    }
	return NULL;
}
Esempio n. 24
0
BOOL HRS_Stop(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool HRS_Stop = (pFuncGetBool)Nordic.resolve("HRS_Stop");
        if(HRS_Stop)
        {
            return HRS_Stop();
        }
    }
	return FALSE;
}
Esempio n. 25
0
BOOL HRS_Start(USHORT usDeviceNumber, UCHAR ucManufactureID)
{
    if(Nordic.isLoaded())
    {
        pFuncStart HRS_Start = (pFuncStart)Nordic.resolve("HRS_Start");
        if(HRS_Start)
        {
            return HRS_Start(usDeviceNumber,ucManufactureID);
        }
    }
	return FALSE;
}
Esempio n. 26
0
USHORT CAD_GetCandence(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetUShort CAD_GetCandence = (pFuncGetUShort)Nordic.resolve("CAD_GetCandence");
        if(CAD_GetCandence)
        {
            return CAD_GetCandence();
        }
    }
	return NULL;
}
Esempio n. 27
0
BOOL CAD_Stop(void)
{
    if(Nordic.isLoaded())
    {
        pFuncGetBool CAD_Stop = (pFuncGetBool)Nordic.resolve("CAD_Stop");
        if(CAD_Stop)
        {
            return CAD_Stop();
        }
    }
	return FALSE;
}
Esempio n. 28
0
 void emitSignals () {
   bool openBabelAvailable = openBabelInterface.isLoaded ();
   bool isInchiAvailable = inChIAvailable && inChIAvailable ();
   bool isGen2dAvailable = gen2dAvailable && gen2dAvailable ();
   qDebug() << "OpenBabel available: " << QString::number (openBabelAvailable)
            << "Library location:" << openBabelInterface.fileName();
   qDebug() << "InChI available: " << QString::number (isInchiAvailable)
            << "gen2d available: " << QString::number (isGen2dAvailable);
   emit parent->obabelIfaceAvailable (openBabelAvailable);
   emit parent->inchiAvailable (isInchiAvailable && isGen2dAvailable);
   emit parent->optimizeAvailable(isGen2dAvailable);
   emit parent->obabelIfaceFileNameChanged(openBabelInterface.fileName());
 }
	qint64 GetLibAPILevel (const QString& file)
	{
		if (file.isEmpty ())
			return static_cast<quint64> (-1);

		QLibrary library (file);
		if (!library.load ())
			return static_cast<quint64> (-1);

		typedef quint64 (*APIVersion_t) ();
		auto getter = reinterpret_cast<APIVersion_t> (library.resolve ("GetAPILevels"));
		return getter ? getter () : static_cast<quint64> (-1);
	}
Esempio n. 30
0
/*!
  Load any font renderer plugins that are available and make the fonts
  that the plugins can read available.
*/
void FontDatabase::loadRenderers()
{
#ifndef QWS
    return;
#else

#ifndef QT_NO_COMPONENT
    if ( !factoryList )
	factoryList = new QValueList<FontFactory>;

    QValueList<FontFactory>::Iterator mit;
    for ( mit = factoryList->begin(); mit != factoryList->end(); ++mit ) {
	qt_fontmanager->factories.setAutoDelete( false );
	qt_fontmanager->factories.removeRef( (*mit).factory );
	qt_fontmanager->factories.setAutoDelete( true );
	(*mit).interface->release();
	(*mit).library->unload();
	delete (*mit).library;
    }
    factoryList->clear();

    QString path = QPEApplication::qpeDir() + "plugins/fontfactories";
#ifdef Q_OS_MACX
    QDir dir( path, "lib*.dylib" );
#else
    QDir dir( path, "lib*.so" );
#endif

    if ( !dir.exists())
    	return;

    QStringList list = dir.entryList();
    QStringList::Iterator it;
    for ( it = list.begin(); it != list.end(); ++it ) {
	FontFactoryInterface *iface = 0;
	QLibrary *lib = new QLibrary( path + "/" + *it );
	if ( lib->queryInterface( IID_FontFactory, (QUnknownInterface**)&iface ) == QS_OK ) {
	    FontFactory factory;
	    factory.library = lib;
	    factory.interface = iface;
	    factory.factory = factory.interface->fontFactory();
	    factoryList->append( factory );
	    qt_fontmanager->factories.append( factory.factory );
	    readFonts( factory.factory );
	} else {
	    delete lib;
	}
    }
#endif
#endif
}