idlefw/plugins/shortcutplugin/src/cpopupeventhandler.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-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:  Shortcut plug-in Popup event handler class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cpopupeventhandler.h"
       
    20 #include "PopupFSM.h"
       
    21 #include "mpopupeventhandleractions.h"
       
    22 
       
    23 /**
       
    24  * Timeout timer values
       
    25  */
       
    26 const TInt KTimeoutShort = 900000;  //900 ms
       
    27 const TInt KTimeoutLong = 6000000;  //6 sec
       
    28 
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CPopupEventHandler* CPopupEventHandler::NewL(
       
    37     MPopupEventHandlerActions& aPopupEventHandlerActions )
       
    38     {
       
    39     CPopupEventHandler* self = CPopupEventHandler::NewLC( aPopupEventHandlerActions );
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CPopupEventHandler* CPopupEventHandler::NewLC(
       
    49     MPopupEventHandlerActions& aPopupEventHandlerActions )
       
    50     {
       
    51     CPopupEventHandler* self = new( ELeave ) CPopupEventHandler(
       
    52         aPopupEventHandlerActions );
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL();
       
    55     return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CPopupEventHandler::~CPopupEventHandler()
       
    63     {
       
    64     Cancel();
       
    65     iTimer.Close();
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CPopupEventHandler::CPopupEventHandler(
       
    73     MPopupEventHandlerActions& aPopupEventHandlerActions )
       
    74     : CActive( EPriorityStandard ),
       
    75     iPopupEventHandlerActions( aPopupEventHandlerActions ),
       
    76     iPopupFSM( *this ),
       
    77     iPublishPopup( ETrue ),
       
    78     iPublishCaption( ETrue ),
       
    79     iCaptionVisible( ETrue )
       
    80     {
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Constructor
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CPopupEventHandler::ConstructL()
       
    88     {
       
    89     User::LeaveIfError( iTimer.CreateLocal() );
       
    90     CActiveScheduler::Add( this );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 TPopupFSM& CPopupEventHandler::PopupFSM()
       
    98     {
       
    99     return iPopupFSM;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 TBool CPopupEventHandler::PublishPopup() const
       
   107     {
       
   108     return iPublishPopup;
       
   109     }
       
   110 
       
   111 TBool CPopupEventHandler::PopupVisible() const
       
   112     {
       
   113     return iPopupVisible;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 TBool CPopupEventHandler::PublishCaption() const
       
   121     {
       
   122     return iPublishCaption;
       
   123     }
       
   124 
       
   125 TBool CPopupEventHandler::CaptionVisible() const
       
   126     {
       
   127     return iCaptionVisible;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CPopupEventHandler::DoCancel()
       
   135     {
       
   136     iTimer.Cancel();
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CPopupEventHandler::RunL()
       
   144     {
       
   145     iPopupFSM.HandleRequestCompleted();
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CPopupEventHandler::CompleteSelf()
       
   153     {
       
   154     TRequestStatus* status = &iStatus;
       
   155     User::RequestComplete( status, KErrNone );
       
   156     SetActive();
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CPopupEventHandler::CancelRequest()
       
   164     {
       
   165     Cancel();
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 void CPopupEventHandler::StartShortTimer()
       
   173     {
       
   174     Cancel();  // Cancel previous request by calling iTimer.Cancel()
       
   175     iTimer.After( iStatus, KTimeoutShort );
       
   176     SetActive();
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 void CPopupEventHandler::StartLongTimer()
       
   184     {
       
   185     Cancel();  // Cancel previous request by calling iTimer.Cancel()
       
   186     iTimer.After( iStatus, KTimeoutLong );
       
   187     SetActive();
       
   188     }
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CPopupEventHandler::IssuePublishPopup()
       
   195     {
       
   196     iPublishPopup = ETrue;
       
   197     iPopupVisible = ETrue;
       
   198     iPopupEventHandlerActions.IssuePublishShortcut();
       
   199     iPublishPopup = EFalse;
       
   200     }
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 void CPopupEventHandler::IssueCleanPopup()
       
   207     {
       
   208     iPublishPopup = ETrue;
       
   209     iPopupVisible = EFalse;
       
   210     iPopupEventHandlerActions.IssuePublishShortcut();
       
   211     iPublishPopup = EFalse;
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 void CPopupEventHandler::IssuePublishCaption()
       
   219     {
       
   220     iPublishCaption = ETrue;
       
   221     iCaptionVisible = ETrue;
       
   222     iPopupEventHandlerActions.IssuePublishShortcut();
       
   223     iPublishCaption = EFalse;
       
   224     }
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 void CPopupEventHandler::IssueCleanCaption()
       
   231     {
       
   232     iPublishCaption = ETrue;
       
   233     iCaptionVisible = EFalse;
       
   234     iPopupEventHandlerActions.IssuePublishShortcut();
       
   235     iPublishCaption = EFalse;
       
   236     }
       
   237 
       
   238 // End of File.