ipsservices/tsrc/profiletester/inc/popimapprofiletester.h
branchRCL_3
changeset 26 968773a0b6ef
equal deleted inserted replaced
25:3533d4323edc 26:968773a0b6ef
       
     1 /*
       
     2  *  Copyright ?2010-2010 Nokia and/or its subsidiary(-ies).  All rights reserved.
       
     3  *  This material, including documentation and any related computer
       
     4  *  programs, is protected by copyright controlled by Nokia.  All
       
     5  *  rights are reserved.  Copying, including reproducing, storing,
       
     6  *  adapting or translating, any or all of this material requires the
       
     7  *  prior written consent of Nokia.  This material also contains
       
     8  *  confidential information which may not be disclosed to others
       
     9  *  without the prior written consent of Nokia.
       
    10  *
       
    11  * Initial Contributors:
       
    12  * Nokia Corporation - initial contribution.
       
    13  *
       
    14  * Contributors:
       
    15  * 
       
    16  * Description: STIF testclass declaration
       
    17  *
       
    18  */
       
    19 
       
    20 #ifndef POPIMAPPROFILETESTER_H
       
    21 #define POPIMAPPROFILETESTER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <StifLogger.h>
       
    25 #include <TestScripterInternal.h>
       
    26 #include <StifTestModule.h>
       
    27 #include <TestclassAssert.h>
       
    28 #include <cemailaccounts.h>
       
    29 #include <centralrepository.h>
       
    30 
       
    31 //cmail side
       
    32 #include "cfsmailbox.h" //for cmail observer
       
    33 #include "cfsmailclient.h"
       
    34 #include "cfsmailcommon.h" //for cmail common flags
       
    35 #include "timeouttimer.h" //for timeout timer
       
    36 #include "baseplugincommonutils.h" //for cleanup
       
    37 #include "FreestyleEmailCenRepKeys.h"
       
    38 #include "../../../ipssossettings/inc/ipssetwizardsettingscenrepkeys.h"
       
    39 
       
    40 #include "mfsmaileventobserver.h"
       
    41 #include "mfsmailrequestobserver.h"
       
    42 #include "mfsmailboxsearchobserver.h"
       
    43 
       
    44 // CONSTANTS
       
    45 #define KIPSSosImap4PluginUid      0x2000e53f
       
    46 #define KIPSSosPop3PluginUid       0x2000e53e
       
    47 
       
    48 const TUint KTenSecondsTime(10);
       
    49 const TUint KHalfMinuteTime(30);
       
    50 const TUint KOneMinuteTime(60);
       
    51 
       
    52 // MACROS
       
    53 #define TEST_CLASS_VERSION_MAJOR 0
       
    54 #define TEST_CLASS_VERSION_MINOR 0
       
    55 #define TEST_CLASS_VERSION_BUILD 0
       
    56 #define DELANDNULL( a ) { if( a ) { delete a; a = NULL; } }
       
    57 
       
    58 class CPopImapProfileTester;
       
    59 class CTimeoutTimer;
       
    60 class CFSMailClient;
       
    61 class CFSMailBox;
       
    62 class CActiveSchedulerWait;
       
    63 
       
    64 enum TWaitingState
       
    65     {
       
    66     EWaitingNothing = 0,
       
    67     EWaitingEvent,
       
    68     EWaitingResponse,
       
    69     EWaitingSearchComplete,
       
    70     };
       
    71 
       
    72 class TAccountSetting
       
    73     {
       
    74 public:
       
    75     //Other TInt values
       
    76     // amount of accounts configured  
       
    77     TInt iAccountsConfigured;
       
    78     // maximum accounts reached 1 = yes, 0 = no
       
    79     TInt iMaxAccountsReached;
       
    80     // protocol 0= POP, 1= IMAP  //-->imap
       
    81     TInt iProtocolIndicator;
       
    82     // Incoming security auth 0 = no, 1 = yes
       
    83     TInt iIncomingSecurityAuth;
       
    84     // Incoming security protocol (0 = OFF, 1 = StartTLS, 2 = SSL/TLS)
       
    85     TInt iIncomingSecurityProtocol;
       
    86     // Outgoing security auth 0 = no, 1 = yes
       
    87     TInt iOutgoingSecurityAuth;
       
    88     // Outgoing security protocol (0 = OFF, 1 = StartTLS, 2 = SSL/TLS)
       
    89     TInt iOutgoingSecurityProtocol;
       
    90     // Operators security auth 0 = no, 1 = yes
       
    91     TInt iOperatorSecurityAuth;
       
    92     // Operators Security protocol (0 = OFF, 1 = StartTLS, 2 = SSL/TLS)
       
    93     TInt iOperatorSecurityProtocol;
       
    94     // Operators outgoing port number
       
    95     TInt iOperatorPort;
       
    96 
       
    97     TInt iIncomingPort;
       
    98     TInt iOutgoingPort;
       
    99 
       
   100     TBuf<10> iAccountType;
       
   101     TBuf<50> iEmailAddress;
       
   102     TBuf<50> iUserName;
       
   103     TBuf<100> iPassWord;
       
   104     TBuf<50> iIncomingServer;
       
   105     TBuf<50> iOutgoingServer;
       
   106     TBuf<20> iMailboxName;
       
   107 
       
   108     /****
       
   109      * Using the default value
       
   110      */
       
   111     TBuf<5> iWizardAccountType;
       
   112     TBuf<2> iOperatorOutgoingServer;
       
   113     TBool iHideUserNameInSetting;
       
   114     TBuf<10> iAccessPoint;
       
   115     };
       
   116 
       
   117 NONSHARABLE_CLASS(CPopImapProfileTester) : public CScriptBase,
       
   118         public MFSMailEventObserver,
       
   119         public MFSMailRequestObserver,
       
   120         public MFSMailBoxSearchObserver,
       
   121         public MTimeoutObserver
       
   122 
       
   123     {
       
   124 public:
       
   125     // Constructors and destructor
       
   126 
       
   127     /**
       
   128      * Two-phased constructor.
       
   129      */
       
   130     static CPopImapProfileTester* NewL(CTestModuleIf& aTestModuleIf);
       
   131 
       
   132     /**
       
   133      * Destructor.
       
   134      */
       
   135     virtual ~CPopImapProfileTester();
       
   136 
       
   137 public:
       
   138     // New functions
       
   139 
       
   140 
       
   141 public:
       
   142     // Functions from base classes
       
   143 
       
   144     /**
       
   145      * From CScriptBase Runs a script line.
       
   146      * @since 
       
   147      * @param aItem Script line containing method name and parameters
       
   148      * @return Symbian OS error code
       
   149      */
       
   150     virtual TInt RunMethodL(CStifItemParser& aItem);
       
   151 
       
   152     // from MFSMailEventObserver
       
   153     void EventL(TFSMailEvent aEvent, TFSMailMsgId aMailbox, TAny* aParam1,
       
   154             TAny* aParam2, TAny* aParam3);
       
   155 
       
   156     // from MFSMailRequestObserver
       
   157     void RequestResponseL(TFSProgress aEvent, TInt aRequestId);
       
   158 
       
   159     // from MFSMailBoxSearchObserver
       
   160     void MatchFoundL(CFSMailMessage* aMatchMessage);
       
   161     void SearchCompletedL();
       
   162     void ClientRequiredSearchPriority(TInt *apRequiredSearchPriority);
       
   163 
       
   164     //from MTimeoutObserver
       
   165     void TimeoutNotify();
       
   166 
       
   167 protected:
       
   168     // New functions
       
   169 
       
   170 
       
   171 protected:
       
   172     // Functions from base classes
       
   173 
       
   174 
       
   175 private:
       
   176 
       
   177     /**
       
   178      * C++ default constructor.
       
   179      */
       
   180     CPopImapProfileTester(CTestModuleIf& aTestModuleIf);
       
   181 
       
   182     /**
       
   183      * By default Symbian 2nd phase constructor is private.
       
   184      */
       
   185     void ConstructL();
       
   186 
       
   187     /**
       
   188      * Frees all resources allocated from test methods.
       
   189      * @since 
       
   190      */
       
   191     void Delete();
       
   192 
       
   193     // _______________________ Test Methods __________________________
       
   194 
       
   195     // Ordinary test cases
       
   196     TInt SetupAccountL(CStifItemParser& /* aItem */);
       
   197     TInt GoOnlineL(CStifItemParser& /* aItem */);
       
   198     TInt GoOfflineL(CStifItemParser& /* aItem */);
       
   199     TInt RefreshNowL(CStifItemParser& /* aItem */);
       
   200     TInt CancelSyncL(CStifItemParser& /* aItem */);
       
   201     TInt ListStandardFoldersL(CStifItemParser& /* aItem */);
       
   202 
       
   203     // list folders from all mailboxes
       
   204     TInt ListFoldersL(CStifItemParser& /* aItem */);
       
   205     // lists  messages in folders of each found mailbox
       
   206     TInt ListMessagesL(CStifItemParser& /* aItem */);
       
   207     // Fetch the specified messages
       
   208     TInt FetchMessagesL(CStifItemParser& /* aItem */);
       
   209     // Send out a mail
       
   210     TInt SendMessageL(CStifItemParser& /* aItem */);
       
   211     // Basic operation of user for creating email
       
   212     TInt BasicMsgOperationsL(CStifItemParser& /* aItem */);
       
   213     // Copy or move message between folders
       
   214     TInt CopyMoveMsgsL(CStifItemParser& /* aItem */);
       
   215     // Search data from messages
       
   216     TInt SearchL(CStifItemParser& /* aItem */);
       
   217     // Add a attachment to new email
       
   218     TInt AttachmentHandlingL(CStifItemParser& /* aItem */);
       
   219     // check if the mailbox is a nokia branding one.
       
   220     TInt BrandingL(CStifItemParser& /* aItem */);
       
   221     // Delete message from Inbox
       
   222     TInt DeleteMsgsL(CStifItemParser& /* aItem */);
       
   223     //remove mailbox
       
   224     TInt RemoveAccountL(CStifItemParser& /* aItem */);
       
   225 
       
   226     /**
       
   227      * Method used to log version of test class
       
   228      */
       
   229     void SendTestClassVersion();
       
   230 
       
   231     CFSMailMessage* CreatePlainTextMsgL(const TDesC& aSubject,
       
   232             const TDesC& aMsgText);
       
   233     TInt MoveMessageToFolderL(CFSMailMessage& aMsg, TFSFolderType aFolderType);
       
   234 
       
   235     TInt GetMessagesFromFolderL(RPointerArray<CFSMailMessage>& aMessages,
       
   236             CFSMailFolder* aFolder, TFSMailDetails aDet,
       
   237             TFSMailSortField aSort, TUint aCount);
       
   238 
       
   239     TInt WaitForEvent(TFSMailEvent aWaitedEvent, TAny *aEventParam1 = NULL,
       
   240             TAny *aEventParam2 = NULL, TInt aTimeout = 60);
       
   241 
       
   242     TInt WaitForResponse(TFSProgress::TFSProgressStatus aWaitedResponse,
       
   243             TInt aTimeout = 60);
       
   244 
       
   245     void OpComplete();
       
   246 
       
   247     TInt InitMailboxL();
       
   248 
       
   249     TInt DeleteTestMsgL(TDesC& aFolderName);
       
   250     TInt ReadAccountSettings(TAccountSetting& aAccountSetting);
       
   251 
       
   252     TInt WriteToWizardCRL(TAccountSetting aAccountSetting);
       
   253 
       
   254     void LogEvent(const TDesC& aLogText, TFSMailEvent aEvents, TAny* aParam1,
       
   255             TAny* aParam2, TAny* /*aParam3*/);
       
   256     void LogTFSProgress(const TDesC& aLogText,
       
   257             const TFSProgress::TFSProgressStatus aProgress, TInt aReqId);
       
   258 
       
   259     void LogTSSMailSyncState(const TDesC& aLogText,
       
   260             const TSSMailSyncState aState);
       
   261 
       
   262     TInt DoSearch(const RPointerArray<TDesC>& aSearchStrings,
       
   263             const TFSMailSortCriteria& aSortCriteria, TInt aTimeout);
       
   264 
       
   265     TInt SendMsgL(CFSMailMessage& aMsg, const TDesC &aSubject,
       
   266             TFSMailMsgId& aGotMsgId);
       
   267 
       
   268     TInt GetFolderNameFromId(TFSMailMsgId aFolderId, TDes& aFolderName);
       
   269 
       
   270     TFSMailMsgId GetFolderIdFromName(const TDesC& aFolderName);
       
   271 
       
   272     TBool ParseEventParams(TAny *aEventParam1, TAny *aEventParam2);
       
   273 
       
   274     CFSMailFolder* FindFolder(const TDesC& aFolderName);
       
   275 
       
   276 public:
       
   277     // Data
       
   278 
       
   279 
       
   280 protected:
       
   281     // Data
       
   282 
       
   283 
       
   284 private:
       
   285     // Data
       
   286     TBool iEventSynchronousCall;
       
   287     CFSMailClient* iMailClient;
       
   288 
       
   289     CFSMailBox* iIPSMailbox;
       
   290 
       
   291     //variables for mfsMailEvent
       
   292     TBool iTimeout;
       
   293     TInt iErr;
       
   294 
       
   295     CTimeoutTimer* iTimeoutTimer;
       
   296     TFSMailEvent iCurrWaitedEvent;
       
   297     TAny* iEventParam1;
       
   298     TAny* iEventParam2;
       
   299 
       
   300     TFSProgress::TFSProgressStatus iCurrWaitedResponse;
       
   301 
       
   302     //OWN: Active scheduler wait and Cb received indication
       
   303     CActiveSchedulerWait* iWait;
       
   304     TWaitingState iWaitingState;
       
   305     TFSMailMsgId iPluginId;
       
   306 
       
   307     //checking status of searching
       
   308     TBool iSearchOngoing;
       
   309     TInt iSearchMatches;
       
   310 
       
   311 public:
       
   312     // Friend classes
       
   313 
       
   314 protected:
       
   315     // Friend classes
       
   316 
       
   317 private:
       
   318     // Friend classes
       
   319 
       
   320 
       
   321     };
       
   322 
       
   323 #endif      // POPIMAPPROFILETESTER_H
       
   324 // End of File