eventsui/eventshandlerui/eventshandlerserver/src/evtglobalquery.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2008 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:  Handler for displaying the Events Global Query
       
    15 *
       
    16 */
       
    17 
       
    18 // System Includes
       
    19 #include <coecntrl.h> // CCoeControl
       
    20 #include <AknGlobalMsgQuery.h> //CAknGlobalMsgQuery
       
    21 #include <avkon.rsg>
       
    22 #include <avkon.hrh>
       
    23 #include <gulicon.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <avkon.mbg>
       
    26 #include <evthandlerserver.mbg>
       
    27 #include <eikimage.h>
       
    28 #include <data_caging_path_literals.hrh>
       
    29 #include <AknsConstants.h> 		// Skin Ids
       
    30 #include <AknIconUtils.h>
       
    31 #include <AknsSkinInstance.h>
       
    32 
       
    33 // User Includes
       
    34 #include "evtglobalquery.h"
       
    35 #include "evtinfonoteparams.h"
       
    36 #include "evtkeylockhandler.h"
       
    37 #include "evtdebug.h"
       
    38 #include "evtinfonoteinterface.h"
       
    39 
       
    40 _LIT( KEvtDefaultIconFileName, "evthandlerserver.mif" );
       
    41 static const TInt KTimetoPlay = 60;
       
    42 
       
    43 // ================ Member funtions for CEvtGlobalQuery class ===============
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CEvtGlobalQuery::CEvtGlobalQuery
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CEvtGlobalQuery::CEvtGlobalQuery( CEvtInfoNoteInputParam&      aInputParam ) 
       
    50         : CActive (EPriorityStandard),  iInputParam( aInputParam )
       
    51 	{
       
    52     CActiveScheduler::Add( this );
       
    53 	}
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CEvtGlobalQuery::~CEvtGlobalQuery
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CEvtGlobalQuery::~CEvtGlobalQuery()
       
    60 	{
       
    61 	Cancel();
       
    62 	
       
    63     // Delete the Query
       
    64 	delete iGlobalMsgQuery;
       
    65 	
       
    66     // Delete the tone player
       
    67     delete iTonePlayer;
       
    68     
       
    69     // Delete Key Lock Handler
       
    70     if( iKeyLockHandler )
       
    71         {
       
    72         delete iKeyLockHandler;
       
    73         }
       
    74 	}
       
    75 	
       
    76 // ---------------------------------------------------------------------------
       
    77 // CEvtGlobalQuery::NewL
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C CEvtGlobalQuery* CEvtGlobalQuery::NewL( CEvtInfoNoteInputParam&      aInputParam )
       
    81     {
       
    82 	CEvtGlobalQuery* self = NewLC(aInputParam);
       
    83 	CleanupStack::Pop( self );
       
    84 	return self;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CEvtGlobalQuery::NewLC
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CEvtGlobalQuery* CEvtGlobalQuery::NewLC( CEvtInfoNoteInputParam&      aInputParam )
       
    92     {
       
    93 	CEvtGlobalQuery* self = new ( ELeave )CEvtGlobalQuery(aInputParam);
       
    94 	CleanupStack::PushL( self );
       
    95 	self->ConstructL( );
       
    96 	return self;
       
    97     } 
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CEvtGlobalQuery::ConstructL
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CEvtGlobalQuery::ConstructL()
       
   104     {
       
   105     EVTUIDEBUG( "+ CEvtGlobalQuery::ConstructL()" );
       
   106 	    	
       
   107     iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
   108         
       
   109     iKeyLockHandler = CEvtKeyLockHandler::NewL( );
       
   110     
       
   111     iTonePlayer = CEvtTonePlayer::NewL( *this );     
       
   112 	
       
   113     EVTUIDEBUG( "- CEvtGlobalQuery::ConstructL()" );
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // void CEvtGlobalQuery::RunL()
       
   118 // ---------------------------------------------------------------------------
       
   119 //                             
       
   120 void CEvtGlobalQuery::RunL()
       
   121     {
       
   122 	EVTUIDEBUG( "+ CEvtGlobalQuery::RunL()" );
       
   123     iReturnBuffer->Zero( );
       
   124 	if(iStatus.Int() == EAknSoftkeyOpen)
       
   125 		{
       
   126 		iReturnBuffer->AppendNum( EOpenTrigger );
       
   127 		
       
   128 		// Disable the Key Lock irrespective of previously maintained state.
       
   129 		// Update the Key Lock state.
       
   130 	    if ( iKeyLockHandler )
       
   131 	        {
       
   132 	        iKeyLockHandler->EnableKeyLock( EFalse );
       
   133 			iKeyLockHandler->UpdateStateWithoutNote();
       
   134 	        }
       
   135 		}
       
   136 	else
       
   137 		{
       
   138 		iReturnBuffer->AppendNum( ECloseInfoNote );
       
   139 	
       
   140 		// Update the Key Lock state.
       
   141 	    if ( iKeyLockHandler )
       
   142 	        {
       
   143 			iKeyLockHandler->UpdateStateWithNote();
       
   144 	        }
       
   145 		}
       
   146     User::RequestComplete( iReturnStatus, KErrNone );
       
   147 	
       
   148 	EVTUIDEBUG( "- CEvtGlobalQuery::RunL()" );
       
   149     }
       
   150     
       
   151 // ---------------------------------------------------------------------------
       
   152 // void CEvtGlobalQuery::DoCancel()
       
   153 // ---------------------------------------------------------------------------
       
   154 // 
       
   155 void CEvtGlobalQuery::DoCancel()
       
   156     {
       
   157 	EVTUIDEBUG( "+ CEvtGlobalQuery::DoCancel()" );
       
   158     // Cancel the outstanding CR notification request
       
   159     if( iGlobalMsgQuery )
       
   160         {
       
   161         iGlobalMsgQuery->CancelMsgQuery();      
       
   162         User::RequestComplete( iReturnStatus, KErrCancel );  
       
   163         }
       
   164 	EVTUIDEBUG( "- CEvtGlobalQuery::DoCancel()" );
       
   165     }
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // TInt CEvtGlobalQuery::RunError()
       
   169 // ---------------------------------------------------------------------------
       
   170 //    
       
   171 TInt CEvtGlobalQuery::RunError( TInt aError )
       
   172 	{    	
       
   173 	return aError;	
       
   174 	} 
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // void CEvtGlobalQuery::CancelDialog()
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 EXPORT_C void CEvtGlobalQuery::CancelDialog()
       
   181 	{    	
       
   182     EVTUIDEBUG( "+ CEvtGlobalQuery::CancelDialog()" );
       
   183 	Cancel();
       
   184     EVTUIDEBUG( "- CEvtGlobalQuery::CancelDialog()" );
       
   185 	} 
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // TInt CEvtGlobalQuery::RunError()
       
   189 // ---------------------------------------------------------------------------
       
   190 //  
       
   191 EXPORT_C void CEvtGlobalQuery::StartGlobalQueryL(TRequestStatus& aStatus, TDes8& aRetBuffer)
       
   192     {
       
   193     EVTUIDEBUG( "+ CEvtGlobalQuery::StartGlobalQueryL()" );
       
   194     iReturnStatus = &aStatus;
       
   195     iReturnBuffer = &aRetBuffer;
       
   196     
       
   197     *iReturnStatus = KRequestPending;
       
   198     
       
   199     if( iGlobalMsgQuery )
       
   200         {
       
   201         iGlobalMsgQuery->CancelMsgQuery();  
       
   202         delete iGlobalMsgQuery;
       
   203         iGlobalMsgQuery = NULL;
       
   204         }
       
   205     
       
   206     TFileName fileName;    
       
   207     TInt bmpID;
       
   208     TInt bmpMaskID;
       
   209     
       
   210     GetIconDetailsL(fileName, bmpID, bmpMaskID);
       
   211     
       
   212     // Maintain the Key Lock State and Enable if it is already not enabled
       
   213     if ( iKeyLockHandler )
       
   214         {
       
   215         iKeyLockHandler->MaintainState();
       
   216         }
       
   217         
       
   218     // If tone player is there, then start tone playing
       
   219     if ( iInputParam.ToneEnabled() )
       
   220         {
       
   221         iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
   222         iGlobalMsgQuery->ShowMsgQueryL(iStatus, iInputParam.Description(), R_AVKON_SOFTKEYS_OPEN_CLOSE, iInputParam.Subject(), fileName, bmpID, bmpMaskID );
       
   223         SetActive();
       
   224         iTonePlayer->PlayFileL( iInputParam.Tone(), iInputParam.ToneRepeat(), KTimetoPlay );
       
   225         }
       
   226     else
       
   227         {
       
   228         iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
   229         iGlobalMsgQuery->ShowMsgQueryL(iStatus, iInputParam.Description(), R_AVKON_SOFTKEYS_OPEN_CLOSE, iInputParam.Subject(), fileName, bmpID, bmpMaskID );
       
   230         SetActive();
       
   231         }
       
   232 
       
   233     EVTUIDEBUG( "- CEvtGlobalQuery::StartGlobalQueryL()" );
       
   234     }  
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // void CEvtGlobalQuery::GetIconDetailsL()
       
   238 // ---------------------------------------------------------------------------
       
   239 //    
       
   240 void CEvtGlobalQuery::GetIconDetailsL( TFileName& aFileName, TInt& aBmpID, TInt& aBmpMaskID )
       
   241 	{    	
       
   242     EVTUIDEBUG( "+ CEvtGlobalQuery::GetIconDetailsL()" );
       
   243 	RProcess currentProcess;
       
   244 	TParse parser;
       
   245 	
       
   246 	parser.Set( currentProcess.FileName(), NULL, NULL );
       
   247 	TPtrC filename( parser.FullName() );
       
   248     //filename.Copy( KTempDrive );
       
   249 	
       
   250 	User::LeaveIfError( parser.Set( KEvtDefaultIconFileName, &KDC_APP_BITMAP_DIR, &filename ));
       
   251     aFileName = parser.FullName();
       
   252     
       
   253      //retrieve accuracy level       
       
   254     CEvtInfoNoteInputParam::TEvtTriggerAccuracy accuracy = iInputParam.TrigerringAccuracy();
       
   255     EVTUIDEBUG1( "Icon creation:Accuracy level = %d", accuracy )
       
   256     
       
   257     switch( accuracy )
       
   258     	{
       
   259     	case CEvtInfoNoteInputParam::EEvtAccurateTrigger:
       
   260     		aBmpID = EMbmEvthandlerserverQgn_note_locev_alarm_acc;
       
   261     		aBmpMaskID = EMbmEvthandlerserverQgn_note_locev_alarm_acc_mask;
       
   262     		break;
       
   263     	case CEvtInfoNoteInputParam::EEvtInaccurateTrigger:
       
   264     		aBmpID = EMbmEvthandlerserverQgn_note_locev_alarm_inacc;
       
   265     		aBmpMaskID = EMbmEvthandlerserverQgn_note_locev_alarm_inacc_mask;
       
   266     		break;
       
   267     	case CEvtInfoNoteInputParam::EEvtHighlyInaccurateTrigger:
       
   268     	default:
       
   269     		aBmpID = EMbmEvthandlerserverQgn_note_locev_alarm_inacc_heavy;
       
   270     		aBmpMaskID = EMbmEvthandlerserverQgn_note_locev_alarm_inacc_heavy_mask;
       
   271     		break;
       
   272     	}
       
   273     EVTUIDEBUG( "- CEvtGlobalQuery::GetIconDetailsL()" );
       
   274 	} 
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // void CEvtGlobalQuery::TonePlayCompleteL()
       
   278 // ---------------------------------------------------------------------------
       
   279 //  
       
   280 void CEvtGlobalQuery::TonePlayCompleteL( TBool aTimeout )
       
   281 	{
       
   282     EVTUIDEBUG( "+ CEvtGlobalQuery::TonePlayCompleteL()" );
       
   283 		// Enable KeyLock on Timeout.
       
   284     if ( iKeyLockHandler && aTimeout )
       
   285         {
       
   286         iKeyLockHandler->EnableKeyLock( ETrue );
       
   287         iKeyLockHandler->UpdateStateWithoutNote();
       
   288         }
       
   289         
       
   290     // Update the CBA
       
   291     iGlobalMsgQuery->UpdateMsgQuery( R_AVKON_SOFTKEYS_OPEN_CLOSE );
       
   292     EVTUIDEBUG( "- CEvtGlobalQuery::TonePlayCompleteL()" );
       
   293 	}
       
   294 	
       
   295