Exemple #1
0
bool SIPFrom::getHost(const std::string& from, std::string& host)
{
  std::string uri;
  if (!getURI(from, uri))
    return false;
  return SIPURI::getHost(uri, host);
}
Exemple #2
0
bool MLModel::isSupportedAction( actions action, const QModelIndex &index ) const
{
    switch ( action )
    {
    case ACTION_ADDTOPLAYLIST:
        return index.isValid();
    case ACTION_SORT:
        return false;
    case ACTION_PLAY:
    case ACTION_STREAM:
    case ACTION_SAVE:
    case ACTION_INFO:
    case ACTION_REMOVE:
        return index.isValid();
    case ACTION_EXPLORE:
        if( index.isValid() )
            return getURI( index ).startsWith( "file://" );
    case ACTION_CREATENODE:
        return false;
    case ACTION_CLEAR:
        return rowCount() && canEdit();
    case ACTION_ENQUEUEFILE:
    case ACTION_ENQUEUEDIR:
    case ACTION_ENQUEUEGENERIC:
        return canEdit();
    default:
        return false;
    }
    return false;
}
Exemple #3
0
bool SIPFrom::getUser(const std::string& from, std::string& user)
{
  std::string uri;
  if (!getURI(from, uri))
    return false;
  return SIPURI::getUser(uri, user);
}
Exemple #4
0
/**
 * Check if we can advance the state machine by loading or playing
 */
