commands/wget/wget.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // wget.h
       
     2 // 
       
     3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #ifndef __W_GET_H__
       
    14 #define __W_GET_H__
       
    15 
       
    16 #include <e32std.h>
       
    17 #include <es_sock.h>
       
    18 #include <rhttpsession.h>
       
    19 #include <mhttpsessioneventcallback.h>
       
    20 #include <mhttpauthenticationcallback.h>
       
    21 #include <mhttptransactioncallback.h>
       
    22 #include <mhttpdatasupplier.h>
       
    23 #include <fshell/ioutils.h>
       
    24 
       
    25 using namespace IoUtils;
       
    26 
       
    27 const TUint32 KDefaultChunkSize = 0x200; // 512 Bytes
       
    28 
       
    29 //
       
    30 // CCmdWget
       
    31 // fshell command to retrieve a file from an HTTP Server on a network
       
    32 //
       
    33 class CCmdWget : public CCommandBase, public MHTTPSessionEventCallback, public MHTTPAuthenticationCallback, public MHTTPTransactionCallback, public MHTTPDataSupplier
       
    34 	{
       
    35 public:
       
    36 	static CCommandBase* NewLC();
       
    37 	~CCmdWget();
       
    38 private:
       
    39 	CCmdWget();
       
    40 	void PrepareDownloadFileL();
       
    41 	void PrepareUploadFileL();
       
    42 	void DumpRespHeadersL(RHTTPTransaction& aTransaction);
       
    43 	void LaunchConnectionL();
       
    44 	void ConfigureHTTPL();
       
    45 	void LaunchHTTPTransactionL();
       
    46 	
       
    47 	// From CCommandBase.
       
    48 	virtual const TDesC& Name() const;
       
    49 	virtual void DoRunL();
       
    50 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
       
    51 	virtual void OptionsL(RCommandOptionList& aOptions);
       
    52 
       
    53 	// From MHTTPSessionEventCallback
       
    54 	virtual void MHFSessionRunL(const THTTPSessionEvent& aEvent);
       
    55 	virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent);
       
    56 	
       
    57 	// From MHTTPTransactionCallback
       
    58 	virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    59 	virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
    60 
       
    61 	// From MHTTPAuthenticationCallback
       
    62 	virtual TBool GetCredentialsL(const TUriC8& aURI, RString aRealm, RStringF aAuthenticationType, RString& aUsername, RString& aPassword);
       
    63 	
       
    64 	// From MHTTPDataSupplier
       
    65 	virtual TBool GetNextDataPart(TPtrC8& aDataPart);
       
    66 	virtual void ReleaseData();
       
    67 	virtual TInt OverallDataSize();
       
    68 	virtual TInt Reset();
       
    69 private:
       
    70 	RHTTPSession iSession;
       
    71 	RHTTPTransaction iTransaction;
       
    72 	RHTTPRequest iRequest;
       
    73 	RSocketServ iSocketServ;
       
    74 	RConnection iConnection;
       
    75 	RFile iLocalFile;
       
    76 	TInt iLocalFileSize;
       
    77 	TInt iLocalBytesRead;
       
    78 	TBuf8<KDefaultChunkSize> iPrevData;
       
    79 	TBool iSessionIsOpen;
       
    80 	TBool iReleaseDataCalled;
       
    81 	
       
    82 	// user-specified arguments & options
       
    83 	TBool iContinue;
       
    84 	TBool iVerbose;
       
    85 	TBool iPostData;
       
    86 	HBufC* iUrl;
       
    87 	HBufC* iUsername;
       
    88 	HBufC* iPassword;
       
    89 	TFileName2 iDestinationFilename;
       
    90 	TFileName2 iUploadFilename;
       
    91 	TInt iIapId;
       
    92 	};
       
    93 
       
    94 #endif // __W_GET_H__