connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveSelectWLanDlgPlugin.cpp
branchRCL_3
changeset 12 ea6e024ea6f9
parent 0 5a93021fdf25
child 57 05bc53fe583b
--- a/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveSelectWLanDlgPlugin.cpp	Fri Feb 19 23:12:51 2010 +0200
+++ b/connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveSelectWLanDlgPlugin.cpp	Fri Mar 12 15:44:18 2010 +0200
@@ -107,7 +107,10 @@
         iResultsListDialog = NULL;
         }
     
+    DestroyAsyncWaitTrigger();
+        
     delete iWlanDataProv;
+    iWlanDataProv = NULL;
 
     CLOG_LEAVEFN( "CActiveSelectWLanDlgPlugin::~CActiveSelectWLanDlgPlugin " );
     }
@@ -134,6 +137,8 @@
     delete iWlanDataProv;
     iWlanDataProv = NULL;
 
+    DestroyAsyncWaitTrigger();
+
     CLOG_LEAVEFN( "CActiveSelectWLanDlgPlugin::DoCancel " );
     }
     
@@ -228,6 +233,8 @@
     {
     CLOG_ENTERFN( "CActiveSelectWLanDlgPlugin::RunL " );  
     
+    DestroyAsyncWaitTrigger();
+
     if ( iWaitDialog )
         {
         iWaitDialog->ProcessFinishedL();     
@@ -261,12 +268,9 @@
 
                 iResultsListDialog->ExecuteLD( R_SELECT_WLAN_LIST_QUERY );
 
-                TInt interval = GetRefreshInterval();
-                CLOG_WRITEF( _L( "interval : %d" ),  interval );
-
-                if( interval )
+                if( iRefreshInterval )
                     {
-                    StartTimerL( interval );
+                    StartTimerL( iRefreshInterval );
                     }
                 }
             }
@@ -321,13 +325,7 @@
 void CActiveSelectWLanDlgPlugin::StartSearchWlanNetworkL()
     {    
     CLOG_ENTERFN( "CActiveSelectWLanDlgPlugin::StartSearchWlanNetworkL " );  
-    
-    DestroyWaitDialog();
 
-    iWaitDialog = new( ELeave )CAknWaitDialog
-                    ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ), ETrue );
-    iWaitDialog->ExecuteLD( R_SEARCHING_WLAN_WAIT_NOTE ); 
-    
     SetActive();    
 
 #ifdef __WINS__
@@ -336,10 +334,24 @@
 #else
     iWlanDataProv->RefreshScanInfo( iStatus );
 #endif
+ 
+    // Start wait dialog asynchronously with low priority.
+    // The reason for this is that sometimes WLAN scan results
+    // are already in the cache and returned fast.
+    // When this happens there is no point in displaying wait note.
+    iRefreshInterval = GetRefreshInterval();
+    CLOG_WRITEF( _L( "interval : %d" ),  iRefreshInterval );
+
+    if ( !iAsyncWaitTrigger )
+        {
+        TCallBack cb( StartWaitNoteL, this );
+        iAsyncWaitTrigger = new( ELeave ) CAsyncCallBack( cb, CActive::EPriorityLow );
+        }
+    iAsyncWaitTrigger->CallBack();
 
     CLOG_LEAVEFN( "CActiveSelectWLanDlgPlugin::StartSearchWlanNetworkL " );
     }
-    
+
 // ---------------------------------------------------------
 // CActiveSelectWLanDlgPlugin::GetRefreshInterval()
 // ---------------------------------------------------------
@@ -416,5 +428,37 @@
     CLOG_LEAVEFN( "CActiveSelectWLanDlgPlugin::DestroyResultsListDialog " );
     }
 
+// ---------------------------------------------------------
+// CActiveSelectWLanDlgPlugin::DestroyAsyncWaitTrigger()
+// ---------------------------------------------------------
+//
+void CActiveSelectWLanDlgPlugin::DestroyAsyncWaitTrigger()
+    {
+    if ( iAsyncWaitTrigger )
+        {
+        iAsyncWaitTrigger->Cancel();
+        delete  iAsyncWaitTrigger;
+        iAsyncWaitTrigger= NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CActiveSelectWLanDlgPlugin::StartWaitNoteL()
+// ---------------------------------------------------------
+//
+TInt CActiveSelectWLanDlgPlugin::StartWaitNoteL( TAny* aObject )
+    {
+    CActiveSelectWLanDlgPlugin* myself = 
+            static_cast<CActiveSelectWLanDlgPlugin*>( aObject );
+    
+    myself->DestroyWaitDialog();
+    
+    myself->iWaitDialog = new( ELeave )CAknWaitDialog
+                        ( REINTERPRET_CAST( CEikDialog**, &(myself->iWaitDialog) ), ETrue );
+    myself->iWaitDialog->ExecuteLD( R_SEARCHING_WLAN_WAIT_NOTE );
+        
+    return 0;   
+    }
+
 // End of File