diff -r 4697dfb2d7ad -r 238255e8b033 messagingapp/smartmessaging/ringbc/inc/ringbctoneconverter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingapp/smartmessaging/ringbc/inc/ringbctoneconverter.h Fri Apr 16 14:56:15 2010 +0300 @@ -0,0 +1,280 @@ +/* +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* For checking the validity of Smart messaging ringing tone and for +* ripping the ringing tone title from binary data. +* +*/ + + +#ifndef __RINGBCTONECONVERT_H +#define __RINGBCTONECONVERT_H + +// INCLUDES +#include +#include "NsmRingTone.h" + +// FORWARD DECLARATIONS +NONSHARABLE_STRUCT( TInstruction ) + { + TInt iValue; + TInt iDuration; + TInt iDurspecifier; + TInt iScale; + TInt iStyle; + }; + +// CONSTANTS + +NONSHARABLE_STRUCT( TCompData ) + { + TInt iTempo; + CArrayFix* iSongData; + TInt iSongLength; + TBuf iSongTitle; + }; + +// CLASS DECLARATION +NONSHARABLE_CLASS( RingBCNSMConverter ) : public CBase + { + public: // New functions + + /** + * Creates an instance of CRingBCNSMConverter and returns it. + */ + static RingBCNSMConverter* NewL(); + + protected: + /** + * Second-phase constructor. + */ + void ConstructL(); + + /** + * Default C++ constructor. + */ + RingBCNSMConverter(); + + public: + /** + * Destructor. + */ + ~RingBCNSMConverter(); + + public: // New methods + + /** + * Converts a Nokia Smart Messaging stream into TCompData. + * + * Smart Messaging: ::=+ + * ::= + * + | + * + * ::='binary[00000001..11111111], indicates + * how many command parts there are in the command.' + * ::='binary[00000000]. This indicates the end + * of the ringing tone programming language.' + + * @param aFileData The NSM stream. + * @return The song. + */ + TCompData* ConvertNsmToCompDataL( const TDesC8& aFileData ); + + /** + * Sets the title of the song. + * + * @param aFileName The new title of the song. + * @return Error code + */ + void SetTitle( const TDesC& aFileName ); + + /** + * Returns a pointer to the title of the ring tone. + * + * Usage: + * 1) Create converter(converter = CRingBCNSMConverter::NewL()) + * 2) Call TitleL function to get title pointer(title = converter->TitleL(aFileData)) + * 3) Use title pointer however necessary + * + * @param aFileData A pointer to the raw file data. + * @return The title as a HBufC. The ownership is + * transferred and it is left in cleanup stack. + * + **/ + HBufC* TitleLC(TPtr8& aFileData); + + /** + * Check if a NSM stream is a valid ringtone. + * + * Usage: + * 1) Create converter(converter = CRingBCNSMConverter::NewL()) + * 2) Call function(booleanValue = converter->IsRingToneMimeTypeL(aFileData)) + * + * @param aFileData A pointer to the raw file data. + * @return ETrue if the tune is a ring tone, EFalse otherwise. + * + **/ + TBool IsRingToneMimeTypeL(TPtr8& aFileData); + + private: + + struct TNsmRTPatterns + { + TInt iStart; + TInt iEnd; + }; + + /** + * Description: This function processes Nokia Smart Messaging Ringing Tone + * to generate Composer data. + * + * Smart Messaging: ::= + * | + * | + * | + * + * + * If necessary, filler bits are aded to ensure that + * is always octet-aligned. + * + * The Ringing Tone programming requires that the order of + * the command parts is the following: , [,] . + */ + void ProcessNsmRingToneCommandPartL(); + + /** + * Description: This function processes Nokia Smart Messaging Ringing Tone + * to generate Composer data. + * + * Smart Messaging: ::= + * | + * | + * | + * + */ + void ProcessNsmRingToneSoundSpecL(); + + /** + * Description: This function processes Nokia Smart Messaging Ringing Tone + * + * + * Smart Messaging: ::= + * ::=+ | 'Uincode disabled' + * + 'Uincode enabled' + * ::='binary[0000..1111]; Indicating how many + * characters are used for the following text.' + */ + void ProcessNsmRingToneSongTitleL(); + + /** + * Description: This function processes Nokia Smart Messaging Ringing Tone + * to generate Composer data. + * + * Smart Messaging: ::= + * ::='binary[00000000..11111111]; + * Indicates how many song patterns follow + * ::=+ + * ::= + * | + * + + * ::= + * + * ::='binary[0000..1111]; Indicates how many + * times the pattern should be repeated. Value zero + * means no repeat. Value binary 1111 means infinite. + * ::= + * | + * ::='binary[00000001..11111111]; + * Indicates how many pattern instructions there are + * in the song pattern. + */ + void ProcessNsmRingToneSongL(); + + /** + * Description: This function processes Nokia Smart Messaging Ringing Tone + * to generate Composer data. + * + * Smart Messaging: ::= + * | | + * | | + * + * ::= + * ::= + * ::= + * ::= + */ + void ProcessNsmRingTonePatternInstructionL(); + + /** + * Description: This function forms a composer symbol from the pattern + * instructions and places it into the CompData structure. + * + * Smart Messaging: ::= + * + */ + void ProcessNsmRingToneNoteInstructionL(TInt aScale, TInt aStyle); + + /** + * This function extracts the specified number of bits from + * the bit stream(returned int will contain both the instruction + * bits and the data bits). + * + * @param aNumBits The number of bits to get. + * @return The value. + */ + TInt GetBits(TInt aNumBits); + + /** + */ + void ResetForCompData(); + + private: // Data + + /// The data being converted from an NSM stream. + TPtrC8 iReceivedNsmRTData; + + /// The flags associated with an NSM stream. + TInt iNsmRTFlags; + + /// The current position in the stream. + TInt iNsmPosition; + + /// The current bit number in the NSM stream. + TInt iNsmPositionBit; + + /// Patterns of NSM data. + TFixedArray iNsmRTPatterns; + + /// The default scale of a tone. + TInt iScale; + + /// The default style of a tone. + TInt iStyle; + + /// The song data created. Owns. + TCompData iCompData; + + /// The song data received for conversion. Refs. + TCompData* iReceivedCompData; + + /// The position in the song data. + TInt iCompDataPosition; + + /// If ETrue, the song data cannot be loaded to Composer. + TBool iReadOnly; +}; +#endif //__RINGBCTONECONVERT_H