24
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
/**
|
|
17 |
@file
|
|
18 |
@internalTechnology
|
|
19 |
*/
|
|
20 |
|
|
21 |
|
|
22 |
#ifndef TETELREQUEST_H
|
|
23 |
#define TETELREQUEST_H
|
|
24 |
|
|
25 |
#include <e32base.h>
|
|
26 |
#include <etel.h>
|
|
27 |
#include <e32cons.h>
|
|
28 |
|
|
29 |
/**
|
|
30 |
Base class to store a request status and the require information to cancel the request
|
|
31 |
Object of this call can be push on the cleanup stack to ensure that a request is canceled
|
|
32 |
on leave.
|
|
33 |
*/
|
|
34 |
class TEtelRequestBase
|
|
35 |
{
|
|
36 |
public:
|
|
37 |
virtual void Cancel()=0;
|
|
38 |
public:
|
|
39 |
inline operator TCleanupItem();
|
|
40 |
inline operator TRequestStatus&();
|
|
41 |
inline TInt Int();
|
|
42 |
protected:
|
|
43 |
static void DoCleanup(TAny* aPtr);
|
|
44 |
inline void Cleanup();
|
|
45 |
protected:
|
|
46 |
TRequestStatus iReqStatus;
|
|
47 |
};
|
|
48 |
|
|
49 |
|
|
50 |
/**
|
|
51 |
TEtelRequestBase for core etel functions
|
|
52 |
*/
|
|
53 |
template<class SubSess>
|
|
54 |
class TCoreEtelRequestStatus : public TEtelRequestBase
|
|
55 |
{
|
|
56 |
public:
|
|
57 |
typedef void (SubSess::*TConstCancelFnPtr)(void) const;
|
|
58 |
typedef void (SubSess::*TCancelFnPtr)(void);
|
|
59 |
public:
|
|
60 |
inline TCoreEtelRequestStatus(SubSess& aSubSess, TCancelFnPtr aCancelFnPtr);
|
|
61 |
inline TCoreEtelRequestStatus(SubSess& aSubSess, TConstCancelFnPtr aCancelFnPtr);
|
|
62 |
void Cancel();
|
|
63 |
protected:
|
|
64 |
SubSess& iSubSess;
|
|
65 |
TConstCancelFnPtr iConstCancelFnPtr;
|
|
66 |
TCancelFnPtr iCancelFnPtr;
|
|
67 |
};
|
|
68 |
|
|
69 |
|
|
70 |
/**
|
|
71 |
TEtelRequestBase for extended etel functions
|
|
72 |
*/
|
|
73 |
class TExtEtelRequestStatus : public TEtelRequestBase
|
|
74 |
{
|
|
75 |
public:
|
|
76 |
inline TExtEtelRequestStatus(RTelSubSessionBase& aSubSess, TInt aCancelIpc);
|
|
77 |
void Cancel();
|
|
78 |
protected:
|
|
79 |
RTelSubSessionBase& iSubSess;
|
|
80 |
TInt iCancelIpc;
|
|
81 |
};
|
|
82 |
|
|
83 |
|
|
84 |
/**
|
|
85 |
*/
|
|
86 |
inline TEtelRequestBase::operator TCleanupItem()
|
|
87 |
{
|
|
88 |
return TCleanupItem(DoCleanup,this);
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
*/
|
|
93 |
inline TEtelRequestBase::operator TRequestStatus&()
|
|
94 |
{
|
|
95 |
return iReqStatus;
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
*/
|
|
100 |
inline TInt TEtelRequestBase::Int()
|
|
101 |
{
|
|
102 |
return iReqStatus.Int();
|
|
103 |
}
|
|
104 |
|
|
105 |
/**
|
|
106 |
*/
|
|
107 |
inline void TEtelRequestBase::Cleanup()
|
|
108 |
{
|
|
109 |
if (iReqStatus == KRequestPending)
|
|
110 |
{
|
|
111 |
Cancel();
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
/**
|
|
116 |
*/
|
|
117 |
template<class SubSess>
|
|
118 |
inline TCoreEtelRequestStatus<SubSess>::TCoreEtelRequestStatus(SubSess& aSubSess, TCancelFnPtr aCancelFnPtr)
|
|
119 |
:iSubSess(aSubSess), iConstCancelFnPtr(NULL), iCancelFnPtr(aCancelFnPtr)
|
|
120 |
{
|
|
121 |
}
|
|
122 |
|
|
123 |
/**
|
|
124 |
*/
|
|
125 |
template<class SubSess>
|
|
126 |
inline TCoreEtelRequestStatus<SubSess>::TCoreEtelRequestStatus(SubSess& aSubSess, TConstCancelFnPtr aCancelFnPtr)
|
|
127 |
:iSubSess(aSubSess), iConstCancelFnPtr(aCancelFnPtr), iCancelFnPtr(NULL)
|
|
128 |
{
|
|
129 |
}
|
|
130 |
|
|
131 |
/**
|
|
132 |
*/
|
|
133 |
template<class SubSess>
|
|
134 |
void TCoreEtelRequestStatus<SubSess>::Cancel()
|
|
135 |
{
|
|
136 |
if (iConstCancelFnPtr)
|
|
137 |
(iSubSess.*iConstCancelFnPtr)();
|
|
138 |
else
|
|
139 |
(iSubSess.*iCancelFnPtr)();
|
|
140 |
User::WaitForRequest(iReqStatus);
|
|
141 |
}
|
|
142 |
|
|
143 |
/**
|
|
144 |
*/
|
|
145 |
inline TExtEtelRequestStatus::TExtEtelRequestStatus(RTelSubSessionBase& aSubSess, TInt aCancelIpc)
|
|
146 |
:iSubSess(aSubSess), iCancelIpc(aCancelIpc)
|
|
147 |
{
|
|
148 |
}
|
|
149 |
|
|
150 |
/**
|
|
151 |
TConsoleReadRequestBase for CConsole::Read function
|
|
152 |
*/
|
|
153 |
class TConsoleReadRequestStatus : public TEtelRequestBase
|
|
154 |
{
|
|
155 |
public:
|
|
156 |
inline TConsoleReadRequestStatus(CConsoleBase& aSubSess);
|
|
157 |
void Cancel();
|
|
158 |
protected:
|
|
159 |
CConsoleBase& iSubSess;
|
|
160 |
};
|
|
161 |
|
|
162 |
/**
|
|
163 |
*/
|
|
164 |
inline TConsoleReadRequestStatus::TConsoleReadRequestStatus(CConsoleBase& aSubSess)
|
|
165 |
:iSubSess(aSubSess)
|
|
166 |
{
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
#endif
|