widgets/widgetapp/src/WidgetUiWindow.cpp
changeset 26 cb62a4f66ebe
parent 25 0ed94ceaa377
child 27 6297cdf66332
--- a/widgets/widgetapp/src/WidgetUiWindow.cpp	Thu Dec 17 09:20:16 2009 +0200
+++ b/widgets/widgetapp/src/WidgetUiWindow.cpp	Thu Jan 07 13:31:38 2010 +0200
@@ -21,7 +21,7 @@
 #include "WidgetUiWindowContainer.h"
 #include "WidgetUiWindowManager.h"
 #include "WidgetUiDialogsProviderProxy.h"
-#include "widgetregistryconstants.h"
+#include <widgetregistryconstants.h>
 #include "browser_platform_variant.hrh"
 #ifdef BRDO_WRT_HS_FF
 #include "cpspublisher.h"
@@ -42,7 +42,6 @@
 #include <aknsdrawutils.h>
 #include "SWInstWidgetUid.h"
 
-
 // EXTERNAL DATA STRUCTURES
 
 // EXTERNAL FUNCTION PROTOTYPES
@@ -194,8 +193,10 @@
 
     iDlId = 0;
 
+    iNeedToNotifyNetworkState = EFalse;
     // determine initial widget online/offline network state
     DetermineNetworkState();
+    iAsyncCallBack = new (ELeave) CAsyncCallBack(TCallBack(DeleteItself,this),CActive::EPriorityUserInput);
     }
 
 // -----------------------------------------------------------------------------
@@ -220,10 +221,20 @@
     delete iLeftSoftKeyLabel;
     delete iWidgetUiDialogsProviderProxy;
     delete iSchemeHandler;
-    delete iMiniviewBitmap;
+    
+    iActiveMiniviewBitmap = 0;
+    iMiniviewBitmap1.Reset();
+    iMiniviewBitmap2.Reset();
+    
 #ifdef BRDO_WRT_HS_FF
     delete iNetworkModeWait;
 #endif
+    if(iAsyncCallBack)
+        {
+        iAsyncCallBack->Cancel();
+        }
+    delete iAsyncCallBack;
+    iAsyncCallBack=NULL;    
     }
 
 // -----------------------------------------------------------------------------
@@ -613,6 +624,9 @@
         {
         Engine()->MakeVisible( ETrue );
         }
+    PublishSnapShot();
+    if(iWidgetLoaded && iNeedToNotifyNetworkState)
+        DetermineNetworkState();
     }
 
 // -----------------------------------------------------------------------------
@@ -627,16 +641,18 @@
         {
 #ifdef BRDO_WRT_HS_FF
 
-        if ( !iMiniviewBitmap )
+        if ( iCpsPublisher)
             {
-            iMiniviewBitmap = new CFbsBitmap();
-            }
-
-        if ( iMiniviewBitmap && iCpsPublisher)
-            {
+            // Swap bitmaps
+            if(iActiveMiniviewBitmap == &iMiniviewBitmap1)
+            	iActiveMiniviewBitmap = &iMiniviewBitmap2;
+            else
+            	iActiveMiniviewBitmap = &iMiniviewBitmap1;
+            
+            // Take snapshot and publish	
             TRAP_IGNORE(
-               (iEngine->TakeSnapshotL( *iMiniviewBitmap ));
-                iCpsPublisher->PublishBitmapL( *iMiniviewBitmap, *iWidgetBundleId );
+               (iEngine->TakeSnapshotL( *iActiveMiniviewBitmap ));
+                iCpsPublisher->PublishBitmapL( *iActiveMiniviewBitmap, *iWidgetBundleId );
                 );
             }
 #endif
@@ -810,6 +826,13 @@
                     iWindowManager.GetConnection()->SetRequestedAP( iap );
                 );
             }
+
+        if ( EBrowserCenRepApSelModeAlwaysAsk == ask )
+            {
+              //Always ask case
+              TUint32 ap( 0 );
+              iWindowManager.GetConnection()->SetRequestedAP( ap );
+            }
         }
     }
 
@@ -825,11 +848,21 @@
     if ( !iWindowManager.GetConnection()->Connected() )
         {
         // 2.2. make a connection
-        TInt connFailure = iWindowManager.GetConnection()->StartConnectionL( ETrue );
+        iConnecting=ETrue;
+        TInt connFailure = 0;
+        TRAPD(err, connFailure=iWindowManager.GetConnection()->StartConnectionL( ETrue ));
+        iConnecting=EFalse;
+        User::LeaveIfError(err);
+        if(iDeleteItself)
+            iAsyncCallBack->CallBack();
         if (KErrCancel == connFailure)
             {
 #ifdef BRDO_WRT_HS_FF
-            iCpsPublisher->NetworkConnectionCancelledL();
+            if(! (EMiniViewEnabled == WidgetMiniViewState() || 
+                  EMiniViewNotEnabled == WidgetMiniViewState()) )
+                {        
+                iCpsPublisher->NetworkConnectionCancelledL();
+                }
 #endif
             User::Leave( connFailure );
             }
@@ -1121,7 +1154,7 @@
     {
     TNetworkState currNetState;
     RWidgetRegistryClientSession& widgetRegistry = iWindowManager.WidgetUIClientSession();
-    TInt inMiniView = widgetRegistry.IsWidgetInMiniView( iUid);
+    TInt inMiniView = !(WidgetMiniViewState()==EMiniViewEnabled || WidgetMiniViewState()==EMiniViewNotEnabled);//widgetRegistry.IsWidgetInMiniView( iUid);
     CWidgetPropertyValue* propValue = widgetRegistry.GetWidgetPropertyValueL( iUid, EAllowNetworkAccess );
     TInt netAccessWdgtProp = *propValue;    // AllowNetworkAccess in the info.plist file
 
@@ -1183,4 +1216,38 @@
             }
         }
     }
+
+// -----------------------------------------------------------------------------
+// CWidgetUiWindow::NeedToNotifyNetworkState()
+// -----------------------------------------------------------------------------
+//
+void CWidgetUiWindow::NeedToNotifyNetworkState(TBool aNetworkState)
+    {
+    iNeedToNotifyNetworkState = aNetworkState;
+    }
+
+// -----------------------------------------------------------------------------
+// CWidgetUiWindow::CanBeDeleted()
+// -----------------------------------------------------------------------------
+//
+TBool CWidgetUiWindow::CanBeDeleted()
+    {
+    iDeleteItself = iConnecting;
+    return !iConnecting;
+    }
+    
+// -----------------------------------------------------------------------------
+// CWidgetUiWindow::DeleteItself()
+// -----------------------------------------------------------------------------
+//
+TInt CWidgetUiWindow::DeleteItself(TAny* aPtr)
+    {
+    CWidgetUiWindow* self = (CWidgetUiWindow*)aPtr;
+    CWidgetUiWindowManager* p = &self->iWindowManager;
+    delete self;
+    if(p->WindowListCount() == 0)
+        p->ExitNow();
+    return 0;
+    }
+
 // End of file