// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::GetCommandsL
//  
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CMediatorServerObjectHandler::GetCommandsL( TMediatorCategory aCategory, 
                                                 RCommandList& aCommands )
    {
    // Find domain & category
    CCategory* category = CategoryL( aCategory ); 
    if ( category )
        {
        category->GetCommandsL( aCommands );
        }
    }
// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::GetEventsL
//  
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CMediatorServerObjectHandler::GetEventsL( TMediatorCategory aCategory, 
                                               REventList& aEvents )
    {
    // Find domain & category
    CCategory* category = CategoryL( aCategory ); 
    if ( category )
        {
        category->GetEventsL( aEvents );
        }
    }
void CAlmSettingsSession::ProcessDataL(void)
{
  TInt func=Message().Function();
  _LIT(KSQL,"select id,name,cid,value from settings where cid=%u and name='%S'");
  RDbView view;
  TBuf<128> sql;
  TUint32 cid=CategoryL(Message().Ptr0());
  HBufC8* param1=ValueLC(Message().Ptr1());
  TPtrC name((const TUint16*)param1->Ptr(),param1->Length()/2);
  sql.Format(KSQL,cid,&name);
  User::LeaveIfError(view.Prepare(iServer.DbL(),TDbQuery(sql),(func==ESettingsServerRequestSet)?RDbView::EUpdatable:RDbView::EReadOnly));
  CleanupClosePushL(view);
  User::LeaveIfError(view.EvaluateAll());
  TBool first=view.FirstL();
  if(func==ESettingsServerRequestSet)
  {
    if(first) view.UpdateL();
    else view.InsertL();
    CleanupCancelPushL(view);
    if(!first)
    {
      view.SetColL(2,name);
      view.SetColL(3,cid);
    }
    HBufC8* value=ValueLC(Message().Ptr2());
    view.SetColL(4,*value);
    view.PutL();
    CleanupStack::Pop(); //view cancel
    CleanupStack::PopAndDestroy(); //value
    iServer.Notify();
  }
  else
  {
    if(!first) User::Leave(KErrNotFound);
    view.GetL();
    TInt len=view.ColSize(4);
    if(func==ESettingsServerRequestGetData)
    {
      HBufC8* data=HBufC8::NewLC(len);
      TPtr8 ptr(data->Des());
      RDbColReadStream stream;
      stream.OpenLC(view,4);
      stream.ReadL(ptr,len);
      Message().WriteL(Message().Ptr2(),ptr);
      CleanupStack::PopAndDestroy(2); //stream,data
    }
    else
    {
      TPckgC<TInt> size(len);
      Message().WriteL(Message().Ptr2(),size);
    }
  }
  CleanupStack::PopAndDestroy(2); //view,param1

}
// -----------------------------------------------------------------------------
// CMediatorServerObjectHandler::IsCategoryEmptyL
//  
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//     
TBool CMediatorServerObjectHandler::IsCategoryEmptyL( TUid aDomain, TUid aCategory)
    {
    TBool empty = EFalse;
    TMediatorCategory category;
    category.iDomain = aDomain;
    category.iCategory = aCategory;
    CCategory* categoryPtr = CategoryL( category );
    if ( categoryPtr )
        {
        TInt eventCount = categoryPtr->EventCount();
        TInt commandCount = categoryPtr->CommandCount();
        if ( !eventCount && !commandCount )
            {
            empty = ETrue;
            }
        categoryPtr = NULL; // Not owned
        }
    return empty;
    }