mmserv/tms/tmsimpl/src/tmsglobalvoleffectbodyimpl.cpp
changeset 0 71ca22bcf22a
child 10 3d8c721bf319
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 "tmsproxy.h"
       
    21 #include "tmsutility.h"
       
    22 #include "tmsglobalvoleffectbodyimpl.h"
       
    23 
       
    24 using namespace TMS;
       
    25 
       
    26 TMSGlobalVolEffectBodyImpl::TMSGlobalVolEffectBodyImpl() :
       
    27     iObserver(NULL),
       
    28     iProxy(NULL),
       
    29     iGlobalEffect(NULL)
       
    30     {
       
    31     }
       
    32 
       
    33 TMSGlobalVolEffectBodyImpl::~TMSGlobalVolEffectBodyImpl()
       
    34     {
       
    35     if (iProxy)
       
    36         {
       
    37         iProxy->Close();
       
    38         delete iProxy;
       
    39         iProxy = NULL;
       
    40         }
       
    41     iObserver = NULL;
       
    42     iGlobalEffect = NULL;
       
    43     iUserData = NULL;
       
    44     }
       
    45 
       
    46 gint TMSGlobalVolEffectBodyImpl::Create(TMSGlobalVolEffectBody*& bodyimpl)
       
    47     {
       
    48     gint ret(TMS_RESULT_INSUFFICIENT_MEMORY);
       
    49     TMSGlobalVolEffectBodyImpl* self = new TMSGlobalVolEffectBodyImpl;
       
    50     if (self)
       
    51         {
       
    52         ret = self->PostConstruct();
       
    53         if (ret != TMS_RESULT_SUCCESS)
       
    54             {
       
    55             delete self;
       
    56             self = NULL;
       
    57             }
       
    58         }
       
    59     bodyimpl = self;
       
    60     return ret;
       
    61     }
       
    62 
       
    63 gint TMSGlobalVolEffectBodyImpl::PostConstruct()
       
    64     {
       
    65     gint ret(TMS_RESULT_SUCCESS);
       
    66     iClientId = 1;
       
    67     iProxy = new TMSProxy;
       
    68     if (iProxy)
       
    69         {
       
    70         if (iProxy->Connect() != TMS_RESULT_SUCCESS)
       
    71             {
       
    72             delete iProxy;
       
    73             iProxy = NULL;
       
    74             ret = TMS_RESULT_FATAL_ERROR;
       
    75             }
       
    76         }
       
    77     else
       
    78         {
       
    79         ret = TMS_RESULT_UNINITIALIZED_OBJECT;
       
    80         }
       
    81     return ret;
       
    82     }
       
    83 
       
    84 gint TMSGlobalVolEffectBodyImpl::AddObserver(TMSEffectObserver& obsrvr,
       
    85         gpointer /*user_data*/)
       
    86     {
       
    87     gint ret(TMS_RESULT_SUCCESS);
       
    88     if (!iObserver)
       
    89         {
       
    90         iObserver = &obsrvr;
       
    91         //iUserData = user_data;
       
    92         if (iProxy)
       
    93             {
       
    94             ret = iProxy->SetMsgQueueNotifier(EMsgQueueGlobalVolumeType,
       
    95                     iObserver, iGlobalEffect, iClientId);
       
    96             if (ret == TMS_RESULT_SUCCESS)
       
    97                 {
       
    98                 ret = iProxy->StartGlobalEffectNotifier();
       
    99                 }
       
   100             }
       
   101         else
       
   102             {
       
   103             ret = TMS_RESULT_DOES_NOT_EXIST;
       
   104             }
       
   105         }
       
   106     else
       
   107         {
       
   108         ret = TMS_RESULT_ALREADY_EXIST;
       
   109         }
       
   110     return ret;
       
   111     }
       
   112 
       
   113 gint TMSGlobalVolEffectBodyImpl::RemoveObserver(TMSEffectObserver& obsrvr)
       
   114     {
       
   115     gint ret(TMS_RESULT_SUCCESS);
       
   116 
       
   117     if (iProxy && (&obsrvr == iObserver))
       
   118         {
       
   119         iProxy->RemoveMsgQueueNotifier(EMsgQueueGlobalVolumeType, iObserver);
       
   120         iObserver = NULL;
       
   121         //ret = iProxy->StopEffectNotifier(obsrvr);
       
   122         }
       
   123     else
       
   124         {
       
   125         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   126         }
       
   127     return ret;
       
   128     }
       
   129 
       
   130 gint TMSGlobalVolEffectBodyImpl::GetLevel(guint& level)
       
   131     {
       
   132     gint ret(TMS_RESULT_SUCCESS);
       
   133     if (iProxy)
       
   134         {
       
   135         ret = iProxy->GetLevel(level);
       
   136         }
       
   137     else
       
   138         {
       
   139         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   140         }
       
   141     return ret;
       
   142     }
       
   143 
       
   144 gint TMSGlobalVolEffectBodyImpl::SetLevel(const guint level)
       
   145     {
       
   146     gint ret(TMS_RESULT_SUCCESS);
       
   147     if (iProxy)
       
   148         {
       
   149         ret = iProxy->SetLevel(level);
       
   150         }
       
   151     else
       
   152         {
       
   153         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   154         }
       
   155     return ret;
       
   156     }
       
   157 
       
   158 gint TMSGlobalVolEffectBodyImpl::GetMaxLevel(guint& level)
       
   159     {
       
   160     gint ret(TMS_RESULT_SUCCESS);
       
   161     if (iProxy)
       
   162         {
       
   163         ret = iProxy->GetMaxLevel(level);
       
   164         }
       
   165     else
       
   166         {
       
   167         ret = TMS_RESULT_DOES_NOT_EXIST;
       
   168         }
       
   169     return ret;
       
   170     }
       
   171 
       
   172 gint TMSGlobalVolEffectBodyImpl::GetType(TMSEffectType& effecttype)
       
   173     {
       
   174     gint ret(TMS_RESULT_SUCCESS);
       
   175     effecttype = TMS_EFFECT_GLOBAL_VOL;
       
   176     return ret;
       
   177     }
       
   178 
       
   179 void TMSGlobalVolEffectBodyImpl::SetParentEffect(TMSEffect*& parenteffect)
       
   180     {
       
   181     iGlobalEffect = NULL;
       
   182     iGlobalEffect = parenteffect;
       
   183     }
       
   184 
       
   185 // End of file