Example #1
0
void printFieldContainer() {
    int N = FieldContainerFactory::the()->getNumTotalContainers();
    for (int i=0;i<N;++i) {
        FieldContainer* fc = FieldContainerFactory::the()->getContainer(i);
        if(fc == 0) continue;

        // skip prototypes
        if(fc->getType().getPrototype() == 0 || fc->getType().getPrototype() == fc  ) continue;

        //cout << "\nFC id: " << fc->getId() << flush;

        AttachmentContainer* ac = dynamic_cast<AttachmentContainer*>(fc);
        if (ac == 0) {
            Attachment* a = dynamic_cast<Attachment*>(fc);
            if (a != 0) {
                FieldContainer* dad = 0;
                if (a->getMFParents()->size() > 0) dad = a->getParents(0);
                ac = dynamic_cast<AttachmentContainer*>(dad);
            }
        }

        const Char8* name = getName(ac);
        if (name != 0) printf("Detected living FC %s (%s) %p refcount %d ID %d\n", fc->getTypeName(), name, fc, fc->getRefCount(), fc->getId());
        else printf( "Detected living FC %s %p refcount %d ID %d\n", fc->getTypeName(), fc, fc->getRefCount(), fc->getId() );
    }
}
Example #2
0
Attachment*
AttachArea::addAttachment(
    DtMail::Message *msg,
    DtMail::BodyPart *lastAttBP,
    String name,
    DtMailBuffer buf
)
{
    DtMailEnv mail_error;
    DtMail::BodyPart * bp = NULL;

    if (!name)
	name = "noname";

    mail_error.clear();

    bp = msg->newBodyPart(mail_error, lastAttBP);
    bp->setContents(mail_error, buf.buffer, buf.size, NULL, name, 0, NULL);

    Attachment *attachment = new Attachment(this,
					    name,
					    bp,
					    _iconCount + 1);
    attachment->setAttachArea(this);
    attachment->initialize();
    addToList(attachment);

    // Update the display.  The Compose Window needs immediate update.

    this->manageList();

    return(attachment);
}
/*! Callback called for each element in an AttachmentMap (this is used by
    preWriteAttachmentMapField).
 */
