creator/inc/creator_message.h
changeset 0 d6fe6244b863
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     1 /*
       
     2 * Copyright (c) 2008 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CREATORMESSAGES_H__
       
    22 #define __CREATORMESSAGES_H__
       
    23 
       
    24 #include "creator_model.h"
       
    25 #include "creator_modulebase.h"
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <e32std.h>
       
    29 #include <msvapi.h>
       
    30 #include <mtclbase.h>
       
    31 #include <mtclreg.h>
       
    32 #include <smut.h>
       
    33 #include <smuthdr.h>
       
    34 #include <smsclnt.h>
       
    35 #include <miutset.h>
       
    36 #include <mmsclient.h>
       
    37 #include <ircmtm.h>
       
    38 #include <irmsgtypeuid.h>
       
    39 #include <btmsgtypeuid.h>
       
    40 #include <bif.h>
       
    41 #include <biouids.h>
       
    42 #include <miuthdr.h>
       
    43 
       
    44 #include <cmsvmimeheaders.h>
       
    45 #include <smtcmtm.h>
       
    46 #include <ircmtm.h>
       
    47 #include <btcmtm.h>
       
    48 #include <mmsvattachmentmanager.h>
       
    49 
       
    50 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
    51 #include <MVPbkSingleContactOperationObserver.h>
       
    52 #include <MVPbkContactStoreListObserver.h>
       
    53 #include <MVPbkContactFindObserver.h>
       
    54 class CVPbkContactManager;
       
    55 #endif
       
    56 
       
    57 class CCreatorEngine;
       
    58 class CMessagesParameters;
       
    59 class CAsyncWaiter; 
       
    60 
       
    61 enum TMessageType
       
    62     {
       
    63     ESMS = 0,
       
    64     EMMS,
       
    65     EAMS,
       
    66     EEmail,
       
    67     ESmartMessage,
       
    68     EIrMessage,
       
    69     EBTMessage
       
    70     };
       
    71 
       
    72 enum TFolderType
       
    73     {
       
    74     EInbox = 0,
       
    75     EDrafts,
       
    76     EOutbox,
       
    77     ESent,
       
    78     EMailbox
       
    79     };
       
    80     
       
    81 class CRecipientInfo : public CBase
       
    82 {
       
    83 public:
       
    84     CRecipientInfo();
       
    85     virtual ~CRecipientInfo();
       
    86     
       
    87     void SetPhoneNumber(HBufC* aPhone);
       
    88     void SetEmailAddress(HBufC* aEmail);
       
    89     const HBufC* PhoneNumber() const;
       
    90     const HBufC* EmailAddress() const;
       
    91     
       
    92 private:
       
    93     HBufC* iPhoneNumber;
       
    94     HBufC* iEmailAddress;
       
    95 };
       
    96 
       
    97 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
    98 class CCreatorMessages : public CBase, public MCreatorModuleBase, public MMsvSessionObserver, 
       
    99     public MVPbkSingleContactOperationObserver, public MVPbkContactStoreListObserver, public MVPbkContactFindObserver
       
   100 #else
       
   101 class CCreatorMessages : public CBase, public MCreatorModuleBase, public MMsvSessionObserver
       
   102 #endif
       
   103     {
       
   104 public: 
       
   105     static CCreatorMessages* NewL(CCreatorEngine* aEngine);
       
   106     static CCreatorMessages* NewLC(CCreatorEngine* aEngine);
       
   107     ~CCreatorMessages();
       
   108 
       
   109 private:
       
   110     CCreatorMessages();
       
   111     void ConstructL(CCreatorEngine* aEngine); // from MCreatorModuleBase
       
   112 
       
   113     TInt CreateSMSEntryL(const CMessagesParameters& parameters);
       
   114     TInt CreateMMSEntryL(const CMessagesParameters& parameters);
       
   115     TInt CreateAMSEntryL(const CMessagesParameters& parameters);
       
   116     TInt CreateEmailEntryL(const CMessagesParameters& parameters);
       
   117     TInt CreateSmartMessageEntryL(const CMessagesParameters& parameters);
       
   118     TInt CreateObexEntryL(TUid aMtm, const CMessagesParameters& parameters);
       
   119     void HandleAttachementsL(const CMessagesParameters& parameters, CMsvStore* store, TInt err );
       
   120     void HandleAttachementL(CMsvStore* store, TInt err, TFileName& sourceFileName );
       
   121 
       
   122     CMsvEntrySelection* DoGetListOfAccountsL(CMsvSession& aSession, TUid aMtm, TBool aAlwaysListHidden);
       
   123     TMsvId DefaultServiceForMTML(CMsvSession& aSession, TUid aMtm, TBool aFindFirstServiceIfNoDefault);
       
   124 
       
   125     void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); // from MMsvSessionObserver
       
   126     
       
   127     void AddRecipientsL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
       
   128     void GetLinkedAddressesL(   RPointerArray<HBufC>& aAddressArray, 
       
   129                                 const RArray<TLinkIdParam>& aLinkIds, 
       
   130                                 TBool aUseEmailAddress,
       
   131                                 TInt aNumOfExistingAddresses );
       
   132     
       
   133     void GetAllRecipientsL(RPointerArray<HBufC>& aRecipientArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
       
   134     void SetSenderToEntryDetails(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress);
       
   135     void SetRecipientToEntryDetails(TMsvEntry& aMsgEntry, const CMessagesParameters& aParameters, TBool aUseEmailAddress);
       
   136     void AddSenderToMtmAddresseeL(CBaseMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
       
   137     void AddMtmSenderL(CMmsClientMtm& aMtm, const CMessagesParameters& aParameters, TBool aUseEmailAddress );
       
   138     void GetSendersL(RPointerArray<HBufC>& aSenderArray, const CMessagesParameters& aParameters, TBool aUseEmailAddress, TInt aMaxNum );
       
   139     void DeleteAllMessagesL( TBool aOnlyCreatedWithCreator );
       
   140     void DeleteAllFromFolderL( const TMsvId aContext, CMsvSession* aSession, CSmsClientMtm* aClientMtm, TBool aOnlyCreatedWithCreator = EFalse );
       
   141     
       
   142 public:
       
   143     TBool AskDataFromUserL(TInt aCommand, TInt& aNumberOfEntries); // from MCreatorModuleBase
       
   144 
       
   145     TInt CreateMessageEntryL(CMessagesParameters *aParameters, TBool aTakeUserGivenParameters=EFalse);    
       
   146     TInt CreateRandomMessageEntryL(TInt aCommand);
       
   147     void DeleteAllL();
       
   148     void DeleteAllCreatedByCreatorL();
       
   149     
       
   150 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
   151     // From MVPbkSingleContactOperationObserver:
       
   152     virtual void VPbkSingleContactOperationComplete(
       
   153             MVPbkContactOperationBase& aOperation,
       
   154             MVPbkStoreContact* aContact );
       
   155             
       
   156     virtual void VPbkSingleContactOperationFailed(
       
   157             MVPbkContactOperationBase& aOperation, 
       
   158             TInt aError );
       
   159     
       
   160     void HandleSingleContactResultL();
       
   161             
       
   162     // From MVPbkContactStoreListObserver
       
   163     virtual void OpenComplete();
       
   164     virtual void StoreReady(MVPbkContactStore&);
       
   165     virtual void StoreUnavailable(MVPbkContactStore&, TInt);
       
   166     virtual void HandleStoreEventL(MVPbkContactStore&, TVPbkContactStoreEvent);
       
   167     
       
   168     // From MVPbkContactFindObserver
       
   169     virtual void FindCompleteL( MVPbkContactLinkArray* aResults );
       
   170     virtual void FindFailed( TInt aError );
       
   171 #endif
       
   172 
       
   173 private:
       
   174     CMessagesParameters*    iParameters;
       
   175     TMessageType            iMessageType;
       
   176     TFolderType             iFolderType;
       
   177     TInt                    iDefinedMessageLength;
       
   178     CArrayFixFlat<TInt>*    iAttachments; 
       
   179     //RPointerArray<HBufC>    iAttachmentPaths;
       
   180     TBool                   iCreateAsUnread;
       
   181     TMsvId                  iUserSelectedMailbox;
       
   182     HBufC*                  iTmpPhoneNumber;
       
   183     HBufC*                  iTmpEmail;
       
   184     RArray<TInt>            iEntryIds; // TMsvId ( == TInt32 ) TMsvEntry::Id()
       
   185     CMsvSession*            iSession;
       
   186 #if(!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
   187     MVPbkContactLinkArray*  iExistingContacts;
       
   188     CVPbkContactManager* iContactManager;
       
   189     MVPbkContactStore* iStore;
       
   190     MVPbkStoreContact* iTempContact;
       
   191 #endif
       
   192     CAsyncWaiter* iWaiter;
       
   193     RPointerArray<HBufC>    iSenderArray;
       
   194     RPointerArray<HBufC>    iRecipientArray;
       
   195 public:
       
   196     };
       
   197 
       
   198 
       
   199 class CMessagesParameters : public CCreatorModuleBaseParameters
       
   200     {
       
   201 public: 
       
   202     TMessageType            iMessageType;
       
   203     TFolderType             iFolderType;
       
   204     HBufC*                  iSenderAddress;    
       
   205     HBufC*                  iRecipientAddress;
       
   206     RPointerArray<HBufC>    iRecipientAddressArray;
       
   207     HBufC*                  iMessageSubject;
       
   208     HBufC*                  iMessageBodyText;
       
   209     CArrayFixFlat<TInt>*    iAttachments; 
       
   210     RPointerArray<HBufC>    iAttachmentPaths;
       
   211     TInt                    iDefinedMessageLength;
       
   212     TUid                    iBIOMessageType;
       
   213     TBool                   iCreateAsUnread;
       
   214     RArray<TLinkIdParam>    iRecipientLinkIds;
       
   215     RArray<TLinkIdParam>    iSenderLinkIds;
       
   216     TInt                    iNumberOfExistingRecipients;
       
   217     TInt                    iNumberOfExistingSenders;
       
   218 
       
   219 public:
       
   220     CMessagesParameters();
       
   221     ~CMessagesParameters();
       
   222     };
       
   223 
       
   224 
       
   225 
       
   226 #endif // __CREATORMESSAGES_H__