|
1 // Copyright (c) 2001-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 @internalAll |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef __CSIMSERCOMM_H__ |
|
23 #define __CSIMSERCOMM_H__ |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 #include <c32comm.h> |
|
28 |
|
29 class CCommWriter; |
|
30 class CCommReader; |
|
31 |
|
32 class MComm |
|
33 { |
|
34 protected: |
|
35 MComm(); |
|
36 virtual ~MComm(); |
|
37 void CommConstructL(TInt aReadPriority, TInt aWritePriority); |
|
38 TInt CommOpen(const TDesC& aName, TCommAccess aAccess); |
|
39 TInt CommOpen(const TDesC& aDll, const TDesC& aName, TCommAccess aAccess); |
|
40 void CommClose(); |
|
41 void CommCancel(); |
|
42 void CommWrite(const TDesC8& aDes); |
|
43 void CommWriteReady(); |
|
44 void CommWriteCancel(); |
|
45 void CommRead(TDes8& aDes); |
|
46 void CommReadOneOrMore(TDes8& aDes); |
|
47 void CommReadReady(); |
|
48 void CommReadCancel(); |
|
49 virtual void CommReadComplete(TInt aStatus)=0; |
|
50 virtual void CommWriteComplete(TInt aStatus)=0; |
|
51 protected: |
|
52 friend class CCommWriter; |
|
53 friend class CCommReader; |
|
54 RCommServ iCommServer; |
|
55 RComm iCommPort; |
|
56 CCommReader* iCommReader; |
|
57 CCommWriter* iCommWriter; |
|
58 TBuf8<1> iBuf; |
|
59 }; |
|
60 |
|
61 class CCommReader : public CActive |
|
62 { |
|
63 public: |
|
64 CCommReader(MComm* aComm, TInt aPriority); |
|
65 virtual ~CCommReader(); |
|
66 inline void Activate() { SetActive(); } |
|
67 inline TRequestStatus& StatusRef() { return iStatus; } |
|
68 protected: |
|
69 virtual void RunL(); |
|
70 virtual void DoCancel(); |
|
71 private: |
|
72 MComm *iComm; |
|
73 }; |
|
74 |
|
75 class CCommWriter : public CActive |
|
76 { |
|
77 public: |
|
78 CCommWriter(MComm* aComm, TInt aPriority); |
|
79 virtual ~CCommWriter(); |
|
80 inline void Activate() { SetActive(); } |
|
81 inline TRequestStatus& StatusRef() { return iStatus; } |
|
82 protected: |
|
83 virtual void RunL(); |
|
84 virtual void DoCancel(); |
|
85 private: |
|
86 MComm *iComm; |
|
87 }; |
|
88 |
|
89 #endif |