omadrm/drmplugins/drmromtm/ui/src/RoMtmUi.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:  Implementation of Rights Object MTM UI
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <txtrich.h>//CRichText
       
    22 #include <eikrted.h> //	CEikRichTextEditor
       
    23 #include <eikenv.h>//CEikonEnv
       
    24 
       
    25 #include <AiwGenericParam.h>
       
    26 #include <AknLaunchAppService.h>
       
    27 
       
    28 #include <eikon.rsg>
       
    29 // Messaging includes
       
    30 #include <MSVUIDS.H>
       
    31 #include <msvids.h>
       
    32 
       
    33 #ifdef RD_MULTIPLE_DRIVE
       
    34 #include <DriveInfo.h>
       
    35 #endif
       
    36 
       
    37 #include <eikproc.h>
       
    38 #include <eikdoc.h>
       
    39 #include <akndialog.h>
       
    40 #include "RoMtmUi.h"
       
    41 #include "RoMtmUiC.h"
       
    42 
       
    43 
       
    44 #include <DocumentHandler.h> // document handler
       
    45 #include <apaid.h> //TApaAppInfo
       
    46 #include <apgcli.h> //RApaLsSession
       
    47 #include <RoapEng.h> // CRoapEng
       
    48 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
       
    49 #include <AknQueryDialog.h> // CAknQueryDialog
       
    50 #include <StringLoader.h> //StringLoader
       
    51 #include <coneresloader.h> //rconeresloader
       
    52 #include <RoMtmUi.rsg> // test
       
    53 // EXTERNAL DATA STRUCTURES
       
    54 // EXTERNAL FUNCTION PROTOTYPES  
       
    55 // CONSTANTS
       
    56 _LIT(KRoAcquisitionPrefix, "ROA:");
       
    57 _LIT(KTriggerPrefix, "TRI:");
       
    58 
       
    59 #ifndef RD_MULTIPLE_DRIVE
       
    60 _LIT( KDriveZ, "z:" );
       
    61 #endif
       
    62                                       
       
    63 _LIT( KRoMtmUiResFileName,"RoMtmUi.rsc" );
       
    64 // MACROS
       
    65 // LOCAL CONSTANTS AND MACROS
       
    66 // MODULE DATA STRUCTURES
       
    67 // LOCAL FUNCTION PROTOTYPES
       
    68 // FORWARD DECLARATIONS
       
    69 
       
    70 
       
    71 // ============================= LOCAL FUNCTIONS ===============================
       
    72 // ============================ LOCAL FUNCTIONS ===============================
       
    73 //#define _DRM_TESTING
       
    74 
       
    75 #ifdef _DRM_TESTING
       
    76 LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
       
    77 LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
       
    78 LOCAL_C void CreateLogL();
       
    79 LOCAL_C void WriteL( const TDesC8& aText );
       
    80 LOCAL_C void WriteL( const TDesC& aText );
       
    81 LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
       
    82 LOCAL_C void WriteL( const TDesC& aText , TInt aErr );
       
    83 LOCAL_C void WriteCurrentTimeL();
       
    84 #endif
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // Testing stuff
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 #ifdef _DRM_TESTING
       
    91 LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
       
    92     {
       
    93     _LIT( KLogFile , "c:\\CRightsObjectMtmUi.txt" );
       
    94     WriteFileL( text , aFs , KLogFile );
       
    95     }
       
    96 
       
    97 LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
       
    98     {
       
    99     RFile file;
       
   100     TInt size;
       
   101     User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
       
   102     CleanupClosePushL( file );
       
   103     User::LeaveIfError( file.Size( size ) );
       
   104     User::LeaveIfError( file.Write( size, text ) );
       
   105     CleanupStack::PopAndDestroy(); //file
       
   106     }
       
   107 
       
   108 LOCAL_C void CreateLogL()
       
   109     {
       
   110     RFs fs;
       
   111     User::LeaveIfError(fs.Connect());
       
   112     CleanupClosePushL(fs);
       
   113     RFile file;
       
   114     User::LeaveIfError( file.Replace( fs , _L("c:\\CRightsObjectMtmUi.txt") , EFileWrite ) );
       
   115     file.Close();
       
   116     CleanupStack::PopAndDestroy(); //fs
       
   117     }
       
   118 
       
   119 LOCAL_C void WriteL( const TDesC& aText )
       
   120     {
       
   121     RFs fs;
       
   122     User::LeaveIfError( fs.Connect() );
       
   123     CleanupClosePushL(fs);
       
   124     HBufC8* text = HBufC8::NewLC(1000);
       
   125     TPtr8 textptr(text->Des() );
       
   126     textptr.Append( aText );
       
   127     textptr.Append( _L8("\r\n") );
       
   128     WriteLogL(textptr , fs);
       
   129     CleanupStack::PopAndDestroy(text);
       
   130     CleanupStack::PopAndDestroy(); //fs
       
   131     WriteCurrentTimeL();
       
   132     }
       
   133 
       
   134 LOCAL_C void WriteL( const TDesC8& aText )
       
   135     {
       
   136     RFs fs;
       
   137     User::LeaveIfError( fs.Connect() );
       
   138     CleanupClosePushL(fs);
       
   139     HBufC8* text = HBufC8::NewLC(1000);
       
   140     TPtr8 textptr(text->Des() );
       
   141     textptr.Append( aText );
       
   142     textptr.Append( _L8("\r\n") );
       
   143     WriteLogL(textptr , fs);
       
   144     CleanupStack::PopAndDestroy(text);
       
   145     CleanupStack::PopAndDestroy(); //fs
       
   146     WriteCurrentTimeL();
       
   147     }
       
   148     
       
   149 LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
       
   150     {
       
   151     _LIT8(KErr,": %d");
       
   152     HBufC8* text = HBufC8::NewLC(1000+20);
       
   153     TBuf8<20> num;
       
   154     TPtr8 textptr(text->Des());
       
   155     textptr.Append(aText);
       
   156     num.Format(KErr(),aErr);
       
   157     textptr.Append(num);
       
   158     WriteL(textptr);
       
   159     CleanupStack::PopAndDestroy(text);
       
   160     }
       
   161     
       
   162 LOCAL_C void WriteL( const TDesC& aText , TInt aErr )
       
   163     {
       
   164     _LIT8(KErr,": %d");
       
   165     HBufC8* text = HBufC8::NewLC(1000+20);
       
   166     TBuf8<20> num;
       
   167     TPtr8 textptr(text->Des());
       
   168     textptr.Append(aText);
       
   169     num.Format(KErr(),aErr);
       
   170     textptr.Append(num);
       
   171     WriteL(textptr);
       
   172     CleanupStack::PopAndDestroy(text);
       
   173     }
       
   174 
       
   175 LOCAL_C void WriteCurrentTimeL()
       
   176     {
       
   177     RFs fs;
       
   178     User::LeaveIfError( fs.Connect() );
       
   179     CleanupClosePushL(fs);
       
   180     HBufC8* text = HBufC8::NewLC(100);
       
   181     TPtr8 textptr(text->Des() );
       
   182 // Date and Time display
       
   183     TTime time;
       
   184     time.HomeTime();
       
   185     TBuf<256> dateString;
       
   186     _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
       
   187     time.FormatL(dateString,KDate);
       
   188     textptr.Append(_L( "\r\n\t\tData:\t" ) );
       
   189     textptr.Append( dateString );
       
   190     _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
       
   191     time.FormatL(dateString,KTime);
       
   192     textptr.Append(_L( "\r\n\t\tTime:\t" ) );
       
   193     textptr.Append( dateString );
       
   194     textptr.Append(_L( "\r\n" ) );
       
   195     textptr.Append(_L( "\r\n" ) );
       
   196     WriteLogL(textptr , fs);
       
   197     CleanupStack::PopAndDestroy(text);
       
   198     CleanupStack::PopAndDestroy(); //fs
       
   199     }
       
   200 #endif
       
   201 /*************************************
       
   202 *
       
   203 *		Global function declarations
       
   204 *
       
   205 **************************************/
       
   206 
       
   207 EXPORT_C CBaseMtmUi* NewMtmUiL( CBaseMtm& aMtm , CRegisteredMtmDll& aRegisteredDll )
       
   208 // Factory function
       
   209 	{
       
   210 	return CRightsObjectMtmUi::NewL( aMtm , aRegisteredDll );
       
   211 	}
       
   212 //
       
   213 // CRightsObjectMtmUi: User Interface MTM
       
   214 //
       
   215 
       
   216 // ============================ MEMBER FUNCTIONS ===============================
       
   217 
       
   218 /*************************************
       
   219 *
       
   220 *		Construction and destruction 
       
   221 *
       
   222 **************************************/
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CRightsObjectMtmUi::CRightsObjectMtmUi
       
   226 // C++ default constructor can NOT contain any code, that
       
   227 // might leave.
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 CRightsObjectMtmUi::CRightsObjectMtmUi( CBaseMtm& aBaseMtm , CRegisteredMtmDll& aRegisteredMtmDll )
       
   231 	:	CBaseMtmUi( aBaseMtm , aRegisteredMtmDll )
       
   232 	{
       
   233 	iOpenService = NULL;
       
   234 	iDocHandler = NULL;
       
   235 	iHostProcess = NULL;
       
   236 	iType = ERo;
       
   237 	}
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CRightsObjectMtmUi::ConstructL
       
   241 // Symbian 2nd phase constructor can leave.
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 void CRightsObjectMtmUi::ConstructL()
       
   245 	{
       
   246 #ifdef _DRM_TESTING
       
   247 	CreateLogL();
       
   248 	WriteL(_L8("ConstructL"));
       
   249 #endif
       
   250 	CBaseMtmUi::ConstructL();
       
   251 	User::LeaveIfError(iFs.Connect());
       
   252 	}
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CRightsObjectMtmUi::NewL
       
   256 // Two-phased constructor.
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 CRightsObjectMtmUi* CRightsObjectMtmUi::NewL( CBaseMtm& aBaseMtm , CRegisteredMtmDll& aRegisteredMtmDll )
       
   260 	{
       
   261 	CRightsObjectMtmUi* self=new ( ELeave ) CRightsObjectMtmUi( aBaseMtm , aRegisteredMtmDll );
       
   262 	CleanupStack::PushL( self );
       
   263 	self->ConstructL();
       
   264 	CleanupStack::Pop();
       
   265 	return self;
       
   266 	}
       
   267 
       
   268 // Destructor
       
   269 CRightsObjectMtmUi::~CRightsObjectMtmUi()
       
   270 	{
       
   271 #ifdef _DRM_TESTING
       
   272 	TRAP(err,WriteL(_L8("~CRightsObjectMtmUi")));
       
   273 #endif
       
   274 	iFs.Close();
       
   275 
       
   276   delete iOpenService;
       
   277 	delete iDocHandler;
       
   278 	}
       
   279 
       
   280 
       
   281 
       
   282 
       
   283 /*************************************
       
   284 *
       
   285 *		from CBaseMtm
       
   286 *
       
   287 **************************************/
       
   288 
       
   289 // -----------------------------------------------------------------------------
       
   290 // CRightsObjectMtmUi::CancelL
       
   291 //
       
   292 // Not supported
       
   293 //
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 CMsvOperation* CRightsObjectMtmUi::CancelL( TRequestStatus& /*aStatus*/ , const CMsvEntrySelection& /*aSelection*/ )
       
   297 	{
       
   298 #ifdef _DRM_TESTING
       
   299 	WriteL(_L8("CancelL"));
       
   300 #endif
       
   301 	
       
   302 	User::Leave( KErrNotSupported ); // no cancelling
       
   303 	return NULL;
       
   304 	}
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CRightsObjectMtmUi::GetResourceFileName
       
   308 //
       
   309 // Implementations provide this function to set the full path 
       
   310 // and name of the resource file associated with the User Interface MTM. 
       
   311 //
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314 void CRightsObjectMtmUi::GetResourceFileName( TFileName& aFileName ) const
       
   315 // Resource file loading 
       
   316 	{ 
       
   317 #ifdef _DRM_TESTING
       
   318 	TRAPD(err,WriteL(_L8("GetResourceFileName")));
       
   319 #endif	
       
   320 	aFileName = KRoMtmResourceFile; 
       
   321 	}
       
   322 
       
   323 //
       
   324 //	Entry manipulation 
       
   325 //
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CRightsObjectMtmUi::OpenL
       
   329 //
       
   330 // Opens an entry. 
       
   331 //
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 CMsvOperation* CRightsObjectMtmUi::OpenL( TRequestStatus& aStatus )
       
   335 // Open 
       
   336 	{
       
   337 #ifdef _DRM_TESTING
       
   338 	WriteL(_L8("OpenL(1)"));
       
   339 #endif	
       
   340 
       
   341     TMsvEntry tEntry = BaseMtm().Entry().Entry();
       
   342     TMsvEntry newEntry( tEntry );
       
   343 
       
   344 	const TUid type( tEntry.iType );
       
   345     CMsvOperation* operation = NULL;	
       
   346 	if ( type == KUidMsvMessageEntry )
       
   347         {
       
   348         operation = ViewL( aStatus );
       
   349         newEntry.SetUnread( EFalse );
       
   350         BaseMtm().Entry().ChangeL( newEntry );
       
   351         }
       
   352     else
       
   353         {
       
   354         User::Leave( KErrNotSupported );
       
   355         }
       
   356 	return operation;
       
   357 	}
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // CRightsObjectMtmUi::OpenL
       
   361 //
       
   362 // Opens the first entry in the selections. 
       
   363 //
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 CMsvOperation* CRightsObjectMtmUi::OpenL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection )
       
   367 // Open selection
       
   368 	{
       
   369 #ifdef _DRM_TESTING
       
   370 	WriteL(_L8("OpenL(2)"));
       
   371 #endif	
       
   372     BaseMtm().SwitchCurrentEntryL( aSelection.At( 0 ) );
       
   373     return OpenL( aStatus );
       
   374 	}
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CRightsObjectMtmUi::CloseL
       
   378 //
       
   379 // Not supported
       
   380 //
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 CMsvOperation* CRightsObjectMtmUi::CloseL( TRequestStatus& /*aStatus*/ )
       
   384 	{
       
   385 // Close 
       
   386 #ifdef _DRM_TESTING
       
   387 	WriteL(_L8("CloseL(1)"));
       
   388 #endif	
       
   389     User::Leave( KErrNotSupported );
       
   390     return NULL;
       
   391 	}
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // CRightsObjectMtmUi::CloseL
       
   395 //
       
   396 // Not supported
       
   397 //
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 CMsvOperation* CRightsObjectMtmUi::CloseL( TRequestStatus& /*aStatus*/ , const CMsvEntrySelection& /*aSelection*/ )
       
   401 	{
       
   402 // Close selection
       
   403 #ifdef _DRM_TESTING
       
   404 	WriteL(_L8("CloseL(2)"));
       
   405 #endif	
       
   406 
       
   407     User::Leave( KErrNotSupported );
       
   408     return NULL;
       
   409 	}
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // CRightsObjectMtmUi::EditL
       
   413 //
       
   414 // Not supported
       
   415 //
       
   416 // -----------------------------------------------------------------------------
       
   417 //
       
   418 CMsvOperation* CRightsObjectMtmUi::EditL( TRequestStatus& /*aStatus*/ )
       
   419 // Edit 
       
   420 	{
       
   421 #ifdef _DRM_TESTING
       
   422 	WriteL(_L8("EditL(1)"));
       
   423 #endif		
       
   424     User::Leave( KErrNotSupported );	
       
   425 	return NULL;
       
   426 	}
       
   427 
       
   428 // -----------------------------------------------------------------------------
       
   429 // CRightsObjectMtmUi::EditL
       
   430 //
       
   431 // Not supported
       
   432 //
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 CMsvOperation* CRightsObjectMtmUi::EditL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection )
       
   436 // Edit selection
       
   437 	{
       
   438 #ifdef _DRM_TESTING
       
   439 	WriteL(_L8("EditL(2)"));
       
   440 #endif	
       
   441 	iBaseMtm.SwitchCurrentEntryL( aSelection.At( 0 ) );
       
   442 	return EditL( aStatus );
       
   443 	}
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 // CRightsObjectMtmUi::ViewL
       
   447 //
       
   448 // Views an entry.
       
   449 //
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 CMsvOperation* CRightsObjectMtmUi::ViewL( TRequestStatus& aStatus )
       
   453 // View
       
   454 	{
       
   455 #ifdef _DRM_TESTING
       
   456 	WriteL(_L8("ViewL(1)"));
       
   457 #endif
       
   458 	
       
   459     CheckMessageTypeL();                                       
       
   460 	return LaunchEditorApplicationL( aStatus , iBaseMtm.Entry().Entry().Id() , ETrue );
       
   461 	}
       
   462 
       
   463 // -----------------------------------------------------------------------------
       
   464 // CRightsObjectMtmUi::ViewL
       
   465 //
       
   466 // Views the first entry in the selection.
       
   467 //
       
   468 // -----------------------------------------------------------------------------
       
   469 //
       
   470 CMsvOperation* CRightsObjectMtmUi::ViewL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection )
       
   471 // View selection
       
   472 	{
       
   473 #ifdef _DRM_TESTING
       
   474 	WriteL(_L8("ViewL(2)"));
       
   475 #endif
       
   476 	
       
   477 	iBaseMtm.SwitchCurrentEntryL( aSelection.At( 0 ) );
       
   478 	return ViewL( aStatus );
       
   479 	}
       
   480 
       
   481 
       
   482 //
       
   483 //	Message responding
       
   484 //
       
   485 
       
   486 // -----------------------------------------------------------------------------
       
   487 // CRightsObjectMtmUi::ReplyL
       
   488 //
       
   489 // Not supported
       
   490 //
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 CMsvOperation* CRightsObjectMtmUi::ReplyL( TMsvId /*aDestination*/ , TMsvPartList /*aPartlist*/ , TRequestStatus& /*aCompletionStatus*/ )
       
   494 // Reply to message - no UI support
       
   495 	{
       
   496 	User::Leave( KErrNotSupported );
       
   497 	return NULL;
       
   498 	}
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // CRightsObjectMtmUi::ForwardL
       
   502 //
       
   503 // Not supported
       
   504 //
       
   505 // -----------------------------------------------------------------------------
       
   506 //
       
   507 CMsvOperation* CRightsObjectMtmUi::ForwardL( TMsvId /*aDestination*/ , TMsvPartList /*aPartlist*/ , TRequestStatus& /*aCompletionStatus*/ )
       
   508 // Forwarded message - no UI support
       
   509 	{
       
   510 	User::Leave( KErrNotSupported );
       
   511 	return NULL;
       
   512 	}
       
   513 
       
   514 
       
   515 //
       
   516 // Specific to CRightsObjectMtmUi
       
   517 //
       
   518 
       
   519 
       
   520 // -----------------------------------------------------------------------------
       
   521 // CRightsObjectMtmUi::CheckMessageTypeL
       
   522 //
       
   523 // Check the type of the message
       
   524 //
       
   525 // -----------------------------------------------------------------------------
       
   526 //
       
   527 void CRightsObjectMtmUi::CheckMessageTypeL()
       
   528 	{
       
   529 #ifdef _DRM_TESTING
       
   530 		WriteL(_L8("CheckMessageTypeL"));
       
   531 #endif	
       
   532 	BaseMtm().LoadMessageL(); 
       
   533 	CRichText& body = BaseMtm().Body();
       
   534 	TPtrC ptr16( body.Read(0) );
       
   535 
       
   536 #ifdef _DRM_TESTING
       
   537 		WriteL(ptr16);
       
   538 #endif		
       
   539 	if ( ptr16.Length()>4 && ptr16.Left(4).Compare(KRoAcquisitionPrefix())==0 )
       
   540 		{
       
   541 		iType = ERoapTriggerRoAcquisition;
       
   542 		}
       
   543 	else if ( ptr16.Length()>4 && ptr16.Left(4).Compare(KTriggerPrefix())==0 )
       
   544 		{
       
   545 		iType = ERoapTrigger;
       
   546 		}
       
   547 	else
       
   548 		{
       
   549 		iType = ERo;	
       
   550 		}
       
   551 		
       
   552 	}
       
   553 
       
   554 // -----------------------------------------------------------------------------
       
   555 // CRightsObjectMtmUi::LaunchEditorApplicationL
       
   556 //
       
   557 // Launch RO Manager to get information for rights corresponding to the message.
       
   558 //
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 CMsvOperation* CRightsObjectMtmUi::LaunchEditorApplicationL( TRequestStatus& aStatus , TMsvId /*aId*/ , 
       
   562 													TBool /*aReadOnly*/ )
       
   563 	{
       
   564 #ifdef _DRM_TESTING
       
   565 	WriteL(_L8("LaunchEditorApplicationL-Start"));
       
   566 #endif	
       
   567 	// get message context
       
   568 	BaseMtm().LoadMessageL(); 
       
   569 	CRichText& body = BaseMtm().Body();
       
   570 	TPtrC ptr16( body.Read(0) );
       
   571     const TUid KUidDRMUI = { 0x101f85c7 };
       
   572 
       
   573 	if ( iType == ERoapTrigger || iType == ERoapTriggerRoAcquisition )
       
   574 		{
       
   575 		
       
   576 #ifdef _DRM_TESTING
       
   577 		WriteL(_L8("LaunchEditorApplicationL-iDocHandler"));
       
   578 #endif
       
   579         
       
   580         _LIT8( KRoapTriggerMimeType, "application/vnd.oma.drm.roap-trigger+xml" );
       
   581         TDataType type = TDataType( KRoapTriggerMimeType );
       
   582         HBufC* filename = NULL;
       
   583 		TPtr ptr(NULL,0);
       
   584 		TBool show;
       
   585 		filename = HBufC::NewLC(ptr16.Length()-4);
       
   586 		ptr.Set(filename->Des());
       
   587 		ptr.Append(ptr16.Right(ptr16.Length()-4));
       
   588 		
       
   589 		show = ShowQueryL(ptr);
       
   590 		if (!show)
       
   591 		    {
       
   592 		    CleanupStack::PopAndDestroy(filename);
       
   593 		    return CompletedOperationL( aStatus );
       
   594 		    }
       
   595 		
       
   596 #ifdef _DRM_TESTING
       
   597 		WriteL(ptr,ptr.Length());
       
   598 #endif		
       
   599 		if (iDocHandler)
       
   600 			{
       
   601 			delete iDocHandler;
       
   602 			iDocHandler = NULL;
       
   603 			}
       
   604 #ifdef _DRM_TESTING
       
   605 		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-NewL"));
       
   606 #endif			
       
   607 		iDocHandler = CDocumentHandler::NewL();
       
   608 #ifdef _DRM_TESTING
       
   609 		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-SetExitObserver"));
       
   610 #endif		
       
   611 		iDocHandler->SetExitObserver(this);
       
   612 #ifdef _DRM_TESTING
       
   613 		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-OpenFileEmbeddedL"));
       
   614 #endif			
       
   615 		iDocHandler->OpenFileEmbeddedL(ptr,type);
       
   616 		CleanupStack::PopAndDestroy(filename);
       
   617 #ifdef _DRM_TESTING
       
   618 		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-End"));
       
   619 #endif		
       
   620 		}
       
   621 	else
       
   622 		{
       
   623 	    if ( iOpenService )
       
   624 	        {
       
   625 	        delete iOpenService;
       
   626 	        iOpenService = NULL;
       
   627 	        }
       
   628 #ifdef _DRM_TESTING
       
   629 		WriteL(_L8("LaunchEditorApplicationL-CAknOpenFileService::NewL"));
       
   630 #endif           
       
   631 
       
   632 		CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
       
   633 		TAiwVariant variantObject( ptr16 );
       
   634 		TAiwGenericParam param( EGenericParamFile, variantObject );
       
   635 		paramList->AppendL( param );
       
   636 		
       
   637     	TRAPD( err, iOpenService = CAknLaunchAppService::NewL( KUidDRMUI, this, paramList ) );
       
   638     	if (err != KErrNone)
       
   639     		{
       
   640     		// just return to Inbox
       
   641     		}
       
   642 
       
   643 		CleanupStack::PopAndDestroy( paramList ); // paramList			
       
   644 		}	
       
   645 
       
   646 #ifdef _DRM_TESTING
       
   647 	WriteL(_L8("LaunchEditorApplicationL-End"));
       
   648 #endif    
       
   649     return CompletedOperationL( aStatus );
       
   650 	}
       
   651 
       
   652 
       
   653 void CRightsObjectMtmUi::HandleServerAppExit(TInt aReason)
       
   654 	{
       
   655 #ifdef _DRM_TESTING
       
   656 	TRAP(err,WriteL(_L8("HandleServerAppExit")));
       
   657 #endif	
       
   658 	MAknServerAppExitObserver::HandleServerAppExit(aReason);
       
   659 	}
       
   660 	
       
   661 // -----------------------------------------------------------------------------
       
   662 // CRightsObjectMtmUi::CompletedOperationL
       
   663 //
       
   664 // return completed operation to UI  
       
   665 //
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 CMsvOperation* CRightsObjectMtmUi::CompletedOperationL( TRequestStatus& aObserverStatus )
       
   669     {
       
   670 #ifdef _DRM_TESTING
       
   671 	WriteL(_L8("CompletedOperationL"));
       
   672 #endif      
       
   673 	//return completed operation pointer
       
   674     TPckgBuf<TMsvLocalOperationProgress> progress;
       
   675     SetProgressSuccess( progress, BaseMtm().Entry().Entry().Id() );
       
   676     CMsvCompletedOperation* operation = 
       
   677         CMsvCompletedOperation::NewL( Session() , Type() , progress , 
       
   678         KMsvLocalServiceIndexEntryId , aObserverStatus );
       
   679     return operation;
       
   680     }
       
   681 
       
   682 void CRightsObjectMtmUi::SetProgressSuccess
       
   683 ( TPckgBuf<TMsvLocalOperationProgress>& aProgress , TMsvId aId )
       
   684     {
       
   685     aProgress().iTotalNumberOfEntries = 1;
       
   686     aProgress().iNumberCompleted = 1;
       
   687     aProgress().iId = aId;
       
   688     }
       
   689 
       
   690 TBool CRightsObjectMtmUi::ShowQueryL( TDesC16& aFile )
       
   691     {
       
   692 #ifdef _DRM_TESTING
       
   693 	WriteL(_L8("ShowQueryL"));
       
   694 #endif       
       
   695     TBool show = ETrue;
       
   696     TInt type = 0;
       
   697     HBufC* msgText = NULL;
       
   698     type = CheckTriggerTypeL(aFile);    
       
   699     
       
   700 #ifndef RD_MULTIPLE_DRIVE
       
   701     
       
   702     TFileName fileName( KDriveZ );
       
   703     
       
   704 #else //RD_MULTIPLE_DRIVE
       
   705     
       
   706     _LIT( KDrive, "%c:");
       
   707     TInt driveNumber( -1 );
       
   708     TChar driveLetter;
       
   709     DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
       
   710 	iFs.DriveToChar( driveNumber, driveLetter );
       
   711 	
       
   712 	TFileName fileName;
       
   713 	
       
   714     fileName.Format( KDrive, (TUint)driveLetter );
       
   715     
       
   716 #endif
       
   717     
       
   718     fileName.Append( KDC_MTM_RESOURCE_DIR );
       
   719     fileName.Append( KRoMtmUiResFileName );
       
   720     RConeResourceLoader loader( *iCoeEnv );
       
   721     loader.OpenL( fileName );
       
   722     switch(type)
       
   723         {
       
   724         case Roap::ERegistrationTrigger:
       
   725             {
       
   726 #ifdef _DRM_TESTING
       
   727 	WriteL(_L8("ShowQueryL->ERegistrationTrigger"));
       
   728 #endif             
       
   729             loader.Close();
       
   730             return ETrue;              
       
   731             }
       
   732         case Roap::ERoAcquisitionTrigger:
       
   733             {
       
   734 #ifdef _DRM_TESTING
       
   735 	WriteL(_L8("ShowQueryL->ERoAcquisitionTrigger"));
       
   736 #endif
       
   737             msgText = StringLoader::LoadLC( R_ROMTMUI_QUERY_RIGHTS_ACQ_MSG , iCoeEnv ); 
       
   738             }break;
       
   739         case Roap::EJoinDomainTrigger:
       
   740             {
       
   741 #ifdef _DRM_TESTING
       
   742 	WriteL(_L8("ShowQueryL->EJoinDomainTrigger"));
       
   743 #endif            
       
   744             msgText = StringLoader::LoadLC( R_ROMTMUI_QUERY_JOIN_DOMAIN_MSG , iCoeEnv ); 
       
   745             }break;
       
   746         case Roap::ELeaveDomainTrigger:
       
   747             {
       
   748 #ifdef _DRM_TESTING
       
   749 	WriteL(_L8("ShowQueryL->ELeaveDomainTrigger"));
       
   750 #endif            
       
   751             msgText = StringLoader::LoadLC( R_ROMTMUI_QUERY_LEAVE_DOMAIN_MSG , iCoeEnv ); 
       
   752             }break;
       
   753         default:
       
   754             {
       
   755 #ifdef _DRM_TESTING
       
   756 	WriteL(_L8("ShowQueryL->default"));
       
   757 #endif            
       
   758             loader.Close();
       
   759             return EFalse;    
       
   760             }
       
   761         }
       
   762 #ifdef _DRM_TESTING
       
   763 	WriteL(*msgText);
       
   764 #endif           
       
   765     loader.Close();
       
   766     CAknQueryDialog* dlg = new (ELeave) CAknQueryDialog( *msgText,
       
   767         CAknQueryDialog::ENoTone );
       
   768     show = dlg->ExecuteLD( R_ROMTMUI_TRIGGER_CONFIRMATION_QUERY ); 
       
   769     CleanupStack::PopAndDestroy( msgText );
       
   770 #ifdef _DRM_TESTING
       
   771 	WriteL(_L8("ShowQueryL->End"),show);
       
   772 #endif   
       
   773     return show;
       
   774     }
       
   775 
       
   776 TInt CRightsObjectMtmUi::CheckTriggerTypeL( TDesC16& aFile )
       
   777     {
       
   778 #ifdef _DRM_TESTING
       
   779 	WriteL(_L8("CheckTriggerTypeL"));
       
   780 #endif    
       
   781     Roap::CRoapEng* roap = NULL;
       
   782     RFile file;
       
   783     TInt size = 0;
       
   784     Roap::TTriggerType type;
       
   785     Roap::TRiContextStatus status;
       
   786     Roap::TDomainOperation op;
       
   787     RPointerArray<HBufC8> array;
       
   788     
       
   789     HBufC8* buf =NULL;
       
   790     TPtr8 ptr(NULL,0);
       
   791     User::LeaveIfError(file.Open(iFs, aFile, EFileShareReadersOrWriters));
       
   792     CleanupClosePushL(file);
       
   793     User::LeaveIfError(file.Size(size));
       
   794     buf = HBufC8::NewLC(size);
       
   795     ptr.Set(buf->Des());
       
   796     User::LeaveIfError(file.Read(ptr,size));
       
   797     CleanupStack::Pop(buf);
       
   798     CleanupStack::PopAndDestroy(&file);
       
   799     CleanupStack::PushL(buf);
       
   800     roap = Roap::CRoapEng::NewL();
       
   801     CleanupStack::PushL(roap);
       
   802     roap->SetTriggerL(ptr,NULL,type,status,op,array);
       
   803     array.ResetAndDestroy();
       
   804     array.Close();
       
   805     CleanupStack::PopAndDestroy(roap);
       
   806     CleanupStack::PopAndDestroy(buf);
       
   807     
       
   808 #ifdef _DRM_TESTING
       
   809 	WriteL(_L8("CheckTriggerTypeL-End"),type);
       
   810 #endif     
       
   811     return type;
       
   812     }
       
   813     
       
   814 
       
   815 
       
   816