Example #1
0
ProviderPtr
ImporterManager::createProvider( QVariantMap config )
{
    Controller *controller = Amarok::Components::statSyncingController();

    // First, get rid of the old provider instance. Note: the StatSyncing::Config
    // remembers the provider by the id, even when it's unregistered. After this
    // block, old instance should be destroyed, its destructor called.
    if( config.contains( "uid" ) )
    {
        const QString providerId = config.value( "uid" ).toString();
        if( m_providers.contains( providerId ) )
        {
            ProviderPtr oldProvider = m_providers.take( providerId );
            if( controller )
                controller->unregisterProvider( oldProvider );
        }
    }

    // Create a concrete provider using the config. The QueuedConnection in connect()
    // is important, because on reconfigure we *destroy* the old provider instance
    ImporterProviderPtr provider = newInstance( config );
    if( !provider )
    {
        warning() << __PRETTY_FUNCTION__ << "created provider is null!";
        return provider;
    }

    connect( provider.data(), SIGNAL(reconfigurationRequested(QVariantMap)),
                                SLOT(createProvider(QVariantMap)), Qt::QueuedConnection);
    m_providers.insert( provider->id(), provider );

    // Register the provider
    if( controller )
    {
        controller->registerProvider( provider );

        // Set provider to offline
        if( Config *config = controller->config() )
        {
            config->updateProvider( provider->id(), provider->prettyName(),
                                    provider->icon(), /*online*/ false );
            config->save();
        }
    }

    // Save the settings
    KConfigGroup group = providerConfig( provider );
    group.deleteGroup();
    foreach( const QString &key, provider->m_config.keys() )
        group.writeEntry( key, provider->m_config.value( key ) );
    group.sync();

    return provider;
}
Example #2
0
    // this = argv[0] (ignored)
    // arg1 = argv[1]
    // argN = argv[argc]
    Atom ClassClosure::construct(int argc, Atom* argv)
    {
        VTable* ivtable = this->ivtable();
        AvmAssert(ivtable != NULL);
        AvmAssert(argv != NULL); // need at least one arg spot passed in

        ScriptObject* obj = newInstance();
        AvmAssert(obj != NULL); //should never be null
        Atom a = obj->atom();
        argv[0] = a; // new object is receiver
        ivtable->init->coerceEnter(argc, argv);
        // this is a class. always return new instance.
        return a;
    }
HdfsClient* HdfsClient::getInstance()
{
   ContextCli *currContext = GetCliGlobals()->currContext();
   HdfsClient *hdfsClient = currContext->getHDFSClient();
   HDFS_Client_RetCode retcode;
   if (hdfsClient == NULL) {
      NAHeap *heap = currContext->exHeap();
      hdfsClient = newInstance(heap, NULL, retcode);
      if (retcode != HDFS_CLIENT_OK)
         return NULL; 
      currContext->setHDFSClient(hdfsClient);
   }
   return hdfsClient;
}
Example #4
0
QScriptValue TypedArray::newInstance(QScriptValue array) {
    const QString ARRAY_LENGTH_HANDLE = "length";
    if (array.property(ARRAY_LENGTH_HANDLE).isValid()) {
        quint32 length = array.property(ARRAY_LENGTH_HANDLE).toInt32();
        QScriptValue newArray = newInstance(length);
        for (quint32 i = 0; i < length; ++i) {
            QScriptValue value = array.property(QString::number(i));
            setProperty(newArray, engine()->toStringHandle(QString::number(i)),
                        i * _bytesPerElement, (value.isNumber()) ? value : QScriptValue(0));
        }
        return newArray;
    }
    engine()->evaluate("throw \"ArgumentError: not an array\"");
    return QScriptValue();
}
Example #5
0
jvalue JPClass::buildObjectWrapper(HostRef* obj)
{
	jvalue res;
	
	JPCleaner cleaner;
	
	vector<HostRef*> args(1);
	args.push_back(obj);

	JPObject* pobj = newInstance(args);

	res.l = pobj->getObject();
	delete pobj;

	return res;
}
Example #6
0
GLC_3DWidget::GLC_3DWidget(const GLC_3DWidget& widget)
: QObject()
, m_Uid(glc::GLC_Gen3DWidgetID())
, m_pWidgetManagerHandle(widget.m_pWidgetManagerHandle)
, m_InstanceIdList()
{
	// Copy the 3Dview instance of the widget
	const int size= widget.m_InstanceIdList.size();
	for (int i= 0; i < size; ++i)
	{
		GLC_3DViewInstance newInstance(widget.m_pWidgetManagerHandle->instanceHandle(widget.m_InstanceIdList.at(i))->deepCopy());
		GLC_uint newId= newInstance.id();
		m_InstanceIdList.append(newId);
		m_pWidgetManagerHandle->add3DViewInstance(newInstance, m_Uid);
	}
}
Example #7
0
void TypeManager::initialize()
{
	defineBuiltInTypes();

	// install the 'co' module
	ModuleInstaller::instance().install();

	/*
		Manually add the necessary annotations to core types.
		In the future we shall revamp reflectors to allow their use before any
		type is created, thus enabling core types to use the core annotations.
	 */
	RefPtr<IObject> annotationObject = newInstance( "co.IncludeAnnotation" );
	IInclude* include = annotationObject->getService<IInclude>();
	include->setValue( "co/reserved/Uuid.h" );
	getType( "co.Uuid" )->addAnnotation( include );
}
Example #8
0
	ShaderInstance* ShaderSet::getInstance (PropertySetGet* properties)
	{
		size_t h = buildHash (properties);
		if (std::find(mFailedToCompile.begin(), mFailedToCompile.end(), h) != mFailedToCompile.end())
			return NULL;
		if (mInstances.find(h) == mInstances.end())
		{
			ShaderInstance newInstance(this, mName + "_" + boost::lexical_cast<std::string>(h), properties);
			if (!newInstance.getSupported())
			{
				mFailedToCompile.push_back(h);
				return NULL;
			}
			mInstances.insert(std::make_pair(h, newInstance));
		}
		return &mInstances.find(h)->second;
	}
