emailservices/emailservermonitor/inc/emailservermonitorutilities.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 11:52:37 +0300
branchRCL_3
changeset 73 c8382f7b54ef
parent 64 3533d4323edc
permissions -rw-r--r--
Revision: 201035 Kit: 201036
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
* Declaration of common functions of Email Server Monitor
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
*/
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
//  Include Files  
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#ifndef EMAILSERVERMONITORUTILITIES_H
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#define EMAILSERVERMONITORUTILITIES_H
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include <e32base.h>
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include <e32cmn.h>     // TSecureId
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
// Forward declarations
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
class CEmailServerMonitorTimer;
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
const TInt KDefaultTimeToWaitInSeconds = 3;
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
/////////////////////////////////////////////////////////////////////////////
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
// LOCAL FUNCTION DECLARATIONS
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
/**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
 * Wait some time to give other applications and servers some time to shut
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
 * down themselves gracefully or to start themselves
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
 * 
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
 * @param aWaitTimeInSeconds Time to wait in seconds
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
 */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
void Wait( TInt aWaitTimeInSeconds = KDefaultTimeToWaitInSeconds );
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
/**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
 * Check is specified process running. If we are checking other UID than
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
 * ourselves, we just check is there specified process running. If we are
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
 * checking our own UID, then we check is there another instance already
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
 * running.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
 * 
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
 * @param aUid Process UID (=Secure ID) to be searched
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
 * @param aProcess If process handle is given, it will updated to have a
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
 *                 a handle to the found process
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
 * @param aProcessUpdated On return ETrue, if aProcess handle was given and
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
 *                        it was updated succesfully
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
 * @return ETrue if the specified process is running, otherwise EFalse.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
 */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
TBool IsProcessRunning( TSecureId aUid, RProcess* aProcess = NULL );
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
/**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
*  Generic timer's callback
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
*  Classes inherited from this one can be used as a callback for the generic
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
*  timer. TimerEvent() is called when the timer elapses.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
*/
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
class MEmailServerMonitorTimerCallback
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
    {
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
public:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
     * @param   aTriggeredTimer The timer which launched this event.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
     */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
    virtual void TimerEventL( CEmailServerMonitorTimer* aTriggeredTimer ) = 0;
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
    };
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
/**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
*  Generic timer
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
*  Caller gives MEmailServerMonitorTimerCallback inherited pointer as a
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
*  parameter, and that pointer is used as a callback when the timer elapses.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
*  Timer interval is given as a parameter for the Start function.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
*
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
*/
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
class CEmailServerMonitorTimer : public CTimer
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
    {
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
public:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
    
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
    * Symbian two-pahse constructor.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
    *
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
    * @param aCallback Callback class
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
    * @param aPriority Timers priority, EPriorityStandard by default
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
    static CEmailServerMonitorTimer* NewL(
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
        MEmailServerMonitorTimerCallback* aCallback,
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
        const TInt aPriority = CActive::EPriorityStandard );
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
    * Symbian two-pahse constructor.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
    *
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
    * @param aCallback Callback class
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
    * @param aPriority Timers priority, EPriorityStandard by default
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
    static CEmailServerMonitorTimer* NewLC(
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
        MEmailServerMonitorTimerCallback* aCallback,
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
        const TInt aPriority = CActive::EPriorityStandard );
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
        
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
    * Destructor.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
    ~CEmailServerMonitorTimer();
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
        
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
    * Starts the timer with specified interval, or with the default value.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
    *
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
    * @param aInterval Timer interval as microseconds
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
    void Start( TInt aInterval );
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
    * Stops the timer.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
    void Stop();
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
    * CActive object's RunL
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
    void RunL();
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
        
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
protected:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
    * Constructor.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
    CEmailServerMonitorTimer( MEmailServerMonitorTimerCallback* aCallback,
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
                              const TInt aPriority );
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
        
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
private:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
    /**
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
    * 2nd phase constructor.
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
    */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
    void ConstructL();
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
private:
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
    /* Pointer to callback class */
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
    MEmailServerMonitorTimerCallback* iCallback;
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
    };
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
3533d4323edc Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
#endif // EMAILSERVERMONITORUTILITIES_H