messagingapp/msgutils/unieditorutils/editorgenutils/inc/UniEditorGenUtils.h
changeset 25 84d9eb65b26f
child 27 e4592d119491
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
       
     1 /*
       
     2  * Copyright (c) 2009 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: General utilities for unified editor and plugin
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef __UNIEDITOR_GEN_UTILS_H__
       
    19 #define __UNIEDITOR_GEN_UTILS_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <e32const.h>
       
    24 #include "muiuutilsdefines.h"
       
    25 #include "convergedmessage.h"
       
    26 #include "MsgMedia.hrh"
       
    27 
       
    28 const TInt KDefaultMaxSmsSize = 10;
       
    29 // Length of one 7bit normal sms
       
    30 const TInt KFirstNormalSmsLength = 160;
       
    31 // Length of one unicode sms
       
    32 const TInt KFirstUnicodeSmsLength = 70;
       
    33 // Submsg length for normal 7bit sms
       
    34 const TInt KNormalConcatenationInterval = 153;
       
    35 // Submsg length for unicode sms
       
    36 const TInt KUnicodeConcatenationInterval = 67;
       
    37 
       
    38 const TInt KMaxSmsSizeByStandard = 30;
       
    39 const TInt KDefaultSmsRecipients = 20;
       
    40 const TInt KDefaultMmsRecipients = 100;
       
    41 const TInt KDefaultMaxSize = 300 * 1024;
       
    42 const TInt KEstimatedMmsSmilHeaderSize = 2.4 * 1024; // 1Kb buffer for mime headers + 1.4Kb for smil  
       
    43 const TInt KEstimatedMimeHeaderSize = 1400; 
       
    44 
       
    45 class CMsgMediaResolver;
       
    46 
       
    47 // CLASS DECLARATION
       
    48 class MUIU_UTILS_EXPORT UniEditorGenUtils
       
    49     {
       
    50 
       
    51       public:
       
    52 
       
    53       explicit UniEditorGenUtils();
       
    54 
       
    55       ~UniEditorGenUtils();
       
    56 
       
    57       public:
       
    58         /**
       
    59         * Returns the current Email-over-Sms settings
       
    60         * @param aSmsc
       
    61         * @param aDestinationAddress
       
    62         * @param aModifiable
       
    63         * @return                   Symbian OS standard error code
       
    64         */
       
    65         TInt ReadEmailOverSmsSettingsL(
       
    66             TDes& aSmsc,
       
    67             TDes& aDestinationAddress,
       
    68             TBool& aModifiable );
       
    69 
       
    70         /**
       
    71         * Writes the current Email-over-Sms settings to file
       
    72         * @param aSmsc service centre, used for Email over Sms
       
    73         * @param aDestinationAddress service number, used for Email over Sms
       
    74         * @param aModifiable to check if user is allowed to modify setting
       
    75         * @return                   Symbian OS standard error code
       
    76         */
       
    77         TInt WriteEmailOverSmsSettingsL(
       
    78             const TDes& aSmsc,
       
    79             const TDes& aDestinationAddress,
       
    80             const TBool& aModifiable );
       
    81 
       
    82         /**
       
    83         * Checks if phone is in offline mode or not
       
    84         * Make sure that offline feature has been checked
       
    85         * using feature manager
       
    86         * @return ETrue if phone is in offline mode, otherwise EFalse.
       
    87         */
       
    88         TBool IsPhoneOfflineL();
       
    89 
       
    90         /**
       
    91          * Checks if email addresses are supported over sms message type
       
    92          * using feature manager
       
    93          * @return ETrue if emailoversms is suppoted
       
    94          */
       
    95         TBool AcceptEmailAddressesL();
       
    96 
       
    97         /**
       
    98          * Checks if the given addresslist contains a valid email address
       
    99          * @param addr converged message address list
       
   100          * @return ETrue if list contains a valid email address
       
   101          */
       
   102         TBool VerifyEmailAddressesL( ConvergedMessageAddressList addr);
       
   103         
       
   104        /** 
       
   105         * Gets byte-size of UTF8 formatted text
       
   106         * @param aText
       
   107         * @return Size of text in bytes
       
   108         */
       
   109         TInt UTF8Size( QString aText );
       
   110         
       
   111         /**
       
   112          * Get maximum recipient count for sms from feature manager
       
   113          * @return max recipient count
       
   114          */
       
   115         TInt MaxSmsRecipientsL();
       
   116         
       
   117         /**
       
   118          * Get maximum recipient count for mms from feature manager
       
   119          * @return max recipient count
       
   120          */
       
   121         TInt MaxMmsRecipientsL();
       
   122         
       
   123         /**
       
   124          * Checks if a given address string is a valid email address
       
   125          * @param addr address string
       
   126          * @return ETrue if addr is valid email address
       
   127          */
       
   128         TBool IsValidEmailAddress( QString addr );
       
   129         
       
   130         /**
       
   131          * Calculates the size of the given message
       
   132          * @param msg ConvergedMessage
       
   133          * @return size of the converged message
       
   134          */
       
   135         TInt CalculateMsgSize(ConvergedMessage& msg);
       
   136 
       
   137         /**
       
   138          * Get the maximum size allowed for mms
       
   139          * using feature manager
       
   140          * @return max mms size
       
   141          */
       
   142         TInt MaxMmsMsgSizeL();
       
   143         
       
   144         /**
       
   145          * get file's size and mimetype info
       
   146          * @param filePath IN path of file
       
   147          * @param size OUT size of the given file
       
   148          * Size includes filesize + max mime headers size
       
   149          * @param mimetype OUT mimetype of the given file
       
   150          * @param mediaType OUT media-type grouping of mimetype
       
   151          */
       
   152         void getFileInfoL(QString filePath,
       
   153                         int& size,
       
   154                         QString& mimetype,
       
   155                         TMsgMediaType& mediaType);
       
   156         
       
   157         /**
       
   158          * get max sms size limit from feature manager
       
   159          * @param unicode if set to true limits 
       
   160          *                 will be based on Unicode charset
       
   161          * @return max sms size limit
       
   162          */
       
   163         int MaxSmsMsgSizeL(bool unicode=false);
       
   164         
       
   165         /**
       
   166          * Convert digits from any digit format to another format eg. from
       
   167          * european digits to arabic-indic digits.
       
   168          * @param aDes        Parameter to change. It can contain digits
       
   169          *                    from several digit types.
       
   170          * @param aDigitType  Destination digit type.
       
   171          */
       
   172         void ConvertDigitsTo( TDes& aDes, TDigitType aDigitType );
       
   173         
       
   174         /**
       
   175          * Identifies the digit format
       
   176          * @param ch    digit, whose format is to be recognized
       
   177          * @return      digit format
       
   178          */
       
   179         TChar NumberToBase(TChar ch);
       
   180 
       
   181         /**
       
   182          * Replace all control chars with a single character,
       
   183          * usually a whitespace.
       
   184          * @param   aDes         Parameter to change
       
   185          * @param   aCharacters  A set of characters to remove
       
   186          * @param   aReplacement A character used as replacement
       
   187          */
       
   188         void ReplaceCharacters(TDes &aDes, const TDesC &aChars, TChar aReplacement);
       
   189 
       
   190       private:
       
   191           /**
       
   192            * get sms character limits from feature manager
       
   193            * @param singlePartLength length of one part
       
   194            * @param concatenatedPartLength total length over all parts
       
   195            * @param unicode if set to true limits 
       
   196            *                 will be based on Unicode charset
       
   197            */
       
   198           void getSmsCharacterLimits(int& singlePartLength, 
       
   199               int& concatenatedPartLength,
       
   200               bool unicode);
       
   201           
       
   202           /**
       
   203            * get the maximum number of parts for sms
       
   204            * using feature manager
       
   205            * @return max number of parts for the sms
       
   206            */
       
   207           int absoluteMaxSmsPartsL();
       
   208           
       
   209           /**
       
   210            * get the character limit for sms
       
   211            * using feature manager
       
   212            * @return sms character limit 
       
   213            */
       
   214           int absoluteMaxSmsCharactersL();
       
   215           
       
   216       private: //data
       
   217           /**
       
   218            * Read only once for optimization purpose
       
   219            * Max number of parts allowed for sms msgs
       
   220            */
       
   221           int mAbsMaxConcatenatedSms;
       
   222           
       
   223           /**
       
   224            * Read only once for optimization purpose
       
   225            * Character limit for sms msgs
       
   226            */
       
   227           int mAbsMaxSmsCharacters;
       
   228           
       
   229           /**
       
   230            * Read only once for optimization purpose
       
   231            * MMS size limit
       
   232            */
       
   233           int mMaxMmsSize;
       
   234     };
       
   235 
       
   236 
       
   237 #endif //__UNIEDITOR_GEN_UTILS_H__
       
   238 
       
   239 // End of file