Example #9
0
	// this = argv[0] (ignored)
	// arg1 = argv[1]
	// argN = argv[argc]
	Atom FunctionObject::construct(int argc, Atom* argv)
	{
		AvmAssert(argv != NULL); // need at least one arg spot passed in

		ScriptObject* obj = newInstance();

		// this is a function
		argv[0] = obj->atom(); // new object is receiver
		Atom result = _call->coerceEnter(argc, argv);

		// for E3 13.2.2 compliance, check result and return it if (Type(result) is Object)

		/* ISSUE does this apply to class constructors too?

		answer: no.  from E4: A constructor may invoke a return statement as long as that 
		statement does not supply a value; a constructor cannot return a value. The newly 
		created object is returned automatically. A constructorÂ’s return type must be omitted. 
		A constructor always returns a new instance. */

		return AvmCore::isNull(result) || AvmCore::isObject(result) ? result : obj->atom();
	}
Example #10
0
GLC_3DWidget& GLC_3DWidget::operator=(const GLC_3DWidget& widget)
{
	if (this != &widget)
	{
		remove3DViewInstance();

		m_Uid= widget.m_Uid;
		m_pWidgetManagerHandle= widget.m_pWidgetManagerHandle;
		m_InstanceIdList= widget.m_InstanceIdList;

		// Copy the 3Dview instance of the widget
		const int size= widget.m_InstanceIdList.size();
		for (int i= 0; i < size; ++i)
		{
			GLC_3DViewInstance newInstance(widget.m_pWidgetManagerHandle->instanceHandle(widget.m_InstanceIdList.at(i))->deepCopy());
			GLC_uint newId= newInstance.id();
			m_InstanceIdList.append(newId);
			m_pWidgetManagerHandle->add3DViewInstance(newInstance, m_Uid);
		}
	}
	return *this;
}
Example #11
0
/**
 * The application constructor
 */