void SoundPlayer::checkForNextStep()
{
	if (m_state == eState_Init)
	{
		if (!m_filePath.empty() && VERIFY(m_player == 0))
		{
			setState(eState_Connecting);
			startTimer();
			m_player = media::MediaClient::createLunaMediaPlayer(*this);
			m_player->addMediaPlayerChangeListener(m_mediaPlayerChangeListener);
		}
	}
	else if (m_state == eState_Connected)
	{
		if (m_filePath.empty())
		{	// if we had any problem, don't recycle this player...
			if (m_retries == 0)
				setState(eState_Finished);
			else
				setState(eState_Dead);
		}
		else if (VERIFY(m_player))
		{
			setState(eState_PlayPending);
			startTimer();
			m_player->load(getURI(), m_audioStreamClass);
			m_player->play();
		}
	}
}
void QRCodeDialog::genCode()
{
    QString uri = getURI();

    if (uri != "")
    {
        ui->lblQRCode->setText("");

        QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
        if (!code)
        {
            ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
            return;
        }
        myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
        myImage.fill(0xffffff);
        unsigned char *p = code->data;
        for (int y = 0; y < code->width; y++)
        {
            for (int x = 0; x < code->width; x++)
            {
                myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
                p++;
            }
        }
        QRcode_free(code);
        ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
    }
    else
        ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message."));
}
Exemple #6
0
void
registerBitmapClass(as_object& where, Global_as::ASFunction ctor,
        Global_as::Properties p, const ObjectURI& uri)
{
    Global_as& gl = getGlobal(where);

    VM& vm = getVM(where);

    // We should be looking for flash.filters.BitmapFilter, but as this
    // triggers a lookup of the flash.filters package while we are creating
    // it, so entering infinite recursion, we'll cheat and assume that
    // the object 'where' is the filters package.
    as_function* constructor =
        getMember(where, getURI(vm, "BitmapFilter")).to_function();
    
    as_object* proto;
    if (constructor) {
        fn_call::Args args;
        VM& vm = getVM(where);
        proto = constructInstance(*constructor, as_environment(vm), args);
    }
    else proto = 0;

    as_object* cl = gl.createClass(ctor, createObject(gl));
    if (proto) p(*proto);

    // The startup script overwrites the prototype assigned by ASconstructor,
    // so the new prototype doesn't have a constructor property. We do the
    // same here.
    cl->set_member(NSV::PROP_PROTOTYPE, proto);
    where.init_member(uri , cl, as_object::DefaultFlags);

}
/** @cond doxygenLibsbmlInternal */
void 
ListOfGlobalRenderInformation::writeXMLNS (XMLOutputStream& stream) const
{
  XMLNamespaces xmlns;
  xmlns.add(getURI(), getPrefix());
  stream << xmlns;
}
void MutableSong::setNewURI(const std::string &value)
{
	std::string orig_uri = getURI();
	if (orig_uri == value)
		m_uri.clear();
	else
		m_uri = value;
}
void WiredTigerRecordStore::appendCustomStats(OperationContext* txn,
                                              BSONObjBuilder* result,
                                              double scale) const {
    result->appendBool("capped", _isCapped);
    if (_isCapped) {
        result->appendIntOrLL("max", _cappedMaxDocs);
        result->appendIntOrLL("maxSize", static_cast<long long>(_cappedMaxSize / scale));
        result->appendIntOrLL("sleepCount", _cappedSleep.load());
        result->appendIntOrLL("sleepMS", _cappedSleepMS.load());
    }
    WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSession(txn);
    WT_SESSION* s = session->getSession();
    BSONObjBuilder bob(result->subobjStart(kWiredTigerEngineName));
    {
        BSONObjBuilder metadata(bob.subobjStart("metadata"));
        Status status = WiredTigerUtil::getApplicationMetadata(txn, getURI(), &metadata);
        if (!status.isOK()) {
            metadata.append("error", "unable to retrieve metadata");
            metadata.append("code", static_cast<int>(status.code()));
            metadata.append("reason", status.reason());
        }
    }

    std::string type, sourceURI;
    WiredTigerUtil::fetchTypeAndSourceURI(txn, _uri, &type, &sourceURI);
    StatusWith<std::string> metadataResult = WiredTigerUtil::getMetadata(txn, sourceURI);
    StringData creationStringName("creationString");
    if (!metadataResult.isOK()) {
        BSONObjBuilder creationString(bob.subobjStart(creationStringName));
        creationString.append("error", "unable to retrieve creation config");
        creationString.append("code", static_cast<int>(metadataResult.getStatus().code()));
        creationString.append("reason", metadataResult.getStatus().reason());
    } else {
        bob.append("creationString", metadataResult.getValue());
        // Type can be "lsm" or "file"
        bob.append("type", type);
    }

    Status status =
        WiredTigerUtil::exportTableToBSON(s, "statistics:" + getURI(), "statistics=(fast)", &bob);
    if (!status.isOK()) {
        bob.append("error", "unable to retrieve statistics");
        bob.append("code", static_cast<int>(status.code()));
        bob.append("reason", status.reason());
    }
}
Exemple #10
0
std::string SIPFrom::getAor()
{
  std::string uri;
  if (getURI(_data, uri))
    return "";
  std::string aor;
  SIPURI::getIdentity(uri, aor);
  return aor;
}
int FileFunction::raiseFileError( char const *aQName, char const *aMessage,
                                  String const &aPath ) const {
  Item const lQName(
    module_->getItemFactory()->createQName( getURI(), "file", aQName )
  );
  ostringstream lErrorMessage;
  lErrorMessage << '"' << aPath << "\": " << aMessage;
  throw USER_EXCEPTION( lQName, lErrorMessage.str() );
}
Exemple #12
0
bool SIPFrom::setUser(std::string& from, const char* user)
{
  std::string uri;
  if (!getURI(from, uri))
    return false;
  
  if (!SIPURI::setUserInfo(uri, user))
    return false;
  return setURI(from, uri.c_str());
}
void OpenURIDialog::accept()
{
    SendCoinsRecipient rcp;
    if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) {
        /* Only accept value URIs */
        QDialog::accept();
    } else {
        ui->uriEdit->setValid(false);
    }
}
Exemple #14
0
/**
 * In case of error, try again
 */
