idlehomescreen/nativeuicontroller/src/ainotifierrenderer.cpp
branchRCL_3
changeset 34 5456b4e8b3a8
child 35 3321d3e205b6
equal deleted inserted replaced
33:5f0182e07bfb 34:5456b4e8b3a8
       
     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 // System includes 
       
    19 #include <e32property.h>
       
    20 
       
    21 // User includes
       
    22 #include <hscontentpublisher.h>
       
    23 #include <hspublisherinfo.h>
       
    24 #include <activeidle2domainpskeys.h>
       
    25 #include <AiNativeUi.rsg>
       
    26 #include "ainotifierrenderer.h"
       
    27 #include "ainativeuiplugins.h"
       
    28 
       
    29 using namespace AiNativeUiController;
       
    30 
       
    31 // Constants
       
    32 
       
    33 // 1-minute timeout before showing soft notification
       
    34 const TInt KNetworkLostTimeout = 60*1000000;
       
    35 
       
    36 // ======== MEMBER FUNCTIONS ========
       
    37 
       
    38 // ----------------------------------------------------------------------------
       
    39 // CAiNotifierRenderer::NewLC()
       
    40 //
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 CAiNotifierRenderer* CAiNotifierRenderer::NewLC()
       
    44     {
       
    45     CAiNotifierRenderer* self = new( ELeave ) CAiNotifierRenderer;
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // CAiNotifierRenderer::~CAiNotifierRenderer()
       
    53 //
       
    54 // ----------------------------------------------------------------------------
       
    55 //
       
    56 CAiNotifierRenderer::~CAiNotifierRenderer()
       
    57     {
       
    58     delete iSoftNotifier;
       
    59     delete iTimer;
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CAiNotifierRenderer::CAiNotifierRenderer()
       
    64 //
       
    65 // ----------------------------------------------------------------------------
       
    66 //
       
    67 CAiNotifierRenderer::CAiNotifierRenderer()
       
    68     {
       
    69     }
       
    70 
       
    71 // ----------------------------------------------------------------------------
       
    72 // CAiNotifierRenderer::ConstructL()
       
    73 //
       
    74 // ----------------------------------------------------------------------------
       
    75 //
       
    76 void CAiNotifierRenderer::ConstructL()
       
    77     {
       
    78     iSoftNotifier = CAknSoftNotifier::NewL();
       
    79     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    80     }
       
    81 
       
    82 // ----------------------------------------------------------------------------
       
    83 // CAiNotifierRenderer::DoPublishL()
       
    84 //
       
    85 // ----------------------------------------------------------------------------
       
    86 //
       
    87 void CAiNotifierRenderer::DoPublishL( CHsContentPublisher& aPlugin,
       
    88     TInt aContent, TInt aResource, TInt /*aIndex*/ )                                                                       
       
    89     {
       
    90     const THsPublisherInfo& info( aPlugin.PublisherInfo() );
       
    91     
       
    92     if( info.Uid() == KDeviceStatusPluginUid )
       
    93     	{
       
    94 	    switch( aContent )
       
    95 	        {
       
    96 	        case EAiDeviceStatusContentNWStatus:
       
    97 	            {
       
    98 	            if ( aResource == EAiDeviceStatusResourceNWLost )
       
    99 	                {
       
   100 	                // Start 60 second timer and when expired show the
       
   101 	                // notifier
       
   102 	                iTimer->Cancel();
       
   103 	                iTimer->Start( KNetworkLostTimeout,
       
   104 	                               KNetworkLostTimeout,
       
   105 	                               TCallBack( NWLostDelayCallBack, this ));
       
   106 	                }
       
   107 	            else if ( aResource == EAiDeviceStatusResourceNWOk )
       
   108 	                {
       
   109 	                iTimer->Cancel();
       
   110 	                RemoveNotification( ESelectNetworkNotification );
       
   111 	                }
       
   112 	            break;
       
   113 	            }
       
   114 	        default:
       
   115 	            {
       
   116 	            User::Leave( KErrNotFound );
       
   117 	            break;
       
   118 	            }
       
   119 	        }
       
   120     	}
       
   121     else
       
   122    		{
       
   123    		User::Leave( KErrNotFound );
       
   124    		}
       
   125     }
       
   126 
       
   127 // ----------------------------------------------------------------------------
       
   128 // CAiNotifierRenderer::DoCleanL()
       
   129 //
       
   130 // ----------------------------------------------------------------------------
       
   131 //
       
   132 void CAiNotifierRenderer::DoCleanL( CHsContentPublisher& /*aPlugin*/,
       
   133     TInt aContent )
       
   134     {
       
   135     switch( aContent )
       
   136         {
       
   137         case EAiDeviceStatusContentNWStatus:
       
   138             {
       
   139             iTimer->Cancel();
       
   140             RemoveNotification( ESelectNetworkNotification );
       
   141             break;
       
   142             }
       
   143         default:
       
   144             {
       
   145             User::Leave( KErrNotFound );
       
   146             break;
       
   147             }
       
   148         }
       
   149     }
       
   150 
       
   151 // ----------------------------------------------------------------------------
       
   152 // CAiNotifierRenderer::AddNotification()
       
   153 //
       
   154 // ----------------------------------------------------------------------------
       
   155 //
       
   156 void CAiNotifierRenderer::AddNotification( TAknSoftNotificationType aType )
       
   157     {
       
   158     TRAP_IGNORE( iSoftNotifier->AddNotificationL( aType, 1 ) );
       
   159     }
       
   160 
       
   161 // ----------------------------------------------------------------------------
       
   162 // CAiNotifierRenderer::RemoveNotification()
       
   163 //
       
   164 // ----------------------------------------------------------------------------
       
   165 //
       
   166 void CAiNotifierRenderer::RemoveNotification( TAknSoftNotificationType aType )
       
   167     {
       
   168     TRAP_IGNORE( iSoftNotifier->CancelSoftNotificationL( aType ); );
       
   169     }
       
   170 
       
   171 // ----------------------------------------------------------------------------
       
   172 // CAiNotifierRenderer::NWLostDelayCallBack()
       
   173 //
       
   174 // ----------------------------------------------------------------------------
       
   175 //
       
   176 TInt CAiNotifierRenderer::NWLostDelayCallBack( TAny* aParam )
       
   177     {
       
   178     CAiNotifierRenderer* self = 
       
   179         reinterpret_cast< CAiNotifierRenderer* >( aParam );
       
   180     
       
   181         if ( self )
       
   182         {
       
   183         self->iTimer->Cancel();
       
   184         self->AddNotification( ESelectNetworkNotification );
       
   185         }
       
   186         
       
   187     return KErrNone;
       
   188     }
       
   189 
       
   190 // End of file
       
   191