omadrm/drmengine/dcfrepository/server/src/DcfRepSrv.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:  server implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "DcfRepSrv.h"
       
    21 #include    "DcfRepSrvSes.h"
       
    22 #include    "DcfRepCommon.h"
       
    23 #include    "Pair.h"
       
    24 #include    "FileScan.h"
       
    25 #include    <e32std.h>
       
    26 #include    <e32base.h>
       
    27 #include    <f32file.h>
       
    28 #include    <caf/data.h>
       
    29 #include    <caf/content.h>
       
    30 #include    <Oma2Agent.h> // oma2agent
       
    31 #include    "Oma2Dcf.h"
       
    32 #include    "Oma1Dcf.h"
       
    33 #include    "drmlog.h"
       
    34 #include <starterclient.h>
       
    35 
       
    36 #ifdef RD_MULTIPLE_DRIVE
       
    37 #include    <DriveInfo.h>
       
    38 #endif
       
    39 
       
    40 // EXTERNAL DATA STRUCTURES
       
    41 // EXTERNAL FUNCTION PROTOTYPES
       
    42 // CONSTANTS
       
    43 _LIT(KSqlUpdate1 , "select filename,position,cid,group,ttid from dcf where filename = '");
       
    44 _LIT(KSqlUpdate2 , "' and position = ");
       
    45 _LIT(KSqlInsert , "select filename,position,cid,group,ttid from dcf");
       
    46 _LIT(KSqlDeleteAll , "delete from dcf");
       
    47 _LIT(KGroupIdReplacement, "cid:group@localhost");
       
    48 // MACROS
       
    49 // LOCAL CONSTANTS AND MACROS
       
    50 
       
    51 #ifdef RD_MULTIPLE_DRIVE
       
    52 _LIT( KDbFileLoc, "%c:\\system\\data\\DcfRepDb" );
       
    53 #endif
       
    54 
       
    55 // MODULE DATA STRUCTURES
       
    56 // LOCAL FUNCTION PROTOTYPES
       
    57 LOCAL_C TInt CreateDataBase(RFs& aFs);
       
    58 
       
    59 #ifndef RD_MULTIPLE_DRIVE
       
    60 LOCAL_C TParse DataFile();
       
    61 #else // RD_MULTIPLE_DRIVE
       
    62 LOCAL_C TParse DataFile( RFs& aFs );
       
    63 #endif
       
    64 
       
    65 LOCAL_C void CreateTablesL(RDbDatabase& aDatabase);
       
    66 LOCAL_C TInt CreateDataBasePath(RFs& aFs);
       
    67 // FORWARD DECLARATIONS
       
    68 
       
    69 //#define _DRM_TESTING
       
    70 //#define _MEM_HEAP_USAGE
       
    71 
       
    72 // ============================ LOCAL FUNCTIONS ===============================
       
    73 #ifdef _DRM_TESTING
       
    74 LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
       
    75 LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
       
    76 LOCAL_C void CreateLogL();
       
    77 LOCAL_C void WriteL( const TDesC8& aText );
       
    78 LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
       
    79 LOCAL_C void WriteCurrentTimeL();
       
    80 
       
    81 #ifdef _MEM_HEAP_USAGE
       
    82 LOCAL_C void WriteHeapAllocL();
       
    83 #endif //_MEM_HEAP_USAGE
       
    84 
       
    85 #endif //_DRM_TESTING
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // Testing stuff
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 #ifdef _DRM_TESTING
       
    92 LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
       
    93     {
       
    94     _LIT( KLogFile , "c:\\CDcfRepSrv.txt" );
       
    95     WriteFileL( text , aFs , KLogFile );
       
    96     }
       
    97 
       
    98 LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
       
    99     {
       
   100     RFile file;
       
   101     TInt size;
       
   102     User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
       
   103     CleanupClosePushL( file );
       
   104     User::LeaveIfError( file.Size( size ) );
       
   105     User::LeaveIfError( file.Write( size, text ) );
       
   106     CleanupStack::PopAndDestroy(&file); //file
       
   107     }
       
   108 
       
   109 LOCAL_C void CreateLogL()
       
   110     {
       
   111     RFs fs;
       
   112     User::LeaveIfError(fs.Connect());
       
   113     CleanupClosePushL(fs);
       
   114     RFile file;
       
   115     User::LeaveIfError( file.Replace( fs , _L("c:\\CDcfRepSrv.txt") , EFileWrite ) );
       
   116     file.Close();
       
   117     CleanupStack::PopAndDestroy(&fs); //fs
       
   118     }
       
   119 
       
   120 LOCAL_C void WriteL( const TDesC8& aText )
       
   121     {
       
   122     RFs fs;
       
   123     User::LeaveIfError( fs.Connect() );
       
   124     CleanupClosePushL(fs);
       
   125     HBufC8* text = HBufC8::NewLC(1000);
       
   126     TPtr8 textptr(text->Des() );
       
   127     textptr.Append( aText );
       
   128     textptr.Append( _L8("\r\n") );
       
   129     WriteLogL(textptr , fs);
       
   130     CleanupStack::PopAndDestroy(text);
       
   131     CleanupStack::PopAndDestroy(&fs); //fs
       
   132     WriteCurrentTimeL();
       
   133 #ifdef _MEM_HEAP_USAGE
       
   134     WriteHeapAllocL();
       
   135 #endif //_MEM_HEAP_USAGE
       
   136     }
       
   137 
       
   138 LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
       
   139     {
       
   140     _LIT8(KErr,": %d");
       
   141     HBufC8* text = HBufC8::NewLC(1000+20);
       
   142     TBuf8<20> num;
       
   143     TPtr8 textptr(text->Des());
       
   144     textptr.Append(aText);
       
   145     num.Format(KErr(),aErr);
       
   146     textptr.Append(num);
       
   147     WriteL(textptr);
       
   148     CleanupStack::PopAndDestroy(text);
       
   149     }
       
   150 
       
   151 LOCAL_C void WriteCurrentTimeL()
       
   152     {
       
   153     RFs fs;
       
   154     User::LeaveIfError( fs.Connect() );
       
   155     CleanupClosePushL(fs);
       
   156     HBufC8* text = HBufC8::NewLC(100);
       
   157     TPtr8 textptr(text->Des() );
       
   158     // Date and Time display
       
   159     TTime time;
       
   160     time.HomeTime();
       
   161     TBuf<256> dateString;
       
   162     _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
       
   163     time.FormatL(dateString,KDate);
       
   164     textptr.Append(_L( "\r\n\t\tData:\t" ) );
       
   165     textptr.Append( dateString );
       
   166     _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
       
   167     time.FormatL(dateString,KTime);
       
   168     textptr.Append(_L( "\r\n\t\tTime:\t" ) );
       
   169     textptr.Append( dateString );
       
   170     textptr.Append(_L( "\r\n" ) );
       
   171     textptr.Append(_L( "\r\n" ) );
       
   172     WriteLogL(textptr , fs);
       
   173     CleanupStack::PopAndDestroy(text);
       
   174     CleanupStack::PopAndDestroy(&fs); //fs
       
   175     }
       
   176 
       
   177 #ifdef _MEM_HEAP_USAGE
       
   178 LOCAL_C void WriteHeapAllocL()
       
   179     {
       
   180     _LIT8(KHeapUsage,"\r\n***** Heap cells allocated: %d *****\r\n");
       
   181     TBuf8<256> string;
       
   182     TInt size = 0;
       
   183     RFs fs;
       
   184     User::LeaveIfError( fs.Connect() );
       
   185     CleanupClosePushL(fs);
       
   186     User::Heap().AllocSize(size);
       
   187     string.Format(KHeapUsage(),size);
       
   188     WriteLogL(string , fs);
       
   189     CleanupStack::PopAndDestroy(&fs); //fs
       
   190     }
       
   191 #endif //_MEM_HEAP_USAGE
       
   192 
       
   193 
       
   194 #endif //_DRM_TESTING
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // DataFile
       
   198 // Return TParse which contain database file name
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 #ifdef RD_MULTIPLE_DRIVE
       
   202 LOCAL_C TParse DataFile( RFs& aFs )
       
   203 #else
       
   204 LOCAL_C TParse DataFile()
       
   205 #endif
       
   206     {
       
   207 #ifdef _DRM_TESTING
       
   208     TRAP_IGNORE( WriteL(_L8("DataFile")) ); 
       
   209 #endif
       
   210 
       
   211     TParse p;
       
   212 
       
   213 #ifndef RD_MULTIPLE_DRIVE
       
   214 
       
   215     p.Set(KDbFileLocation,NULL,NULL);
       
   216 
       
   217 #else //RD_MULTIPLE_DRIVE
       
   218 
       
   219     TInt driveNumber( -1 );
       
   220     TChar driveLetter;
       
   221     DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
       
   222 
       
   223     aFs.DriveToChar( driveNumber, driveLetter );
       
   224 
       
   225     TFileName dbFile;
       
   226     dbFile.Format( KDbFileLoc, (TUint)driveLetter );
       
   227 
       
   228     p.Set(dbFile,NULL,NULL);
       
   229 
       
   230 #endif
       
   231 
       
   232     return p;
       
   233     }
       
   234 
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CreateTablesL
       
   238 // Create table through database session
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 LOCAL_C void CreateTablesL(RDbDatabase& aDatabase)
       
   242     {
       
   243 #ifdef _DRM_TESTING
       
   244     WriteL(_L8("CreateTablesL"));
       
   245 #endif
       
   246 
       
   247     CDbColSet* columns = CDbColSet::NewLC();
       
   248 
       
   249     //filename columns
       
   250     TDbCol filename(KColFilename,EDbColLongText16);
       
   251     filename.iAttributes = TDbCol::ENotNull;
       
   252     columns->AddL(filename);
       
   253 
       
   254     //position columns
       
   255     TDbCol position(KColPosition,EDbColUint16);
       
   256     position.iAttributes = TDbCol::ENotNull;
       
   257     columns->AddL(position);
       
   258 
       
   259     //content id columns
       
   260     TDbCol cid(KColCid,EDbColLongText16);
       
   261     cid.iAttributes = TDbCol::ENotNull;
       
   262     columns->AddL(cid);
       
   263 
       
   264     //content group id columns
       
   265     TDbCol group(KColGroupId,EDbColLongText16);
       
   266     columns->AddL(group);
       
   267 
       
   268     //transaction id columns
       
   269     TDbCol ttid(KColTtid,EDbColText16,KTtidLen);
       
   270     columns->AddL(ttid);
       
   271 
       
   272     aDatabase.CreateTable( KTable,*columns);
       
   273     CleanupStack::PopAndDestroy(columns); //columns
       
   274 
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CreateDataBasePath
       
   279 // Create database with client side database access
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 LOCAL_C TInt CreateDataBasePath(RFs& aFs)
       
   283     {
       
   284 #ifdef _DRM_TESTING
       
   285     TRAPD(r,WriteL(_L8("CreateDataBasePath")));
       
   286 #endif
       
   287 
       
   288     TInt err = 0;
       
   289 
       
   290 #ifndef RD_MULTIPLE_DRIVE
       
   291 
       
   292     err = aFs.MkDirAll( DataFile(). DriveAndPath() );
       
   293 
       
   294 #else //RD_MULTIPLE_DRIVE
       
   295 
       
   296     err = aFs.MkDirAll( DataFile( aFs ). DriveAndPath() );
       
   297 
       
   298 #endif
       
   299 
       
   300     return err;
       
   301     }
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // CreateDataBase
       
   305 // Create database with client side database access
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 LOCAL_C TInt CreateDataBase(RFs& aFs)
       
   309     {
       
   310 #ifdef _DRM_TESTING
       
   311     TRAPD(r,WriteL(_L8("CreateDataBase")));
       
   312 #endif
       
   313 
       
   314     RDbNamedDatabase database;
       
   315     TInt err = 0;
       
   316     TFileName file;
       
   317 
       
   318 #ifndef RD_MULTIPLE_DRIVE
       
   319 
       
   320     file = DataFile().FullName();
       
   321 
       
   322 
       
   323 #else // RD_MULTIPLE_DRIVE
       
   324 
       
   325     file = DataFile( aFs ).FullName();
       
   326 
       
   327 #endif
       
   328 
       
   329     if (!err)
       
   330         {
       
   331 #ifdef _DRM_TESTING
       
   332         TRAP(r,WriteL(_L8("CreateDataBase->DataFile"),err));
       
   333 #endif
       
   334         err = CreateDataBasePath(aFs);
       
   335 
       
   336         err = database.Create(aFs,file);
       
   337         if (!err)
       
   338             {
       
   339 #ifdef _DRM_TESTING
       
   340             TRAP(r,WriteL(_L8("CreateDataBase->database.Create"),err));
       
   341 #endif
       
   342             TRAP( err , CreateTablesL(database) );
       
   343 #ifdef _DRM_TESTING
       
   344             TRAP(r,WriteL(_L8("CreateDataBase->CreateTablesL"),err));
       
   345 #endif
       
   346             }
       
   347         database.Close();
       
   348         }
       
   349     return err;
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // From8To16
       
   354 // transfer buf from 8 bit to 16 bit
       
   355 // -----------------------------------------------------------------------------
       
   356 //
       
   357 LOCAL_C TInt From8To16( const TDesC8& a8 , HBufC16*& a16 )
       
   358     {
       
   359 #ifdef _DRM_TESTING
       
   360     TRAPD(r,WriteL(_L8("From8To16")));
       
   361 #endif
       
   362 
       
   363     TInt err = KErrNone;
       
   364     a16 = HBufC::NewMax( a8.Length() );
       
   365     if ( a16 )
       
   366         {
       
   367         TPtr ptr( a16->Des() );
       
   368         ptr.SetLength( a8.Length() );
       
   369         for (TInt i = 0 ; i<a8.Length() ; i++ )
       
   370             {
       
   371             ptr[i] = ( unsigned char ) a8[i];
       
   372             }
       
   373         }
       
   374     else err = KErrNoMemory;
       
   375     return err;
       
   376     }
       
   377 
       
   378 // ============================ MEMBER FUNCTIONS ===============================
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CDcfRepSrv::CDcfRepSrv
       
   382 // C++ default constructor can NOT contain any code, that
       
   383 // might leave.
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 CDcfRepSrv::CDcfRepSrv():CServer2( EPriorityStandard ),
       
   387     iScan(NULL),
       
   388     iCidList(NULL),
       
   389     iPairList(NULL),
       
   390     iState(EStateIdle),
       
   391     iArmed( EFalse )
       
   392     {
       
   393 
       
   394     }
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 // CDcfRepSrv::ConstructL
       
   398 // Symbian 2nd phase constructor can leave.
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 void CDcfRepSrv::ConstructL()
       
   402     {
       
   403 #ifdef _DRM_TESTING
       
   404     CreateLogL();
       
   405     WriteL(_L8("ConstructL"));
       
   406 #endif
       
   407     StartL(KDcfRepSrvName);
       
   408     User::LeaveIfError(iFs.Connect());
       
   409     iScan = CFileScan::NewL(iFs);
       
   410     OpenDatabaseL();
       
   411 
       
   412     User::RenameThread(KDcfRepSrvName);
       
   413 
       
   414     iProcWatcher = CProcWatcher::NewL( *this, _L( "*RightsServer*" ), _L( "RightsServer" ) );
       
   415     iProcWatcher->StartWatching();
       
   416     iArmed = ETrue;
       
   417     }
       
   418 
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CDcfRepSrv::NewLC
       
   422 // Two-phased constructor.
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 CDcfRepSrv* CDcfRepSrv::NewLC()
       
   426     {
       
   427     CDcfRepSrv* self = new( ELeave ) CDcfRepSrv;
       
   428     CleanupStack::PushL( self );
       
   429     self->ConstructL();
       
   430     return self;
       
   431     }
       
   432 
       
   433 
       
   434 // Destructor
       
   435 CDcfRepSrv::~CDcfRepSrv()
       
   436     {
       
   437 #ifdef _DRM_TESTING
       
   438     TRAPD(r,WriteL(_L8("~CDcfRepSrv")));
       
   439 #endif
       
   440 
       
   441     delete iScan;
       
   442     CleanScanInternal();
       
   443     CleanDatabase();
       
   444     iFs.Close();
       
   445     for (TInt i = 0 ; i < iMessageList.Count() ; i++ )
       
   446         {
       
   447         if ( iMessageList[i]!=NULL && !(iMessageList[i]->IsNull()) )
       
   448             {
       
   449             iMessageList[i]->Complete(KErrCancel);
       
   450             }
       
   451 
       
   452         }
       
   453     iMessageList.ResetAndDestroy();
       
   454     iMessageList.Close();
       
   455     }
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // CDcfRepSrv::NewSessionL
       
   459 // Called when a client requires a new instance.
       
   460 // -----------------------------------------------------------------------------
       
   461 CSession2* CDcfRepSrv::NewSessionL(const TVersion &aVersion,
       
   462     const RMessage2& /*aMessage*/ ) const
       
   463     {
       
   464 #ifdef _DRM_TESTING
       
   465     WriteL(_L8("NewSessionL"));
       
   466 #endif
       
   467     // check we're the right version
       
   468     if (!User::QueryVersionSupported(TVersion(KDcfRepMajorVersionNumber,
       
   469                 KDcfRepMinorVersionNumber,
       
   470                 KDcfRepBuildVersionNumber),
       
   471             aVersion))
       
   472         {
       
   473         User::Leave(KErrNotSupported);
       
   474         }
       
   475 
       
   476     // make new session
       
   477     return CDcfRepSrvSes::NewL();
       
   478     }
       
   479 
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // Startup().
       
   483 // This function starts the actual DCF Repository server after initializing
       
   484 // the cleanup stack and active scheduler.
       
   485 // Returns: TInt: Symbian OS error code.
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 
       
   489 TInt CDcfRepSrv::Startup( void )
       
   490     {
       
   491     TInt err = 0;
       
   492     TBool clientIsWaiting = EFalse;
       
   493     RSemaphore semaphore;
       
   494 
       
   495     CTrapCleanup* cleanupStack = CTrapCleanup::New();
       
   496 
       
   497     if (cleanupStack == NULL)
       
   498         {
       
   499         PanicServer(ECreateTrapCleanup);
       
   500         }
       
   501 
       
   502     // check if the client wants to be signaled that we are ready
       
   503     if ( semaphore.OpenGlobal(KDcfRepSemaphoreName) == KErrNone )
       
   504         {
       
   505         clientIsWaiting = ETrue;
       
   506         }
       
   507 
       
   508     TRAP(err, StartupL());
       
   509 
       
   510     // release client side waiting
       
   511     if (clientIsWaiting)
       
   512         {
       
   513         semaphore.Signal();
       
   514         semaphore.Close();
       
   515         }
       
   516 
       
   517     if (err != KErrNone)
       
   518         {
       
   519         PanicServer(ESrvCreateServer);
       
   520         }
       
   521 
       
   522     delete cleanupStack;
       
   523     cleanupStack = NULL;
       
   524     return KErrNone;
       
   525     }
       
   526 
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 // StartupL().
       
   530 // This function starts the actual DCF Repository after initializing scheduler
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 
       
   534 void CDcfRepSrv::StartupL()
       
   535     {
       
   536     // Construct active scheduler
       
   537     CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
       
   538     CleanupStack::PushL(activeScheduler) ;
       
   539 
       
   540     // Install active scheduler
       
   541     // We don't need to check whether an active scheduler is already installed
       
   542     // as this is a new thread, so there won't be one
       
   543     CActiveScheduler::Install(activeScheduler);
       
   544 
       
   545     // Construct our server
       
   546     CDcfRepSrv::NewLC();
       
   547 
       
   548     // Start handling requests
       
   549     CActiveScheduler::Start();
       
   550 
       
   551     CleanupStack::PopAndDestroy(2);    //  activeScheduler and anonymous CDcfRepSrv
       
   552     }
       
   553 
       
   554 void CDcfRepSrv::PanicServer(TDcfRepSrvPanic aPanic)
       
   555     {
       
   556 #ifdef _DRM_TESTING
       
   557     TRAPD(r,WriteL(_L8("PanicServer")));
       
   558     r =  0;
       
   559 #endif
       
   560 
       
   561     User::Panic(KDcfRepSrv, aPanic);
       
   562     }
       
   563 
       
   564 
       
   565 // -----------------------------------------------------------------------------
       
   566 // AddFileL()
       
   567 // The function will add a file info into database
       
   568 // -----------------------------------------------------------------------------
       
   569 //
       
   570 void CDcfRepSrv::AddFileL( const TDesC& aFile )
       
   571     {
       
   572 #ifdef _DRM_TESTING
       
   573     WriteL(_L8("AddFileL"));
       
   574 #endif
       
   575 
       
   576     TInt err = 0;
       
   577     TInt state = iState;
       
   578     TBool flag = EFalse;
       
   579 
       
   580     // to process the file as doing scanning fully for file system
       
   581     iState = EStateFullScan;
       
   582     err = ProcessFile(aFile , flag);
       
   583     // change the state back
       
   584     iState = state;
       
   585     User::LeaveIfError(err);
       
   586     if ( flag == ENoDcf )
       
   587         {
       
   588         User::Leave(KErrNotSupported);
       
   589         }
       
   590     else if (flag == EOma2Dcf)
       
   591         {
       
   592         AddDomainRoL(aFile);
       
   593         }
       
   594     }
       
   595 
       
   596 // -----------------------------------------------------------------------------
       
   597 // AddDomainRoL()
       
   598 // The function will add a file info into database
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 void CDcfRepSrv::AddDomainRoL( const TDesC& aFile )
       
   602     {
       
   603 #ifdef _DRM_TESTING
       
   604     WriteL(_L8("AddDomainRoL"));
       
   605 #endif
       
   606 
       
   607     __UHEAP_MARK;
       
   608     RFile file;
       
   609     TPtr8 ptr(NULL,0,0);
       
   610     CContent* content =NULL;
       
   611     User::LeaveIfError(file.Open(iFs, aFile, EFileShareReadersOrWriters | EFileWrite ) );
       
   612     CleanupClosePushL(file);
       
   613     content = CContent::NewL(file);
       
   614     CleanupStack::PushL(content);
       
   615     User::LeaveIfError(content->AgentSpecificCommand(EEmbedDomainRo,
       
   616             KNullDesC8, ptr ));
       
   617     CleanupStack::PopAndDestroy(2); // content, file
       
   618     __UHEAP_MARKEND;
       
   619     }
       
   620 
       
   621 
       
   622 // -----------------------------------------------------------------------------
       
   623 // OpenDatabaseL()
       
   624 // The function will open database
       
   625 // -----------------------------------------------------------------------------
       
   626 //
       
   627 void CDcfRepSrv::OpenDatabaseL()
       
   628     {
       
   629 #ifdef _DRM_TESTING
       
   630     WriteL(_L8("OpenDatabaseL"));
       
   631 #endif
       
   632 
       
   633 
       
   634     TInt err = CreateDataBase(iFs);
       
   635     if ( err==KErrAlreadyExists )
       
   636         {
       
   637         err = KErrNone;
       
   638         }
       
   639 
       
   640     User::LeaveIfError(iDbs.Connect());
       
   641 
       
   642 #ifndef RD_MULTIPLE_DRIVE
       
   643 
       
   644     User::LeaveIfError(iDb.Open(iDbs,DataFile().FullName()));
       
   645 
       
   646 #else // RD_MULTIPLE_DRIVE
       
   647 
       
   648     User::LeaveIfError(iDb.Open(iDbs,DataFile(iFs).FullName()));
       
   649 
       
   650 #endif
       
   651     }
       
   652 
       
   653 
       
   654 // -----------------------------------------------------------------------------
       
   655 // CleanTableL()
       
   656 // The function will empty the talbe
       
   657 // -----------------------------------------------------------------------------
       
   658 //
       
   659 void CDcfRepSrv::CleanTableL()
       
   660     {
       
   661 #ifdef _DRM_TESTING
       
   662     WriteL(_L8("CleanTableL"));
       
   663 #endif
       
   664 
       
   665     User::LeaveIfError(iDb.Execute(KSqlDeleteAll()));
       
   666     }
       
   667 
       
   668 // -----------------------------------------------------------------------------
       
   669 // ProcessFile()
       
   670 // This function check if the file is DRM protected and add it into database.
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 TInt CDcfRepSrv::ProcessFile(const TDesC& aFile , TInt& aType)
       
   674     {
       
   675 #ifdef _DRM_TESTING
       
   676     TRAPD(r,WriteL(_L8("ProcessFile")));
       
   677 #endif
       
   678 
       
   679     TInt err = 0;
       
   680     aType = ENoDcf;
       
   681 
       
   682     TRAP(err , CheckFileL(aFile , aType));
       
   683     if (aType)
       
   684         {
       
   685         TRAP(err , StoreFileL(aFile,aType));
       
   686         }
       
   687     return err;
       
   688     }
       
   689 
       
   690 // -----------------------------------------------------------------------------
       
   691 // CheckFileL()
       
   692 // check if it is target file
       
   693 // -----------------------------------------------------------------------------
       
   694 //
       
   695 void CDcfRepSrv::CheckFileL(const TDesC& aFile , TInt& aType)
       
   696     {
       
   697 #ifdef _DRM_TESTING
       
   698     WriteL(_L8("CheckFileL"));
       
   699 #endif
       
   700 
       
   701     RFile f;
       
   702     TInt pos = 0;
       
   703     TBuf8<256> buf;
       
   704 
       
   705     switch(iState)
       
   706         {
       
   707         case EStateFullScan:
       
   708         case EStateScan:
       
   709                 {
       
   710                 User::LeaveIfError(f.Open(iFs,aFile,EFileRead|EFileShareReadersOrWriters));
       
   711                 CleanupClosePushL(f);
       
   712                 User::LeaveIfError(f.Seek(ESeekStart,pos));
       
   713                 User::LeaveIfError(f.Read(0,buf));
       
   714                 CleanupStack::PopAndDestroy(&f);
       
   715                 if (COma1Dcf::IsValidDcf(buf))
       
   716                     {
       
   717                     aType = EOma1Dcf;
       
   718                     }
       
   719 #ifdef __DRM_OMA2
       
   720                 else if (COma2Dcf::IsValidDcf(buf))
       
   721                     {
       
   722                     aType = EOma2Dcf;
       
   723                     }
       
   724 #endif
       
   725                 else
       
   726                     {
       
   727                     aType = ENoDcf;
       
   728                     }
       
   729 
       
   730                 }
       
   731             break;
       
   732         case EStateSetTtid:
       
   733                 {
       
   734                 TParse p;
       
   735                 User::LeaveIfError(p.Set(aFile,NULL,NULL));
       
   736                 if ( !p.Ext().Compare( KOma2DcfExtension ) ||
       
   737                     !p.Ext().Compare( KOma2DcfExtensionAudio ) ||
       
   738                     !p.Ext().Compare( KOma2DcfExtensionVideo ) )
       
   739                     {
       
   740                     User::LeaveIfError(f.Open(iFs,aFile,EFileRead|EFileShareReadersOrWriters));
       
   741                     CleanupClosePushL(f);
       
   742                     User::LeaveIfError(f.Seek(ESeekStart,pos));
       
   743                     User::LeaveIfError(f.Read(0,buf));
       
   744                     CleanupStack::PopAndDestroy(&f);
       
   745                     if (COma1Dcf::IsValidDcf(buf))
       
   746                         {
       
   747                         aType = EOma1Dcf;
       
   748                         }
       
   749 #ifdef __DRM_OMA2
       
   750                     else if (COma2Dcf::IsValidDcf(buf))
       
   751                         {
       
   752                         aType = EOma2Dcf;
       
   753                         }
       
   754 #endif
       
   755                     else
       
   756                         {
       
   757                         aType = ENoDcf;
       
   758                         }
       
   759                     }
       
   760                 }
       
   761             break;
       
   762         default:
       
   763             ;
       
   764         }
       
   765     }
       
   766 
       
   767 // -----------------------------------------------------------------------------
       
   768 // StoreFile()
       
   769 // save file info into database
       
   770 // -----------------------------------------------------------------------------
       
   771 //
       
   772 void CDcfRepSrv::StoreFileL(const TDesC& aFile , TInt aType)
       
   773     {
       
   774 #ifdef _DRM_TESTING
       
   775     WriteL(_L8("StoreFileL"));
       
   776 #endif
       
   777 
       
   778     RFile f;
       
   779     User::LeaveIfError(f.Open(iFs,aFile,EFileRead|EFileShareReadersOrWriters));
       
   780     CleanupClosePushL(f);
       
   781     TInt i = 0;
       
   782     TInt setTtid = -1;
       
   783     HBufC16* cid = NULL;
       
   784     HBufC16* ttid = NULL;
       
   785     HBufC16* group = NULL;
       
   786 
       
   787     if (aType == EOma1Dcf)
       
   788         {
       
   789         COma1Dcf* d = COma1Dcf::NewL(f);
       
   790         CleanupStack::PushL(d);
       
   791         User::LeaveIfError( From8To16( *(d->iContentID) , cid ) );
       
   792         CleanupStack::PopAndDestroy(d);
       
   793         CleanupStack::PushL(cid);
       
   794         ttid = HBufC::NewMaxLC(16);
       
   795         *ttid = KNullDesC16;
       
   796         UpdateDatabaseL(aFile , KStartPosition , *cid , KNullDesC() , *ttid);
       
   797         if (iCidList)
       
   798             {
       
   799             for (i = 0; i<iCidList->Count(); i++)
       
   800                 {
       
   801                 HBufC* temp = NULL;
       
   802                 User::LeaveIfError( From8To16(*((*iCidList)[i]) , temp ) );
       
   803                 CleanupStack::PushL(temp);
       
   804                 if (!temp->Compare(*cid))
       
   805                     {
       
   806                     delete (*iCidList)[i];
       
   807                     iCidList->Remove(i);
       
   808                     CleanupStack::PopAndDestroy(temp);
       
   809                     break;
       
   810                     }
       
   811                 CleanupStack::PopAndDestroy(temp); //temp
       
   812                 }
       
   813             if (iCidList->Count()<=0)
       
   814                 {
       
   815                 CompleteScanning(KErrNone);
       
   816                 }
       
   817             }
       
   818         CleanupStack::PopAndDestroy(2); //cid,ttid
       
   819         }
       
   820     else if (aType == EOma2Dcf)
       
   821         {
       
   822         COma2Dcf* d = COma2Dcf::NewL(f);
       
   823         CleanupStack::PushL(d);
       
   824 
       
   825         // Set group ID and content ID for this entry
       
   826         if (d->iGroupId)
       
   827             {
       
   828             User::LeaveIfError( From8To16( *(d->iGroupId) , group ) );
       
   829 
       
   830             // replace the content ID for this entry with a placeholder to prevent
       
   831             // that the file is listed wrongly under the group ID
       
   832             cid = KGroupIdReplacement().AllocL();
       
   833             }
       
   834         else
       
   835             {
       
   836             User::LeaveIfError( From8To16( *(d->iContentID) , cid ) );
       
   837             group = HBufC::NewMaxL(16);
       
   838             *group = KNullDesC16;
       
   839             }
       
   840         CleanupStack::PushL(cid);
       
   841         CleanupStack::PushL(group);
       
   842 
       
   843         if (iState == EStateSetTtid)
       
   844             {
       
   845             for (i = 0; iPairList && i<iPairList->Count() && !ttid; i++)
       
   846                 {
       
   847                 HBufC* temp = NULL;
       
   848                 User::LeaveIfError( From8To16(*((*iPairList)[i]->iCid) , temp ) );
       
   849                 CleanupStack::PushL(temp);
       
   850                 if (!temp->Compare(*cid))
       
   851                     {
       
   852                     User::LeaveIfError( From8To16(*((*iPairList)[i]->iTtid) , ttid ) );
       
   853 
       
   854                     // EFileWrite is needed for this case
       
   855                     // So we cannot do it here. we must close the file
       
   856                     setTtid = i;
       
   857                     }
       
   858                 CleanupStack::PopAndDestroy(temp); //temp
       
   859                 }
       
   860             }
       
   861         if (!ttid)
       
   862             {
       
   863             if (d->iTransactionTracking)
       
   864                 {
       
   865                 User::LeaveIfError( From8To16( *(d->iTransactionTracking) , ttid ) );
       
   866                 }
       
   867             else
       
   868                 {
       
   869                 ttid = HBufC::NewMaxL(16);
       
   870                 *ttid = KNullDesC16;
       
   871                 }
       
   872             }
       
   873         CleanupStack::PushL(ttid);
       
   874 
       
   875         UpdateDatabaseL(aFile , KStartPosition , *cid , *group , *ttid);
       
   876         if (iCidList)
       
   877             {
       
   878             for (i = 0; i<iCidList->Count(); i++)
       
   879                 {
       
   880                 HBufC* temp = NULL;
       
   881                 User::LeaveIfError( From8To16(*((*iCidList)[i]) , temp ) );
       
   882                 CleanupStack::PushL(temp);
       
   883                 if (!temp->Compare(*cid))
       
   884                     {
       
   885                     delete (*iCidList)[i];
       
   886                     iCidList->Remove(i);
       
   887                     CleanupStack::PopAndDestroy(temp);
       
   888                     break;
       
   889                     }
       
   890                 CleanupStack::PopAndDestroy(temp); //temp
       
   891                 }
       
   892             if (iCidList->Count()<=0)
       
   893                 {
       
   894                 CompleteScanning(KErrNone);
       
   895                 }
       
   896             }
       
   897         CleanupStack::PopAndDestroy(4); // group,ttid,cid,d
       
   898         }
       
   899 
       
   900     CleanupStack::PopAndDestroy(&f); // f
       
   901 
       
   902     if (setTtid>=0)
       
   903         {
       
   904         ResetTtidL( aFile , *((*iPairList)[setTtid]->iTtid));
       
   905         }
       
   906     }
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 // ResetTtidL()
       
   910 // save new ttid into file
       
   911 // -----------------------------------------------------------------------------
       
   912 //
       
   913 void CDcfRepSrv::ResetTtidL(
       
   914     const TDesC& aFile,
       
   915     const TDesC8& aTtid
       
   916     )
       
   917     {
       
   918 #ifdef _DRM_TESTING
       
   919     WriteL(_L8("ResetTtidL"));
       
   920 #endif
       
   921 
       
   922     RFile f;
       
   923     User::LeaveIfError(f.Open(iFs,aFile, EFileWrite|EFileShareReadersOrWriters ));
       
   924     CleanupClosePushL(f);
       
   925     COma2Dcf* d = COma2Dcf::NewL(f);
       
   926     CleanupStack::PushL(d);
       
   927     ResetTtidL(d,aTtid);
       
   928     CleanupStack::PopAndDestroy(2); // f,d
       
   929     }
       
   930 
       
   931 // -----------------------------------------------------------------------------
       
   932 // ResetTtidL()
       
   933 // save new ttid into file
       
   934 // -----------------------------------------------------------------------------
       
   935 //
       
   936 void CDcfRepSrv::ResetTtidL(
       
   937     COma2Dcf* aDcf,
       
   938     const TDesC8& aTtid
       
   939     )
       
   940     {
       
   941 #ifdef _DRM_TESTING
       
   942     WriteL(_L8("ResetTtidL"));
       
   943 #endif
       
   944 
       
   945     aDcf->SetTransactionIdL(aTtid);
       
   946     }
       
   947 
       
   948 // -----------------------------------------------------------------------------
       
   949 // UpdateDatabaseL()
       
   950 // save info into database
       
   951 // -----------------------------------------------------------------------------
       
   952 //
       
   953 void CDcfRepSrv::UpdateDatabaseL(
       
   954     const TDesC& aFile,
       
   955     TInt aPos,
       
   956     const TDesC& aCid ,
       
   957     const TDesC& aGroupId ,
       
   958     const TDesC& aTtid)
       
   959     {
       
   960 #ifdef _DRM_TESTING
       
   961     WriteL(_L8("UpdateDatabaseL"));
       
   962 #endif
       
   963 
       
   964     HBufC* sql = NULL;
       
   965     TPtr ptr(NULL,0,0);
       
   966     TBuf<4> num;
       
   967     sql = HBufC::NewMaxLC(aFile.Length()+200);
       
   968     ptr.Set(sql->Des());
       
   969     ptr.SetLength(0);
       
   970     ptr.Append(KSqlUpdate1);
       
   971     ptr.Append(aFile);
       
   972     ptr.Append(KSqlUpdate2);
       
   973     num.Num(aPos);
       
   974     ptr.Append(num);
       
   975 
       
   976     iView.Close();
       
   977 
       
   978     User::LeaveIfError(
       
   979         iView.Prepare(
       
   980             iDb,TDbQuery(ptr),
       
   981             TDbWindow::EUnlimited,
       
   982             RDbView::EUpdatable
       
   983             )
       
   984         );
       
   985     User::LeaveIfError(iView.EvaluateAll());
       
   986     if (iView.FirstL())
       
   987         {
       
   988         iView.UpdateL();
       
   989         iView.SetColL(KOrdCid,aCid);
       
   990         iView.SetColL(KOrdGroupId,aGroupId);
       
   991         iView.SetColL(KOrdTtid,aTtid);
       
   992         iView.PutL();
       
   993         }
       
   994     else
       
   995         {
       
   996         iView.Reset();
       
   997         iView.Close();
       
   998         iView.Prepare(
       
   999             iDb,TDbQuery(KSqlInsert),
       
  1000             TDbWindow::EUnlimited,
       
  1001             RDbView::EInsertOnly
       
  1002             );
       
  1003         iView.InsertL();
       
  1004         iView.SetColL(KOrdFilename,aFile);
       
  1005         iView.SetColL(KOrdPosition,aPos);
       
  1006         iView.SetColL(KOrdCid,aCid);
       
  1007         iView.SetColL(KOrdGroupId,aGroupId);
       
  1008         iView.SetColL(KOrdTtid,aTtid);
       
  1009         iView.PutL();
       
  1010         }
       
  1011     iView.Reset();
       
  1012     iView.Close();
       
  1013     CleanupStack::PopAndDestroy(sql); //sql
       
  1014     }
       
  1015 
       
  1016 // -----------------------------------------------------------------------------
       
  1017 // State()
       
  1018 // This function returns the state of the Server
       
  1019 // -----------------------------------------------------------------------------
       
  1020 //
       
  1021 TInt CDcfRepSrv::State() const
       
  1022     {
       
  1023 #ifdef _DRM_TESTING
       
  1024     TRAPD(r,WriteL(_L8("State")));
       
  1025 #endif
       
  1026 
       
  1027     return iState;
       
  1028     }
       
  1029 
       
  1030 // -----------------------------------------------------------------------------
       
  1031 // SetState()
       
  1032 // This function set the state of the Server
       
  1033 // -----------------------------------------------------------------------------
       
  1034 //
       
  1035 void CDcfRepSrv::SetState(TServerState aMode)
       
  1036     {
       
  1037 #ifdef _DRM_TESTING
       
  1038     TRAPD(r,WriteL(_L8("SetState")));
       
  1039 #endif
       
  1040 
       
  1041     iState = aMode;
       
  1042     }
       
  1043 
       
  1044 
       
  1045 // -----------------------------------------------------------------------------
       
  1046 // CompleteScanning().
       
  1047 // This function complete request from client
       
  1048 // -----------------------------------------------------------------------------
       
  1049 //
       
  1050 void CDcfRepSrv::CompleteScanning(TInt aRet)
       
  1051     {
       
  1052 #ifdef _DRM_TESTING
       
  1053     TRAPD(r,WriteL(_L8("CompleteScanning")));
       
  1054 #endif
       
  1055 
       
  1056     for (TInt i = 0 ; i<iMessageList.Count() ; i++ )
       
  1057         {
       
  1058         if ( iMessageList[i] && !(iMessageList[i]->IsNull()) )
       
  1059             {
       
  1060             iMessageList[i]->Complete(aRet);
       
  1061             }
       
  1062         }
       
  1063     iMessageList.ResetAndDestroy();
       
  1064 
       
  1065     CleanScanInternal();
       
  1066     iState = EStateIdle;
       
  1067     }
       
  1068 
       
  1069 // -----------------------------------------------------------------------------
       
  1070 // SetMessage().
       
  1071 // This function save the incomplete message to server
       
  1072 // -----------------------------------------------------------------------------
       
  1073 //
       
  1074 RMessage2* CDcfRepSrv::SetMessageL(const RMessage2& aMessage)
       
  1075     {
       
  1076 #ifdef _DRM_TESTING
       
  1077     WriteL(_L8("SetMessageL"));
       
  1078 #endif
       
  1079     RMessage2* m = NULL;
       
  1080     m = new (ELeave) RMessage2(aMessage);
       
  1081     iMessageList.AppendL(m);
       
  1082     return m;
       
  1083     }
       
  1084 
       
  1085 
       
  1086 // -----------------------------------------------------------------------------
       
  1087 // RemoveMessage().
       
  1088 // This function to remove the imcomplete message from server if it is still there
       
  1089 // when session is deleted
       
  1090 // -----------------------------------------------------------------------------
       
  1091 //
       
  1092 void CDcfRepSrv::RemoveMessageL( const RMessage2* aMessage )
       
  1093     {
       
  1094     for (TInt i = 0 ; i<iMessageList.Count() ; i++ )
       
  1095         {
       
  1096         if ( iMessageList[i] == aMessage )
       
  1097             {
       
  1098             delete iMessageList[i];
       
  1099             iMessageList[i] = NULL;
       
  1100             iMessageList.Remove( i );
       
  1101             return;
       
  1102             }
       
  1103         }
       
  1104     return;
       
  1105     };
       
  1106 
       
  1107 
       
  1108 // -----------------------------------------------------------------------------
       
  1109 // SetCidList().
       
  1110 // This function set content ID List
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 void CDcfRepSrv::SetCidList(RPointerArray<HBufC8>*& aList)
       
  1114     {
       
  1115 #ifdef _DRM_TESTING
       
  1116     TRAPD(r,WriteL(_L8("SetCidList")));
       
  1117 #endif
       
  1118 
       
  1119     if (iCidList)
       
  1120         {
       
  1121         iCidList->ResetAndDestroy();
       
  1122         iCidList->Close();
       
  1123         delete iCidList;
       
  1124         }
       
  1125     iCidList = aList;
       
  1126     }
       
  1127 
       
  1128 // -----------------------------------------------------------------------------
       
  1129 // SetPairList().
       
  1130 // This function set list of pairs for content ID and transation ID
       
  1131 // -----------------------------------------------------------------------------
       
  1132 //
       
  1133 void CDcfRepSrv::SetPairList(RPointerArray<CPair>*& aList)
       
  1134     {
       
  1135 #ifdef _DRM_TESTING
       
  1136     TRAPD(r,WriteL(_L8("SetPairList")));
       
  1137 #endif
       
  1138 
       
  1139     if (iPairList)
       
  1140         {
       
  1141         iPairList->ResetAndDestroy();
       
  1142         iPairList->Close();
       
  1143         delete iPairList;
       
  1144         }
       
  1145     iPairList = aList;
       
  1146     }
       
  1147 
       
  1148 
       
  1149 // -----------------------------------------------------------------------------
       
  1150 // Scan()
       
  1151 // This function scan the file system
       
  1152 // -----------------------------------------------------------------------------
       
  1153 //
       
  1154 TInt CDcfRepSrv::Scan()
       
  1155     {
       
  1156 #ifdef _DRM_TESTING
       
  1157     TRAPD(r,WriteL(_L8("Scan")));
       
  1158 #endif
       
  1159 
       
  1160     TInt err = 0;
       
  1161     if (iState == EStateFullScan)
       
  1162         {
       
  1163         TRAP(err,CleanTableL());
       
  1164         }
       
  1165     err = iScan->SearchContent(this);
       
  1166     if (err)
       
  1167         {
       
  1168         CleanScanInternal();
       
  1169         iState = EStateIdle;
       
  1170         }
       
  1171     return err;
       
  1172     }
       
  1173 
       
  1174 void CDcfRepSrv::CleanScanInternal()
       
  1175     {
       
  1176 #ifdef _DRM_TESTING
       
  1177     TRAPD(r,WriteL(_L8("CleanScanInternal")));
       
  1178 #endif
       
  1179 
       
  1180     if (iCidList)
       
  1181         {
       
  1182         iCidList->ResetAndDestroy();
       
  1183         iCidList->Close();
       
  1184         delete iCidList;
       
  1185         iCidList = NULL;
       
  1186         }
       
  1187     if (iPairList)
       
  1188         {
       
  1189         iPairList->ResetAndDestroy();
       
  1190         iPairList->Close();
       
  1191         delete iPairList;
       
  1192         iPairList = NULL;
       
  1193         }
       
  1194     }
       
  1195 
       
  1196 void CDcfRepSrv::CleanDatabase()
       
  1197     {
       
  1198 #ifdef _DRM_TESTING
       
  1199     TRAPD(r,WriteL(_L8("CleanDatabase")));
       
  1200 #endif
       
  1201 
       
  1202     iView.Close();
       
  1203     iDb.Close();
       
  1204     iDbs.Close();
       
  1205     }
       
  1206 
       
  1207 // -----------------------------------------------------------------------------
       
  1208 // CDcfRepSrv::WatchedObjectChangedL
       
  1209 // -----------------------------------------------------------------------------
       
  1210 //
       
  1211 void CDcfRepSrv::WatchedObjectChangedL( const TDesC& aObject )
       
  1212     {
       
  1213     DRMLOG( _L( "CDcfRepSrv::WatchedObjectChangedL ->" ) );
       
  1214     DRMLOG( aObject );
       
  1215 
       
  1216     if ( aObject.Left( KProcIdentifier().Length() ) == KProcIdentifier && iArmed )
       
  1217         {
       
  1218 #ifdef _DEBUG
       
  1219         DRMLOG( _L( "Peer process killed (DEBUG mode, not rebooting)" ) );
       
  1220 #else
       
  1221         DRMLOG( _L( "Peer process killed, rebooting" ) );
       
  1222         RStarterSession starter;
       
  1223         User::LeaveIfError( starter.Connect() );
       
  1224         starter.Shutdown();
       
  1225         starter.Close();
       
  1226 #endif
       
  1227         }
       
  1228 
       
  1229     DRMLOG( _L( "CDRMRightsServer::WatchedObjectChangedL <-" ) );
       
  1230     }
       
  1231 
       
  1232 // -----------------------------------------------------------------------------
       
  1233 // CDcfRepSrv::StopWatchingL
       
  1234 // -----------------------------------------------------------------------------
       
  1235 //
       
  1236 void CDcfRepSrv::StopWatchingL()
       
  1237     {
       
  1238     DRMLOG( _L( "CDcfRepSrv::StopWatchingL ->" ) );
       
  1239     iArmed = EFalse;
       
  1240     DRMLOG( _L( "CDRMRightsServer::StopWatchingL <-" ) );
       
  1241     }
       
  1242 
       
  1243 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  1244 
       
  1245 // -----------------------------------------------------------------------------
       
  1246 // E32 Entry for Executable
       
  1247 // -----------------------------------------------------------------------------
       
  1248 
       
  1249 TInt E32Main()
       
  1250     {
       
  1251     return CDcfRepSrv::Startup();
       
  1252     }
       
  1253 
       
  1254 //  End of File