omadrm/drmplugins/drmromtm/client/src/RoMtmCli.cpp
changeset 0 95b198f216e5
child 12 8a03a285ab14
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Rights Object Client side MTM
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    23 #include <mtmuidsdef.hrh>
       
    24 #endif
       
    25 #include <e32std.h>
       
    26 #include <txtrich.h>
       
    27 #include <msvreg.h>
       
    28 #include <msvstore.h>    // cmsvstore
       
    29 #include <msvids.h>      // kmsvlocalserviceindexentryid
       
    30 #include <mtmdef.h>      // kmsvmessagepartbody
       
    31 #include <msvuids.h>     // kuidmsvmessageentry
       
    32 #include <sysutil.h>     // disk space checking
       
    33 
       
    34 #include    "romtmcli.h"
       
    35 #include    "romtmcc.h"
       
    36 #include    "romtmcommon.h"
       
    37 GLREF_C void Panic( TRoMtmCliPanic aPanic );
       
    38 
       
    39 // EXTERNAL DATA STRUCTURES
       
    40 // EXTERNAL FUNCTION PROTOTYPES
       
    41 // CONSTANTS
       
    42 // MACROS
       
    43 // LOCAL CONSTANTS AND MACROS
       
    44 // MODULE DATA STRUCTURES
       
    45 // LOCAL FUNCTION PROTOTYPES
       
    46 // FORWARD DECLARATIONS
       
    47 
       
    48 // ============================= LOCAL FUNCTIONS ===============================
       
    49 
       
    50 // ============================ MEMBER FUNCTIONS ===============================
       
    51 
       
    52 
       
    53 
       
    54 /*************************************
       
    55 *
       
    56 *        Construction and destruction
       
    57 *
       
    58 **************************************/
       
    59 
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CRightsObjectMtmClient::CRightsObjectMtmClient
       
    63 // C++ default constructor can NOT contain any code, that
       
    64 // might leave.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CRightsObjectMtmClient::CRightsObjectMtmClient(
       
    68     CRegisteredMtmDll& aRegisteredMtmDll ,
       
    69     CMsvSession& aMsvSession
       
    70     )
       
    71 : CBaseMtm(aRegisteredMtmDll , aMsvSession )
       
    72     {
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CRightsObjectMtmClient::ConstructL()
       
    77 // Symbian 2nd phase constructor can leave.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CRightsObjectMtmClient::ConstructL()
       
    81     {
       
    82     SwitchCurrentEntryL( KMsvRootIndexEntryId );
       
    83     }
       
    84 
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CRightsObjectMtmClient* CRightsObjectMtmClient::NewL
       
    88 // Two-phased constructor.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CRightsObjectMtmClient* CRightsObjectMtmClient::NewL(
       
    92     CRegisteredMtmDll& aRegisteredMtmDll ,
       
    93     CMsvSession& aMsvSession
       
    94     )
       
    95 // Factory function
       
    96     {
       
    97     CRightsObjectMtmClient* self = new ( ELeave ) CRightsObjectMtmClient( aRegisteredMtmDll , aMsvSession );
       
    98     CleanupStack::PushL( self );
       
    99     self->ConstructL();
       
   100     CleanupStack::Pop( self );
       
   101     return self;
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // Destructor
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 CRightsObjectMtmClient::~CRightsObjectMtmClient()
       
   109     {
       
   110     }
       
   111 
       
   112 /*************************************
       
   113 *
       
   114 *        from CBaseMtm
       
   115 *
       
   116 **************************************/
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CRightsObjectMtmClient::AddAddresseeL
       
   120 //
       
   121 // Not supported
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CRightsObjectMtmClient::AddAddresseeL( const TDesC& /*aRealAddress*/ )
       
   125     {
       
   126     User::Leave( KErrNotSupported );
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CRightsObjectMtmClient::AddAddresseeL
       
   131 //
       
   132 // Not supported
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CRightsObjectMtmClient::AddAddresseeL( const TDesC& /*aRealAddress*/ ,
       
   136     const TDesC& /*aAlias*/ )
       
   137     {
       
   138     User::Leave( KErrNotSupported );
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CRightsObjectMtmClient::RemoveAddressee
       
   143 //
       
   144 // Not supported
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CRightsObjectMtmClient::RemoveAddressee( TInt /*aIndex*/ )
       
   148     {
       
   149     // Not supported.
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CRightsObjectMtmClient::SaveMessageL
       
   154 //
       
   155 // Commits cached changes to the storage controlled by the Message Server
       
   156 // can only be called on message contexts.
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CRightsObjectMtmClient::SaveMessageL()
       
   160     // Store entry data
       
   161     {
       
   162     TMsvEntry indexEntry( iMsvEntry->Entry() );
       
   163     RFs& fs( Session().FileSession() );
       
   164     const CRichText* body( &Body() );
       
   165 
       
   166     if ( !body )
       
   167         {
       
   168         User::Leave( KErrArgument );
       
   169         }
       
   170     // check if there is space for text to be saved
       
   171     if ( SysUtil::DiskSpaceBelowCriticalLevelL(
       
   172             &fs,
       
   173             body->DocumentLength() * sizeof( TText ),
       
   174             RFs::GetSystemDrive() ) )
       
   175         {
       
   176         User::Leave( KErrDiskFull );
       
   177         }
       
   178 
       
   179 
       
   180     // get an editable message store
       
   181     CMsvStore* store( iMsvEntry->EditStoreL() );
       
   182     CleanupStack::PushL( store );
       
   183 
       
   184     switch ( iMsvEntry->Entry().iType.iUid )
       
   185         {
       
   186         case KUidMsvMessageEntryValue:
       
   187                 {
       
   188                 StoreBodyL( *store );
       
   189                 break;
       
   190                 }
       
   191         default:
       
   192                 {
       
   193                 User::Leave( KErrNotSupported );
       
   194                 break;
       
   195                 }
       
   196         }
       
   197     // commit the index changes.
       
   198     iMsvEntry->ChangeL( indexEntry );
       
   199     store->CommitL();
       
   200     CleanupStack::PopAndDestroy( store );
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CRightsObjectMtmClient::LoadMessageL
       
   205 //
       
   206 // Loads the cache with the message data for the current context
       
   207 // can only be called on message contexts.
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 void CRightsObjectMtmClient::LoadMessageL()
       
   211     {
       
   212     TMsvEntry indexEntry( iMsvEntry->Entry() );
       
   213     switch ( indexEntry.iType.iUid )
       
   214         {
       
   215         case KUidMsvMessageEntryValue:
       
   216                 {
       
   217                 // get read-only message store
       
   218                 Body().Reset();
       
   219                 CMsvStore* store( iMsvEntry->ReadStoreL() );
       
   220                 CleanupStack::PushL( store );
       
   221                 RestoreBodyL( *store );
       
   222                 CleanupStack::PopAndDestroy( store );
       
   223                 break;
       
   224                 }
       
   225         default:
       
   226             // if we fall through here, we should panic because
       
   227             // we have wrong entry type
       
   228                 {
       
   229                 User::Leave( KErrNotSupported );
       
   230                 break;
       
   231                 }
       
   232         }
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CRightsObjectMtmClient::ReplyL
       
   237 //
       
   238 // Not supported
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 CMsvOperation* CRightsObjectMtmClient::ReplyL (
       
   242     TMsvId /*aReplyEntryId*/ ,
       
   243     TMsvPartList /*aPartlist*/ ,
       
   244     TRequestStatus& /*aCompletionStatus*/ )
       
   245     {
       
   246     User::Leave( KErrNotSupported );
       
   247     return NULL;
       
   248     }
       
   249 
       
   250 // -----------------------------------------------------------------------------
       
   251 // CRightsObjectMtmClient::ForwardL
       
   252 //
       
   253 // Not supported
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 CMsvOperation* CRightsObjectMtmClient::ForwardL(
       
   257     TMsvId /*aForwardEntryId*/ ,
       
   258     TMsvPartList /*aPartList*/ ,
       
   259     TRequestStatus& /*aCompletionStatus*/ )
       
   260     {
       
   261     User::Leave( KErrNotSupported );
       
   262     return NULL;
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CRightsObjectMtmClient::ValidateMessage
       
   267 //
       
   268 // Not supported
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 TMsvPartList CRightsObjectMtmClient::ValidateMessage( TUint /*PartList*/ )
       
   272     {
       
   273     return KErrNone;
       
   274     }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CRightsObjectMtmClient::Find
       
   278 //
       
   279 // Not supported
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 TMsvPartList CRightsObjectMtmClient::Find( const TDesC& /*aTextToFind*/ , TMsvPartList /*aPartList*/ )
       
   283     // Find text in entry
       
   284     {
       
   285     return KErrNone;
       
   286     }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // CRightsObjectMtmClient::QueryCapability
       
   290 //
       
   291 // Queries if the MTM supports a particular capability, specified by a UID.
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 TInt CRightsObjectMtmClient::QueryCapability( TUid aCapability , TInt& aResponse )
       
   295     // Query for capability
       
   296     {
       
   297     TInt error( KErrNone );
       
   298     switch ( aCapability.iUid )
       
   299         {
       
   300         case KUidMtmQueryMaxBodySizeValue:
       
   301         case KUidMtmQueryMaxTotalMsgSizeValue:
       
   302                 {
       
   303                 aResponse = KMaxRoMessageSize;
       
   304                 break;
       
   305                 }
       
   306         case KUidMtmQuerySupportedBodyValue:
       
   307                 {
       
   308                 aResponse = KMtm7BitBody | KMtm8BitBody |
       
   309                     KMtm16BitBody | KMtmBinaryBody;
       
   310                 break;
       
   311                 }
       
   312         case KUidMtmQuerySupportSubjectValue:
       
   313         case KUidMtmQueryOffLineAllowedValue:
       
   314                 {
       
   315                 aResponse=ETrue;
       
   316                 break;
       
   317                 }
       
   318         default:
       
   319                 {
       
   320                 error = KErrNotSupported;
       
   321                 }
       
   322         }
       
   323     return error;
       
   324     }
       
   325 
       
   326 // -----------------------------------------------------------------------------
       
   327 // CRightsObjectMtmClient::InvokeSyncFunctionL
       
   328 //
       
   329 // Not supported
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 void CRightsObjectMtmClient::InvokeSyncFunctionL(
       
   333     TInt /*aFunctionId*/ ,
       
   334     const CMsvEntrySelection& /*aSelection*/ ,
       
   335     TDes8& /*aParameter*/ )
       
   336 // Call MTM-specific operation synchronously
       
   337     {
       
   338     User::Leave( KErrNotSupported );
       
   339     }
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CRightsObjectMtmClient::InvokeAsyncFunctionL
       
   343 //
       
   344 // Not supported
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 CMsvOperation* CRightsObjectMtmClient::InvokeAsyncFunctionL(
       
   348     TInt /*aFunctionId*/ ,
       
   349     const CMsvEntrySelection& /*aSelection*/ ,
       
   350     TDes8& /*aParameter*/ ,
       
   351     TRequestStatus& /*aCompletionStatus*/ )
       
   352 // Call MTM-specific operation asynchronously
       
   353     {
       
   354     User::Leave( KErrNotSupported );
       
   355     return NULL;
       
   356     }
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // CRightsObjectMtmClient::ContextEntrySwitched
       
   360 //
       
   361 // Not supported
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 void CRightsObjectMtmClient::ContextEntrySwitched()
       
   365     // Context change notification
       
   366     //
       
   367     // No need to know entry changes
       
   368     //
       
   369     {
       
   370     }
       
   371 
       
   372