alarmui/AppServerStuff/Src/AlarmService.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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:  Works as a proxy together with RAknAlarmClient and CAknAlarmWrapper between EikAlert and CAlmAlarmControl. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 #include "pim_trace.h"
       
    22 #include "AlarmService.h"
       
    23 #include "AlmAlarmControl.h"
       
    24 #include <asshdalarm.h>
       
    25 
       
    26 // ---------------------------------------------------------
       
    27 // 
       
    28 // ---------------------------------------------------------
       
    29 EXPORT_C MAknAlarmServiceStartup* Entry()
       
    30     {
       
    31     TRACE_ENTRY_POINT;
       
    32     CAknAlarmService* alarmService = new CAknAlarmService;
       
    33     TRACE_EXIT_POINT;
       
    34     return alarmService;
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // 
       
    39 // ---------------------------------------------------------
       
    40 CAknAlarmService::CAknAlarmService()
       
    41     {
       
    42     TRACE_ENTRY_POINT;
       
    43     TRACE_EXIT_POINT;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // 
       
    48 // ---------------------------------------------------------
       
    49 CAknAlarmService::~CAknAlarmService()
       
    50     {
       
    51     TRACE_ENTRY_POINT;
       
    52     if( iAlarmAlert )
       
    53         {
       
    54         iAlarmAlert->Release();
       
    55         }
       
    56     TRACE_EXIT_POINT;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // 
       
    61 // ---------------------------------------------------------
       
    62 void CAknAlarmService::StartupNewSessionL(TAny*)
       
    63     {
       
    64     TRACE_ENTRY_POINT;
       
    65     iAlarmAlert=new (ELeave) CAlmAlarmControl();
       
    66     iAlarmAlert->ConstructL(this);
       
    67     TRACE_EXIT_POINT;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // 
       
    72 // ---------------------------------------------------------
       
    73 void CAknAlarmService::ServiceL(const RMessage2 &aMessage)
       
    74     {
       
    75     TRACE_ENTRY_POINT;
       
    76     TBool completeMessage( ETrue );
       
    77 
       
    78     switch( aMessage.Function() )
       
    79         {
       
    80         case EASAltOpCodeNotify:
       
    81             if ( iMessage.IsNull() )
       
    82                 {
       
    83                 iMessage = aMessage;
       
    84                 completeMessage = EFalse;
       
    85                 }
       
    86             break;
       
    87 
       
    88         case EASAltOpCodeNotifyCancel:
       
    89             {
       
    90             if( !iMessage.IsNull() )
       
    91                 {
       
    92                 iMessage.Complete( KErrCancel );
       
    93                 }
       
    94             }
       
    95             break;
       
    96 
       
    97         case EASAltOpCodeVisible:
       
    98             {
       
    99             TInt value( 0 );
       
   100             TPckg<TInt> pckg( value );
       
   101             aMessage.ReadL( 0, pckg );
       
   102 
       
   103             if( value )
       
   104                 {
       
   105                 iAlarmAlert->ShowAlarm();
       
   106                 }
       
   107             else
       
   108                 {
       
   109                 iAlarmAlert->HideAlarm();
       
   110                 }
       
   111             }
       
   112             break;
       
   113 
       
   114         case EASAltOpCodeSetState:
       
   115             {
       
   116             TInt value( 0 );
       
   117             TPckg<TInt> pckg( value );
       
   118             aMessage.ReadL( 0, pckg );
       
   119             SetAlertState( value );
       
   120             }
       
   121             break;
       
   122 
       
   123         case EASAltOpCodeSetAlarm:
       
   124             UpdateAlarmInfo( aMessage );
       
   125             break;
       
   126 
       
   127         case EAknSAltOpCodeAskServerState:
       
   128             {
       
   129             TPckgC<TInt> pckgC( iAlarmAlert->CurrentServerState() );
       
   130             aMessage.WriteL( 0, pckgC );
       
   131             }
       
   132             break;
       
   133 
       
   134         default:
       
   135             aMessage.Complete( KErrNotSupported );
       
   136             break;
       
   137         }
       
   138 
       
   139     if( completeMessage && !aMessage.IsNull() )
       
   140         {
       
   141         aMessage.Complete( KErrNone );
       
   142         }
       
   143     TRACE_EXIT_POINT;
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------
       
   147 // 
       
   148 // ---------------------------------------------------------
       
   149 void CAknAlarmService::SetAlertState(TInt aAlarmServerStateFlags)
       
   150     {
       
   151     TRACE_ENTRY_POINT;
       
   152     iAlarmAlert->UpdateForAlarmServerState(aAlarmServerStateFlags);
       
   153     TRACE_EXIT_POINT;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------
       
   157 // 
       
   158 // ---------------------------------------------------------
       
   159 void CAknAlarmService::UpdateAlarmInfo(const RMessage2& aMessage)
       
   160     {
       
   161     TRACE_ENTRY_POINT;
       
   162     TASShdAlarm alarm;
       
   163     TPckg<TASShdAlarm> pAlarm(alarm);
       
   164     PIM_TRAPD_ASSERT( aMessage.ReadL(0,pAlarm); )
       
   165     TFullName owner;
       
   166     PIM_TRAPD_ASSERT( aMessage.ReadL(1,owner); )
       
   167     iAlarmAlert->UpdateAlarmInfo(alarm,owner);
       
   168     TRACE_EXIT_POINT;
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------
       
   172 // 
       
   173 // ---------------------------------------------------------
       
   174 void CAknAlarmService::CmdAcknowledgeAlarm()
       
   175     {
       
   176     TRACE_ENTRY_POINT;
       
   177     if( !iMessage.IsNull() )
       
   178         {
       
   179         iMessage.Complete( ECmdAcknowledgedAlarm );
       
   180         }
       
   181     TRACE_EXIT_POINT;
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // 
       
   186 // ---------------------------------------------------------
       
   187 TBool CAknAlarmService::CmdTaskAwayFromAlarmL()
       
   188     {
       
   189     TRACE_ENTRY_POINT;
       
   190     if( !iMessage.IsNull() )
       
   191         {
       
   192         iMessage.Complete( ECmdTaskAwayFromAlarm );
       
   193         }
       
   194     TRACE_EXIT_POINT;
       
   195     return ETrue;
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------
       
   199 // 
       
   200 // ---------------------------------------------------------
       
   201 TBool CAknAlarmService::CmdTaskAwayFromAlarmL(TInt aMinutesToSnooze)
       
   202     {
       
   203     TRACE_ENTRY_POINT;
       
   204     if( !iMessage.IsNull() )
       
   205         {
       
   206         TPckgC<TInt> pckgC( aMinutesToSnooze );
       
   207         iMessage.WriteL( 0, pckgC );
       
   208         iMessage.Complete( ECmdTaskAwayFromAlarmWTime );
       
   209         }
       
   210     TRACE_EXIT_POINT;
       
   211     return ETrue;
       
   212     }
       
   213 
       
   214 
       
   215 // End of File