void DviService::Invoke(IDviInvocation& aInvocation, const Brx& aActionName) { iLock.Wait(); TBool disabled = iDisabled; if (disabled) { iLock.Signal(); aInvocation.InvocationReportError(502, Brn("Action not available")); } iCurrentInvocationCount++; (void)iDisabledSem.Clear(); iLock.Signal(); { AutoFunctor a(MakeFunctor(*this, &DviService::InvocationCompleted)); for (TUint i=0; i<iDvActions.size(); i++) { if (iDvActions[i].Action()->Name() == aActionName) { try { iDvActions[i].Functor()(aInvocation); } catch (Exception& e) { Brn msg(e.Message()); aInvocation.InvocationReportError(801, msg); } catch (...) { aInvocation.InvocationReportError(801, Brn("Unknown error")); } return; } } } aInvocation.InvocationReportError(501, Brn("Action not implemented")); }
void DviService::Invoke(IDviInvocation& aInvocation, const Brx& aActionName) { iLock.Wait(); #if 0 // debug logging { Bws<512> debugBuf("Service: "); debugBuf.Append(iServiceType.Name()); debugBuf.Append(", Action: "); debugBuf.Append(aActionName); debugBuf.Append("\n"); Log::Print(debugBuf); } #endif TBool disabled = iDisabled; if (disabled) { iLock.Signal(); aInvocation.InvocationReportError(502, Brn("Action not available")); } iCurrentInvocationCount++; (void)iDisabledSem.Clear(); iLock.Signal(); { AutoFunctor a(MakeFunctor(*this, &DviService::InvocationCompleted)); for (TUint i=0; i<iDvActions.size(); i++) { if (iDvActions[i].Action()->Name() == aActionName) { try { iDvActions[i].Functor()(aInvocation); } catch (InvocationError&) { // avoid calls to aInvocation.InvocationReportError in other catch blocks throw; } catch (Exception& e) { Brn msg(e.Message()); aInvocation.InvocationReportError(801, msg); } catch (...) { aInvocation.InvocationReportError(801, Brn("Unknown error")); } return; } } } aInvocation.InvocationReportError(501, Brn("Action not implemented")); }
void DviService::Invoke(IDviInvocation& aInvocation, TUint aVersion, const Brx& aActionName) { for (TUint i=0; i<iDvActions.size(); i++) { if (iDvActions[i].Action()->Name() == aActionName) { iDvActions[i].Functor()(aInvocation, aVersion); return; } } aInvocation.InvocationReportError(501, Brn("Action not implemented")); }
int32_t DvInvocationReportError(DvInvocationC aInvocation, uint32_t aCode, const char* aDescription) { IDviInvocation* invocation = InvocationFromHandle(aInvocation); try { Brn desc(aDescription); invocation->InvocationReportError(aCode, desc); } catch (WriterError&) { return -1; } catch (InvocationError&) {} return 0; }