examples/ForumNokia/SMSExample/Engine/inc/SMSEngine.h

00001 /*
00002  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 #ifndef CSMSENGINE_H
00031 #define CSMSENGINE_H
00032 
00033 //  EXTERNAL INCLUDES
00034 #include <e32base.h>
00035 
00036 //  INTERNAL INCLUDES
00037 #include "SMSExampleMtmsEngine.h"
00038 
00039 //  CONSTANTS
00040 const TInt KSmsMessageLength = 512;
00041 const TInt KAddressLength = 64;
00042 
00043 
00044 class MSmsEngineObserver
00045 {
00046     public:
00047         virtual void SendingMessage()=0;
00048         virtual void MessageSent()=0;
00049         virtual void MessageReceived(const TDesC& addr, const TDesC& msg)=0;
00050         virtual void SmsEngineInitialized()=0;
00051         virtual void SmsEngineError(TInt aErrorCode)=0;
00052         virtual void MessageDeleted()=0; //if automatic deletion is on
00053 };
00054 
00055 //  CLASS DEFINITION
00065 class CSmsEngine : public CBase, public MMsvSessionObserver, public MSMSExampleMtmsEngineObserver
00066     {
00067     public:     // Constructors and destructor
00068 
00073         IMPORT_C static CSmsEngine* NewL(MSmsEngineObserver& aObserver);
00074 
00079         IMPORT_C static CSmsEngine* NewLC(MSmsEngineObserver& aObserver);
00080 
00084         IMPORT_C ~CSmsEngine();
00085 
00086      public:     //new functions
00092         IMPORT_C void SendSmsL(const TDesC& aAddr, const TDesC&aMsg); //nyt CreateSmsMessage, validateCreatedSms ja SendSms, laita kaikki piiloon
00093 
00099         IMPORT_C void ListenforIncomingSms(TBool aListening);
00100 
00106         IMPORT_C void SetAutomaticDeletetion(TBool aDeletion);
00107 
00108 
00116         IMPORT_C void GetFolderSMSMessageInformationL(TMsvId aFolderID,
00117                                                 CDesCArrayFlat*& aAddresses,
00118                                                 CDesCArrayFlat*& aMessages);
00119 
00128         IMPORT_C RArray<TMsvId>* GetMessageIds();
00129 
00135         IMPORT_C void CopyMessageL( TMsvId aMessageId, TMsvId aFolder );
00136 
00142         IMPORT_C void MoveToFolderL( TMsvId aMessageId,  TMsvId aFolder );
00143 
00148         IMPORT_C void DeleteMessageL( TMsvId aMessageId );
00149 
00150     public:  //from base classes
00151 
00155         void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
00156 
00160         void HandleMessageSentL(TInt aError);
00161 
00162     private:    // Constructors
00163 
00168         CSmsEngine(MSmsEngineObserver& aObserver);
00169 
00173         void ConstructL();
00174 
00175     private:
00176 
00183         void SendSmsInThirdEditionL(const TDesC& aAddr, const TDesC& aMsg);
00184 
00185     private:    // Data
00186 
00187         //The observer
00188         MSmsEngineObserver& iObserver;
00189 
00190         // SMS engine
00191         CSMSExampleMtmsEngine* iEngine;
00192 
00193         // Parser that searches phone numbers
00194         //CSMSExampleParser* iParser;
00195 
00196         // Recipient address
00197         TBuf<KAddressLength> iAddress;
00198 
00199         // Message body
00200         TBuf<KSmsMessageLength> iMessage;
00201 
00202         // ETrue is automatic delete is on, EFalse otherwise
00203         TBool iAutomaticDelete;
00204 
00205         // are we listening for incoming messages
00206         TBool iListeningForIncoming;
00207 
00208         // Session with the messaging server
00209         CMsvSession* iMsvSession;
00210 
00211         // CMsvEntry accesses and acts upon a particular Message Server entry
00212         CMsvEntry* iMsvEntry;
00213 
00214         // Id of a new message
00215         TMsvId iNewMessageId;
00216 
00217         // Id of the sent message
00218         TMsvId iSentMessageId;
00219 
00220     };
00221 
00222 //  INLINE FUNCTIONS
00223 
00224 #endif      //  CSMSENGINE_H
00225 
00226 // End of file

Generated by  doxygen 1.6.2