uifw/EikStd/alertsrc/EIKALMCT.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-1999 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <uikon/eiksvfty.h>
       
    19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    20 #include <uikon/eiknotifyalert.h>
       
    21 #endif
       
    22 
       
    23 #include "AlarmObserver.h"
       
    24 #include "Eikalmct.h"
       
    25 //#include "eikalert.hrh"
       
    26 
       
    27 
       
    28 _LIT(KAlertDllFile, "AlmAlert.dll");
       
    29 
       
    30 //
       
    31 // CEikAlarmControl class
       
    32 //
       
    33 
       
    34 EXPORT_C CEikAlarmControl::CEikAlarmControl(CEikAlmControlSupervisor* aSupervisor, CEikServAppUiBase* aAppUi)
       
    35     : iSupervisor(aSupervisor), iAppUi(aAppUi)
       
    36     //
       
    37     // default c'tor
       
    38     //
       
    39     {
       
    40     }
       
    41 
       
    42 EXPORT_C CEikAlarmControl::~CEikAlarmControl()
       
    43     //
       
    44     // d'tor
       
    45     //
       
    46     {
       
    47     if (iAlarm)
       
    48         {
       
    49         iAlarm->Release();
       
    50         }
       
    51     iLibrary.Close();
       
    52     }
       
    53 
       
    54 void CEikAlarmControl::Release()
       
    55     {
       
    56     delete this;
       
    57     }
       
    58 
       
    59 void CEikAlarmControl::StartPlayAlarmL(const TDesC& aAlarmName)
       
    60     {
       
    61     if (iAlarm)
       
    62         {
       
    63         iAlarm->StartPlayAlarmL(aAlarmName);
       
    64         }
       
    65     /*if (iAlarmPlayer)
       
    66         iAlarmPlayer->StartPlay();
       
    67     else
       
    68         iAlarmPlayer=CEikAlarmPlayer::NewL(*iEikonEnv,aAlarmName);*/
       
    69     }
       
    70 
       
    71 void CEikAlarmControl::StopPlayAlarm()
       
    72     {
       
    73     if (iAlarm)
       
    74         {
       
    75         iAlarm->StopPlayAlarm();
       
    76         }
       
    77     /*if (iAlarmPlayer)
       
    78         iAlarmPlayer->StopPlay();*/
       
    79     }
       
    80 
       
    81 EXPORT_C void CEikAlarmControl::ConstructL()
       
    82     //
       
    83     // Create window and components
       
    84     //
       
    85     {
       
    86     User::LeaveIfError(iLibrary.Load(KAlertDllFile));
       
    87     TLibraryFunction constructor = iLibrary.Lookup(1);
       
    88     iAlarm = (MAlarmObserver*)((*constructor)());
       
    89     User::LeaveIfNull(iAlarm);
       
    90     iAlarm->ConstructL(iSupervisor, iAppUi);
       
    91     }
       
    92 
       
    93 void CEikAlarmControl::ShowAlarm()
       
    94     {
       
    95     if (iAlarm)
       
    96         {
       
    97         iAlarm->ShowAlarm();
       
    98         }
       
    99     }
       
   100 
       
   101 void CEikAlarmControl::HideAlarm()
       
   102     {
       
   103     if (iAlarm)
       
   104         {
       
   105         iAlarm->HideAlarm();
       
   106         }
       
   107     /*if (!IsVisible())
       
   108         return;
       
   109     delete iAlarmPlayer;
       
   110     iAlarmPlayer=NULL;
       
   111     RWindowGroup& groupWin=iAppUi->AlertGroupWin();
       
   112     for (TInt i=0; i<3; i++)
       
   113         {
       
   114         groupWin.CancelCaptureKey(iExternalKeys[i]);
       
   115         groupWin.CancelCaptureKeyUpAndDowns(iExternalKeyUpAndDowns[i]);
       
   116         }
       
   117     iAppUi->BringAlertGroupWinForwards(EFalse);
       
   118     MakeVisible(EFalse);
       
   119 
       
   120     iCba->MakeVisible(EFalse);
       
   121     // Make the CBA refuse keypresses
       
   122     CCoeControl* cba = iCba->ButtonGroup()->AsControl();
       
   123     iEikonEnv->EikAppUi()->UpdateStackedControlFlags(cba,
       
   124         ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus,
       
   125         ECoeStackFlagRefusesAllKeys | ECoeStackFlagRefusesFocus);
       
   126 
       
   127     iEikonEnv->RouseSleepingDialog(this,EFalse);*/
       
   128     }
       
   129 
       
   130 TInt CEikAlarmControl::CurrentServerState() const
       
   131     {
       
   132     if (iAlarm)
       
   133         {
       
   134         return iAlarm->CurrentServerState();
       
   135         }
       
   136     return iCurrentAlarmServerState;
       
   137     }
       
   138 
       
   139 void CEikAlarmControl::UpdateSoundPauseTimeInterval(TInt aMinutes)
       
   140     //
       
   141     // Update the visual pause time
       
   142     //
       
   143     {
       
   144     if (iAlarm)
       
   145         {
       
   146         iAlarm->UpdateSoundPauseTimeInterval(aMinutes);
       
   147         }
       
   148     }
       
   149 
       
   150 void CEikAlarmControl::UpdateForAlarmServerState(TInt aNewAlarmServerState)
       
   151     {
       
   152     iCurrentAlarmServerState = aNewAlarmServerState;
       
   153     if (iAlarm)
       
   154         {
       
   155         iAlarm->UpdateForAlarmServerState(aNewAlarmServerState);
       
   156         }
       
   157     // The order of the following are important
       
   158     // Note that these are always updated because they can change independently
       
   159     // of their binary state.
       
   160     /*TInt timePaused=iSupervisor->PauseSoundMinutes();
       
   161     if (!timePaused && aNewAlarmServerState&EAlmSvrSoundOff)
       
   162         iAlarmInfoView->SetSoundOff();
       
   163     else if (!timePaused && aNewAlarmServerState&EAlmSvrQuietPeriod)
       
   164         iAlarmInfoView->SetQuietPeriodTimeEnd(iSupervisor->QuietPeriodEndTime());
       
   165     else
       
   166         iAlarmInfoView->SetPauseSoundTime(timePaused);
       
   167     if (aNewAlarmServerState==iCurrentAlarmServerState)
       
   168         return;
       
   169     if (!timePaused && (aNewAlarmServerState&EAlmSvrNoSoundToPlay) && (!(aNewAlarmServerState&EAlmSvrSoundOff)))
       
   170         {
       
   171         CEikAlarmControlInfo::TSilentType silent=CEikAlarmControlInfo::ESilentAlarm;
       
   172         //if (!(iButtons->ControlById(EEikBidOk)->IsDimmed())) // silence pressed
       
   173         if (!iSilence)
       
   174             silent=CEikAlarmControlInfo::EAlarmSilenced;
       
   175         //iAlarmInfoView->SetNoSoundToPlay(silent);
       
   176         }
       
   177     if (aNewAlarmServerState&EAlmSvrManyDueAlarms)
       
   178         iAlarmInfoView->SetManyDueAlarms();
       
   179     if (aNewAlarmServerState&EAlmSvrNoSnoozeMemory)
       
   180         iAlarmInfoView->SetNoMemoryToSnooze();
       
   181     iAlarmInfoView->DrawSnoozeLabelNow();*/
       
   182     //
       
   183     }
       
   184 
       
   185 /*void CEikAlarmControl::CheckSilenceButtonDimmed()
       
   186     {*/
       
   187     /*CCoeControl* silenceButton=iButtons->ControlById(EEikBidOk);
       
   188     TBool wasDimmed=silenceButton->IsDimmed();
       
   189     TBool newDimmed=iCurrentAlarmServerState&(EAlmSvrQuietPeriod|EAlmSvrSoundOff|EAlmSvrNoSoundToPlay);
       
   190     if (wasDimmed!=newDimmed)
       
   191         {
       
   192         silenceButton->SetDimmed(newDimmed);
       
   193         silenceButton->DrawNow();
       
   194         }*/
       
   195 /*    TBool wasDimmed(iSilence);
       
   196     TBool newDimmed(iCurrentAlarmServerState &
       
   197         (EAlmSvrQuietPeriod|EAlmSvrSoundOff|EAlmSvrNoSoundToPlay));
       
   198     if (wasDimmed != newDimmed)
       
   199         {
       
   200         iSilence = newDimmed;
       
   201         }
       
   202     }*/
       
   203 
       
   204 void CEikAlarmControl::UpdateAlarmInfo(const TASShdAlarm& aAlarm,const TFullName &aOwner)
       
   205     {
       
   206     if (iAlarm)
       
   207         {
       
   208         iAlarm->UpdateAlarmInfo(aAlarm, aOwner);
       
   209         }
       
   210     //iTime->UpdateDate();
       
   211     //iTime->UpdateCityInfo();
       
   212     /*_LIT(KFormatBuf," (%S)");
       
   213     TBuf<KAlarmMaxCharInTitle> ownerBuf;
       
   214     if (aAlarm.iType!=EAlarmTypeClock)
       
   215         {
       
   216         TPtrC owner=BaflUtils::ExtractAppNameFromFullName(aOwner);
       
   217         if (owner.Length())
       
   218             ownerBuf.Format(KFormatBuf ,&owner);
       
   219         }
       
   220     iAlarmInfoView->SetAlarm(aAlarm, ownerBuf);
       
   221     iAlarmInfoView->DrawAllLabelsNow();*/
       
   222     }
       
   223