|
1 // Copyright (c) 2005-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 #ifndef __CSPOOFSERVER_H__ |
|
17 #define __CSPOOFSERVER_H__ |
|
18 |
|
19 #include <in_sock.h> |
|
20 #include "cscriptfileprocessor.h" |
|
21 |
|
22 // Definitions |
|
23 const TInt KNextLineBufferSize = 2048; |
|
24 const TInt KCurrentBufferSize = KNextLineBufferSize + 2; |
|
25 |
|
26 class MImapTestEventHandler |
|
27 { |
|
28 public: |
|
29 virtual void TestComplete(TInt aErrorCode)=0; |
|
30 }; |
|
31 |
|
32 class CSpoofServer : public CActive |
|
33 { |
|
34 |
|
35 public: |
|
36 IMPORT_C static CSpoofServer* NewL(MImapTestEventHandler& aObserver,const TDesC& aScriptFile); |
|
37 IMPORT_C static CSpoofServer* NewLC(MImapTestEventHandler& aObserver,const TDesC& aScriptFile); |
|
38 IMPORT_C void StartL(const TInt aPortNumber); |
|
39 ~CSpoofServer(); |
|
40 |
|
41 private: |
|
42 CSpoofServer(MImapTestEventHandler& aObserver); |
|
43 void ConstructL(const TDesC& aScriptFile); |
|
44 void IssueWrite(); |
|
45 void IssueRead(); |
|
46 //implemented functions from CActive |
|
47 virtual void DoCancel(); |
|
48 virtual void RunL(); |
|
49 virtual TInt RunError(TInt aError); |
|
50 |
|
51 private: |
|
52 enum TIMAPServerState |
|
53 { |
|
54 EIdle=0, |
|
55 EWriting, |
|
56 EReading |
|
57 }; |
|
58 TIMAPServerState iServerStatus; |
|
59 RSocket iListeningSocket; |
|
60 RSocket iServiceSocket; |
|
61 RSocketServ iSocketServer; |
|
62 TBuf8<KCurrentBufferSize> iBuffer; |
|
63 TBuf8<KNextLineBufferSize> iNextLine; |
|
64 TSockXfrLength iReadLength; |
|
65 CScriptFileProcessor* iScriptFileProcessor; |
|
66 MImapTestEventHandler& iObserver; |
|
67 }; |
|
68 |
|
69 #endif //__CSPOOFSERVER_H__ |
|
70 |