|
1 // Copyright (c) 2006-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 #include "cimapservergreeting.h" |
|
17 |
|
18 #include "cimapservergreetinginfo.h" |
|
19 #include "moutputstream.h" |
|
20 #include "cimapsessionconsts.h" |
|
21 #include "imappaniccodes.h" |
|
22 |
|
23 // Construction and Destruction |
|
24 CImapServerGreeting* CImapServerGreeting::NewL(CImapFolderInfo* aSelectedFolderData, TInt aLogId, CImapServerGreetingInfo& aServerGreetingInfo) |
|
25 // static method |
|
26 { |
|
27 CImapServerGreeting* self = new(ELeave)CImapServerGreeting(aSelectedFolderData, aLogId, aServerGreetingInfo); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CImapServerGreeting::CImapServerGreeting(CImapFolderInfo* aSelectedFolderData, TInt aLogId, CImapServerGreetingInfo& aServerGreetingInfo) |
|
32 : CImapCommandEx(aSelectedFolderData, aLogId) |
|
33 , iServerGreetingInfo(aServerGreetingInfo) |
|
34 { |
|
35 // override the default CImapCommand value |
|
36 iCompleteOnAnyResponse = ETrue; |
|
37 } |
|
38 |
|
39 CImapServerGreeting::~CImapServerGreeting() |
|
40 { |
|
41 } |
|
42 |
|
43 /** |
|
44 The server sends its greeting upon connection. |
|
45 No message needs to be sent in order for this to happen. |
|
46 So this method is an empty stub that allows the server greeting object |
|
47 to fit into the CImapCommand framework. |
|
48 @param aTagId Ignored in this implementation of CImapCommand. |
|
49 @param aStream Ignored in this implementation of CImapCommand. |
|
50 */ |
|
51 void CImapServerGreeting::SendMessageL(TInt /*aTagId*/, MOutputStream& /*aStream*/) |
|
52 { |
|
53 __ASSERT_DEBUG(iOutputBuffer==NULL, TImapServerPanic::ImapPanic(TImapServerPanic::ECommandOutputBufferNotNull)); |
|
54 } |
|
55 |
|
56 /** |
|
57 Server Greeting is a single untagged response with the response code OK/PREAUTH/BYE |
|
58 Because iCompleteOnAnyResponse is ETrue, the command will complete on receipt of this response. |
|
59 @return ECompleteUntagged |
|
60 */ |
|
61 CImapCommand::TParseBlockResult CImapServerGreeting::ParseUntaggedResponseL() |
|
62 { |
|
63 // From RFC3501 section 9... |
|
64 // |
|
65 // greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF |
|
66 // resp-cond-auth = ("OK" / "PREAUTH") SP resp-text |
|
67 // resp-cond-bye = "BYE" SP resp-text |
|
68 // |
|
69 // resp-text is ignored by this implementation |
|
70 |
|
71 TPtrC8 serverGreetingTag = GetNextPart(); |
|
72 |
|
73 if (serverGreetingTag.CompareF(KImapTxtOk) == 0) |
|
74 { |
|
75 iServerGreetingInfo.SetResponseTag(CImapServerGreetingInfo::ETagOk); |
|
76 } |
|
77 else if (serverGreetingTag.CompareF(KImapTxtPreAuth) == 0) |
|
78 { |
|
79 iServerGreetingInfo.SetResponseTag(CImapServerGreetingInfo::ETagPreAuth); |
|
80 } |
|
81 else if (serverGreetingTag.CompareF(KImapTxtBye) == 0) |
|
82 { |
|
83 iServerGreetingInfo.SetResponseTag(CImapServerGreetingInfo::ETagBye); |
|
84 } |
|
85 else |
|
86 { |
|
87 CorruptDataL(); |
|
88 } |
|
89 |
|
90 return ECompleteUntagged; |
|
91 } |