void SoundPlayer::onError()
{
	if (VERIFY(m_player) && eState_PlayPending && m_retries++ < 3)
	{
		m_player->unload();
		m_player->load(getURI(), m_audioStreamClass);
		m_player->seek(0);
		m_player->play();
	}
}
Exemple #15
0
bool SIPFrom::setHostPort(std::string& from, const char* hostPort)
{
  std::string uri;
  if (!getURI(from, uri))
    return false;

  if (!SIPURI::setHostPort(uri, hostPort))
    return false;
  return setURI(from, uri.c_str());
}
void SkImageRef_ashmem::flatten(SkFlattenableWriteBuffer& buffer) const {
    this->INHERITED::flatten(buffer);
    const char* uri = getURI();
    if (uri) {
        size_t len = strlen(uri);
        buffer.write32(len);
        buffer.writePad(uri, len);
    } else {
        buffer.write32(0);
    }
}
Exemple #17
0
eFlag Tree::parse(Sit S, DataLine *d)
{
    Log1(S, L1_PARSING, getURI());
    double time_was = getMillisecs();
    TreeConstructer tc(S);
    eFlag retval = tc.parseDataLineUsingExpat(S, this, d);
    if (!retval)
    {
        Log1(S, L1_PARSE_DONE, getMillisecsDiff(time_was));
    }
    return retval;
}
Status WiredTigerRecordStore::compact(OperationContext* txn,
                                      RecordStoreCompactAdaptor* adaptor,
                                      const CompactOptions* options,
                                      CompactStats* stats) {
    WiredTigerSessionCache* cache = WiredTigerRecoveryUnit::get(txn)->getSessionCache();
    WiredTigerSession* session = cache->getSession();
    WT_SESSION* s = session->getSession();
    int ret = s->compact(s, getURI().c_str(), "timeout=0");
    invariantWTOK(ret);
    cache->releaseSession(session);
    return Status::OK();
}
Exemple #19
0
    uint64_t Namespace::bytesUsedDeep() const
    {
        uint64_t size = bytesUsed();

        Atom prefix = getPrefix();
        if (AvmCore::isString(prefix))
            size += AvmCore::atomToString(prefix)->bytesUsed();

        size += getURI()->bytesUsed();

        return size;
    }
