email/imum/Utils/Inc/EmailUtils.H
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *       Static functions for imum
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __EMAILUTILS_H__
       
    21 #define __EMAILUTILS_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <eikdialg.h>
       
    25 #include <msvapi.h> // CMsvOperation
       
    26 #include <miutmsg.h> // CImEmailMessage
       
    27 #include <Muiumsginfo.h>
       
    28 #include <AlwaysOnlineManagerClient.h>
       
    29 #include <ConeResLoader.h>  // RConeResourceLoader
       
    30 #include <mtmuibas.h>
       
    31 #include "MuiuDynamicHeader.h"
       
    32 #include "ImumMboxSettingsCtrl.h"
       
    33 #include "ImumMboxData.h"
       
    34 #include "ImumDaSettingsKeys.h"
       
    35 
       
    36 // CONSTANTS
       
    37 enum TIMASMailboxType
       
    38     {
       
    39     EMailboxPOP3,
       
    40     EMailboxIMAP4
       
    41     };
       
    42 
       
    43 enum TIMASMailSecurity
       
    44     {
       
    45     EImumSecurityOn = 0,
       
    46     EImumSecurityMs,
       
    47     EImumSecurityOff
       
    48     };
       
    49 
       
    50 enum TIMASMailPort
       
    51     {
       
    52     EIMASPortDefault = 0,
       
    53     EIMASPortUserDefined
       
    54     };
       
    55 
       
    56 enum TFetchAttachments
       
    57     {
       
    58     EFetchAttachments = 0,
       
    59     EFetchBodyOnly
       
    60     };
       
    61 
       
    62 enum TSendOption
       
    63     {
       
    64     EImmediately = 0,
       
    65     EOnNextConnection
       
    66     };
       
    67 
       
    68 enum TIMASOnOff
       
    69     {
       
    70     EIMASOn = 0,
       
    71     EIMASOff
       
    72     };
       
    73 
       
    74 enum TIMASYesNo
       
    75     {
       
    76     EIMASYes = 0, // yes is 0 because it is ui specified so that 'yes' options is first in the list
       
    77     EIMASNo
       
    78     };
       
    79 
       
    80 enum TIMASFetchHeaders
       
    81     {
       
    82     EIMASFetchAll = 0,
       
    83     EIMASFetchUserDefined,
       
    84     EIMASFetchPastNumberOfDays
       
    85     };
       
    86 
       
    87 /**
       
    88 * User defined KB if higher that 0, so if some KB has been
       
    89 * set, the value being bigger that 0 already tells us that
       
    90 * the setting is userdefined
       
    91 */
       
    92 enum TIMASFetchedPartsMapping
       
    93     {
       
    94     EIMASMapHeadersOnly = -2,
       
    95     EIMASMapFullBody = -1,
       
    96     EIMASMapUserDefinedKB = 0
       
    97     };
       
    98 
       
    99 enum TIMASFetchedPartsButtons
       
   100     {
       
   101     EIMASHeadersOnly = 0,
       
   102     EIMASLessThan,
       
   103     EIMASFullBody, // only for IMAP
       
   104     EIMASBodyAndAttachments
       
   105     };
       
   106 
       
   107 enum TIMSAoInterval
       
   108     {
       
   109     EIMASAoInterval5Min = 0,
       
   110     EIMASAoInterval15Min,
       
   111     EIMASAoInterval30Min,
       
   112     EIMASAoInterval1Hour,
       
   113     EIMASAoInterval2Hours,
       
   114     EIMASAoInterval4Hours,
       
   115     EIMASAoInterval6Hours
       
   116     };
       
   117 
       
   118 enum TIMASAoHoursButtons
       
   119     {
       
   120     EIMASAoHoursAll = 0,
       
   121     EIMASAoHoursUserDefined
       
   122     };
       
   123 
       
   124 const TInt KIMASDefaultPortImap4        = 143;
       
   125 const TInt KIMASDefaultSecurityPortImap4 = 993;
       
   126 const TInt KIMASDefaultPortPop3         = 110;
       
   127 const TInt KIMASDefaultSecurityPortPop3 = 995;
       
   128 const TInt KIMASDefaultPortSmtp         = 25;
       
   129 const TInt KIMASDefaultSecurityPortSmtp = 465;
       
   130 const TInt KImumMaxMailboxes            = 6;
       
   131 const TInt KIMASMaxAccounts             = 255;
       
   132 
       
   133 const TInt KIMASAoInterval5Min   = 5;
       
   134 const TInt KIMASAoInterval15Min  = 15;
       
   135 const TInt KIMASAoInterval30Min  = 30;
       
   136 const TInt KIMASAoInterval1Hour  = 60;
       
   137 const TInt KIMASAoInterval2Hours = 120;
       
   138 const TInt KIMASAoInterval4Hours = 240;
       
   139 const TInt KIMASAoInterval6Hours = 360;
       
   140 
       
   141 // MACROS
       
   142 // DATA TYPES
       
   143 // FUNCTION PROTOTYPES
       
   144 // FORWARD DECLARATIONS
       
   145 class CImEmailMessage;
       
   146 class CEikonEnv;
       
   147 class CImBaseEmailSettings;
       
   148 class CContactItemFieldSet;
       
   149 class CImIAPPreferences;
       
   150 class CRepository;
       
   151 class CImImap4Settings;
       
   152 class CImPop3Settings;
       
   153 class CImSmtpSettings;
       
   154 class CImumInternalApi;
       
   155 
       
   156 // CLASS DECLARATION
       
   157 
       
   158 /**
       
   159 *  Static functions for imum
       
   160 *  ?other_description_lines
       
   161 *
       
   162 *  @lib ?library
       
   163 *  @since S60 3.0
       
   164 */
       
   165 class MsvEmailMtmUiUtils
       
   166     {
       
   167     public:
       
   168 
       
   169         /**
       
   170         * Check there is enough disk space on the specified drive to
       
   171         * fetch a message of aMsgSize bytes.
       
   172         * If not, display a message and return EFalse.
       
   173         */
       
   174         IMPORT_C static TBool CheckAvailableDiskSpaceForDownloadL(
       
   175             TInt aMsgSize,
       
   176             CEikonEnv& aEikonEnv,
       
   177             CMsvSession& aSession );
       
   178 
       
   179         /**
       
   180         * Do a message server entry copy or move.
       
   181         */
       
   182         IMPORT_C static CMsvOperation* DoCEntryCopyMoveL(
       
   183             CMsvEntry& aEntry,
       
   184             const CMsvEntrySelection& aSel,
       
   185             TMsvId aTargetId,
       
   186             TRequestStatus& aCompletionStatus,
       
   187             TBool aCopy);
       
   188 
       
   189         /**
       
   190         * Strip message entries that have their
       
   191         * 'Complete' flag set from a CMsvEntrySelection.
       
   192         */
       
   193         IMPORT_C static CMsvEntrySelection* StripCompleteEntriesLC(
       
   194             const CMsvEntry& aParent,
       
   195             const CMsvEntrySelection& aSelection);
       
   196 
       
   197         /**
       
   198         * Strip message entries that have their 'Deleted'
       
   199         * flag set from a CMsvEntrySelection.
       
   200         */
       
   201         IMPORT_C static CMsvEntrySelection* StripDeletedEntriesLC(
       
   202             const CMsvEntry& aParent,
       
   203             const CMsvEntrySelection& aSelection);
       
   204 
       
   205         /**
       
   206         * Sets fields in the message info data array using
       
   207         * TMsvEntry and CImHeader information;
       
   208         * the TDes parameters are needed so that the strings
       
   209         * have persisted memory to
       
   210         * live in since the info data elements are all TPtrs
       
   211         */
       
   212         IMPORT_C static void SetMessageInfoDataLCCCCC(
       
   213             TMsgInfoMessageInfoData& aInfoData,
       
   214             CBaseMtm& aMtm,
       
   215             CCoeEnv& aEnv,
       
   216             TDes& dateBuf,
       
   217             TDes& timeBuf,
       
   218             TDes& sizeBuf,
       
   219             TDes& priorityBuf );
       
   220 
       
   221         /**
       
   222         * Sets fields in the message info data array using
       
   223         * TMsvEntry and CImHeader information;
       
   224         * the TDes parameters are needed so that the strings have
       
   225         * persisted memory to live in since the info data elements
       
   226         * are all TPtrs.
       
   227         * If entry has ReadStoreL this pushes 4 items to cleanup stack.
       
   228         * If ReadStoreL does not exist then only 2 items are pushed
       
   229         * to cleanup stack
       
   230         */
       
   231         IMPORT_C static TBool SetMessageInfoDataLCC(
       
   232             TMsgInfoMessageInfoData& aInfoData,
       
   233             CBaseMtm& aMtm,
       
   234             CCoeEnv& aEnv,
       
   235             TDes& dateBuf,
       
   236             TDes& timeBuf,
       
   237             TDes& sizeBuf,
       
   238             TDes& priorityBuf );
       
   239 
       
   240         /**
       
   241         * Replaces tab and enter characters by spaces using
       
   242         * AknTextUtils::ReplaceCharacters
       
   243         */
       
   244         static void ReplaceCharacters( TDes& aText );
       
   245         
       
   246         /**
       
   247         * Disconnect mailbox if it is tried to be
       
   248         * edited when connection is on.
       
   249         * aService is Imap4 or Pop3 service
       
   250         */
       
   251         IMPORT_C static TBool DisconnectMailboxL(
       
   252             const TMsvEntry& aService,
       
   253             CMsvSession& aSession );
       
   254 
       
   255         /**
       
   256         * Checks offline mode flag
       
   257         */
       
   258         IMPORT_C static TBool DoOfflineChecksL( TMsvId aService );
       
   259 
       
   260         /**
       
   261         * Removes 'Deleted' flag synchronoushly from single entry
       
   262         * @since S60 2.6
       
   263         * @param aBaseMtm:    client mtm (Imap4 or Pop3 in this case)
       
   264         * @param aFunctionId: 'remove delete flag' function id
       
   265         * @param aEntryId:    id of the entry
       
   266         * @return standard error code
       
   267         */
       
   268         IMPORT_C static TInt RemoveOfflineDeleteL(
       
   269             CBaseMtm& aBaseMtm,
       
   270             TInt aFunctionId,
       
   271             TMsvId aEntryId );
       
   272 
       
   273         /**
       
   274         * Function reserve disk space for deletion
       
   275         * @since S60 3.0
       
   276         * @param aFileSession, File session to be used for operation
       
   277         * @param aDriveNo, Drive where the space is needed
       
   278         * @param aSize, Amount of space needed
       
   279         * @return KErrNone, when reservation succesful
       
   280         */
       
   281         IMPORT_C static TInt AcquireDiskSpace(
       
   282             RFs& aFileSession,
       
   283             const TInt aDriveNo,
       
   284             const TInt aSize );
       
   285 
       
   286         /**
       
   287         * Sends specified message to mailbox
       
   288         * @since S60 3.0
       
   289         * @param aCommand, Command to be send to mailbox
       
   290         * @param aMailboxId, Mailbox the command is directed to
       
   291         */
       
   292         IMPORT_C static void SendAOCommandL(
       
   293             const TAlwaysOnlineServerAPICommands aCommand,
       
   294             TMsvId aMailboxId );
       
   295 
       
   296         /**
       
   297         *
       
   298         * @since S60 3.0
       
   299         */
       
   300         static TUint32 MsvId2AccountIdL(
       
   301             CMsvSession& aMsvSession,
       
   302             const TMsvId aMailboxId );
       
   303 
       
   304         /**
       
   305         * Creates central repository connection
       
   306         * @since S60 3.0
       
   307         * @param aRepository, Repository object to be created
       
   308         * @param aRepositoryUid, Uid to be used to create the session
       
   309         */
       
   310         static void CreateCenRepConnectionL(
       
   311             CRepository*& aRepository,
       
   312             TUid aRepositoryUid );
       
   313 
       
   314         /**
       
   315         *
       
   316         * @since S60 3.0
       
   317         */
       
   318         static void StoreSecuritySettings(
       
   319             CImBaseEmailSettings& aSettings,
       
   320             const TIMASMailSecurity& aSecurity );
       
   321 
       
   322         /**
       
   323         *
       
   324         * @since S60 3.0
       
   325         */
       
   326         static void StoreSecuritySettings(
       
   327             CImBaseEmailSettings& aSettings,
       
   328             const TImumDaSettings::TSecurityValues& aSecurity );
       
   329             
       
   330         /**
       
   331          * 
       
   332          *
       
   333          * @since S60 v3.2
       
   334          * @param 
       
   335          * @return 
       
   336          */
       
   337         static TInt RestoreSecuritySettings(
       
   338             const CImBaseEmailSettings& aSettings );
       
   339             
       
   340         /**
       
   341         *
       
   342         * @since S60 3.0
       
   343         */
       
   344         static TUint32 GetDefaultSecurityPort(
       
   345             const TIMASMailSecurity aSecurity,
       
   346             const TBool aIncoming,
       
   347             const TBool aIsImap4 = EFalse );
       
   348 
       
   349 
       
   350         /**
       
   351         * Tell to Ncn that there might be new messages to show
       
   352         * @since S60 3.0
       
   353         */
       
   354         IMPORT_C static void CallNewMessagesL( const TMsvId aMailboxId );
       
   355 
       
   356         /**
       
   357         * Checks the number of always online boxes
       
   358         * @since S60 3.0
       
   359         */
       
   360         static TBool CheckActiveAOLimitsL(
       
   361             CImumInternalApi& aEmailApi,            
       
   362             const TMsvId aMailboxId );
       
   363 
       
   364         /**
       
   365         *
       
   366         * @since S60 3.0
       
   367         */
       
   368         static TUint32 GetAccountId(
       
   369             const CImumMboxData& aAccountSettings );
       
   370 
       
   371         /**
       
   372         *
       
   373         * @since S60 3.0
       
   374         */
       
   375         IMPORT_C static void LoadResourceFileL(
       
   376             RConeResourceLoader& aResourceLoader );
       
   377 
       
   378         /**
       
   379         *
       
   380         * @since S60 3.0
       
   381         */
       
   382         static void GetMailboxName(
       
   383             TDes& aDest,
       
   384             CMsvSession& aMsvSession,
       
   385             TMsvId aMailboxId );
       
   386 
       
   387         /**
       
   388         *
       
   389         * @since S60 3.0
       
   390         */
       
   391         IMPORT_C static void CreateConnectingToText(
       
   392             TDes& aDest,
       
   393             CMsvSession& aMsvSession,
       
   394             TMsvId aMailboxId );
       
   395 
       
   396         
       
   397         /**
       
   398         *
       
   399         * @since S60 3.1
       
   400         */
       
   401         static void CheckAccountNameL(     
       
   402             CImumInternalApi& aMailboxApi,       
       
   403             TDes& aAccountName,
       
   404             const TMsvId aOwningMailbox,   
       
   405             const TBool& aGenerate = EFalse );       
       
   406 
       
   407         /**
       
   408         * @since S60 5.0
       
   409         * Strips tab and enter characters from text
       
   410         * @param aText, descriptor to operate on
       
   411         */
       
   412         static void StripCharacters( TDes& aText );
       
   413             
       
   414             
       
   415     private:
       
   416 
       
   417         /**
       
   418         *
       
   419         */
       
   420         static HBufC* TurnArrayIntoCommaSeparatedStringLC(
       
   421             CDesCArray& aTextArray );
       
   422                     
       
   423         /**
       
   424         *
       
   425         * @since S60 3.1
       
   426         */
       
   427         static TInt ContinueRenamingL( 
       
   428             CImumInternalApi& aMailboxApi,
       
   429             TInt& aResult,
       
   430             TDes& aAccountName, 
       
   431             const TMsvId aOwningMailbox,
       
   432             const TInt aNumber,
       
   433             const CMsvEntry& aAccount,
       
   434             const TBool aGenerate );            
       
   435 
       
   436         /**
       
   437         *
       
   438         * @since S60 3.1
       
   439         */
       
   440         static TInt ChangeAccountNameL(
       
   441             const TDesC& aOriginalAccountName,
       
   442             TDes& aAccountName,
       
   443             const TInt aNumber );
       
   444             
       
   445         /**
       
   446         *
       
   447         * @since S60 3.1
       
   448         */
       
   449         static TBool IsAccountNameUsedL(
       
   450             CImumInternalApi& aMailboxApi,
       
   451             TInt& aResult,
       
   452             const TDesC& aAccountName,
       
   453             const TMsvId aOwningMailbox,
       
   454             const CMsvEntry& aAccount );            
       
   455         
       
   456         /**
       
   457         * 
       
   458         * @since S60 3.2
       
   459         */    
       
   460         static void GetPriorityString(
       
   461             const TMsvEntry& aEntry,
       
   462             CCoeEnv& aEnv,
       
   463             TDes& aPriorityBuf );                      
       
   464     };
       
   465 
       
   466 #endif
       
   467