void OSBCommonElement::handleAttachmentMapElementPreWrite(
    FieldContainer *refedFC)
{
    OSG_OSB_LOG(("OSBCommonElement::handleAttachmentMapElementPreWrite\n"));

    if(refedFC == NULL)
        return;

    Attachment *refedAtt = dynamic_cast<Attachment *>(refedFC);

    // skip attachments marked as 'internal'
    if(refedAtt                              == NULL ||
       refedAtt->getSFInternal()->getValue() == true   )
    {
        return;
    }

    OSBRootElement    *root     = editRoot();
    UInt32             refedId  = refedAtt->getId  ();
    const std::string &typeName = refedAtt->getType().getName();

    // only schedule a container once
    if(root->getIdSet().count(refedId) > 0)
        return;

    OSBElementBase *elem = OSBElementFactory::the()->acquire(typeName, root);

    root->editIdSet      ().insert   (refedId);
    root->editElementList().push_back(elem   );
    elem->setContainer(refedAtt);
    elem->preWrite    (refedAtt);
}
Example #4
0
//
// Create a new attachment for this module
//
CSSM_HANDLE Module::attach(const CSSM_VERSION &version,
                           uint32 subserviceId,
                           CSSM_SERVICE_TYPE subserviceType,
                           const CSSM_API_MEMORY_FUNCS &memoryOps,
                           CSSM_ATTACH_FLAGS attachFlags,
                           CSSM_KEY_HIERARCHY keyHierarchy,
                           CSSM_FUNC_NAME_ADDR *functionTable,
                           uint32 functionTableSize)
{
    StLock<Mutex> _(mLock);
    
    // check if the module can do this kind of service
    if (!supportsService(subserviceType))
        CssmError::throwMe(CSSMERR_CSSM_INVALID_SERVICE_MASK);

    Attachment *attachment = cssm.attachmentMakerFor(subserviceType)->make(this,
                                   version,
                                   subserviceId, subserviceType,
                                   memoryOps,
                                   attachFlags,
                                   keyHierarchy,
                                   functionTable, functionTableSize);

    try {
        // add to module's attachment map
        attachmentMap.insert(AttachmentMap::value_type(attachment->handle(), attachment));
    } catch (...) {
        delete attachment;
        throw;
    }

    // all done
    return attachment->handle();
}
Example #5
0
void Attachment::IdleTimer::handler()
{
	m_fireTime = 0;
	if (!m_expTime)	// Timer was reset to zero, do nothing
		return;

	// Ensure attachment is still alive and idle

	StableAttachmentPart* stable = m_attachment->getStable();
	if (!stable)
		return;

	MutexEnsureUnlock guard(*stable->getMutex(), FB_FUNCTION);
	if (!guard.tryEnter())
		return;

	if (!m_expTime)
		return;

	// If timer was reset to fire later, restart ITimer
	time_t curTime = time(NULL);
	if (curTime < m_expTime)
	{
		reset(m_expTime - curTime);
		return;
	}

	Attachment* att = stable->getHandle();
	att->signalShutdown(isc_att_shut_idle);
	JRD_shutdown_attachment(att);
}
Example #6
0
Attachment * Attachment::attachmentWithRFC822Message(Data * messageData)
{
    Attachment * attachment;
    
    attachment = new Attachment();
    attachment->setMimeType(MCSTR("message/rfc822"));
    attachment->setData(messageData);
    
    return (Attachment *) attachment->autorelease();
}
Example #7
0
void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawElements, const FGeometry& AllottedGeometry, Skeleton* Skeleton) {
	TArray<FVector> vertices;
	TArray<int32> indices;
	TArray<FVector2D> uvs;
	TArray<FColor> colors;
	TArray<FVector> darkColors;

	int idx = 0;
	int meshSection = 0;
	UMaterialInstanceDynamic* lastMaterial = nullptr;

	SkeletonClipping &clipper = widget->clipper;
	Vector<float> &worldVertices = widget->worldVertices;

	float depthOffset = 0;
	unsigned short quadIndices[] = { 0, 1, 2, 0, 2, 3 };

	for (int i = 0; i < (int)Skeleton->getSlots().size(); ++i) {
		Vector<float> &attachmentVertices = worldVertices;
		unsigned short* attachmentIndices = nullptr;
		int numVertices;
		int numIndices;
		AtlasRegion* attachmentAtlasRegion = nullptr;
		Color attachmentColor;
		attachmentColor.set(1, 1, 1, 1);
		float* attachmentUvs = nullptr;

		Slot* slot = Skeleton->getDrawOrder()[i];
		Attachment* attachment = slot->getAttachment();
		if (!attachment) continue;
		if (!attachment->getRTTI().isExactly(RegionAttachment::rtti) && !attachment->getRTTI().isExactly(MeshAttachment::rtti) && !attachment->getRTTI().isExactly(ClippingAttachment::rtti)) continue;

		if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
			RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
			attachmentColor.set(regionAttachment->getColor());
			attachmentAtlasRegion = (AtlasRegion*)regionAttachment->getRendererObject();
			regionAttachment->computeWorldVertices(slot->getBone(), attachmentVertices, 0, 2);
			attachmentIndices = quadIndices;
			attachmentUvs = regionAttachment->getUVs().buffer();
			numVertices = 4;
			numIndices = 6;
		}
		else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
			MeshAttachment* mesh = (MeshAttachment*)attachment;
			attachmentColor.set(mesh->getColor());
			attachmentAtlasRegion = (AtlasRegion*)mesh->getRendererObject();
			mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices, 0, 2);
			attachmentIndices = mesh->getTriangles().buffer();
			attachmentUvs = mesh->getUVs().buffer();
			numVertices = mesh->getWorldVerticesLength() >> 1;
			numIndices = mesh->getTriangles().size();
		}
		else /* clipping */ {
Example #8
0
void
ViewMsgDialog::invokeAttachmentAction(
    int index
)
{
    DtMailEditor *editor = this->get_editor();
    AttachArea *attacharea = editor->attachArea();
    Attachment *attachment = attacharea->getSelectedAttachment();

    attachment->invokeAction(index);

}
Example #9
0
void
AttachArea::saveAttachmentToFile(
    DtMailEnv &mail_error,
    char *save_path
)
{

    Attachment *attachment = this->getSelectedAttachment();

    if(attachment != NULL)
    	attachment->saveToFile(mail_error, save_path);

}
Example #10
0
Attachment * Attachment::attachmentWithText(String * text)
{
    Data * data;
    Attachment * attachment;
    
    attachment = new Attachment();
    attachment->setInlineAttachment(true);
    attachment->setMimeType(MCSTR("text/plain"));
    data = text->dataUsingEncoding("utf-8");
    attachment->setData(data);
    
    return (Attachment *) attachment->autorelease();
}
Example #11
0
Attachment * Attachment::attachmentWithHTMLString(String * htmlString)
{
    Data * data;
    Attachment * attachment;
    
    attachment = new Attachment();
    attachment->setInlineAttachment(true);
    attachment->setMimeType(MCSTR("text/html"));
    data = htmlString->dataUsingEncoding("utf-8");
    attachment->setData(data);
    
    return (Attachment *) attachment->autorelease();
}
Example #12
0
void
AttachArea::undeleteLastDeletedAttachment(
    DtMailEnv &mail_error
)
{

    Attachment *tmpAttachment;
    Attachment **list;
    time_t time_deleted = 0, tmpTime = 0;
    int i;

    if (_deleteCount == 0) {
	return;
    }

    list = getList();

    tmpAttachment = list[0];
    time_deleted = tmpAttachment->getBodyPart()->getDeleteTime(mail_error);
    if (mail_error.isSet()) {
	// do something
    }

    for (i=1; i<getIconCount(); i++) {
	if (list[i]->isDeleted()) {
	    tmpTime = list[i]->getBodyPart()->getDeleteTime(mail_error);
	    if (mail_error.isSet()) {
		// do something
	    }
	    if ( tmpTime > time_deleted) {
		time_deleted = tmpTime;
		tmpAttachment = list[i];
	    }
	}
    }

    tmpAttachment->undeleteIt();
    _deleteCount--;

    // Unmanage all.
    // Their positions need to get recomputed and the deleted
    // ones get remanaged in manageList().

    for (i=0; i<getIconCount(); i++) {
	list[i]->unmanageIconWidget();
    }


    this->manageList();

}
Example #13
0
void AttachmentBase::execSyncV(      FieldContainer    &oFrom,
                                        ConstFieldMaskArg  whichField,
                                        AspectOffsetStore &oOffsets,
                                        ConstFieldMaskArg  syncMode,
                                  const UInt32             uiSyncInfo)
{
    Attachment *pThis = static_cast<Attachment *>(this);

    pThis->execSync(static_cast<Attachment *>(&oFrom),
                    whichField,
                    oOffsets,
                    syncMode,
                    uiSyncInfo);
}
Example #14
0
void KOIncidenceEditor::createEmbeddedURLPages(Incidence *i)
{
    kdDebug(5850) << "KOIncidenceEditor::createEmbeddedURLPages()" << endl;

    if(!i) return;
    if(!mEmbeddedURLPages.isEmpty())
    {
        kdDebug(5850) << "mEmbeddedURLPages are not empty, clearing it!" << endl;
        mEmbeddedURLPages.setAutoDelete(true);
        mEmbeddedURLPages.clear();
        mEmbeddedURLPages.setAutoDelete(false);
    }
    if(!mAttachedDesignerFields.isEmpty())
    {
        for(QPtrList<QWidget>::Iterator it = mAttachedDesignerFields.begin();
                it != mAttachedDesignerFields.end(); ++it)
        {
            if(mDesignerFieldForWidget.contains(*it))
            {
                mDesignerFields.remove(mDesignerFieldForWidget[ *it ]);
            }
        }
        mAttachedDesignerFields.setAutoDelete(true);
        mAttachedDesignerFields.clear();
        mAttachedDesignerFields.setAutoDelete(false);
    }

    Attachment::List att = i->attachments();
    for(Attachment::List::Iterator it = att.begin(); it != att.end(); ++it)
    {
        Attachment *a = (*it);
        kdDebug(5850) << "Iterating over the attachments " << endl;
        kdDebug(5850) << "label=" << a->label() << ", url=" << a->uri() << ", mimetype=" << a->mimeType() << endl;
        if(a && a->showInline() && a->isUri())
        {
            // TODO: Allow more mime-types, but add security checks!
            /*      if ( a->mimeType() == "application/x-designer" ) {
                    QString tmpFile;
                    if ( KIO::NetAccess::download( a->uri(), tmpFile, this ) ) {
                      mAttachedDesignerFields.append( addDesignerTab( tmpFile ) );
                      KIO::NetAccess::removeTempFile( tmpFile );
                    }
                  } else*/
            // TODO: Enable that check again!
            if(a->mimeType() == "text/html")
            {
                setupEmbeddedURLPage(a->label(), a->uri(), a->mimeType());
            }
        }
    }
}
Example #15
0
Attachment * Attachment::attachmentWithData(String * filename, Data * data)
{
    Attachment * attachment;
    String * mimeType;
    
    attachment = new Attachment();
    mimeType = Attachment::mimeTypeForFilename(filename);
    if (mimeType != NULL) {
        attachment->setMimeType(mimeType);
    }
    if (filename != NULL) {
        attachment->setFilename(filename->lastPathComponent());
    }
    attachment->setData(data);
    
    return (Attachment *) attachment->autorelease();
}
bool
WebGLFramebuffer::Attachment::HasSameDimensionsAs(const Attachment& other) const {
    const WebGLRectangleObject *thisRect = RectangleObject();
    const WebGLRectangleObject *otherRect = other.RectangleObject();
    return thisRect &&
           otherRect &&
           thisRect->HasSameDimensionsAs(*otherRect);
}
void ExecuteStatement::execute(Jrd::thread_db* tdbb, jrd_req* request, DSC* desc)
{
    SET_TDBB(tdbb);

    Attachment* attachment = tdbb->getAttachment();
    jrd_tra* const transaction = tdbb->getTransaction();

    if (transaction->tra_callback_count >= MAX_CALLBACKS)
    {
        ERR_post(Arg::Gds(isc_exec_sql_max_call_exceeded));
    }

    Firebird::string sqlStatementText;
    getString(tdbb, sqlStatementText, desc, request);

    transaction->tra_callback_count++;

    try
    {
        AutoPtr<PreparedStatement> stmt(attachment->prepareStatement(
                                            tdbb, *tdbb->getDefaultPool(), transaction, sqlStatementText));

        // Other requests appear to be incorrect in this context
        const long requests =
            (1 << REQ_INSERT) | (1 << REQ_DELETE) | (1 << REQ_UPDATE) |
            (1 << REQ_DDL) | (1 << REQ_SET_GENERATOR) | (1 << REQ_EXEC_PROCEDURE) |
            (1 << REQ_EXEC_BLOCK);

        if (!((1 << stmt->getRequest()->req_type) & requests))
        {
            ERR_post(Arg::Gds(isc_sqlerr) << Arg::Num(-902) <<
                     Arg::Gds(isc_exec_sql_invalid_req) << Arg::Str(sqlStatementText));
        }

        stmt->execute(tdbb, transaction);

        fb_assert(transaction == tdbb->getTransaction());
    }
    catch (const Firebird::Exception&)
    {
        transaction->tra_callback_count--;
        throw;
    }

    transaction->tra_callback_count--;
}
void FieldTraits<AttachmentMap>::copyFromBin(BinaryDataHandler &pMem,
                                             AttachmentMap     &aMap )
{
    Attachment *attPtr;
    UInt32      key;
    UInt16      binding;
    UInt32      fcId;
    UInt32      size;
        
    pMem.getValue(size);


    AttachmentMap::const_iterator mapIt  = aMap.begin();
    AttachmentMap::const_iterator mapEnd = aMap.end  ();

    for(; mapIt != mapEnd; ++mapIt)
    {
        if((*mapIt).second != NULL)
        {
            Thread::getCurrentChangeList()->addDelayedSubRef<
            UnrecordedRefCountPolicy>((*mapIt).second);
        }
    }
        
    aMap.clear();

        
    for(UInt32 i = 0; i < size; ++i)
    {
        pMem.getValue(binding);
        pMem.getValue(fcId   );
        
        attPtr = dynamic_cast<Attachment *>(
            FieldContainerFactory::the()->getMappedContainer(fcId));

        if(attPtr != NULL)
        {
            key = (static_cast<UInt32>(attPtr->getGroupId()) << 16) | binding;

            UnrecordedRefCountPolicy::addRef(attPtr);

            aMap.insert(AttachmentMap::value_type(key, attPtr));
        }
    }
}
Example #19
0
LiteralNode* MAKE_system_privilege(const char* privilege)
{
	thread_db* tdbb = JRD_get_thread_data();
	Attachment* att = tdbb->getAttachment();
	jrd_tra* tra = att->getSysTransaction();

	string p(privilege);
	p.upper();
	USHORT value = SCL_convert_privilege(tdbb, tra, p);

	USHORT* valuePtr = FB_NEW_POOL(*tdbb->getDefaultPool()) USHORT(value);

	LiteralNode* literal = FB_NEW_POOL(*tdbb->getDefaultPool()) LiteralNode(*tdbb->getDefaultPool());
	literal->litDesc.dsc_dtype = dtype_short;
	literal->litDesc.dsc_length = sizeof(USHORT);
	literal->litDesc.dsc_scale = 0;
	literal->litDesc.dsc_sub_type = 0;
	literal->litDesc.dsc_address = reinterpret_cast<UCHAR*>(valuePtr);

	return literal;
}
Example #20
0
bool Attachment::operator==( const Attachment &a2 ) const
{
  return uri()          == a2.uri() &&
         d->mLabel      == a2.label() &&
         d->mLocal      == a2.isLocal() &&
         d->mBinary     == a2.isBinary() &&
         d->mShowInline == a2.showInline() &&
         size()         == a2.size() &&
         decodedData()  == a2.decodedData();
}
void
WebGLFramebuffer::FramebufferTexture2D(GLenum target,
                                       GLenum attachment,
                                       GLenum textarget,
                                       WebGLTexture* wtex,
                                       GLint level)
{
    MOZ_ASSERT(mContext->mBoundFramebuffer == this);

    if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture", wtex))
        return;

    if (target != LOCAL_GL_FRAMEBUFFER)
        return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: target", target);

    if (textarget != LOCAL_GL_TEXTURE_2D &&
        (textarget < LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X ||
         textarget > LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))
    {
        return mContext->ErrorInvalidEnumInfo("framebufferTexture2D: invalid texture target", textarget);
    }

    if (wtex) {
        bool isTexture2D = wtex->Target() == LOCAL_GL_TEXTURE_2D;
        bool isTexTarget2D = textarget == LOCAL_GL_TEXTURE_2D;
        if (isTexture2D != isTexTarget2D) {
            return mContext->ErrorInvalidOperation("framebufferTexture2D: mismatched texture and texture target");
        }
    }

    if (level != 0)
        return mContext->ErrorInvalidValue("framebufferTexture2D: level must be 0");

    /* Get the requested attachment. If result is NULL, attachment is
     * invalid and an error is generated.
     *
     * Don't use GetAttachment(...) here because it opt builds it
     * returns mColorAttachment[0] for invalid attachment, which we
     * really don't want to mess with.
     */
    Attachment* a = GetAttachmentOrNull(attachment);
    if (!a)
        return; // Error generated internally to GetAttachmentOrNull.

    /* Invalidate cached framebuffer status and inform texture of it's
     * new attachment
     */
    mStatus = 0;
    // Detach current
    if (a->Texture())
        a->Texture()->DetachFrom(this, attachment);
    else if (a->Renderbuffer())
        a->Renderbuffer()->DetachFrom(this, attachment);

    // Attach new
    if (wtex)
        wtex->AttachTo(this, attachment);

    a->SetTexImage(wtex, textarget, level);
}
Example #22
0
Attachment* 
AttachArea::addAttachment( 
    String name,
    DtMail::BodyPart *body_part
)
{
    // _iconCount + 1 because iconCount starts at 0 and we want 
    //  attachmentCount to begin at 1.  attachmentCount is set to be
    // in the widget's userData.  

    Attachment *attachment = new Attachment(
					this, 
					name, 
					body_part, 
					_iconCount + 1
				);
    attachment->setAttachArea(this);
    attachment->initialize();
    addToList( attachment );

    return(attachment);
}
Example #23
0
void
WebGLFramebuffer::FramebufferTexture2D(FBAttachment attachPoint,
                                       TexImageTarget texImageTarget,
                                       WebGLTexture* tex, GLint level)
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture",
                                           tex))
    {
        return;
    }

    if (tex) {
        bool isTexture2D = tex->Target() == LOCAL_GL_TEXTURE_2D;
        bool isTexTarget2D = texImageTarget == LOCAL_GL_TEXTURE_2D;
        if (isTexture2D != isTexTarget2D) {
            mContext->ErrorInvalidOperation("framebufferTexture2D: Mismatched"
                                            " texture and texture target.");
            return;
        }
    }

    if (level != 0) {
        mContext->ErrorInvalidValue("framebufferTexture2D: Level must be 0.");
        return;
    }

    /* Get the requested attachment. If result is NULL, attachment is invalid
     * and an error is generated.
     *
     * Don't use GetAttachment(...) here because it opt builds it returns
     * mColorAttachment[0] for invalid attachment, which we really don't want to
     * mess with.
     */
    Attachment* attachment = GetAttachmentOrNull(attachPoint);
    if (!attachment)
        return; // Error generated internally to GetAttachmentOrNull.

    // Invalidate cached framebuffer status and inform texture of its new
    // attachment.
    mStatus = 0;

    // Detach current:
    if (attachment->Texture())
        attachment->Texture()->DetachFrom(this, attachPoint);
    else if (attachment->Renderbuffer())
        attachment->Renderbuffer()->DetachFrom(this, attachPoint);

    // Attach new:
    if (tex)
        tex->AttachTo(this, attachPoint);

    attachment->SetTexImage(tex, texImageTarget, level);
}
Example #24
0
void
ViewMsgDialog::save_selected_attachment(
    char *selection
)
{
   
    DtMailEnv mail_error;
    
    mail_error.clear();
    DtMailEditor *editor = this->get_editor();
    AttachArea *attacharea = editor->attachArea();
    Attachment *attachment = attacharea->getSelectedAttachment();

   // Get selected attachment, if none selected, then return.
   if ( attachment == NULL ) {
	  // Let User know that no attachment has been selected???
	  int answer = 0;
	  char *helpId = NULL;


	  _genDialog->setToErrorDialog(
		    GETMSG(DT_catd, 1, 177, "Mailer"),		  
		    GETMSG(DT_catd, 2, 20, "An attachment needs to be selected before issuing the\n\"Save As\" command to save to a file.") );
	  helpId = DTMAILHELPSELECTATTACH;
	  answer = _genDialog->post_and_return(
			GETMSG(DT_catd, 3, 75, "OK"), helpId );
	  return;
      }

    attachment->saveToFile(mail_error, selection);

    if (mail_error.isSet()) {
	// do something
    }

}
Example #25
0
AudioItem Attachment::to(const Attachment &data)
{
    AudioItem item;
    item.setId(data.property("aid").toInt());
    item.setOwnerId(data.property("owner_id").toInt());
    item.setArtist(data.property("performer").toString());
    item.setTitle(data.property("title").toString());
    item.setUrl(data.property("url").toUrl());
    item.setDuration(data.property("duration").toDouble());
    return item;
}
void
WebGLFramebuffer::FramebufferRenderbuffer(GLenum target,
                                          GLenum attachment,
                                          GLenum rbtarget,
                                          WebGLRenderbuffer* wrb)
{
    MOZ_ASSERT(mContext->mBoundFramebuffer == this);

    if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: renderbuffer", wrb))
        return;

    if (target != LOCAL_GL_FRAMEBUFFER)
        return mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: target", target);

    if (rbtarget != LOCAL_GL_RENDERBUFFER)
        return mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: renderbuffer target:", rbtarget);

    /* Get the requested attachment. If result is NULL, attachment is
     * invalid and an error is generated.
     *
     * Don't use GetAttachment(...) here because it opt builds it
     * returns mColorAttachment[0] for invalid attachment, which we
     * really don't want to mess with.
     */
    Attachment* a = GetAttachmentOrNull(attachment);
    if (!a)
        return; // Error generated internally to GetAttachmentOrNull.

    /* Invalidate cached framebuffer status and inform texture of it's
     * new attachment
     */
    mStatus = 0;
    // Detach current
    if (a->Texture())
        a->Texture()->DetachFrom(this, attachment);
    else if (a->Renderbuffer())
        a->Renderbuffer()->DetachFrom(this, attachment);

    // Attach new
    if (wrb)
        wrb->AttachTo(this, attachment);

    a->SetRenderbuffer(wrb);
}
Example #27
0
void
WebGLFramebuffer::FramebufferRenderbuffer(FBAttachment attachPoint,
                                          RBTarget rbtarget,
                                          WebGLRenderbuffer* rb)
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: renderbuffer",
                                           rb))
    {
        return;
    }

    /* Get the requested attachment. If result is NULL, attachment is invalid
     * and an error is generated.
     *
     * Don't use GetAttachment(...) here because it opt builds it returns
     * mColorAttachment[0] for invalid attachment, which we really don't want to
     * mess with.
     */
    Attachment* attachment = GetAttachmentOrNull(attachPoint);
    if (!attachment)
        return; // Error generated internally to GetAttachmentOrNull.

    // Invalidate cached framebuffer status and inform texture of its new
    // attachment.
    mStatus = 0;

    // Detach current:
    if (attachment->Texture())
        attachment->Texture()->DetachFrom(this, attachPoint);
    else if (attachment->Renderbuffer())
        attachment->Renderbuffer()->DetachFrom(this, attachPoint);

    // Attach new:
    if (rb)
        rb->AttachTo(this, attachPoint);

    attachment->SetRenderbuffer(rb);
}
void VsSpring::SetupPhysics()
{
	if(m_vxSpring)
		DeletePhysics();

	if(m_aryAttachmentPoints.GetSize() == 2)
	{
		Attachment *lpPrimaryAttachment = m_aryAttachmentPoints[0];
		Attachment *lpSecondaryAttachment = m_aryAttachmentPoints[1];

		if(!lpPrimaryAttachment && !lpSecondaryAttachment)
		{
			Enabled(false);
			return;
		}

		VsRigidBody *lpVsPrimary = dynamic_cast<VsRigidBody *>(lpPrimaryAttachment->Parent());
		VsRigidBody *lpVsSecondary = dynamic_cast<VsRigidBody *>(lpSecondaryAttachment->Parent());

		if(!lpVsPrimary && !lpVsSecondary)
		{
			Enabled(false);
			return;
		}

		m_vxSpring = new AnimatVxSpring(lpVsPrimary->Part(), lpVsSecondary->Part(), m_fltNaturalLength, m_fltStiffness, m_fltDamping); // attached to the reference frame.

		CStdFPoint vPrimPos = lpPrimaryAttachment->AbsolutePosition();
		CStdFPoint vSecPos = lpSecondaryAttachment->AbsolutePosition();
		
	    m_vxSpring->setPartAttachmentPosition(0, vPrimPos.x, vPrimPos.y, vPrimPos.z);
	    m_vxSpring->setPartAttachmentPosition(1, vSecPos.x, vSecPos.y, vSecPos.z);

		m_vxSpring->enable(m_bEnabled);
		GetVsSimulator()->Universe()->addConstraint(m_vxSpring);
	}
	else
		Enabled(false);
}
Example #29
0
static bool shutdown_locks(thread_db* tdbb, SSHORT flag)
{
    /**************************************
     *
     *	s h u t d o w n _ l o c k s
     *
     **************************************
     *
     * Functional description
     *	Release all attachment and database
     *	locks if database is quiet.
     *
     **************************************/
    Database* dbb = tdbb->getDatabase();

    /* Mark database and all active attachments as shutdown. */

    dbb->dbb_ast_flags &= ~(DBB_shutdown | DBB_shutdown_single | DBB_shutdown_full);

    switch (flag & isc_dpb_shut_mode_mask)
    {
    case isc_dpb_shut_normal:
        break;
    case isc_dpb_shut_multi:
        dbb->dbb_ast_flags |= DBB_shutdown;
        break;
    case isc_dpb_shut_single:
        dbb->dbb_ast_flags |= DBB_shutdown | DBB_shutdown_single;
        break;
    case isc_dpb_shut_full:
        dbb->dbb_ast_flags |= DBB_shutdown | DBB_shutdown_full;
        break;
    default:
        fb_assert(false);
    }

    Attachment* attachment;

    for (attachment = dbb->dbb_attachments; attachment; attachment = attachment->att_next)
    {
        if (!(attachment->att_flags & ATT_shutdown_manager))
        {
            attachment->att_flags |= ATT_shutdown;
            attachment->cancelExternalConnection(tdbb);
            LCK_cancel_wait(attachment);
        }
    }

    JRD_shutdown_attachments(dbb);

    for (int retry = 0; retry < 10 && dbb->dbb_use_count; retry++)
    {
        // Let active database threads rundown
        Database::Checkout dcoHolder(dbb);
        THREAD_SLEEP(1 * 100);
    }

    if (dbb->dbb_use_count)
    {
        return false;
    }

    /* Since no attachment is actively running, release all
       attachment-specfic locks while they're not looking. */

    const Attachment* shut_attachment = NULL;

    for (attachment = dbb->dbb_attachments; attachment; attachment = attachment->att_next)
    {
        if (attachment->att_flags & ATT_shutdown_manager)
        {
            shut_attachment = attachment;
            continue;
        }

        if (attachment->att_id_lock)
            LCK_release(tdbb, attachment->att_id_lock);

        TRA_shutdown_attachment(tdbb, attachment);
    }

    /* Release database locks that are shared by all attachments.
       These include relation and index existence locks, as well
       as, relation interest and record locking locks for PC semantic
       record locking. */

    CMP_shutdown_database(tdbb);

    /* If shutdown manager is here, leave enough database lock context
       to run as a normal attachment. Otherwise, get rid of the rest
       of the database locks.*/

    if (!shut_attachment)
    {
        CCH_shutdown_database(dbb);
        if (dbb->dbb_monitor_lock)
            LCK_release(tdbb, dbb->dbb_monitor_lock);
        if (dbb->dbb_shadow_lock)
            LCK_release(tdbb, dbb->dbb_shadow_lock);
        if (dbb->dbb_retaining_lock)
            LCK_release(tdbb, dbb->dbb_retaining_lock);
        if (dbb->dbb_lock)
            LCK_release(tdbb, dbb->dbb_lock);
        dbb->dbb_shared_counter.shutdown(tdbb);
        dbb->dbb_backup_manager->shutdown(tdbb);
        dbb->dbb_ast_flags |= DBB_shutdown_locks;
    }

    return true;
}
Example #30
0
void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay)
{
    /**************************************
     *
     *	S H U T _ d a t a b a s e
     *
     **************************************
     *
     * Functional description
     *	Schedule database for shutdown
     *
     **************************************/
    SET_TDBB(tdbb);
    Database* dbb = tdbb->getDatabase();
    Attachment* attachment = tdbb->getAttachment();

    /* Only platform's user locksmith can shutdown or bring online
       a database. */

    if (!attachment->locksmith())
    {
        ERR_post(Arg::Gds(isc_no_priv) << "shutdown" << "database" << dbb->dbb_filename);
    }

    const int shut_mode = flag & isc_dpb_shut_mode_mask;

    // Check if requested shutdown mode is valid
    // Note that if we are already in requested mode we just return true.
    // This is required to ensure backward compatible behavior (gbak relies on that,
    // user-written scripts may rely on this behaviour too)
    switch (shut_mode)
    {
    case isc_dpb_shut_full:
        if (dbb->dbb_ast_flags & DBB_shutdown_full)
        {
            same_mode();
            return;
        }
        break;
    case isc_dpb_shut_multi:
        if ((dbb->dbb_ast_flags & DBB_shutdown_full) || (dbb->dbb_ast_flags & DBB_shutdown_single))
        {
            bad_mode();
        }
        if (dbb->dbb_ast_flags & DBB_shutdown)
        {
            same_mode();
            return;
        }
        break;
    case isc_dpb_shut_single:
        if (dbb->dbb_ast_flags & DBB_shutdown_full)
        {
            bad_mode();
        }
        if (dbb->dbb_ast_flags & DBB_shutdown_single)
        {
            same_mode();
            return;
        }
        break;
    case isc_dpb_shut_normal:
        if (!(dbb->dbb_ast_flags & DBB_shutdown))
        {
            same_mode();
            return;
        }
        bad_mode();
    default:
        bad_mode(); // unexpected mode
    }

    // Reject exclusive and single-user shutdown attempts
    // for a physically locked database

    if (shut_mode == isc_dpb_shut_full || shut_mode == isc_dpb_shut_single)
    {
        check_backup_state(tdbb);
    }

    attachment->att_flags |= ATT_shutdown_manager;
    --dbb->dbb_use_count;

    /* Database is being shutdown. First notification gives shutdown
       type and delay in seconds. */

    bool exclusive = notify_shutdown(tdbb, flag, delay);

    /* Notify local attachments */

    SHUT_blocking_ast(tdbb);

    /* Try to get exclusive database lock periodically up to specified delay. If we
       haven't gotten it report shutdown error for weaker forms. For forced shutdown
       keep notifying until successful. */

    SSHORT timeout = delay - SHUT_WAIT_TIME;

    if (!exclusive)
    {
        for (; timeout >= 0; timeout -= SHUT_WAIT_TIME)
        {
            if ((exclusive = notify_shutdown(tdbb, flag, timeout)) ||
                    !(dbb->dbb_ast_flags & (DBB_shut_attach | DBB_shut_tran | DBB_shut_force)))
            {
                break;
            }
        }
    }

    if (!exclusive && (timeout > 0 || flag & (isc_dpb_shut_attachment | isc_dpb_shut_transaction)))
    {
        notify_shutdown(tdbb, 0, -1);	/* Tell everyone we're giving up */
        SHUT_blocking_ast(tdbb);
        attachment->att_flags &= ~ATT_shutdown_manager;
        ++dbb->dbb_use_count;
        ERR_post(Arg::Gds(isc_shutfail));
    }

    /* Once there are no more transactions active, force all remaining
       attachments to shutdown. */

    if (flag & isc_dpb_shut_transaction)
    {
        exclusive = false;
        flag = isc_dpb_shut_force | shut_mode;
    }

    dbb->dbb_ast_flags |= DBB_shutdown;
    dbb->dbb_ast_flags &= ~(DBB_shutdown_single | DBB_shutdown_full);
    switch (shut_mode)
    {
    case isc_dpb_shut_normal:
    case isc_dpb_shut_multi:
        break;
    case isc_dpb_shut_single:
        dbb->dbb_ast_flags |= DBB_shutdown_single;
        break;
    case isc_dpb_shut_full:
        dbb->dbb_ast_flags |= DBB_shutdown_full;
        break;
    default:
        fb_assert(false);
    }

    if (!exclusive && (flag & isc_dpb_shut_force))
    {
        // TMN: Ugly counting!
        while (!notify_shutdown(tdbb, flag, 0))
            ;
    }

    ++dbb->dbb_use_count;
    dbb->dbb_ast_flags &= ~(DBB_shut_force | DBB_shut_attach | DBB_shut_tran);
    WIN window(HEADER_PAGE_NUMBER);
    Ods::header_page* header = (Ods::header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
    CCH_MARK_MUST_WRITE(tdbb, &window);
    // Set appropriate shutdown mode in database header
    header->hdr_flags &= ~Ods::hdr_shutdown_mask;
    switch (shut_mode)
    {
    case isc_dpb_shut_normal:
        break;
    case isc_dpb_shut_multi:
        header->hdr_flags |= Ods::hdr_shutdown_multi;
        break;
    case isc_dpb_shut_single:
        header->hdr_flags |= Ods::hdr_shutdown_single;
        break;
    case isc_dpb_shut_full:
        header->hdr_flags |= Ods::hdr_shutdown_full;
        break;
    default:
        fb_assert(false);
    }
    CCH_RELEASE(tdbb, &window);
    CCH_release_exclusive(tdbb);
}