Exemple #20
0
static as_value
get_flash_text_package(const fn_call& fn)
{
    log_debug("Loading flash.text package");
 
    Global_as& gl = getGlobal(fn);

    as_object* pkg = createObject(gl);
    
    VM& vm = getVM(fn);

    textrenderer_class_init(*pkg, getURI(vm, "TextRenderer"));

    return pkg;
}
Exemple #21
0
static as_value
get_flash_net_package(const fn_call& fn)
{
    log_debug("Loading flash.net package");
 
    Global_as& gl = getGlobal(fn);

    as_object* pkg = createObject(gl);
    
    VM& vm = getVM(fn);

    filereference_class_init(*pkg, getURI(vm, "FileReference"));

    return pkg;
}
Exemple #22
0
bool NamespaceSupport::processName(const XMLString& qname, XMLString& namespaceURI, XMLString& localName, bool isAttribute) const
{
	XMLString prefix;
	Name::split(qname, prefix, localName);
	if (prefix.empty() && isAttribute)
	{
		namespaceURI.clear();
		return true;
	}
	else
	{
		namespaceURI = getURI(prefix);
		return !namespaceURI.empty() || prefix.empty();
	}
}
Exemple #23
0
void
as_object::add_property(const std::string& name, as_function& getter,
                        as_function* setter)
{
    const ObjectURI& uri = getURI(vm(), name);

    Property* prop = _members.getProperty(uri);

    if (prop) {
        const as_value& cacheVal = prop->getCache();
        // Used to return the return value of addGetterSetter, but this
        // is always true.
        _members.addGetterSetter(uri, getter, setter, cacheVal);
        return;
        // NOTE: watch triggers not called when adding a new
        // getter-setter property
    }
    else {

        _members.addGetterSetter(uri, getter, setter, as_value());

        // Nothing more to do if there are no triggers.
        if (!_trigs.get()) return;

        // check if we have a trigger, if so, invoke it
        // and set val to its return
        TriggerContainer::iterator trigIter = _trigs->find(uri);

        if (trigIter != _trigs->end()) {

            Trigger& trig = trigIter->second;

            log_debug("add_property: property %s is being watched", name);
            as_value v = trig.call(as_value(), as_value(), *this);

            // The trigger call could have deleted the property,
            // so we check for its existence again, and do NOT put
            // it back in if it was deleted
            prop = _members.getProperty(uri);
            if (!prop) {
                log_debug("Property %s deleted by trigger on create (getter-setter)", name);
                return;
            }
            prop->setCache(v);
        }
        return;
    }
}
void MovieContent::advance(FactoriesPtr factories, ContentWindowManagerPtr window, const boost::posix_time::time_duration timeSinceLastFrame)
{
    // Stop decoding when the window is moving to avoid saccades when reaching a new GLWindow
    // The decoding resumes when the movement is finished
    if( blockAdvance_ )
        return;

    boost::shared_ptr< Movie > movie = factories->getMovieFactory().getObject(getURI());

    // skip a frame if the Content rectangle is not visible in any window; otherwise decode normally
    const bool skipDecoding = !movie->getRenderContext()->isRegionVisible(window->getCoordinates());

    movie->setPause( window->getControlState() & STATE_PAUSED );
    movie->setLoop( window->getControlState() & STATE_LOOP );
    movie->nextFrame(timeSinceLastFrame, skipDecoding);
}
Exemple #25
0
    void sample()
    {
        ::fivox::URI uri = getURI();

        // for compatibility
        if( _vm.count( "size" ))
            uri.addQuery( "size", std::to_string( _vm["size"].as< size_t >( )));

        const ::fivox::URIHandler params( uri );
        auto source = params.newImageSource< fivox::FloatVolume >();

        const fivox::Vector3f& extent( source->getSizeInMicrometer( ));
        const size_t size( std::ceil( source->getSizeInVoxel().find_max( )));

        const VolumeHandler volumeHandler( size, extent );
        VolumePtr output = source->GetOutput();

        output->SetRegions( volumeHandler.computeRegion( _decompose ));
        output->SetSpacing( volumeHandler.computeSpacing( ));
        const fivox::AABBf& bbox = source->getBoundingBox();
        output->SetOrigin( volumeHandler.computeOrigin( bbox.getCenter( )));

        ::fivox::EventSourcePtr loader = source->getEventSource();
        const fivox::Vector2ui frameRange( getFrameRange( loader->getDt( )));

        const std::string& datatype( _vm["datatype"].as< std::string >( ));
        if( datatype == "char" )
        {
            LBINFO << "Sampling volume as char (uint8_t) data" << std::endl;
            _sample< uint8_t >( source, frameRange, params, _outputFile );
        }
        else if( datatype == "short" )
        {
            LBINFO << "Sampling volume as short (uint16_t) data" << std::endl;
            _sample< uint16_t >( source, frameRange, params, _outputFile );
        }
        else if( datatype == "int" )
        {
            LBINFO << "Sampling volume as int (uint32_t) data" << std::endl;
            _sample< uint32_t >( source, frameRange, params, _outputFile );
        }
        else
        {
            LBINFO << "Sampling volume as floating point data" << std::endl;
            _sample< float >( source, frameRange, params, _outputFile );
        }
    }
