mmserv/tms/tmsimpl/src/tmsvolumeeffectbodyimpl.cpp
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
child 12 5a06f39ad45b
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 #include <tms.h>
       
    19 #include <tmseffectobsrvr.h>
       
    20 #include "tmscallproxy.h"
       
    21 #include "tmsqueuehandler.h"
       
    22 #include "tmsvolumeeffectbodyimpl.h"
       
    23 
       
    24 using namespace TMS;
       
    25 
       
    26 TMSVolumeEffectBodyImpl::TMSVolumeEffectBodyImpl() :
       
    27     iObserver(NULL),
       
    28     iProxy(NULL),
       
    29     iParentEffect(NULL)
       
    30     {
       
    31     }
       
    32 
       
    33 TMSVolumeEffectBodyImpl::~TMSVolumeEffectBodyImpl()
       
    34     {
       
    35     }
       
    36 
       
    37 gint TMSVolumeEffectBodyImpl::Create(TMSVolumeEffectBody*& bodyimpl)
       
    38     {
       
    39     gint ret(TMS_RESULT_INSUFFICIENT_MEMORY);
       
    40     TMSVolumeEffectBodyImpl* self = new TMSVolumeEffectBodyImpl;
       
    41     if (self)
       
    42         {
       
    43         ret = self->PostConstruct();
       
    44         if (ret != TMS_RESULT_SUCCESS)
       
    45             {
       
    46             delete self;
       
    47             self = NULL;
       
    48             }
       
    49         }
       
    50     bodyimpl = self;
       
    51     return ret;
       
    52     }
       
    53 
       
    54 gint TMSVolumeEffectBodyImpl::PostConstruct()
       
    55     {
       
    56     gint ret(TMS_RESULT_SUCCESS);
       
    57     return ret;
       
    58     }
       
    59 
       
    60 gint TMSVolumeEffectBodyImpl::AddObserver(TMSEffectObserver& obsrvr,
       
    61         gpointer user_data)
       
    62     {
       
    63     gint ret(TMS_RESULT_SUCCESS);
       
    64     if (!iObserver)
       
    65         {
       
    66         iObserver = &obsrvr;
       
    67         iUserData = user_data;
       
    68         }
       
    69     else
       
    70         {
       
    71         ret = TMS_RESULT_ALREADY_EXIST;
       
    72         }
       
    73     return ret;
       
    74     }
       
    75 
       
    76 gint TMSVolumeEffectBodyImpl::RemoveObserver(TMSEffectObserver& obsrvr)
       
    77     {
       
    78     gint ret(TMS_RESULT_SUCCESS);
       
    79     if (&obsrvr == iObserver)
       
    80         {
       
    81         iObserver = NULL;
       
    82         }
       
    83     else
       
    84         {
       
    85         ret = TMS_RESULT_DOES_NOT_EXIST;
       
    86         }
       
    87     return ret;
       
    88     }
       
    89 
       
    90 gint TMSVolumeEffectBodyImpl::GetLevel(guint& level)
       
    91     {
       
    92     gint ret(TMS_RESULT_SUCCESS);
       
    93     if (iProxy)
       
    94         {
       
    95         ret = iProxy->GetVolume(level);
       
    96         }
       
    97     else
       
    98         {
       
    99         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   100         }
       
   101     return ret;
       
   102     }
       
   103 
       
   104 gint TMSVolumeEffectBodyImpl::SetLevel(const guint level)
       
   105     {
       
   106     gint ret(TMS_RESULT_SUCCESS);
       
   107     if (iProxy)
       
   108         {
       
   109         ret = iProxy->SetVolume(level);
       
   110         }
       
   111     else
       
   112         {
       
   113         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   114         }
       
   115     return ret;
       
   116     }
       
   117 
       
   118 gint TMSVolumeEffectBodyImpl::GetMaxLevel(guint& level)
       
   119     {
       
   120     gint ret(TMS_RESULT_SUCCESS);
       
   121     if (iProxy)
       
   122         {
       
   123         ret = iProxy->GetMaxVolume(level);
       
   124         }
       
   125     else
       
   126         {
       
   127         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   128         }
       
   129     return ret;
       
   130     }
       
   131 
       
   132 gint TMSVolumeEffectBodyImpl::GetType(TMSEffectType& effecttype)
       
   133     {
       
   134     gint ret(TMS_RESULT_SUCCESS);
       
   135     effecttype = TMS_EFFECT_VOLUME;
       
   136     return ret;
       
   137     }
       
   138 
       
   139 gint TMSVolumeEffectBodyImpl::SetParentEffect(TMSEffect*& parenteffect)
       
   140     {
       
   141     gint ret(TMS_RESULT_SUCCESS);
       
   142     iParentEffect = NULL;
       
   143     iParentEffect = parenteffect;
       
   144     return ret;
       
   145     }
       
   146 
       
   147 void TMSVolumeEffectBodyImpl::SetProxy(TMSCallProxy* aProxy,
       
   148         gpointer queuehandler)
       
   149     {
       
   150     iProxy = aProxy;
       
   151     if (queuehandler)
       
   152         {
       
   153         ((CQueueHandler*) queuehandler)->AddObserver(*this, TMS_EFFECT_VOLUME);
       
   154         }
       
   155     }
       
   156 
       
   157 void TMSVolumeEffectBodyImpl::QueueEvent(TInt aEventType, TInt aError,
       
   158         void* /*user_data*/)
       
   159     {
       
   160     TMSSignalEvent event;
       
   161 
       
   162     event.type = TMS_EVENT_EFFECT_VOL_CHANGED;
       
   163     event.reason = aError;
       
   164 
       
   165     switch (aEventType)
       
   166         {
       
   167         case TMS_EVENT_EFFECT_VOL_CHANGED:
       
   168             {
       
   169             if (iObserver && iParentEffect)
       
   170                 {
       
   171                 iObserver->EffectsEvent(iParentEffect, event);
       
   172                 }
       
   173             }
       
   174             break;
       
   175         default:
       
   176             break;
       
   177         }
       
   178     }
       
   179 
       
   180 // End of file