omadrm/drmengine/drmclock/Src/DRMClockClient2.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include "DRMClockClient.h"
    20 #include "DRMClockClient.h"
    21 #include "DRMclockClientServer.h"
    21 #include "drmclockclientserver.h"
    22 #include "DRMTypes.h"
    22 #include "DRMTypes.h"
    23 
    23 
    24 #include "DRMLog.h"
    24 #include "drmlog.h"
    25 
    25 
    26 
    26 
    27 // EXTERNAL DATA STRUCTURES
    27 // EXTERNAL DATA STRUCTURES
    28 // EXTERNAL FUNCTION PROTOTYPES  
    28 // EXTERNAL FUNCTION PROTOTYPES
    29 
    29 
    30 // CONSTANTS
    30 // CONSTANTS
    31 // MACROS
    31 // MACROS
    32 
    32 
    33 // LOCAL CONSTANTS AND MACROS
    33 // LOCAL CONSTANTS AND MACROS
    55 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    56 //
    56 //
    57 EXPORT_C RDRMClockClient::RDRMClockClient()
    57 EXPORT_C RDRMClockClient::RDRMClockClient()
    58     {
    58     {
    59     }
    59     }
    60     
    60 
    61 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    62 // RDRMClockClient::~RDRMClockClient
    62 // RDRMClockClient::~RDRMClockClient
    63 // Destructor.
    63 // Destructor.
    64 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    65 //
    65 //
    66 EXPORT_C RDRMClockClient::~RDRMClockClient()
    66 EXPORT_C RDRMClockClient::~RDRMClockClient()
    67     {
    67     {
    68     }    
    68     }
    69 
    69 
    70 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    71 // RDRMClockClient::Connect
    71 // RDRMClockClient::Connect
    72 // Opens connection to the server.
    72 // Opens connection to the server.
    73 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    74 //
    74 //
    75 EXPORT_C TInt RDRMClockClient::Connect()
    75 EXPORT_C TInt RDRMClockClient::Connect()
    76     {
    76     {
    77     TInt ret = KErrNone;
    77     TInt ret = KErrNone;
    78 #ifdef __DRM_CLOCK    
    78 #ifdef __DRM_CLOCK
    79     DRMLOG( _L( "RDRMClockClient::Connect" ) );
    79     DRMLOG( _L( "RDRMClockClient::Connect" ) );
    80 
    80 
    81     const TVersion requiredVersion( 
    81     const TVersion requiredVersion(
    82         DRMClock::KServerMajorVersion,
    82         DRMClock::KServerMajorVersion,
    83         DRMClock::KServerMinorVersion,
    83         DRMClock::KServerMinorVersion,
    84         DRMClock::KServerBuildVersion );
    84         DRMClock::KServerBuildVersion );
    85     
    85 
    86     DRMLOG( _L("RDRMClockClient: Create a new session" ) );
    86     DRMLOG( _L("RDRMClockClient: Create a new session" ) );
    87     ret = CreateSession( DRMClock::KServerName,
    87     ret = CreateSession( DRMClock::KServerName,
    88                          requiredVersion, 
    88                          requiredVersion,
    89                          KMaxMessageSlots );
    89                          KMaxMessageSlots );
    90     DRMLOG2( _L( "Result: %d") , ret );
    90     DRMLOG2( _L( "Result: %d") , ret );
    91 #else
    91 #else
    92     DRMLOG( _L( "RDRMClockClient: No Session Created, DRMClock is off") );
    92     DRMLOG( _L( "RDRMClockClient: No Session Created, DRMClock is off") );
    93 #endif // __DRM_CLOCK
    93 #endif // __DRM_CLOCK
    94     
    94 
    95     return ret;
    95     return ret;
    96     }
    96     }
    97 
    97 
    98 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    99 // RDRMClockClient::Close
    99 // RDRMClockClient::Close
   100 // Closes the connection to the server.
   100 // Closes the connection to the server.
   101 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   102 //
   102 //
   103 EXPORT_C void RDRMClockClient::Close() 
   103 EXPORT_C void RDRMClockClient::Close()
   104     {
   104     {
   105     DRMLOG( _L( "RDRMClockClient::Close" ) );
   105     DRMLOG( _L( "RDRMClockClient::Close" ) );
   106 
   106 
   107     RHandleBase::Close();
   107     RHandleBase::Close();
   108     }
   108     }
   113 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   114 //
   114 //
   115 EXPORT_C TInt RDRMClockClient::GetSecureTime( TTime& aTime, TInt& aTimeZone,
   115 EXPORT_C TInt RDRMClockClient::GetSecureTime( TTime& aTime, TInt& aTimeZone,
   116                                      DRMClock::ESecurityLevel& aSecurityLevel ) const
   116                                      DRMClock::ESecurityLevel& aSecurityLevel ) const
   117     {
   117     {
   118 #ifdef __DRM_CLOCK    	
   118 #ifdef __DRM_CLOCK
   119     TPckg<TTime> package(aTime);
   119     TPckg<TTime> package(aTime);
   120     TPckg<TInt> package2(aTimeZone);
   120     TPckg<TInt> package2(aTimeZone);
   121     TPckg<DRMClock::ESecurityLevel> package3(aSecurityLevel);
   121     TPckg<DRMClock::ESecurityLevel> package3(aSecurityLevel);
   122                 
   122 
   123     DRMLOG( _L( "RDRMClockClient::GetSecureTime" ) );
   123     DRMLOG( _L( "RDRMClockClient::GetSecureTime" ) );
   124     TInt error = KErrNone;
   124     TInt error = KErrNone;
   125     
   125 
   126     // Send the message.
   126     // Send the message.
   127     error = SendReceive( DRMClock::EGetDRMTime, TIpcArgs( &package, &package2, &package3 ) );
   127     error = SendReceive( DRMClock::EGetDRMTime, TIpcArgs( &package, &package2, &package3 ) );
   128     
   128 
   129     DRMLOG2( _L( "RDRMClockClient::GetSecureTime: %d" ), error );
   129     DRMLOG2( _L( "RDRMClockClient::GetSecureTime: %d" ), error );
   130     return error;
   130     return error;
   131 #else
   131 #else
   132     DRMLOG( _L( "RDRMClockClient::GetSecureTime, UI Time is returned, DRMClock is off" ) );
   132     DRMLOG( _L( "RDRMClockClient::GetSecureTime, UI Time is returned, DRMClock is off" ) );
   133 	  TTime currentLocal;
   133       TTime currentLocal;
   134     TInt64 result = 0;
   134     TInt64 result = 0;
   135     	  
   135 
   136 	  // aTime:
   136       // aTime:
   137 	  aTime.UniversalTime();
   137       aTime.UniversalTime();
   138 	  currentLocal.HomeTime();
   138       currentLocal.HomeTime();
   139     
   139 
   140     result = currentLocal.Int64() - aTime.Int64();
   140     result = currentLocal.Int64() - aTime.Int64();
   141     result /= KMinuteInMicroseconds;
   141     result /= KMinuteInMicroseconds;
   142     result /= KTimeZoneIncrement;
   142     result /= KTimeZoneIncrement;
   143     
   143 
   144     // aTimeZone:
   144     // aTimeZone:
   145     aTimeZone = I64INT(result);
   145     aTimeZone = I64INT(result);
   146 
   146 
   147 	  // aSecurityLevel:
   147       // aSecurityLevel:
   148 	  aSecurityLevel = DRMClock::KSecure;
   148       aSecurityLevel = DRMClock::KSecure;
   149 	  return KErrNone;
   149       return KErrNone;
   150 #endif // __DRM_CLOCK
   150 #endif // __DRM_CLOCK
   151     }
   151     }
   152 
   152 
   153 
   153 
   154 // -----------------------------------------------------------------------------
   154 // -----------------------------------------------------------------------------
   160     {
   160     {
   161     TInt error = KErrNone;
   161     TInt error = KErrNone;
   162 #ifdef __DRM_CLOCK
   162 #ifdef __DRM_CLOCK
   163     TPckg<TTime> package(aTime);
   163     TPckg<TTime> package(aTime);
   164     TPckg<TInt> package2(aTimeZone);
   164     TPckg<TInt> package2(aTimeZone);
   165     
   165 
   166     DRMLOG( _L( "RDRMClockClient::UpdateSecureTime" ) );
   166     DRMLOG( _L( "RDRMClockClient::UpdateSecureTime" ) );
   167         
   167 
   168     error = SendReceive( DRMClock::EUpdateDRMTime, TIpcArgs( &package, &package2 ) );
   168     error = SendReceive( DRMClock::EUpdateDRMTime, TIpcArgs( &package, &package2 ) );
   169     
   169 
   170     DRMLOG2( _L( "RDRMClockClient::UpdateSecureTime: " ), error );
   170     DRMLOG2( _L( "RDRMClockClient::UpdateSecureTime: " ), error );
   171 #else
   171 #else
   172     DRMLOG( _L("RDRMClockClient::UpdateSecureTime, Did nothing DRMClock is off") );
   172     DRMLOG( _L("RDRMClockClient::UpdateSecureTime, Did nothing DRMClock is off") );
   173 #endif
   173 #endif
   174     // All done.
   174     // All done.
   175     return error;
   175     return error;
   176     }
   176     }
   177 
   177 
   178 // ========================== OTHER EXPORTED FUNCTIONS =========================
   178 // ========================== OTHER EXPORTED FUNCTIONS =========================
   179 
   179 
   180 //  End of File  
   180 //  End of File