Exemple #26
0
void QRCodeDialog::genCode()
{
    QString uri = getURI();
    //qDebug() << "Encoding:" << uri.toUtf8().constData();
    QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
    myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
    myImage.fill(0xffffff);
    unsigned char *p = code->data;
    for(int y = 0; y < code->width; y++) {
        for(int x = 0; x < code->width; x++) {
            myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
            p++;
        }
    }
    QRcode_free(code);
    ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
}
int64_t WiredTigerRecordStore::storageSize(OperationContext* txn,
                                           BSONObjBuilder* extraInfo,
                                           int infoLevel) const {
    WiredTigerSession* session = WiredTigerRecoveryUnit::get(txn)->getSession(txn);
    StatusWith<int64_t> result =
        WiredTigerUtil::getStatisticsValueAs<int64_t>(session->getSession(),
                                                      "statistics:" + getURI(),
                                                      "statistics=(size)",
                                                      WT_STAT_DSRC_BLOCK_SIZE);
    uassertStatusOK(result.getStatus());

    int64_t size = result.getValue();

    if (size == 0 && _isCapped) {
        // Many things assume an empty capped collection still takes up space.
        return 1;
    }
    return size;
}
Exemple #28
0
bool HTTPPacket::encodeStartLine(DataBuffer *output) {
    if (PT_REQUEST == getPacketType()) {
        const char *methodStr = getMethodString();
        const char *uri = getURI();
        if( NULL == methodStr || NULL == uri) {
            return false;
        }
        output->writeBytes(methodStr, strlen(methodStr));
        output->writeBytes(" ", 1);
        output->writeBytes(uri, strlen(uri));
        output->writeBytes(" ", 1);
        if (HTTP_1_0 == getVersion()) {
            output->writeBytes("HTTP/1.0", 8);
        } else {
            output->writeBytes("HTTP/1.1", 8);
        }
        output->writeBytes("\r\n ", 2);
    } else {
        int statusCode = getStatusCode();
        if (0 == statusCode) {
            return false;
        }
        if (HTTP_1_0 == getVersion()) {
            output->writeBytes("HTTP/1.0", 8);
        } else {
            output->writeBytes("HTTP/1.1", 8);
        }
        output->writeBytes(" ", 1);
        char codeStr[32];
        snprintf(codeStr, 32, "%d", statusCode);
        output->writeBytes(codeStr, 3);
        output->writeBytes(" ", 1);
        const char *reasonPhrase = getReasonPhrase();
        if (NULL != reasonPhrase) {
            output->writeBytes(reasonPhrase, strlen(reasonPhrase));
        }
        output->writeBytes("\r\n", 2);
    }
    return true;
}
StringBuffer MailSyncSourceConfig::print() {

    StringBuffer ret;
    ret = "** SOURCE: "; ret += getName(); ret += "**\r\n";
    
    ret += "URI:\t\t"; ret += getURI(); ret += "\r\n";
    ret += "SyncModes:\t"; ret += getSyncModes(); ret += "\r\n";
    ret += "Type:\t\t"; ret += getType(); ret += "\r\n";
    ret += "Sync:\t\t"; ret += getSync(); ret += "\r\n";
    ret += "Encoding:\t"; ret += getEncoding(); ret += "\r\n";
    ret += "Version:\t"; ret += getVersion(); ret += "\r\n";
    ret += "SupportedType:\t"; ret += getSupportedTypes(); ret += "\r\n";
    ret += "Last:\t\t"; ret.append(getLast()); ret += "\r\n";
    ret += "Encryption:\t"; ret += getEncryption(); ret += "\r\n";    
    ret += "Enabled:\t"; ret += (isEnabled() == true ? "1" : "0"); ret += "\r\n";    


    ret += "DownloadAge:\t"; ret.append(getDownloadAge()); ret += "\r\n";    
    ret += "BodySize:\t"; ret.append(getBodySize()); ret += "\r\n";
    ret += "AttachSize:\t"; ret.append(getAttachSize()); ret += "\r\n";

    return ret;
}
Exemple #30
0
	Stringp Namespace::format(AvmCore* core) const
	{
		(void) core;
		return getURI();
	}