Example #1
0
daeURI::daeURI(daeString uriString, daeBool nofrag)
{
	initialize();
	// !!!GAC this is inefficient as hell, but was the best way to isolate this functionality till the
	// !!!GAC daeURI class can be written to support modifying URIs better (should be possible to make a URI,
	// !!!GAC change any member and have getURI return the proper const string URI)
	if(nofrag)
	{
		// Strip off the fragment part before constructing the URI
		daeString temp		= safeCreate(uriString);
		daeChar* fragment	= (daeChar*)findCharacterReverse(temp, '#');
		if(fragment)
		{
			*fragment = 0;
		}
		setURI(temp);
		safeDelete(temp);
	}
	else
	{
		// Generate the URI without changing the string
		setURI(uriString);
	}
	if(nofrag)
		validate();
}
Example #2
0
daeURI::daeURI(daeURI& copyFrom)
{
	initialize();
	setURI(copyFrom.getOriginalURI());
	element = copyFrom.element;   // !!!GAC SetURI immediately clears element so we must do this after
	state = copyFrom.state;
}
Example #3
0
CMIRIAMResourceObject::CMIRIAMResourceObject(CRDFNode * pNode):
  mId(),
  mpNode(pNode)
{
  if (mpNode != NULL)
    setURI(mpNode->getObject().getResource());
}
Example #4
0
void HTTPRequest::read(std::istream& istr)
{
	static const int eof = std::char_traits<char>::eof();

	std::string method;
	std::string uri;
	std::string version;
	method.reserve(16);
	uri.reserve(64);
	version.reserve(16);
	int ch = istr.get();
	if (istr.bad()) throw NetException("Error reading HTTP request header");
	if (ch == eof) throw NoMessageException();
	while (Poco::Ascii::isSpace(ch)) ch = istr.get();
	if (ch == eof) throw MessageException("No HTTP request header");
	while (!Poco::Ascii::isSpace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); }
	if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP request method invalid or too long");
	while (Poco::Ascii::isSpace(ch)) ch = istr.get();
	while (!Poco::Ascii::isSpace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); }
	if (!Poco::Ascii::isSpace(ch)) throw MessageException("HTTP request URI invalid or too long");
	while (Poco::Ascii::isSpace(ch)) ch = istr.get();
	while (!Poco::Ascii::isSpace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); }
	if (!Poco::Ascii::isSpace(ch)) throw MessageException("Invalid HTTP version string");
	while (ch != '\n' && ch != eof) { ch = istr.get(); }
	HTTPMessage::read(istr);
	ch = istr.get();
	while (ch != '\n' && ch != eof) { ch = istr.get(); }
	setMethod(method);
	setURI(uri);
	setVersion(version);
}
Example #5
0
void ofApp::setup()
{
    ofSetLogLevel(OF_LOG_VERBOSE); //what does that mean?
    ofSetFrameRate(30);
//    int wi = 800;
//    int he = 600;
    int wi = 620;
    int he = 480;
//    int wi = 640;
//    int he = 360;
    
//    int wi = 1280;
//    int he = 960;
    alteredReality.allocate(wi, he, OF_IMAGE_COLOR);
    background.allocate(wi, he, OF_IMAGE_COLOR);
    movement.allocate(wi, he, OF_IMAGE_COLOR_ALPHA);
    
        
    loadCameras();
    
    IPCameraDef& cam = ipcams[0];
    
    auto c = std::make_shared<Video::IPVideoGrabber>(); //make_shared ???
    

    c->setURI(cam.getURL());
    c->connect(); // connect immediately


    grabbers.push_back(c);

}
Example #6
0
void
daeURI::resolveURI()
{
	// !!!GAC bug 486, there used to be code here that just returned if state was uri_empty or uri_resolve_local this has been removed.
	if (element != NULL)
	{
		// !!!GAC bug 388 and 421, need to add a fragment (#) before the ID (was setURI(element->getID()))
		if(element->getID() == NULL || element->getID()[0] == 0)
		{
			// We can't resolve to an element that has no ID, so if the ID is blank, fail and return
			state = uri_failed_invalid_reference;
			return;
		}
		daeChar* newID = (daeChar*)daeMemorySystem::malloc("tmp",strlen(element->getID())+2);
		strcpy(newID,"#");
		strcat(newID,element->getID());
		// !!!GAC We have to save element and container because setURI clears them for some reason
		daeElementRef	elementSave = element;
		setURI(newID);
		// !!!GAC Hopefully, calling validate like below is the right thing to do to get the full URI resolution
		element		= elementSave;
		validate(element->getDocumentURI());
		element		= elementSave;
		daeMemorySystem::free("tmp",newID);
		state = uri_success;  // !!!GAC The element pointer and the URI should agree now, so set success
	}
	else
	{
		state = uri_failed_invalid_reference;
	}
}
void MailSyncSourceConfig::assign(const MailSyncSourceConfig& sc) {
    setName     (sc.getName     ());
    setURI      (sc.getURI      ());
    setSyncModes(sc.getSyncModes());
    setType     (sc.getType     ());
    setSync     (sc.getSync     ());
    setLast     (sc.getLast     ());

    setEncoding      (sc.getEncoding      ());
    setVersion       (sc.getVersion       ());
    setSupportedTypes(sc.getSupportedTypes());
    //setCtCap         (sc.getCtCap         ());
    setEncryption    (sc.getEncryption    ());

    setDownloadAge(sc.getDownloadAge());
    setBodySize(sc.getBodySize());
    setAttachSize(sc.getAttachSize());

    setInbox(sc.getInbox());
    setOutbox(sc.getOutbox());
    setSent(sc.getSent());
    setTrash(sc.getTrash());
    setDraft(sc.getDraft());
    setSchedule(sc.getSchedule());
    mailAccounts = sc.getMailAccounts();
}
Example #8
0
void
daeURI::copyFrom(daeURI& copyFrom)
{
	setURI(copyFrom.getOriginalURI());
	element = copyFrom.element;		// !!!GAC SetURI immediately clears element so we must do this after
	state = copyFrom.state;
	// !!!GAC Should there be a call to validate in here?
}
Example #9
0
// receiving session from other user who initiated call
void LLVoiceChannelP2P::setSessionHandle(const std::string& handle, const std::string &inURI)
{ 
	BOOL needs_activate = FALSE;
	if (callStarted())
	{
		// defer to lower agent id when already active
		if (mOtherUserID < gAgent.getID())
		{
			// pretend we haven't started the call yet, so we can connect to this session instead
			deactivate();
			needs_activate = TRUE;
		}
		else
		{
			// we are active and have priority, invite the other user again
			// under the assumption they will join this new session
			mSessionHandle.clear();
			LLVoiceClient::getInstance()->callUser(mOtherUserID);
			return;
		}
	}

	mSessionHandle = handle;

	// The URI of a p2p session should always be the other end's SIP URI.
	if(!inURI.empty())
	{
		setURI(inURI);
	}
	else
	{
		LL_WARNS("Voice") << "incoming SIP URL is not provided. Channel may not work properly." << LL_ENDL;
		// In the case of an incoming AvaLine call, the generated URI will be different from the
		// original one. This is because the P2P URI is based on avatar UUID but Avaline is not.
		// See LLVoiceClient::sessionAddedEvent()
		setURI(LLVoiceClient::getInstance()->sipURIFromID(mOtherUserID));
	}
	
	mReceivedCall = TRUE;

	if (needs_activate)
	{
		activate();
	}
}
Example #10
0
bool CMIRIAMResourceObject::setNode(CRDFNode * pNode)
{
  mpNode = pNode;

  if (mpNode != NULL)
    return setURI(mpNode->getObject().getResource());

  return true;
}
Example #11
0
//
// LLVoiceChannelP2P
//
LLVoiceChannelP2P::LLVoiceChannelP2P(const LLUUID& session_id, const std::string& session_name, const LLUUID& other_user_id) : 
		LLVoiceChannelGroup(session_id, session_name), 
		mOtherUserID(other_user_id),
		mReceivedCall(FALSE)
{
	// make sure URI reflects encoded version of other user's agent id
	// *NOTE: in case of Avaline call generated SIP URL will be incorrect.
	// But it will be overridden in LLVoiceChannelP2P::setSessionHandle() called when agent accepts call
	setURI(LLVoiceClient::getInstance()->sipURIFromID(other_user_id));
}
Example #12
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());
}
Example #13
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());
}
SkImageRef_ashmem::SkImageRef_ashmem(SkFlattenableReadBuffer& buffer)
        : INHERITED(buffer) {
    fRec.fFD = -1;
    fRec.fAddr = NULL;
    fRec.fSize = 0;
    fRec.fPinned = false;
    fCT = NULL;
    size_t length = buffer.readU32();
    if (length) {
        char* buf = (char*) malloc(length);
        buffer.read(buf, length);
        setURI(buf, length);
    }
    this->useDefaultMutex();   // we don't need/want the shared imageref mutex
}
Example #15
0
void LLVoiceChannelGroup::setChannelInfo(
	const std::string& uri,
	const std::string& credentials)
{
	setURI(uri);

	mCredentials = credentials;

	if (mState == STATE_NO_CHANNEL_INFO)
	{
		if(!mURI.empty() && !mCredentials.empty())
		{
			setState(STATE_READY);

			// if we are supposed to be active, reconnect
			// this will happen on initial connect, as we request credentials on first use
			if (sCurrentVoiceChannel == this)
			{
				// just in case we got new channel info while active
				// should move over to new channel
				activate();
			}
		}
		else
		{
			//*TODO: notify user
			LL_WARNS("Voice") << "Received invalid credentials for channel " << mSessionName << LL_ENDL;
			deactivate();
		}
	}
	else if ( mIsRetrying )
	{
		// we have the channel info, just need to use it now
		LLVoiceClient::getInstance()->setNonSpatialChannel(
			mURI,
			mCredentials);
	}
}
Example #16
0
void SyncSourceConfig::assign(const SyncSourceConfig& sc) {
    if (&sc == this) {
        return;
    }

    setName          (sc.getName          ());
    setURI           (sc.getURI           ());
    setSyncModes     (sc.getSyncModes     ());
    setType          (sc.getType          ());
    setSync          (sc.getSync          ());
    setLast          (sc.getLast          ());
    setEncoding      (sc.getEncoding      ());
    setVersion       (sc.getVersion       ());
    setSupportedTypes(sc.getSupportedTypes());
    setSyncMode      (sc.getSyncMode      ());
	setIsAllowed     (sc.isAllowed        ());
//    setCtCap         (sc.getCtCap         ());
    setEncryption    (sc.getEncryption    ());
    setLastSourceError(sc.getLastSourceError());
    setLastSyncServerTime(sc.AbstractSyncSourceConfig::getLastSyncServerTime());
    
    extraProps = sc.getExtraProps();
}
Example #17
0
void ofApp::loadNextCamera(){
    
    int wi = 620;
    int he = 480;
    num_measurements = 1;
    
    avColors.clear(); //might now even need
    first = true;
    background.allocate(wi, he, OF_IMAGE_COLOR);
    movement.allocate(wi, he, OF_IMAGE_COLOR_ALPHA);
    drawing = false;
    hideMovement = false;
    
    loadCameras();
    IPCameraDef& cam = ipcam;
    
    auto c = std::make_shared<Video::IPVideoGrabber>(); //make_shared ???
    c->setURI(cam.getURL());
    c->connect(); // connect immediately
    
    the_stream = c;
    
}
Example #18
0
void LLVoiceChannel::setChannelInfo(
	const std::string& uri,
	const std::string& credentials)
{
	setURI(uri);

	mCredentials = credentials;

	if (mState == STATE_NO_CHANNEL_INFO)
	{
		if (mURI.empty())
		{
			LLNotificationsUtil::add("VoiceChannelJoinFailed", mNotifyArgs);
			LL_WARNS("Voice") << "Received empty URI for channel " << mSessionName << LL_ENDL;
			deactivate();
		}
		else if (mCredentials.empty())
		{
			LLNotificationsUtil::add("VoiceChannelJoinFailed", mNotifyArgs);
			LL_WARNS("Voice") << "Received empty credentials for channel " << mSessionName << LL_ENDL;
			deactivate();
		}
		else
		{
			setState(STATE_READY);

			// if we are supposed to be active, reconnect
			// this will happen on initial connect, as we request credentials on first use
			if (sCurrentVoiceChannel == this)
			{
				// just in case we got new channel info while active
				// should move over to new channel
				activate();
			}
		}
	}
}
Example #19
0
daeURI::daeURI(int dummy)
{
	(void)dummy;
	// This constructor builds a  base URI from the current working directory
	// This should work for windows or linux
	// !!!GAC the buffers should probably be bigger
	char buffer[1024], *b1;
	strcpy(buffer, "file:///");
#ifdef NO_GETCWD
	// The platform has no getcwd call, so leave the value as file:///
#else
	#ifdef _WIN32
		// Windows getcwd always returns a path beginning with a drive letter, so we add file:/// to the beginning 
		getcwd(&buffer[8],1024-8);
	#else
		// Linux getcwd always returns a path beginning with a slash, so we add file:// to the beginning
		getcwd(&buffer[7],1024-7);
	#endif
#endif
	// If the path contains windows backslashes, flip them to forward slashes
	for(b1 = buffer;*b1 != 0;b1++)
	{
		if(*b1 == '\\')
		{
			*b1 = '/';
		}
	}
	// The path must end in a slash or the last part of it will be taken as a filename
	if(*(b1-1) != '/')
	{
		*(b1++) = '/';
	}
		*b1 = '\0';
	initialize();
	setURI(buffer);
	validate();
}
Example #20
0
void Awstats::config(HttpVHost *pVHost, int val, char* achBuf, const XmlNode *pAwNode, 
              char* iconURI, const char* vhDomain, int vhAliasesLen )
{
    const char *pURI;
    const char *pValue;
    char *p;
    int handlerType;
    int len = strlen( achBuf );
    int iChrootLen = 0;
    if ( HttpGlobals::s_psChroot != NULL )
    iChrootLen = HttpGlobals::s_psChroot->len();
    setMode( val );
    

    if ( achBuf[len - 1] == '/' )
        achBuf[len - 1] = 0;

    setWorkingDir( achBuf );

    pURI = pAwNode->getChildValue( "awstatsURI" );

    if ( ( !pURI ) || ( *pURI != '/' ) || ( * ( pURI + strlen( pURI ) - 1 ) != '/' )
            || ( strlen( pURI ) > 100 ) )
    {
        ConfigCtx::getCurConfigCtx()->log_warn( "AWStats URI is invalid"
                             ", use default [/awstats/]." );
        iconURI[9] = 0;;
        pURI = iconURI;
    }

    setURI( pURI );

    if ( val == AWS_STATIC )
    {
        handlerType = HandlerType::HT_NULL;
        strcat( achBuf, "/html/" );
    }
    else
    {
        ConfigCtx::getCurConfigCtx()->getValidPath( achBuf, "$SERVER_ROOT/add-ons/awstats/wwwroot/cgi-bin/",
                      "AWStats CGI-BIN directory" );

        if ( pVHost->getRootContext().determineMime( "pl", NULL )->getHandler()->getHandlerType() )
            handlerType = HandlerType::HT_NULL;
        else
            handlerType = HandlerType::HT_CGI;
    }

    HttpContext *pContext =
        pVHost->addContext( pURI, handlerType, &achBuf[iChrootLen], NULL, 1 );

    p = achBuf;
    if ( ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "securedConn", 0, 1, 0 ) == 1 )
    {
        p += safe_snprintf( achBuf, 8192,
                "rewriteCond %%{HTTPS} !on\n"
                "rewriteCond %%{HTTP:X-Forwarded-Proto} !https\n"
                "rewriteRule ^(.*)$ https://%%{SERVER_NAME}%%{REQUEST_URI} [R,L]\n" );

    }
    if ( val == AWS_STATIC )
    {
        safe_snprintf( p, &achBuf[8192] - p,
                       "RewriteRule ^$ awstats.%s.html\n",
                       pVHost->getName() );
    }
    else
    {
        safe_snprintf( p, &achBuf[8192] - p, 
                       "RewriteRule ^$ awstats.pl\n"
                       "RewriteCond %%{QUERY_STRING} !configdir=\n"
                       "RewriteRule ^awstats.pl "
                       "$0?config=%s&configdir=%s/conf [QSA]\n",
                       pVHost->getName(),
                       getWorkingDir() + iChrootLen );
        pContext->setUidMode( UID_DOCROOT );
    }

    pContext->enableRewrite( 1 );
    pContext->configRewriteRule( pVHost->getRewriteMaps(), achBuf );

    pValue = pAwNode->getChildValue( "realm" );

    if ( pValue )
        pVHost->configAuthRealm( pContext, pValue );

    pValue = pAwNode->getChildValue( "siteDomain" );

    if ( !pValue )
    {
        ConfigCtx::getCurConfigCtx()->log_warn( "SiteDomain configuration is invalid"
                             ", use default [%s].",  vhDomain );
        pValue = vhDomain;
    }
    else
    {
        ConfigCtx::getCurConfigCtx()->expandDomainNames( pValue, achBuf, 4096 );
        pValue = achBuf;
    }

    setSiteDomain( pValue );

    pValue = pAwNode->getChildValue( "siteAliases" );
    int needConvert = 1;

    if ( !pValue )
    {
        if ( vhAliasesLen == 0 )
        {
            safe_snprintf( achBuf, 8192, "127.0.0.1 localhost REGEX[%s]",
                           getSiteDomain() );
            ConfigCtx::getCurConfigCtx()->log_warn( "SiteAliases configuration is invalid"
                                 ", use default [%s].", achBuf );
            pValue = achBuf;
            needConvert = 0;
        }
        else
            pValue = "$vh_aliases";
    }

    if ( needConvert )
    {
        ConfigCtx::getCurConfigCtx()->expandDomainNames( pValue, &achBuf[4096], 4096, ' ' );
        ConfigCtx::getCurConfigCtx()->convertToRegex( &achBuf[4096], achBuf, 4096 );
        pValue = achBuf;
        ConfigCtx::getCurConfigCtx()->log_info( "SiteAliases is set to '%s'", achBuf );
    }

    setAliases( pValue );

    val = ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "updateInterval", 3600, 3600 * 24, 3600 * 24 );

    if ( val % 3600 != 0 )
        val = ( ( val + 3599 ) / 3600 ) * 3600;

    setInterval( val );

    val = ConfigCtx::getCurConfigCtx()->getLongValue( pAwNode, "updateOffset", 0, LONG_MAX, 0 );

    if ( val > getInterval() )
        val %= getInterval();

    setOffset( val );

    pVHost->setAwstats( this );    
}
Example #21
0
bool SIPFrom::setURI(const char* uri)
{
  return setURI(_data, uri);
}
Example #22
0
daeURI::daeURI(daeURI& baseURI, daeString uriString)
{
	initialize();
	setURI(uriString);
	validate(&baseURI);
}