voipplugins/sipconnectionprovider/ipvoicemailengine/inc/ipvmbxengine.h
changeset 0 a4daefaec16c
child 15 43658d24f35d
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Creates SMS message if Event in MailBox has occurred
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef IPVMBXENGINE_H
       
    21 #define IPVMBXENGINE_H
       
    22 
       
    23 #include <msvapi.h>
       
    24 #include <mcetransactiondatacontainer.h>
       
    25 #include <stringresourcereader.h>
       
    26 
       
    27 #include "ipvmbxinterface.h"
       
    28 #include "ipvmbxbase.h"
       
    29 #include "ipvmbxparsetype.h"
       
    30 
       
    31 
       
    32 class CSIPProfile;
       
    33 class CSPSettings;
       
    34 class CIpVmbxBase;
       
    35 class TIpVmbxEventMonitor;
       
    36 
       
    37 
       
    38 /**
       
    39  *  Creates SMS message if Event in MailBox has occurred.
       
    40  *
       
    41  *  @lib IpVmbxAppEngine.lib
       
    42  */
       
    43 NONSHARABLE_CLASS( CIpVmbxEngine ) :
       
    44     public CBase,
       
    45     public MMsvSessionObserver
       
    46     {
       
    47 
       
    48 public:  // Constructors and destructor
       
    49 
       
    50     /** Internal state messages */
       
    51     enum TIpVmbxMessages
       
    52         {
       
    53         EEngineUndefined,
       
    54         EEngineSubscribed,
       
    55         EEngineTerminated,
       
    56         EEngineSubscribeRejected,
       
    57         EEngineIncorrectAccount,
       
    58         EEngineSmsError,
       
    59         EEngineSmsOom,
       
    60         EEngineNetworkLost,
       
    61         EEngineNetworkError
       
    62         };
       
    63 
       
    64     /**
       
    65      * Two-phased constructor.
       
    66      *
       
    67      * @param aInterface Instance to interface for status message sending
       
    68      */
       
    69     IMPORT_C static CIpVmbxEngine* NewL( CIpVmbxInterface& aInterface );
       
    70 
       
    71     /**
       
    72      * Destructor.
       
    73      */
       
    74     virtual ~CIpVmbxEngine();
       
    75 
       
    76 
       
    77 public: // New functions
       
    78 
       
    79     /**
       
    80      * Starts subscription to MailBox when SIP profile has registered. Only
       
    81      * one of these parameters can be used at same time.
       
    82      *
       
    83      * @param aServiceProviderId Service provider id of mail settings
       
    84      * @param aSipProfileId Connected SIP profile id
       
    85      */
       
    86     void SubscribeProfileL(
       
    87         TUint32 aServiceProviderId,
       
    88         CSIPProfile& aSipProfile );
       
    89 
       
    90     /**
       
    91      * Registration status of profile.
       
    92      *
       
    93      * @param aServiceProviderId Provider id which status is queried
       
    94      * @param aProfileSubscribe Status of subscription
       
    95      * @return KErrNotFound if profile does not exist
       
    96      */
       
    97     TInt ProfileSubscribed(
       
    98         TUint32 aServiceProviderId,
       
    99         TBool& aProfileSubscribed );
       
   100 
       
   101     /**
       
   102      * Resolve address of base class using recipient address
       
   103      *
       
   104      * @param aId Recipient
       
   105      * @return Address of base class
       
   106      */
       
   107     CIpVmbxBase* SubscriptionByRecipient( const TDesC8& aRecipient8 );
       
   108 
       
   109     /**
       
   110      * EventMonitor has received event and the event
       
   111      * will be gained and checked if it requires any action
       
   112      *
       
   113      * @param aRecipient Recipient of event
       
   114      */
       
   115 #ifdef EUNIT_TEST_IMPLEMENTATION
       
   116     virtual void EventReceivedL( const TDesC8& aRecipient8 );
       
   117 #else
       
   118     void EventReceivedL( const TDesC8& aRecipient8 );
       
   119 #endif
       
   120 
       
   121     /**
       
   122      * Disconnects IPVME from voice mail -server
       
   123      *
       
   124      * @param aServiceProviderId Provider id to be unregistered
       
   125      */
       
   126     void UnsubscribeProfileL( TUint32 aServiceProviderId );
       
   127 
       
   128     /**
       
   129      * Cleanup base class and free resources
       
   130      *
       
   131      * @pre Unsubscribe has been sent to voice mail -server
       
   132      */
       
   133     void CleanVmbxBase();
       
   134 
       
   135     /**
       
   136      * Send status messages to observers
       
   137      *
       
   138      * @param aServiceProviderId Service provider id
       
   139      * @param aMessage MIpVmbxObserver status messages
       
   140      */
       
   141 #ifdef EUNIT_TEST_IMPLEMENTATION
       
   142 
       
   143     virtual void HandleMessage(
       
   144         TUint32 aServiceProviderId,
       
   145         CIpVmbxEngine::TIpVmbxMessages aMessage );
       
   146 
       
   147 #else
       
   148 
       
   149     void HandleMessage(
       
   150         TUint32 aServiceProviderId,
       
   151         CIpVmbxEngine::TIpVmbxMessages aMessage );
       
   152 
       
   153 #endif
       
   154 
       
   155     /**
       
   156      * Fetch instance to base class using service id
       
   157      *
       
   158      * @param aServiceProviderId Service id to indentify base class
       
   159      * @return Instance to base
       
   160      */
       
   161     CIpVmbxBase* SubscriptionByProvider( TUint32 aServiceProviderId );
       
   162 
       
   163 
       
   164 protected:
       
   165 
       
   166 // from base class MMsvSessionObserver
       
   167 
       
   168     /**
       
   169      * From base class MMsvSessionObserver
       
   170      * For notification of events from a Message Server session
       
   171      *
       
   172      * @since Series 60 3.0
       
   173      * @param aEvent Indicates the event type,
       
   174      * @param*aArg1 Event type-specific argument value
       
   175      * @param*aArg2 Event type-specific argument value
       
   176      * @param*aArg3 Event type-specific argument value
       
   177      */
       
   178     virtual void HandleSessionEventL( TMsvSessionEvent aEvent, TAny *aArg1,
       
   179         TAny *aArg2, TAny *aArg3 );
       
   180 
       
   181 
       
   182 private:
       
   183 
       
   184     void ConstructL();
       
   185 
       
   186     /**
       
   187      * C++ default constructor.
       
   188      *
       
   189      * @param aInterface Instance to interface for status message sending
       
   190      */
       
   191     CIpVmbxEngine( CIpVmbxInterface& aInterface );
       
   192 
       
   193     /**
       
   194      * For parsing the content of NOTIFY and some optional messages.
       
   195      * If function completes without errors, supplied content is cut so that
       
   196      * only possible optional header data is left.
       
   197      *
       
   198      * @param aCreateSms ETrue if user has to be informed (SMS).
       
   199      * @param aContent Notify content to be parsed
       
   200      * @param aTotalMessages Total messages
       
   201      * @param aNewMessages New messages
       
   202      * @param aFrom Voice mail account
       
   203      */
       
   204     void ParseNotifyContentL(
       
   205         TBool& aCreateSms,
       
   206         TDes8& aContent8,
       
   207         TDes8& aTotalMessages8,
       
   208         TDes8& aNewMessages8,
       
   209         TDes8& aFrom8 ) const;
       
   210 
       
   211     /**
       
   212      * Creates SMS message and sends it
       
   213      *
       
   214      * @param aFrom MBX uri
       
   215      * @param aMessageBody Generated message
       
   216      */
       
   217     void CreateSMSMessageL( const TDesC8& aFrom8, const TDesC8& aMessageBody8 );
       
   218 
       
   219     /**
       
   220      * For parsing optional headers from content of NOTIFY.
       
   221      *
       
   222      * @param aContent Notify content
       
   223      * @param aMessageBody Message body for optional parameters
       
   224      */
       
   225     void ParseOptionalHeadersL(
       
   226         const TDesC8& aContent8,
       
   227         TDes8& aMessageBody8 ) const;
       
   228 
       
   229     /**
       
   230      * Read localized content to message body
       
   231      *
       
   232      * @param aTotalMessages Total messages
       
   233      * @param aNewMessages New messages
       
   234      * @param aMessagesBody Message body
       
   235      */
       
   236     void ReadResourcesL(
       
   237             const TDesC8& aTotalMessages8,
       
   238             const TDesC8& aNewMessages8,
       
   239             TDes8& aMessagesBody8 );
       
   240 
       
   241     /**
       
   242      * Creates and verifies message body
       
   243      *
       
   244      * @param aContent Notify content
       
   245      * @param aTotal Total messages
       
   246      * @param aNew New messages
       
   247      * @param aFrom MBX uri
       
   248      * @param aMessageBody Message body
       
   249      */
       
   250     void CreateMessageBodyL(
       
   251         const TDesC8& aContent8,
       
   252         const TDesC8& aTotal8,
       
   253         const TDesC8& aNew8,
       
   254         TDes8& aFrom8,
       
   255         TDes8& aMessageBody8 );
       
   256 
       
   257     /**
       
   258      * General optional parameter parser
       
   259      *
       
   260      * @param aTagPtr8 Source text
       
   261      * @param aResourceReader Instance to resource reader( to prevent
       
   262      *        double instantiation )
       
   263      * @return Translation, NULL if not found.
       
   264      */
       
   265     HBufC* TranslateTagL(
       
   266         const TDesC8& aTagPtr8,
       
   267         CStringResourceReader& aResourceReader ) const;
       
   268 
       
   269     /**
       
   270      * Fetch message part from whole message. It gets first part from
       
   271      * provided string and checks validity of message part.
       
   272      *
       
   273      * @param aContent8 Source text
       
   274      * @return Message part, empty if content was not valid.
       
   275      */
       
   276     TPtrC8 FetchMessagePartL( const TDesC8& aContent8 ) const;
       
   277 
       
   278     /**
       
   279      * Check name header from message part.
       
   280      *
       
   281      * @param aNameHeader8 Source text
       
   282      */
       
   283     void TestNamePartL( const TDesC8& aNameHeader8 ) const;
       
   284 
       
   285     /**
       
   286      * Check value header from message part.
       
   287      *
       
   288      * @param aValueHeader8 Source text
       
   289      */
       
   290     void TestValuePartL( const TDesC8& aValueHeader8 ) const;
       
   291 
       
   292 
       
   293 private: // data
       
   294 
       
   295     /**
       
   296      * MCE server connection
       
   297      * Own.
       
   298      */
       
   299     CMceManager* iMceManager;
       
   300 
       
   301     /**
       
   302      * Event content
       
   303      */
       
   304     TMceTransactionDataContainer iEventData;
       
   305 
       
   306     /**
       
   307      * MCE Event observer
       
   308      * Own.
       
   309      */
       
   310     TIpVmbxEventMonitor* iIpVmbxEventMonitor;
       
   311 
       
   312     /**
       
   313      * Interface
       
   314      */
       
   315     CIpVmbxInterface& iInterface;
       
   316 
       
   317     /**
       
   318      * Vmbx parameters
       
   319      * Own.
       
   320      */
       
   321     CSPSettings* iServiceSettings;
       
   322 
       
   323     /**
       
   324      *  Array of current Base classes
       
   325      */
       
   326     RPointerArray< CIpVmbxBase > iVmbxBaseArray;
       
   327 
       
   328     /**
       
   329      *  Indicates if VME is already running
       
   330      */
       
   331     TBool iBasicServicesRunning;
       
   332 
       
   333 
       
   334     EUNIT_IMPLEMENTATION
       
   335     };
       
   336 
       
   337 #endif      // IPVMBXENGINE_H