//---------------------------------------------------------------------------
int QueueElement::attachment_cb(struct MediaInfo_Event_Global_AttachedFile_0 *Event)
{
    std::string attachment((const char*)Event->Content, Event->Content_Size);

    std::string realname = "Unknown";
    if (Event->Name && Event->Name[0])
        realname = std::string(Event->Name);

    std::string path;

    if (Core::create_local_unique_data_filename("MediaconchTemp", "attachment", "", path) < 0)
        return 0;

    std::ofstream ofs(path.c_str(), std::ofstream::out);
    ofs.write(attachment.c_str(), attachment.size());
    ofs.close();

    Attachment *attach = new Attachment;
    attach->filename = path;
    attach->realname = realname;

    attachments.push_back(attach);

    return 0;
}
Example #2
0
void DeriveKey::activate()
{
	if (!mActive)
	{
        check(CSSM_CSP_CreateDeriveKeyContext(attachment()->handle(), mAlgorithm,
            mTargetType, mKeySize, mCred, mKey, mIterationCount, mSalt, mSeed, &mHandle));
		mActive = true;
    }
}
Example #3
0
Key
WrapKey::operator () (Key &keyToBeWrapped, const CssmData *descriptiveData)
{
	Key wrappedKey;

	check(CSSM_WrapKey(handle(), neededCred(), keyToBeWrapped, descriptiveData,
					   wrappedKey.makeNewKey(attachment())));
	wrappedKey->activate();

	return wrappedKey;
}
Example #4
0
Key
DeriveKey::operator () (CssmData *param, const KeySpec &spec)
{
	Key derivedKey;
	check(CSSM_DeriveKey(handle(), param, spec.usage, spec.attributes,
						 spec.label, &compositeRcc(),
						 derivedKey.makeNewKey(attachment())));
	derivedKey->activate();

	return derivedKey;
}
FramebufferConfiguration FramebufferConfiguration::DefaultFramebuffer(int w, int h)
{
   FramebufferConfiguration config(w,h);
   RenderbufferAttachment attachment(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT);
   config.addRenderbuffer(attachment);
   TextureConfig tCfg("color", GL_RGB, GL_RGB, GL_UNSIGNED_BYTE);
   tCfg.setWrapMode(GL_CLAMP_TO_BORDER);
   TextureAttachment tbuffer(tCfg,GL_COLOR_ATTACHMENT0);

   config.addTexturebuffer(tbuffer);
   return config;
}
Example #6
0
CameraAttachmentPtr CameraAttachment::New( EventThreadServices& eventThreadServices, const SceneGraph::Node& parentNode )
{
  CameraAttachmentPtr attachment( new CameraAttachment( eventThreadServices ) );

  // Transfer object ownership of scene-object to message
  SceneGraph::CameraAttachment* sceneObject = CreateSceneObject();
  AttachToNodeMessage( eventThreadServices.GetUpdateManager(), parentNode, sceneObject );

  // Keep raw pointer for message passing
  attachment->mSceneObject = sceneObject;

  return attachment;
}
Example #7
0
Key
UnwrapKey::operator () (const CssmKey &keyToBeUnwrapped, const KeySpec &spec)
{
	CssmData data(reinterpret_cast<uint8 *>(1), 0);
	Key unwrappedKey;
	check(CSSM_UnwrapKey(handle(), NULL,
						 &keyToBeUnwrapped, spec.usage, spec.attributes,
						 spec.label, &compositeRcc(),
						 unwrappedKey.makeNewKey(attachment()), &data));
	unwrappedKey->activate();

	return unwrappedKey;
}
Example #8
0
Key
UnwrapKey::operator () (const CssmKey &keyToBeUnwrapped, const KeySpec &spec,
						CssmData *descriptiveData)
{
	Key unwrappedKey;
	check(CSSM_UnwrapKey(handle(), NULL, &keyToBeUnwrapped, spec.usage,
						 spec.attributes, spec.label, &compositeRcc(),
						 unwrappedKey.makeNewKey(attachment()),
						 descriptiveData));
	unwrappedKey->activate();

	return unwrappedKey;
}
Example #9
0
void Pop3::Message::OnAttachment (GenericInput<'\0'> & input, std::string const & filename)
{
	Base64::Decoder decoder;
	std::auto_ptr<Attachment> attachment (new Pop3::Attachment (filename));
	Pop3::Attachment::Storage::Output output (attachment->GetStorage ());
	try
	{
		decoder.Decode (input, output);
	}
	catch (Base64::Exception e)
	{
		throw Pop3::MsgCorruptException (e.GetMessage ());
	}
	_attachments.push_back (attachment);
}
LightAttachmentPtr LightAttachment::New( const SceneGraph::Node& parentNode )
{
  StagePtr stage = Stage::GetCurrent();

  LightAttachmentPtr attachment( new LightAttachment( *stage ) );

  // Transfer object ownership of scene-object to message
  SceneGraph::LightAttachment* sceneObject = SceneGraph::LightAttachment::New();
  sceneObject->SetLight( attachment->mCachedLight );
  AttachToNodeMessage( stage->GetUpdateManager(), parentNode, sceneObject );

  // Keep raw pointer for message passing
  attachment->mSceneObject = sceneObject;

  return attachment;
}
void FillLayer::computeCachedPropertiesIfNeeded() const
{
    if (m_cachedPropertiesComputed)
        return;
    m_thisOrNextLayersClipMax = clip();
    m_thisOrNextLayersUseContentBox = clip() == ContentFillBox || origin() == ContentFillBox;
    m_thisOrNextLayersHaveLocalAttachment = attachment() == LocalBackgroundAttachment;
    m_cachedPropertiesComputed = true;

    if (m_next) {
        m_next->computeCachedPropertiesIfNeeded();
        m_thisOrNextLayersClipMax = clipMax(thisOrNextLayersClipMax(), m_next->thisOrNextLayersClipMax());
        m_thisOrNextLayersUseContentBox |= m_next->m_thisOrNextLayersUseContentBox;
        m_thisOrNextLayersHaveLocalAttachment |= m_next->m_thisOrNextLayersHaveLocalAttachment;
    }
}
Example #12
0
File: chord.cpp Project: Pfeil/CAN2
QString Chord::toString(MinorPolicy mpolicy, EnharmonicPolicy epolicy) const
{
    QString text = baseString(epolicy);

    if (isMinor())
    {
        switch (mpolicy)
        {
        case LowerCase:
            text = text.toLower();
            break;
        case FollowingM:
            text += "m";
            break;
        }
    }

    return m_before + text + attachment() + m_after;
}
Example #13
0
HDRScene::HDRScene(Context * ctx):
   camera(ctx->getWindowWidth(),ctx->getWindowHeight()),
   woodTex(TextureConfig("assets/textures/wood.png",GL_SRGB,GL_RGB,GL_UNSIGNED_BYTE), 64.0f,
           TextureConfig("assets/textures/solid_black.png"))
{

   tunnel.transform.setScale(glm::vec3(5.0f, 5.0f, 55.0f));
   tunnel.transform.translate(glm::vec3(0.0,0.0,25.0));

   hdrExposureProg = createProgram("Phong lighting program");
   hdrPostProcessProg = createProgram("HDR Postprocessing program");
   
   FramebufferConfiguration config(ctx->getWindowWidth(),ctx->getWindowHeight());
   TextureAttachment attachment(TextureConfig("color",GL_RGB16F,GL_RGB,GL_FLOAT),GL_COLOR_ATTACHMENT0);
   config.addTexturebuffer(attachment);
   config.addRenderbuffer(RenderbufferAttachment(GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT));
   framebuffer.init(config);




}
void TestKeePass2Format::testKdbxDeviceFailure()
{
    auto key = QSharedPointer<CompositeKey>::create();
    key->addKey(QSharedPointer<PasswordKey>::create("test"));
    QScopedPointer<Database> db(new Database());
    db->setKey(key);
    // Disable compression so we write a predictable number of bytes.
    db->setCompressionAlgorithm(Database::CompressionNone);

    auto entry = new Entry();
    entry->setParent(db->rootGroup());
    QByteArray attachment(4096, 'Z');
    entry->attachments()->set("test", attachment);

    FailDevice failDevice(512);
    QVERIFY(failDevice.open(QIODevice::WriteOnly));
    bool hasError;
    QString errorString;
    writeKdbx(&failDevice, db.data(), hasError, errorString);
    QVERIFY(hasError);
    QCOMPARE(errorString, QString("FAILDEVICE"));
}
TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const TextArray& text, FontPointer font, bool isLeftToRight )
{
  StagePtr stage = Stage::GetCurrent();

  TextAttachmentPtr attachment( new TextAttachment( *stage ) );

  // Second-phase construction

  attachment->mFont = font;
  attachment->mText = text;
  attachment->mIsLeftToRight = isLeftToRight;

  // Transfer object ownership of scene-object to message
  SceneGraph::TextAttachment* sceneObject = SceneGraph::TextAttachment::New();

  AttachToNodeMessage( stage->GetUpdateManager(), parentNode, sceneObject );

  // Keep raw pointer for message passing
  attachment->mSceneObject = sceneObject;

  attachment->SetSmoothEdge(attachment->mSmoothing);      // adjust smoothedge for font weight

  return attachment;
}
Example #16
0
void Post::Serialize(Json::Value& root) {
    // General Post
    if(!id_.empty())
        root["id"] = id_;
    if(!entity_.empty())
        root["entity"] = entity_;

    /*
    if(!published_at_.empty())
        root["published_at"] = published_at_;
        */

    if(licenses_.size() > 0) {
        Json::Value licenses;
        jsn::SerializeVector(licenses_, licenses);
        root["licenses"] = licenses;
    }

    if(!type_.empty())
        root["type"] = type_;
   
    if(content_.size() > 0) {
        Json::Value content(Json::objectValue);
        jsn::SerializeMapIntoObject(content, content_);
        root["content"] = content;
    }

    if(attachments_.size() > 0) {
        Json::Value attachment_arr(Json::arrayValue);
        AttachmentMap::iterator itr = attachments_.begin();
        for(;itr!= attachments_.end(); itr++) {
            Json::Value attachment(Json::objectValue);
            itr->second.Serialize(attachment);
            attachment_arr.append(attachment);
        }
        root["attachments"] = attachment_arr;
    }

    if(mentions_.size() > 0) {
        Json::Value mentions_array(Json::arrayValue);
        MentionsList::iterator itr = mentions_.begin();
        for(;itr!= mentions_.end(); itr++) {
            Json::Value mention(Json::objectValue);
            jsn::SerializeObject(&(*itr), mention);
            mentions_array.append(mention);
        }
        root["mentions"] = mentions_array;
    }


    Json::Value app(Json::nullValue);
    tent_app_.Serialize(app); 
    if(!app.isNull())
        root["app"] = app;

    if(views_.size() > 0) {
        Json::Value views(Json::objectValue);
        jsn::SerializeMapIntoObject(views, views_);
        root["views"] = views;
    }

    Json::Value permissions(Json::objectValue);
    jsn::SerializeObject(&permissions_, permissions);
    root["permissions"] = permissions;

    Json::Value version(Json::objectValue);
    jsn::SerializeObject(&version_, version);
    root["version"] = version;
}
Example #17
0
{
    check(CSSM_QuerySize(handle(), encrypt, count, &sizes));
}


//
// The override() method of Context is an expert feature. It replaces the entire
// context with a context object provided. It is up to the caller to keep this context
// consistent with the purpose of the Context subclass he is (mis)using.
// This feature is currently used by the SecurityServer.
//
void Context::override(const Security::Context &ctx)
{
	if (!isActive()) {
		// make a valid context object (it doesn't matter what kind - keep it cheap)
		check(CSSM_CSP_CreateDigestContext(attachment()->handle(), CSSM_ALGID_NONE, &mHandle));
	}
	// now replace everything with the context data provided
	check(CSSM_SetContext(mHandle, &ctx));
	mActive = true;		// now active
}


//
// RccContexts
//
const ResourceControlContext &RccBearer::compositeRcc() const
{
	// explicitly specified RCC wins
	if (mRcc)
		return *mRcc;