email/imum/Utils/Src/EmailFeatureUtils.cpp
branchRCL_3
changeset 27 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
26:ebe688cedc25 27:7fdbb852d323
       
     1 /*
       
     2 * Copyright (c) 2006 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: 
       
    15 *       Static functions for imum
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32base.h>
       
    22 #include <centralrepository.h>          // CRepository
       
    23 #include <muiuflagger.h>                // CMuiuFlags
       
    24 #include <featmgr.h>
       
    25 
       
    26 #include "EmailFeatureUtils.h"
       
    27 #include "ImumUtilsLogging.h"
       
    28 #include <SettingEnforcementInfo.h>
       
    29 
       
    30 // EXTERNAL DATA STRUCTURES
       
    31 // EXTERNAL FUNCTION PROTOTYPES
       
    32 // CONSTANTS
       
    33 // MACROS
       
    34 // LOCAL CONSTANTS AND MACROS
       
    35 // MODULE DATA STRUCTURES
       
    36 // LOCAL FUNCTION PROTOTYPES
       
    37 // FORWARD DECLARATIONS
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // ----------------------------------------------------------------------------
       
    42 // MsvEmailMtmUiFeatureUtils::LocalFeatureL()
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 EXPORT_C TBool MsvEmailMtmUiFeatureUtils::LocalFeatureL(
       
    46     const TUid& aCenRepUid,
       
    47     const TUint32 aKeyId,
       
    48     const TUint32 aFlag )
       
    49     {
       
    50     IMUM_STATIC_CONTEXT( MsvEmailMtmUiFeatureUtils::LocalFeatureL, 0, utils, KLogUi );
       
    51 
       
    52     // Create the connection to Central Repository
       
    53     CRepository* cenrep = CRepository::NewLC( aCenRepUid );
       
    54 
       
    55     // Fetch the value from the
       
    56     TInt flags;
       
    57     TInt error = cenrep->Get( aKeyId, flags );
       
    58 
       
    59     // Remove the connection
       
    60     CleanupStack::PopAndDestroy( cenrep );
       
    61     cenrep = NULL;
       
    62 
       
    63     // Return the result as a boolean value
       
    64     return ( flags & aFlag ) == aFlag;
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // MsvEmailMtmUiFeatureUtils::FetchGlobalEmailFeaturesL()
       
    69 // ----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C void MsvEmailMtmUiFeatureUtils::FetchGlobalEmailFeaturesL(
       
    72     TMuiuGlobalFeatureArray& aFeatureArray )
       
    73     {
       
    74     IMUM_STATIC_CONTEXT( MsvEmailMtmUiFeatureUtils::FetchGlobalEmailFeaturesL, 0, utils, KLogUi );
       
    75 
       
    76     // Get global features
       
    77     // EMailFeatureAlwaysOnlineEmail
       
    78     aFeatureArray.Append( KFeatureIdAlwaysOnLineEmail );
       
    79     // EMailFeatureProtocolWlan
       
    80     aFeatureArray.Append( KFeatureIdProtocolWlan );
       
    81     // EMailFeatureCsd
       
    82     aFeatureArray.Append( KFeatureIdAppCsdSupport );
       
    83     // EMailFeatureHelp
       
    84     aFeatureArray.Append( KFeatureIdHelp );
       
    85     // EMailFeatureOfflineMode
       
    86     aFeatureArray.Append( KFeatureIdOfflineMode );
       
    87     // EMailFeatureMeetingRequestSupport
       
    88     aFeatureArray.Append( KFeatureIdMeetingRequestSupport );
       
    89     // EMailFeatureOmaEmn
       
    90     aFeatureArray.Append( KFeatureIdOmaEmailNotifications );
       
    91 
       
    92     if( SettingEnforcementStateL() )
       
    93         {
       
    94         aFeatureArray.Append( KFeatureIdSapPolicyManagement );
       
    95         }
       
    96     }
       
    97 
       
    98 // ----------------------------------------------------------------------------
       
    99 // MsvEmailMtmUiFeatureUtils::FetchLocalEmailFeaturesL()
       
   100 // ----------------------------------------------------------------------------
       
   101 //
       
   102 EXPORT_C void MsvEmailMtmUiFeatureUtils::FetchLocalEmailFeaturesL(
       
   103     TMuiuLocalFeatureArray& aFeatureArray )
       
   104     {
       
   105     IMUM_STATIC_CONTEXT( MsvEmailMtmUiFeatureUtils::FetchLocalEmailFeaturesL, 0, utils, KLogUi );
       
   106 
       
   107     // EMailFeatureAlwaysOnlineCSD
       
   108     TMuiuLocalFeatureItem temp = {
       
   109         KCRUidMuiuVariation, KMuiuEmailConfigFlags,
       
   110         KEmailFeatureIdAlwaysOnline, ETrue };
       
   111     aFeatureArray.Append( temp );
       
   112 
       
   113     // EmailFeatureAlwaysonlineHeaders
       
   114     temp.iFlag = KEmailFeatureIdAlwaysonlineHeaders;
       
   115     aFeatureArray.Append( temp );
       
   116     }
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // MsvEmailMtmUiFeatureUtils::EmailFeaturesLC()
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C CMuiuFlags* MsvEmailMtmUiFeatureUtils::EmailFeaturesLC(
       
   123     const TBool aGetGlobals,
       
   124     const TBool aGetLocals )
       
   125     {
       
   126     IMUM_STATIC_CONTEXT( MsvEmailMtmUiFeatureUtils::EmailFeaturesLC, 0, utils, KLogUi );
       
   127 
       
   128     TMuiuGlobalFeatureArray globals;
       
   129     TMuiuLocalFeatureArray locals;
       
   130 
       
   131     if ( aGetGlobals )
       
   132         {
       
   133         FetchGlobalEmailFeaturesL( globals );
       
   134         }
       
   135 
       
   136     if ( aGetLocals )
       
   137         {
       
   138         FetchLocalEmailFeaturesL( locals );
       
   139         }
       
   140 
       
   141     CMuiuFlags* flags = CMuiuFlags::NewLC( &globals, &locals );
       
   142     globals.Reset();
       
   143     locals.Reset();
       
   144 
       
   145     return flags;
       
   146     }
       
   147 
       
   148 // ----------------------------------------------------------------------------
       
   149 // MsvEmailMtmUiFeatureUtils::EmailFeaturesL()
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 EXPORT_C CMuiuFlags* MsvEmailMtmUiFeatureUtils::EmailFeaturesL(
       
   153     const TBool aGetGlobals,
       
   154     const TBool aGetLocals )
       
   155     {
       
   156     IMUM_STATIC_CONTEXT( MsvEmailMtmUiFeatureUtils::EmailFeaturesL, 0, utils, KLogUi );
       
   157 
       
   158     CMuiuFlags* flags = EmailFeaturesLC( aGetGlobals, aGetLocals );
       
   159     CleanupStack::Pop( flags );
       
   160 
       
   161     return flags;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // MsvEmailMtmUiUtils::SettingEnforcementStateL
       
   166 // Checks if setting enforcement is activated.
       
   167 // ---------------------------------------------------------
       
   168 TBool MsvEmailMtmUiFeatureUtils::SettingEnforcementStateL()
       
   169     {
       
   170     FeatureManager::InitializeLibL();
       
   171     TBool sapPolicy = 
       
   172         FeatureManager::FeatureSupported( KFeatureIdSapPolicyManagement );
       
   173     FeatureManager::UnInitializeLib();
       
   174     if( !sapPolicy )
       
   175         {
       
   176         return EFalse;
       
   177         }
       
   178     
       
   179     CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
       
   180     CleanupStack::PushL(info);
       
   181 
       
   182     TBool active = EFalse;
       
   183     User::LeaveIfError(info->EnforcementActive( EEMailEnforcement, active ) );
       
   184     CleanupStack::PopAndDestroy(info);
       
   185     info = NULL;
       
   186     return active;
       
   187     }
       
   188     
       
   189 // End of File
       
   190