static int FindDeviceContext(pointer device) /* device token */ { double M[2][2]; /* temporary matrix */ float Xres,Yres; /* device resolution */ int orient = -1; /* device orientation */ int rc = -1; /* return code for QueryDeviceState */ if (rc != 0) /* we only bother with this check once */ Abort("Context: QueryDeviceState didn't work"); M[0][0] = M[1][0] = M[0][1] = M[1][1] = 0.0; switch (orient) { case 0: M[0][0] = Xres; M[1][1] = -Yres; break; case 1: M[1][0] = Yres; M[0][1] = Xres; break; case 2: M[0][0] = -Xres; M[1][1] = Yres; break; case 3: M[1][0] = -Yres; M[0][1] = -Xres; break; default: Abort("QueryDeviceState returned invalid orientation"); } return(FindContext(M)); }
// ---------------------------------------------------------------------------- // CSipSecIpsecMechanism::ResponseReceivedL // ---------------------------------------------------------------------------- // TBool CSipSecIpsecMechanism::ResponseReceivedL( TSIPTransportParams& aTransportParams, CSIPResponse& aResponse, CSIPRequest& aRequest, TRegistrationId /*aRegistrationId*/, TTransactionId /*aTransactionId*/, TInetAddr& aNextHop, const CUri8& /*aRemoteTarget*/, const TDesC8& /*aOutboundProxy*/, MSIPSecUser* aUser, MSIPSecSecurityMechanismObserver& aObserver ) { CSipSecAgreeContext* c = FindContext( aUser ); if ( c ) { c->ApplyRulesL( aResponse, aRequest, aObserver ); } else { // No context was found for the user, create possibly new one CreateNewContextL( aTransportParams, aResponse, aRequest, aNextHop, aUser, aObserver ); } return EFalse; }
void ShaderEditManager::OnGLContextSet(HGLRC oldRCHandle, HGLRC newRCHandle) { //If setting a NULL context, just assign and return if(newRCHandle == NULL) { currContext = NULL; return; } //Set the new context handle SEContext * setContext = FindContext(newRCHandle); if(!setContext) { LOGERR(("ShaderEditManager::OnGLContextSet - Error finding context %x",newRCHandle)); } currContext = setContext; //Init. the context if not currently init if(currContext) { if(!currContext->IsInit()) { currContext->Init(gliCallBacks); } #ifdef GLI_BUILD_WINDOWS //Set the last used device context for this render context currContext->SetDCHandle(gliCallBacks->GetWGLFunctions()->wglGetCurrentDC()); #endif // GLI_BUILD_WINDOWS //Update the bound shaders frame numbers currContext->SetShaderFrameNum(gliCallBacks->GetFrameNumber()); } }
// ---------------------------------------------------------------------------- // CSipSecIpsecMechanism::ProcessSecurityVerifyL // ---------------------------------------------------------------------------- // void CSipSecIpsecMechanism::ProcessSecurityVerifyL( TSIPTransportParams& /*aTransportParams*/, CSIPRequest& aRequest, TInetAddr& aNextHop, const CUri8& /*aRemoteTarget*/, const TDesC8& /*aOutboundProxy*/, MSIPSecUser* /*aUser*/, TRegistrationId /*aRegistrationId*/, RPointerArray<CSIPSecurityServerHeader>& /*aSecurityServer*/, RPointerArray<CSIPSecurityVerifyHeader>& aSecurityVerify ) { // No action if verify hdrs exist already in the request if ( aRequest.HasHeader( SIPStrings::StringF( SipStrConsts::ESecurityVerifyHeader ) ) ) { return; } // In case when two records exist already but more recent record is not // yet in "temporal" state, ipsec still has to use old sec verify hdrs. // FW would like to already use new sec verifys instead. CSipSecAgreeContext* c = FindContext( aNextHop ); if ( c ) { c->ApplyRulesL( aSecurityVerify ); } }
void ShaderEditManager::OnGLContextShareLists(HGLRC srcHandle, HGLRC dstHandle) { //Get the context handles SEContext * srcContext = FindContext(srcHandle); SEContext * dstContext = FindContext(dstHandle); //Check that the contexts exists if(srcContext == NULL || dstContext == NULL) { LOGERR(("ShaderEditManager::OnGLContextShareLists - Source and destination contexts not found")); return; } //Share the source lists/shaders with the destination context if(!srcContext->ShareLists(dstContext)) { LOGERR(("ShaderEditManager::OnGLContextShareLists - Error sharing lists")); } }
// ----------------------------------------------------------------------------- // CMccCryptoContextContainer::GenerateContextId // ----------------------------------------------------------------------------- // TUint32 CMccCryptoContextContainer::GenerateContextId() { __INTERFACE( "CMccContextContainer::GenerateContextId" ) TUint32 id( 0 ); do { id = static_cast<TUint32>( Math::Random() ); } while ( KErrNotFound != FindContext( id ) ); return id; }
bool CslIrcThread::Disconnect(const CslIrcContext& context) { wxCriticalSectionLocker enter(m_section); CslIrcContext *ctx; if (!(ctx=FindContext(context))) return false; ctx->Disconnecting=true; return true; }
void ShaderEditManager::OnGLContextCreate(HGLRC rcHandle) { //Check that there cannot be duplicates if(FindContext(rcHandle) != NULL) { LOGERR(("ShaderEditManager::OnGLContextCreate - Adding existing context %x?",rcHandle)); return; } //Create the new context and add it to the list SEContext * newContext = new SEContext(rcHandle); contextArray.push_back(newContext); }
// ---------------------------------------------------------------------------- // CSipSecIpsecMechanism::ClearCache // ---------------------------------------------------------------------------- // void CSipSecIpsecMechanism::ClearCache( MSIPSecUser* aUser ) { CSipSecAgreeContext* c = FindContext( aUser ); if ( c ) { TRAPD( err, c->ClearL() ); if ( err != KErrNone ) { DeleteContext( c ); } } }
// --------------------------------------------------------------------------- // CMccCryptoContextContainer::RemoveContext // --------------------------------------------------------------------------- // TInt CMccCryptoContextContainer::RemoveContext( TUint32 aContextId ) { __INTERFACE( "CMccContextContainer::RemoveContext" ) TInt contextId = FindContext( aContextId ); if ( KErrNotFound != contextId ) { iContextArray.Remove( contextId ); return KErrNone; } return KErrNotFound; }
// --------------------------------------------------------------------------- // CMccCryptoContextContainer::GetContext // --------------------------------------------------------------------------- // TInt CMccCryptoContextContainer::GetContext( TUint32 aContextId, TMccCryptoContext* &aContext ) { __INTERFACE( "CMccContextContainer::GetContext" ) TInt contextId = FindContext( aContextId ); if ( KErrNotFound != contextId ) { aContext = &iContextArray[ contextId ]; return KErrNone; } return KErrNotFound; }
// --------------------------------------------------------------------------- // CMccCryptoContextContainer::UpdateContextL // --------------------------------------------------------------------------- // TInt CMccCryptoContextContainer::UpdateContext( TUint32 aContextId, TMccCryptoContext& aContext ) { __INTERFACE( "CMccContextContainer::UpdateContext" ) TInt contextId = FindContext( aContextId ); if ( KErrNotFound != contextId ) { iContextArray[ contextId ].UpdateContext( aContext ); return KErrNone; } return KErrNotFound; }
// ---------------------------------------------------------------------------- // CSipSecIpsecMechanism::ParametersUpdatedL // ---------------------------------------------------------------------------- // TBool CSipSecIpsecMechanism::ParametersUpdatedL( MSIPSecUser* aUser ) { // Digest has possibly updated keying material CSipSecAgreeContext* c = FindContext( aUser ); if ( c ) { const TDesC8* key = 0; TRAPD( err, key = &iEngineContext.ValueL( KSIPSecIK ) ); if ( err == KErrNone ) { return c->SetAuthKeyL( *key ); } c->AuthKeyFailedL(); } return EFalse; }
WindowInterface& BindToContext(std::string name) { std::unique_lock<std::recursive_mutex> l(contexts_mutex); // N.B. context is modified prior to invoking MakeCurrent so that // state management callbacks (such as Resize()) can be correctly // processed. PangolinGl *context_to_bind = FindContext(name); if( !context_to_bind ) { std::shared_ptr<PangolinGl> newcontext(new PangolinGl()); RegisterNewContext(name, newcontext); return *(newcontext.get()); }else{ context_to_bind->MakeCurrent(); return *context_to_bind; } }
// ---------------------------------------------------------------------------- // CSipSecIpsecMechanism::AddSecurityParamsL // ---------------------------------------------------------------------------- // void CSipSecIpsecMechanism::AddSecurityParamsL( TSIPTransportParams& aTransportParams, CSIPRequest& aRequest, TRegistrationId /*aRegistrationId*/, TTransactionId /*aTransactionId*/, TInetAddr& aNextHop, const CUri8& /*aRemoteTarget*/, const TDesC8& aOutboundProxy, MSIPSecUser* aUser ) { CSipSecAgreeContext* c = FindContext( aNextHop ); if ( c ) { c->ApplyRulesL( aTransportParams, aRequest, aOutboundProxy, aUser ); } else { ProcessInitialReqisterL( aTransportParams, aRequest ); } }
bool CslIrcThread::Connect(const CslIrcContext& context) { m_section.Enter(); if (FindContext(context)) return false; CslIrcContext *ctx=new CslIrcContext(context); m_contexts.Add(ctx); irc_set_ctx(ctx->Session,ctx); m_section.Leave(); if (m_mutex.TryLock()!=wxMUTEX_NO_ERROR) return true; m_condition->Signal(); m_mutex.Unlock(); return true; }
Trans_t * FindTrans( Element_t *e ) { char context[LINESIZE], *cp, **vec, *atval; int i, a, match; Trans_t *t, *tt; /* loop through all transpecs */ for (t=TrSpecs; t; t=t->next) { /* Only one of gi or gilist will be set. */ /* Check if elem name matches */ if (t->gi && !StrEq(t->gi, e->gi)) continue; /* Match one in the list of GIs? */ if (t->gilist) { for (match=0,vec=t->gilist; *vec; vec++) { if (StrEq(*vec, e->gi)) { match = 1; break; } } if (!match) continue; } /* Check context */ /* Special case of context */ if (t->parent) if (!QRelation(e, t->parent, REL_Parent)) continue; if (t->context) { /* no context specified -> a match */ FindContext(e, t->depth, context); /* If reg expr set, do regex compare; else just string compare. */ if (t->context_re) { if (! tpt_regexec(t->context_re, context)) continue; } else { /* Is depth of spec deeper than element's depth? */ if (t->depth > e->depth) continue; /* See if context of element matches "context" of transpec */ match = ( (t->context[0] == context[0]) && !strcmp(t->context, context) ); if (!match) continue; } } /* Check attributes. Loop through list, comparing each. */ if (t->nattpairs) { /* no att specified -> a match */ for (match=1,a=0; a<t->nattpairs; a++) { if (!(atval = FindAttValByName(e, t->attpair[a].name))) { match = 0; break; } if (!tpt_regexec(t->attpair[a].rex, atval)) match = 0; } if (!match) continue; } /* Check relationships: child, parent, ancestor, sib, ... */ if (t->relations) { Mapping_t *r; match = 1; for (r=t->relations->maps,i=0; i<t->relations->n_used; i++) { if (!CheckRelation(e, r[i].name, r[i].sval, 0, 0, RA_Current)) { match = 0; break; } } if (!match) continue; } /* check this element's parent's attribute */ if (t->pattrset && e->parent) { char *p, **tok; i = 2; match = 1; tok = Split(t->pattrset, &i, S_STRDUP); if ( i == 2 ) { p = FindAttValByName(e->parent, tok[0]); if ( !p || strcmp(p, tok[1]) ) match = 0; } else { if (!FindAttValByName(e->parent, t->pattrset)) match = 0; } free(tok[0]); if (!match) continue; } /* check this element's "birth order" */ if (t->nth_child) { /* First one is called "1" by the user. Internally called "0". */ i = t->nth_child; if (i > 0) { /* positive # -- count from beginning */ if (e->my_eorder != (i-1)) continue; } else { /* negative # -- count from end */ i = e->parent->necont + i; if (e->my_eorder != i) continue; } } /* check that variables match */ if (t->var_name) { cp = FindMappingVal(Variables, t->var_name); if (!cp || strcmp(cp, t->var_value)) continue; } /* check content */ if (t->content) { /* no att specified -> a match */ for (match=0,i=0; i<e->ndcont; i++) { if (tpt_regexec(t->content_re, e->dcont[i])) { match = 1; break; } } if (!match) continue; } /* -------- at this point we've passed all criteria -------- */ /* See if we should be using another transpec's actions. */ if (t->use_id) { if (t->use_id < 0) return &NullTrans; /* missing? */ /* see if we have a pointer to that transpec */ if (t->use_trans) return t->use_trans; for (tt=TrSpecs; tt; tt=tt->next) { if (t->use_id == tt->my_id) { /* remember pointer for next time */ t->use_trans = tt; return t->use_trans; } } t->use_id = -1; /* flag it as missing */ fprintf(stderr, "Warning: transpec ID (%d) not found for %s.\n", t->use_id, e->gi); return &NullTrans; } return t; } /* At this point, we have not found a matching spec. See if there * is a wildcard, and if so, use it. (Wildcard GI is named "*".) */ if ((t = FindTransByName("*"))) return t; if (warnings) fprintf(stderr, "Warning: transpec not found for %s\n", e->gi); /* default spec - pass character data and descend node */ return &NullTrans; }
void NetworkData::RemoveTemporaryData(uint8_t *aData, uint8_t &aDataLength, PrefixTlv &aPrefix) { NetworkDataTlv *cur = reinterpret_cast<NetworkDataTlv *>(aPrefix.GetSubTlvs()); NetworkDataTlv *end; BorderRouterTlv *borderRouter; HasRouteTlv *hasRoute; ContextTlv *context; BorderRouterEntry *borderRouterEntry; HasRouteEntry *hasRouteEntry; uint8_t length; uint8_t contextId; uint8_t *dst; uint8_t *src; while (1) { end = reinterpret_cast<NetworkDataTlv *>(aPrefix.GetSubTlvs() + aPrefix.GetSubTlvsLength()); if (cur >= end) { break; } if (cur->IsStable()) { switch (cur->GetType()) { case NetworkDataTlv::kTypeBorderRouter: { borderRouter = FindBorderRouter(aPrefix); if ((context = FindContext(aPrefix)) == NULL) { break; } contextId = context->GetContextId(); // replace p_border_router_16 for (int i = 0; i < borderRouter->GetNumEntries(); i++) { borderRouterEntry = borderRouter->GetEntry(i); if (borderRouterEntry->IsDhcp() || borderRouterEntry->IsConfigure()) { borderRouterEntry->SetRloc(0xfc00 | contextId); } else { borderRouterEntry->SetRloc(0xfffe); } } break; } case NetworkDataTlv::kTypeHasRoute: { hasRoute = FindHasRoute(aPrefix); // replace r_border_router_16 for (int j = 0; j < hasRoute->GetNumEntries(); j++) { hasRouteEntry = hasRoute->GetEntry(j); hasRouteEntry->SetRloc(0xfffe); } break; } default: { break; } } // keep stable tlv cur = cur->GetNext(); } else { // remove temporary tlv length = sizeof(NetworkDataTlv) + cur->GetLength(); dst = reinterpret_cast<uint8_t *>(cur); src = reinterpret_cast<uint8_t *>(cur->GetNext()); memmove(dst, src, aDataLength - (src - aData)); aPrefix.SetSubTlvsLength(aPrefix.GetSubTlvsLength() - length); aDataLength -= length; } } }
void UT_CCFContextManager::UT_CCFContextManager_RequestContextL_2L( ) { RThread thread; CleanupClosePushL(thread); SetupContextCacheL(); RContextObjectArray resultBuffer; resultBuffer.Reset(); // QUERY 1 CCFContextQuery* query = CCFContextQuery::NewLC( KNullDesC, KNullDesC ); query->SetSourceL(_L("SourceC")); query->SetTypeL(_L("TypeC")); EUNIT_ASSERT_NO_LEAVE( iCFContextManagerInterface->RequestContextL( resultBuffer, *query, thread ) ); EUNIT_ASSERT_DESC( resultBuffer.Count() == 1, "More than 1 context returned!" ); TInt index = FindContext(resultBuffer, _L("SourceC"), _L("TypeC"), _L("ValueCC")); EUNIT_ASSERT_DESC( index >= 0, "ResultError!" ); // QUERY 2 query->SetSourceL(_L("SourceC")); query->SetTypeL(_L("")); resultBuffer.Reset(); query->SetSubTypeMatch(ETrue); EUNIT_ASSERT_NO_LEAVE( iCFContextManagerInterface->RequestContextL( resultBuffer, *query, thread ) ); EUNIT_ASSERT_DESC( resultBuffer.Count() == 4, "Did not return 4 contexts!" ); index = FindContext(resultBuffer, _L("SourceC"), _L("TypeC"), _L("ValueCC")); EUNIT_ASSERT_DESC( index >= 0, "ResultError!" ); index = FindContext(resultBuffer, _L("SourceC"), _L("TypeD"), _L("ValueCD")); EUNIT_ASSERT_DESC( index >= 0, "ResultError!" ); index = FindContext(resultBuffer, _L("SourceC"), _L("TypeC.SubtypeA"), _L("ValueCCA")); EUNIT_ASSERT_DESC( index >= 0, "ResultError!" ); index = FindContext(resultBuffer, _L("SourceC"), _L("TypeC.SubtypeB"), _L("ValueCCB")); EUNIT_ASSERT_DESC( index >= 0, "ResultError!" ); resultBuffer.Close(); CleanupStack::PopAndDestroy( query ); CleanupStack::PopAndDestroy( &thread ); }