RingApplication::RingApplication(int & argc, char ** argv) : QApplication(argc,argv)
{

#ifdef ENABLE_VIDEO
   //Necessary to draw OpenGL from a separated thread
   setAttribute(Qt::AA_X11InitThreads,true);
#endif

   try {
      CallModel::instance();
   }
   catch (...) {
      KMessageBox::error(Ring::app(),ErrorMessage::GENERIC_ERROR);
   }

   // Start remaining initialisation
   initializePaths();
   initializeMainWindow();

// #ifdef DISABLE_UNIQUE_APPLICATION
   newInstance();
// #endif
}
Example #12
0
bool SambaComponent::parseJson(const QJsonObject& obj)
{
	// parse JSON
	QString module = obj["module"].toString();
	QString module_version = obj["module_version"].toString();
	QString classname = obj["classname"].toString();
	QString type = obj["type"].toString();

	if (type == "connection")
		m_type = COMPONENT_CONNECTION;
	else if (type == "device")
		m_type = COMPONENT_DEVICE;
	else if (type == "board")
		m_type = COMPONENT_BOARD;

	// create component
	QString script = QString("import %1 %2; %3 { }")
			.arg(module).arg(module_version).arg(classname);
	m_component = new QQmlComponent(m_engine->qmlEngine());
	m_component->setData(script.toLocal8Bit(), QUrl());
	if (m_component->status() != QQmlComponent::Ready) {
		qCCritical(sambaLogQml) << script;
		qCCritical(sambaLogQml) << m_component->errorString();
		return false;
	}

	// create instance to get name and aliases
	QObject* object = newInstance();
	if (object) {
		m_name = object->property("name").toString();
		m_aliases = object->property("aliases").toStringList();
		m_priority = object->property("priority").toInt();
		delete object;
	}

	return true;
}
Example #13
0
void KUniqueApplication::newInstanceNoFork()
{
  if (dcopClient()->isSuspended())
  {
    // Try again later.
    TQTimer::singleShot( 200, this, TQT_SLOT(newInstanceNoFork()) );
    return;
  }
  
  s_handleAutoStarted = false;
  newInstance();
  d->firstInstance = false;
#if defined Q_WS_X11
  // KDE4 remove
  // A hack to make startup notification stop for apps which override newInstance()
  // and reuse an already existing window there, but use KWin::activateWindow()
  // instead of TDEStartupInfo::setNewStartupId(). Therefore KWin::activateWindow()
  // for now sets this flag. Automatically ending startup notification always
  // would cause problem if the new window would show up with a small delay.
  if( s_handleAutoStarted )
      TDEStartupInfo::handleAutoAppStartedSending();
#endif
  // What to do with the return value ?
}
Example #14
0
void
KUniqueApplication::processDelayed()
{
  if (dcopClient()->isSuspended())
  {
    // Try again later.
    TQTimer::singleShot( 200, this, TQT_SLOT(processDelayed()));
    return;
  }
  d->processingRequest = true;
  while( !d->requestList.isEmpty() )
  {
     DCOPRequest *request = d->requestList.take(0);
     TQByteArray replyData;
     TQCString replyType;
     if (request->fun == "newInstance()") {
       dcopClient()->setPriorityCall(false);
       TQDataStream ds(request->data, IO_ReadOnly);
       TDECmdLineArgs::loadAppArgs(ds);
       if( !ds.atEnd()) // backwards compatibility
       {
           TQCString asn_id;
           ds >> asn_id;
           setStartupId( asn_id );
       }
       s_handleAutoStarted = false;
       int exitCode = newInstance();
       d->firstInstance = false;
#if defined Q_WS_X11
       if( s_handleAutoStarted )
           TDEStartupInfo::handleAutoAppStartedSending(); // KDE4 remove?
#endif
       TQDataStream rs(replyData, IO_WriteOnly);
       rs << exitCode;
       replyType = "int";
     }
Example #15
0
RTObject * RTType::newInstance(FILE *f)
{
	std::string type = readString( f );
	return newInstance( type );
}
Example #16
0
/*!
    \qmlmethod QtAudioEngine1::SoundInstance QtAudioEngine1::Sound::newInstance()

    Returns a new \l SoundInstance.
*/
QDeclarativeSoundInstance* QDeclarativeSound::newInstance()
{
    return newInstance(false);
}
Example #17
0
RTObject * RTType::newInstance(SENode &node)
{
	std::string type;
	node[0]  >>  type;
	return newInstance( type );
}
QScriptValue post_data_list_class::newInstance()
{
	return newInstance(http_data_list());
}
Example #19
0
QScriptValue DirClass::createInstance(const QScriptContext &context)
{
    return context.argumentCount() > 0
            ? newInstance(context.argument(0).toString())
            : newInstance();
}
Example #20
0
QScriptValue ByteArrayClass::newInstance(const QString &text)
{
    const auto ba = text.toUtf8();
    engine()->reportAdditionalMemoryCost(ba.size());
    return newInstance(ba);
}
Example #21
0
QScriptValue TimerClass::newInstance() {
  return newInstance(new QTimer(engine()));
}
Example #22
0
/**
 * Emit the newInstance event
 */
void UAVObject::emitNewInstance(UAVObject * obj)
{
    emit newInstance(obj);
}
/**
 * Register an object with the manager. This function must be called for all newly created instances.
 * A new instance can be created directly by instantiating a new object or by calling clone() of
 * an existing object. The object will be registered and will be properly initialized so that it can accept
 * updates.
 */
bool UAVObjectManager::registerObject(UAVDataObject *obj)
{
    QMutexLocker locker(mutex);

    // Check if this object type is already in the list
    for (int objidx = 0; objidx < objects.length(); ++objidx) {
        // Check if the object ID is in the list
        if (objects[objidx].length() > 0 && objects[objidx][0]->getObjID() == obj->getObjID()) {
            // Check if this is a single instance object, if yes we can not add a new instance
            if (obj->isSingleInstance()) {
                return false;
            }
            // The object type has alredy been added, so now we need to initialize the new instance with the appropriate id
            // There is a single metaobject for all object instances of this type, so no need to create a new one
            // Get object type metaobject from existing instance
            UAVDataObject *refObj = dynamic_cast<UAVDataObject *>(objects[objidx][0]);
            if (refObj == NULL) {
                return false;
            }
            UAVMetaObject *mobj = refObj->getMetaObject();
            // If the instance ID is specified and not at the default value (0) then we need to make sure
            // that there are no gaps in the instance list. If gaps are found then then additional instances
            // will be created.
            if ((obj->getInstID() > 0) && (obj->getInstID() < MAX_INSTANCES)) {
                for (int instidx = 0; instidx < objects[objidx].length(); ++instidx) {
                    if (objects[objidx][instidx]->getInstID() == obj->getInstID()) {
                        // Instance conflict, do not add
                        return false;
                    }
                }
                // Check if there are any gaps between the requested instance ID and the ones in the list,
                // if any then create the missing instances.
                for (quint32 instidx = objects[objidx].length(); instidx < obj->getInstID(); ++instidx) {
                    UAVDataObject *cobj = obj->clone(instidx);
                    cobj->initialize(mobj);
                    objects[objidx].append(cobj);
                    getObject(cobj->getObjID())->emitNewInstance(cobj);
                    emit newInstance(cobj);
                }
                // Finally, initialize the actual object instance
                obj->initialize(mobj);
            } else if (obj->getInstID() == 0) {
                // Assign the next available ID and initialize the object instance
                obj->initialize(objects[objidx].length(), mobj);
            } else {
                return false;
            }
            // Add the actual object instance in the list
            objects[objidx].append(obj);
            getObject(obj->getObjID())->emitNewInstance(obj);
            emit newInstance(obj);
            return true;
        }
    }
    // If this point is reached then this is the first time this object type (ID) is added in the list
    // create a new list of the instances, add in the object collection and create the object's metaobject
    // Create metaobject
    QString mname = obj->getName();
    mname.append("Meta");
    UAVMetaObject *mobj = new UAVMetaObject(obj->getObjID() + 1, mname, obj);
    // Initialize object
    obj->initialize(0, mobj);
    // Add to list
    addObject(obj);
    addObject(mobj);
    return true;
}
Example #24
0
		virtual DatabaseWrapper open(const BenchmarkOptions& benchmarkOptions, size_type instanceNumber)
		{
			DatabaseWrapper newInstance(new BdbBtreeWrapper(benchmarkOptions, instanceNumber));
			return newInstance;
		}
Example #25
0
QScriptValue SqlQueryClass::newInstance(const QString s)
{
    return newInstance(QSqlQuery(s));
}
Example #26
0
	DatabaseWrapperFactory newBdbBtreeWrapperFactory()
	{
		DatabaseWrapperFactory newInstance(new BdbBtreeWrapperFactory());
		return newInstance;
	}
Example #27
0
QScriptValue SqlFieldClass::newInstance(const QString &fieldName, QVariant::Type type)
{
    return newInstance(QSqlField(fieldName, type));
}
QScriptValue SearchResultsScriptClass::newInstance()
{
	return newInstance(SearchResults());
}
Example #29
0
QScriptValue ByteArrayClass::newInstance(int size) {
//      engine()->reportAdditionalMemoryCost(size); // Requires Qt 4.7
    return newInstance(QByteArray(size, /*ch=*/0));
}
Example #30
0
QScriptValue TypedArray::newInstance(quint32 length) {
    ArrayBufferClass* array = getScriptEngine()->getArrayBufferClass();
    QScriptValue buffer = array->newInstance(length * _bytesPerElement);
    return newInstance(buffer, 0, length);
}