omadrm/drmengine/drmclock/Src/DRMClock.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
--- a/omadrm/drmengine/drmclock/Src/DRMClock.cpp	Tue Feb 02 00:21:44 2010 +0200
+++ b/omadrm/drmengine/drmclock/Src/DRMClock.cpp	Fri Apr 16 15:14:55 2010 +0300
@@ -21,7 +21,7 @@
 #include <mmtsy_names.h>
 
 #include "DRMClock.h"
-#include "DRMLog.h"
+#include "drmlog.h"
 #include "DRMEventTimeChange.h"
 #include "wmdrmfileserverclient.h"
 
@@ -32,10 +32,11 @@
 #include <e32keys.h>
 
 #ifdef RD_MULTIPLE_DRIVE
-#include <DriveInfo.h>
+#include <driveinfo.h>
 #endif
 
 #include "DRMNitzObserver.h"
+#include "GPSWatcher.h"
 
 // EXTERNAL DATA STRUCTURES
 
@@ -85,6 +86,7 @@
 void CDRMClock::ConstructL()
     {
     DRMLOG( _L( "DRM Clock Starting: " ) );
+    TInt error = KErrNone;
 
     // Create a notifier instance
     iNotifier = CDRMNotifier::NewL();
@@ -95,9 +97,11 @@
     iObserver = CDRMNitzObserver::NewL( iPhone, const_cast<CDRMClock*>(this));
 
     iObserver->Start();
+    
+    TRAP( error, iGpsWatcher = CGPSWatcher::NewL( const_cast<CDRMClock*>(this) ));
+    DRMLOG2( _L("DRMClock: GPS watcher started: %d"), error );    
 #endif
 
-
     DRMLOG( _L( "DRM Clock started" ) );		    
     };
 
@@ -158,6 +162,13 @@
         delete iObserver;
         iObserver = 0;
         }  
+        
+    if( iGpsWatcher )
+        {
+        iGpsWatcher->Cancel();
+        delete iGpsWatcher;
+        iGpsWatcher = 0;
+        }   
 #endif // __WINS__        
     };
 
@@ -189,7 +200,7 @@
         
         aTime.UniversalTime();
 
-        aSecurityLevel = DRMClock::KInsecure;
+        aSecurityLevel = DRMClock::KInsecure; 
        
         DRMLOG( _L( "CDRMClock::GetSecureTime: DRMClock is Insecure" ) );        
         }
@@ -308,6 +319,31 @@
     DRMLOG( _L( "CDRMClock::ResetSecureTimeL ok" ) );
     };
 
+// ---------------------------------------------------------
+// CDRMClock::Notify
+// Notify DRM clock about an event
+// ---------------------------------------------------------
+//
+void CDRMClock::Notify( TInt aNotify )
+    {
+    switch( aNotify )
+        {
+        case ENotifyGPSTimeReceived:
+            // GPS time received, listen again after the next boot, destroy GPS watcher:
+            DRMLOG(_L("Notify: ENotifyGPSTimeReceived, Deleting GPS watcher"));
+            delete iGpsWatcher;
+            iGpsWatcher = NULL;
+            DRMLOG(_L("Notify: GPS Watcher deleted"));
+            break;    
+        case ENotifyNone:
+        default:
+            break;  // Do nothing    
+        }    
+    }
+
+
+
+
 
 // ---------------------------------------------------------
 // CDRMClock::ConnectToPhoneL(const TDateTime& aDateTime)