vmbx/vmbxengine/src/voicemailboximpl.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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:  Implementation of the CVoiceMailboxImpl class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <featmgr.h>
       
    21 #include <cvoicemailboxentry.h>
       
    22 #include "voicemailboxdefsinternal.h"
       
    23 
       
    24 #include "vmbxenginebase.h"
       
    25 #include "vmbxuiutilities.h"
       
    26 #include "vmbxenginefactory.h"
       
    27 #include "vmbxobserver.h"
       
    28 #include "vmbxlogger.h"
       
    29 #include "vmbxutilities.h"
       
    30 #include "vmbxcenrephandler.h"
       
    31 #include "voicemailboximpl.h"
       
    32 
       
    33 // phone application uid
       
    34 const TInt KPhoneApplicationUid          = 0x100058B3;
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS =============================
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CVoiceMailboxImpl::NewL
       
    40 // Two-phased constructor.
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 CVoiceMailboxImpl* CVoiceMailboxImpl::NewL()
       
    44     {
       
    45     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NewL =>" );
       
    46     CVoiceMailboxImpl* vmbx = CVoiceMailboxImpl::NewLC();
       
    47     CleanupStack::Pop( vmbx );
       
    48     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NewL <=" );
       
    49     return vmbx;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CVoiceMailboxImpl::NewLC
       
    54 // Two-phased constructor.
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CVoiceMailboxImpl* CVoiceMailboxImpl::NewLC()
       
    58     {
       
    59     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NewLC =>" );
       
    60     CVoiceMailboxImpl* vmbx = new( ELeave ) CVoiceMailboxImpl();
       
    61     CleanupStack::PushL( vmbx );
       
    62     vmbx->ConstructL();
       
    63     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NewLC <=" );
       
    64     return vmbx;
       
    65     }
       
    66 // ---------------------------------------------------------------------------
       
    67 // CVoiceMailboxImpl::~CVoiceMailboxImpl
       
    68 // Destructor
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 CVoiceMailboxImpl::~CVoiceMailboxImpl()
       
    72     {
       
    73     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::~CVoiceMailboxImpl =>" );
       
    74     FeatureManager::UnInitializeLib();
       
    75     delete iUiUtilities;
       
    76     delete iVmbxFactory;
       
    77     delete iVmbxObserver;
       
    78     delete iCenRepHandler;
       
    79     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::~CVoiceMailboxImpl <=" );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CVoiceMailboxImpl::GetStoredEntry
       
    84 // 
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 TInt CVoiceMailboxImpl::GetStoredEntry( const TVoiceMailboxParams& aParams,
       
    88                                             CVoiceMailboxEntry*& aEntry ) const
       
    89     {
       
    90     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetStoredEntry =>" );
       
    91     TRAPD( err, GetStoredEntryL( aParams, aEntry ) );
       
    92     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetStoredEntry: err%I <=", err );
       
    93     return err;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CVoiceMailboxImpl::SaveEntry
       
    98 // 
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 TInt CVoiceMailboxImpl::SaveEntry( const CVoiceMailboxEntry& aEntry )
       
   102     {
       
   103     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SaveEntry =>" );
       
   104     TRAPD( err, SaveEntryL( aEntry ) );
       
   105     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::SaveEntry: err%I <=", err );
       
   106     return err;
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CVoiceMailboxImpl::QueryNewEntry
       
   111 // 
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 TInt CVoiceMailboxImpl::QueryNewEntry( const TVoiceMailboxParams& aParams,
       
   115                                            CVoiceMailboxEntry*& aEntry )
       
   116     {
       
   117     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryNewEntry =>" );
       
   118     TRAPD( err, QueryNewEntryL( aParams, aEntry ) );
       
   119     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::QueryNewEntry err%I <=",
       
   120         err );
       
   121     return err;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CVoiceMailboxImpl::QueryChangeEntry
       
   126 // 
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 TInt CVoiceMailboxImpl::QueryChangeEntry( const TVoiceMailboxParams& aParams,
       
   130                                              CVoiceMailboxEntry*& aEntry )
       
   131     {
       
   132     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryChangeEntry =>" );
       
   133     TRAPD( err, QueryChangeEntryL( aParams, aEntry ) );
       
   134     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::QueryChangeEntry: err%I <=",
       
   135         err );
       
   136     return err;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CVoiceMailboxImpl::QueryVmbxType
       
   141 // 
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 TInt CVoiceMailboxImpl::QueryVmbxType( TVoiceMailboxParams& aParams )
       
   145     {
       
   146     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryVmbxType =>" );
       
   147     TRAPD( err, QueryVmbxTypeL( aParams ) );
       
   148     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::QueryVmbxType: err%I<=", err );
       
   149     return err;
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // CVoiceMailboxImpl::NotifyVmbxNumberChangeL
       
   154 //
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CVoiceMailboxImpl::NotifyVmbxNumberChangeL(
       
   158     MVoiceMailboxObserver& aObserver,
       
   159     const TBool /*aNotifyOnActiveLineOnly*/ )
       
   160     {
       
   161     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NotifyVmbxNumberChangeL =>" );
       
   162     if ( !iNotifyCallBack )
       
   163         {
       
   164         iNotifyCallBack = &aObserver;
       
   165         iVmbxObserver = CVmbxObserver::NewL( *this );
       
   166         iVmbxObserver->SetVmbxObserver( *this );
       
   167         }
       
   168     else
       
   169         {
       
   170         User::Leave( KErrInUse );
       
   171         }
       
   172     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NotifyVmbxNumberChangeL <=" );
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // CVoiceMailboxImpl::NotifyVmbxNumberChangeCancel
       
   177 //
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 void CVoiceMailboxImpl::NotifyVmbxNumberChangeCancel()
       
   181     {
       
   182     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NotifyVmbxNumberChangeCancel =>" );
       
   183     iNotifyCallBack = NULL;
       
   184     delete iVmbxObserver;
       
   185     iVmbxObserver = NULL;
       
   186     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NotifyVmbxNumberChangeCancel <=" );
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CVoiceMailboxImpl::CheckConfiguration
       
   191 //
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 TBool CVoiceMailboxImpl::CheckConfiguration( const TVoiceMailboxParams& aParams,
       
   195                              const TInt aFlags )
       
   196     {
       
   197     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CheckConfiguration =>" );
       
   198     TBool configuration( EFalse );
       
   199     CVmbxEngineBase* vmbx = NULL;
       
   200     TRAPD( res, iVmbxFactory->CreateEngineL( vmbx, aParams.iType ) );
       
   201     if ( KErrNone == res && vmbx )
       
   202         {
       
   203         configuration = vmbx->CheckConfiguration( aParams, aFlags );
       
   204         }
       
   205     delete vmbx;
       
   206     vmbx = NULL;
       
   207     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CheckConfiguration <=" );
       
   208     return configuration;
       
   209     }
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // CVoiceMailboxImpl::GetServiceIds
       
   213 //
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 TInt CVoiceMailboxImpl::GetServiceIds( RIdArray& aProfileIds )
       
   217     {
       
   218     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetServiceIds =>" );
       
   219     TRAPD( err, GetServiceIdsL( aProfileIds ) );
       
   220     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetServiceIds: err%I <=", err );
       
   221     return err;
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CVoiceMailboxImpl::GetVmbxImage
       
   226 //
       
   227 // ---------------------------------------------------------------------------
       
   228 /* CGulIcon* CVoiceMailboxImpl::GetVmbxImage(
       
   229                         const TVoiceMailboxParams& aParams )
       
   230     {
       
   231     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetVmbxImage =>" );
       
   232     CGulIcon* guiIcon( NULL );
       
   233     TRAPD( err, guiIcon = GetVmbxImageL( aParams ) );
       
   234     if ( KErrNone != err )
       
   235         {
       
   236         delete guiIcon;
       
   237         guiIcon = NULL;
       
   238         }
       
   239     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetVmbxImage: err%I <=", err );
       
   240     return guiIcon;
       
   241     } */
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // CVoiceMailboxImpl::GetVmbxImages
       
   245 //
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 /* CArrayPtr<CGulIcon>* CVoiceMailboxImpl::GetVmbxImages(
       
   249                             RArray<TVoiceMailboxParams>& aParams )
       
   250     {
       
   251     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetVmbxImages =>" );
       
   252     CArrayPtr<CGulIcon>* guiIcons( NULL );
       
   253     TRAPD( err, guiIcons = GetVmbxImagesL( aParams ) );
       
   254     if ( KErrNone != err )
       
   255         {
       
   256         if ( guiIcons )
       
   257             {
       
   258             guiIcons->ResetAndDestroy();
       
   259             }
       
   260         }
       
   261     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetVmbxImages: err%I <=", err );
       
   262     return guiIcons;
       
   263     } */
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // CVoiceMailboxImpl::SaveProvisionedEntry
       
   267 //
       
   268 // ---------------------------------------------------------------------------
       
   269 //
       
   270 TInt CVoiceMailboxImpl::SaveProvisionedEntry( 
       
   271                                     const CVoiceMailboxEntry& aEntry )
       
   272     {
       
   273     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SaveProvisionedEntry =>" );
       
   274     TRAPD( err, SaveProvisionedEntryL( aEntry ) );
       
   275     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::SaveProvisionedEntry: err%I <=",
       
   276     err );
       
   277     return err;
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // CVoiceMailboxImpl::SatRefreshL
       
   282 // 
       
   283 // notify Sat Refresh
       
   284 // ---------------------------------------------------------------------------
       
   285 //
       
   286 void CVoiceMailboxImpl::SatRefreshL()
       
   287     {
       
   288     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SatRefreshL =>" );
       
   289     // notify sim file's entry changed
       
   290     NotifyChangedL( EVmbxVoice );
       
   291     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SatRefreshL <=" );
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // CVoiceMailboxImpl::CenRepChangedL
       
   296 // 
       
   297 // notify CenRep Changed
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 void CVoiceMailboxImpl::CenRepChangedL( TVmbxCenRepKey aId )
       
   301     {
       
   302     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CenRepChangedL =>" );
       
   303     TVmbxAlsLineType alsLine = VmbxUtilities::AlsLine();
       
   304     if ( ( ( EVmbxVoiceLinePrimaryKey == aId 
       
   305             || EVmbxVideoLinePrimaryKey == aId ) // primary value changed
       
   306             && EVmbxAlsLine2 != alsLine )// line 1 active or using default line
       
   307         || ( ( EVmbxVoiceLineAlternateKey == aId 
       
   308             || EVmbxVideoLineAlternateKey == aId )// alternate value changed
       
   309             && EVmbxAlsLine2 == alsLine ) )// line 2 active
       
   310         {
       
   311         if ( VmbxUtilities::VideoSupported() 
       
   312             && ( ( EVmbxVideoLinePrimaryKey == aId 
       
   313             || EVmbxVideoLineAlternateKey == aId ) ) )
       
   314             {
       
   315             NotifyChangedL( EVmbxVideo );
       
   316             }
       
   317         else
       
   318             {
       
   319             NotifyChangedL( EVmbxVoice );
       
   320             }
       
   321         }
       
   322     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CenRepChangedL <=" );
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CVoiceMailboxImpl::SimStoreChangedL
       
   327 // notify sim store changed
       
   328 // 
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 void CVoiceMailboxImpl::SimStoreChangedL()
       
   332     {
       
   333     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SimStoreChangedL =>" );
       
   334     // notify sim file changed
       
   335     NotifyChangedL( EVmbxVoice );
       
   336     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SimStoreChangedL <=" );
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // CVoiceMailboxImpl::CVoiceMailboxImpl
       
   341 // C++ default constructor can NOT contain any code, that
       
   342 // might leave.
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 CVoiceMailboxImpl::CVoiceMailboxImpl()
       
   346     {
       
   347     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CVoiceMailboxImpl <=>" );
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CVoiceMailboxImpl::ConstructL
       
   352 // Two-phased constructor.
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 void CVoiceMailboxImpl::ConstructL()
       
   356     {
       
   357     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::ConstructL =>" );
       
   358     FeatureManager::InitializeLibL();
       
   359 
       
   360     // Create Ui utilities for dialog and images
       
   361     iUiUtilities = CVmbxUiUtilities::NewL();
       
   362     // create CenRep
       
   363     iCenRepHandler = CVmbxCenRepHandler::NewL();
       
   364 
       
   365     // Create factory for voice/video/voip engine
       
   366     iVmbxFactory = CVmbxEngineFactory::NewL( *this );
       
   367     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::ConstructL <=" );
       
   368     }
       
   369 
       
   370 // ---------------------------------------------------------------------------
       
   371 // CVoiceMailboxImpl::GetStoredEntryL
       
   372 // 
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CVoiceMailboxImpl::GetStoredEntryL( const TVoiceMailboxParams& aParams,
       
   376                                     CVoiceMailboxEntry*& aEntry ) const
       
   377     {
       
   378     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetStoredEntryL =>" );
       
   379     CVoiceMailboxEntry* entry( NULL );
       
   380     CVmbxEngineBase* vmbxBox( NULL );
       
   381     iVmbxFactory->CreateEngineL( vmbxBox, aParams.iType );
       
   382     CleanupStack::PushL( vmbxBox );
       
   383     vmbxBox->GetL( entry );
       
   384     CleanupStack::PopAndDestroy( vmbxBox );
       
   385     aEntry = entry;
       
   386     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetStoredEntryL <=" );
       
   387     }
       
   388 
       
   389 // ---------------------------------------------------------------------------
       
   390 // CVoiceMailboxImpl::SaveEntryL
       
   391 // 
       
   392 // ---------------------------------------------------------------------------
       
   393 //
       
   394 void CVoiceMailboxImpl::SaveEntryL( const CVoiceMailboxEntry& aEntry )
       
   395     {
       
   396     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SaveEntryL =>" );
       
   397     TVoiceMailboxParams params( aEntry );
       
   398     CVmbxEngineBase* vmbxBox( NULL );
       
   399     iVmbxFactory->CreateEngineL( vmbxBox, aEntry.VoiceMailboxType() );
       
   400     CleanupStack::PushL( vmbxBox );
       
   401     if ( vmbxBox->CheckConfiguration( params, EVmbxChangeNbrAllowedOnUi ) )
       
   402         {
       
   403         vmbxBox->SaveL( aEntry, ETrue );
       
   404         }
       
   405     else
       
   406         {
       
   407         User::Leave( KErrNotSupported );
       
   408         }
       
   409     CleanupStack::PopAndDestroy( vmbxBox );
       
   410     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SaveEntryL <=" );
       
   411     }
       
   412 
       
   413 // ---------------------------------------------------------------------------
       
   414 // CVoiceMailboxImpl::QueryNewEntryL
       
   415 // 
       
   416 // ---------------------------------------------------------------------------
       
   417 //
       
   418 void CVoiceMailboxImpl::QueryNewEntryL( const TVoiceMailboxParams& aParams,
       
   419                                    CVoiceMailboxEntry*& aEntry )
       
   420     {
       
   421     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryNewEntryL =>" );
       
   422     CVmbxEngineBase* vmbxBox( NULL );
       
   423     iVmbxFactory->CreateEngineL( vmbxBox, aParams.iType );
       
   424     CleanupStack::PushL( vmbxBox );
       
   425     if ( vmbxBox->CheckConfiguration( aParams, EVmbxChangeNbrAllowedOnUi ) )
       
   426         {
       
   427         CVoiceMailboxEntry* entry = CVoiceMailboxEntry::NewLC();
       
   428         entry->SetVoiceMailboxType( aParams.iType );
       
   429         entry->SetServiceId( aParams.iServiceId );
       
   430         vmbxBox->QueryDefineNumberL( *entry );
       
   431         CleanupStack::Pop( entry );
       
   432         aEntry = entry;
       
   433         }
       
   434     else
       
   435         {
       
   436         CheckNumberProvisionedL( aParams );
       
   437         }
       
   438     CleanupStack::PopAndDestroy( vmbxBox );
       
   439     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryNewEntryL <=" );
       
   440     }
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 // CVoiceMailboxImpl::QueryChangeEntryL
       
   444 // 
       
   445 // ---------------------------------------------------------------------------
       
   446 //
       
   447 void CVoiceMailboxImpl::QueryChangeEntryL( const TVoiceMailboxParams& aParams,
       
   448                                             CVoiceMailboxEntry*& aEntry )
       
   449     {
       
   450     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryChangeEntryL =>" );
       
   451     CVmbxEngineBase* vmbxBox( NULL );
       
   452     iVmbxFactory->CreateEngineL( vmbxBox, aParams.iType );
       
   453     CleanupStack::PushL( vmbxBox );
       
   454     if ( vmbxBox->CheckConfiguration( aParams, EVmbxChangeNbrAllowedOnUi ) )
       
   455         {
       
   456         CVoiceMailboxEntry* entry( NULL );
       
   457         GetStoredEntryL( aParams, entry );
       
   458         CleanupStack::PushL( entry );
       
   459         vmbxBox->QueryChangeNumberL( *entry );
       
   460         CleanupStack::Pop( entry );
       
   461         aEntry = entry;
       
   462         }
       
   463     else
       
   464         {
       
   465         CheckNumberProvisionedL( aParams );
       
   466         }
       
   467     CleanupStack::PopAndDestroy( vmbxBox );
       
   468     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryChangeEntryL <=" );
       
   469     }
       
   470 
       
   471 // ---------------------------------------------------------------------------
       
   472 // CleanupRPointerArray
       
   473 // avoid memory leak when using RPointerArray
       
   474 // ---------------------------------------------------------------------------
       
   475 //
       
   476 LOCAL_C void CleanupRPointerArray( TAny* aParam )
       
   477     {
       
   478     if ( aParam )
       
   479         {
       
   480         static_cast< RPointerArray<CVoiceMailboxEntry>* >( aParam )
       
   481                                                     ->ResetAndDestroy();
       
   482         }
       
   483     }
       
   484 
       
   485 // ---------------------------------------------------------------------------
       
   486 // CVoiceMailboxImpl::QueryVmbxTypeL
       
   487 // Query vmbx type
       
   488 // ---------------------------------------------------------------------------
       
   489 //
       
   490 void CVoiceMailboxImpl::QueryVmbxTypeL( TVoiceMailboxParams& aParams )
       
   491     {
       
   492     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL =>" );
       
   493     aParams.iType = EVmbxNone;
       
   494     aParams.iServiceId = KVmbxServiceIdNone;
       
   495 
       
   496     TInt result ( KErrNotFound );
       
   497     RPointerArray<CVoiceMailboxEntry> array;
       
   498     TCleanupItem item( CleanupRPointerArray, &array );
       
   499     CleanupStack::PushL( item );
       
   500     GetDefinedEntriesL( array );
       
   501 
       
   502     TInt definedCount = array.Count();
       
   503     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL:\
       
   504         definedCount%I", definedCount );
       
   505     // more than one number defined
       
   506     if ( definedCount > 1 )
       
   507         {
       
   508         VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL:\
       
   509         more than one number Denfined" );
       
   510         // query call type
       
   511         RArray<TVoiceMailboxParams> paramsArray;
       
   512         CleanupClosePushL( paramsArray );
       
   513         TVoiceMailboxParams entryParams;
       
   514         for ( TInt i = 0; i < array.Count(); i++ )
       
   515             {
       
   516             entryParams.iType = array[i]->VoiceMailboxType();
       
   517             entryParams.iServiceId = array[i]->ServiceId();
       
   518             paramsArray.AppendL( entryParams );
       
   519             }
       
   520         //CArrayPtr<CGulIcon>* dialogIcons = GetVmbxImagesL( paramsArray );
       
   521         //CleanupStack::PushL( dialogIcons );
       
   522         iUiUtilities->ShowCallSelectionDialogL( 
       
   523         array, /* dialogIcons, */ aParams, result );
       
   524         //CleanupStack::Pop( dialogIcons );
       
   525         CleanupStack::PopAndDestroy( &paramsArray );
       
   526         }
       
   527     // only one number defined
       
   528     else if ( 1 == definedCount )
       
   529         {
       
   530         // return the onle defined number
       
   531         VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL:\
       
   532         One number Denfined" );
       
   533         aParams.iType = array[0]->VoiceMailboxType();
       
   534         result = KErrNone;
       
   535         }
       
   536     // there is no number defined
       
   537     else
       
   538         {
       
   539         VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL:\
       
   540              no number Denfined" );
       
   541         // define number
       
   542         if ( VmbxUtilities::VideoSupported() )
       
   543             {
       
   544             // query to be defined type
       
   545             iUiUtilities->ShowDefineSelectionDialogL( aParams.iType, result );
       
   546             // if result is KErrNone(but result should be also KErrNotFound ),
       
   547             // it means user have seclected the defined type;
       
   548             // else user cancel to select the type, so should return result value
       
   549             if ( KErrNone == result )
       
   550                 {
       
   551                 result = KErrNotFound;
       
   552                 }
       
   553             }
       
   554         else
       
   555             {
       
   556             aParams.iType = EVmbxVoice;
       
   557             }
       
   558         }
       
   559 
       
   560     CleanupStack::PopAndDestroy( &array ); //item 
       
   561     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL: result%I",
       
   562     result );
       
   563     User::LeaveIfError( result );
       
   564     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::QueryVmbxTypeL <=" );
       
   565     }
       
   566 
       
   567 // ----------------------------------------------------------------------------
       
   568 // CVoiceMailboxImpl::GetDefinedEntriesL
       
   569 //
       
   570 // ----------------------------------------------------------------------------
       
   571 //
       
   572 void CVoiceMailboxImpl::GetDefinedEntriesL( 
       
   573                             RPointerArray<CVoiceMailboxEntry>& aArray )
       
   574     {
       
   575     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedEntriesL =>" );
       
   576     TRAPD( voiceErr,GetDefinedVoiceEntryL( aArray ));
       
   577     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetDefinedEntriesL: voiceErr%I",
       
   578             voiceErr );
       
   579     // It should be ignored when video/voip unsupported or no number defined
       
   580     if ( KErrNotFound != voiceErr )
       
   581         {
       
   582         User::LeaveIfError( voiceErr );
       
   583         }
       
   584     
       
   585     TRAPD( videoErr, GetDefinedVideoEntryL( aArray ) );
       
   586     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetDefinedEntriesL: videoErr%I",
       
   587             videoErr );
       
   588     if ( KErrNotSupported != videoErr && KErrNotFound != videoErr )
       
   589         {
       
   590         User::LeaveIfError( videoErr );
       
   591         }
       
   592  
       
   593     TRAPD( voIperr, GetDefinedVoipEntriesL( aArray ));
       
   594 
       
   595     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetDefinedEntriesL: voIperr%I",
       
   596             voIperr );
       
   597     // It should be ignored when video/voip unsupported or no number defined
       
   598     if ( KErrNotSupported != voIperr && KErrNotFound != voIperr )
       
   599         {
       
   600         User::LeaveIfError( voIperr );
       
   601         }
       
   602  
       
   603     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedEntriesL <=" );
       
   604     }
       
   605 
       
   606 // ----------------------------------------------------------------------------
       
   607 // CVoiceMailboxImpl::GetDefinedVoiceEntryL
       
   608 //
       
   609 // ----------------------------------------------------------------------------
       
   610 //
       
   611 void CVoiceMailboxImpl::GetDefinedVoiceEntryL( 
       
   612                             RPointerArray<CVoiceMailboxEntry>& aArray )
       
   613     {
       
   614     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedVoiceEntryL =>" );
       
   615     // check voice mailbox
       
   616     CVmbxEngineBase* voiceBox( NULL );
       
   617     iVmbxFactory->CreateEngineL( voiceBox, EVmbxVoice );
       
   618     CleanupStack::PushL( voiceBox );
       
   619     // get voice entry
       
   620     CVoiceMailboxEntry* voiceEntry( NULL);
       
   621     voiceBox->GetL( voiceEntry );
       
   622     CleanupStack::PushL( voiceEntry );
       
   623     // get voice number
       
   624     TPtrC vmbxVoiceNumber( KNullDesC );
       
   625     TInt resVoice = voiceEntry->GetVmbxNumber( vmbxVoiceNumber );
       
   626     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetDefinedVoiceEntryL:\
       
   627                     VoiceNumber = %S ", &vmbxVoiceNumber );
       
   628     if ( KErrNone == resVoice && vmbxVoiceNumber.Length() )
       
   629         {
       
   630         aArray.AppendL( voiceEntry );
       
   631         }
       
   632     CleanupStack::Pop( voiceEntry );
       
   633     CleanupStack::PopAndDestroy( voiceBox );
       
   634     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedVoiceEntryL <=" );
       
   635     }
       
   636 
       
   637 // ----------------------------------------------------------------------------
       
   638 // CVoiceMailboxImpl::GetDefinedVideoEntryL
       
   639 //
       
   640 // ----------------------------------------------------------------------------
       
   641 //
       
   642 void CVoiceMailboxImpl::GetDefinedVideoEntryL( 
       
   643                             RPointerArray<CVoiceMailboxEntry>& aArray )
       
   644     {
       
   645     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedVideoEntryL =>" );
       
   646     // check video mailbox
       
   647     CVmbxEngineBase* videoBox = NULL;
       
   648     iVmbxFactory->CreateEngineL( videoBox, EVmbxVideo );
       
   649     CleanupStack::PushL( videoBox );
       
   650 
       
   651     CVoiceMailboxEntry* videoEntry( NULL );
       
   652     // get video entry
       
   653     videoBox->GetL( videoEntry );
       
   654     CleanupStack::PushL( videoEntry );
       
   655     TPtrC vmbxVideoNumber( KNullDesC );
       
   656 
       
   657     TInt resVideo = videoEntry->GetVmbxNumber( vmbxVideoNumber );
       
   658     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetDefinedVideoEntryL:\
       
   659                             VideoNumber = %S ", &vmbxVideoNumber );
       
   660 
       
   661     if ( KErrNone == resVideo && vmbxVideoNumber.Length() )
       
   662         {
       
   663         aArray.AppendL( videoEntry );
       
   664         }
       
   665     CleanupStack::Pop( videoEntry );
       
   666     CleanupStack::PopAndDestroy( videoBox );
       
   667     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedVideoEntryL <=" );
       
   668     }
       
   669 
       
   670 // ----------------------------------------------------------------------------
       
   671 // CVoiceMailboxImpl::GetDefinedVoipEntriesL
       
   672 //
       
   673 // ----------------------------------------------------------------------------
       
   674 //
       
   675 void CVoiceMailboxImpl::GetDefinedVoipEntriesL( 
       
   676                             RPointerArray<CVoiceMailboxEntry>& aArray )
       
   677     {
       
   678     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedVoipEntriesL =>" );
       
   679     // check VoIP mailbox
       
   680     CVmbxEngineBase* voIPBox = NULL;
       
   681     iVmbxFactory->CreateEngineL( voIPBox, EVmbxVoip );
       
   682     CleanupStack::PushL( voIPBox );
       
   683 
       
   684     RIdArray profileIds;
       
   685     CleanupClosePushL( profileIds );
       
   686 
       
   687     voIPBox->GetServiceIdsL( profileIds );
       
   688     TInt profileCounts = profileIds.Count();
       
   689     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetDefinedVoipEntriesL:\
       
   690                                    VoIP profileCounts%I ", profileCounts);
       
   691     if ( 0 < profileCounts )
       
   692         {
       
   693         for ( TInt i( 0 ); i < profileCounts; i++ )
       
   694             {
       
   695             voIPBox->SetCurrentServiceId( profileIds[i] );
       
   696             CVoiceMailboxEntry* voIPEntry( NULL );
       
   697             // get voip entry
       
   698             voIPBox->GetL( voIPEntry );
       
   699             CleanupStack::PushL( voIPEntry );
       
   700             TPtrC vmbxVoIPName( KNullDesC );
       
   701             TInt resVoIP = voIPEntry->GetVmbxName( vmbxVoIPName );
       
   702 
       
   703             TPtrC vmbxVoIPAddress( KNullDesC );
       
   704             if ( KErrNone == resVoIP )
       
   705                 {
       
   706                 VMBLOGSTRING2( 
       
   707                 "VMBX: CVoiceMailboxImpl::GetDefinedVoipEntriesL:\
       
   708                         vmbxVoIPName = %S ", &vmbxVoIPName );
       
   709                 resVoIP = voIPEntry->GetVmbxNumber( vmbxVoIPAddress );
       
   710                 }
       
   711             if ( KErrNone == resVoIP && vmbxVoIPAddress.Length() 
       
   712                  && vmbxVoIPName.Length() )
       
   713                 {
       
   714                 VMBLOGSTRING2( 
       
   715                 "VMBX: CVoiceMailboxImpl::GetDefinedVoipEntriesL:\
       
   716                     vmbxVoIPAddress = %S ", &vmbxVoIPAddress );
       
   717                 aArray.AppendL( voIPEntry );
       
   718                 }
       
   719             CleanupStack::Pop( voIPEntry );
       
   720             }
       
   721         }
       
   722     CleanupStack::PopAndDestroy( &profileIds );
       
   723     CleanupStack::PopAndDestroy( voIPBox );
       
   724     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetDefinedVoipEntriesL <=" );
       
   725     }
       
   726 
       
   727 // ----------------------------------------------------------------------------
       
   728 // CVoiceMailboxImpl::GetServiceIdsL
       
   729 //
       
   730 // ----------------------------------------------------------------------------
       
   731 void CVoiceMailboxImpl::GetServiceIdsL( RIdArray& aProfileIds )
       
   732     {
       
   733     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetServiceIdsL =>" );
       
   734     // Get all Service Ids
       
   735     RIdArray profileIds;
       
   736     CleanupClosePushL( profileIds );
       
   737     CVmbxEngineBase* vmbx = NULL;
       
   738     iVmbxFactory->CreateEngineL( vmbx, EVmbxVoip );
       
   739     CleanupStack::PushL( vmbx );
       
   740     vmbx->GetServiceIdsL( profileIds );
       
   741     for ( TInt i( 0 ); i < profileIds.Count(); i++ )
       
   742         {
       
   743         aProfileIds.AppendL( profileIds[i]);
       
   744         }
       
   745     CleanupStack::PopAndDestroy( vmbx );
       
   746     CleanupStack::Pop( &profileIds );
       
   747     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetServiceIdsL <=");
       
   748     }
       
   749 
       
   750 // ----------------------------------------------------------------------------
       
   751 // CVoiceMailboxImpl::GetVmbxImageL
       
   752 //
       
   753 // ----------------------------------------------------------------------------
       
   754 /* CGulIcon* CVoiceMailboxImpl::GetVmbxImageL( 
       
   755                     const TVoiceMailboxParams& aParams )
       
   756     {
       
   757     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetVmbxImageL =>" );
       
   758     CGulIcon* guiIcon( NULL );
       
   759     CVmbxEngineBase* vmbxEngine = NULL;
       
   760     iVmbxFactory->CreateEngineL( vmbxEngine, aParams.iType );
       
   761     CleanupStack::PushL( vmbxEngine );
       
   762     if ( vmbxEngine )
       
   763         {
       
   764         guiIcon = vmbxEngine->GetVmbxImageL( aParams );
       
   765         }
       
   766     CleanupStack::PopAndDestroy( vmbxEngine ); 
       
   767     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetVmbxImageL <=" );
       
   768     return guiIcon;
       
   769     } */
       
   770 
       
   771 // ----------------------------------------------------------------------------
       
   772 // CVoiceMailboxImpl::GetVmbxImagesL
       
   773 //
       
   774 // ----------------------------------------------------------------------------
       
   775 //
       
   776 /* CArrayPtr<CGulIcon>* CVoiceMailboxImpl::GetVmbxImagesL(
       
   777                             RArray<TVoiceMailboxParams>& aParams )
       
   778     {
       
   779     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetVmbxImagesL =>" );
       
   780     CAknIconArray* icons =
       
   781                 new( ELeave ) CAknIconArray( KVmLbxItemsArraySize );
       
   782     CleanupStack::PushL( icons );
       
   783 
       
   784     const TInt count = aParams.Count();
       
   785     VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::GetVmbxImagesL count %I",
       
   786         count);
       
   787     for( TInt i = 0; i < count; i++ )
       
   788         {
       
   789         CGulIcon *icon = GetVmbxImageL( aParams[i] );
       
   790         icons->AppendL( icon );
       
   791         }
       
   792     CleanupStack::Pop( icons );
       
   793     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::GetVmbxImagesL <=" );
       
   794     return icons;
       
   795     } */
       
   796 
       
   797 // ---------------------------------------------------------------------------
       
   798 // CVoiceMailboxImpl::SaveProvisionedEntryL
       
   799 //
       
   800 // ---------------------------------------------------------------------------
       
   801 //
       
   802 void CVoiceMailboxImpl::SaveProvisionedEntryL( 
       
   803                                     const CVoiceMailboxEntry& aEntry )
       
   804     {
       
   805     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SaveProvisionedEntryL =>" );
       
   806     CVmbxEngineBase* vmbxEngine = NULL;
       
   807     iVmbxFactory->CreateEngineL( vmbxEngine, aEntry.VoiceMailboxType() );
       
   808     CleanupStack::PushL( vmbxEngine );
       
   809     TVoiceMailboxParams params( aEntry );
       
   810     vmbxEngine->SaveProvisionedEntryL( aEntry );
       
   811     CleanupStack::PopAndDestroy( vmbxEngine );
       
   812     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::SaveProvisionedEntryL <=");
       
   813     }
       
   814 
       
   815 // ---------------------------------------------------------------------------
       
   816 // CVoiceMailboxImpl::NotifyChangedL
       
   817 // notify changed and tell the change to observer
       
   818 // 
       
   819 // ---------------------------------------------------------------------------
       
   820 //
       
   821 void CVoiceMailboxImpl::NotifyChangedL( TVmbxType aType )
       
   822     {
       
   823     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NotifyChangedL =>" );
       
   824     iUiUtilities->DismissDialogL();
       
   825     if ( iNotifyCallBack )
       
   826         {
       
   827         CVmbxEngineBase* vmbxEngine = NULL;
       
   828         iVmbxFactory->CreateEngineL( vmbxEngine, aType );
       
   829         CleanupStack::PushL( vmbxEngine );
       
   830         CVoiceMailboxEntry* entry( NULL );
       
   831         vmbxEngine->GetL( entry );
       
   832         CleanupStack::PushL( entry );
       
   833         iNotifyCallBack->HandleNotifyL( *entry );
       
   834         CleanupStack::PopAndDestroy( entry );           
       
   835         CleanupStack::PopAndDestroy( vmbxEngine );
       
   836         }
       
   837     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::NotifyChangedL <=" );
       
   838     }
       
   839 
       
   840 // ---------------------------------------------------------------------------
       
   841 // CVoiceMailboxImpl::VmbxUiUtilities
       
   842 // notify changed and tell the change to observer
       
   843 // 
       
   844 // ---------------------------------------------------------------------------
       
   845 //
       
   846 MVmbxUiUtilities& CVoiceMailboxImpl::VmbxUiUtilities()
       
   847     {
       
   848     return *iUiUtilities;
       
   849     }
       
   850 
       
   851 // ---------------------------------------------------------------------------
       
   852 // CVoiceMailboxImpl::VmbxCenRepHandler
       
   853 // notify changed and tell the change to observer
       
   854 // 
       
   855 // ---------------------------------------------------------------------------
       
   856 //
       
   857 MVmbxCenrepHandler& CVoiceMailboxImpl::VmbxCenRepHandler()
       
   858     {
       
   859     return *iCenRepHandler;
       
   860     }
       
   861 
       
   862 // ---------------------------------------------------------------------------
       
   863 // CVoiceMailboxImpl::CheckNumberProvisionedL
       
   864 // 
       
   865 // ---------------------------------------------------------------------------
       
   866 //
       
   867 void CVoiceMailboxImpl::CheckNumberProvisionedL( 
       
   868         const TVoiceMailboxParams& aParams )
       
   869     {
       
   870     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CheckNumberProvisionedL =>" );
       
   871     if ( ( EVmbxVoice == aParams.iType 
       
   872             && EVmbxSimMemory == iCenRepHandler->StoreType() )
       
   873          || ( EVmbxVideo == aParams.iType ) )
       
   874         {
       
   875         // get current active process
       
   876         RProcess curProcess;
       
   877         TInt curProcessId( curProcess.SecureId().iId );
       
   878         VMBLOGSTRING2( "VMBX: CVoiceMailboxImpl::CheckNumberProvisionedL \
       
   879             Get cur process id: curProcessId = %I", curProcessId );
       
   880         // User press 1+send key or long press 1
       
   881         if ( KPhoneApplicationUid == curProcessId )
       
   882             {
       
   883             RPointerArray<CVoiceMailboxEntry> array;
       
   884             TCleanupItem item( CleanupRPointerArray, &array );
       
   885             CleanupStack::PushL( item );
       
   886             GetDefinedEntriesL( array );
       
   887             // Only operator has the possibility to configure device, 
       
   888             // user is not allowed to edit the voice mail numbers
       
   889             if ( array.Count() < 1 )
       
   890                 {
       
   891                 // show not allowed user editing dialog
       
   892                 iUiUtilities->ShowNotAllowedEditingDialogL();
       
   893                 }
       
   894             CleanupStack::PopAndDestroy( &array ); //item 
       
   895             } 
       
   896         }
       
   897     // User don't have access to edit cs voice or video number
       
   898     User::Leave( KErrAccessDenied );
       
   899     VMBLOGSTRING( "VMBX: CVoiceMailboxImpl::CheckNumberProvisionedL <=" );
       
   900     }
       
   901 
       
   902 // End of file