imageeditor/plugins/DrawPlugin/src/TimeAO.cpp
author Simon Howkins <simonh@symbian.org>
Mon, 15 Nov 2010 12:21:35 +0000
changeset 24 f8a4151f4fe1
parent 12 18b321db4884
permissions -rw-r--r--
Added include to define the macros used
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     1
/*
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     2
 ============================================================================
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     3
 Name		: TimeAO.cpp
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     4
 Author	  : 
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     5
 Version	 : 1.0
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     6
 Copyright   : Your copyright notice
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     7
 Description : CTimeAO implementation
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     8
 ============================================================================
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
     9
 */
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    10
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    11
#include "TimeAO.h"
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    12
#include "MCountTime.h"
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    13
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    14
// CTimeAO()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    15
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    16
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    17
CTimeAO::CTimeAO() :
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    18
	CActive(EPriorityStandard) // Standard priority
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    19
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    20
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    21
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    22
// NewLC()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    23
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    24
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    25
CTimeAO* CTimeAO::NewLC()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    26
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    27
	CTimeAO* self = new (ELeave) CTimeAO();
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    28
	CleanupStack::PushL(self);
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    29
	self->ConstructL();
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    30
	return self;
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    31
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    32
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    33
// NewL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    34
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    35
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    36
CTimeAO* CTimeAO::NewL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    37
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    38
	CTimeAO* self = CTimeAO::NewLC();
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    39
	CleanupStack::Pop(); // self;
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    40
	return self;
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    41
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    42
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    43
// ConstructL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    44
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    45
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    46
void CTimeAO::ConstructL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    47
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    48
	User::LeaveIfError(iTimer.CreateLocal());
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    49
	CActiveScheduler::Add(this); // Add to scheduler
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    50
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    51
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    52
// ~CTimeAO()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    53
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    54
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    55
CTimeAO::~CTimeAO()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    56
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    57
	Cancel(); // Cancel any request, if outstanding
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    58
	iTimer.Close(); // Destroy the RTimer object
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    59
	// Delete instance variables if any
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    60
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    61
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    62
// DoCancel()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    63
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    64
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    65
void CTimeAO::DoCancel()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    66
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    67
	iTimer.Cancel();
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    68
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    69
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    70
// StartL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    71
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    72
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    73
void CTimeAO::StartL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    74
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    75
	Cancel(); // Cancel any request, just to be sure
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    76
	iTimer.After(iStatus, 1000000); // Set for later
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    77
	SetActive(); // Tell scheduler a request is active
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    78
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    79
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    80
// SetObserver()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    81
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    82
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    83
void CTimeAO::SetObserver(MCountTime* aObserver)
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    84
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    85
	iObserver = aObserver;
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    86
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    87
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    88
// RunL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    89
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    90
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    91
void CTimeAO::RunL()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    92
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    93
	
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    94
	if (iObserver != NULL)
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    95
		{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    96
		iObserver->Notify();
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    97
		}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    98
	}
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
    99
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   100
// RunError()
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   101
// ---------------------------------------------------------------------------
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   102
//
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   103
TInt CTimeAO::RunError(TInt aError)
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   104
	{
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   105
	return aError;
18b321db4884 *m enhance
qifeima <>
parents:
diff changeset
   106
	}