idlehomescreen/nativeuicontroller/src/ainotifierrenderer.cpp
changeset 0 f72a12da539e
child 9 f966699dea19
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Dialog renderer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32property.h>
       
    20 #include <activeidle2domainpskeys.h>
       
    21 #include <aipropertyextension.h>
       
    22 
       
    23 #include <AiNativeUi.rsg>
       
    24 
       
    25 #include "ainotifierrenderer.h"
       
    26 #include "ainativeuiplugins.h"
       
    27 
       
    28 using namespace AiNativeUiController;
       
    29 
       
    30 // 1-minute timeout before showing soft notification
       
    31 const TInt KNetworkLostTimeout = 60*1000000;
       
    32 
       
    33 // ======== MEMBER FUNCTIONS ========
       
    34 
       
    35 CAiNotifierRenderer* CAiNotifierRenderer::NewLC()
       
    36     {
       
    37     CAiNotifierRenderer* self = new( ELeave ) CAiNotifierRenderer;
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     return self;
       
    41     }
       
    42 
       
    43 
       
    44 CAiNotifierRenderer::~CAiNotifierRenderer()
       
    45     {
       
    46     delete iSoftNotifier;
       
    47     delete iTimer;
       
    48     }
       
    49 
       
    50 
       
    51 CAiNotifierRenderer::CAiNotifierRenderer()
       
    52     {
       
    53     }
       
    54 
       
    55 void CAiNotifierRenderer::ConstructL()
       
    56     {
       
    57     iSoftNotifier = CAknSoftNotifier::NewL();
       
    58     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    59     }
       
    60 
       
    61 void CAiNotifierRenderer::DoPublishL( MAiPropertyExtension& aPlugin,
       
    62                                     TInt aContent,
       
    63                                     TInt aResource,
       
    64                                     TInt /*aIndex*/  )
       
    65     {
       
    66     if( aPlugin.PublisherInfoL()->iUid == KDeviceStatusPluginUid )
       
    67     	{
       
    68 	    switch( aContent )
       
    69 	        {
       
    70 	        case EAiDeviceStatusContentNWStatus:
       
    71 	            {
       
    72 	            if ( aResource == EAiDeviceStatusResourceNWLost )
       
    73 	                {
       
    74 	                // Start 60 second timer and when expired show the
       
    75 	                // notifier
       
    76 	                iTimer->Cancel();
       
    77 	                iTimer->Start( KNetworkLostTimeout,
       
    78 	                               KNetworkLostTimeout,
       
    79 	                               TCallBack( NWLostDelayCallBack, this ));
       
    80 	                }
       
    81 	            else if ( aResource == EAiDeviceStatusResourceNWOk )
       
    82 	                {
       
    83 	                iTimer->Cancel();
       
    84 	                RemoveNotification( ESelectNetworkNotification );
       
    85 	                }
       
    86 	            break;
       
    87 	            }
       
    88 	        default:
       
    89 	            {
       
    90 	            User::Leave( KErrNotFound );
       
    91 	            break;
       
    92 	            }
       
    93 	        };
       
    94     	}
       
    95     else
       
    96    		{
       
    97    		User::Leave( KErrNotFound );
       
    98    		}
       
    99     }
       
   100 
       
   101 void CAiNotifierRenderer::DoCleanL( MAiPropertyExtension& /*aPlugin*/,
       
   102                                     TInt aContent )
       
   103     {
       
   104     switch( aContent )
       
   105         {
       
   106         case EAiDeviceStatusContentNWStatus:
       
   107             {
       
   108             iTimer->Cancel();
       
   109             RemoveNotification( ESelectNetworkNotification );
       
   110             break;
       
   111             }
       
   112         default:
       
   113             {
       
   114             User::Leave( KErrNotFound );
       
   115             break;
       
   116             }
       
   117         };
       
   118 
       
   119     }
       
   120 
       
   121 
       
   122 void CAiNotifierRenderer::AddNotification( TAknSoftNotificationType aType )
       
   123     {
       
   124     TRAP_IGNORE( iSoftNotifier->AddNotificationL( aType, 1 ); );
       
   125     }
       
   126 
       
   127 void CAiNotifierRenderer::RemoveNotification( TAknSoftNotificationType aType)
       
   128     {
       
   129     TRAP_IGNORE( iSoftNotifier->CancelSoftNotificationL( aType ); );
       
   130     }
       
   131 
       
   132 TInt CAiNotifierRenderer::NWLostDelayCallBack(TAny* aParam)
       
   133     {
       
   134     CAiNotifierRenderer* self = reinterpret_cast<CAiNotifierRenderer *> (aParam);
       
   135     if ( self )
       
   136         {
       
   137         self->iTimer->Cancel();
       
   138         self->AddNotification( ESelectNetworkNotification );
       
   139         }
       
   140     return KErrNone;
       
   141     }
       
   142 
       
   143